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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart

Issue 22791002: Add renames in output when using the mirror helper library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments and fixed some latent bugs in other parts of the code. Created 7 years, 4 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 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 27 matching lines...) Expand all
38 class DeclarationTypePlaceholder { 38 class DeclarationTypePlaceholder {
39 final TypeAnnotation typeNode; 39 final TypeAnnotation typeNode;
40 final bool requiresVar; 40 final bool requiresVar;
41 DeclarationTypePlaceholder(this.typeNode, this.requiresVar); 41 DeclarationTypePlaceholder(this.typeNode, this.requiresVar);
42 } 42 }
43 43
44 class SendVisitor extends ResolvedVisitor { 44 class SendVisitor extends ResolvedVisitor {
45 final PlaceholderCollector collector; 45 final PlaceholderCollector collector;
46 46
47 get compiler => collector.compiler; 47 get compiler => collector.compiler;
48 DartBackend get backend => compiler.backend;
49 48
50 SendVisitor(this.collector, TreeElements elements) : super(elements); 49 SendVisitor(this.collector, TreeElements elements) : super(elements);
51 50
52 visitOperatorSend(Send node) { 51 visitOperatorSend(Send node) {
53 } 52 }
54 53
55 visitForeignSend(Send node) {} 54 visitForeignSend(Send node) {}
56 55
57 visitSuperSend(Send node) { 56 visitSuperSend(Send node) {
58 Element element = elements[node]; 57 Element element = elements[node];
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 collector.tryMakeLocalPlaceholder(element, node.selector); 99 collector.tryMakeLocalPlaceholder(element, node.selector);
101 } else { 100 } else {
102 assert(node.selector is FunctionExpression); 101 assert(node.selector is FunctionExpression);
103 } 102 }
104 } 103 }
105 } 104 }
106 } 105 }
107 106
108 visitStaticSend(Send node) { 107 visitStaticSend(Send node) {
109 final element = elements[node]; 108 final element = elements[node];
110 backend.registerStaticSend(element, node); 109 collector.backend.registerStaticSend(element, node);
111 110
112 if (Elements.isUnresolved(element) 111 if (Elements.isUnresolved(element)
113 || identical(element, compiler.assertMethod)) { 112 || identical(element, compiler.assertMethod)) {
114 return; 113 return;
115 } 114 }
116 if (element.isConstructor() || element.isFactoryConstructor()) { 115 if (element.isConstructor() || element.isFactoryConstructor()) {
117 // Rename named constructor in redirection position: 116 // Rename named constructor in redirection position:
118 // class C { C.named(); C.redirecting() : this.named(); } 117 // class C { C.named(); C.redirecting() : this.named(); }
119 if (node.receiver is Identifier 118 if (node.receiver is Identifier
120 && node.receiver.asIdentifier().isThis()) { 119 && node.receiver.asIdentifier().isThis()) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 final List<DeclarationTypePlaceholder> declarationTypePlaceholders; 153 final List<DeclarationTypePlaceholder> declarationTypePlaceholders;
155 final Map<String, Set<Identifier>> memberPlaceholders; 154 final Map<String, Set<Identifier>> memberPlaceholders;
156 final Map<Element, List<ConstructorPlaceholder>> constructorPlaceholders; 155 final Map<Element, List<ConstructorPlaceholder>> constructorPlaceholders;
157 Map<String, LocalPlaceholder> currentLocalPlaceholders; 156 Map<String, LocalPlaceholder> currentLocalPlaceholders;
158 Element currentElement; 157 Element currentElement;
159 FunctionElement topmostEnclosingFunction; 158 FunctionElement topmostEnclosingFunction;
160 TreeElements treeElements; 159 TreeElements treeElements;
161 160
162 LibraryElement get coreLibrary => compiler.coreLibrary; 161 LibraryElement get coreLibrary => compiler.coreLibrary;
163 FunctionElement get entryFunction => compiler.mainApp.find(Compiler.MAIN); 162 FunctionElement get entryFunction => compiler.mainApp.find(Compiler.MAIN);
163 DartBackend get backend => compiler.backend;
164 164
165 get currentFunctionScope => functionScopes.putIfAbsent( 165 get currentFunctionScope => functionScopes.putIfAbsent(
166 topmostEnclosingFunction, () => new FunctionScope()); 166 topmostEnclosingFunction, () => new FunctionScope());
167 167
168 PlaceholderCollector(this.compiler, this.fixedMemberNames, this.elementAsts) : 168 PlaceholderCollector(this.compiler, this.fixedMemberNames, this.elementAsts) :
169 nullNodes = new Set<Node>(), 169 nullNodes = new Set<Node>(),
170 unresolvedNodes = new Set<Node>(), 170 unresolvedNodes = new Set<Node>(),
171 elementNodes = new Map<Element, Set<Node>>(), 171 elementNodes = new Map<Element, Set<Node>>(),
172 functionScopes = new Map<FunctionElement, FunctionScope>(), 172 functionScopes = new Map<FunctionElement, FunctionScope>(),
173 privateNodes = new Map<LibraryElement, Set<Identifier>>(), 173 privateNodes = new Map<LibraryElement, Set<Identifier>>(),
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 531 }
532 } 532 }
533 node.visitChildren(this); 533 node.visitChildren(this);
534 } 534 }
535 535
536 visitFunctionExpression(FunctionExpression node) { 536 visitFunctionExpression(FunctionExpression node) {
537 bool isKeyword(Identifier id) => 537 bool isKeyword(Identifier id) =>
538 id != null && Keyword.keywords[id.source.slowToString()] != null; 538 id != null && Keyword.keywords[id.source.slowToString()] != null;
539 539
540 Element element = treeElements[node]; 540 Element element = treeElements[node];
541 if (element == backend.mirrorHelperGetNameFunction) {
542 backend.registerHelperFunction(element, node);
543 }
541 // May get null here in case of A(int this.f()); 544 // May get null here in case of A(int this.f());
542 if (element != null) { 545 if (element != null) {
543 // Rename only local functions. 546 // Rename only local functions.
544 if (topmostEnclosingFunction == null) { 547 if (topmostEnclosingFunction == null) {
545 topmostEnclosingFunction = element; 548 topmostEnclosingFunction = element;
546 } 549 }
547 if (!identical(element, currentElement)) { 550 if (!identical(element, currentElement)) {
548 if (node.name != null) { 551 if (node.name != null) {
549 assert(node.name is Identifier); 552 assert(node.name is Identifier);
550 tryMakeLocalPlaceholder(element, node.name); 553 tryMakeLocalPlaceholder(element, node.name);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 621
619 visitBlock(Block node) { 622 visitBlock(Block node) {
620 for (Node statement in node.statements.nodes) { 623 for (Node statement in node.statements.nodes) {
621 if (statement is VariableDefinitions) { 624 if (statement is VariableDefinitions) {
622 makeVarDeclarationTypePlaceholder(statement); 625 makeVarDeclarationTypePlaceholder(statement);
623 } 626 }
624 } 627 }
625 node.visitChildren(this); 628 node.visitChildren(this);
626 } 629 }
627 } 630 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698