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

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

Issue 12047041: Testable patch parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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 '../../../sdk/lib/_internal/compiler/compiler.dart' as api; 9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
10 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t'; 10 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t';
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 */ 164 */
165 void registerSource(Uri uri, String source) { 165 void registerSource(Uri uri, String source) {
166 sourceFiles[uri.toString()] = new MockFile(source); 166 sourceFiles[uri.toString()] = new MockFile(source);
167 } 167 }
168 168
169 /** 169 /**
170 * Used internally to create a library from a source text. The created library 170 * Used internally to create a library from a source text. The created library
171 * is fixed to export its top-level declarations. 171 * is fixed to export its top-level declarations.
172 */ 172 */
173 LibraryElement createLibrary(String name, String source) { 173 LibraryElement createLibrary(String name, String source) {
174 Uri uri = new Uri.fromComponents(scheme: "source", path: name); 174 var library = createUnparsedLibrary(name, source);
175 var script = new Script(uri, new MockFile(source));
176 var library = new LibraryElementX(script);
177 parseScript(source, library); 175 parseScript(source, library);
178 library.setExports(library.localScope.values.toList()); 176 library.setExports(library.localScope.values.toList());
179 return library; 177 return library;
180 } 178 }
181 179
180 LibraryElement createUnparsedLibrary(String name, String source) {
181 Uri uri = new Uri.fromComponents(scheme: "source", path: name);
182 var script = new Script(uri, new MockFile(source));
183 return new LibraryElementX(script);
184 }
185
182 void reportWarning(Node node, var message) { 186 void reportWarning(Node node, var message) {
183 warnings.add(new WarningMessage(node, message.message)); 187 warnings.add(new WarningMessage(node, message.message));
184 } 188 }
185 189
186 void reportError(Node node, var message) { 190 void reportError(Node node, var message) {
187 if (message is String && message.startsWith("no library name found in")) { 191 if (message is String && message.startsWith("no library name found in")) {
188 // TODO(ahe): Fix the MockCompiler to not have this problem. 192 // TODO(ahe): Fix the MockCompiler to not have this problem.
189 return; 193 return;
190 } 194 }
191 errors.add(new WarningMessage(node, message.message)); 195 errors.add(new WarningMessage(node, message.message));
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 operator []=(Node node, Element element) { 325 operator []=(Node node, Element element) {
322 map[node] = element; 326 map[node] = element;
323 } 327 }
324 328
325 operator [](Node node) => map[node]; 329 operator [](Node node) => map[node];
326 330
327 void remove(Node node) { 331 void remove(Node node) {
328 map.remove(node); 332 map.remove(node);
329 } 333 }
330 } 334 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/patch_parser.dart ('k') | dart/tests/compiler/dart2js/patch2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698