libyasm/errwarn.h File Reference

YASM error and warning reporting interface. More...

Go to the source code of this file.

Defines

#define yasm_internal_error(message)   yasm_internal_error_(__FILE__, __LINE__, message)
 Easily-callable version of yasm_internal_error_().

Typedefs

typedef void(*) yasm_print_error_func (const char *fn, unsigned long line, const char *msg, const char *xref_fn, unsigned long xref_line, const char *xref_msg)
 Print out an error.
typedef void(*) yasm_print_warning_func (const char *fn, unsigned long line, const char *msg)
 Print out a warning.

Enumerations

enum  yasm_warn_class {
  YASM_WARN_NONE = 0, YASM_WARN_GENERAL, YASM_WARN_UNREC_CHAR, YASM_WARN_PREPROC,
  YASM_WARN_ORPHAN_LABEL, YASM_WARN_UNINIT_CONTENTS, YASM_WARN_SIZE_OVERRIDE
}
 Warning classes (that may be enabled/disabled). More...
enum  yasm_error_class {
  YASM_ERROR_NONE = 0x0000, YASM_ERROR_GENERAL = 0xFFFF, YASM_ERROR_ARITHMETIC = 0x0001, YASM_ERROR_OVERFLOW = 0x8001,
  YASM_ERROR_FLOATING_POINT = 0x4001, YASM_ERROR_ZERO_DIVISION = 0x2001, YASM_ERROR_ASSERTION = 0x0002, YASM_ERROR_VALUE = 0x0004,
  YASM_ERROR_NOT_ABSOLUTE = 0x8004, YASM_ERROR_TOO_COMPLEX = 0x4004, YASM_ERROR_NOT_CONSTANT = 0x2004, YASM_ERROR_IO = 0x0008,
  YASM_ERROR_NOT_IMPLEMENTED = 0x0010, YASM_ERROR_TYPE = 0x0020, YASM_ERROR_SYNTAX = 0x0040, YASM_ERROR_PARSE = 0x8040
}
 Error classes. More...

Functions

YASM_LIB_DECL void yasm_errwarn_initialize (void)
 Initialize any internal data structures.
YASM_LIB_DECL void yasm_errwarn_cleanup (void)
 Clean up any memory allocated by yasm_errwarn_initialize() or other functions.
YASM_LIB_DECL void yasm__fatal (const char *message,...)
 Reporting point of fatal errors, with variable arguments (internal only).
YASM_LIB_DECL void yasm_error_clear (void)
 Unconditionally clear the error indicator, freeing any associated data.
yasm_error_class yasm_error_occurred (void)
 Get the error indicator.
YASM_LIB_DECL int yasm_error_matches (yasm_error_class eclass)
 Check the error indicator against an error class.
YASM_LIB_DECL void yasm_error_set_va (yasm_error_class eclass, const char *format, va_list va)
 Set the error indicator (va_list version).
YASM_LIB_DECL void yasm_error_set (yasm_error_class eclass, const char *format,...)
 Set the error indicator.
YASM_LIB_DECL void yasm_error_set_xref_va (unsigned long xrefline, const char *format, va_list va)
 Set a cross-reference for a new error (va_list version).
YASM_LIB_DECL void yasm_error_set_xref (unsigned long xrefline, const char *format,...)
 Set a cross-reference for a new error.
YASM_LIB_DECL void yasm_error_fetch (yasm_error_class *eclass, char **str, unsigned long *xrefline, char **xrefstr)
 Fetch the error indicator and all associated data.
YASM_LIB_DECL void yasm_warn_clear (void)
 Unconditionally clear all warning indicators, freeing any associated data.
YASM_LIB_DECL yasm_warn_class yasm_warn_occurred (void)
 Get the first warning indicator.
YASM_LIB_DECL void yasm_warn_set_va (yasm_warn_class wclass, const char *format, va_list va)
 Add a warning indicator (va_list version).
YASM_LIB_DECL void yasm_warn_set (yasm_warn_class wclass, const char *format,...)
 Add a warning indicator.
YASM_LIB_DECL void yasm_warn_fetch (yasm_warn_class *wclass, char **str)
 Fetch the first warning indicator and all associated data.
YASM_LIB_DECL void yasm_warn_enable (yasm_warn_class wclass)
 Enable a class of warnings.
YASM_LIB_DECL void yasm_warn_disable (yasm_warn_class wclass)
 Disable a class of warnings.
YASM_LIB_DECL void yasm_warn_disable_all (void)
 Disable all classes of warnings.
YASM_LIB_DECL yasm_errwarnsyasm_errwarns_create (void)
 Create an error/warning set for collection of multiple error/warnings.
YASM_LIB_DECL void yasm_errwarns_destroy (yasm_errwarns *errwarns)
 Destroy an error/warning set.
YASM_LIB_DECL void yasm_errwarn_propagate (yasm_errwarns *errwarns, unsigned long line)
 Propagate error indicator and warning indicator(s) to an error/warning set.
YASM_LIB_DECL unsigned int yasm_errwarns_num_errors (yasm_errwarns *errwarns, int warning_as_error)
 Get total number of errors logged.
YASM_LIB_DECL void yasm_errwarns_output_all (yasm_errwarns *errwarns, yasm_linemap *lm, int warning_as_error, yasm_print_error_func print_error, yasm_print_warning_func print_warning)
 Outputs error/warning set in sorted order (sorted by virtual line number).
YASM_LIB_DECL char * yasm__conv_unprint (int ch)
 Convert a possibly unprintable character into a printable string.

Variables

YASM_LIB_DECL void(*) yasm_internal_error_ (const char *file, unsigned int line, const char *message)
 Reporting point of internal errors.
YASM_LIB_DECL void(*) yasm_fatal (const char *message, va_list va)
 Reporting point of fatal errors.
YASM_LIB_DECL const char *(*) yasm_gettext_hook (const char *msgid)
 Hook for library users to map to gettext() if GNU gettext is being used.


Detailed Description

YASM error and warning reporting interface.

Definition in file errwarn.h.


Define Documentation

#define yasm_internal_error ( message   )     yasm_internal_error_(__FILE__, __LINE__, message)

Easily-callable version of yasm_internal_error_().

Automatically uses __FILE__ and __LINE__ as the file and line.

Parameters:
message internal error message

Definition at line 99 of file errwarn.h.


Typedef Documentation

typedef void(*) yasm_print_error_func(const char *fn, unsigned long line, const char *msg,const char *xref_fn, unsigned long xref_line,const char *xref_msg)

Print out an error.

Parameters:
fn filename of source file
line line number
msg error message
xref_fn cross-referenced source filename
xref_line cross-referenced line number
xref_msg cross-referenced error message

Definition at line 312 of file errwarn.h.

typedef void(*) yasm_print_warning_func(const char *fn, unsigned long line, const char *msg)

Print out a warning.

Parameters:
fn filename of source file
line line number
msg warning message

Definition at line 322 of file errwarn.h.


Enumeration Type Documentation

enum yasm_error_class

Error classes.

Bitmask-based to support limited subclassing.

Enumerator:
YASM_ERROR_NONE  No error.
YASM_ERROR_GENERAL  Non-specific.
YASM_ERROR_ARITHMETIC  Arithmetic error (general).
YASM_ERROR_OVERFLOW  Arithmetic overflow.
YASM_ERROR_FLOATING_POINT  Floating point error.
YASM_ERROR_ZERO_DIVISION  Divide-by-zero.
YASM_ERROR_ASSERTION  Assertion error.
YASM_ERROR_VALUE  Value inappropriate (e.g.

not in range)

YASM_ERROR_NOT_ABSOLUTE  Absolute expression required.
YASM_ERROR_TOO_COMPLEX  Expression too complex.
YASM_ERROR_NOT_CONSTANT  Constant expression required.
YASM_ERROR_IO  I/O error.
YASM_ERROR_NOT_IMPLEMENTED  Not implemented error.
YASM_ERROR_TYPE  Type error.
YASM_ERROR_SYNTAX  Syntax error.
YASM_ERROR_PARSE  Parser error.

Definition at line 53 of file errwarn.h.

enum yasm_warn_class

Warning classes (that may be enabled/disabled).

Enumerator:
YASM_WARN_NONE  No warning.
YASM_WARN_GENERAL  Non-specific warnings.
YASM_WARN_UNREC_CHAR  Unrecognized characters (while tokenizing).
YASM_WARN_PREPROC  Preprocessor warnings.
YASM_WARN_ORPHAN_LABEL  Label alone on a line without a colon.
YASM_WARN_UNINIT_CONTENTS  Uninitialized space in code/data section.
YASM_WARN_SIZE_OVERRIDE  Double size override.

Definition at line 42 of file errwarn.h.


Function Documentation

YASM_LIB_DECL char* yasm__conv_unprint ( int  ch  ) 

Convert a possibly unprintable character into a printable string.

For internal use only.

Parameters:
ch possibly unprintable character
Returns:
Printable string representation (static buffer).

YASM_LIB_DECL void yasm__fatal ( const char *  message,
  ... 
)

Reporting point of fatal errors, with variable arguments (internal only).

Warning:
This function calls yasm_fatal, and thus does not return to the calling code.
Parameters:
message fatal error message
... argument list for message

YASM_LIB_DECL void yasm_error_clear ( void   ) 

Unconditionally clear the error indicator, freeing any associated data.

Has no effect if the error indicator is not set.

YASM_LIB_DECL void yasm_error_fetch ( yasm_error_class eclass,
char **  str,
unsigned long *  xrefline,
char **  xrefstr 
)

Fetch the error indicator and all associated data.

If the error indicator is set, the output pointers are set to the current error indicator values, and the error indicator is cleared. The code using this function is then responsible for yasm_xfree()'ing str and xrefstr (if non-NULL). If the error indicator is not set, all output values are set to 0 (including eclass, which is set to YASM_ERROR_NONE).

Parameters:
eclass error class (output)
str error message
xrefline virtual line used for cross-referencing (0 if no xref)
xrefstr cross-reference error message (NULL if no xref)

YASM_LIB_DECL int yasm_error_matches ( yasm_error_class  eclass  ) 

Check the error indicator against an error class.

To check if any error has been set, check against the YASM_ERROR_GENERAL class. This function properly checks error subclasses.

Parameters:
eclass base error class to check against
Returns:
Nonzero if error indicator is set and a subclass of eclass, 0 otherwise.

yasm_error_class yasm_error_occurred ( void   ) 

Get the error indicator.

YASM_ERROR_NONE is returned if no error has been set. Note that as YASM_ERROR_NONE is 0, the return value can also be treated as a boolean value.

Returns:
Current error indicator.

YASM_LIB_DECL void yasm_error_set ( yasm_error_class  eclass,
const char *  format,
  ... 
)

Set the error indicator.

Has no effect if the error indicator is already set.

Parameters:
eclass error class
format printf format string
... argument list for format

YASM_LIB_DECL void yasm_error_set_va ( yasm_error_class  eclass,
const char *  format,
va_list  va 
)

Set the error indicator (va_list version).

Has no effect if the error indicator is already set.

Parameters:
eclass error class
format printf format string
va argument list for format

YASM_LIB_DECL void yasm_error_set_xref ( unsigned long  xrefline,
const char *  format,
  ... 
)

Set a cross-reference for a new error.

Has no effect if the error indicator is already set (e.g. with yasm_error_set()). This function must be called prior to its corresponding yasm_error_set() call.

Parameters:
xrefline virtual line to cross-reference to (should not be 0)
format printf format string
... argument list for format

YASM_LIB_DECL void yasm_error_set_xref_va ( unsigned long  xrefline,
const char *  format,
va_list  va 
)

Set a cross-reference for a new error (va_list version).

Has no effect if the error indicator is already set (e.g. with yasm_error_set()). This function must be called prior to its corresponding yasm_error_set() call.

Parameters:
xrefline virtual line to cross-reference to (should not be 0)
format printf format string
va argument list for format

YASM_LIB_DECL void yasm_errwarn_initialize ( void   ) 

Initialize any internal data structures.

YASM_LIB_DECL void yasm_errwarn_propagate ( yasm_errwarns errwarns,
unsigned long  line 
)

Propagate error indicator and warning indicator(s) to an error/warning set.

Has no effect if the error indicator and warning indicator are not set. Does not print immediately; yasm_errwarn_output_all() outputs accumulated errors and warnings. Generally multiple errors on the same line will be reported, but errors of class YASM_ERROR_PARSE will get overwritten by any other class on the same line.

Parameters:
errwarns error/warning set
line virtual line

YASM_LIB_DECL yasm_errwarns* yasm_errwarns_create ( void   ) 

Create an error/warning set for collection of multiple error/warnings.

Returns:
Newly allocated set.

YASM_LIB_DECL void yasm_errwarns_destroy ( yasm_errwarns errwarns  ) 

Destroy an error/warning set.

Parameters:
errwarns error/warning set

YASM_LIB_DECL unsigned int yasm_errwarns_num_errors ( yasm_errwarns errwarns,
int  warning_as_error 
)

Get total number of errors logged.

Parameters:
errwarns error/warning set
warning_as_error if nonzero, warnings are treated as errors.
Returns:
Number of errors.

YASM_LIB_DECL void yasm_errwarns_output_all ( yasm_errwarns errwarns,
yasm_linemap lm,
int  warning_as_error,
yasm_print_error_func  print_error,
yasm_print_warning_func  print_warning 
)

Outputs error/warning set in sorted order (sorted by virtual line number).

Parameters:
errwarns error/warning set
lm line map (to convert virtual lines into filename/line pairs)
warning_as_error if nonzero, treat warnings as errors.
print_error function called to print out errors
print_warning function called to print out warnings

YASM_LIB_DECL void yasm_warn_clear ( void   ) 

Unconditionally clear all warning indicators, freeing any associated data.

Has no effect if no warning indicators have been set.

YASM_LIB_DECL void yasm_warn_disable ( yasm_warn_class  wclass  ) 

Disable a class of warnings.

Parameters:
wclass warning class

YASM_LIB_DECL void yasm_warn_disable_all ( void   ) 

Disable all classes of warnings.

YASM_LIB_DECL void yasm_warn_enable ( yasm_warn_class  wclass  ) 

Enable a class of warnings.

Parameters:
wclass warning class

YASM_LIB_DECL void yasm_warn_fetch ( yasm_warn_class wclass,
char **  str 
)

Fetch the first warning indicator and all associated data.

If there is at least one warning indicator, the output pointers are set to the first warning indicator values, and first warning indicator is removed. The code using this function is then responsible for yasm_xfree()'ing str and xrefstr (if non-NULL). If there is no warning indicator set, all output values are set to 0 (including wclass, which is set to YASM_WARN_NONE).

Parameters:
wclass warning class (output)
str warning message

YASM_LIB_DECL yasm_warn_class yasm_warn_occurred ( void   ) 

Get the first warning indicator.

YASM_WARN_NONE is returned if no warning has been set. Note that as YASM_WARN_NONE is 0, the return value can also be treated as a boolean value.

Returns:
First warning indicator.

YASM_LIB_DECL void yasm_warn_set ( yasm_warn_class  wclass,
const char *  format,
  ... 
)

Add a warning indicator.

Parameters:
wclass warning class
format printf format string
... argument list for format

YASM_LIB_DECL void yasm_warn_set_va ( yasm_warn_class  wclass,
const char *  format,
va_list  va 
)

Add a warning indicator (va_list version).

Parameters:
wclass warning class
format printf format string
va argument list for format


Variable Documentation

YASM_LIB_DECL void(*) yasm_fatal(const char *message, va_list va)

Reporting point of fatal errors.

Warning:
This function must NOT return to calling code; exit or longjmp instead.
Parameters:
message fatal error message
va va_list argument list for message

YASM_LIB_DECL const char*(*) yasm_gettext_hook(const char *msgid)

Hook for library users to map to gettext() if GNU gettext is being used.

Parameters:
msgid message catalog identifier
Returns:
Translated message.

YASM_LIB_DECL void(*) yasm_internal_error_(const char *file, unsigned int line, const char *message)

Reporting point of internal errors.

These are usually due to sanity check failures in the code.

Warning:
This function must NOT return to calling code; exit or longjmp instead.
Parameters:
file source file (ala __FILE__)
line source line (ala __LINE__)
message internal error message


Generated on Thu Jul 24 01:23:31 2008 for libyasm by  doxygen 1.5.2