Lines Matching full:fs
41 static int codesJ (FuncState *fs, OpCode o, int sj, int k);
74 static TValue *const2val (FuncState *fs, const expdesc *e) { in const2val() argument
76 return &fs->ls->dyd->actvar.arr[e->u.info].k; in const2val()
84 int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v) { in luaK_exp2const() argument
98 setsvalue(fs->ls->L, v, e->u.strval); in luaK_exp2const()
102 setobj(fs->ls->L, v, const2val(fs, e)); in luaK_exp2const()
116 static Instruction *previousinstruction (FuncState *fs) { in previousinstruction() argument
118 if (fs->pc > fs->lasttarget) in previousinstruction()
119 return &fs->f->code[fs->pc - 1]; /* previous instruction */ in previousinstruction()
131 void luaK_nil (FuncState *fs, int from, int n) { in luaK_nil() argument
133 Instruction *previous = previousinstruction(fs); in luaK_nil()
146 luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */ in luaK_nil()
154 static int getjump (FuncState *fs, int pc) { in getjump() argument
155 int offset = GETARG_sJ(fs->f->code[pc]); in getjump()
167 static void fixjump (FuncState *fs, int pc, int dest) { in fixjump() argument
168 Instruction *jmp = &fs->f->code[pc]; in fixjump()
172 luaX_syntaxerror(fs->ls, "control structure too long"); in fixjump()
181 void luaK_concat (FuncState *fs, int *l1, int l2) { in luaK_concat() argument
188 while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ in luaK_concat()
190 fixjump(fs, list, l2); /* last element links to 'l2' */ in luaK_concat()
199 int luaK_jump (FuncState *fs) { in luaK_jump() argument
200 return codesJ(fs, OP_JMP, NO_JUMP, 0); in luaK_jump()
207 void luaK_ret (FuncState *fs, int first, int nret) { in luaK_ret() argument
214 luaK_codeABC(fs, op, first, nret + 1, 0); in luaK_ret()
222 static int condjump (FuncState *fs, OpCode op, int A, int B, int C, int k) { in condjump() argument
223 luaK_codeABCk(fs, op, A, B, C, k); in condjump()
224 return luaK_jump(fs); in condjump()
232 int luaK_getlabel (FuncState *fs) { in luaK_getlabel() argument
233 fs->lasttarget = fs->pc; in luaK_getlabel()
234 return fs->pc; in luaK_getlabel()
243 static Instruction *getjumpcontrol (FuncState *fs, int pc) { in getjumpcontrol() argument
244 Instruction *pi = &fs->f->code[pc]; in getjumpcontrol()
259 static int patchtestreg (FuncState *fs, int node, int reg) { in patchtestreg() argument
260 Instruction *i = getjumpcontrol(fs, node); in patchtestreg()
277 static void removevalues (FuncState *fs, int list) { in removevalues() argument
278 for (; list != NO_JUMP; list = getjump(fs, list)) in removevalues()
279 patchtestreg(fs, list, NO_REG); in removevalues()
288 static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, in patchlistaux() argument
291 int next = getjump(fs, list); in patchlistaux()
292 if (patchtestreg(fs, list, reg)) in patchlistaux()
293 fixjump(fs, list, vtarget); in patchlistaux()
295 fixjump(fs, list, dtarget); /* jump to default target */ in patchlistaux()
306 void luaK_patchlist (FuncState *fs, int list, int target) { in luaK_patchlist() argument
307 lua_assert(target <= fs->pc); in luaK_patchlist()
308 patchlistaux(fs, list, target, NO_REG, target); in luaK_patchlist()
312 void luaK_patchtohere (FuncState *fs, int list) { in luaK_patchtohere() argument
313 int hr = luaK_getlabel(fs); /* mark "here" as a jump target */ in luaK_patchtohere()
314 luaK_patchlist(fs, list, hr); in luaK_patchtohere()
329 static void savelineinfo (FuncState *fs, Proto *f, int line) { in savelineinfo() argument
330 int linedif = line - fs->previousline; in savelineinfo()
331 int pc = fs->pc - 1; /* last instruction coded */ in savelineinfo()
332 if (abs(linedif) >= LIMLINEDIFF || fs->iwthabs++ >= MAXIWTHABS) { in savelineinfo()
333 luaM_growvector(fs->ls->L, f->abslineinfo, fs->nabslineinfo, in savelineinfo()
335 f->abslineinfo[fs->nabslineinfo].pc = pc; in savelineinfo()
336 f->abslineinfo[fs->nabslineinfo++].line = line; in savelineinfo()
338 fs->iwthabs = 1; /* restart counter */ in savelineinfo()
340 luaM_growvector(fs->ls->L, f->lineinfo, pc, f->sizelineinfo, ls_byte, in savelineinfo()
343 fs->previousline = line; /* last line saved */ in savelineinfo()
353 static void removelastlineinfo (FuncState *fs) { in removelastlineinfo() argument
354 Proto *f = fs->f; in removelastlineinfo()
355 int pc = fs->pc - 1; /* last instruction coded */ in removelastlineinfo()
357 fs->previousline -= f->lineinfo[pc]; /* correct last line saved */ in removelastlineinfo()
358 fs->iwthabs--; /* undo previous increment */ in removelastlineinfo()
361 lua_assert(f->abslineinfo[fs->nabslineinfo - 1].pc == pc); in removelastlineinfo()
362 fs->nabslineinfo--; /* remove it */ in removelastlineinfo()
363 fs->iwthabs = MAXIWTHABS + 1; /* force next line info to be absolute */ in removelastlineinfo()
372 static void removelastinstruction (FuncState *fs) { in removelastinstruction() argument
373 removelastlineinfo(fs); in removelastinstruction()
374 fs->pc--; in removelastinstruction()
382 int luaK_code (FuncState *fs, Instruction i) { in luaK_code() argument
383 Proto *f = fs->f; in luaK_code()
385 luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction, in luaK_code()
387 f->code[fs->pc++] = i; in luaK_code()
388 savelineinfo(fs, f, fs->ls->lastline); in luaK_code()
389 return fs->pc - 1; /* index of new instruction */ in luaK_code()
397 int luaK_codeABCk (FuncState *fs, OpCode o, int a, int b, int c, int k) { in luaK_codeABCk() argument
401 return luaK_code(fs, CREATE_ABCk(o, a, b, c, k)); in luaK_codeABCk()
408 int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { in luaK_codeABx() argument
411 return luaK_code(fs, CREATE_ABx(o, a, bc)); in luaK_codeABx()
418 int luaK_codeAsBx (FuncState *fs, OpCode o, int a, int bc) { in luaK_codeAsBx() argument
422 return luaK_code(fs, CREATE_ABx(o, a, b)); in luaK_codeAsBx()
429 static int codesJ (FuncState *fs, OpCode o, int sj, int k) { in codesJ() argument
433 return luaK_code(fs, CREATE_sJ(o, j, k)); in codesJ()
440 static int codeextraarg (FuncState *fs, int a) { in codeextraarg() argument
442 return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a)); in codeextraarg()
451 static int luaK_codek (FuncState *fs, int reg, int k) { in luaK_codek() argument
453 return luaK_codeABx(fs, OP_LOADK, reg, k); in luaK_codek()
455 int p = luaK_codeABx(fs, OP_LOADKX, reg, 0); in luaK_codek()
456 codeextraarg(fs, k); in luaK_codek()
466 void luaK_checkstack (FuncState *fs, int n) { in luaK_checkstack() argument
467 int newstack = fs->freereg + n; in luaK_checkstack()
468 if (newstack > fs->f->maxstacksize) { in luaK_checkstack()
470 luaX_syntaxerror(fs->ls, in luaK_checkstack()
472 fs->f->maxstacksize = cast_byte(newstack); in luaK_checkstack()
480 void luaK_reserveregs (FuncState *fs, int n) { in luaK_reserveregs() argument
481 luaK_checkstack(fs, n); in luaK_reserveregs()
482 fs->freereg += n; in luaK_reserveregs()
491 static void freereg (FuncState *fs, int reg) { in freereg() argument
492 if (reg >= luaY_nvarstack(fs)) { in freereg()
493 fs->freereg--; in freereg()
494 lua_assert(reg == fs->freereg); in freereg()
502 static void freeregs (FuncState *fs, int r1, int r2) { in freeregs() argument
504 freereg(fs, r1); in freeregs()
505 freereg(fs, r2); in freeregs()
508 freereg(fs, r2); in freeregs()
509 freereg(fs, r1); in freeregs()
517 static void freeexp (FuncState *fs, expdesc *e) { in freeexp() argument
519 freereg(fs, e->u.info); in freeexp()
527 static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) { in freeexps() argument
530 freeregs(fs, r1, r2); in freeexps()
543 static int addk (FuncState *fs, TValue *key, TValue *v) { in addk() argument
545 lua_State *L = fs->ls->L; in addk()
546 Proto *f = fs->f; in addk()
547 const TValue *idx = luaH_get(fs->ls->h, key); /* query scanner table */ in addk()
552 if (k < fs->nk && ttypetag(&f->k[k]) == ttypetag(v) && in addk()
558 k = fs->nk; in addk()
562 luaH_finishset(L, fs->ls->h, key, idx, &val); in addk()
566 fs->nk++; in addk()
575 static int stringK (FuncState *fs, TString *s) { in stringK() argument
577 setsvalue(fs->ls->L, &o, s); in stringK()
578 return addk(fs, &o, &o); /* use string itself as key */ in stringK()
585 static int luaK_intK (FuncState *fs, lua_Integer n) { in luaK_intK() argument
588 return addk(fs, &o, &o); /* use integer itself as key */ in luaK_intK()
602 static int luaK_numberK (FuncState *fs, lua_Number r) { in luaK_numberK() argument
608 return addk(fs, &o, &o); /* use number itself as key */ in luaK_numberK()
618 return addk(fs, &kv, &o); in luaK_numberK()
624 return addk(fs, &o, &o); /* use number itself as key */ in luaK_numberK()
632 static int boolF (FuncState *fs) { in boolF() argument
635 return addk(fs, &o, &o); /* use boolean itself as key */ in boolF()
642 static int boolT (FuncState *fs) { in boolT() argument
645 return addk(fs, &o, &o); /* use boolean itself as key */ in boolT()
652 static int nilK (FuncState *fs) { in nilK() argument
656 sethvalue(fs->ls->L, &k, fs->ls->h); in nilK()
657 return addk(fs, &k, &v); in nilK()
679 void luaK_int (FuncState *fs, int reg, lua_Integer i) { in luaK_int() argument
681 luaK_codeAsBx(fs, OP_LOADI, reg, cast_int(i)); in luaK_int()
683 luaK_codek(fs, reg, luaK_intK(fs, i)); in luaK_int()
687 static void luaK_float (FuncState *fs, int reg, lua_Number f) { in luaK_float() argument
690 luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); in luaK_float()
692 luaK_codek(fs, reg, luaK_numberK(fs, f)); in luaK_float()
728 void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { in luaK_setreturns() argument
729 Instruction *pc = &getinstruction(fs, e); in luaK_setreturns()
735 SETARG_A(*pc, fs->freereg); in luaK_setreturns()
736 luaK_reserveregs(fs, 1); in luaK_setreturns()
744 static void str2K (FuncState *fs, expdesc *e) { in str2K() argument
746 e->u.info = stringK(fs, e->u.strval); in str2K()
761 void luaK_setoneret (FuncState *fs, expdesc *e) { in luaK_setoneret() argument
764 lua_assert(GETARG_C(getinstruction(fs, e)) == 2); in luaK_setoneret()
766 e->u.info = GETARG_A(getinstruction(fs, e)); in luaK_setoneret()
769 SETARG_C(getinstruction(fs, e), 2); in luaK_setoneret()
779 void luaK_dischargevars (FuncState *fs, expdesc *e) { in luaK_dischargevars() argument
782 const2exp(const2val(fs, e), e); in luaK_dischargevars()
791 e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); in luaK_dischargevars()
796 e->u.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
801 freereg(fs, e->u.ind.t); in luaK_dischargevars()
802 e->u.info = luaK_codeABC(fs, OP_GETI, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
807 freereg(fs, e->u.ind.t); in luaK_dischargevars()
808 e->u.info = luaK_codeABC(fs, OP_GETFIELD, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
813 freeregs(fs, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
814 e->u.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.ind.t, e->u.ind.idx); in luaK_dischargevars()
819 luaK_setoneret(fs, e); in luaK_dischargevars()
832 static void discharge2reg (FuncState *fs, expdesc *e, int reg) { in discharge2reg() argument
833 luaK_dischargevars(fs, e); in discharge2reg()
836 luaK_nil(fs, reg, 1); in discharge2reg()
840 luaK_codeABC(fs, OP_LOADFALSE, reg, 0, 0); in discharge2reg()
844 luaK_codeABC(fs, OP_LOADTRUE, reg, 0, 0); in discharge2reg()
848 str2K(fs, e); in discharge2reg()
851 luaK_codek(fs, reg, e->u.info); in discharge2reg()
855 luaK_float(fs, reg, e->u.nval); in discharge2reg()
859 luaK_int(fs, reg, e->u.ival); in discharge2reg()
863 Instruction *pc = &getinstruction(fs, e); in discharge2reg()
869 luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); in discharge2reg()
887 static void discharge2anyreg (FuncState *fs, expdesc *e) { in discharge2anyreg() argument
889 luaK_reserveregs(fs, 1); /* get a register */ in discharge2anyreg()
890 discharge2reg(fs, e, fs->freereg-1); /* put value there */ in discharge2anyreg()
895 static int code_loadbool (FuncState *fs, int A, OpCode op) { in code_loadbool() argument
896 luaK_getlabel(fs); /* those instructions may be jump targets */ in code_loadbool()
897 return luaK_codeABC(fs, op, A, 0, 0); in code_loadbool()
905 static int need_value (FuncState *fs, int list) { in need_value() argument
906 for (; list != NO_JUMP; list = getjump(fs, list)) { in need_value()
907 Instruction i = *getjumpcontrol(fs, list); in need_value()
921 static void exp2reg (FuncState *fs, expdesc *e, int reg) { in exp2reg() argument
922 discharge2reg(fs, e, reg); in exp2reg()
924 luaK_concat(fs, &e->t, e->u.info); /* put this jump in 't' list */ in exp2reg()
929 if (need_value(fs, e->t) || need_value(fs, e->f)) { in exp2reg()
930 int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); in exp2reg()
931 p_f = code_loadbool(fs, reg, OP_LFALSESKIP); /* skip next inst. */ in exp2reg()
932 p_t = code_loadbool(fs, reg, OP_LOADTRUE); in exp2reg()
934 luaK_patchtohere(fs, fj); in exp2reg()
936 final = luaK_getlabel(fs); in exp2reg()
937 patchlistaux(fs, e->f, final, reg, p_f); in exp2reg()
938 patchlistaux(fs, e->t, final, reg, p_t); in exp2reg()
949 void luaK_exp2nextreg (FuncState *fs, expdesc *e) { in luaK_exp2nextreg() argument
950 luaK_dischargevars(fs, e); in luaK_exp2nextreg()
951 freeexp(fs, e); in luaK_exp2nextreg()
952 luaK_reserveregs(fs, 1); in luaK_exp2nextreg()
953 exp2reg(fs, e, fs->freereg - 1); in luaK_exp2nextreg()
961 int luaK_exp2anyreg (FuncState *fs, expdesc *e) { in luaK_exp2anyreg() argument
962 luaK_dischargevars(fs, e); in luaK_exp2anyreg()
966 if (e->u.info >= luaY_nvarstack(fs)) { /* reg. is not a local? */ in luaK_exp2anyreg()
967 exp2reg(fs, e, e->u.info); /* put final result in it */ in luaK_exp2anyreg()
974 luaK_exp2nextreg(fs, e); /* default: use next available register */ in luaK_exp2anyreg()
983 void luaK_exp2anyregup (FuncState *fs, expdesc *e) { in luaK_exp2anyregup() argument
985 luaK_exp2anyreg(fs, e); in luaK_exp2anyregup()
993 void luaK_exp2val (FuncState *fs, expdesc *e) { in luaK_exp2val() argument
995 luaK_exp2anyreg(fs, e); in luaK_exp2val()
997 luaK_dischargevars(fs, e); in luaK_exp2val()
1005 static int luaK_exp2K (FuncState *fs, expdesc *e) { in luaK_exp2K() argument
1009 case VTRUE: info = boolT(fs); break; in luaK_exp2K()
1010 case VFALSE: info = boolF(fs); break; in luaK_exp2K()
1011 case VNIL: info = nilK(fs); break; in luaK_exp2K()
1012 case VKINT: info = luaK_intK(fs, e->u.ival); break; in luaK_exp2K()
1013 case VKFLT: info = luaK_numberK(fs, e->u.nval); break; in luaK_exp2K()
1014 case VKSTR: info = stringK(fs, e->u.strval); break; in luaK_exp2K()
1035 int luaK_exp2RK (FuncState *fs, expdesc *e) { in luaK_exp2RK() argument
1036 if (luaK_exp2K(fs, e)) in luaK_exp2RK()
1039 luaK_exp2anyreg(fs, e); in luaK_exp2RK()
1045 static void codeABRK (FuncState *fs, OpCode o, int a, int b, in codeABRK() argument
1047 int k = luaK_exp2RK(fs, ec); in codeABRK()
1048 luaK_codeABCk(fs, o, a, b, ec->u.info, k); in codeABRK()
1055 void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { in luaK_storevar() argument
1058 freeexp(fs, ex); in luaK_storevar()
1059 exp2reg(fs, ex, var->u.var.ridx); /* compute 'ex' into proper place */ in luaK_storevar()
1063 int e = luaK_exp2anyreg(fs, ex); in luaK_storevar()
1064 luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); in luaK_storevar()
1068 codeABRK(fs, OP_SETTABUP, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1072 codeABRK(fs, OP_SETI, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1076 codeABRK(fs, OP_SETFIELD, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1080 codeABRK(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, ex); in luaK_storevar()
1085 freeexp(fs, ex); in luaK_storevar()
1092 void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { in luaK_self() argument
1094 luaK_exp2anyreg(fs, e); in luaK_self()
1096 freeexp(fs, e); in luaK_self()
1097 e->u.info = fs->freereg; /* base register for op_self */ in luaK_self()
1099 luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ in luaK_self()
1100 codeABRK(fs, OP_SELF, e->u.info, ereg, key); in luaK_self()
1101 freeexp(fs, key); in luaK_self()
1108 static void negatecondition (FuncState *fs, expdesc *e) { in negatecondition() argument
1109 Instruction *pc = getjumpcontrol(fs, e->u.info); in negatecondition()
1122 static int jumponcond (FuncState *fs, expdesc *e, int cond) { in jumponcond() argument
1124 Instruction ie = getinstruction(fs, e); in jumponcond()
1126 removelastinstruction(fs); /* remove previous OP_NOT */ in jumponcond()
1127 return condjump(fs, OP_TEST, GETARG_B(ie), 0, 0, !cond); in jumponcond()
1131 discharge2anyreg(fs, e); in jumponcond()
1132 freeexp(fs, e); in jumponcond()
1133 return condjump(fs, OP_TESTSET, NO_REG, e->u.info, 0, cond); in jumponcond()
1140 void luaK_goiftrue (FuncState *fs, expdesc *e) { in luaK_goiftrue() argument
1142 luaK_dischargevars(fs, e); in luaK_goiftrue()
1145 negatecondition(fs, e); /* jump when it is false */ in luaK_goiftrue()
1154 pc = jumponcond(fs, e, 0); /* jump when false */ in luaK_goiftrue()
1158 luaK_concat(fs, &e->f, pc); /* insert new jump in false list */ in luaK_goiftrue()
1159 luaK_patchtohere(fs, e->t); /* true list jumps to here (to go through) */ in luaK_goiftrue()
1167 void luaK_goiffalse (FuncState *fs, expdesc *e) { in luaK_goiffalse() argument
1169 luaK_dischargevars(fs, e); in luaK_goiffalse()
1180 pc = jumponcond(fs, e, 1); /* jump if true */ in luaK_goiffalse()
1184 luaK_concat(fs, &e->t, pc); /* insert new jump in 't' list */ in luaK_goiffalse()
1185 luaK_patchtohere(fs, e->f); /* false list jumps to here (to go through) */ in luaK_goiffalse()
1193 static void codenot (FuncState *fs, expdesc *e) { in codenot() argument
1204 negatecondition(fs, e); in codenot()
1209 discharge2anyreg(fs, e); in codenot()
1210 freeexp(fs, e); in codenot()
1211 e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); in codenot()
1219 removevalues(fs, e->f); /* values are useless when negated */ in codenot()
1220 removevalues(fs, e->t); in codenot()
1227 static int isKstr (FuncState *fs, expdesc *e) { in isKstr() argument
1229 ttisshrstring(&fs->f->k[e->u.info])); in isKstr()
1285 void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { in luaK_indexed() argument
1287 str2K(fs, k); in luaK_indexed()
1290 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ in luaK_indexed()
1291 luaK_exp2anyreg(fs, t); /* put it in a register */ in luaK_indexed()
1300 if (isKstr(fs, k)) { in luaK_indexed()
1309 t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */ in luaK_indexed()
1340 static int constfolding (FuncState *fs, int op, expdesc *e1, in constfolding() argument
1345 luaO_rawarith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ in constfolding()
1395 static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { in codeunexpval() argument
1396 int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ in codeunexpval()
1397 freeexp(fs, e); in codeunexpval()
1398 e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ in codeunexpval()
1400 luaK_fixline(fs, line); in codeunexpval()
1410 static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2, in finishbinexpval() argument
1413 int v1 = luaK_exp2anyreg(fs, e1); in finishbinexpval()
1414 int pc = luaK_codeABCk(fs, op, 0, v1, v2, 0); in finishbinexpval()
1415 freeexps(fs, e1, e2); in finishbinexpval()
1418 luaK_fixline(fs, line); in finishbinexpval()
1419 luaK_codeABCk(fs, mmop, v1, v2, event, flip); /* to call metamethod */ in finishbinexpval()
1420 luaK_fixline(fs, line); in finishbinexpval()
1428 static void codebinexpval (FuncState *fs, BinOpr opr, in codebinexpval() argument
1431 int v2 = luaK_exp2anyreg(fs, e2); /* make sure 'e2' is in a register */ in codebinexpval()
1436 finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN, binopr2TM(opr)); in codebinexpval()
1443 static void codebini (FuncState *fs, OpCode op, in codebini() argument
1448 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINI, event); in codebini()
1455 static void codebinK (FuncState *fs, BinOpr opr, in codebinK() argument
1460 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event); in codebinK()
1467 static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, in finishbinexpneg() argument
1477 finishbinexpval(fs, e1, e2, op, int2sC(-v2), 0, line, OP_MMBINI, event); in finishbinexpneg()
1479 SETARG_B(fs->f->code[fs->pc - 1], int2sC(v2)); in finishbinexpneg()
1494 static void codebinNoK (FuncState *fs, BinOpr opr, in codebinNoK() argument
1498 codebinexpval(fs, opr, e1, e2, line); /* use standard operators */ in codebinNoK()
1506 static void codearith (FuncState *fs, BinOpr opr, in codearith() argument
1508 if (tonumeral(e2, NULL) && luaK_exp2K(fs, e2)) /* K operand? */ in codearith()
1509 codebinK(fs, opr, e1, e2, flip, line); in codearith()
1511 codebinNoK(fs, opr, e1, e2, flip, line); in codearith()
1520 static void codecommutative (FuncState *fs, BinOpr op, in codecommutative() argument
1528 codebini(fs, OP_ADDI, e1, e2, flip, line, TM_ADD); in codecommutative()
1530 codearith(fs, op, e1, e2, flip, line); in codecommutative()
1538 static void codebitwise (FuncState *fs, BinOpr opr, in codebitwise() argument
1545 if (e2->k == VKINT && luaK_exp2K(fs, e2)) /* K operand? */ in codebitwise()
1546 codebinK(fs, opr, e1, e2, flip, line); in codebitwise()
1548 codebinNoK(fs, opr, e1, e2, flip, line); in codebitwise()
1556 static void codeorder (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { in codeorder() argument
1563 r1 = luaK_exp2anyreg(fs, e1); in codeorder()
1569 r1 = luaK_exp2anyreg(fs, e2); in codeorder()
1574 r1 = luaK_exp2anyreg(fs, e1); in codeorder()
1575 r2 = luaK_exp2anyreg(fs, e2); in codeorder()
1578 freeexps(fs, e1, e2); in codeorder()
1579 e1->u.info = condjump(fs, op, r1, r2, isfloat, 1); in codeorder()
1588 static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { in codeeq() argument
1597 r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */ in codeeq()
1602 else if (luaK_exp2RK(fs, e2)) { /* 2nd expression is constant? */ in codeeq()
1608 r2 = luaK_exp2anyreg(fs, e2); in codeeq()
1610 freeexps(fs, e1, e2); in codeeq()
1611 e1->u.info = condjump(fs, op, r1, r2, isfloat, (opr == OPR_EQ)); in codeeq()
1619 void luaK_prefix (FuncState *fs, UnOpr opr, expdesc *e, int line) { in luaK_prefix() argument
1621 luaK_dischargevars(fs, e); in luaK_prefix()
1624 if (constfolding(fs, opr + LUA_OPUNM, e, &ef)) in luaK_prefix()
1628 codeunexpval(fs, unopr2op(opr), e, line); in luaK_prefix()
1630 case OPR_NOT: codenot(fs, e); break; in luaK_prefix()
1640 void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { in luaK_infix() argument
1641 luaK_dischargevars(fs, v); in luaK_infix()
1644 luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ in luaK_infix()
1648 luaK_goiffalse(fs, v); /* go ahead only if 'v' is false */ in luaK_infix()
1652 luaK_exp2nextreg(fs, v); /* operand must be on the stack */ in luaK_infix()
1661 luaK_exp2anyreg(fs, v); in luaK_infix()
1668 luaK_exp2RK(fs, v); in luaK_infix()
1676 luaK_exp2anyreg(fs, v); in luaK_infix()
1689 static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) { in codeconcat() argument
1690 Instruction *ie2 = previousinstruction(fs); in codeconcat()
1694 freeexp(fs, e2); in codeconcat()
1699 luaK_codeABC(fs, OP_CONCAT, e1->u.info, 2, 0); /* new concat opcode */ in codeconcat()
1700 freeexp(fs, e2); in codeconcat()
1701 luaK_fixline(fs, line); in codeconcat()
1709 void luaK_posfix (FuncState *fs, BinOpr opr, in luaK_posfix() argument
1711 luaK_dischargevars(fs, e2); in luaK_posfix()
1712 if (foldbinop(opr) && constfolding(fs, opr + LUA_OPADD, e1, e2)) in luaK_posfix()
1717 luaK_concat(fs, &e2->f, e1->f); in luaK_posfix()
1723 luaK_concat(fs, &e2->t, e1->t); in luaK_posfix()
1728 luaK_exp2nextreg(fs, e2); in luaK_posfix()
1729 codeconcat(fs, e1, e2, line); in luaK_posfix()
1733 codecommutative(fs, opr, e1, e2, line); in luaK_posfix()
1737 if (finishbinexpneg(fs, e1, e2, OP_ADDI, line, TM_SUB)) in luaK_posfix()
1742 codearith(fs, opr, e1, e2, 0, line); in luaK_posfix()
1746 codebitwise(fs, opr, e1, e2, line); in luaK_posfix()
1752 codebini(fs, OP_SHLI, e1, e2, 1, line, TM_SHL); /* I << r2 */ in luaK_posfix()
1754 else if (finishbinexpneg(fs, e1, e2, OP_SHRI, line, TM_SHL)) { in luaK_posfix()
1758 codebinexpval(fs, opr, e1, e2, line); in luaK_posfix()
1763 codebini(fs, OP_SHRI, e1, e2, 0, line, TM_SHR); /* r1 >> I */ in luaK_posfix()
1765 codebinexpval(fs, opr, e1, e2, line); in luaK_posfix()
1769 codeeq(fs, opr, e1, e2); in luaK_posfix()
1778 codeorder(fs, opr, e1, e2); in luaK_posfix()
1790 void luaK_fixline (FuncState *fs, int line) { in luaK_fixline() argument
1791 removelastlineinfo(fs); in luaK_fixline()
1792 savelineinfo(fs, fs->f, line); in luaK_fixline()
1796 void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize) { in luaK_settablesize() argument
1797 Instruction *inst = &fs->f->code[pc]; in luaK_settablesize()
1814 void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { in luaK_setlist() argument
1819 luaK_codeABC(fs, OP_SETLIST, base, tostore, nelems); in luaK_setlist()
1823 luaK_codeABCk(fs, OP_SETLIST, base, tostore, nelems, 1); in luaK_setlist()
1824 codeextraarg(fs, extra); in luaK_setlist()
1826 fs->freereg = base + 1; /* free registers with list values */ in luaK_setlist()
1850 void luaK_finish (FuncState *fs) { in luaK_finish() argument
1852 Proto *p = fs->f; in luaK_finish()
1853 for (i = 0; i < fs->pc; i++) { in luaK_finish()
1858 if (!(fs->needclose || p->is_vararg)) in luaK_finish()
1864 if (fs->needclose) in luaK_finish()
1872 fixjump(fs, i, target); in luaK_finish()