| 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, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 TYPES; | 21 TYPES; |
| 22 | 22 |
| 23 import '../../../compiler_new.dart'; | 23 import '../../../compiler_new.dart'; |
| 24 import '../../compiler.dart' show Compiler; | 24 import '../../compiler.dart' show Compiler; |
| 25 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; | 25 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; |
| 26 import '../../common_elements.dart' show CommonElements; | 26 import '../../common_elements.dart' show CommonElements; |
| 27 import '../../elements/elements.dart' show ClassElement, MethodElement; | 27 import '../../elements/elements.dart' show ClassElement, MethodElement; |
| 28 import '../../js/js.dart' as js; | 28 import '../../js/js.dart' as js; |
| 29 import '../../js_backend/js_backend.dart' | 29 import '../../js_backend/js_backend.dart' |
| 30 show JavaScriptBackend, Namer, ConstantEmitter; | 30 show JavaScriptBackend, Namer, ConstantEmitter; |
| 31 import '../../js_backend/interceptor_data.dart'; |
| 31 import '../constant_ordering.dart' show deepCompareConstants; | 32 import '../constant_ordering.dart' show deepCompareConstants; |
| 32 import '../js_emitter.dart' show NativeEmitter; | 33 import '../js_emitter.dart' show NativeEmitter; |
| 33 import '../js_emitter.dart' show NativeGenerator, buildTearOffCode; | 34 import '../js_emitter.dart' show NativeGenerator, buildTearOffCode; |
| 34 import '../model.dart'; | 35 import '../model.dart'; |
| 35 | 36 |
| 36 class ModelEmitter { | 37 class ModelEmitter { |
| 37 final Compiler compiler; | 38 final Compiler compiler; |
| 38 final Namer namer; | 39 final Namer namer; |
| 39 ConstantEmitter constantEmitter; | 40 ConstantEmitter constantEmitter; |
| 40 final NativeEmitter nativeEmitter; | 41 final NativeEmitter nativeEmitter; |
| 41 | 42 |
| 42 JavaScriptBackend get backend => compiler.backend; | 43 JavaScriptBackend get backend => compiler.backend; |
| 43 | 44 |
| 44 /// For deferred loading we communicate the initializers via this global var. | 45 /// For deferred loading we communicate the initializers via this global var. |
| 45 static const String deferredInitializersGlobal = | 46 static const String deferredInitializersGlobal = |
| 46 r"$__dart_deferred_initializers__"; | 47 r"$__dart_deferred_initializers__"; |
| 47 | 48 |
| 48 static const String deferredExtension = "part.js"; | 49 static const String deferredExtension = "part.js"; |
| 49 | 50 |
| 50 static const String typeNameProperty = r"builtin$cls"; | 51 static const String typeNameProperty = r"builtin$cls"; |
| 51 | 52 |
| 52 ModelEmitter(Compiler compiler, Namer namer, this.nativeEmitter) | 53 ModelEmitter(Compiler compiler, Namer namer, this.nativeEmitter) |
| 53 : this.compiler = compiler, | 54 : this.compiler = compiler, |
| 54 this.namer = namer { | 55 this.namer = namer { |
| 55 this.constantEmitter = new ConstantEmitter( | 56 this.constantEmitter = new ConstantEmitter( |
| 56 compiler, namer, this.generateConstantReference, constantListGenerator); | 57 compiler, namer, this.generateConstantReference, constantListGenerator); |
| 57 } | 58 } |
| 58 | 59 |
| 60 InterceptorData get _interceptorData => |
| 61 // TODO(johnniwinther): Pass [InterceptorData] directly? |
| 62 nativeEmitter.interceptorData; |
| 63 |
| 59 js.Expression constantListGenerator(js.Expression array) { | 64 js.Expression constantListGenerator(js.Expression array) { |
| 60 // TODO(floitsch): remove hard-coded name. | 65 // TODO(floitsch): remove hard-coded name. |
| 61 return js.js('makeConstList(#)', [array]); | 66 return js.js('makeConstList(#)', [array]); |
| 62 } | 67 } |
| 63 | 68 |
| 64 js.Expression generateEmbeddedGlobalAccess(String global) { | 69 js.Expression generateEmbeddedGlobalAccess(String global) { |
| 65 return js.js(generateEmbeddedGlobalAccessString(global)); | 70 return js.js(generateEmbeddedGlobalAccessString(global)); |
| 66 } | 71 } |
| 67 | 72 |
| 68 String generateEmbeddedGlobalAccessString(String global) { | 73 String generateEmbeddedGlobalAccessString(String global) { |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 // functionType, stub1_name, stub1_callName, stub1_code, ...] | 865 // functionType, stub1_name, stub1_callName, stub1_code, ...] |
| 861 var data = []; | 866 var data = []; |
| 862 if (method.aliasName != null) { | 867 if (method.aliasName != null) { |
| 863 data.add(js.quoteName(method.aliasName)); | 868 data.add(js.quoteName(method.aliasName)); |
| 864 } | 869 } |
| 865 data.add(method.code); | 870 data.add(method.code); |
| 866 data.add(js.quoteName(method.callName, allowNull: true)); | 871 data.add(js.quoteName(method.callName, allowNull: true)); |
| 867 | 872 |
| 868 if (method.needsTearOff) { | 873 if (method.needsTearOff) { |
| 869 MethodElement element = method.element; | 874 MethodElement element = method.element; |
| 870 bool isIntercepted = | 875 bool isIntercepted = _interceptorData.isInterceptedMethod(element); |
| 871 backend.interceptorData.isInterceptedMethod(element); | |
| 872 data.add(new js.LiteralBool(isIntercepted)); | 876 data.add(new js.LiteralBool(isIntercepted)); |
| 873 data.add(js.quoteName(method.tearOffName)); | 877 data.add(js.quoteName(method.tearOffName)); |
| 874 data.add((method.functionType)); | 878 data.add((method.functionType)); |
| 875 } | 879 } |
| 876 | 880 |
| 877 data.addAll(method.parameterStubs.expand(makeNameCallNameCodeTriplet)); | 881 data.addAll(method.parameterStubs.expand(makeNameCallNameCodeTriplet)); |
| 878 if (method.canBeApplied) { | 882 if (method.canBeApplied) { |
| 879 data.add(js.number(method.requiredParameterCount)); | 883 data.add(js.number(method.requiredParameterCount)); |
| 880 data.add(_encodeOptionalParameterDefaultValues(method)); | 884 data.add(_encodeOptionalParameterDefaultValues(method)); |
| 881 } | 885 } |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 #eagerClasses; | 1279 #eagerClasses; |
| 1276 | 1280 |
| 1277 var end = Date.now(); | 1281 var end = Date.now(); |
| 1278 // print('Setup: ' + (end - start) + ' ms.'); | 1282 // print('Setup: ' + (end - start) + ' ms.'); |
| 1279 | 1283 |
| 1280 #invokeMain; // Start main. | 1284 #invokeMain; // Start main. |
| 1281 | 1285 |
| 1282 })(Date.now(), #code) | 1286 })(Date.now(), #code) |
| 1283 }"""; | 1287 }"""; |
| 1284 } | 1288 } |
| OLD | NEW |