Implemented reading from struct fields

This commit is contained in:
2025-02-04 20:43:15 +01:00
parent 03a3bd8f02
commit bde68d4d64
10 changed files with 112 additions and 15 deletions

View File

@ -1,3 +1,6 @@
import mem
import sys
struct Point {
x Int
y Int
@ -5,7 +8,20 @@ struct Point {
main() {
p := new(Point)
p.x = 4
p.x = 1
p.y = 2
out := mem.alloc(8)
out[0] = 'x'
out[1] = ' '
out[2] = '0' + p.x
out[3] = '\n'
out[4] = 'y'
out[5] = ' '
out[6] = '0' + p.y
out[7] = '\n'
sys.write(1, out, 8)
mem.free(out)
delete(p)
}