| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // The following methods are used to handle type information | 5 // The following methods are used to handle type information |
| 6 // | 6 // |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * @constructor | 9 * @constructor |
| 10 * @param {string} classkey | 10 * @param {string} classkey |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 if (!rtt) { | 201 if (!rtt) { |
| 202 throw new Error("internal error: can not find " + | 202 throw new Error("internal error: can not find " + |
| 203 classkey + " in " + JSON.stringify(o)); | 203 classkey + " in " + JSON.stringify(o)); |
| 204 } | 204 } |
| 205 return rtt.typeArgs; | 205 return rtt.typeArgs; |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 // Base types for runtime type information | 208 // Base types for runtime type information |
| 209 | 209 |
| 210 /** @type {!RTT} */ | 210 /** @type {!RTT} */ |
| 211 RTT.objectType = new RTT($cls('Object')); | 211 function ImplementsAll(name) { |
| 212 RTT.objectType.implementedBy = function(o) {return true}; | 212 RTT.call(this,name); |
| 213 RTT.objectType.implementedByType = function(o) {return true}; | 213 } |
| 214 $inherits(ImplementsAll,RTT); |
| 215 ImplementsAll.prototype.implementedBy = function(o) {return true}; |
| 216 ImplementsAll.prototype.implementedByType = function(o) {return true}; |
| 214 | 217 |
| 215 /** @type {!RTT} */ | 218 RTT.objectType = new ImplementsAll($cls('Object')); |
| 216 RTT.dynamicType = new RTT($cls('Dynamic')); | 219 RTT.dynamicType = new ImplementsAll($cls('Dynamic')); |
| 217 RTT.dynamicType.implementedBy = function(o) {return true}; | 220 RTT.placeholderType = new ImplementsAll($cls('::')); |
| 218 RTT.dynamicType.implementedByType = function(o) {return true}; | |
| 219 | |
| 220 /** @type {!RTT} */ | |
| 221 RTT.placeholderType = new RTT($cls('::')); | |
| 222 RTT.placeholderType.implementedBy = function(o) {return true}; | |
| 223 RTT.placeholderType.implementedByType = function(o) {return true}; | |
| 224 | 221 |
| 225 /** | 222 /** |
| 226 * Checks that a value is assignable to an expected type, and either returns tha
t | 223 * Checks that a value is assignable to an expected type, and either returns tha
t |
| 227 * value if it is, or else throws a TypeMismatchException. | 224 * value if it is, or else throws a TypeMismatchException. |
| 228 * | 225 * |
| 229 * @param {!RTT} the expected type | 226 * @param {!RTT} the expected type |
| 230 * @param {*} the value to check | 227 * @param {*} the value to check |
| 231 * @return {*} the value | 228 * @return {*} the value |
| 232 */ | 229 */ |
| 233 function $chk(rtt, value) { | 230 function $chk(rtt, value) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 return typeof o == 'number'; | 277 return typeof o == 'number'; |
| 281 } | 278 } |
| 282 | 279 |
| 283 /** | 280 /** |
| 284 * @param {*} o | 281 * @param {*} o |
| 285 * @return {boolean} | 282 * @return {boolean} |
| 286 */ | 283 */ |
| 287 function $isString(o) { | 284 function $isString(o) { |
| 288 return typeof o == 'string'; | 285 return typeof o == 'string'; |
| 289 } | 286 } |
| OLD | NEW |