Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 11688010: NoSuchMethod on different super accesses/invocations handled. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 3115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3126 handleForeignJsCallInIsolate(node); 3126 handleForeignJsCallInIsolate(node);
3127 } else if (name == const SourceString('DART_CLOSURE_TO_JS')) { 3127 } else if (name == const SourceString('DART_CLOSURE_TO_JS')) {
3128 handleForeignDartClosureToJs(node); 3128 handleForeignDartClosureToJs(node);
3129 } else { 3129 } else {
3130 throw "Unknown foreign: ${selector}"; 3130 throw "Unknown foreign: ${selector}";
3131 } 3131 }
3132 } 3132 }
3133 3133
3134 generateSuperNoSuchMethodSend(Send node) { 3134 generateSuperNoSuchMethodSend(Send node) {
3135 Selector selector = elements.getSelector(node); 3135 Selector selector = elements.getSelector(node);
3136 SourceString name = selector.name; 3136 String name = selector.invocationMirrorMemberName;
3137
3138 ClassElement cls = work.element.getEnclosingClass(); 3137 ClassElement cls = work.element.getEnclosingClass();
3138 if (cls is ClosureClassElement) {
3139 ClosureClassElement closureClass = cls;
3140 cls = closureClass.methodElement.getEnclosingClass();
3141 }
3139 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); 3142 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD);
3140 if (element.enclosingElement.declaration != compiler.objectClass) { 3143 if (element.enclosingElement.declaration != compiler.objectClass) {
3141 // Register the call as dynamic if [:noSuchMethod:] on the super class 3144 // Register the call as dynamic if [:noSuchMethod:] on the super class
3142 // is _not_ the default implementation from [:Object:]. 3145 // is _not_ the default implementation from [:Object:].
3143 compiler.enqueuer.codegen.registerDynamicInvocation(name, selector); 3146 compiler.enqueuer.codegen.registerDynamicInvocation(selector.name,
3147 selector);
3144 } 3148 }
3145 HStatic target = new HStatic(element); 3149 HStatic target = new HStatic(element);
3146 add(target); 3150 add(target);
3147 HInstruction self = localsHandler.readThis(); 3151 HInstruction self = localsHandler.readThis();
3148 Constant nameConstant = constantSystem.createString( 3152 Constant nameConstant = constantSystem.createString(
3149 new DartString.literal(name.slowToString()), node); 3153 new DartString.literal(name), node);
3150 3154
3151 String internalName = backend.namer.instanceMethodInvocationName( 3155 String internalName = backend.namer.invocationMirrorInternalName(selector);
3152 currentLibrary, name, selector);
3153 Constant internalNameConstant = 3156 Constant internalNameConstant =
3154 constantSystem.createString(new DartString.literal(internalName), node); 3157 constantSystem.createString(new DartString.literal(internalName), node);
3155 3158
3156 Element createInvocationMirror = 3159 Element createInvocationMirror =
3157 compiler.findHelper(Compiler.CREATE_INVOCATION_MIRROR); 3160 compiler.findHelper(Compiler.CREATE_INVOCATION_MIRROR);
3158 3161
3159 var arguments = new List<HInstruction>(); 3162 var arguments = new List<HInstruction>();
3160 if (node.argumentsNode != null) { 3163 if (node.argumentsNode != null) {
3161 addGenericSendArgumentsToList(node.arguments, arguments); 3164 addGenericSendArgumentsToList(node.arguments, arguments);
3162 } 3165 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3202 Selector selector = elements.getSelector(node); 3205 Selector selector = elements.getSelector(node);
3203 Element element = elements[node]; 3206 Element element = elements[node];
3204 if (element == null) return generateSuperNoSuchMethodSend(node); 3207 if (element == null) return generateSuperNoSuchMethodSend(node);
3205 // TODO(5346): Try to avoid the need for calling [declaration] before 3208 // TODO(5346): Try to avoid the need for calling [declaration] before
3206 // creating an [HStatic]. 3209 // creating an [HStatic].
3207 HInstruction target = new HStatic(element.declaration); 3210 HInstruction target = new HStatic(element.declaration);
3208 HInstruction context = localsHandler.readThis(); 3211 HInstruction context = localsHandler.readThis();
3209 add(target); 3212 add(target);
3210 var inputs = <HInstruction>[target, context]; 3213 var inputs = <HInstruction>[target, context];
3211 if (node.isPropertyAccess) { 3214 if (node.isPropertyAccess) {
3212 push(new HInvokeSuper(inputs)); 3215 push(new HInvokeSuper(inputs, isGetter: true));
3213 } else if (element.isFunction() || element.isGenerativeConstructor()) { 3216 } else if (element.isFunction() || element.isGenerativeConstructor()) {
3214 // TODO(5347): Try to avoid the need for calling [implementation] before 3217 // TODO(5347): Try to avoid the need for calling [implementation] before
3215 // calling [addStaticSendArgumentsToList]. 3218 // calling [addStaticSendArgumentsToList].
3216 FunctionElement function = element.implementation; 3219 FunctionElement function = element.implementation;
3217 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, 3220 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
3218 function, inputs); 3221 function, inputs);
3219 if (!succeeded) { 3222 if (!succeeded) {
3220 generateWrongArgumentCountError(node, element, node.arguments); 3223 generateSuperNoSuchMethodSend(node);
3221 } else { 3224 } else {
3222 push(new HInvokeSuper(inputs)); 3225 push(new HInvokeSuper(inputs));
3223 } 3226 }
3224 } else { 3227 } else {
3225 target = new HInvokeSuper(inputs); 3228 target = new HInvokeSuper(inputs);
3226 add(target); 3229 add(target);
3227 inputs = <HInstruction>[target]; 3230 inputs = <HInstruction>[target];
3228 addDynamicSendArgumentsToList(node, inputs); 3231 addDynamicSendArgumentsToList(node, inputs);
3229 push(new HInvokeClosure(selector, inputs)); 3232 push(new HInvokeClosure(selector, inputs));
3230 } 3233 }
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
3637 visitSendSet(SendSet node) { 3640 visitSendSet(SendSet node) {
3638 Element element = elements[node]; 3641 Element element = elements[node];
3639 if (!Elements.isUnresolved(element) && element.impliesType()) { 3642 if (!Elements.isUnresolved(element) && element.impliesType()) {
3640 Identifier selector = node.selector; 3643 Identifier selector = node.selector;
3641 generateThrowNoSuchMethod(node, selector.source.slowToString(), 3644 generateThrowNoSuchMethod(node, selector.source.slowToString(),
3642 argumentNodes: node.arguments); 3645 argumentNodes: node.arguments);
3643 return; 3646 return;
3644 } 3647 }
3645 Operator op = node.assignmentOperator; 3648 Operator op = node.assignmentOperator;
3646 if (node.isSuperCall) { 3649 if (node.isSuperCall) {
3647 if (element == null) return generateSuperNoSuchMethodSend(node); 3650 bool assignable = true;
ngeoffray 2012/12/28 10:24:03 Maybe a Elements.isAssignable helper method could
Johnni Winther 2012/12/28 22:32:31 Done.
3651 if (element == null) {
3652 assignable = false;
3653 } else if (element.isFunction()) {
3654 assignable = false;
3655 } else if (element.isField()) {
3656 if (element.modifiers.isFinalOrConst()) {
3657 assignable = false;
3658 }
3659 } else if (element.isAbstractField()) {
3660 AbstractFieldElement abstractFieldElement = element;
3661 if (abstractFieldElement.setter == null) {
3662 assignable = false;
3663 }
3664 }
3665 if (!assignable) {
3666 return generateSuperNoSuchMethodSend(node);
3667 }
3648 HInstruction target = new HStatic(element); 3668 HInstruction target = new HStatic(element);
3649 HInstruction context = localsHandler.readThis(); 3669 HInstruction context = localsHandler.readThis();
3650 add(target); 3670 add(target);
3651 var inputs = <HInstruction>[target, context]; 3671 var inputs = <HInstruction>[target, context];
3652 addDynamicSendArgumentsToList(node, inputs); 3672 addDynamicSendArgumentsToList(node, inputs);
3653 if (!identical(node.assignmentOperator.source.stringValue, '=')) { 3673 if (!identical(node.assignmentOperator.source.stringValue, '=')) {
3654 compiler.unimplemented('complex super assignment', 3674 compiler.unimplemented('complex super assignment',
3655 node: node.assignmentOperator); 3675 node: node.assignmentOperator);
3656 } 3676 }
3657 push(new HInvokeSuper(inputs, isSetter: true)); 3677 push(new HInvokeSuper(inputs, isSetter: true));
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
5074 new HSubGraphBlockInformation(elseBranch.graph)); 5094 new HSubGraphBlockInformation(elseBranch.graph));
5075 5095
5076 HBasicBlock conditionStartBlock = conditionBranch.block; 5096 HBasicBlock conditionStartBlock = conditionBranch.block;
5077 conditionStartBlock.setBlockFlow(info, joinBlock); 5097 conditionStartBlock.setBlockFlow(info, joinBlock);
5078 SubGraph conditionGraph = conditionBranch.graph; 5098 SubGraph conditionGraph = conditionBranch.graph;
5079 HIf branch = conditionGraph.end.last; 5099 HIf branch = conditionGraph.end.last;
5080 assert(branch is HIf); 5100 assert(branch is HIf);
5081 branch.blockInformation = conditionStartBlock.blockFlow; 5101 branch.blockInformation = conditionStartBlock.blockFlow;
5082 } 5102 }
5083 } 5103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698