Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformer for MULTIPLY works the wrong way round #5

Open
rs-idesis opened this issue Mar 26, 2024 · 0 comments
Open

Transformer for MULTIPLY works the wrong way round #5

rs-idesis opened this issue Mar 26, 2024 · 0 comments

Comments

@rs-idesis
Copy link

rs-idesis commented Mar 26, 2024

Hello!

I am new to Cobol, but according to Cobol examples and specifications I found, printMultiplyRegular() in MultiplyStatementRule contains a bug. It treats the first operand as the result and "MULTIPLY 42 BY B" is transformed into "BigDecimal.valueOf(42) = BigDecimal.valueOf(42).multiply(b);", which makes no sense (especially when the first argument is a literal).

This replacement will fix it:

package io.proleap.cobol.transform.java.rules.lang.procedure.multiply;

// ...

public class MultiplyStatementRule extends CobolTransformRule<MultiplyStatementContext, MultiplyStatement> {

	// ...

	protected void printMultiplyRegular(MultiplyStatement multiplyStatement, RuleContext rc) {
		ByPhrase regular = multiplyStatement.getByPhrase();

		for (ByOperand regularOperand : regular.getByOperands()) {
			rc.visit(regularOperand.getOperandCall().getCtx());
			rc.p(" = ");
			rc.visit(regularOperand.getOperandCall().getCtx());
			rc.p(".multiply(");
			rc.visit(multiplyStatement.getOperandValueStmt().getCtx());
			rc.p(");");
			rc.pNl(regular);
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant