Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 5 /** |
| 6 * This part contains helpers for supporting runtime type information. | 6 * This part contains helpers for supporting runtime type information. |
| 7 * | 7 * |
| 8 * The helper use a mixture of Dart and JavaScript objects. To indicate which is | 8 * The helper use a mixture of Dart and JavaScript objects. To indicate which is |
| 9 * used where we adopt the scheme of using explicit type annotation for Dart | 9 * used where we adopt the scheme of using explicit type annotation for Dart |
| 10 * objects and 'var' or omitted return type for JavaScript objects. | 10 * objects and 'var' or omitted return type for JavaScript objects. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 * To check subtype relations between generic classes we use a JavaScript | 30 * To check subtype relations between generic classes we use a JavaScript |
| 31 * expression that describes the necessary substitution for type arguments. | 31 * expression that describes the necessary substitution for type arguments. |
| 32 * Such a substitution expresssion can be: | 32 * Such a substitution expresssion can be: |
| 33 * 1) `null`, if no substituted check is necessary, because the | 33 * 1) `null`, if no substituted check is necessary, because the |
| 34 * type variables are the same or there are no type variables in the class | 34 * type variables are the same or there are no type variables in the class |
| 35 * that is checked for. | 35 * that is checked for. |
| 36 * 2) A list expression describing the type arguments to be used in the | 36 * 2) A list expression describing the type arguments to be used in the |
| 37 * subtype check, if the type arguments to be used in the check do not | 37 * subtype check, if the type arguments to be used in the check do not |
| 38 * depend on the type arguments of the object. | 38 * depend on the type arguments of the object. |
| 39 * 3) A function mapping the type variables of the object to be checked to | 39 * 3) A function mapping the type variables of the object to be checked to |
| 40 * a list expression. | 40 * a list expression. The function may also return null, which is equivalent |
|
karlklose
2015/01/20 10:37:32
"null" -> "`null`".
| |
| 41 * to an array containing only null values. | |
| 41 */ | 42 */ |
| 42 | 43 |
| 43 part of _js_helper; | 44 part of _js_helper; |
| 44 | 45 |
| 45 Type createRuntimeType(String name) => new TypeImpl(name); | 46 Type createRuntimeType(String name) => new TypeImpl(name); |
| 46 | 47 |
| 47 class TypeImpl implements Type { | 48 class TypeImpl implements Type { |
| 48 final String _typeName; | 49 final String _typeName; |
| 49 String _unmangledName; | 50 String _unmangledName; |
| 50 | 51 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 * | 230 * |
| 230 * See the comment in the beginning of this file for a description of the | 231 * See the comment in the beginning of this file for a description of the |
| 231 * possible values for [substitution]. | 232 * possible values for [substitution]. |
| 232 */ | 233 */ |
| 233 substitute(var substitution, var arguments) { | 234 substitute(var substitution, var arguments) { |
| 234 assert(substitution == null || | 235 assert(substitution == null || |
| 235 isJsFunction(substitution)); | 236 isJsFunction(substitution)); |
| 236 assert(arguments == null || isJsArray(arguments)); | 237 assert(arguments == null || isJsArray(arguments)); |
| 237 if (isJsFunction(substitution)) { | 238 if (isJsFunction(substitution)) { |
| 238 substitution = invoke(substitution, arguments); | 239 substitution = invoke(substitution, arguments); |
| 239 if (isJsArray(substitution)) { | 240 if (substitution == null || isJsArray(substitution)) { |
| 240 arguments = substitution; | 241 arguments = substitution; |
| 241 } else if (isJsFunction(substitution)) { | 242 } else if (isJsFunction(substitution)) { |
| 242 // TODO(johnniwinther): Check if this is still needed. | 243 // TODO(johnniwinther): Check if this is still needed. |
| 243 arguments = invoke(substitution, arguments); | 244 arguments = invoke(substitution, arguments); |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 return arguments; | 247 return arguments; |
| 247 } | 248 } |
| 248 | 249 |
| 249 /** | 250 /** |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 * `null` and `undefined` (which we can avoid). | 680 * `null` and `undefined` (which we can avoid). |
| 680 */ | 681 */ |
| 681 bool isIdentical(var s, var t) => JS('bool', '# === #', s, t); | 682 bool isIdentical(var s, var t) => JS('bool', '# === #', s, t); |
| 682 | 683 |
| 683 /** | 684 /** |
| 684 * Returns `true` if the JavaScript values [s] and [t] are not identical. We use | 685 * Returns `true` if the JavaScript values [s] and [t] are not identical. We use |
| 685 * this helper instead of [identical] because `identical` needs to merge | 686 * this helper instead of [identical] because `identical` needs to merge |
| 686 * `null` and `undefined` (which we can avoid). | 687 * `null` and `undefined` (which we can avoid). |
| 687 */ | 688 */ |
| 688 bool isNotIdentical(var s, var t) => JS('bool', '# !== #', s, t); | 689 bool isNotIdentical(var s, var t) => JS('bool', '# !== #', s, t); |
| OLD | NEW |