summaryrefslogtreecommitdiffstats
path: root/eshtrans/backend
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-02-28 23:28:01 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-02-28 23:28:01 (EST)
commit1778852e86d710c5d28d46031b59e186a429dd38 (patch)
tree9d0610d266a1c6e3deb56b3948863972a90fba2f /eshtrans/backend
parent222ad7c5b260afb6394e39c2bdbd69a92cf4a7d5 (diff)
downloadeggshell-1778852e86d710c5d28d46031b59e186a429dd38.zip
eggshell-1778852e86d710c5d28d46031b59e186a429dd38.tar.gz
eggshell-1778852e86d710c5d28d46031b59e186a429dd38.tar.bz2
eshtrans: Support parameter lists
Diffstat (limited to 'eshtrans/backend')
-rw-r--r--eshtrans/backend/codegen.esh26
1 files changed, 26 insertions, 0 deletions
diff --git a/eshtrans/backend/codegen.esh b/eshtrans/backend/codegen.esh
index 8fd1088..2637d51 100644
--- a/eshtrans/backend/codegen.esh
+++ b/eshtrans/backend/codegen.esh
@@ -55,6 +55,9 @@ codegen_sub()
local fname=
local static=
local static_fname=
+ local type=
+ local params=
+ local types=
local t=
print_spc=false
@@ -63,6 +66,9 @@ codegen_sub()
fname=''
static=false
static_fname=false
+ type=false
+ params=0
+ types=''
IFS="${RS}"
for t in ${array}; do
@@ -94,11 +100,22 @@ codegen_sub()
;;
T_FNAME)
fname="${t}"
+ params=0
+ types=''
;;
T_STATIC)
static=true
continue
;;
+ T_TYPE)
+ type=true
+ params=$((${params} + 1))
+ types="${types}${t#*${US}}:"
+ continue
+ ;;
+ T_COMMA)
+ continue
+ ;;
esac
if ${pragma}; then
pragma=false
@@ -128,6 +145,10 @@ codegen_sub()
toktext "${fname}"
;;
esac
+ elif ${type}; then
+ type=false
+ types="${types}${t#*${US}} "
+ continue
fi
# Function start/end tokens
@@ -139,6 +160,11 @@ codegen_sub()
else
printf ':;'
fi
+ if [ ${params} -gt 0 ]; then
+ printf ' __check_args %s %d %s %s;' \
+ "${fname#*${US}}" ${params} \
+ "'${types% }'" '"${@}"'
+ fi
;;
T_FN_END)
if ! ${pragma_nostack}; then