duskos

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

commit 50d22c9a5b6739ab41a7b6d0178435f875c85214
parent 6a893ca80685ed2cba5cae763d15e6743410374b
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat, 25 Mar 2023 09:26:17 -0400

halcc: boolnot()

Diffstat:
Mfs/comp/c/egen.fs | 4+++-
Mfs/tests/comp/c/cc.fs | 2+-
Mfs/tests/comp/c/test2.c | 3+++
3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/comp/c/egen.fs b/fs/comp/c/egen.fs @@ -31,6 +31,8 @@ alias noop parseFactor ( tok -- res ) \ forward declaration unaryop _neg, neg, neg : _ -1 i) xor, ; unaryop _not, _ ^ +: _ W=0>Z, Z) C>W, ; +unaryop _!, _ not : _&, dup Result :& ; : _*, dup Result :* ; @@ -41,7 +43,7 @@ unaryop _not, _ ^ : _++, 1 _ ; : _--, -1 _ ; UOPSCNT wordtbl uoptbl ( res -- res ) -'w _neg, 'w _not, 'w _err 'w _&, 'w _*, 'w _++, 'w _--, +'w _neg, 'w _not, 'w _!, 'w _&, 'w _*, 'w _++, 'w _--, \ ops that can freely swap their operands : _prep ( left right -- left halop ) diff --git a/fs/tests/comp/c/cc.fs b/fs/tests/comp/c/cc.fs @@ -55,9 +55,9 @@ forcontinue 9 #eq forempty \ no crash -1 0 lts # -1 0 ltu not # -testend \s 0 boolnot 1 #eq 42 boolnot 0 #eq +testend \s S" foobar" 2 get8b 'o' #eq S" foobar" 4 get8b 'b' #eq S" foobar" dup 2 'X' set8b S" fXobar" #s= diff --git a/fs/tests/comp/c/test2.c b/fs/tests/comp/c/test2.c @@ -221,3 +221,6 @@ int lts(int a, int b) { int ltu(unsigned int a, unsigned int b) { return a < b; } +int boolnot(int x) { + return !x; +}