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

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

Issue 11034021: [dart2dart] Don't go inside TypeAnnotation.typeName, otherwise in "new lib.A()" expression (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | 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 { 5 class LocalPlaceholder {
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 } 84 }
85 } 85 }
86 86
87 visitStaticSend(Send node) { 87 visitStaticSend(Send node) {
88 final element = elements[node]; 88 final element = elements[node];
89 if (Elements.isUnresolved(element) || element === compiler.assertMethod) { 89 if (Elements.isUnresolved(element) || element === compiler.assertMethod) {
90 return; 90 return;
91 } 91 }
92 if (element.isConstructor() || element.isFactoryConstructor()) { 92 if (element.isConstructor() || element.isFactoryConstructor()) {
93 // Rename named constructor in redirection position:
94 // class C { C.named(); C.redirecting() : this.named(); }
95 if (node.receiver is Identifier
96 && node.receiver.asIdentifier().isThis()) {
97 assert(node.selector is Identifier);
98 collector.tryMakeMemberPlaceholder(node.selector);
99 }
100 // Field names can be exposed as names of optional arguments, e.g. 93 // Field names can be exposed as names of optional arguments, e.g.
101 // class C { 94 // class C {
102 // final field; 95 // final field;
103 // C([this.field]); 96 // C([this.field]);
104 // } 97 // }
105 // Do not forget to rename them as well. 98 // Do not forget to rename them as well.
106 FunctionElement functionElement = element; 99 FunctionElement functionElement = element;
107 Link<Element> optionalParameters = 100 Link<Element> optionalParameters =
108 functionElement.functionSignature.optionalParameters; 101 functionElement.functionSignature.optionalParameters;
109 for (final argument in node.argumentsNode) { 102 for (final argument in node.argumentsNode) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 typeElement === dynamicTypeElement)) { 459 typeElement === dynamicTypeElement)) {
467 makeNullPlaceholder(node.typeName.receiver); 460 makeNullPlaceholder(node.typeName.receiver);
468 } else { 461 } else {
469 if (typeElement !== dynamicTypeElement) { 462 if (typeElement !== dynamicTypeElement) {
470 makeTypePlaceholder(target, type); 463 makeTypePlaceholder(target, type);
471 } else { 464 } else {
472 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target); 465 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target);
473 } 466 }
474 } 467 }
475 } 468 }
476 node.visitChildren(this); 469 // Visit only type arguments, otherwise in case of lib.Class type annotation
470 // typeName is Send and we go to visitGetterSend, as a result "Class" is
471 // added to member placeholders.
472 visit(node.typeArguments);
477 } 473 }
478 474
479 visitVariableDefinitions(VariableDefinitions node) { 475 visitVariableDefinitions(VariableDefinitions node) {
480 // Collect only local placeholders. 476 // Collect only local placeholders.
481 for (Node definition in node.definitions.nodes) { 477 for (Node definition in node.definitions.nodes) {
482 Element definitionElement = treeElements[definition]; 478 Element definitionElement = treeElements[definition];
483 // definitionElement may be null if we're inside variable definitions 479 // definitionElement may be null if we're inside variable definitions
484 // of a function that is a parameter of another function. 480 // of a function that is a parameter of another function.
485 // TODO(smok): Fix this when resolver correctly deals with 481 // TODO(smok): Fix this when resolver correctly deals with
486 // such cases. 482 // such cases.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 if (topmostEnclosingFunction === null) { 519 if (topmostEnclosingFunction === null) {
524 topmostEnclosingFunction = element; 520 topmostEnclosingFunction = element;
525 } 521 }
526 if (element !== currentElement) { 522 if (element !== currentElement) {
527 if (node.name !== null) { 523 if (node.name !== null) {
528 assert(node.name is Identifier); 524 assert(node.name is Identifier);
529 tryMakeLocalPlaceholder(element, node.name); 525 tryMakeLocalPlaceholder(element, node.name);
530 } 526 }
531 } 527 }
532 } 528 }
533 node.visitChildren(this); 529 visit(node.modifiers);
Roman 2012/10/02 14:57:10 I know you don't like calling explicitly visit() f
530 // We don't want to visit Send for function name, it appears as
531 // getter send and we end up renaming constructor as member identifier.
532 if (node.name is Identifier) {
533 visitIdentifier(node.name);
534 }
535 visit(node.returnType);
536 visit(node.parameters);
537 visit(node.initializers);
538 visit(node.body);
534 // Make sure we don't omit return type of methods which names are 539 // Make sure we don't omit return type of methods which names are
535 // identifiers, because the following works fine: 540 // identifiers, because the following works fine:
536 // int interface() => 1; 541 // int interface() => 1;
537 // But omitting 'int' makes VM unhappy. 542 // But omitting 'int' makes VM unhappy.
538 // TODO(smok): Remove it when http://dartbug.com/5278 is fixed. 543 // TODO(smok): Remove it when http://dartbug.com/5278 is fixed.
539 if (node.name === null || !isKeyword(node.name.asIdentifier())) { 544 if (node.name === null || !isKeyword(node.name.asIdentifier())) {
540 makeOmitDeclarationTypePlaceholder(node.returnType); 545 makeOmitDeclarationTypePlaceholder(node.returnType);
541 } 546 }
542 collectFunctionParameters(node.parameters); 547 collectFunctionParameters(node.parameters);
543 } 548 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 613
609 visitBlock(Block node) { 614 visitBlock(Block node) {
610 for (Node statement in node.statements.nodes) { 615 for (Node statement in node.statements.nodes) {
611 if (statement is VariableDefinitions) { 616 if (statement is VariableDefinitions) {
612 makeVarDeclarationTypePlaceholder(statement); 617 makeVarDeclarationTypePlaceholder(statement);
613 } 618 }
614 } 619 }
615 node.visitChildren(this); 620 node.visitChildren(this);
616 } 621 }
617 } 622 }
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