MCPcopy Create free account
hub / github.com/danomatika/ofxLua / luaK_finish

Function luaK_finish

libs/lua/lcode.c:1843–1871  ·  view source on GitHub ↗

** Do a final pass over the code of a function, doing small peephole ** optimizations and adjustments. */

Source from the content-addressed store, hash-verified

1841** optimizations and adjustments.
1842*/
1843void luaK_finish (FuncState *fs) {
1844 int i;
1845 Proto *p = fs->f;
1846 for (i = 0; i < fs->pc; i++) {
1847 Instruction *pc = &p->code[i];
1848 lua_assert(i == 0 || isOT(*(pc - 1)) == isIT(*pc));
1849 switch (GET_OPCODE(*pc)) {
1850 case OP_RETURN0: case OP_RETURN1: {
1851 if (!(fs->needclose || p->is_vararg))
1852 break; /* no extra work */
1853 /* else use OP_RETURN to do the extra work */
1854 SET_OPCODE(*pc, OP_RETURN);
1855 } /* FALLTHROUGH */
1856 case OP_RETURN: case OP_TAILCALL: {
1857 if (fs->needclose)
1858 SETARG_k(*pc, 1); /* signal that it needs to close */
1859 if (p->is_vararg)
1860 SETARG_C(*pc, p->numparams + 1); /* signal that it is vararg */
1861 break;
1862 }
1863 case OP_JMP: {
1864 int target = finaltarget(p->code, i);
1865 fixjump(fs, i, target);
1866 break;
1867 }
1868 default: break;
1869 }
1870 }
1871}

Callers 1

close_funcFunction · 0.85

Calls 2

finaltargetFunction · 0.85
fixjumpFunction · 0.85

Tested by

no test coverage detected