Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: packages/js/src/varargs.dart

Issue 2104113003: Added js and js_util to observatory deps (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/js/js.dart ('k') | packages/js_util/dist/js_util.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/js/src/varargs.dart
diff --git a/packages/js/src/varargs.dart b/packages/js/src/varargs.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6d316b35f217bf3ac2ef46b95e35b05c78e5fd4b
--- /dev/null
+++ b/packages/js/src/varargs.dart
@@ -0,0 +1,64 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Declarations for variable arguments support
+/// (rest params and spread operator).
+///
+/// These are currently *not* supported by dart2js or Dartium.
+library js.varargs;
+
+class _Rest {
+ const _Rest();
+}
+
+/// Annotation to tag ES6 rest parameters (https://goo.gl/r0bJ1K).
+///
+/// This is *not* supported by dart2js or Dartium (yet).
+///
+/// This is meant to be used by the Dart Dev Compiler
+/// when compiling helper functions of its runtime to ES6.
+///
+/// The following function:
+///
+/// foo(a, b, @rest others) { ... }
+///
+/// Will be compiled to ES6 code like the following:
+///
+/// function foo(a, b, ...others) { ... }
+///
+/// Which is roughly equivalent to the following ES5 code:
+///
+/// function foo(a, b/*, ...others*/) {
+/// var others = [].splice.call(arguments, 2);
+/// ...
+/// }
+///
+const _Rest rest = const _Rest();
+
+/// Intrinsic function that maps to the ES6 spread operator
+/// (https://goo.gl/NedHKr).
+///
+/// This is *not* supported by dart2js or Dartium (yet),
+/// and *cannot* be called at runtime.
+///
+/// This is meant to be used by the Dart Dev Compiler when
+/// compiling its runtime to ES6.
+///
+/// The following expression:
+///
+/// foo(a, b, spread(others))
+///
+/// Will be compiled to ES6 code like the following:
+///
+/// foo(a, b, ...others)
+///
+/// Which is roughly equivalent to the following ES5 code:
+///
+/// foo.apply(null, [a, b].concat(others))
+///
+dynamic spread(args) {
+ throw new StateError(
+ 'The spread function cannot be called, '
+ 'it should be compiled away.');
+}
« no previous file with comments | « packages/js/js.dart ('k') | packages/js_util/dist/js_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698