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.model_emitter; | 5 library dart2js.new_js_emitter.model_emitter; |
6 | 6 |
7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; | 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; |
8 import '../../dart2jslib.dart' show Compiler; | 8 import '../../dart2jslib.dart' show Compiler; |
9 import '../../dart_types.dart' show DartType; | 9 import '../../dart_types.dart' show DartType; |
10 import '../../elements/elements.dart' show ClassElement, FunctionElement; | 10 import '../../elements/elements.dart' show ClassElement, FunctionElement; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 final NativeEmitter nativeEmitter; | 43 final NativeEmitter nativeEmitter; |
44 | 44 |
45 JavaScriptBackend get backend => compiler.backend; | 45 JavaScriptBackend get backend => compiler.backend; |
46 | 46 |
47 /// For deferred loading we communicate the initializers via this global var. | 47 /// For deferred loading we communicate the initializers via this global var. |
48 static const String deferredInitializersGlobal = | 48 static const String deferredInitializersGlobal = |
49 r"$__dart_deferred_initializers__"; | 49 r"$__dart_deferred_initializers__"; |
50 | 50 |
51 static const String deferredExtension = "part.js"; | 51 static const String deferredExtension = "part.js"; |
52 | 52 |
| 53 static const String typeNameProperty = r"builtin$cls"; |
| 54 |
53 ModelEmitter(Compiler compiler, Namer namer, this.nativeEmitter) | 55 ModelEmitter(Compiler compiler, Namer namer, this.nativeEmitter) |
54 : this.compiler = compiler, | 56 : this.compiler = compiler, |
55 this.namer = namer { | 57 this.namer = namer { |
56 // TODO(floitsch): remove hard-coded name. | 58 // TODO(floitsch): remove hard-coded name. |
57 // TODO(floitsch): there is no harm in caching the template. | 59 // TODO(floitsch): there is no harm in caching the template. |
58 js.Template makeConstantListTemplate = | 60 js.Template makeConstantListTemplate = |
59 js.js.uncachedExpressionTemplate('makeConstList(#)'); | 61 js.js.uncachedExpressionTemplate('makeConstList(#)'); |
60 | 62 |
61 this.constantEmitter = new ConstantEmitter( | 63 this.constantEmitter = new ConstantEmitter( |
62 compiler, namer, this.generateConstantReference, | 64 compiler, namer, this.generateConstantReference, |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 } else { | 1085 } else { |
1084 constructor = descriptor[2]; | 1086 constructor = descriptor[2]; |
1085 functionsIndex = 3; | 1087 functionsIndex = 3; |
1086 } | 1088 } |
1087 | 1089 |
1088 for (var i = functionsIndex; i < descriptor.length; i += 2) { | 1090 for (var i = functionsIndex; i < descriptor.length; i += 2) { |
1089 parseFunctionDescriptor(prototype, descriptor[i], descriptor[i + 1], | 1091 parseFunctionDescriptor(prototype, descriptor[i], descriptor[i + 1], |
1090 typesOffset); | 1092 typesOffset); |
1091 } | 1093 } |
1092 | 1094 |
1093 constructor.builtin\$cls = name; // Needed for RTI. | 1095 constructor.$typeNameProperty = name; // Needed for RTI. |
1094 constructor.prototype = prototype; | 1096 constructor.prototype = prototype; |
1095 prototype[#operatorIsPrefix + name] = constructor; | 1097 prototype[#operatorIsPrefix + name] = constructor; |
1096 prototype.constructor = constructor; | 1098 prototype.constructor = constructor; |
1097 return constructor; | 1099 return constructor; |
1098 } | 1100 } |
1099 | 1101 |
1100 function fillPrototypeWithMixedIn(mixinName, mixinHolderIndex, prototype) { | 1102 function fillPrototypeWithMixedIn(mixinName, mixinHolderIndex, prototype) { |
1101 var mixin = holders[mixinHolderIndex][mixinName].ensureResolved(); | 1103 var mixin = holders[mixinHolderIndex][mixinName].ensureResolved(); |
1102 var mixinPrototype = mixin.prototype; | 1104 var mixinPrototype = mixin.prototype; |
1103 | 1105 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 | 1176 |
1175 var end = Date.now(); | 1177 var end = Date.now(); |
1176 // print('Setup: ' + (end - start) + ' ms.'); | 1178 // print('Setup: ' + (end - start) + ' ms.'); |
1177 | 1179 |
1178 #invokeMain; // Start main. | 1180 #invokeMain; // Start main. |
1179 | 1181 |
1180 }(Date.now(), #code) | 1182 }(Date.now(), #code) |
1181 }"""; | 1183 }"""; |
1182 | 1184 |
1183 } | 1185 } |
OLD | NEW |