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 dart2js.ir_builder_task; | 5 library dart2js.ir_builder_task; |
6 | 6 |
7 import '../closure.dart' as closurelib; | 7 import '../closure.dart' as closurelib; |
8 import '../closure.dart' hide ClosureScope; | 8 import '../closure.dart' hide ClosureScope; |
9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 3189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3200 if (!Elements.isStaticOrTopLevelFunction(closure)) { | 3200 if (!Elements.isStaticOrTopLevelFunction(closure)) { |
3201 internalError(argument, | 3201 internalError(argument, |
3202 'only static or toplevel function supported'); | 3202 'only static or toplevel function supported'); |
3203 } | 3203 } |
3204 if (closure.functionSignature.hasOptionalParameters) { | 3204 if (closure.functionSignature.hasOptionalParameters) { |
3205 internalError(argument, | 3205 internalError(argument, |
3206 'closures with optional parameters not supported'); | 3206 'closures with optional parameters not supported'); |
3207 } | 3207 } |
3208 return irBuilder.buildForeignCode( | 3208 return irBuilder.buildForeignCode( |
3209 js.js.expressionTemplateYielding( | 3209 js.js.expressionTemplateYielding( |
3210 backend.emitter.staticFunctionAccess(function)), | 3210 backend.emitter.staticFunctionAccess(closure)), |
3211 <ir.Primitive>[], | 3211 <ir.Primitive>[], |
3212 NativeBehavior.PURE, | 3212 NativeBehavior.PURE, |
3213 dependency: closure); | 3213 dependency: closure); |
3214 | 3214 |
3215 case 'JS_BUILTIN': | 3215 case 'JS_BUILTIN': |
3216 // The first argument is a description of the type and effect of the | 3216 // The first argument is a description of the type and effect of the |
3217 // builtin, which has already been analyzed in the frontend. The second | 3217 // builtin, which has already been analyzed in the frontend. The second |
3218 // argument must be a [JsBuiltin] value. All other arguments are | 3218 // argument must be a [JsBuiltin] value. All other arguments are |
3219 // values used by the JavaScript template that is associated with the | 3219 // values used by the JavaScript template that is associated with the |
3220 // builtin. | 3220 // builtin. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3302 CallStructure.NO_ARGS); | 3302 CallStructure.NO_ARGS); |
3303 | 3303 |
3304 GET_STATIC_STATE: case 'JS_GET_STATIC_STATE': | 3304 GET_STATIC_STATE: case 'JS_GET_STATIC_STATE': |
3305 validateArgumentCount(exactly: 0); | 3305 validateArgumentCount(exactly: 0); |
3306 | 3306 |
3307 return irBuilder.buildForeignCode( | 3307 return irBuilder.buildForeignCode( |
3308 js.js.parseForeignJS(backend.namer.staticStateHolder), | 3308 js.js.parseForeignJS(backend.namer.staticStateHolder), |
3309 const <ir.Primitive>[], | 3309 const <ir.Primitive>[], |
3310 NativeBehavior.PURE); | 3310 NativeBehavior.PURE); |
3311 | 3311 |
| 3312 case 'JS_SET_STATIC_STATE': |
| 3313 validateArgumentCount(exactly: 1); |
| 3314 |
| 3315 ir.Primitive value = visit(argumentNodes.single); |
| 3316 String isolateName = backend.namer.staticStateHolder; |
| 3317 return irBuilder.buildForeignCode( |
| 3318 js.js.parseForeignJS("$isolateName = #"), |
| 3319 <ir.Primitive>[value], |
| 3320 NativeBehavior.PURE); |
| 3321 |
3312 case 'JS_CALL_IN_ISOLATE': | 3322 case 'JS_CALL_IN_ISOLATE': |
3313 validateArgumentCount(exactly: 2); | 3323 validateArgumentCount(exactly: 2); |
3314 | 3324 |
3315 if (!compiler.hasIsolateSupport) { | 3325 if (!compiler.hasIsolateSupport) { |
3316 ir.Primitive closure = visit(argumentNodes.tail.head); | 3326 ir.Primitive closure = visit(argumentNodes.tail.head); |
3317 return irBuilder.buildCallInvocation(closure, CallStructure.NO_ARGS, | 3327 return irBuilder.buildCallInvocation(closure, CallStructure.NO_ARGS, |
3318 const <ir.Primitive>[]); | 3328 const <ir.Primitive>[]); |
3319 } | 3329 } |
3320 return buildIsolateHelperInvocation('_callInIsolate', | 3330 return buildIsolateHelperInvocation('_callInIsolate', |
3321 CallStructure.TWO_ARGS); | 3331 CallStructure.TWO_ARGS); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3393 } | 3403 } |
3394 | 3404 |
3395 processSetStatic(ir.SetStatic node) { | 3405 processSetStatic(ir.SetStatic node) { |
3396 node.body = replacementFor(node.body); | 3406 node.body = replacementFor(node.body); |
3397 } | 3407 } |
3398 | 3408 |
3399 processContinuation(ir.Continuation node) { | 3409 processContinuation(ir.Continuation node) { |
3400 node.body = replacementFor(node.body); | 3410 node.body = replacementFor(node.body); |
3401 } | 3411 } |
3402 } | 3412 } |
OLD | NEW |