-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare block machine processor (#2231)
A few preparations for #2226: - Extracted a `test_utils` module - Introduced a new `Variable` type, which can refer to either a cell or a "parameter" (either input or output of a machine call). I think in the future, we could have more variants (e.g. scalar publics). `Variable` is now used instead of `Cell` in `WitgenInference`. - `WitgenInference::process_identity` now also returns whether any progress has been made. - Renamed `lookup` -> `machine_call` when rendering `Effect`s
- Loading branch information
1 parent
19a9457
commit d007b8f
Showing
4 changed files
with
186 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
pub(crate) mod affine_symbolic_expression; | ||
mod cell; | ||
pub(crate) mod jit_processor; | ||
mod symbolic_expression; | ||
mod variable; | ||
pub(crate) mod witgen_inference; | ||
|
||
#[cfg(test)] | ||
pub(crate) mod test_util; |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use itertools::Itertools; | ||
use powdr_number::GoldilocksField; | ||
|
||
use crate::witgen::jit::affine_symbolic_expression::MachineCallArgument; | ||
|
||
use super::{ | ||
affine_symbolic_expression::{Assertion, Effect}, | ||
variable::Variable, | ||
}; | ||
|
||
pub fn format_code(effects: &[Effect<GoldilocksField, Variable>]) -> String { | ||
effects | ||
.iter() | ||
.map(|effect| match effect { | ||
Effect::Assignment(v, expr) => format!("{v} = {expr};"), | ||
Effect::Assertion(Assertion { | ||
lhs, | ||
rhs, | ||
expected_equal, | ||
}) => { | ||
format!( | ||
"assert {lhs} {} {rhs};", | ||
if *expected_equal { "==" } else { "!=" } | ||
) | ||
} | ||
Effect::MachineCall(id, args) => { | ||
format!( | ||
"machine_call({id}, [{}]);", | ||
args.iter() | ||
.map(|arg| match arg { | ||
MachineCallArgument::Known(k) => format!("Known({k})"), | ||
MachineCallArgument::Unknown(u) => format!("Unknown({u})"), | ||
}) | ||
.join(", ") | ||
) | ||
} | ||
Effect::RangeConstraint(..) => { | ||
panic!("Range constraints should not be part of the code.") | ||
} | ||
}) | ||
.join("\n") | ||
} |
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
Oops, something went wrong.