Skip to content

Commit 3b6a17f

Browse files
authored
Improve ETS model (#313)
1 parent 6ec737c commit 3b6a17f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1503
-1880
lines changed

jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/CommonInst.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,19 @@ import org.jacodb.api.common.CommonMethod
2121
interface CommonInst {
2222
val location: CommonInstLocation
2323

24-
// TODO: replace with extension property
2524
val method: CommonMethod
2625
get() = location.method
2726
}
2827

2928
interface CommonInstLocation {
3029
val method: CommonMethod
31-
// val index: Int
32-
// val lineNumber: Int
3330
}
3431

3532
interface CommonAssignInst : CommonInst {
3633
val lhv: CommonValue
3734
val rhv: CommonExpr
3835
}
3936

40-
// TODO: add 'callExpr: CoreExpr' property
4137
interface CommonCallInst : CommonInst
4238

4339
interface CommonReturnInst : CommonInst {

jacodb-api-common/src/main/kotlin/org/jacodb/api/common/cfg/CommonValue.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ interface CommonThis : CommonValue
2323
interface CommonArgument : CommonValue
2424

2525
interface CommonFieldRef : CommonValue {
26-
val instance: CommonValue? // null for static fields
27-
// val classField: CommonField
26+
val instance: CommonValue?
2827
}
2928

3029
interface CommonArrayAccess : CommonValue {

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/JcBlockGraphImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class JcBlockGraphImpl(
109109
(block.start.index..block.end.index).map { jcGraph.instructions[it] }
110110

111111
override fun block(inst: JcInst): JcBasicBlock {
112-
assert(inst.location.method == jcGraph.method) {
113-
"required method of instruction ${jcGraph.method} but got ${inst.location.method}"
112+
assert(inst.method == jcGraph.method) {
113+
"required method of instruction ${jcGraph.method} but got ${inst.method}"
114114
}
115115
for (basicBlock in entries) {
116116
if (basicBlock.contains(inst)) {

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/graphs/GraphDominators.kt

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,8 @@
1717
package org.jacodb.impl.cfg.graphs
1818

1919
import org.jacodb.api.common.cfg.BytecodeGraph
20-
import org.jacodb.api.jvm.cfg.JcBasicBlock
21-
import org.jacodb.api.jvm.cfg.JcBlockGraph
2220
import org.jacodb.api.jvm.cfg.JcCatchInst
23-
import org.jacodb.api.jvm.cfg.JcGraph
24-
import org.jacodb.api.jvm.cfg.JcInst
25-
import java.util.*
26-
21+
import java.util.BitSet
2722

2823
/**
2924
* Calculate dominators for basic blocks.
@@ -159,14 +154,6 @@ open class GraphDominators<NODE>(val graph: BytecodeGraph<NODE>) {
159154
}
160155
}
161156

162-
fun JcGraph.findDominators(): GraphDominators<JcInst> {
163-
return GraphDominators(this).also {
164-
it.find()
165-
}
166-
}
167-
168-
fun JcBlockGraph.findDominators(): GraphDominators<JcBasicBlock> {
169-
return GraphDominators(this).also {
170-
it.find()
171-
}
157+
fun <NODE> BytecodeGraph<NODE>.findDominators(): GraphDominators<NODE> {
158+
return GraphDominators(this).also { it.find() }
172159
}

jacodb-ets/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ plugins {
77

88
dependencies {
99
api(project(":jacodb-api-common"))
10-
api(project(":jacodb-core"))
1110

1211
implementation(Libs.kotlin_logging)
1312
implementation(Libs.slf4j_simple)
1413
implementation(Libs.kotlinx_serialization_json)
14+
implementation(Libs.kotlinx_coroutines_core)
1515
implementation(Libs.jdot)
1616

1717
testImplementation(kotlin("test"))

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/Position.kt

Lines changed: 0 additions & 83 deletions
This file was deleted.

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/StmtPositionInfo.kt

Lines changed: 0 additions & 64 deletions
This file was deleted.

jacodb-ets/src/main/kotlin/org/jacodb/ets/dsl/BlockCfg.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data class Block(
2626

2727
data class BlockCfg(
2828
val blocks: List<Block>,
29-
val successors: Map<Int, List<Int>>,
29+
val successors: Map<Int, List<Int>>, // for IF stmt, successors are (true, false) branches
3030
)
3131

3232
fun Program.toBlockCfg(): BlockCfg {

0 commit comments

Comments
 (0)