From 8fb1af0e33cd8688f57cd0e3ab86420a8cfe99bd Mon Sep 17 00:00:00 2001 From: Roberto I Date: Wed, 17 Sep 2025 16:07:48 -0300 Subject: Varag parameter is a new kind of variable To allow some optimizations on its use. --- lcode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index cafe265e..f74223eb 100644 --- a/lcode.c +++ b/lcode.c @@ -785,6 +785,15 @@ void luaK_setoneret (FuncState *fs, expdesc *e) { } } +/* +** Change a vararg parameter into a regular local variable +*/ +void luaK_vapar2local (FuncState *fs, expdesc *var) { + fs->f->flag |= PF_VATAB; /* function will need a vararg table */ + /* now a vararg parameter is equivalent to a regular local variable */ + var->k = VLOCAL; +} + /* ** Ensure that expression 'e' is not a variable (nor a ). @@ -796,6 +805,9 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { const2exp(const2val(fs, e), e); break; } + case VVARGVAR: { + luaK_vapar2local(fs, e); /* turn it into a local variable */ + } /* FALLTHROUGH */ case VLOCAL: { /* already in a register */ int temp = e->u.var.ridx; e->u.info = temp; /* (can't do a direct assignment; values overlap) */ -- cgit v1.2.3-55-g6feb