aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-10-16 08:59:34 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-10-16 08:59:34 -0200
commit45ccb0e881064492a3f422b15b50dad71eed36fa (patch)
treed819206b4af4fb9a257534471455ce233c1c93e3 /lvm.c
parent4be18fa889657ebd317f5311ecf65da64891242b (diff)
downloadlua-45ccb0e881064492a3f422b15b50dad71eed36fa.tar.gz
lua-45ccb0e881064492a3f422b15b50dad71eed36fa.tar.bz2
lua-45ccb0e881064492a3f422b15b50dad71eed36fa.zip
"nupvalues" is kept in Closure, not in prototype (as a preparation
for C closures...)
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/lvm.c b/lvm.c
index 91d923a4..4b77c3a6 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.8 1997/10/06 14:51:11 roberto Exp roberto $ 2** $Id: lvm.c,v 1.9 1997/10/13 22:12:04 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*/
@@ -76,12 +76,11 @@ int luaV_tostring (TObject *obj)
76} 76}
77 77
78 78
79void luaV_closure (void) 79void luaV_closure (int nelems)
80{ 80{
81 int nelems = (luaD_stack.top-1)->value.tf->nupvalues;
82 Closure *c = luaF_newclosure(nelems); 81 Closure *c = luaF_newclosure(nelems);
83 c->consts[0] = *(luaD_stack.top-1); 82 memcpy(c->consts, luaD_stack.top-(nelems+1), (nelems+1)*sizeof(TObject));
84 memcpy(&c->consts[1], luaD_stack.top-(nelems+1), nelems*sizeof(TObject)); 83 c->nelems = nelems;
85 luaD_stack.top -= nelems; 84 luaD_stack.top -= nelems;
86 ttype(luaD_stack.top-1) = LUA_T_FUNCTION; 85 ttype(luaD_stack.top-1) = LUA_T_FUNCTION;
87 (luaD_stack.top-1)->value.cl = c; 86 (luaD_stack.top-1)->value.cl = c;
@@ -427,7 +426,7 @@ StkId luaV_execute (Closure *cl, StkId base)
427 aux = 0; goto setmap; 426 aux = 0; goto setmap;
428 427
429 case SETMAP: 428 case SETMAP:
430 aux = *(pc++); 429 aux = *pc++;
431 setmap: { 430 setmap: {
432 TObject *arr = luaD_stack.top-(2*aux)-3; 431 TObject *arr = luaD_stack.top-(2*aux)-3;
433 do { 432 do {
@@ -447,12 +446,12 @@ StkId luaV_execute (Closure *cl, StkId base)
447 break; 446 break;
448 447
449 case ARGS: 448 case ARGS:
450 luaD_adjusttop(base + *(pc++)); 449 luaD_adjusttop(base+(*pc++));
451 break; 450 break;
452 451
453 case VARARGS: 452 case VARARGS:
454 luaC_checkGC(); 453 luaC_checkGC();
455 adjust_varargs(base + *(pc++)); 454 adjust_varargs(base+(*pc++));
456 break; 455 break;
457 456
458 case CREATEARRAYW: 457 case CREATEARRAYW:
@@ -632,14 +631,13 @@ StkId luaV_execute (Closure *cl, StkId base)
632 if (ttype(--luaD_stack.top) == LUA_T_NIL) pc -= aux; 631 if (ttype(--luaD_stack.top) == LUA_T_NIL) pc -= aux;
633 break; 632 break;
634 633
635 case CLOSUREW:
636 aux = next_word(pc); goto closure;
637
638 case CLOSURE: 634 case CLOSURE:
639 aux = *pc++; 635 aux = *pc++; goto closure;
636
637 case CLOSURE0: case CLOSURE1:
638 aux -= CLOSURE0;
640 closure: 639 closure:
641 *luaD_stack.top++ = consts[aux]; 640 luaV_closure(aux);
642 luaV_closure();
643 luaC_checkGC(); 641 luaC_checkGC();
644 break; 642 break;
645 643