diff --git a/rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4 b/rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4 index 764f54437..cacccaf10 100644 --- a/rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4 +++ b/rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4 @@ -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] ')' ); @@ -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); diff --git a/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 b/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 index 8d7c243e7..601d94e5a 100644 --- a/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 +++ b/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 @@ -2581,6 +2581,7 @@ SPLAT_ALL | SPLAT_HIVAL | SPLAT_INIT | SPLAT_INDICATOR + | SPLAT_ALL_INDICATORS | SPLAT_INZSR | SPLAT_IN | SPLAT_JOBRUN diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt index 57d876596..977bea098 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt @@ -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()) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt index 652239edf..c2285745a 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt @@ -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) } diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt index dcd4189c7..a489f75ed 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt @@ -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) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt index f70d2ec78..d1a6143df 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt @@ -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()) + } } diff --git a/rpgJavaInterpreter-core/src/test/resources/MOVEAIN.rpgle b/rpgJavaInterpreter-core/src/test/resources/MOVEAIN.rpgle new file mode 100644 index 000000000..12fcd9bf6 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/MOVEAIN.rpgle @@ -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 \ No newline at end of file