OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 code_generator_dependencies; | 5 library code_generator_dependencies; |
6 | 6 |
7 import '../js_backend.dart'; | 7 import '../js_backend.dart'; |
8 import '../../common/registry.dart' show | 8 import '../../common/registry.dart' show |
9 Registry; | 9 Registry; |
| 10 import '../../common/codegen.dart' show |
| 11 CodegenRegistry; |
10 import '../../compiler.dart' show | 12 import '../../compiler.dart' show |
11 Compiler; | 13 Compiler; |
12 import '../../constants/values.dart'; | 14 import '../../constants/values.dart'; |
13 import '../../dart_types.dart' show | 15 import '../../dart_types.dart' show |
14 DartType, | 16 DartType, |
15 TypeVariableType, | 17 TypeVariableType, |
16 InterfaceType; | 18 InterfaceType; |
17 import '../../enqueue.dart' show | 19 import '../../enqueue.dart' show |
18 CodegenEnqueuer; | 20 CodegenEnqueuer; |
19 import '../../elements/elements.dart'; | 21 import '../../elements/elements.dart'; |
20 import '../../js_emitter/js_emitter.dart'; | 22 import '../../js_emitter/js_emitter.dart'; |
21 import '../../js/js.dart' as js; | 23 import '../../js/js.dart' as js; |
| 24 import '../../native/native.dart' show NativeBehavior; |
22 import '../../universe/selector.dart' show | 25 import '../../universe/selector.dart' show |
23 Selector; | 26 Selector; |
24 import '../../world.dart' show | 27 import '../../world.dart' show |
25 ClassWorld; | 28 ClassWorld; |
26 | 29 |
27 | 30 |
28 /// Encapsulates the dependencies of the function-compiler to the compiler, | 31 /// Encapsulates the dependencies of the function-compiler to the compiler, |
29 /// backend and emitter. | 32 /// backend and emitter. |
30 // TODO(sigurdm): Should be refactored when we have a better feeling for the | 33 // TODO(sigurdm): Should be refactored when we have a better feeling for the |
31 // interface. | 34 // interface. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 122 } |
120 | 123 |
121 bool isInterceptorClass(ClassElement element) { | 124 bool isInterceptorClass(ClassElement element) { |
122 return element.isSubclassOf(_backend.jsInterceptorClass); | 125 return element.isSubclassOf(_backend.jsInterceptorClass); |
123 } | 126 } |
124 | 127 |
125 Set<ClassElement> getInterceptedClassesOn(Selector selector) { | 128 Set<ClassElement> getInterceptedClassesOn(Selector selector) { |
126 return _backend.getInterceptedClassesOn(selector.name); | 129 return _backend.getInterceptedClassesOn(selector.name); |
127 } | 130 } |
128 | 131 |
| 132 Set<ClassElement> get interceptedClasses { |
| 133 return _backend.interceptedClasses; |
| 134 } |
| 135 |
129 void registerSpecializedGetInterceptor(Set<ClassElement> classes) { | 136 void registerSpecializedGetInterceptor(Set<ClassElement> classes) { |
130 _backend.registerSpecializedGetInterceptor(classes); | 137 _backend.registerSpecializedGetInterceptor(classes); |
131 } | 138 } |
132 | 139 |
133 js.Expression constructorAccess(ClassElement element) { | 140 js.Expression constructorAccess(ClassElement element) { |
134 return _backend.emitter.constructorAccess(element); | 141 return _backend.emitter.constructorAccess(element); |
135 } | 142 } |
136 | 143 |
137 js.Name instanceFieldPropertyName(Element field) { | 144 js.Name instanceFieldPropertyName(Element field) { |
138 return _namer.instanceFieldPropertyName(field); | 145 return _namer.instanceFieldPropertyName(field); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 ClassWorld classWorld = _compiler.world; | 228 ClassWorld classWorld = _compiler.world; |
222 if (classWorld.isUsedAsMixin(cls)) return true; | 229 if (classWorld.isUsedAsMixin(cls)) return true; |
223 | 230 |
224 Iterable<ClassElement> subclasses = _compiler.world.strictSubclassesOf(cls); | 231 Iterable<ClassElement> subclasses = _compiler.world.strictSubclassesOf(cls); |
225 return subclasses.any((ClassElement subclass) { | 232 return subclasses.any((ClassElement subclass) { |
226 return !_backend.rti.isTrivialSubstitution(subclass, cls); | 233 return !_backend.rti.isTrivialSubstitution(subclass, cls); |
227 }); | 234 }); |
228 } | 235 } |
229 | 236 |
230 js.Expression generateTypeRepresentation(DartType dartType, | 237 js.Expression generateTypeRepresentation(DartType dartType, |
231 List<js.Expression> arguments) { | 238 List<js.Expression> arguments, |
| 239 CodegenRegistry registry) { |
232 int variableIndex = 0; | 240 int variableIndex = 0; |
233 js.Expression representation = _backend.rti.getTypeRepresentation( | 241 js.Expression representation = _backend.rti.getTypeRepresentation( |
234 dartType, | 242 dartType, |
235 (_) => arguments[variableIndex++]); | 243 (_) => arguments[variableIndex++]); |
236 assert(variableIndex == arguments.length); | 244 assert(variableIndex == arguments.length); |
| 245 // Representation contains JavaScript Arrays. |
| 246 registry.registerInstantiatedClass(_backend.jsArrayClass); |
237 return representation; | 247 return representation; |
238 } | 248 } |
239 | 249 |
240 void registerIsCheck(DartType type, Registry registry) { | 250 void registerIsCheck(DartType type, Registry registry) { |
241 _enqueuer.registerIsCheck(type); | 251 _enqueuer.registerIsCheck(type); |
242 _backend.registerIsCheckForCodegen(type, _enqueuer, registry); | 252 _backend.registerIsCheckForCodegen(type, _enqueuer, registry); |
243 } | 253 } |
244 | 254 |
245 js.Name getTypeTestTag(DartType type) { | 255 js.Name getTypeTestTag(DartType type) { |
246 return _backend.namer.operatorIsType(type); | 256 return _backend.namer.operatorIsType(type); |
247 } | 257 } |
248 | 258 |
249 js.Name getTypeSubstitutionTag(ClassElement element) { | 259 js.Name getTypeSubstitutionTag(ClassElement element) { |
250 return _backend.namer.substitutionName(element); | 260 return _backend.namer.substitutionName(element); |
251 } | 261 } |
252 | 262 |
253 bool operatorEqHandlesNullArgument(FunctionElement element) { | 263 bool operatorEqHandlesNullArgument(FunctionElement element) { |
254 return _backend.operatorEqHandlesNullArgument(element); | 264 return _backend.operatorEqHandlesNullArgument(element); |
255 } | 265 } |
256 | 266 |
257 bool hasStrictSubtype(ClassElement element) { | 267 bool hasStrictSubtype(ClassElement element) { |
258 return _compiler.world.hasAnyStrictSubtype(element); | 268 return _compiler.world.hasAnyStrictSubtype(element); |
259 } | 269 } |
260 | 270 |
| 271 ClassElement get jsFixedArrayClass => _backend.jsFixedArrayClass; |
261 ClassElement get jsExtendableArrayClass => _backend.jsExtendableArrayClass; | 272 ClassElement get jsExtendableArrayClass => _backend.jsExtendableArrayClass; |
| 273 ClassElement get jsUnmodifiableArrayClass => |
| 274 _backend.jsUnmodifiableArrayClass; |
262 ClassElement get jsMutableArrayClass => _backend.jsMutableArrayClass; | 275 ClassElement get jsMutableArrayClass => _backend.jsMutableArrayClass; |
263 | 276 |
264 bool isStringClass(ClassElement classElement) => | 277 bool isStringClass(ClassElement classElement) => |
265 classElement == _backend.jsStringClass || | 278 classElement == _backend.jsStringClass || |
266 classElement == _compiler.stringClass; | 279 classElement == _compiler.stringClass; |
267 | 280 |
268 bool isBoolClass(ClassElement classElement) => | 281 bool isBoolClass(ClassElement classElement) => |
269 classElement == _backend.jsBoolClass || | 282 classElement == _backend.jsBoolClass || |
270 classElement == _compiler.boolClass; | 283 classElement == _compiler.boolClass; |
| 284 |
| 285 // TODO(sra): Should this be part of CodegenRegistry? |
| 286 void registerNativeBehavior(NativeBehavior nativeBehavior, node) { |
| 287 if (nativeBehavior == null) return; |
| 288 _enqueuer.nativeEnqueuer.registerNativeBehavior(nativeBehavior, node); |
| 289 } |
271 } | 290 } |
OLD | NEW |