Remove symrec_get_int_value(), add symrec_get_label().

svn path=/trunk/yasm/; revision=445
0.3
Peter Johnson 23 years ago
parent 746f2ef74f
commit a3db6e7106
  1. 47
      libyasm/symrec.c
  2. 14
      libyasm/symrec.h
  3. 47
      src/symrec.c
  4. 14
      src/symrec.h

@ -227,43 +227,7 @@ symrec_declare(const char *name, SymVisibility vis, void *of_data)
} }
return rec; return rec;
} }
#if 0
int
symrec_get_int_value(const symrec *sym, unsigned long *ret_val,
int resolve_label)
{
/* If we already know the value, just return it. */
if (sym->status & SYM_VALUED) {
switch (sym->type) {
case SYM_CONSTANT_INT:
*ret_val = sym->value.int_val;
break;
case SYM_CONSTANT_FLOAT:
/* FIXME: Line number on this error will be incorrect. */
if (floatnum_get_int(ret_val, sym->value.flt))
Error(_("Floating point value cannot fit in 32-bit single precision"));
break;
case SYM_LABEL:
if (!bytecode_get_offset(sym->value.label.sect,
sym->value.label.bc, ret_val))
InternalError(__LINE__, __FILE__,
_("Label symbol is valued but cannot get offset"));
case SYM_UNKNOWN:
InternalError(__LINE__, __FILE__,
_("Have a valued symbol but of unknown type"));
}
return 1;
}
/* Try to get offset of unvalued label */
if (resolve_label && sym->type == SYM_LABEL)
return bytecode_get_offset(sym->value.label.sect, sym->value.label.bc,
ret_val);
/* We can't get the value right now. */
return 0;
}
#endif
const char * const char *
symrec_get_name(const symrec *sym) symrec_get_name(const symrec *sym)
{ {
@ -284,6 +248,17 @@ symrec_get_equ(const symrec *sym)
return (const expr *)NULL; return (const expr *)NULL;
} }
int
symrec_get_label(const symrec *sym, symrec_get_label_sectionp *sect,
symrec_get_label_bytecodep *precbc)
{
if (sym->type != SYM_LABEL)
return 0;
*sect = sym->value.label.sect;
*precbc = sym->value.label.bc;
return 1;
}
unsigned long unsigned long
symrec_get_opt_flags(const symrec *sym) symrec_get_opt_flags(const symrec *sym)
{ {

@ -34,18 +34,16 @@
/*@dependent@*/ symrec *symrec_declare(const char *name, SymVisibility vis, /*@dependent@*/ symrec *symrec_declare(const char *name, SymVisibility vis,
/*@only@*/ /*@null@*/ void *of_data); /*@only@*/ /*@null@*/ void *of_data);
/* Get the numeric 32-bit value of a symbol if possible.
* Return value is IF POSSIBLE, not the value.
* If resolve_label is true, tries to get offset of labels, otherwise it
* returns not possible.
*/
int symrec_get_int_value(const symrec *sym, unsigned long *ret_val,
int resolve_label);
/*@observer@*/ const char *symrec_get_name(const symrec *sym); /*@observer@*/ const char *symrec_get_name(const symrec *sym);
SymVisibility symrec_get_visibility(const symrec *sym); SymVisibility symrec_get_visibility(const symrec *sym);
/*@observer@*/ /*@null@*/ const expr *symrec_get_equ(const symrec *sym); /*@observer@*/ /*@null@*/ const expr *symrec_get_equ(const symrec *sym);
/* Returns 0 if not a label or if EXTERN/COMMON (not defined in the file) */
typedef /*@dependent@*/ section *symrec_get_label_sectionp;
typedef /*@dependent@*/ /*@null@*/ bytecode *symrec_get_label_bytecodep;
int symrec_get_label(const symrec *sym,
/*@out@*/ symrec_get_label_sectionp *sect,
/*@out@*/ symrec_get_label_bytecodep *precbc);
/* Get and set optimizer flags */ /* Get and set optimizer flags */
unsigned long symrec_get_opt_flags(const symrec *sym); unsigned long symrec_get_opt_flags(const symrec *sym);

@ -227,43 +227,7 @@ symrec_declare(const char *name, SymVisibility vis, void *of_data)
} }
return rec; return rec;
} }
#if 0
int
symrec_get_int_value(const symrec *sym, unsigned long *ret_val,
int resolve_label)
{
/* If we already know the value, just return it. */
if (sym->status & SYM_VALUED) {
switch (sym->type) {
case SYM_CONSTANT_INT:
*ret_val = sym->value.int_val;
break;
case SYM_CONSTANT_FLOAT:
/* FIXME: Line number on this error will be incorrect. */
if (floatnum_get_int(ret_val, sym->value.flt))
Error(_("Floating point value cannot fit in 32-bit single precision"));
break;
case SYM_LABEL:
if (!bytecode_get_offset(sym->value.label.sect,
sym->value.label.bc, ret_val))
InternalError(__LINE__, __FILE__,
_("Label symbol is valued but cannot get offset"));
case SYM_UNKNOWN:
InternalError(__LINE__, __FILE__,
_("Have a valued symbol but of unknown type"));
}
return 1;
}
/* Try to get offset of unvalued label */
if (resolve_label && sym->type == SYM_LABEL)
return bytecode_get_offset(sym->value.label.sect, sym->value.label.bc,
ret_val);
/* We can't get the value right now. */
return 0;
}
#endif
const char * const char *
symrec_get_name(const symrec *sym) symrec_get_name(const symrec *sym)
{ {
@ -284,6 +248,17 @@ symrec_get_equ(const symrec *sym)
return (const expr *)NULL; return (const expr *)NULL;
} }
int
symrec_get_label(const symrec *sym, symrec_get_label_sectionp *sect,
symrec_get_label_bytecodep *precbc)
{
if (sym->type != SYM_LABEL)
return 0;
*sect = sym->value.label.sect;
*precbc = sym->value.label.bc;
return 1;
}
unsigned long unsigned long
symrec_get_opt_flags(const symrec *sym) symrec_get_opt_flags(const symrec *sym)
{ {

@ -34,18 +34,16 @@
/*@dependent@*/ symrec *symrec_declare(const char *name, SymVisibility vis, /*@dependent@*/ symrec *symrec_declare(const char *name, SymVisibility vis,
/*@only@*/ /*@null@*/ void *of_data); /*@only@*/ /*@null@*/ void *of_data);
/* Get the numeric 32-bit value of a symbol if possible.
* Return value is IF POSSIBLE, not the value.
* If resolve_label is true, tries to get offset of labels, otherwise it
* returns not possible.
*/
int symrec_get_int_value(const symrec *sym, unsigned long *ret_val,
int resolve_label);
/*@observer@*/ const char *symrec_get_name(const symrec *sym); /*@observer@*/ const char *symrec_get_name(const symrec *sym);
SymVisibility symrec_get_visibility(const symrec *sym); SymVisibility symrec_get_visibility(const symrec *sym);
/*@observer@*/ /*@null@*/ const expr *symrec_get_equ(const symrec *sym); /*@observer@*/ /*@null@*/ const expr *symrec_get_equ(const symrec *sym);
/* Returns 0 if not a label or if EXTERN/COMMON (not defined in the file) */
typedef /*@dependent@*/ section *symrec_get_label_sectionp;
typedef /*@dependent@*/ /*@null@*/ bytecode *symrec_get_label_bytecodep;
int symrec_get_label(const symrec *sym,
/*@out@*/ symrec_get_label_sectionp *sect,
/*@out@*/ symrec_get_label_bytecodep *precbc);
/* Get and set optimizer flags */ /* Get and set optimizer flags */
unsigned long symrec_get_opt_flags(const symrec *sym); unsigned long symrec_get_opt_flags(const symrec *sym);

Loading…
Cancel
Save