From 5784c76b8090110ec6b448cd66259bf527190488 Mon Sep 17 00:00:00 2001 From: domenico Date: Tue, 13 Aug 2024 11:13:15 +0200 Subject: [PATCH 1/3] Add test case --- .../smeup/MULANGT02ConstAndDSpecTest.kt | 6 ++++ .../test/resources/smeup/MUDRNRAPU00246.rpgle | 34 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00246.rpgle diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt index 41bae0075..3abfc2cb0 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt @@ -538,4 +538,10 @@ open class MULANGT02ConstAndDSpecTest : MULANGTTest() { val expected = listOf("ok") assertEquals(expected, "smeup/MUDRNRAPU00243".outputOf(configuration = smeupConfig)) } + + @Test + fun executeMUDRNRAPU00246() { + val expected = listOf("ok") + assertEquals(expected, "smeup/MUDRNRAPU00246".outputOf(configuration = smeupConfig)) + } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00246.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00246.rpgle new file mode 100644 index 000000000..d4c7e8560 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00246.rpgle @@ -0,0 +1,34 @@ + D £DBG_Str S 2 + + ********** PREPROCESSOR COPYSTART QILEGEN,£UIBDS + V* ============================================================== + V* MODIFICHE Ril. T Au Descrizione + V* gg/mm/aa nn.mm i xx Breve descrizione + V* ============================================================== + V* 10/05/21 V5R1 BONMAI Creazione + V* 18/05/24 V6R1 FORDAR Estensione + V* /COPY £UIBDS + V* ============================================================== + *--------------------------------------------------------------------------------------------* + *IF NOT DEFINED(UIBDS_INCLUDED) + *DEFINE UIBDS_INCLUDED + D £UIBDS DS 10 + D £UIBME 0 + *--------------------------------------------------------------------------------------------* + ********** PREPROCESSOR COPYEND QILEGEN,£UIBDS + + DXUIBME S LIKE(£UIBME) + + *--------------------------------------------------------------* + RD* Impostazioni iniziali + *--------------------------------------------------------------* + C IMP0 BEGSR + C IF %SUBST(£UIBME:1:3)='STA' + C MOVEL(P) 'STA' XUIBME 10 + C ELSE + C MOVEL(P) £UIBME XUIBME 10 + C ENDIF + C ENDSR + + C EVAL £DBG_Str='ok' + C £DBG_Str DSPLY From e0c155a86083605808a726c2a449f6e5327756b4 Mon Sep 17 00:00:00 2001 From: domenico Date: Tue, 13 Aug 2024 11:13:23 +0200 Subject: [PATCH 2/3] Add type matching rule --- .../rpgparser/parsing/parsetreetoast/misc.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 da72ef6a2..4dcc0c64b 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 @@ -2224,6 +2224,7 @@ internal fun getProgramNameToCopyBlocks(): ProgramNameToCopyBlocks { } internal fun List.removeDuplicatedDataDefinition(): List { + // NOTE: With current logic when type matches on duplications the first definition wins val dataDefinitionMap = mutableMapOf() return removeUnnecessaryRecordFormat().filter { val dataDefinition = dataDefinitionMap[it.name] @@ -2241,14 +2242,18 @@ internal fun List.removeDuplicatedDataDefinition internal fun AbstractDataDefinition.matchType(dataDefinition: AbstractDataDefinition): Boolean { fun Type.matchType(other: Any?): Boolean { - if (this is NumberType && other is NumberType) { - val resultDigits = this.entireDigits == other.entireDigits && this.decimalDigits == other.decimalDigits - if (rpgType?.isNotBlank()!! && other.rpgType?.isNotEmpty()!!) { - return resultDigits && rpgType == other.rpgType + // TODO: Improve logic for StringType/UnlimitedStringType matching + return when { + this is NumberType && other is NumberType -> { + val resultDigits = this.entireDigits == other.entireDigits && this.decimalDigits == other.decimalDigits + if (rpgType?.isNotBlank()!! && other.rpgType?.isNotEmpty()!!) { + return resultDigits && rpgType == other.rpgType + } + resultDigits } - return resultDigits - } else { - return this == other + this is UnlimitedStringType && other is StringType -> true + this is StringType && other is UnlimitedStringType -> true + else -> this == other } } From d72c9e7ca86aaa3e1ae46c77944ae0c738ebdbf2 Mon Sep 17 00:00:00 2001 From: domenico Date: Tue, 13 Aug 2024 12:04:58 +0200 Subject: [PATCH 3/3] Remove StringType to UnlimitedStringType matching rule --- .../kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt | 1 - 1 file changed, 1 deletion(-) 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 4dcc0c64b..0d873841d 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 @@ -2252,7 +2252,6 @@ internal fun AbstractDataDefinition.matchType(dataDefinition: AbstractDataDefini resultDigits } this is UnlimitedStringType && other is StringType -> true - this is StringType && other is UnlimitedStringType -> true else -> this == other } }