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§
Sourcefn type_context(&mut self) -> &mut T
fn type_context(&mut self) -> &mut T
Returns a reference to the TypeSet.
Sourcefn try_load_variable(&mut self, variable: &str) -> Option<TypedValue<T>>
fn try_load_variable(&mut self, variable: &str) -> Option<TypedValue<T>>
Attempts to load a variable from the context.
Sourcefn declare(&mut self, variable: &str, value: TypedValue<T>)
fn declare(&mut self, variable: &str, value: TypedValue<T>)
Declares a variable in the context.
Sourcefn assign_variable(
&mut self,
variable: &str,
value: &TypedValue<T>,
) -> Result<(), Box<str>>
fn assign_variable( &mut self, variable: &str, value: &TypedValue<T>, ) -> Result<(), Box<str>>
Assigns a new value to a variable in the context.
Sourcefn place_of_variable(&mut self, variable: &str) -> Result<Place, Box<str>>
fn place_of_variable(&mut self, variable: &str) -> Result<Place, Box<str>>
Returns the Place naming a variable (the root of a reference).
Sourcefn load_place(&mut self, place: &Place) -> Result<TypedValue<T>, Box<str>>
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.
Sourcefn store_place(
&mut self,
place: &Place,
value: &TypedValue<T>,
) -> Result<(), Box<str>>
fn store_place( &mut self, place: &Place, value: &TypedValue<T>, ) -> Result<(), Box<str>>
Stores a value into the given place, descending its field path.
Sourcefn struct_fields(&self, struct_name: &str) -> Option<Vec<(Box<str>, Box<str>)>>
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.
Sourcefn open_scope(&mut self)
fn open_scope(&mut self)
Opens a new scope in the current stack frame.
Sourcefn close_scope(&mut self)
fn close_scope(&mut self)
Closes the last scope in the current stack frame.
Sourcefn call_function(
&mut self,
function_name: &str,
args: &[TypedValue<T>],
) -> Result<TypedValue<T>, FunctionCallError>
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".