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

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.lookupSuperSelector(selector);
2009 // [target] may be null which means invoking noSuchMethod on 2009 // [target] may be null which means invoking noSuchMethod on
2010 // super. 2010 // super.
2011 if (target == null) { 2011 if (target == null) {
2012 target = warnAndCreateErroneousElement( 2012 target = warnAndCreateErroneousElement(
2013 node, name, MessageKind.NO_SUCH_SUPER_MEMBER, 2013 node, name, MessageKind.NO_SUCH_SUPER_MEMBER,
2014 {'className': currentClass, 'memberName': name}); 2014 {'className': currentClass, 'memberName': name});
2015 // We still need to register the invocation, because we might 2015 // We still need to register the invocation, because we might
2016 // call [:super.noSuchMethod:] that does a 2016 // call [:super.noSuchMethod:] that does a
2017 // [:InvocationMirror.invokeOn:]. 2017 // [:InvocationMirror.invokeOn:].
2018 world.registerDynamicInvocation(selector.name, selector); 2018 world.registerDynamicInvocation(selector.name, selector);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 getter = warnAndCreateErroneousElement( 2285 getter = warnAndCreateErroneousElement(
2286 node.selector, field.name, MessageKind.CANNOT_RESOLVE_GETTER); 2286 node.selector, field.name, MessageKind.CANNOT_RESOLVE_GETTER);
2287 compiler.backend.registerThrowNoSuchMethod(); 2287 compiler.backend.registerThrowNoSuchMethod();
2288 } 2288 }
2289 } else if (target.impliesType()) { 2289 } else if (target.impliesType()) {
2290 compiler.backend.registerThrowNoSuchMethod(); 2290 compiler.backend.registerThrowNoSuchMethod();
2291 } else if (target.modifiers.isFinal() || target.modifiers.isConst()) { 2291 } else if (target.modifiers.isFinal() || target.modifiers.isConst()) {
2292 setter = warnAndCreateErroneousElement( 2292 setter = warnAndCreateErroneousElement(
2293 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER); 2293 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER);
2294 compiler.backend.registerThrowNoSuchMethod(); 2294 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 } 2295 }
2304 } 2296 }
2305 2297
2306 visit(node.argumentsNode); 2298 visit(node.argumentsNode);
2307 2299
2308 // TODO(ngeoffray): Check if the target can be assigned. 2300 // TODO(ngeoffray): Check if the target can be assigned.
2309 // TODO(ngeoffray): Warn if target is null and the send is 2301 // TODO(ngeoffray): Warn if target is null and the send is
2310 // unqualified. 2302 // unqualified.
2311 2303
2312 Selector selector = mapping.getSelector(node); 2304 Selector selector = mapping.getSelector(node);
2313 if (isComplex) { 2305 if (isComplex) {
2314 Selector getterSelector; 2306 Selector getterSelector;
2315 if (selector.isSetter()) { 2307 if (selector.isSetter()) {
2316 getterSelector = new Selector.getterFrom(selector); 2308 getterSelector = new Selector.getterFrom(selector);
2317 } else { 2309 } else {
2318 assert(selector.isIndexSet()); 2310 assert(selector.isIndexSet());
2319 getterSelector = new Selector.index(); 2311 getterSelector = new Selector.index();
2320 } 2312 }
2321 registerSend(getterSelector, getter); 2313 registerSend(getterSelector, getter);
2322 mapping.setGetterSelectorInComplexSendSet(node, getterSelector); 2314 mapping.setGetterSelectorInComplexSendSet(node, getterSelector);
2315 if (node.isSuperCall) {
2316 getter = currentClass.lookupSuperSelector(getterSelector);
2317 if (getter == null) {
2318 target = warnAndCreateErroneousElement(
2319 node, selector.name, MessageKind.NO_SUCH_SUPER_MEMBER,
2320 {'className': currentClass, 'memberName': selector.name});
2321 compiler.backend.registerSuperNoSuchMethod();
2322 }
2323 }
2323 useElement(node.selector, getter); 2324 useElement(node.selector, getter);
2324 2325
2325 // Make sure we include the + and - operators if we are using 2326 // Make sure we include the + and - operators if we are using
2326 // the ++ and -- ones. Also, if op= form is used, include op itself. 2327 // the ++ and -- ones. Also, if op= form is used, include op itself.
2327 void registerBinaryOperator(SourceString name) { 2328 void registerBinaryOperator(SourceString name) {
2328 Selector binop = new Selector.binaryOperator(name); 2329 Selector binop = new Selector.binaryOperator(name);
2329 world.registerDynamicInvocation(binop.name, binop); 2330 world.registerDynamicInvocation(binop.name, binop);
2330 mapping.setOperatorSelectorInComplexSendSet(node, binop); 2331 mapping.setOperatorSelectorInComplexSendSet(node, binop);
2331 } 2332 }
2332 if (identical(source, '++')) { 2333 if (identical(source, '++')) {
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
3807 return e; 3808 return e;
3808 } 3809 }
3809 3810
3810 /// Assumed to be called by [resolveRedirectingFactory]. 3811 /// Assumed to be called by [resolveRedirectingFactory].
3811 Element visitReturn(Return node) { 3812 Element visitReturn(Return node) {
3812 Node expression = node.expression; 3813 Node expression = node.expression;
3813 return finishConstructorReference(visit(expression), 3814 return finishConstructorReference(visit(expression),
3814 expression, expression); 3815 expression, expression);
3815 } 3816 }
3816 } 3817 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/enqueue.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698