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/dart2jslib.dart' | 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 class Object {} | 82 class Object {} |
83 class Type {} | 83 class Type {} |
84 class Function {} | 84 class Function {} |
85 class List<E> {} | 85 class List<E> {} |
86 abstract class Map<K,V> {} | 86 abstract class Map<K,V> {} |
87 class Closure {} | 87 class Closure {} |
88 class Null {} | 88 class Null {} |
89 class Dynamic_ {} | 89 class Dynamic_ {} |
90 bool identical(Object a, Object b) {}'''; | 90 bool identical(Object a, Object b) {}'''; |
91 | 91 |
| 92 const String DEFAULT_ISOLATE_HELPERLIB = r''' |
| 93 class _WorkerBase {}'''; |
| 94 |
92 class MockCompiler extends Compiler { | 95 class MockCompiler extends Compiler { |
93 List<WarningMessage> warnings; | 96 List<WarningMessage> warnings; |
94 List<WarningMessage> errors; | 97 List<WarningMessage> errors; |
95 final Map<String, SourceFile> sourceFiles; | 98 final Map<String, SourceFile> sourceFiles; |
96 Node parsedTree; | 99 Node parsedTree; |
97 | 100 |
98 MockCompiler({String coreSource: DEFAULT_CORELIB, | 101 MockCompiler({String coreSource: DEFAULT_CORELIB, |
99 String helperSource: DEFAULT_HELPERLIB, | 102 String helperSource: DEFAULT_HELPERLIB, |
100 String interceptorsSource: DEFAULT_INTERCEPTORSLIB, | 103 String interceptorsSource: DEFAULT_INTERCEPTORSLIB, |
| 104 String isolateHelperSource: DEFAULT_ISOLATE_HELPERLIB, |
101 bool enableTypeAssertions: false, | 105 bool enableTypeAssertions: false, |
102 bool enableMinification: false, | 106 bool enableMinification: false, |
103 bool enableConcreteTypeInference: false, | 107 bool enableConcreteTypeInference: false, |
104 bool analyzeAll: false}) | 108 bool analyzeAll: false}) |
105 : warnings = [], errors = [], | 109 : warnings = [], errors = [], |
106 sourceFiles = new Map<String, SourceFile>(), | 110 sourceFiles = new Map<String, SourceFile>(), |
107 super(enableTypeAssertions: enableTypeAssertions, | 111 super(enableTypeAssertions: enableTypeAssertions, |
108 enableMinification: enableMinification, | 112 enableMinification: enableMinification, |
109 enableConcreteTypeInference: enableConcreteTypeInference, | 113 enableConcreteTypeInference: enableConcreteTypeInference, |
110 analyzeAll: analyzeAll) { | 114 analyzeAll: analyzeAll) { |
111 coreLibrary = createLibrary("core", coreSource); | 115 coreLibrary = createLibrary("core", coreSource); |
112 // We need to set the assert method to avoid calls with a 'null' | 116 // We need to set the assert method to avoid calls with a 'null' |
113 // target being interpreted as a call to assert. | 117 // target being interpreted as a call to assert. |
114 jsHelperLibrary = createLibrary("helper", helperSource); | 118 jsHelperLibrary = createLibrary("helper", helperSource); |
115 importHelperLibrary(coreLibrary); | 119 importHelperLibrary(coreLibrary); |
116 libraryLoader.importLibrary(jsHelperLibrary, coreLibrary, null); | 120 libraryLoader.importLibrary(jsHelperLibrary, coreLibrary, null); |
117 | 121 |
118 assertMethod = jsHelperLibrary.find(buildSourceString('assert')); | 122 assertMethod = jsHelperLibrary.find(buildSourceString('assert')); |
119 interceptorsLibrary = createLibrary("interceptors", interceptorsSource); | 123 interceptorsLibrary = createLibrary("interceptors", interceptorsSource); |
| 124 isolateHelperLibrary = createLibrary("isolate_helper", isolateHelperSource); |
120 | 125 |
121 mainApp = mockLibrary(this, ""); | 126 mainApp = mockLibrary(this, ""); |
122 initializeSpecialClasses(); | 127 initializeSpecialClasses(); |
123 // We need to make sure the Object class is resolved. When registering a | 128 // We need to make sure the Object class is resolved. When registering a |
124 // dynamic invocation the ArgumentTypesRegistry eventually iterates over | 129 // dynamic invocation the ArgumentTypesRegistry eventually iterates over |
125 // the interfaces of the Object class which would be 'null' if the class | 130 // the interfaces of the Object class which would be 'null' if the class |
126 // wasn't resolved. | 131 // wasn't resolved. |
127 objectClass.ensureResolved(this); | 132 objectClass.ensureResolved(this); |
128 } | 133 } |
129 | 134 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 operator []=(Node node, Element element) { | 278 operator []=(Node node, Element element) { |
274 map[node] = element; | 279 map[node] = element; |
275 } | 280 } |
276 | 281 |
277 operator [](Node node) => map[node]; | 282 operator [](Node node) => map[node]; |
278 | 283 |
279 void remove(Node node) { | 284 void remove(Node node) { |
280 map.remove(node); | 285 map.remove(node); |
281 } | 286 } |
282 } | 287 } |
OLD | NEW |