Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 class LocalPlaceholder { | 7 class LocalPlaceholder { |
| 8 final String identifier; | 8 final String identifier; |
| 9 final Set<Node> nodes; | 9 final Set<Node> nodes; |
| 10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); | 10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 collector.tryMakeLocalPlaceholder(element, node.selector); | 100 collector.tryMakeLocalPlaceholder(element, node.selector); |
| 101 } else { | 101 } else { |
| 102 assert(node.selector is FunctionExpression); | 102 assert(node.selector is FunctionExpression); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 visitStaticSend(Send node) { | 108 visitStaticSend(Send node) { |
| 109 final element = elements[node]; | 109 final element = elements[node]; |
| 110 backend.registerStaticSend(element, node); | 110 collector.backend.registerStaticSend(element, node); |
|
ahe
2013/08/19 15:34:06
I don't understand this change.
zarah
2013/08/20 14:08:17
Since the backend is now needed in the collector a
| |
| 111 | 111 |
| 112 if (Elements.isUnresolved(element) | 112 if (Elements.isUnresolved(element) |
| 113 || identical(element, compiler.assertMethod)) { | 113 || identical(element, compiler.assertMethod)) { |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 if (element.isConstructor() || element.isFactoryConstructor()) { | 116 if (element.isConstructor() || element.isFactoryConstructor()) { |
| 117 // Rename named constructor in redirection position: | 117 // Rename named constructor in redirection position: |
| 118 // class C { C.named(); C.redirecting() : this.named(); } | 118 // class C { C.named(); C.redirecting() : this.named(); } |
| 119 if (node.receiver is Identifier | 119 if (node.receiver is Identifier |
| 120 && node.receiver.asIdentifier().isThis()) { | 120 && node.receiver.asIdentifier().isThis()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 final List<DeclarationTypePlaceholder> declarationTypePlaceholders; | 154 final List<DeclarationTypePlaceholder> declarationTypePlaceholders; |
| 155 final Map<String, Set<Identifier>> memberPlaceholders; | 155 final Map<String, Set<Identifier>> memberPlaceholders; |
| 156 final Map<Element, List<ConstructorPlaceholder>> constructorPlaceholders; | 156 final Map<Element, List<ConstructorPlaceholder>> constructorPlaceholders; |
| 157 Map<String, LocalPlaceholder> currentLocalPlaceholders; | 157 Map<String, LocalPlaceholder> currentLocalPlaceholders; |
| 158 Element currentElement; | 158 Element currentElement; |
| 159 FunctionElement topmostEnclosingFunction; | 159 FunctionElement topmostEnclosingFunction; |
| 160 TreeElements treeElements; | 160 TreeElements treeElements; |
| 161 | 161 |
| 162 LibraryElement get coreLibrary => compiler.coreLibrary; | 162 LibraryElement get coreLibrary => compiler.coreLibrary; |
| 163 FunctionElement get entryFunction => compiler.mainApp.find(Compiler.MAIN); | 163 FunctionElement get entryFunction => compiler.mainApp.find(Compiler.MAIN); |
| 164 DartBackend get backend => compiler.backend; | |
| 164 | 165 |
| 165 get currentFunctionScope => functionScopes.putIfAbsent( | 166 get currentFunctionScope => functionScopes.putIfAbsent( |
| 166 topmostEnclosingFunction, () => new FunctionScope()); | 167 topmostEnclosingFunction, () => new FunctionScope()); |
| 167 | 168 |
| 168 PlaceholderCollector(this.compiler, this.fixedMemberNames, this.elementAsts) : | 169 PlaceholderCollector(this.compiler, this.fixedMemberNames, this.elementAsts) : |
| 169 nullNodes = new Set<Node>(), | 170 nullNodes = new Set<Node>(), |
| 170 unresolvedNodes = new Set<Node>(), | 171 unresolvedNodes = new Set<Node>(), |
| 171 elementNodes = new Map<Element, Set<Node>>(), | 172 elementNodes = new Map<Element, Set<Node>>(), |
| 172 functionScopes = new Map<FunctionElement, FunctionScope>(), | 173 functionScopes = new Map<FunctionElement, FunctionScope>(), |
| 173 privateNodes = new Map<LibraryElement, Set<Identifier>>(), | 174 privateNodes = new Map<LibraryElement, Set<Identifier>>(), |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 } | 532 } |
| 532 } | 533 } |
| 533 node.visitChildren(this); | 534 node.visitChildren(this); |
| 534 } | 535 } |
| 535 | 536 |
| 536 visitFunctionExpression(FunctionExpression node) { | 537 visitFunctionExpression(FunctionExpression node) { |
| 537 bool isKeyword(Identifier id) => | 538 bool isKeyword(Identifier id) => |
| 538 id != null && Keyword.keywords[id.source.slowToString()] != null; | 539 id != null && Keyword.keywords[id.source.slowToString()] != null; |
| 539 | 540 |
| 540 Element element = treeElements[node]; | 541 Element element = treeElements[node]; |
| 542 if (element == compiler.mirrorHelperFunction) { | |
| 543 backend.registerHelperFunction(element, node); | |
| 544 } | |
| 541 // May get null here in case of A(int this.f()); | 545 // May get null here in case of A(int this.f()); |
| 542 if (element != null) { | 546 if (element != null) { |
| 543 // Rename only local functions. | 547 // Rename only local functions. |
| 544 if (topmostEnclosingFunction == null) { | 548 if (topmostEnclosingFunction == null) { |
| 545 topmostEnclosingFunction = element; | 549 topmostEnclosingFunction = element; |
| 546 } | 550 } |
| 547 if (!identical(element, currentElement)) { | 551 if (!identical(element, currentElement)) { |
| 548 if (node.name != null) { | 552 if (node.name != null) { |
| 549 assert(node.name is Identifier); | 553 assert(node.name is Identifier); |
| 550 tryMakeLocalPlaceholder(element, node.name); | 554 tryMakeLocalPlaceholder(element, node.name); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 | 622 |
| 619 visitBlock(Block node) { | 623 visitBlock(Block node) { |
| 620 for (Node statement in node.statements.nodes) { | 624 for (Node statement in node.statements.nodes) { |
| 621 if (statement is VariableDefinitions) { | 625 if (statement is VariableDefinitions) { |
| 622 makeVarDeclarationTypePlaceholder(statement); | 626 makeVarDeclarationTypePlaceholder(statement); |
| 623 } | 627 } |
| 624 } | 628 } |
| 625 node.visitChildren(this); | 629 node.visitChildren(this); |
| 626 } | 630 } |
| 627 } | 631 } |
| OLD | NEW |