summaryrefslogtreecommitdiff
path: root/libyasm/errwarn.c
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2003-10-02 05:03:50 +0000
committerPeter Johnson <peter@tortall.net>2003-10-02 05:03:50 +0000
commit55438b722983d01811f5edf1ecfc86df3d2dd31c (patch)
treee944694581a253d32d593b69f0bdabde8be02dbc /libyasm/errwarn.c
parent18b2af8355f76ea9fb1c883488d4ca8046766453 (diff)
downloadyasm-55438b722983d01811f5edf1ecfc86df3d2dd31c.tar.gz
Massive libyasm / module interface update - Phase 1
As yasm has evolved, various minor additions have been made to libyasm to support the new features. These minor additions have accumulated, and some contain significant redundancies. In addition, the core focus of yasm has begun to move away from the front-end commandline program "yasm" to focusing on libyasm, a collection of reusable routines for use in all sorts of programs dealing with code at the assembly level, and the modules that provide specific features for parsing such code. This libyasm/module update focuses on cleaning up much of the cruft that has accumulated in libyasm, standardizing function names, eliminating redundancies, making many of the core objects more reusable for future extensions, and starting to make libyasm and the modules thread-safe by eliminating static variables. Specific changes include: - Making a symbol table data structure (no longer global). It follows a factory model for creating symrecs. - Label symbols now refer only to bytecodes; bytecodes have a pointer to their containing section. - Standardizing on *_create() and *_destroy() for allocation/deallocation. - Adding a standardized callback mechanism for all data structures that allow associated data. Allowed the removal of objfmt and dbgfmt-specific data callbacks in their interfaces. - Unmodularizing linemgr, but allowing multiple linemap instances (linemgr is now renamed linemap). - Remove references to lindex; all virtual lines (from linemap) are now just "line"s. - Eliminating the bytecode "type" enum, instead adding a standardized callback mechanism for custom (and standard internal) bytecode types. This will make it much easier to add new bytecodes, and eliminate the possibility of type collisions. This also allowed the removal of the of_data and df_data bytecodes, as objfmts and dbgfmts can now easily implement their own bytecodes, and the cleanup of arch's bytecode usage. - Remove the bytecodehead and sectionhead pseudo-containers, instead making true containers: section now implements all the functions of bytecodehead, and the new object data structure implements all the functions of sectionhead. - Add object data structure: it's a container that contains sections, a symbol table, and a line mapping for a single object. Every former use of sectionhead now takes an object. - Make arch interface and all standard architectures thread-safe: yasm_arch_module is the module interface; it contains a create() function that returns a yasm_arch * to store local yasm_arch data; all yasm_arch_module functions take the yasm_arch *. - Make nasm parser thread-safe. To be done in phase 2: making other module interfaces thread-safe. Note that while the module interface may be thread-safe, not all modules may be written in such a fashion (hopefully all the "standard" ones will be, but this is yet to be determined). svn path=/trunk/yasm/; revision=1058
Diffstat (limited to 'libyasm/errwarn.c')
-rw-r--r--libyasm/errwarn.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c
index 700a97e3..f62e182d 100644
--- a/libyasm/errwarn.c
+++ b/libyasm/errwarn.c
@@ -179,12 +179,12 @@ def_fatal(const char *fmt, ...)
* type is WE_PARSERERROR.
*/
static errwarn_data *
-errwarn_data_new(unsigned long lindex, int replace_parser_error)
+errwarn_data_new(unsigned long line, int replace_parser_error)
{
errwarn_data *first, *next, *ins_we, *we;
enum { INS_NONE, INS_HEAD, INS_AFTER } action = INS_NONE;
- /* Find the entry with either line=lindex or the last one with line<lindex.
+ /* Find the entry with either line=line or the last one with line<line.
* Start with the last entry added to speed the search.
*/
ins_we = previous_we;
@@ -193,14 +193,14 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
action = INS_HEAD;
while (action == INS_NONE) {
next = SLIST_NEXT(ins_we, link);
- if (lindex < ins_we->line) {
+ if (line < ins_we->line) {
if (ins_we == first)
action = INS_HEAD;
else
ins_we = first;
} else if (!next)
action = INS_AFTER;
- else if (lindex >= ins_we->line && lindex < next->line)
+ else if (line >= ins_we->line && line < next->line)
action = INS_AFTER;
else
ins_we = next;
@@ -214,7 +214,7 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
we = yasm_xmalloc(sizeof(errwarn_data));
we->type = WE_UNKNOWN;
- we->line = lindex;
+ we->line = line;
if (action == INS_HEAD)
SLIST_INSERT_HEAD(&errwarns, we, link);
@@ -231,13 +231,13 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
return we;
}
-/* Register an error at line lindex. Does not print the error, only stores it
+/* Register an error at line line. Does not print the error, only stores it
* for output_all() to print.
*/
void
-yasm__error_va(unsigned long lindex, const char *fmt, va_list va)
+yasm__error_va(unsigned long line, const char *fmt, va_list va)
{
- errwarn_data *we = errwarn_data_new(lindex, 1);
+ errwarn_data *we = errwarn_data_new(line, 1);
we->type = WE_ERROR;
@@ -250,11 +250,11 @@ yasm__error_va(unsigned long lindex, const char *fmt, va_list va)
error_count++;
}
-/* Register an warning at line lindex. Does not print the warning, only stores
+/* Register an warning at line line. Does not print the warning, only stores
* it for output_all() to print.
*/
void
-yasm__warning_va(yasm_warn_class num, unsigned long lindex, const char *fmt,
+yasm__warning_va(yasm_warn_class num, unsigned long line, const char *fmt,
va_list va)
{
errwarn_data *we;
@@ -262,7 +262,7 @@ yasm__warning_va(yasm_warn_class num, unsigned long lindex, const char *fmt,
if (!(warn_class_enabled & (1UL<<num)))
return; /* warning is part of disabled class */
- we = errwarn_data_new(lindex, 0);
+ we = errwarn_data_new(line, 0);
we->type = WE_WARNING;
@@ -275,27 +275,27 @@ yasm__warning_va(yasm_warn_class num, unsigned long lindex, const char *fmt,
warning_count++;
}
-/* Register an error at line lindex. Does not print the error, only stores it
+/* Register an error at line line. Does not print the error, only stores it
* for output_all() to print.
*/
void
-yasm__error(unsigned long lindex, const char *fmt, ...)
+yasm__error(unsigned long line, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
- yasm__error_va(lindex, fmt, va);
+ yasm__error_va(line, fmt, va);
va_end(va);
}
-/* Register an warning at line lindex. Does not print the warning, only stores
+/* Register an warning at line line. Does not print the warning, only stores
* it for output_all() to print.
*/
void
-yasm__warning(yasm_warn_class num, unsigned long lindex, const char *fmt, ...)
+yasm__warning(yasm_warn_class num, unsigned long line, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
- yasm__warning_va(num, lindex, fmt, va);
+ yasm__warning_va(num, line, fmt, va);
va_end(va);
}
@@ -303,9 +303,9 @@ yasm__warning(yasm_warn_class num, unsigned long lindex, const char *fmt, ...)
* system.
*/
void
-yasm__parser_error(unsigned long lindex, const char *s)
+yasm__parser_error(unsigned long line, const char *s)
{
- yasm__error(lindex, N_("parser error: %s"), s);
+ yasm__error(line, N_("parser error: %s"), s);
previous_we->type = WE_PARSERERROR;
}
@@ -337,7 +337,7 @@ yasm_get_num_errors(int warning_as_error)
}
void
-yasm_errwarn_output_all(yasm_linemgr *lm, int warning_as_error,
+yasm_errwarn_output_all(yasm_linemap *lm, int warning_as_error,
yasm_print_error_func print_error, yasm_print_warning_func print_warning)
{
errwarn_data *we;
@@ -354,7 +354,7 @@ yasm_errwarn_output_all(yasm_linemgr *lm, int warning_as_error,
/* Output error/warnings. */
SLIST_FOREACH(we, &errwarns, link) {
/* Output error/warning */
- lm->lookup(we->line, &filename, &line);
+ yasm_linemap_lookup(lm, we->line, &filename, &line);
if (we->type == WE_ERROR)
print_error(filename, line, we->msg);
else