| 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; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 @override | 29 @override |
| 30 Emitter createEmitter( | 30 Emitter createEmitter( |
| 31 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld) { | 31 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld) { |
| 32 return new Emitter( | 32 return new Emitter( |
| 33 task.compiler, namer, task.nativeEmitter, closedWorld, task); | 33 task.compiler, namer, task.nativeEmitter, closedWorld, task); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 class Emitter extends emitterTask.EmitterBase { | 37 class Emitter extends emitterTask.EmitterBase { |
| 38 final Compiler _compiler; | 38 final Compiler _compiler; |
| 39 final ClosedWorld _closedWorld; |
| 39 final Namer namer; | 40 final Namer namer; |
| 40 final ModelEmitter _emitter; | 41 final ModelEmitter _emitter; |
| 41 | 42 |
| 42 JavaScriptBackend get _backend => _compiler.backend; | 43 JavaScriptBackend get _backend => _compiler.backend; |
| 43 | 44 |
| 44 Emitter(Compiler compiler, Namer namer, NativeEmitter nativeEmitter, | 45 Emitter(this._compiler, this.namer, NativeEmitter nativeEmitter, |
| 45 ClosedWorld closedWorld, CodeEmitterTask task) | 46 this._closedWorld, CodeEmitterTask task) |
| 46 : this._compiler = compiler, | 47 : _emitter = new ModelEmitter( |
| 47 this.namer = namer, | 48 _compiler, namer, nativeEmitter, _closedWorld, task); |
| 48 _emitter = | |
| 49 new ModelEmitter(compiler, namer, nativeEmitter, closedWorld, task); | |
| 50 | 49 |
| 51 DiagnosticReporter get reporter => _compiler.reporter; | 50 DiagnosticReporter get reporter => _compiler.reporter; |
| 52 | 51 |
| 53 @override | 52 @override |
| 54 int emitProgram(ProgramBuilder programBuilder) { | 53 int emitProgram(ProgramBuilder programBuilder) { |
| 55 Program program = programBuilder.buildProgram(); | 54 Program program = programBuilder.buildProgram(); |
| 56 return _emitter.emitProgram(program); | 55 return _emitter.emitProgram(program); |
| 57 } | 56 } |
| 58 | 57 |
| 59 // TODO(floitsch): copied from full emitter. Adjust or share. | 58 // TODO(floitsch): copied from full emitter. Adjust or share. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 return js.js('#.ensureResolved()', globalPropertyAccessForType(element)); | 118 return js.js('#.ensureResolved()', globalPropertyAccessForType(element)); |
| 120 } | 119 } |
| 121 | 120 |
| 122 @override | 121 @override |
| 123 js.Template templateForBuiltin(JsBuiltin builtin) { | 122 js.Template templateForBuiltin(JsBuiltin builtin) { |
| 124 String typeNameProperty = ModelEmitter.typeNameProperty; | 123 String typeNameProperty = ModelEmitter.typeNameProperty; |
| 125 | 124 |
| 126 switch (builtin) { | 125 switch (builtin) { |
| 127 case JsBuiltin.dartObjectConstructor: | 126 case JsBuiltin.dartObjectConstructor: |
| 128 return js.js.expressionTemplateYielding( | 127 return js.js.expressionTemplateYielding( |
| 129 typeAccess(_compiler.commonElements.objectClass)); | 128 typeAccess(_closedWorld.commonElements.objectClass)); |
| 130 | 129 |
| 131 case JsBuiltin.isCheckPropertyToJsConstructorName: | 130 case JsBuiltin.isCheckPropertyToJsConstructorName: |
| 132 int isPrefixLength = namer.operatorIsPrefix.length; | 131 int isPrefixLength = namer.operatorIsPrefix.length; |
| 133 return js.js.expressionTemplateFor('#.substring($isPrefixLength)'); | 132 return js.js.expressionTemplateFor('#.substring($isPrefixLength)'); |
| 134 | 133 |
| 135 case JsBuiltin.isFunctionType: | 134 case JsBuiltin.isFunctionType: |
| 136 return _backend.rtiEncoder.templateForIsFunctionType; | 135 return _backend.rtiEncoder.templateForIsFunctionType; |
| 137 | 136 |
| 138 case JsBuiltin.rawRtiToJsConstructorName: | 137 case JsBuiltin.rawRtiToJsConstructorName: |
| 139 return js.js.expressionTemplateFor("#.$typeNameProperty"); | 138 return js.js.expressionTemplateFor("#.$typeNameProperty"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 166 reporter.internalError( | 165 reporter.internalError( |
| 167 NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin"); | 166 NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin"); |
| 168 return null; | 167 return null; |
| 169 } | 168 } |
| 170 } | 169 } |
| 171 | 170 |
| 172 @override | 171 @override |
| 173 // TODO(het): Generate this correctly | 172 // TODO(het): Generate this correctly |
| 174 int generatedSize(OutputUnit unit) => 0; | 173 int generatedSize(OutputUnit unit) => 0; |
| 175 } | 174 } |
| OLD | NEW |