OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.startup_emitter; | 5 library dart2js.js_emitter.startup_emitter; |
6 | 6 |
7 import 'package:js_runtime/shared/embedded_names.dart' | 7 import 'package:js_runtime/shared/embedded_names.dart' |
8 show JsBuiltin, METADATA, STATIC_FUNCTION_NAME_TO_CLOSURE, TYPES; | 8 show JsBuiltin, METADATA, STATIC_FUNCTION_NAME_TO_CLOSURE, TYPES; |
9 | 9 |
10 import '../../common.dart'; | 10 import '../../common.dart'; |
11 import '../../compiler.dart' show Compiler; | 11 import '../../compiler.dart' show Compiler; |
12 import '../../constants/values.dart' show ConstantValue; | 12 import '../../constants/values.dart' show ConstantValue; |
13 import '../../deferred_load.dart' show OutputUnit; | 13 import '../../deferred_load.dart' show OutputUnit; |
14 import '../../elements/elements.dart' | 14 import '../../elements/elements.dart' |
15 show ClassElement, Element, FieldElement, MethodElement; | 15 show ClassElement, Element, FieldElement, MethodElement; |
16 import '../../js/js.dart' as js; | 16 import '../../js/js.dart' as js; |
17 import '../../js_backend/js_backend.dart' show JavaScriptBackend, Namer; | 17 import '../../js_backend/js_backend.dart' show JavaScriptBackend, Namer; |
| 18 import '../../js_backend/interceptor_data.dart'; |
18 import '../../world.dart' show ClosedWorld; | 19 import '../../world.dart' show ClosedWorld; |
19 import '../js_emitter.dart' show CodeEmitterTask, NativeEmitter; | 20 import '../js_emitter.dart' show CodeEmitterTask, NativeEmitter; |
20 import '../js_emitter.dart' as emitterTask show Emitter, EmitterFactory; | 21 import '../js_emitter.dart' as emitterTask show Emitter, EmitterFactory; |
21 import '../model.dart'; | 22 import '../model.dart'; |
22 import '../program_builder/program_builder.dart' show ProgramBuilder; | 23 import '../program_builder/program_builder.dart' show ProgramBuilder; |
23 import 'model_emitter.dart'; | 24 import 'model_emitter.dart'; |
24 | 25 |
25 class EmitterFactory implements emitterTask.EmitterFactory { | 26 class EmitterFactory implements emitterTask.EmitterFactory { |
26 final bool generateSourceMap; | 27 final bool generateSourceMap; |
27 | 28 |
28 EmitterFactory({this.generateSourceMap}); | 29 EmitterFactory({this.generateSourceMap}); |
29 | 30 |
30 @override | 31 @override |
31 bool get supportsReflection => false; | 32 bool get supportsReflection => false; |
32 | 33 |
33 @override | 34 @override |
34 Emitter createEmitter( | 35 Emitter createEmitter( |
35 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld) { | 36 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld) { |
36 return new Emitter( | 37 return new Emitter(task.compiler, namer, task.nativeEmitter, |
37 task.compiler, namer, task.nativeEmitter, generateSourceMap); | 38 closedWorld.interceptorData, generateSourceMap); |
38 } | 39 } |
39 } | 40 } |
40 | 41 |
41 class Emitter implements emitterTask.Emitter { | 42 class Emitter implements emitterTask.Emitter { |
42 final Compiler _compiler; | 43 final Compiler _compiler; |
43 final Namer namer; | 44 final Namer namer; |
44 final ModelEmitter _emitter; | 45 final ModelEmitter _emitter; |
45 | 46 |
46 JavaScriptBackend get _backend => _compiler.backend; | 47 JavaScriptBackend get _backend => _compiler.backend; |
47 | 48 |
48 Emitter(Compiler compiler, Namer namer, NativeEmitter nativeEmitter, | 49 Emitter(Compiler compiler, Namer namer, NativeEmitter nativeEmitter, |
49 bool shouldGenerateSourceMap) | 50 InterceptorData interceptorData, bool shouldGenerateSourceMap) |
50 : this._compiler = compiler, | 51 : this._compiler = compiler, |
51 this.namer = namer, | 52 this.namer = namer, |
52 _emitter = new ModelEmitter( | 53 _emitter = new ModelEmitter(compiler, namer, nativeEmitter, |
53 compiler, namer, nativeEmitter, shouldGenerateSourceMap); | 54 interceptorData, shouldGenerateSourceMap); |
54 | 55 |
55 DiagnosticReporter get reporter => _compiler.reporter; | 56 DiagnosticReporter get reporter => _compiler.reporter; |
56 | 57 |
57 @override | 58 @override |
58 int emitProgram(ProgramBuilder programBuilder) { | 59 int emitProgram(ProgramBuilder programBuilder) { |
59 Program program = programBuilder.buildProgram(); | 60 Program program = programBuilder.buildProgram(); |
60 return _emitter.emitProgram(program); | 61 return _emitter.emitProgram(program); |
61 } | 62 } |
62 | 63 |
63 @override | 64 @override |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 193 } |
193 } | 194 } |
194 | 195 |
195 @override | 196 @override |
196 int generatedSize(OutputUnit unit) { | 197 int generatedSize(OutputUnit unit) { |
197 Fragment key = _emitter.outputBuffers.keys | 198 Fragment key = _emitter.outputBuffers.keys |
198 .firstWhere((Fragment fragment) => fragment.outputUnit == unit); | 199 .firstWhere((Fragment fragment) => fragment.outputUnit == unit); |
199 return _emitter.outputBuffers[key].length; | 200 return _emitter.outputBuffers[key].length; |
200 } | 201 } |
201 } | 202 } |
OLD | NEW |