[RFA] Handle BINOP_INTDIV in valarith.c

Pierre Muller muller@ics.u-strasbg.fr
Wed Jan 23 22:36:00 GMT 2008



> -----Original Message-----
> From: Joel Brobecker [mailto:brobecker@adacore.com]
> Sent: Wednesday, January 23, 2008 7:25 PM
> To: Pierre Muller
> Cc: 'Eli Zaretskii'; gdb-patches@sourceware.org
> Subject: Re: [RFA] Handle BINOP_INTDIV in valarith.c
> 
> >   I will send a separate patch for
> > a new binop called BINOP_FLOATDIV
> > that will force the result of 'a / b' to be a
> > float in all cases.
> 
> That seems unnecessary to me unless BINOP_DIV and your BINOP_FLOATDIV
> have different meanings in Pascal? Otherwise, I think the problem is
> that the pascal language needs its own expression evaluator so that
> it can handle the '/' operator specifically. The rest can be delegated
> to the standard expression evaluator.

  I wrote the floatdiv version,
which allows me to easily force the conversion to double
formats for left and right operand:
  This simple patch portion from gdb/valarith.c does the main trick:
@@ -865,7 +868,8 @@ value_binop (struct value *arg1, struct 
     }
   else if (TYPE_CODE (type1) == TYPE_CODE_FLT
 	   ||
-	   TYPE_CODE (type2) == TYPE_CODE_FLT)
+	   TYPE_CODE (type2) == TYPE_CODE_FLT
+	   || op == BINOP_FLOATDIV)
     {
       /* FIXME-if-picky-about-floating-accuracy: Should be doing this
          in target format.  real.c in GCC probably has the necessary

Adding BINOP_FLOATDIV is indeed unnecessary if
you can tell me how to check for the correct
languages here.

   maybe 
   || (op == BINOP_DIV && current_language = language_pascal))
would work, but I don't know if current_language is the right variable to
test and it would make the use of this feature by other languages
more complicated than just switching from
BINOP_DIV vto BINOP_FLOATDIV in their respective expression parser?


Pierre Muller
GDB pascal language support maintainer




More information about the Gdb-patches mailing list