| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 const USE_LAZY_EMITTER = const bool.fromEnvironment("dart2js.use.lazy.emitter"); | 7 const USE_LAZY_EMITTER = const bool.fromEnvironment("dart2js.use.lazy.emitter"); |
| 8 const USE_STARTUP_EMITTER = | |
| 9 const bool.fromEnvironment("dart2js.use.startup.emitter"); | |
| 10 | 8 |
| 11 /** | 9 /** |
| 12 * Generates the code for all used classes in the program. Static fields (even | 10 * Generates the code for all used classes in the program. Static fields (even |
| 13 * in classes) are ignored, since they can be treated as non-class elements. | 11 * in classes) are ignored, since they can be treated as non-class elements. |
| 14 * | 12 * |
| 15 * The code for the containing (used) methods must exist in the `universe`. | 13 * The code for the containing (used) methods must exist in the `universe`. |
| 16 */ | 14 */ |
| 17 class CodeEmitterTask extends CompilerTask { | 15 class CodeEmitterTask extends CompilerTask { |
| 18 // TODO(floitsch): the code-emitter task should not need a namer. | 16 // TODO(floitsch): the code-emitter task should not need a namer. |
| 19 final Namer namer; | 17 final Namer namer; |
| 20 final TypeTestRegistry typeTestRegistry; | 18 final TypeTestRegistry typeTestRegistry; |
| 21 NativeEmitter nativeEmitter; | 19 NativeEmitter nativeEmitter; |
| 22 MetadataCollector metadataCollector; | 20 MetadataCollector metadataCollector; |
| 23 Emitter emitter; | 21 Emitter emitter; |
| 24 | 22 |
| 25 /// Records if a type variable is read dynamically for type tests. | 23 /// Records if a type variable is read dynamically for type tests. |
| 26 final Set<TypeVariableElement> readTypeVariables = | 24 final Set<TypeVariableElement> readTypeVariables = |
| 27 new Set<TypeVariableElement>(); | 25 new Set<TypeVariableElement>(); |
| 28 | 26 |
| 29 JavaScriptBackend get backend => compiler.backend; | 27 JavaScriptBackend get backend => compiler.backend; |
| 30 | 28 |
| 31 @deprecated | 29 @deprecated |
| 32 // This field should be removed. It's currently only needed for dump-info and | 30 // This field should be removed. It's currently only needed for dump-info and |
| 33 // tests. | 31 // tests. |
| 34 // The field is set after the program has been emitted. | 32 // The field is set after the program has been emitted. |
| 35 /// Contains a list of all classes that are emitted. | 33 /// Contains a list of all classes that are emitted. |
| 36 Set<ClassElement> neededClasses; | 34 Set<ClassElement> neededClasses; |
| 37 | 35 |
| 38 CodeEmitterTask(Compiler compiler, Namer namer, bool generateSourceMap) | 36 CodeEmitterTask(Compiler compiler, Namer namer, bool generateSourceMap, |
| 37 bool useStartupEmitter) |
| 39 : super(compiler), | 38 : super(compiler), |
| 40 this.namer = namer, | 39 this.namer = namer, |
| 41 this.typeTestRegistry = new TypeTestRegistry(compiler) { | 40 this.typeTestRegistry = new TypeTestRegistry(compiler) { |
| 42 nativeEmitter = new NativeEmitter(this); | 41 nativeEmitter = new NativeEmitter(this); |
| 43 if (USE_LAZY_EMITTER) { | 42 if (USE_LAZY_EMITTER) { |
| 44 emitter = new lazy_js_emitter.Emitter(compiler, namer, nativeEmitter); | 43 emitter = new lazy_js_emitter.Emitter(compiler, namer, nativeEmitter); |
| 45 } else if (USE_STARTUP_EMITTER) { | 44 } else if (useStartupEmitter) { |
| 46 emitter = new startup_js_emitter.Emitter( | 45 emitter = new startup_js_emitter.Emitter( |
| 47 compiler, namer, nativeEmitter, generateSourceMap); | 46 compiler, namer, nativeEmitter, generateSourceMap); |
| 48 } else { | 47 } else { |
| 49 emitter = | 48 emitter = |
| 50 new full_js_emitter.Emitter(compiler, namer, generateSourceMap, this); | 49 new full_js_emitter.Emitter(compiler, namer, generateSourceMap, this); |
| 51 } | 50 } |
| 52 metadataCollector = new MetadataCollector(compiler, emitter); | 51 metadataCollector = new MetadataCollector(compiler, emitter); |
| 53 } | 52 } |
| 54 | 53 |
| 55 String get name => 'Code emitter'; | 54 String get name => 'Code emitter'; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 201 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
| 203 | 202 |
| 204 /// Returns the JS code for accessing the given [constant]. | 203 /// Returns the JS code for accessing the given [constant]. |
| 205 jsAst.Expression constantReference(ConstantValue constant); | 204 jsAst.Expression constantReference(ConstantValue constant); |
| 206 | 205 |
| 207 /// Returns the JS template for the given [builtin]. | 206 /// Returns the JS template for the given [builtin]. |
| 208 jsAst.Template templateForBuiltin(JsBuiltin builtin); | 207 jsAst.Template templateForBuiltin(JsBuiltin builtin); |
| 209 | 208 |
| 210 void invalidateCaches(); | 209 void invalidateCaches(); |
| 211 } | 210 } |
| OLD | NEW |