| 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_NEW_EMITTER = const bool.fromEnvironment("dart2js.use.new.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; |
| 18 final TypeTestRegistry typeTestRegistry; | 18 final TypeTestRegistry typeTestRegistry; |
| 19 NativeEmitter nativeEmitter; | 19 NativeEmitter nativeEmitter; |
| 20 MetadataEmitter metadataEmitter; | 20 MetadataCollector metadataCollector; |
| 21 OldEmitter oldEmitter; | 21 OldEmitter oldEmitter; |
| 22 Emitter emitter; | 22 Emitter emitter; |
| 23 | 23 |
| 24 final Set<ClassElement> neededClasses = new Set<ClassElement>(); | 24 final Set<ClassElement> neededClasses = new Set<ClassElement>(); |
| 25 final Map<OutputUnit, List<ClassElement>> outputClassLists = | 25 final Map<OutputUnit, List<ClassElement>> outputClassLists = |
| 26 new Map<OutputUnit, List<ClassElement>>(); | 26 new Map<OutputUnit, List<ClassElement>>(); |
| 27 final Map<OutputUnit, List<ConstantValue>> outputConstantLists = | 27 final Map<OutputUnit, List<ConstantValue>> outputConstantLists = |
| 28 new Map<OutputUnit, List<ConstantValue>>(); | 28 new Map<OutputUnit, List<ConstantValue>>(); |
| 29 final Map<OutputUnit, List<Element>> outputStaticLists = | 29 final Map<OutputUnit, List<Element>> outputStaticLists = |
| 30 new Map<OutputUnit, List<Element>>(); | 30 new Map<OutputUnit, List<Element>>(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 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 oldEmitter = new OldEmitter(compiler, namer, generateSourceMap, this); | 55 oldEmitter = new OldEmitter(compiler, namer, generateSourceMap, this); |
| 56 emitter = USE_NEW_EMITTER | 56 emitter = USE_NEW_EMITTER |
| 57 ? new new_js_emitter.Emitter(compiler, namer) | 57 ? new new_js_emitter.Emitter(compiler, namer) |
| 58 : oldEmitter; | 58 : oldEmitter; |
| 59 nativeEmitter = new NativeEmitter(this); | 59 nativeEmitter = new NativeEmitter(this); |
| 60 metadataEmitter = new MetadataEmitter(); | 60 metadataCollector = new MetadataCollector(compiler, emitter); |
| 61 metadataEmitter.emitter = oldEmitter; | |
| 62 } | 61 } |
| 63 | 62 |
| 64 String get name => 'Code emitter'; | 63 String get name => 'Code emitter'; |
| 65 | 64 |
| 66 /// Returns the closure expression of a static function. | 65 /// Returns the closure expression of a static function. |
| 67 jsAst.Expression isolateStaticClosureAccess(FunctionElement element) { | 66 jsAst.Expression isolateStaticClosureAccess(FunctionElement element) { |
| 68 return emitter.isolateStaticClosureAccess(element); | 67 return emitter.isolateStaticClosureAccess(element); |
| 69 } | 68 } |
| 70 | 69 |
| 71 /// Returns the JS function that must be invoked to get the value of the | 70 /// Returns the JS function that must be invoked to get the value of the |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 jsAst.Expression typeAccess(Element e); | 459 jsAst.Expression typeAccess(Element e); |
| 461 | 460 |
| 462 /// Returns the JS expression representing a function that returns 'null' | 461 /// Returns the JS expression representing a function that returns 'null' |
| 463 jsAst.Expression generateFunctionThatReturnsNull(); | 462 jsAst.Expression generateFunctionThatReturnsNull(); |
| 464 | 463 |
| 465 int compareConstants(ConstantValue a, ConstantValue b); | 464 int compareConstants(ConstantValue a, ConstantValue b); |
| 466 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 465 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
| 467 | 466 |
| 468 void invalidateCaches(); | 467 void invalidateCaches(); |
| 469 } | 468 } |
| OLD | NEW |