2 * (c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: fltcstoper.c,v 1.7 1994/06/27 08:00:02 ceriel Exp $ */
6 /* C O N S T A N T E X P R E S S I O N H A N D L I N G */
7 /* F O R F L O A T I N G P O I N T N U M B E R S */
12 #include "trgt_sizes.h"
14 #include <flt_arith.h>
22 extern int ResultKnown;
23 extern char *symbol2str();
25 fltcstbin(expp, oper, expr)
26 register struct expr **expp, *expr;
28 /* The operation oper is performed on the constant
29 expressions *expp(ld) and expr(ct), and the result restored in
36 o1 = (*expp)->FL_ARITH;
39 ASSERT(is_fp_cst(*expp) && is_fp_cst(expr));
42 flt_mul(&o1, &o2, &o1);
45 flt_div(&o1, &o2, &o1);
48 flt_add(&o1, &o2, &o1);
51 flt_sub(&o1, &o2, &o1);
60 cmpval = flt_cmp(&o1, &o2);
62 case '<': cmpval = (cmpval < 0); break;
63 case '>': cmpval = (cmpval > 0); break;
64 case LESSEQ: cmpval = (cmpval <= 0); break;
65 case GREATEREQ: cmpval = (cmpval >= 0); break;
66 case EQUAL: cmpval = (cmpval == 0); break;
67 case NOTEQUAL: cmpval = (cmpval != 0); break;
71 /* in case of situations like a += 3.0; where a undefined */
78 case FLT_UNFL: /* ignore underflow */
82 expr_warning(expr,"floating point overflow on %s"
87 expr_error(expr,"division by 0.0");
89 expr_warning(expr,"division by 0.0");
91 default: /* there can't be another status */
92 crash("(fltcstoper) bad status");
95 fill_int_expr(*expp, (arith)cmpval, INT);
97 (*expp)->FL_ARITH = o1;
99 (*expp)->ex_flags |= expr->ex_flags;
100 (*expp)->ex_flags &= ~EX_PARENS;
101 free_expression(expr);