Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add Submodel #682

Merged
merged 1 commit into from
Feb 17, 2025
Merged

feat!: add Submodel #682

merged 1 commit into from
Feb 17, 2025

Conversation

niklasdewally
Copy link
Collaborator

@niklasdewally niklasdewally commented Feb 17, 2025

Add Submodel, and refactor Model to be a wrapper over Submodel.

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-table
and constraints tree for that scope.

This commit refactors Model to be a wrapper over Submodel, and
removes methods operating on constraints and the symbol table from
Model, placing them in Submodel instead. A Model can be borrowed as
a Submodel using as_submodel() and as_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 than Submodel 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. See
    SerdeModel.

@niklasdewally niklasdewally marked this pull request as draft February 17, 2025 14:12
@niklasdewally niklasdewally marked this pull request as ready for review February 17, 2025 14:14
Add `Submodel`, and refactor `Model` to be a wrapper over `Submodel`.

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-table
and constraints tree for that scope.

This commit refactors `Model` to be a wrapper over `Submodel`, and
removes methods operating on constraints and the symbol table from
`Model`, placing them in `Submodel` instead. A `Model` can be borrowed as
a `Submodel` using `as_submodel()` and `as_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 than `Submodel` 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`. See
    `SerdeModel`.
@niklasdewally niklasdewally force-pushed the nik/scoping/add-submodel branch from 8ea0b91 to 4149f04 Compare February 17, 2025 14:16
Copy link
Contributor

Code and Documentation Coverage Report

Documentation Coverage

This PR:

conjure_core: 3% with examples, 55% documented -- 8/128/245
conjure_oxide: 0% with examples, 19% documented -- 0/4/36
minion_rs: 30% with examples, 82% documented -- 2/23/112
tree-morph: 42% with examples, 100% documented -- 8/22/22

Main:

conjure_core: 3% with examples, 55% documented -- 8/145/271
conjure_oxide: 0% with examples, 19% documented -- 0/4/36
minion_rs: 30% with examples, 82% documented -- 2/23/112
tree-morph: 42% with examples, 100% documented -- 8/22/22

View full documentation coverage for main, this PR

Code Coverage Summary

This PR: Detailed Report

  functions..: 65.5% (651 of 994 functions)
  branches...: no data found

Main: Detailed Report

  functions..: 65.8% (644 of 979 functions)
  branches...: no data found

Coverage Main & PR Coverage Change

Functions coverage changed by -0.30% and covered lines changed by 7
Branches... coverage: No comparison data available

@niklasdewally niklasdewally merged commit 542c89e into main Feb 17, 2025
14 checks passed
@niklasdewally niklasdewally deleted the nik/scoping/add-submodel branch February 17, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants