OLD | NEW |
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 mainApp = mockLibrary(this, ""); | 138 mainApp = mockLibrary(this, ""); |
139 initializeSpecialClasses(); | 139 initializeSpecialClasses(); |
140 // We need to make sure the Object class is resolved. When registering a | 140 // We need to make sure the Object class is resolved. When registering a |
141 // dynamic invocation the ArgumentTypesRegistry eventually iterates over | 141 // dynamic invocation the ArgumentTypesRegistry eventually iterates over |
142 // the interfaces of the Object class which would be 'null' if the class | 142 // the interfaces of the Object class which would be 'null' if the class |
143 // wasn't resolved. | 143 // wasn't resolved. |
144 objectClass.ensureResolved(this); | 144 objectClass.ensureResolved(this); |
145 } | 145 } |
146 | 146 |
147 /** | 147 /** |
| 148 * Registers the [source] with [uri] making it possible load [source] as a |
| 149 * library. |
| 150 */ |
| 151 void registerSource(Uri uri, String source) { |
| 152 sourceFiles[uri.toString()] = new MockFile(source); |
| 153 } |
| 154 |
| 155 /** |
148 * Used internally to create a library from a source text. The created library | 156 * Used internally to create a library from a source text. The created library |
149 * is fixed to export its top-level declarations. | 157 * is fixed to export its top-level declarations. |
150 */ | 158 */ |
151 LibraryElement createLibrary(String name, String source) { | 159 LibraryElement createLibrary(String name, String source) { |
152 Uri uri = new Uri.fromComponents(scheme: "source", path: name); | 160 Uri uri = new Uri.fromComponents(scheme: "source", path: name); |
153 var script = new Script(uri, new MockFile(source)); | 161 var script = new Script(uri, new MockFile(source)); |
154 var library = new LibraryElementX(script); | 162 var library = new LibraryElementX(script); |
155 parseScript(source, library); | 163 parseScript(source, library); |
156 library.setExports(library.localScope.values.toList()); | 164 library.setExports(library.localScope.values.toList()); |
157 return library; | 165 return library; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 operator []=(Node node, Element element) { | 307 operator []=(Node node, Element element) { |
300 map[node] = element; | 308 map[node] = element; |
301 } | 309 } |
302 | 310 |
303 operator [](Node node) => map[node]; | 311 operator [](Node node) => map[node]; |
304 | 312 |
305 void remove(Node node) { | 313 void remove(Node node) { |
306 map.remove(node); | 314 map.remove(node); |
307 } | 315 } |
308 } | 316 } |
OLD | NEW |