diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-07-18 21:07:17 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-07-18 18:43:12 -0700 |
commit | 9bd1506d5999d7c41a4cf6de2f43b97939bb260e (patch) | |
tree | d3dad5bda2b167af7dfe29cad7cb532406ddb1c4 /nasm.h | |
parent | 159178f2aa516718fcb420a281c17adc8b330492 (diff) | |
download | nasm-9bd1506d5999d7c41a4cf6de2f43b97939bb260e.tar.gz nasm-9bd1506d5999d7c41a4cf6de2f43b97939bb260e.tar.bz2 nasm-9bd1506d5999d7c41a4cf6de2f43b97939bb260e.zip |
Remove function pointers in output, simplify error handling
Remove a bunch of function pointers in the output stage; they are
never changed and don't add any value. Also make "ofile" a global
variable and let the backend use it directly.
All we ever did with these variables were stashing it in locals and
using them as-is anyway for no benefit.
Also change the global error function, nasm_error() into a true
function which invokes a function pointer internally. That lets us
use direct calls to it.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'nasm.h')
-rw-r--r-- | nasm.h | 48 |
1 files changed, 25 insertions, 23 deletions
@@ -122,9 +122,12 @@ typedef bool (*lfunc) (char *label, int32_t *segment, int64_t *offset); * should affect the local-label system), or something odder like * an EQU or a segment-base symbol, which shouldn't. */ -typedef void (*ldfunc) (char *label, int32_t segment, int64_t offset, - char *special, bool is_norm, bool isextrn, - struct ofmt * ofmt, efunc error); +typedef void (*ldfunc)(char *label, int32_t segment, int64_t offset, + char *special, bool is_norm, bool isextrn, + struct ofmt * ofmt, efunc error); +void define_label(char *label, int32_t segment, int64_t offset, + char *special, bool is_norm, bool isextrn, + struct ofmt * ofmt, efunc error); /* * List-file generators should look like this: @@ -786,7 +789,7 @@ struct ofmt { * an output format, be sure to set this to whatever default you want * */ - struct dfmt *current_dfmt; + const struct dfmt *current_dfmt; /* * This, if non-NULL, is a NULL-terminated list of `char *'s @@ -798,13 +801,10 @@ struct ofmt { macros_t *stdmac; /* - * This procedure is called at the start of an output session. - * It tells the output format what file it will be writing to, - * what routine to report errors through, and how to interface - * to the label manager and expression evaluator if necessary. - * It also gives it a chance to do other initialisation. + * This procedure is called at the start of an output session to set + * up internal parameters. */ - void (*init) (FILE * fp, efunc error, ldfunc ldef, evalfunc eval); + void (*init)(void); /* * This procedure is called to pass generic information to the @@ -924,7 +924,7 @@ struct ofmt { * The parameter `outname' points to an area of storage * guaranteed to be at least FILENAME_MAX in size. */ - void (*filename) (char *inname, char *outname, efunc error); + void (*filename) (char *inname, char *outname); /* * This procedure is called after assembly finishes, to allow @@ -938,6 +938,8 @@ struct ofmt { void (*cleanup) (int debuginfo); }; +extern struct ofmt *ofmt; +extern FILE *ofile; /* * ------------------------------------------------------------ @@ -959,17 +961,15 @@ struct dfmt { const char *shortname; /* - * init - called initially to set up local pointer to object format, - * void pointer to implementation defined data, file pointer (which - * probably won't be used, but who knows?), and error function. + * init - called initially to set up local pointer to object format. */ - void (*init) (struct ofmt * of, void *id, FILE * fp, efunc error); + void (*init)(void); /* * linenum - called any time there is output with a change of * line number or file. */ - void (*linenum) (const char *filename, int32_t linenumber, int32_t segto); + void (*linenum)(const char *filename, int32_t linenumber, int32_t segto); /* * debug_deflabel - called whenever a label is defined. Parameters @@ -977,8 +977,8 @@ struct dfmt { * would be called before the output format version. */ - void (*debug_deflabel) (char *name, int32_t segment, int64_t offset, - int is_global, char *special); + void (*debug_deflabel)(char *name, int32_t segment, int64_t offset, + int is_global, char *special); /* * debug_directive - called whenever a DEBUG directive other than 'LINE' * is encountered. 'directive' contains the first parameter to the @@ -987,27 +987,29 @@ struct dfmt { * function with 'directive' equal to "VAR" and 'params' equal to * "_somevar:int". */ - void (*debug_directive) (const char *directive, const char *params); + void (*debug_directive)(const char *directive, const char *params); /* * typevalue - called whenever the assembler wishes to register a type * for the last defined label. This routine MUST detect if a type was * already registered and not re-register it. */ - void (*debug_typevalue) (int32_t type); + void (*debug_typevalue)(int32_t type); /* * debug_output - called whenever output is required * 'type' is the type of info required, and this is format-specific */ - void (*debug_output) (int type, void *param); + void (*debug_output)(int type, void *param); /* * cleanup - called after processing of file is complete */ - void (*cleanup) (void); - + void (*cleanup)(void); }; + +extern const struct dfmt *dfmt; + /* * The type definition macros * for debugging |