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

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

Issue 1083633002: Copy OldResolver dispatch logic to SendVisitor and remove OldResolver. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | pkg/compiler/lib/src/resolved_visitor.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 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 19 matching lines...) Expand all
30 30
31 ConstructorPlaceholder(this.node, this.element); 31 ConstructorPlaceholder(this.node, this.element);
32 } 32 }
33 33
34 class DeclarationTypePlaceholder { 34 class DeclarationTypePlaceholder {
35 final TypeAnnotation typeNode; 35 final TypeAnnotation typeNode;
36 final bool requiresVar; 36 final bool requiresVar;
37 DeclarationTypePlaceholder(this.typeNode, this.requiresVar); 37 DeclarationTypePlaceholder(this.typeNode, this.requiresVar);
38 } 38 }
39 39
40 class SendVisitor extends OldResolvedVisitor { 40 class SendVisitor extends Visitor {
41 final TreeElements elements;
41 final PlaceholderCollector collector; 42 final PlaceholderCollector collector;
42 43
43 SendVisitor(this.collector, TreeElements elements) 44 SendVisitor(this.collector, this.elements);
44 : super(elements);
45 45
46 visitOperatorSend(Send node) { 46 visitSend(Send node) {
47 }
48
49 visitForeignSend(Send node) {}
50
51 visitSuperSend(Send node) {
52 Element element = elements[node]; 47 Element element = elements[node];
53 if (element != null && element.isConstructor) { 48 if (elements.isAssert(node)) {
54 collector.tryMakeConstructorPlaceholder(node, element); 49 return;
50 } else if (elements.isTypeLiteral(node)) {
51 DartType type = elements.getTypeLiteralType(node);
52 if (!type.isDynamic) {
53 if (type is TypeVariableType) {
54 collector.makeTypeVariablePlaceholder(node.selector, type);
55 } else {
56 collector.makeTypePlaceholder(node.selector, type);
57 }
58 }
59 } else if (node.isSuperCall) {
60 if (element != null && element.isConstructor) {
61 collector.tryMakeConstructorPlaceholder(node, element);
62 } else {
63 collector.tryMakeMemberPlaceholder(node.selector);
64 }
65 } else if (node.isOperator) {
66 return;
67 } else if (node.isPropertyAccess) {
68 if (!Elements.isUnresolved(element) && element.impliesType) {
69 collector.makeElementPlaceholder(node, element);
70 } else {
71 visitGetterSend(node);
72 }
73 } else if (element != null && Initializers.isConstructorRedirect(node)) {
74 visitStaticSend(node);
75 } else if (Elements.isClosureSend(node, element)) {
76 if (element != null) {
77 collector.tryMakeLocalPlaceholder(element, node.selector);
78 }
55 } else { 79 } else {
56 collector.tryMakeMemberPlaceholder(node.selector); 80 if (Elements.isUnresolved(element)) {
81 if (element == null) {
82 // Example: f() with 'f' unbound.
83 // This can only happen inside an instance method.
84 visitDynamicSend(node);
85 } else {
86 visitStaticSend(node);
87 }
88 } else if (element.isInstanceMember) {
89 // Example: f() with 'f' bound to instance method.
90 visitDynamicSend(node);
91 } else if (!element.isInstanceMember) {
92 // Example: A.f() or f() with 'f' bound to a static function.
93 // Also includes new A() or new A.named() which is treated like a
94 // static call to a factory.
95 visitStaticSend(node);
96 }
57 } 97 }
58 } 98 }
59 99
60 visitDynamicSend(Send node) { 100 visitDynamicSend(Send node) {
61 final element = elements[node]; 101 final element = elements[node];
62 if (element == null || !element.isErroneous) { 102 if (element == null || !element.isErroneous) {
63 collector.tryMakeMemberPlaceholder(node.selector); 103 collector.tryMakeMemberPlaceholder(node.selector);
64 } 104 }
65 } 105 }
66 106
67 visitClosureSend(Send node) {
68 final element = elements[node];
69 if (element != null) {
70 collector.tryMakeLocalPlaceholder(element, node.selector);
71 }
72 }
73
74 visitGetterSend(Send node) { 107 visitGetterSend(Send node) {
75 final element = elements[node]; 108 final element = elements[node];
76 // element == null means dynamic property access. 109 // element == null means dynamic property access.
77 if (element == null) { 110 if (element == null) {
78 collector.tryMakeMemberPlaceholder(node.selector); 111 collector.tryMakeMemberPlaceholder(node.selector);
79 } else if (element.isErroneous) { 112 } else if (element.isErroneous) {
80 collector.makeUnresolvedPlaceholder(node); 113 collector.makeUnresolvedPlaceholder(node);
81 return; 114 return;
82 } else if (element.isPrefix) { 115 } else if (element.isPrefix) {
83 // Node is prefix part in case of source 'lib.somesetter = 5;' 116 // Node is prefix part in case of source 'lib.somesetter = 5;'
84 collector.makeErasePrefixPlaceholder(node); 117 collector.makeErasePrefixPlaceholder(node);
85 } else if (Elements.isStaticOrTopLevel(element)) { 118 } else if (Elements.isStaticOrTopLevel(element)) {
86 // Unqualified or prefixed top level or static. 119 // Unqualified or prefixed top level or static.
87 collector.makeElementPlaceholder(node.selector, element); 120 collector.makeElementPlaceholder(node.selector, element);
88 } else if (!element.isTopLevel) { 121 } else if (!element.isTopLevel) {
89 if (element.isInstanceMember) { 122 if (element.isInstanceMember) {
90 collector.tryMakeMemberPlaceholder(node.selector); 123 collector.tryMakeMemberPlaceholder(node.selector);
91 } else { 124 } else {
92 // May get FunctionExpression here in selector 125 // May get FunctionExpression here in selector
93 // in case of A(int this.f()); 126 // in case of A(int this.f());
94 if (node.selector is Identifier) { 127 if (node.selector is Identifier) {
95 collector.tryMakeLocalPlaceholder(element, node.selector); 128 collector.tryMakeLocalPlaceholder(element, node.selector);
96 } else { 129 } else {
97 assert(node.selector is FunctionExpression); 130 assert(node.selector is FunctionExpression);
98 } 131 }
99 } 132 }
100 } 133 }
101 } 134 }
102 135
103 visitAssertSend(node) {
104 visitStaticSend(node);
105 }
106
107 visitStaticSend(Send node) { 136 visitStaticSend(Send node) {
108 Element element = elements[node]; 137 Element element = elements[node];
109 collector.mirrorRenamer.registerStaticSend( 138 collector.mirrorRenamer.registerStaticSend(
110 collector.currentElement, element, node); 139 collector.currentElement, element, node);
111 140
112 if (Elements.isUnresolved(element) 141 if (Elements.isUnresolved(element)
113 || elements.isAssert(node) 142 || elements.isAssert(node)
114 || element.isDeferredLoaderGetter) { 143 || element.isDeferredLoaderGetter) {
115 return; 144 return;
116 } 145 }
(...skipping 14 matching lines...) Expand all
131 assert(elements[node.receiver].isPrefix); 160 assert(elements[node.receiver].isPrefix);
132 // Hack: putting null into map overrides receiver of original node. 161 // Hack: putting null into map overrides receiver of original node.
133 collector.makeErasePrefixPlaceholder(node.receiver); 162 collector.makeErasePrefixPlaceholder(node.receiver);
134 } 163 }
135 } 164 }
136 165
137 internalError(Spannable node, String reason) { 166 internalError(Spannable node, String reason) {
138 collector.internalError(reason, node: node); 167 collector.internalError(reason, node: node);
139 } 168 }
140 169
141 visitTypePrefixSend(Send node) { 170 visitNode(Node node) {
142 collector.makeElementPlaceholder(node, elements[node]); 171 internalError(node, "Unhandled node");
143 }
144
145 visitTypeLiteralSend(Send node) {
146 DartType type = elements.getTypeLiteralType(node);
147 if (!type.isDynamic) {
148 if (type is TypeVariableType) {
149 collector.makeTypeVariablePlaceholder(node.selector, type);
150 } else {
151 collector.makeTypePlaceholder(node.selector, type);
152 }
153 }
154 } 172 }
155 } 173 }
156 174
157 class PlaceholderCollector extends Visitor { 175 class PlaceholderCollector extends Visitor {
158 final DiagnosticListener listener; 176 final DiagnosticListener listener;
159 final MirrorRenamer mirrorRenamer; 177 final MirrorRenamer mirrorRenamer;
160 final FunctionElement mainFunction; 178 final FunctionElement mainFunction;
161 final Set<String> fixedMemberNames; // member names which cannot be renamed. 179 final Set<String> fixedMemberNames; // member names which cannot be renamed.
162 final Map<Element, ElementAst> elementAsts; 180 final Map<Element, ElementAst> elementAsts;
163 final Set<Node> prefixNodesToErase = new Set<Node>(); 181 final Set<Node> prefixNodesToErase = new Set<Node>();
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 718
701 visitBlock(Block node) { 719 visitBlock(Block node) {
702 for (Node statement in node.statements.nodes) { 720 for (Node statement in node.statements.nodes) {
703 if (statement is VariableDefinitions) { 721 if (statement is VariableDefinitions) {
704 makeVarDeclarationTypePlaceholder(statement); 722 makeVarDeclarationTypePlaceholder(statement);
705 } 723 }
706 } 724 }
707 node.visitChildren(this); 725 node.visitChildren(this);
708 } 726 }
709 } 727 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolved_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698