Implemented struct pointer types
This commit is contained in:
parent
f7bc903aa4
commit
f76f0a1e4b
17 changed files with 190 additions and 102 deletions
|
@ -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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue