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

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

Issue 1154073004: Change more JS foreign methods to JS_GET_NAME. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix long lines. Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/js_mirrors.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 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 '', 2311 '',
2312 'function(f,r){' 2312 'function(f,r){'
2313 'return function(){' 2313 'return function(){'
2314 'return f.apply({\$receiver:r(this)},arguments)' 2314 'return f.apply({\$receiver:r(this)},arguments)'
2315 '}' 2315 '}'
2316 '}(#,#)', functionType, getReceiver); 2316 '}(#,#)', functionType, getReceiver);
2317 } else { 2317 } else {
2318 throw 'Error in reflectionInfo.'; 2318 throw 'Error in reflectionInfo.';
2319 } 2319 }
2320 2320
2321 JS('', '#[#] = #', prototype, JS_GET_NAME(JsGetName.SIGNATURE_NAME), signatu reFunction); 2321 JS('', '#[#] = #', prototype, JS_GET_NAME(JsGetName.SIGNATURE_NAME),
2322 signatureFunction);
2322 2323
2323 JS('', '#[#] = #', prototype, callName, trampoline); 2324 JS('', '#[#] = #', prototype, callName, trampoline);
2324 for (int i = 1; i < functions.length; i++) { 2325 for (int i = 1; i < functions.length; i++) {
2325 var stub = functions[i]; 2326 var stub = functions[i];
2326 var stubCallName = JS('String|Null', '#[#]', stub, 2327 var stubCallName = JS('String|Null', '#[#]', stub,
2327 JS_GET_NAME(JsGetName.CALL_NAME_PROPERTY)); 2328 JS_GET_NAME(JsGetName.CALL_NAME_PROPERTY));
2328 if (stubCallName != null) { 2329 if (stubCallName != null) {
2329 JS('', '#[#] = #', prototype, stubCallName, 2330 JS('', '#[#] = #', prototype, stubCallName,
2330 isStatic ? stub : forwardCallTo(receiver, stub, isIntercepted)); 2331 isStatic ? stub : forwardCallTo(receiver, stub, isIntercepted));
2331 } 2332 }
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
3214 } 3215 }
3215 throw new CastErrorImplementation(pretty, self); 3216 throw new CastErrorImplementation(pretty, self);
3216 } else { 3217 } else {
3217 // TODO(ahe): Pass "pretty" function-type to TypeErrorImplementation? 3218 // TODO(ahe): Pass "pretty" function-type to TypeErrorImplementation?
3218 throw new TypeErrorImplementation(expression, self); 3219 throw new TypeErrorImplementation(expression, self);
3219 } 3220 }
3220 } 3221 }
3221 3222
3222 _extractFunctionTypeObjectFrom(o) { 3223 _extractFunctionTypeObjectFrom(o) {
3223 var interceptor = getInterceptor(o); 3224 var interceptor = getInterceptor(o);
3224 return JS('bool', '# in #', JS_GET_NAME(JsGetName.SIGNATURE_NAME), intercept or) 3225 var signatureName = JS_GET_NAME(JsGetName.SIGNATURE_NAME);
3226 return JS('bool', '# in #', signatureName, interceptor)
3225 ? JS('', '#[#]()', interceptor, JS_GET_NAME(JsGetName.SIGNATURE_NAME)) 3227 ? JS('', '#[#]()', interceptor, JS_GET_NAME(JsGetName.SIGNATURE_NAME))
3226 : null; 3228 : null;
3227 } 3229 }
3228 3230
3229 toRti() { 3231 toRti() {
3230 var result = createDartFunctionTypeRti(); 3232 var result = createDartFunctionTypeRti();
3231 if (isVoid) { 3233 if (isVoid) {
3232 JS('', '#[#] = true', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_VOID_RET URN_TAG)); 3234 JS('', '#[#] = true', result,
3235 JS_GET_NAME(JsGetName.FUNCTION_TYPE_VOID_RETURN_TAG));
3233 } else { 3236 } else {
3234 if (returnType is! DynamicRuntimeType) { 3237 if (returnType is! DynamicRuntimeType) {
3235 JS('', '#[#] = #', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_RETURN_TY PE_TAG), 3238 JS('', '#[#] = #', result,
3239 JS_GET_NAME(JsGetName.FUNCTION_TYPE_RETURN_TYPE_TAG),
3236 returnType.toRti()); 3240 returnType.toRti());
3237 } 3241 }
3238 } 3242 }
3239 if (parameterTypes != null && !parameterTypes.isEmpty) { 3243 if (parameterTypes != null && !parameterTypes.isEmpty) {
3240 JS('', '#[#] = #', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PA RAMETERS_TAG), 3244 JS('', '#[#] = #', result,
3245 JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG),
3241 listToRti(parameterTypes)); 3246 listToRti(parameterTypes));
3242 } 3247 }
3243 3248
3244 if (optionalParameterTypes != null && !optionalParameterTypes.isEmpty) { 3249 if (optionalParameterTypes != null && !optionalParameterTypes.isEmpty) {
3245 JS('', '#[#] = #', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_OPTIONAL_PA RAMETERS_TAG), 3250 JS('', '#[#] = #', result,
3251 JS_GET_NAME(JsGetName.FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG),
3246 listToRti(optionalParameterTypes)); 3252 listToRti(optionalParameterTypes));
3247 } 3253 }
3248 3254
3249 if (namedParameters != null) { 3255 if (namedParameters != null) {
3250 var namedRti = JS('=Object', 'Object.create(null)'); 3256 var namedRti = JS('=Object', 'Object.create(null)');
3251 var keys = extractKeys(namedParameters); 3257 var keys = extractKeys(namedParameters);
3252 for (var i = 0; i < keys.length; i++) { 3258 for (var i = 0; i < keys.length; i++) {
3253 var name = keys[i]; 3259 var name = keys[i];
3254 var rti = JS('', '#[#]', namedParameters, name).toRti(); 3260 var rti = JS('', '#[#]', namedParameters, name).toRti();
3255 JS('', '#[#] = #', namedRti, name, rti); 3261 JS('', '#[#] = #', namedRti, name, rti);
3256 } 3262 }
3257 JS('', '#[#] = #', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAM ETERS_TAG), 3263 JS('', '#[#] = #', result,
3264 JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAMETERS_TAG),
3258 namedRti); 3265 namedRti);
3259 } 3266 }
3260 3267
3261 return result; 3268 return result;
3262 } 3269 }
3263 3270
3264 static listToRti(list) { 3271 static listToRti(list) {
3265 list = JS('JSFixedArray', '#', list); 3272 list = JS('JSFixedArray', '#', list);
3266 var result = JS('JSExtendableArray', '[]'); 3273 var result = JS('JSExtendableArray', '[]');
3267 for (var i = 0; i < list.length; i++) { 3274 for (var i = 0; i < list.length; i++) {
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 // This is a function that will return a helper function that does the 4096 // This is a function that will return a helper function that does the
4090 // iteration of the sync*. 4097 // iteration of the sync*.
4091 // 4098 //
4092 // Each invocation should give a body with fresh state. 4099 // Each invocation should give a body with fresh state.
4093 final dynamic /* js function */ _outerHelper; 4100 final dynamic /* js function */ _outerHelper;
4094 4101
4095 SyncStarIterable(this._outerHelper); 4102 SyncStarIterable(this._outerHelper);
4096 4103
4097 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); 4104 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper));
4098 } 4105 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698