aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2025-09-17 16:07:48 -0300
committerRoberto I <roberto@inf.puc-rio.br>2025-09-17 16:07:48 -0300
commit8fb1af0e33cd8688f57cd0e3ab86420a8cfe99bd (patch)
tree2c199de5e67f395a4f9c94fcfb2ef3f0dad8882a /lcode.c
parent140b672e2ee2ac842661ece4b48e1a64f0cd11ea (diff)
downloadlua-8fb1af0e33cd8688f57cd0e3ab86420a8cfe99bd.tar.gz
lua-8fb1af0e33cd8688f57cd0e3ab86420a8cfe99bd.tar.bz2
lua-8fb1af0e33cd8688f57cd0e3ab86420a8cfe99bd.zip
Varag parameter is a new kind of variable
To allow some optimizations on its use.
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c12
1 files changed, 12 insertions, 0 deletions
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) {
785 } 785 }
786} 786}
787 787
788/*
789** Change a vararg parameter into a regular local variable
790*/
791void luaK_vapar2local (FuncState *fs, expdesc *var) {
792 fs->f->flag |= PF_VATAB; /* function will need a vararg table */
793 /* now a vararg parameter is equivalent to a regular local variable */
794 var->k = VLOCAL;
795}
796
788 797
789/* 798/*
790** Ensure that expression 'e' is not a variable (nor a <const>). 799** Ensure that expression 'e' is not a variable (nor a <const>).
@@ -796,6 +805,9 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
796 const2exp(const2val(fs, e), e); 805 const2exp(const2val(fs, e), e);
797 break; 806 break;
798 } 807 }
808 case VVARGVAR: {
809 luaK_vapar2local(fs, e); /* turn it into a local variable */
810 } /* FALLTHROUGH */
799 case VLOCAL: { /* already in a register */ 811 case VLOCAL: { /* already in a register */
800 int temp = e->u.var.ridx; 812 int temp = e->u.var.ridx;
801 e->u.info = temp; /* (can't do a direct assignment; values overlap) */ 813 e->u.info = temp; /* (can't do a direct assignment; values overlap) */