aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-12 11:35:37 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-12 11:35:37 -0200
commitf0dffaa209d80b9852e873830243245c1facdd05 (patch)
tree562ac67e30c59242ae862bb3db2f4c7a670565b9
parent77a6836fef12a6383d1c9eb1587aa5afa30c9b5a (diff)
downloadlua-f0dffaa209d80b9852e873830243245c1facdd05.tar.gz
lua-f0dffaa209d80b9852e873830243245c1facdd05.tar.bz2
lua-f0dffaa209d80b9852e873830243245c1facdd05.zip
new way to hanlde arg information
-rw-r--r--lopcodes.h13
-rw-r--r--lua.stx15
-rw-r--r--lvm.c22
3 files changed, 21 insertions, 29 deletions
diff --git a/lopcodes.h b/lopcodes.h
index 3f25e828..ee0f9354 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.13 1997/12/29 17:35:46 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.14 1997/12/30 19:08:23 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -169,19 +169,14 @@ SETLINEW,/* w - - LINE=w */
169 169
170POP,/* b - - TOP-=(b+1) */ 170POP,/* b - - TOP-=(b+1) */
171POP0,/* - - - TOP-=1 */ 171POP0,/* - - - TOP-=1 */
172POP1,/* - - - TOP-=2 */ 172POP1/* - - - TOP-=2 */
173 173
174ARGS,/* b - - TOP=BASE+b */
175ARGS0,/* - - - TOP=BASE+0 */
176ARGS1,/* - - - TOP=BASE+1 */
177ARGS2,/* - - - TOP=BASE+2 */
178ARGS3,/* - - - TOP=BASE+3 */
179VARARGS/* b v_x...v_1 {v_1...v_x;n=x} TOP=BASE+b+1 */
180} OpCode; 174} OpCode;
181 175
182 176
183#define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */ 177#define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */
184#define LFIELDS_PER_FLUSH 64 /* lists (SETLIST) */ 178#define LFIELDS_PER_FLUSH 64 /* lists (SETLIST) */
185 179
180#define ZEROVARARG 64
186 181
187#endif 182#endif
diff --git a/lua.stx b/lua.stx
index b10ea3bb..0208a638 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,6 +1,6 @@
1%{ 1%{
2/* 2/*
3** $Id: lua.stx,v 1.31 1997/12/30 19:08:23 roberto Exp roberto $ 3** $Id: lua.stx,v 1.32 1998/01/12 13:00:51 roberto Exp roberto $
4** Syntax analizer and code generator 4** Syntax analizer and code generator
5** See Copyright Notice in lua.h 5** See Copyright Notice in lua.h
6*/ 6*/
@@ -448,11 +448,15 @@ static void adjust_mult_assign (int vars, long exps)
448 448
449static void code_args (int nparams, int dots) 449static void code_args (int nparams, int dots)
450{ 450{
451 L->currState->nlocalvar += nparams; 451 L->currState->nlocalvar += nparams; /* "self" may already be there */
452 if (!dots) 452 nparams = L->currState->nlocalvar;
453 code_oparg(ARGS, 4, L->currState->nlocalvar, L->currState->nlocalvar); 453 if (!dots) {
454 L->currState->f->code[1] = nparams; /* fill-in arg information */
455 deltastack(nparams);
456 }
454 else { 457 else {
455 code_oparg(VARARGS, 0, L->currState->nlocalvar, L->currState->nlocalvar+1); 458 L->currState->f->code[1] = nparams+ZEROVARARG;
459 deltastack(nparams+1);
456 add_localvar(luaS_new("arg")); 460 add_localvar(luaS_new("arg"));
457 } 461 }
458} 462}
@@ -577,6 +581,7 @@ static void init_state (TaggedString *filename)
577 else 581 else
578 fs->maxvars = -1; /* flag no debug information */ 582 fs->maxvars = -1; /* flag no debug information */
579 code_byte(0); /* to be filled with stacksize */ 583 code_byte(0); /* to be filled with stacksize */
584 code_byte(0); /* to be filled with arg information */
580 L->lexstate->lastline = 0; /* invalidate it */ 585 L->lexstate->lastline = 0; /* invalidate it */
581} 586}
582 587
diff --git a/lvm.c b/lvm.c
index 0fcaff2c..3140b4e4 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.20 1997/12/29 17:35:46 roberto Exp roberto $ 2** $Id: lvm.c,v 1.21 1997/12/30 19:08:23 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -289,6 +289,12 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
289 if (lua_callhook) 289 if (lua_callhook)
290 luaD_callHook(base, tf, 0); 290 luaD_callHook(base, tf, 0);
291 luaD_checkstack((*pc++)+EXTRA_STACK); 291 luaD_checkstack((*pc++)+EXTRA_STACK);
292 if (*pc < ZEROVARARG)
293 luaD_adjusttop(base+*(pc++));
294 else { /* varargs */
295 luaC_checkGC();
296 adjust_varargs(base+(*pc++)-ZEROVARARG);
297 }
292 while (1) { 298 while (1) {
293 int aux; 299 int aux;
294 switch ((OpCode)(aux = *pc++)) { 300 switch ((OpCode)(aux = *pc++)) {
@@ -473,20 +479,6 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
473 S->top -= (aux+1); 479 S->top -= (aux+1);
474 break; 480 break;
475 481
476 case ARGS:
477 aux = *pc++; goto args;
478
479 case ARGS0: case ARGS1: case ARGS2: case ARGS3:
480 aux -= ARGS0;
481 args:
482 luaD_adjusttop(base+aux);
483 break;
484
485 case VARARGS:
486 luaC_checkGC();
487 adjust_varargs(base+(*pc++));
488 break;
489
490 case CREATEARRAYW: 482 case CREATEARRAYW:
491 aux = next_word(pc); goto createarray; 483 aux = next_word(pc); goto createarray;
492 484