diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-06 09:40:55 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-06 09:40:55 -0200 |
commit | 1fdb445e7dae6d08b67e46e1979f285b38bbc18d (patch) | |
tree | be92c31ae65a64303c83cb746558ed6243d67bc4 | |
parent | c7119a93f07e4e0edcd5d7d7f23fb447e4cf6acd (diff) | |
download | lua-1fdb445e7dae6d08b67e46e1979f285b38bbc18d.tar.gz lua-1fdb445e7dae6d08b67e46e1979f285b38bbc18d.tar.bz2 lua-1fdb445e7dae6d08b67e46e1979f285b38bbc18d.zip |
details.
-rw-r--r-- | lvm.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.68 1999/11/29 18:27:49 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.69 1999/12/01 19:50:08 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 | */ |
@@ -108,22 +108,22 @@ void luaV_gettable (lua_State *L) { | |||
108 | else { /* object is a table... */ | 108 | else { /* object is a table... */ |
109 | int tg = table->value.a->htag; | 109 | int tg = table->value.a->htag; |
110 | im = luaT_getim(L, tg, IM_GETTABLE); | 110 | im = luaT_getim(L, tg, IM_GETTABLE); |
111 | if (ttype(im) == LUA_T_NIL) { /* and does not have a "gettable" method */ | 111 | if (ttype(im) == LUA_T_NIL) { /* and does not have a `gettable' method */ |
112 | const TObject *h = luaH_get(L, avalue(table), table+1); | 112 | const TObject *h = luaH_get(L, avalue(table), table+1); |
113 | if (ttype(h) == LUA_T_NIL && | 113 | if (ttype(h) == LUA_T_NIL && |
114 | (ttype(im=luaT_getim(L, tg, IM_INDEX)) != LUA_T_NIL)) { | 114 | (ttype(im=luaT_getim(L, tg, IM_INDEX)) != LUA_T_NIL)) { |
115 | /* result is nil and there is an "index" tag method */ | 115 | /* result is nil and there is an `index' tag method */ |
116 | luaD_callTM(L, im, 2, 1); /* calls it */ | 116 | luaD_callTM(L, im, 2, 1); /* calls it */ |
117 | } | 117 | } |
118 | else { | 118 | else { |
119 | L->top--; | 119 | L->top--; |
120 | *table = *h; /* "push" result into table position */ | 120 | *table = *h; /* `push' result into table position */ |
121 | } | 121 | } |
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | /* else it has a "gettable" method, go through to next command */ | 124 | /* else it has a `gettable' method, go through to next command */ |
125 | } | 125 | } |
126 | /* object is not a table, or it has a "gettable" method */ | 126 | /* object is not a table, or it has a `gettable' method */ |
127 | luaD_callTM(L, im, 2, 1); | 127 | luaD_callTM(L, im, 2, 1); |
128 | } | 128 | } |
129 | 129 | ||
@@ -442,6 +442,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
442 | case SETLIST: aux += *pc++; { | 442 | case SETLIST: aux += *pc++; { |
443 | int n = *(pc++); | 443 | int n = *(pc++); |
444 | Hash *arr = avalue(top-n-1); | 444 | Hash *arr = avalue(top-n-1); |
445 | L->top = top-n; /* final value of `top' (in case of errors) */ | ||
445 | aux *= LFIELDS_PER_FLUSH; | 446 | aux *= LFIELDS_PER_FLUSH; |
446 | for (; n; n--) | 447 | for (; n; n--) |
447 | luaH_setint(L, arr, n+aux, --top); | 448 | luaH_setint(L, arr, n+aux, --top); |
@@ -449,7 +450,9 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
449 | } | 450 | } |
450 | 451 | ||
451 | case SETMAP: aux = *pc++; { | 452 | case SETMAP: aux = *pc++; { |
452 | Hash *arr = avalue(top-(2*aux)-3); | 453 | StkId finaltop = top-2*(aux+1); |
454 | Hash *arr = avalue(finaltop-1); | ||
455 | L->top = finaltop; /* final value of `top' (in case of errors) */ | ||
453 | do { | 456 | do { |
454 | luaH_set(L, arr, top-2, top-1); | 457 | luaH_set(L, arr, top-2, top-1); |
455 | top-=2; | 458 | top-=2; |
@@ -529,9 +532,9 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
529 | call_binTM(L, top, IM_CONCAT, "unexpected type for concatenation"); | 532 | call_binTM(L, top, IM_CONCAT, "unexpected type for concatenation"); |
530 | else | 533 | else |
531 | tsvalue(top-2) = strconc(L, tsvalue(top-2), tsvalue(top-1)); | 534 | tsvalue(top-2) = strconc(L, tsvalue(top-2), tsvalue(top-1)); |
535 | top--; | ||
532 | L->top = top; | 536 | L->top = top; |
533 | luaC_checkGC(L); | 537 | luaC_checkGC(L); |
534 | top--; | ||
535 | break; | 538 | break; |
536 | 539 | ||
537 | case MINUSOP: | 540 | case MINUSOP: |
@@ -585,7 +588,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
585 | case CLOSURE: aux += *pc++; | 588 | case CLOSURE: aux += *pc++; |
586 | *top++ = consts[aux]; | 589 | *top++ = consts[aux]; |
587 | L->top = top; | 590 | L->top = top; |
588 | aux = *pc++; | 591 | aux = *pc++; /* number of upvalues */ |
589 | luaV_closure(L, aux); | 592 | luaV_closure(L, aux); |
590 | luaC_checkGC(L); | 593 | luaC_checkGC(L); |
591 | top -= aux; | 594 | top -= aux; |