| 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 '../../elements/elements.dart' | 13 import '../../elements/elements.dart' |
| 14 show ClassElement, Element, FieldElement, FunctionElement; | 14 show ClassElement, Element, FieldElement, FunctionElement; |
| 15 import '../../js/js.dart' as js; | 15 import '../../js/js.dart' as js; |
| 16 import '../../js_backend/js_backend.dart' show JavaScriptBackend, Namer; | 16 import '../../js_backend/js_backend.dart' show JavaScriptBackend, Namer; |
| 17 import '../js_emitter.dart' show NativeEmitter; | 17 import '../../world.dart' show ClosedWorld; |
| 18 import '../js_emitter.dart' as emitterTask show Emitter; | 18 import '../js_emitter.dart' show CodeEmitterTask, NativeEmitter; |
| 19 import '../js_emitter.dart' as emitterTask show Emitter, EmitterFactory; |
| 19 import '../model.dart'; | 20 import '../model.dart'; |
| 20 import '../program_builder/program_builder.dart' show ProgramBuilder; | 21 import '../program_builder/program_builder.dart' show ProgramBuilder; |
| 21 import 'model_emitter.dart'; | 22 import 'model_emitter.dart'; |
| 22 | 23 |
| 24 class EmitterFactory implements emitterTask.EmitterFactory { |
| 25 final bool generateSourceMap; |
| 26 |
| 27 EmitterFactory({this.generateSourceMap}); |
| 28 |
| 29 @override |
| 30 String get patchVersion => "startup"; |
| 31 |
| 32 @override |
| 33 bool get supportsReflection => false; |
| 34 |
| 35 @override |
| 36 Emitter createEmitter( |
| 37 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld) { |
| 38 return new Emitter( |
| 39 task.compiler, namer, task.nativeEmitter, generateSourceMap); |
| 40 } |
| 41 } |
| 42 |
| 23 class Emitter implements emitterTask.Emitter { | 43 class Emitter implements emitterTask.Emitter { |
| 24 final Compiler _compiler; | 44 final Compiler _compiler; |
| 25 final Namer namer; | 45 final Namer namer; |
| 26 final ModelEmitter _emitter; | 46 final ModelEmitter _emitter; |
| 27 | 47 |
| 28 JavaScriptBackend get _backend => _compiler.backend; | 48 JavaScriptBackend get _backend => _compiler.backend; |
| 29 | 49 |
| 30 Emitter(Compiler compiler, Namer namer, NativeEmitter nativeEmitter, | 50 Emitter(Compiler compiler, Namer namer, NativeEmitter nativeEmitter, |
| 31 bool shouldGenerateSourceMap) | 51 bool shouldGenerateSourceMap) |
| 32 : this._compiler = compiler, | 52 : this._compiler = compiler, |
| 33 this.namer = namer, | 53 this.namer = namer, |
| 34 _emitter = new ModelEmitter( | 54 _emitter = new ModelEmitter( |
| 35 compiler, namer, nativeEmitter, shouldGenerateSourceMap); | 55 compiler, namer, nativeEmitter, shouldGenerateSourceMap); |
| 36 | 56 |
| 37 DiagnosticReporter get reporter => _compiler.reporter; | 57 DiagnosticReporter get reporter => _compiler.reporter; |
| 38 | 58 |
| 39 @override | 59 @override |
| 40 String get patchVersion => "startup"; | |
| 41 | |
| 42 @override | |
| 43 int emitProgram(ProgramBuilder programBuilder) { | 60 int emitProgram(ProgramBuilder programBuilder) { |
| 44 Program program = programBuilder.buildProgram(); | 61 Program program = programBuilder.buildProgram(); |
| 45 return _emitter.emitProgram(program); | 62 return _emitter.emitProgram(program); |
| 46 } | 63 } |
| 47 | 64 |
| 48 @override | 65 @override |
| 49 bool get supportsReflection => false; | |
| 50 | |
| 51 @override | |
| 52 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant) { | 66 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant) { |
| 53 return _emitter.isConstantInlinedOrAlreadyEmitted(constant); | 67 return _emitter.isConstantInlinedOrAlreadyEmitted(constant); |
| 54 } | 68 } |
| 55 | 69 |
| 56 @override | 70 @override |
| 57 int compareConstants(ConstantValue a, ConstantValue b) { | 71 int compareConstants(ConstantValue a, ConstantValue b) { |
| 58 return _emitter.compareConstants(a, b); | 72 return _emitter.compareConstants(a, b); |
| 59 } | 73 } |
| 60 | 74 |
| 61 @override | 75 @override |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 default: | 190 default: |
| 177 reporter.internalError( | 191 reporter.internalError( |
| 178 NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin"); | 192 NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin"); |
| 179 return null; | 193 return null; |
| 180 } | 194 } |
| 181 } | 195 } |
| 182 | 196 |
| 183 @override | 197 @override |
| 184 void invalidateCaches() {} | 198 void invalidateCaches() {} |
| 185 } | 199 } |
| OLD | NEW |