pub struct CtfeContext {
pub constants: HashMap<String, CtfeValue>,
pub recursion_depth: u32,
pub max_depth: u32,
pub fuel: u64,
pub fuel_used: u64,
/* private fields */
}Expand description
Evaluation context: maps names / variable IDs to their current values.
Fields§
§constants: HashMap<String, CtfeValue>Global constant bindings (function name → value).
recursion_depth: u32Current recursion depth.
max_depth: u32Maximum recursion depth.
fuel: u64Remaining evaluation fuel.
fuel_used: u64Total fuel consumed so far.
Implementations§
Source§impl CtfeContext
impl CtfeContext
Sourcepub fn bind_local(&mut self, id: LcnfVarId, value: CtfeValue)
pub fn bind_local(&mut self, id: LcnfVarId, value: CtfeValue)
Bind a local variable.
Sourcepub fn lookup_local(&self, id: LcnfVarId) -> Option<&CtfeValue>
pub fn lookup_local(&self, id: LcnfVarId) -> Option<&CtfeValue>
Look up a local variable.
Sourcepub fn consume_fuel(&mut self) -> Result<(), CtfeError>
pub fn consume_fuel(&mut self) -> Result<(), CtfeError>
Consume one unit of fuel, returning Err(Timeout) if exhausted.
Sourcepub fn push_frame(&mut self) -> Result<(), CtfeError>
pub fn push_frame(&mut self) -> Result<(), CtfeError>
Push a call frame, returning Err(StackOverflow) if too deep.
Sourcepub fn child_context(&self) -> CtfeContext
pub fn child_context(&self) -> CtfeContext
Create a child context for evaluating a sub-expression with fresh locals.
Sourcepub fn merge_fuel_from(&mut self, child: &CtfeContext)
pub fn merge_fuel_from(&mut self, child: &CtfeContext)
Merge fuel consumption back from a child context.
Trait Implementations§
Source§impl Clone for CtfeContext
impl Clone for CtfeContext
Source§fn clone(&self) -> CtfeContext
fn clone(&self) -> CtfeContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CtfeContext
impl Debug for CtfeContext
Auto Trait Implementations§
impl Freeze for CtfeContext
impl RefUnwindSafe for CtfeContext
impl Send for CtfeContext
impl Sync for CtfeContext
impl Unpin for CtfeContext
impl UnsafeUnpin for CtfeContext
impl UnwindSafe for CtfeContext
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