diff options
| -rw-r--r-- | lvm.c | 18 |
1 files changed, 7 insertions, 11 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.165 2001/02/06 16:01:29 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.166 2001/02/07 18:13:49 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 | */ |
| @@ -101,7 +101,7 @@ static void callTM (lua_State *L, const char *fmt, ...) { | |||
| 101 | StkId base = L->top; | 101 | StkId base = L->top; |
| 102 | int has_result = 0; | 102 | int has_result = 0; |
| 103 | va_start(argp, fmt); | 103 | va_start(argp, fmt); |
| 104 | for (;;) { | 104 | while (*fmt) { |
| 105 | switch (*fmt++) { | 105 | switch (*fmt++) { |
| 106 | case 'c': | 106 | case 'c': |
| 107 | setclvalue(L->top, va_arg(argp, Closure *)); | 107 | setclvalue(L->top, va_arg(argp, Closure *)); |
| @@ -114,12 +114,10 @@ static void callTM (lua_State *L, const char *fmt, ...) { | |||
| 114 | break; | 114 | break; |
| 115 | case 'r': | 115 | case 'r': |
| 116 | has_result = 1; | 116 | has_result = 1; |
| 117 | /* go through */ | 117 | continue; |
| 118 | default: | ||
| 119 | goto endloop; | ||
| 120 | } | 118 | } |
| 121 | incr_top; | 119 | incr_top; |
| 122 | } endloop: | 120 | } |
| 123 | luaD_call(L, base, has_result); | 121 | luaD_call(L, base, has_result); |
| 124 | if (has_result) { | 122 | if (has_result) { |
| 125 | L->top--; | 123 | L->top--; |
| @@ -140,18 +138,16 @@ void luaV_gettable (lua_State *L, StkId t, TObject *key, StkId res) { | |||
| 140 | if (ttype(t) == LUA_TTABLE && /* `t' is a table? */ | 138 | if (ttype(t) == LUA_TTABLE && /* `t' is a table? */ |
| 141 | ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */ | 139 | ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */ |
| 142 | luaT_gettm(G(L), tg, TM_GETTABLE) == NULL)) { /* or no TM? */ | 140 | luaT_gettm(G(L), tg, TM_GETTABLE) == NULL)) { /* or no TM? */ |
| 143 | /* do a primitive get */ | 141 | const TObject *h = luaH_get(hvalue(t), key); /* do a primitive get */ |
| 144 | const TObject *h = luaH_get(hvalue(t), key); | ||
| 145 | /* result is no nil or there is no `index' tag method? */ | 142 | /* result is no nil or there is no `index' tag method? */ |
| 146 | if (ttype(h) != LUA_TNIL || ((tm=luaT_gettm(G(L), tg, TM_INDEX)) == NULL)) { | 143 | if (ttype(h) != LUA_TNIL || ((tm=luaT_gettm(G(L), tg, TM_INDEX)) == NULL)) { |
| 147 | setobj(res, h); | 144 | setobj(res, h); |
| 148 | return; | 145 | return; |
| 149 | } | 146 | } |
| 150 | /* else call `index' tag method */ | 147 | /* else will call `index' tag method */ |
| 151 | } | 148 | } |
| 152 | else { /* try a `gettable' tag method */ | 149 | else /* try a `gettable' tag method */ |
| 153 | tm = luaT_gettmbyObj(G(L), t, TM_GETTABLE); | 150 | tm = luaT_gettmbyObj(G(L), t, TM_GETTABLE); |
| 154 | } | ||
| 155 | if (tm == NULL) /* no tag method? */ | 151 | if (tm == NULL) /* no tag method? */ |
| 156 | luaG_typeerror(L, t, "index"); | 152 | luaG_typeerror(L, t, "index"); |
| 157 | else | 153 | else |
