1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
4 # Copyright 2006-2008 Floréal Morandat <morandat@lirmm.fr>
6 # This file is free software, which comes along with NIT. This software is
7 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
10 # is kept unaltered, and a notification of the changes is added.
11 # You are allowed to redistribute it and sell it, alone or is a part of
14 # Exposes methods for debugging ropes when needed.
17 intrude import ::standard
::ropes
21 # Writes self as a dot file on the hard drive
22 fun to_dot
(filepath
: String): String is abstract
26 # Generates a dot string
27 fun to_dot
(s
: String): String is abstract
31 redef fun to_dot
(s
): String
33 s
+= "n{object_id} [label = \"{str}\
" shape = rect];\n"
34 s
+= "n{str.object_id} -> n{object_id} [label = \"contains\
"];\n"
41 redef fun to_dot
(s
): String
43 s
+= "n{object_id} [label = {length}];\n"
45 s
+= "n{object_id} -> n{left.object_id} [label = \"left\
"];\n"
49 s
+= "n{object_id} -> n{right.object_id} [label = \"right\
"];\n"
57 fun to_dot
(s
: String): String is abstract
60 redef class FlatString
61 redef fun to_dot
(s
: String): String
63 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"
67 redef class FlatBuffer
68 redef fun to_dot
(s
: String): String
70 return s
+ "n{object_id} [label=\"FlatBuffer\\length
= {length}\\ncapacity
= {capacity}\\nitems
= {items.to_s_with_length(items.cstring_length)}\
"];\n"
74 redef class RopeString
75 redef fun to_dot
(filepath
: String)
77 var of
= new OFStream.open
(filepath
)
78 var ret
: String = new RopeString.from
("digraph g \{\n")
79 ret
= root
.to_dot
(ret
).as(RopeString)