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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 /// | 607 /// |
608 /// Otherwise an array should be used, for example `map([1, 2, 3, 4])` will | 608 /// Otherwise an array should be used, for example `map([1, 2, 3, 4])` will |
609 /// create a map with keys [1, 3] and values [2, 4]. Each key-value pair | 609 /// create a map with keys [1, 3] and values [2, 4]. Each key-value pair |
610 /// should be adjacent entries in the array. | 610 /// should be adjacent entries in the array. |
611 /// | 611 /// |
612 /// For a map with no keys the function can be called with no arguments, for | 612 /// For a map with no keys the function can be called with no arguments, for |
613 /// example `map()`. | 613 /// example `map()`. |
614 /// | 614 /// |
615 // TODO(jmesserly): this could be faster | 615 // TODO(jmesserly): this could be faster |
616 // TODO(jmesserly): we can use default values `= dynamic` once #417 is fixed. | 616 // TODO(jmesserly): we can use default values `= dynamic` once #417 is fixed. |
617 // TODO(jmesserly): move this to classes for consistentcy with list literals? | 617 // TODO(jmesserly): move this to classes for consistency with list literals? |
618 map(values, [K, V]) => JS( | 618 map(values, [K, V]) => JS( |
619 '', | 619 '', |
620 '''(() => { | 620 '''(() => { |
621 if ($K == null) $K = $dynamic; | 621 if ($K == null) $K = $dynamic; |
622 if ($V == null) $V = $dynamic; | 622 if ($V == null) $V = $dynamic; |
623 let map = ${getGenericClass(LinkedHashMap)}($K, $V).new(); | 623 let map = ${getGenericClass(LinkedHashMap)}($K, $V).new(); |
624 if (Array.isArray($values)) { | 624 if (Array.isArray($values)) { |
625 for (let i = 0, end = $values.length - 1; i < end; i += 2) { | 625 for (let i = 0, end = $values.length - 1; i < end; i += 2) { |
626 let key = $values[i]; | 626 let key = $values[i]; |
627 let value = $values[i + 1]; | 627 let value = $values[i + 1]; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 name = '+' + name; | 936 name = '+' + name; |
937 } | 937 } |
938 return name; | 938 return name; |
939 } | 939 } |
940 | 940 |
941 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 941 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
942 /// | 942 /// |
943 /// Libraries are not actually deferred in DDC, so this just returns a future | 943 /// Libraries are not actually deferred in DDC, so this just returns a future |
944 /// that completes immediately. | 944 /// that completes immediately. |
945 Future loadLibrary() => new Future.value(); | 945 Future loadLibrary() => new Future.value(); |
OLD | NEW |