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

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

Issue 23819039: Create type masks lazily. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
11 /// A set of additional dependencies. See [registerDependency] below. 11 /// A set of additional dependencies. See [registerDependency] below.
12 Set<Element> get otherDependencies; 12 Set<Element> get otherDependencies;
13 13
14 Element operator[](Node node); 14 Element operator[](Node node);
15 Selector getSelector(Send send); 15 Selector getSelector(Send send);
16 Selector getGetterSelectorInComplexSendSet(SendSet node); 16 Selector getGetterSelectorInComplexSendSet(SendSet node);
17 Selector getOperatorSelectorInComplexSendSet(SendSet node); 17 Selector getOperatorSelectorInComplexSendSet(SendSet node);
18 DartType getType(Node node); 18 DartType getType(Node node);
19 void setSelector(Node node, Selector selector); 19 void setSelector(Node node, Selector selector);
20 void setGetterSelectorInComplexSendSet(SendSet node, Selector selector); 20 void setGetterSelectorInComplexSendSet(SendSet node, Selector selector);
21 void setOperatorSelectorInComplexSendSet(SendSet node, Selector selector); 21 void setOperatorSelectorInComplexSendSet(SendSet node, Selector selector);
22 Selector getIteratorSelector(ForIn node); 22 Selector getIteratorSelector(ForIn node);
23 Selector getMoveNextSelector(ForIn node); 23 Selector getMoveNextSelector(ForIn node);
24 Selector getCurrentSelector(ForIn node); 24 Selector getCurrentSelector(ForIn node);
25 Selector setIteratorSelector(ForIn node, Selector selector); 25 Selector setIteratorSelector(ForIn node, Selector selector);
26 Selector setMoveNextSelector(ForIn node, Selector selector); 26 Selector setMoveNextSelector(ForIn node, Selector selector);
27 Selector setCurrentSelector(ForIn node, Selector selector); 27 Selector setCurrentSelector(ForIn node, Selector selector);
28 28
29 /**
30 * Returns [:true:] if [node] is a type literal.
31 *
32 * Resolution marks this by setting the type on the node to be the
33 * [:Type:] type.
34 */
35 bool isTypeLiteral(Send node);
36
29 /// Register additional dependencies required by [currentElement]. 37 /// Register additional dependencies required by [currentElement].
30 /// For example, elements that are used by a backend. 38 /// For example, elements that are used by a backend.
31 void registerDependency(Element element); 39 void registerDependency(Element element);
32 } 40 }
33 41
34 class TreeElementMapping implements TreeElements { 42 class TreeElementMapping implements TreeElements {
35 final Element currentElement; 43 final Element currentElement;
36 final Map<Spannable, Selector> selectors = 44 final Map<Spannable, Selector> selectors =
37 new LinkedHashMap<Spannable, Selector>(); 45 new LinkedHashMap<Spannable, Selector>();
38 final Map<Node, DartType> types = new LinkedHashMap<Node, DartType>(); 46 final Map<Node, DartType> types = new LinkedHashMap<Node, DartType>();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 133 }
126 134
127 Selector setCurrentSelector(ForIn node, Selector selector) { 135 Selector setCurrentSelector(ForIn node, Selector selector) {
128 selectors[node.inToken] = selector; 136 selectors[node.inToken] = selector;
129 } 137 }
130 138
131 Selector getCurrentSelector(ForIn node) { 139 Selector getCurrentSelector(ForIn node) {
132 return selectors[node.inToken]; 140 return selectors[node.inToken];
133 } 141 }
134 142
143 bool isTypeLiteral(Send node) {
144 return getType(node) != null;
145 }
146
135 void registerDependency(Element element) { 147 void registerDependency(Element element) {
136 otherDependencies.add(element.implementation); 148 otherDependencies.add(element.implementation);
137 } 149 }
138 150
139 String toString() => 'TreeElementMapping($currentElement)'; 151 String toString() => 'TreeElementMapping($currentElement)';
140 } 152 }
141 153
142 class ResolverTask extends CompilerTask { 154 class ResolverTask extends CompilerTask {
143 ResolverTask(Compiler compiler) : super(compiler); 155 ResolverTask(Compiler compiler) : super(compiler);
144 156
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 MessageKind.CANNOT_RESOLVE_GETTER); 2315 MessageKind.CANNOT_RESOLVE_GETTER);
2304 } 2316 }
2305 } else if (target.isTypeVariable()) { 2317 } else if (target.isTypeVariable()) {
2306 ClassElement cls = target.getEnclosingClass(); 2318 ClassElement cls = target.getEnclosingClass();
2307 assert(enclosingElement.getEnclosingClass() == cls); 2319 assert(enclosingElement.getEnclosingClass() == cls);
2308 compiler.backend.registerClassUsingVariableExpression(cls); 2320 compiler.backend.registerClassUsingVariableExpression(cls);
2309 compiler.backend.registerTypeVariableExpression(mapping); 2321 compiler.backend.registerTypeVariableExpression(mapping);
2310 // Set the type of the node to [Type] to mark this send as a 2322 // Set the type of the node to [Type] to mark this send as a
2311 // type variable expression. 2323 // type variable expression.
2312 mapping.setType(node, compiler.typeClass.computeType(compiler)); 2324 mapping.setType(node, compiler.typeClass.computeType(compiler));
2313 world.registerInstantiatedClass(compiler.typeClass, mapping); 2325 world.registerTypeLiteral(target, mapping);
2314 } else if (target.impliesType() && !sendIsMemberAccess) { 2326 } else if (target.impliesType() && !sendIsMemberAccess) {
2315 // Set the type of the node to [Type] to mark this send as a 2327 // Set the type of the node to [Type] to mark this send as a
2316 // type literal. 2328 // type literal.
2317 mapping.setType(node, compiler.typeClass.computeType(compiler)); 2329 mapping.setType(node, compiler.typeClass.computeType(compiler));
2318 world.registerTypeLiteral(target, mapping); 2330 world.registerTypeLiteral(target, mapping);
2319 } 2331 }
2320 } 2332 }
2321 2333
2322 bool resolvedArguments = false; 2334 bool resolvedArguments = false;
2323 if (node.isOperator) { 2335 if (node.isOperator) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 2479
2468 // Make sure we include the + and - operators if we are using 2480 // Make sure we include the + and - operators if we are using
2469 // the ++ and -- ones. Also, if op= form is used, include op itself. 2481 // the ++ and -- ones. Also, if op= form is used, include op itself.
2470 void registerBinaryOperator(SourceString name) { 2482 void registerBinaryOperator(SourceString name) {
2471 Selector binop = new Selector.binaryOperator(name); 2483 Selector binop = new Selector.binaryOperator(name);
2472 world.registerDynamicInvocation(binop); 2484 world.registerDynamicInvocation(binop);
2473 mapping.setOperatorSelectorInComplexSendSet(node, binop); 2485 mapping.setOperatorSelectorInComplexSendSet(node, binop);
2474 } 2486 }
2475 if (identical(source, '++')) { 2487 if (identical(source, '++')) {
2476 registerBinaryOperator(const SourceString('+')); 2488 registerBinaryOperator(const SourceString('+'));
2489 world.registerInstantiatedClass(compiler.intClass, mapping);
2477 } else if (identical(source, '--')) { 2490 } else if (identical(source, '--')) {
2478 registerBinaryOperator(const SourceString('-')); 2491 registerBinaryOperator(const SourceString('-'));
2492 world.registerInstantiatedClass(compiler.intClass, mapping);
2479 } else if (source.endsWith('=')) { 2493 } else if (source.endsWith('=')) {
2480 registerBinaryOperator(Elements.mapToUserOperator(operatorName)); 2494 registerBinaryOperator(Elements.mapToUserOperator(operatorName));
2481 } 2495 }
2482 } 2496 }
2483 2497
2484 registerSend(selector, setter); 2498 registerSend(selector, setter);
2485 return useElement(node, setter); 2499 return useElement(node, setter);
2486 } 2500 }
2487 2501
2488 void registerSend(Selector selector, Element target) { 2502 void registerSend(Selector selector, Element target) {
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
4150 return e; 4164 return e;
4151 } 4165 }
4152 4166
4153 /// Assumed to be called by [resolveRedirectingFactory]. 4167 /// Assumed to be called by [resolveRedirectingFactory].
4154 Element visitReturn(Return node) { 4168 Element visitReturn(Return node) {
4155 Node expression = node.expression; 4169 Node expression = node.expression;
4156 return finishConstructorReference(visit(expression), 4170 return finishConstructorReference(visit(expression),
4157 expression, expression); 4171 expression, expression);
4158 } 4172 }
4159 } 4173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698