Definition at line 249 of file ControlFlow.py.
◆ __init__()
def ControlFlow.DotVisitor.__init__ |
( |
|
self | ) |
|
◆ collapse_identical_ancestors()
def ControlFlow.DotVisitor.collapse_identical_ancestors |
( |
|
self, |
|
|
|
thetype |
|
) |
| |
If AND nodes are inside AND nodes, the graph could be simplified
to not contain those (same true for OR and ordered)
Definition at line 292 of file ControlFlow.py.
292 def collapse_identical_ancestors(self, thetype):
294 If AND nodes are inside AND nodes, the graph could be simplified
295 to not contain those (same true for OR and ordered)
297 if len(self.stack) != 0:
298 mother = self.stack[-1][1]
299 for entry
in self.stack[::-1]:
300 if not isinstance(entry[0], thetype):
◆ enter()
def ControlFlow.DotVisitor.enter |
( |
|
self, |
|
|
|
visitee |
|
) |
| |
Definition at line 257 of file ControlFlow.py.
257 def enter(self, visitee):
258 if visitee
not in self.ids:
260 dot_id = self.ids[visitee] =
"T%s" % self.number
261 dot_id = self.ids[visitee]
263 if self.is_needed(visitee):
264 if isinstance(visitee, ControlFlowLeaf):
265 entry =
'%s [label="%s", shape=box]' % (dot_id, visitee.name())
266 elif isinstance(visitee, OrNode):
267 entry =
'%s [label="OR", shape=invhouse]' % dot_id
268 elif isinstance(visitee, AndNode):
269 entry =
'%s [label="AND", shape=invhouse]' % dot_id
270 elif isinstance(visitee, OrderedNode):
271 entry =
'%s [label=">>", shape=point]' % dot_id
272 elif isinstance(visitee, InvertNode):
273 entry =
'%s [label="NOT", shape=circle, color=red]' % dot_id
274 elif isinstance(visitee, par):
275 entry =
'%s [label="PAR", shape=circle]' % dot_id
276 elif isinstance(visitee, seq):
277 entry =
'%s [label="SEQ", shape=circle]' % dot_id
279 entry =
'%s [label="%s", shape=circle]' % (dot_id,
type(visitee))
280 self.nodes.append(entry)
281 if len(self.stack) != 0:
282 mother = self.collapse_identical_ancestors(
type(self.stack[-1][0]))
284 mother = self.stack[-1][1]
285 edge =
"%s->%s" % (dot_id, mother)
286 self.edges.append(edge)
287 self.stack.append((visitee, dot_id))
◆ is_needed()
def ControlFlow.DotVisitor.is_needed |
( |
|
self, |
|
|
|
visitee |
|
) |
| |
Check whether this node is actually needed
Definition at line 306 of file ControlFlow.py.
306 def is_needed(self, visitee):
308 Check whether this node is actually needed
310 if len(self.stack) != 0:
311 return not isinstance(visitee,
type(self.stack[-1][0]))
◆ leave()
def ControlFlow.DotVisitor.leave |
( |
|
self, |
|
|
|
visitee |
|
) |
| |
◆ write()
def ControlFlow.DotVisitor.write |
( |
|
self, |
|
|
|
filename |
|
) |
| |
Definition at line 314 of file ControlFlow.py.
314 def write(self, filename):
325 "\n".join(self.nodes),
326 "\n".join(self.edges),
329 with open(filename,
"w")
as outfile:
330 outfile.write(output)
◆ edges
ControlFlow.DotVisitor.edges |
◆ ids
ControlFlow.DotVisitor.ids |
◆ nodes
ControlFlow.DotVisitor.nodes |
◆ number
ControlFlow.DotVisitor.number |
◆ stack
ControlFlow.DotVisitor.stack |
The documentation for this class was generated from the following file: