| 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.new_js_emitter.emitter; | 5 library dart2js.new_js_emitter.emitter; |
| 6 | 6 |
| 7 import '../model.dart'; | 7 import '../model.dart'; |
| 8 import 'model_emitter.dart'; | 8 import 'model_emitter.dart'; |
| 9 import '../../common.dart'; | 9 import '../../common.dart'; |
| 10 import '../../elements/elements.dart' show FieldElement; | 10 import '../../elements/elements.dart' show FieldElement; |
| 11 import '../../js/js.dart' as js; | 11 import '../../js/js.dart' as js; |
| 12 | 12 |
| 13 import '../../js_backend/js_backend.dart' show Namer, JavaScriptBackend; | 13 import '../../js_backend/js_backend.dart' show Namer, JavaScriptBackend; |
| 14 import '../../js_emitter/js_emitter.dart' as emitterTask show | 14 import '../../js_emitter/js_emitter.dart' as emitterTask show |
| 15 CodeEmitterTask, | 15 CodeEmitterTask, |
| 16 Emitter; | 16 Emitter; |
| 17 | 17 |
| 18 class Emitter implements emitterTask.Emitter { | 18 class Emitter implements emitterTask.Emitter { |
| 19 final Compiler _compiler; | 19 final Compiler _compiler; |
| 20 final Namer namer; | 20 final Namer namer; |
| 21 final ModelEmitter _emitter; | 21 final ModelEmitter _emitter; |
| 22 | 22 |
| 23 Emitter(Compiler compiler, Namer namer) | 23 Emitter(Compiler compiler, Namer namer) |
| 24 : this._compiler = compiler, | 24 : this._compiler = compiler, |
| 25 this.namer = namer, | 25 this.namer = namer, |
| 26 _emitter = new ModelEmitter(compiler, namer); | 26 _emitter = new ModelEmitter(compiler, namer); |
| 27 | 27 |
| 28 @override | 28 @override |
| 29 int emitProgram(Program program) { | 29 void emitProgram(Program program) { |
| 30 return _emitter.emitProgram(program); | 30 _emitter.emitProgram(program); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // TODO(floitsch): copied from OldEmitter. Adjust or share. | 33 // TODO(floitsch): copied from OldEmitter. Adjust or share. |
| 34 @override | 34 @override |
| 35 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant) { | 35 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant) { |
| 36 if (constant.isFunction) return true; // Already emitted. | 36 if (constant.isFunction) return true; // Already emitted. |
| 37 if (constant.isPrimitive) return true; // Inlined. | 37 if (constant.isPrimitive) return true; // Inlined. |
| 38 if (constant.isDummy) return true; // Inlined. | 38 if (constant.isDummy) return true; // Inlined. |
| 39 // The name is null when the constant is already a JS constant. | 39 // The name is null when the constant is already a JS constant. |
| 40 // TODO(floitsch): every constant should be registered, so that we can | 40 // TODO(floitsch): every constant should be registered, so that we can |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 @override | 130 @override |
| 131 js.Expression typeAccess(Element element) { | 131 js.Expression typeAccess(Element element) { |
| 132 // TODO(floitsch): minify 'ensureResolved'. | 132 // TODO(floitsch): minify 'ensureResolved'. |
| 133 // TODO(floitsch): don't emit `ensureResolved` for eager classes. | 133 // TODO(floitsch): don't emit `ensureResolved` for eager classes. |
| 134 return js.js('#.ensureResolved()', _globalPropertyAccess(element)); | 134 return js.js('#.ensureResolved()', _globalPropertyAccess(element)); |
| 135 } | 135 } |
| 136 | 136 |
| 137 @override | 137 @override |
| 138 void invalidateCaches() {} | 138 void invalidateCaches() {} |
| 139 } | 139 } |
| OLD | NEW |