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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 wrapType(type) { | 154 wrapType(type) { |
155 // If we've already wrapped this type once, use the previous wrapper. This | 155 // If we've already wrapped this type once, use the previous wrapper. This |
156 // way, multiple references to the same type return an identical Type. | 156 // way, multiple references to the same type return an identical Type. |
157 if (JS('bool', '#.hasOwnProperty(#)', type, _typeObject)) { | 157 if (JS('bool', '#.hasOwnProperty(#)', type, _typeObject)) { |
158 return JS('', '#[#]', type, _typeObject); | 158 return JS('', '#[#]', type, _typeObject); |
159 } | 159 } |
160 return JS('', '#[#] = new #(#)', type, _typeObject, WrappedType, type); | 160 return JS('', '#[#] = new #(#)', type, _typeObject, WrappedType, type); |
161 } | 161 } |
162 | 162 |
163 /// Given a WrappedType, return the internal runtime type object. | 163 /// Given a WrappedType, return the internal runtime type object. |
164 unwrapType(obj) => obj._runtimeType; | 164 unwrapType(obj) => obj._wrappedType; |
165 | 165 |
166 _getRuntimeType(value) => JS('', '#[#]', value, _runtimeType); | 166 _getRuntimeType(value) => JS('', '#[#]', value, _runtimeType); |
167 | 167 |
168 /// Tag the runtime type of [value] to be type [t]. | 168 /// Tag the runtime type of [value] to be type [t]. |
169 void tag(value, t) { | 169 void tag(value, t) { |
170 JS('', '#[#] = #', value, _runtimeType, t); | 170 JS('', '#[#] = #', value, _runtimeType, t); |
171 } | 171 } |
172 | 172 |
173 void tagComputed(value, compute) { | 173 void tagComputed(value, compute) { |
174 JS('', '#(#, #, { get: # })', defineProperty, value, _runtimeType, compute); | 174 JS('', '#(#, #, { get: # })', defineProperty, value, _runtimeType, compute); |
175 } | 175 } |
176 | 176 |
177 void tagLazy(value, compute) { | 177 void tagLazy(value, compute) { |
178 JS('', '#(#, #, { get: # })', | 178 JS('', '#(#, #, { get: # })', |
179 defineLazyProperty, value, _runtimeType, compute); | 179 defineLazyProperty, value, _runtimeType, compute); |
180 } | 180 } |
OLD | NEW |