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

Bugfix/nw23001440/movea with in #401

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ SPLAT_FILE: '*'[fF][iI][lL][eE];
SPLAT_GETIN: '*'[gG][eE][tT][iI][nN];
SPLAT_HIVAL: '*'[hH][iI][vV][aA][lL];
SPLAT_INIT: '*'[iI][nN][iI][tT];
SPLAT_ALL_INDICATORS: '*' [iI] [nN] [ ] [ ];
SPLAT_INDICATOR : ( '*' [iI] [nN] [0-9] [0-9]
| '*' [iI] [nN] [a-zA-Z] [a-zA-Z]
| '*' [iI] [nN] '(' [0-9] [0-9] ')' );
Expand Down Expand Up @@ -1032,6 +1033,7 @@ CS_Factor2_SPLAT_GETIN : SPLAT_GETIN {35+6<= getCharPositionInLine() && getCharP
CS_Factor2_SPLAT_HIVAL : SPLAT_HIVAL {35+6<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_HIVAL);
CS_Factor2_SPLAT_INIT : SPLAT_INIT {35+5<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_INIT);
CS_Factor2_SPLAT_INDICATOR : SPLAT_INDICATOR {35+4<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_INDICATOR);
CS_Factor2_SPLAT_ALL_INDICATORS : SPLAT_ALL_INDICATORS {35+4<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_ALL_INDICATORS);
CS_Factor2_SPLAT_INZSR : SPLAT_INZSR {35+6<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_INZSR);
CS_Factor2_SPLAT_IN : SPLAT_IN {35+3<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_IN);
CS_Factor2_SPLAT_JOBRUN : SPLAT_JOBRUN {35+7<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_JOBRUN);
Expand Down
1 change: 1 addition & 0 deletions rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -2581,6 +2581,7 @@ SPLAT_ALL
| SPLAT_HIVAL
| SPLAT_INIT
| SPLAT_INDICATOR
| SPLAT_ALL_INDICATORS
| SPLAT_INZSR
| SPLAT_IN
| SPLAT_JOBRUN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,13 @@ class ExpressionEvaluation(
override fun eval(expression: AssignmentExpr) =
throw RuntimeException("AssignmentExpr should be handled by the interpreter: $expression")

override fun eval(expression: GlobalIndicatorExpr) =
throw RuntimeException("PredefinedGlobalIndicatorExpr should be handled by the interpreter: $expression")
override fun eval(expression: GlobalIndicatorExpr): Value {
val value = StringBuilder()
for (i in IndicatorType.Predefined.range) {
value.append(if (interpreterStatus.indicators[i] == null) "0" else if (interpreterStatus.indicators[i]!!.value) "1" else "0")
}
return StringValue(value.toString())
}

override fun eval(expression: ParmsExpr): Value {
return IntValue(interpreterStatus.params.toLong())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ data class IndicatorExpr(val index: IndicatorKey, override val position: Positio
@Serializable
data class GlobalIndicatorExpr(override val position: Position? = null) :
AssignableExpression(position) {
override fun size(): Int {
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
override fun size(): Int = IndicatorType.Predefined.range.last
override fun evalWith(evaluator: Evaluator): Value = evaluator.eval(this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,11 @@ internal fun SymbolicConstantsContext.toAst(conf: ToAstConfiguration = ToAstConf
position = position
)
}
this.SPLAT_ALL_INDICATORS() != null -> {
GlobalIndicatorExpr(
position = position
)
}
this.SPLAT_ALL() != null -> {
val content: LiteralContext = this.parent.getChild(1) as LiteralContext
AllExpr(content.toAst(conf), position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2202,4 +2202,12 @@ Test 6
val expected = listOf("A1_OK", "A2_OK", "A3_OK", "N1_OK", "N2_OK", "N3_OK", "DS_OK", "DSA1_OK", "DSA2_OK")
assertEquals(expected, "RESET01".outputOf())
}

@Test
fun executeMOVEAIN() {
val expected = listOf(
"111000000000000000000000000000000000000000010000000000000000000000000000000000000000000100000000000",
"001000000000000000000000000000000000000000010000000000000000000000000000000000000000000100000000000")
assertEquals(expected, "MOVEAIN".outputOf())
}
}
19 changes: 19 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/MOVEAIN.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
D £DBG_Ind S 99
*
C MOVEL *ON *IN44
C MOVE *ON *IN03
C SETON 88
C SETON 0102
C MOVEA(P) *IN £DBG_Ind
* Expected:
* '111000000000000000000000000000000000000000010000000000000000000000000000000000000000000100000000000'
C £DBG_Ind DSPLY
*
C SETOFF 0102
C* MOVEL '1' *IN03
C MOVEA(P) *IN £DBG_Ind
* Expected:
* '000000000000000000000000000000000000000000010000000000000000000000000000000000000000000100000000000'
C £DBG_Ind DSPLY
*
C SETON LR
Loading