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

Unified Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 11085020: Revert "Address Peter's comments on Function.apply." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | « lib/compiler/implementation/lib/core_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/js_helper.dart
diff --git a/lib/compiler/implementation/lib/js_helper.dart b/lib/compiler/implementation/lib/js_helper.dart
index 459fb6cd7f1c759e85b2adf7a1e8eb4d9133d688..7170d2c1b158cbb4c4aacc801d790602808de2d3 100644
--- a/lib/compiler/implementation/lib/js_helper.dart
+++ b/lib/compiler/implementation/lib/js_helper.dart
@@ -610,46 +610,46 @@ class Primitives {
}
JS('void', '#[#] = #', object, key, value);
}
-}
-applyFunction(Function function,
- List positionalArguments,
- Map<String, Dynamic> namedArguments) {
- int argumentCount = 0;
- StringBuffer buffer = new StringBuffer();
- List arguments = [];
-
- if (positionalArguments != null) {
- argumentCount += positionalArguments.length;
- arguments.addAll(positionalArguments);
- }
-
- // Sort the named arguments to get the right selector name and
- // arguments order.
- if (namedArguments != null && !namedArguments.isEmpty()) {
- // Call new List.from to make sure we get a JavaScript array.
- List<String> listOfNamedArguments =
- new List<String>.from(namedArguments.getKeys());
- argumentCount += namedArguments.length;
- // We're sorting on strings, and the behavior is the same between
- // Dart string sort and JS string sort. To avoid needing the Dart
- // sort implementation, we use the JavaScript one instead.
- JS('void', '#.sort()', listOfNamedArguments);
- listOfNamedArguments.forEach((String name) {
- buffer.add('\$$name');
- arguments.add(namedArguments[name]);
- });
- }
-
- String selectorName = 'call\$$argumentCount$buffer';
- var jsFunction = JS('var', '#[#]', function, selectorName);
- if (jsFunction == null) {
- throw new NoSuchMethodError(function, selectorName, arguments);
- }
- // We bound 'this' to [function] because of how we compile
- // closures: escaped local variables are stored and accessed through
- // [function].
- return JS('var', '#.apply(#, #)', jsFunction, function, arguments);
+ static applyFunction(Function function,
+ List positionalArguments,
+ Map<String, Dynamic> namedArguments) {
+ int argumentCount = 0;
+ StringBuffer buffer = new StringBuffer();
+ List arguments = [];
+
+ if (positionalArguments != null) {
+ argumentCount += positionalArguments.length;
+ arguments.addAll(positionalArguments);
+ }
+
+ // Sort the named arguments to get the right selector name and
+ // arguments order.
+ if (namedArguments != null && !namedArguments.isEmpty()) {
+ // Call new List.from to make sure we get a JavaScript array.
+ List<String> listOfNamedArguments =
+ new List<String>.from(namedArguments.getKeys());
+ argumentCount += namedArguments.length;
+ // We're sorting on strings, and the behavior is the same between
+ // Dart string sort and JS string sort. To avoid needing the Dart
+ // sort implementation, we use the JavaScript one instead.
+ JS('void', '#.sort()', listOfNamedArguments);
+ listOfNamedArguments.forEach((String name) {
+ buffer.add('\$$name');
+ arguments.add(namedArguments[name]);
+ });
+ }
+
+ String selectorName = 'call\$$argumentCount$buffer';
+ var jsFunction = JS('var', '#[#]', function, selectorName);
+ if (jsFunction == null) {
+ throw new NoSuchMethodError(function, selectorName, arguments);
+ }
+ // We bound 'this' to [function] because of how we compile
+ // closures: escaped local variables are stored and accessed through
+ // [function].
+ return JS('var', '#.apply(#, #)', jsFunction, function, arguments);
+ }
}
/**
« no previous file with comments | « lib/compiler/implementation/lib/core_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698