Skip to content

Transformer for MULTIPLY works the wrong way round #5

@rs-idesis

Description

@rs-idesis

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);
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions