Implemented struct pointer types

This commit is contained in:
2025-02-05 15:16:00 +01:00
parent 85568949a2
commit 5d38a4980a
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)
}