duskos

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

commit 20d96c07255311c38fdb8225362eb541560d5e1b
parent 20ca6bd2f2dd17b50e1a17566a6eb616eba9bfd0
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Mon, 20 Mar 2023 21:25:38 -0400

halcc: incdec()

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

diff --git a/fs/comp/c/egen.fs b/fs/comp/c/egen.fs @@ -32,8 +32,12 @@ unaryop _not, _ ^ : _&, dup Result :& ; : _*, dup Result :* ; +: _ ( res incsz -- res ) + over Result :isW? if W+n, else over Result :hal# [+n], then ; +: _++, 1 _ ; : _--, -1 _ ; + UOPSCNT wordtbl _tbl ( res -- res ) -'w _neg, 'w _not, 'w _err 'w _&, 'w _*, 'w _err 'w _err +'w _neg, 'w _not, 'w _err 'w _&, 'w _*, 'w _++, 'w _--, \ we gave to call "res" after having parsed its arguments. "(" is parsed. \ Arguments construction: basically, we can place arguments on PS in the order diff --git a/fs/tests/comp/c/cc.fs b/fs/tests/comp/c/cc.fs @@ -28,8 +28,8 @@ ptrget 42 #eq ptrset 54 #eq 12 condif 13 #eq 42 condif 142 #eq -testend \s 42 incdec 43 #eq +testend \s 54 incdecp 54 #eq exprparens 9 #eq cnoop ( no result! ) scnt 0 #eq diff --git a/fs/tests/comp/c/test2.c b/fs/tests/comp/c/test2.c @@ -107,3 +107,9 @@ int condif(int x) { } return x; } +// test that ++ and -- modify the lvalue directly +int incdec(int x) { + ++x; + --x; + return ++x; +}