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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 const TypeVariable(this.owner, this.name, this.bound); | 78 const TypeVariable(this.owner, this.name, this.bound); |
| 79 } | 79 } |
| 80 | 80 |
| 81 getMangledTypeName(TypeImpl type) => type._typeName; | 81 getMangledTypeName(TypeImpl type) => type._typeName; |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * Sets the runtime type information on [target]. [rti] is a type | 84 * Sets the runtime type information on [target]. [rti] is a type |
| 85 * representation of type 4 or 5, that is, either a JavaScript array or | 85 * representation of type 4 or 5, that is, either a JavaScript array or |
| 86 * `null`. | 86 * `null`. |
| 87 */ | 87 */ |
| 88 // Don't inline. Let the JS engine inline this. The call expression is much | |
| 89 // more compact that the inlined expansion. | |
| 90 // TODO(sra): For most objects it would be better to initialize the type info as | |
| 91 // a field in the constructor: http://dartbug.com/22676 . | |
| 92 @NoInline() | |
| 88 Object setRuntimeTypeInfo(Object target, var rti) { | 93 Object setRuntimeTypeInfo(Object target, var rti) { |
| 89 assert(rti == null || isJsArray(rti)); | 94 assert(rti == null || isJsArray(rti)); |
| 90 // We have to check for null because factories may return null. | 95 // We have to check for null because factories may return null. |
| 96 // TODO(sra): How is this true? The factory should be executing some code that | |
| 97 // creates an object that already has the correct info. | |
|
Siggi Cherem (dart-lang)
2015/09/17 16:10:10
do you mean that we would never invoke setRuntimeT
| |
| 91 if (target != null) JS('var', r'#.$builtinTypeInfo = #', target, rti); | 98 if (target != null) JS('var', r'#.$builtinTypeInfo = #', target, rti); |
| 92 return target; | 99 return target; |
| 93 } | 100 } |
| 94 | 101 |
| 95 /** | 102 /** |
| 96 * Returns the runtime type information of [target]. The returned value is a | 103 * Returns the runtime type information of [target]. The returned value is a |
| 97 * list of type representations for the type arguments. | 104 * list of type representations for the type arguments. |
| 98 */ | 105 */ |
| 99 getRuntimeTypeInfo(Object target) { | 106 getRuntimeTypeInfo(Object target) { |
| 100 if (target == null) return null; | 107 if (target == null) return null; |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 * `null` and `undefined` (which we can avoid). | 679 * `null` and `undefined` (which we can avoid). |
| 673 */ | 680 */ |
| 674 bool isIdentical(var s, var t) => JS('bool', '# === #', s, t); | 681 bool isIdentical(var s, var t) => JS('bool', '# === #', s, t); |
| 675 | 682 |
| 676 /** | 683 /** |
| 677 * Returns `true` if the JavaScript values [s] and [t] are not identical. We use | 684 * Returns `true` if the JavaScript values [s] and [t] are not identical. We use |
| 678 * this helper instead of [identical] because `identical` needs to merge | 685 * this helper instead of [identical] because `identical` needs to merge |
| 679 * `null` and `undefined` (which we can avoid). | 686 * `null` and `undefined` (which we can avoid). |
| 680 */ | 687 */ |
| 681 bool isNotIdentical(var s, var t) => JS('bool', '# !== #', s, t); | 688 bool isNotIdentical(var s, var t) => JS('bool', '# !== #', s, t); |
| OLD | NEW |