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

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

Issue 10854158: Make selector registration in the resolver and code generator more explicit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 TreeElementMapping resolveStatement(String text) { 130 TreeElementMapping resolveStatement(String text) {
131 parsedTree = parseStatement(text); 131 parsedTree = parseStatement(text);
132 return resolveNodeStatement(parsedTree, mainApp); 132 return resolveNodeStatement(parsedTree, mainApp);
133 } 133 }
134 134
135 TreeElementMapping resolveNodeStatement(Node tree, Element element) { 135 TreeElementMapping resolveNodeStatement(Node tree, Element element) {
136 ResolverVisitor visitor = new ResolverVisitor(this, element); 136 ResolverVisitor visitor = new ResolverVisitor(this, element);
137 if (visitor.scope is TopScope) { 137 if (visitor.scope is TopScope) {
138 visitor.scope = new BlockScope(visitor.scope); 138 visitor.scope = new MethodScope(visitor.scope, element);
139 } 139 }
140 visitor.visit(tree); 140 visitor.visit(tree);
141 visitor.scope = new TopScope(element.getLibrary()); 141 visitor.scope = new TopScope(element.getLibrary());
142 return visitor.mapping; 142 return visitor.mapping;
143 } 143 }
144 144
145 resolverVisitor() { 145 resolverVisitor() {
146 Element mockElement = 146 Element mockElement =
147 new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp); 147 new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp);
148 ResolverVisitor visitor = new ResolverVisitor(this, mockElement); 148 ResolverVisitor visitor = new ResolverVisitor(this, mockElement);
149 visitor.scope = new BlockScope(visitor.scope); 149 visitor.scope = new MethodScope(visitor.scope, mockElement);
150 return visitor; 150 return visitor;
151 } 151 }
152 152
153 parseScript(String text, [LibraryElement library]) { 153 parseScript(String text, [LibraryElement library]) {
154 if (library === null) library = mainApp; 154 if (library === null) library = mainApp;
155 parseUnit(text, this, library); 155 parseUnit(text, this, library);
156 } 156 }
157 157
158 void scanBuiltinLibraries() { 158 void scanBuiltinLibraries() {
159 // Do nothing. The mock core library is already handled in the constructor. 159 // Do nothing. The mock core library is already handled in the constructor.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 }); 202 });
203 } 203 }
204 } 204 }
205 205
206 LibraryElement mockLibrary(Compiler compiler, String source) { 206 LibraryElement mockLibrary(Compiler compiler, String source) {
207 Uri uri = new Uri.fromComponents(scheme: "source"); 207 Uri uri = new Uri.fromComponents(scheme: "source");
208 var library = new LibraryElement(new Script(uri, new MockFile(source))); 208 var library = new LibraryElement(new Script(uri, new MockFile(source)));
209 importLibrary(library, compiler.coreLibrary, compiler); 209 importLibrary(library, compiler.coreLibrary, compiler);
210 return library; 210 return library;
211 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698