Skip to main content

TypedExpr

Enum TypedExpr 

Source
pub enum TypedExpr {
Show 25 variants Int { value: i64, ty: QalaType, span: Span, }, Float { value: f64, ty: QalaType, span: Span, }, Byte { value: u8, ty: QalaType, span: Span, }, Str { value: String, ty: QalaType, span: Span, }, Bool { value: bool, ty: QalaType, span: Span, }, Ident { name: String, ty: QalaType, span: Span, }, Paren { inner: Box<TypedExpr>, ty: QalaType, span: Span, }, Tuple { elems: Vec<TypedExpr>, ty: QalaType, span: Span, }, ArrayLit { elems: Vec<TypedExpr>, ty: QalaType, span: Span, }, ArrayRepeat { value: Box<TypedExpr>, count: Box<TypedExpr>, ty: QalaType, span: Span, }, StructLit { name: String, fields: Vec<TypedFieldInit>, ty: QalaType, span: Span, }, FieldAccess { obj: Box<TypedExpr>, name: String, ty: QalaType, span: Span, }, MethodCall { receiver: Box<TypedExpr>, name: String, args: Vec<TypedExpr>, ty: QalaType, span: Span, }, Call { callee: Box<TypedExpr>, args: Vec<TypedExpr>, ty: QalaType, span: Span, }, Index { obj: Box<TypedExpr>, index: Box<TypedExpr>, ty: QalaType, span: Span, }, Try { expr: Box<TypedExpr>, ty: QalaType, span: Span, }, Unary { op: UnaryOp, operand: Box<TypedExpr>, ty: QalaType, span: Span, }, Binary { op: BinOp, lhs: Box<TypedExpr>, rhs: Box<TypedExpr>, ty: QalaType, span: Span, }, Range { start: Option<Box<TypedExpr>>, end: Option<Box<TypedExpr>>, inclusive: bool, ty: QalaType, span: Span, }, Pipeline { lhs: Box<TypedExpr>, call: Box<TypedExpr>, ty: QalaType, span: Span, }, Comptime { body: Box<TypedExpr>, ty: QalaType, span: Span, }, Block { block: TypedBlock, ty: QalaType, span: Span, }, Match { scrutinee: Box<TypedExpr>, arms: Vec<TypedMatchArm>, ty: QalaType, span: Span, }, OrElse { expr: Box<TypedExpr>, fallback: Box<TypedExpr>, ty: QalaType, span: Span, }, Interpolation { parts: Vec<TypedInterpPart>, ty: QalaType, span: Span, },
}
Expand description

a typed expression. mirror of ast::Expr with a resolved QalaType annotation on every variant.

nothing is desugared: TypedExpr::Pipeline stays a pipeline (not f(x, a)), TypedExpr::Interpolation stays a parts list (not a + chain), TypedExpr::Match and TypedExpr::Block produce values directly. the rule is the same as for the untyped AST – the typechecker only types; codegen lowers.

every recursive position is a Box<TypedExpr>; the variant-level ty field is the design choice over a wrapper struct (TypedExpr { kind, span, ty }) – per-variant means TypedExpr::ty is one exhaustive match that the compiler enforces.

Variants§

§

Int

an integer literal with its resolved type (QalaType::I64).

Fields

§value: i64
§span: Span
§

Float

a float literal with its resolved type (QalaType::F64).

Fields

§value: f64
§span: Span
§

Byte

a byte literal with its resolved type (QalaType::Byte).

Fields

§value: u8
§span: Span
§

Str

a string literal with its resolved type (QalaType::Str).

Fields

§value: String
§span: Span
§

Bool

a boolean literal with its resolved type (QalaType::Bool).

Fields

§value: bool
§span: Span
§

Ident

an identifier reference resolved to its bound type.

Fields

§name: String
§span: Span
§

Paren

( inner ) – a parenthesized expression. semantically transparent; the resolved type is the inner’s type.

Fields

§span: Span
§

Tuple

( e1, e2, ... ) – a tuple. resolved type is QalaType::Tuple of the element types.

Fields

§span: Span
§

ArrayLit

[ e1, e2, ... ] – an array literal. resolved type is QalaType::Array with Some(n) length matching elems.len().

Fields

§span: Span
§

ArrayRepeat

[ value; count ] – the repeat form of an array literal.

Fields

§span: Span
§

StructLit

Name { field: e, ... } – a struct literal. resolved type is QalaType::Named of the struct.

Fields

§name: String
§span: Span
§

FieldAccess

obj.name – field access. distinct from TypedExpr::MethodCall: this is the form with no ( ... ) after the .name. resolved type is the field’s type.

Fields

§name: String
§span: Span
§

MethodCall

receiver.name(args) – a method call. distinct from a field access followed by a call; the typechecker resolves it to the fn Type.name(self, ...) declaration. resolved type is the method’s return type.

Fields

§receiver: Box<TypedExpr>
§name: String
§span: Span
§

Call

callee(args) – a call expression. resolved type is the callee’s return type.

Fields

§callee: Box<TypedExpr>
§span: Span
§

Index

obj[index] – an index expression. resolved type is the element type of the array.

Fields

§span: Span
§

Try

expr? – error propagation. resolved type is the Ok payload (for Result<T, E>) or the Some payload (for Option<T>).

Fields

§span: Span
§

Unary

a unary-operator application: !operand or -operand. resolved type is determined by the operand and the operator.

Fields

§operand: Box<TypedExpr>
§span: Span
§

Binary

a binary-operator application. resolved type is determined by the operator (arithmetic: matches the operand type; comparison and equality: bool; &&/||: bool). the or fallback is not here – it is TypedExpr::OrElse.

Fields

§span: Span
§

Range

start .. end or start ..= end. resolved type is the iterable type the range stands for.

Fields

§inclusive: bool
§span: Span
§

Pipeline

lhs |> call – the pipeline operator. NOT desugared in the typed AST either; desugaring is Phase 4 codegen’s job. resolved type is the call’s return type.

Fields

§span: Span
§

Comptime

comptime body – compile-time evaluated. resolved type is the body’s type (the typechecker only types it; evaluation is codegen).

Fields

§span: Span
§

Block

{ ...; trailing } used as an expression. resolved type is the block’s trailing-value type (or void); duplicated at this level so the uniform TypedExpr::ty accessor reads from a variant field rather than peeking into the TypedBlock.

Fields

§span: Span
§

Match

match scrutinee { arm, ... }. NOT desugared. resolved type is the common type of all arm bodies; exhaustiveness is checked by the typechecker against the scrutinee’s enum type.

Fields

§scrutinee: Box<TypedExpr>
§span: Span
§

OrElse

expr or fallback – the inline fallback for a Result/Option. NOT desugared. resolved type is the T of Result<T, E> / Option<T>.

Fields

§fallback: Box<TypedExpr>
§span: Span
§

Interpolation

a string with {expr} interpolations. NOT desugared to a + chain; the conversion-and-concatenation happens in Phase 4 codegen. resolved type is QalaType::Str.

Fields

§span: Span

Implementations§

Source§

impl TypedExpr

Source

pub fn ty(&self) -> &QalaType

the resolved type of this expression.

exhaustive match: the proof every typed expression has a type. the typechecker fills this; codegen reads it to drive instruction selection (int add vs float add, struct-field offset, exhaustiveness, …).

Source

pub fn span(&self) -> Span

the source span of this expression.

every variant carries its span field; this match is exhaustive over all of them, the same shape as ast::Expr::span(). the typechecker copies the span from the untyped node when it constructs the typed one.

Trait Implementations§

Source§

impl Clone for TypedExpr

Source§

fn clone(&self) -> TypedExpr

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 Debug for TypedExpr

Source§

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

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

impl PartialEq for TypedExpr

Source§

fn eq(&self, other: &TypedExpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TypedExpr

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more