Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
Submodel
, and refactorModel
to be a wrapper overSubmodel
.This commit is part of on-going work to add lexical scope to Conjure
Oxide and is a follow up to 8636432 (feat!: add parent symbol tables
(#680), 2025-02-17).
DETAILS
A
Submodel
represents a particular scope and holds the symbol-tableand constraints tree for that scope.
This commit refactors
Model
to be a wrapper overSubmodel
, andremoves methods operating on constraints and the symbol table from
Model
, placing them inSubmodel
instead. AModel
can be borrowed asa
Submodel
usingas_submodel()
andas_submodel_mut()
.The language semantics of a top level model and a sub-model are
identical, so treating it as
Submodel
in most cases is valid.Model
is a separate type thanSubmodel
for the following reasons:It will hold global-only information in the future, such as dominance
constraints.
It holds a pointer to the context.
We need special initialisation and de-serialisation logic for the
top level model that we do not want for
Submodel
. SeeSerdeModel
.