-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Brillig array inputs and outputs (#1630)
* first attempt at brillig multiple array inptus * working array identity function for brillig * cleanup dbgs * remove unused imports * remove dbg * a little cleanup * fix up foreign calls for array inputs and outputs * fix outputs clippy err * move conversion to RegisterValueOrArray to its own method * missing &mut and TODO link * PR comment for brillig output array types * cleanup comment * enable struct inputs/outputs * cargo clippy
- Loading branch information
Showing
9 changed files
with
189 additions
and
53 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
25 changes: 25 additions & 0 deletions
25
crates/nargo_cli/tests/test_data_ssa_refactor/brillig_identity_function/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 |
---|---|---|
@@ -1,10 +1,35 @@ | ||
use dep::std; | ||
|
||
struct myStruct { | ||
foo: Field, | ||
foo_arr: [Field; 2], | ||
} | ||
|
||
// Tests a very simple program. | ||
// | ||
// The features being tested is the identity function in Brillig | ||
fn main(x : Field) { | ||
assert(x == identity(x)); | ||
// TODO: add support for array comparison | ||
let arr = identity_array([x, x]); | ||
assert(x == arr[0]); | ||
assert(x == arr[1]); | ||
|
||
let s = myStruct { foo: x, foo_arr: [x, x] }; | ||
let identity_struct = identity_struct(s); | ||
assert(x == identity_struct.foo); | ||
assert(x == identity_struct.foo_arr[0]); | ||
assert(x == identity_struct.foo_arr[1]); | ||
} | ||
|
||
unconstrained fn identity(x : Field) -> Field { | ||
x | ||
} | ||
|
||
unconstrained fn identity_array(arr : [Field; 2]) -> [Field; 2] { | ||
arr | ||
} | ||
|
||
unconstrained fn identity_struct(s : myStruct) -> myStruct { | ||
s | ||
} |
1 change: 1 addition & 0 deletions
1
crates/nargo_cli/tests/test_data_ssa_refactor/brillig_identity_function/target/c.json
Large diffs are not rendered by default.
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
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.