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

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

Issue 17599008: Stop passing the selector name separately to methods in the enqueuer. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 get currentElement; 8 Element get currentElement;
9 Set<Node> get superUses; 9 Set<Node> get superUses;
10 10
(...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 target = currentClass.lookupSuperSelector(selector, compiler); 2076 target = currentClass.lookupSuperSelector(selector, compiler);
2077 // [target] may be null which means invoking noSuchMethod on 2077 // [target] may be null which means invoking noSuchMethod on
2078 // super. 2078 // super.
2079 if (target == null) { 2079 if (target == null) {
2080 target = warnAndCreateErroneousElement( 2080 target = warnAndCreateErroneousElement(
2081 node, name, MessageKind.NO_SUCH_SUPER_MEMBER, 2081 node, name, MessageKind.NO_SUCH_SUPER_MEMBER,
2082 {'className': currentClass, 'memberName': name}); 2082 {'className': currentClass, 'memberName': name});
2083 // We still need to register the invocation, because we might 2083 // We still need to register the invocation, because we might
2084 // call [:super.noSuchMethod:] which calls 2084 // call [:super.noSuchMethod:] which calls
2085 // [JSInvocationMirror._invokeOn]. 2085 // [JSInvocationMirror._invokeOn].
2086 world.registerDynamicInvocation(selector.name, selector); 2086 world.registerDynamicInvocation(selector);
2087 compiler.backend.registerSuperNoSuchMethod(mapping); 2087 compiler.backend.registerSuperNoSuchMethod(mapping);
2088 } 2088 }
2089 } else if (Elements.isUnresolved(resolvedReceiver)) { 2089 } else if (Elements.isUnresolved(resolvedReceiver)) {
2090 return null; 2090 return null;
2091 } else if (resolvedReceiver.isClass()) { 2091 } else if (resolvedReceiver.isClass()) {
2092 ClassElement receiverClass = resolvedReceiver; 2092 ClassElement receiverClass = resolvedReceiver;
2093 receiverClass.ensureResolved(compiler); 2093 receiverClass.ensureResolved(compiler);
2094 if (node.isOperator) { 2094 if (node.isOperator) {
2095 // When the resolved receiver is a class, we can have two cases: 2095 // When the resolved receiver is a class, we can have two cases:
2096 // 1) a static send: C.foo, or 2096 // 1) a static send: C.foo, or
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 2307
2308 if (node.isCall) { 2308 if (node.isCall) {
2309 if (Elements.isUnresolved(target) || 2309 if (Elements.isUnresolved(target) ||
2310 target.isGetter() || 2310 target.isGetter() ||
2311 target.isField() || 2311 target.isField() ||
2312 Elements.isClosureSend(node, target)) { 2312 Elements.isClosureSend(node, target)) {
2313 // If we don't know what we're calling or if we are calling a getter, 2313 // If we don't know what we're calling or if we are calling a getter,
2314 // we need to register that fact that we may be calling a closure 2314 // we need to register that fact that we may be calling a closure
2315 // with the same arguments. 2315 // with the same arguments.
2316 Selector call = new Selector.callClosureFrom(selector); 2316 Selector call = new Selector.callClosureFrom(selector);
2317 world.registerDynamicInvocation(call.name, call); 2317 world.registerDynamicInvocation(call);
2318 } else if (target.impliesType()) { 2318 } else if (target.impliesType()) {
2319 // We call 'call()' on a Type instance returned from the reference to a 2319 // We call 'call()' on a Type instance returned from the reference to a
2320 // class or typedef literal. We do not need to register this call as a 2320 // class or typedef literal. We do not need to register this call as a
2321 // dynamic invocation, because we statically know what the target is. 2321 // dynamic invocation, because we statically know what the target is.
2322 } else if (!selector.applies(target, compiler)) { 2322 } else if (!selector.applies(target, compiler)) {
2323 warnArgumentMismatch(node, target); 2323 warnArgumentMismatch(node, target);
2324 } 2324 }
2325 2325
2326 if (target != null && 2326 if (target != null &&
2327 target.isForeign(compiler) && 2327 target.isForeign(compiler) &&
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 {'className': currentClass, 'memberName': selector.name}); 2417 {'className': currentClass, 'memberName': selector.name});
2418 compiler.backend.registerSuperNoSuchMethod(mapping); 2418 compiler.backend.registerSuperNoSuchMethod(mapping);
2419 } 2419 }
2420 } 2420 }
2421 useElement(node.selector, getter); 2421 useElement(node.selector, getter);
2422 2422
2423 // Make sure we include the + and - operators if we are using 2423 // Make sure we include the + and - operators if we are using
2424 // the ++ and -- ones. Also, if op= form is used, include op itself. 2424 // the ++ and -- ones. Also, if op= form is used, include op itself.
2425 void registerBinaryOperator(SourceString name) { 2425 void registerBinaryOperator(SourceString name) {
2426 Selector binop = new Selector.binaryOperator(name); 2426 Selector binop = new Selector.binaryOperator(name);
2427 world.registerDynamicInvocation(binop.name, binop); 2427 world.registerDynamicInvocation(binop);
2428 mapping.setOperatorSelectorInComplexSendSet(node, binop); 2428 mapping.setOperatorSelectorInComplexSendSet(node, binop);
2429 } 2429 }
2430 if (identical(source, '++')) { 2430 if (identical(source, '++')) {
2431 registerBinaryOperator(const SourceString('+')); 2431 registerBinaryOperator(const SourceString('+'));
2432 } else if (identical(source, '--')) { 2432 } else if (identical(source, '--')) {
2433 registerBinaryOperator(const SourceString('-')); 2433 registerBinaryOperator(const SourceString('-'));
2434 } else if (source.endsWith('=')) { 2434 } else if (source.endsWith('=')) {
2435 registerBinaryOperator(Elements.mapToUserOperator(operatorName)); 2435 registerBinaryOperator(Elements.mapToUserOperator(operatorName));
2436 } 2436 }
2437 } 2437 }
2438 2438
2439 registerSend(selector, setter); 2439 registerSend(selector, setter);
2440 return useElement(node, setter); 2440 return useElement(node, setter);
2441 } 2441 }
2442 2442
2443 void registerSend(Selector selector, Element target) { 2443 void registerSend(Selector selector, Element target) {
2444 if (target == null || target.isInstanceMember()) { 2444 if (target == null || target.isInstanceMember()) {
2445 if (selector.isGetter()) { 2445 if (selector.isGetter()) {
2446 world.registerDynamicGetter(selector.name, selector); 2446 world.registerDynamicGetter(selector);
2447 } else if (selector.isSetter()) { 2447 } else if (selector.isSetter()) {
2448 world.registerDynamicSetter(selector.name, selector); 2448 world.registerDynamicSetter(selector);
2449 } else { 2449 } else {
2450 world.registerDynamicInvocation(selector.name, selector); 2450 world.registerDynamicInvocation(selector);
2451 } 2451 }
2452 } else if (Elements.isStaticOrTopLevel(target)) { 2452 } else if (Elements.isStaticOrTopLevel(target)) {
2453 // TODO(kasperl): It seems like we're not supposed to register 2453 // TODO(kasperl): It seems like we're not supposed to register
2454 // the use of classes. Wouldn't it be simpler if we just did? 2454 // the use of classes. Wouldn't it be simpler if we just did?
2455 if (!target.isClass()) { 2455 if (!target.isClass()) {
2456 // [target] might be the implementation element and only declaration 2456 // [target] might be the implementation element and only declaration
2457 // elements may be registered. 2457 // elements may be registered.
2458 world.registerStaticUse(target.declaration); 2458 world.registerStaticUse(target.declaration);
2459 } 2459 }
2460 } 2460 }
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 error(node.target, MessageKind.INVALID_CONTINUE); 2823 error(node.target, MessageKind.INVALID_CONTINUE);
2824 } 2824 }
2825 label.setContinueTarget(); 2825 label.setContinueTarget();
2826 mapping[node.target] = label; 2826 mapping[node.target] = label;
2827 } 2827 }
2828 mapping[node] = target; 2828 mapping[node] = target;
2829 } 2829 }
2830 2830
2831 registerImplicitInvocation(SourceString name, int arity) { 2831 registerImplicitInvocation(SourceString name, int arity) {
2832 Selector selector = new Selector.call(name, null, arity); 2832 Selector selector = new Selector.call(name, null, arity);
2833 world.registerDynamicInvocation(name, selector); 2833 world.registerDynamicInvocation(selector);
2834 } 2834 }
2835 2835
2836 visitForIn(ForIn node) { 2836 visitForIn(ForIn node) {
2837 LibraryElement library = enclosingElement.getLibrary(); 2837 LibraryElement library = enclosingElement.getLibrary();
2838 mapping.setIteratorSelector(node, compiler.iteratorSelector); 2838 mapping.setIteratorSelector(node, compiler.iteratorSelector);
2839 world.registerDynamicGetter(compiler.iteratorSelector.name, 2839 world.registerDynamicGetter(compiler.iteratorSelector);
2840 compiler.iteratorSelector);
2841 mapping.setCurrentSelector(node, compiler.currentSelector); 2840 mapping.setCurrentSelector(node, compiler.currentSelector);
2842 world.registerDynamicGetter(compiler.currentSelector.name, 2841 world.registerDynamicGetter(compiler.currentSelector);
2843 compiler.currentSelector);
2844 mapping.setMoveNextSelector(node, compiler.moveNextSelector); 2842 mapping.setMoveNextSelector(node, compiler.moveNextSelector);
2845 world.registerDynamicInvocation(compiler.moveNextSelector.name, 2843 world.registerDynamicInvocation(compiler.moveNextSelector);
2846 compiler.moveNextSelector);
2847 2844
2848 visit(node.expression); 2845 visit(node.expression);
2849 Scope blockScope = new BlockScope(scope); 2846 Scope blockScope = new BlockScope(scope);
2850 Node declaration = node.declaredIdentifier; 2847 Node declaration = node.declaredIdentifier;
2851 visitIn(declaration, blockScope); 2848 visitIn(declaration, blockScope);
2852 2849
2853 Send send = declaration.asSend(); 2850 Send send = declaration.asSend();
2854 VariableDefinitions variableDefinitions = 2851 VariableDefinitions variableDefinitions =
2855 declaration.asVariableDefinitions(); 2852 declaration.asVariableDefinitions();
2856 Element loopVariable; 2853 Element loopVariable;
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4054 return e; 4051 return e;
4055 } 4052 }
4056 4053
4057 /// Assumed to be called by [resolveRedirectingFactory]. 4054 /// Assumed to be called by [resolveRedirectingFactory].
4058 Element visitReturn(Return node) { 4055 Element visitReturn(Return node) {
4059 Node expression = node.expression; 4056 Node expression = node.expression;
4060 return finishConstructorReference(visit(expression), 4057 return finishConstructorReference(visit(expression),
4061 expression, expression); 4058 expression, expression);
4062 } 4059 }
4063 } 4060 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698