]> granicus.if.org Git - yasm/commitdiff
Change yasm_value macros into functions. Fix up the prototype of
authorPeter Johnson <peter@tortall.net>
Wed, 31 May 2006 06:25:28 +0000 (06:25 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 31 May 2006 06:25:28 +0000 (06:25 -0000)
yasm_value_init_sym (which was out of date).

svn path=/branches/new-optimizer/; revision=1546

libyasm/value.c
libyasm/value.h

index 1a0c8b61adb44333dbd7f7ba95743735c2473598..375d3a1327b378f0985b9047546914b2d7fb27aa 100644 (file)
 #include "expr-int.h"
 #include "bc-int.h"
 
+void
+yasm_value_initialize(/*@out@*/ yasm_value *value,
+                     /*@null@*/ /*@kept@*/ yasm_expr *e, unsigned int size)
+{
+    value->abs = e;
+    value->rel = NULL;
+    value->wrt = NULL;
+    value->seg_of = 0;
+    value->rshift = 0;
+    value->curpos_rel = 0;
+    value->ip_rel = 0;
+    value->section_rel = 0;
+    value->size = size;
+}
+
+void
+yasm_value_init_sym(/*@out@*/ yasm_value *value, /*@null@*/ yasm_symrec *sym,
+                   unsigned int size)
+{
+    value->abs = NULL;
+    value->rel = sym;
+    value->wrt = NULL;
+    value->seg_of = 0;
+    value->rshift = 0;
+    value->curpos_rel = 0;
+    value->ip_rel = 0;
+    value->section_rel = 0;
+    value->size = size;
+}
+
+void
+yasm_value_init_copy(yasm_value *value, const yasm_value *orig)
+{
+    value->abs = orig->abs ? yasm_expr_copy(orig->abs) : NULL;
+    value->rel = orig->rel;
+    value->wrt = orig->wrt;
+    value->seg_of = orig->seg_of;
+    value->rshift = orig->rshift;
+    value->curpos_rel = orig->curpos_rel;
+    value->ip_rel = orig->ip_rel;
+    value->section_rel = orig->section_rel;
+    value->size = orig->size;
+}
+
+void
+yasm_value_delete(yasm_value *value)
+{
+    yasm_expr_destroy((value)->abs);
+    value->abs = NULL;
+    value->rel = NULL;
+}
+
 static int
 value_finalize_scan(yasm_value *value, yasm_expr *e, int ssym_not_ok)
 {
index 8687f9c81929d5e71568df9b963e7c0b709b0c59..6aef60117f3c7a5833b6497ea21b81c996418d3c 100644 (file)
@@ -54,9 +54,17 @@ void yasm_value_initialize(/*@out@*/ yasm_value *value,
  * initialized.
  * \param value            value to be initialized
  * \param sym      symrec
+ * \param size     value size (in bits)
  */
 void yasm_value_init_sym(/*@out@*/ yasm_value *value,
-                        /*@null@*/ yasm_symrec *sym);
+                        /*@null@*/ yasm_symrec *sym, unsigned int size);
+
+/** Initialize a #yasm_value as a copy of another yasm_value.  Any expressions
+ * within orig are copied, so it's safe to delete the copy.
+ * \param value            value (copy to create)
+ * \param orig     original value
+ */
+void yasm_value_init_copy(yasm_value *value, const yasm_value *orig);
 
 /** Frees any memory inside value; does not free value itself.
  * \param value            value
@@ -125,40 +133,4 @@ int yasm_value_output_basic
  */
 void yasm_value_print(const yasm_value *value, FILE *f, int indent_level);
 
-
-#ifndef YASM_DOXYGEN
-#define yasm_value_initialize(value, e, sz) \
-    do { \
-       (value)->abs = e; \
-       (value)->rel = NULL; \
-       (value)->wrt = NULL; \
-       (value)->seg_of = 0; \
-       (value)->rshift = 0; \
-       (value)->curpos_rel = 0; \
-       (value)->ip_rel = 0; \
-       (value)->section_rel = 0; \
-       (value)->size = sz; \
-    } while(0)
-
-#define yasm_value_init_sym(value, sym, sz) \
-    do { \
-       (value)->abs = NULL; \
-       (value)->rel = sym; \
-       (value)->wrt = NULL; \
-       (value)->seg_of = 0; \
-       (value)->rshift = 0; \
-       (value)->curpos_rel = 0; \
-       (value)->ip_rel = 0; \
-       (value)->section_rel = 0; \
-       (value)->size = sz; \
-    } while(0)
-
-#define yasm_value_delete(value) \
-    do { \
-       yasm_expr_destroy((value)->abs); \
-       (value)->abs = NULL; \
-       (value)->rel = NULL; \
-    } while(0)
-#endif
-
 #endif