Skip to main content

ExprKind

Enum ExprKind 

Source
pub enum ExprKind {
Show 21 variants Int(i64), Number(f64), Str(String), StringInterp(Vec<StringPart>), Bool(bool), None, Ident(String), BinaryOp { left: Box<Expr>, op: BinOp, right: Box<Expr>, }, UnaryOp { op: UnaryOp, expr: Box<Expr>, }, Call { callee: Box<Expr>, args: Vec<Expr>, }, MethodCall { object: Box<Expr>, method: String, args: Vec<Expr>, }, FieldAccess { object: Box<Expr>, field: String, }, StructConstruct { namespace: Option<String>, type_name: String, fields: Vec<(String, Expr)>, }, EnumConstruct { namespace: Option<String>, type_name: String, variant: String, payload: VariantPayload, }, Index { object: Box<Expr>, index: Box<Expr>, }, Array(Vec<Expr>), Dict(Vec<(String, Expr)>), IfExpr { condition: Box<Expr>, then_expr: Box<Expr>, else_expr: Box<Expr>, }, Lambda { params: Vec<String>, body: Vec<Stmt>, }, Match { scrutinee: Box<Expr>, arms: Vec<MatchArm>, }, Try(Box<Expr>),
}

Variants§

§

Int(i64)

Integer literal (phase 6). Produced by integer tokens like 42; distinct from Number so each engine can emit a Value::Int(i64) directly.

§

Number(f64)

§

Str(String)

§

StringInterp(Vec<StringPart>)

§

Bool(bool)

§

None

§

Ident(String)

§

BinaryOp

Fields

§left: Box<Expr>
§right: Box<Expr>
§

UnaryOp

Fields

§expr: Box<Expr>
§

Call

Fields

§callee: Box<Expr>
§args: Vec<Expr>
§

MethodCall

Fields

§object: Box<Expr>
§method: String
§args: Vec<Expr>
§

FieldAccess

Bare field read: obj.field (no parens after the field name). Distinct from MethodCall, which always has (…).

Fields

§object: Box<Expr>
§field: String
§

StructConstruct

Struct literal: Point { x: 1, y: 2 }. Only parsed in contexts where struct literals are allowed — control-flow conditions and for-in iterables disallow them so that if foo { body } stays unambiguous.

Fields

§namespace: Option<String>

Some("m") for m.Entity { ... } — a namespaced struct literal through a module alias. None for the unqualified Entity { ... } form. The walker / VM / AOT resolve the (namespace, type_name) pair via the current scope’s type-alias table before constructing the Value::Struct.

§type_name: String
§fields: Vec<(String, Expr)>
§

EnumConstruct

Enum variant construction: Shape::Circle(5), Shape::Rectangle { w: 4, h: 3 }, Shape::Empty. The payload shape is determined at parse time from the syntax at the construction site.

Fields

§namespace: Option<String>

Some("r") for r.Result::Ok(v) — a namespaced variant constructor through a module alias. None for unqualified Result::Ok(v).

§type_name: String
§variant: String
§

Index

Fields

§object: Box<Expr>
§index: Box<Expr>
§

Array(Vec<Expr>)

§

Dict(Vec<(String, Expr)>)

§

IfExpr

Fields

§condition: Box<Expr>
§then_expr: Box<Expr>
§else_expr: Box<Expr>
§

Lambda

Anonymous function expression: fn(params) { body }. Captures the referenced free variables from the enclosing scope when evaluated; see the evaluator for capture rules.

Fields

§params: Vec<String>
§body: Vec<Stmt>
§

Match

match scrutinee { pat => body, ... } — checks each arm top-to-bottom, evaluates the first matching arm’s body, and returns its value. Raises a runtime error if no arm matches (exhaustiveness isn’t checked statically in v1).

Fields

§scrutinee: Box<Expr>
§

Try(Box<Expr>)

try <expr> — inspect a Result-shaped enum variant. If <expr> evaluates to an Ok(value)-shaped variant, unwrap to value. If it evaluates to an Err(...)-shaped variant, short-circuit the enclosing function’s return with that value (same mechanism as a return statement). At top-level scope (no enclosing fn) or on a non-Result scrutinee, try raises a runtime error.

Desugars roughly to the match:

match <expr> {
    Ok(v) => v,
    Err(_) => return <expr>,
}

but is its own AST node so each engine can compile it directly without paying the pattern-construction cost.

Trait Implementations§

Source§

impl Clone for ExprKind

Source§

fn clone(&self) -> ExprKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExprKind

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.