Enum PreExp

Source
pub enum PreExp {
    Primitive(Spanned<Primitive>),
    Abs(InputSpan, Box<PreExp>),
    BlockFunction(Spanned<BlockFunction>),
    Variable(Spanned<String>),
    CompoundVariable(Spanned<CompoundVariable>),
    ArrayAccess(Spanned<AddressableAccess>),
    BlockScopedFunction(Spanned<BlockScopedFunction>),
    FunctionCall(InputSpan, FunctionCall),
    BinaryOperation(Spanned<BinOp>, Box<PreExp>, Box<PreExp>),
    UnaryOperation(Spanned<UnOp>, Box<PreExp>),
}
Expand description

Represents an expression in the intermediate language before final transformation.

This enum captures different types of expressions that can appear in the source code, including primitives, variables, function calls, and mathematical operations.

Variants§

§

Primitive(Spanned<Primitive>)

A primitive value like numbers, strings, booleans

§

Abs(InputSpan, Box<PreExp>)

Absolute value expression, e.g. |x|

§

BlockFunction(Spanned<BlockFunction>)

A block function like average, min, max, etc.

§

Variable(Spanned<String>)

A simple variable reference like ‘x’

§

CompoundVariable(Spanned<CompoundVariable>)

A compound variable like ‘x_y’

§

ArrayAccess(Spanned<AddressableAccess>)

Array access expression like ‘arr[i]’

§

BlockScopedFunction(Spanned<BlockScopedFunction>)

A block function with a scope, like a summation or a product

§

FunctionCall(InputSpan, FunctionCall)

A function call expression

§

BinaryOperation(Spanned<BinOp>, Box<PreExp>, Box<PreExp>)

A binary operation like addition, multiplication

§

UnaryOperation(Spanned<UnOp>, Box<PreExp>)

A unary operation like negation

Implementations§

Source§

impl PreExp

Source

pub fn to_boxed(self) -> Box<PreExp>

Source

pub fn span(&self) -> &InputSpan

Source

pub fn into_exp( &self, context: &mut TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<Exp, TransformError>

Source

pub fn as_static_primitive(&self) -> Option<Primitive>

Source

pub fn as_primitive( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<Primitive, TransformError>

Source

pub fn as_number( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<f64, TransformError>

Source

pub fn as_number_cast( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<f64, TransformError>

Source

pub fn as_integer( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<i64, TransformError>

Source

pub fn as_integer_cast( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<i64, TransformError>

Source

pub fn as_positive_integer( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<u64, TransformError>

Source

pub fn as_usize( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<usize, TransformError>

Source

pub fn as_usize_cast( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<usize, TransformError>

Source

pub fn as_string( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<String, TransformError>

Source

pub fn as_boolean( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<bool, TransformError>

Source

pub fn as_graph( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<Graph, TransformError>

Source

pub fn as_node( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<GraphNode, TransformError>

Source

pub fn as_edge( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<GraphEdge, TransformError>

Source

pub fn as_iterator( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<IterableKind, TransformError>

Source§

impl PreExp

Trait Implementations§

Source§

impl Clone for PreExp

Source§

fn clone(&self) -> PreExp

Returns a copy 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 PreExp

Source§

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

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

impl Display for PreExp

Source§

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

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

impl Serialize for PreExp

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TypeCheckable for PreExp

Source§

fn type_check( &self, context: &mut TypeCheckerContext, fn_context: &FunctionContext<'_>, ) -> Result<(), TransformError>

Performs type checking on the implementing type. Read more
Source§

fn populate_token_type_map( &self, context: &mut TypeCheckerContext, fn_context: &FunctionContext<'_>, )

Populates the token type map with type information. Read more
Source§

impl WithType for PreExp

Source§

fn get_type( &self, context: &TypeCheckerContext, fn_context: &FunctionContext<'_>, ) -> PrimitiveKind

Gets the primitive type of the implementing type. Read more

Auto Trait Implementations§

§

impl Freeze for PreExp

§

impl RefUnwindSafe for PreExp

§

impl Send for PreExp

§

impl Sync for PreExp

§

impl Unpin for PreExp

§

impl UnwindSafe for PreExp

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.