-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into e/ssa_error
- Loading branch information
Showing
15 changed files
with
184 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
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
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
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,29 +1,36 @@ | ||
use std::collections::BTreeMap; | ||
|
||
use acvm::acir::native_types::Witness; | ||
use iter_extended::{btree_map, vecmap}; | ||
use iter_extended::btree_map; | ||
use noirc_abi::{Abi, AbiParameter, FunctionSignature}; | ||
|
||
/// Arranges a function signature and a generated circuit's return witnesses into a | ||
/// `noirc_abi::Abi`. | ||
pub(crate) fn gen_abi(func_sig: FunctionSignature, return_witnesses: Vec<Witness>) -> Abi { | ||
pub(crate) fn gen_abi( | ||
func_sig: FunctionSignature, | ||
input_witnesses: &[Witness], | ||
return_witnesses: Vec<Witness>, | ||
) -> Abi { | ||
let (parameters, return_type) = func_sig; | ||
let param_witnesses = param_witnesses_from_abi_param(¶meters); | ||
let param_witnesses = param_witnesses_from_abi_param(¶meters, input_witnesses); | ||
Abi { parameters, return_type, param_witnesses, return_witnesses } | ||
} | ||
|
||
// Takes each abi parameter and shallowly maps to the expected witness range in which the | ||
// parameter's constituent values live. | ||
fn param_witnesses_from_abi_param( | ||
abi_params: &Vec<AbiParameter>, | ||
input_witnesses: &[Witness], | ||
) -> BTreeMap<String, Vec<Witness>> { | ||
let mut offset = 1; | ||
let mut idx = 0_usize; | ||
|
||
btree_map(abi_params, |param| { | ||
let num_field_elements_needed = param.typ.field_count(); | ||
let idx_start = offset; | ||
let idx_end = idx_start + num_field_elements_needed; | ||
let witnesses = vecmap(idx_start..idx_end, Witness); | ||
offset += num_field_elements_needed; | ||
(param.name.clone(), witnesses) | ||
let mut wit = Vec::new(); | ||
for _ in 0..num_field_elements_needed { | ||
wit.push(input_witnesses[idx]); | ||
idx += 1; | ||
} | ||
(param.name.clone(), wit) | ||
}) | ||
} |
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
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
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
Oops, something went wrong.