vm changes to support arrays

Dibyendu Majumdar 9 years ago
parent 10b9f6341b
commit 1702668eac

@ -227,6 +227,9 @@ OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */
OP_EXTRAARG,/* Ax extra (larger) argument for previous opcode */
OP_RAVI_NEWARRAYI, /* A R(A) := array of int */
OP_RAVI_NEWARRAYF, /* A R(A) := array of float */
OP_RAVI_LOADIZ, /* A R(A) := tointeger(0) */
OP_RAVI_LOADFZ, /* A R(A) := tonumber(0) */

@ -65,6 +65,9 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
"VARARG",
"EXTRAARG",
"NEWARRAYI", /* A R(A) := array of int */
"NEWARRAYF", /* A R(A) := array of float */
"LOADIZ", /* A R(A) := tointeger(0) */
"LOADFZ", /* A R(A) := tonumber(0) */
@ -254,8 +257,11 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
, opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_LOADIZ A R(A) := tointeger(0) */
, opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_LOADFZ A R(A) := tonumber(0) */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* A R(A) := array of int */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* A R(A) := array of float */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_LOADIZ A R(A) := tointeger(0) */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_LOADFZ A R(A) := tonumber(0) */
,opmode(0, 1, OpArgR, OpArgN, iABC)/* OP_RAVI_UNMF A B R(A) := -R(B) floating point */
,opmode(0, 1, OpArgR, OpArgN, iABC)/* OP_RAVI_UNMI A B R(A) := -R(B) integer */
@ -439,6 +445,9 @@ LUAI_DDEF const lu_byte luaP_optypes[NUM_OPCODES] = {
, LUA_TNONE /* OP_VARARG */
, LUA_TNONE /* OP_EXTRAARG */
, LUA_TNUMINT, /* A R(A) := array of int */
, LUA_TNUMFLT, /* A R(A) := array of float */
, LUA_TNUMINT /* OP_RAVI_LOADIZ A R(A) := tointeger(0) */
, LUA_TNUMFLT /* OP_RAVI_LOADFZ A R(A) := tonumber(0) */

@ -1210,6 +1210,18 @@ newframe: /* reentry point when frame changes (call/return) */
int c = INDEXK(GETARG_C(i));
switch (OP(op)) {
case OP(OP_RAVI_NEWARRAYI): {
Table *t = raviH_new(L, RAVI_TARRAYINT);
sethvalue(L, ra, t);
checkGC(L, ra + 1);
} break;
case OP(OP_RAVI_NEWARRAYF): {
Table *t = raviH_new(L, RAVI_TARRAYFLT);
sethvalue(L, ra, t);
checkGC(L, ra + 1);
} break;
case OP(OP_RAVI_LOADIZ): {
setivalue(ra, 0);
} break;

Loading…
Cancel
Save