Lines Matching refs:fs

42 static int codesJ (FuncState *fs, OpCode o, int sj, int k);
75 static TValue *const2val (FuncState *fs, const expdesc *e) { in const2val() argument
77 return &fs->ls->dyd->actvar.arr[e->u.info].k; in const2val()
85 int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v) { in luaK_exp2const() argument
99 setsvalue(fs->ls->L, v, e->u.strval); in luaK_exp2const()
103 setobj(fs->ls->L, v, const2val(fs, e)); in luaK_exp2const()
117 static Instruction *previousinstruction (FuncState *fs) { in previousinstruction() argument
119 if (fs->pc > fs->lasttarget) in previousinstruction()
120 return &fs->f->code[fs->pc - 1]; /* previous instruction */ in previousinstruction()
132 void luaK_nil (FuncState *fs, int from, int n) { in luaK_nil() argument
134 Instruction *previous = previousinstruction(fs); in luaK_nil()
147 luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */ in luaK_nil()
155 static int getjump (FuncState *fs, int pc) { in getjump() argument
156 int offset = GETARG_sJ(fs->f->code[pc]); in getjump()
168 static void fixjump (FuncState *fs, int pc, int dest) { in fixjump() argument
169 Instruction *jmp = &fs->f->code[pc]; in fixjump()
173 luaX_syntaxerror(fs->ls, "control structure too long"); in fixjump()
182 void luaK_concat (FuncState *fs, int *l1, int l2) { in luaK_concat() argument
189 while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ in luaK_concat()
191 fixjump(fs, list, l2); /* last element links to 'l2' */ in luaK_concat()
200 int luaK_jump (FuncState *fs) { in luaK_jump() argument
201 return codesJ(fs, OP_JMP, NO_JUMP, 0); in luaK_jump()
208 void luaK_ret (FuncState *fs, int first, int nret) { in luaK_ret() argument
215 luaK_codeABC(fs, op, first, nret + 1, 0); in luaK_ret()
223 static int condjump (FuncState *fs, OpCode op, int A, int B, int C, int k) { in condjump() argument
224 luaK_codeABCk(fs, op, A, B, C, k); in condjump()
225 return luaK_jump(fs); in condjump()
233 int luaK_getlabel (FuncState *fs) { in luaK_getlabel() argument
234 fs->lasttarget = fs->pc; in luaK_getlabel()
235 return fs->pc; in luaK_getlabel()
244 static Instruction *getjumpcontrol (FuncState *fs, int pc) { in getjumpcontrol() argument
245 Instruction *pi = &fs->f->code[pc]; in getjumpcontrol()
260 static int patchtestreg (FuncState *fs, int node, int reg) { in patchtestreg() argument
261 Instruction *i = getjumpcontrol(fs, node); in patchtestreg()
278 static void removevalues (FuncState *fs, int list) { in removevalues() argument
279 for (; list != NO_JUMP; list = getjump(fs, list)) in removevalues()
280 patchtestreg(fs, list, NO_REG); in removevalues()
289 static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, in patchlistaux() argument
292 int next = getjump(fs, list); in patchlistaux()
293 if (patchtestreg(fs, list, reg)) in patchlistaux()
294 fixjump(fs, list, vtarget); in patchlistaux()
296 fixjump(fs, list, dtarget); /* jump to default target */ in patchlistaux()
307 void luaK_patchlist (FuncState *fs, int list, int target) { in luaK_patchlist() argument
308 lua_assert(target <= fs->pc); in luaK_patchlist()
309 patchlistaux(fs, list, target, NO_REG, target); in luaK_patchlist()
313 void luaK_patchtohere (FuncState *fs, int list) { in luaK_patchtohere() argument
314 int hr = luaK_getlabel(fs); /* mark "here" as a jump target */ in luaK_patchtohere()
315 luaK_patchlist(fs, list, hr); in luaK_patchtohere()
330 static void savelineinfo (FuncState *fs, Proto *f, int line) { in savelineinfo() argument
331 int linedif = line - fs->previousline; in savelineinfo()
332 int pc = fs->pc - 1; /* last instruction coded */ in savelineinfo()
333 if (abs(linedif) >= LIMLINEDIFF || fs->iwthabs++ >= MAXIWTHABS) { in savelineinfo()
334 luaM_growvector(fs->ls->L, f->abslineinfo, fs->nabslineinfo, in savelineinfo()
336 f->abslineinfo[fs->nabslineinfo].pc = pc; in savelineinfo()
337 f->abslineinfo[fs->nabslineinfo++].line = line; in savelineinfo()
339 fs->iwthabs = 1; /* restart counter */ in savelineinfo()
341 luaM_growvector(fs->ls->L, f->lineinfo, pc, f->sizelineinfo, ls_byte, in savelineinfo()
344 fs->previousline = line; /* last line saved */ in savelineinfo()
354 static void removelastlineinfo (FuncState *fs) { in removelastlineinfo() argument
355 Proto *f = fs->f; in removelastlineinfo()
356 int pc = fs->pc - 1; /* last instruction coded */ in removelastlineinfo()
358 fs->previousline -= f->lineinfo[pc]; /* correct last line saved */ in removelastlineinfo()
359 fs->iwthabs--; /* undo previous increment */ in removelastlineinfo()
362 lua_assert(f->abslineinfo[fs->nabslineinfo - 1].pc == pc); in removelastlineinfo()
363 fs->nabslineinfo--; /* remove it */ in removelastlineinfo()
364 fs->iwthabs = MAXIWTHABS + 1; /* force next line info to be absolute */ in removelastlineinfo()
373 static void removelastinstruction (FuncState *fs) { in removelastinstruction() argument
374 removelastlineinfo(fs); in removelastinstruction()
375 fs->pc--; in removelastinstruction()
383 int luaK_code (FuncState *fs, Instruction i) { in luaK_code() argument
384 Proto *f = fs->f; in luaK_code()
386 luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction, in luaK_code()
388 f->code[fs->pc++] = i; in luaK_code()
389 savelineinfo(fs, f, fs->ls->lastline); in luaK_code()
390 return fs->pc - 1; /* index of new instruction */ in luaK_code()
398 int luaK_codeABCk (FuncState *fs, OpCode o, int a, int b, int c, int k) { in luaK_codeABCk() argument
402 return luaK_code(fs, CREATE_ABCk(o, a, b, c, k)); in luaK_codeABCk()
409 int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { in luaK_codeABx() argument
412 return luaK_code(fs, CREATE_ABx(o, a, bc)); in luaK_codeABx()
419 static int codeAsBx (FuncState *fs, OpCode o, int a, int bc) { in codeAsBx() argument
423 return luaK_code(fs, CREATE_ABx(o, a, b)); in codeAsBx()
430 static int codesJ (FuncState *fs, OpCode o, int sj, int k) { in codesJ() argument
434 return luaK_code(fs, CREATE_sJ(o, j, k)); in codesJ()
441 static int codeextraarg (FuncState *fs, int a) { in codeextraarg() argument
443 return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a)); in codeextraarg()
452 static int luaK_codek (FuncState *fs, int reg, int k) { in luaK_codek() argument
454 return luaK_codeABx(fs, OP_LOADK, reg, k); in luaK_codek()
456 int p = luaK_codeABx(fs, OP_LOADKX, reg, 0); in luaK_codek()
457 codeextraarg(fs, k); in luaK_codek()
467 void luaK_checkstack (FuncState *fs, int n) { in luaK_checkstack() argument
468 int newstack = fs->freereg + n; in luaK_checkstack()
469 if (newstack > fs->f->maxstacksize) { in luaK_checkstack()
471 luaX_syntaxerror(fs->ls, in luaK_checkstack()
473 fs->f->maxstacksize = cast_byte(newstack); in luaK_checkstack()
481 void luaK_reserveregs (FuncState *fs, int n) { in luaK_reserveregs() argument
482 luaK_checkstack(fs, n); in luaK_reserveregs()
483 fs->freereg += n; in luaK_reserveregs()
492 static void freereg (FuncState *fs, int reg) { in freereg() argument
493 if (reg >= luaY_nvarstack(fs)) { in freereg()
494 fs->freereg--; in freereg()
495 lua_assert(reg == fs->freereg); in freereg()
503 static void freeregs (FuncState *fs, int r1, int r2) { in freeregs() argument
505 freereg(fs, r1); in freeregs()
506 freereg(fs, r2); in freeregs()
509 freereg(fs, r2); in freeregs()
510 freereg(fs, r1); in freeregs()
518 static void freeexp (FuncState *fs, expdesc *e) { in freeexp() argument
520 freereg(fs, e->u.info); in freeexp()
528 static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) { in freeexps() argument
531 freeregs(fs, r1, r2); in freeexps()
544 static int addk (FuncState *fs, TValue *key, TValue *v) { in addk() argument
546 lua_State *L = fs->ls->L; in addk()
547 Proto *f = fs->f; in addk()
548 const TValue *idx = luaH_get(fs->ls->h, key); /* query scanner table */ in addk()
553 if (k < fs->nk && ttypetag(&f->k[k]) == ttypetag(v) && in addk()
559 k = fs->nk; in addk()
563 luaH_finishset(L, fs->ls->h, key, idx, &val); in addk()
567 fs->nk++; in addk()
576 static int stringK (FuncState *fs, TString *s) { in stringK() argument
578 setsvalue(fs->ls->L, &o, s); in stringK()
579 return addk(fs, &o, &o); /* use string itself as key */ in stringK()
586 static int luaK_intK (FuncState *fs, lua_Integer n) { in luaK_intK() argument
589 return addk(fs, &o, &o); /* use integer itself as key */ in luaK_intK()
603 static int luaK_numberK (FuncState *fs, lua_Number r) { in luaK_numberK() argument
609 return addk(fs, &o, &o); /* use number itself as key */ in luaK_numberK()
619 return addk(fs, &kv, &o); in luaK_numberK()
625 return addk(fs, &o, &o); /* use number itself as key */ in luaK_numberK()
633 static int boolF (FuncState *fs) { in boolF() argument
636 return addk(fs, &o, &o); /* use boolean itself as key */ in boolF()
643 static int boolT (FuncState *fs) { in boolT() argument
646 return addk(fs, &o, &o); /* use boolean itself as key */ in boolT()
653 static int nilK (FuncState *fs) { in nilK() argument
657 sethvalue(fs->ls->L, &k, fs->ls->h); in nilK()
658 return addk(fs, &k, &v); in nilK()
680 void luaK_int (FuncState *fs, int reg, lua_Integer i) { in luaK_int() argument
682 codeAsBx(fs, OP_LOADI, reg, cast_int(i)); in luaK_int()
684 luaK_codek(fs, reg, luaK_intK(fs, i)); in luaK_int()
688 static void luaK_float (FuncState *fs, int reg, lua_Number f) { in luaK_float() argument
691 codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); in luaK_float()
693 luaK_codek(fs, reg, luaK_numberK(fs, f)); in luaK_float()
729 void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { in luaK_setreturns() argument
730 Instruction *pc = &getinstruction(fs, e); in luaK_setreturns()
736 SETARG_A(*pc, fs->freereg); in luaK_setreturns()
737 luaK_reserveregs(fs, 1); in luaK_setreturns()
745 static void str2K (FuncState *fs, expdesc *e) { in str2K() argument
747 e->u.info = stringK(fs, e->u.strval); in str2K()
762 void luaK_setoneret (FuncState *fs, expdesc *e) { in luaK_setoneret() argument
765 lua_assert(GETARG_C(getinstruction(fs, e)) == 2); in luaK_setoneret()
767 e->u.info = GETARG_A(getinstruction(fs, e)); in luaK_setoneret()
770 SETARG_C(getinstruction(fs, e), 2); in luaK_setoneret()
780 void luaK_dischargevars (FuncState *fs, expdesc *e) { in luaK_dischargevars() argument
783 const2exp(const2val(fs, e), e); in luaK_dischargevars()
793 e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); in luaK_dischargevars()
798 e->u.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
803 freereg(fs, e->u.ind.t); in luaK_dischargevars()
804 e->u.info = luaK_codeABC(fs, OP_GETI, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
809 freereg(fs, e->u.ind.t); in luaK_dischargevars()
810 e->u.info = luaK_codeABC(fs, OP_GETFIELD, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
815 freeregs(fs, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
816 e->u.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
821 luaK_setoneret(fs, e); in luaK_dischargevars()
834 static void discharge2reg (FuncState *fs, expdesc *e, int reg) { in discharge2reg() argument
835 luaK_dischargevars(fs, e); in discharge2reg()
838 luaK_nil(fs, reg, 1); in discharge2reg()
842 luaK_codeABC(fs, OP_LOADFALSE, reg, 0, 0); in discharge2reg()
846 luaK_codeABC(fs, OP_LOADTRUE, reg, 0, 0); in discharge2reg()
850 str2K(fs, e); in discharge2reg()
853 luaK_codek(fs, reg, e->u.info); in discharge2reg()
857 luaK_float(fs, reg, e->u.nval); in discharge2reg()
861 luaK_int(fs, reg, e->u.ival); in discharge2reg()
865 Instruction *pc = &getinstruction(fs, e); in discharge2reg()
871 luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); in discharge2reg()
889 static void discharge2anyreg (FuncState *fs, expdesc *e) { in discharge2anyreg() argument
891 luaK_reserveregs(fs, 1); /* get a register */ in discharge2anyreg()
892 discharge2reg(fs, e, fs->freereg-1); /* put value there */ in discharge2anyreg()
897 static int code_loadbool (FuncState *fs, int A, OpCode op) { in code_loadbool() argument
898 luaK_getlabel(fs); /* those instructions may be jump targets */ in code_loadbool()
899 return luaK_codeABC(fs, op, A, 0, 0); in code_loadbool()
907 static int need_value (FuncState *fs, int list) { in need_value() argument
908 for (; list != NO_JUMP; list = getjump(fs, list)) { in need_value()
909 Instruction i = *getjumpcontrol(fs, list); in need_value()
923 static void exp2reg (FuncState *fs, expdesc *e, int reg) { in exp2reg() argument
924 discharge2reg(fs, e, reg); in exp2reg()
926 luaK_concat(fs, &e->t, e->u.info); /* put this jump in 't' list */ in exp2reg()
931 if (need_value(fs, e->t) || need_value(fs, e->f)) { in exp2reg()
932 int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); in exp2reg()
933 p_f = code_loadbool(fs, reg, OP_LFALSESKIP); /* skip next inst. */ in exp2reg()
934 p_t = code_loadbool(fs, reg, OP_LOADTRUE); in exp2reg()
936 luaK_patchtohere(fs, fj); in exp2reg()
938 final = luaK_getlabel(fs); in exp2reg()
939 patchlistaux(fs, e->f, final, reg, p_f); in exp2reg()
940 patchlistaux(fs, e->t, final, reg, p_t); in exp2reg()
951 void luaK_exp2nextreg (FuncState *fs, expdesc *e) { in luaK_exp2nextreg() argument
952 luaK_dischargevars(fs, e); in luaK_exp2nextreg()
953 freeexp(fs, e); in luaK_exp2nextreg()
954 luaK_reserveregs(fs, 1); in luaK_exp2nextreg()
955 exp2reg(fs, e, fs->freereg - 1); in luaK_exp2nextreg()
963 int luaK_exp2anyreg (FuncState *fs, expdesc *e) { in luaK_exp2anyreg() argument
964 luaK_dischargevars(fs, e); in luaK_exp2anyreg()
968 if (e->u.info >= luaY_nvarstack(fs)) { /* reg. is not a local? */ in luaK_exp2anyreg()
969 exp2reg(fs, e, e->u.info); /* put final result in it */ in luaK_exp2anyreg()
976 luaK_exp2nextreg(fs, e); /* default: use next available register */ in luaK_exp2anyreg()
985 void luaK_exp2anyregup (FuncState *fs, expdesc *e) { in luaK_exp2anyregup() argument
987 luaK_exp2anyreg(fs, e); in luaK_exp2anyregup()
995 void luaK_exp2val (FuncState *fs, expdesc *e) { in luaK_exp2val() argument
997 luaK_exp2anyreg(fs, e); in luaK_exp2val()
999 luaK_dischargevars(fs, e); in luaK_exp2val()
1007 static int luaK_exp2K (FuncState *fs, expdesc *e) { in luaK_exp2K() argument
1011 case VTRUE: info = boolT(fs); break; in luaK_exp2K()
1012 case VFALSE: info = boolF(fs); break; in luaK_exp2K()
1013 case VNIL: info = nilK(fs); break; in luaK_exp2K()
1014 case VKINT: info = luaK_intK(fs, e->u.ival); break; in luaK_exp2K()
1015 case VKFLT: info = luaK_numberK(fs, e->u.nval); break; in luaK_exp2K()
1016 case VKSTR: info = stringK(fs, e->u.strval); break; in luaK_exp2K()
1037 static int exp2RK (FuncState *fs, expdesc *e) { in exp2RK() argument
1038 if (luaK_exp2K(fs, e)) in exp2RK()
1041 luaK_exp2anyreg(fs, e); in exp2RK()
1047 static void codeABRK (FuncState *fs, OpCode o, int a, int b, in codeABRK() argument
1049 int k = exp2RK(fs, ec); in codeABRK()
1050 luaK_codeABCk(fs, o, a, b, ec->u.info, k); in codeABRK()
1057 void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { in luaK_storevar() argument
1060 freeexp(fs, ex); in luaK_storevar()
1061 exp2reg(fs, ex, var->u.var.ridx); /* compute 'ex' into proper place */ in luaK_storevar()
1065 int e = luaK_exp2anyreg(fs, ex); in luaK_storevar()
1066 luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); in luaK_storevar()
1070 codeABRK(fs, OP_SETTABUP, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1074 codeABRK(fs, OP_SETI, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1078 codeABRK(fs, OP_SETFIELD, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1082 codeABRK(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1087 freeexp(fs, ex); in luaK_storevar()
1094 void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { in luaK_self() argument
1096 luaK_exp2anyreg(fs, e); in luaK_self()
1098 freeexp(fs, e); in luaK_self()
1099 e->u.info = fs->freereg; /* base register for op_self */ in luaK_self()
1101 luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ in luaK_self()
1102 codeABRK(fs, OP_SELF, e->u.info, ereg, key); in luaK_self()
1103 freeexp(fs, key); in luaK_self()
1110 static void negatecondition (FuncState *fs, expdesc *e) { in negatecondition() argument
1111 Instruction *pc = getjumpcontrol(fs, e->u.info); in negatecondition()
1124 static int jumponcond (FuncState *fs, expdesc *e, int cond) { in jumponcond() argument
1126 Instruction ie = getinstruction(fs, e); in jumponcond()
1128 removelastinstruction(fs); /* remove previous OP_NOT */ in jumponcond()
1129 return condjump(fs, OP_TEST, GETARG_B(ie), 0, 0, !cond); in jumponcond()
1133 discharge2anyreg(fs, e); in jumponcond()
1134 freeexp(fs, e); in jumponcond()
1135 return condjump(fs, OP_TESTSET, NO_REG, e->u.info, 0, cond); in jumponcond()
1142 void luaK_goiftrue (FuncState *fs, expdesc *e) { in luaK_goiftrue() argument
1144 luaK_dischargevars(fs, e); in luaK_goiftrue()
1147 negatecondition(fs, e); /* jump when it is false */ in luaK_goiftrue()
1156 pc = jumponcond(fs, e, 0); /* jump when false */ in luaK_goiftrue()
1160 luaK_concat(fs, &e->f, pc); /* insert new jump in false list */ in luaK_goiftrue()
1161 luaK_patchtohere(fs, e->t); /* true list jumps to here (to go through) */ in luaK_goiftrue()
1169 void luaK_goiffalse (FuncState *fs, expdesc *e) { in luaK_goiffalse() argument
1171 luaK_dischargevars(fs, e); in luaK_goiffalse()
1182 pc = jumponcond(fs, e, 1); /* jump if true */ in luaK_goiffalse()
1186 luaK_concat(fs, &e->t, pc); /* insert new jump in 't' list */ in luaK_goiffalse()
1187 luaK_patchtohere(fs, e->f); /* false list jumps to here (to go through) */ in luaK_goiffalse()
1195 static void codenot (FuncState *fs, expdesc *e) { in codenot() argument
1206 negatecondition(fs, e); in codenot()
1211 discharge2anyreg(fs, e); in codenot()
1212 freeexp(fs, e); in codenot()
1213 e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); in codenot()
1221 removevalues(fs, e->f); /* values are useless when negated */ in codenot()
1222 removevalues(fs, e->t); in codenot()
1229 static int isKstr (FuncState *fs, expdesc *e) { in isKstr() argument
1231 ttisshrstring(&fs->f->k[e->u.info])); in isKstr()
1287 void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { in luaK_indexed() argument
1289 str2K(fs, k); in luaK_indexed()
1292 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ in luaK_indexed()
1293 luaK_exp2anyreg(fs, t); /* put it in a register */ in luaK_indexed()
1296 lua_assert(isKstr(fs, k)); in luaK_indexed()
1304 if (isKstr(fs, k)) { in luaK_indexed()
1313 t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */ in luaK_indexed()
1344 static int constfolding (FuncState *fs, int op, expdesc *e1, in constfolding() argument
1349 luaO_rawarith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ in constfolding()
1399 static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { in codeunexpval() argument
1400 int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ in codeunexpval()
1401 freeexp(fs, e); in codeunexpval()
1402 e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ in codeunexpval()
1404 luaK_fixline(fs, line); in codeunexpval()
1414 static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2, in finishbinexpval() argument
1417 int v1 = luaK_exp2anyreg(fs, e1); in finishbinexpval()
1418 int pc = luaK_codeABCk(fs, op, 0, v1, v2, 0); in finishbinexpval()
1419 freeexps(fs, e1, e2); in finishbinexpval()
1422 luaK_fixline(fs, line); in finishbinexpval()
1423 luaK_codeABCk(fs, mmop, v1, v2, event, flip); /* to call metamethod */ in finishbinexpval()
1424 luaK_fixline(fs, line); in finishbinexpval()
1432 static void codebinexpval (FuncState *fs, BinOpr opr, in codebinexpval() argument
1435 int v2 = luaK_exp2anyreg(fs, e2); /* make sure 'e2' is in a register */ in codebinexpval()
1440 finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN, binopr2TM(opr)); in codebinexpval()
1447 static void codebini (FuncState *fs, OpCode op, in codebini() argument
1452 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINI, event); in codebini()
1459 static void codebinK (FuncState *fs, BinOpr opr, in codebinK() argument
1464 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event); in codebinK()
1471 static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, in finishbinexpneg() argument
1481 finishbinexpval(fs, e1, e2, op, int2sC(-v2), 0, line, OP_MMBINI, event); in finishbinexpneg()
1483 SETARG_B(fs->f->code[fs->pc - 1], int2sC(v2)); in finishbinexpneg()
1498 static void codebinNoK (FuncState *fs, BinOpr opr, in codebinNoK() argument
1502 codebinexpval(fs, opr, e1, e2, line); /* use standard operators */ in codebinNoK()
1510 static void codearith (FuncState *fs, BinOpr opr, in codearith() argument
1512 if (tonumeral(e2, NULL) && luaK_exp2K(fs, e2)) /* K operand? */ in codearith()
1513 codebinK(fs, opr, e1, e2, flip, line); in codearith()
1515 codebinNoK(fs, opr, e1, e2, flip, line); in codearith()
1524 static void codecommutative (FuncState *fs, BinOpr op, in codecommutative() argument
1532 codebini(fs, OP_ADDI, e1, e2, flip, line, TM_ADD); in codecommutative()
1534 codearith(fs, op, e1, e2, flip, line); in codecommutative()
1542 static void codebitwise (FuncState *fs, BinOpr opr, in codebitwise() argument
1549 if (e2->k == VKINT && luaK_exp2K(fs, e2)) /* K operand? */ in codebitwise()
1550 codebinK(fs, opr, e1, e2, flip, line); in codebitwise()
1552 codebinNoK(fs, opr, e1, e2, flip, line); in codebitwise()
1560 static void codeorder (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { in codeorder() argument
1567 r1 = luaK_exp2anyreg(fs, e1); in codeorder()
1573 r1 = luaK_exp2anyreg(fs, e2); in codeorder()
1578 r1 = luaK_exp2anyreg(fs, e1); in codeorder()
1579 r2 = luaK_exp2anyreg(fs, e2); in codeorder()
1582 freeexps(fs, e1, e2); in codeorder()
1583 e1->u.info = condjump(fs, op, r1, r2, isfloat, 1); in codeorder()
1592 static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { in codeeq() argument
1601 r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */ in codeeq()
1606 else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */ in codeeq()
1612 r2 = luaK_exp2anyreg(fs, e2); in codeeq()
1614 freeexps(fs, e1, e2); in codeeq()
1615 e1->u.info = condjump(fs, op, r1, r2, isfloat, (opr == OPR_EQ)); in codeeq()
1623 void luaK_prefix (FuncState *fs, UnOpr opr, expdesc *e, int line) { in luaK_prefix() argument
1625 luaK_dischargevars(fs, e); in luaK_prefix()
1628 if (constfolding(fs, opr + LUA_OPUNM, e, &ef)) in luaK_prefix()
1632 codeunexpval(fs, unopr2op(opr), e, line); in luaK_prefix()
1634 case OPR_NOT: codenot(fs, e); break; in luaK_prefix()
1644 void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { in luaK_infix() argument
1645 luaK_dischargevars(fs, v); in luaK_infix()
1648 luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ in luaK_infix()
1652 luaK_goiffalse(fs, v); /* go ahead only if 'v' is false */ in luaK_infix()
1656 luaK_exp2nextreg(fs, v); /* operand must be on the stack */ in luaK_infix()
1665 luaK_exp2anyreg(fs, v); in luaK_infix()
1672 exp2RK(fs, v); in luaK_infix()
1680 luaK_exp2anyreg(fs, v); in luaK_infix()
1693 static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) { in codeconcat() argument
1694 Instruction *ie2 = previousinstruction(fs); in codeconcat()
1698 freeexp(fs, e2); in codeconcat()
1703 luaK_codeABC(fs, OP_CONCAT, e1->u.info, 2, 0); /* new concat opcode */ in codeconcat()
1704 freeexp(fs, e2); in codeconcat()
1705 luaK_fixline(fs, line); in codeconcat()
1713 void luaK_posfix (FuncState *fs, BinOpr opr, in luaK_posfix() argument
1715 luaK_dischargevars(fs, e2); in luaK_posfix()
1716 if (foldbinop(opr) && constfolding(fs, opr + LUA_OPADD, e1, e2)) in luaK_posfix()
1721 luaK_concat(fs, &e2->f, e1->f); in luaK_posfix()
1727 luaK_concat(fs, &e2->t, e1->t); in luaK_posfix()
1732 luaK_exp2nextreg(fs, e2); in luaK_posfix()
1733 codeconcat(fs, e1, e2, line); in luaK_posfix()
1737 codecommutative(fs, opr, e1, e2, line); in luaK_posfix()
1741 if (finishbinexpneg(fs, e1, e2, OP_ADDI, line, TM_SUB)) in luaK_posfix()
1746 codearith(fs, opr, e1, e2, 0, line); in luaK_posfix()
1750 codebitwise(fs, opr, e1, e2, line); in luaK_posfix()
1756 codebini(fs, OP_SHLI, e1, e2, 1, line, TM_SHL); /* I << r2 */ in luaK_posfix()
1758 else if (finishbinexpneg(fs, e1, e2, OP_SHRI, line, TM_SHL)) { in luaK_posfix()
1762 codebinexpval(fs, opr, e1, e2, line); in luaK_posfix()
1767 codebini(fs, OP_SHRI, e1, e2, 0, line, TM_SHR); /* r1 >> I */ in luaK_posfix()
1769 codebinexpval(fs, opr, e1, e2, line); in luaK_posfix()
1773 codeeq(fs, opr, e1, e2); in luaK_posfix()
1782 codeorder(fs, opr, e1, e2); in luaK_posfix()
1794 void luaK_fixline (FuncState *fs, int line) { in luaK_fixline() argument
1795 removelastlineinfo(fs); in luaK_fixline()
1796 savelineinfo(fs, fs->f, line); in luaK_fixline()
1800 void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize) { in luaK_settablesize() argument
1801 Instruction *inst = &fs->f->code[pc]; in luaK_settablesize()
1818 void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { in luaK_setlist() argument
1823 luaK_codeABC(fs, OP_SETLIST, base, tostore, nelems); in luaK_setlist()
1827 luaK_codeABCk(fs, OP_SETLIST, base, tostore, nelems, 1); in luaK_setlist()
1828 codeextraarg(fs, extra); in luaK_setlist()
1830 fs->freereg = base + 1; /* free registers with list values */ in luaK_setlist()
1854 void luaK_finish (FuncState *fs) { in luaK_finish() argument
1856 Proto *p = fs->f; in luaK_finish()
1857 for (i = 0; i < fs->pc; i++) { in luaK_finish()
1862 if (!(fs->needclose || p->is_vararg)) in luaK_finish()
1868 if (fs->needclose) in luaK_finish()
1876 fixjump(fs, i, target); in luaK_finish()