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

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

Issue 930093002: Support positional optional parameters even if stubs are missing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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:_js_embedded_names' show 7 import 'dart:_js_embedded_names' show
8 GET_TYPE_FROM_NAME, 8 GET_TYPE_FROM_NAME,
9 GET_ISOLATE_TAG, 9 GET_ISOLATE_TAG,
10 INTERCEPTED_NAMES, 10 INTERCEPTED_NAMES,
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 arguments = new List.from(positionalArguments); 1070 arguments = new List.from(positionalArguments);
1071 } 1071 }
1072 argumentCount = JS('int', '#.length', arguments); 1072 argumentCount = JS('int', '#.length', arguments);
1073 } else { 1073 } else {
1074 arguments = []; 1074 arguments = [];
1075 } 1075 }
1076 1076
1077 String selectorName = '${JS_GET_NAME("CALL_PREFIX")}\$$argumentCount'; 1077 String selectorName = '${JS_GET_NAME("CALL_PREFIX")}\$$argumentCount';
1078 var jsFunction = JS('var', '#[#]', function, selectorName); 1078 var jsFunction = JS('var', '#[#]', function, selectorName);
1079 if (jsFunction == null) { 1079 if (jsFunction == null) {
1080 var interceptor = getInterceptor(function);
1081 jsFunction = JS('', '#["call*"]', interceptor);
1080 1082
1081 // TODO(ahe): This might occur for optional arguments if there is no call 1083 if (jsFunction == null) {
1082 // selector with that many arguments. 1084 return functionNoSuchMethod(function, positionalArguments, null);
1083 1085 }
1084 return functionNoSuchMethod(function, positionalArguments, null); 1086 ReflectionInfo info = new ReflectionInfo(jsFunction);
1087 int maxArgumentCount = info.requiredParameterCount +
1088 info.optionalParameterCount;
1089 if (info.areOptionalParametersNamed || maxArgumentCount < argumentCount) {
1090 return functionNoSuchMethod(function, positionalArguments, null);
1091 }
1092 arguments = new List.from(arguments);
1093 for (int pos = argumentCount; pos < maxArgumentCount; pos++) {
1094 arguments.add(info.defaultValue(pos));
1095 }
1085 } 1096 }
1086 // We bound 'this' to [function] because of how we compile 1097 // We bound 'this' to [function] because of how we compile
1087 // closures: escaped local variables are stored and accessed through 1098 // closures: escaped local variables are stored and accessed through
1088 // [function]. 1099 // [function].
1089 return JS('var', '#.apply(#, #)', jsFunction, function, arguments); 1100 return JS('var', '#.apply(#, #)', jsFunction, function, arguments);
1090 } 1101 }
1091 1102
1092 static applyFunctionWithNamedArguments(Function function, 1103 static applyFunctionWithNamedArguments(Function function,
1093 List positionalArguments, 1104 List positionalArguments,
1094 Map<String, dynamic> namedArguments) { 1105 Map<String, dynamic> namedArguments) {
(...skipping 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 // This is a function that will return a helper function that does the 3731 // This is a function that will return a helper function that does the
3721 // iteration of the sync*. 3732 // iteration of the sync*.
3722 // 3733 //
3723 // Each invocation should give a helper with fresh state. 3734 // Each invocation should give a helper with fresh state.
3724 final dynamic /* js function */ _outerHelper; 3735 final dynamic /* js function */ _outerHelper;
3725 3736
3726 SyncStarIterable(this._outerHelper); 3737 SyncStarIterable(this._outerHelper);
3727 3738
3728 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); 3739 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper));
3729 } 3740 }
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