Fix bug in structures that don't use TYPER sizes.

Thanks Frank!
This commit is contained in:
Brad Nelson
2023-07-07 16:16:00 -07:00
parent a5f9ca1b35
commit 998d619355
3 changed files with 17 additions and 2 deletions

View File

@ -28,7 +28,8 @@ long-size long-size typer long
variable last-struct
: struct ( "name" ) 1 0 typer latestxt >body last-struct ! ;
: struct ( "name" ) 1 0 typer latestxt >body last-struct !
1 last-align ! ;
: align-by ( a n -- a ) 1- dup >r + r> invert and ;
: struct-align ( n -- )
dup last-struct @ cell+ @ max last-struct @ cell+ !

View File

@ -46,3 +46,17 @@ e: test-nested-structure
1000 ->bar ->right 1012 =assert
1000 ->bar ->bottom 1016 =assert
;e
e: test-forth-structure
also structures
0 last-align !
struct foo
1 field t1
4 field t2
9 field t3
12 field t4
0 t1 0 =assert
0 t2 1 =assert
0 t3 5 =assert
0 t4 14 =assert
;e