diff --git a/smojol-core/src/main/java/org/smojol/common/transpiler/FunctionCallNode.java b/smojol-core/src/main/java/org/smojol/common/transpiler/CallFunctionTranspilerNode.java similarity index 82% rename from smojol-core/src/main/java/org/smojol/common/transpiler/FunctionCallNode.java rename to smojol-core/src/main/java/org/smojol/common/transpiler/CallFunctionTranspilerNode.java index 7592c8e8..4a34f3d5 100644 --- a/smojol-core/src/main/java/org/smojol/common/transpiler/FunctionCallNode.java +++ b/smojol-core/src/main/java/org/smojol/common/transpiler/CallFunctionTranspilerNode.java @@ -8,11 +8,11 @@ import java.util.List; @Getter -public class FunctionCallNode extends TranspilerNode { +public class CallFunctionTranspilerNode extends TranspilerNode { private final String functionName; private final List arguments; - public FunctionCallNode(String functionName, List arguments) { + public CallFunctionTranspilerNode(String functionName, List arguments) { super(ImmutableList.of(SemanticCategory.FUNCTION)); this.functionName = functionName; this.arguments = arguments; diff --git a/smojol-core/src/main/java/org/smojol/common/transpiler/TranspilerCloneOperation.java b/smojol-core/src/main/java/org/smojol/common/transpiler/TranspilerCloneOperation.java index f8b1b0e1..485dd29b 100644 --- a/smojol-core/src/main/java/org/smojol/common/transpiler/TranspilerCloneOperation.java +++ b/smojol-core/src/main/java/org/smojol/common/transpiler/TranspilerCloneOperation.java @@ -21,7 +21,7 @@ public static TranspilerNode clone(TranspilerNode original, List case LessThanOrEqualToNode n -> new LessThanOrEqualToNode(n.getLhs(), n.getRhs()); case PrimitiveValueTranspilerNode n -> new PrimitiveValueTranspilerNode(n.getValue()); case SymbolReferenceNode n -> new SymbolReferenceNode(n.getName()); - case FunctionCallNode n -> new FunctionCallNode(n.getFunctionName(), n.getArguments()); + case CallFunctionTranspilerNode n -> new CallFunctionTranspilerNode(n.getFunctionName(), n.getArguments()); case IndexReferenceNode n -> new IndexReferenceNode(n.getRoot(), n.getIndexes()); case NotTranspilerNode n -> new NotTranspilerNode(n); case AndTranspilerNode n -> new AndTranspilerNode(n.getLhs(), n.getRhs()); diff --git a/smojol-toolkit/src/main/java/org/smojol/toolkit/analysis/task/transpiler/BuildTranspilerFlowgraphTask.java b/smojol-toolkit/src/main/java/org/smojol/toolkit/analysis/task/transpiler/BuildTranspilerFlowgraphTask.java index 390de20b..665f6b70 100644 --- a/smojol-toolkit/src/main/java/org/smojol/toolkit/analysis/task/transpiler/BuildTranspilerFlowgraphTask.java +++ b/smojol-toolkit/src/main/java/org/smojol/toolkit/analysis/task/transpiler/BuildTranspilerFlowgraphTask.java @@ -123,7 +123,7 @@ public static Gson initGson() { .registerSubtype(LessThanNode.class, "less_than") .registerSubtype(GreaterThanOrEqualToNode.class, "greater_than_or_equal_to") .registerSubtype(LessThanOrEqualToNode.class, "less_than_or_equal_to") - .registerSubtype(FunctionCallNode.class, "function_call") + .registerSubtype(CallFunctionTranspilerNode.class, "function_call") .registerSubtype(IndexReferenceNode.class, "index_reference") .registerSubtype(JumpTranspilerNode.class, "jump") .registerSubtype(ValueOfNode.class, "valueOf") diff --git a/smojol-toolkit/src/main/java/org/smojol/toolkit/transpiler/TranspilerExpressionBuilder.java b/smojol-toolkit/src/main/java/org/smojol/toolkit/transpiler/TranspilerExpressionBuilder.java index 458c7cf2..caddcc1e 100644 --- a/smojol-toolkit/src/main/java/org/smojol/toolkit/transpiler/TranspilerExpressionBuilder.java +++ b/smojol-toolkit/src/main/java/org/smojol/toolkit/transpiler/TranspilerExpressionBuilder.java @@ -30,7 +30,7 @@ else if (expression instanceof ExponentExpression e) else if (expression instanceof NegativeExpression e) return new NegativeNode(build(e.getExpression())); else if (expression instanceof PrimitiveCobolExpression e) return new PrimitiveValueTranspilerNode(e.data()); else if (expression instanceof FunctionCallExpression e) - return new FunctionCallNode(e.getFunctionName(), e.getArguments().stream().map(this::build).toList()); + return new CallFunctionTranspilerNode(e.getFunctionName(), e.getArguments().stream().map(this::build).toList()); else if (expression instanceof NotExpression e) return new NotTranspilerNode(build(e.getExpression())); else if (expression instanceof AndExpression e) return new AndTranspilerNode(build(e.getLhs()), build(e.getRhs())); else if (expression instanceof OrExpression e) return new OrTranspilerNode(build(e.getLhs()), build(e.getRhs())); @@ -39,19 +39,19 @@ else if (expression instanceof SimpleConditionExpression e) { if (e.getComparison() == null) return explicitCondition(e.getLhs(), dataStructures); return TranspilerComparisonOperator.operator(e.getComparison().getRelationalOperation(), build(e.getLhs()), build(e.getComparison().getRhs())); } else if (expression instanceof SpecialRegisterExpression e) - return new FunctionCallNode(e.getFunctionCall().getFunctionName(), e.getFunctionCall().getArguments().stream().map(this::build).toList()); + return new CallFunctionTranspilerNode(e.getFunctionCall().getFunctionName(), e.getFunctionCall().getArguments().stream().map(this::build).toList()); else if (expression instanceof NullCobolExpression e) return new NullTranspilerNode(); - else if (expression instanceof IsNumericCondition e) return new FunctionCallNode("isNumeric", ImmutableList.of(build(e.getExpression()))); - else if (expression instanceof IsAlphabeticCondition e) return new FunctionCallNode("isAlphanumeric", ImmutableList.of(build(e.getExpression()))); + else if (expression instanceof IsNumericCondition e) return new CallFunctionTranspilerNode("isNumeric", ImmutableList.of(build(e.getExpression()))); + else if (expression instanceof IsAlphabeticCondition e) return new CallFunctionTranspilerNode("isAlphanumeric", ImmutableList.of(build(e.getExpression()))); // TODO: IDMS expressions not supported yet throw new UnsupportedOperationException("Unknown expression type: " + expression); } private TranspilerNode explicitCondition(CobolExpression conditionalConstant, CobolDataStructure root) { LOGGER.finest("Resolving conditional constant: " + conditionalConstant.description()); - if (conditionalConstant instanceof IdmsExpression) return new FunctionCallNode("idms_placeholder_function", ImmutableList.of(new SymbolReferenceNode(conditionalConstant.description()))); + if (conditionalConstant instanceof IdmsExpression) return new CallFunctionTranspilerNode("idms_placeholder_function", ImmutableList.of(new SymbolReferenceNode(conditionalConstant.description()))); CobolDataStructure range = root.reference(((VariableExpression) conditionalConstant).getName()); CobolDataStructure actualVariable = range.parent(); - return new FunctionCallNode("isInRange", ImmutableList.of(new SymbolReferenceNode(actualVariable.name()), new SymbolReferenceNode(range.name()))); + return new CallFunctionTranspilerNode("isInRange", ImmutableList.of(new SymbolReferenceNode(actualVariable.name()), new SymbolReferenceNode(range.name()))); } }