Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java @ 13536:419b3ea1bdd1
Truffle-DSL: removed try-catch hack for polymorphic invocations.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 07 Jan 2014 22:26:53 +0100 |
parents | e8ef44830b50 |
children | f270f09616da |
comparison
equal
deleted
inserted
replaced
13535:e8ef44830b50 | 13536:419b3ea1bdd1 |
---|---|
1161 | 1161 |
1162 for (VariableElement var : type.getFields()) { | 1162 for (VariableElement var : type.getFields()) { |
1163 NodeChildData child = node.findChild(var.getSimpleName().toString()); | 1163 NodeChildData child = node.findChild(var.getSimpleName().toString()); |
1164 | 1164 |
1165 if (child != null) { | 1165 if (child != null) { |
1166 method.getParameters().add(new CodeVariableElement(child.getNodeType(), child.getName())); | 1166 method.getParameters().add(new CodeVariableElement(child.getOriginalType(), child.getName())); |
1167 } else { | 1167 } else { |
1168 method.getParameters().add(new CodeVariableElement(var.asType(), var.getSimpleName().toString())); | 1168 method.getParameters().add(new CodeVariableElement(var.asType(), var.getSimpleName().toString())); |
1169 } | 1169 } |
1170 | 1170 |
1171 builder.startStatement(); | 1171 builder.startStatement(); |
2912 } else { | 2912 } else { |
2913 returnBuilder.tree(createTemplateMethodCall(returnBuilder, null, specialization, specialization, null)); | 2913 returnBuilder.tree(createTemplateMethodCall(returnBuilder, null, specialization, specialization, null)); |
2914 } | 2914 } |
2915 | 2915 |
2916 if (!returnBuilder.isEmpty()) { | 2916 if (!returnBuilder.isEmpty()) { |
2917 ExecutableTypeData sourceExecutableType = node.findExecutableType(specialization.getReturnType().getTypeSystemType(), 0); | |
2918 boolean sourceThrowsUnexpected = sourceExecutableType != null && sourceExecutableType.hasUnexpectedValue(getContext()); | |
2919 boolean targetSupportsUnexpected = executable.hasUnexpectedValue(getContext()); | |
2920 | |
2921 TypeData targetType = node.getTypeSystem().findTypeData(builder.findMethod().getReturnType()); | 2917 TypeData targetType = node.getTypeSystem().findTypeData(builder.findMethod().getReturnType()); |
2922 TypeData sourceType = specialization.getReturnType().getTypeSystemType(); | 2918 TypeData sourceType = specialization.getReturnType().getTypeSystemType(); |
2923 | 2919 |
2924 if (specialization.isPolymorphic() && sourceThrowsUnexpected && !targetSupportsUnexpected) { | |
2925 builder.startTryBlock(); | |
2926 } | |
2927 builder.startReturn(); | 2920 builder.startReturn(); |
2928 if (targetType == null || sourceType == null) { | 2921 if (targetType == null || sourceType == null) { |
2929 builder.tree(returnBuilder.getRoot()); | 2922 builder.tree(returnBuilder.getRoot()); |
2930 } else if (sourceType.needsCastTo(getContext(), targetType)) { | 2923 } else if (sourceType.needsCastTo(getContext(), targetType)) { |
2931 builder.tree(createCallTypeSystemMethod(context, parent, node, TypeSystemCodeGenerator.expectTypeMethodName(targetType), returnBuilder.getRoot())); | 2924 String castMethodName = TypeSystemCodeGenerator.expectTypeMethodName(targetType); |
2925 if (!executable.hasUnexpectedValue(context)) { | |
2926 castMethodName = TypeSystemCodeGenerator.asTypeMethodName(targetType); | |
2927 } | |
2928 builder.tree(createCallTypeSystemMethod(context, parent, node, castMethodName, returnBuilder.getRoot())); | |
2932 } else { | 2929 } else { |
2933 builder.tree(returnBuilder.getRoot()); | 2930 builder.tree(returnBuilder.getRoot()); |
2934 } | 2931 } |
2935 builder.end(); | 2932 builder.end(); |
2936 if (specialization.isPolymorphic() && sourceThrowsUnexpected && !targetSupportsUnexpected) { | |
2937 builder.end(); | |
2938 builder.startCatchBlock(getUnexpectedValueException(), "ex"); | |
2939 builder.startReturn(); | |
2940 CodeTree returns = CodeTreeBuilder.singleString("ex.getResult()"); | |
2941 if (sourceType.needsCastTo(getContext(), targetType)) { | |
2942 builder.tree(createCallTypeSystemMethod(context, parent, node, TypeSystemCodeGenerator.asTypeMethodName(targetType), returns)); | |
2943 } else { | |
2944 builder.tree(returns); | |
2945 } | |
2946 builder.end(); | |
2947 builder.end(); | |
2948 } | |
2949 } | 2933 } |
2950 | 2934 |
2951 if (!specialization.getExceptions().isEmpty()) { | 2935 if (!specialization.getExceptions().isEmpty()) { |
2952 for (SpecializationThrowsData exception : specialization.getExceptions()) { | 2936 for (SpecializationThrowsData exception : specialization.getExceptions()) { |
2953 builder.end().startCatchBlock(exception.getJavaClass(), "ex"); | 2937 builder.end().startCatchBlock(exception.getJavaClass(), "ex"); |