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

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

Issue 10969070: Support Dynamic type with a prefix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | tests/language/import_core_prefix_test.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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 Identifier receiver = send.receiver; 444 Identifier receiver = send.receiver;
445 Identifier selector = send.selector; 445 Identifier selector = send.selector;
446 getConstructor() => 446 getConstructor() =>
447 (element as ClassElement).lookupConstructor( 447 (element as ClassElement).lookupConstructor(
448 receiver.source, selector.source); 448 receiver.source, selector.source);
449 hasPrefix = (element is TypedefElement) || getConstructor() === null; 449 hasPrefix = (element is TypedefElement) || getConstructor() === null;
450 if (!hasPrefix) target = receiver; 450 if (!hasPrefix) target = receiver;
451 } 451 }
452 } 452 }
453 // TODO(antonm): is there a better way to detect unresolved types? 453 // TODO(antonm): is there a better way to detect unresolved types?
454 if (type.element !== compiler.types.dynamicType.element) { 454 // Corner case: dart:core type with a prefix.
455 // Corner case: dart:core type with a prefix. 455 // Most probably there are some additional problems with
456 // Most probably there are some additional problems with 456 // coreLibPrefix.topLevels.
457 // coreLibPrefix.Dynamic and coreLibPrefix.topLevels. 457 Element typeElement = type.element;
458 if (type.element.getLibrary() === coreLibrary && hasPrefix) { 458 Element dynamicTypeElement = compiler.types.dynamicType.element;
459 makeNullPlaceholder(node.typeName.receiver); 459 if (hasPrefix &&
460 (typeElement.getLibrary() === coreLibrary ||
Roman 2012/09/24 15:24:57 if continuation is usually indented by 4 spaces, o
Anton Muhin 2012/09/24 16:00:22 Done.
461 typeElement === dynamicTypeElement)) {
462 makeNullPlaceholder(node.typeName.receiver);
463 } else {
464 if (typeElement !== dynamicTypeElement) {
465 makeTypePlaceholder(target, type);
460 } else { 466 } else {
461 makeTypePlaceholder(target, type); 467 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target);
462 } 468 }
463 } else {
464 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target);
465 } 469 }
466 } 470 }
467 node.visitChildren(this); 471 node.visitChildren(this);
468 } 472 }
469 473
470 visitVariableDefinitions(VariableDefinitions node) { 474 visitVariableDefinitions(VariableDefinitions node) {
471 // Collect only local placeholders. 475 // Collect only local placeholders.
472 for (Node definition in node.definitions.nodes) { 476 for (Node definition in node.definitions.nodes) {
473 Element definitionElement = treeElements[definition]; 477 Element definitionElement = treeElements[definition];
474 // definitionElement may be null if we're inside variable definitions 478 // definitionElement may be null if we're inside variable definitions
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 603
600 visitBlock(Block node) { 604 visitBlock(Block node) {
601 for (Node statement in node.statements.nodes) { 605 for (Node statement in node.statements.nodes) {
602 if (statement is VariableDefinitions) { 606 if (statement is VariableDefinitions) {
603 makeVarDeclarationTypePlaceholder(statement); 607 makeVarDeclarationTypePlaceholder(statement);
604 } 608 }
605 } 609 }
606 node.visitChildren(this); 610 node.visitChildren(this);
607 } 611 }
608 } 612 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/import_core_prefix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698