#[non_exhaustive]pub enum Expression {
Literal(Value),
Unresolved(Symbolic),
BinaryOp {
op: BinaryOp,
lhs: Box<Expression>,
rhs: Box<Expression>,
span: Span,
},
UnaryOp {
op: UnaryOp,
operand: Box<Expression>,
span: Span,
},
TemplateConcat(Vec<Expression>),
Array(Vec<Expression>),
Object(Vec<(Expression, Expression)>),
FuncCall(Box<FuncCall>),
Conditional(Box<Conditional>),
For(Box<ForExpr>),
}Expand description
A possibly-resolved HCL expression.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Literal(Value)
A fully-resolved value.
Unresolved(Symbolic)
A symbolic reference the evaluator could not resolve (var.x,
local.y, data.z.w, aws_iam_role.r.arn, etc.).
BinaryOp
Binary operation. Subtrees may themselves be Unresolved.
UnaryOp
Unary operation.
TemplateConcat(Vec<Expression>)
Template concatenation, e.g. "foo-${var.x}-bar" → parts.
Array(Vec<Expression>)
HCL tuple / array literal whose elements are not all
Expression::Literal yet. The loader emits this when the array
contains at least one Expression::Unresolved / function call /
reference; once every element resolves, the evaluator collapses it
to Expression::Literal of Value::List.
Per [10-data-model.md § 2.3 expression-and-values lowering table]:
“tuple / object literals → recurse → Value::List / Value::Map
once children resolved at evaluator phase; during loader, kept as
expression nodes.”
Object(Vec<(Expression, Expression)>)
HCL object literal whose keys or values are not yet fully resolved.
Keys are themselves Expression because HCL allows expression
keys ({(var.kind) = "x"}) — the IR preserves that until the
evaluator can collapse to a Value::Map.
FuncCall(Box<FuncCall>)
Function call.
Conditional(Box<Conditional>)
cond ? a : b.
For(Box<ForExpr>)
[for ... in ...] / {for ... in ...}.
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn as_literal(&self) -> Option<&Value>
pub fn as_literal(&self) -> Option<&Value>
Returns the resolved Value if this expression is a
Expression::Literal.
Sourcepub fn is_fully_resolved(&self) -> bool
pub fn is_fully_resolved(&self) -> bool
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Expression
impl Debug for Expression
Source§impl<'de> Deserialize<'de> for Expression
impl<'de> Deserialize<'de> for Expression
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>,
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§fn eq(&self, other: &Expression) -> bool
fn eq(&self, other: &Expression) -> bool
self and other values to be equal, and is used by ==.