| 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 /// | 9 /// |
| 10 /// Runtime type information. This module defines the mapping from | 10 /// Runtime type information. This module defines the mapping from |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 let t; | 59 let t; |
| 60 if ($args.length == 0) { | 60 if ($args.length == 0) { |
| 61 // No type arguments, it's all dynamic | 61 // No type arguments, it's all dynamic |
| 62 t = $definiteFunctionType( | 62 t = $definiteFunctionType( |
| 63 $dynamicR, Array($closure.length).fill($dynamicR)); | 63 $dynamicR, Array($closure.length).fill($dynamicR)); |
| 64 } else { | 64 } else { |
| 65 // We're passed the piecewise components of the function type, | 65 // We're passed the piecewise components of the function type, |
| 66 // construct it. | 66 // construct it. |
| 67 t = $definiteFunctionType.apply(null, $args); | 67 t = $definiteFunctionType.apply(null, $args); |
| 68 } | 68 } |
| 69 tag($closure, t); | 69 $tag($closure, t); |
| 70 return $closure; | 70 return $closure; |
| 71 })()'''); | 71 })()'''); |
| 72 | 72 |
| 73 // TODO(vsm): How should we encode the runtime type? | 73 // TODO(vsm): How should we encode the runtime type? |
| 74 final _runtimeType = JS('', 'Symbol("_runtimeType")'); | 74 final _runtimeType = JS('', 'Symbol("_runtimeType")'); |
| 75 | 75 |
| 76 checkPrimitiveType(obj) => JS('', '''(() => { | 76 checkPrimitiveType(obj) => JS('', '''(() => { |
| 77 switch (typeof $obj) { | 77 switch (typeof $obj) { |
| 78 case "undefined": | 78 case "undefined": |
| 79 return $Null; | 79 return $Null; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 tagMemoized(value, compute) => JS('', '''(() => { | 167 tagMemoized(value, compute) => JS('', '''(() => { |
| 168 let cache = null; | 168 let cache = null; |
| 169 function getter() { | 169 function getter() { |
| 170 if ($compute == null) return cache; | 170 if ($compute == null) return cache; |
| 171 cache = $compute(); | 171 cache = $compute(); |
| 172 $compute = null; | 172 $compute = null; |
| 173 return cache; | 173 return cache; |
| 174 } | 174 } |
| 175 $tagComputed($value, getter); | 175 $tagComputed($value, getter); |
| 176 })()'''); | 176 })()'''); |
| OLD | NEW |