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

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

Issue 1414913002: Introduce .isMalformed (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address review 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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Example: A.f() or f() with 'f' bound to a static function. 90 // Example: A.f() or f() with 'f' bound to a static function.
91 // Also includes new A() or new A.named() which is treated like a 91 // Also includes new A() or new A.named() which is treated like a
92 // static call to a factory. 92 // static call to a factory.
93 visitStaticSend(node); 93 visitStaticSend(node);
94 } 94 }
95 } 95 }
96 } 96 }
97 97
98 visitDynamicSend(Send node) { 98 visitDynamicSend(Send node) {
99 final element = elements[node]; 99 final element = elements[node];
100 if (element == null || !element.isErroneous) { 100 if (element == null || !element.isMalformed) {
101 collector.tryMakeMemberPlaceholder(node.selector); 101 collector.tryMakeMemberPlaceholder(node.selector);
102 } 102 }
103 } 103 }
104 104
105 visitGetterSend(Send node) { 105 visitGetterSend(Send node) {
106 final element = elements[node]; 106 final element = elements[node];
107 // element == null means dynamic property access. 107 // element == null means dynamic property access.
108 if (element == null) { 108 if (element == null) {
109 collector.tryMakeMemberPlaceholder(node.selector); 109 collector.tryMakeMemberPlaceholder(node.selector);
110 } else if (element.isErroneous) { 110 } else if (element.isMalformed) {
111 collector.makeUnresolvedPlaceholder(node); 111 collector.makeUnresolvedPlaceholder(node);
112 return; 112 return;
113 } else if (element.isPrefix) { 113 } else if (element.isPrefix) {
114 // Node is prefix part in case of source 'lib.somesetter = 5;' 114 // Node is prefix part in case of source 'lib.somesetter = 5;'
115 collector.makeErasePrefixPlaceholder(node); 115 collector.makeErasePrefixPlaceholder(node);
116 } else if (Elements.isStaticOrTopLevel(element)) { 116 } else if (Elements.isStaticOrTopLevel(element)) {
117 // Unqualified or prefixed top level or static. 117 // Unqualified or prefixed top level or static.
118 collector.makeElementPlaceholder(node.selector, element); 118 collector.makeElementPlaceholder(node.selector, element);
119 } else if (!element.isTopLevel) { 119 } else if (!element.isTopLevel) {
120 if (element.isInstanceMember) { 120 if (element.isInstanceMember) {
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
489 Element constructor = treeElements[send]; 489 Element constructor = treeElements[send];
490 assert(constructor != null); 490 assert(constructor != null);
491 assert(send.receiver == null); 491 assert(send.receiver == null);
492 if (!Elements.isErroneous(constructor)) { 492 if (!Elements.isMalformed(constructor)) {
493 tryMakeConstructorPlaceholder(node.send.selector, constructor); 493 tryMakeConstructorPlaceholder(node.send.selector, constructor);
494 // TODO(smok): Should this be in visitNamedArgument? 494 // TODO(smok): Should this be in visitNamedArgument?
495 // Field names can be exposed as names of optional arguments, e.g. 495 // Field names can be exposed as names of optional arguments, e.g.
496 // class C { 496 // class C {
497 // final field; 497 // final field;
498 // C([this.field]); 498 // C([this.field]);
499 // } 499 // }
500 // Do not forget to rename them as well. 500 // Do not forget to rename them as well.
501 FunctionElement constructorFunction = constructor; 501 FunctionElement constructorFunction = constructor;
502 List<Element> optionalParameters = 502 List<Element> optionalParameters =
(...skipping 20 matching lines...) Expand all
523 523
524 visitSend(Send send) { 524 visitSend(Send send) {
525 Element element = treeElements[send]; 525 Element element = treeElements[send];
526 tryMakePrivateIdentifier(send.selector, element); 526 tryMakePrivateIdentifier(send.selector, element);
527 new SendVisitor(this, treeElements).visitSend(send); 527 new SendVisitor(this, treeElements).visitSend(send);
528 send.visitChildren(this); 528 send.visitChildren(this);
529 } 529 }
530 530
531 visitSendSet(SendSet send) { 531 visitSendSet(SendSet send) {
532 Element element = treeElements[send]; 532 Element element = treeElements[send];
533 if (Elements.isErroneous(element)) { 533 if (Elements.isMalformed(element)) {
534 // Complicated case: constructs like receiver.selector++ can resolve 534 // Complicated case: constructs like receiver.selector++ can resolve
535 // to ErroneousElement. Fortunately, receiver.selector still 535 // to ErroneousElement. Fortunately, receiver.selector still
536 // can be resoved via treeElements[send.selector], that's all 536 // can be resoved via treeElements[send.selector], that's all
537 // that is needed to rename the construct properly. 537 // that is needed to rename the construct properly.
538 element = treeElements[send.selector]; 538 element = treeElements[send.selector];
539 } 539 }
540 tryMakePrivateIdentifier(send.selector, element); 540 tryMakePrivateIdentifier(send.selector, element);
541 if (element == null) { 541 if (element == null) {
542 if (send.receiver != null) tryMakeMemberPlaceholder(send.selector); 542 if (send.receiver != null) tryMakeMemberPlaceholder(send.selector);
543 } else if (!element.isErroneous) { 543 } else if (!element.isMalformed) {
544 if (Elements.isStaticOrTopLevel(element)) { 544 if (Elements.isStaticOrTopLevel(element)) {
545 // TODO(smok): Worth investigating why sometimes we get getter/setter 545 // TODO(smok): Worth investigating why sometimes we get getter/setter
546 // here and sometimes abstract field. 546 // here and sometimes abstract field.
547 assert(element.isClass || element is VariableElement || 547 assert(element.isClass || element is VariableElement ||
548 element.isAccessor || element.isAbstractField || 548 element.isAccessor || element.isAbstractField ||
549 element.isFunction || element.isTypedef || 549 element.isFunction || element.isTypedef ||
550 element is TypeVariableElement); 550 element is TypeVariableElement);
551 makeElementPlaceholder(send.selector, element); 551 makeElementPlaceholder(send.selector, element);
552 } else { 552 } else {
553 Identifier identifier = send.selector.asIdentifier(); 553 Identifier identifier = send.selector.asIdentifier();
(...skipping 160 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/cps_ir/cps_ir_builder.dart ('k') | pkg/compiler/lib/src/dart_backend/renamer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698