Change yasm_value macros into functions. Fix up the prototype of

yasm_value_init_sym (which was out of date).

svn path=/branches/new-optimizer/; revision=1546
This commit is contained in:
Peter Johnson 2006-05-31 06:25:28 +00:00
parent eca4d7c5c2
commit 23be1d813f
2 changed files with 61 additions and 37 deletions

View file

@ -46,6 +46,58 @@
#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)
{

View 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