]> granicus.if.org Git - yasm/commitdiff
Add expr_get_floatnum().
authorPeter Johnson <peter@tortall.net>
Mon, 18 Mar 2002 08:00:39 +0000 (08:00 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 18 Mar 2002 08:00:39 +0000 (08:00 -0000)
svn path=/trunk/yasm/; revision=529

libyasm/expr.c
libyasm/expr.h
src/expr.c
src/expr.h

index 119e36b1728491334ae57f213216a31d0c3dc816..d47740879db4c651972d6c4e66891c51c78c85e2 100644 (file)
@@ -845,6 +845,19 @@ expr_get_intnum(expr **ep)
 }
 /*@=unqualifiedtrans =nullderef -nullstate -onlytrans@*/
 
+/*@-unqualifiedtrans -nullderef -nullstate -onlytrans@*/
+const floatnum *
+expr_get_floatnum(expr **ep)
+{
+    *ep = expr_simplify(*ep);
+
+    if ((*ep)->op == EXPR_IDENT && (*ep)->terms[0].type == EXPR_FLOAT)
+       return (*ep)->terms[0].data.flt;
+    else
+       return (floatnum *)NULL;
+}
+/*@=unqualifiedtrans =nullderef -nullstate -onlytrans@*/
+
 /*@-unqualifiedtrans -nullderef -nullstate -onlytrans@*/
 const symrec *
 expr_get_symrec(expr **ep, int simplify)
index 76476866b9ac22c0ca31545a239fde94b144cdd6..d76a5d4fb771350abe8fc2e18e1232d8b9fecb0f 100644 (file)
@@ -66,6 +66,12 @@ void expr_expand_labelequ(expr *e, const section *srcsect, int withstart,
  */
 /*@dependent@*/ /*@null@*/ const intnum *expr_get_intnum(expr **ep);
 
+/* Gets the float value of e if the expression is just an float.  If the
+ * expression is more complex (contains anything other than floats, ie
+ * integers, non-valued labels, registers), returns NULL.
+ */
+/*@dependent@*/ /*@null@*/ const floatnum *expr_get_floatnum(expr **ep);
+
 /* Gets the symrec value of e if the expression is just an symbol.  If the
  * expression is more complex, returns NULL.  Simplifies the expr first if
  * simplify is nonzero.
index 119e36b1728491334ae57f213216a31d0c3dc816..d47740879db4c651972d6c4e66891c51c78c85e2 100644 (file)
@@ -845,6 +845,19 @@ expr_get_intnum(expr **ep)
 }
 /*@=unqualifiedtrans =nullderef -nullstate -onlytrans@*/
 
+/*@-unqualifiedtrans -nullderef -nullstate -onlytrans@*/
+const floatnum *
+expr_get_floatnum(expr **ep)
+{
+    *ep = expr_simplify(*ep);
+
+    if ((*ep)->op == EXPR_IDENT && (*ep)->terms[0].type == EXPR_FLOAT)
+       return (*ep)->terms[0].data.flt;
+    else
+       return (floatnum *)NULL;
+}
+/*@=unqualifiedtrans =nullderef -nullstate -onlytrans@*/
+
 /*@-unqualifiedtrans -nullderef -nullstate -onlytrans@*/
 const symrec *
 expr_get_symrec(expr **ep, int simplify)
index 76476866b9ac22c0ca31545a239fde94b144cdd6..d76a5d4fb771350abe8fc2e18e1232d8b9fecb0f 100644 (file)
@@ -66,6 +66,12 @@ void expr_expand_labelequ(expr *e, const section *srcsect, int withstart,
  */
 /*@dependent@*/ /*@null@*/ const intnum *expr_get_intnum(expr **ep);
 
+/* Gets the float value of e if the expression is just an float.  If the
+ * expression is more complex (contains anything other than floats, ie
+ * integers, non-valued labels, registers), returns NULL.
+ */
+/*@dependent@*/ /*@null@*/ const floatnum *expr_get_floatnum(expr **ep);
+
 /* Gets the symrec value of e if the expression is just an symbol.  If the
  * expression is more complex, returns NULL.  Simplifies the expr first if
  * simplify is nonzero.