pub enum ExprKind<T = ()> {
Show 16 variants
Lit(Literal),
Var(Var),
Slot(SlotId),
Unknown {
name: SmolStr,
type_annotation: Option<Type>,
},
If {
test_expr: Arc<Expr<T>>,
then_expr: Arc<Expr<T>>,
else_expr: Arc<Expr<T>>,
},
And {
left: Arc<Expr<T>>,
right: Arc<Expr<T>>,
},
Or {
left: Arc<Expr<T>>,
right: Arc<Expr<T>>,
},
UnaryApp {
op: UnaryOp,
arg: Arc<Expr<T>>,
},
BinaryApp {
op: BinaryOp,
arg1: Arc<Expr<T>>,
arg2: Arc<Expr<T>>,
},
MulByConst {
arg: Arc<Expr<T>>,
constant: i64,
},
ExtensionFunctionApp {
op: ExtensionFunctionOp,
args: Arc<Vec<Expr<T>>>,
},
GetAttr {
expr: Arc<Expr<T>>,
attr: SmolStr,
},
HasAttr {
expr: Arc<Expr<T>>,
attr: SmolStr,
},
Like {
expr: Arc<Expr<T>>,
pattern: Pattern,
},
Set(Arc<Vec<Expr<T>>>),
Record {
pairs: Arc<Vec<(SmolStr, Expr<T>)>>,
},
}Expand description
The possible expression variants. This enum should be matched on by code recursively traversing the AST.
Variants§
Lit(Literal)
Literal value
Var(Var)
Variable
Slot(SlotId)
Template Slots
Unknown
Symbolic Unknown for partial-eval
Fields
If
Ternary expression
Fields
And
Boolean AND
Fields
Or
Boolean OR
Fields
UnaryApp
Application of a built-in unary operator (single parameter)
BinaryApp
Application of a built-in binary operator (two parameters)
Fields
MulByConst
Multiplication by constant
This isn’t just a BinaryOp because its arguments aren’t both expressions.
(Similar to how like isn’t a BinaryOp and has its own AST node as well.)
Fields
ExtensionFunctionApp
Application of an extension function to n arguments INVARIANT (MethodStyleArgs): if op.style is MethodStyle then args cannot be empty. The first element of args refers to the subject of the method call Ideally, we find some way to make this non-representable.
Fields
op: ExtensionFunctionOpExtension function to apply
GetAttr
Get an attribute of an entity, or a field of a record
Fields
HasAttr
Does the given expr have the given attr?
Fields
Like
Regex-like string matching similar to IAM’s StringLike operator.
Fields
Set(Arc<Vec<Expr<T>>>)
Set (whose elements may be arbitrary expressions)
Record
Anonymous record (whose elements may be arbitrary expressions)
This is a Vec for the same reason as above.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for ExprKind<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ExprKind<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl<T: Eq> Eq for ExprKind<T>
impl<T> StructuralPartialEq for ExprKind<T>
Auto Trait Implementations§
impl<T> Freeze for ExprKind<T>
impl<T> RefUnwindSafe for ExprKind<T>where
T: RefUnwindSafe,
impl<T> Send for ExprKind<T>
impl<T> Sync for ExprKind<T>
impl<T> Unpin for ExprKind<T>
impl<T> UnwindSafe for ExprKind<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more