summaryrefslogtreecommitdiffstats
path: root/eshtrans
diff options
context:
space:
mode:
Diffstat (limited to 'eshtrans')
-rw-r--r--eshtrans/backend/codegen.esh22
1 files changed, 19 insertions, 3 deletions
diff --git a/eshtrans/backend/codegen.esh b/eshtrans/backend/codegen.esh
index e257990..49b44fd 100644
--- a/eshtrans/backend/codegen.esh
+++ b/eshtrans/backend/codegen.esh
@@ -43,17 +43,18 @@ codegen_sub()
local array="${1}"
shift 1
local ionum=
+ local fname=
local static=
local static_fname=
- local fname=
ionum=false
+ fname=''
static=false
static_fname=false
- fname=''
IFS="${RS}"
for t in ${array}; do
+ # Handle I/O number false positives.
if ${ionum}; then
case "${t%${US}*}" in
T_WORD|T_CMDNAME|T_FNAME)
@@ -63,6 +64,12 @@ codegen_sub()
ionum=false
fi
+ # Function names
+ case "${t%${US}*}" in T_FNAME)
+ fname="${t}"
+ ;;
+ esac
+
# State machine for static variables and functions
case "${t%${US}*}" in
T_STATIC)
@@ -75,7 +82,6 @@ codegen_sub()
case "${t%${US}*}" in
T_FNAME)
static_fname=true
- fname="${t}"
continue
;;
*)
@@ -97,6 +103,16 @@ codegen_sub()
esac
fi
+ # Function start/end tokens
+ case "${t%${US}*}" in
+ T_FN_START)
+ printf '__fn_start %s\n' "${fname#*${US}}"
+ ;;
+ T_FN_END|T_RETURN)
+ printf '__fn_end\n'
+ ;;
+ esac
+
toktext "${t}"
case "${t%${US}*}" in