ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

lvm.cpp

Go to the documentation of this file.
00001 /*
00002 ** Lua virtual machine
00003 ** See Copyright Notice in lua.h
00004 */
00005 
00006 #define FORBIDDEN_SYMBOL_EXCEPTION_setjmp
00007 #define FORBIDDEN_SYMBOL_EXCEPTION_longjmp
00008 
00009 #include "engines/grim/lua/lauxlib.h"
00010 #include "engines/grim/lua/ldo.h"
00011 #include "engines/grim/lua/lfunc.h"
00012 #include "engines/grim/lua/lgc.h"
00013 #include "engines/grim/lua/lmem.h"
00014 #include "engines/grim/lua/lopcodes.h"
00015 #include "engines/grim/lua/lstate.h"
00016 #include "engines/grim/lua/lstring.h"
00017 #include "engines/grim/lua/ltable.h"
00018 #include "engines/grim/lua/ltask.h"
00019 #include "engines/grim/lua/ltm.h"
00020 #include "engines/grim/lua/luadebug.h"
00021 #include "engines/grim/lua/lvm.h"
00022 
00023 namespace Grim {
00024 
00025 #define skip_word(pc)   (pc += 2)
00026 #define get_word(pc)    ((*((pc) + 1) << 8)|(*(pc)))
00027 #define next_word(pc)   (pc += 2, get_word(pc - 2))
00028 
00029 #define EXTRA_STACK 5
00030 
00031 static TaggedString *strconc(char *l, char *r) {
00032     size_t nl = strlen(l);
00033     char *buffer = luaL_openspace(nl + strlen(r) + 1);
00034     strcpy(buffer, l);
00035     strcpy(buffer + nl, r);
00036     return luaS_new(buffer);
00037 }
00038 
00039 int32 luaV_tonumber (TObject *obj) { // LUA_NUMBER
00040     double t;
00041     char c;
00042 
00043     if (ttype(obj) != LUA_T_STRING)
00044         return 1;
00045     else if (sscanf(svalue(obj), "%lf %c", &t, &c) == 1) {
00046         nvalue(obj) = (float)t;
00047         ttype(obj) = LUA_T_NUMBER;
00048         return 0;
00049     } else
00050         return 2;
00051 }
00052 
00053 int32 luaV_tostring (TObject *obj) { // LUA_NUMBER
00054     if (ttype(obj) != LUA_T_NUMBER)
00055         return 1;
00056     else {
00057         char s[60];
00058         float f = nvalue(obj);
00059         int32 i;
00060         if ((float)(-MAX_INT) <= f && f <= (float)MAX_INT && (float)(i = (int32)f) == f)
00061             sprintf (s, "%d", (int)i);
00062         else
00063             sprintf (s, "%g", (double)nvalue(obj));
00064         tsvalue(obj) = luaS_new(s);
00065         ttype(obj) = LUA_T_STRING;
00066         return 0;
00067     }
00068 }
00069 
00070 void luaV_closure(int32 nelems) {
00071     if (nelems > 0) {
00072         Stack *S = &lua_state->stack;
00073         Closure *c = luaF_newclosure(nelems);
00074         c->consts[0] = *(S->top - 1);
00075         memcpy(&c->consts[1], S->top - (nelems + 1), nelems * sizeof(TObject));
00076         S->top -= nelems;
00077         ttype(S->top - 1) = LUA_T_CLOSURE;
00078         (S->top - 1)->value.cl = c;
00079     }
00080 }
00081 
00082 /*
00083 ** Function to index a table.
00084 ** Receives the table at top-2 and the index at top-1.
00085 */
00086 void luaV_gettable() {
00087     Stack *S = &lua_state->stack;
00088     TObject *im;
00089     if (ttype(S->top - 2) != LUA_T_ARRAY)  // not a table, get "gettable" method
00090         im = luaT_getimbyObj(S->top - 2, IM_GETTABLE);
00091     else {  // object is a table...
00092         int32 tg = (S->top - 2)->value.a->htag;
00093         im = luaT_getim(tg, IM_GETTABLE);
00094         if (ttype(im) == LUA_T_NIL) {  // and does not have a "gettable" method
00095             TObject *h = luaH_get(avalue(S->top - 2), S->top - 1);
00096             if (h && ttype(h) != LUA_T_NIL) {
00097                 --S->top;
00098                 *(S->top - 1) = *h;
00099             } else if (ttype(im = luaT_getim(tg, IM_INDEX)) != LUA_T_NIL)
00100                 luaD_callTM(im, 2, 1);
00101             else {
00102                 --S->top;
00103                 ttype(S->top - 1) = LUA_T_NIL;
00104             }
00105             return;
00106         }
00107         // else it has a "gettable" method, go through to next command
00108     }
00109     // object is not a table, or it has a "gettable" method
00110     if (ttype(im) != LUA_T_NIL)
00111         luaD_callTM(im, 2, 1);
00112     else
00113         lua_error("indexed expression not a table");
00114 }
00115 
00116 /*
00117 ** Function to store indexed based on values at the stack.top
00118 ** mode = 0: raw store (without tag methods)
00119 ** mode = 1: normal store (with tag methods)
00120 ** mode = 2: "deep lua_state->stack.stack" store (with tag methods)
00121 */
00122 void luaV_settable(TObject *t, int32 mode) {
00123     struct Stack *S = &lua_state->stack;
00124     TObject *im = (mode == 0) ? nullptr : luaT_getimbyObj(t, IM_SETTABLE);
00125     if (ttype(t) == LUA_T_ARRAY && (!im || ttype(im) == LUA_T_NIL)) {
00126         TObject *h = luaH_set(avalue(t), t + 1);
00127         *h = *(S->top - 1);
00128         S->top -= (mode == 2) ? 1 : 3;
00129     } else {  // object is not a table, and/or has a specific "settable" method
00130         if (im && ttype(im) != LUA_T_NIL) {
00131             if (mode == 2) {
00132                 *(S->top + 1) = *(lua_state->stack.top - 1);
00133                 *(S->top) = *(t + 1);
00134                 *(S->top - 1) = *t;
00135                 S->top += 2;  // WARNING: caller must assure stack space
00136             }
00137             luaD_callTM(im, 3, 0);
00138         } else
00139             lua_error("indexed expression not a table");
00140     }
00141 }
00142 
00143 void luaV_getglobal(TaggedString *ts) {
00144     // WARNING: caller must assure stack space
00145     TObject *value = &ts->globalval;
00146     TObject *im = luaT_getimbyObj(value, IM_GETGLOBAL);
00147     if (ttype(im) == LUA_T_NIL) {  // default behavior
00148         *lua_state->stack.top++ = *value;
00149     } else {
00150         Stack *S = &lua_state->stack;
00151         ttype(S->top) = LUA_T_STRING;
00152         tsvalue(S->top) = ts;
00153         S->top++;
00154         *S->top++ = *value;
00155         luaD_callTM(im, 2, 1);
00156     }
00157 }
00158 
00159 void luaV_setglobal(TaggedString *ts) {
00160     TObject *oldvalue = &ts->globalval;
00161     TObject *im = luaT_getimbyObj(oldvalue, IM_SETGLOBAL);
00162     if (ttype(im) == LUA_T_NIL)  // default behavior */
00163         luaS_rawsetglobal(ts, --lua_state->stack.top);
00164     else {
00165         // WARNING: caller must assure stack space
00166         Stack *S = &lua_state->stack;
00167         TObject newvalue = *(S->top - 1);
00168         ttype(S->top - 1) = LUA_T_STRING;
00169         tsvalue(S->top - 1) = ts;
00170         *S->top++ = *oldvalue;
00171         *S->top++ = newvalue;
00172         luaD_callTM(im, 3, 0);
00173     }
00174 }
00175 
00176 static void call_binTM(IMS event, const char *msg) {
00177     TObject *im = luaT_getimbyObj(lua_state->stack.top - 2, event); // try first operand
00178     if (ttype(im) == LUA_T_NIL) {
00179         im = luaT_getimbyObj(lua_state->stack.top - 1, event);  // try second operand
00180         if (ttype(im) == LUA_T_NIL) {
00181             im = luaT_getim(0, event);  // try a 'global' i.m.
00182             if (ttype(im) == LUA_T_NIL)
00183                 lua_error(msg);
00184         }
00185     }
00186     lua_pushstring(luaT_eventname[event]);
00187     luaD_callTM(im, 3, 1);
00188 }
00189 
00190 
00191 static void call_arith(IMS event) {
00192     call_binTM(event, "unexpected type in arithmetic operation");
00193 }
00194 
00195 static void comparison(lua_Type ttype_less, lua_Type ttype_equal, lua_Type ttype_great, IMS op) {
00196     Stack *S = &lua_state->stack;
00197     TObject *l = S->top-2;
00198     TObject *r = S->top-1;
00199     int32 result;
00200     if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER)
00201         result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1;
00202     else if (ttype(l) == LUA_T_STRING && ttype(r) == LUA_T_STRING)
00203         result = strcoll(svalue(l), svalue(r));
00204     else {
00205         call_binTM(op, "unexpected type in comparison");
00206         return;
00207     }
00208     S->top--;
00209     nvalue(S->top - 1) = 1;
00210     ttype(S->top - 1) = (result < 0) ? ttype_less : (result == 0) ? ttype_equal : ttype_great;
00211 }
00212 
00213 void luaV_pack(StkId firstel, int32 nvararg, TObject *tab) {
00214     TObject *firstelem = lua_state->stack.stack + firstel;
00215     int32 i;
00216     if (nvararg < 0)
00217         nvararg = 0;
00218     avalue(tab) = luaH_new(nvararg + 1);  // +1 for field 'n'
00219     ttype(tab) = LUA_T_ARRAY;
00220     for (i = 0; i < nvararg; i++) {
00221         TObject index;
00222         ttype(&index) = LUA_T_NUMBER;
00223         nvalue(&index) = (float)i + 1;
00224         *(luaH_set(avalue(tab), &index)) = *(firstelem + i);
00225     }
00226     // store counter in field "n" */
00227     {
00228         TObject index, extra;
00229         ttype(&index) = LUA_T_STRING;
00230         tsvalue(&index) = luaS_new("n");
00231         ttype(&extra) = LUA_T_NUMBER;
00232         nvalue(&extra) = (float)nvararg;
00233         *(luaH_set(avalue(tab), &index)) = extra;
00234     }
00235 }
00236 
00237 static void adjust_varargs(StkId first_extra_arg) {
00238     TObject arg;
00239     luaV_pack(first_extra_arg, (lua_state->stack.top - lua_state->stack.stack) - first_extra_arg, &arg);
00240     luaD_adjusttop(first_extra_arg);
00241     *lua_state->stack.top++ = arg;
00242 }
00243 
00244 StkId luaV_execute(lua_Task *task) {
00245     if (!task->some_flag) {
00246         luaD_checkstack((*task->pc++) + EXTRA_STACK);
00247         if (*task->pc < ZEROVARARG) {
00248             luaD_adjusttop(task->base + *(task->pc++));
00249         } else {
00250             luaC_checkGC();
00251             adjust_varargs(task->base + (*task->pc++) - ZEROVARARG);
00252         }
00253         task->some_flag = 1;
00254     }
00255     lua_state->state_counter2++;
00256 
00257     while (1) {
00258         switch ((OpCode)(task->aux = *task->pc++)) {
00259         case PUSHNIL0:
00260             ttype(task->S->top++) = LUA_T_NIL;
00261             break;
00262         case PUSHNIL:
00263             task->aux = *task->pc++;
00264             do {
00265                 ttype(task->S->top++) = LUA_T_NIL;
00266             } while (task->aux--);
00267             break;
00268         case PUSHNUMBER:
00269             task->aux = *task->pc++;
00270             goto pushnumber;
00271         case PUSHNUMBERW:
00272             task->aux = next_word(task->pc);
00273             goto pushnumber;
00274         case PUSHNUMBER0:
00275         case PUSHNUMBER1:
00276         case PUSHNUMBER2:
00277             task->aux -= PUSHNUMBER0;
00278 pushnumber:
00279             ttype(task->S->top) = LUA_T_NUMBER;
00280             nvalue(task->S->top) = (float)task->aux;
00281             task->S->top++;
00282             break;
00283         case PUSHLOCAL:
00284             task->aux = *task->pc++;
00285             goto pushlocal;
00286         case PUSHLOCAL0:
00287         case PUSHLOCAL1:
00288         case PUSHLOCAL2:
00289         case PUSHLOCAL3:
00290         case PUSHLOCAL4:
00291         case PUSHLOCAL5:
00292         case PUSHLOCAL6:
00293         case PUSHLOCAL7:
00294             task->aux -= PUSHLOCAL0;
00295 pushlocal:
00296             *task->S->top++ = *((task->S->stack + task->base) + task->aux);
00297             break;
00298         case GETGLOBALW:
00299             task->aux = next_word(task->pc);
00300             goto getglobal;
00301         case GETGLOBAL:
00302             task->aux = *task->pc++;
00303             goto getglobal;
00304         case GETGLOBAL0:
00305         case GETGLOBAL1:
00306         case GETGLOBAL2:
00307         case GETGLOBAL3:
00308         case GETGLOBAL4:
00309         case GETGLOBAL5:
00310         case GETGLOBAL6:
00311         case GETGLOBAL7:
00312             task->aux -= GETGLOBAL0;
00313 getglobal:
00314             luaV_getglobal(tsvalue(&task->consts[task->aux]));
00315             break;
00316         case GETTABLE:
00317             luaV_gettable();
00318             break;
00319         case GETDOTTEDW:
00320             task->aux = next_word(task->pc); goto getdotted;
00321         case GETDOTTED:
00322             task->aux = *task->pc++;
00323             goto getdotted;
00324         case GETDOTTED0:
00325         case GETDOTTED1:
00326         case GETDOTTED2:
00327         case GETDOTTED3:
00328         case GETDOTTED4:
00329         case GETDOTTED5:
00330         case GETDOTTED6:
00331         case GETDOTTED7:
00332             task->aux -= GETDOTTED0;
00333 getdotted:
00334             *task->S->top++ = task->consts[task->aux];
00335             luaV_gettable();
00336             break;
00337         case PUSHSELFW:
00338             task->aux = next_word(task->pc);
00339             goto pushself;
00340         case PUSHSELF:
00341             task->aux = *task->pc++;
00342             goto pushself;
00343         case PUSHSELF0:
00344         case PUSHSELF1:
00345         case PUSHSELF2:
00346         case PUSHSELF3:
00347         case PUSHSELF4:
00348         case PUSHSELF5:
00349         case PUSHSELF6:
00350         case PUSHSELF7:
00351             task->aux -= PUSHSELF0;
00352 pushself:
00353             {
00354                 TObject receiver = *(task->S->top - 1);
00355                 *task->S->top++ = task->consts[task->aux];
00356                 luaV_gettable();
00357                 *task->S->top++ = receiver;
00358                 break;
00359             }
00360         case PUSHCONSTANTW:
00361             task->aux = next_word(task->pc);
00362             goto pushconstant;
00363         case PUSHCONSTANT:
00364             task->aux = *task->pc++; goto pushconstant;
00365         case PUSHCONSTANT0:
00366         case PUSHCONSTANT1:
00367         case PUSHCONSTANT2:
00368         case PUSHCONSTANT3:
00369         case PUSHCONSTANT4:
00370         case PUSHCONSTANT5:
00371         case PUSHCONSTANT6:
00372         case PUSHCONSTANT7:
00373             task->aux -= PUSHCONSTANT0;
00374 pushconstant:
00375             *task->S->top++ = task->consts[task->aux];
00376             break;
00377         case PUSHUPVALUE:
00378             task->aux = *task->pc++;
00379             goto pushupvalue;
00380         case PUSHUPVALUE0:
00381         case PUSHUPVALUE1:
00382             task->aux -= PUSHUPVALUE0;
00383 pushupvalue:
00384             *task->S->top++ = task->cl->consts[task->aux + 1];
00385             break;
00386         case SETLOCAL:
00387             task->aux = *task->pc++;
00388             goto setlocal;
00389         case SETLOCAL0:
00390         case SETLOCAL1:
00391         case SETLOCAL2:
00392         case SETLOCAL3:
00393         case SETLOCAL4:
00394         case SETLOCAL5:
00395         case SETLOCAL6:
00396         case SETLOCAL7:
00397             task->aux -= SETLOCAL0;
00398 setlocal:
00399             *((task->S->stack + task->base) + task->aux) = *(--task->S->top);
00400             break;
00401         case SETGLOBALW:
00402             task->aux = next_word(task->pc);
00403             goto setglobal;
00404         case SETGLOBAL:
00405             task->aux = *task->pc++;
00406             goto setglobal;
00407         case SETGLOBAL0:
00408         case SETGLOBAL1:
00409         case SETGLOBAL2:
00410         case SETGLOBAL3:
00411         case SETGLOBAL4:
00412         case SETGLOBAL5:
00413         case SETGLOBAL6:
00414         case SETGLOBAL7:
00415             task->aux -= SETGLOBAL0;
00416 setglobal:
00417             luaV_setglobal(tsvalue(&task->consts[task->aux]));
00418             break;
00419         case SETTABLE0:
00420             luaV_settable(task->S->top - 3, 1);
00421             break;
00422         case SETTABLE:
00423             luaV_settable(task->S->top - 3 - (*task->pc++), 2);
00424             break;
00425         case SETLISTW:
00426             task->aux = next_word(task->pc);
00427             task->aux *= LFIELDS_PER_FLUSH;
00428             goto setlist;
00429         case SETLIST:
00430             task->aux = *(task->pc++) * LFIELDS_PER_FLUSH;
00431             goto setlist;
00432         case SETLIST0:
00433             task->aux = 0;
00434 setlist:
00435             {
00436                 int32 n = *(task->pc++);
00437                 TObject *arr = task->S->top - n - 1;
00438                 for (; n; n--) {
00439                     ttype(task->S->top) = LUA_T_NUMBER;
00440                     nvalue(task->S->top) = (float)(n + task->aux);
00441                     *(luaH_set(avalue(arr), task->S->top)) = *(task->S->top - 1);
00442                     task->S->top--;
00443             }
00444             break;
00445         }
00446         case SETMAP0:
00447             task->aux = 0;
00448             goto setmap;
00449         case SETMAP:
00450             task->aux = *task->pc++;
00451 setmap:
00452             {
00453                 TObject *arr = task->S->top - (2 * task->aux) - 3;
00454                 do {
00455                     *(luaH_set(avalue(arr), task->S->top - 2)) = *(task->S->top - 1);
00456                     task->S->top -= 2;
00457                 } while (task->aux--);
00458                 break;
00459             }
00460         case POP:
00461             task->aux = *task->pc++;
00462             goto pop;
00463         case POP0:
00464         case POP1:
00465             task->aux -= POP0;
00466 pop:
00467             task->S->top -= (task->aux + 1);
00468             break;
00469         case CREATEARRAYW:
00470             task->aux = next_word(task->pc);
00471             goto createarray;
00472         case CREATEARRAY0:
00473         case CREATEARRAY1:
00474             task->aux -= CREATEARRAY0;
00475             goto createarray;
00476         case CREATEARRAY:
00477             task->aux = *task->pc++;
00478 createarray:
00479             luaC_checkGC();
00480             avalue(task->S->top) = luaH_new(task->aux);
00481             ttype(task->S->top) = LUA_T_ARRAY;
00482             task->S->top++;
00483             break;
00484         case EQOP:
00485         case NEQOP:
00486             {
00487                 int32 res = luaO_equalObj(task->S->top - 2, task->S->top - 1);
00488                 task->S->top--;
00489                 if (task->aux == NEQOP)
00490                     res = !res;
00491                 ttype(task->S->top - 1) = res ? LUA_T_NUMBER : LUA_T_NIL;
00492                 nvalue(task->S->top - 1) = 1;
00493                 break;
00494             }
00495         case LTOP:
00496             comparison(LUA_T_NUMBER, LUA_T_NIL, LUA_T_NIL, IM_LT);
00497             break;
00498         case LEOP:
00499             comparison(LUA_T_NUMBER, LUA_T_NUMBER, LUA_T_NIL, IM_LE);
00500             break;
00501         case GTOP:
00502             comparison(LUA_T_NIL, LUA_T_NIL, LUA_T_NUMBER, IM_GT);
00503             break;
00504         case GEOP:
00505             comparison(LUA_T_NIL, LUA_T_NUMBER, LUA_T_NUMBER, IM_GE);
00506             break;
00507         case ADDOP:
00508             {
00509                 TObject *l = task->S->top - 2;
00510                 TObject *r = task->S->top - 1;
00511                 if (tonumber(r) || tonumber(l))
00512                     call_arith(IM_ADD);
00513                 else {
00514                     nvalue(l) += nvalue(r);
00515                     --task->S->top;
00516                 }
00517             break;
00518             }
00519         case SUBOP:
00520             {
00521                 TObject *l = task->S->top - 2;
00522                 TObject *r = task->S->top - 1;
00523                 if (tonumber(r) || tonumber(l))
00524                     call_arith(IM_SUB);
00525                 else {
00526                     nvalue(l) -= nvalue(r);
00527                     --task->S->top;
00528                 }
00529                 break;
00530             }
00531         case MULTOP:
00532             {
00533                 TObject *l = task->S->top - 2;
00534                 TObject *r = task->S->top - 1;
00535                 if (tonumber(r) || tonumber(l))
00536                     call_arith(IM_MUL);
00537                 else {
00538                     nvalue(l) *= nvalue(r);
00539                     --task->S->top;
00540                 }
00541                 break;
00542             }
00543         case DIVOP:
00544             {
00545                 TObject *l = task->S->top - 2;
00546                 TObject *r = task->S->top - 1;
00547                 if (tonumber(r) || tonumber(l))
00548                     call_arith(IM_DIV);
00549                 else {
00550                     nvalue(l) /= nvalue(r);
00551                     --task->S->top;
00552                 }
00553                 break;
00554             }
00555         case POWOP:
00556             call_arith(IM_POW);
00557             break;
00558         case CONCOP:
00559             {
00560                 TObject *l = task->S->top - 2;
00561                 TObject *r = task->S->top - 1;
00562                 if (tostring(l) || tostring(r))
00563                     call_binTM(IM_CONCAT, "unexpected type for concatenation");
00564                 else {
00565                     tsvalue(l) = strconc(svalue(l), svalue(r));
00566                     --task->S->top;
00567                 }
00568                 luaC_checkGC();
00569                 break;
00570             }
00571         case MINUSOP:
00572             if (tonumber(task->S->top - 1)) {
00573                 ttype(task->S->top) = LUA_T_NIL;
00574                 task->S->top++;
00575                 call_arith(IM_UNM);
00576             } else
00577                 nvalue(task->S->top - 1) = -nvalue(task->S->top - 1);
00578             break;
00579         case NOTOP:
00580             ttype(task->S->top - 1) = (ttype(task->S->top - 1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL;
00581             nvalue(task->S->top - 1) = 1;
00582             break;
00583         case ONTJMPW:
00584             task->aux = next_word(task->pc);
00585             goto ontjmp;
00586         case ONTJMP:
00587             task->aux = *task->pc++;
00588 ontjmp:
00589             if (ttype(task->S->top - 1) != LUA_T_NIL)
00590                 task->pc += task->aux;
00591             else
00592                 task->S->top--;
00593             break;
00594         case ONFJMPW:
00595             task->aux = next_word(task->pc);
00596             goto onfjmp;
00597         case ONFJMP:
00598             task->aux = *task->pc++;
00599 onfjmp:
00600             if (ttype(task->S->top - 1) == LUA_T_NIL)
00601                 task->pc += task->aux;
00602             else
00603                 task->S->top--;
00604             break;
00605         case JMPW:
00606             task->aux = next_word(task->pc);
00607             goto jmp;
00608         case JMP:
00609             task->aux = *task->pc++;
00610 jmp:
00611             task->pc += task->aux;
00612             break;
00613         case IFFJMPW:
00614             task->aux = next_word(task->pc);
00615             goto iffjmp;
00616         case IFFJMP:
00617             task->aux = *task->pc++;
00618 iffjmp:
00619             if (ttype(--task->S->top) == LUA_T_NIL)
00620                 task->pc += task->aux;
00621             break;
00622         case IFTUPJMPW:
00623             task->aux = next_word(task->pc);
00624             goto iftupjmp;
00625         case IFTUPJMP:
00626             task->aux = *task->pc++;
00627 iftupjmp:
00628             if (ttype(--task->S->top) != LUA_T_NIL)
00629                 task->pc -= task->aux;
00630             break;
00631         case IFFUPJMPW:
00632             task->aux = next_word(task->pc);
00633             goto iffupjmp;
00634         case IFFUPJMP:
00635             task->aux = *task->pc++;
00636 iffupjmp:
00637             if (ttype(--task->S->top) == LUA_T_NIL)
00638                 task->pc -= task->aux;
00639             break;
00640         case CLOSURE:
00641             task->aux = *task->pc++;
00642             goto closure;
00643         case CLOSURE0:
00644         case CLOSURE1:
00645             task->aux -= CLOSURE0;
00646 closure:
00647             luaV_closure(task->aux);
00648             luaC_checkGC();
00649             break;
00650       case CALLFUNC:
00651             task->aux = *task->pc++;
00652             goto callfunc;
00653       case CALLFUNC0:
00654       case CALLFUNC1:
00655             task->aux -= CALLFUNC0;
00656 callfunc:
00657             lua_state->state_counter2--;
00658             return -((task->S->top - task->S->stack) - (*task->pc++));
00659         case ENDCODE:
00660             task->S->top = task->S->stack + task->base;
00661             // fall through
00662         case RETCODE:
00663             lua_state->state_counter2--;
00664             return (task->base + ((task->aux == 123) ? *task->pc : 0));
00665         case SETLINEW:
00666             task->aux = next_word(task->pc);
00667             goto setline;
00668         case SETLINE:
00669             task->aux = *task->pc++;
00670 setline:
00671             if ((task->S->stack + task->base - 1)->ttype != LUA_T_LINE) {
00672                 // open space for LINE value */
00673                 luaD_openstack((task->S->top - task->S->stack) - task->base);
00674                 task->base++;
00675                 (task->S->stack + task->base - 1)->ttype = LUA_T_LINE;
00676             }
00677             (task->S->stack + task->base - 1)->value.i = task->aux;
00678             if (lua_linehook)
00679                 luaD_lineHook(task->aux);
00680             break;
00681 #ifdef LUA_DEBUG
00682         default:
00683             LUA_INTERNALERROR("internal error - opcode doesn't match");
00684 #endif
00685         }
00686     }
00687 }
00688 
00689 } // end of namespace Grim


Generated on Sat Jul 13 2019 05:01:06 for ResidualVM by doxygen 1.7.1
curved edge   curved edge