Class Expr

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class Expr : public seq::SrcObject

Class from which all Seq expressions derive.

An “expression” can be thought of as an AST node, potentially containing sub-expressions. Every expression has a type.

Subclassed by seq::ArrayContainsExpr, seq::ArrayExpr, seq::ArrayLookupExpr, seq::AtomicExpr, seq::BlankExpr, seq::BoolExpr, seq::BOpExpr, seq::CallExpr, seq::CondExpr, seq::ConstructExpr, seq::DefaultExpr, seq::DictCompExpr, seq::DictExpr, seq::FloatExpr, seq::FuncExpr, seq::GenExpr, seq::GetElemExpr, seq::GetStaticElemExpr, seq::IntExpr, seq::IsExpr, seq::ListCompExpr, seq::ListExpr, seq::MatchExpr, seq::MethodExpr, seq::NoneExpr, seq::OptExpr, seq::PartialCallExpr, seq::PipeExpr, seq::RecordExpr, seq::SeqExpr, seq::SetCompExpr, seq::SetExpr, seq::StrExpr, seq::TypeExpr, seq::TypeOfExpr, seq::UOpExpr, seq::ValueExpr, seq::VarExpr, seq::VarPtrExpr, seq::YieldExpr

Public Functions

Expr(types::Type *type)

Constructs an expression of fixed type.

  • type: fixed type of expression


Constructs an expression without a fixed type.

void setTryCatch(TryCatch *tc)

Sets the enclosing try-catch statement.

TryCatch *getTryCatch()

Returns the enclosing try-catch statement.

Value *codegen(BaseFunc *base, llvm::BasicBlock *&block)

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

types::Type *getType() const

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

std::string getName() const

Returns the given name of this expression.

void resolveTypes()

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

virtual llvm::Value *codegen0(BaseFunc *base, llvm::BasicBlock *&block) = 0

Performs code generation for this expression.


value representing expression result; possibly null if type is void

  • base: the function containing this expression

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

types::Type *getType0() const

Determines and returns the type of this expression.

void ensure(types::Type *type)

Ensures that this expression has the specified type. Throws an exception if this is not the case.

  • type: required type of this expression

Expr *clone(Generic *ref)

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


cloned expression

  • ref: generic object that is being cloned

Protected Attributes

std::string name

Human-readable name for this expression, mainly for debugging