refactoring via XmiliaH

pull/216/head
Dibyendu Majumdar 3 years ago
parent 4a20693671
commit 248c730c43

@ -993,38 +993,35 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
break; break;
} }
case VINDEXED: { case VINDEXED: {
OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP; OpCode op;
if (op == OP_SETTABLE) { int e = luaK_exp2RK(fs, ex);
if (var->u.ind.vt == VLOCAL) {
/* table value set - if array access then use specialized versions */ /* table value set - if array access then use specialized versions */
if (var->ravi_type == RAVI_TARRAYFLT && if (var->u.ind.key_ravi_type == RAVI_TNUMINT) {
var->u.ind.key_ravi_type == RAVI_TNUMINT) { if (var->ravi_type == RAVI_TARRAYFLT) {
if (!(ex->ravi_type == RAVI_TNUMFLT || (ex->k == VINDEXED && ex->ravi_type == RAVI_TARRAYFLT))) op = ex->ravi_type == RAVI_TNUMFLT ? OP_RAVI_FARRAY_SETF : /* input value is known to be number */
/* input value may need conversion */ OP_RAVI_FARRAY_SET; /* input value may need conversion */
op = OP_RAVI_FARRAY_SET; }
else else if (var->ravi_type == RAVI_TARRAYINT) {
/* input value is known to be number */ op = ex->ravi_type == RAVI_TNUMINT ? OP_RAVI_IARRAY_SETI : /* input value is known to be integer */
op = OP_RAVI_FARRAY_SETF; OP_RAVI_IARRAY_SET; /* input value may need conversion */
} else if (var->ravi_type == RAVI_TARRAYINT && }
var->u.ind.key_ravi_type == RAVI_TNUMINT) { else {
if (!(ex->ravi_type == RAVI_TNUMINT || (ex->k == VINDEXED && ex->ravi_type == RAVI_TARRAYINT))) /* index op with integer key, target may not be a table */
/* input value may need conversion */ op = OP_RAVI_SETI;
op = OP_RAVI_IARRAY_SET; }
else
/* input value is known to be integer */
op = OP_RAVI_IARRAY_SETI;
} else if (var->u.ind.key_ravi_type == RAVI_TNUMINT) {
/* index op with integer key, target may not be a table */
op = OP_RAVI_SETI;
} else if (var->ravi_type == RAVI_TTABLE && var->u.ind.key_ravi_type == RAVI_TSTRING && isshortstr(fs, var->u.ind.idx)) {
/* table with string key */
op = OP_RAVI_TABLE_SETFIELD;
} }
else if (var->u.ind.key_ravi_type == RAVI_TSTRING && isshortstr(fs, var->u.ind.idx)) { else if (var->u.ind.key_ravi_type == RAVI_TSTRING && isshortstr(fs, var->u.ind.idx)) {
/* index op with string key, target may not be a table */ op = var->ravi_type == RAVI_TTABLE ? OP_RAVI_TABLE_SETFIELD : /* table with string key */
op = OP_RAVI_SETFIELD; OP_RAVI_SETFIELD; /* index op with string key, target may not be a table */
}
else {
op = OP_SETTABLE;
} }
} }
int e = luaK_exp2RK(fs, ex); else {
op = OP_SETTABUP;
}
luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e); luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
break; break;
} }

Loading…
Cancel
Save