• Home
  • Raw
  • Download

Lines Matching refs:fs

40 static int codesJ (FuncState *fs, OpCode o, int sj, int k);
73 static TValue *const2val (FuncState *fs, const expdesc *e) { in const2val() argument
75 return &fs->ls->dyd->actvar.arr[e->u.info].k; in const2val()
83 int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v) { in luaK_exp2const() argument
97 setsvalue(fs->ls->L, v, e->u.strval); in luaK_exp2const()
101 setobj(fs->ls->L, v, const2val(fs, e)); in luaK_exp2const()
115 static Instruction *previousinstruction (FuncState *fs) { in previousinstruction() argument
117 if (fs->pc > fs->lasttarget) in previousinstruction()
118 return &fs->f->code[fs->pc - 1]; /* previous instruction */ in previousinstruction()
130 void luaK_nil (FuncState *fs, int from, int n) { in luaK_nil() argument
132 Instruction *previous = previousinstruction(fs); in luaK_nil()
145 luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */ in luaK_nil()
153 static int getjump (FuncState *fs, int pc) { in getjump() argument
154 int offset = GETARG_sJ(fs->f->code[pc]); in getjump()
166 static void fixjump (FuncState *fs, int pc, int dest) { in fixjump() argument
167 Instruction *jmp = &fs->f->code[pc]; in fixjump()
171 luaX_syntaxerror(fs->ls, "control structure too long"); in fixjump()
180 void luaK_concat (FuncState *fs, int *l1, int l2) { in luaK_concat() argument
187 while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ in luaK_concat()
189 fixjump(fs, list, l2); /* last element links to 'l2' */ in luaK_concat()
198 int luaK_jump (FuncState *fs) { in luaK_jump() argument
199 return codesJ(fs, OP_JMP, NO_JUMP, 0); in luaK_jump()
206 void luaK_ret (FuncState *fs, int first, int nret) { in luaK_ret() argument
213 luaK_codeABC(fs, op, first, nret + 1, 0); in luaK_ret()
221 static int condjump (FuncState *fs, OpCode op, int A, int B, int C, int k) { in condjump() argument
222 luaK_codeABCk(fs, op, A, B, C, k); in condjump()
223 return luaK_jump(fs); in condjump()
231 int luaK_getlabel (FuncState *fs) { in luaK_getlabel() argument
232 fs->lasttarget = fs->pc; in luaK_getlabel()
233 return fs->pc; in luaK_getlabel()
242 static Instruction *getjumpcontrol (FuncState *fs, int pc) { in getjumpcontrol() argument
243 Instruction *pi = &fs->f->code[pc]; in getjumpcontrol()
258 static int patchtestreg (FuncState *fs, int node, int reg) { in patchtestreg() argument
259 Instruction *i = getjumpcontrol(fs, node); in patchtestreg()
276 static void removevalues (FuncState *fs, int list) { in removevalues() argument
277 for (; list != NO_JUMP; list = getjump(fs, list)) in removevalues()
278 patchtestreg(fs, list, NO_REG); in removevalues()
287 static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, in patchlistaux() argument
290 int next = getjump(fs, list); in patchlistaux()
291 if (patchtestreg(fs, list, reg)) in patchlistaux()
292 fixjump(fs, list, vtarget); in patchlistaux()
294 fixjump(fs, list, dtarget); /* jump to default target */ in patchlistaux()
305 void luaK_patchlist (FuncState *fs, int list, int target) { in luaK_patchlist() argument
306 lua_assert(target <= fs->pc); in luaK_patchlist()
307 patchlistaux(fs, list, target, NO_REG, target); in luaK_patchlist()
311 void luaK_patchtohere (FuncState *fs, int list) { in luaK_patchtohere() argument
312 int hr = luaK_getlabel(fs); /* mark "here" as a jump target */ in luaK_patchtohere()
313 luaK_patchlist(fs, list, hr); in luaK_patchtohere()
337 static void savelineinfo (FuncState *fs, Proto *f, int line) { in savelineinfo() argument
338 int linedif = line - fs->previousline; in savelineinfo()
339 int pc = fs->pc - 1; /* last instruction coded */ in savelineinfo()
340 if (abs(linedif) >= LIMLINEDIFF || fs->iwthabs++ > MAXIWTHABS) { in savelineinfo()
341 luaM_growvector(fs->ls->L, f->abslineinfo, fs->nabslineinfo, in savelineinfo()
343 f->abslineinfo[fs->nabslineinfo].pc = pc; in savelineinfo()
344 f->abslineinfo[fs->nabslineinfo++].line = line; in savelineinfo()
346 fs->iwthabs = 0; /* restart counter */ in savelineinfo()
348 luaM_growvector(fs->ls->L, f->lineinfo, pc, f->sizelineinfo, ls_byte, in savelineinfo()
351 fs->previousline = line; /* last line saved */ in savelineinfo()
361 static void removelastlineinfo (FuncState *fs) { in removelastlineinfo() argument
362 Proto *f = fs->f; in removelastlineinfo()
363 int pc = fs->pc - 1; /* last instruction coded */ in removelastlineinfo()
365 fs->previousline -= f->lineinfo[pc]; /* correct last line saved */ in removelastlineinfo()
366 fs->iwthabs--; /* undo previous increment */ in removelastlineinfo()
369 lua_assert(f->abslineinfo[fs->nabslineinfo - 1].pc == pc); in removelastlineinfo()
370 fs->nabslineinfo--; /* remove it */ in removelastlineinfo()
371 fs->iwthabs = MAXIWTHABS + 1; /* force next line info to be absolute */ in removelastlineinfo()
380 static void removelastinstruction (FuncState *fs) { in removelastinstruction() argument
381 removelastlineinfo(fs); in removelastinstruction()
382 fs->pc--; in removelastinstruction()
390 int luaK_code (FuncState *fs, Instruction i) { in luaK_code() argument
391 Proto *f = fs->f; in luaK_code()
393 luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction, in luaK_code()
395 f->code[fs->pc++] = i; in luaK_code()
396 savelineinfo(fs, f, fs->ls->lastline); in luaK_code()
397 return fs->pc - 1; /* index of new instruction */ in luaK_code()
405 int luaK_codeABCk (FuncState *fs, OpCode o, int a, int b, int c, int k) { in luaK_codeABCk() argument
409 return luaK_code(fs, CREATE_ABCk(o, a, b, c, k)); in luaK_codeABCk()
416 int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { in luaK_codeABx() argument
419 return luaK_code(fs, CREATE_ABx(o, a, bc)); in luaK_codeABx()
426 int luaK_codeAsBx (FuncState *fs, OpCode o, int a, int bc) { in luaK_codeAsBx() argument
430 return luaK_code(fs, CREATE_ABx(o, a, b)); in luaK_codeAsBx()
437 static int codesJ (FuncState *fs, OpCode o, int sj, int k) { in codesJ() argument
441 return luaK_code(fs, CREATE_sJ(o, j, k)); in codesJ()
448 static int codeextraarg (FuncState *fs, int a) { in codeextraarg() argument
450 return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a)); in codeextraarg()
459 static int luaK_codek (FuncState *fs, int reg, int k) { in luaK_codek() argument
461 return luaK_codeABx(fs, OP_LOADK, reg, k); in luaK_codek()
463 int p = luaK_codeABx(fs, OP_LOADKX, reg, 0); in luaK_codek()
464 codeextraarg(fs, k); in luaK_codek()
474 void luaK_checkstack (FuncState *fs, int n) { in luaK_checkstack() argument
475 int newstack = fs->freereg + n; in luaK_checkstack()
476 if (newstack > fs->f->maxstacksize) { in luaK_checkstack()
478 luaX_syntaxerror(fs->ls, in luaK_checkstack()
480 fs->f->maxstacksize = cast_byte(newstack); in luaK_checkstack()
488 void luaK_reserveregs (FuncState *fs, int n) { in luaK_reserveregs() argument
489 luaK_checkstack(fs, n); in luaK_reserveregs()
490 fs->freereg += n; in luaK_reserveregs()
499 static void freereg (FuncState *fs, int reg) { in freereg() argument
500 if (reg >= luaY_nvarstack(fs)) { in freereg()
501 fs->freereg--; in freereg()
502 lua_assert(reg == fs->freereg); in freereg()
510 static void freeregs (FuncState *fs, int r1, int r2) { in freeregs() argument
512 freereg(fs, r1); in freeregs()
513 freereg(fs, r2); in freeregs()
516 freereg(fs, r2); in freeregs()
517 freereg(fs, r1); in freeregs()
525 static void freeexp (FuncState *fs, expdesc *e) { in freeexp() argument
527 freereg(fs, e->u.info); in freeexp()
535 static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) { in freeexps() argument
538 freeregs(fs, r1, r2); in freeexps()
549 static int addk (FuncState *fs, TValue *key, TValue *v) { in addk() argument
550 lua_State *L = fs->ls->L; in addk()
551 Proto *f = fs->f; in addk()
552 TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */ in addk()
557 if (k < fs->nk && ttypetag(&f->k[k]) == ttypetag(v) && in addk()
563 k = fs->nk; in addk()
570 fs->nk++; in addk()
579 static int stringK (FuncState *fs, TString *s) { in stringK() argument
581 setsvalue(fs->ls->L, &o, s); in stringK()
582 return addk(fs, &o, &o); /* use string itself as key */ in stringK()
592 static int luaK_intK (FuncState *fs, lua_Integer n) { in luaK_intK() argument
596 return addk(fs, &k, &o); in luaK_intK()
602 static int luaK_numberK (FuncState *fs, lua_Number r) { in luaK_numberK() argument
605 return addk(fs, &o, &o); /* use number itself as key */ in luaK_numberK()
612 static int boolF (FuncState *fs) { in boolF() argument
615 return addk(fs, &o, &o); /* use boolean itself as key */ in boolF()
622 static int boolT (FuncState *fs) { in boolT() argument
625 return addk(fs, &o, &o); /* use boolean itself as key */ in boolT()
632 static int nilK (FuncState *fs) { in nilK() argument
636 sethvalue(fs->ls->L, &k, fs->ls->h); in nilK()
637 return addk(fs, &k, &v); in nilK()
659 void luaK_int (FuncState *fs, int reg, lua_Integer i) { in luaK_int() argument
661 luaK_codeAsBx(fs, OP_LOADI, reg, cast_int(i)); in luaK_int()
663 luaK_codek(fs, reg, luaK_intK(fs, i)); in luaK_int()
667 static void luaK_float (FuncState *fs, int reg, lua_Number f) { in luaK_float() argument
670 luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); in luaK_float()
672 luaK_codek(fs, reg, luaK_numberK(fs, f)); in luaK_float()
708 void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { in luaK_setreturns() argument
709 Instruction *pc = &getinstruction(fs, e); in luaK_setreturns()
715 SETARG_A(*pc, fs->freereg); in luaK_setreturns()
716 luaK_reserveregs(fs, 1); in luaK_setreturns()
724 static void str2K (FuncState *fs, expdesc *e) { in str2K() argument
726 e->u.info = stringK(fs, e->u.strval); in str2K()
741 void luaK_setoneret (FuncState *fs, expdesc *e) { in luaK_setoneret() argument
744 lua_assert(GETARG_C(getinstruction(fs, e)) == 2); in luaK_setoneret()
746 e->u.info = GETARG_A(getinstruction(fs, e)); in luaK_setoneret()
749 SETARG_C(getinstruction(fs, e), 2); in luaK_setoneret()
759 void luaK_dischargevars (FuncState *fs, expdesc *e) { in luaK_dischargevars() argument
762 const2exp(const2val(fs, e), e); in luaK_dischargevars()
771 e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); in luaK_dischargevars()
776 e->u.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
781 freereg(fs, e->u.ind.t); in luaK_dischargevars()
782 e->u.info = luaK_codeABC(fs, OP_GETI, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
787 freereg(fs, e->u.ind.t); in luaK_dischargevars()
788 e->u.info = luaK_codeABC(fs, OP_GETFIELD, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
793 freeregs(fs, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
794 e->u.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
799 luaK_setoneret(fs, e); in luaK_dischargevars()
812 static void discharge2reg (FuncState *fs, expdesc *e, int reg) { in discharge2reg() argument
813 luaK_dischargevars(fs, e); in discharge2reg()
816 luaK_nil(fs, reg, 1); in discharge2reg()
820 luaK_codeABC(fs, OP_LOADFALSE, reg, 0, 0); in discharge2reg()
824 luaK_codeABC(fs, OP_LOADTRUE, reg, 0, 0); in discharge2reg()
828 str2K(fs, e); in discharge2reg()
831 luaK_codek(fs, reg, e->u.info); in discharge2reg()
835 luaK_float(fs, reg, e->u.nval); in discharge2reg()
839 luaK_int(fs, reg, e->u.ival); in discharge2reg()
843 Instruction *pc = &getinstruction(fs, e); in discharge2reg()
849 luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); in discharge2reg()
866 static void discharge2anyreg (FuncState *fs, expdesc *e) { in discharge2anyreg() argument
868 luaK_reserveregs(fs, 1); /* get a register */ in discharge2anyreg()
869 discharge2reg(fs, e, fs->freereg-1); /* put value there */ in discharge2anyreg()
874 static int code_loadbool (FuncState *fs, int A, OpCode op) { in code_loadbool() argument
875 luaK_getlabel(fs); /* those instructions may be jump targets */ in code_loadbool()
876 return luaK_codeABC(fs, op, A, 0, 0); in code_loadbool()
884 static int need_value (FuncState *fs, int list) { in need_value() argument
885 for (; list != NO_JUMP; list = getjump(fs, list)) { in need_value()
886 Instruction i = *getjumpcontrol(fs, list); in need_value()
900 static void exp2reg (FuncState *fs, expdesc *e, int reg) { in exp2reg() argument
901 discharge2reg(fs, e, reg); in exp2reg()
903 luaK_concat(fs, &e->t, e->u.info); /* put this jump in 't' list */ in exp2reg()
908 if (need_value(fs, e->t) || need_value(fs, e->f)) { in exp2reg()
909 int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); in exp2reg()
910 p_f = code_loadbool(fs, reg, OP_LFALSESKIP); /* skip next inst. */ in exp2reg()
911 p_t = code_loadbool(fs, reg, OP_LOADTRUE); in exp2reg()
913 luaK_patchtohere(fs, fj); in exp2reg()
915 final = luaK_getlabel(fs); in exp2reg()
916 patchlistaux(fs, e->f, final, reg, p_f); in exp2reg()
917 patchlistaux(fs, e->t, final, reg, p_t); in exp2reg()
928 void luaK_exp2nextreg (FuncState *fs, expdesc *e) { in luaK_exp2nextreg() argument
929 luaK_dischargevars(fs, e); in luaK_exp2nextreg()
930 freeexp(fs, e); in luaK_exp2nextreg()
931 luaK_reserveregs(fs, 1); in luaK_exp2nextreg()
932 exp2reg(fs, e, fs->freereg - 1); in luaK_exp2nextreg()
940 int luaK_exp2anyreg (FuncState *fs, expdesc *e) { in luaK_exp2anyreg() argument
941 luaK_dischargevars(fs, e); in luaK_exp2anyreg()
945 if (e->u.info >= luaY_nvarstack(fs)) { /* reg. is not a local? */ in luaK_exp2anyreg()
946 exp2reg(fs, e, e->u.info); /* put final result in it */ in luaK_exp2anyreg()
950 luaK_exp2nextreg(fs, e); /* otherwise, use next available register */ in luaK_exp2anyreg()
959 void luaK_exp2anyregup (FuncState *fs, expdesc *e) { in luaK_exp2anyregup() argument
961 luaK_exp2anyreg(fs, e); in luaK_exp2anyregup()
969 void luaK_exp2val (FuncState *fs, expdesc *e) { in luaK_exp2val() argument
971 luaK_exp2anyreg(fs, e); in luaK_exp2val()
973 luaK_dischargevars(fs, e); in luaK_exp2val()
981 static int luaK_exp2K (FuncState *fs, expdesc *e) { in luaK_exp2K() argument
985 case VTRUE: info = boolT(fs); break; in luaK_exp2K()
986 case VFALSE: info = boolF(fs); break; in luaK_exp2K()
987 case VNIL: info = nilK(fs); break; in luaK_exp2K()
988 case VKINT: info = luaK_intK(fs, e->u.ival); break; in luaK_exp2K()
989 case VKFLT: info = luaK_numberK(fs, e->u.nval); break; in luaK_exp2K()
990 case VKSTR: info = stringK(fs, e->u.strval); break; in luaK_exp2K()
1011 int luaK_exp2RK (FuncState *fs, expdesc *e) { in luaK_exp2RK() argument
1012 if (luaK_exp2K(fs, e)) in luaK_exp2RK()
1015 luaK_exp2anyreg(fs, e); in luaK_exp2RK()
1021 static void codeABRK (FuncState *fs, OpCode o, int a, int b, in codeABRK() argument
1023 int k = luaK_exp2RK(fs, ec); in codeABRK()
1024 luaK_codeABCk(fs, o, a, b, ec->u.info, k); in codeABRK()
1031 void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { in luaK_storevar() argument
1034 freeexp(fs, ex); in luaK_storevar()
1035 exp2reg(fs, ex, var->u.var.sidx); /* compute 'ex' into proper place */ in luaK_storevar()
1039 int e = luaK_exp2anyreg(fs, ex); in luaK_storevar()
1040 luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); in luaK_storevar()
1044 codeABRK(fs, OP_SETTABUP, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1048 codeABRK(fs, OP_SETI, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1052 codeABRK(fs, OP_SETFIELD, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1056 codeABRK(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1061 freeexp(fs, ex); in luaK_storevar()
1068 void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { in luaK_self() argument
1070 luaK_exp2anyreg(fs, e); in luaK_self()
1072 freeexp(fs, e); in luaK_self()
1073 e->u.info = fs->freereg; /* base register for op_self */ in luaK_self()
1075 luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ in luaK_self()
1076 codeABRK(fs, OP_SELF, e->u.info, ereg, key); in luaK_self()
1077 freeexp(fs, key); in luaK_self()
1084 static void negatecondition (FuncState *fs, expdesc *e) { in negatecondition() argument
1085 Instruction *pc = getjumpcontrol(fs, e->u.info); in negatecondition()
1098 static int jumponcond (FuncState *fs, expdesc *e, int cond) { in jumponcond() argument
1100 Instruction ie = getinstruction(fs, e); in jumponcond()
1102 removelastinstruction(fs); /* remove previous OP_NOT */ in jumponcond()
1103 return condjump(fs, OP_TEST, GETARG_B(ie), 0, 0, !cond); in jumponcond()
1107 discharge2anyreg(fs, e); in jumponcond()
1108 freeexp(fs, e); in jumponcond()
1109 return condjump(fs, OP_TESTSET, NO_REG, e->u.info, 0, cond); in jumponcond()
1116 void luaK_goiftrue (FuncState *fs, expdesc *e) { in luaK_goiftrue() argument
1118 luaK_dischargevars(fs, e); in luaK_goiftrue()
1121 negatecondition(fs, e); /* jump when it is false */ in luaK_goiftrue()
1130 pc = jumponcond(fs, e, 0); /* jump when false */ in luaK_goiftrue()
1134 luaK_concat(fs, &e->f, pc); /* insert new jump in false list */ in luaK_goiftrue()
1135 luaK_patchtohere(fs, e->t); /* true list jumps to here (to go through) */ in luaK_goiftrue()
1143 void luaK_goiffalse (FuncState *fs, expdesc *e) { in luaK_goiffalse() argument
1145 luaK_dischargevars(fs, e); in luaK_goiffalse()
1156 pc = jumponcond(fs, e, 1); /* jump if true */ in luaK_goiffalse()
1160 luaK_concat(fs, &e->t, pc); /* insert new jump in 't' list */ in luaK_goiffalse()
1161 luaK_patchtohere(fs, e->f); /* false list jumps to here (to go through) */ in luaK_goiffalse()
1169 static void codenot (FuncState *fs, expdesc *e) { in codenot() argument
1180 negatecondition(fs, e); in codenot()
1185 discharge2anyreg(fs, e); in codenot()
1186 freeexp(fs, e); in codenot()
1187 e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); in codenot()
1195 removevalues(fs, e->f); /* values are useless when negated */ in codenot()
1196 removevalues(fs, e->t); in codenot()
1203 static int isKstr (FuncState *fs, expdesc *e) { in isKstr() argument
1205 ttisshrstring(&fs->f->k[e->u.info])); in isKstr()
1261 void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { in luaK_indexed() argument
1263 str2K(fs, k); in luaK_indexed()
1266 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ in luaK_indexed()
1267 luaK_exp2anyreg(fs, t); /* put it in a register */ in luaK_indexed()
1276 if (isKstr(fs, k)) { in luaK_indexed()
1285 t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */ in luaK_indexed()
1315 static int constfolding (FuncState *fs, int op, expdesc *e1, in constfolding() argument
1320 luaO_rawarith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ in constfolding()
1341 static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { in codeunexpval() argument
1342 int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ in codeunexpval()
1343 freeexp(fs, e); in codeunexpval()
1344 e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ in codeunexpval()
1346 luaK_fixline(fs, line); in codeunexpval()
1356 static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2, in finishbinexpval() argument
1359 int v1 = luaK_exp2anyreg(fs, e1); in finishbinexpval()
1360 int pc = luaK_codeABCk(fs, op, 0, v1, v2, 0); in finishbinexpval()
1361 freeexps(fs, e1, e2); in finishbinexpval()
1364 luaK_fixline(fs, line); in finishbinexpval()
1365 luaK_codeABCk(fs, mmop, v1, v2, event, flip); /* to call metamethod */ in finishbinexpval()
1366 luaK_fixline(fs, line); in finishbinexpval()
1374 static void codebinexpval (FuncState *fs, OpCode op, in codebinexpval() argument
1376 int v2 = luaK_exp2anyreg(fs, e2); /* both operands are in registers */ in codebinexpval()
1378 finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN, in codebinexpval()
1386 static void codebini (FuncState *fs, OpCode op, in codebini() argument
1391 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINI, event); in codebini()
1398 static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, in finishbinexpneg() argument
1408 finishbinexpval(fs, e1, e2, op, int2sC(-v2), 0, line, OP_MMBINI, event); in finishbinexpneg()
1410 SETARG_B(fs->f->code[fs->pc - 1], int2sC(v2)); in finishbinexpneg()
1426 static void codearith (FuncState *fs, BinOpr opr, in codearith() argument
1429 if (tonumeral(e2, NULL) && luaK_exp2K(fs, e2)) { /* K operand? */ in codearith()
1432 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event); in codearith()
1438 codebinexpval(fs, op, e1, e2, line); /* use standard operators */ in codearith()
1448 static void codecommutative (FuncState *fs, BinOpr op, in codecommutative() argument
1456 codebini(fs, cast(OpCode, OP_ADDI), e1, e2, flip, line, TM_ADD); in codecommutative()
1458 codearith(fs, op, e1, e2, flip, line); in codecommutative()
1466 static void codebitwise (FuncState *fs, BinOpr opr, in codebitwise() argument
1471 if (e1->k == VKINT && luaK_exp2RK(fs, e1)) { in codebitwise()
1475 else if (!(e2->k == VKINT && luaK_exp2RK(fs, e2))) { /* no constants? */ in codebitwise()
1477 codebinexpval(fs, op, e1, e2, line); /* all-register opcodes */ in codebitwise()
1482 lua_assert(ttisinteger(&fs->f->k[v2])); in codebitwise()
1483 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, in codebitwise()
1492 static void codeorder (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { in codeorder() argument
1498 r1 = luaK_exp2anyreg(fs, e1); in codeorder()
1504 r1 = luaK_exp2anyreg(fs, e2); in codeorder()
1509 r1 = luaK_exp2anyreg(fs, e1); in codeorder()
1510 r2 = luaK_exp2anyreg(fs, e2); in codeorder()
1512 freeexps(fs, e1, e2); in codeorder()
1513 e1->u.info = condjump(fs, op, r1, r2, isfloat, 1); in codeorder()
1522 static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { in codeeq() argument
1531 r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */ in codeeq()
1536 else if (luaK_exp2RK(fs, e2)) { /* 1st expression is constant? */ in codeeq()
1542 r2 = luaK_exp2anyreg(fs, e2); in codeeq()
1544 freeexps(fs, e1, e2); in codeeq()
1545 e1->u.info = condjump(fs, op, r1, r2, isfloat, (opr == OPR_EQ)); in codeeq()
1553 void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { in luaK_prefix() argument
1555 luaK_dischargevars(fs, e); in luaK_prefix()
1558 if (constfolding(fs, op + LUA_OPUNM, e, &ef)) in luaK_prefix()
1562 codeunexpval(fs, cast(OpCode, op + OP_UNM), e, line); in luaK_prefix()
1564 case OPR_NOT: codenot(fs, e); break; in luaK_prefix()
1574 void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { in luaK_infix() argument
1575 luaK_dischargevars(fs, v); in luaK_infix()
1578 luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ in luaK_infix()
1582 luaK_goiffalse(fs, v); /* go ahead only if 'v' is false */ in luaK_infix()
1586 luaK_exp2nextreg(fs, v); /* operand must be on the stack */ in luaK_infix()
1595 luaK_exp2anyreg(fs, v); in luaK_infix()
1601 luaK_exp2RK(fs, v); in luaK_infix()
1609 luaK_exp2anyreg(fs, v); in luaK_infix()
1622 static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) { in codeconcat() argument
1623 Instruction *ie2 = previousinstruction(fs); in codeconcat()
1627 freeexp(fs, e2); in codeconcat()
1632 luaK_codeABC(fs, OP_CONCAT, e1->u.info, 2, 0); /* new concat opcode */ in codeconcat()
1633 freeexp(fs, e2); in codeconcat()
1634 luaK_fixline(fs, line); in codeconcat()
1642 void luaK_posfix (FuncState *fs, BinOpr opr, in luaK_posfix() argument
1644 luaK_dischargevars(fs, e2); in luaK_posfix()
1645 if (foldbinop(opr) && constfolding(fs, opr + LUA_OPADD, e1, e2)) in luaK_posfix()
1650 luaK_concat(fs, &e2->f, e1->f); in luaK_posfix()
1656 luaK_concat(fs, &e2->t, e1->t); in luaK_posfix()
1661 luaK_exp2nextreg(fs, e2); in luaK_posfix()
1662 codeconcat(fs, e1, e2, line); in luaK_posfix()
1666 codecommutative(fs, opr, e1, e2, line); in luaK_posfix()
1670 if (finishbinexpneg(fs, e1, e2, OP_ADDI, line, TM_SUB)) in luaK_posfix()
1675 codearith(fs, opr, e1, e2, 0, line); in luaK_posfix()
1679 codebitwise(fs, opr, e1, e2, line); in luaK_posfix()
1685 codebini(fs, OP_SHLI, e1, e2, 1, line, TM_SHL); /* I << r2 */ in luaK_posfix()
1687 else if (finishbinexpneg(fs, e1, e2, OP_SHRI, line, TM_SHL)) { in luaK_posfix()
1691 codebinexpval(fs, OP_SHL, e1, e2, line); in luaK_posfix()
1696 codebini(fs, OP_SHRI, e1, e2, 0, line, TM_SHR); /* r1 >> I */ in luaK_posfix()
1698 codebinexpval(fs, OP_SHR, e1, e2, line); in luaK_posfix()
1702 codeeq(fs, opr, e1, e2); in luaK_posfix()
1707 codeorder(fs, op, e1, e2); in luaK_posfix()
1714 codeorder(fs, op, e1, e2); in luaK_posfix()
1726 void luaK_fixline (FuncState *fs, int line) { in luaK_fixline() argument
1727 removelastlineinfo(fs); in luaK_fixline()
1728 savelineinfo(fs, fs->f, line); in luaK_fixline()
1732 void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize) { in luaK_settablesize() argument
1733 Instruction *inst = &fs->f->code[pc]; in luaK_settablesize()
1750 void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { in luaK_setlist() argument
1755 luaK_codeABC(fs, OP_SETLIST, base, tostore, nelems); in luaK_setlist()
1759 luaK_codeABCk(fs, OP_SETLIST, base, tostore, nelems, 1); in luaK_setlist()
1760 codeextraarg(fs, extra); in luaK_setlist()
1762 fs->freereg = base + 1; /* free registers with list values */ in luaK_setlist()
1786 void luaK_finish (FuncState *fs) { in luaK_finish() argument
1788 Proto *p = fs->f; in luaK_finish()
1789 for (i = 0; i < fs->pc; i++) { in luaK_finish()
1794 if (!(fs->needclose || p->is_vararg)) in luaK_finish()
1800 if (fs->needclose) in luaK_finish()
1808 fixjump(fs, i, target); in luaK_finish()