Chromium Code Reviews| Index: dart/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/dart/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| index a0df3633e7c96c59ff7c62d9097470995719c6a2..4bbbd968398778ced44f4470657381d22c3cfe17 100644 |
| --- a/dart/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| +++ b/dart/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| @@ -1885,6 +1885,19 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| return new HTypeConversion.withTypeRepresentation(type, kind, subtype, |
| original, typeVariable); |
| } else if (type.kind == TypeKind.FUNCTION) { |
| + // HERE |
| + String name = kind == HTypeConversion.CAST_TYPE_CHECK |
| + ? '_asCheck' : '_assertCheck'; |
| + |
| + List arguments = [buildFunctionType(type), original]; |
| + pushInvokeDynamic( |
| + null, |
| + new Selector.call(name, compiler.jsHelperLibrary, 1), |
| + arguments); |
| + |
| + return new HTypeConversion(type, kind, original.instructionType, pop()); |
| +/* |
| + |
| if (backend.rti.isSimpleFunctionType(type)) { |
| return original.convertType(compiler, type, kind); |
| } |
| @@ -1906,6 +1919,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| } else { |
| return new HTypeConversion(type, kind, subtype, original); |
| } |
| +*/ |
| } else { |
| return original.convertType(compiler, type, kind); |
| } |
| @@ -2014,7 +2028,9 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| } |
| HInstruction attachPosition(HInstruction target, Node node) { |
| - target.sourcePosition = sourceFileLocationForBeginToken(node); |
| + if (node != null) { |
| + target.sourcePosition = sourceFileLocationForBeginToken(node); |
| + } |
| return target; |
| } |
| @@ -2916,9 +2932,39 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| return buildLiteralList(inputs); |
| } |
| + HInstruction buildFunctionType(FunctionType type) { |
| + List<HInstruction> typeVariables = <HInstruction>[]; |
|
Johnni Winther
2013/10/30 12:02:19
Make [typeVariables] a Map<TypeVariableElement, HI
ahe
2013/11/29 13:10:17
Just tried it, it doesn't work. I don't think you
|
| + bool hasDirectTypeVariables = |
| + !currentElement.enclosingElement.isClosure() && |
| + currentElement.isInstanceMember(); |
| + |
| + type.forEachTypeVariable((TypeVariableType variable) { |
| + if (hasDirectTypeVariables) { |
| + HInstruction receiver = localsHandler.readThis(); |
| + push(new HReadTypeVariable(variable, receiver)); |
| + } else { |
| + push( |
| + new HReadTypeVariable.noReceiver( |
| + variable, addTypeVariableReference(variable))); |
| + } |
| + typeVariables.add(pop()); |
| + }); |
| + push(new HFunctionType(typeVariables, type)); |
| + return pop(); |
| + } |
| + |
| HInstruction buildIsNode(Node node, DartType type, HInstruction expression) { |
| type = type.unalias(compiler); |
| if (type.kind == TypeKind.FUNCTION) { |
| + // HERE |
| + List arguments = [buildFunctionType(type), expression]; |
| + pushInvokeDynamic( |
| + node, new Selector.call('_isTest', compiler.jsHelperLibrary, 1), |
| + arguments); |
| + |
| + return new HIs.compound(type, expression, pop()); |
| + |
| +/* |
| if (backend.rti.isSimpleFunctionType(type)) { |
| // TODO(johnniwinther): Avoid interceptor if unneeded. |
| return new HIs.raw(type, expression, invokeInterceptor(expression)); |
| @@ -2960,6 +3006,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| pushInvokeStatic(node, checkFunctionSubtype, inputs, HType.BOOLEAN); |
| HInstruction call = pop(); |
| return new HIs.compound(type, expression, call); |
| +*/ |
| } else if (type.kind == TypeKind.TYPE_VARIABLE) { |
| HInstruction runtimeType = addTypeVariableReference(type); |
| Element helper = backend.getCheckSubtypeOfRuntimeType(); |