diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 11:58:26 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 11:58:26 -0300 |
commit | 3c9d999424520c809e05bee11d81788b488434f6 (patch) | |
tree | 7556d9ea10bda42b226aec4dd956753467cc0864 /lvm.c | |
parent | f7840a3e0bc07813246b2bad6bf4579848187908 (diff) | |
download | lua-3c9d999424520c809e05bee11d81788b488434f6.tar.gz lua-3c9d999424520c809e05bee11d81788b488434f6.tar.bz2 lua-3c9d999424520c809e05bee11d81788b488434f6.zip |
many details (most by lhf).
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.88 2000/02/22 13:31:30 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.89 2000/02/22 18:12:46 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 | */ |
@@ -30,8 +30,6 @@ | |||
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | 32 | ||
33 | #define highbyte(L, x) ((x)<<8) | ||
34 | |||
35 | 33 | ||
36 | /* | 34 | /* |
37 | ** Extra stack size to run a function: | 35 | ** Extra stack size to run a function: |
@@ -106,7 +104,7 @@ void luaV_closure (lua_State *L, int nelems) { | |||
106 | void luaV_gettable (lua_State *L, StkId top) { | 104 | void luaV_gettable (lua_State *L, StkId top) { |
107 | TObject *table = top-2; | 105 | TObject *table = top-2; |
108 | const TObject *im; | 106 | const TObject *im; |
109 | if (ttype(table) != LUA_T_ARRAY) { /* not a table, get gettable method */ | 107 | if (ttype(table) != LUA_T_ARRAY) { /* not a table, get gettable TM */ |
110 | im = luaT_getimbyObj(L, table, IM_GETTABLE); | 108 | im = luaT_getimbyObj(L, table, IM_GETTABLE); |
111 | if (ttype(im) == LUA_T_NIL) { | 109 | if (ttype(im) == LUA_T_NIL) { |
112 | L->top = top; | 110 | L->top = top; |
@@ -116,7 +114,7 @@ void luaV_gettable (lua_State *L, StkId top) { | |||
116 | else { /* object is a table... */ | 114 | else { /* object is a table... */ |
117 | int tg = table->value.a->htag; | 115 | int tg = table->value.a->htag; |
118 | im = luaT_getim(L, tg, IM_GETTABLE); | 116 | im = luaT_getim(L, tg, IM_GETTABLE); |
119 | if (ttype(im) == LUA_T_NIL) { /* and does not have a `gettable' method */ | 117 | if (ttype(im) == LUA_T_NIL) { /* and does not have a `gettable' TM */ |
120 | const TObject *h = luaH_get(L, avalue(table), table+1); | 118 | const TObject *h = luaH_get(L, avalue(table), table+1); |
121 | if (ttype(h) == LUA_T_NIL && | 119 | if (ttype(h) == LUA_T_NIL && |
122 | (ttype(im=luaT_getim(L, tg, IM_INDEX)) != LUA_T_NIL)) { | 120 | (ttype(im=luaT_getim(L, tg, IM_INDEX)) != LUA_T_NIL)) { |
@@ -128,9 +126,9 @@ void luaV_gettable (lua_State *L, StkId top) { | |||
128 | *table = *h; /* `push' result into table position */ | 126 | *table = *h; /* `push' result into table position */ |
129 | return; | 127 | return; |
130 | } | 128 | } |
131 | /* else it has a `gettable' method, go through to next command */ | 129 | /* else it has a `gettable' TM, go through to next command */ |
132 | } | 130 | } |
133 | /* object is not a table, or it has a `gettable' method */ | 131 | /* object is not a table, or it has a `gettable' TM */ |
134 | L->top = top; | 132 | L->top = top; |
135 | luaD_callTM(L, im, 2, 1); | 133 | luaD_callTM(L, im, 2, 1); |
136 | } | 134 | } |
@@ -261,7 +259,7 @@ int luaV_lessthan (lua_State *L, TObject *l, TObject *r) { | |||
261 | else if (ttype(l) == LUA_T_STRING && ttype(r) == LUA_T_STRING) | 259 | else if (ttype(l) == LUA_T_STRING && ttype(r) == LUA_T_STRING) |
262 | return (luaV_strcomp(tsvalue(l), tsvalue(r)) < 0); | 260 | return (luaV_strcomp(tsvalue(l), tsvalue(r)) < 0); |
263 | else { | 261 | else { |
264 | /* update top and put arguments in correct order to call Tag Method */ | 262 | /* update top and put arguments in correct order to call TM */ |
265 | if (l<r) /* are arguments in correct order? */ | 263 | if (l<r) /* are arguments in correct order? */ |
266 | L->top = r+1; /* yes; 2nd is on top */ | 264 | L->top = r+1; /* yes; 2nd is on top */ |
267 | else { /* no; exchange them */ | 265 | else { /* no; exchange them */ |
@@ -562,7 +560,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
562 | call_arith(L, top+1, IM_UNM); | 560 | call_arith(L, top+1, IM_UNM); |
563 | } | 561 | } |
564 | else | 562 | else |
565 | nvalue(top-1) = - nvalue(top-1); | 563 | nvalue(top-1) = -nvalue(top-1); |
566 | break; | 564 | break; |
567 | 565 | ||
568 | case NOTOP: | 566 | case NOTOP: |