Skip to content

Commit

Permalink
Regenerate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenthuberdeau committed Oct 18, 2024
1 parent 64e5e72 commit 6936288
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
22 changes: 11 additions & 11 deletions examples/compiled/base64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ _encode() {
}

defarr _lut 256
: $((__t1 = c = 0))
: $((c = 0))
_get() {
let c; let __t1
while _getchar __t1; [ $((c = __t1)) -ge 0 ]; do
let c
while _getchar c; [ $c -ge 0 ]; do
if [ $((c = _$((_lut + c)))) -ge 0 ] ; then
break
fi
done
: $(($1 = c))
endlet $1 __t1 c
endlet $1 c
}

: $((__t1 = c4 = c3 = c2 = c1 = i = 0))
: $((c4 = c3 = c2 = c1 = i = 0))
_decode() {
let i; let c1; let c2; let c3; let c4; let __t1
let i; let c1; let c2; let c3; let c4
i=0
while [ $i -lt 256 ]; do
: $((_$((_lut + i)) = -1))
Expand All @@ -130,21 +130,21 @@ _decode() {
: $((_$((_lut + 255 & _$((_codes + i)))) = i))
: $((i += 1))
done
while _get __t1; [ $((c1 = __t1)) -ge 0 ]; do
if _get __t1; [ $((c2 = __t1)) -lt 0 ] ; then
while _get c1; [ $c1 -ge 0 ]; do
if _get c2; [ $c2 -lt 0 ] ; then
exit 1
fi
printf \\$((((c1 << 2) | (c2 >> 4))/64))$((((c1 << 2) | (c2 >> 4))/8%8))$((((c1 << 2) | (c2 >> 4))%8))
if _get __t1; [ $((c3 = __t1)) -lt 0 ] ; then
if _get c3; [ $c3 -lt 0 ] ; then
break
fi
printf \\$(((255 & ((c2 << 4) | (c3 >> 2)))/64))$(((255 & ((c2 << 4) | (c3 >> 2)))/8%8))$(((255 & ((c2 << 4) | (c3 >> 2)))%8))
if _get __t1; [ $((c4 = __t1)) -lt 0 ] ; then
if _get c4; [ $c4 -lt 0 ] ; then
break
fi
printf \\$(((255 & ((c3 << 6) | c4))/64))$(((255 & ((c3 << 6) | c4))/8%8))$(((255 & ((c3 << 6) | c4))%8))
done
endlet $1 __t1 c4 c3 c2 c1 i
endlet $1 c4 c3 c2 c1 i
}

: $((myargv = argc = 0))
Expand Down
14 changes: 7 additions & 7 deletions examples/compiled/c4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ _main() { # argc: $2, argv: $3
: $((__tmp = $1)) $((argc = $4)) $((argv_ = $5)) $((fd = $6)) $((bt = $7)) $((ty = $8)) $((poolsz = $9)) $((idmain = ${10})) $((pc = ${11})) $((sp = ${12})) $((bp = ${13})) $((a = ${14})) $((cycle = ${15})) $((i = ${16})) $((t = ${17})) $((__t1 = ${18})) $(($1 = __tmp))
return
fi
if _open __t1 $((_$argv_)) 0; [ $((fd = __t1)) -lt 0 ] ; then
if _open fd $((_$argv_)) 0; [ $fd -lt 0 ] ; then
printf "could not open("
_put_pstr __ $((_$argv_))
printf ")\n"
Expand All @@ -837,25 +837,25 @@ _main() { # argc: $2, argv: $3
return
fi
poolsz=$((256 * 1024))
if _malloc __t1 $poolsz; [ $((!(_sym = __t1))) != 0 ] ; then
if _malloc _sym $poolsz; [ $((!_sym)) != 0 ] ; then
printf "could not malloc(%d) symbol area\n" $poolsz
: $(($1 = -1))
: $((__tmp = $1)) $((argc = $4)) $((argv_ = $5)) $((fd = $6)) $((bt = $7)) $((ty = $8)) $((poolsz = $9)) $((idmain = ${10})) $((pc = ${11})) $((sp = ${12})) $((bp = ${13})) $((a = ${14})) $((cycle = ${15})) $((i = ${16})) $((t = ${17})) $((__t1 = ${18})) $(($1 = __tmp))
return
fi
if _malloc __t1 $poolsz; [ $((!(_le = _e = __t1))) != 0 ] ; then
if _malloc _e $poolsz; [ $((!(_le = _e))) != 0 ] ; then
printf "could not malloc(%d) text area\n" $poolsz
: $(($1 = -1))
: $((__tmp = $1)) $((argc = $4)) $((argv_ = $5)) $((fd = $6)) $((bt = $7)) $((ty = $8)) $((poolsz = $9)) $((idmain = ${10})) $((pc = ${11})) $((sp = ${12})) $((bp = ${13})) $((a = ${14})) $((cycle = ${15})) $((i = ${16})) $((t = ${17})) $((__t1 = ${18})) $(($1 = __tmp))
return
fi
if _malloc __t1 $poolsz; [ $((!(_data = __t1))) != 0 ] ; then
if _malloc _data $poolsz; [ $((!_data)) != 0 ] ; then
printf "could not malloc(%d) data area\n" $poolsz
: $(($1 = -1))
: $((__tmp = $1)) $((argc = $4)) $((argv_ = $5)) $((fd = $6)) $((bt = $7)) $((ty = $8)) $((poolsz = $9)) $((idmain = ${10})) $((pc = ${11})) $((sp = ${12})) $((bp = ${13})) $((a = ${14})) $((cycle = ${15})) $((i = ${16})) $((t = ${17})) $((__t1 = ${18})) $(($1 = __tmp))
return
fi
if _malloc __t1 $poolsz; [ $((!(sp = __t1))) != 0 ] ; then
if _malloc sp $poolsz; [ $((!sp)) != 0 ] ; then
printf "could not malloc(%d) stack area\n" $poolsz
: $(($1 = -1))
: $((__tmp = $1)) $((argc = $4)) $((argv_ = $5)) $((fd = $6)) $((bt = $7)) $((ty = $8)) $((poolsz = $9)) $((idmain = ${10})) $((pc = ${11})) $((sp = ${12})) $((bp = ${13})) $((a = ${14})) $((cycle = ${15})) $((i = ${16})) $((t = ${17})) $((__t1 = ${18})) $(($1 = __tmp))
Expand All @@ -879,13 +879,13 @@ _main() { # argc: $2, argv: $3
: $((_$((_id + _Tk)) = _Char))
_next __
idmain=$_id
if _malloc __t1 $poolsz; [ $((!(_lp = _p = __t1))) != 0 ] ; then
if _malloc _p $poolsz; [ $((!(_lp = _p))) != 0 ] ; then
printf "could not malloc(%d) source area\n" $poolsz
: $(($1 = -1))
: $((__tmp = $1)) $((argc = $4)) $((argv_ = $5)) $((fd = $6)) $((bt = $7)) $((ty = $8)) $((poolsz = $9)) $((idmain = ${10})) $((pc = ${11})) $((sp = ${12})) $((bp = ${13})) $((a = ${14})) $((cycle = ${15})) $((i = ${16})) $((t = ${17})) $((__t1 = ${18})) $(($1 = __tmp))
return
fi
if _read __t1 $fd $_p $((poolsz - 1)); [ $((i = __t1)) -le 0 ] ; then
if _read i $fd $_p $((poolsz - 1)); [ $i -le 0 ] ; then
printf "read() returned %d\n" $i
: $(($1 = -1))
: $((__tmp = $1)) $((argc = $4)) $((argv_ = $5)) $((fd = $6)) $((bt = $7)) $((ty = $8)) $((poolsz = $9)) $((idmain = ${10})) $((pc = ${11})) $((sp = ${12})) $((bp = ${13})) $((a = ${14})) $((cycle = ${15})) $((i = ${16})) $((t = ${17})) $((__t1 = ${18})) $(($1 = __tmp))
Expand Down
10 changes: 5 additions & 5 deletions examples/compiled/cp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ _malloc() { # $2 = object size
defarr() { _malloc $1 $2; }

defarr _buffer 1024
: $((__t1 = len = c = dst = src = args = argc = 0))
: $((len = c = dst = src = args = argc = 0))
_main() { let argc $2; let args $3
let src; let dst; let c; let len; let __t1
let src; let dst; let c; let len
if [ $argc != 3 ] ; then
printf "Usage: cp <source> <destination>\n"
: $(($1 = 1))
endlet $1 __t1 len c dst src args argc
endlet $1 len c dst src args argc
return
fi
_open src $((_$((args + 1)))) 0
Expand All @@ -39,10 +39,10 @@ _main() { let argc $2; let args $3
if [ $dst = 0 ] ; then
_file_error __ $((_$((args + 2))))
fi
while _read __t1 $src $_buffer 1024; [ $((len = __t1)) != 0 ]; do
while _read len $src $_buffer 1024; [ $len != 0 ]; do
_write __ $dst $_buffer $len
done
endlet $1 __t1 len c dst src args argc
endlet $1 len c dst src args argc
}

# Runtime library
Expand Down
8 changes: 4 additions & 4 deletions examples/compiled/wc-stdin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ _is_word_separator() { let c $2
endlet $1 c
}

: $((__t1 = last_sep = sep = c = chars = words = lines = 0))
: $((last_sep = sep = c = chars = words = lines = 0))
_main() {
let lines; let words; let chars; let c; let sep; let last_sep; let __t1
let lines; let words; let chars; let c; let sep; let last_sep
lines=0
words=0
chars=0
sep=0
last_sep=0
while _getchar __t1; [ $((c = __t1)) != -1 ]; do
while _getchar c; [ $c != -1 ]; do
: $((chars += 1))
if [ $c = $__NEWLINE__ ] ; then
: $((lines += 1))
Expand All @@ -28,7 +28,7 @@ _main() {
last_sep=$sep
done
printf "%d %d %d\n" $lines $words $chars
endlet $1 __t1 last_sep sep c chars words lines
endlet $1 last_sep sep c chars words lines
}

# Character constants
Expand Down
8 changes: 4 additions & 4 deletions examples/compiled/welcome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
set -e -u -f
LC_ALL=C

: $((__t1 = i = name = 0))
: $((i = name = 0))
_main() {
let name; let i; let __t1
let name; let i
_malloc name 100
i=0
printf "What is your name?\n"
while { _getchar __t1; [ $((_$((name + i)) = __t1)) != -1 ]; } && [ $((_$((name + i)))) != $__NEWLINE__ ]; do
while { _getchar _$((name + i)); [ $((_$((name + i)))) != -1 ]; } && [ $((_$((name + i)))) != $__NEWLINE__ ]; do
: $((i += 1))
done
: $((_$((name + i)) = __NUL__))
printf "Hello, "
_put_pstr __ $name
printf "\n"
endlet $1 __t1 i name
endlet $1 i name
}

# Character constants
Expand Down

0 comments on commit 6936288

Please sign in to comment.