# Class Stmt¶

## Class Documentation¶

class seq::Stmt : public seq::SrcObject

Class from which all Seq statements derive.

A “statement” can be thought of as an AST node, potentially containing sub-expressions and sub-statements.

Public Functions

Stmt(std::string name)
std::string getName() const

Returns the given name of this statement.

Stmt *getPrev() const

Returns the statement enclosing this statement, or null if none.

Block *getParent()

Returns the parent (i.e. enclosing) block of this statement.

void setParent(Block *parent)

Sets the parent (i.e. enclosing) block of this statement.

BaseFunc *getBase() const

Returns the function containing this statement.

void setBase(BaseFunc *base)

Sets the function containing this statement.

Stmt *findEnclosingLoop()

Returns the innermost enclosing loop statement.

void addBreakToEnclosingLoop(llvm::BranchInst *inst)

Adds the given branch instruction as a “break” to the loop enclosing this statement.

void addContinueToEnclosingLoop(llvm::BranchInst *inst)

Adds the given branch instruction as a “continue” to the loop enclosing this statement.

void setTryCatch(TryCatch *tc)

Sets the enclosing try-catch statement.

TryCatch *getTryCatch()

Returns the enclosing try-catch statement.

bool isLoop()

Returns whether this statement represents a loop.

void ensureLoop()

Throws an exception if this statement is not a loop.

void addBreak(llvm::BranchInst *inst)

Adds the given branch instruction as a “break” to this statement (ensuring that it is indeed a loop in the process).

void addContinue(llvm::BranchInst *inst)

Adds the given branch instruction as a “continue” to this statement (ensuring that it is indeed a loop in the process).

void setBreaks(llvm::BasicBlock *block)

Sets the destination block for all branch instructions representing “breaks” contained in this statement (ensuring that it is indeed a loop in the process).

void setContinues(llvm::BasicBlock *block)

Sets the destination block for all branch instructions representing “continues” contained in this statement (ensuring that it is indeed a loop in the process).

void codegen(llvm::BasicBlock *&block)

Delegates to codegen0(); catches exceptions and fills in source information.

void resolveTypes()

Performs type resolution on this statement and all sub-expressions/statements/etc. This is called prior to Expr::getType().

void codegen0(llvm::BasicBlock *&block) = 0

Performs code generation for this statement.

Parameters
• block: reference to block where code should be generated; possibly modified to point to a new block where codegen should resume

Stmt *clone(Generic *ref) = 0

Clones this statement. ref is used internally to keep track of cloned objects, and to make sure we don’t clone certain objects twice.

Return

cloned statement

Parameters
• ref: generic object that is being cloned

void setCloneBase(Stmt *stmt, Generic *ref)

Copies this statement’s fields to a cloned statement’s.

Parameters
• stmt: object to copy fields to

• ref: generic object that is being cloned

Protected Attributes

Block *parent

Block containing this statement.

bool loop

Whether this statement represents a loop.