mirror of
https://github.com/nineties/planckforth
synced 2024-12-27 21:58:35 +01:00
Add operations for defining struct
This commit is contained in:
parent
ca8f5a191f
commit
f20138a855
1 changed files with 21 additions and 0 deletions
21
bootstrap.fs
21
bootstrap.fs
|
@ -1301,3 +1301,24 @@ main
|
||||||
cell- dup @ .
|
cell- dup @ .
|
||||||
repeat 2drop
|
repeat 2drop
|
||||||
;
|
;
|
||||||
|
|
||||||
|
( === Data Structure === )
|
||||||
|
|
||||||
|
: struct ( -- offset )
|
||||||
|
0
|
||||||
|
;
|
||||||
|
: end-struct ( offset "name" -- )
|
||||||
|
constant
|
||||||
|
;
|
||||||
|
|
||||||
|
: cell% ( offset1 -- offset2 size ) aligned cell ;
|
||||||
|
: char% ( offset1 -- offset2 size ) 1 ;
|
||||||
|
: chars% ( offset1 n -- offset2 size ) ;
|
||||||
|
: cells% ( offset1 n -- offset2 size ) swap aligned swap cells ;
|
||||||
|
|
||||||
|
: field ( offset1 size2 "name" -- offset2 )
|
||||||
|
create
|
||||||
|
over , \ fill offset
|
||||||
|
+ \ return new offset
|
||||||
|
does> @ +
|
||||||
|
;
|
||||||
|
|
Loading…
Reference in a new issue