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

Side by Side Diff: sdk/lib/_internal/js_runtime/lib/js_helper.dart

Issue 1266903004: dart2js: Default values for static functions are now inside closures. (in the startup emitter). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart ('k') | no next file » | 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 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 1249
1250 int argumentCount = arguments.length; 1250 int argumentCount = arguments.length;
1251 1251
1252 int requiredParameterCount = JS('int', r'#[#]', function, 1252 int requiredParameterCount = JS('int', r'#[#]', function,
1253 JS_GET_NAME(JsGetName.REQUIRED_PARAMETER_PROPERTY)); 1253 JS_GET_NAME(JsGetName.REQUIRED_PARAMETER_PROPERTY));
1254 1254
1255 if (argumentCount < requiredParameterCount) { 1255 if (argumentCount < requiredParameterCount) {
1256 return functionNoSuchMethod(function, arguments, namedArguments); 1256 return functionNoSuchMethod(function, arguments, namedArguments);
1257 } 1257 }
1258 1258
1259 var defaultValues = JS('var', r'#[#]', function, 1259 var defaultValuesClosure = JS('var', r'#[#]', function,
1260 JS_GET_NAME(JsGetName.DEFAULT_VALUES_PROPERTY)); 1260 JS_GET_NAME(JsGetName.DEFAULT_VALUES_PROPERTY));
1261 if (JS('bool', 'typeof # == "function"', defaultValues)) { 1261
1262 // Anonymous closures return a function that returns the default values 1262 bool acceptsOptionalArguments = defaultValuesClosure != null;
1263 // instead of providing the default values directly. 1263
1264 defaultValues = JS('', '#()', defaultValues); 1264 // Default values are stored inside a JavaScript closure to avoid
1265 } 1265 // accessing them too early.
1266 bool acceptsOptionalArguments = defaultValues != null; 1266 var defaultValues = acceptsOptionalArguments
1267 ? JS('', '#()', defaultValuesClosure)
1268 : null;
1267 1269
1268 var interceptor = getInterceptor(function); 1270 var interceptor = getInterceptor(function);
1269 var jsFunction = JS('', '#[#]', interceptor, 1271 var jsFunction = JS('', '#[#]', interceptor,
1270 JS_GET_NAME(JsGetName.CALL_CATCH_ALL)); 1272 JS_GET_NAME(JsGetName.CALL_CATCH_ALL));
1271 if (jsFunction is String) { 1273 if (jsFunction is String) {
1272 // Anonymous closures redirect to the catch-all property instead of 1274 // Anonymous closures redirect to the catch-all property instead of
1273 // storing the catch-all method directly in the catch-all property. 1275 // storing the catch-all method directly in the catch-all property.
1274 jsFunction = JS('', '#[#]', interceptor, jsFunction); 1276 jsFunction = JS('', '#[#]', interceptor, jsFunction);
1275 } 1277 }
1276 1278
(...skipping 2982 matching lines...) Expand 10 before | Expand all | Expand 10 after
4259 // This is a function that will return a helper function that does the 4261 // This is a function that will return a helper function that does the
4260 // iteration of the sync*. 4262 // iteration of the sync*.
4261 // 4263 //
4262 // Each invocation should give a body with fresh state. 4264 // Each invocation should give a body with fresh state.
4263 final dynamic /* js function */ _outerHelper; 4265 final dynamic /* js function */ _outerHelper;
4264 4266
4265 SyncStarIterable(this._outerHelper); 4267 SyncStarIterable(this._outerHelper);
4266 4268
4267 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); 4269 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper));
4268 } 4270 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698