Implemented struct pointer types

This commit is contained in:
Eduard Urbach 2025-02-05 15:16:00 +01:00
parent f7bc903aa4
commit f76f0a1e4b
Signed by: eduard
GPG key ID: 49226B848C78F6C8
17 changed files with 190 additions and 102 deletions

View file

@ -7,10 +7,19 @@ struct Point {
}
main() {
p := construct()
print(p)
delete(p)
}
construct() -> *Point {
p := new(Point)
p.x = 1
p.y = 2
return p
}
print(p *Point) {
out := mem.alloc(8)
out[0] = 'x'
out[1] = ' '
@ -21,7 +30,5 @@ main() {
out[6] = '0' + p.y
out[7] = '\n'
sys.write(1, out, 8)
mem.free(out)
delete(p)
mem.free(out, 8)
}