c: add a decompile mode

This commit is contained in:
xfnw 2023-10-19 19:07:38 -04:00
parent 117f128435
commit b62236e8d9
1 changed files with 9 additions and 2 deletions

11
bin/c
View File

@ -32,12 +32,14 @@ EOF
expr=
type=
decompile=
debug=
while getopts 'e:i:tg' opt; do
while getopts 'e:i:tdg' opt; do
case "${opt}" in
(e) expr=$OPTARG;;
(i) echo "#include <${OPTARG}>" >&3;;
(t) type=1;;
(d) decompile=1;;
(g) debug="-fsanitize=address -g";;
(?) exit 1;;
esac
@ -121,4 +123,9 @@ CFLAGS += -Wall -Wextra -Wpedantic $debug
EOF
make -s -C "${temp}" run
"${temp}/run"
if [ -n "${decompile}" ]; then
objdump -d -Mintel "${temp}/run"
else
"${temp}/run"
fi