duskos

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

commit ad2695b2628cb5ca89dabea6d94680593bdb9f30
parent 678bc96676fb6afca1f29aa4fcd4fae10abf3fd1
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Thu, 30 Mar 2023 16:51:02 -0400

halcc: use the new <>) in assign ops

In addition to generating tighter code, this will help simplify my approach to
subscript assignment (foo[bar] += baz)

Diffstat:
Mfs/comp/c/egen.fs | 18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/comp/c/egen.fs b/fs/comp/c/egen.fs @@ -66,15 +66,15 @@ UOPSCNT wordtbl uoptbl ( res -- res ) over Result :*arisz over Result :*arisz over = _assert ( left right arisz ) >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 !, ; -assign _+=, _+, -assign _*=, _*, assign _/=, _/, assign _%=, _%, -assign _&=, _&, assign _^=, _^, assign _|=, _|, -assign _-=, _-, assign _/=, _/, assign _%=, _%, -assign _<<=, _<<, assign _>>=, _>>, - -: _=, tuck Result :?>W Result :hal$ !, ; +: _prep ( left right -- res halop ) Result :?>W$ dup Result :hal# <>) ; +: _=, _prep @, ; : _-=, _prep -, ; +: _*=, _prep *, ; : _/=, _prep /, ; : _%=, _prep %, ; +: _&=, _prep and, ; : _^=, _prep xor, ; : _|=, _prep or, ; +: _<<=, _prep <<, ; : _>>=, _prep >>, ; + +: _+=, + over Result :*arisz dup 1 > if over Result :*n else drop then + _prep +, ; \ To avoid W juggling, we check if our right operand is W. If it is, no need \ for juggling, all we need is to invert the condition we use.