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 '../backend_helpers.dart' show | 7 import '../backend_helpers.dart' show BackendHelpers; |
8 BackendHelpers; | |
9 import '../js_backend.dart'; | 8 import '../js_backend.dart'; |
10 | 9 |
11 import '../../common.dart'; | 10 import '../../common.dart'; |
12 import '../../common/codegen.dart' show | 11 import '../../common/codegen.dart' show CodegenRegistry; |
13 CodegenRegistry; | 12 import '../../compiler.dart' show Compiler; |
14 import '../../compiler.dart' show | |
15 Compiler; | |
16 import '../../constants/values.dart'; | 13 import '../../constants/values.dart'; |
17 import '../../dart_types.dart' show | 14 import '../../dart_types.dart' show DartType, TypeVariableType, InterfaceType; |
18 DartType, | 15 import '../../enqueue.dart' show CodegenEnqueuer; |
19 TypeVariableType, | |
20 InterfaceType; | |
21 import '../../enqueue.dart' show | |
22 CodegenEnqueuer; | |
23 import '../../elements/elements.dart'; | 16 import '../../elements/elements.dart'; |
24 import '../../js_emitter/js_emitter.dart'; | 17 import '../../js_emitter/js_emitter.dart'; |
25 import '../../js/js.dart' as js; | 18 import '../../js/js.dart' as js; |
26 import '../../native/native.dart' show NativeBehavior; | 19 import '../../native/native.dart' show NativeBehavior; |
27 import '../../universe/selector.dart' show | 20 import '../../universe/selector.dart' show Selector; |
28 Selector; | 21 import '../../world.dart' show ClassWorld; |
29 import '../../world.dart' show | |
30 ClassWorld; | |
31 import '../../types/types.dart'; | 22 import '../../types/types.dart'; |
32 | 23 |
33 /// Encapsulates the dependencies of the function-compiler to the compiler, | 24 /// Encapsulates the dependencies of the function-compiler to the compiler, |
34 /// backend and emitter. | 25 /// backend and emitter. |
35 // TODO(sigurdm): Should be refactored when we have a better feeling for the | 26 // TODO(sigurdm): Should be refactored when we have a better feeling for the |
36 // interface. | 27 // interface. |
37 class Glue { | 28 class Glue { |
38 final Compiler _compiler; | 29 final Compiler _compiler; |
39 | 30 |
40 CodegenEnqueuer get _enqueuer => _compiler.enqueuer.codegen; | 31 CodegenEnqueuer get _enqueuer => _compiler.enqueuer.codegen; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 132 |
142 js.Name instanceFieldPropertyName(Element field) { | 133 js.Name instanceFieldPropertyName(Element field) { |
143 return _namer.instanceFieldPropertyName(field); | 134 return _namer.instanceFieldPropertyName(field); |
144 } | 135 } |
145 | 136 |
146 js.Name instanceMethodName(FunctionElement element) { | 137 js.Name instanceMethodName(FunctionElement element) { |
147 return _namer.instanceMethodName(element); | 138 return _namer.instanceMethodName(element); |
148 } | 139 } |
149 | 140 |
150 js.Expression prototypeAccess(ClassElement e, | 141 js.Expression prototypeAccess(ClassElement e, |
151 {bool hasBeenInstantiated: false}) { | 142 {bool hasBeenInstantiated: false}) { |
152 return _emitter.prototypeAccess(e, | 143 return _emitter.prototypeAccess(e, |
153 hasBeenInstantiated: hasBeenInstantiated); | 144 hasBeenInstantiated: hasBeenInstantiated); |
154 } | 145 } |
155 | 146 |
156 js.Name getInterceptorName(Set<ClassElement> interceptedClasses) { | 147 js.Name getInterceptorName(Set<ClassElement> interceptedClasses) { |
157 return _backend.namer.nameForGetInterceptor(interceptedClasses); | 148 return _backend.namer.nameForGetInterceptor(interceptedClasses); |
158 } | 149 } |
159 | 150 |
160 js.Expression getInterceptorLibrary() { | 151 js.Expression getInterceptorLibrary() { |
161 return new js.VariableUse( | 152 return new js.VariableUse( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { | 216 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { |
226 ClassWorld classWorld = _compiler.world; | 217 ClassWorld classWorld = _compiler.world; |
227 if (classWorld.isUsedAsMixin(cls)) return true; | 218 if (classWorld.isUsedAsMixin(cls)) return true; |
228 | 219 |
229 return _compiler.world.anyStrictSubclassOf(cls, (ClassElement subclass) { | 220 return _compiler.world.anyStrictSubclassOf(cls, (ClassElement subclass) { |
230 return !_backend.rti.isTrivialSubstitution(subclass, cls); | 221 return !_backend.rti.isTrivialSubstitution(subclass, cls); |
231 }); | 222 }); |
232 } | 223 } |
233 | 224 |
234 js.Expression generateTypeRepresentation(DartType dartType, | 225 js.Expression generateTypeRepresentation(DartType dartType, |
235 List<js.Expression> arguments, | 226 List<js.Expression> arguments, CodegenRegistry registry) { |
236 CodegenRegistry registry) { | |
237 int variableIndex = 0; | 227 int variableIndex = 0; |
238 js.Expression representation = _backend.rtiEncoder.getTypeRepresentation( | 228 js.Expression representation = _backend.rtiEncoder |
239 dartType, | 229 .getTypeRepresentation(dartType, (_) => arguments[variableIndex++]); |
240 (_) => arguments[variableIndex++]); | |
241 assert(variableIndex == arguments.length); | 230 assert(variableIndex == arguments.length); |
242 // Representation contains JavaScript Arrays. | 231 // Representation contains JavaScript Arrays. |
243 registry.registerInstantiatedClass(_helpers.jsArrayClass); | 232 registry.registerInstantiatedClass(_helpers.jsArrayClass); |
244 return representation; | 233 return representation; |
245 } | 234 } |
246 | 235 |
247 js.Name getTypeTestTag(DartType type) { | 236 js.Name getTypeTestTag(DartType type) { |
248 return _backend.namer.operatorIsType(type); | 237 return _backend.namer.operatorIsType(type); |
249 } | 238 } |
250 | 239 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 bool mayGenerateInstanceofCheck(DartType type) { | 286 bool mayGenerateInstanceofCheck(DartType type) { |
298 return _backend.mayGenerateInstanceofCheck(type); | 287 return _backend.mayGenerateInstanceofCheck(type); |
299 } | 288 } |
300 | 289 |
301 bool methodUsesReceiverArgument(FunctionElement function) { | 290 bool methodUsesReceiverArgument(FunctionElement function) { |
302 assert(isInterceptedMethod(function)); | 291 assert(isInterceptedMethod(function)); |
303 ClassElement class_ = function.enclosingClass.declaration; | 292 ClassElement class_ = function.enclosingClass.declaration; |
304 return isInterceptorClass(class_) || isUsedAsMixin(class_); | 293 return isInterceptorClass(class_) || isUsedAsMixin(class_); |
305 } | 294 } |
306 } | 295 } |
OLD | NEW |