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 dart2js.js_emitter.code_emitter_task; | 5 library dart2js.js_emitter.code_emitter_task; |
6 | 6 |
7 import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin; | 7 import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin; |
8 | 8 |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../common/tasks.dart' show CompilerTask; | 10 import '../common/tasks.dart' show CompilerTask; |
(...skipping 22 matching lines...) Expand all Loading... |
33 * The code for the containing (used) methods must exist in the `universe`. | 33 * The code for the containing (used) methods must exist in the `universe`. |
34 */ | 34 */ |
35 class CodeEmitterTask extends CompilerTask { | 35 class CodeEmitterTask extends CompilerTask { |
36 TypeTestRegistry typeTestRegistry; | 36 TypeTestRegistry typeTestRegistry; |
37 NativeEmitter nativeEmitter; | 37 NativeEmitter nativeEmitter; |
38 MetadataCollector metadataCollector; | 38 MetadataCollector metadataCollector; |
39 EmitterFactory _emitterFactory; | 39 EmitterFactory _emitterFactory; |
40 Emitter _emitter; | 40 Emitter _emitter; |
41 final Compiler compiler; | 41 final Compiler compiler; |
42 | 42 |
43 /// Records if a type variable is read dynamically for type tests. | |
44 final Set<TypeVariableEntity> readTypeVariables = | |
45 new Set<TypeVariableEntity>(); | |
46 | |
47 JavaScriptBackend get backend => compiler.backend; | 43 JavaScriptBackend get backend => compiler.backend; |
48 | 44 |
49 @deprecated | 45 @deprecated |
50 // This field should be removed. It's currently only needed for dump-info and | 46 // This field should be removed. It's currently only needed for dump-info and |
51 // tests. | 47 // tests. |
52 // The field is set after the program has been emitted. | 48 // The field is set after the program has been emitted. |
53 /// Contains a list of all classes that are emitted. | 49 /// Contains a list of all classes that are emitted. |
54 Set<ClassEntity> neededClasses; | 50 Set<ClassEntity> neededClasses; |
55 | 51 |
56 CodeEmitterTask( | 52 CodeEmitterTask( |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 /// The given type [e] might be a Typedef. | 140 /// The given type [e] might be a Typedef. |
145 jsAst.Expression typeAccess(Entity e) { | 141 jsAst.Expression typeAccess(Entity e) { |
146 return emitter.typeAccess(e); | 142 return emitter.typeAccess(e); |
147 } | 143 } |
148 | 144 |
149 /// Returns the JS template for the given [builtin]. | 145 /// Returns the JS template for the given [builtin]. |
150 jsAst.Template builtinTemplateFor(JsBuiltin builtin) { | 146 jsAst.Template builtinTemplateFor(JsBuiltin builtin) { |
151 return emitter.templateForBuiltin(builtin); | 147 return emitter.templateForBuiltin(builtin); |
152 } | 148 } |
153 | 149 |
154 void registerReadTypeVariable(TypeVariableEntity element) { | |
155 readTypeVariables.add(element); | |
156 } | |
157 | |
158 Set<ClassEntity> _finalizeRti() { | 150 Set<ClassEntity> _finalizeRti() { |
159 // Compute the required type checks to know which classes need a | 151 // Compute the required type checks to know which classes need a |
160 // 'is$' method. | 152 // 'is$' method. |
161 typeTestRegistry.computeRequiredTypeChecks(); | 153 typeTestRegistry.computeRequiredTypeChecks(); |
162 // Compute the classes needed by RTI. | 154 // Compute the classes needed by RTI. |
163 return typeTestRegistry.computeRtiNeededClasses(); | 155 return typeTestRegistry.computeRtiNeededClasses(); |
164 } | 156 } |
165 | 157 |
166 /// Creates the [Emitter] for this task. | 158 /// Creates the [Emitter] for this task. |
167 void createEmitter(Namer namer, ClosedWorld closedWorld) { | 159 void createEmitter(Namer namer, ClosedWorld closedWorld) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 234 |
243 /// Returns the JS code for accessing the given [constant]. | 235 /// Returns the JS code for accessing the given [constant]. |
244 jsAst.Expression constantReference(ConstantValue constant); | 236 jsAst.Expression constantReference(ConstantValue constant); |
245 | 237 |
246 /// Returns the JS template for the given [builtin]. | 238 /// Returns the JS template for the given [builtin]. |
247 jsAst.Template templateForBuiltin(JsBuiltin builtin); | 239 jsAst.Template templateForBuiltin(JsBuiltin builtin); |
248 | 240 |
249 /// Returns the size of the code generated for a given output [unit]. | 241 /// Returns the size of the code generated for a given output [unit]. |
250 int generatedSize(OutputUnit unit); | 242 int generatedSize(OutputUnit unit); |
251 } | 243 } |
OLD | NEW |