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

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

Issue 10828390: dart2dart Fix factory for interfaces renames (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/compiler/dart2js/unparser_test.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 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // 1.dart: interface C default p0.C { C(); } 120 // 1.dart: interface C default p0.C { C(); }
121 // the second case is just a bug now. 121 // the second case is just a bug now.
122 final enclosingClass = element.getEnclosingClass(); 122 final enclosingClass = element.getEnclosingClass();
123 Node nameNode = node.name; 123 Node nameNode = node.name;
124 if (nameNode is Send) nameNode = nameNode.receiver; 124 if (nameNode is Send) nameNode = nameNode.receiver;
125 // For cases like class C implements I { I(); } 125 // For cases like class C implements I { I(); }
126 if (nameNode.asIdentifier().token.slowToString() 126 if (nameNode.asIdentifier().token.slowToString()
127 == enclosingClass.name.slowToString()) { 127 == enclosingClass.name.slowToString()) {
128 makeTypePlaceholder(nameNode, enclosingClass.type); 128 makeTypePlaceholder(nameNode, enclosingClass.type);
129 } 129 }
130
131 // If we have interface constructor, make sure that we put placeholder
132 // for its default factory implementation.
133 // Example:
134 // interface I { I();}
Anton Muhin 2012/08/21 09:06:35 interface I default C ?
Roman 2012/08/21 09:18:40 Done.
135 // class C { I() {} }
136 if (element.defaultImplementation !== null
137 && element.defaultImplementation !== element) {
Anton Muhin 2012/08/21 09:06:35 what this check does?
Roman 2012/08/21 09:18:40 Here we are processing interface constructor: inte
138 FunctionElement implementingFactory = element.defaultImplementation;
139 Node factoryName = implementingFactory.cachedNode.name;
140 if (factoryName is Identifier) {
141 // Plain interface name. Rename it unless it is the default
142 // constructor for enclosing class.
143 // Example:
144 // interface I { I(); }
Anton Muhin 2012/08/21 09:06:35 again, I default C?
Roman 2012/08/21 09:18:40 Actually, here not necessary default.
145 // class C implements I { C(); } don't rename this case.
146 if (factoryName.token.slowToString()
Anton Muhin 2012/08/20 18:43:34 SourceString's are comparable
Anton Muhin 2012/08/20 18:43:34 why do you need a check here? maybe just drop if
Roman 2012/08/21 08:31:20 The comment above is actually incorrect, that if i
Roman 2012/08/21 08:31:20 Done.
147 != implementingFactory.getEnclosingClass().name.slowToString()) {
Anton Muhin 2012/08/21 09:06:35 it might be more straightforward to compare for eq
Roman 2012/08/21 09:18:40 I changed that to factoryName.token == implementin
148 makeElementPlaceholder(factoryName, enclosingClass);
149 }
150 } else {
151 // I.named() inside C, rename first part.
152 assert(factoryName is Send);
153 makeElementPlaceholder((factoryName as Send).receiver, enclosingClass) ;
Anton Muhin 2012/08/20 18:43:34 nit: factoryName.asSend()
Anton Muhin 2012/08/20 18:43:34 nit: line too long
Roman 2012/08/21 08:31:20 Done.
Roman 2012/08/21 08:31:20 Done.
154 }
155 }
156
130 // Process Ctor(this._field) correctly. 157 // Process Ctor(this._field) correctly.
131 for (Node parameter in node.parameters) { 158 for (Node parameter in node.parameters) {
132 VariableDefinitions definitions = parameter.asVariableDefinitions(); 159 VariableDefinitions definitions = parameter.asVariableDefinitions();
133 if (definitions !== null) { 160 if (definitions !== null) {
134 for (Node definition in definitions.definitions) { 161 for (Node definition in definitions.definitions) {
135 Send send = definition.asSend(); 162 Send send = definition.asSend();
136 if (send !== null) { 163 if (send !== null) {
137 assert(send.receiver is Identifier); 164 assert(send.receiver is Identifier);
138 assert(send.receiver.asIdentifier().isThis()); 165 assert(send.receiver.asIdentifier().isThis());
139 if (send.selector is Identifier) { 166 if (send.selector is Identifier) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 visit(node.defaultClause.typeArguments); 450 visit(node.defaultClause.typeArguments);
424 } 451 }
425 } 452 }
426 453
427 visitTypedef(Typedef node) { 454 visitTypedef(Typedef node) {
428 assert(currentElement is TypedefElement); 455 assert(currentElement is TypedefElement);
429 makeElementPlaceholder(node.name, currentElement); 456 makeElementPlaceholder(node.name, currentElement);
430 node.visitChildren(this); 457 node.visitChildren(this);
431 } 458 }
432 } 459 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698