-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #448 from Zokrates/structs
Implement structures
- Loading branch information
Showing
38 changed files
with
4,734 additions
and
1,272 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
struct Point { | ||
field x | ||
field y | ||
} | ||
|
||
def main(field a) -> (Point): | ||
Point p = Point {x: 1, y: 0} | ||
p.x = a | ||
p.y = p.x | ||
return p |
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,8 @@ | ||
struct Point { | ||
field x | ||
field y | ||
} | ||
|
||
def main() -> (Point): | ||
Point p = Point {x: 1, y: 0} | ||
return p |
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,14 @@ | ||
struct Bar { | ||
field[2] c | ||
bool d | ||
} | ||
|
||
struct Foo { | ||
Bar a | ||
bool b | ||
} | ||
|
||
def main() -> (Foo): | ||
Foo[2] f = [Foo { a: Bar { c: [0, 0], d: false }, b: true}, Foo { a: Bar {c: [0, 0], d: false}, b: true}] | ||
f[0].a.c = [42, 43] | ||
return f[0] |
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,16 @@ | ||
struct Point { | ||
field x | ||
field y | ||
} | ||
|
||
def main(Point p, Point q) -> (Point): | ||
|
||
field a = 42 | ||
field d = 21 | ||
|
||
field dpxpyqxqy = d * p.x * p.y * q.x * q.y | ||
|
||
return Point { | ||
x: (p.x * q.y + q.x * p.y) / (1 + dpxpyqxqy), | ||
y: (q.x * q.y - a * p.x * p.y) / (1 - dpxpyqxqy) | ||
} |
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,29 @@ | ||
struct Bar { | ||
field[2] c | ||
bool d | ||
} | ||
|
||
struct Foo { | ||
Bar a | ||
bool b | ||
} | ||
|
||
def main() -> (Foo): | ||
Foo[2] f = [ | ||
Foo { | ||
a: Bar { | ||
c: [0, 0], | ||
d: false | ||
}, | ||
b: true | ||
}, | ||
Foo { | ||
a: Bar { | ||
c: [0, 0], | ||
d: false | ||
}, | ||
b: true | ||
} | ||
] | ||
f[0].a.c = [42, 43] | ||
return f[0] |
Oops, something went wrong.