Lines Matching refs:es
161 #define bivui(x, op, y) (es->natural ? \
204 Expr_state * const es = &curstate;
228 exprtoken(es);
229 if (es->tok == END) {
230 es->tok = LIT;
231 es->val = tempvar();
233 v = intvar(es, evalexpr(es, MAX_PREC));
235 if (es->tok != END)
236 evalerr(es, ET_UNEXPECTED, NULL);
238 if (es->arith && es->natural)
241 setint_v(vp, v, es->arith);
252 evalerr(Expr_state *es, enum error_type type, const char *str)
257 es->arith = false;
260 switch (es->tok) {
262 s = es->val->name;
265 s = str_val(es->val);
271 tbuf[0] = *es->tokp;
276 s = opinfo[(int)es->tok].name;
278 warningf(true, "%s: %s '%s'", es->expression,
283 warningf(true, "%s: %s '%s'", es->expression,
288 warningf(true, "%s: %s '%s'", es->expression,
294 es->expression, str, "requires lvalue");
299 es->expression, str, "applied to read-only variable");
304 warningf(true, "%s: %s", es->expression, str);
311 evalexpr(Expr_state *es, int prec)
318 op = es->tok;
321 exprtoken(es);
322 vl = intvar(es, evalexpr(es, P_PRIMARY));
331 exprtoken(es);
332 vl = evalexpr(es, MAX_PREC);
333 if (es->tok != CLOSE_PAREN)
334 evalerr(es, ET_STR, "missing )");
335 exprtoken(es);
337 exprtoken(es);
338 vl = do_ppmm(es, op, es->val, true);
339 exprtoken(es);
341 vl = es->val;
342 exprtoken(es);
344 evalerr(es, ET_UNEXPECTED, NULL);
347 if (es->tok == O_PLUSPLUS || es->tok == O_MINUSMINUS) {
348 vl = do_ppmm(es, es->tok, vl, false);
349 exprtoken(es);
353 vl = evalexpr(es, prec - 1);
354 for (op = es->tok; IS_BINOP(op) && opinfo[(int)op].prec == prec;
355 op = es->tok) {
356 exprtoken(es);
360 vl = intvar(es, vl);
362 if (!es->noassign)
363 assign_check(es, op, vasn);
364 vr = intvar(es, evalexpr(es, P_ASSIGN));
366 vr = intvar(es, evalexpr(es, prec - 1));
369 if (es->noassign)
372 evalerr(es, ET_STR, "zero divisor");
384 * signed arithmetics (!es->natural) case,
389 if (!es->natural &&
403 if (!es->natural &&
460 es->noassign++;
461 vr = intvar(es, evalexpr(es, prec - 1));
464 es->noassign--;
468 es->noassign++;
469 vr = intvar(es, evalexpr(es, prec - 1));
472 es->noassign--;
479 es->noassign++;
480 vl = evalexpr(es, MAX_PREC);
482 es->noassign--;
483 if (es->tok != CTERN)
484 evalerr(es, ET_STR, "missing :");
485 exprtoken(es);
487 es->noassign++;
488 vr = evalexpr(es, P_TERN);
490 es->noassign--;
503 if (!es->noassign) {
505 setint_v(vasn, vr, es->arith);
517 exprtoken(Expr_state *es)
519 const char *cp = es->tokp;
527 if (es->tokp == es->expression && c == '#') {
529 es->natural = true; /* switch to unsigned */
533 es->tokp = cp;
536 es->tok = END;
545 evalerr(es, ET_STR, "missing ]");
554 if (es->noassign) {
555 es->val = tempvar();
556 es->val->flag |= EXPRLVALUE;
558 strndupx(tvar, es->tokp, cp - es->tokp, ATEMP);
559 es->val = global(tvar);
562 es->tok = VAR;
566 strndupx(tvar, es->tokp, cp - es->tokp, ATEMP);
573 evalerr(es, ET_STR,
576 c = cp - es->tokp;
580 memcpy(tvar + 2, es->tokp + 1, c - 2);
587 strndupx(tvar, es->tokp, --cp - es->tokp, ATEMP);
589 es->val = tempvar();
590 es->val->flag &= ~INTEGER;
591 es->val->type = 0;
592 es->val->val.s = tvar;
593 if (setint_v(es->val, es->val, es->arith) == NULL)
594 evalerr(es, ET_BADLIT, tvar);
596 es->tok = LIT;
603 es->tok = (enum token)i;
608 es->tok = BAD;
610 es->tokp = cp;
615 do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool is_prefix)
620 assign_check(es, op, vasn);
622 vl = intvar(es, vasn);
625 if (es->natural)
630 if (es->natural)
636 setint_v(vasn, vl, es->arith);
647 assign_check(Expr_state *es, enum token op, struct tbl *vasn)
649 if (es->tok == END || !vasn ||
651 evalerr(es, ET_LVALUE, opinfo[(int)op].name);
653 evalerr(es, ET_RDONLY, opinfo[(int)op].name);
673 intvar(Expr_state *es, struct tbl *vp)
683 if (setint_v(vq, vp, es->arith) == NULL) {
685 evalerr(es, ET_RECURSIVE, vp->name);
686 es->evaling = vp;
688 es->arith);
690 es->evaling = NULL;