Lib.Terminator module

MIF08, CAP, CFG library - Terminators.

Each block of a CFG ends with a branching instruction called a terminator. There are three kinds of terminators:

During the construction of the CFG, jump2terminator() builds a terminator for each extracted chunk of instructions.

class Lib.Terminator.Return[source]

Bases: Statement

A terminator that marks the end of the function.

printIns(stream)[source]

Print the statement on the given output. Should never be called on the base class.

targets() List[Label][source]

Return the labels targetted by the Return terminator.

args() List[Operand][source]
rename(renamer: Renamer)[source]
substitute(subst: Dict[Operand, Operand])[source]
is_read_only() bool[source]
class Lib.Terminator.BranchingTerminator(cond: Condition, op1: Operand, op2: Operand, label_then: Label, label_else: Label)[source]

Bases: Instruction

A terminating statement with a condition.

cond: Condition

The condition of the branch

label_then: Label

The destination label if the condition is true

label_else: Label

The destination label if the condition is false

op1: Operand

The first operand of the condition

op2: Operand

The second operand of the condition

args() List[Operand][source]

List of operands the instruction takes

targets() List[Label][source]

Return the labels targetted by the Branching terminator.

rename(renamer: Renamer)[source]
substitute(subst: Dict[Operand, Operand])[source]
Lib.Terminator.Terminator = Lib.Terminator.Return | Lib.Statement.AbsoluteJump | Lib.Terminator.BranchingTerminator

Type alias for terminators

Lib.Terminator.jump2terminator(j: ConditionalJump | AbsoluteJump | None, next_label: Label | None) Return | AbsoluteJump | BranchingTerminator[source]

Construct the Terminator associated to the potential jump j to the potential label next_label.