Enum bitsy_lang::Expr
source · pub enum Expr {
Show 23 variants
Reference(Span, OnceCell<Type>, Path),
Net(Span, OnceCell<Type>, NetId),
Word(Span, OnceCell<Type>, Option<Width>, u64),
Enum(Span, OnceCell<Type>, Type, String),
Ctor(Span, OnceCell<Type>, String, Vec<Arc<Expr>>),
Struct(Span, OnceCell<Type>, Vec<(String, Arc<Expr>)>),
Let(Span, OnceCell<Type>, String, Option<Type>, Arc<Expr>, Arc<Expr>),
UnOp(Span, OnceCell<Type>, UnOp, Arc<Expr>),
BinOp(Span, OnceCell<Type>, BinOp, Arc<Expr>, Arc<Expr>),
If(Span, OnceCell<Type>, Arc<Expr>, Arc<Expr>, Arc<Expr>),
Match(Span, OnceCell<Type>, Arc<Expr>, Vec<MatchArm>),
Mux(Span, OnceCell<Type>, Arc<Expr>, Arc<Expr>, Arc<Expr>),
Cat(Span, OnceCell<Type>, Vec<Arc<Expr>>),
Sext(Span, OnceCell<Type>, Arc<Expr>),
Zext(Span, OnceCell<Type>, Arc<Expr>),
TryCast(Span, OnceCell<Type>, Arc<Expr>),
ToWord(Span, OnceCell<Type>, Arc<Expr>),
Vec(Span, OnceCell<Type>, Vec<Arc<Expr>>),
IdxField(Span, OnceCell<Type>, Arc<Expr>, String),
Idx(Span, OnceCell<Type>, Arc<Expr>, u64),
IdxRange(Span, OnceCell<Type>, Arc<Expr>, u64, u64),
Call(Span, OnceCell<Type>, Arc<FnDef>, Vec<Arc<Expr>>),
Hole(Span, OnceCell<Type>, Option<String>),
}
Expand description
An expression.
Variants§
Reference(Span, OnceCell<Type>, Path)
A referenec to a port, reg, or node.
Net(Span, OnceCell<Type>, NetId)
A referenec to a net. Used only in crate::sim::Sim
.
Word(Span, OnceCell<Type>, Option<Width>, u64)
A literal Word.
Enum(Span, OnceCell<Type>, Type, String)
A literal enum value.
Ctor(Span, OnceCell<Type>, String, Vec<Arc<Expr>>)
Constructor (for Valid<T>
)
Struct(Span, OnceCell<Type>, Vec<(String, Arc<Expr>)>)
Constructor for structs. Eg, { x = 0, y = 0}
.
Let(Span, OnceCell<Type>, String, Option<Type>, Arc<Expr>, Arc<Expr>)
Let binding. Eg, let x = a + b in x + x
.
UnOp(Span, OnceCell<Type>, UnOp, Arc<Expr>)
A unary operation. Eg, !0b101w3
.
BinOp(Span, OnceCell<Type>, BinOp, Arc<Expr>, Arc<Expr>)
A binary operation. Eg, 1w8 + 1w8
.
If(Span, OnceCell<Type>, Arc<Expr>, Arc<Expr>, Arc<Expr>)
An if
expression.
Match(Span, OnceCell<Type>, Arc<Expr>, Vec<MatchArm>)
A match
expression.
Mux(Span, OnceCell<Type>, Arc<Expr>, Arc<Expr>, Arc<Expr>)
A multiplexer. Eg, mux(cond, a, b)
.
Cat(Span, OnceCell<Type>, Vec<Arc<Expr>>)
A concatenate expression. Eg, cat(foo, 0w1)
.
Sext(Span, OnceCell<Type>, Arc<Expr>)
A sign extension expression.
Zext(Span, OnceCell<Type>, Arc<Expr>)
A zero extension expression.
TryCast(Span, OnceCell<Type>, Arc<Expr>)
Try to cast a Word
to an enum
type.
ToWord(Span, OnceCell<Type>, Arc<Expr>)
A word expression. Used to cast user-defined enum
types to their bit values.
Vec(Span, OnceCell<Type>, Vec<Arc<Expr>>)
A vector constructor expression. Eg, [0w2, 1w2, 2w2]
.
IdxField(Span, OnceCell<Type>, Arc<Expr>, String)
Idx(Span, OnceCell<Type>, Arc<Expr>, u64)
A static index. Eg, foo[0]
.
IdxRange(Span, OnceCell<Type>, Arc<Expr>, u64, u64)
A static index range. Eg, foo[8..4]
.
Call(Span, OnceCell<Type>, Arc<FnDef>, Vec<Arc<Expr>>)
A function call. Eg, foo(x, y)
.
Hole(Span, OnceCell<Type>, Option<String>)
A hole. Eg, ?foo
.
Implementations§
source§impl Expr
impl Expr
pub fn assert_has_types(&self)
sourcepub fn with_subexprs(&self, callback: &mut dyn FnMut(&Expr))
pub fn with_subexprs(&self, callback: &mut dyn FnMut(&Expr))
Walk the expression tree in-order, calling callback
for each subexpression.