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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 12374094: Implement complex super assignment. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element operator[](Node node); 8 Element operator[](Node node);
9 Selector getSelector(Send send); 9 Selector getSelector(Send send);
10 Selector getGetterSelectorInComplexSendSet(SendSet node); 10 Selector getGetterSelectorInComplexSendSet(SendSet node);
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 return null; 1998 return null;
1999 } 1999 }
2000 if (currentClass.supertype == null) { 2000 if (currentClass.supertype == null) {
2001 // This is just to guard against internal errors, so no need 2001 // This is just to guard against internal errors, so no need
2002 // for a real error message. 2002 // for a real error message.
2003 error(node.receiver, MessageKind.GENERIC, 2003 error(node.receiver, MessageKind.GENERIC,
2004 {'text': "Object has no superclass"}); 2004 {'text': "Object has no superclass"});
2005 } 2005 }
2006 // TODO(johnniwinther): Ensure correct behavior if currentClass is a 2006 // TODO(johnniwinther): Ensure correct behavior if currentClass is a
2007 // patch. 2007 // patch.
2008 target = currentClass.lookupSuperMember(name); 2008 target = currentClass.superclass.lookupSelector(
kasperl 2013/03/05 07:32:36 I think this would be easier to read if you did so
ngeoffray 2013/03/05 08:46:25 Done.
2009 selector, superLookup: true);
2009 // [target] may be null which means invoking noSuchMethod on 2010 // [target] may be null which means invoking noSuchMethod on
2010 // super. 2011 // super.
2011 if (target == null) { 2012 if (target == null) {
2012 target = warnAndCreateErroneousElement( 2013 target = warnAndCreateErroneousElement(
2013 node, name, MessageKind.NO_SUCH_SUPER_MEMBER, 2014 node, name, MessageKind.NO_SUCH_SUPER_MEMBER,
2014 {'className': currentClass, 'memberName': name}); 2015 {'className': currentClass, 'memberName': name});
2015 // We still need to register the invocation, because we might 2016 // We still need to register the invocation, because we might
2016 // call [:super.noSuchMethod:] that does a 2017 // call [:super.noSuchMethod:] that does a
2017 // [:InvocationMirror.invokeOn:]. 2018 // [:InvocationMirror.invokeOn:].
2018 world.registerDynamicInvocation(selector.name, selector); 2019 world.registerDynamicInvocation(selector.name, selector);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 getter = warnAndCreateErroneousElement( 2286 getter = warnAndCreateErroneousElement(
2286 node.selector, field.name, MessageKind.CANNOT_RESOLVE_GETTER); 2287 node.selector, field.name, MessageKind.CANNOT_RESOLVE_GETTER);
2287 compiler.backend.registerThrowNoSuchMethod(); 2288 compiler.backend.registerThrowNoSuchMethod();
2288 } 2289 }
2289 } else if (target.impliesType()) { 2290 } else if (target.impliesType()) {
2290 compiler.backend.registerThrowNoSuchMethod(); 2291 compiler.backend.registerThrowNoSuchMethod();
2291 } else if (target.modifiers.isFinal() || target.modifiers.isConst()) { 2292 } else if (target.modifiers.isFinal() || target.modifiers.isConst()) {
2292 setter = warnAndCreateErroneousElement( 2293 setter = warnAndCreateErroneousElement(
2293 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER); 2294 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER);
2294 compiler.backend.registerThrowNoSuchMethod(); 2295 compiler.backend.registerThrowNoSuchMethod();
2295 } else if (isComplex && target.name == const SourceString('[]=')) {
2296 getter = target.getEnclosingClass().lookupMember(
2297 const SourceString('[]'));
2298 if (getter == null) {
2299 getter = warnAndCreateErroneousElement(
2300 node, setter.name, MessageKind.CANNOT_RESOLVE_INDEX);
2301 compiler.backend.registerThrowNoSuchMethod();
2302 }
2303 } 2296 }
2304 } 2297 }
2305 2298
2306 visit(node.argumentsNode); 2299 visit(node.argumentsNode);
2307 2300
2308 // TODO(ngeoffray): Check if the target can be assigned. 2301 // TODO(ngeoffray): Check if the target can be assigned.
2309 // TODO(ngeoffray): Warn if target is null and the send is 2302 // TODO(ngeoffray): Warn if target is null and the send is
2310 // unqualified. 2303 // unqualified.
2311 2304
2312 Selector selector = mapping.getSelector(node); 2305 Selector selector = mapping.getSelector(node);
2313 if (isComplex) { 2306 if (isComplex) {
2314 Selector getterSelector; 2307 Selector getterSelector;
2315 if (selector.isSetter()) { 2308 if (selector.isSetter()) {
2316 getterSelector = new Selector.getterFrom(selector); 2309 getterSelector = new Selector.getterFrom(selector);
2317 } else { 2310 } else {
2318 assert(selector.isIndexSet()); 2311 assert(selector.isIndexSet());
2319 getterSelector = new Selector.index(); 2312 getterSelector = new Selector.index();
2320 } 2313 }
2321 registerSend(getterSelector, getter); 2314 registerSend(getterSelector, getter);
2322 mapping.setGetterSelectorInComplexSendSet(node, getterSelector); 2315 mapping.setGetterSelectorInComplexSendSet(node, getterSelector);
2316 if (node.isSuperCall) {
2317 getter = currentClass.superclass.lookupSelector(
2318 getterSelector, superLookup: true);
2319 if (getter == null) {
2320 target = warnAndCreateErroneousElement(
2321 node, selector.name, MessageKind.NO_SUCH_SUPER_MEMBER,
2322 {'className': currentClass, 'memberName': selector.name});
2323 compiler.backend.registerSuperNoSuchMethod();
2324 }
2325 }
2323 useElement(node.selector, getter); 2326 useElement(node.selector, getter);
2324 2327
2325 // Make sure we include the + and - operators if we are using 2328 // Make sure we include the + and - operators if we are using
2326 // the ++ and -- ones. Also, if op= form is used, include op itself. 2329 // the ++ and -- ones. Also, if op= form is used, include op itself.
2327 void registerBinaryOperator(SourceString name) { 2330 void registerBinaryOperator(SourceString name) {
2328 Selector binop = new Selector.binaryOperator(name); 2331 Selector binop = new Selector.binaryOperator(name);
2329 world.registerDynamicInvocation(binop.name, binop); 2332 world.registerDynamicInvocation(binop.name, binop);
2330 mapping.setOperatorSelectorInComplexSendSet(node, binop); 2333 mapping.setOperatorSelectorInComplexSendSet(node, binop);
2331 } 2334 }
2332 if (identical(source, '++')) { 2335 if (identical(source, '++')) {
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
3807 return e; 3810 return e;
3808 } 3811 }
3809 3812
3810 /// Assumed to be called by [resolveRedirectingFactory]. 3813 /// Assumed to be called by [resolveRedirectingFactory].
3811 Element visitReturn(Return node) { 3814 Element visitReturn(Return node) {
3812 Node expression = node.expression; 3815 Node expression = node.expression;
3813 return finishConstructorReference(visit(expression), 3816 return finishConstructorReference(visit(expression),
3814 expression, expression); 3817 expression, expression);
3815 } 3818 }
3816 } 3819 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698