Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java @ 11554:5d5007c9a5aa
Truffle-DSL: fixed a if bug target parameters and executes accidently do not match.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Sun, 08 Sep 2013 13:16:12 +0200 |
parents | 2fb276f5e3e9 |
children | 152b4146f05b |
comparison
equal
deleted
inserted
replaced
11553:8a2664ad5c55 | 11554:5d5007c9a5aa |
---|---|
2001 builder.string(" = "); | 2001 builder.string(" = "); |
2002 if (cast != null) { | 2002 if (cast != null) { |
2003 startCallTypeSystemMethod(getContext(), builder, child.getNodeData(), cast.getMethodName()); | 2003 startCallTypeSystemMethod(getContext(), builder, child.getNodeData(), cast.getMethodName()); |
2004 } | 2004 } |
2005 | 2005 |
2006 if (targetExecutable.getType().needsCastTo(context, targetParameter.getTypeSystemType()) && cast == null) { | |
2007 startCallTypeSystemMethod(getContext(), builder, child.getNodeData(), TypeSystemCodeGenerator.expectTypeMethodName(targetParameter.getTypeSystemType())); | |
2008 } | |
2009 | |
2006 NodeData node = getModel().getNode(); | 2010 NodeData node = getModel().getNode(); |
2007 ActualParameter sourceParameter = sourceExecutable.findParameter(targetParameter.getLocalName()); | 2011 ActualParameter sourceParameter = sourceExecutable.findParameter(targetParameter.getLocalName()); |
2008 if (sourceParameter == null) { | 2012 if (sourceParameter == null) { |
2009 builder.tree(createExecuteChildExpression(builder, child, targetParameter, targetExecutable, unexpectedParameter)); | 2013 builder.tree(createExecuteChildExpression(builder, child, targetParameter, targetExecutable, unexpectedParameter)); |
2010 } else { | 2014 } else { |
2011 CodeTree var = CodeTreeBuilder.singleString(valueNameEvaluated(targetParameter)); | 2015 CodeTree var = CodeTreeBuilder.singleString(valueNameEvaluated(targetParameter)); |
2012 builder.tree(createExpectExecutableType(node, sourceParameter.getTypeSystemType(), targetExecutable, var)); | 2016 builder.tree(createExpectExecutableType(node, sourceParameter.getTypeSystemType(), targetExecutable, var)); |
2013 } | 2017 } |
2018 | |
2019 if (targetExecutable.getType().needsCastTo(context, targetParameter.getTypeSystemType())) { | |
2020 builder.end().end(); | |
2021 } | |
2022 | |
2014 if (cast != null) { | 2023 if (cast != null) { |
2015 builder.end().end(); | 2024 builder.end().end(); |
2016 } | 2025 } |
2017 | 2026 |
2018 return builder.getRoot(); | 2027 return builder.getRoot(); |
2047 } | 2056 } |
2048 return hasUnexpected; | 2057 return hasUnexpected; |
2049 } | 2058 } |
2050 | 2059 |
2051 private boolean hasUnexpectedType(ExecutableTypeData target, ActualParameter sourceParameter, TypeData type) { | 2060 private boolean hasUnexpectedType(ExecutableTypeData target, ActualParameter sourceParameter, TypeData type) { |
2061 boolean targetCast = target.getType().needsCastTo(context, type); | |
2062 if (targetCast && getModel().getNode().getTypeSystem().lookupCast(target.getType(), type) == null) { | |
2063 return true; | |
2064 } | |
2052 if (sourceParameter == null) { | 2065 if (sourceParameter == null) { |
2053 return target.hasUnexpectedValue(getContext()); | 2066 return target.hasUnexpectedValue(getContext()); |
2054 } else { | 2067 } else { |
2055 if (sourceParameter.getTypeSystemType().needsCastTo(getContext(), type)) { | 2068 if (sourceParameter.getTypeSystemType().needsCastTo(getContext(), type)) { |
2056 return target.hasUnexpectedValue(getContext()); | 2069 return target.hasUnexpectedValue(getContext()); |