CFNode

class understand.CFNode

Bases: object

A node in a control flow graph

Node line and column numbers are 1-based.

Methods Summary

child_label

Return the label from this node to child.

children

Return the children of this node.

column_begin

Return the beginning column number of the node.

column_end

Return the ending column number of the node.

end_node

Return the end node if applicable

kind

Return the kind of the node.

line_begin

Return the beginning line number of the node

line_end

Return the ending line number of the node

Methods Documentation

child_label(child)

Return the label from this node to child.

Parameters:

child (understand.CFNode) – a child node

Return type:

str

Returns:

the label or None if none. Most nodes do not have labelled children.

Possible labels are:

  • “yes”: conditionals/loops

  • “no”: conditionals/loops

  • “<0”: arith-if

  • “=0”: arith-if

  • “>0”: arith-if

  • “default”: computed-goto, io-control

  • “end” : io-control

  • “eor” : io-control

  • “err” : io-control

  • “0”,”1”,etc: computed-goto

children([flags])

Return the children of this node.

Parameters:

flags (int) – optional, a combination of node flags

Return type:

list[understand.CFNode]

Returns:

a list of children

Flags control the type of children. The available flags are:

  • understand.CFNode_Normal

  • understand.CFNode_Deferred

If flags are not provided, normal children are returned.

column_begin()

Return the beginning column number of the node.

Return type:

int

Returns:

the beginning column number if available. Nodes without location information will return None

column_end()

Return the ending column number of the node.

Return type:

int

Returns:

the ending column number if available. Nodes without location information will return None

end_node()

Return the end node if applicable

Return type:

understand.CFNode

Returns:

the end node or None if there is none. Structures such as loops and conditionals have an end node.

kind()

Return the kind of the node.

Return type:

str

Returns:

the kind of the node

Possible kinds are:

accept-block-begin

end-do-while

loop

arith-if

end-if

loop-expr

assigned-goto

end-loop

next

block-begin

end-repeat-until

next-when

break

end-select

passive

call-alt-return

end-select

raise

case

end-switch

repeat-until

case-default

end-try

return

case-fallthru

end-where

select

case-when

end-with-do

select-case

computed-goto

exception-when

select-else

conditional-goto

exit

select-or

continue

exit-do

select-then-abort

continue-do

exit-do-if

start

continue-for

exit-for

stop

continue-while

exit-for-if

switch

cycle

exit-if

switch-case

do

exit-if-if

switch-default

do-infinite

exit-loop

terminate

do-until

exit-loop-if

throw

do-while

exit-select

try

else

exit-try

try-catch

else-where

exit-when

try-else

else-where-cond

exit-while

try-finally

elsif

exit-while-if

until

end

for

where

end-block

goto

while

end-case

if

while-for

end-do

io-control

while-for-else

end-do-until

jovial3-goto

with-do

line_begin()

Return the beginning line number of the node

Return type:

int

Returns:

the beginning line number if available. Nodes without location information will return None

line_end()

Return the ending line number of the node

Return type:

int

Returns:

the ending line number if available. Nodes without location information will return None