# HG changeset patch # User Christian Humer # Date 1389130013 -3600 # Node ID 419b3ea1bdd16ed72f229617cfc9d1ec586daed3 # Parent e8ef44830b507bb0474cd784838bef9c06087149 Truffle-DSL: removed try-catch hack for polymorphic invocations. diff -r e8ef44830b50 -r 419b3ea1bdd1 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Tue Jan 07 22:06:37 2014 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Tue Jan 07 22:26:53 2014 +0100 @@ -1163,7 +1163,7 @@ NodeChildData child = node.findChild(var.getSimpleName().toString()); if (child != null) { - method.getParameters().add(new CodeVariableElement(child.getNodeType(), child.getName())); + method.getParameters().add(new CodeVariableElement(child.getOriginalType(), child.getName())); } else { method.getParameters().add(new CodeVariableElement(var.asType(), var.getSimpleName().toString())); } @@ -2914,38 +2914,22 @@ } if (!returnBuilder.isEmpty()) { - ExecutableTypeData sourceExecutableType = node.findExecutableType(specialization.getReturnType().getTypeSystemType(), 0); - boolean sourceThrowsUnexpected = sourceExecutableType != null && sourceExecutableType.hasUnexpectedValue(getContext()); - boolean targetSupportsUnexpected = executable.hasUnexpectedValue(getContext()); - TypeData targetType = node.getTypeSystem().findTypeData(builder.findMethod().getReturnType()); TypeData sourceType = specialization.getReturnType().getTypeSystemType(); - if (specialization.isPolymorphic() && sourceThrowsUnexpected && !targetSupportsUnexpected) { - builder.startTryBlock(); - } builder.startReturn(); if (targetType == null || sourceType == null) { builder.tree(returnBuilder.getRoot()); } else if (sourceType.needsCastTo(getContext(), targetType)) { - builder.tree(createCallTypeSystemMethod(context, parent, node, TypeSystemCodeGenerator.expectTypeMethodName(targetType), returnBuilder.getRoot())); + String castMethodName = TypeSystemCodeGenerator.expectTypeMethodName(targetType); + if (!executable.hasUnexpectedValue(context)) { + castMethodName = TypeSystemCodeGenerator.asTypeMethodName(targetType); + } + builder.tree(createCallTypeSystemMethod(context, parent, node, castMethodName, returnBuilder.getRoot())); } else { builder.tree(returnBuilder.getRoot()); } builder.end(); - if (specialization.isPolymorphic() && sourceThrowsUnexpected && !targetSupportsUnexpected) { - builder.end(); - builder.startCatchBlock(getUnexpectedValueException(), "ex"); - builder.startReturn(); - CodeTree returns = CodeTreeBuilder.singleString("ex.getResult()"); - if (sourceType.needsCastTo(getContext(), targetType)) { - builder.tree(createCallTypeSystemMethod(context, parent, node, TypeSystemCodeGenerator.asTypeMethodName(targetType), returns)); - } else { - builder.tree(returns); - } - builder.end(); - builder.end(); - } } if (!specialization.getExceptions().isEmpty()) {