| 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 */ | 6 */ |
| 7 | 7 |
| 8 dart_library.library('dart/_types', null, /* Imports */[ | 8 dart_library.library('dart/_types', null, /* Imports */[ |
| 9 ], /* Lazy Imports */[ | 9 ], /* Lazy Imports */[ |
| 10 'dart/_utils', |
| 10 'dart/core', | 11 'dart/core', |
| 11 'dart/_classes', | 12 'dart/_classes', |
| 12 'dart/_rtti' | 13 'dart/_rtti' |
| 13 ], function(exports, core, classes, rtti) { | 14 ], function(exports, dart_utils, core, classes, rtti) { |
| 14 'use strict'; | 15 'use strict'; |
| 15 | 16 |
| 16 const getOwnPropertyNames = Object.getOwnPropertyNames; | 17 const getOwnPropertyNames = Object.getOwnPropertyNames; |
| 17 | 18 |
| 18 const assert = dart_utils.assert; | 19 const assert = dart_utils.assert_; |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * Types in dart are represented at runtime as follows. | 22 * Types in dart are represented at runtime as follows. |
| 22 * - Normal nominal types, produced from classes, are represented | 23 * - Normal nominal types, produced from classes, are represented |
| 23 * at runtime by the JS class of which they are an instance. | 24 * at runtime by the JS class of which they are an instance. |
| 24 * If the type is the result of instantiating a generic class, | 25 * If the type is the result of instantiating a generic class, |
| 25 * then the "classes" module manages the association between the | 26 * then the "classes" module manages the association between the |
| 26 * instantiated class and the original class declaration | 27 * instantiated class and the original class declaration |
| 27 * and the type arguments with which it was instantiated. This | 28 * and the type arguments with which it was instantiated. This |
| 28 * assocation can be queried via the "classes" module". | 29 * assocation can be queried via the "classes" module". |
| 29 * | 30 * |
| 30 * - All other types are represented as instances of class TypeRep, | 31 * - All other types are represented as instances of class TypeRep, |
| 31 * defined in this module. | 32 * defined in this module. |
| 32 * - Dynamic, Void, and Bottom are singleton instances of sentinal | 33 * - Dynamic, Void, and Bottom are singleton instances of sentinal |
| 33 * classes. | 34 * classes. |
| 34 * - Function types are instances of subclasses of AbstractFunctionType. | 35 * - Function types are instances of subclasses of AbstractFunctionType. |
| 35 * | 36 * |
| 36 * Function types are represented in one of two ways: | 37 * Function types are represented in one of two ways: |
| 37 * - As an instance of FunctionType. These are eagerly computed. | 38 * - As an instance of FunctionType. These are eagerly computed. |
| 38 * - As an instance of TypeDef. The TypeDef representation lazily | 39 * - As an instance of TypeDef. The TypeDef representation lazily |
| 39 * computes an instance of FunctionType, and delegates to that instance. | 40 * computes an instance of FunctionType, and delegates to that instance. |
| 40 * | 41 * |
| 41 * All types satisfy the following interface: | 42 * All types satisfy the following interface: |
| 42 * get String name; | 43 * get String name; |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 let typeArgs = classes.getGenericArgs(type); | 538 let typeArgs = classes.getGenericArgs(type); |
| 538 if (!typeArgs) return true; | 539 if (!typeArgs) return true; |
| 539 for (let t of typeArgs) { | 540 for (let t of typeArgs) { |
| 540 if (t != core.Object && t != dynamicR) return false; | 541 if (t != core.Object && t != dynamicR) return false; |
| 541 } | 542 } |
| 542 return true; | 543 return true; |
| 543 } | 544 } |
| 544 exports.isGroundType = isGroundType; | 545 exports.isGroundType = isGroundType; |
| 545 | 546 |
| 546 }); | 547 }); |
| OLD | NEW |