Lines Matching refs:es
203 Expr_state * const es = &curstate; in v_evaluate() local
227 exprtoken(es); in v_evaluate()
228 if (es->tok == END) { in v_evaluate()
229 es->tok = LIT; in v_evaluate()
230 es->val = tempvar(); in v_evaluate()
232 v = intvar(es, evalexpr(es, MAX_PREC)); in v_evaluate()
234 if (es->tok != END) in v_evaluate()
235 evalerr(es, ET_UNEXPECTED, NULL); in v_evaluate()
237 if (es->arith && es->natural) in v_evaluate()
240 setint_v(vp, v, es->arith); in v_evaluate()
251 evalerr(Expr_state *es, enum error_type type, const char *str) in evalerr() argument
256 es->arith = false; in evalerr()
259 switch (es->tok) { in evalerr()
261 s = es->val->name; in evalerr()
264 s = str_val(es->val); in evalerr()
270 tbuf[0] = *es->tokp; in evalerr()
275 s = opinfo[(int)es->tok].name; in evalerr()
277 warningf(true, "%s: %s '%s'", es->expression, in evalerr()
282 warningf(true, "%s: %s '%s'", es->expression, in evalerr()
287 warningf(true, "%s: %s '%s'", es->expression, in evalerr()
293 es->expression, str, "requires lvalue"); in evalerr()
298 es->expression, str, "applied to read-only variable"); in evalerr()
303 warningf(true, "%s: %s", es->expression, str); in evalerr()
311 do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool is_prefix) in do_ppmm() argument
316 assign_check(es, op, vasn); in do_ppmm()
318 vl = intvar(es, vasn); in do_ppmm()
324 if (!es->noassign) { in do_ppmm()
326 setint_v(vasn, vl, es->arith); in do_ppmm()
338 evalexpr(Expr_state *es, unsigned int prec) in evalexpr() argument
345 switch ((int)(op = es->tok)) { in evalexpr()
350 exprtoken(es); in evalexpr()
351 vl = intvar(es, evalexpr(es, P_PRIMARY)); in evalexpr()
369 exprtoken(es); in evalexpr()
370 vl = evalexpr(es, MAX_PREC); in evalexpr()
371 if (es->tok != CLOSE_PAREN) in evalexpr()
372 evalerr(es, ET_STR, "missing )"); in evalexpr()
373 exprtoken(es); in evalexpr()
378 exprtoken(es); in evalexpr()
379 vl = do_ppmm(es, op, es->val, true); in evalexpr()
380 exprtoken(es); in evalexpr()
385 vl = es->val; in evalexpr()
386 exprtoken(es); in evalexpr()
390 evalerr(es, ET_UNEXPECTED, NULL); in evalexpr()
394 if (es->tok == O_PLUSPLUS || es->tok == O_MINUSMINUS) { in evalexpr()
395 vl = do_ppmm(es, es->tok, vl, false); in evalexpr()
396 exprtoken(es); in evalexpr()
403 vl = evalexpr(es, prec - 1); in evalexpr()
404 while ((int)(op = es->tok) >= (int)O_EQ && (int)op <= (int)O_COMMA && in evalexpr()
406 exprtoken(es); in evalexpr()
410 vl = intvar(es, vl); in evalexpr()
412 if (!es->noassign) in evalexpr()
413 assign_check(es, op, vasn); in evalexpr()
414 vr = intvar(es, evalexpr(es, P_ASSIGN)); in evalexpr()
419 es->noassign++; in evalexpr()
420 vl = evalexpr(es, MAX_PREC); in evalexpr()
422 es->noassign--; in evalexpr()
423 if (es->tok != CTERN) in evalexpr()
424 evalerr(es, ET_STR, "missing :"); in evalexpr()
425 exprtoken(es); in evalexpr()
427 es->noassign++; in evalexpr()
428 vr = evalexpr(es, P_TERN); in evalexpr()
430 es->noassign--; in evalexpr()
434 vr = intvar(es, evalexpr(es, prec - 1)); in evalexpr()
443 if (!es->noassign) in evalexpr()
444 evalerr(es, ET_STR, "zero divisor"); in evalexpr()
475 #define cmpop(op) (es->natural ? \ in evalexpr()
488 if (es->natural) { in evalexpr()
495 if (es->natural) { in evalexpr()
545 res = es->natural || vl->val.i >= 0 ? in evalexpr()
581 es->noassign++; in evalexpr()
582 vr = intvar(es, evalexpr(es, prec - 1)); in evalexpr()
585 es->noassign--; in evalexpr()
589 es->noassign++; in evalexpr()
590 vr = intvar(es, evalexpr(es, prec - 1)); in evalexpr()
593 es->noassign--; in evalexpr()
605 if (!es->noassign) { in evalexpr()
607 setint_v(vasn, vr, es->arith); in evalexpr()
619 exprtoken(Expr_state *es) in exprtoken() argument
621 const char *cp = es->tokp; in exprtoken()
629 if (es->tokp == es->expression && c == '#') { in exprtoken()
632 es->natural = true; in exprtoken()
636 es->tokp = cp; in exprtoken()
639 es->tok = END; in exprtoken()
648 evalerr(es, ET_STR, "missing ]"); in exprtoken()
651 if (es->noassign) { in exprtoken()
652 es->val = tempvar(); in exprtoken()
653 es->val->flag |= EXPRLVALUE; in exprtoken()
655 strndupx(tvar, es->tokp, cp - es->tokp, ATEMP); in exprtoken()
656 es->val = global(tvar); in exprtoken()
659 es->tok = VAR; in exprtoken()
663 strndupx(tvar, es->tokp, cp - es->tokp, ATEMP); in exprtoken()
670 evalerr(es, ET_STR, in exprtoken()
673 c = cp - es->tokp; in exprtoken()
677 memcpy(tvar + 2, es->tokp + 1, c - 2); in exprtoken()
684 strndupx(tvar, es->tokp, --cp - es->tokp, ATEMP); in exprtoken()
686 es->val = tempvar(); in exprtoken()
687 es->val->flag &= ~INTEGER; in exprtoken()
688 es->val->type = 0; in exprtoken()
689 es->val->val.s = tvar; in exprtoken()
690 if (setint_v(es->val, es->val, es->arith) == NULL) in exprtoken()
691 evalerr(es, ET_BADLIT, tvar); in exprtoken()
693 es->tok = LIT; in exprtoken()
700 es->tok = (enum token)i; in exprtoken()
705 es->tok = BAD; in exprtoken()
707 es->tokp = cp; in exprtoken()
711 assign_check(Expr_state *es, enum token op, struct tbl *vasn) in assign_check() argument
713 if (es->tok == END || !vasn || in assign_check()
715 evalerr(es, ET_LVALUE, opinfo[(int)op].name); in assign_check()
717 evalerr(es, ET_RDONLY, opinfo[(int)op].name); in assign_check()
737 intvar(Expr_state *es, struct tbl *vp) in intvar() argument
747 if (setint_v(vq, vp, es->arith) == NULL) { in intvar()
749 evalerr(es, ET_RECURSIVE, vp->name); in intvar()
750 es->evaling = vp; in intvar()
752 v_evaluate(vq, str_val(vp), KSH_UNWIND_ERROR, es->arith); in intvar()
754 es->evaling = NULL; in intvar()