array opcodes for get/set

pull/81/head
Dibyendu Majumdar 9 years ago
parent 7f65ba6224
commit e26f5d53b5

@ -286,33 +286,6 @@ OP_RAVI_DIVIIKR,/* A B C R(A) := Kst(B) / R(C) */
OP_RAVI_DIVIIRK,/* A B C R(A) := R(B) / Kst(C) */
OP_RAVI_DIVIIRR,/* A B C R(A) := R(B) / R(C) */
OP_RAVI_EQFFKK,/* A B C if ((Kst(B) == Kst(C)) ~= A) then pc++ */
OP_RAVI_EQFFKR,/* A B C if ((Kst(B) == R(C)) ~= A) then pc++ */
OP_RAVI_EQFFRK,/* A B C if ((R(B) == Kst(C)) ~= A) then pc++ */
OP_RAVI_EQFFRR,/* A B C if ((R(B) == R(C)) ~= A) then pc++ */
OP_RAVI_EQIIKK,/* A B C if ((Kst(B) == Kst(C)) ~= A) then pc++ */
OP_RAVI_EQIIKR,/* A B C if ((Kst(B) == R(C)) ~= A) then pc++ */
OP_RAVI_EQIIRK,/* A B C if ((R(B) == Kst(C)) ~= A) then pc++ */
OP_RAVI_EQIIRR,/* A B C if ((R(B) == R(C)) ~= A) then pc++ */
OP_RAVI_LTFFKK,/* A B C if ((Kst(B) < Kst(C)) ~= A) then pc++ */
OP_RAVI_LTFFKR,/* A B C if ((Kst(B) < R(C)) ~= A) then pc++ */
OP_RAVI_LTFFRK,/* A B C if ((R(B) < Kst(C)) ~= A) then pc++ */
OP_RAVI_LTFFRR,/* A B C if ((R(B) < R(C)) ~= A) then pc++ */
OP_RAVI_LTIIKK,/* A B C if ((Kst(B) < Kst(C)) ~= A) then pc++ */
OP_RAVI_LTIIKR,/* A B C if ((Kst(B) < R(C)) ~= A) then pc++ */
OP_RAVI_LTIIRK,/* A B C if ((R(B) < Kst(C)) ~= A) then pc++ */
OP_RAVI_LTIIRR,/* A B C if ((R(B) < R(C)) ~= A) then pc++ */
OP_RAVI_LEFFKK,/* A B C if ((Kst(B) <= Kst(C)) ~= A) then pc++ */
OP_RAVI_LEFFKR,/* A B C if ((Kst(B) <= R(C)) ~= A) then pc++ */
OP_RAVI_LEFFRK,/* A B C if ((R(B) <= Kst(C)) ~= A) then pc++ */
OP_RAVI_LEFFRR,/* A B C if ((R(B) <= R(C)) ~= A) then pc++ */
OP_RAVI_LEIIKK,/* A B C if ((Kst(B) <= Kst(C)) ~= A) then pc++ */
OP_RAVI_LEIIKR,/* A B C if ((Kst(B) <= R(C)) ~= A) then pc++ */
OP_RAVI_LEIIRK,/* A B C if ((R(B) <= Kst(C)) ~= A) then pc++ */
OP_RAVI_LEIIRR,/* A B C if ((R(B) <= R(C)) ~= A) then pc++ */
OP_RAVI_TOINT, /* A R(A) := toint(R(A)) */
OP_RAVI_TOFLT, /* A R(A) := tofloat(R(A)) */
OP_RAVI_TOARRAYI, /* A R(A) := to_arrayi(R(A)) */
@ -323,36 +296,16 @@ OP_RAVI_MOVEF, /* A B R(A) := R(B), check R(B) is float */
OP_RAVI_MOVEAI, /* A B R(A) := R(B), check R(B) is array of int */
OP_RAVI_MOVEAF, /* A B R(A) := R(B), check R(B) is array of floats */
OP_RAVI_ARRAYGET_SIK,/* A B C R(A) := R(B)[Kst(C)] */
OP_RAVI_ARRAYGET_SIR,/* A B C R(A) := R(B)[R(C)] */
OP_RAVI_ARRAYGET_IIK,/* A B C R(A) := R(B)[Kst(C)] */
OP_RAVI_ARRAYGET_IIR,/* A B C R(A) := R(B)[R(C)] */
OP_RAVI_ARRAYGET_FIK,/* A B C R(A) := R(B)[Kst(C)] */
OP_RAVI_ARRAYGET_FIR,/* A B C R(A) := R(B)[R(C)] */
OP_RAVI_ARRAYGET_LIK,/* A B C R(A) := R(B)[Kst(C)] */
OP_RAVI_ARRAYGET_LIR,/* A B C R(A) := R(B)[R(C)] */
OP_RAVI_ARRAYSET_ISKK,/* A B C R(A)[Kst(B)] := Kst(C) */
OP_RAVI_ARRAYSET_ISKR,/* A B C R(A)[Kst(B)] := R(C) */
OP_RAVI_ARRAYSET_ISRK,/* A B C R(A)[R(B)] := Kst(C) */
OP_RAVI_ARRAYSET_ISRR,/* A B C R(A)[R(B)] := R(C) */
OP_RAVI_ARRAYSET_IIKK,/* A B C R(A)[Kst(B)] := Kst(C) */
OP_RAVI_ARRAYSET_IIKR,/* A B C R(A)[Kst(B)] := R(C) */
OP_RAVI_ARRAYSET_IIRK,/* A B C R(A)[R(B)] := Kst(C) */
OP_RAVI_ARRAYSET_IIRR,/* A B C R(A)[R(B)] := R(C) */
OP_RAVI_ARRAYSET_IFKK,/* A B C R(A)[Kst(B)] := Kst(C) */
OP_RAVI_ARRAYSET_IFKR,/* A B C R(A)[Kst(B)] := R(C) */
OP_RAVI_ARRAYSET_IFRK,/* A B C R(A)[R(B)] := Kst(C) */
OP_RAVI_ARRAYSET_IFRR,/* A B C R(A)[R(B)] := R(C) */
OP_RAVI_ARRAYSET_ILKK,/* A B C R(A)[Kst(B)] := Kst(C) */
OP_RAVI_ARRAYSET_ILKR,/* A B C R(A)[Kst(B)] := R(C) */
OP_RAVI_ARRAYSET_ILRK,/* A B C R(A)[R(B)] := Kst(C) */
OP_RAVI_ARRAYSET_ILRR,/* A B C R(A)[R(B)] := R(C) */
OP_RAVI_GETTABLE_AI,/* A B C R(A) := R(B)[RK(C)] where R(B) is array of integers and RK(C) is int */
OP_RAVI_GETTABLE_AF,/* A B C R(A) := R(B)[RK(C)] where R(B) is array of floats and RK(C) is int */
OP_RAVI_SETTABLE_AI,/* A B C R(A)[RK(B)] := RK(C) where RK(B) is an int, R(A) is array of ints, and RK(C) is an int */
OP_RAVI_SETTABLE_AF,/* A B C R(A)[RK(B)] := RK(C) where RK(B) is an int, R(A) is array of floats, and RK(C) is an float */
} OpCode;
#define NUM_OPCODES (cast(int, OP_RAVI_ARRAYSET_ILRR) + 1)
#define NUM_OPCODES (cast(int, OP_RAVI_SETTABLE_AF) + 1)
/*===========================================================================
Notes:

@ -51,6 +51,7 @@ typedef struct expdesc {
short idx; /* index (R/K) */
lu_byte t; /* table (register or upvalue) */
lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
ravitype_t key_type; /* key type */
} ind;
int info; /* for generic use */
lua_Number nval; /* for VKFLT */

@ -472,12 +472,19 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
freereg(fs, e->u.ind.idx);
if (e->u.ind.vt == VLOCAL) { /* 't' is in a register? */
freereg(fs, e->u.ind.t);
op = OP_GETTABLE;
/* table access - set specialized op codes if array types are detected */
if (e->ravi_type == RAVI_TARRAYFLT && e->u.ind.key_type == RAVI_TNUMINT)
op = OP_RAVI_GETTABLE_AF;
else if (e->ravi_type == RAVI_TARRAYINT && e->u.ind.key_type == RAVI_TNUMINT)
op = OP_RAVI_GETTABLE_AI;
else
op = OP_GETTABLE;
if (e->ravi_type == RAVI_TARRAYFLT || e->ravi_type == RAVI_TARRAYINT)
/* set the type of resulting expression */
e->ravi_type = e->ravi_type == RAVI_TARRAYFLT ? RAVI_TNUMFLT : RAVI_TNUMINT;
}
e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx);
e->k = VRELOCABLE;
if (op == OP_GETTABLE && (e->ravi_type == RAVI_TARRAYFLT || e->ravi_type == RAVI_TARRAYINT))
e->ravi_type = e->ravi_type == RAVI_TARRAYFLT ? RAVI_TNUMFLT : RAVI_TNUMINT;
DEBUG_EXPR(raviY_printf(fs, "luaK_dischargevars (VINDEXED->VRELOCABLE) %e\n", e));
break;
}
@ -727,6 +734,13 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
}
case VINDEXED: {
OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP;
if (op == OP_SETTABLE) {
/* table value set - if array access then use specialized versions */
if (var->ravi_type == RAVI_TARRAYFLT && var->u.ind.key_type == RAVI_TNUMINT)
op = OP_RAVI_SETTABLE_AF;
else if (var->ravi_type == RAVI_TARRAYINT && var->u.ind.key_type == RAVI_TNUMINT)
op = OP_RAVI_SETTABLE_AI;
}
int e = luaK_exp2RK(fs, ex);
luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
break;
@ -865,6 +879,7 @@ static void codenot (FuncState *fs, expdesc *e) {
void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
lua_assert(!hasjumps(t));
t->u.ind.t = t->u.info;
t->u.ind.key_type = k->ravi_type; /* RAVI record the key type */
t->u.ind.idx = luaK_exp2RK(fs, k);
t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL
: check_exp(vkisinreg(t->k), VLOCAL);

@ -124,33 +124,6 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
"DIVIIRK",/* A B C R(A) := R(B) / Kst(C) */
"DIVIIRR",/* A B C R(A) := R(B) / R(C) */
"EQFFKK",/* A B C if ((Kst(B) == Kst(C)) ~= A) then pc++ */
"EQFFKR",/* A B C if ((Kst(B) == R(C)) ~= A) then pc++ */
"EQFFRK",/* A B C if ((R(B) == Kst(C)) ~= A) then pc++ */
"EQFFRR",/* A B C if ((R(B) == R(C)) ~= A) then pc++ */
"EQIIKK",/* A B C if ((Kst(B) == Kst(C)) ~= A) then pc++ */
"EQIIKR",/* A B C if ((Kst(B) == R(C)) ~= A) then pc++ */
"EQIIRK",/* A B C if ((R(B) == Kst(C)) ~= A) then pc++ */
"EQIIRR",/* A B C if ((R(B) == R(C)) ~= A) then pc++ */
"LTFFKK",/* A B C if ((Kst(B) < Kst(C)) ~= A) then pc++ */
"LTFFKR",/* A B C if ((Kst(B) < R(C)) ~= A) then pc++ */
"LTFFRK",/* A B C if ((R(B) < Kst(C)) ~= A) then pc++ */
"LTFFRR",/* A B C if ((R(B) < R(C)) ~= A) then pc++ */
"LTIIKK",/* A B C if ((Kst(B) < Kst(C)) ~= A) then pc++ */
"LTIIKR",/* A B C if ((Kst(B) < R(C)) ~= A) then pc++ */
"LTIIRK",/* A B C if ((R(B) < Kst(C)) ~= A) then pc++ */
"LTIIRR",/* A B C if ((R(B) < R(C)) ~= A) then pc++ */
"LEFFKK",/* A B C if ((Kst(B) <= Kst(C)) ~= A) then pc++ */
"LEFFKR",/* A B C if ((Kst(B) <= R(C)) ~= A) then pc++ */
"LEFFRK",/* A B C if ((R(B) <= Kst(C)) ~= A) then pc++ */
"LEFFRR",/* A B C if ((R(B) <= R(C)) ~= A) then pc++ */
"LEIIKK",/* A B C if ((Kst(B) <= Kst(C)) ~= A) then pc++ */
"LEIIKR",/* A B C if ((Kst(B) <= R(C)) ~= A) then pc++ */
"LEIIRK",/* A B C if ((R(B) <= Kst(C)) ~= A) then pc++ */
"LEIIRR",/* A B C if ((R(B) <= R(C)) ~= A) then pc++ */
"TOINT", /* A R(A) := toint(R(A)) */
"TOFLT", /* A R(A) := tofloat(R(A)) */
"TOARRAYI", /* A R(A) := to_arrayi(R(A)) */
@ -161,31 +134,11 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
"MOVEAI", /* A B R(A) := R(B), check R(B) is array of int */
"MOVEAF", /* A B R(A) := R(B), check R(B) is array of floats */
"ARRAYGET_SIK",/* A B C R(A) := R(B)[Kst(C)] */
"ARRAYGET_SIR",/* A B C R(A) := R(B)[R(C)] */
"ARRAYGET_IIK",/* A B C R(A) := R(B)[Kst(C)] */
"ARRAYGET_IIR",/* A B C R(A) := R(B)[R(C)] */
"ARRAYGET_FIK",/* A B C R(A) := R(B)[Kst(C)] */
"ARRAYGET_FIR",/* A B C R(A) := R(B)[R(C)] */
"ARRAYGET_LIK",/* A B C R(A) := R(B)[Kst(C)] */
"ARRAYGET_LIR",/* A B C R(A) := R(B)[R(C)] */
"ARRAYSET_ISKK",/* A B C R(A)[Kst(B)] := Kst(C) */
"ARRAYSET_ISKR",/* A B C R(A)[Kst(B)] := R(C) */
"ARRAYSET_ISRK",/* A B C R(A)[R(B)] := Kst(C) */
"ARRAYSET_ISRR",/* A B C R(A)[R(B)] := R(C) */
"ARRAYSET_IIKK",/* A B C R(A)[Kst(B)] := Kst(C) */
"ARRAYSET_IIKR",/* A B C R(A)[Kst(B)] := R(C) */
"ARRAYSET_IIRK",/* A B C R(A)[R(B)] := Kst(C) */
"ARRAYSET_IIRR",/* A B C R(A)[R(B)] := R(C) */
"ARRAYSET_IFKK",/* A B C R(A)[Kst(B)] := Kst(C) */
"ARRAYSET_IFKR",/* A B C R(A)[Kst(B)] := R(C) */
"ARRAYSET_IFRK",/* A B C R(A)[R(B)] := Kst(C) */
"ARRAYSET_IFRR",/* A B C R(A)[R(B)] := R(C) */
"ARRAYSET_ILKK",/* A B C R(A)[Kst(B)] := Kst(C) */
"ARRAYSET_ILKR",/* A B C R(A)[Kst(B)] := R(C) */
"ARRAYSET_ILRK",/* A B C R(A)[R(B)] := Kst(C) */
"ARRAYSET_ILRR",/* A B C R(A)[R(B)] := R(C) */
"GETTABLE_AI",/* A B C R(A) := R(B)[RK(C)] where R(B) is array of integers and RK(C) is int */
"GETTABLE_AF",/* A B C R(A) := R(B)[RK(C)] where R(B) is array of floats and RK(C) is int */
"SETTABLE_AI",/* A B C R(A)[RK(B)] := RK(C) where RK(B) is an int, R(A) is array of ints, and RK(C) is an int */
"SETTABLE_AF",/* A B C R(A)[RK(B)] := RK(C) where RK(B) is an int, R(A) is array of floats, and RK(C) is an float */
NULL
};
@ -302,33 +255,6 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
,opmode(0, 1, OpArgR, OpArgK, iABC) /*RAVI_DIVIIRK A B C R(A) := R(B) / Kst(C) */
,opmode(0, 1, OpArgR, OpArgR, iABC) /*RAVI_DIVIIRR A B C R(A) := R(B) / R(C) */
,opmode(1, 0, OpArgK, OpArgK, iABC) /*RAVI_EQFFKK A B C if ((Kst(B) == Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgR, iABC) /*RAVI_EQFFKR A B C if ((Kst(B) == R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgK, iABC) /*RAVI_EQFFRK A B C if ((R(B) == Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgR, iABC) /*RAVI_EQFFRR A B C if ((R(B) == R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgK, iABC) /*RAVI_EQIIKK A B C if ((Kst(B) == Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgR, iABC) /*RAVI_EQIIKR A B C if ((Kst(B) == R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgK, iABC) /*RAVI_EQIIRK A B C if ((R(B) == Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgR, iABC) /*RAVI_EQIIRR A B C if ((R(B) == R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgK, iABC) /*RAVI_LTFFKK A B C if ((Kst(B) < Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgR, iABC) /*RAVI_LTFFKR A B C if ((Kst(B) < R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgK, iABC) /*RAVI_LTFFRK A B C if ((R(B) < Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgR, iABC) /*RAVI_LTFFRR A B C if ((R(B) < R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgK, iABC) /*RAVI_LTIIKK A B C if ((Kst(B) < Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgR, iABC) /*RAVI_LTIIKR A B C if ((Kst(B) < R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgK, iABC) /*RAVI_LTIIRK A B C if ((R(B) < Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgR, iABC) /*RAVI_LTIIRR A B C if ((R(B) < R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgK, iABC) /*RAVI_LEFFKK A B C if ((Kst(B) <= Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgR, iABC) /*RAVI_LEFFKR A B C if ((Kst(B) <= R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgK, iABC) /*RAVI_LEFFRK A B C if ((R(B) <= Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgR, iABC) /*RAVI_LEFFRR A B C if ((R(B) <= R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgK, iABC) /*RAVI_LEIIKK A B C if ((Kst(B) <= Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgK, OpArgR, iABC) /*RAVI_LEIIKR A B C if ((Kst(B) <= R(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgK, iABC) /*RAVI_LEIIRK A B C if ((R(B) <= Kst(C)) ~= A) then pc++ */
,opmode(1, 0, OpArgR, OpArgR, iABC) /*RAVI_LEIIRR A B C if ((R(B) <= R(C)) ~= A) then pc++ */
, opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_TOINT A R(A) := toint(R(A)) */
, opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_TOFLT A R(A) := tonumber(R(A)) */
, opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_TOARRAYI A R(A) := check_array_of_int(R(A)) */
@ -339,31 +265,11 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
, opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_RAVI_MOVEAI A B R(A) := R(B), check R(B) is array of int */
, opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_RAVI_MOVEAF A B R(A) := R(B), check R(B) is array of floats */
,opmode(0, 1, OpArgR, OpArgK, iABC) /*RAVI_ARRAYGET_SIK A B C R(A) := R(B)[Kst(C)] */
,opmode(0, 1, OpArgR, OpArgR, iABC) /*RAVI_ARRAYGET_SIR A B C R(A) := R(B)[R(C)] */
,opmode(0, 1, OpArgR, OpArgK, iABC) /*RAVI_ARRAYGET_IIK A B C R(A) := R(B)[Kst(C)] */
,opmode(0, 1, OpArgR, OpArgR, iABC) /*RAVI_ARRAYGET_IIR A B C R(A) := R(B)[R(C)] */
,opmode(0, 1, OpArgR, OpArgK, iABC) /*RAVI_ARRAYGET_FIK A B C R(A) := R(B)[Kst(C)] */
,opmode(0, 1, OpArgR, OpArgR, iABC) /*RAVI_ARRAYGET_FIR A B C R(A) := R(B)[R(C)] */
,opmode(0, 1, OpArgR, OpArgK, iABC) /*RAVI_ARRAYGET_LIK A B C R(A) := R(B)[Kst(C)] */
,opmode(0, 1, OpArgR, OpArgR, iABC) /*RAVI_ARRAYGET_LIR A B C R(A) := R(B)[R(C)] */
,opmode(0, 0, OpArgK, OpArgK, iABC) /*RAVI_ARRAYSET_ISKK A B C R(A)[Kst(B)] := Kst(C) */
,opmode(0, 0, OpArgK, OpArgR, iABC) /*RAVI_ARRAYSET_ISKR A B C R(A)[Kst(B)] := R(C) */
,opmode(0, 0, OpArgR, OpArgK, iABC) /*RAVI_ARRAYSET_ISRK A B C R(A)[R(B)] := Kst(C) */
,opmode(0, 0, OpArgR, OpArgR, iABC) /*RAVI_ARRAYSET_ISRR A B C R(A)[R(B)] := R(C) */
,opmode(0, 0, OpArgK, OpArgK, iABC) /*RAVI_ARRAYSET_IIKK A B C R(A)[Kst(B)] := Kst(C) */
,opmode(0, 0, OpArgK, OpArgR, iABC) /*RAVI_ARRAYSET_IIKR A B C R(A)[Kst(B)] := R(C) */
,opmode(0, 0, OpArgR, OpArgK, iABC) /*RAVI_ARRAYSET_IIRK A B C R(A)[R(B)] := Kst(C) */
,opmode(0, 0, OpArgR, OpArgR, iABC) /*RAVI_ARRAYSET_IIRR A B C R(A)[R(B)] := R(C) */
,opmode(0, 0, OpArgK, OpArgK, iABC) /*RAVI_ARRAYSET_IFKK A B C R(A)[Kst(B)] := Kst(C) */
,opmode(0, 0, OpArgK, OpArgR, iABC) /*RAVI_ARRAYSET_IFKR A B C R(A)[Kst(B)] := R(C) */
,opmode(0, 0, OpArgR, OpArgK, iABC) /*RAVI_ARRAYSET_IFRK A B C R(A)[R(B)] := Kst(C) */
,opmode(0, 0, OpArgR, OpArgR, iABC) /*RAVI_ARRAYSET_IFRR A B C R(A)[R(B)] := R(C) */
,opmode(0, 0, OpArgK, OpArgK, iABC) /*RAVI_ARRAYSET_ILKK A B C R(A)[Kst(B)] := Kst(C) */
,opmode(0, 0, OpArgK, OpArgR, iABC) /*RAVI_ARRAYSET_ILKR A B C R(A)[Kst(B)] := R(C) */
,opmode(0, 0, OpArgR, OpArgK, iABC) /*RAVI_ARRAYSET_ILRK A B C R(A)[R(B)] := Kst(C) */
,opmode(0, 0, OpArgR, OpArgR, iABC) /*RAVI_ARRAYSET_ILRR A B C R(A)[R(B)] := R(C) */
, opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_GETTABLE_AI A B C R(A) := R(B)[RK(C)] where R(B) is array of integers and RK(C) is int */
, opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_GETTABLE_AF A B C R(A) := R(B)[RK(C)] where R(B) is array of floats and RK(C) is int */
, opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_SETTABLE_AI A B C R(A)[RK(B)] := RK(C) where RK(B) is an int, R(A) is array of ints, and RK(C) is an int */
, opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_SETTABLE_AF A B C R(A)[RK(B)] := RK(C) where RK(B) is an int, R(A) is array of floats, and RK(C) is an float */
};

@ -1469,164 +1469,6 @@ newframe: /* reentry point when frame changes (call/return) */
setivalue(ra, ivalue(rb) / ivalue(rc));
} break;
case OP_RAVI_EQFFKK: {
TValue *rb = KB(i);
TValue *rc = KC(i);
Protect(if (cast_int(fltvalue(rb) == fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_EQFFKR: {
TValue *rb = KB(i);
TValue *rc = RC(i);
Protect(if (cast_int(fltvalue(rb) == fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_EQFFRK: {
TValue *rb = RB(i);
TValue *rc = KC(i);
Protect(if (cast_int(fltvalue(rb) == fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_EQFFRR: {
TValue *rb = RB(i);
TValue *rc = RC(i);
Protect(if (cast_int(fltvalue(rb) == fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_EQIIKK: {
TValue *rb = KB(i);
TValue *rc = KC(i);
Protect(if ((ivalue(rb) == ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_EQIIKR: {
TValue *rb = KB(i);
TValue *rc = RC(i);
Protect(if ((ivalue(rb) == ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_EQIIRK: {
TValue *rb = RB(i);
TValue *rc = KC(i);
Protect(if ((ivalue(rb) == ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_EQIIRR: {
TValue *rb = RB(i);
TValue *rc = RC(i);
Protect(if ((ivalue(rb) == ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LTFFKK: {
TValue *rb = KB(i);
TValue *rc = KC(i);
Protect(if (cast_int(fltvalue(rb) < fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LTFFKR: {
TValue *rb = KB(i);
TValue *rc = RC(i);
Protect(if (cast_int(fltvalue(rb) < fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LTFFRK: {
TValue *rb = RB(i);
TValue *rc = KC(i);
Protect(if (cast_int(fltvalue(rb) < fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LTFFRR: {
TValue *rb = RB(i);
TValue *rc = RC(i);
Protect(if (cast_int(fltvalue(rb) < fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LTIIKK: {
TValue *rb = KB(i);
TValue *rc = KC(i);
Protect(if ((ivalue(rb) < ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LTIIKR: {
TValue *rb = KB(i);
TValue *rc = RC(i);
Protect(if ((ivalue(rb) < ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LTIIRK: {
TValue *rb = RB(i);
TValue *rc = KC(i);
Protect(if ((ivalue(rb) < ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LTIIRR: {
TValue *rb = RB(i);
TValue *rc = RC(i);
Protect(if ((ivalue(rb) < ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LEFFKK: {
TValue *rb = KB(i);
TValue *rc = KC(i);
Protect(if (cast_int(fltvalue(rb) <= fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LEFFKR: {
TValue *rb = KB(i);
TValue *rc = RC(i);
Protect(if (cast_int(fltvalue(rb) <= fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LEFFRK: {
TValue *rb = RB(i);
TValue *rc = KC(i);
Protect(if (cast_int(fltvalue(rb) <= fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LEFFRR: {
TValue *rb = RB(i);
TValue *rc = RC(i);
Protect(if (cast_int(fltvalue(rb) <= fltvalue(rc)) != GETARG_A(i))
ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LEIIKK: {
TValue *rb = KB(i);
TValue *rc = KC(i);
Protect(if ((ivalue(rb) <= ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LEIIKR: {
TValue *rb = KB(i);
TValue *rc = RC(i);
Protect(if ((ivalue(rb) <= ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LEIIRK: {
TValue *rb = RB(i);
TValue *rc = KC(i);
Protect(if ((ivalue(rb) <= ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_LEIIRR: {
TValue *rb = RB(i);
TValue *rc = RC(i);
Protect(if ((ivalue(rb) <= ivalue(rc)) != GETARG_A(i)) ci->u.l.savedpc++;
else donextjump(ci);)
} break;
case OP_RAVI_TOINT: {
lua_Integer j;
if (tointeger(ra, &j)) {
@ -1679,6 +1521,22 @@ newframe: /* reentry point when frame changes (call/return) */
} else
luaG_runerror(L, "MOVEAF: double[] expected");
} break;
case OP_RAVI_GETTABLE_AI:
case OP_RAVI_GETTABLE_AF: {
TValue *rb = RB(i);
TValue *rc = RKC(i);
lua_Integer idx = ivalue(rc);
Table *t = hvalue(rb);
setobjs2s(L, ra, raviH_getint(L, t, idx));
} break;
case OP_RAVI_SETTABLE_AI:
case OP_RAVI_SETTABLE_AF: {
Table *t = hvalue(ra);
TValue *rb = RKB(i);
TValue *rc = RKC(i);
lua_Integer idx = ivalue(rb);
raviH_setint(L, t, idx, rc);
} break;
}
}
}

@ -575,7 +575,7 @@ int test_ravitable()
int main(const char *argv[])
{
int failures = 0;
failures += test_luacomp1("local x:double[] = {1}; local d:double = x[1];");
failures += test_luacompexec1("local x:double[] = {1}; local i:int = 1; local d:double = x[i]; x[i] = 5; return d*x[i];", 5);
failures += test_luacompexec1("local d:double = 5.0; return d+5 == 5+d and d-5 == 5-d and d*5 == 5*d", 1);
failures += test_luacompexec1("local a:double = 1.0; return a+127 == 128.0;", 1);
failures += test_luacompexec1("local a:double = 1.0; return a+128 == 129.0;", 1);

Loading…
Cancel
Save