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 = | 8 const USE_STARTUP_EMITTER = |
9 const bool.fromEnvironment("dart2js.use.startup.emitter"); | 9 const bool.fromEnvironment("dart2js.use.startup.emitter"); |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 emitter = new startup_js_emitter.Emitter(compiler, namer, nativeEmitter); | 46 emitter = new startup_js_emitter.Emitter(compiler, namer, nativeEmitter); |
47 } else { | 47 } else { |
48 emitter = | 48 emitter = |
49 new full_js_emitter.Emitter(compiler, namer, generateSourceMap, this); | 49 new full_js_emitter.Emitter(compiler, namer, generateSourceMap, this); |
50 } | 50 } |
51 metadataCollector = new MetadataCollector(compiler, emitter); | 51 metadataCollector = new MetadataCollector(compiler, emitter); |
52 } | 52 } |
53 | 53 |
54 String get name => 'Code emitter'; | 54 String get name => 'Code emitter'; |
55 | 55 |
| 56 /// Returns the string that is used to find library patches that are |
| 57 /// specialized for the emitter. |
| 58 String get patchVersion => emitter.patchVersion; |
| 59 |
56 /// Returns the closure expression of a static function. | 60 /// Returns the closure expression of a static function. |
57 jsAst.Expression isolateStaticClosureAccess(FunctionElement element) { | 61 jsAst.Expression isolateStaticClosureAccess(FunctionElement element) { |
58 return emitter.isolateStaticClosureAccess(element); | 62 return emitter.isolateStaticClosureAccess(element); |
59 } | 63 } |
60 | 64 |
61 /// Returns the JS function that must be invoked to get the value of the | 65 /// Returns the JS function that must be invoked to get the value of the |
62 /// lazily initialized static. | 66 /// lazily initialized static. |
63 jsAst.Expression isolateLazyInitializerAccess(FieldElement element) { | 67 jsAst.Expression isolateLazyInitializerAccess(FieldElement element) { |
64 return emitter.isolateLazyInitializerAccess(element); | 68 return emitter.isolateLazyInitializerAccess(element); |
65 } | 69 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 compiler, namer, this, emitter, rtiNeededClasses); | 145 compiler, namer, this, emitter, rtiNeededClasses); |
142 int size = emitter.emitProgram(programBuilder); | 146 int size = emitter.emitProgram(programBuilder); |
143 // TODO(floitsch): we shouldn't need the `neededClasses` anymore. | 147 // TODO(floitsch): we shouldn't need the `neededClasses` anymore. |
144 neededClasses = programBuilder.collector.neededClasses; | 148 neededClasses = programBuilder.collector.neededClasses; |
145 return size; | 149 return size; |
146 }); | 150 }); |
147 } | 151 } |
148 } | 152 } |
149 | 153 |
150 abstract class Emitter { | 154 abstract class Emitter { |
| 155 /// Returns the string that is used to find library patches that are |
| 156 /// specialized for this emitter. |
| 157 String get patchVersion; |
| 158 |
151 /// Uses the [programBuilder] to generate a model of the program, emits | 159 /// Uses the [programBuilder] to generate a model of the program, emits |
152 /// the program, and returns the size of the generated output. | 160 /// the program, and returns the size of the generated output. |
153 int emitProgram(ProgramBuilder programBuilder); | 161 int emitProgram(ProgramBuilder programBuilder); |
154 | 162 |
155 /// Returns true, if the emitter supports reflection. | 163 /// Returns true, if the emitter supports reflection. |
156 bool get supportsReflection; | 164 bool get supportsReflection; |
157 | 165 |
158 /// Returns the JS function that must be invoked to get the value of the | 166 /// Returns the JS function that must be invoked to get the value of the |
159 /// lazily initialized static. | 167 /// lazily initialized static. |
160 jsAst.Expression isolateLazyInitializerAccess(FieldElement element); | 168 jsAst.Expression isolateLazyInitializerAccess(FieldElement element); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 201 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
194 | 202 |
195 /// Returns the JS code for accessing the given [constant]. | 203 /// Returns the JS code for accessing the given [constant]. |
196 jsAst.Expression constantReference(ConstantValue constant); | 204 jsAst.Expression constantReference(ConstantValue constant); |
197 | 205 |
198 /// Returns the JS template for the given [builtin]. | 206 /// Returns the JS template for the given [builtin]. |
199 jsAst.Template templateForBuiltin(JsBuiltin builtin); | 207 jsAst.Template templateForBuiltin(JsBuiltin builtin); |
200 | 208 |
201 void invalidateCaches(); | 209 void invalidateCaches(); |
202 } | 210 } |
OLD | NEW |