diff --git a/jacodb-ets/src/main/kotlin/org/jacodb/ets/dto/Convert.kt b/jacodb-ets/src/main/kotlin/org/jacodb/ets/dto/Convert.kt index e4b701aef..c664c6110 100644 --- a/jacodb-ets/src/main/kotlin/org/jacodb/ets/dto/Convert.kt +++ b/jacodb-ets/src/main/kotlin/org/jacodb/ets/dto/Convert.kt @@ -180,48 +180,72 @@ class EtsMethodBuilder( } } - is NopStmtDto -> EtsNopStmt(location = loc()) + is NopStmtDto -> { + EtsNopStmt(location = loc()) + } - is AssignStmtDto -> EtsAssignStmt( - location = loc(), - lhv = convertToEtsEntity(stmt.left) as EtsValue, - rhv = ensureOneAddress(convertToEtsEntity(stmt.right)), - ) + is AssignStmtDto -> { + val lhv = convertToEtsEntity(stmt.left) as EtsValue + val rhv = ensureOneAddress(convertToEtsEntity(stmt.right)) + EtsAssignStmt( + location = loc(), + lhv = lhv, + rhv = rhv, + ) + } - is CallStmtDto -> EtsCallStmt( - location = loc(), - expr = convertToEtsEntity(stmt.expr) as EtsCallExpr, - ) + is CallStmtDto -> { + val expr = convertToEtsEntity(stmt.expr) as EtsCallExpr + EtsCallStmt( + location = loc(), + expr = expr, + ) + } is ReturnStmtDto -> { + val returnValue = ensureOneAddress(convertToEtsEntity(stmt.arg)) EtsReturnStmt( location = loc(), - returnValue = ensureOneAddress(convertToEtsEntity(stmt.arg)), + returnValue = returnValue, ) } - is ReturnVoidStmtDto -> EtsReturnStmt( - location = loc(), - returnValue = null, - ) + is ReturnVoidStmtDto -> { + EtsReturnStmt( + location = loc(), + returnValue = null, + ) + } - is ThrowStmtDto -> EtsThrowStmt( - location = loc(), - arg = convertToEtsEntity(stmt.arg), - ) + is ThrowStmtDto -> { + val arg = convertToEtsEntity(stmt.arg) + EtsThrowStmt( + location = loc(), + arg = arg, + ) + } - is GotoStmtDto -> EtsGotoStmt(location = loc()) + is GotoStmtDto -> { + EtsGotoStmt(location = loc()) + } - is IfStmtDto -> EtsIfStmt( - location = loc(), - condition = convertToEtsEntity(stmt.condition), - ) + is IfStmtDto -> { + val condition = convertToEtsEntity(stmt.condition) + EtsIfStmt( + location = loc(), + condition = condition, + ) + } - is SwitchStmtDto -> EtsSwitchStmt( - location = loc(), - arg = convertToEtsEntity(stmt.arg), - cases = stmt.cases.map { convertToEtsEntity(it) }, - ) + is SwitchStmtDto -> { + val arg = convertToEtsEntity(stmt.arg) + val cases = stmt.cases.map { convertToEtsEntity(it) } + EtsSwitchStmt( + location = loc(), + arg = arg, + cases = cases, + ) + } // else -> error("Unknown Stmt: $stmt") } diff --git a/jacodb-ets/src/test/kotlin/org/jacodb/ets/test/EtsFromJsonTest.kt b/jacodb-ets/src/test/kotlin/org/jacodb/ets/test/EtsFromJsonTest.kt index 9cf77e3e7..6978f51cc 100644 --- a/jacodb-ets/src/test/kotlin/org/jacodb/ets/test/EtsFromJsonTest.kt +++ b/jacodb-ets/src/test/kotlin/org/jacodb/ets/test/EtsFromJsonTest.kt @@ -34,6 +34,7 @@ import org.jacodb.ets.dto.LocalDto import org.jacodb.ets.dto.MethodDto import org.jacodb.ets.dto.ModifierDto import org.jacodb.ets.dto.NumberTypeDto +import org.jacodb.ets.dto.ReturnVoidStmtDto import org.jacodb.ets.dto.StmtDto import org.jacodb.ets.dto.convertToEtsFile import org.jacodb.ets.dto.convertToEtsMethod @@ -133,9 +134,7 @@ class EtsFromJsonTest { """.trimIndent() val stmtDto = Json.decodeFromString(jsonString) println("stmtDto = $stmtDto") - val ctx = EtsMethodBuilder(defaultSignature) - val stmt = ctx.convertToEtsStmt(stmtDto) - Assertions.assertEquals(EtsReturnStmt(EtsInstLocation(ctx.etsMethod, 0), null), stmt) + Assertions.assertEquals(ReturnVoidStmtDto, stmtDto) } @Test