| 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 representation of runtime types. | 5 /// This library defines the representation of runtime types. |
| 6 part of dart._runtime; | 6 part of dart._runtime; |
| 7 | 7 |
| 8 final metadata = JS('', 'Symbol("metadata")'); | 8 final metadata = JS('', 'Symbol("metadata")'); |
| 9 | 9 |
| 10 /// The symbol used to store the cached `Type` object associated with a class. | 10 /// The symbol used to store the cached `Type` object associated with a class. |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 functionType(returnType, args, extra) => | 505 functionType(returnType, args, extra) => |
| 506 _functionType(false, returnType, args, extra); | 506 _functionType(false, returnType, args, extra); |
| 507 | 507 |
| 508 /// | 508 /// |
| 509 /// Create a definite function type. No substitution of dynamic for | 509 /// Create a definite function type. No substitution of dynamic for |
| 510 /// bottom occurs. | 510 /// bottom occurs. |
| 511 /// | 511 /// |
| 512 definiteFunctionType(returnType, args, extra) => | 512 definiteFunctionType(returnType, args, extra) => |
| 513 _functionType(true, returnType, args, extra); | 513 _functionType(true, returnType, args, extra); |
| 514 | 514 |
| 515 /// |
| 516 /// TODO(vsm): Remove when mirrors is deprecated. |
| 517 /// This is a temporary workaround to support dart:mirrors, which doesn't |
| 518 /// understand generic methods. |
| 519 /// |
| 520 getFunctionTypeMirror(AbstractFunctionType type) { |
| 521 if (type is GenericFunctionType) { |
| 522 var typeArgs = new List.filled(type.formalCount, dynamic); |
| 523 return type.instantiate(typeArgs); |
| 524 } |
| 525 return type; |
| 526 } |
| 527 |
| 515 bool isType(obj) => JS( | 528 bool isType(obj) => JS( |
| 516 '', | 529 '', |
| 517 '''(() => { | 530 '''(() => { |
| 518 return $_getRuntimeType($obj) === $Type; | 531 return $_getRuntimeType($obj) === $Type; |
| 519 })()'''); | 532 })()'''); |
| 520 | 533 |
| 521 String typeName(type) => JS( | 534 String typeName(type) => JS( |
| 522 '', | 535 '', |
| 523 '''(() => { | 536 '''(() => { |
| 524 if ($type === void 0) return "undefined type"; | 537 if ($type === void 0) return "undefined type"; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 return true; | 925 return true; |
| 913 } | 926 } |
| 914 | 927 |
| 915 let typeArgs = $getGenericArgs($type); | 928 let typeArgs = $getGenericArgs($type); |
| 916 if (!typeArgs) return true; | 929 if (!typeArgs) return true; |
| 917 for (let t of typeArgs) { | 930 for (let t of typeArgs) { |
| 918 if (t != $Object && t != $dynamic) return false; | 931 if (t != $Object && t != $dynamic) return false; |
| 919 } | 932 } |
| 920 return true; | 933 return true; |
| 921 })()'''); | 934 })()'''); |
| OLD | NEW |