ropes_debug :: ropes_debug $ FlatString
Immutable strings of characters.ropes_debug :: ropes_debug $ Text
High-level abstraction for all text representationsropes_debug :: ropes_debug $ FlatString
Immutable strings of characters.ropes_debug :: ropes_debug $ Text
High-level abstraction for all text representationscore :: union_find
union–find algorithm using an efficient disjoint-set data structure
# Exposes methods for debugging ropes when needed.
module ropes_debug
import core
intrude import core::text::ropes
redef class Text
# Writes self as a dot file on the hard drive
private fun internal_to_dot: String is abstract
# Returns the graphviz-formatted content of `self`
fun to_dot: String do
return "digraph g \{\n" + internal_to_dot + "\}\n"
end
end
redef class Concat
redef fun internal_to_dot
do
var s = "n{object_id} [label = {length}];\n"
s += "n{object_id} -> n{left.object_id} [label = \"left\"];\n"
s += left.internal_to_dot
s += "n{object_id} -> n{right.object_id} [label = \"right\"];\n"
s += right.internal_to_dot
return s
end
end
redef class FlatString
redef fun internal_to_dot
do
return "n{object_id} [label=\"FlatString\\nlength = {length}\\nbyte_length = {byte_length}\\nfirst_byte = {first_byte}\\nlast_byte = {last_byte}\\nText = {self.escape_to_dot}\"];\n"
end
end
redef class FlatBuffer
redef fun internal_to_dot
do
return "n{object_id} [label=\"FlatBuffer\\nbyte_length = {byte_length}\\nlength = {length}\\ncapacity = {capacity}\\nText = {escape_to_dot}\"];\n"
end
end
lib/ropes_debug/ropes_debug.nit:14,1--54,3