diff options
-rw-r--r-- | opcode.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 4.3 1997/04/15 17:32:47 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 4.4 1997/04/24 22:59:57 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -320,9 +320,13 @@ static void do_call (StkId base, int nResults) | |||
320 | */ | 320 | */ |
321 | static void pushsubscript (void) | 321 | static void pushsubscript (void) |
322 | { | 322 | { |
323 | int tg = luaI_efectivetag(top-2); | 323 | TObject *im; |
324 | TObject *im = luaI_getim(tg, IM_GETTABLE); | 324 | if (ttype(top-2) != LUA_T_ARRAY) /* not a table, get "gettable" method */ |
325 | if (ttype(top-2) == LUA_T_ARRAY && ttype(im) == LUA_T_NIL) { | 325 | im = luaI_getimbyObj(top-2, IM_GETTABLE); |
326 | else { /* object is a table... */ | ||
327 | int tg = (top-2)->value.a->htag; | ||
328 | im = luaI_getim(tg, IM_GETTABLE); | ||
329 | if (ttype(im) == LUA_T_NIL) { /* and does not have a "gettable" method */ | ||
326 | TObject *h = lua_hashget(avalue(top-2), top-1); | 330 | TObject *h = lua_hashget(avalue(top-2), top-1); |
327 | if (h != NULL && ttype(h) != LUA_T_NIL) { | 331 | if (h != NULL && ttype(h) != LUA_T_NIL) { |
328 | --top; | 332 | --top; |
@@ -334,13 +338,15 @@ static void pushsubscript (void) | |||
334 | --top; | 338 | --top; |
335 | ttype(top-1) = LUA_T_NIL; | 339 | ttype(top-1) = LUA_T_NIL; |
336 | } | 340 | } |
341 | return; | ||
342 | } | ||
343 | /* else it has a "gettable" method, go through to next command */ | ||
337 | } | 344 | } |
338 | else { /* object is not a table, and/or has a specific "gettable" method */ | 345 | /* object is not a table, or it has a "gettable" method */ |
339 | if (ttype(im) != LUA_T_NIL) | 346 | if (ttype(im) != LUA_T_NIL) |
340 | callIM(im, 2, 1); | 347 | callIM(im, 2, 1); |
341 | else | 348 | else |
342 | lua_error("indexed expression not a table"); | 349 | lua_error("indexed expression not a table"); |
343 | } | ||
344 | } | 350 | } |
345 | 351 | ||
346 | 352 | ||