OLD | NEW |
---|---|
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 Loading... | |
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_SIGNATURE_NAME(), signatureFunction); | 2321 JS('', '#[#] = #', prototype, JS_GET_NAME(JsGetName.SIGNATURE_NAME), signatu reFunction); |
herhut
2015/06/03 08:58:28
Long line...
| |
2322 | 2322 |
2323 JS('', '#[#] = #', prototype, callName, trampoline); | 2323 JS('', '#[#] = #', prototype, callName, trampoline); |
2324 for (int i = 1; i < functions.length; i++) { | 2324 for (int i = 1; i < functions.length; i++) { |
2325 var stub = functions[i]; | 2325 var stub = functions[i]; |
2326 var stubCallName = JS('String|Null', '#[#]', stub, | 2326 var stubCallName = JS('String|Null', '#[#]', stub, |
2327 JS_GET_NAME(JsGetName.CALL_NAME_PROPERTY)); | 2327 JS_GET_NAME(JsGetName.CALL_NAME_PROPERTY)); |
2328 if (stubCallName != null) { | 2328 if (stubCallName != null) { |
2329 JS('', '#[#] = #', prototype, stubCallName, | 2329 JS('', '#[#] = #', prototype, stubCallName, |
2330 isStatic ? stub : forwardCallTo(receiver, stub, isIntercepted)); | 2330 isStatic ? stub : forwardCallTo(receiver, stub, isIntercepted)); |
2331 } | 2331 } |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3214 } | 3214 } |
3215 throw new CastErrorImplementation(pretty, self); | 3215 throw new CastErrorImplementation(pretty, self); |
3216 } else { | 3216 } else { |
3217 // TODO(ahe): Pass "pretty" function-type to TypeErrorImplementation? | 3217 // TODO(ahe): Pass "pretty" function-type to TypeErrorImplementation? |
3218 throw new TypeErrorImplementation(expression, self); | 3218 throw new TypeErrorImplementation(expression, self); |
3219 } | 3219 } |
3220 } | 3220 } |
3221 | 3221 |
3222 _extractFunctionTypeObjectFrom(o) { | 3222 _extractFunctionTypeObjectFrom(o) { |
3223 var interceptor = getInterceptor(o); | 3223 var interceptor = getInterceptor(o); |
3224 return JS('bool', '# in #', JS_SIGNATURE_NAME(), interceptor) | 3224 return JS('bool', '# in #', JS_GET_NAME(JsGetName.SIGNATURE_NAME), intercept or) |
herhut
2015/06/03 08:58:28
Long line...
| |
3225 ? JS('', '#[#]()', interceptor, JS_SIGNATURE_NAME()) | 3225 ? JS('', '#[#]()', interceptor, JS_GET_NAME(JsGetName.SIGNATURE_NAME)) |
3226 : null; | 3226 : null; |
3227 } | 3227 } |
3228 | 3228 |
3229 toRti() { | 3229 toRti() { |
3230 var result = createDartFunctionTypeRti(); | 3230 var result = createDartFunctionTypeRti(); |
3231 if (isVoid) { | 3231 if (isVoid) { |
3232 JS('', '#[#] = true', result, JS_FUNCTION_TYPE_VOID_RETURN_TAG()); | 3232 JS('', '#[#] = true', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_VOID_RET URN_TAG)); |
herhut
2015/06/03 08:58:28
Long line...
| |
3233 } else { | 3233 } else { |
3234 if (returnType is! DynamicRuntimeType) { | 3234 if (returnType is! DynamicRuntimeType) { |
3235 JS('', '#[#] = #', result, JS_FUNCTION_TYPE_RETURN_TYPE_TAG(), | 3235 JS('', '#[#] = #', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_RETURN_TY PE_TAG), |
herhut
2015/06/03 08:58:28
Long line...
| |
3236 returnType.toRti()); | 3236 returnType.toRti()); |
3237 } | 3237 } |
3238 } | 3238 } |
3239 if (parameterTypes != null && !parameterTypes.isEmpty) { | 3239 if (parameterTypes != null && !parameterTypes.isEmpty) { |
3240 JS('', '#[#] = #', result, JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG(), | 3240 JS('', '#[#] = #', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PA RAMETERS_TAG), |
herhut
2015/06/03 08:58:27
Long line...
| |
3241 listToRti(parameterTypes)); | 3241 listToRti(parameterTypes)); |
3242 } | 3242 } |
3243 | 3243 |
3244 if (optionalParameterTypes != null && !optionalParameterTypes.isEmpty) { | 3244 if (optionalParameterTypes != null && !optionalParameterTypes.isEmpty) { |
3245 JS('', '#[#] = #', result, JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG(), | 3245 JS('', '#[#] = #', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_OPTIONAL_PA RAMETERS_TAG), |
herhut
2015/06/03 08:58:27
Long line...
| |
3246 listToRti(optionalParameterTypes)); | 3246 listToRti(optionalParameterTypes)); |
3247 } | 3247 } |
3248 | 3248 |
3249 if (namedParameters != null) { | 3249 if (namedParameters != null) { |
3250 var namedRti = JS('=Object', 'Object.create(null)'); | 3250 var namedRti = JS('=Object', 'Object.create(null)'); |
3251 var keys = extractKeys(namedParameters); | 3251 var keys = extractKeys(namedParameters); |
3252 for (var i = 0; i < keys.length; i++) { | 3252 for (var i = 0; i < keys.length; i++) { |
3253 var name = keys[i]; | 3253 var name = keys[i]; |
3254 var rti = JS('', '#[#]', namedParameters, name).toRti(); | 3254 var rti = JS('', '#[#]', namedParameters, name).toRti(); |
3255 JS('', '#[#] = #', namedRti, name, rti); | 3255 JS('', '#[#] = #', namedRti, name, rti); |
3256 } | 3256 } |
3257 JS('', '#[#] = #', result, JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG(), | 3257 JS('', '#[#] = #', result, JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAM ETERS_TAG), |
herhut
2015/06/03 08:58:27
Long line...
| |
3258 namedRti); | 3258 namedRti); |
3259 } | 3259 } |
3260 | 3260 |
3261 return result; | 3261 return result; |
3262 } | 3262 } |
3263 | 3263 |
3264 static listToRti(list) { | 3264 static listToRti(list) { |
3265 list = JS('JSFixedArray', '#', list); | 3265 list = JS('JSFixedArray', '#', list); |
3266 var result = JS('JSExtendableArray', '[]'); | 3266 var result = JS('JSExtendableArray', '[]'); |
3267 for (var i = 0; i < list.length; i++) { | 3267 for (var i = 0; i < list.length; i++) { |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4089 // This is a function that will return a helper function that does the | 4089 // This is a function that will return a helper function that does the |
4090 // iteration of the sync*. | 4090 // iteration of the sync*. |
4091 // | 4091 // |
4092 // Each invocation should give a body with fresh state. | 4092 // Each invocation should give a body with fresh state. |
4093 final dynamic /* js function */ _outerHelper; | 4093 final dynamic /* js function */ _outerHelper; |
4094 | 4094 |
4095 SyncStarIterable(this._outerHelper); | 4095 SyncStarIterable(this._outerHelper); |
4096 | 4096 |
4097 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); | 4097 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); |
4098 } | 4098 } |
OLD | NEW |