pub struct ConstantPropagationTable {
pub(crate) parent: Option<Box<ConstantPropagationTable>>,
pub(crate) constants: IndexMap<Symbol, Expression>,
pub(crate) scope_index: usize,
pub(crate) scopes: Vec<RefCell<ConstantPropagationTable>>,
}
Fields§
§parent: Option<Box<ConstantPropagationTable>>
The parent scope if it exists. For example, the parent scope of a then-block is the scope containing the associated ConditionalStatement.
constants: IndexMap<Symbol, Expression>
The known constants in the current scope This field is populated as necessary.
scope_index: usize
The index of the current scope.
scopes: Vec<RefCell<ConstantPropagationTable>>
The sub-scopes of this scope.
Implementations§
source§impl ConstantPropagationTable
impl ConstantPropagationTable
sourcepub fn scope_index(&mut self) -> usize
pub fn scope_index(&mut self) -> usize
Returns the current scope index. Increments the scope index.
sourcepub fn insert_constant(
&mut self,
symbol: Symbol,
expr: Expression,
) -> Result<()>
pub fn insert_constant( &mut self, symbol: Symbol, expr: Expression, ) -> Result<()>
Inserts a constant into the constant propagation table.
sourcepub fn insert_block(&mut self) -> usize
pub fn insert_block(&mut self) -> usize
Creates a new scope for the block and stores it in the constant propagation table.
sourcepub fn lookup_constant(&self, symbol: Symbol) -> Option<&Expression>
pub fn lookup_constant(&self, symbol: Symbol) -> Option<&Expression>
Attempts to lookup a constant in the constant propagation table.
sourcepub fn constant_in_local_scope(&self, symbol: Symbol) -> bool
pub fn constant_in_local_scope(&self, symbol: Symbol) -> bool
Returns true if the constant exists in the local scope
sourcepub fn constant_in_parent_scope(&self, symbol: Symbol) -> bool
pub fn constant_in_parent_scope(&self, symbol: Symbol) -> bool
Returns true if the constant exists in any parent scope
sourcepub fn lookup_scope_by_index(&self, index: usize) -> Option<&RefCell<Self>>
pub fn lookup_scope_by_index(&self, index: usize) -> Option<&RefCell<Self>>
Returns the scope associated with index
, if it exists in the constant propagation table
Trait Implementations§
source§impl Clone for ConstantPropagationTable
impl Clone for ConstantPropagationTable
source§fn clone(&self) -> ConstantPropagationTable
fn clone(&self) -> ConstantPropagationTable
Returns a copy 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 ConstantPropagationTable
impl Debug for ConstantPropagationTable
source§impl Default for ConstantPropagationTable
impl Default for ConstantPropagationTable
source§fn default() -> ConstantPropagationTable
fn default() -> ConstantPropagationTable
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for ConstantPropagationTable
impl<'de> Deserialize<'de> for ConstantPropagationTable
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ConstantPropagationTable
impl !RefUnwindSafe for ConstantPropagationTable
impl Send for ConstantPropagationTable
impl !Sync for ConstantPropagationTable
impl Unpin for ConstantPropagationTable
impl UnwindSafe for ConstantPropagationTable
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
fn take_from_value<D>(
value: &mut Value,
field: &str,
) -> Result<T, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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