duskos

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

commit da8a77a17bd3e28d40a5ea34c75137acfc09cabb
parent 7ddac090d31a00d3c9f1902a3088b3bd2311da68
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun, 26 Mar 2023 13:00:51 -0400

halcc: replace Result :<<n and :>>n with :*n and :/n

Didn't I remember that I would hit that same roadblock when structures would
come around? Fool me once...

Diffstat:
Mfs/comp/c/egen.fs | 9++++-----
Mfs/comp/c/expr.fs | 8++++----
2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/fs/comp/c/egen.fs b/fs/comp/c/egen.fs @@ -1,6 +1,5 @@ \ Expression code generation require /sys/scratch.fs -?f<< /lib/math.fs ?f<< /comp/c/tok.fs ?f<< /comp/c/glob.fs ?f<< /comp/c/expr.fs @@ -38,7 +37,7 @@ unaryop _!, _ not : _*, dup Result :* ; : _ ( res incsz -- res ) - over Result :*arisz log2 lshift + over Result :*arisz * over Result :isW? if W+n, else over Result :hal# [+n], then ; : _++, 1 _ ; : _--, -1 _ ; @@ -54,7 +53,7 @@ UOPSCNT wordtbl uoptbl ( res -- res ) : _+, ( left right -- res ) over Result :*arisz over Result :*arisz <> if over Result :*arisz 1 = if swap then \ left has mutiplier - over Result :*arisz log2 over Result :<<n ( left right*arisz ) + over Result :*arisz over Result :*n ( left right*arisz ) over >r _prep +, r> over Result :copymeta else _prep +, then ; @@ -65,7 +64,7 @@ UOPSCNT wordtbl uoptbl ( res -- res ) : _-, ( left right -- res ) over Result :*arisz over Result :*arisz over = _assert ( left right arisz ) - >r _prep -, r> log2 ?dup if over Result :>>n then dup Result :toint ; + >r _prep -, r> ?dup if over Result :/n then dup Result :toint ; : assign doer ' , does> @ ( left right w ) >r over Result :hal# rot> r> execute ( lefthal res ) swap !, ; @@ -128,7 +127,7 @@ code _callA branchA, CDecl type if PS+ Result :W else Result :none then ; : _incdec, ( res incsz -- res ) - over Result :*arisz log2 lshift + over Result :*arisz * swap bi+ Result :hal# | Result :?>W ( incsz res halop ) rot swap [+n], ; \ parses, if possible, a postfix operator. If none, this is a noop. diff --git a/fs/comp/c/expr.fs b/fs/comp/c/expr.fs @@ -100,12 +100,12 @@ struct[ Result dup :isW? if :release W>A, A*) else :hal# then ; : :* ( self -- ) 1 over to+ lvl dup :isW? if W) swap :opsz @, else drop then ; - : :<<n ( n self -- ) + : :*n ( n self -- ) dup :isconst? if - dup arg rot lshift swap to arg else :?>W i) <<, then ; - : :>>n ( n self -- ) + dup arg rot * swap to arg else :?>W i) *, then ; + : :/n ( n self -- ) dup :isconst? if - dup arg rot rshift swap to arg else :?>W i) >>, then ; + dup arg rot / swap to arg else :?>W i) /, then ; \ For pointer arithmetics, we apply the "bottom level" logic one level higher. \ That is, when lvl=blvl, our "arisz" is 1 (regular arithmetics), when \ lvl=blvl+1, our arisz is "basesz" (we add and subtract by chunks of the