diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-12 02:19:23 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-12 02:19:23 +0300 |
| commit | e1f17535a043b55ce34de4d7583928d8c94bb71a (patch) | |
| tree | 256299aeb970730e56a48e6ad72ac82e848a14d1 /tests/struct_call.ek | |
| parent | 7294673a9889f968eef86930d4e09f47070439fc (diff) | |
| download | ek-e1f17535a043b55ce34de4d7583928d8c94bb71a.tar.gz ek-e1f17535a043b55ce34de4d7583928d8c94bb71a.zip | |
start work on struct handling
Diffstat (limited to 'tests/struct_call.ek')
| -rw-r--r-- | tests/struct_call.ek | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/struct_call.ek b/tests/struct_call.ek new file mode 100644 index 0000000..d73dfb1 --- /dev/null +++ b/tests/struct_call.ek @@ -0,0 +1,37 @@ +typedef i27 {} +typedef i9 {} + +typedef int_pair { + i27 a; + i27 b; +} + +extern putchar(i9 c); + +add_int_pair(int_pair a, int_pair b => int_pair) +{ + return int_pair!{.a = a.a + b.a, .b = a.b + b.b}; +} + +add_int_pair_self(*int_pair a, *int_pair b) +{ + a*.a = a*.a + b*.a; + a*.b = a*.b + b*.b; +} + +main() +{ + mut a = int_pair!{.a = 1, .b = 2}; + mut b = int_pair!{.a = 3, .b = 4}; + + mut n = add_int_pair(a, b); + putchar('0' + n.a as i9); + putchar('0' + n.b as i9); + + add_int_pair_self(a&, b&); + + putchar('0' + a.a as i9); + putchar('0' + a.b as i9); + putchar('0' + b.a as i9); + putchar('0' + b.b as i9); +} |
