pub enum Expr {
Show 21 variants
Reference(Loc, OnceCell<Type>, Path),
Net(Loc, OnceCell<Type>, NetId),
Word(Loc, OnceCell<Type>, Option<Width>, u64),
Enum(Loc, OnceCell<Type>, Type, String),
Ctor(Loc, OnceCell<Type>, String, Vec<Arc<Expr>>),
Struct(Loc, OnceCell<Type>, Vec<(String, Arc<Expr>)>),
Let(Loc, OnceCell<Type>, String, Arc<Expr>, Arc<Expr>),
UnOp(Loc, OnceCell<Type>, UnOp, Arc<Expr>),
BinOp(Loc, OnceCell<Type>, BinOp, Arc<Expr>, Arc<Expr>),
If(Loc, OnceCell<Type>, Arc<Expr>, Arc<Expr>, Arc<Expr>),
Match(Loc, OnceCell<Type>, Arc<Expr>, Vec<MatchArm>),
Mux(Loc, OnceCell<Type>, Arc<Expr>, Arc<Expr>, Arc<Expr>),
Cat(Loc, OnceCell<Type>, Vec<Arc<Expr>>),
Sext(Loc, OnceCell<Type>, Arc<Expr>),
ToWord(Loc, OnceCell<Type>, Arc<Expr>),
Vec(Loc, OnceCell<Type>, Vec<Arc<Expr>>),
IdxField(Loc, OnceCell<Type>, Arc<Expr>, String),
Idx(Loc, OnceCell<Type>, Arc<Expr>, u64),
IdxRange(Loc, OnceCell<Type>, Arc<Expr>, u64, u64),
Call(Loc, OnceCell<Type>, Arc<FnDef>, Vec<Arc<Expr>>),
Hole(Loc, OnceCell<Type>, Option<String>),
}Expand description
An expression.
Variants§
Reference(Loc, OnceCell<Type>, Path)
A referenec to a port, reg, or node.
Net(Loc, OnceCell<Type>, NetId)
A referenec to a net. Used only in crate::sim::Sim.
Word(Loc, OnceCell<Type>, Option<Width>, u64)
A literal Word.
Enum(Loc, OnceCell<Type>, Type, String)
A literal enum value.
Ctor(Loc, OnceCell<Type>, String, Vec<Arc<Expr>>)
Constructor (for Valid<T>)
Struct(Loc, OnceCell<Type>, Vec<(String, Arc<Expr>)>)
Constructor for structs. Eg, { x = 0, y = 0}.
Let(Loc, OnceCell<Type>, String, Arc<Expr>, Arc<Expr>)
Let binding. Eg, let x = a + b in x + x.
UnOp(Loc, OnceCell<Type>, UnOp, Arc<Expr>)
A unary operation. Eg, !0b101w3.
BinOp(Loc, OnceCell<Type>, BinOp, Arc<Expr>, Arc<Expr>)
A binary operation. Eg, 1w8 + 1w8.
If(Loc, OnceCell<Type>, Arc<Expr>, Arc<Expr>, Arc<Expr>)
An if expression.
Match(Loc, OnceCell<Type>, Arc<Expr>, Vec<MatchArm>)
A match expression.
Mux(Loc, OnceCell<Type>, Arc<Expr>, Arc<Expr>, Arc<Expr>)
A multiplexer. Eg, mux(cond, a, b).
Cat(Loc, OnceCell<Type>, Vec<Arc<Expr>>)
A concatenate expression. Eg, cat(foo, 0w1).
Sext(Loc, OnceCell<Type>, Arc<Expr>)
A sign extension expression.
ToWord(Loc, OnceCell<Type>, Arc<Expr>)
A word expression. Used to cast user-defined enum types to their bit values.
Vec(Loc, OnceCell<Type>, Vec<Arc<Expr>>)
A vector constructor expression. Eg, [0w2, 1w2, 2w2].
IdxField(Loc, OnceCell<Type>, Arc<Expr>, String)
Idx(Loc, OnceCell<Type>, Arc<Expr>, u64)
A static index. Eg, foo[0].
IdxRange(Loc, OnceCell<Type>, Arc<Expr>, u64, u64)
A static index range. Eg, foo[8..4].
Call(Loc, OnceCell<Type>, Arc<FnDef>, Vec<Arc<Expr>>)
A function call. Eg, foo(x, y).
Hole(Loc, 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.