Implemented reading from struct fields
This commit is contained in:
@ -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)
|
||||
}
|
Reference in New Issue
Block a user