| 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 '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| 11 | 11 |
| 12 import '../../js_backend/js_backend.dart' show Namer, JavaScriptBackend; | 12 import '../../js_backend/js_backend.dart' show Namer, JavaScriptBackend; |
| 13 import '../../js_emitter/js_emitter.dart' as emitterTask show | 13 import '../../js_emitter/js_emitter.dart' as emitterTask show |
| 14 CodeEmitterTask, | 14 CodeEmitterTask, |
| 15 Emitter; | 15 Emitter; |
| 16 import '../../deferred_load.dart'; |
| 16 | 17 |
| 17 class Emitter implements emitterTask.Emitter { | 18 class Emitter implements emitterTask.Emitter { |
| 18 final Compiler _compiler; | 19 final Compiler _compiler; |
| 19 final Namer namer; | 20 final Namer namer; |
| 20 final ModelEmitter _emitter; | 21 final ModelEmitter _emitter; |
| 21 | 22 |
| 22 Emitter(Compiler compiler, Namer namer) | 23 Emitter(Compiler compiler, Namer namer) |
| 23 : this._compiler = compiler, | 24 : this._compiler = compiler, |
| 24 this.namer = namer, | 25 this.namer = namer, |
| 25 _emitter = new ModelEmitter(compiler, namer); | 26 _emitter = new ModelEmitter(compiler, namer); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 js.Expression generateEmbeddedGlobalAccess(String global) { | 67 js.Expression generateEmbeddedGlobalAccess(String global) { |
| 67 // TODO(floitsch): We should not use "init" for globals. | 68 // TODO(floitsch): We should not use "init" for globals. |
| 68 return js.string("init.$global"); | 69 return js.string("init.$global"); |
| 69 } | 70 } |
| 70 | 71 |
| 71 js.Expression constantReference(ConstantValue value) { | 72 js.Expression constantReference(ConstantValue value) { |
| 72 return _emitter.constantEmitter.reference(value); | 73 return _emitter.constantEmitter.reference(value); |
| 73 } | 74 } |
| 74 | 75 |
| 75 js.Expression isolateLazyInitializerAccess(Element element) { | 76 js.Expression isolateLazyInitializerAccess(Element element) { |
| 76 return js.js('#.#', [namer.globalObjectFor(element), | 77 return js.js('#.#', [namer.globalObjectFor(element), |
| 77 namer.getLazyInitializerName(element)]); | 78 namer.getLazyInitializerName(element)]); |
| 78 } | 79 } |
| 79 | 80 |
| 80 js.Expression isolateStaticClosureAccess(Element element) { | 81 js.Expression isolateStaticClosureAccess(Element element) { |
| 81 return js.js('#.#()', | 82 return js.js('#.#()', |
| 82 [namer.globalObjectFor(element), namer.getStaticClosureName(element)]); | 83 [namer.globalObjectFor(element), namer.getStaticClosureName(element)]); |
| 83 } | 84 } |
| 84 | 85 |
| 85 js.PropertyAccess globalPropertyAccess(Element element) { | 86 js.PropertyAccess globalPropertyAccess(Element element) { |
| 86 String name = namer.getNameX(element); | 87 String name = namer.getNameX(element); |
| 87 js.PropertyAccess pa = new js.PropertyAccess.field( | 88 js.PropertyAccess pa = new js.PropertyAccess.field( |
| 88 new js.VariableUse(namer.globalObjectFor(element)), | 89 new js.VariableUse(namer.globalObjectFor(element)), |
| 89 name); | 90 name); |
| 90 return pa; | 91 return pa; |
| 91 } | 92 } |
| 92 | 93 |
| 93 js.PropertyAccess staticFieldAccess(Element element) { | 94 js.PropertyAccess staticFieldAccess(Element element) { |
| 94 return globalPropertyAccess(element); | 95 return globalPropertyAccess(element); |
| 95 } | 96 } |
| 96 | 97 |
| 97 js.PropertyAccess staticFunctionAccess(Element element) { | 98 js.PropertyAccess staticFunctionAccess(Element element) { |
| 98 return globalPropertyAccess(element); | 99 return globalPropertyAccess(element); |
| 99 } | 100 } |
| 100 | 101 |
| 101 js.PropertyAccess classAccess(Element element) { | 102 js.PropertyAccess classAccess(Element element) { |
| 102 return globalPropertyAccess(element); | 103 return globalPropertyAccess(element); |
| 103 } | 104 } |
| 104 | 105 |
| 105 js.PropertyAccess typedefAccess(Element element) { | 106 js.PropertyAccess typedefAccess(Element element) { |
| 106 return globalPropertyAccess(element); | 107 return globalPropertyAccess(element); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void invalidateCaches() {} | 110 void invalidateCaches() {} |
| 111 |
| 110 } | 112 } |
| OLD | NEW |