OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import '../common.dart'; | 5 import '../common.dart'; |
6 import '../common/registry.dart' show Registry; | 6 import '../common/registry.dart' show Registry; |
7 import '../compiler.dart' show Compiler; | 7 import '../compiler.dart' show Compiler; |
8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 JavaScriptBackend get _backend => _compiler.backend; | 57 JavaScriptBackend get _backend => _compiler.backend; |
58 DiagnosticReporter get reporter => _compiler.reporter; | 58 DiagnosticReporter get reporter => _compiler.reporter; |
59 | 59 |
60 /// Compute the [WorldImpact] for the type variables registered since last | 60 /// Compute the [WorldImpact] for the type variables registered since last |
61 /// flush. | 61 /// flush. |
62 WorldImpact flush({bool forResolution}) { | 62 WorldImpact flush({bool forResolution}) { |
63 if (forResolution) return const WorldImpact(); | 63 if (forResolution) return const WorldImpact(); |
64 return impactBuilder.flush(); | 64 return impactBuilder.flush(); |
65 } | 65 } |
66 | 66 |
67 void registerClassWithTypeVariables( | 67 void registerClassWithTypeVariables(ClassElement cls, Enqueuer enqueuer) { |
68 ClassElement cls, Enqueuer enqueuer, Registry registry) { | |
69 if (enqueuer.isResolutionQueue) { | 68 if (enqueuer.isResolutionQueue) { |
70 // On first encounter, we have to ensure that the support classes get | 69 // On first encounter, we have to ensure that the support classes get |
71 // resolved. | 70 // resolved. |
72 if (!_seenClassesWithTypeVariables) { | 71 if (!_seenClassesWithTypeVariables) { |
73 _backend.enqueueClass(enqueuer, _typeVariableClass, registry); | 72 _backend.enqueueClass(enqueuer, _typeVariableClass); |
74 _typeVariableClass.ensureResolved(_compiler.resolution); | 73 _typeVariableClass.ensureResolved(_compiler.resolution); |
75 Link constructors = _typeVariableClass.constructors; | 74 Link constructors = _typeVariableClass.constructors; |
76 if (constructors.isEmpty && constructors.tail.isEmpty) { | 75 if (constructors.isEmpty && constructors.tail.isEmpty) { |
77 reporter.internalError(_typeVariableClass, | 76 reporter.internalError(_typeVariableClass, |
78 "Class '$_typeVariableClass' should only have one constructor"); | 77 "Class '$_typeVariableClass' should only have one constructor"); |
79 } | 78 } |
80 _typeVariableConstructor = _typeVariableClass.constructors.head; | 79 _typeVariableConstructor = _typeVariableClass.constructors.head; |
81 _backend.enqueueInResolution(_typeVariableConstructor, registry); | 80 _backend.enqueue(enqueuer, _typeVariableConstructor); |
82 _backend.registerInstantiatedType( | 81 enqueuer.registerInstantiatedType(_typeVariableClass.rawType); |
83 _typeVariableClass.rawType, enqueuer, registry); | |
84 enqueuer.registerStaticUse(new StaticUse.staticInvoke( | 82 enqueuer.registerStaticUse(new StaticUse.staticInvoke( |
85 _backend.registerBackendUse(_backend.helpers.createRuntimeType), | 83 _backend.registerBackendUse(_backend.helpers.createRuntimeType), |
86 CallStructure.ONE_ARG)); | 84 CallStructure.ONE_ARG)); |
87 _seenClassesWithTypeVariables = true; | 85 _seenClassesWithTypeVariables = true; |
88 } | 86 } |
89 } else { | 87 } else { |
90 if (_backend.isAccessibleByReflection(cls)) { | 88 if (_backend.isAccessibleByReflection(cls)) { |
91 processTypeVariablesOf(cls); | 89 processTypeVariablesOf(cls); |
92 } | 90 } |
93 } | 91 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 167 } |
170 | 168 |
171 List<jsAst.Expression> typeVariablesOf(ClassElement classElement) { | 169 List<jsAst.Expression> typeVariablesOf(ClassElement classElement) { |
172 List<jsAst.Expression> result = _typeVariables[classElement]; | 170 List<jsAst.Expression> result = _typeVariables[classElement]; |
173 if (result == null) { | 171 if (result == null) { |
174 result = const <jsAst.Expression>[]; | 172 result = const <jsAst.Expression>[]; |
175 } | 173 } |
176 return result; | 174 return result; |
177 } | 175 } |
178 } | 176 } |
OLD | NEW |