MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / symbexec

Function symbexec

Source/Misc/lua/src/lua.c:4825–4983  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4823
4824
4825static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
4826int pc;
4827int last; /* stores position of last instruction that changed `reg' */
4828last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
4829check(precheck(pt));
4830for (pc = 0; pc < lastpc; pc++) {
4831Instruction i = pt->code[pc];
4832OpCode op = GET_OPCODE(i);
4833int a = GETARG_A(i);
4834int b = 0;
4835int c = 0;
4836check(op < NUM_OPCODES);
4837checkreg(pt, a);
4838switch (getOpMode(op)) {
4839case iABC: {
4840b = GETARG_B(i);
4841c = GETARG_C(i);
4842check(checkArgMode(pt, b, getBMode(op)));
4843check(checkArgMode(pt, c, getCMode(op)));
4844break;
4845}
4846case iABx: {
4847b = GETARG_Bx(i);
4848if (getBMode(op) == OpArgK) check(b < pt->sizek);
4849break;
4850}
4851case iAsBx: {
4852b = GETARG_sBx(i);
4853if (getBMode(op) == OpArgR) {
4854int dest = pc+1+b;
4855check(0 <= dest && dest < pt->sizecode);
4856if (dest > 0) {
4857int j;
4858/* check that it does not jump to a setlist count; this
4859is tricky, because the count from a previous setlist may
4860have the same value of an invalid setlist; so, we must
4861go all the way back to the first of them (if any) */
4862for (j = 0; j < dest; j++) {
4863Instruction d = pt->code[dest-1-j];
4864if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
4865}
4866/* if 'j' is even, previous value is not a setlist (even if
4867it looks like one) */
4868check((j&1) == 0);
4869}
4870}
4871break;
4872}
4873}
4874if (testAMode(op)) {
4875if (a == reg) last = pc; /* change register `a' */
4876}
4877if (testTMode(op)) {
4878check(pc+2 < pt->sizecode); /* check skip */
4879check(GET_OPCODE(pt->code[pc+1]) == OP_JMP);
4880}
4881switch (op) {
4882case OP_LOADBOOL: {

Callers 2

luaG_checkcodeFunction · 0.85
getobjnameFunction · 0.85

Calls 3

precheckFunction · 0.85
checkArgModeFunction · 0.85
checkFunction · 0.70

Tested by

no test coverage detected