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.full_emitter; | 5 library dart2js.js_emitter.full_emitter; |
6 | 6 |
7 import 'dart:collection' show HashMap; | 7 import 'dart:collection' show HashMap; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 | 9 |
10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
11 import 'package:js_runtime/shared/embedded_names.dart' | 11 import 'package:js_runtime/shared/embedded_names.dart' |
12 show JsBuiltin, JsGetName; | 12 show JsBuiltin, JsGetName; |
13 | 13 |
14 import '../../../compiler_new.dart'; | 14 import '../../../compiler_new.dart'; |
15 import '../../common.dart'; | 15 import '../../common.dart'; |
16 import '../../compiler.dart' show Compiler; | 16 import '../../compiler.dart' show Compiler; |
17 import '../../constants/values.dart'; | 17 import '../../constants/values.dart'; |
18 import '../../common_elements.dart' show CommonElements, ElementEnvironment; | 18 import '../../common_elements.dart' show CommonElements, ElementEnvironment; |
19 import '../../elements/resolution_types.dart' show ResolutionDartType; | 19 import '../../elements/resolution_types.dart' show ResolutionDartType; |
20 import '../../deferred_load.dart' show OutputUnit; | 20 import '../../deferred_load.dart' show OutputUnit; |
21 import '../../elements/elements.dart' | 21 import '../../elements/elements.dart' |
22 show | 22 show |
23 ClassElement, | 23 ClassElement, |
24 ConstructorBodyElement, | 24 ConstructorBodyElement, |
25 FieldElement, | 25 FieldElement, |
26 LibraryElement, | 26 LibraryElement, |
27 MethodElement, | |
28 TypedefElement; | 27 TypedefElement; |
29 import '../../elements/entities.dart'; | 28 import '../../elements/entities.dart'; |
30 import '../../elements/entity_utils.dart' as utils; | 29 import '../../elements/entity_utils.dart' as utils; |
31 import '../../elements/names.dart'; | 30 import '../../elements/names.dart'; |
32 import '../../hash/sha1.dart' show Hasher; | 31 import '../../hash/sha1.dart' show Hasher; |
33 import '../../io/code_output.dart'; | 32 import '../../io/code_output.dart'; |
34 import '../../io/location_provider.dart' show LocationCollector; | 33 import '../../io/location_provider.dart' show LocationCollector; |
35 import '../../io/source_map_builder.dart' show SourceMapBuilder; | 34 import '../../io/source_map_builder.dart' show SourceMapBuilder; |
36 import '../../js/js.dart' as jsAst; | 35 import '../../js/js.dart' as jsAst; |
37 import '../../js/js.dart' show js; | 36 import '../../js/js.dart' show js; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 final bool generateSourceMap; | 176 final bool generateSourceMap; |
178 | 177 |
179 Emitter(this.compiler, this.namer, this._closedWorld, this.generateSourceMap, | 178 Emitter(this.compiler, this.namer, this._closedWorld, this.generateSourceMap, |
180 this.task, this._sorter) | 179 this.task, this._sorter) |
181 : classEmitter = new ClassEmitter(_closedWorld), | 180 : classEmitter = new ClassEmitter(_closedWorld), |
182 interceptorEmitter = new InterceptorEmitter(_closedWorld), | 181 interceptorEmitter = new InterceptorEmitter(_closedWorld), |
183 nsmEmitter = new NsmEmitter(_closedWorld) { | 182 nsmEmitter = new NsmEmitter(_closedWorld) { |
184 constantEmitter = new ConstantEmitter( | 183 constantEmitter = new ConstantEmitter( |
185 compiler.options, | 184 compiler.options, |
186 _closedWorld.commonElements, | 185 _closedWorld.commonElements, |
| 186 compiler.codegenWorldBuilder, |
187 compiler.backend.rtiNeed, | 187 compiler.backend.rtiNeed, |
188 compiler.backend.rtiEncoder, | 188 compiler.backend.rtiEncoder, |
189 namer, | 189 namer, |
190 task, | 190 task, |
191 this.constantReference, | 191 this.constantReference, |
192 constantListGenerator); | 192 constantListGenerator); |
193 containerBuilder.emitter = this; | 193 containerBuilder.emitter = this; |
194 classEmitter.emitter = this; | 194 classEmitter.emitter = this; |
195 nsmEmitter.emitter = this; | 195 nsmEmitter.emitter = this; |
196 interceptorEmitter.emitter = this; | 196 interceptorEmitter.emitter = this; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 jsAst.Expression generateEmbeddedGlobalAccess(String global) { | 296 jsAst.Expression generateEmbeddedGlobalAccess(String global) { |
297 return js(generateEmbeddedGlobalAccessString(global)); | 297 return js(generateEmbeddedGlobalAccessString(global)); |
298 } | 298 } |
299 | 299 |
300 String generateEmbeddedGlobalAccessString(String global) { | 300 String generateEmbeddedGlobalAccessString(String global) { |
301 // TODO(floitsch): don't use 'init' as global embedder storage. | 301 // TODO(floitsch): don't use 'init' as global embedder storage. |
302 return '$initName.$global'; | 302 return '$initName.$global'; |
303 } | 303 } |
304 | 304 |
305 @override | 305 @override |
306 jsAst.Expression isolateLazyInitializerAccess(FieldElement element) { | 306 jsAst.Expression isolateLazyInitializerAccess(FieldEntity element) { |
307 return jsAst.js('#.#', [ | 307 return jsAst.js('#.#', [ |
308 namer.globalObjectForMember(element), | 308 namer.globalObjectForMember(element), |
309 namer.lazyInitializerName(element) | 309 namer.lazyInitializerName(element) |
310 ]); | 310 ]); |
311 } | 311 } |
312 | 312 |
313 @override | 313 @override |
314 jsAst.Expression isolateStaticClosureAccess(MethodElement element) { | 314 jsAst.Expression isolateStaticClosureAccess(FunctionEntity element) { |
315 return jsAst.js('#.#()', [ | 315 return jsAst.js('#.#()', [ |
316 namer.globalObjectForMember(element), | 316 namer.globalObjectForMember(element), |
317 namer.staticClosureName(element) | 317 namer.staticClosureName(element) |
318 ]); | 318 ]); |
319 } | 319 } |
320 | 320 |
321 @override | 321 @override |
322 jsAst.PropertyAccess prototypeAccess( | 322 jsAst.PropertyAccess prototypeAccess( |
323 ClassElement element, bool hasBeenInstantiated) { | 323 ClassElement element, bool hasBeenInstantiated) { |
324 return jsAst.js('#.prototype', constructorAccess(element)); | 324 return jsAst.js('#.prototype', constructorAccess(element)); |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 // data. | 1972 // data. |
1973 mapping["_comment"] = "This mapping shows which compiled `.js` files are " | 1973 mapping["_comment"] = "This mapping shows which compiled `.js` files are " |
1974 "needed for a given deferred library import."; | 1974 "needed for a given deferred library import."; |
1975 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); | 1975 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); |
1976 compiler.outputProvider( | 1976 compiler.outputProvider( |
1977 compiler.options.deferredMapUri.path, '', OutputType.info) | 1977 compiler.options.deferredMapUri.path, '', OutputType.info) |
1978 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) | 1978 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) |
1979 ..close(); | 1979 ..close(); |
1980 } | 1980 } |
1981 } | 1981 } |
OLD | NEW |