void gen_expr_if(expr *e) { char *lblfin; lblfin = out_label_code("ifexp_fi"); gen_expr(e->expr); if(e->lhs){ char *lblelse = out_label_code("ifexp_else"); out_jfalse(lblelse); gen_expr(e->lhs); out_push_lbl(lblfin, 0); out_jmp(); out_label(lblelse); free(lblelse); }else{ out_dup(); out_jtrue(lblfin); } out_pop(); gen_expr(e->rhs); out_label(lblfin); free(lblfin); }
/*------------------------------------------------------------------------- * Function: out_error * * Purpose: Prints an error message followed by an object. * * Return: void * * Programmer: Robb Matzke * [email protected] * Dec 11 1996 * * Modifications: * * Robb Matzke, 3 Feb 1997 * Changed prefix name from `error' to `***ERROR***' to make it * stand out more. * *------------------------------------------------------------------------- */ void out_error (const char *mesg, obj_t obj) { if (!ErrorDisable) { out_reset (OUT_STDERR); out_push (OUT_STDERR, "***ERROR***"); out_putw (OUT_STDERR, mesg); obj_print (obj, OUT_STDERR); out_pop (OUT_STDERR); out_nl (OUT_STDERR); } }
void gen_expr_assign_compound(expr *e) { /* int += float * lea int, cast up to float, add, cast down to int, store */ lea_expr(e->bits.compound_upcast ? expr_cast_child(e->lhs) : e->lhs); if(e->assign_is_post){ out_dup(); out_deref(); out_flush_volatile(); out_swap(); out_comment("saved for compound op"); } out_dup(); /* delay the dereference until after generating rhs. * this is fine, += etc aren't sequence points */ gen_expr(e->rhs); /* here's the delayed dereference */ out_swap(); out_deref(); if(e->bits.compound_upcast) out_cast(e->lhs->tree_type, /*normalise_bool:*/1); out_swap(); out_op(e->op); if(e->bits.compound_upcast) /* need to cast back down to store */ out_cast(e->tree_type, /*normalise_bool:*/1); out_store(); if(e->assign_is_post) out_pop(); }
/*------------------------------------------------------------------------- * Function: out_errorn * * Purpose: Print an error message to the standard error stream, * followed by a linefeed. * * Return: void * * Programmer: Robb Matzke * [email protected] * Dec 11 1996 * * Modifications: * * Robb Matzke, 3 Feb 1997 * Changed prefix name from `error' to `***ERROR***' to make it * stand out more. * *------------------------------------------------------------------------- */ void out_errorn (const char *fmt, ...) { char buf[4096]; va_list ap; if (!ErrorDisable) { va_start (ap, fmt); vsprintf (buf, fmt, ap); va_end (ap); if (OUT_STDERR && OUT_STDERR->f) { out_reset (OUT_STDERR); out_push (OUT_STDERR, "***ERROR***"); out_putw (OUT_STDERR, buf); out_pop (OUT_STDERR); out_nl (OUT_STDERR); } else { fputs (buf, stderr); fputc ('\n', stderr); } } }