| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.lazy_emitter; | 5 library dart2js.js_emitter.lazy_emitter; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin; | 7 import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin; |
| 8 | 8 |
| 9 import '../../common.dart'; | 9 import '../../common.dart'; |
| 10 import '../../compiler.dart' show Compiler; | 10 import '../../compiler.dart' show Compiler; |
| 11 import '../../constants/values.dart' show ConstantValue; | 11 import '../../constants/values.dart' show ConstantValue; |
| 12 import '../../elements/elements.dart' | 12 import '../../elements/elements.dart' |
| 13 show ClassElement, Element, FieldElement, FunctionElement; | 13 show ClassElement, Element, FieldElement, FunctionElement; |
| 14 import '../../js/js.dart' as js; | 14 import '../../js/js.dart' as js; |
| 15 import '../../js_backend/js_backend.dart' show JavaScriptBackend, Namer; | 15 import '../../js_backend/js_backend.dart' show JavaScriptBackend, Namer; |
| 16 import '../js_emitter.dart' show NativeEmitter; | 16 import '../../world.dart' show ClosedWorld; |
| 17 import '../js_emitter.dart' as emitterTask show Emitter; | 17 import '../js_emitter.dart' show CodeEmitterTask, NativeEmitter; |
| 18 import '../js_emitter.dart' as emitterTask show Emitter, EmitterFactory; |
| 18 import '../model.dart'; | 19 import '../model.dart'; |
| 19 import '../program_builder/program_builder.dart' show ProgramBuilder; | 20 import '../program_builder/program_builder.dart' show ProgramBuilder; |
| 20 import 'model_emitter.dart'; | 21 import 'model_emitter.dart'; |
| 21 | 22 |
| 23 class EmitterFactory implements emitterTask.EmitterFactory { |
| 24 @override |
| 25 String get patchVersion => "lazy"; |
| 26 |
| 27 @override |
| 28 bool get supportsReflection => false; |
| 29 |
| 30 @override |
| 31 Emitter createEmitter( |
| 32 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld) { |
| 33 return new Emitter(task.compiler, namer, task.nativeEmitter); |
| 34 } |
| 35 } |
| 36 |
| 22 class Emitter implements emitterTask.Emitter { | 37 class Emitter implements emitterTask.Emitter { |
| 23 final Compiler _compiler; | 38 final Compiler _compiler; |
| 24 final Namer namer; | 39 final Namer namer; |
| 25 final ModelEmitter _emitter; | 40 final ModelEmitter _emitter; |
| 26 | 41 |
| 27 JavaScriptBackend get _backend => _compiler.backend; | 42 JavaScriptBackend get _backend => _compiler.backend; |
| 28 | 43 |
| 29 Emitter(Compiler compiler, Namer namer, NativeEmitter nativeEmitter) | 44 Emitter(Compiler compiler, Namer namer, NativeEmitter nativeEmitter) |
| 30 : this._compiler = compiler, | 45 : this._compiler = compiler, |
| 31 this.namer = namer, | 46 this.namer = namer, |
| 32 _emitter = new ModelEmitter(compiler, namer, nativeEmitter); | 47 _emitter = new ModelEmitter(compiler, namer, nativeEmitter); |
| 33 | 48 |
| 34 DiagnosticReporter get reporter => _compiler.reporter; | 49 DiagnosticReporter get reporter => _compiler.reporter; |
| 35 | 50 |
| 36 @override | 51 @override |
| 37 String get patchVersion => "lazy"; | |
| 38 | |
| 39 @override | |
| 40 int emitProgram(ProgramBuilder programBuilder) { | 52 int emitProgram(ProgramBuilder programBuilder) { |
| 41 Program program = programBuilder.buildProgram(); | 53 Program program = programBuilder.buildProgram(); |
| 42 return _emitter.emitProgram(program); | 54 return _emitter.emitProgram(program); |
| 43 } | 55 } |
| 44 | 56 |
| 45 @override | |
| 46 bool get supportsReflection => false; | |
| 47 | |
| 48 // TODO(floitsch): copied from full emitter. Adjust or share. | 57 // TODO(floitsch): copied from full emitter. Adjust or share. |
| 49 @override | 58 @override |
| 50 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant) { | 59 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant) { |
| 51 return _emitter.isConstantInlinedOrAlreadyEmitted(constant); | 60 return _emitter.isConstantInlinedOrAlreadyEmitted(constant); |
| 52 } | 61 } |
| 53 | 62 |
| 54 // TODO(floitsch): copied from full emitter. Adjust or share. | 63 // TODO(floitsch): copied from full emitter. Adjust or share. |
| 55 @override | 64 @override |
| 56 int compareConstants(ConstantValue a, ConstantValue b) { | 65 int compareConstants(ConstantValue a, ConstantValue b) { |
| 57 return _emitter.compareConstants(a, b); | 66 return _emitter.compareConstants(a, b); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 default: | 183 default: |
| 175 reporter.internalError( | 184 reporter.internalError( |
| 176 NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin"); | 185 NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin"); |
| 177 return null; | 186 return null; |
| 178 } | 187 } |
| 179 } | 188 } |
| 180 | 189 |
| 181 @override | 190 @override |
| 182 void invalidateCaches() {} | 191 void invalidateCaches() {} |
| 183 } | 192 } |
| OLD | NEW |