Enum cedar_policy_core::ast::ExprKind
source · 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 {
fn_name: Name,
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
Fields
Symbolic Unknown for partial-eval
If
Fields
Ternary expression
And
Fields
Boolean AND
Or
Fields
Boolean OR
UnaryApp
Application of a built-in unary operator (single parameter)
BinaryApp
Fields
Application of a built-in binary operator (two parameters)
MulByConst
Fields
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.)
ExtensionFunctionApp
Fields
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.
GetAttr
Fields
Get an attribute of an entity, or a field of a record
HasAttr
Fields
Does the given expr
have the given attr
?
Like
Fields
Regex-like string matching similar to IAM’s StringLike
operator.
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.