X-Git-Url: http://nitlanguage.org diff --git a/lib/ropes_debug.nit b/lib/ropes_debug.nit index b9ba5ab..da40da1 100644 --- a/lib/ropes_debug.nit +++ b/lib/ropes_debug.nit @@ -14,63 +14,53 @@ # Exposes methods for debugging ropes when needed. module ropes_debug -intrude import ::standard::ropes -import ::standard +import standard +intrude import standard::ropes -redef class Rope +redef class Text # Writes self as a dot file on the hard drive - fun to_dot(filepath: String): String is abstract -end + private fun internal_to_dot: String is abstract -redef class RopeNode - # Generates a dot string - fun to_dot(s: String): String is abstract + fun to_dot: String do + return "digraph g \{\n" + internal_to_dot + "\}\n" + end end -redef class Leaf - redef fun to_dot(s): String +redef class Concat + redef fun internal_to_dot: String do - s += "n{object_id} [label = \"{str}\" shape = rect];\n" - s += "n{str.object_id} -> n{object_id} [label = \"contains\"];\n" - s = str.to_dot(s) + 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 Concat - redef fun to_dot(s): String +redef class RopeBuffer + redef fun internal_to_dot: String do - s += "n{object_id} [label = {length}];\n" - if left != null then - s += "n{object_id} -> n{left.object_id} [label = \"left\"];\n" - s = left.to_dot(s) - end - if right != null then - s += "n{object_id} -> n{right.object_id} [label = \"right\"];\n" - s = right.to_dot(s) - end + var s = "n{object_id} [label = {length}];\n" + s += "n{object_id} -> n{str.object_id} [label = \"str\"];\n" + s += str.internal_to_dot + s += "n{object_id} -> n{ns.object_id} [label = \"ns\"];\n" + s += "n{ns.object_id}[label = \"NativeString\", content=\"{ns.to_s_with_length(rpos)}\"];\n" return s end end redef class FlatString - fun to_dot(s: String): String + redef fun internal_to_dot: String do - return s + "n{object_id} [label=\"FlatString\\nindex_from = {index_from}\\nindex_to = {index_to}\\nNativeString = {items.to_s_with_length(items.cstring_length)}\"];\n" + return "n{object_id} [label=\"FlatString\\nindex_from = {index_from}\\nindex_to = {index_to}\\nNativeString = {items.to_s_with_length(items.cstring_length)}\"];\n" end end -redef class RopeString - redef fun to_dot(filepath: String) +redef class FlatBuffer + redef fun internal_to_dot: String do - var of = new OFStream.open(filepath) - var ret: String = new RopeString.from("digraph g \{\n") - ret = root.to_dot(ret).as(RopeString) - ret += "\}\n" - ret.write_to(of) - of.close - return ret + return "n{object_id} [label=\"FlatBuffer\\length = {length}\\ncapacity = {capacity}\\nitems = {items.to_s_with_length(items.cstring_length)}\"];\n" end end -