pub struct VariableContext { /* private fields */ }
Expand description
变量上下文管理器。
管理多层嵌套的作用域,支持上下文和帧的推入/弹出操作。 用于跟踪不同作用域中的变量定义和可见性。
Implementations§
Source§impl VariableContext
impl VariableContext
Sourcepub fn all_contexts(&self) -> &Vec<Vec<VariableFrame>>
pub fn all_contexts(&self) -> &Vec<Vec<VariableFrame>>
获取所有上下文的引用。
Source§impl VariableContext
impl VariableContext
Sourcepub fn define_variable(&mut self, name: String, var: Variable)
pub fn define_variable(&mut self, name: String, var: Variable)
在当前作用域定义变量。
Sourcepub fn get_variable(&self, name: &str) -> Option<&Variable>
pub fn get_variable(&self, name: &str) -> Option<&Variable>
查找变量(搜索所有上下文和帧)。
Sourcepub fn get_variable_current_context(&self, name: &str) -> Option<&Variable>
pub fn get_variable_current_context(&self, name: &str) -> Option<&Variable>
在当前上下文中查找变量。
Sourcepub fn push_frame(&mut self)
pub fn push_frame(&mut self)
推入新的作用域帧。
Sourcepub fn push_context(&mut self)
pub fn push_context(&mut self)
推入新的上下文。
Sourcepub fn pop_context(&mut self) -> Result<(), String>
pub fn pop_context(&mut self) -> Result<(), String>
弹出上下文。
Trait Implementations§
Source§impl Clone for VariableContext
impl Clone for VariableContext
Source§fn clone(&self) -> VariableContext
fn clone(&self) -> VariableContext
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 moreAuto Trait Implementations§
impl Freeze for VariableContext
impl RefUnwindSafe for VariableContext
impl Send for VariableContext
impl Sync for VariableContext
impl Unpin for VariableContext
impl UnwindSafe for VariableContext
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