Skip to content

Commit

Permalink
Merge pull request #556 from smeup/bugfix/LS24003177/comptime-definestmt
Browse files Browse the repository at this point in the history
Bugfix/ls24003177/comptime definestmt
  • Loading branch information
lanarimarco authored Jul 4, 2024
2 parents 9352055 + 27c7f66 commit 695b2b5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,18 @@ open class BaseCompileTimeInterpreter(
}

private fun Cspec_fixedContext.findType(declName: String, conf: ToAstConfiguration): Type? {
val ast = this.toAst(conf)
if (ast is StatementThatCanDefineData) {
val dataDefinition = ast.dataDefinition()
dataDefinition.forEach {
if (it.name == declName) {
return it.type
}
return when (val ast = this.toAst(conf)) {
is DefineStmt -> {
if (declName != ast.newVarName) return null
val type = findType(rContext().statement(), ast.originalName, conf)
type
}
is StatementThatCanDefineData -> {
val dataDefinition = ast.dataDefinition()
dataDefinition.firstOrNull { it.name == declName }?.type
}
else -> null
}
return null
}

private fun Parm_fixedContext.findType(conf: ToAstConfiguration): Type? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,14 @@ open class MULANGT02ConstAndDSpecTest : MULANGTTest() {
val expected = listOf("ok")
assertEquals(expected, "smeup/MUDRNRAPU00221".outputOf(configuration = smeupConfig))
}

/**
* Comptime DEFINE support
* @see #LS24003177
*/
@Test
fun executeMUDRNRAPU00222() {
val expected = listOf("ok")
assertEquals(expected, "smeup/MUDRNRAPU00222".outputOf(configuration = smeupConfig))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
D £DBG_Str S 2

D CSDS DS
D $OAVT1 LIKE(§OAVT1)

C *LIKE DEFINE £OAVT1 §OAVT1

C *ENTRY PLIST
C PARM £OAVT1 2

C EVAL £DBG_Str='ok'
C £DBG_Str DSPLY

0 comments on commit 695b2b5

Please sign in to comment.