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

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

Issue 10827424: Do not create placeholders for elements that won't be later renamed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« no previous file with comments | « no previous file | lib/compiler/implementation/dart_backend/renamer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class LocalPlaceholder implements Hashable { 5 class LocalPlaceholder implements Hashable {
6 final String identifier; 6 final String identifier;
7 final Set<Node> nodes; 7 final Set<Node> nodes;
8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); 8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>();
9 int hashCode() => identifier.hashCode(); 9 int hashCode() => identifier.hashCode();
10 String toString() => 10 String toString() =>
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 final Compiler compiler; 91 final Compiler compiler;
92 final Set<Node> nullNodes; // Nodes that should not be in output. 92 final Set<Node> nullNodes; // Nodes that should not be in output.
93 final Set<Identifier> unresolvedNodes; 93 final Set<Identifier> unresolvedNodes;
94 final Map<Element, Set<Node>> elementNodes; 94 final Map<Element, Set<Node>> elementNodes;
95 final Map<FunctionElement, Set<LocalPlaceholder>> localPlaceholders; 95 final Map<FunctionElement, Set<LocalPlaceholder>> localPlaceholders;
96 final Map<LibraryElement, Set<Identifier>> privateNodes; 96 final Map<LibraryElement, Set<Identifier>> privateNodes;
97 Map<String, LocalPlaceholder> currentLocalPlaceholders; 97 Map<String, LocalPlaceholder> currentLocalPlaceholders;
98 Element currentElement; 98 Element currentElement;
99 TreeElements treeElements; 99 TreeElements treeElements;
100 100
101 LibraryElement get coreLibrary => compiler.coreLibrary;
102 FunctionElement get entryFunction => compiler.mainApp.find(Compiler.MAIN);
103
101 PlaceholderCollector(this.compiler) : 104 PlaceholderCollector(this.compiler) :
102 nullNodes = new Set<Node>(), 105 nullNodes = new Set<Node>(),
103 unresolvedNodes = new Set<Identifier>(), 106 unresolvedNodes = new Set<Identifier>(),
104 elementNodes = new Map<Element, Set<Node>>(), 107 elementNodes = new Map<Element, Set<Node>>(),
105 localPlaceholders = new Map<FunctionElement, Set<LocalPlaceholder>>(), 108 localPlaceholders = new Map<FunctionElement, Set<LocalPlaceholder>>(),
106 privateNodes = new Map<LibraryElement, Set<Identifier>>(); 109 privateNodes = new Map<LibraryElement, Set<Identifier>>();
107 110
108 void collectFunctionDeclarationPlaceholders( 111 void collectFunctionDeclarationPlaceholders(
109 FunctionElement element, FunctionExpression node) { 112 FunctionElement element, FunctionExpression node) {
110 if (element.isGenerativeConstructor() || element.isFactoryConstructor()) { 113 if (element.isGenerativeConstructor() || element.isFactoryConstructor()) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 makeElementPlaceholder(node, type.element); 253 makeElementPlaceholder(node, type.element);
251 } 254 }
252 255
253 void makeNullPlaceholder(Node node) { 256 void makeNullPlaceholder(Node node) {
254 assert(node is Identifier || node is Send); 257 assert(node is Identifier || node is Send);
255 nullNodes.add(node); 258 nullNodes.add(node);
256 } 259 }
257 260
258 void makeElementPlaceholder(Node node, Element element) { 261 void makeElementPlaceholder(Node node, Element element) {
259 assert(element !== null); 262 assert(element !== null);
263 if (element === entryFunction) return;
Roman 2012/08/21 07:44:58 This is not the problem of your CL, but we should
Anton Muhin 2012/08/21 09:16:54 Good point, I'll fix it. On 2012/08/21 07:44:58,
264 if (element.getLibrary() === coreLibrary) return;
260 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node); 265 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node);
261 } 266 }
262 267
263 void makePrivateIdentifier(Identifier node) { 268 void makePrivateIdentifier(Identifier node) {
264 assert(node !== null); 269 assert(node !== null);
265 privateNodes.putIfAbsent( 270 privateNodes.putIfAbsent(
266 currentElement.getLibrary(), () => new Set<Identifier>()).add(node); 271 currentElement.getLibrary(), () => new Set<Identifier>()).add(node);
267 } 272 }
268 273
269 void makeUnresolvedPlaceholder(Node node) { 274 void makeUnresolvedPlaceholder(Node node) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 visit(node.defaultClause.typeArguments); 428 visit(node.defaultClause.typeArguments);
424 } 429 }
425 } 430 }
426 431
427 visitTypedef(Typedef node) { 432 visitTypedef(Typedef node) {
428 assert(currentElement is TypedefElement); 433 assert(currentElement is TypedefElement);
429 makeElementPlaceholder(node.name, currentElement); 434 makeElementPlaceholder(node.name, currentElement);
430 node.visitChildren(this); 435 node.visitChildren(this);
431 } 436 }
432 } 437 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/dart_backend/renamer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698