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

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

Issue 10855127: Fix the case of function field via this initialization. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/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 SendVisitor extends ResolvedVisitor { 5 class SendVisitor extends ResolvedVisitor {
6 final PlaceholderCollector collector; 6 final PlaceholderCollector collector;
7 7
8 SendVisitor(this.collector, TreeElements elements) : super(elements); 8 SendVisitor(this.collector, TreeElements elements) : super(elements);
9 9
10 visitSuperSend(Send node) {} 10 visitSuperSend(Send node) {}
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 makeTypePlaceholder(nameNode, enclosingClass.type); 85 makeTypePlaceholder(nameNode, enclosingClass.type);
86 } 86 }
87 // Process Ctor(this._field) correctly. 87 // Process Ctor(this._field) correctly.
88 for (Node parameter in node.parameters) { 88 for (Node parameter in node.parameters) {
89 VariableDefinitions definitions = parameter.asVariableDefinitions(); 89 VariableDefinitions definitions = parameter.asVariableDefinitions();
90 if (definitions !== null) { 90 if (definitions !== null) {
91 for (Node definition in definitions.definitions) { 91 for (Node definition in definitions.definitions) {
92 Send send = definition.asSend(); 92 Send send = definition.asSend();
93 if (send !== null) { 93 if (send !== null) {
94 assert(send.receiver.isThis()); 94 assert(send.receiver.isThis());
95 tryMakePrivateIdentifier(send.selector.asIdentifier()); 95 if (send.selector is Identifier) {
96 tryMakePrivateIdentifier(send.selector.asIdentifier());
97 } else if (send.selector is FunctionExpression) {
98 // C(int this.f()) case where f is field of function type.
99 tryMakePrivateIdentifier(
100 send.selector.asFunctionExpression().name.asIdentifier());
101 } else {
102 internalError('Unreachable case');
103 }
96 } else { 104 } else {
97 assert(definition is Identifier); 105 assert(definition is Identifier);
98 } 106 }
99 } 107 }
100 } else { 108 } else {
101 assert(parameter is NodeList); 109 assert(parameter is NodeList);
102 // We don't have to rename privates in optionals. 110 // We don't have to rename privates in optionals.
103 } 111 }
104 } 112 }
105 } else if (element.isTopLevel()) { 113 } else if (element.isTopLevel()) {
(...skipping 13 matching lines...) Expand all
119 127
120 void collectFieldDeclarationPlaceholders(Element element, Node node) { 128 void collectFieldDeclarationPlaceholders(Element element, Node node) {
121 if (element.isInstanceMember()) { 129 if (element.isInstanceMember()) {
122 for (Node definition in node.definitions) { 130 for (Node definition in node.definitions) {
123 if (definition is Identifier) { 131 if (definition is Identifier) {
124 tryMakePrivateIdentifier(definition.asIdentifier()); 132 tryMakePrivateIdentifier(definition.asIdentifier());
125 } else if (definition is SendSet) { 133 } else if (definition is SendSet) {
126 tryMakePrivateIdentifier( 134 tryMakePrivateIdentifier(
127 definition.asSendSet().selector.asIdentifier()); 135 definition.asSendSet().selector.asIdentifier());
128 } else { 136 } else {
129 assert(false); // Unreachable. 137 internalError('Unreachable case');
130 } 138 }
131 } 139 }
132 } 140 }
133 } 141 }
134 142
135 void collect(Element element, TreeElements elements) { 143 void collect(Element element, TreeElements elements) {
136 treeElements = elements; 144 treeElements = elements;
137 Node elementNode; 145 Node elementNode;
138 if (element is FunctionElement) { 146 if (element is FunctionElement) {
139 currentElement = element; 147 currentElement = element;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 274 }
267 // TODO(antonm): is there a better way to detect unresolved types? 275 // TODO(antonm): is there a better way to detect unresolved types?
268 if (type !== compiler.types.dynamicType) { 276 if (type !== compiler.types.dynamicType) {
269 makeTypePlaceholder(target, type); 277 makeTypePlaceholder(target, type);
270 } else { 278 } else {
271 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target); 279 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target);
272 } 280 }
273 node.visitChildren(this); 281 node.visitChildren(this);
274 } 282 }
275 } 283 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698