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

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

Issue 10876011: dart2dart Make sure we never create placeholder for Dynamic type. (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 | no next file » | 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 void makeNullPlaceholder(Node node) { 209 void makeNullPlaceholder(Node node) {
210 assert(node is Identifier || node is Send); 210 assert(node is Identifier || node is Send);
211 nullNodes.add(node); 211 nullNodes.add(node);
212 } 212 }
213 213
214 void makeElementPlaceholder(Node node, Element element) { 214 void makeElementPlaceholder(Node node, Element element) {
215 assert(element !== null); 215 assert(element !== null);
216 if (element === entryFunction) return; 216 if (element === entryFunction) return;
217 if (element.getLibrary() === coreLibrary) return; 217 if (element.getLibrary() === coreLibrary) return;
218 if (element == compiler.types.dynamicType.element) {
219 internalError(
220 'Should never make element placeholder for dynamic type element',
221 node);
222 }
218 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node); 223 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node);
219 } 224 }
220 225
221 void makePrivateIdentifier(Identifier node) { 226 void makePrivateIdentifier(Identifier node) {
222 assert(node !== null); 227 assert(node !== null);
223 privateNodes.putIfAbsent( 228 privateNodes.putIfAbsent(
224 currentElement.getLibrary(), () => new Set<Identifier>()).add(node); 229 currentElement.getLibrary(), () => new Set<Identifier>()).add(node);
225 } 230 }
226 231
227 void makeUnresolvedPlaceholder(Node node) { 232 void makeUnresolvedPlaceholder(Node node) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 final send = node.typeName.asSend(); 321 final send = node.typeName.asSend();
317 Identifier receiver = send.receiver; 322 Identifier receiver = send.receiver;
318 Identifier selector = send.selector; 323 Identifier selector = send.selector;
319 final hasPrefix = element is TypedefElement || 324 final hasPrefix = element is TypedefElement ||
320 element.lookupConstructor(receiver.source, selector.source) 325 element.lookupConstructor(receiver.source, selector.source)
321 === null; 326 === null;
322 if (!hasPrefix) target = send.receiver; 327 if (!hasPrefix) target = send.receiver;
323 } 328 }
324 } 329 }
325 // TODO(antonm): is there a better way to detect unresolved types? 330 // TODO(antonm): is there a better way to detect unresolved types?
326 if (type !== compiler.types.dynamicType) { 331 if (type.element !== compiler.types.dynamicType.element) {
327 makeTypePlaceholder(target, type); 332 makeTypePlaceholder(target, type);
328 } else { 333 } else {
329 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target); 334 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target);
330 } 335 }
331 } 336 }
332 node.visitChildren(this); 337 node.visitChildren(this);
333 } 338 }
334 339
335 visitVariableDefinitions(VariableDefinitions node) { 340 visitVariableDefinitions(VariableDefinitions node) {
336 // Collect only local placeholders. 341 // Collect only local placeholders.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 visit(node.defaultClause.typeArguments); 405 visit(node.defaultClause.typeArguments);
401 } 406 }
402 } 407 }
403 408
404 visitTypedef(Typedef node) { 409 visitTypedef(Typedef node) {
405 assert(currentElement is TypedefElement); 410 assert(currentElement is TypedefElement);
406 makeElementPlaceholder(node.name, currentElement); 411 makeElementPlaceholder(node.name, currentElement);
407 node.visitChildren(this); 412 node.visitChildren(this);
408 } 413 }
409 } 414 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698