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