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

Side by Side Diff: tests/compiler/dart2js/mock_compiler.dart

Issue 10834061: Resolve typedefs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated scope handling and type resolution 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
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 #library('mock_compiler'); 5 #library('mock_compiler');
6 6
7 #import("dart:uri"); 7 #import("dart:uri");
8 8
9 #import("../../../lib/compiler/implementation/elements/elements.dart"); 9 #import("../../../lib/compiler/implementation/elements/elements.dart");
10 #import("../../../lib/compiler/implementation/leg.dart"); 10 #import("../../../lib/compiler/implementation/leg.dart");
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 errors = []; 117 errors = [];
118 } 118 }
119 119
120 TreeElementMapping resolveStatement(String text) { 120 TreeElementMapping resolveStatement(String text) {
121 parsedTree = parseStatement(text); 121 parsedTree = parseStatement(text);
122 return resolveNodeStatement(parsedTree, mainApp); 122 return resolveNodeStatement(parsedTree, mainApp);
123 } 123 }
124 124
125 TreeElementMapping resolveNodeStatement(Node tree, Element element) { 125 TreeElementMapping resolveNodeStatement(Node tree, Element element) {
126 ResolverVisitor visitor = new ResolverVisitor(this, element); 126 ResolverVisitor visitor = new ResolverVisitor(this, element);
127 if (visitor.context is TopScope) { 127 if (visitor.scope is TopScope) {
128 visitor.context = new BlockScope(visitor.context); 128 visitor.scope = new BlockScope(visitor.scope);
129 } 129 }
130 visitor.visit(tree); 130 visitor.visit(tree);
131 visitor.context = new TopScope(element.getLibrary()); 131 visitor.scope = new TopScope(element.getLibrary());
132 // Resolve the type annotations encountered in the code. 132 // Resolve the type annotations encountered in the code.
133 while (!resolver.toResolve.isEmpty()) { 133 while (!resolver.toResolve.isEmpty()) {
134 resolver.toResolve.removeFirst().ensureResolved(this); 134 resolver.toResolve.removeFirst().ensureResolved(this);
135 } 135 }
136 return visitor.mapping; 136 return visitor.mapping;
137 } 137 }
138 138
139 resolverVisitor() { 139 resolverVisitor() {
140 Element mockElement = 140 Element mockElement =
141 new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp); 141 new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp);
142 ResolverVisitor visitor = new ResolverVisitor(this, mockElement); 142 ResolverVisitor visitor = new ResolverVisitor(this, mockElement);
143 visitor.context = new BlockScope(visitor.context); 143 visitor.scope = new BlockScope(visitor.scope);
144 return visitor; 144 return visitor;
145 } 145 }
146 146
147 parseScript(String text, [LibraryElement library]) { 147 parseScript(String text, [LibraryElement library]) {
148 if (library === null) library = mainApp; 148 if (library === null) library = mainApp;
149 parseUnit(text, this, library); 149 parseUnit(text, this, library);
150 } 150 }
151 151
152 void scanBuiltinLibraries() { 152 void scanBuiltinLibraries() {
153 // Do nothing. The mock core library is already handled in the constructor. 153 // Do nothing. The mock core library is already handled in the constructor.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 }); 197 });
198 } 198 }
199 } 199 }
200 200
201 LibraryElement mockLibrary(Compiler compiler, String source) { 201 LibraryElement mockLibrary(Compiler compiler, String source) {
202 Uri uri = new Uri(scheme: "source"); 202 Uri uri = new Uri(scheme: "source");
203 var library = new LibraryElement(new Script(uri, new MockFile(source))); 203 var library = new LibraryElement(new Script(uri, new MockFile(source)));
204 importLibrary(library, compiler.coreLibrary, compiler); 204 importLibrary(library, compiler.coreLibrary, compiler);
205 return library; 205 return library;
206 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698