OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 /// Declarations for variable arguments support | |
6 /// (rest params and spread operator). | |
7 /// | |
8 /// These are currently *not* supported by dart2js or Dartium. | |
9 library js.varargs; | |
10 | |
11 class _Rest { | |
12 const _Rest(); | |
13 } | |
14 | |
15 /// Annotation to tag ES6 rest parameters (https://goo.gl/r0bJ1K). | |
16 /// | |
17 /// This is *not* supported by dart2js or Dartium (yet). | |
18 /// | |
19 /// This is meant to be used by the Dart Dev Compiler | |
20 /// when compiling helper functions of its runtime to ES6. | |
21 /// | |
22 /// The following function: | |
23 /// | |
24 /// foo(a, b, @rest others) { ... } | |
25 /// | |
26 /// Will be compiled to ES6 code like the following: | |
27 /// | |
28 /// function foo(a, b, ...others) { ... } | |
29 /// | |
30 /// Which is roughly equivalent to the following ES5 code: | |
31 /// | |
32 /// function foo(a, b/*, ...others*/) { | |
33 /// var others = [].splice.call(arguments, 2); | |
34 /// ... | |
35 /// } | |
36 /// | |
37 const _Rest rest = const _Rest(); | |
38 | |
39 /// Intrinsic function that maps to the ES6 spread operator | |
40 /// (https://goo.gl/NedHKr). | |
41 /// | |
42 /// This is *not* supported by dart2js or Dartium (yet), | |
43 /// and *cannot* be called at runtime. | |
44 /// | |
45 /// This is meant to be used by the Dart Dev Compiler when | |
46 /// compiling its runtime to ES6. | |
47 /// | |
48 /// The following expression: | |
49 /// | |
50 /// foo(a, b, spread(others)) | |
51 /// | |
52 /// Will be compiled to ES6 code like the following: | |
53 /// | |
54 /// foo(a, b, ...others) | |
55 /// | |
56 /// Which is roughly equivalent to the following ES5 code: | |
57 /// | |
58 /// foo.apply(null, [a, b].concat(others)) | |
59 /// | |
60 dynamic spread(args) { | |
61 throw new StateError( | |
62 'The spread function cannot be called, ' | |
63 'it should be compiled away.'); | |
64 } | |
OLD | NEW |