| 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 12 matching lines...) Expand all Loading... |
| 23 parameterIdentifiers.add(node.source.slowToString()); | 23 parameterIdentifiers.add(node.source.slowToString()); |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 class ConstructorPlaceholder { | 27 class ConstructorPlaceholder { |
| 28 final Node node; | 28 final Node node; |
| 29 final DartType type; | 29 final DartType type; |
| 30 final bool isRedirectingCall; | 30 final bool isRedirectingCall; |
| 31 ConstructorPlaceholder(this.node, this.type) | 31 ConstructorPlaceholder(this.node, this.type) |
| 32 : this.isRedirectingCall = false; | 32 : this.isRedirectingCall = false; |
| 33 // Note: factory redirection is not redirecting call! |
| 33 ConstructorPlaceholder.redirectingCall(this.node) | 34 ConstructorPlaceholder.redirectingCall(this.node) |
| 34 : this.type = null, this.isRedirectingCall = true; | 35 : this.type = null, this.isRedirectingCall = true; |
| 35 } | 36 } |
| 36 | 37 |
| 37 class DeclarationTypePlaceholder { | 38 class DeclarationTypePlaceholder { |
| 38 final TypeAnnotation typeNode; | 39 final TypeAnnotation typeNode; |
| 39 final bool requiresVar; | 40 final bool requiresVar; |
| 40 DeclarationTypePlaceholder(this.typeNode, this.requiresVar); | 41 DeclarationTypePlaceholder(this.typeNode, this.requiresVar); |
| 41 } | 42 } |
| 42 | 43 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 declarationTypePlaceholders = new List<DeclarationTypePlaceholder>(), | 169 declarationTypePlaceholders = new List<DeclarationTypePlaceholder>(), |
| 169 memberPlaceholders = new Map<String, Set<Identifier>>(), | 170 memberPlaceholders = new Map<String, Set<Identifier>>(), |
| 170 constructorPlaceholders = | 171 constructorPlaceholders = |
| 171 new Map<Element, List<ConstructorPlaceholder>>(); | 172 new Map<Element, List<ConstructorPlaceholder>>(); |
| 172 | 173 |
| 173 void collectFunctionDeclarationPlaceholders( | 174 void collectFunctionDeclarationPlaceholders( |
| 174 FunctionElement element, FunctionExpression node) { | 175 FunctionElement element, FunctionExpression node) { |
| 175 if (element.isGenerativeConstructor() || element.isFactoryConstructor()) { | 176 if (element.isGenerativeConstructor() || element.isFactoryConstructor()) { |
| 176 DartType type = element.getEnclosingClass().type.asRaw(); | 177 DartType type = element.getEnclosingClass().type.asRaw(); |
| 177 makeConstructorPlaceholder(node.name, element, type); | 178 makeConstructorPlaceholder(node.name, element, type); |
| 179 Return bodyAsReturn = node.body.asReturn(); |
| 180 if (bodyAsReturn != null && bodyAsReturn.isRedirectingFactoryBody) { |
| 181 // Factory redirection. |
| 182 FunctionElement redirectTarget = element.defaultImplementation; |
| 183 assert(redirectTarget != null && redirectTarget != element); |
| 184 type = redirectTarget.getEnclosingClass().type.asRaw(); |
| 185 makeConstructorPlaceholder( |
| 186 bodyAsReturn.expression, redirectTarget, type); |
| 187 } |
| 178 } else if (Elements.isStaticOrTopLevel(element)) { | 188 } else if (Elements.isStaticOrTopLevel(element)) { |
| 179 // Note: this code should only rename private identifiers for class' | 189 // Note: this code should only rename private identifiers for class' |
| 180 // fields/getters/setters/methods. Top-level identifiers are renamed | 190 // fields/getters/setters/methods. Top-level identifiers are renamed |
| 181 // just to escape conflicts and that should be enough as we shouldn't | 191 // just to escape conflicts and that should be enough as we shouldn't |
| 182 // be able to resolve private identifiers for other libraries. | 192 // be able to resolve private identifiers for other libraries. |
| 183 makeElementPlaceholder(node.name, element); | 193 makeElementPlaceholder(node.name, element); |
| 184 } else if (element.isMember()) { | 194 } else if (element.isMember()) { |
| 185 if (node.name is Identifier) { | 195 if (node.name is Identifier) { |
| 186 tryMakeMemberPlaceholder(node.name); | 196 tryMakeMemberPlaceholder(node.name); |
| 187 } else { | 197 } else { |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 615 |
| 606 visitBlock(Block node) { | 616 visitBlock(Block node) { |
| 607 for (Node statement in node.statements.nodes) { | 617 for (Node statement in node.statements.nodes) { |
| 608 if (statement is VariableDefinitions) { | 618 if (statement is VariableDefinitions) { |
| 609 makeVarDeclarationTypePlaceholder(statement); | 619 makeVarDeclarationTypePlaceholder(statement); |
| 610 } | 620 } |
| 611 } | 621 } |
| 612 node.visitChildren(this); | 622 node.visitChildren(this); |
| 613 } | 623 } |
| 614 } | 624 } |
| OLD | NEW |