Skip to main content

ExprContext

Trait ExprContext 

Source
pub trait ExprContext<T = DefaultTypeSet>
where T: TypeSet,
{ // Required methods fn type_context(&mut self) -> &mut T; fn try_load_variable(&mut self, variable: &str) -> Option<TypedValue<T>>; fn declare(&mut self, variable: &str, value: TypedValue<T>); fn assign_variable( &mut self, variable: &str, value: &TypedValue<T>, ) -> Result<(), Box<str>>; fn place_of_variable(&mut self, variable: &str) -> Result<Place, Box<str>>; fn load_place(&mut self, place: &Place) -> Result<TypedValue<T>, Box<str>>; fn store_place( &mut self, place: &Place, value: &TypedValue<T>, ) -> Result<(), Box<str>>; fn struct_fields( &self, struct_name: &str, ) -> Option<Vec<(Box<str>, Box<str>)>>; fn open_scope(&mut self); fn close_scope(&mut self); fn call_function( &mut self, function_name: &str, args: &[TypedValue<T>], ) -> Result<TypedValue<T>, FunctionCallError>; }
Expand description

An expression context that provides the necessary environment for evaluating expressions.

Required Methods§

Source

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

Returns a reference to the TypeSet.

Source

fn try_load_variable(&mut self, variable: &str) -> Option<TypedValue<T>>

Attempts to load a variable from the context.

Source

fn declare(&mut self, variable: &str, value: TypedValue<T>)

Declares a variable in the context.

Source

fn assign_variable( &mut self, variable: &str, value: &TypedValue<T>, ) -> Result<(), Box<str>>

Assigns a new value to a variable in the context.

Source

fn place_of_variable(&mut self, variable: &str) -> Result<Place, Box<str>>

Returns the Place naming a variable (the root of a reference).

Source

fn load_place(&mut self, place: &Place) -> Result<TypedValue<T>, Box<str>>

Loads (a clone of) the value at the given place, descending its field path.

Source

fn store_place( &mut self, place: &Place, value: &TypedValue<T>, ) -> Result<(), Box<str>>

Stores a value into the given place, descending its field path.

Source

fn struct_fields(&self, struct_name: &str) -> Option<Vec<(Box<str>, Box<str>)>>

Returns the (field name, field type name) pairs of a struct definition, in declaration order, or None if no such struct is defined.

Used to validate and coerce struct literals and to type-check struct-typed annotations.

Source

fn open_scope(&mut self)

Opens a new scope in the current stack frame.

Source

fn close_scope(&mut self)

Closes the last scope in the current stack frame.

Source

fn call_function( &mut self, function_name: &str, args: &[TypedValue<T>], ) -> Result<TypedValue<T>, FunctionCallError>

Calls a function in the context.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> ExprContext<T> for Context<'_, T>
where T: TypeSet,