Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/indirect-calls-nondet' into indi…
Browse files Browse the repository at this point in the history
…rect-calls-nondet

# Conflicts:
#	src/main/scala/util/RunUtils.scala
  • Loading branch information
l-kent committed Nov 2, 2023
2 parents 2a5fd77 + 0f15ae5 commit 9be3c66
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/main/scala/cfg_visualiser/DotTools.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ object IDGenerator {
}
}

def wrap(input: String, width: Integer = 20): String =
if (input.length() <= width) {
input
} else {
var splitPoint = width;
while (input.charAt(splitPoint).isLetterOrDigit && splitPoint > width / 2) {
// search backwards for a non alphanumeric charcter to split on
splitPoint -= 1
}
if (input.charAt(splitPoint).isLetterOrDigit) {
// didn't find a character to split on
splitPoint = width;
}
val line = input.substring(0, splitPoint)
line + "\\l" + wrap(input.substring(splitPoint), width)
}


/** Super-class for elements of a Graphviz dot file.
*/
abstract class DotElement {
Expand All @@ -33,7 +51,7 @@ class DotNode(val id: String, val label: String) extends DotElement {
override def toString: String = toDotString

def toDotString: String =
s"\"$id\"" + "[label=\"" + label + "\"]"
s"\"$id\"" + "[label=\"" + wrap(label, 80) + "\"]"

}

Expand Down Expand Up @@ -116,6 +134,5 @@ class DotGraph(val title: String, val nodes: Iterable[DotNode], val edges: Itera

override def toString: String = toDotString

def toDotString: String =
"digraph " + title + "{" + (nodes ++ edges).foldLeft("")((str, elm) => str + elm.toDotString + "\n") + "}"
def toDotString: String = "digraph " + title + " {\n" + (nodes ++ edges).foldLeft("")((str, elm) => str + elm.toDotString + "\n") + "}"
}

0 comments on commit 9be3c66

Please sign in to comment.