-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for nested arrays on brillig gen (#2029)
* feat: support for nested arrays inside brillig * refactor: extract entry point management to a mod * feat: add flatten/deflatten to brillig entrypoint * style: remove unused import * perf: deallocate registers on entrypoint * style: improve error message
- Loading branch information
1 parent
2d87c87
commit 8adc57c
Showing
12 changed files
with
654 additions
and
293 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
crates/nargo_cli/tests/test_data_ssa_refactor/brillig_nested_arrays/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.6.0" | ||
|
||
[dependencies] |
2 changes: 2 additions & 0 deletions
2
crates/nargo_cli/tests/test_data_ssa_refactor/brillig_nested_arrays/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,2 @@ | ||
x = "0" | ||
y = "1" |
30 changes: 30 additions & 0 deletions
30
crates/nargo_cli/tests/test_data_ssa_refactor/brillig_nested_arrays/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,30 @@ | ||
struct Header { | ||
params: [Field; 3], | ||
} | ||
|
||
struct MyNote { | ||
plain: Field, | ||
array: [Field; 2], | ||
header: Header, | ||
} | ||
|
||
unconstrained fn access_nested(notes: [MyNote; 2], x: Field, y: Field) -> Field { | ||
notes[x].array[y] + notes[y].array[x] + notes[x].plain + notes[y].header.params[x] | ||
} | ||
|
||
unconstrained fn create_inside_brillig(x: Field, y: Field) { | ||
let header = Header { params: [1, 2, 3]}; | ||
let note0 = MyNote { array: [1, 2], plain : 3, header }; | ||
let note1 = MyNote { array: [4, 5], plain : 6, header }; | ||
assert(access_nested([note0, note1], x, y) == (2 + 4 + 3 + 1)); | ||
} | ||
|
||
fn main(x: Field, y: Field) { | ||
let header = Header { params: [1, 2, 3]}; | ||
let note0 = MyNote { array: [1, 2], plain : 3, header }; | ||
let note1 = MyNote { array: [4, 5], plain : 6, header }; | ||
|
||
create_inside_brillig(x, y); | ||
assert(access_nested([note0, note1], x, y) == (2 + 4 + 3 + 1)); | ||
} | ||
|
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.