summaryrefslogtreecommitdiffstats
path: root/eshtrans
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-02-28 15:08:43 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-02-28 15:08:43 (EST)
commit405ff1ffad7310a04ff104284d600a066d6dd925 (patch)
tree9c64d2b7aa04bcc818d52b759a5d10f61ff521a2 /eshtrans
parent96716798e04aded65e9023c40fa8492350cf212d (diff)
downloadeggshell-405ff1ffad7310a04ff104284d600a066d6dd925.zip
eggshell-405ff1ffad7310a04ff104284d600a066d6dd925.tar.gz
eggshell-405ff1ffad7310a04ff104284d600a066d6dd925.tar.bz2
eshtrans/backend: Implement "nostack" pragma
Diffstat (limited to 'eshtrans')
-rw-r--r--eshtrans/backend/codegen.esh41
1 files changed, 30 insertions, 11 deletions
diff --git a/eshtrans/backend/codegen.esh b/eshtrans/backend/codegen.esh
index 9e95956..ddd466b 100644
--- a/eshtrans/backend/codegen.esh
+++ b/eshtrans/backend/codegen.esh
@@ -23,6 +23,7 @@ sbufc=
sc=
tu_id=
static_fn_n=
+pragma_nostack=false
sgetc()
{
@@ -50,12 +51,14 @@ codegen_sub()
shift 1
local print_spc=
local ionum=
+ local pragma=
local fname=
local static=
local static_fname=
print_spc=false
ionum=false
+ pragma=false
fname=''
static=false
static_fname=false
@@ -83,19 +86,25 @@ 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_USE)
+ pragma=true
+ continue
+ ;;
+ T_FNAME)
+ fname="${t}"
+ ;;
T_STATIC)
static=true
continue
;;
esac
+ if ${pragma}; then
+ pragma=false
+ eval "pragma_${t#*${US}}=true"
+ continue
+ fi
+ # State machine for static variables and functions
if ${static}; then
static=false
case "${t%${US}*}" in
@@ -125,14 +134,24 @@ codegen_sub()
# Function start/end tokens
case "${t%${US}*}" in
T_FN_START)
- printf '__fn_start %s %s;' \
- "${tu_id}" "${fname#*${US}}"
+ if ! ${pragma_nostack}; then
+ printf '__fn_start %s %s;' \
+ "${tu_id}" "${fname#*${US}}"
+ else
+ printf ':;'
+ fi
;;
T_FN_END)
- printf '__fn_end;'
+ if ! ${pragma_nostack}; then
+ printf '__fn_end;'
+ else
+ printf ':;'
+ fi
;;
T_RETURN)
- printf '__fn_end; '
+ if ! ${pragma_nostack}; then
+ printf '__fn_end; '
+ fi
;;
esac