Skip to main content

ExprKind

Enum ExprKind 

Source
pub enum ExprKind<P: Phase = Raw> {
Show 23 variants Number(f64), Integer(i64), Bool(bool), StringLiteral(String), GraphRef(Spanned<ScopedName>), BinOp { op: BinOp, lhs: Box<Expr<P>>, rhs: Box<Expr<P>>, }, UnaryOp { op: UnaryOp, operand: Box<Expr<P>>, }, FnCall { callee: IdentPath, type_args: Vec<GenericArg<P>>, args: Vec<Expr<P>>, }, If { condition: Box<Expr<P>>, then_branch: Box<Expr<P>>, else_branch: Box<Expr<P>>, }, UnitLiteral { value: f64, unit: UnitExpr, }, Convert { expr: Box<Expr<P>>, target: UnitExpr, }, DisplayTimezone { expr: Box<Expr<P>>, timezone: String, }, FieldAccess { expr: Box<Expr<P>>, field: Spanned<FieldName>, }, ConstructorCall { callee: IdentPath, generic_args: Vec<GenericArg<P>>, fields: Vec<FieldInit<P>>, }, MapLiteral { entries: Vec<MapEntry<P>>, }, ForComp { bindings: Vec<ForBinding>, body: Box<Expr<P>>, }, IndexAccess { expr: Box<Expr<P>>, args: Vec<IndexArg<P>>, }, Scan { source: Box<Expr<P>>, init: Box<Expr<P>>, acc_name: Spanned<LocalName>, val_name: Spanned<LocalName>, body: Box<Expr<P>>, }, Unfold { init: Box<Expr<P>>, prev_name: Spanned<LocalName>, curr_name: Spanned<LocalName>, body: Box<Expr<P>>, }, Match { scrutinee: Box<Expr<P>>, arms: Vec<MatchArm<P>>, }, InlineDagRef { path: ModulePath, args: Vec<ParamBinding<P>>, output: Spanned<DeclName>, }, UnresolvedRef(UnresolvedRef), Sugar(P::ExprSugar),
}

Variants§

§

Number(f64)

Numeric literal: 1200.0, 3.98e5, 200_000.0

§

Integer(i64)

Integer literal: 42, 1_000

§

Bool(bool)

Boolean literal: true, false

§

StringLiteral(String)

String literal: "hello" (used as arguments to datetime(), epoch(), etc.)

§

GraphRef(Spanned<ScopedName>)

Graph reference: @name or @alias.member. The payload encodes qualification structurally — Local for bare @name, Qualified for @alias.member (after the namespace-alias rewrite). Producers never invent or interpret a flat-string separator.

§

BinOp

Binary operation: a + b, a * b, a ^ b, a && b, etc.

Fields

§lhs: Box<Expr<P>>
§rhs: Box<Expr<P>>
§

UnaryOp

Unary operation: -x, !x

Fields

§operand: Box<Expr<P>>
§

FnCall

Function call syntax: sqrt(x), atan2(y, x), eye<3>(), or module.fn(x).

The callee is a syntactic path. Bare calls and qualified calls have the same AST shape; semantic categorization/resolution happens later.

Fields

§callee: IdentPath
§type_args: Vec<GenericArg<P>>
§args: Vec<Expr<P>>
§

If

Conditional: if cond { then_expr } else { else_expr }

Fields

§condition: Box<Expr<P>>
§then_branch: Box<Expr<P>>
§else_branch: Box<Expr<P>>
§

UnitLiteral

Unit-annotated literal: 400 km, 9.80665 m/s^2

Fields

§value: f64
§

Convert

Conversion: expr -> unit_expr

Fields

§expr: Box<Expr<P>>
§target: UnitExpr
§

DisplayTimezone

Timezone display: expr -> "America/New_York" (datetime only)

Fields

§expr: Box<Expr<P>>
§timezone: String
§

FieldAccess

Field access: @transfer.dv1, @mission.transfer.dv1

Fields

§expr: Box<Expr<P>>
§

ConstructorCall

Constructor-call syntax for values of user-defined unified type declarations.

Payload constructors use named arguments, e.g. TransferResult(dv1: @dv1, dv2: @dv2) or module.TransferResult(dv1: @dv1). The callee is a syntactic path; name resolution decides whether it denotes a constructor.

Fields

§callee: IdentPath
§generic_args: Vec<GenericArg<P>>
§fields: Vec<FieldInit<P>>
§

MapLiteral

Map literal: { Maneuver.Departure: 2.46 km/s, Maneuver.Correction: 0.05 km/s }

Fields

§entries: Vec<MapEntry<P>>
§

ForComp

For comprehension: for m: Maneuver { @delta_v[m] + 1.0 }

Fields

§bindings: Vec<ForBinding>
§body: Box<Expr<P>>
§

IndexAccess

Index access: @delta_v[m], @delta_v[Maneuver.Departure], @P[a, b]

Fields

§expr: Box<Expr<P>>
§args: Vec<IndexArg<P>>
§

Scan

Scan: scan(source, init, |acc, val| body)

Fields

§source: Box<Expr<P>>
§init: Box<Expr<P>>
§acc_name: Spanned<LocalName>
§val_name: Spanned<LocalName>
§body: Box<Expr<P>>
§

Unfold

Unfold: unfold(init, |prev_i, i| body)

Generates an indexed value from a seed by iterating over a range index. The closure receives (prev_i, i) bindings for the previous and current step indices, and the body can reference @node_name[prev_i].

Fields

§init: Box<Expr<P>>
§prev_name: Spanned<LocalName>
§curr_name: Spanned<LocalName>
§body: Box<Expr<P>>
§

Match

Match expression: match @status { Nominal => ..., Warning(message: code) => ... }

Fields

§scrutinee: Box<Expr<P>>
§arms: Vec<MatchArm<P>>
§

InlineDagRef

Inline DAG invocation: @dag(args).out or @module.dag(args).out.

Each syntactic occurrence denotes a fresh DAG instantiation that is desugared during TIR lowering to the equivalent include <path>(args) as <synthetic>; @<synthetic>.out. Preserved as a distinct AST variant so source spans survive for diagnostics.

The post-@ expression as a whole must denote a node — that is the invariant @ enforces. @dag(args).out is well-formed because dag(args).out projects an output node from a fresh DAG instance, and likewise @module.dag(args).out projects an output node from a DAG brought into scope via import module.{dag}; or import path as module;. Bare @dag(args) (no projection) is rejected — a DAG instance with no projection is not a node.

Fields

§path: ModulePath

Path to the DAG being invoked. Single-segment for same-file calls (@dag(args).out), multi-segment for cross-file qualified calls (@module.dag(args).out). The leaf segment names the DAG; any preceding segments resolve through module aliases brought into scope by import.

§args: Vec<ParamBinding<P>>

Param/index bindings, same shape as include bindings.

§output: Spanned<DeclName>

Projected output node name (after the closing paren .).

§

UnresolvedRef(UnresolvedRef)

Unresolved reference produced by the parser.

Carries an unresolved identifier path. HIR expression lowering is the single stage that classifies and resolves these paths.

§

Sugar(P::ExprSugar)

Phase-specific expression sugar.

In Raw, this is crate::syntax::ast::RawExprSugar and carries surface forms like TableLiteral that are eliminated by the desugar pass. In Desugared, the payload is core::convert::Infallible — the variant is statically unreachable.

Trait Implementations§

Source§

impl<P: Clone + Phase> Clone for ExprKind<P>
where P::ExprSugar: Clone,

Source§

fn clone(&self) -> ExprKind<P>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug + Phase> Debug for ExprKind<P>
where P::ExprSugar: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FormatEquivalent for ExprKind

Source§

fn format_equivalent(&self, other: &Self) -> bool

Returns true if self and other are equivalent up to formatting.
Source§

impl From<ExprKind> for ExprKind<Desugared>

Source§

fn from(k: ExprKind<Raw>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<P> Freeze for ExprKind<P>
where <P as Phase>::ExprSugar: Freeze,

§

impl<P> RefUnwindSafe for ExprKind<P>
where <P as Phase>::ExprSugar: RefUnwindSafe,

§

impl<P> Send for ExprKind<P>
where <P as Phase>::ExprSugar: Send,

§

impl<P> Sync for ExprKind<P>
where <P as Phase>::ExprSugar: Sync,

§

impl<P> Unpin for ExprKind<P>
where <P as Phase>::ExprSugar: Unpin,

§

impl<P> UnsafeUnpin for ExprKind<P>
where <P as Phase>::ExprSugar: UnsafeUnpin,

§

impl<P> UnwindSafe for ExprKind<P>
where <P as Phase>::ExprSugar: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.