| Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
|
| diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
|
| index 3addf4bd482c5a0022320b976a2aab79b9e0cec1..46e5002e6ae86963495bff2853fb7693b56f8c43 100644
|
| --- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
|
| +++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
|
| @@ -28,7 +28,7 @@ import '../tree/nodes.dart' show FunctionExpression, Node;
|
| import '../types/masks.dart';
|
| import '../universe/call_structure.dart' show CallStructure;
|
| import '../universe/selector.dart';
|
| -import '../universe/use.dart' show TypeUse;
|
| +import '../universe/use.dart' show StaticUse, TypeUse;
|
| import '../universe/side_effects.dart' show SideEffects;
|
| import 'graph_builder.dart';
|
| import 'kernel_ast_adapter.dart';
|
| @@ -1191,31 +1191,6 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
|
| }
|
| _pushStaticInvocation(target, <HInstruction>[], backend.dynamicType);
|
| }
|
| -
|
| - /*
|
| - if (!node.arguments.isEmpty) {
|
| - reporter.internalError(
|
| - node, 'Too many arguments to JS_CURRENT_ISOLATE_CONTEXT.');
|
| - }
|
| -
|
| - if (!compiler.hasIsolateSupport) {
|
| - // If the isolate library is not used, we just generate code
|
| - // to fetch the static state.
|
| - String name = backend.namer.staticStateHolder;
|
| - push(new HForeignCode(
|
| - js.js.parseForeignJS(name), backend.dynamicType, <HInstruction>[],
|
| - nativeBehavior: native.NativeBehavior.DEPENDS_OTHER));
|
| - } else {
|
| - // Call a helper method from the isolate library. The isolate
|
| - // library uses its own isolate structure, that encapsulates
|
| - // Leg's isolate.
|
| - Element element = helpers.currentIsolate;
|
| - if (element == null) {
|
| - reporter.internalError(node, 'Isolate library and compiler mismatch.');
|
| - }
|
| - pushInvokeStatic(null, element, [], typeMask: backend.dynamicType);
|
| - }
|
| - */
|
| }
|
|
|
| void handleForeignJsCallInIsolate(ir.StaticInvocation invocation) {
|
| @@ -1224,12 +1199,48 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
|
|
|
| void handleForeignDartClosureToJs(
|
| ir.StaticInvocation invocation, String name) {
|
| - unhandledForeign(invocation);
|
| + // TODO(sra): Do we need to wrap the closure in something that saves the
|
| + // current isolate?
|
| + handleForeignRawFunctionRef(invocation, name);
|
| }
|
|
|
| void handleForeignRawFunctionRef(
|
| ir.StaticInvocation invocation, String name) {
|
| - unhandledForeign(invocation);
|
| + if (_unexpectedForeignArguments(invocation, 1, 1)) {
|
| + stack.add(graph.addConstantNull(compiler)); // Result expected on stack.
|
| + return;
|
| + }
|
| +
|
| + ir.Expression closure = invocation.arguments.positional.single;
|
| + String problem = 'requires a static method or top-level method';
|
| + if (closure is ir.StaticGet) {
|
| + ir.Member staticTarget = closure.target;
|
| + if (staticTarget is ir.Procedure) {
|
| + if (staticTarget.kind == ir.ProcedureKind.Method) {
|
| + ir.FunctionNode function = staticTarget.function;
|
| + if (function != null &&
|
| + function.requiredParameterCount ==
|
| + function.positionalParameters.length &&
|
| + function.namedParameters.isEmpty) {
|
| + registry?.registerStaticUse(
|
| + new StaticUse.foreignUse(astAdapter.getMember(staticTarget)));
|
| + push(new HForeignCode(
|
| + js.js.expressionTemplateYielding(backend.emitter
|
| + .staticFunctionAccess(astAdapter.getMember(staticTarget))),
|
| + backend.dynamicType,
|
| + <HInstruction>[],
|
| + nativeBehavior: native.NativeBehavior.PURE));
|
| + return;
|
| + }
|
| + problem = 'does not handle a closure with optional parameters';
|
| + }
|
| + }
|
| + }
|
| +
|
| + compiler.reporter.reportErrorMessage(astAdapter.getNode(invocation),
|
| + MessageKind.GENERIC, {'text': "'$name' $problem."});
|
| + stack.add(graph.addConstantNull(compiler)); // Result expected on stack.
|
| + return;
|
| }
|
|
|
| void handleForeignJsSetStaticState(ir.StaticInvocation invocation) {
|
|
|