Documentation ¶
Overview ¶
Package cfa implements control flow analysis of control flow graphs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type If ¶
type If struct { // Condition node (A). Cond graph.Node // Body node (B). Body graph.Node // Exit node (C). Exit graph.Node }
If represents a 1-way conditional statement.
Pseudo-code:
if (A) { B } C
func FindIf ¶
FindIf returns the first occurrence of a 1-way conditional statement in g, and a boolean indicating if such a primitive was found.
func (If) IsValid ¶
IsValid reports whether the cond, body and exit node candidates of prim form a valid 1-way conditional statement in g.
Control flow graph:
cond ↓ ↘ ↓ body ↓ ↙ exit
type IfElse ¶
type IfElse struct { // Condition node (A). Cond graph.Node // Body node of the true branch (B). BodyTrue graph.Node // Body node of the false branch (C). BodyFalse graph.Node // Exit node (D). Exit graph.Node }
IfElse represents a 2-way conditional statement.
Pseudo-code:
if (A) { B } else { C } D
func FindIfElse ¶
FindIfElse returns the first occurrence of a 2-way conditional statement in g, and a boolean indicating if such a primitive was found.
func (IfElse) IsValid ¶
IsValid reports whether the cond, body_true, body_false and exit node candidates of prim form a valid 2-way conditional statement in g.
Control flow graph:
cond ↙ ↘ body_true body_false ↘ ↙ exit
type IfReturn ¶
type IfReturn struct { // Condition node (A). Cond graph.Node // Body node with return statement (B). Body graph.Node // Exit node (C). Exit graph.Node }
IfReturn represents a 1-way conditional with a body return statement.
Pseudo-code:
if (A) { B return } C
func FindIfReturn ¶
FindIfReturn returns the first occurrence of a 1-way conditional with a body return statement in g, and a boolean indicating if such a primitive was found.
func (IfReturn) IsValid ¶
IsValid reports whether the cond, body and exit node candidates of prim form a valid 1-way conditional with a body return statement in g.
Control flow graph:
cond ↓ ↘ ↓ body ↓ exit
type PostLoop ¶
PostLoop represents a post-test loop.
Pseudo-code:
do { } while (A) B
func FindPostLoop ¶
FindPostLoop returns the first occurrence of a post-test loop in g, and a boolean indicating if such a primitive was found.
func (PostLoop) IsValid ¶
IsValid reports whether the cond and exit node candidates of prim form a valid post-test loop in g.
Control flow graph:
cond ↘ ↓ ↖↲ ↓ exit
type PreLoop ¶
type PreLoop struct { // Condition node (A). Cond graph.Node // Body node (B). Body graph.Node // Exit node (C). Exit graph.Node }
PreLoop represents a pre-test loop.
Pseudo-code:
while (A) { B } C
func FindPreLoop ¶
FindPreLoop returns the first occurrence of a pre-test loop in g, and a boolean indicating if such a primitive was found.
func (PreLoop) IsValid ¶
IsValid reports whether the cond, body and exit node candidates of prim form a valid pre-test loop in g.
Control flow graph:
cond ↓ ↖↘ ↓ body ↓ exit
type Seq ¶
Seq represents a sequence of two statements.
Pseudo-code:
A B
func FindSeq ¶
FindSeq returns the first occurrence of a sequence of two statements in g, and a boolean indicating if such a primitive was found.
func (Seq) IsValid ¶
IsValid reports whether the entry and exit node candidates of prim form a valid sequence of two statements in g.
Control flow graph:
entry ↓ exit