duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit abcdbcc66def1957b1b7679a3acc79e49838ab60
parent 44289836342d28ea01f13a439adc6a48675cc82f
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Fri, 31 Mar 2023 14:58:20 -0400

halcc: consolidate

Diffstat:
Mfs/comp/c/expr.fs | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/comp/c/expr.fs b/fs/comp/c/expr.fs @@ -6,6 +6,8 @@ : _err ( -- ) tokdbg abort" expr error" ; : _assert ( f -- ) not if _err then ; +NULLSTR TYPE_UINT CDecl :new const UintCDecl + struct[ Result 0 const NONE \ Nothing (probably a released W) 1 const CONST \ Is a constant (value in arg) @@ -27,7 +29,7 @@ struct[ Result 0 value currentW \ link to Result : :Wfree# currentW if abort" W is already taken!" then ; - : :new ( arg type -- res ) SZ syspad :[ , , 0 , 0 , 0 , syspad :] ; + : :new ( arg type -- res ) SZ syspad :[ , , 0 , UintCDecl , 0 , syspad :] ; : :none ( -- res ) 0 NONE :new ; : :const ( n -- res ) CONST :new ; : :W ( -- res ) :Wfree# 0 W :new dup to currentW ; @@ -44,8 +46,7 @@ struct[ Result dup type _ + c@ emit spc> dup arg .x spc> dup target ?dup if '{' emit _:. '}' emit spc> then - dup cdecl ?dup if CDecl :. spc> then - dup lvl . spc> ." W=" currentW bool . ; + dup cdecl CDecl :. spc> lvl . spc> ." W=" currentW bool . ; : :. _:. nl> ; : :W! ( self -- ) dup to currentW W swap to type ; \ Copy meta information (basesz, lvl from "other" result @@ -55,13 +56,14 @@ struct[ Result : :& ( self -- res ) dup :iscdecl? _assert 0 REF :new 2dup :copymeta tuck to target ; : :* ( self -- res ) - 0 DEREF :new 2dup :copymeta tuck to target -1 over to+ lvl ; + 0 DEREF :new 2dup :copymeta tuck to target -1 over to+ lvl + dup lvl 0>= _assert ; : :cdecl ( cdecl -- res ) 0 CDECL :new ( cdecl res ) over CDecl :lvl over to lvl tuck to cdecl ; - : :basesz cdecl ?dup if CDecl type typesize else 4 then ; - : :unsigned? cdecl ?dup if typeunsigned? else 1 then ; + : :basesz cdecl CDecl type typesize ; + : :unsigned? cdecl typeunsigned? ; : :cdecl# dup :iscdecl? _assert cdecl ; : :nb) ( halop self -- halop ) dup lvl if drop else :basesz nb) then ; \ Never changes W, never pushes to PS