Skip to content

Commit c12d7e5

Browse files
authored
Minor fixes (#342)
1 parent 3b490e3 commit c12d7e5

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package org.jacodb.ets.dsl
1919
import java.util.IdentityHashMap
2020

2121
private fun Node.toDotLabel() = when (this) {
22+
is Nop -> "nop"
2223
is Assign -> "$target := $expr"
2324
is Return -> "return $expr"
2425
is If -> "if ($condition)"
25-
is Nop -> "nop"
2626
is Label -> "label $name"
2727
is Goto -> "goto $targetLabel"
2828
}
@@ -90,6 +90,7 @@ fun Program.toDot(): String {
9090
lines += " $curId -> $nextId"
9191
}
9292
}
93+
9394
processForEdges(nodes)
9495

9596
lines += "}"
@@ -111,7 +112,7 @@ fun BlockCfg.toDot(): String {
111112
// Nodes
112113
for (block in blocks) {
113114
val s = block.statements.joinToString("") { it.toDotLabel() + "\\l" }
114-
lines += " ${block.id} [label=\"Block #${block.id}\\n${s}\"]"
115+
lines += " ${block.id} [label=\"[#${block.id}]\\l${s}\"]"
115116
}
116117

117118
// Edges

jacodb-ets/src/main/kotlin/org/jacodb/ets/model/Expr.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ data class EtsInstanceCallExpr(
736736
override val type: EtsType,
737737
) : EtsCallExpr, CommonInstanceCallExpr {
738738
override fun toString(): String {
739-
return "virtual ${instance}.${callee.name}(${args.joinToString()})"
739+
return "call ${instance}.${callee.name}(${args.joinToString()})"
740740
}
741741

742742
override fun <R> accept(visitor: EtsExpr.Visitor<R>): R {
@@ -750,7 +750,7 @@ data class EtsStaticCallExpr(
750750
override val type: EtsType,
751751
) : EtsCallExpr {
752752
override fun toString(): String {
753-
return "static ${callee.enclosingClass.name}.${callee.name}(${args.joinToString()})"
753+
return "static_call ${callee.enclosingClass.name}.${callee.name}(${args.joinToString()})"
754754
}
755755

756756
override fun <R> accept(visitor: EtsExpr.Visitor<R>): R {
@@ -765,7 +765,7 @@ data class EtsPtrCallExpr(
765765
override val type: EtsType,
766766
) : EtsCallExpr {
767767
override fun toString(): String {
768-
return "ptr ${ptr}(${args.joinToString()})"
768+
return "ptr_call ${ptr}(${args.joinToString()})"
769769
}
770770

771771
override fun <R> accept(visitor: EtsExpr.Visitor<R>): R {

jacodb-ets/src/main/kotlin/org/jacodb/ets/model/Scene.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.jacodb.api.common.CommonProject
2121
class EtsScene(
2222
val projectFiles: List<EtsFile>,
2323
val sdkFiles: List<EtsFile> = emptyList(),
24+
val projectName: String? = null,
2425
) : CommonProject {
2526
init {
2627
projectFiles.forEach { it.scene = this }

jacodb-ets/src/main/kotlin/org/jacodb/ets/model/Signatures.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,31 @@ data class EtsClassSignature(
7979
}
8080
}
8181

82+
private val cachedHashCode: Int = run {
83+
var result = name.hashCode()
84+
result = 31 * result + file.hashCode()
85+
result = 31 * result + (namespace?.hashCode() ?: 0)
86+
result
87+
}
88+
89+
override fun hashCode(): Int {
90+
return cachedHashCode
91+
}
92+
93+
override fun equals(other: Any?): Boolean {
94+
if (this === other) return true
95+
if (javaClass != other?.javaClass) return false
96+
97+
other as EtsClassSignature
98+
99+
if (cachedHashCode != other.cachedHashCode) return false
100+
if (name != other.name) return false
101+
if (file != other.file) return false
102+
if (namespace != other.namespace) return false
103+
104+
return true
105+
}
106+
82107
companion object {
83108
val UNKNOWN = EtsClassSignature(
84109
name = UNKNOWN_CLASS_NAME,

jacodb-ets/src/main/kotlin/org/jacodb/ets/model/Stmt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ interface EtsTerminatingStmt : EtsStmt
9898

9999
data class EtsReturnStmt(
100100
override val location: EtsStmtLocation,
101-
override val returnValue: EtsValue?,
101+
override val returnValue: EtsValue?, // TODO: make returnValue EtsLocal
102102
) : EtsTerminatingStmt, CommonReturnInst {
103103
override fun toString(): String {
104104
return if (returnValue != null) {

jacodb-ets/src/main/kotlin/org/jacodb/ets/utils/BlockCfgToDot.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ private fun String.htmlEncode(): String = this
3030
.replace("&", "&amp;")
3131
.replace("<", "&lt;")
3232
.replace(">", "&gt;")
33+
.replace("\\\"", "&quot;")
3334
.replace("\"", "&quot;")
3435

3536
fun EtsBlockCfg.toDot(

0 commit comments

Comments
 (0)