OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of ssa; | 5 part of ssa; |
6 | 6 |
7 /** | 7 /** |
8 * A special element for the extra parameter taken by intercepted | 8 * A special element for the extra parameter taken by intercepted |
9 * methods. We need to override [Element.computeType] because our | 9 * methods. We need to override [Element.computeType] because our |
10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
(...skipping 3597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3608 // TODO(johnniwinther): Try to eliminate the need to distinguish declaration | 3608 // TODO(johnniwinther): Try to eliminate the need to distinguish declaration |
3609 // and implementation signatures. Currently it is need because the | 3609 // and implementation signatures. Currently it is need because the |
3610 // signatures have different elements for parameters. | 3610 // signatures have different elements for parameters. |
3611 FunctionElement implementation = function.implementation; | 3611 FunctionElement implementation = function.implementation; |
3612 FunctionSignature params = implementation.computeSignature(compiler); | 3612 FunctionSignature params = implementation.computeSignature(compiler); |
3613 if (params.optionalParameterCount != 0) { | 3613 if (params.optionalParameterCount != 0) { |
3614 compiler.cancel( | 3614 compiler.cancel( |
3615 '"$name" does not handle closure with optional parameters', | 3615 '"$name" does not handle closure with optional parameters', |
3616 node: closure); | 3616 node: closure); |
3617 } | 3617 } |
3618 visit(closure); | 3618 |
| 3619 compiler.enqueuer.codegen.registerStaticUse(element); |
| 3620 push(new HForeign(backend.namer.elementAccess(element), |
| 3621 backend.dynamicType, |
| 3622 <HInstruction>[])); |
3619 return params; | 3623 return params; |
3620 } | 3624 } |
3621 | 3625 |
3622 void handleForeignDartClosureToJs(Send node, String name) { | 3626 void handleForeignDartClosureToJs(Send node, String name) { |
3623 FunctionSignature params = handleForeignRawFunctionRef(node, name); | 3627 // TODO(ahe): This implements DART_CLOSURE_TO_JS and should probably take |
3624 List<HInstruction> inputs = <HInstruction>[pop()]; | 3628 // care to wrap the closure in another closure that saves the current |
3625 String invocationName = backend.namer.invocationName( | 3629 // isolate. |
3626 new Selector.callClosure(params.requiredParameterCount)); | 3630 handleForeignRawFunctionRef(node, name); |
3627 push(new HForeign(js.js('#.$invocationName'), | |
3628 backend.dynamicType, | |
3629 inputs)); | |
3630 } | 3631 } |
3631 | 3632 |
3632 void handleForeignSetCurrentIsolate(Send node) { | 3633 void handleForeignSetCurrentIsolate(Send node) { |
3633 if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) { | 3634 if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) { |
3634 compiler.cancel('Exactly one argument required', | 3635 compiler.cancel('Exactly one argument required', |
3635 node: node.argumentsNode); | 3636 node: node.argumentsNode); |
3636 } | 3637 } |
3637 visit(node.arguments.head); | 3638 visit(node.arguments.head); |
3638 String isolateName = backend.namer.currentIsolate; | 3639 String isolateName = backend.namer.currentIsolate; |
3639 SideEffects sideEffects = new SideEffects.empty(); | 3640 SideEffects sideEffects = new SideEffects.empty(); |
(...skipping 2762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6402 DartType unaliased = type.unalias(builder.compiler); | 6403 DartType unaliased = type.unalias(builder.compiler); |
6403 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 6404 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
6404 unaliased.accept(this, builder); | 6405 unaliased.accept(this, builder); |
6405 } | 6406 } |
6406 | 6407 |
6407 void visitDynamicType(DynamicType type, SsaFromAstMixin builder) { | 6408 void visitDynamicType(DynamicType type, SsaFromAstMixin builder) { |
6408 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); | 6409 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); |
6409 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); | 6410 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); |
6410 } | 6411 } |
6411 } | 6412 } |
OLD | NEW |