Separate Overlay into its own thing (#344)

It's no longer attached to a Block. Makes access to overlays more
streamlined by removing this one indirection. Also makes it easier to
create standalone overlays without a block which might come in handy.
This commit is contained in:
Jakub Žádník
2021-11-17 06:23:55 +02:00
committed by GitHub
parent b35914bd17
commit f8f437b060
6 changed files with 78 additions and 57 deletions

View File

@@ -1,6 +1,6 @@
use std::ops::{Index, IndexMut};
use crate::{Overlay, Signature, VarId};
use crate::{Signature, VarId};
use super::Statement;
@@ -8,7 +8,6 @@ use super::Statement;
pub struct Block {
pub signature: Box<Signature>,
pub stmts: Vec<Statement>,
pub overlay: Overlay,
pub captures: Vec<VarId>,
}
@@ -47,19 +46,9 @@ impl Block {
Self {
signature: Box::new(Signature::new("")),
stmts: vec![],
overlay: Overlay::new(),
captures: vec![],
}
}
pub fn with_overlay(self, overlay: Overlay) -> Self {
Self {
signature: self.signature,
stmts: self.stmts,
overlay,
captures: self.captures,
}
}
}
impl<T> From<T> for Block
@@ -70,7 +59,6 @@ where
Self {
signature: Box::new(Signature::new("")),
stmts: stmts.collect(),
overlay: Overlay::new(),
captures: vec![],
}
}