pub struct SymbolTable { /* private fields */ }
Expand description
The global symbol table, mapping names to their definitions.
Names in the symbol table are unique, including between different types of object stored in the symbol table. For example, you cannot have a letting and decision variable with the same name.
§Symbol Kinds
The symbol table tracks the following types of symbol:
§Decision Variables
find NAME: DOMAIN
See DecisionVariable
.
§Lettings
Lettings define constants, of which there are two types:
-
Constant values:
letting val be A
, where A is anExpression
.A can be any integer, boolean, or matrix expression. A can include references to other lettings, model parameters, and, unlike Savile Row, decision variables.
-
Constant domains:
letting Domain be domain D
, where D is aDomain
.D can include references to other lettings and model parameters, and, unlike Savile Row, decision variables.
Unless otherwise stated, these follow the semantics specified in section 2.2.2 of the Savile Row manual (version 1.9.1 at time of writing).
Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn new() -> SymbolTable
pub fn new() -> SymbolTable
Creates an empty symbol table.
Sourcepub fn with_parent(parent: Rc<RefCell<SymbolTable>>) -> SymbolTable
pub fn with_parent(parent: Rc<RefCell<SymbolTable>>) -> SymbolTable
Creates an empty symbol table with the given parent.
Sourcepub fn lookup_local(&self, name: &Name) -> Option<Rc<Declaration>>
pub fn lookup_local(&self, name: &Name) -> Option<Rc<Declaration>>
Looks up the declaration with the given name in the current scope only.
Returns None
if there is no declaration with that name in the current scope.
Sourcepub fn lookup(&self, name: &Name) -> Option<Rc<Declaration>>
pub fn lookup(&self, name: &Name) -> Option<Rc<Declaration>>
Looks up the declaration with the given name, checking all enclosing scopes.
Returns None
if there is no declaration with that name in scope.
Sourcepub fn insert(&mut self, declaration: Rc<Declaration>) -> Option<()>
pub fn insert(&mut self, declaration: Rc<Declaration>) -> Option<()>
Inserts a declaration into the symbol table.
Returns None
if there is already a symbol with this name in the local scope.
Sourcepub fn update_insert(&mut self, declaration: Rc<Declaration>)
pub fn update_insert(&mut self, declaration: Rc<Declaration>)
Updates or adds a declaration in the immediate local scope.
Sourcepub fn return_type(&self, name: &Name) -> Option<ReturnType>
pub fn return_type(&self, name: &Name) -> Option<ReturnType>
Looks up the return type for name if it has one and is in scope.
Sourcepub fn return_type_local(&self, name: &Name) -> Option<ReturnType>
pub fn return_type_local(&self, name: &Name) -> Option<ReturnType>
Looks up the return type for name if has one and is in the local scope.
Sourcepub fn domain(&self, name: &Name) -> Option<Domain>
pub fn domain(&self, name: &Name) -> Option<Domain>
Looks up the domain of name if it has one and is in scope.
This method can return domain references: if a ground domain is always required, use
SymbolTable::resolve_domain
.
Sourcepub fn resolve_domain(&self, name: &Name) -> Option<Domain>
pub fn resolve_domain(&self, name: &Name) -> Option<Domain>
Looks up the domain of name, resolving domain references to ground domains.
See SymbolTable::domain
.
Sourcepub fn into_iter_local(self) -> LocalIntoIter
pub fn into_iter_local(self) -> LocalIntoIter
Iterates over entries in the local symbol table only.
Sourcepub fn extend(&mut self, other: SymbolTable)
pub fn extend(&mut self, other: SymbolTable)
Extends the symbol table with the given symbol table, updating the gensym counter if necessary.
Sourcepub fn gensym(&self) -> Name
pub fn gensym(&self) -> Name
Returns an arbitrary variable name that is not in the symbol table.
Sourcepub fn parent_mut_unchecked(&mut self) -> &mut Option<Rc<RefCell<SymbolTable>>>
pub fn parent_mut_unchecked(&mut self) -> &mut Option<Rc<RefCell<SymbolTable>>>
Gets the parent of this symbol table as a mutable reference.
This function provides no sanity checks.
Trait Implementations§
Source§impl Biplate<Expression> for SymbolTable
impl Biplate<Expression> for SymbolTable
Source§fn biplate(
&self,
) -> (Tree<Expression>, Box<dyn Fn(Tree<Expression>) -> SymbolTable>)
fn biplate( &self, ) -> (Tree<Expression>, Box<dyn Fn(Tree<Expression>) -> SymbolTable>)
§fn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
§fn descend_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self
fn descend_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self
Uniplate::descend
] Read more§fn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
§fn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
§fn transform_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self
fn transform_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self
Source§impl Biplate<SubModel> for SymbolTable
impl Biplate<SubModel> for SymbolTable
Source§fn biplate(
&self,
) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> SymbolTable>)
fn biplate( &self, ) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> SymbolTable>)
§fn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
§fn descend_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self
fn descend_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self
Uniplate::descend
] Read more§fn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
§fn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
§fn transform_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self
fn transform_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self
Source§impl Clone for SymbolTable
impl Clone for SymbolTable
Source§fn clone(&self) -> SymbolTable
fn clone(&self) -> SymbolTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SymbolTable
impl Debug for SymbolTable
Source§impl Default for SymbolTable
impl Default for SymbolTable
Source§fn default() -> SymbolTable
fn default() -> SymbolTable
Source§impl DefaultWithId for SymbolTable
impl DefaultWithId for SymbolTable
Source§fn default_with_id(id: u32) -> SymbolTable
fn default_with_id(id: u32) -> SymbolTable
T
, but with the given id.Source§impl<'de> Deserialize<'de> for SymbolTable
impl<'de> Deserialize<'de> for SymbolTable
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SymbolTable, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SymbolTable, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl IntoIterator for SymbolTable
impl IntoIterator for SymbolTable
Source§fn into_iter(self) -> <SymbolTable as IntoIterator>::IntoIter
fn into_iter(self) -> <SymbolTable as IntoIterator>::IntoIter
Iterates over symbol table entries in scope.
Source§impl PartialEq for SymbolTable
impl PartialEq for SymbolTable
Source§impl Serialize for SymbolTable
impl Serialize for SymbolTable
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl Uniplate for SymbolTable
impl Uniplate for SymbolTable
Source§fn uniplate(
&self,
) -> (Tree<SymbolTable>, Box<dyn Fn(Tree<SymbolTable>) -> SymbolTable>)
fn uniplate( &self, ) -> (Tree<SymbolTable>, Box<dyn Fn(Tree<SymbolTable>) -> SymbolTable>)
Uniplate
. Read more§fn descend(&self, op: Arc<dyn Fn(Self) -> Self>) -> Self
fn descend(&self, op: Arc<dyn Fn(Self) -> Self>) -> Self
§fn universe(&self) -> VecDeque<Self>
fn universe(&self) -> VecDeque<Self>
§fn with_children(&self, children: VecDeque<Self>) -> Self
fn with_children(&self, children: VecDeque<Self>) -> Self
§fn transform(&self, f: Arc<dyn Fn(Self) -> Self>) -> Self
fn transform(&self, f: Arc<dyn Fn(Self) -> Self>) -> Self
§fn rewrite(&self, f: Arc<dyn Fn(Self) -> Option<Self>>) -> Self
fn rewrite(&self, f: Arc<dyn Fn(Self) -> Option<Self>>) -> Self
§fn cata<T>(&self, op: Arc<dyn Fn(Self, VecDeque<T>) -> T>) -> T
fn cata<T>(&self, op: Arc<dyn Fn(Self, VecDeque<T>) -> T>) -> T
impl Eq for SymbolTable
Auto Trait Implementations§
impl !Freeze for SymbolTable
impl !RefUnwindSafe for SymbolTable
impl !Send for SymbolTable
impl !Sync for SymbolTable
impl Unpin for SymbolTable
impl !UnwindSafe for SymbolTable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§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>
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>
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