| 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 '../../dart2jslib.dart'; | 8 import '../../dart2jslib.dart'; |
| 9 import '../../js_emitter/js_emitter.dart'; | 9 import '../../js_emitter/js_emitter.dart'; |
| 10 import '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| 11 import '../../constants/values.dart'; | 11 import '../../constants/values.dart'; |
| 12 import '../../elements/elements.dart'; | 12 import '../../elements/elements.dart'; |
| 13 import '../../constants/expressions.dart'; | 13 import '../../constants/expressions.dart'; |
| 14 import '../../dart_types.dart' show TypeVariableType; |
| 14 | 15 |
| 15 /// Encapsulates the dependencies of the function-compiler to the compiler, | 16 /// Encapsulates the dependencies of the function-compiler to the compiler, |
| 16 /// backend and emitter. | 17 /// backend and emitter. |
| 17 // TODO(sigurdm): Should be refactored when we have a better feeling for the | 18 // TODO(sigurdm): Should be refactored when we have a better feeling for the |
| 18 // interface. | 19 // interface. |
| 19 class Glue { | 20 class Glue { |
| 20 final Compiler _compiler; | 21 final Compiler _compiler; |
| 21 | 22 |
| 22 JavaScriptBackend get _backend => _compiler.backend; | 23 JavaScriptBackend get _backend => _compiler.backend; |
| 23 | 24 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 109 |
| 109 | 110 |
| 110 String getInterceptorName(Set<ClassElement> interceptedClasses) { | 111 String getInterceptorName(Set<ClassElement> interceptedClasses) { |
| 111 return _backend.namer.nameForGetInterceptor(interceptedClasses); | 112 return _backend.namer.nameForGetInterceptor(interceptedClasses); |
| 112 } | 113 } |
| 113 | 114 |
| 114 js.Expression getInterceptorLibrary() { | 115 js.Expression getInterceptorLibrary() { |
| 115 return new js.VariableUse( | 116 return new js.VariableUse( |
| 116 _backend.namer.globalObjectFor(_backend.interceptorsLibrary)); | 117 _backend.namer.globalObjectFor(_backend.interceptorsLibrary)); |
| 117 } | 118 } |
| 119 |
| 120 FunctionElement getCreateRuntimeType() { |
| 121 return _backend.getCreateRuntimeType(); |
| 122 } |
| 123 |
| 124 FunctionElement getRuntimeTypeToString() { |
| 125 return _backend.getRuntimeTypeToString(); |
| 126 } |
| 127 |
| 128 FunctionElement getTypeArgumentWithSubstitution() { |
| 129 return _backend.getGetRuntimeTypeArgument(); |
| 130 } |
| 131 |
| 132 FunctionElement getTypeArgumentByIndex() { |
| 133 return _backend.getGetTypeArgumentByIndex(); |
| 134 } |
| 135 |
| 136 js.Expression getSubstitutionName(ClassElement cls) { |
| 137 return js.string(_namer.substitutionName(cls)); |
| 138 } |
| 139 |
| 140 int getTypeVariableIndex(TypeVariableType variable) { |
| 141 return RuntimeTypes.getTypeVariableIndex(variable.element); |
| 142 } |
| 143 |
| 144 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { |
| 145 ClassWorld classWorld = _compiler.world; |
| 146 if (classWorld.isUsedAsMixin(cls)) return true; |
| 147 |
| 148 Iterable<ClassElement> subclasses = _compiler.world.strictSubclassesOf(cls); |
| 149 return subclasses.any((ClassElement subclass) { |
| 150 return !_backend.rti.isTrivialSubstitution(subclass, cls); |
| 151 }); |
| 152 } |
| 118 } | 153 } |
| OLD | NEW |