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

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

Issue 10830359: dart2dart Fix collecting type of class fields (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 DartBackend extends Backend { 5 class DartBackend extends Backend {
6 final List<CompilerTask> tasks; 6 final List<CompilerTask> tasks;
7 final UnparseValidator unparseValidator; 7 final UnparseValidator unparseValidator;
8 8
9 Map<Element, TreeElements> get resolvedElements() => 9 Map<Element, TreeElements> get resolvedElements() =>
10 compiler.enqueuer.resolution.resolvedElements; 10 compiler.enqueuer.resolution.resolvedElements;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 */ 138 */
139 class ReferencedElementCollector extends AbstractVisitor { 139 class ReferencedElementCollector extends AbstractVisitor {
140 final Compiler compiler; 140 final Compiler compiler;
141 final Element rootElement; 141 final Element rootElement;
142 final TreeElements treeElements; 142 final TreeElements treeElements;
143 final newTypedefElementCallback; 143 final newTypedefElementCallback;
144 final newClassElementCallback; 144 final newClassElementCallback;
145 145
146 ReferencedElementCollector( 146 ReferencedElementCollector(
147 this.compiler, 147 this.compiler,
148 this.rootElement, this.treeElements, 148 Element rootElement, this.treeElements,
149 this.newTypedefElementCallback, this.newClassElementCallback); 149 this.newTypedefElementCallback, this.newClassElementCallback)
150 : this.rootElement = (rootElement is VariableElement)
151 ? (rootElement as VariableElement).variables : rootElement;
150 152
151 visitClassNode(ClassNode node) { 153 visitClassNode(ClassNode node) {
152 super.visitClassNode(node); 154 super.visitClassNode(node);
153 // Temporary hack which should go away once interfaces 155 // Temporary hack which should go away once interfaces
154 // and default clauses are out. 156 // and default clauses are out.
155 if (node.defaultClause !== null) { 157 if (node.defaultClause !== null) {
156 // Resolver cannot resolve parameterized default clauses. 158 // Resolver cannot resolve parameterized default clauses.
157 TypeAnnotation evilCousine = new TypeAnnotation( 159 TypeAnnotation evilCousine = new TypeAnnotation(
158 node.defaultClause.typeName, null); 160 node.defaultClause.typeName, null);
159 evilCousine.accept(this); 161 evilCousine.accept(this);
160 } 162 }
161 } 163 }
162 164
163 visitNode(Node node) { node.visitChildren(this); } 165 visitNode(Node node) { node.visitChildren(this); }
164 166
165 visitTypeAnnotation(TypeAnnotation typeAnnotation) { 167 visitTypeAnnotation(TypeAnnotation typeAnnotation) {
166 final type = compiler.resolveTypeAnnotation(rootElement, typeAnnotation); 168 final type = compiler.resolveTypeAnnotation(rootElement, typeAnnotation);
167 Element typeElement = type.element; 169 Element typeElement = type.element;
168 if (typeElement.isTypedef()) newTypedefElementCallback(typeElement); 170 if (typeElement.isTypedef()) newTypedefElementCallback(typeElement);
169 if (typeElement.isClass()) newClassElementCallback(typeElement); 171 if (typeElement.isClass()) newClassElementCallback(typeElement);
170 typeAnnotation.visitChildren(this); 172 typeAnnotation.visitChildren(this);
171 } 173 }
172 174
173 void collect() { 175 void collect() {
174 compiler.withCurrentElement(rootElement, () { 176 compiler.withCurrentElement(rootElement, () {
175 rootElement.parseNode(compiler).accept(this); 177 rootElement.parseNode(compiler).accept(this);
176 }); 178 });
177 } 179 }
178 } 180 }
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