From 5099ce6c120e6ff272e5e471f9caf9da30a5496e Mon Sep 17 00:00:00 2001 From: Konstantin Chukharev Date: Thu, 24 Jul 2025 16:02:22 +0300 Subject: [PATCH] Remove misleading CommonInst::method, remove unused common InstList --- .../org/jacodb/api/common/cfg/CommonInst.kt | 3 -- .../org/jacodb/api/common/cfg/InstList.kt | 38 ------------------- .../kotlin/org/jacodb/api/jvm/cfg/JcInst.kt | 2 - .../org/jacodb/impl/cfg/JcBlockGraphImpl.kt | 4 +- .../main/kotlin/org/jacodb/ets/model/Stmt.kt | 3 -- .../org/jacodb/ets/utils/BlockCfgToDot.kt | 2 +- 6 files changed, 3 insertions(+), 49 deletions(-) delete mode 100644 jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/InstList.kt diff --git a/jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/CommonInst.kt b/jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/CommonInst.kt index 5237519f1..458684399 100644 --- a/jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/CommonInst.kt +++ b/jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/CommonInst.kt @@ -20,9 +20,6 @@ import org.jacodb.api.common.CommonMethod interface CommonInst { val location: CommonInstLocation - - val method: CommonMethod - get() = location.method } interface CommonInstLocation { diff --git a/jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/InstList.kt b/jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/InstList.kt deleted file mode 100644 index bd2943f4f..000000000 --- a/jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/InstList.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 UnitTestBot contributors (utbot.org) - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jacodb.api.common.cfg - -interface InstList : Iterable { - val instructions: List - val size: Int - val indices: IntRange - val lastIndex: Int - - operator fun get(index: Int): INST - fun getOrNull(index: Int): INST? - - fun toMutableList(): MutableInstList -} - -interface MutableInstList : InstList { - fun insertBefore(inst: INST, vararg newInstructions: INST) - fun insertBefore(inst: INST, newInstructions: Collection) - fun insertAfter(inst: INST, vararg newInstructions: INST) - fun insertAfter(inst: INST, newInstructions: Collection) - fun remove(inst: INST): Boolean - fun removeAll(inst: Collection): Boolean -} diff --git a/jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/cfg/JcInst.kt b/jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/cfg/JcInst.kt index 4c813b3b7..dcafcf86b 100644 --- a/jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/cfg/JcInst.kt +++ b/jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/cfg/JcInst.kt @@ -55,8 +55,6 @@ interface JcInst : CommonInst { override val location: JcInstLocation val operands: List - override val method: JcMethod - get() = location.method val lineNumber: Int get() = location.lineNumber diff --git a/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/JcBlockGraphImpl.kt b/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/JcBlockGraphImpl.kt index ddc8b17e1..cd69d769c 100644 --- a/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/JcBlockGraphImpl.kt +++ b/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/JcBlockGraphImpl.kt @@ -109,8 +109,8 @@ class JcBlockGraphImpl( (block.start.index..block.end.index).map { jcGraph.instructions[it] } override fun block(inst: JcInst): JcBasicBlock { - assert(inst.method == jcGraph.method) { - "required method of instruction ${jcGraph.method} but got ${inst.method}" + assert(inst.location.method == jcGraph.method) { + "required method of instruction ${jcGraph.method} but got ${inst.location.method}" } for (basicBlock in entries) { if (basicBlock.contains(inst)) { diff --git a/jacodb-ets/src/main/kotlin/org/jacodb/ets/model/Stmt.kt b/jacodb-ets/src/main/kotlin/org/jacodb/ets/model/Stmt.kt index 834ac3eb6..4875db2e4 100644 --- a/jacodb-ets/src/main/kotlin/org/jacodb/ets/model/Stmt.kt +++ b/jacodb-ets/src/main/kotlin/org/jacodb/ets/model/Stmt.kt @@ -25,9 +25,6 @@ import org.jacodb.api.common.cfg.CommonReturnInst interface EtsStmt : CommonInst { override val location: EtsStmtLocation - override val method: EtsMethod - get() = location.method - interface Visitor { fun visit(stmt: EtsNopStmt): R fun visit(stmt: EtsAssignStmt): R diff --git a/jacodb-ets/src/main/kotlin/org/jacodb/ets/utils/BlockCfgToDot.kt b/jacodb-ets/src/main/kotlin/org/jacodb/ets/utils/BlockCfgToDot.kt index 6f75b4b52..af05679f8 100644 --- a/jacodb-ets/src/main/kotlin/org/jacodb/ets/utils/BlockCfgToDot.kt +++ b/jacodb-ets/src/main/kotlin/org/jacodb/ets/utils/BlockCfgToDot.kt @@ -154,7 +154,7 @@ fun InterproceduralCfg.toHighlightedDotWithCalls( val h = sanitize(stmt.hashCode()) val clusterName = "cluster_${h}_B${parentBlock}" // method signature label - val methodSig = cfg.entries.first().method.signature + val methodSig = cfg.entries.first().location.method.signature // open subgraph lines += " subgraph \"$clusterName\" {" lines += " label=\"$methodSig\";"