diff options
author | P. J. McDermott <pj@pehjota.net> | 2016-02-22 15:07:33 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2016-02-22 15:07:33 (EST) |
commit | 589a8f036c12259895c24a500480b17b32d73159 (patch) | |
tree | da0229b4acdb21d1607e7fdfbc14979ea796a1e2 /eshtrans | |
parent | 71f69788f64bdc17caece676b5f0ee8ded9e29d5 (diff) | |
download | eggshell-589a8f036c12259895c24a500480b17b32d73159.zip eggshell-589a8f036c12259895c24a500480b17b32d73159.tar.gz eggshell-589a8f036c12259895c24a500480b17b32d73159.tar.bz2 |
eshtrans/backend: Add function start/end calls
Diffstat (limited to 'eshtrans')
-rw-r--r-- | eshtrans/backend/codegen.esh | 22 |
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 |