forked from privacy-scaling-explorations/zkevm-circuits
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Operation & Refactor OperationRef
- OperationRef has been converted to a usize which points to the position of the Operation it references inside of the `OperationContainer`. - Implemented associated unchecked downcasting fns for `Operation` as is the only way to get the internal specific typed object from the enum without adding `TryFrom` impls which would include a bunch of error management.
- Loading branch information
Showing
2 changed files
with
138 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
use super::OperationRef; | ||
use super::{container::OperationContainer, Operation, OperationRef}; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
pub(crate) struct BusMappingInstance<'a> { | ||
memory: Vec<OperationRef<'a>>, | ||
stack: Vec<OperationRef<'a>>, | ||
storage: Vec<OperationRef<'a>>, | ||
} | ||
pub(crate) struct BusMappingInstance(pub(crate) Vec<OperationRef>); | ||
|
||
// XXX: Impl Index for BusMappingInstance | ||
|
||
impl BusMappingInstance { | ||
pub const fn new() -> BusMappingInstance { | ||
BusMappingInstance(Vec::new()) | ||
} | ||
|
||
impl<'a> BusMappingInstance<'a> { | ||
pub const fn new() -> BusMappingInstance<'a> { | ||
BusMappingInstance { | ||
memory: Vec::new(), | ||
stack: Vec::new(), | ||
storage: Vec::new(), | ||
} | ||
pub fn insert(&mut self, op: OperationRef) { | ||
self.0.push(op) | ||
} | ||
|
||
pub fn insert(&mut self, op: OperationRef<'a>) { | ||
match op { | ||
OperationRef::Memory(_) => self.memory.push(op), | ||
OperationRef::Stack(_) => self.stack.push(op), | ||
OperationRef::Storage(_) => self.storage.push(op), | ||
} | ||
pub fn register_and_insert( | ||
&mut self, | ||
container: &mut OperationContainer, | ||
op: impl Into<Operation>, | ||
) { | ||
self.insert(container.insert(op)) | ||
} | ||
} |