| 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 */ | 7 */ |
| 8 | 8 |
| 9 dart_library.library('dart_runtime/_rtti', null, /* Imports */[ | 9 dart_library.library('dart_runtime/_rtti', null, /* Imports */[ |
| 10 ], /* Lazy Imports */[ | 10 ], /* Lazy Imports */[ |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 */ | 130 */ |
| 131 function realRuntimeType(obj) { | 131 function realRuntimeType(obj) { |
| 132 let result = checkPrimitiveType(obj); | 132 let result = checkPrimitiveType(obj); |
| 133 if (result !== null) return result; | 133 if (result !== null) return result; |
| 134 // TODO(vsm): Should we treat Dart and JS objects differently here? | 134 // TODO(vsm): Should we treat Dart and JS objects differently here? |
| 135 // E.g., we can check if obj instanceof core.Object to differentiate. | 135 // E.g., we can check if obj instanceof core.Object to differentiate. |
| 136 result = obj[_runtimeType]; | 136 result = obj[_runtimeType]; |
| 137 if (result) return result; | 137 if (result) return result; |
| 138 result = obj.constructor; | 138 result = obj.constructor; |
| 139 if (result == Function) { | 139 if (result == Function) { |
| 140 return getFunctionType(obj); | 140 // An undecorated Function should have come from |
| 141 // JavaScript. Treat as untyped. |
| 142 return types.jsobject; |
| 141 } | 143 } |
| 142 return result; | 144 return result; |
| 143 } | 145 } |
| 144 exports.realRuntimeType = realRuntimeType; | 146 exports.realRuntimeType = realRuntimeType; |
| 145 | 147 |
| 146 function LazyTagged(infoFn) { | 148 function LazyTagged(infoFn) { |
| 147 class _Tagged { | 149 class _Tagged { |
| 148 get [_runtimeType]() {return infoFn();} | 150 get [_runtimeType]() {return infoFn();} |
| 149 } | 151 } |
| 150 return _Tagged; | 152 return _Tagged; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 171 function getter() { | 173 function getter() { |
| 172 if (compute == null) return cache; | 174 if (compute == null) return cache; |
| 173 cache = compute(); | 175 cache = compute(); |
| 174 compute = null; | 176 compute = null; |
| 175 return cache; | 177 return cache; |
| 176 } | 178 } |
| 177 tagComputed(value, getter); | 179 tagComputed(value, getter); |
| 178 } | 180 } |
| 179 exports.tagMemoized = tagMemoized; | 181 exports.tagMemoized = tagMemoized; |
| 180 }); | 182 }); |
| OLD | NEW |