OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// This library defines the association between runtime objects and | 5 /// This library defines the association between runtime objects and |
6 /// runtime types. | 6 /// runtime types. |
7 part of dart._runtime; | 7 part of dart._runtime; |
8 | 8 |
9 /// Runtime type information. This module defines the mapping from | 9 /// Runtime type information. This module defines the mapping from |
10 /// runtime objects to their runtime type information. See the types | 10 /// runtime objects to their runtime type information. See the types |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 /// | 51 /// |
52 /// `dart.fn(cls, rType, argsT, extras)` marks cls as having the | 52 /// `dart.fn(cls, rType, argsT, extras)` marks cls as having the |
53 /// runtime type dart.functionType(rType, argsT, extras). | 53 /// runtime type dart.functionType(rType, argsT, extras). |
54 /// | 54 /// |
55 /// Note that since we are producing a type for a concrete function, | 55 /// Note that since we are producing a type for a concrete function, |
56 /// it is sound to use the definite arrow type. | 56 /// it is sound to use the definite arrow type. |
57 /// | 57 /// |
58 fn(closure, t) { | 58 fn(closure, t) { |
59 if (t == null) { | 59 if (t == null) { |
60 // No type arguments, it's all dynamic | 60 // No type arguments, it's all dynamic |
61 t = definiteFunctionType(JS('', '#', dynamic), | 61 t = fnType(JS('', '#', dynamic), |
62 JS('', 'Array(#.length).fill(#)', closure, dynamic), JS('', 'void 0')); | 62 JS('', 'Array(#.length).fill(#)', closure, dynamic), JS('', 'void 0')); |
63 } | 63 } |
64 tag(closure, t); | 64 tag(closure, t); |
65 return closure; | 65 return closure; |
66 } | 66 } |
67 | 67 |
68 lazyFn(closure, computeType) { | 68 lazyFn(closure, computeType) { |
69 tagLazy(closure, computeType); | 69 tagLazy(closure, computeType); |
70 return closure; | 70 return closure; |
71 } | 71 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Note: this is a JS Symbol, not a Dart one. | 104 // Note: this is a JS Symbol, not a Dart one. |
105 return JS('', '#', jsobject); | 105 return JS('', '#', jsobject); |
106 } | 106 } |
107 | 107 |
108 return null; | 108 return null; |
109 } | 109 } |
110 | 110 |
111 getFunctionType(obj) { | 111 getFunctionType(obj) { |
112 // TODO(vsm): Encode this properly on the function for Dart-generated code. | 112 // TODO(vsm): Encode this properly on the function for Dart-generated code. |
113 var args = JS('', 'Array(#.length).fill(#)', obj, dynamic); | 113 var args = JS('', 'Array(#.length).fill(#)', obj, dynamic); |
114 return definiteFunctionType(bottom, args, JS('', 'void 0')); | 114 return fnType(bottom, args, JS('', 'void 0')); |
115 } | 115 } |
116 | 116 |
117 /// Returns the runtime representation of the type of obj. | 117 /// Returns the runtime representation of the type of obj. |
118 /// | 118 /// |
119 /// The resulting object is used internally for runtime type checking. This is | 119 /// The resulting object is used internally for runtime type checking. This is |
120 /// different from the user-visible Type object returned by calling | 120 /// different from the user-visible Type object returned by calling |
121 /// `runtimeType` on some Dart object. | 121 /// `runtimeType` on some Dart object. |
122 getReifiedType(obj) { | 122 getReifiedType(obj) { |
123 var result = _checkPrimitiveType(obj); | 123 var result = _checkPrimitiveType(obj); |
124 if (result != null) return result; | 124 if (result != null) return result; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 if (module == null) return null; | 222 if (module == null) return null; |
223 JS('', '#[#] = #', module, _moduleName, name); | 223 JS('', '#[#] = #', module, _moduleName, name); |
224 return module; | 224 return module; |
225 } | 225 } |
226 | 226 |
227 /// Track all libraries | 227 /// Track all libraries |
228 void trackLibraries(String moduleName, libraries, sourceMap) { | 228 void trackLibraries(String moduleName, libraries, sourceMap) { |
229 JS('', '#.set(#, #)', _loadedSourceMaps, moduleName, sourceMap); | 229 JS('', '#.set(#, #)', _loadedSourceMaps, moduleName, sourceMap); |
230 JS('', '#.set(#, #)', _loadedModules, moduleName, libraries); | 230 JS('', '#.set(#, #)', _loadedModules, moduleName, libraries); |
231 } | 231 } |
OLD | NEW |