commit 55722405149dec484c746cef4b1d064bca148fea
parent 6b4b844a704d252d9222bb07a0c6ed6f8f138279
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sun, 2 Apr 2023 07:40:13 -0400
halcc: fix PS leak in conditionals
Diffstat:
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/comp/c/fgen.fs b/fs/comp/c/fgen.fs
@@ -32,7 +32,7 @@ alias noop parseStatement ( tok -- ) \ forward declaration
';' readChar? not if parseExpression emitRet read; else emitNullRet then ;
: _if
- read( nextt parseExpression Result :?>W$ read) W=0>Z, 0 Z) branchC,
+ read( nextt parseExpression Result :?>W$ read) expr$ W=0>Z, 0 Z) branchC,
nextt parseStatement
nextt dup S" else" s= if ( jump_addr tok )
drop [compile] else nextt parseStatement
@@ -44,7 +44,7 @@ alias noop parseStatement ( tok -- ) \ forward declaration
\ initialization
read( ';' readChar? not if parseExpression Result :release read; then
here nextt parseExpression Result :?>W$ read;
- W=0>Z, 0 Z) branchC, 0 branch, ( caddr cjmpz cjmp ) \ control
+ expr$ W=0>Z, 0 Z) branchC, 0 branch, ( caddr cjmpz cjmp ) \ control
rot here ')' readChar? not if ( cjmpz cjmp caddr aaddr )
parseExpression Result :release read) then
swap [compile] again ( cjmpz cjmp aaddr ) \ adjustment
@@ -62,7 +62,7 @@ alias noop parseStatement ( tok -- ) \ forward declaration
: _while
_breaks :count >r _conts :count >r
here read( nextt parseExpression read)
- Result :?>W$ W=0>Z, 0 Z) branchC,
+ Result :?>W$ expr$ W=0>Z, 0 Z) branchC,
nextt parseStatement ( tgt jmp )
r> resolvecontinues
swap [compile] again [compile] then r> resolvebreaks ;
@@ -73,7 +73,7 @@ alias noop parseStatement ( tok -- ) \ forward declaration
r> resolvecontinues
nextt S" while" s= _assert
read( nextt parseExpression read)
- Result :?>W$ W=0>Z, NZ) branchC, drop
+ Result :?>W$ expr$ W=0>Z, NZ) branchC, drop
read; r> resolvebreaks ;
code _lookup ( nref lookup -- )
diff --git a/fs/tests/comp/c/lib.fs b/fs/tests/comp/c/lib.fs
@@ -57,7 +57,7 @@ memfile MemFile :buf( s c@+ []= #
fclose(hdl);
return 1;
}
-\ foo #
+foo #
create myarray 3 , 7 , 8 , 5 , 2 , 1 , 9 , 5 , 4 ,
myarray 9 qsort