Mercurial > hg > truffle
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java @ 12398:c78612fb0120
Truffle-DSL. fixed some issues with new generation strategy.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 11 Oct 2013 20:45:14 +0200 |
parents | 8e8347ecabbc |
children | 980db6c0bcd3 |
comparison
equal
deleted
inserted
replaced
12397:80963ec8134e | 12398:c78612fb0120 |
---|---|
1964 return targetExecutable; | 1964 return targetExecutable; |
1965 } | 1965 } |
1966 | 1966 |
1967 private CodeTree createExecuteChild(CodeTreeBuilder parent, NodeChildData child, ExecutableTypeData sourceExecutable, ActualParameter targetParameter, ActualParameter unexpectedParameter) { | 1967 private CodeTree createExecuteChild(CodeTreeBuilder parent, NodeChildData child, ExecutableTypeData sourceExecutable, ActualParameter targetParameter, ActualParameter unexpectedParameter) { |
1968 SpecializationData specialization = getModel(); | 1968 SpecializationData specialization = getModel(); |
1969 if (specialization.isPolymorphic() && targetParameter.getTypeSystemType().isGeneric() && unexpectedParameter == null) { | 1969 TreeSet<TypeData> possiblePolymorphicTypes = lookupPolymorphicTargetTypes(targetParameter); |
1970 TreeSet<TypeData> possiblePolymorphicTypes = lookupPolymorphicTargetTypes(targetParameter); | 1970 if (specialization.isPolymorphic() && targetParameter.getTypeSystemType().isGeneric() && unexpectedParameter == null && possiblePolymorphicTypes.size() > 1) { |
1971 | 1971 |
1972 CodeTreeBuilder builder = parent.create(); | 1972 CodeTreeBuilder builder = parent.create(); |
1973 | 1973 |
1974 boolean elseIf = false; | 1974 boolean elseIf = false; |
1975 for (TypeData possiblePolymoprhicType : possiblePolymorphicTypes) { | 1975 for (TypeData possiblePolymoprhicType : possiblePolymorphicTypes) { |
2198 private boolean hasUnexpected(ActualParameter sourceParameter, ActualParameter targetParameter, ActualParameter unexpectedParameter) { | 2198 private boolean hasUnexpected(ActualParameter sourceParameter, ActualParameter targetParameter, ActualParameter unexpectedParameter) { |
2199 NodeChildData child = getModel().getNode().findChild(targetParameter.getSpecification().getName()); | 2199 NodeChildData child = getModel().getNode().findChild(targetParameter.getSpecification().getName()); |
2200 | 2200 |
2201 if (getModel().isPolymorphic() && targetParameter.getTypeSystemType().isGeneric() && unexpectedParameter == null) { | 2201 if (getModel().isPolymorphic() && targetParameter.getTypeSystemType().isGeneric() && unexpectedParameter == null) { |
2202 // check for other polymorphic types | 2202 // check for other polymorphic types |
2203 for (TypeData polymorphicTargetType : lookupPolymorphicTargetTypes(targetParameter)) { | 2203 TreeSet<TypeData> polymorphicTargetTypes = lookupPolymorphicTargetTypes(targetParameter); |
2204 if (hasUnexpectedType(child, sourceParameter, polymorphicTargetType)) { | 2204 if (polymorphicTargetTypes.size() > 1) { |
2205 return true; | 2205 for (TypeData polymorphicTargetType : polymorphicTargetTypes) { |
2206 if (hasUnexpectedType(child, sourceParameter, polymorphicTargetType)) { | |
2207 return true; | |
2208 } | |
2206 } | 2209 } |
2207 } | 2210 } |
2208 } | 2211 } |
2209 | 2212 |
2210 if (hasUnexpectedType(child, sourceParameter, targetParameter.getTypeSystemType())) { | 2213 if (hasUnexpectedType(child, sourceParameter, targetParameter.getTypeSystemType())) { |
2216 private boolean hasUnexpectedType(NodeChildData child, ActualParameter sourceParameter, TypeData targetType) { | 2219 private boolean hasUnexpectedType(NodeChildData child, ActualParameter sourceParameter, TypeData targetType) { |
2217 List<TypeData> implicitSourceTypes = getModel().getNode().getTypeSystem().lookupSourceTypes(targetType); | 2220 List<TypeData> implicitSourceTypes = getModel().getNode().getTypeSystem().lookupSourceTypes(targetType); |
2218 | 2221 |
2219 for (TypeData implicitSourceType : implicitSourceTypes) { | 2222 for (TypeData implicitSourceType : implicitSourceTypes) { |
2220 TypeData sourceType; | 2223 TypeData sourceType; |
2224 ExecutableTypeData targetExecutable = resolveExecutableType(child, implicitSourceType); | |
2221 if (sourceParameter != null) { | 2225 if (sourceParameter != null) { |
2222 sourceType = sourceParameter.getTypeSystemType(); | 2226 sourceType = sourceParameter.getTypeSystemType(); |
2223 } else { | 2227 } else { |
2224 ExecutableTypeData targetExecutable = resolveExecutableType(child, implicitSourceType); | |
2225 if (targetExecutable.hasUnexpectedValue(getContext())) { | 2228 if (targetExecutable.hasUnexpectedValue(getContext())) { |
2226 return true; | 2229 return true; |
2227 } | 2230 } |
2228 sourceType = targetExecutable.getType(); | 2231 sourceType = targetExecutable.getType(); |
2229 } | 2232 } |