Emily Fortuna 2017-01-31 13:53:12 -08:00
parent efcdcb7709
commit 6baace1a2f
2 changed files with 36 additions and 12 deletions

View file

@ -136,8 +136,16 @@ abstract class KernelElementAdapterMixin implements KernelElementAdapter {
@override
Selector getSelector(ir.Expression node) {
if (node is ir.PropertyGet) return getGetterSelector(node);
if (node is ir.PropertySet) return getSetterSelector(node);
// TODO(efortuna): This is screaming for a common interface between
// PropertyGet and SuperPropertyGet (and same for *Get). Talk to kernel
// folks.
if (node is ir.PropertyGet) {
return getGetterSelector((node as ir.PropertyGet).name);
}
if (node is ir.SuperPropertyGet) {
return getGetterSelector((node as ir.SuperPropertyGet).name);
}
if (node is ir.PropertySet) return getSetterSelector(node.name);
if (node is ir.InvocationExpression) return getInvocationSelector(node);
throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE,
"Can only get the selector for a property get or an invocation: "
@ -161,15 +169,13 @@ abstract class KernelElementAdapterMixin implements KernelElementAdapter {
return new Selector(kind, name, callStructure);
}
Selector getGetterSelector(ir.PropertyGet getter) {
ir.Name irName = getter.name;
Selector getGetterSelector(ir.Name irName) {
Name name = new Name(
irName.name, irName.isPrivate ? getLibrary(irName.library) : null);
return new Selector.getter(name);
}
Selector getSetterSelector(ir.PropertySet setter) {
ir.Name irName = setter.name;
Selector getSetterSelector(ir.Name irName) {
Name name = new Name(
irName.name, irName.isPrivate ? getLibrary(irName.library) : null);
return new Selector.setter(name);

View file

@ -2627,11 +2627,12 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
return null;
}
@override
void visitSuperMethodInvocation(ir.SuperMethodInvocation invocation) {
HInstruction _buildInvokeSuper(
ir.Expression invocation, List<HInstruction> arguments) {
// Invocation is either a method invocation or a property get/set.
// TODO(efortuna): Common interface?
// TODO(efortuna): Add source information.
Selector selector = astAdapter.getSelector(invocation);
List<HInstruction> arguments = _visitArgumentsForStaticTarget(
invocation.interfaceTarget.function, invocation.arguments);
HInstruction receiver = localsHandler.readThis();
ir.Class surroundingClass = _containingClass(invocation);
@ -2642,17 +2643,34 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
inputs.add(receiver);
inputs.addAll(arguments);
ir.Member interfaceTarget = invocation is ir.SuperMethodInvocation ?
(invocation as ir.SuperMethodInvocation).interfaceTarget :
(invocation as ir.SuperPropertyGet).interfaceTarget;
HInstruction instruction = new HInvokeSuper(
astAdapter.getMethod(invocation.interfaceTarget),
astAdapter.getMember(interfaceTarget),
astAdapter.getClass(surroundingClass),
selector,
inputs,
astAdapter.returnTypeOf(invocation.interfaceTarget),
astAdapter.returnTypeOf(interfaceTarget),
null,
isSetter: selector.isSetter || selector.isIndexSet);
instruction.sideEffects =
closedWorld.getSideEffectsOfSelector(selector, null);
push(instruction);
return instruction;
}
@override
void visitSuperPropertyGet(ir.SuperPropertyGet propertyGet) {
_buildInvokeSuper(propertyGet, const <HInstruction>[]);
}
@override
void visitSuperMethodInvocation(ir.SuperMethodInvocation invocation) {
List<HInstruction> arguments = _visitArgumentsForStaticTarget(
invocation.interfaceTarget.function, invocation.arguments);
_buildInvokeSuper(invocation, arguments);
}
@override