Skip to content

Commit b70957d

Browse files
authored
Fix EtsCfgToDot (#307)
1 parent 8339b14 commit b70957d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.jacodb.ets.graph.EtsCfg
2626
private fun EtsStmt.toDotLabel(): String = when (this) {
2727
is EtsNopStmt -> "nop"
2828
is EtsAssignStmt -> "$lhv := $rhv"
29-
is EtsReturnStmt -> "return $returnValue"
29+
is EtsReturnStmt -> returnValue?.let { "return $it" } ?: "return"
3030
is EtsIfStmt -> "if ($condition)"
3131
else -> this.toString() // TODO: support more statement types
3232
}
@@ -38,8 +38,9 @@ fun EtsCfg.toDot(): String {
3838

3939
// Nodes
4040
stmts.forEach { stmt ->
41-
val id= stmt.location.index
42-
lines += " $id [label=\"$id: ${stmt.toDotLabel()}\"]"
41+
val id = stmt.location.index
42+
val label = stmt.toDotLabel().replace("\"", "\\\"")
43+
lines += " $id [label=\"$id: $label\"]"
4344
}
4445

4546
// Edges

0 commit comments

Comments
 (0)