-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dynamic arrays for experimental-ssa (#1969)
* dynamic arrays for experimental-ssa * Code review * switch to new acvm and backend * panic on non-homogenous arrays The PR does not supported them. * switch to new backend * update cargo.lock * small cleanup * small cleanup * clippy * remove helper method, doesn't help with readability * small cleanup * small cleanup * typo * Update crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs * small cleanup * clippy * add function comment * documentation * rename AcirArray -> AcirDynamicArray * use helper method for AcirVar -> Witness * use Option for optional values * remove TODO --------- Co-authored-by: kevaundray <kevtheappdev@gmail.com>
- Loading branch information
1 parent
5526c52
commit 08d199a
Showing
8 changed files
with
383 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
5 changes: 5 additions & 0 deletions
5
crates/nargo_cli/tests/test_data_ssa_refactor/array_dynamic/Nargo.toml
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,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
9 changes: 9 additions & 0 deletions
9
crates/nargo_cli/tests/test_data_ssa_refactor/array_dynamic/Prover.toml
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,9 @@ | ||
x = [104, 101, 108, 108, 111] | ||
z = "59" | ||
t = "10" | ||
index = [0,1,2,3,4] | ||
index2 = [0,1,2,3,4] | ||
offset = 1 | ||
sublen = 2 | ||
|
||
|
32 changes: 32 additions & 0 deletions
32
crates/nargo_cli/tests/test_data_ssa_refactor/array_dynamic/src/main.nr
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,32 @@ | ||
|
||
fn main(x: [u32; 5], mut z: u32, t: u32, index: [Field;5], index2: [Field;5], offset: Field, sublen: Field) { | ||
let idx = (z - 5*t - 5) as Field; | ||
//dynamic array test | ||
dyn_array(x, idx, idx - 3); | ||
|
||
//regression for issue 1283 | ||
let mut s = 0; | ||
let x3 = [246,159,32,176,8]; | ||
for i in 0..5 { | ||
s += x3[index[i]]; | ||
} | ||
assert(s!=0); | ||
|
||
if 3 < (sublen as u32) { | ||
assert(index[offset + 3] == index2[3]); | ||
} | ||
} | ||
|
||
fn dyn_array(mut x: [u32; 5], y: Field, z: Field) { | ||
assert(x[y] == 111); | ||
assert(x[z] == 101); | ||
x[z] = 0; | ||
assert(x[y] == 111); | ||
assert(x[1] == 0); | ||
if y as u32 < 10 { | ||
x[y] = x[y] - 2; | ||
} else { | ||
x[y] = 0; | ||
} | ||
assert(x[4] == 109); | ||
} |
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.