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

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

Issue 10966044: Properly process dart:core classes if dart:core is imported with 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 | « lib/compiler/implementation/dart_backend/backend.dart ('k') | tests/language/language.status » ('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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 typeDeclarationElement = currentElement.getEnclosingClass(); 428 typeDeclarationElement = currentElement.getEnclosingClass();
429 } 429 }
430 if (typeDeclarationElement !== null && isPlainTypeName(node) 430 if (typeDeclarationElement !== null && isPlainTypeName(node)
431 && tryResolveAndCollectTypeVariable( 431 && tryResolveAndCollectTypeVariable(
432 typeDeclarationElement, node.typeName)) { 432 typeDeclarationElement, node.typeName)) {
433 return; 433 return;
434 } 434 }
435 // We call [resolveReturnType] to allow having 'void'. 435 // We call [resolveReturnType] to allow having 'void'.
436 final type = compiler.resolveReturnType(currentElement, node); 436 final type = compiler.resolveReturnType(currentElement, node);
437 if (type is InterfaceType || type is TypedefType) { 437 if (type is InterfaceType || type is TypedefType) {
438 var target = node.typeName; 438 Node target = node.typeName;
439 bool hasPrefix = false;
439 if (node.typeName is Send) { 440 if (node.typeName is Send) {
440 final element = treeElements[node]; 441 final element = treeElements[node];
441 if (element !== null) { 442 if (element !== null) {
442 final send = node.typeName.asSend(); 443 final send = node.typeName.asSend();
443 Identifier receiver = send.receiver; 444 Identifier receiver = send.receiver;
444 Identifier selector = send.selector; 445 Identifier selector = send.selector;
445 hasPrefix() { 446 getConstructor() =>
446 if (element is TypedefElement) return true; 447 (element as ClassElement).lookupConstructor(
447 ClassElement classElement = element; 448 receiver.source, selector.source);
448 final constructor = classElement.lookupConstructor( 449 hasPrefix = (element is TypedefElement) || getConstructor() === null;
449 receiver.source, selector.source); 450 if (!hasPrefix) target = receiver;
450 return constructor === null;
451 }
452 if (!hasPrefix()) target = send.receiver;
453 } 451 }
454 } 452 }
455 // TODO(antonm): is there a better way to detect unresolved types? 453 // TODO(antonm): is there a better way to detect unresolved types?
456 if (type.element !== compiler.types.dynamicType.element) { 454 if (type.element !== compiler.types.dynamicType.element) {
Roman 2012/09/24 09:32:53 please add a comment about mycore.Dynamic, mycore.
Anton Muhin 2012/09/24 10:09:37 Done.
457 makeTypePlaceholder(target, type); 455 // Corner case: dart:core type with a prefix.
456 if (type.element.getLibrary() === coreLibrary && hasPrefix) {
457 makeNullPlaceholder(node.typeName.receiver);
458 } else {
459 makeTypePlaceholder(target, type);
460 }
458 } else { 461 } else {
459 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target); 462 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target);
460 } 463 }
461 } 464 }
462 node.visitChildren(this); 465 node.visitChildren(this);
463 } 466 }
464 467
465 visitVariableDefinitions(VariableDefinitions node) { 468 visitVariableDefinitions(VariableDefinitions node) {
466 // Collect only local placeholders. 469 // Collect only local placeholders.
467 for (Node definition in node.definitions.nodes) { 470 for (Node definition in node.definitions.nodes) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 597
595 visitBlock(Block node) { 598 visitBlock(Block node) {
596 for (Node statement in node.statements.nodes) { 599 for (Node statement in node.statements.nodes) {
597 if (statement is VariableDefinitions) { 600 if (statement is VariableDefinitions) {
598 makeVarDeclarationTypePlaceholder(statement); 601 makeVarDeclarationTypePlaceholder(statement);
599 } 602 }
600 } 603 }
601 node.visitChildren(this); 604 node.visitChildren(this);
602 } 605 }
603 } 606 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart_backend/backend.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698