Chromium Code Reviews| 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 runtime operations on objects used by the code | 5 /// This library defines runtime operations on objects used by the code |
| 6 /// generator. | 6 /// generator. |
| 7 part of dart._runtime; | 7 part of dart._runtime; |
| 8 | 8 |
| 9 _canonicalFieldName(obj, name, args, displayName) => JS('', '''(() => { | 9 _canonicalFieldName(obj, name, args, displayName) => JS('', '''(() => { |
| 10 $name = $canonicalMember($obj, $name); | 10 $name = $canonicalMember($obj, $name); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 let result = $strongInstanceOf($obj, $type); | 246 let result = $strongInstanceOf($obj, $type); |
| 247 if (result !== null) return result; | 247 if (result !== null) return result; |
| 248 let actual = $getReifiedType($obj); | 248 let actual = $getReifiedType($obj); |
| 249 $throwStrongModeError('Strong mode is check failure: ' + | 249 $throwStrongModeError('Strong mode is check failure: ' + |
| 250 $typeName(actual) + ' does not soundly subtype ' + | 250 $typeName(actual) + ' does not soundly subtype ' + |
| 251 $typeName($type)); | 251 $typeName($type)); |
| 252 })()'''); | 252 })()'''); |
| 253 | 253 |
| 254 @JSExportName('as') | 254 @JSExportName('as') |
| 255 cast(obj, type) { | 255 cast(obj, type) { |
| 256 if (obj == null) return obj; | 256 if (JS('bool', '# == #', type, dynamic) || obj == null) return obj; |
|
Jennifer Messerly
2016/05/26 18:14:51
super trivial but: wouldn't null be more common th
Leaf
2016/05/26 18:16:37
Maybe, but I doubt it. By far the majority of the
| |
| 257 | |
| 258 bool result = strongInstanceOf(obj, type, true); | 257 bool result = strongInstanceOf(obj, type, true); |
| 259 if (JS('bool', '#', result)) return obj; | 258 if (JS('bool', '#', result)) return obj; |
| 260 _throwCastError(obj, type, result); | 259 _throwCastError(obj, type, result); |
| 261 } | 260 } |
| 262 | 261 |
| 263 bool test(obj) { | 262 bool test(obj) { |
| 264 if (obj is bool) return obj; | 263 if (obj is bool) return obj; |
| 265 return booleanConversionFailed(obj); | 264 return booleanConversionFailed(obj); |
| 266 } | 265 } |
| 267 | 266 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 constructor(dartIterator) { | 587 constructor(dartIterator) { |
| 589 this.dartIterator = dartIterator; | 588 this.dartIterator = dartIterator; |
| 590 } | 589 } |
| 591 next() { | 590 next() { |
| 592 let i = this.dartIterator; | 591 let i = this.dartIterator; |
| 593 let done = !i.moveNext(); | 592 let done = !i.moveNext(); |
| 594 return { done: done, value: done ? void 0 : i.current }; | 593 return { done: done, value: done ? void 0 : i.current }; |
| 595 } | 594 } |
| 596 } | 595 } |
| 597 '''); | 596 '''); |
| OLD | NEW |