Skip to content

Commit

Permalink
Merge from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
davidepalladino-apuliasoft committed Mar 5, 2024
2 parents 175510b + 745baf8 commit 95c9492
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,8 @@ private fun RpgParser.Parm_fixedContext.toFieldInfo(conf: ToAstConfiguration = T
return FieldInfo(this.name, overlayInfo = overlayInfo,
explicitStartOffset = this.explicitStartOffset(),
explicitEndOffset = if (explicitStartOffset() != null) this.explicitEndOffset() else null,
explicitElementType = this.calculateExplicitElementType(arraySizeDeclared, conf) ?: knownDataDefinitions.firstOrNull { it.name.equals(varName, ignoreCase = true) }?.type,
explicitElementType = this.calculateExplicitElementType(arraySizeDeclared, conf) ?: knownDataDefinitions.firstOrNull { it.name.equals(varName, ignoreCase = true) }?.type
?: knownDataDefinitions.flatMap { it.fields }.firstOrNull { fe -> fe.name.equals(varName, ignoreCase = true) }?.type,
arraySizeDeclared = this.arraySizeDeclared(conf),
arraySizeDeclaredOnThisField = this.arraySizeDeclared(conf),
initializationValue = initializationValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ internal fun RpgParser.WhenstatementContext.toAst(conf: ToAstConfiguration = ToA

internal fun RpgParser.CasestatementContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): CaseStmt {
val casClauses = this.csCASxx().map { it.toAst(conf) }
val otherClause = this.csCASother().toAst()
val otherClause = if (this.csCASother() != null) this.csCASother().toAst() else null
return CaseStmt(
cases = casClauses,
other = otherClause,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,18 @@ open class SmeupInterpreterTest : AbstractTest() {
assertEquals(expected, "smeup/T02_A60_P02".outputOf())
}

@Test
fun executeT12_A08_P01() {
val expected = listOf("123")
assertEquals(expected, "smeup/T12_A08_P01".outputOf())
}

@Test
fun executeT12_A08_P02() {
val expected = listOf("12")
assertEquals(expected, "smeup/T12_A08_P02".outputOf())
}

@Test
fun executeT10_A35_P07() {
val expected = listOf<String>("Src1=1 Src2=0")
Expand Down Expand Up @@ -479,6 +491,38 @@ open class SmeupInterpreterTest : AbstractTest() {
assertEquals(expected, "smeup/T02_A30_P03".outputOf())
}

@Test
fun executeT02_A40_P08() {
val expected = listOf(
"CNCLI AAAAAA 333"
)
assertEquals(expected, "smeup/T02_A40_P08".outputOf())
}

@Test
fun executeT02_A40_P09() {
val expected = listOf(
"CNCLI AAAAAA 333"
)
assertEquals(expected, "smeup/T02_A40_P09".outputOf())
}

@Test
fun executeT02_A50_P08() {
val expected = listOf(
"A50_A81(Funzione ) A50_N81(Funzione )A50_V81(Funzione)"
)
assertEquals(expected, "smeup/T02_A50_P08".outputOf())
}

@Test
fun executeT02_A50_P09() {
val expected = listOf(
"A50_A91(Funzione ) A50_N91(Funzione )A50_V91(Funzione)"
)
assertEquals(expected, "smeup/T02_A50_P09".outputOf())
}

@Test
fun executeT60_A10_P01() {
val expected = listOf<String>("KA(0)KB(0)KC(0)KD(0)KE(0)KF(0)KG(0)KH(0)KI(0)KJ(0)KK(0)KL(0)KM(0)KN(0)KP(0)KQ(0)KR(0)KS(0)KT(0)KU(0)KV(0)KW(0)KX(0)KY(0)")
Expand Down
20 changes: 20 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/smeup/T02_A40_P08.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
D A40_DS1 DS 30
D DS1_FL1 2
D DS1_FL2 10
D DS1_FL3 15
D DS1_FL4 3 0

D A40_DS8 DS
D DS8_FL1 LIKE(DS1_FL1)
D DS8_FL2 LIKE(DS1_FL2)
D DS8_FL3 LIKE(DS1_FL3)
D DS8_FL4 LIKE(DS1_FL4)
D £DBG_Str S 50 VARYING

D* DS definita con tutti campi in LIKE
C EVAL DS8_FL1 = 'CN'
C EVAL DS8_FL2 = 'CLI'
C EVAL DS8_FL3 = 'AAAAAA'
C EVAL DS8_FL4 = 333
C EVAL £DBG_Str=%TRIMR(A40_DS8)
C £DBG_Str DSPLY
20 changes: 20 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/smeup/T02_A40_P09.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
D A40_DS1 DS 30
D DS1_FL1 2
D DS1_FL2 10
D DS1_FL3 15
D DS1_FL4 3 0

D A40_DS9 DS
D DS9_FL1 LIKE(DS1_FL1)
D DS9_FL2 10
D DS9_FL3 LIKE(DS1_FL3)
D DS9_FL4 3 0
D £DBG_Str S 50 VARYING

D* DS definita con campi in LIKE e campi normali
C EVAL DS9_FL1 = 'CN'
C EVAL DS9_FL2 = 'CLI'
C EVAL DS9_FL3 = 'AAAAAA'
C EVAL DS9_FL4 = 333
C EVAL £DBG_Str=%TRIMR(A40_DS9)
C £DBG_Str DSPLY
18 changes: 18 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/smeup/T02_A50_P08.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
D £DBG_I_Fun S 10 Funzione chiamata
D £DBG_I_Num S 7 0 Numero esecuzioni
D £DBG_O_Str S 2560 VARYING Risultato

D A50_A81 S LIKE(£DBG_I_Fun)
D A50_N81 S LIKE(£DBG_I_Num)
D A50_V81 S LIKE(£DBG_O_Str)

D £DBG_Str S 150 VARYING

D* DS con overlay e campi definiti singolarmente
C EVAL A50_A81='Funzione'
C EVAL A50_N81=1234567
C EVAL A50_V81='Funzione'
C EVAL £DBG_Str= 'A50_A81('+A50_A81+')'
C +' A50_N81('+%CHAR(A50_A81)+')'
C + 'A50_V81('+A50_V81+')'
C £DBG_Str DSPLY
22 changes: 22 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/smeup/T02_A50_P09.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
D £DBG_I_Fun S 10 Funzione chiamata
D £DBG_I_Num S 7 0 Numero esecuzioni
D £DBG_O_Str S 2560 VARYING Risultato

D A50_A81 S LIKE(£DBG_I_Fun)
D A50_N81 S LIKE(£DBG_I_Num)
D A50_V81 S LIKE(£DBG_O_Str)

D A50_A91 S LIKE(A50_A81)
D A50_N91 S LIKE(A50_N81)
D A50_V91 S LIKE(A50_V81)

D £DBG_Str S 150 VARYING

D* DS con overlay e campi definiti singolarmente
C EVAL A50_A91='Funzione'
C EVAL A50_N91=1234567
C EVAL A50_V91='Funzione'
C EVAL £DBG_Str= 'A50_A91('+A50_A91+')'
C +' A50_N91('+%CHAR(A50_A91)+')'
C + 'A50_V91('+A50_V91+')'
C £DBG_Str DSPLY
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
D £DBG_Str S 1
D £DBG_Str S 3
*
C MOVEL '1' CHOISE 1
C EXSR SEZ_T12_A08
Expand All @@ -9,6 +9,8 @@
C MOVEL ' ' CHOISE
C EXSR SEZ_T12_A08
*
C £DBG_Str DSPLY
*
C SETON LR
*---------------------------------------------------------------
C SEZ_T12_A08 BEGSR
Expand All @@ -19,21 +21,19 @@
C CAS CHOISER3
C ENDCS
*
C £DBG_Str DSPLY
*
C ENDSR
*---------------------------------------------------------------
C CHOISER1 BEGSR
*--------------------------------------------------------------*
c EVAL £DBG_Str='1'
C EVAL £DBG_Str=%TRIM(£DBG_Str)+'1'
C ENDSR
*---------------------------------------------------------------
C CHOISER2 BEGSR
*--------------------------------------------------------------*
c EVAL £DBG_Str='2'
C EVAL £DBG_Str=%TRIM(£DBG_Str)+'2'
C ENDSR
*---------------------------------------------------------------
C CHOISER3 BEGSR
*--------------------------------------------------------------*
C EVAL £DBG_Str='3'
C EVAL £DBG_Str=%TRIM(£DBG_Str)+'3'
C ENDSR
33 changes: 33 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/smeup/T12_A08_P02.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
D £DBG_Str S 3
*
C MOVEL '1' CHOISE 1
C EXSR SEZ_T12_A08
*
C MOVEL '2' CHOISE
C EXSR SEZ_T12_A08
*
C MOVEL ' ' CHOISE
C EXSR SEZ_T12_A08
*
C £DBG_Str DSPLY
*
C SETON LR
*---------------------------------------------------------------
C SEZ_T12_A08 BEGSR
*---------------------------------------------------------------
*
C CHOISE CASEQ '1' CHOISER1
C CHOISE CASEQ '2' CHOISER2
C ENDCS
*
C ENDSR
*---------------------------------------------------------------
C CHOISER1 BEGSR
*--------------------------------------------------------------*
C EVAL £DBG_Str=%TRIM(£DBG_Str)+'1'
C ENDSR
*---------------------------------------------------------------
C CHOISER2 BEGSR
*--------------------------------------------------------------*
C EVAL £DBG_Str=%TRIM(£DBG_Str)+'2'
C ENDSR

0 comments on commit 95c9492

Please sign in to comment.