aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-05 17:33:28 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-05 17:33:28 +1000
commit91be09a37c65b6b9247c7e3cdf4e189627226511 (patch)
treecdc17054b4b2c80cef6dfdaf21b0e713c8c05ef9 /src
parentde072f1a1819d6d4b41205dcc985b5d23bf9c43a (diff)
downloadfengari-91be09a37c65b6b9247c7e3cdf4e189627226511.tar.gz
fengari-91be09a37c65b6b9247c7e3cdf4e189627226511.tar.bz2
fengari-91be09a37c65b6b9247c7e3cdf4e189627226511.zip
Flatten CallInfo union member
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js12
-rw-r--r--src/ldebug.js10
-rw-r--r--src/ldo.js20
-rw-r--r--src/lstate.js20
-rw-r--r--src/lvm.js96
5 files changed, 78 insertions, 80 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 9347d84..aa8cf04 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -856,8 +856,8 @@ const lua_callk = function(L, nargs, nresults, ctx, k) {
let func = L.top - (nargs + 1);
if (k !== null && L.nny === 0) { /* need to prepare continuation? */
- L.ci.u.c.k = k;
- L.ci.u.c.ctx = ctx;
+ L.ci.c_k = k;
+ L.ci.c_ctx = ctx;
ldo.luaD_call(L, func, nresults);
} else { /* no continuation or no yieldable */
ldo.luaD_callnoyield(L, func, nresults);
@@ -900,17 +900,17 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) {
status = ldo.luaD_pcall(L, f_call, c, c.funcOff, func);
} else { /* prepare continuation (call is already protected by 'resume') */
let ci = L.ci;
- ci.u.c.k = k; /* prepare continuation (call is already protected by 'resume') */
- ci.u.c.ctx = ctx; /* prepare continuation (call is already protected by 'resume') */
+ ci.c_k = k; /* prepare continuation (call is already protected by 'resume') */
+ ci.c_ctx = ctx; /* prepare continuation (call is already protected by 'resume') */
/* save information for error recovery */
ci.extra = c.funcOff;
- ci.u.c.old_errfunc = L.errfunc;
+ ci.c_old_errfunc = L.errfunc;
L.errfunc = func;
ci.callstatus &= ~lstate.CIST_OAH | L.allowhook;
ci.callstatus |= lstate.CIST_YPCALL; /* function can do error recovery */
ldo.luaD_call(L, c.funcOff, nresults); /* do the call */
ci.callstatus &= ~lstate.CIST_YPCALL;
- L.errfunc = ci.u.c.old_errfunc;
+ L.errfunc = ci.c_old_errfunc;
status = TS.LUA_OK;
}
diff --git a/src/ldebug.js b/src/ldebug.js
index 910720f..fc5e378 100644
--- a/src/ldebug.js
+++ b/src/ldebug.js
@@ -87,7 +87,7 @@ const upvalname = function(p, uv) {
const findvararg = function(ci, n) {
let nparams = ci.func.value.p.numparams;
- if (n >= ci.u.l.base - ci.funcOff - nparams)
+ if (n >= ci.l_base - ci.funcOff - nparams)
return null; /* no such vararg */
else {
return {
@@ -104,7 +104,7 @@ const findlocal = function(L, ci, n) {
if (n < 0) /* access to vararg values? */
return findvararg(ci, -n);
else {
- base = ci.u.l.base;
+ base = ci.l_base;
name = lfunc.luaF_getlocalname(ci.func.value.p, n, ci.pcOff);
}
} else
@@ -497,7 +497,7 @@ const funcnamefromcode = function(L, ci) {
};
const isinstack = function(L, ci, o) {
- for (let i = ci.u.l.base; i < ci.top; i++) {
+ for (let i = ci.l_base; i < ci.top; i++) {
if (L.stack[i] === o)
return i;
}
@@ -531,7 +531,7 @@ const varinfo = function(L, o) {
kind = getupvalname(L, ci, o); /* check whether 'o' is an upvalue */
let stkid = isinstack(L, ci, o);
if (!kind && stkid) /* no? try a register */
- kind = getobjname(ci.func.value.p, ci.pcOff, stkid - ci.u.l.base);
+ kind = getobjname(ci.func.value.p, ci.pcOff, stkid - ci.l_base);
}
return kind ? lobject.luaO_pushfstring(L, defs.to_luastring(" (%s '%s')", true), kind.funcname, kind.name) : defs.to_luastring("", true);
@@ -633,7 +633,7 @@ const luaG_traceexec = function(L) {
if (L.status === TS.LUA_YIELD) { /* did hook yield? */
if (counthook)
L.hookcount = 1; /* undo decrement to zero */
- ci.u.l.savedpc--; /* undo increment (resume will increment it again) */
+ ci.l_savedpc--; /* undo increment (resume will increment it again) */
ci.callstatus |= lstate.CIST_HOOKYIELD; /* mark that it yielded */
ci.func = L.top - 1; /* protect stack below results */
ldo.luaD_throw(L, TS.LUA_YIELD);
diff --git a/src/ldo.js b/src/ldo.js
index 7c1f474..9ef8b66 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -114,10 +114,10 @@ const luaD_precall = function(L, off, nresults) {
ci.nresults = nresults;
ci.func = func;
ci.funcOff = off;
- ci.u.l.base = base;
+ ci.l_base = base;
ci.top = base + fsize;
L.top = ci.top;
- ci.u.l.savedpc = p.code;
+ ci.l_savedpc = p.code;
ci.pcOff = 0;
ci.callstatus = lstate.CIST_LUA;
@@ -323,19 +323,19 @@ const finishCcall = function(L, status) {
let ci = L.ci;
/* must have a continuation and must be able to call it */
- assert(ci.u.c.k !== null && L.nny === 0);
+ assert(ci.c_k !== null && L.nny === 0);
/* error status can only happen in a protected call */
assert(ci.callstatus & lstate.CIST_YPCALL || status === TS.LUA_YIELD);
if (ci.callstatus & TS.CIST_YPCALL) { /* was inside a pcall? */
ci.callstatus &= ~TS.CIST_YPCALL; /* continuation is also inside it */
- L.errfunc = ci.u.c.old_errfunc; /* with the same error function */
+ L.errfunc = ci.c_old_errfunc; /* with the same error function */
}
/* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already
handled */
if (ci.nresults === LUA_MULTRET && L.ci.top < L.top) L.ci.top = L.top;
- let n = ci.u.c.k(L, status, ci.u.c.ctx); /* call continuation function */
+ let n = ci.c_k(L, status, ci.c_ctx); /* call continuation function */
assert(n < (L.top - L.ci.funcOff), "not enough elements in the stack");
luaD_poscall(L, ci, L.top - n, n); /* finish 'luaD_precall' */
};
@@ -390,7 +390,7 @@ const recover = function(L, status) {
L.ci = ci;
L.allowhook = ci.callstatus & lstate.CIST_OAH; /* restore original 'allowhook' */
L.nny = 0; /* should be zero to be yieldable */
- L.errfunc = ci.u.c.old_errfunc;
+ L.errfunc = ci.c_old_errfunc;
return 1; /* continue running the coroutine */
};
@@ -428,8 +428,8 @@ const resume = function(L, n) {
if (ci.callstatus & lstate.CIST_LUA) /* yielded inside a hook? */
lvm.luaV_execute(L); /* just continue running Lua code */
else { /* 'common' yield */
- if (ci.u.c.k !== null) { /* does it have a continuation function? */
- n = ci.u.c.k(L, TS.LUA_YIELD, ci.u.c.ctx); /* call continuation */
+ if (ci.c_k !== null) { /* does it have a continuation function? */
+ n = ci.c_k(L, TS.LUA_YIELD, ci.c_ctx); /* call continuation */
assert(n < (L.top - L.ci.funcOff), "not enough elements in the stack");
firstArg = L.top - n; /* yield results come from continuation */
}
@@ -502,9 +502,9 @@ const lua_yieldk = function(L, nresults, ctx, k) {
if (ci.callstatus & lstate.CIST_LUA) /* inside a hook? */
assert(k === null, "hooks cannot continue after yielding");
else {
- ci.u.c.k = k;
+ ci.c_k = k;
if (k !== null) /* is there a continuation? */
- ci.u.c.ctx = ctx; /* save context */
+ ci.c_ctx = ctx; /* save context */
ci.funcOff = L.top - nresults - 1; /* protect stack below results */
ci.func = L.stack[ci.funcOff];
luaD_throw(L, TS.LUA_YIELD);
diff --git a/src/lstate.js b/src/lstate.js
index 51688e0..4fd2951 100644
--- a/src/lstate.js
+++ b/src/lstate.js
@@ -25,17 +25,15 @@ class CallInfo {
this.previous = previous;
this.next = next;
this.pcOff = 0;
- this.u = {
- l: { /* only for Lua functions */
- base: base, /* base for this function */
- savedpc: []
- },
- c: { /* only for JS functions */
- k: null, /* continuation in case of yields */
- old_errfunc: null,
- ctx: null /* context info. in case of yields */
- }
- };
+
+ /* only for Lua functions */
+ this.l_base = base; /* base for this function */
+ this.l_savedpc = [];
+ /* only for JS functions */
+ this.c_k = null; /* continuation in case of yields */
+ this.c_old_errfunc = null;
+ this.c_ctx = null; /* context info. in case of yields */
+
this.nresults = 0;
this.callstatus = 0;
}
diff --git a/src/lvm.js b/src/lvm.js
index d45ecec..9e280c9 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -23,8 +23,8 @@ const LUA_MULTRET = defs.LUA_MULTRET;
const luaV_finishOp = function(L) {
let ci = L.ci;
let OCi = OC.OpCodesI;
- let base = ci.u.l.base;
- let inst = ci.u.l.savedpc[ci.pcOff - 1]; /* interrupted instruction */
+ let base = ci.l_base;
+ let inst = ci.l_savedpc[ci.pcOff - 1]; /* interrupted instruction */
let op = inst.opcode;
switch (op) { /* finish its execution */
@@ -44,7 +44,7 @@ const luaV_finishOp = function(L) {
ci.callstatus ^= lstate.CIST_LEQ; /* clear mark */
res = res !== 1 ? 1 : 0; /* negate result */
}
- assert(ci.u.l.savedpc[ci.pcOff] === OCi.OP_JMP);
+ assert(ci.l_savedpc[ci.pcOff] === OCi.OP_JMP);
if (res !== inst.A) /* condition failed? */
ci.pcOff++; /* skip jump instruction */
break;
@@ -60,12 +60,12 @@ const luaV_finishOp = function(L) {
}
/* move final result to final position */
- L.stack[ci.u.l.base + inst.A] = L.stack[L.top - 1];
+ L.stack[ci.l_base + inst.A] = L.stack[L.top - 1];
L.top = ci.top; /* restore top */
break;
}
case OCi.OP_TFORCALL: {
- assert(ci.u.l.savedpc[ci.pcOff] === OCi.OP_TFORLOOP);
+ assert(ci.l_savedpc[ci.pcOff] === OCi.OP_TFORLOOP);
L.top = ci.top; /* correct top */
break;
}
@@ -114,13 +114,13 @@ const luaV_execute = function(L) {
ci = L.ci;
cl = ci.func.value;
k = cl.p.k;
- base = ci.u.l.base;
+ base = ci.l_base;
- i = ci.u.l.savedpc[ci.pcOff++];
+ i = ci.l_savedpc[ci.pcOff++];
if (L.hookmask & (defs.LUA_MASKLINE | defs.LUA_MASKCOUNT)) {
ldebug.luaG_traceexec(L);
- base = ci.u.l.base;
+ base = ci.l_base;
}
@@ -142,8 +142,8 @@ const luaV_execute = function(L) {
break;
}
case OCi.OP_LOADKX: {
- assert(ci.u.l.savedpc[ci.pcOff].opcode === OCi.OP_EXTRAARG);
- let konst = k[ci.u.l.savedpc[ci.pcOff++].Ax];
+ assert(ci.l_savedpc[ci.pcOff].opcode === OCi.OP_EXTRAARG);
+ let konst = k[ci.l_savedpc[ci.pcOff++].Ax];
L.stack[ra] = new lobject.TValue(konst.type, konst.value);
break;
}
@@ -179,7 +179,7 @@ const luaV_execute = function(L) {
let key = RKC(L, base, k, i);
gettable(L, table, key, ra);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
case OCi.OP_SETTABUP: {
@@ -188,7 +188,7 @@ const luaV_execute = function(L) {
let v = RKC(L, base, k, i);
settable(L, table, key, v);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
@@ -197,7 +197,7 @@ const luaV_execute = function(L) {
let key = RKC(L, base, k, i);
gettable(L, table, key, ra);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
case OCi.OP_SETTABLE: {
@@ -206,7 +206,7 @@ const luaV_execute = function(L) {
let v = RKC(L, base, k, i);
settable(L, table, key, v);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
@@ -221,7 +221,7 @@ const luaV_execute = function(L) {
L.stack[ra + 1] = table;
gettable(L, table, key, ra);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
@@ -237,7 +237,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, numberop1 + numberop2);
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_ADD);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -253,7 +253,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, numberop1 - numberop2);
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_SUB);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -269,7 +269,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, numberop1 * numberop2);
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_MUL);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -285,7 +285,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, (numberop1 - Math.floor(numberop1 / numberop2) * numberop2));
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_MOD);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -299,7 +299,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, Math.pow(numberop1, numberop2));
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_POW);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -313,7 +313,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, numberop1 / numberop2);
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_DIV);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -329,7 +329,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, Math.floor(numberop1 / numberop2));
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_IDIV);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -343,7 +343,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, (numberop1 & numberop2));
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_BAND);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -357,7 +357,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, (numberop1 | numberop2));
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_BOR);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -371,7 +371,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, (numberop1 ^ numberop2));
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_BXOR);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -385,7 +385,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, (numberop1 << numberop2)); // TODO: luaV_shiftl ?
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_SHL);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -399,7 +399,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, (numberop1 >> numberop2));
} else {
ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_SHR);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -413,7 +413,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, -numberop);
} else {
ltm.luaT_trybinTM(L, op, op, ra, ltm.TMS.TM_UNM);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -425,7 +425,7 @@ const luaV_execute = function(L) {
L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, ~op.value);
} else {
ltm.luaT_trybinTM(L, op, op, ra, ltm.TMS.TM_BNOT);
- base = ci.u.l.base;
+ base = ci.l_base;
}
break;
}
@@ -436,7 +436,7 @@ const luaV_execute = function(L) {
}
case OCi.OP_LEN: {
luaV_objlen(L, ra, L.stack[RB(L, base, i)]);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
case OCi.OP_CONCAT: {
@@ -445,7 +445,7 @@ const luaV_execute = function(L) {
let rb;
L.top = base + c + 1; /* mark the end of concat operands */
luaV_concat(L, c - b + 1);
- base = ci.u.l.base;
+ base = ci.l_base;
ra = RA(L, base, i); /* 'luaV_concat' may invoke TMs and move the stack */
rb = base + b;
L.stack[ra] = L.stack[rb];
@@ -461,7 +461,7 @@ const luaV_execute = function(L) {
ci.pcOff++;
else
donextjump(L, ci);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
case OCi.OP_LT: {
@@ -469,7 +469,7 @@ const luaV_execute = function(L) {
ci.pcOff++;
else
donextjump(L, ci);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
case OCi.OP_LE: {
@@ -477,7 +477,7 @@ const luaV_execute = function(L) {
ci.pcOff++;
else
donextjump(L, ci);
- base = ci.u.l.base;
+ base = ci.l_base;
break;
}
case OCi.OP_TEST: {
@@ -507,7 +507,7 @@ const luaV_execute = function(L) {
if (ldo.luaD_precall(L, ra, nresults)) {
if (nresults >= 0)
L.top = ci.top;
- base = ci.u.l.base;
+ base = ci.l_base;
} else {
ci = L.ci;
continue newframe;
@@ -518,7 +518,7 @@ const luaV_execute = function(L) {
case OCi.OP_TAILCALL: {
if (i.B !== 0) L.top = ra + i.B;
if (ldo.luaD_precall(L, ra, LUA_MULTRET)) { // JS function
- base = ci.u.l.base;
+ base = ci.l_base;
} else {
/* tail call: put called frame (n) in place of caller one (o) */
let nci = L.ci;
@@ -527,22 +527,22 @@ const luaV_execute = function(L) {
let nfuncOff = nci.funcOff;
let ofunc = oci.func;
let ofuncOff = oci.funcOff;
- let lim = nci.u.l.base + nfunc.value.p.numparams;
- if (cl.p.p.length > 0) lfunc.luaF_close(L, oci.u.l.base);
+ let lim = nci.l_base + nfunc.value.p.numparams;
+ if (cl.p.p.length > 0) lfunc.luaF_close(L, oci.l_base);
for (let aux = 0; nfuncOff + aux < lim; aux++)
L.stack[ofuncOff + aux] = L.stack[nfuncOff + aux];
oci.func = nci.func;
- oci.u.l.base = ofuncOff + (nci.u.l.base - nfuncOff);
+ oci.l_base = ofuncOff + (nci.l_base - nfuncOff);
L.top = ofuncOff + (L.top - nfuncOff);
oci.top = L.top;
- oci.u.l.savedpc = nci.u.l.savedpc;
+ oci.l_savedpc = nci.l_savedpc;
oci.pcOff = nci.pcOff;
oci.callstatus |= lstate.CIST_TAIL;
L.ci = oci;
ci = L.ci;
L.ciOff--;
- assert(L.top === oci.u.l.base + L.stack[ofuncOff].value.p.maxstacksize);
+ assert(L.top === oci.l_base + L.stack[ofuncOff].value.p.maxstacksize);
continue newframe;
}
@@ -629,9 +629,9 @@ const luaV_execute = function(L) {
L.stack[cb] = L.stack[ra];
L.top = cb + 3; /* func. + 2 args (state and index) */
ldo.luaD_call(L, cb, i.C);
- base = ci.u.l.base;
+ base = ci.l_base;
L.top = ci.top;
- i = ci.u.l.savedpc[ci.pcOff++];
+ i = ci.l_savedpc[ci.pcOff++];
ra = RA(L, base, i);
assert(i.opcode === OCi.OP_TFORLOOP);
specialCase = OCi.OP_TFORLOOP;
@@ -651,8 +651,8 @@ const luaV_execute = function(L) {
if (n === 0) n = L.top - ra - 1;
if (c === 0) {
- assert(ci.u.l.savedpc[ci.pcOff].opcode === OCi.OP_EXTRAARG);
- c = ci.u.l.savedpc[ci.pcOff++].Ax;
+ assert(ci.l_savedpc[ci.pcOff].opcode === OCi.OP_EXTRAARG);
+ c = ci.l_savedpc[ci.pcOff++].Ax;
}
let h = L.stack[ra].value;
@@ -693,7 +693,7 @@ const luaV_execute = function(L) {
if (b < 0) {
b = n; /* get all var. arguments */
- base = ci.u.l.base;
+ base = ci.l_base;
ra = RA(L, base, i); /* previous call may change the stack */
L.top = ra + n;
@@ -715,12 +715,12 @@ const luaV_execute = function(L) {
const dojump = function(L, ci, i, e) {
let a = i.A;
- if (a !== 0) lfunc.luaF_close(L, ci.u.l.base + a - 1);
+ if (a !== 0) lfunc.luaF_close(L, ci.l_base + a - 1);
ci.pcOff += i.sBx + e;
};
const donextjump = function(L, ci) {
- dojump(L, ci, ci.u.l.savedpc[ci.pcOff], 1);
+ dojump(L, ci, ci.l_savedpc[ci.pcOff], 1);
};