]> granicus.if.org Git - yasm/commitdiff
Remove symrec_get_int_value(), add symrec_get_label().
authorPeter Johnson <peter@tortall.net>
Wed, 9 Jan 2002 09:02:33 +0000 (09:02 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 9 Jan 2002 09:02:33 +0000 (09:02 -0000)
svn path=/trunk/yasm/; revision=445

libyasm/symrec.c
libyasm/symrec.h
src/symrec.c
src/symrec.h

index 3dba92fc805aa884fb0e5f77a235432e028535be..8fe3534e6550e0899e496164d89dc50642e4582c 100644 (file)
@@ -227,43 +227,7 @@ symrec_declare(const char *name, SymVisibility vis, void *of_data)
     }
     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 *
 symrec_get_name(const symrec *sym)
 {
@@ -284,6 +248,17 @@ symrec_get_equ(const symrec *sym)
     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
 symrec_get_opt_flags(const symrec *sym)
 {
index c7d7da1d7c30fde45910ce4be19bcf9a668951af..432dae9218721864a508b2a56fe9d57b0c3c5a50 100644 (file)
 /*@dependent@*/ symrec *symrec_declare(const char *name, SymVisibility vis,
                                       /*@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);
 SymVisibility symrec_get_visibility(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 */
 unsigned long symrec_get_opt_flags(const symrec *sym);
index 3dba92fc805aa884fb0e5f77a235432e028535be..8fe3534e6550e0899e496164d89dc50642e4582c 100644 (file)
@@ -227,43 +227,7 @@ symrec_declare(const char *name, SymVisibility vis, void *of_data)
     }
     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 *
 symrec_get_name(const symrec *sym)
 {
@@ -284,6 +248,17 @@ symrec_get_equ(const symrec *sym)
     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
 symrec_get_opt_flags(const symrec *sym)
 {
index c7d7da1d7c30fde45910ce4be19bcf9a668951af..432dae9218721864a508b2a56fe9d57b0c3c5a50 100644 (file)
 /*@dependent@*/ symrec *symrec_declare(const char *name, SymVisibility vis,
                                       /*@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);
 SymVisibility symrec_get_visibility(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 */
 unsigned long symrec_get_opt_flags(const symrec *sym);