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 class InvocationImpl extends Invocation { | 9 class InvocationImpl extends Invocation { |
10 final Symbol memberName; | 10 final Symbol memberName; |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 })()'''); | 502 })()'''); |
503 | 503 |
504 /// | 504 /// |
505 /// Implements a sequence of .? operations. | 505 /// Implements a sequence of .? operations. |
506 /// | 506 /// |
507 /// Will call each successive callback, unless one returns null, which stops | 507 /// Will call each successive callback, unless one returns null, which stops |
508 /// the sequence. | 508 /// the sequence. |
509 /// | 509 /// |
510 nullSafe(obj, @rest callbacks) => JS('', '''(() => { | 510 nullSafe(obj, @rest callbacks) => JS('', '''(() => { |
511 if ($obj == null) return $obj; | 511 if ($obj == null) return $obj; |
512 for (const callback of $callbacks) { | 512 for (let callback of $callbacks) { |
vsm
2016/09/12 14:47:50
FF isn't happy about const here.
| |
513 $obj = callback($obj); | 513 $obj = callback($obj); |
514 if ($obj == null) break; | 514 if ($obj == null) break; |
515 } | 515 } |
516 return $obj; | 516 return $obj; |
517 })()'''); | 517 })()'''); |
518 | 518 |
519 final _value = JS('', 'Symbol("_value")'); | 519 final _value = JS('', 'Symbol("_value")'); |
520 /// | 520 /// |
521 /// Looks up a sequence of [keys] in [map], recursively, and | 521 /// Looks up a sequence of [keys] in [map], recursively, and |
522 /// returns the result. If the value is not found, [valueFn] will be called to | 522 /// returns the result. If the value is not found, [valueFn] will be called to |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 if (obj != null && getExtensionType(obj) != null) { | 741 if (obj != null && getExtensionType(obj) != null) { |
742 return JS('', 'dartx.#', name); | 742 return JS('', 'dartx.#', name); |
743 } | 743 } |
744 | 744 |
745 // Check for certain names that we can't use in JS | 745 // Check for certain names that we can't use in JS |
746 if (name == 'constructor' || name == 'prototype') { | 746 if (name == 'constructor' || name == 'prototype') { |
747 name = '+' + name; | 747 name = '+' + name; |
748 } | 748 } |
749 return name; | 749 return name; |
750 } | 750 } |
OLD | NEW |