| 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.model_emitter; | 5 library dart2js.js_emitter.lazy_emitter.model_emitter; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart' | 7 import 'package:js_runtime/shared/embedded_names.dart' |
| 8 show | 8 show |
| 9 CREATE_NEW_ISOLATE, | 9 CREATE_NEW_ISOLATE, |
| 10 DEFERRED_LIBRARY_URIS, | 10 DEFERRED_LIBRARY_URIS, |
| 11 DEFERRED_LIBRARY_HASHES, | 11 DEFERRED_LIBRARY_HASHES, |
| 12 GET_TYPE_FROM_NAME, | 12 GET_TYPE_FROM_NAME, |
| 13 INITIALIZE_LOADED_HUNK, | 13 INITIALIZE_LOADED_HUNK, |
| 14 INTERCEPTORS_BY_TAG, | 14 INTERCEPTORS_BY_TAG, |
| 15 IS_HUNK_INITIALIZED, | 15 IS_HUNK_INITIALIZED, |
| 16 IS_HUNK_LOADED, | 16 IS_HUNK_LOADED, |
| 17 LEAF_TAGS, | 17 LEAF_TAGS, |
| 18 MANGLED_GLOBAL_NAMES, | 18 MANGLED_GLOBAL_NAMES, |
| 19 METADATA, | 19 METADATA, |
| 20 TYPE_TO_INTERCEPTOR_MAP, | 20 TYPE_TO_INTERCEPTOR_MAP, |
| 21 TYPES; | 21 TYPES; |
| 22 | 22 |
| 23 import '../../compiler.dart' show Compiler; | 23 import '../../compiler.dart' show Compiler; |
| 24 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; | 24 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; |
| 25 import '../../core_types.dart' show CommonElements; | 25 import '../../core_types.dart' show CommonElements; |
| 26 import '../../elements/elements.dart' show ClassElement, FunctionElement; | 26 import '../../elements/elements.dart' show ClassElement, MethodElement; |
| 27 import '../../js/js.dart' as js; | 27 import '../../js/js.dart' as js; |
| 28 import '../../js_backend/js_backend.dart' | 28 import '../../js_backend/js_backend.dart' |
| 29 show JavaScriptBackend, Namer, ConstantEmitter; | 29 show JavaScriptBackend, Namer, ConstantEmitter; |
| 30 import '../constant_ordering.dart' show deepCompareConstants; | 30 import '../constant_ordering.dart' show deepCompareConstants; |
| 31 import '../js_emitter.dart' show NativeEmitter; | 31 import '../js_emitter.dart' show NativeEmitter; |
| 32 import '../js_emitter.dart' show NativeGenerator, buildTearOffCode; | 32 import '../js_emitter.dart' show NativeGenerator, buildTearOffCode; |
| 33 import '../model.dart'; | 33 import '../model.dart'; |
| 34 | 34 |
| 35 class ModelEmitter { | 35 class ModelEmitter { |
| 36 final Compiler compiler; | 36 final Compiler compiler; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 // Sorting by the long name clusters constants with the same constructor | 97 // Sorting by the long name clusters constants with the same constructor |
| 98 // which compresses a tiny bit better. | 98 // which compresses a tiny bit better. |
| 99 int r = namer.constantLongName(a).compareTo(namer.constantLongName(b)); | 99 int r = namer.constantLongName(a).compareTo(namer.constantLongName(b)); |
| 100 if (r != 0) return r; | 100 if (r != 0) return r; |
| 101 | 101 |
| 102 // Resolve collisions in the long name by using a structural order. | 102 // Resolve collisions in the long name by using a structural order. |
| 103 return deepCompareConstants(a, b); | 103 return deepCompareConstants(a, b); |
| 104 } | 104 } |
| 105 | 105 |
| 106 js.Expression generateStaticClosureAccess(FunctionElement element) { | 106 js.Expression generateStaticClosureAccess(MethodElement element) { |
| 107 return js.js('#.#()', | 107 return js.js('#.#()', |
| 108 [namer.globalObjectFor(element), namer.staticClosureName(element)]); | 108 [namer.globalObjectFor(element), namer.staticClosureName(element)]); |
| 109 } | 109 } |
| 110 | 110 |
| 111 js.Expression generateConstantReference(ConstantValue value) { | 111 js.Expression generateConstantReference(ConstantValue value) { |
| 112 if (value.isFunction) { | 112 if (value.isFunction) { |
| 113 FunctionConstantValue functionConstant = value; | 113 FunctionConstantValue functionConstant = value; |
| 114 return generateStaticClosureAccess(functionConstant.element); | 114 return generateStaticClosureAccess(functionConstant.element); |
| 115 } | 115 } |
| 116 | 116 |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 #eagerClasses; | 1267 #eagerClasses; |
| 1268 | 1268 |
| 1269 var end = Date.now(); | 1269 var end = Date.now(); |
| 1270 // print('Setup: ' + (end - start) + ' ms.'); | 1270 // print('Setup: ' + (end - start) + ' ms.'); |
| 1271 | 1271 |
| 1272 #invokeMain; // Start main. | 1272 #invokeMain; // Start main. |
| 1273 | 1273 |
| 1274 })(Date.now(), #code) | 1274 })(Date.now(), #code) |
| 1275 }"""; | 1275 }"""; |
| 1276 } | 1276 } |
| OLD | NEW |