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_NEW_EMITTER = const bool.fromEnvironment("dart2js.use.new.emitter"); | 7 const USE_LAZY_EMITTER = const bool.fromEnvironment("dart2js.use.lazy.emitter"); |
8 | 8 |
9 /** | 9 /** |
10 * 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 |
11 * 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. |
12 * | 12 * |
13 * 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`. |
14 */ | 14 */ |
15 class CodeEmitterTask extends CompilerTask { | 15 class CodeEmitterTask extends CompilerTask { |
16 // TODO(floitsch): the code-emitter task should not need a namer. | 16 // TODO(floitsch): the code-emitter task should not need a namer. |
17 final Namer namer; | 17 final Namer namer; |
(...skipping 29 matching lines...) Expand all Loading... |
47 List<TypedefElement> typedefsNeededForReflection; | 47 List<TypedefElement> typedefsNeededForReflection; |
48 | 48 |
49 JavaScriptBackend get backend => compiler.backend; | 49 JavaScriptBackend get backend => compiler.backend; |
50 | 50 |
51 CodeEmitterTask(Compiler compiler, Namer namer, bool generateSourceMap) | 51 CodeEmitterTask(Compiler compiler, Namer namer, bool generateSourceMap) |
52 : super(compiler), | 52 : super(compiler), |
53 this.namer = namer, | 53 this.namer = namer, |
54 this.typeTestRegistry = new TypeTestRegistry(compiler) { | 54 this.typeTestRegistry = new TypeTestRegistry(compiler) { |
55 nativeEmitter = new NativeEmitter(this); | 55 nativeEmitter = new NativeEmitter(this); |
56 oldEmitter = new OldEmitter(compiler, namer, generateSourceMap, this); | 56 oldEmitter = new OldEmitter(compiler, namer, generateSourceMap, this); |
57 emitter = USE_NEW_EMITTER | 57 emitter = USE_LAZY_EMITTER |
58 ? new new_js_emitter.Emitter(compiler, namer, nativeEmitter) | 58 ? new lazy_js_emitter.Emitter(compiler, namer, nativeEmitter) |
59 : oldEmitter; | 59 : oldEmitter; |
60 metadataCollector = new MetadataCollector(compiler, emitter); | 60 metadataCollector = new MetadataCollector(compiler, emitter); |
61 } | 61 } |
62 | 62 |
63 String get name => 'Code emitter'; | 63 String get name => 'Code emitter'; |
64 | 64 |
65 /// Returns the closure expression of a static function. | 65 /// Returns the closure expression of a static function. |
66 jsAst.Expression isolateStaticClosureAccess(FunctionElement element) { | 66 jsAst.Expression isolateStaticClosureAccess(FunctionElement element) { |
67 return emitter.isolateStaticClosureAccess(element); | 67 return emitter.isolateStaticClosureAccess(element); |
68 } | 68 } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 453 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
454 | 454 |
455 /// Returns the JS code for accessing the given [constant]. | 455 /// Returns the JS code for accessing the given [constant]. |
456 jsAst.Expression constantReference(ConstantValue constant); | 456 jsAst.Expression constantReference(ConstantValue constant); |
457 | 457 |
458 /// Returns the JS template for the given [builtin]. | 458 /// Returns the JS template for the given [builtin]. |
459 jsAst.Template templateForBuiltin(JsBuiltin builtin); | 459 jsAst.Template templateForBuiltin(JsBuiltin builtin); |
460 | 460 |
461 void invalidateCaches(); | 461 void invalidateCaches(); |
462 } | 462 } |
OLD | NEW |