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

Side by Side Diff: pkg/compiler/lib/src/dart_backend/placeholder_collector.dart

Issue 1383483006: Extract DiagnosticReporter implementation from Compiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes after rebase. Created 5 years, 2 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
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/outputter.dart ('k') | pkg/compiler/lib/src/dart_types.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 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 internalError(Spannable node, String reason) { 163 internalError(Spannable node, String reason) {
164 collector.internalError(reason, node: node); 164 collector.internalError(reason, node: node);
165 } 165 }
166 166
167 visitNode(Node node) { 167 visitNode(Node node) {
168 internalError(node, "Unhandled node"); 168 internalError(node, "Unhandled node");
169 } 169 }
170 } 170 }
171 171
172 class PlaceholderCollector extends Visitor { 172 class PlaceholderCollector extends Visitor {
173 final DiagnosticListener listener; 173 final DiagnosticReporter reporter;
174 final MirrorRenamer mirrorRenamer; 174 final MirrorRenamer mirrorRenamer;
175 final FunctionElement mainFunction; 175 final FunctionElement mainFunction;
176 final Set<String> fixedMemberNames; // member names which cannot be renamed. 176 final Set<String> fixedMemberNames; // member names which cannot be renamed.
177 final Map<Element, ElementAst> elementAsts; 177 final Map<Element, ElementAst> elementAsts;
178 final Set<Node> prefixNodesToErase = new Set<Node>(); 178 final Set<Node> prefixNodesToErase = new Set<Node>();
179 final Set<Node> unresolvedNodes = new Set<Node>(); 179 final Set<Node> unresolvedNodes = new Set<Node>();
180 final Map<Element, Set<Node>> elementNodes = new Map<Element, Set<Node>>(); 180 final Map<Element, Set<Node>> elementNodes = new Map<Element, Set<Node>>();
181 final Map<FunctionElement, FunctionScope> functionScopes 181 final Map<FunctionElement, FunctionScope> functionScopes
182 = new Map<FunctionElement, FunctionScope>(); 182 = new Map<FunctionElement, FunctionScope>();
183 final Map<LibraryElement, Set<Identifier>> privateNodes = 183 final Map<LibraryElement, Set<Identifier>> privateNodes =
184 new Map<LibraryElement, Set<Identifier>>(); 184 new Map<LibraryElement, Set<Identifier>>();
185 final List<DeclarationTypePlaceholder> declarationTypePlaceholders 185 final List<DeclarationTypePlaceholder> declarationTypePlaceholders
186 = new List<DeclarationTypePlaceholder>(); 186 = new List<DeclarationTypePlaceholder>();
187 final Map<String, Set<Identifier>> memberPlaceholders 187 final Map<String, Set<Identifier>> memberPlaceholders
188 = new Map<String, Set<Identifier>>(); 188 = new Map<String, Set<Identifier>>();
189 final List<ConstructorPlaceholder> constructorPlaceholders 189 final List<ConstructorPlaceholder> constructorPlaceholders
190 = new List<ConstructorPlaceholder>(); 190 = new List<ConstructorPlaceholder>();
191 Map<String, LocalPlaceholder> currentLocalPlaceholders; 191 Map<String, LocalPlaceholder> currentLocalPlaceholders;
192 Element currentElement; 192 Element currentElement;
193 FunctionElement topmostEnclosingFunction; 193 FunctionElement topmostEnclosingFunction;
194 TreeElements treeElements; 194 TreeElements treeElements;
195 195
196 get currentFunctionScope => functionScopes.putIfAbsent( 196 get currentFunctionScope => functionScopes.putIfAbsent(
197 topmostEnclosingFunction, () => new FunctionScope()); 197 topmostEnclosingFunction, () => new FunctionScope());
198 198
199 PlaceholderCollector(this.listener, this.mirrorRenamer, 199 PlaceholderCollector(this.reporter, this.mirrorRenamer,
200 this.fixedMemberNames, this.elementAsts, 200 this.fixedMemberNames, this.elementAsts,
201 this.mainFunction); 201 this.mainFunction);
202 202
203 void collectFunctionDeclarationPlaceholders( 203 void collectFunctionDeclarationPlaceholders(
204 FunctionElement element, FunctionExpression node) { 204 FunctionElement element, FunctionExpression node) {
205 if (element.isConstructor) { 205 if (element.isConstructor) {
206 ConstructorElement constructor = element; 206 ConstructorElement constructor = element;
207 tryMakeConstructorPlaceholder(node.name, element); 207 tryMakeConstructorPlaceholder(node.name, element);
208 RedirectingFactoryBody bodyAsRedirectingFactoryBody = 208 RedirectingFactoryBody bodyAsRedirectingFactoryBody =
209 node.body.asRedirectingFactoryBody(); 209 node.body.asRedirectingFactoryBody();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 VariableDefinitions definitions = elementNode; 251 VariableDefinitions definitions = elementNode;
252 Node definition = definitions.definitions.nodes.head; 252 Node definition = definitions.definitions.nodes.head;
253 collectFieldDeclarationPlaceholders(element, definition); 253 collectFieldDeclarationPlaceholders(element, definition);
254 makeVarDeclarationTypePlaceholder(definitions); 254 makeVarDeclarationTypePlaceholder(definitions);
255 } else { 255 } else {
256 assert(element is ClassElement || element is TypedefElement); 256 assert(element is ClassElement || element is TypedefElement);
257 } 257 }
258 currentLocalPlaceholders = new Map<String, LocalPlaceholder>(); 258 currentLocalPlaceholders = new Map<String, LocalPlaceholder>();
259 if (!(element is ConstructorElement && element.isRedirectingFactory)) { 259 if (!(element is ConstructorElement && element.isRedirectingFactory)) {
260 // Do not visit the body of redirecting factories. 260 // Do not visit the body of redirecting factories.
261 listener.withCurrentElement(element, () { 261 reporter.withCurrentElement(element, () {
262 elementNode.accept(this); 262 elementNode.accept(this);
263 }); 263 });
264 } 264 }
265 } 265 }
266 266
267 // TODO(karlklose): should we create placeholders for these? 267 // TODO(karlklose): should we create placeholders for these?
268 bool isTypedefParameter(Element element) { 268 bool isTypedefParameter(Element element) {
269 return element != null && 269 return element != null &&
270 element.enclosingElement != null && 270 element.enclosingElement != null &&
271 element.enclosingElement.isTypedef; 271 element.enclosingElement.isTypedef;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 468
469 if (constructorName != null) { 469 if (constructorName != null) {
470 Element definingConstructor = findDefiningConstructor(element); 470 Element definingConstructor = findDefiningConstructor(element);
471 constructorPlaceholders.add(new ConstructorPlaceholder(constructorName, 471 constructorPlaceholders.add(new ConstructorPlaceholder(constructorName,
472 definingConstructor)); 472 definingConstructor));
473 tryMakePrivateIdentifier(constructorName, element); 473 tryMakePrivateIdentifier(constructorName, element);
474 } 474 }
475 } 475 }
476 476
477 void internalError(String reason, {Node node}) { 477 void internalError(String reason, {Node node}) {
478 listener.internalError(node, reason); 478 reporter.internalError(node, reason);
479 } 479 }
480 480
481 visit(Node node) => (node == null) ? null : node.accept(this); 481 visit(Node node) => (node == null) ? null : node.accept(this);
482 482
483 visitNode(Node node) { node.visitChildren(this); } // We must go deeper. 483 visitNode(Node node) { node.visitChildren(this); } // We must go deeper.
484 484
485 visitNewExpression(NewExpression node) { 485 visitNewExpression(NewExpression node) {
486 Send send = node.send; 486 Send send = node.send;
487 DartType type = treeElements.getType(node); 487 DartType type = treeElements.getType(node);
488 assert(type != null); 488 assert(type != null);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 714
715 visitBlock(Block node) { 715 visitBlock(Block node) {
716 for (Node statement in node.statements.nodes) { 716 for (Node statement in node.statements.nodes) {
717 if (statement is VariableDefinitions) { 717 if (statement is VariableDefinitions) {
718 makeVarDeclarationTypePlaceholder(statement); 718 makeVarDeclarationTypePlaceholder(statement);
719 } 719 }
720 } 720 }
721 node.visitChildren(this); 721 node.visitChildren(this);
722 } 722 }
723 } 723 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/outputter.dart ('k') | pkg/compiler/lib/src/dart_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698