pub struct SubModel { /* private fields */ }
Expand description
A sub-model, representing a lexical scope in the model.
Each sub-model contains a symbol table representing its scope, as well as a expression tree.
The expression tree is formed of a root node of type Expression::Root
, which contains a
vector of top-level constraints.
Implementations§
Source§impl SubModel
impl SubModel
Sourcepub fn new(parent: Rc<RefCell<SymbolTable>>) -> SubModel
pub fn new(parent: Rc<RefCell<SymbolTable>>) -> SubModel
Creates a new [Submodel
] as a child scope of parent
.
parent
should be the symbol table of the containing scope of this sub-model.
Sourcepub fn symbols_ptr_unchecked(&self) -> &Rc<RefCell<SymbolTable>>
pub fn symbols_ptr_unchecked(&self) -> &Rc<RefCell<SymbolTable>>
The symbol table for this sub-model as a pointer.
The caller should only mutate the returned symbol table if this method was called on a mutable model.
Sourcepub fn symbols(&self) -> Ref<'_, SymbolTable>
pub fn symbols(&self) -> Ref<'_, SymbolTable>
The symbol table for this sub-model as a reference.
Sourcepub fn symbols_mut(&mut self) -> RefMut<'_, SymbolTable>
pub fn symbols_mut(&mut self) -> RefMut<'_, SymbolTable>
The symbol table for this sub-model as a mutable reference.
Sourcepub fn root(&self) -> &Expression
pub fn root(&self) -> &Expression
The root node of this sub-model.
The root node is an Expression::Root
containing a vector of the top level constraints
in this sub-model.
Sourcepub fn replace_root(&mut self, new_root: Expression) -> Expression
pub fn replace_root(&mut self, new_root: Expression) -> Expression
Replaces the root node with new_root
, returning the old root node.
§Panics
- If
new_root
is not anExpression::Root
.
Sourcepub fn constraints(&self) -> &Vec<Expression>
pub fn constraints(&self) -> &Vec<Expression>
The top-level constraints in this sub-model.
Sourcepub fn constraints_mut(&mut self) -> &mut Vec<Expression>
pub fn constraints_mut(&mut self) -> &mut Vec<Expression>
The top-level constraints in this sub-model as a mutable vector.
Sourcepub fn replace_constraints(
&mut self,
new_constraints: Vec<Expression>,
) -> Vec<Expression>
pub fn replace_constraints( &mut self, new_constraints: Vec<Expression>, ) -> Vec<Expression>
Replaces the top-level constraints with new_constraints
, returning the old ones.
Sourcepub fn add_constraint(&mut self, constraint: Expression)
pub fn add_constraint(&mut self, constraint: Expression)
Adds a top-level constraint.
Sourcepub fn add_constraints(&mut self, constraints: Vec<Expression>)
pub fn add_constraints(&mut self, constraints: Vec<Expression>)
Adds top-level constraints.
Sourcepub fn add_symbol(&mut self, sym: Declaration) -> Option<()>
pub fn add_symbol(&mut self, sym: Declaration) -> Option<()>
Adds a new symbol to the symbol table
(Wrapper over SymbolTable.insert
)
Trait Implementations§
Source§impl Biplate<Expression> for SubModel
impl Biplate<Expression> for SubModel
Source§fn biplate(
&self,
) -> (Tree<Expression>, Box<dyn Fn(Tree<Expression>) -> SubModel>)
fn biplate( &self, ) -> (Tree<Expression>, Box<dyn Fn(Tree<Expression>) -> SubModel>)
§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 Expression
impl Biplate<SubModel> for Expression
Source§fn biplate(&self) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> Expression>)
fn biplate(&self) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> Expression>)
§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 Model
impl Biplate<SubModel> for Model
Source§fn biplate(&self) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> Model>)
fn biplate(&self) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> Model>)
§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 SubModel
impl Biplate<SubModel> for SubModel
Source§fn biplate(&self) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> SubModel>)
fn biplate(&self) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> SubModel>)
§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<'de> Deserialize<'de> for SubModel
impl<'de> Deserialize<'de> for SubModel
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SubModel, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SubModel, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for SubModel
impl Serialize for SubModel
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 Typeable for SubModel
impl Typeable for SubModel
fn return_type(&self) -> Option<ReturnType>
Source§impl Uniplate for SubModel
impl Uniplate for SubModel
Source§fn uniplate(&self) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> SubModel>)
fn uniplate(&self) -> (Tree<SubModel>, Box<dyn Fn(Tree<SubModel>) -> SubModel>)
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 SubModel
impl StructuralPartialEq for SubModel
Auto Trait Implementations§
impl Freeze for SubModel
impl !RefUnwindSafe for SubModel
impl !Send for SubModel
impl !Sync for SubModel
impl Unpin for SubModel
impl !UnwindSafe for SubModel
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