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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 1029853002: Fix implementation of Function.apply with optional positional arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/corelib/apply4_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:_async_await_error_codes' as async_error_codes; 7 import 'dart:_async_await_error_codes' as async_error_codes;
8 8
9 import 'dart:_js_embedded_names' show 9 import 'dart:_js_embedded_names' show
10 DEFERRED_LIBRARY_URIS, 10 DEFERRED_LIBRARY_URIS,
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 int requiredArgumentCount = info.requiredParameterCount; 1174 int requiredArgumentCount = info.requiredParameterCount;
1175 int maxArgumentCount = requiredArgumentCount + 1175 int maxArgumentCount = requiredArgumentCount +
1176 info.optionalParameterCount; 1176 info.optionalParameterCount;
1177 if (info.areOptionalParametersNamed || 1177 if (info.areOptionalParametersNamed ||
1178 requiredArgumentCount > argumentCount || 1178 requiredArgumentCount > argumentCount ||
1179 maxArgumentCount < argumentCount) { 1179 maxArgumentCount < argumentCount) {
1180 return functionNoSuchMethod(function, positionalArguments, null); 1180 return functionNoSuchMethod(function, positionalArguments, null);
1181 } 1181 }
1182 arguments = new List.from(arguments); 1182 arguments = new List.from(arguments);
1183 for (int pos = argumentCount; pos < maxArgumentCount; pos++) { 1183 for (int pos = argumentCount; pos < maxArgumentCount; pos++) {
1184 arguments.add(info.defaultValue(pos)); 1184 arguments.add(getMetadata(info.defaultValue(pos)));
1185 } 1185 }
1186 } 1186 }
1187 // We bound 'this' to [function] because of how we compile 1187 // We bound 'this' to [function] because of how we compile
1188 // closures: escaped local variables are stored and accessed through 1188 // closures: escaped local variables are stored and accessed through
1189 // [function]. 1189 // [function].
1190 return JS('var', '#.apply(#, #)', jsFunction, function, arguments); 1190 return JS('var', '#.apply(#, #)', jsFunction, function, arguments);
1191 } 1191 }
1192 1192
1193 static applyFunctionWithNamedArguments(Function function, 1193 static applyFunctionWithNamedArguments(Function function,
1194 List positionalArguments, 1194 List positionalArguments,
(...skipping 2708 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 // This is a function that will return a helper function that does the 3903 // This is a function that will return a helper function that does the
3904 // iteration of the sync*. 3904 // iteration of the sync*.
3905 // 3905 //
3906 // Each invocation should give a body with fresh state. 3906 // Each invocation should give a body with fresh state.
3907 final dynamic /* js function */ _outerHelper; 3907 final dynamic /* js function */ _outerHelper;
3908 3908
3909 SyncStarIterable(this._outerHelper); 3909 SyncStarIterable(this._outerHelper);
3910 3910
3911 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); 3911 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper));
3912 } 3912 }
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/apply4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698