]> granicus.if.org Git - yasm/commitdiff
Correctly output float expressions.
authorPeter Johnson <peter@tortall.net>
Mon, 18 Mar 2002 08:01:04 +0000 (08:01 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 18 Mar 2002 08:01:04 +0000 (08:01 -0000)
svn path=/trunk/yasm/; revision=530

modules/objfmts/bin/bin-objfmt.c
src/objfmts/bin/bin-objfmt.c

index 1e8a06cd5355803661c05743c07569d6e41224f7..3bd10069b05dc1f3361088e9c11cd29e3ecf4849 100644 (file)
@@ -27,6 +27,7 @@
 #include "globals.h"
 #include "errwarn.h"
 #include "intnum.h"
+#include "floatnum.h"
 #include "expr.h"
 #include "symrec.h"
 
@@ -185,6 +186,7 @@ bin_objfmt_output_expr(expr **ep, unsigned char **bufp, unsigned long valsize,
     /*@null@*/ bin_objfmt_output_info *info = (bin_objfmt_output_info *)d;
     bin_objfmt_expr_data data;
     /*@dependent@*/ /*@null@*/ const intnum *num;
+    /*@dependent@*/ /*@null@*/ const floatnum *flt;
     unsigned long val;
 
     assert(info != NULL);
@@ -205,6 +207,25 @@ bin_objfmt_output_expr(expr **ep, unsigned char **bufp, unsigned long valsize,
        data.withstart = 1;
     }
     expr_traverse_leaves_in(*ep, &data, bin_objfmt_expr_traverse_callback);
+
+    /* Handle floating point expressions */
+    flt = expr_get_floatnum(ep);
+    if (flt) {
+       int fltret;
+       fltret = floatnum_get_sized(flt, *bufp, valsize);
+       if (fltret < 0) {
+           ErrorAt((*ep)->line, _("underflow in floating point expression"));
+           return 1;
+       }
+       if (fltret > 0) {
+           ErrorAt((*ep)->line, _("overflow in floating point expression"));
+           return 1;
+       }
+       *bufp += valsize;
+       return 0;
+    }
+
+    /* Handle integer expressions */
     num = expr_get_intnum(ep);
     if (!num) {
        ErrorAt((*ep)->line,
index 1e8a06cd5355803661c05743c07569d6e41224f7..3bd10069b05dc1f3361088e9c11cd29e3ecf4849 100644 (file)
@@ -27,6 +27,7 @@
 #include "globals.h"
 #include "errwarn.h"
 #include "intnum.h"
+#include "floatnum.h"
 #include "expr.h"
 #include "symrec.h"
 
@@ -185,6 +186,7 @@ bin_objfmt_output_expr(expr **ep, unsigned char **bufp, unsigned long valsize,
     /*@null@*/ bin_objfmt_output_info *info = (bin_objfmt_output_info *)d;
     bin_objfmt_expr_data data;
     /*@dependent@*/ /*@null@*/ const intnum *num;
+    /*@dependent@*/ /*@null@*/ const floatnum *flt;
     unsigned long val;
 
     assert(info != NULL);
@@ -205,6 +207,25 @@ bin_objfmt_output_expr(expr **ep, unsigned char **bufp, unsigned long valsize,
        data.withstart = 1;
     }
     expr_traverse_leaves_in(*ep, &data, bin_objfmt_expr_traverse_callback);
+
+    /* Handle floating point expressions */
+    flt = expr_get_floatnum(ep);
+    if (flt) {
+       int fltret;
+       fltret = floatnum_get_sized(flt, *bufp, valsize);
+       if (fltret < 0) {
+           ErrorAt((*ep)->line, _("underflow in floating point expression"));
+           return 1;
+       }
+       if (fltret > 0) {
+           ErrorAt((*ep)->line, _("overflow in floating point expression"));
+           return 1;
+       }
+       *bufp += valsize;
+       return 0;
+    }
+
+    /* Handle integer expressions */
     num = expr_get_intnum(ep);
     if (!num) {
        ErrorAt((*ep)->line,