Skip to content

Commit

Permalink
Rename to avoid ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
avishek-sen-gupta committed Nov 19, 2024
1 parent 58bfa8b commit e1d073d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<TranspilerNode> arguments;

public FunctionCallNode(String functionName, List<TranspilerNode> arguments) {
public CallFunctionTranspilerNode(String functionName, List<TranspilerNode> arguments) {
super(ImmutableList.of(SemanticCategory.FUNCTION));
this.functionName = functionName;
this.arguments = arguments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static TranspilerNode clone(TranspilerNode original, List<TranspilerNode>
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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())));
}
}

0 comments on commit e1d073d

Please sign in to comment.