Skip to content

Commit

Permalink
Fixed Z-ADD for T10_A20_P19.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidepalladino-apuliasoft committed Jan 31, 2024
1 parent 9ed7884 commit 7c69b5e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,11 @@ internal fun CsMOVELContext.toAst(conf: ToAstConfiguration = ToAstConfiguration(

internal fun CsZ_ADDContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): ZAddStmt {
val position = toPosition(conf.considerPosition)
val expression = this.cspec_fixed_standard_parts().factor2Expression(conf) ?: throw UnsupportedOperationException("Z-ADD operation requires factor 2: ${this.text} - ${position.atLine()}")
val name = this.cspec_fixed_standard_parts().result.text
val expression = this.cspec_fixed_standard_parts().factor2Expression(conf) ?: throw UnsupportedOperationException("Z-ADD operation requires factor 2: ${this.text} - ${position.atLine()}")
val resultExpression = annidatedReferenceExpression(name, position)
val dataDefinition = this.cspec_fixed_standard_parts().toDataDefinition(name, position, conf)
return ZAddStmt(DataRefExpr(ReferenceByName(name), position), dataDefinition, expression, position)
return ZAddStmt(resultExpression, dataDefinition, expression, position)
}

internal fun CsMULTContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): MultStmt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,8 @@ open class SmeupInterpreterTest : AbstractTest() {
fun executeT10_A20_P19() {
val expected = listOf("1020")
assertEquals(expected, "smeup/T10_A20_P19".outputOf())
assertFailsWith<Exception> {
"smeup/T10_A20_P19F".outputOf()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
D £DBG_Str S 50 VARYING
D A20_AR1 S 2 0 DIM(2)
***************************************************************************
C Z-ADD 10 A20_AR1(1
C Z-ADD 20 A20_AR12)
C EVAL £DBG_Str=%CHAR(A20_AR1(1))
C +%CHAR(A20_AR1(2))
* EXPECTED: 1020
C £DBG_Str DSPLY
C SETON LR

0 comments on commit 7c69b5e

Please sign in to comment.