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
impl PreExp
pub fn to_boxed(self) -> Box<PreExp>
pub fn span(&self) -> &InputSpan
pub fn into_exp( &self, context: &mut TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<Exp, TransformError>
pub fn as_static_primitive(&self) -> Option<Primitive>
pub fn as_primitive( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<Primitive, TransformError>
pub fn as_number( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<f64, TransformError>
pub fn as_number_cast( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<f64, TransformError>
pub fn as_integer( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<i64, TransformError>
pub fn as_integer_cast( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<i64, TransformError>
pub fn as_positive_integer( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<u64, TransformError>
pub fn as_usize( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<usize, TransformError>
pub fn as_usize_cast( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<usize, TransformError>
pub fn as_string( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<String, TransformError>
pub fn as_boolean( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<bool, TransformError>
pub fn as_graph( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<Graph, TransformError>
pub fn as_node( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<GraphNode, TransformError>
pub fn as_edge( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<GraphEdge, TransformError>
pub fn as_iterator( &self, context: &TransformerContext, fn_context: &FunctionContext<'_>, ) -> Result<IterableKind, TransformError>
Trait Implementations§
Source§impl TypeCheckable for PreExp
impl TypeCheckable for PreExp
Source§fn type_check(
&self,
context: &mut TypeCheckerContext,
fn_context: &FunctionContext<'_>,
) -> Result<(), TransformError>
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<'_>,
)
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
impl WithType for PreExp
Source§fn get_type(
&self,
context: &TypeCheckerContext,
fn_context: &FunctionContext<'_>,
) -> PrimitiveKind
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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