From ffee5da4dab26c8500add63da540ee252545370f Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Fri, 8 Aug 2025 23:51:31 +0200 Subject: Variadic function declarations and calls --- il.fun | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'il.fun') diff --git a/il.fun b/il.fun index 55f97de..9f8c2b7 100644 --- a/il.fun +++ b/il.fun @@ -385,6 +385,14 @@ functor IL(P: PARSER) = struct if isFunc then Reg v else Addr v end + fun convStrlit ctx id t = + let + val v = getNew8 ctx + in + ctxPutOp ctx (IrSet (v, SaAddr (id, 0w0))); + (if P.isArray t then Addr else Reg) v + end + fun convId ctx (P.Gid p) = convGLconst ctx p | convId (Lctx { localVars, paramNum, ... }) (P.Lid id) = if id < paramNum then (* function parameter *) @@ -994,7 +1002,7 @@ functor IL(P: PARSER) = struct Reg vRes end - and convExpr ctx ea: ev = + and convExpr ctx ea = let val P.EA (e, _, _, t) = ea in @@ -1002,7 +1010,7 @@ functor IL(P: PARSER) = struct P.Eid (_, loc) => convId ctx (valOf loc) | P.Econst (_, P.Ninteger w) => convConst ctx (w, t) | P.Econst (_, _) => raise Unreachable - | P.Estrlit id => convGLconst ctx (id, false) + | P.Estrlit id => convStrlit ctx id t | P.EmemberByV (ea, field) => convFieldAccessByV ctx ea field | P.EmemberByP (ea, field) => convFieldAccesByP ctx ea field | P.EsizeofType t => convSizeOfType ctx t -- cgit v1.2.3