Skip to content

Commit

Permalink
document invariants
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed Mar 5, 2024
1 parent 45dd882 commit ea65848
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/run/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ impl<'a, M: Mode> Net<'a, M> {
/// [`Def`]s, when not pre-compiled, are represented as lists of instructions.
#[derive(Debug, Default, Clone)]
pub struct InterpretedDef {
pub instr: Vec<Instruction>,
pub trgs: usize,
pub(crate) instr: Vec<Instruction>,
/// The number of targets used in the def; must be greater than all of the
/// `TrgId` indices in `instr`.
pub(crate) trgs: usize,
}

impl AsDef for InterpretedDef {
Expand All @@ -214,6 +216,12 @@ impl AsDef for InterpretedDef {

let mut trgs = Trgs(&mut net.trgs[..] as *mut _ as *mut _);

/// Points to an array of `Trg`s of length at least `def.trgs`. The `Trg`s
/// may not all be initialized.
///
/// Only `TrgId`s with index less than `def.trgs` may be passed to `get_trg`
/// and `set_trg`, and `get_trg` can only be called after `set_trg` was
/// called with the same `TrgId`.
struct Trgs(*mut Trg);

impl Trgs {
Expand Down

0 comments on commit ea65848

Please sign in to comment.