src/xmalloc.c \
src/xstrdup.c \
src/strcasecmp.c
+libyasm_la_LDFLAGS = -no-undefined
yasm_SOURCES += \
src/main.c \
const char *ext, const char *def);
static void print_error(const char *fmt, ...);
+static /*@exits@*/ void handle_yasm_int_error(const char *file,
+ unsigned int line,
+ const char *message);
+static /*@exits@*/ void handle_yasm_fatal(const char *message);
+static const char *handle_yasm_gettext(const char *msgid);
+static void print_yasm_error(const char *filename, unsigned long line,
+ const char *msg);
+static void print_yasm_warning(const char *filename, unsigned long line,
+ const char *msg);
+
/* values for special_options */
#define SPECIAL_SHOW_HELP 0x01
#define SPECIAL_SHOW_VERSION 0x02
textdomain(PACKAGE);
/* Initialize errwarn handling */
- yasm_std_errwarn.initialize();
-
- /* Initialize memory allocation */
- xalloc_initialize((void (*) (int))yasm_std_errwarn.fatal,
- YASM_FATAL_NOMEM);
+ yasm_internal_error_ = handle_yasm_int_error;
+ yasm_fatal = handle_yasm_fatal;
+ yasm_gettext_hook = handle_yasm_gettext;
+ yasm_errwarn_initialize();
/* Set libltdl malloc/free functions. */
#ifdef WITH_DMALLOC
}
/* Initialize line manager */
- yasm_std_linemgr.initialize(yasm_std_errwarn.internal_error_);
+ yasm_std_linemgr.initialize();
yasm_std_linemgr.set(in_filename, 1, 1);
/* Initialize intnum and floatnum */
- yasm_intnum_initialize(&yasm_std_errwarn);
- yasm_floatnum_initialize(&yasm_std_errwarn);
+ yasm_intnum_initialize();
+ yasm_floatnum_initialize();
/* Initialize symbol table */
- yasm_symrec_initialize(&yasm_std_errwarn);
+ yasm_symrec_initialize();
/* handle preproc-only case here */
if (preproc_only) {
}
/* Pre-process until done */
- cur_preproc->initialize(in, in_filename, &yasm_std_linemgr,
- &yasm_std_errwarn);
+ cur_preproc->initialize(in, in_filename, &yasm_std_linemgr);
while ((got = cur_preproc->input(preproc_buf, PREPROC_BUF_SIZE)) != 0)
fwrite(preproc_buf, got, 1, obj);
if (obj != stdout)
fclose(obj);
- if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ if (yasm_get_num_errors(warning_error) > 0) {
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
if (obj != stdout)
remove(obj_filename);
xfree(preproc_buf);
return EXIT_FAILURE;
}
- cur_arch->initialize(&yasm_std_errwarn);
+ cur_arch->initialize();
/* Set basic as the optimizer (TODO: user choice) */
cur_optimizer = load_optimizer("basic");
}
yasm_arch_common_initialize(cur_arch);
- yasm_expr_initialize(cur_arch, &yasm_std_errwarn);
- yasm_bc_initialize(cur_arch, &yasm_std_errwarn);
+ yasm_expr_initialize(cur_arch);
+ yasm_bc_initialize(cur_arch);
/* If not already specified, default to bin as the object format. */
if (!cur_objfmt)
/* Initialize the object format */
if (cur_objfmt->initialize)
cur_objfmt->initialize(in_filename, obj_filename, cur_dbgfmt,
- cur_arch, &yasm_std_errwarn);
+ cur_arch);
/* Set NASM as the parser */
cur_parser = load_parser("nasm");
/* Parse! */
sections = cur_parser->do_parse(cur_preproc, cur_arch, cur_objfmt,
- &yasm_std_linemgr, &yasm_std_errwarn, in,
- in_filename, 0);
+ &yasm_std_linemgr, in, in_filename, 0);
/* Close input file */
if (in != stdin)
fclose(in);
- if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ if (yasm_get_num_errors(warning_error) > 0) {
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
cleanup(sections);
return EXIT_FAILURE;
}
yasm_symrec_parser_finalize();
- cur_optimizer->optimize(sections, &yasm_std_errwarn);
+ cur_optimizer->optimize(sections);
- if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ if (yasm_get_num_errors(warning_error) > 0) {
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
cleanup(sections);
return EXIT_FAILURE;
}
/* If we had an error at this point, we also need to delete the output
* object file (to make sure it's not left newer than the source).
*/
- if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ if (yasm_get_num_errors(warning_error) > 0) {
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
remove(obj_filename);
cleanup(sections);
return EXIT_FAILURE;
}
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
cleanup(sections);
return EXIT_SUCCESS;
yasm_floatnum_cleanup();
yasm_intnum_cleanup();
- yasm_std_errwarn.cleanup();
+ yasm_errwarn_cleanup();
yasm_std_linemgr.cleanup();
BitVector_Shutdown();
if (extra == 1) {
/* -w, disable warnings */
- yasm_std_errwarn.warn_disable_all();
+ yasm_warn_disable_all();
return 0;
}
warning_error = enable;
} else if (strcmp(cmd, "unrecognized-char") == 0) {
if (enable)
- yasm_std_errwarn.warn_enable(YASM_WARN_UNREC_CHAR);
+ yasm_warn_enable(YASM_WARN_UNREC_CHAR);
else
- yasm_std_errwarn.warn_disable(YASM_WARN_UNREC_CHAR);
+ yasm_warn_disable(YASM_WARN_UNREC_CHAR);
} else
return 1;
va_end(va);
fputc('\n', stderr);
}
+
+static /*@exits@*/ void
+handle_yasm_int_error(const char *file, unsigned int line, const char *message)
+{
+ fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
+ gettext(message));
+#ifdef HAVE_ABORT
+ abort();
+#else
+ exit(EXIT_FAILURE);
+#endif
+}
+
+static /*@exits@*/ void
+handle_yasm_fatal(const char *message)
+{
+ fprintf(stderr, _("FATAL: %s\n"), gettext(message));
+#ifdef HAVE_ABORT
+ abort();
+#else
+ exit(EXIT_FAILURE);
+#endif
+}
+
+static const char *
+handle_yasm_gettext(const char *msgid)
+{
+ return gettext(msgid);
+}
+
+static void
+print_yasm_error(const char *filename, unsigned long line, const char *msg)
+{
+ fprintf(stderr, "%s:%lu: %s\n", filename, line, msg);
+}
+
+static void
+print_yasm_warning(const char *filename, unsigned long line, const char *msg)
+{
+ fprintf(stderr, "%s:%lu: %s %s\n", filename, line, _("warning:"), msg);
+}
src/xmalloc.c \
src/xstrdup.c \
src/strcasecmp.c
+libyasm_la_LDFLAGS = -no-undefined
yasm_SOURCES += \
src/main.c \
/* keyword used to select architecture */
const char *keyword;
- void (*initialize) (yasm_errwarn *we);
+ void (*initialize) (void);
void (*cleanup) (void);
struct {
unsigned char bytes_static[16];
/*@dependent@*/ static yasm_arch *cur_arch;
-/*@dependent@*/ static yasm_errwarn *cur_we;
void
-yasm_bc_initialize(yasm_arch *a, yasm_errwarn *we)
+yasm_bc_initialize(yasm_arch *a)
{
cur_arch = a;
- cur_we = we;
}
yasm_immval *
objfmt_data->of->bc_objfmt_data_delete(objfmt_data->type,
objfmt_data->data);
else
- cur_we->internal_error(
+ yasm_internal_error(
N_("objfmt can't handle its own objfmt data bytecode"));
break;
default:
if (bc->type < cur_arch->bc.type_max)
cur_arch->bc.bc_delete(bc);
else
- cur_we->internal_error(N_("Unknown bytecode type"));
+ yasm_internal_error(N_("Unknown bytecode type"));
break;
}
/*@=branchstate@*/
* the circular reference error to filter through.
*/
if (temp && yasm_expr__contains(temp, YASM_EXPR_FLOAT))
- cur_we->error(line,
+ yasm__error(line,
N_("expression must not contain floating point value"));
else
- cur_we->error(line,
+ yasm__error(line,
N_("attempt to reserve non-constant quantity of space"));
retval = YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
} else
/* Open file and determine its length */
f = fopen(incbin->filename, "rb");
if (!f) {
- cur_we->error(line, N_("`incbin': unable to open file `%s'"),
- incbin->filename);
+ yasm__error(line, N_("`incbin': unable to open file `%s'"),
+ incbin->filename);
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
}
if (fseek(f, 0L, SEEK_END) < 0) {
- cur_we->error(line, N_("`incbin': unable to seek on file `%s'"),
- incbin->filename);
+ yasm__error(line, N_("`incbin': unable to seek on file `%s'"),
+ incbin->filename);
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
}
flen = (unsigned long)ftell(f);
/* Compute length of incbin from start, maxlen, and len */
if (start > flen) {
- cur_we->warning(YASM_WARN_GENERAL, line,
- N_("`incbin': start past end of file `%s'"),
- incbin->filename);
+ yasm__warning(YASM_WARN_GENERAL, line,
+ N_("`incbin': start past end of file `%s'"),
+ incbin->filename);
start = flen;
}
flen -= start;
switch (bc->type) {
case YASM_BC__EMPTY:
- cur_we->internal_error(N_("got empty bytecode in bc_calc_len"));
+ yasm_internal_error(N_("got empty bytecode in bc_calc_len"));
/*break;*/
case YASM_BC__DATA:
retval = bc_resolve_data((bytecode_data *)bc, &bc->len);
break;
case YASM_BC__ALIGN:
/* TODO */
- cur_we->internal_error(
- N_("TODO: align bytecode not implemented!"));
+ yasm_internal_error(N_("TODO: align bytecode not implemented!"));
/*break;*/
case YASM_BC__OBJFMT_DATA:
- cur_we->internal_error(N_("resolving objfmt data bytecode?"));
+ yasm_internal_error(N_("resolving objfmt data bytecode?"));
/*break;*/
default:
if (bc->type < cur_arch->bc.type_max)
retval = cur_arch->bc.bc_resolve(bc, save, sect,
calc_bc_dist);
else
- cur_we->internal_error(N_("Unknown bytecode type"));
+ yasm_internal_error(N_("Unknown bytecode type"));
}
/* Multiply len by number of multiples */
if (!num) {
retval = YASM_BC_RESOLVE_UNKNOWN_LEN;
if (temp && yasm_expr__contains(temp, YASM_EXPR_FLOAT)) {
- cur_we->error(bc->line,
+ yasm__error(bc->line,
N_("expression must not contain floating point value"));
retval |= YASM_BC_RESOLVE_ERROR;
}
if (incbin->start) {
num = yasm_expr_get_intnum(&incbin->start, NULL);
if (!num)
- cur_we->internal_error(
+ yasm_internal_error(
N_("could not determine start in bc_tobytes_incbin"));
start = yasm_intnum_get_uint(num);
}
/* Open file */
f = fopen(incbin->filename, "rb");
if (!f) {
- cur_we->error(line, N_("`incbin': unable to open file `%s'"),
- incbin->filename);
+ yasm__error(line, N_("`incbin': unable to open file `%s'"),
+ incbin->filename);
return 1;
}
/* Seek to start of data */
if (fseek(f, (long)start, SEEK_SET) < 0) {
- cur_we->error(line, N_("`incbin': unable to seek on file `%s'"),
- incbin->filename);
+ yasm__error(line, N_("`incbin': unable to seek on file `%s'"),
+ incbin->filename);
fclose(f);
return 1;
}
/* Read len bytes */
if (fread(*bufp, (size_t)len, 1, f) < (size_t)len) {
- cur_we->error(line,
- N_("`incbin': unable to read %lu bytes from file `%s'"),
- len, incbin->filename);
+ yasm__error(line,
+ N_("`incbin': unable to read %lu bytes from file `%s'"),
+ len, incbin->filename);
fclose(f);
return 1;
}
if (bc->multiple) {
num = yasm_expr_get_intnum(&bc->multiple, NULL);
if (!num)
- cur_we->internal_error(
+ yasm_internal_error(
N_("could not determine multiple in bc_tobytes"));
*multiple = yasm_intnum_get_uint(num);
if (*multiple == 0) {
switch (bc->type) {
case YASM_BC__EMPTY:
- cur_we->internal_error(N_("got empty bytecode in bc_tobytes"));
+ yasm_internal_error(N_("got empty bytecode in bc_tobytes"));
/*break;*/
case YASM_BC__DATA:
error = bc_tobytes_data((bytecode_data *)bc, &destbuf, sect, bc, d,
break;
case YASM_BC__ALIGN:
/* TODO */
- cur_we->internal_error(
- N_("TODO: align bytecode not implemented!"));
+ yasm_internal_error(N_("TODO: align bytecode not implemented!"));
/*break;*/
case YASM_BC__OBJFMT_DATA:
objfmt_data = (bytecode_objfmt_data *)bc;
error = output_bc_objfmt_data(objfmt_data->type,
objfmt_data->data, &destbuf);
else
- cur_we->internal_error(
+ yasm_internal_error(
N_("Have objfmt data bytecode but no way to output it"));
break;
default:
error = cur_arch->bc.bc_tobytes(bc, &destbuf, sect, d,
output_expr);
else
- cur_we->internal_error(N_("Unknown bytecode type"));
+ yasm_internal_error(N_("Unknown bytecode type"));
}
if (!error && ((unsigned long)(destbuf - origbuf) != datasize))
- cur_we->internal_error(
+ yasm_internal_error(
N_("written length does not match optimized length"));
return mybuf;
}
} yasm_bytecode_type;
#define YASM_BYTECODE_TYPE_BASE YASM_BC__OBJFMT_DATA+1
-void yasm_bc_initialize(yasm_arch *a, yasm_errwarn *we);
+void yasm_bc_initialize(yasm_arch *a);
/*@only@*/ yasm_immval *yasm_imm_new_int(unsigned long int_val,
unsigned long lindex);
typedef struct yasm_floatnum yasm_floatnum;
typedef struct yasm_linemgr yasm_linemgr;
-typedef struct yasm_errwarn yasm_errwarn;
typedef enum {
YASM_EXPR_ADD,
#define MSG_MAXSIZE 1024
+/* Default handlers for replacable functions */
+static /*@exits@*/ void def_internal_error_
+ (const char *file, unsigned int line, const char *message);
+static /*@exits@*/ void def_fatal(const char *message);
+static const char *def_gettext_hook(const char *msgid);
+
+/* Storage for errwarn's "extern" functions */
+/*@exits@*/ void (*yasm_internal_error_)
+ (const char *file, unsigned int line, const char *message)
+ = def_internal_error_;
+/*@exits@*/ void (*yasm_fatal) (const char *message) = def_fatal;
+const char * (*yasm_gettext_hook) (const char *msgid) = def_gettext_hook;
+
/* Enabled warnings. See errwarn.h for a list. */
static unsigned long warn_class_enabled;
/* Total warning count */
static unsigned int warning_count;
-/* See errwarn.h for constants that match up to these strings.
- * When adding a string here, keep errwarn.h in sync!
- */
-
-/* Fatal error messages. Match up with fatal_num enum in errwarn.h. */
-/*@-observertrans@*/
-static const char *fatal_msgs[] = {
- N_("unknown"),
- N_("out of memory")
-};
-/*@=observertrans@*/
-
typedef /*@reldef@*/ SLIST_HEAD(errwarndatahead_s, errwarn_data)
errwarndatahead;
static /*@only@*/ /*@null@*/ errwarndatahead errwarns;
static char unprint[5];
-static void
-yasm_std_errwarn_initialize(void)
+static const char *
+def_gettext_hook(const char *msgid)
+{
+ return msgid;
+}
+
+void
+yasm_errwarn_initialize(void)
{
/* Default enabled warnings. See errwarn.h for a list. */
warn_class_enabled =
previous_we = NULL;
}
-static void
-yasm_std_errwarn_cleanup(void)
+void
+yasm_errwarn_cleanup(void)
{
errwarn_data *we;
/* Convert a possibly unprintable character into a printable string, using
* standard cat(1) convention for unprintable characters.
*/
-static char *
-yasm_std_errwarn_conv_unprint(char ch)
+char *
+yasm__conv_unprint(char ch)
{
int pos = 0;
* Exit immediately because it's essentially an assert() trap.
*/
static void
-yasm_std_errwarn_internal_error_(const char *file, unsigned int line,
- const char *message)
+def_internal_error_(const char *file, unsigned int line, const char *message)
{
- fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
- gettext(message));
+ fprintf(stderr,
+ yasm_gettext_hook(N_("INTERNAL ERROR at %s, line %u: %s\n")),
+ file, line, yasm_gettext_hook(message));
#ifdef HAVE_ABORT
abort();
#else
* memory), so just exit immediately.
*/
static void
-yasm_std_errwarn_fatal(yasm_fatal_cause num)
+def_fatal(const char *message)
{
- fprintf(stderr, _("FATAL: %s\n"), gettext(fatal_msgs[num]));
+ fprintf(stderr, yasm_gettext_hook(N_("FATAL: %s\n")),
+ yasm_gettext_hook(message));
#ifdef HAVE_ABORT
abort();
#else
assert(ins_we != NULL);
SLIST_INSERT_AFTER(ins_we, we, link);
} else
- yasm_std_errwarn_internal_error_(__FILE__, __LINE__,
- N_("Unexpected errwarn insert action"));
+ yasm_internal_error(N_("Unexpected errwarn insert action"));
}
/* Remember previous err/warn */
/* Register an error at line lindex. Does not print the error, only stores it
* for output_all() to print.
*/
-static void
-yasm_std_errwarn_error_va(unsigned long lindex, const char *fmt, va_list va)
+void
+yasm__error_va(unsigned long lindex, const char *fmt, va_list va)
{
errwarn_data *we = errwarn_data_new(lindex, 1);
we->type = WE_ERROR;
#ifdef HAVE_VSNPRINTF
- vsnprintf(we->msg, MSG_MAXSIZE, gettext(fmt), va);
+ vsnprintf(we->msg, MSG_MAXSIZE, yasm_gettext_hook(fmt), va);
#else
- vsprintf(we->msg, gettext(fmt), va);
+ vsprintf(we->msg, yasm_gettext_hook(fmt), va);
#endif
error_count++;
/* Register an warning at line lindex. Does not print the warning, only stores
* it for output_all() to print.
*/
-static void
-yasm_std_errwarn_warning_va(yasm_warn_class num, unsigned long lindex,
- const char *fmt, va_list va)
+void
+yasm__warning_va(yasm_warn_class num, unsigned long lindex, const char *fmt,
+ va_list va)
{
errwarn_data *we;
we->type = WE_WARNING;
#ifdef HAVE_VSNPRINTF
- vsnprintf(we->msg, MSG_MAXSIZE, gettext(fmt), va);
+ vsnprintf(we->msg, MSG_MAXSIZE, yasm_gettext_hook(fmt), va);
#else
- vsprintf(we->msg, gettext(fmt), va);
+ vsprintf(we->msg, yasm_gettext_hook(fmt), va);
#endif
warning_count++;
/* Register an error at line lindex. Does not print the error, only stores it
* for output_all() to print.
*/
-static void
-yasm_std_errwarn_error(unsigned long lindex, const char *fmt, ...)
+void
+yasm__error(unsigned long lindex, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
- yasm_std_errwarn_error_va(lindex, fmt, va);
+ yasm__error_va(lindex, fmt, va);
va_end(va);
}
/* Register an warning at line lindex. Does not print the warning, only stores
* it for output_all() to print.
*/
-static void
-yasm_std_errwarn_warning(yasm_warn_class num, unsigned long lindex,
- const char *fmt, ...)
+void
+yasm__warning(yasm_warn_class num, unsigned long lindex, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
- yasm_std_errwarn_warning_va(num, lindex, fmt, va);
+ yasm__warning_va(num, lindex, fmt, va);
va_end(va);
}
/* Parser error handler. Moves YACC-style error into our error handling
* system.
*/
-static void
-yasm_std_errwarn_parser_error(unsigned long lindex, const char *s)
+void
+yasm__parser_error(unsigned long lindex, const char *s)
{
- yasm_std_errwarn_error(lindex, N_("parser error: %s"), s);
+ yasm__error(lindex, N_("parser error: %s"), s);
previous_we->type = WE_PARSERERROR;
}
-static void
-yasm_std_errwarn_warn_enable(yasm_warn_class num)
+void
+yasm_warn_enable(yasm_warn_class num)
{
warn_class_enabled |= (1UL<<num);
}
-static void
-yasm_std_errwarn_warn_disable(yasm_warn_class num)
+void
+yasm_warn_disable(yasm_warn_class num)
{
warn_class_enabled &= ~(1UL<<num);
}
-static void
-yasm_std_errwarn_warn_disable_all(void)
+void
+yasm_warn_disable_all(void)
{
warn_class_enabled = 0;
}
-/* Get the number of errors (including warnings if warnings are being treated
- * as errors).
- */
-static unsigned int
-yasm_std_errwarn_get_num_errors(int warning_as_error)
+unsigned int
+yasm_get_num_errors(int warning_as_error)
{
if (warning_as_error)
return error_count+warning_count;
return error_count;
}
-/* Output all previously stored errors and warnings to stderr. */
-static void
-yasm_std_errwarn_output_all(yasm_linemgr *lm, int warning_as_error)
+void
+yasm_errwarn_output_all(yasm_linemgr *lm, int warning_as_error,
+ void (*print_error) (const char *fn, unsigned long line, const char *msg),
+ void (*print_warning) (const char *fn, unsigned long line,
+ const char *msg))
{
errwarn_data *we;
const char *filename;
/* If we're treating warnings as errors, tell the user about it. */
if (warning_as_error && warning_as_error != 2) {
- fprintf(stderr, "%s\n", _("warnings being treated as errors"));
+ print_error("", 0,
+ yasm_gettext_hook(N_("warnings being treated as errors")));
warning_as_error = 2;
}
/* Output error/warning */
lm->lookup(we->line, &filename, &line);
if (we->type == WE_ERROR)
- fprintf(stderr, "%s:%lu: %s\n", filename, line, we->msg);
+ print_error(filename, line, we->msg);
else
- fprintf(stderr, "%s:%lu: %s %s\n", filename, line, _("warning:"),
- we->msg);
+ print_warning(filename, line, we->msg);
}
}
-
-yasm_errwarn yasm_std_errwarn = {
- yasm_std_errwarn_initialize,
- yasm_std_errwarn_cleanup,
- yasm_std_errwarn_internal_error_,
- yasm_std_errwarn_fatal,
- yasm_std_errwarn_error_va,
- yasm_std_errwarn_warning_va,
- yasm_std_errwarn_error,
- yasm_std_errwarn_warning,
- yasm_std_errwarn_parser_error,
- yasm_std_errwarn_warn_enable,
- yasm_std_errwarn_warn_disable,
- yasm_std_errwarn_warn_disable_all,
- yasm_std_errwarn_get_num_errors,
- yasm_std_errwarn_output_all,
- yasm_std_errwarn_conv_unprint
-};
YASM_WARN_PREPROC /* preprocessor warnings */
} yasm_warn_class;
-/* Fatal error constants.
- * See fatal_msgs in errwarn.c for strings that match up to these constants.
- * When adding a constant here, keep errwarn.c in sync!
- */
-typedef enum {
- YASM_FATAL_UNKNOWN = 0,
- YASM_FATAL_NOMEM
-} yasm_fatal_cause;
+/* Initialize any internal data structures. */
+void yasm_errwarn_initialize(void);
-struct yasm_errwarn {
- /* Initialize any internal data structures. */
- void (*initialize) (void);
+/* Cleans up any memory allocated by initialize or other functions. */
+void yasm_errwarn_cleanup(void);
- /* Cleans up any memory allocated by initialize or other functions. */
- void (*cleanup) (void);
-
- /* Reporting point of internal errors. These are usually due to sanity
- * check failures in the code.
- * This function must NOT return to calling code. Either exit or longjmp.
- */
- /*@exits@*/ void (*internal_error_) (const char *file, unsigned int line,
- const char *message);
-#define internal_error(msg) internal_error_(__FILE__, __LINE__, msg)
+/* Reporting point of internal errors. These are usually due to sanity
+ * check failures in the code.
+ * This function must NOT return to calling code. Either exit or longjmp.
+ */
+extern /*@exits@*/ void (*yasm_internal_error_)
+ (const char *file, unsigned int line, const char *message);
+#define yasm_internal_error(msg) \
+ yasm_internal_error_(__FILE__, __LINE__, msg)
- /* Reporting point of fatal errors.
- * This function must NOT return to calling code. Either exit or longjmp.
- */
- /*@exits@*/ void (*fatal) (yasm_fatal_cause);
+/* Reporting point of fatal errors.
+ * This function must NOT return to calling code. Either exit or longjmp.
+ */
+extern /*@exits@*/ void (*yasm_fatal) (const char *message);
- /* va_list versions of the below two functions */
- void (*error_va) (unsigned long lindex, const char *, va_list va);
- void (*warning_va) (yasm_warn_class, unsigned long lindex, const char *,
- va_list va);
+/* va_list versions of the below two functions */
+void yasm__error_va(unsigned long lindex, const char *, va_list va);
+void yasm__warning_va(yasm_warn_class, unsigned long lindex, const char *,
+ va_list va);
- void (*error) (unsigned long lindex, const char *, ...) /*@printflike@*/;
- void (*warning) (yasm_warn_class, unsigned long lindex, const char *, ...)
- /*@printflike@*/;
+void yasm__error(unsigned long lindex, const char *, ...) /*@printflike@*/;
+void yasm__warning(yasm_warn_class, unsigned long lindex, const char *, ...)
+ /*@printflike@*/;
- /* Logs a parser error. These can be overwritten by non-parser errors on
- * the same line.
- */
- void (*parser_error) (unsigned long lindex, const char *);
+/* Logs a parser error. These can be overwritten by non-parser errors on
+ * the same line.
+ */
+void yasm__parser_error(unsigned long lindex, const char *);
- /* Enables/disables a class of warnings. */
- void (*warn_enable) (yasm_warn_class);
- void (*warn_disable) (yasm_warn_class);
- void (*warn_disable_all) (void);
+/* Enables/disables a class of warnings. */
+void yasm_warn_enable(yasm_warn_class);
+void yasm_warn_disable(yasm_warn_class);
+void yasm_warn_disable_all(void);
- /* Returns total number of errors logged to this point.
- * If warning_as_error is nonzero, warnings are treated as errors.
- */
- unsigned int (*get_num_errors) (int warning_as_error);
+/* Returns total number of errors logged to this point.
+ * If warning_as_error is nonzero, warnings are treated as errors.
+ */
+unsigned int yasm_get_num_errors(int warning_as_error);
- /* Outputs all errors/warnings (e.g. to stderr or elsewhere). */
- void (*output_all) (yasm_linemgr *lm, int warning_as_error);
+/* Outputs all errors/warnings by calling print_error and print_warning. */
+void yasm_errwarn_output_all
+ (yasm_linemgr *lm, int warning_as_error,
+ void (*print_error) (const char *fn, unsigned long line, const char *msg),
+ void (*print_warning) (const char *fn, unsigned long line,
+ const char *msg));
- /* Convert a possibly unprintable character into a printable string. */
- char * (*conv_unprint) (char ch);
-};
+/* Convert a possibly unprintable character into a printable string. */
+char *yasm__conv_unprint(char ch);
-extern yasm_errwarn yasm_std_errwarn;
+/* Map to gettext() if gettext is being used. */
+extern const char * (*yasm_gettext_hook) (const char *msgid);
#endif
/*@null@*/ void *d));
static /*@dependent@*/ yasm_arch *cur_arch;
-static /*@dependent@*/ yasm_errwarn *cur_we;
void
-yasm_expr_initialize(yasm_arch *a, yasm_errwarn *we)
+yasm_expr_initialize(yasm_arch *a)
{
cur_arch = a;
- cur_we = we;
}
/* allocate a new expression node, with children as defined.
/*@=usereleased@*/
}
} else {
- cur_we->internal_error(N_("Right side of expression must exist"));
+ yasm_internal_error(N_("Right side of expression must exist"));
}
if (right) {
/* Check for circular reference */
SLIST_FOREACH(np, eh, next) {
if (np->e == equ_expr) {
- cur_we->error(e->line,
- N_("circular reference detected."));
+ yasm__error(e->line,
+ N_("circular reference detected."));
return e;
}
}
typedef struct yasm_expr__item yasm_expr__item;
-void yasm_expr_initialize(yasm_arch *a, yasm_errwarn *we);
+void yasm_expr_initialize(yasm_arch *a);
/*@only@*/ yasm_expr *yasm_expr_new(yasm_expr_op, /*@only@*/ yasm_expr__item *,
/*@only@*/ /*@null@*/ yasm_expr__item *,
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80},0x7fff}, /* 1e+0 */
};
-static /*@dependent@*/ yasm_errwarn *cur_we;
-
static void
POT_Table_Init_Entry(/*@out@*/ POT_Entry *e, POT_Entry_Source *s, int dec_exp)
/*@-compdef@*/
void
-yasm_floatnum_initialize(yasm_errwarn *we)
+yasm_floatnum_initialize(void)
/*@globals undef POT_TableN, undef POT_TableP, POT_TableP_Source,
POT_TableN_Source @*/
{
int dec_exp = 1;
int i;
- cur_we = we;
-
/* Allocate space for two POT tables */
POT_TableN = xmalloc(14*sizeof(POT_Entry));
POT_TableP = xmalloc(15*sizeof(POT_Entry)); /* note 1 extra for -1 */
/*@unused@*/ yasm_floatnum *operand, unsigned long lindex)
{
if (op != YASM_EXPR_NEG)
- cur_we->error(lindex,
- N_("Unsupported floating-point arithmetic operation"));
+ yasm__error(lindex,
+ N_("Unsupported floating-point arithmetic operation"));
else
acc->sign ^= 1;
}
/* underflow and overflow both set!? */
if (underflow && overflow)
- cur_we->internal_error(N_("Both underflow and overflow set"));
+ yasm_internal_error(N_("Both underflow and overflow set"));
/* check for underflow or overflow and set up appropriate output */
if (underflow) {
/* get little-endian bytes */
buf = BitVector_Block_Read(output, &len);
if (len < byte_size)
- cur_we->internal_error(
+ yasm_internal_error(
N_("Byte length of BitVector does not match bit length"));
/* copy to output */
case 10:
return floatnum_get_common(flt, ptr, 10, 64, 0, 15);
default:
- cur_we->internal_error(N_("Invalid float conversion size"));
+ yasm_internal_error(N_("Invalid float conversion size"));
/*@notreached@*/
return 1; /* never reached, but silence GCC warning */
}
#ifndef YASM_FLOATNUM_H
#define YASM_FLOATNUM_H
-void yasm_floatnum_initialize(yasm_errwarn *we);
+void yasm_floatnum_initialize(void);
/* Clean up internal allocations */
void yasm_floatnum_cleanup(void);
/* static bitvect used for conversions */
static /*@only@*/ wordptr conv_bv;
-static /*@dependent@*/ yasm_errwarn *cur_we;
void
-yasm_intnum_initialize(yasm_errwarn *we)
+yasm_intnum_initialize(void)
{
- cur_we = we;
-
conv_bv = BitVector_Create(BITVECT_ALLOC_SIZE, FALSE);
BitVector_from_Dec_static_Boot(BITVECT_ALLOC_SIZE);
}
if (BitVector_from_Dec_static(conv_bv,
(unsigned char *)str) == ErrCode_Ovfl)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("Numeric constant too large for internal format"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Numeric constant too large for internal format"));
if (Set_Max(conv_bv) < 32) {
intn->type = INTNUM_UL;
intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0);
intn->origsize = (unsigned char)strlen(str);
if(intn->origsize > BITVECT_ALLOC_SIZE)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("Numeric constant too large for internal format"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Numeric constant too large for internal format"));
BitVector_from_Bin(conv_bv, (unsigned char *)str);
if (Set_Max(conv_bv) < 32) {
intn->origsize = strlen(str)*3;
if(intn->origsize > BITVECT_ALLOC_SIZE)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("Numeric constant too large for internal format"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Numeric constant too large for internal format"));
BitVector_from_Oct(conv_bv, (unsigned char *)str);
if (Set_Max(conv_bv) < 32) {
intn->origsize = strlen(str)*4;
if(intn->origsize > BITVECT_ALLOC_SIZE)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("Numeric constant too large for internal format"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Numeric constant too large for internal format"));
BitVector_from_Hex(conv_bv, (unsigned char *)str);
if (Set_Max(conv_bv) < 32) {
size_t len = strlen(str);
if (len > 4)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("character constant too large, ignoring trailing characters"));
intn->val.ul = 0;
if (!operand && op != YASM_EXPR_NEG && op != YASM_EXPR_NOT &&
op != YASM_EXPR_LNOT)
- cur_we->internal_error(N_("Operation needs an operand"));
+ yasm_internal_error(N_("Operation needs an operand"));
/* A operation does a bitvector computation if result is allocated. */
switch (op) {
BitVector_Copy(result, op1);
break;
default:
- cur_we->internal_error(
- N_("invalid operation in intnum calculation"));
+ yasm_internal_error(N_("invalid operation in intnum calculation"));
}
/* If we were doing a bitvector computation... */
case INTNUM_BV:
return BitVector_Chunk_Read(intn->val.bv, 32, 0);
default:
- cur_we->internal_error(N_("unknown intnum type"));
+ yasm_internal_error(N_("unknown intnum type"));
/*@notreached@*/
return 0;
}
} else
return (long)BitVector_Chunk_Read(intn->val.bv, 32, 0);
default:
- cur_we->internal_error(N_("unknown intnum type"));
+ yasm_internal_error(N_("unknown intnum type"));
/*@notreached@*/
return 0;
}
case INTNUM_BV:
buf = BitVector_Block_Read(intn->val.bv, &len);
if (len < (unsigned int)size)
- cur_we->internal_error(
- N_("Invalid size specified (too large)"));
+ yasm_internal_error(N_("Invalid size specified (too large)"));
memcpy(ptr, buf, size);
xfree(buf);
break;
#ifndef YASM_INTNUM_H
#define YASM_INTNUM_H
-void yasm_intnum_initialize(yasm_errwarn *we);
+void yasm_intnum_initialize(void);
/* Clean up internal allocations */
void yasm_intnum_cleanup(void);
#include "hamt.h"
+#include "errwarn.h"
#include "linemgr.h"
-static /*@exits@*/ void (*efunc) (const char *file, unsigned int line,
- const char *message);
-
/* Source lines tracking */
typedef struct {
struct line_index_mapping *vector;
}
static void
-yasm_std_linemgr_initialize(/*@exits@*/
- void (*error_func) (const char *file,
- unsigned int line,
- const char *message))
+yasm_std_linemgr_initialize(void)
{
int i;
- filename_table = HAMT_new(error_func);
- efunc = error_func;
+ filename_table = HAMT_new(yasm_internal_error_);
line_index = 1;
adrh->vector[line_index-1] = data;
if (adrh->delete_func != delete_func)
- efunc(__FILE__, __LINE__,
- N_("multiple deletion functions specified"));
+ yasm_internal_error(N_("multiple deletion functions specified"));
} else {
- efunc(__FILE__, __LINE__, N_("non-common data not supported yet"));
+ yasm_internal_error(N_("non-common data not supported yet"));
delete_func(data);
}
}
struct yasm_linemgr {
/* Initialize cur_lindex and any manager internal data structures. */
- void (*initialize) (/*@exits@*/
- void (*error_func) (const char *file,
- unsigned int line,
- const char *message));
+ void (*initialize) (void);
/* Cleans up any memory allocated. */
void (*cleanup) (void);
* provided solely for informational purposes.
*/
void (*initialize) (const char *in_filename, const char *obj_filename,
- yasm_dbgfmt *df, yasm_arch *a, yasm_errwarn *we);
+ yasm_dbgfmt *df, yasm_arch *a);
/* Write out (post-optimized) sections to the object file.
* This function may call symrec functions as necessary (including
* object file. (A failure is indicated by calling ErrorAt() from within
* this function).
*/
- void (*optimize) (yasm_sectionhead *sections, yasm_errwarn *we);
+ void (*optimize) (yasm_sectionhead *sections);
};
#endif
*/
yasm_sectionhead *(*do_parse)
(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of, yasm_linemgr *lm,
- yasm_errwarn *we, FILE *f, const char *in_filename, int save_input);
+ FILE *f, const char *in_filename, int save_input);
};
#endif
* This function also takes the FILE * to the initial starting file and
* the filename.
*/
- void (*initialize) (FILE *f, const char *in_filename, yasm_linemgr *lm,
- yasm_errwarn *we);
+ void (*initialize) (FILE *f, const char *in_filename, yasm_linemgr *lm);
/* Cleans up any allocated memory. */
void (*cleanup) (void);
int res_only; /* allow only resb family of bytecodes? */
yasm_bytecodehead bc; /* the bytecodes for the section's contents */
-
- /*@exits@*/ void (*error_func) (const char *file, unsigned int line,
- const char *message);
};
/*@-compdestroy@*/
yasm_section *
yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
unsigned long start, int res_only, int *isnew,
- unsigned long lindex,
- /*@exits@*/ void (*error_func)
- (const char *file, unsigned int line,
- const char *message))
+ unsigned long lindex)
{
yasm_section *s;
s->opt_flags = 0;
s->res_only = res_only;
- s->error_func = error_func;
-
*isnew = 1;
return s;
}
/*@-onlytrans@*/
yasm_section *
-yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start,
- /*@exits@*/ void (*error_func)
- (const char *file, unsigned int line,
- const char *message))
+yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start)
{
yasm_section *s;
s->opt_flags = 0;
s->res_only = 1;
- s->error_func = error_func;
-
return s;
}
/*@=onlytrans@*/
if (of->section_data_delete)
of->section_data_delete(of_data);
else
- sect->error_func(__FILE__, __LINE__,
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific section data"));
return;
}
if (of2->section_data_delete)
of2->section_data_delete(sect->data.general.of_data);
else
- sect->error_func(__FILE__, __LINE__,
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific section data"));
}
if (of->section_data_delete)
of->section_data_delete(sect->data.general.of_data);
else
- sect->error_func(__FILE__, __LINE__,
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific section data"));
}
}
/*@dependent@*/ yasm_section *yasm_sections_switch_general
(yasm_sectionhead *headp, const char *name, unsigned long start,
- int res_only, /*@out@*/ int *isnew, unsigned long lindex,
- /*@exits@*/ void (*error_func) (const char *file, unsigned int line,
- const char *message));
+ int res_only, /*@out@*/ int *isnew, unsigned long lindex);
/*@dependent@*/ yasm_section *yasm_sections_switch_absolute
- (yasm_sectionhead *headp, /*@keep@*/ yasm_expr *start,
- /*@exits@*/ void (*error_func) (const char *file, unsigned int line,
- const char *message));
+ (yasm_sectionhead *headp, /*@keep@*/ yasm_expr *start);
int yasm_section_is_absolute(yasm_section *sect);
nontablesymhead;
static /*@only@*/ nontablesymhead *non_table_syms;
-static /*@dependent@*/ yasm_errwarn *cur_we;
-
void
-yasm_symrec_initialize(yasm_errwarn *we)
+yasm_symrec_initialize(void)
{
- cur_we = we;
-
- sym_table = HAMT_new(cur_we->internal_error_);
+ sym_table = HAMT_new(yasm_internal_error_);
non_table_syms = xmalloc(sizeof(nontablesymhead));
SLIST_INIT(non_table_syms);
}
if (sym->of->symrec_data_delete)
sym->of->symrec_data_delete(sym->of_data);
else
- cur_we->internal_error(
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific data"));
}
xfree(sym);
/* Has it been defined before (either by DEFINED or COMMON/EXTERN)? */
if ((rec->status & SYM_DEFINED) ||
(rec->visibility & (YASM_SYM_COMMON | YASM_SYM_EXTERN))) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("duplicate definition of `%s'; first defined on line %lu"),
name, rec->line);
} else {
((rec->visibility & YASM_SYM_EXTERN) && (vis == YASM_SYM_EXTERN)))))
rec->visibility |= vis;
else
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("duplicate definition of `%s'; first defined on line %lu"),
name, rec->line);
return rec;
if (sym->of->symrec_data_delete)
sym->of->symrec_data_delete(sym->of_data);
else
- cur_we->internal_error(
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific data"));
}
sym->of = of;
/* error if a symbol is used but never defined or extern/common declared */
if ((sym->status & SYM_USED) && !(sym->status & SYM_DEFINED) &&
!(sym->visibility & (YASM_SYM_EXTERN | YASM_SYM_COMMON))) {
- cur_we->error(sym->line, N_("undefined symbol `%s' (first use)"),
- sym->name);
+ yasm__error(sym->line, N_("undefined symbol `%s' (first use)"),
+ sym->name);
if (sym->line < firstundef_line)
firstundef_line = sym->line;
}
firstundef_line = ULONG_MAX;
yasm_symrec_traverse(NULL, symrec_parser_finalize_checksym);
if (firstundef_line < ULONG_MAX)
- cur_we->error(firstundef_line,
- N_(" (Each undefined symbol is reported only once.)"));
+ yasm__error(firstundef_line,
+ N_(" (Each undefined symbol is reported only once.)"));
}
void
#ifndef YASM_SYMREC_H
#define YASM_SYMREC_H
-void yasm_symrec_initialize(yasm_errwarn *we);
+void yasm_symrec_initialize(void);
/*@dependent@*/ yasm_symrec *yasm_symrec_use(const char *name,
unsigned long lindex);
Suite *s = floatnum_suite();
SRunner *sr = srunner_create(s);
BitVector_Boot();
- yasm_floatnum_initialize(NULL);
+ yasm_floatnum_initialize();
srunner_run_all(sr, CRNORMAL);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
/*@only@*/ char *xstrdup(const char *str);
/* Error-checking memory allocation routines in xmalloc.c. */
-void xalloc_initialize(/*@exits@*/ void (*fatal_func) (int type),
- int nomem_fatal_type);
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/
#include "util.h"
RCSID("$IdPath$");
+#include "errwarn.h"
-static /*@exits@*/ void (*fatal_func) (int type);
-static int nomem_fatal_type;
-
-
-void
-xalloc_initialize(/*@exits@*/ void (*f) (int type), int t)
-{
- fatal_func = f;
- nomem_fatal_type = t;
-}
#ifndef WITH_DMALLOC
size = 1;
newmem = malloc(size);
if (!newmem)
- fatal_func(nomem_fatal_type);
+ yasm_fatal(N_("out of memory"));
return newmem;
}
newmem = calloc(nelem, elsize);
if (!newmem)
- fatal_func(nomem_fatal_type);
+ yasm_fatal(N_("out of memory"));
return newmem;
}
else
newmem = realloc(oldmem, size);
if (!newmem)
- fatal_func(nomem_fatal_type);
+ yasm_fatal(N_("out of memory"));
return newmem;
}
src/xmalloc.c \
src/xstrdup.c \
src/strcasecmp.c
+libyasm_la_LDFLAGS = -no-undefined
yasm_SOURCES += \
src/main.c \
unsigned char yasm_x86_LTX_mode_bits = 0;
-/*@dependent@*/ yasm_errwarn *yasm_x86__errwarn;
static void
-x86_initialize(yasm_errwarn *we)
+x86_initialize(void)
{
- yasm_x86__errwarn = we;
}
static void
(lval == 16 || lval == 32 || lval == 64))
yasm_x86_LTX_mode_bits = (unsigned char)lval;
else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "BITS");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "BITS");
return 0;
} else
return 1;
case X86_FPUREG:
return 10;
default:
- cur_we->internal_error(N_("unknown register size"));
+ yasm_internal_error(N_("unknown register size"));
}
return 0;
}
fprintf(f, "st%d", (int)(reg&0xF));
break;
default:
- cur_we->internal_error(N_("unknown register size"));
+ yasm_internal_error(N_("unknown register size"));
}
}
yasm_bytecode *yasm_x86__bc_new_jmprel(x86_new_jmprel_data *d);
extern unsigned char yasm_x86_LTX_mode_bits;
-extern /*@dependent@*/ yasm_errwarn *yasm_x86__errwarn;
-#define cur_we yasm_x86__errwarn
void yasm_x86__bc_delete(yasm_bytecode *bc);
void yasm_x86__bc_print(FILE *f, int indent_level, const yasm_bytecode *bc);
jmprel->op_sel = d->op_sel;
if ((d->op_sel == JR_SHORT_FORCED) && (d->near_op_len == 0))
- cur_we->error(d->lindex,
- N_("no SHORT form of that jump instruction exists"));
+ yasm__error(d->lindex,
+ N_("no SHORT form of that jump instruction exists"));
if ((d->op_sel == JR_NEAR_FORCED) && (d->short_op_len == 0))
- cur_we->error(d->lindex,
- N_("no NEAR form of that jump instruction exists"));
+ yasm__error(d->lindex,
+ N_("no NEAR form of that jump instruction exists"));
jmprel->shortop.opcode[0] = d->short_op[0];
jmprel->shortop.opcode[1] = d->short_op[1];
return;
if (segment != 0 && x86_ea->segment != 0)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("multiple segment overrides, using leftmost"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("multiple segment overrides, using leftmost"));
x86_ea->segment = segment;
}
return NULL;
if ((x86_bytecode_type)bc->type != X86_BC_INSN)
- cur_we->internal_error(N_("Trying to get EA of non-instruction"));
+ yasm_internal_error(N_("Trying to get EA of non-instruction"));
return (yasm_effaddr *)(((x86_insn *)bc)->ea);
}
jmprel->opersize = opersize;
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("OperSize override applied to non-instruction"));
}
}
jmprel->addrsize = addrsize;
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("AddrSize override applied to non-instruction"));
}
}
lockrep_pre = &jmprel->lockrep_pre;
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("LockRep prefix applied to non-instruction"));
}
if (*lockrep_pre != 0)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("multiple LOCK or REP prefixes, using leftmost"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("multiple LOCK or REP prefixes, using leftmost"));
*lockrep_pre = prefix;
}
temp = yasm_expr_copy(jmprel->target);
num = yasm_expr_get_intnum(&temp, calc_bc_dist);
if (!num) {
- cur_we->error(bc->line,
+ yasm__error(bc->line,
N_("short jump target external or out of segment"));
yasm_expr_delete(temp);
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
yasm_expr_delete(temp);
/* does a short form exist? */
if (jmprel->shortop.opcode_len == 0) {
- cur_we->error(bc->line,
- N_("short jump does not exist"));
+ yasm__error(bc->line, N_("short jump does not exist"));
return YASM_BC_RESOLVE_ERROR |
YASM_BC_RESOLVE_UNKNOWN_LEN;
}
/* short displacement must fit in -128 <= rel <= +127 */
if (rel < -128 || rel > 127) {
- cur_we->error(bc->line, N_("short jump out of range"));
+ yasm__error(bc->line, N_("short jump out of range"));
return YASM_BC_RESOLVE_ERROR |
YASM_BC_RESOLVE_UNKNOWN_LEN;
}
jrshort = 0;
if (save) {
if (jmprel->nearop.opcode_len == 0) {
- cur_we->error(bc->line, N_("near jump does not exist"));
+ yasm__error(bc->line, N_("near jump does not exist"));
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
}
}
* it to actually be within short range).
*/
if (save) {
- cur_we->error(bc->line,
+ yasm__error(bc->line,
N_("short jump out of range (near jump does not exist)"));
return YASM_BC_RESOLVE_ERROR |
YASM_BC_RESOLVE_UNKNOWN_LEN;
jrshort = 0;
} else {
if (save) {
- cur_we->error(bc->line,
+ yasm__error(bc->line,
N_("short jump out of range (near jump does not exist)"));
return YASM_BC_RESOLVE_ERROR |
YASM_BC_RESOLVE_UNKNOWN_LEN;
default:
break;
}
- cur_we->internal_error(N_("Didn't handle bytecode type in x86 arch"));
+ yasm_internal_error(N_("Didn't handle bytecode type in x86 arch"));
/*@notreached@*/
return YASM_BC_RESOLVE_UNKNOWN_LEN;
}
YASM_WRITE_8(*bufp, 0x67);
if (insn->rex != 0 && insn->rex != 0xff) {
if (insn->mode_bits != 64)
- cur_we->internal_error(
+ yasm_internal_error(
N_("x86: got a REX prefix in non-64-bit mode"));
YASM_WRITE_8(*bufp, insn->rex);
}
if (ea) {
if (x86_ea->need_modrm) {
if (!x86_ea->valid_modrm)
- cur_we->internal_error(
- N_("invalid Mod/RM in x86 tobytes_insn"));
+ yasm_internal_error(N_("invalid Mod/RM in x86 tobytes_insn"));
YASM_WRITE_8(*bufp, x86_ea->modrm);
}
if (x86_ea->need_sib) {
if (!x86_ea->valid_sib)
- cur_we->internal_error(N_("invalid SIB in x86 tobytes_insn"));
+ yasm_internal_error(N_("invalid SIB in x86 tobytes_insn"));
YASM_WRITE_8(*bufp, x86_ea->sib);
}
&eat.sib, &eat.valid_sib,
&eat.need_sib, &insn->rex,
yasm_common_calc_bc_dist))
- cur_we->internal_error(N_("checkea failed"));
+ yasm_internal_error(N_("checkea failed"));
if (ea->disp) {
if (output_expr(&ea->disp, bufp, ea->len, *bufp-bufp_orig,
case JR_SHORT:
/* 1 byte relative displacement */
if (jmprel->shortop.opcode_len == 0)
- cur_we->internal_error(N_("short jump does not exist"));
+ yasm_internal_error(N_("short jump does not exist"));
/* Opcode */
for (i=0; i<jmprel->shortop.opcode_len; i++)
case JR_NEAR:
/* 2/4 byte relative displacement (depending on operand size) */
if (jmprel->nearop.opcode_len == 0) {
- cur_we->error(bc->line, N_("near jump does not exist"));
+ yasm__error(bc->line, N_("near jump does not exist"));
return 1;
}
return 1;
break;
default:
- cur_we->internal_error(N_("unrecognized relative jump op_sel"));
+ yasm_internal_error(N_("unrecognized relative jump op_sel"));
}
return 0;
}
if (rel) {
long val;
if (valsize != 1 && valsize != 2 && valsize != 4)
- cur_we->internal_error(
+ yasm_internal_error(
N_("tried to do PC-relative offset from invalid sized value"));
val = yasm_intnum_get_uint(intn);
val -= bc->len;
/* The reg expn *must* be EXPR_ADD at this point. Sanity check. */
if (e->terms[havereg_expr].type != YASM_EXPR_EXPR ||
e->terms[havereg_expr].data.expn->op != YASM_EXPR_ADD)
- cur_we->internal_error(N_("Register expression not ADD or EXPN"));
+ yasm_internal_error(N_("Register expression not ADD or EXPN"));
/* Iterate over each term in reg expn */
for (i=0; i<e->terms[havereg_expr].data.expn->numterms; i++) {
* Sanity check for EXPR_INT.
*/
if (e->terms[i].data.expn->terms[0].type != YASM_EXPR_REG)
- cur_we->internal_error(
+ yasm_internal_error(
N_("Register not found in reg expn"));
if (e->terms[i].data.expn->terms[1].type != YASM_EXPR_INT)
- cur_we->internal_error(
+ yasm_internal_error(
N_("Non-integer value in reg expn"));
reg = get_reg(&e->terms[i].data.expn->terms[0], ®num,
data);
*/
if (!yasm_intnum_check_size(intn, (size_t)wordsize, 0) &&
!yasm_intnum_check_size(intn, 1, 1)) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
case 2:
case 4:
if (wordsize != *displen) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid effective address (displacement size)"));
return 0;
}
break;
default:
/* we shouldn't ever get any other size! */
- cur_we->internal_error(N_("strange EA displacement size"));
+ yasm_internal_error(N_("strange EA displacement size"));
}
return 1;
* otherwise illegal. It's also illegal in non-64-bit mode.
*/
if (*n_modrm || *n_sib) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid effective address (displacement size)"));
return 0;
}
/* We can only do 64-bit addresses in 64-bit mode. */
if (*addrsize == 64 && bits != 64) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid effective address (64-bit in non-64-bit mode)"));
return 0;
}
calc_bc_dist)) {
case 0:
e = *ep;
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
case 1:
return 1;
*/
for (i=0; i<17; i++) {
if (reg3264mult[i] < 0) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
if (i != indexreg && reg3264mult[i] == 1 &&
*/
for (i=0; i<17; i++)
if (i != basereg && i != indexreg && reg3264mult[i] != 0) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
if (indexreg != REG3264_NONE && reg3264mult[indexreg] != 1 &&
reg3264mult[indexreg] != 2 && reg3264mult[indexreg] != 4 &&
reg3264mult[indexreg] != 8) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
* legal.
*/
if (reg3264mult[REG3264_ESP] > 1 || basereg == REG3264_ESP) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
/* If mult==1 and basereg is not ESP, swap indexreg w/basereg. */
/* RIP is only legal if it's the ONLY register used. */
if (indexreg == REG64_RIP ||
(basereg == REG64_RIP && indexreg != REG3264_NONE)) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
*/
if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
bits, X86_REX_B)) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid combination of operands and effective address"));
return 0;
}
else {
if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
bits, X86_REX_B)) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid combination of operands and effective address"));
return 0;
}
if (yasm_x86__set_rex_from_reg(rex, &low3,
X86_REG64 | indexreg, bits,
X86_REX_X)) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid combination of operands and effective address"));
return 0;
}
/* 64-bit mode does not allow 16-bit addresses */
if (bits == 64) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("16-bit addresses not supported in 64-bit mode"));
return 0;
}
calc_bc_dist)) {
case 0:
e = *ep;
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
case 1:
return 1;
/* reg multipliers not 0 or 1 are illegal. */
if (reg16mult.bx & ~1 || reg16mult.si & ~1 || reg16mult.di & ~1 ||
reg16mult.bp & ~1) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
/* Check the modrm value for invalid combinations. */
if (modrm16[havereg] & 0070) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
switch (*addrsize) {
case 64:
if (bits != 64) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid effective address (64-bit in non-64-bit mode)"));
return 0;
}
case 16:
/* 64-bit mode does not allow 16-bit addresses */
if (bits == 64) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("16-bit addresses not supported in 64-bit mode"));
return 0;
}
int fltret;
if (!yasm_floatnum_check_size(flt, (size_t)valsize)) {
- cur_we->error(e->line, N_("invalid floating point constant size"));
+ yasm__error(e->line, N_("invalid floating point constant size"));
return 1;
}
fltret = yasm_floatnum_get_sized(flt, *bufp, (size_t)valsize);
if (fltret < 0) {
- cur_we->error(e->line, N_("underflow in floating point expression"));
+ yasm__error(e->line, N_("underflow in floating point expression"));
return 1;
}
if (fltret > 0) {
- cur_we->error(e->line, N_("overflow in floating point expression"));
+ yasm__error(e->line, N_("overflow in floating point expression"));
return 1;
}
*bufp += valsize;
/* We know the target is in operand 0, but sanity check for Imm. */
op = yasm_ops_first(operands);
if (op->type != YASM_INSN__OPERAND_IMM)
- cur_we->internal_error(N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
d.target = yasm_expr_new(YASM_EXPR_SUB, yasm_expr_expr(op->data.val),
yasm_expr_sym(yasm_symrec_define_label("$", cur_section, prev_bc,
0, lindex)), lindex);
mismatch = 1;
break;
default:
- cur_we->internal_error(N_("invalid operand type"));
+ yasm_internal_error(N_("invalid operand type"));
}
if (mismatch)
mismatch = 1;
break;
default:
- cur_we->internal_error(N_("invalid target modifier type"));
+ yasm_internal_error(N_("invalid target modifier type"));
}
}
if (!found) {
/* Didn't find a matching one */
- cur_we->error(lindex,
- N_("invalid combination of opcode and operands"));
+ yasm__error(lindex, N_("invalid combination of opcode and operands"));
return NULL;
}
case MOD_ExtErr:
switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
case 0:
- cur_we->error(lindex, N_("mismatch in operand sizes"));
+ yasm__error(lindex, N_("mismatch in operand sizes"));
break;
case 1:
- cur_we->error(lindex, N_("operand size not specified"));
+ yasm__error(lindex, N_("operand size not specified"));
break;
default:
- cur_we->internal_error(
- N_("unrecognized x86 ext mod index"));
+ yasm_internal_error(N_("unrecognized x86 ext mod index"));
}
return NULL; /* It was an error */
case MOD_ExtWarn:
switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
default:
- cur_we->internal_error(
- N_("unrecognized x86 ext mod index"));
+ yasm_internal_error(N_("unrecognized x86 ext mod index"));
}
break;
default:
- cur_we->internal_error(N_("unrecognized x86 extended modifier"));
+ yasm_internal_error(N_("unrecognized x86 extended modifier"));
}
/* Shortcut to JmpRel */
yasm_x86_LTX_mode_bits);
break;
case YASM_INSN__OPERAND_SEGREG:
- cur_we->internal_error(
+ yasm_internal_error(
N_("invalid operand conversion"));
case YASM_INSN__OPERAND_MEMORY:
d.ea = op->data.ea;
d.im_len = size_lookup[(info->operands[i] &
OPS_MASK)>>OPS_SHIFT];
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_SImm:
if (op->type == YASM_INSN__OPERAND_IMM) {
OPS_MASK)>>OPS_SHIFT];
d.im_sign = 1;
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_Spare:
if (op->type == YASM_INSN__OPERAND_SEGREG)
if (yasm_x86__set_rex_from_reg(&d.rex, &d.spare,
op->data.reg, yasm_x86_LTX_mode_bits,
X86_REX_R)) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("invalid combination of opcode and operands"));
return NULL;
}
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_Op0Add:
if (op->type == YASM_INSN__OPERAND_REG) {
if (yasm_x86__set_rex_from_reg(&d.rex, &opadd,
op->data.reg, yasm_x86_LTX_mode_bits,
X86_REX_B)) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("invalid combination of opcode and operands"));
return NULL;
}
d.op[0] += opadd;
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_Op1Add:
/* Op1Add is only used for FPU, so no need to do REX */
if (op->type == YASM_INSN__OPERAND_REG)
d.op[1] += (unsigned char)(op->data.reg&7);
else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_SpareEA:
if (op->type == YASM_INSN__OPERAND_REG) {
yasm_x86__set_rex_from_reg(&d.rex, &d.spare,
op->data.reg, yasm_x86_LTX_mode_bits,
X86_REX_R)) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("invalid combination of opcode and operands"));
if (d.ea)
xfree(d.ea);
return NULL;
}
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
default:
- cur_we->internal_error(N_("unknown operand action"));
+ yasm_internal_error(N_("unknown operand action"));
}
switch (info->operands[i] & OPAP_MASK) {
d.signext_imm8_op = 1;
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("unknown operand postponed action"));
}
}
/* catchalls */
[\001-\377]+ {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("unrecognized CPU identifier `%s'"), id);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("unrecognized CPU identifier `%s'"), id);
return;
}
[\000] {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("unrecognized CPU identifier `%s'"), id);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("unrecognized CPU identifier `%s'"), id);
return;
}
*/
}
O "64" {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a prefix in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a prefix in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_OPERSIZE;
/* address size overrides */
A "16" {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("Cannot override address size to 16 bits in 64-bit mode"));
return YASM_ARCH_CHECK_ID_NONE;
}
}
A "64" {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a prefix in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a prefix in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_ADDRSIZE;
/* control, debug, and test registers */
C R [02-48] {
if (yasm_x86_LTX_mode_bits != 64 && oid[2] == '8') {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_CRREG | (oid[2]-'0');
X M M [0-9] {
if (yasm_x86_LTX_mode_bits != 64 &&
(oid[3] == '8' || oid[3] == '9')) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_XMMREG | (oid[3]-'0');
}
X M M "1" [0-5] {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | (10+oid[4]-'0');
/* integer registers */
R A X {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 0;
}
R C X {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 1;
}
R D X {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 2;
}
R B X {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 3;
}
R S P {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 4;
}
R B P {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 5;
}
R S I {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 6;
}
R D I {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 7;
}
R [8-9] {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | (oid[1]-'0');
}
R "1" [0-5] {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | (10+oid[2]-'0');
E D I { data[0] = X86_REG32 | 7; return YASM_ARCH_CHECK_ID_REG; }
R [8-9] D {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG32 | (oid[1]-'0');
}
R "1" [0-5] D {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG32 | (10+oid[2]-'0');
D I { data[0] = X86_REG16 | 7; return YASM_ARCH_CHECK_ID_REG; }
R [8-9] W {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG16 | (oid[1]-'0');
}
R "1" [0-5] W {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG16 | (10+oid[2]-'0');
B H { data[0] = X86_REG8 | 7; return YASM_ARCH_CHECK_ID_REG; }
S P L {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8X | 4;
}
B P L {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8X | 5;
}
S I L {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8X | 6;
}
D I L {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8X | 7;
}
R [8-9] B {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8 | (oid[1]-'0');
}
R "1" [0-5] B {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8 | (10+oid[2]-'0');
/* segment registers */
E S {
if (yasm_x86_LTX_mode_bits == 64)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("`%s' segment register ignored in 64-bit mode"), oid);
data[0] = 0x2600;
return YASM_ARCH_CHECK_ID_SEGREG;
C S { data[0] = 0x2e01; return YASM_ARCH_CHECK_ID_SEGREG; }
S S {
if (yasm_x86_LTX_mode_bits == 64)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("`%s' segment register ignored in 64-bit mode"), oid);
data[0] = 0x3602;
return YASM_ARCH_CHECK_ID_SEGREG;
}
D S {
if (yasm_x86_LTX_mode_bits == 64)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("`%s' segment register ignored in 64-bit mode"), oid);
data[0] = 0x3e03;
return YASM_ARCH_CHECK_ID_SEGREG;
/* RIP for 64-bit mode IP-relative offsets */
R I P {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_RIP;
M O V S X { RET_INSN(movszx, 0xBE, CPU_386); }
M O V S X D {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(movsxd, 0, CPU_Hammer|CPU_64);
P U S H { RET_INSN(push, 0, CPU_Any); }
P U S H A {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x0060, CPU_186);
}
P U S H A D {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x2060, CPU_386);
}
P U S H A W {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x1060, CPU_186);
P O P { RET_INSN(pop, 0, CPU_Any); }
P O P A {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x0061, CPU_186);
}
P O P A D {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x2061, CPU_386);
}
P O P A W {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x1061, CPU_186);
/* Load segment registers from memory */
L D S {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(ldes, 0xC5, CPU_Any);
}
L E S {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(ldes, 0xC4, CPU_Any);
C M C { RET_INSN(onebyte, 0x00F5, CPU_Any); }
L A H F {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x009F, CPU_Any);
}
S A H F {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x009E, CPU_Any);
P U S H F W { RET_INSN(onebyte, 0x109C, CPU_Any); }
P U S H F Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x409C, CPU_Hammer|CPU_64);
P O P F W { RET_INSN(onebyte, 0x109D, CPU_Any); }
P O P F Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x409D, CPU_Hammer|CPU_64);
N O T { RET_INSN(f6, 0x02, CPU_Any); }
A A A {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x0037, CPU_Any);
}
A A S {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x003F, CPU_Any);
}
D A A {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x0027, CPU_Any);
}
D A S {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x002F, CPU_Any);
}
A A D {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(aadm, 0x01, CPU_Any);
}
A A M {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(aadm, 0x00, CPU_Any);
C W D E { RET_INSN(onebyte, 0x2098, CPU_386); }
C D Q E {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x4098, CPU_Hammer|CPU_64);
C D Q { RET_INSN(onebyte, 0x2099, CPU_386); }
C D O {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x4099, CPU_Hammer|CPU_64);
J E C X Z { RET_INSN(jcxz, 32, CPU_386); }
J R C X Z {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(jcxz, 64, CPU_Hammer|CPU_64);
C M P S D { RET_INSN(cmpsd, 0, CPU_Any); }
C M P S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40A7, CPU_Hammer|CPU_64);
L O D S D { RET_INSN(onebyte, 0x20AD, CPU_386); }
L O D S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40AD, CPU_Hammer|CPU_64);
M O V S D { RET_INSN(movsd, 0, CPU_Any); }
M O V S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40A5, CPU_Any);
S C A S D { RET_INSN(onebyte, 0x20AF, CPU_386); }
S C A S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40AF, CPU_Hammer|CPU_64);
S T O S D { RET_INSN(onebyte, 0x20AB, CPU_386); }
S T O S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40AB, CPU_Hammer|CPU_64);
I N T "03" { RET_INSN(onebyte, 0x00CC, CPU_Any); }
I N T O {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x00CE, CPU_Any);
I R E T D { RET_INSN(onebyte, 0x20CF, CPU_386); }
I R E T Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40CF, CPU_Hammer|CPU_64);
R S M { RET_INSN(twobyte, 0x0FAA, CPU_586|CPU_SMM); }
B O U N D {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(bound, 0, CPU_186);
/* Protection control */
A R P L {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(arpl, 0, CPU_286|CPU_Prot);
/* Pentium II/Pentium Pro extensions */
S Y S E N T E R {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(twobyte, 0x0F34, CPU_686);
}
S Y S E X I T {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(twobyte, 0x0F35, CPU_686|CPU_Priv);
/* AMD x86-64 extensions */
S W A P G S {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(threebyte, 0x0F01F8, CPU_Hammer|CPU_64);
L O A D A L L "286" { RET_INSN(twobyte, 0x0F05, CPU_286|CPU_Undoc); }
S A L C {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x00D6, CPU_Undoc);
yasm_objfmt yasm_bin_LTX_objfmt;
static /*@dependent@*/ yasm_arch *cur_arch;
-static /*@dependent@*/ yasm_errwarn *cur_we;
static void
bin_objfmt_initialize(/*@unused@*/ const char *in_filename,
/*@unused@*/ const char *obj_filename,
- /*@unused@*/ yasm_dbgfmt *df, yasm_arch *a,
- yasm_errwarn *we)
+ /*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
{
cur_arch = a;
- cur_we = we;
}
/* Aligns sect to either its specified alignment (in its objfmt-specific data)
/* Check for complex float expressions */
if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
- cur_we->error((*ep)->line,
- N_("floating point expression too complex"));
+ yasm__error((*ep)->line, N_("floating point expression too complex"));
return 1;
}
/* Couldn't output, assume it contains an external reference. */
- cur_we->error((*ep)->line,
+ yasm__error((*ep)->line,
N_("binary object format does not support external references"));
return 1;
}
/* Warn that gaps are converted to 0 and write out the 0's. */
if (gap) {
unsigned long left;
- cur_we->warning(YASM_WARN_GENERAL, bc->line,
+ yasm__warning(YASM_WARN_GENERAL, bc->line,
N_("uninitialized space declared in code/data section: zeroing"));
/* Write out in chunks */
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
bss = yasm_sections_find_general(sections, ".bss");
if (!text)
- cur_we->internal_error(N_("No `.text' section in bin objfmt output"));
+ yasm_internal_error(N_("No `.text' section in bin objfmt output"));
/* First determine the actual starting offsets for .data and .bss.
* As the order in the file is .text -> .data -> .bss (not present),
assert(startexpr != NULL);
startnum = yasm_expr_get_intnum(&startexpr, NULL);
if (!startnum)
- cur_we->internal_error(
- N_("Complex expr for start in bin objfmt output"));
+ yasm_internal_error(N_("Complex expr for start in bin objfmt output"));
start = yasm_intnum_get_uint(startnum);
yasm_expr_delete(startexpr);
textstart = start;
resonly = 1;
} else {
/* other section names not recognized. */
- cur_we->error(lindex, N_("segment name `%s' not recognized"),
- sectname);
+ yasm__error(lindex, N_("segment name `%s' not recognized"),
+ sectname);
return NULL;
}
unsigned long bitcnt;
if (strcmp(sectname, ".text") == 0) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("cannot specify an alignment to the `%s' section"),
sectname);
return NULL;
align = yasm_expr_get_intnum(&vp->param, NULL);
if (!align) {
- cur_we->error(lindex,
- N_("argument to `%s' is not a power of two"),
- vp->val);
+ yasm__error(lindex,
+ N_("argument to `%s' is not a power of two"),
+ vp->val);
return NULL;
}
alignval = yasm_intnum_get_uint(align);
*/
BitCount(bitcnt, alignval);
if (bitcnt > 1) {
- cur_we->error(lindex,
- N_("argument to `%s' is not a power of two"),
- vp->val);
+ yasm__error(lindex,
+ N_("argument to `%s' is not a power of two"),
+ vp->val);
return NULL;
}
}
retval = yasm_sections_switch_general(headp, sectname, start, resonly,
- &isnew, lindex,
- cur_we->internal_error_);
+ &isnew, lindex);
if (isnew) {
if (have_alignval) {
yasm_symrec_define_label(sectname, retval, (yasm_bytecode *)NULL,
1, lindex);
} else if (have_alignval)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("alignment value ignored on section redeclaration"));
return retval;
unsigned long lindex)
{
yasm_expr_delete(size);
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("binary object format does not support common variables"));
}
/* ORG takes just a simple integer as param */
vp = yasm_vps_first(valparams);
if (vp->val) {
- cur_we->error(lindex, N_("argument to ORG should be numeric"));
+ yasm__error(lindex, N_("argument to ORG should be numeric"));
return 0;
} else if (vp->param)
start = yasm_expr_get_intnum(&vp->param, NULL);
if (!start) {
- cur_we->error(lindex, N_("argument to ORG should be numeric"));
+ yasm__error(lindex, N_("argument to ORG should be numeric"));
return 0;
}
/* ORG changes the start of the .text section */
sect = yasm_sections_find_general(headp, ".text");
if (!sect)
- cur_we->internal_error(
+ yasm_internal_error(
N_("bin objfmt: .text section does not exist before ORG is called?"));
yasm_section_set_start(sect, yasm_intnum_get_uint(start), lindex);
yasm_objfmt yasm_coff_LTX_objfmt;
static /*@dependent@*/ yasm_arch *cur_arch;
-static /*@dependent@*/ yasm_errwarn *cur_we;
static /*@dependent@*/ coff_symtab_entry *
coff_symtab_entry *entry;
if (STAILQ_EMPTY(&coff_symtab))
- cur_we->internal_error(N_("empty COFF symbol table"));
+ yasm_internal_error(N_("empty COFF symbol table"));
entry = STAILQ_LAST(&coff_symtab, coff_symtab_entry, link);
sym_data_prev = yasm_symrec_get_of_data(entry->sym);
assert(sym_data_prev != NULL);
static void
coff_objfmt_initialize(const char *in_filename,
/*@unused@*/ const char *obj_filename,
- /*@unused@*/ yasm_dbgfmt *df, yasm_arch *a,
- yasm_errwarn *we)
+ /*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
{
yasm_symrec *filesym;
coff_symrec_data *data;
coff_symtab_entry *entry;
cur_arch = a;
- cur_we = we;
coff_objfmt_parse_scnum = 1; /* section numbering starts at 1 */
STAILQ_INIT(&coff_symtab);
yasm_sym_vis vis;
if (valsize != 4) {
- cur_we->error((*ep)->line, N_("coff: invalid relocation size"));
+ yasm__error((*ep)->line, N_("coff: invalid relocation size"));
return 1;
}
/* Check for complex float expressions */
if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
- cur_we->error((*ep)->line,
- N_("floating point expression too complex"));
+ yasm__error((*ep)->line, N_("floating point expression too complex"));
return 1;
}
- cur_we->error((*ep)->line, N_("coff: relocation too complex"));
+ yasm__error((*ep)->line, N_("coff: relocation too complex"));
return 1;
}
/* Warn that gaps are converted to 0 and write out the 0's. */
if (gap) {
unsigned long left;
- cur_we->warning(YASM_WARN_GENERAL, bc->line,
+ yasm__warning(YASM_WARN_GENERAL, bc->line,
N_("uninitialized space declared in code/data section: zeroing"));
/* Write out in chunks */
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
} else {
pos = ftell(info->f);
if (pos == -1) {
- cur_we->error(0, N_("could not get file position on output file"));
+ yasm__error(0, N_("could not get file position on output file"));
return 1;
}
pos = ftell(info->f);
if (pos == -1) {
- cur_we->error(0, N_("could not get file position on output file"));
+ yasm__error(0, N_("could not get file position on output file"));
return 1;
}
csd->relptr = (unsigned long)pos;
csymd = yasm_symrec_get_of_data(reloc->sym);
if (!csymd)
- cur_we->internal_error(
+ yasm_internal_error(
N_("coff: no symbol data for relocated symbol"));
YASM_WRITE_32_L(localbuf, reloc->addr); /* address of relocation */
YASM_WRITE_32_L(localbuf, csd->relptr); /* file ptr to relocs */
YASM_WRITE_32_L(localbuf, 0); /* file ptr to line nums */
if (csd->nreloc >= 64*1024) {
- cur_we->warning(YASM_WARN_GENERAL, 0,
- N_("too many relocations in section `%s'"),
- yasm_section_get_name(sect));
+ yasm__warning(YASM_WARN_GENERAL, 0,
+ N_("too many relocations in section `%s'"),
+ yasm_section_get_name(sect));
YASM_WRITE_16_L(localbuf, 0xFFFF); /* max out */
} else
YASM_WRITE_16_L(localbuf, csd->nreloc); /* num of relocation entries */
/* Allocate space for headers by seeking forward */
if (fseek(f, 20+40*(coff_objfmt_parse_scnum-1), SEEK_SET) < 0) {
- cur_we->error(0, N_("could not seek on output file"));
+ yasm__error(0, N_("could not seek on output file"));
return;
}
/* Symbol table */
pos = ftell(f);
if (pos == -1) {
- cur_we->error(0, N_("could not get file position on output file"));
+ yasm__error(0, N_("could not get file position on output file"));
return;
}
symtab_pos = (unsigned long)pos;
/* Get symrec's of_data (needed for storage class) */
csymd = yasm_symrec_get_of_data(entry->sym);
if (!csymd)
- cur_we->internal_error(
- N_("coff: expected sym data to be present"));
+ yasm_internal_error(N_("coff: expected sym data to be present"));
/* Look at symrec for value/scnum/etc. */
if (yasm_symrec_get_label(entry->sym, §, &precbc)) {
intn = yasm_expr_get_intnum(&csymd->size,
yasm_common_calc_bc_dist);
if (!intn)
- cur_we->error(csymd->size->line,
+ yasm__error(csymd->size->line,
N_("COMMON data size not an integer expression"));
else
value = yasm_intnum_get_uint(intn);
strncpy((char *)localbuf, entry->aux[0].fname, 14);
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("coff: unrecognized aux symtab type"));
}
fwrite(info.buf, 18, 1, f);
/* Write headers */
if (fseek(f, 0, SEEK_SET) < 0) {
- cur_we->error(0, N_("could not seek on output file"));
+ yasm__error(0, N_("could not seek on output file"));
return;
}
sectname = vp->val;
if (strlen(sectname) > 8) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("COFF section names limited to 8 characters: truncating"));
sectname[8] = '\0';
}
}
retval = yasm_sections_switch_general(headp, sectname, 0, resonly, &isnew,
- lindex, cur_we->internal_error_);
+ lindex);
if (isnew) {
coff_section_data *data;
COFF_SYMTAB_AUX_SECT);
data->sym = sym;
} else if (flags_override)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("section flags ignored on section redeclaration"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("section flags ignored on section redeclaration"));
return retval;
}
*/
static FILE *dbg_objfmt_file;
-static /*@dependent@*/ yasm_errwarn *cur_we;
static void
dbg_objfmt_initialize(const char *in_filename, const char *obj_filename,
- yasm_dbgfmt *df, yasm_arch *a, yasm_errwarn *we)
+ yasm_dbgfmt *df, yasm_arch *a)
{
- cur_we = we;
-
dbg_objfmt_file = fopen(obj_filename, "wt");
if (!dbg_objfmt_file) {
fprintf(stderr, N_("could not open file `%s'"), obj_filename);
if ((vp = yasm_vps_first(valparams)) && !vp->param && vp->val != NULL) {
retval = yasm_sections_switch_general(headp, vp->val, 200, 0, &isnew,
- lindex, cur_we->internal_error_);
+ lindex);
if (isnew) {
fprintf(dbg_objfmt_file, "(new) ");
yasm_symrec_define_label(vp->val, retval, (yasm_bytecode *)NULL, 1,
#define BCFLAG_INPROGRESS (1UL<<0)
#define BCFLAG_DONE (1UL<<1)
-static /*@dependent@*/ yasm_errwarn *cur_we;
static int basic_optimize_section_1(yasm_section *sect,
/*@unused@*/ /*@null@*/ void *d);
basic_optimize_calc_bc_dist_1);
if (bcr_retval & YASM_BC_RESOLVE_UNKNOWN_LEN) {
if (!(bcr_retval & YASM_BC_RESOLVE_ERROR))
- cur_we->error(bc->line, N_("circular reference detected."));
+ yasm__error(bc->line, N_("circular reference detected."));
data->saw_unknown = -1;
return 0;
}
assert(data != NULL);
if (bc->opt_flags != BCFLAG_DONE)
- cur_we->internal_error(N_("Optimizer pass 1 missed a bytecode!"));
+ yasm_internal_error(N_("Optimizer pass 1 missed a bytecode!"));
if (!data->precbc)
bc->offset = 0;
data.sect = sect;
if (yasm_section_get_opt_flags(sect) != SECTFLAG_DONE)
- cur_we->internal_error(N_("Optimizer pass 1 missed a section!"));
+ yasm_internal_error(N_("Optimizer pass 1 missed a section!"));
return yasm_bcs_traverse(yasm_section_get_bytecodes(sect), &data,
basic_optimize_bytecode_2);
}
static void
-basic_optimize(yasm_sectionhead *sections, yasm_errwarn *we)
+basic_optimize(yasm_sectionhead *sections)
{
int saw_unknown = 0;
- cur_we = we;
-
/* Optimization process: (essentially NASM's pass 1)
* Determine the size of all bytecodes.
* Forward references are /not/ resolved (only backward references are
$$ = (yasm_bytecode *)NULL;
}
| error '\n' {
- cur_we->error(cur_lindex,
- N_("label or instruction expected at start of line"));
+ yasm__error(cur_lindex,
+ N_("label or instruction expected at start of line"));
$$ = (yasm_bytecode *)NULL;
yyerrok;
}
yasm_ops_delete(&$2.operands, 0);
}
| INSN error {
- cur_we->error(cur_lindex, N_("expression syntax error"));
+ yasm__error(cur_lindex, N_("expression syntax error"));
$$ = NULL;
}
| PREFIX instr {
dataval: dvexpr { $$ = yasm_dv_new_expr($1); }
| STRING { $$ = yasm_dv_new_string($1); }
| error {
- cur_we->error(cur_lindex, N_("expression syntax error"));
+ yasm__error(cur_lindex, N_("expression syntax error"));
$$ = (yasm_dataval *)NULL;
}
;
xfree($1);
}
| DIRECTIVE_NAME error {
- cur_we->error(cur_lindex, N_("invalid arguments to [%s]"), $1);
+ yasm__error(cur_lindex, N_("invalid arguments to [%s]"), $1);
xfree($1);
}
;
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 1)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 1;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 2)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 2;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 4)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 4;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 8)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 8;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 10)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 10;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 16)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 16;
}
nasm_parser_objfmt->extern_declare(sym, objext_valparams,
lindex);
} else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "EXTERN");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "EXTERN");
} else if (yasm__strcasecmp(name, "global") == 0) {
vp = yasm_vps_first(valparams);
if (vp->val) {
nasm_parser_objfmt->global_declare(sym, objext_valparams,
lindex);
} else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "GLOBAL");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "GLOBAL");
} else if (yasm__strcasecmp(name, "common") == 0) {
vp = yasm_vps_first(valparams);
if (vp->val) {
vp2 = yasm_vps_next(vp);
if (!vp2 || (!vp2->val && !vp2->param))
- cur_we->error(lindex,
- N_("no size specified in %s declaration"),
- "COMMON");
+ yasm__error(lindex, N_("no size specified in %s declaration"),
+ "COMMON");
else {
if (vp2->val) {
sym = yasm_symrec_declare(vp->val, YASM_SYM_COMMON,
}
}
} else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "COMMON");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "COMMON");
} else if (yasm__strcasecmp(name, "section") == 0 ||
yasm__strcasecmp(name, "segment") == 0) {
yasm_section *new_section =
nasm_parser_prev_bc =
yasm_bcs_last(yasm_section_get_bytecodes(new_section));
} else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "SECTION");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "SECTION");
} else if (yasm__strcasecmp(name, "absolute") == 0) {
/* it can be just an ID or a complete expression, so handle both. */
vp = yasm_vps_first(valparams);
nasm_parser_cur_section =
yasm_sections_switch_absolute(&nasm_parser_sections,
p_expr_new_ident(yasm_expr_sym(
- yasm_symrec_use(vp->val, lindex))),
- cur_we->internal_error_);
+ yasm_symrec_use(vp->val, lindex))));
else if (vp->param) {
nasm_parser_cur_section =
- yasm_sections_switch_absolute(&nasm_parser_sections, vp->param,
- cur_we->internal_error_);
+ yasm_sections_switch_absolute(&nasm_parser_sections,
+ vp->param);
vp->param = NULL;
}
nasm_parser_prev_bc = (yasm_bytecode *)NULL;
const yasm_intnum *intcpu;
intcpu = yasm_expr_get_intnum(&vp->param, NULL);
if (!intcpu)
- cur_we->error(lindex, N_("invalid argument to [%s]"),
- "CPU");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "CPU");
else {
char strcpu[16];
sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu));
;
} else if (nasm_parser_objfmt->directive(name, valparams, objext_valparams,
&nasm_parser_sections, lindex)) {
- cur_we->error(lindex, N_("unrecognized directive [%s]"), name);
+ yasm__error(lindex, N_("unrecognized directive [%s]"), name);
}
yasm_vps_delete(valparams);
static void
nasm_parser_error(const char *s)
{
- cur_we->parser_error(cur_lindex, s);
+ yasm__parser_error(cur_lindex, s);
}
/*@dependent@*/ yasm_arch *nasm_parser_arch;
/*@dependent@*/ yasm_objfmt *nasm_parser_objfmt;
/*@dependent@*/ yasm_linemgr *nasm_parser_linemgr;
-/*@dependent@*/ yasm_errwarn *nasm_parser_errwarn;
int nasm_parser_save_input;
static /*@dependent@*/ yasm_sectionhead *
nasm_parser_do_parse(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of,
- yasm_linemgr *lm, yasm_errwarn *we, FILE *f,
- const char *in_filename, int save_input)
+ yasm_linemgr *lm, FILE *f, const char *in_filename,
+ int save_input)
/*@globals killed nasm_parser_locallabel_base @*/
{
- pp->initialize(f, in_filename, lm, we);
+ pp->initialize(f, in_filename, lm);
nasm_parser_in = f;
nasm_parser_input = pp->input;
nasm_parser_arch = a;
nasm_parser_objfmt = of;
nasm_parser_linemgr = lm;
- nasm_parser_errwarn = we;
nasm_parser_save_input = save_input;
/* Initialize section list */
extern /*@dependent@*/ yasm_arch *nasm_parser_arch;
extern /*@dependent@*/ yasm_objfmt *nasm_parser_objfmt;
extern /*@dependent@*/ yasm_linemgr *nasm_parser_linemgr;
-extern /*@dependent@*/ yasm_errwarn *nasm_parser_errwarn;
extern int nasm_parser_save_input;
#define p_expr_new_branch(o,r) yasm_expr_new_branch(o,r,cur_lindex)
#define p_expr_new_ident(r) yasm_expr_new_ident(r,cur_lindex)
-#define cur_we nasm_parser_errwarn
-
#endif
yylval.str_val = xstrndup(s.tok, TOKLEN);
RETURN(ID);
} else if (!nasm_parser_locallabel_base) {
- cur_we->warning(YASM_WARN_GENERAL, cur_lindex,
- N_("no non-local label before `%s'"),
- s.tok[0]);
+ yasm__warning(YASM_WARN_GENERAL, cur_lindex,
+ N_("no non-local label before `%s'"), s.tok[0]);
yylval.str_val = xstrndup(s.tok, TOKLEN);
} else {
len = TOKLEN + nasm_parser_locallabel_base_len;
case YASM_ARCH_CHECK_ID_TARGETMOD:
RETURN(TARGETMOD);
default:
- cur_we->warning(YASM_WARN_GENERAL, cur_lindex,
+ yasm__warning(YASM_WARN_GENERAL, cur_lindex,
N_("Arch feature not supported, treating as identifier"));
yylval.str_val = xstrndup(s.tok, TOKLEN);
RETURN(ID);
}
any {
- cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
- N_("ignoring unrecognized character `%s'"),
- cur_we->conv_unprint(s.tok[0]));
+ yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
+ N_("ignoring unrecognized character `%s'"),
+ yasm__conv_unprint(s.tok[0]));
goto scan;
}
*/
}
any {
- cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
- N_("ignoring unrecognized character `%s'"),
- cur_we->conv_unprint(s.tok[0]));
+ yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
+ N_("ignoring unrecognized character `%s'"),
+ yasm__conv_unprint(s.tok[0]));
goto linechg;
}
*/
}
any {
- cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
- N_("ignoring unrecognized character `%s'"),
- cur_we->conv_unprint(s.tok[0]));
+ yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
+ N_("ignoring unrecognized character `%s'"),
+ yasm__conv_unprint(s.tok[0]));
goto directive;
}
*/
/*!re2c
"\n" {
if (cursor == s.eof)
- cur_we->error(cur_lindex,
- N_("unexpected end of file in string"));
+ yasm__error(cur_lindex,
+ N_("unexpected end of file in string"));
else
- cur_we->error(cur_lindex, N_("unterminated string"));
+ yasm__error(cur_lindex, N_("unterminated string"));
strbuf[count] = '\0';
yylval.str_val = strbuf;
if (nasm_parser_save_input && cursor != s.eof)
static FILE *in;
static yasm_linemgr *cur_lm;
-static yasm_errwarn *cur_we;
static char *line, *linepos;
static size_t lineleft;
static char *file_name;
va_start(va, fmt);
switch (severity & ERR_MASK) {
case ERR_WARNING:
- cur_we->warning_va(YASM_WARN_PREPROC, cur_lm->get_current(), fmt,
- va);
+ yasm__warning_va(YASM_WARN_PREPROC, cur_lm->get_current(), fmt,
+ va);
break;
case ERR_NONFATAL:
- cur_we->error_va(cur_lm->get_current(), fmt, va);
+ yasm__error_va(cur_lm->get_current(), fmt, va);
break;
case ERR_FATAL:
- cur_we->fatal(YASM_FATAL_UNKNOWN); /* FIXME */
+ yasm_fatal(N_("unknown")); /* FIXME */
break;
case ERR_PANIC:
- cur_we->internal_error(fmt); /* FIXME */
+ yasm_internal_error(fmt); /* FIXME */
break;
case ERR_DEBUG:
break;
}
static void
-nasm_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
- yasm_errwarn *we)
+nasm_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
{
in = f;
cur_lm = lm;
- cur_we = we;
line = NULL;
file_name = NULL;
prior_linnum = 0;
static int is_interactive;
static FILE *in;
static yasm_linemgr *cur_lm;
-static yasm_errwarn *cur_we;
int isatty(int);
static void
-raw_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
- yasm_errwarn *we)
+raw_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
{
in = f;
cur_lm = lm;
- cur_we = we;
/*@-unrecog@*/
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
/*@=unrecog@*/
if (c == '\n')
buf[n++] = (char)c;
if (c == EOF && ferror(in))
- cur_we->error(cur_lm->get_current(),
- N_("error when reading from file"));
+ yasm__error(cur_lm->get_current(),
+ N_("error when reading from file"));
} else if (((n = fread(buf, 1, max_size, in)) == 0) && ferror(in))
- cur_we->error(cur_lm->get_current(),
- N_("error when reading from file"));
+ yasm__error(cur_lm->get_current(), N_("error when reading from file"));
return n;
}
YYSTYPE yapp_preproc_lval;
/*@dependent@*/ yasm_linemgr *yapp_preproc_linemgr;
-/*@dependent@*/ yasm_errwarn *yapp_preproc_errwarn;
int isatty(int);
void
yapp_macro_error_exists (YAPP_Macro *v)
{
- if (v) cur_we->error(cur_lindex, N_("Redefining macro of the same name %d:%d"), v->type, v->args);
+ if (v) yasm__error(cur_lindex, N_("Redefining macro of the same name %d:%d"), v->type, v->args);
}
void
yapp_macro_error_sameargname (YAPP_Macro *v)
{
- if (v) cur_we->error(cur_lindex, N_("Duplicate argument names in macro"));
+ if (v) yasm__error(cur_lindex, N_("Duplicate argument names in macro"));
}
YAPP_Macro *
if ((argc >= 0 && ym->args < 0)
|| (argc < 0 && ym->args >= 0))
{
- cur_we->warning(YASM_WARN_PREPROC, cur_lindex, N_("Attempted %%define both with and without parameters"));
+ yasm__warning(YASM_WARN_PREPROC, cur_lindex, N_("Attempted %%define both with and without parameters"));
return NULL;
}
}
expand_token_list(struct source_head *paramexp, struct source_head *to_head, source **to_tail);
static void
-yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
- yasm_errwarn *we)
+yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
{
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
yapp_preproc_linemgr = lm;
- yapp_preproc_errwarn = we;
yapp_preproc_current_file = xstrdup(in_filename);
yapp_preproc_line_number = 1;
yapp_lex_initialize(f);
out->out = current_output = YAPP_OUTPUT;
SLIST_INSERT_HEAD(&output_head, out, next);
- macro_table = HAMT_new(we->internal_error_);
+ macro_table = HAMT_new(yasm_internal_error_);
source_tail = SLIST_FIRST(&source_head);
macro_tail = SLIST_FIRST(¯o_head);
while ((token = yapp_preproc_lex()) != '\n') {
if (token == 0)
return 0;
- cur_we->error(cur_lindex, N_("Skipping possibly valid %%define stuff"));
+ yasm__error(cur_lindex, N_("Skipping possibly valid %%define stuff"));
}
append_token('\n', to_head, to_tail);
return '\n';
if (token == WHITESPACE)
token = yapp_preproc_lex();
if (token != IDENT) {
- cur_we->error(cur_lindex, N_("Identifier expected after %%%s"), synlvl);
+ yasm__error(cur_lindex, N_("Identifier expected after %%%s"), synlvl);
}
return token;
}
ydebug(("YAPP: +Expand macro %s...\n", name));
- if (ym->expanding) cur_we->internal_error(N_("Recursively expanding a macro!"));
+ if (ym->expanding) yasm_internal_error(N_("Recursively expanding a macro!"));
if (ym->type == YAPP_DEFINE) {
if (ym->args == -1) {
/* find out what we got */
if (from_head) {
- cur_we->internal_error(N_("Expanding macro with non-null from_head ugh\n"));
+ yasm_internal_error(N_("Expanding macro with non-null from_head ugh\n"));
}
token = yapp_preproc_lex();
append_token(token, &replay_head, &replay_tail);
default:
if (token < 256)
- cur_we->internal_error(N_("Unexpected character token in parameter expansion"));
+ yasm_internal_error(N_("Unexpected character token in parameter expansion"));
else
- cur_we->error(cur_lindex, N_("Cannot handle preprocessor items inside possible macro invocation"));
+ yasm__error(cur_lindex, N_("Cannot handle preprocessor items inside possible macro invocation"));
}
}
ym->expanding = 1;
/* so the macro exists. build a HAMT parameter table */
- param_table = HAMT_new(cur_we->internal_error_);
+ param_table = HAMT_new(yasm_internal_error_);
/* fill the entries by walking the replay buffer and create
* "macros". coincidentally, clear the replay buffer. */
xfree(replay);
}
else if (param) {
- cur_we->internal_error(N_("Got to end of arglist before end of replay!"));
+ yasm_internal_error(N_("Got to end of arglist before end of replay!"));
}
replay = SLIST_FIRST(&replay_head);
if (replay || param)
- cur_we->internal_error(N_("Count and distribution of define args mismatched!"));
+ yasm_internal_error(N_("Count and distribution of define args mismatched!"));
/* the param_table is set up without errors, so expansion is ready
* to go */
}
}
else
- cur_we->internal_error(N_("Invoking Macros not yet supported"));
+ yasm_internal_error(N_("Invoking Macros not yet supported"));
ym->expanding = 0;
}
append_token(token, &source_head, &source_tail);
/*if (append_to_return()==0) state=YAPP_STATE_EOF;*/
ydebug(("YAPP: default: '%c' \"%s\"\n", token, yapp_preproc_lval.str_val));
- /*cur_we->error(cur_lindex, N_("YAPP got an unhandled token."));*/
+ /*yasm__error(cur_lindex, N_("YAPP got an unhandled token."));*/
break;
case IDENT:
case CLEAR:
HAMT_delete(macro_table, (void (*)(void *))yapp_macro_delete);
- macro_table = HAMT_new(cur_we->internal_error_);
+ macro_table = HAMT_new(yasm_internal_error_);
break;
case DEFINE:
break;
}
else if (last_token == ',' || token != ',')
- cur_we->error(cur_lindex, N_("Unexpected token in %%define parameters"));
+ yasm__error(cur_lindex, N_("Unexpected token in %%define parameters"));
last_token = token;
}
if (token == ')') {
append_token('\n', &source_head, &source_tail);
}
else {
- cur_we->internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident"));
+ yasm_internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident"));
}
break;
}
break;
default:
- cur_we->error(cur_lindex, N_("YAPP got into a bad state"));
+ yasm__error(cur_lindex, N_("YAPP got into a bad state"));
}
if (need_line_directive) {
append_token(LINE, &source_head, &source_tail);
void set_inhibit(void);
extern /*@dependent@*/ yasm_linemgr *yapp_preproc_linemgr;
-extern /*@dependent@*/ yasm_errwarn *yapp_preproc_errwarn;
#define cur_lindex (yapp_preproc_linemgr->get_current())
-#define cur_we yapp_preproc_errwarn
}
if(inch == '\n')
- cur_we->error(cur_lindex, _("unterminated string"));
+ yasm__error(cur_lindex, _("unterminated string"));
else if(inch == EOF)
- cur_we->error(cur_lindex, _("unexpected end of file in string"));
+ yasm__error(cur_lindex, _("unexpected end of file in string"));
strbuf[count] = '\0';
/* FIXME: handle includes that aren't relative */
incfile = fopen (yytext, "r");
if(!incfile) {
- cur_we->error(cur_lindex, _("include file `%s': %s"),
- yytext, strerror(errno));
+ yasm__error(cur_lindex, _("include file `%s': %s"),
+ yytext, strerror(errno));
xfree(inc);
}
else {
[][+*/,()-] { return yytext[0]; }
<inhibit>. {
- cur_we->warning(YASM_WARN_PREPROC, cur_lindex, _("Unhandled character in <inhibit> `%s'"), cur_we->conv_unprint(yytext[0]));
+ yasm__warning(YASM_WARN_PREPROC, cur_lindex, _("Unhandled character in <inhibit> `%s'"), yasm__conv_unprint(yytext[0]));
}
. {
- cur_we->warning(YASM_WARN_PREPROC, cur_lindex, _("ignoring unrecognized character `%s'"),
- cur_we->conv_unprint(yytext[0]));
+ yasm__warning(YASM_WARN_PREPROC, cur_lindex, _("ignoring unrecognized character `%s'"),
+ yasm__conv_unprint(yytext[0]));
}
%%
src/xmalloc.c \
src/xstrdup.c \
src/strcasecmp.c
+libyasm_la_LDFLAGS = -no-undefined
yasm_SOURCES += \
src/main.c \
/* keyword used to select architecture */
const char *keyword;
- void (*initialize) (yasm_errwarn *we);
+ void (*initialize) (void);
void (*cleanup) (void);
struct {
unsigned char yasm_x86_LTX_mode_bits = 0;
-/*@dependent@*/ yasm_errwarn *yasm_x86__errwarn;
static void
-x86_initialize(yasm_errwarn *we)
+x86_initialize(void)
{
- yasm_x86__errwarn = we;
}
static void
(lval == 16 || lval == 32 || lval == 64))
yasm_x86_LTX_mode_bits = (unsigned char)lval;
else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "BITS");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "BITS");
return 0;
} else
return 1;
case X86_FPUREG:
return 10;
default:
- cur_we->internal_error(N_("unknown register size"));
+ yasm_internal_error(N_("unknown register size"));
}
return 0;
}
fprintf(f, "st%d", (int)(reg&0xF));
break;
default:
- cur_we->internal_error(N_("unknown register size"));
+ yasm_internal_error(N_("unknown register size"));
}
}
yasm_bytecode *yasm_x86__bc_new_jmprel(x86_new_jmprel_data *d);
extern unsigned char yasm_x86_LTX_mode_bits;
-extern /*@dependent@*/ yasm_errwarn *yasm_x86__errwarn;
-#define cur_we yasm_x86__errwarn
void yasm_x86__bc_delete(yasm_bytecode *bc);
void yasm_x86__bc_print(FILE *f, int indent_level, const yasm_bytecode *bc);
jmprel->op_sel = d->op_sel;
if ((d->op_sel == JR_SHORT_FORCED) && (d->near_op_len == 0))
- cur_we->error(d->lindex,
- N_("no SHORT form of that jump instruction exists"));
+ yasm__error(d->lindex,
+ N_("no SHORT form of that jump instruction exists"));
if ((d->op_sel == JR_NEAR_FORCED) && (d->short_op_len == 0))
- cur_we->error(d->lindex,
- N_("no NEAR form of that jump instruction exists"));
+ yasm__error(d->lindex,
+ N_("no NEAR form of that jump instruction exists"));
jmprel->shortop.opcode[0] = d->short_op[0];
jmprel->shortop.opcode[1] = d->short_op[1];
return;
if (segment != 0 && x86_ea->segment != 0)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("multiple segment overrides, using leftmost"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("multiple segment overrides, using leftmost"));
x86_ea->segment = segment;
}
return NULL;
if ((x86_bytecode_type)bc->type != X86_BC_INSN)
- cur_we->internal_error(N_("Trying to get EA of non-instruction"));
+ yasm_internal_error(N_("Trying to get EA of non-instruction"));
return (yasm_effaddr *)(((x86_insn *)bc)->ea);
}
jmprel->opersize = opersize;
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("OperSize override applied to non-instruction"));
}
}
jmprel->addrsize = addrsize;
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("AddrSize override applied to non-instruction"));
}
}
lockrep_pre = &jmprel->lockrep_pre;
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("LockRep prefix applied to non-instruction"));
}
if (*lockrep_pre != 0)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("multiple LOCK or REP prefixes, using leftmost"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("multiple LOCK or REP prefixes, using leftmost"));
*lockrep_pre = prefix;
}
temp = yasm_expr_copy(jmprel->target);
num = yasm_expr_get_intnum(&temp, calc_bc_dist);
if (!num) {
- cur_we->error(bc->line,
+ yasm__error(bc->line,
N_("short jump target external or out of segment"));
yasm_expr_delete(temp);
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
yasm_expr_delete(temp);
/* does a short form exist? */
if (jmprel->shortop.opcode_len == 0) {
- cur_we->error(bc->line,
- N_("short jump does not exist"));
+ yasm__error(bc->line, N_("short jump does not exist"));
return YASM_BC_RESOLVE_ERROR |
YASM_BC_RESOLVE_UNKNOWN_LEN;
}
/* short displacement must fit in -128 <= rel <= +127 */
if (rel < -128 || rel > 127) {
- cur_we->error(bc->line, N_("short jump out of range"));
+ yasm__error(bc->line, N_("short jump out of range"));
return YASM_BC_RESOLVE_ERROR |
YASM_BC_RESOLVE_UNKNOWN_LEN;
}
jrshort = 0;
if (save) {
if (jmprel->nearop.opcode_len == 0) {
- cur_we->error(bc->line, N_("near jump does not exist"));
+ yasm__error(bc->line, N_("near jump does not exist"));
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
}
}
* it to actually be within short range).
*/
if (save) {
- cur_we->error(bc->line,
+ yasm__error(bc->line,
N_("short jump out of range (near jump does not exist)"));
return YASM_BC_RESOLVE_ERROR |
YASM_BC_RESOLVE_UNKNOWN_LEN;
jrshort = 0;
} else {
if (save) {
- cur_we->error(bc->line,
+ yasm__error(bc->line,
N_("short jump out of range (near jump does not exist)"));
return YASM_BC_RESOLVE_ERROR |
YASM_BC_RESOLVE_UNKNOWN_LEN;
default:
break;
}
- cur_we->internal_error(N_("Didn't handle bytecode type in x86 arch"));
+ yasm_internal_error(N_("Didn't handle bytecode type in x86 arch"));
/*@notreached@*/
return YASM_BC_RESOLVE_UNKNOWN_LEN;
}
YASM_WRITE_8(*bufp, 0x67);
if (insn->rex != 0 && insn->rex != 0xff) {
if (insn->mode_bits != 64)
- cur_we->internal_error(
+ yasm_internal_error(
N_("x86: got a REX prefix in non-64-bit mode"));
YASM_WRITE_8(*bufp, insn->rex);
}
if (ea) {
if (x86_ea->need_modrm) {
if (!x86_ea->valid_modrm)
- cur_we->internal_error(
- N_("invalid Mod/RM in x86 tobytes_insn"));
+ yasm_internal_error(N_("invalid Mod/RM in x86 tobytes_insn"));
YASM_WRITE_8(*bufp, x86_ea->modrm);
}
if (x86_ea->need_sib) {
if (!x86_ea->valid_sib)
- cur_we->internal_error(N_("invalid SIB in x86 tobytes_insn"));
+ yasm_internal_error(N_("invalid SIB in x86 tobytes_insn"));
YASM_WRITE_8(*bufp, x86_ea->sib);
}
&eat.sib, &eat.valid_sib,
&eat.need_sib, &insn->rex,
yasm_common_calc_bc_dist))
- cur_we->internal_error(N_("checkea failed"));
+ yasm_internal_error(N_("checkea failed"));
if (ea->disp) {
if (output_expr(&ea->disp, bufp, ea->len, *bufp-bufp_orig,
case JR_SHORT:
/* 1 byte relative displacement */
if (jmprel->shortop.opcode_len == 0)
- cur_we->internal_error(N_("short jump does not exist"));
+ yasm_internal_error(N_("short jump does not exist"));
/* Opcode */
for (i=0; i<jmprel->shortop.opcode_len; i++)
case JR_NEAR:
/* 2/4 byte relative displacement (depending on operand size) */
if (jmprel->nearop.opcode_len == 0) {
- cur_we->error(bc->line, N_("near jump does not exist"));
+ yasm__error(bc->line, N_("near jump does not exist"));
return 1;
}
return 1;
break;
default:
- cur_we->internal_error(N_("unrecognized relative jump op_sel"));
+ yasm_internal_error(N_("unrecognized relative jump op_sel"));
}
return 0;
}
if (rel) {
long val;
if (valsize != 1 && valsize != 2 && valsize != 4)
- cur_we->internal_error(
+ yasm_internal_error(
N_("tried to do PC-relative offset from invalid sized value"));
val = yasm_intnum_get_uint(intn);
val -= bc->len;
/* The reg expn *must* be EXPR_ADD at this point. Sanity check. */
if (e->terms[havereg_expr].type != YASM_EXPR_EXPR ||
e->terms[havereg_expr].data.expn->op != YASM_EXPR_ADD)
- cur_we->internal_error(N_("Register expression not ADD or EXPN"));
+ yasm_internal_error(N_("Register expression not ADD or EXPN"));
/* Iterate over each term in reg expn */
for (i=0; i<e->terms[havereg_expr].data.expn->numterms; i++) {
* Sanity check for EXPR_INT.
*/
if (e->terms[i].data.expn->terms[0].type != YASM_EXPR_REG)
- cur_we->internal_error(
+ yasm_internal_error(
N_("Register not found in reg expn"));
if (e->terms[i].data.expn->terms[1].type != YASM_EXPR_INT)
- cur_we->internal_error(
+ yasm_internal_error(
N_("Non-integer value in reg expn"));
reg = get_reg(&e->terms[i].data.expn->terms[0], ®num,
data);
*/
if (!yasm_intnum_check_size(intn, (size_t)wordsize, 0) &&
!yasm_intnum_check_size(intn, 1, 1)) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
case 2:
case 4:
if (wordsize != *displen) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid effective address (displacement size)"));
return 0;
}
break;
default:
/* we shouldn't ever get any other size! */
- cur_we->internal_error(N_("strange EA displacement size"));
+ yasm_internal_error(N_("strange EA displacement size"));
}
return 1;
* otherwise illegal. It's also illegal in non-64-bit mode.
*/
if (*n_modrm || *n_sib) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid effective address (displacement size)"));
return 0;
}
/* We can only do 64-bit addresses in 64-bit mode. */
if (*addrsize == 64 && bits != 64) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid effective address (64-bit in non-64-bit mode)"));
return 0;
}
calc_bc_dist)) {
case 0:
e = *ep;
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
case 1:
return 1;
*/
for (i=0; i<17; i++) {
if (reg3264mult[i] < 0) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
if (i != indexreg && reg3264mult[i] == 1 &&
*/
for (i=0; i<17; i++)
if (i != basereg && i != indexreg && reg3264mult[i] != 0) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
if (indexreg != REG3264_NONE && reg3264mult[indexreg] != 1 &&
reg3264mult[indexreg] != 2 && reg3264mult[indexreg] != 4 &&
reg3264mult[indexreg] != 8) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
* legal.
*/
if (reg3264mult[REG3264_ESP] > 1 || basereg == REG3264_ESP) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
/* If mult==1 and basereg is not ESP, swap indexreg w/basereg. */
/* RIP is only legal if it's the ONLY register used. */
if (indexreg == REG64_RIP ||
(basereg == REG64_RIP && indexreg != REG3264_NONE)) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
*/
if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
bits, X86_REX_B)) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid combination of operands and effective address"));
return 0;
}
else {
if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
bits, X86_REX_B)) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid combination of operands and effective address"));
return 0;
}
if (yasm_x86__set_rex_from_reg(rex, &low3,
X86_REG64 | indexreg, bits,
X86_REX_X)) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid combination of operands and effective address"));
return 0;
}
/* 64-bit mode does not allow 16-bit addresses */
if (bits == 64) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("16-bit addresses not supported in 64-bit mode"));
return 0;
}
calc_bc_dist)) {
case 0:
e = *ep;
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
case 1:
return 1;
/* reg multipliers not 0 or 1 are illegal. */
if (reg16mult.bx & ~1 || reg16mult.si & ~1 || reg16mult.di & ~1 ||
reg16mult.bp & ~1) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
/* Check the modrm value for invalid combinations. */
if (modrm16[havereg] & 0070) {
- cur_we->error(e->line, N_("invalid effective address"));
+ yasm__error(e->line, N_("invalid effective address"));
return 0;
}
switch (*addrsize) {
case 64:
if (bits != 64) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("invalid effective address (64-bit in non-64-bit mode)"));
return 0;
}
case 16:
/* 64-bit mode does not allow 16-bit addresses */
if (bits == 64) {
- cur_we->error(e->line,
+ yasm__error(e->line,
N_("16-bit addresses not supported in 64-bit mode"));
return 0;
}
int fltret;
if (!yasm_floatnum_check_size(flt, (size_t)valsize)) {
- cur_we->error(e->line, N_("invalid floating point constant size"));
+ yasm__error(e->line, N_("invalid floating point constant size"));
return 1;
}
fltret = yasm_floatnum_get_sized(flt, *bufp, (size_t)valsize);
if (fltret < 0) {
- cur_we->error(e->line, N_("underflow in floating point expression"));
+ yasm__error(e->line, N_("underflow in floating point expression"));
return 1;
}
if (fltret > 0) {
- cur_we->error(e->line, N_("overflow in floating point expression"));
+ yasm__error(e->line, N_("overflow in floating point expression"));
return 1;
}
*bufp += valsize;
/* We know the target is in operand 0, but sanity check for Imm. */
op = yasm_ops_first(operands);
if (op->type != YASM_INSN__OPERAND_IMM)
- cur_we->internal_error(N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
d.target = yasm_expr_new(YASM_EXPR_SUB, yasm_expr_expr(op->data.val),
yasm_expr_sym(yasm_symrec_define_label("$", cur_section, prev_bc,
0, lindex)), lindex);
mismatch = 1;
break;
default:
- cur_we->internal_error(N_("invalid operand type"));
+ yasm_internal_error(N_("invalid operand type"));
}
if (mismatch)
mismatch = 1;
break;
default:
- cur_we->internal_error(N_("invalid target modifier type"));
+ yasm_internal_error(N_("invalid target modifier type"));
}
}
if (!found) {
/* Didn't find a matching one */
- cur_we->error(lindex,
- N_("invalid combination of opcode and operands"));
+ yasm__error(lindex, N_("invalid combination of opcode and operands"));
return NULL;
}
case MOD_ExtErr:
switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
case 0:
- cur_we->error(lindex, N_("mismatch in operand sizes"));
+ yasm__error(lindex, N_("mismatch in operand sizes"));
break;
case 1:
- cur_we->error(lindex, N_("operand size not specified"));
+ yasm__error(lindex, N_("operand size not specified"));
break;
default:
- cur_we->internal_error(
- N_("unrecognized x86 ext mod index"));
+ yasm_internal_error(N_("unrecognized x86 ext mod index"));
}
return NULL; /* It was an error */
case MOD_ExtWarn:
switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
default:
- cur_we->internal_error(
- N_("unrecognized x86 ext mod index"));
+ yasm_internal_error(N_("unrecognized x86 ext mod index"));
}
break;
default:
- cur_we->internal_error(N_("unrecognized x86 extended modifier"));
+ yasm_internal_error(N_("unrecognized x86 extended modifier"));
}
/* Shortcut to JmpRel */
yasm_x86_LTX_mode_bits);
break;
case YASM_INSN__OPERAND_SEGREG:
- cur_we->internal_error(
+ yasm_internal_error(
N_("invalid operand conversion"));
case YASM_INSN__OPERAND_MEMORY:
d.ea = op->data.ea;
d.im_len = size_lookup[(info->operands[i] &
OPS_MASK)>>OPS_SHIFT];
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_SImm:
if (op->type == YASM_INSN__OPERAND_IMM) {
OPS_MASK)>>OPS_SHIFT];
d.im_sign = 1;
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_Spare:
if (op->type == YASM_INSN__OPERAND_SEGREG)
if (yasm_x86__set_rex_from_reg(&d.rex, &d.spare,
op->data.reg, yasm_x86_LTX_mode_bits,
X86_REX_R)) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("invalid combination of opcode and operands"));
return NULL;
}
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_Op0Add:
if (op->type == YASM_INSN__OPERAND_REG) {
if (yasm_x86__set_rex_from_reg(&d.rex, &opadd,
op->data.reg, yasm_x86_LTX_mode_bits,
X86_REX_B)) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("invalid combination of opcode and operands"));
return NULL;
}
d.op[0] += opadd;
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_Op1Add:
/* Op1Add is only used for FPU, so no need to do REX */
if (op->type == YASM_INSN__OPERAND_REG)
d.op[1] += (unsigned char)(op->data.reg&7);
else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
case OPA_SpareEA:
if (op->type == YASM_INSN__OPERAND_REG) {
yasm_x86__set_rex_from_reg(&d.rex, &d.spare,
op->data.reg, yasm_x86_LTX_mode_bits,
X86_REX_R)) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("invalid combination of opcode and operands"));
if (d.ea)
xfree(d.ea);
return NULL;
}
} else
- cur_we->internal_error(
- N_("invalid operand conversion"));
+ yasm_internal_error(N_("invalid operand conversion"));
break;
default:
- cur_we->internal_error(N_("unknown operand action"));
+ yasm_internal_error(N_("unknown operand action"));
}
switch (info->operands[i] & OPAP_MASK) {
d.signext_imm8_op = 1;
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("unknown operand postponed action"));
}
}
/* catchalls */
[\001-\377]+ {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("unrecognized CPU identifier `%s'"), id);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("unrecognized CPU identifier `%s'"), id);
return;
}
[\000] {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("unrecognized CPU identifier `%s'"), id);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("unrecognized CPU identifier `%s'"), id);
return;
}
*/
}
O "64" {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a prefix in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a prefix in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_OPERSIZE;
/* address size overrides */
A "16" {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("Cannot override address size to 16 bits in 64-bit mode"));
return YASM_ARCH_CHECK_ID_NONE;
}
}
A "64" {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a prefix in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a prefix in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_ADDRSIZE;
/* control, debug, and test registers */
C R [02-48] {
if (yasm_x86_LTX_mode_bits != 64 && oid[2] == '8') {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_CRREG | (oid[2]-'0');
X M M [0-9] {
if (yasm_x86_LTX_mode_bits != 64 &&
(oid[3] == '8' || oid[3] == '9')) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_XMMREG | (oid[3]-'0');
}
X M M "1" [0-5] {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | (10+oid[4]-'0');
/* integer registers */
R A X {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 0;
}
R C X {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 1;
}
R D X {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 2;
}
R B X {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 3;
}
R S P {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 4;
}
R B P {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 5;
}
R S I {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 6;
}
R D I {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | 7;
}
R [8-9] {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | (oid[1]-'0');
}
R "1" [0-5] {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG64 | (10+oid[2]-'0');
E D I { data[0] = X86_REG32 | 7; return YASM_ARCH_CHECK_ID_REG; }
R [8-9] D {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG32 | (oid[1]-'0');
}
R "1" [0-5] D {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG32 | (10+oid[2]-'0');
D I { data[0] = X86_REG16 | 7; return YASM_ARCH_CHECK_ID_REG; }
R [8-9] W {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG16 | (oid[1]-'0');
}
R "1" [0-5] W {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG16 | (10+oid[2]-'0');
B H { data[0] = X86_REG8 | 7; return YASM_ARCH_CHECK_ID_REG; }
S P L {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8X | 4;
}
B P L {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8X | 5;
}
S I L {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8X | 6;
}
D I L {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8X | 7;
}
R [8-9] B {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8 | (oid[1]-'0');
}
R "1" [0-5] B {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_REG8 | (10+oid[2]-'0');
/* segment registers */
E S {
if (yasm_x86_LTX_mode_bits == 64)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("`%s' segment register ignored in 64-bit mode"), oid);
data[0] = 0x2600;
return YASM_ARCH_CHECK_ID_SEGREG;
C S { data[0] = 0x2e01; return YASM_ARCH_CHECK_ID_SEGREG; }
S S {
if (yasm_x86_LTX_mode_bits == 64)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("`%s' segment register ignored in 64-bit mode"), oid);
data[0] = 0x3602;
return YASM_ARCH_CHECK_ID_SEGREG;
}
D S {
if (yasm_x86_LTX_mode_bits == 64)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("`%s' segment register ignored in 64-bit mode"), oid);
data[0] = 0x3e03;
return YASM_ARCH_CHECK_ID_SEGREG;
/* RIP for 64-bit mode IP-relative offsets */
R I P {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is a register in 64-bit mode"), oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is a register in 64-bit mode"), oid);
return YASM_ARCH_CHECK_ID_NONE;
}
data[0] = X86_RIP;
M O V S X { RET_INSN(movszx, 0xBE, CPU_386); }
M O V S X D {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(movsxd, 0, CPU_Hammer|CPU_64);
P U S H { RET_INSN(push, 0, CPU_Any); }
P U S H A {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x0060, CPU_186);
}
P U S H A D {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x2060, CPU_386);
}
P U S H A W {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x1060, CPU_186);
P O P { RET_INSN(pop, 0, CPU_Any); }
P O P A {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x0061, CPU_186);
}
P O P A D {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x2061, CPU_386);
}
P O P A W {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x1061, CPU_186);
/* Load segment registers from memory */
L D S {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(ldes, 0xC5, CPU_Any);
}
L E S {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(ldes, 0xC4, CPU_Any);
C M C { RET_INSN(onebyte, 0x00F5, CPU_Any); }
L A H F {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x009F, CPU_Any);
}
S A H F {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x009E, CPU_Any);
P U S H F W { RET_INSN(onebyte, 0x109C, CPU_Any); }
P U S H F Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x409C, CPU_Hammer|CPU_64);
P O P F W { RET_INSN(onebyte, 0x109D, CPU_Any); }
P O P F Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x409D, CPU_Hammer|CPU_64);
N O T { RET_INSN(f6, 0x02, CPU_Any); }
A A A {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x0037, CPU_Any);
}
A A S {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x003F, CPU_Any);
}
D A A {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x0027, CPU_Any);
}
D A S {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x002F, CPU_Any);
}
A A D {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(aadm, 0x01, CPU_Any);
}
A A M {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(aadm, 0x00, CPU_Any);
C W D E { RET_INSN(onebyte, 0x2098, CPU_386); }
C D Q E {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x4098, CPU_Hammer|CPU_64);
C D Q { RET_INSN(onebyte, 0x2099, CPU_386); }
C D O {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x4099, CPU_Hammer|CPU_64);
J E C X Z { RET_INSN(jcxz, 32, CPU_386); }
J R C X Z {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(jcxz, 64, CPU_Hammer|CPU_64);
C M P S D { RET_INSN(cmpsd, 0, CPU_Any); }
C M P S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40A7, CPU_Hammer|CPU_64);
L O D S D { RET_INSN(onebyte, 0x20AD, CPU_386); }
L O D S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40AD, CPU_Hammer|CPU_64);
M O V S D { RET_INSN(movsd, 0, CPU_Any); }
M O V S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40A5, CPU_Any);
S C A S D { RET_INSN(onebyte, 0x20AF, CPU_386); }
S C A S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40AF, CPU_Hammer|CPU_64);
S T O S D { RET_INSN(onebyte, 0x20AB, CPU_386); }
S T O S Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40AB, CPU_Hammer|CPU_64);
I N T "03" { RET_INSN(onebyte, 0x00CC, CPU_Any); }
I N T O {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x00CE, CPU_Any);
I R E T D { RET_INSN(onebyte, 0x20CF, CPU_386); }
I R E T Q {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(onebyte, 0x40CF, CPU_Hammer|CPU_64);
R S M { RET_INSN(twobyte, 0x0FAA, CPU_586|CPU_SMM); }
B O U N D {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(bound, 0, CPU_186);
/* Protection control */
A R P L {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(arpl, 0, CPU_286|CPU_Prot);
/* Pentium II/Pentium Pro extensions */
S Y S E N T E R {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(twobyte, 0x0F34, CPU_686);
}
S Y S E X I T {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(twobyte, 0x0F35, CPU_686|CPU_Priv);
/* AMD x86-64 extensions */
S W A P G S {
if (yasm_x86_LTX_mode_bits != 64) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("`%s' is an instruction in 64-bit mode"),
- oid);
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("`%s' is an instruction in 64-bit mode"),
+ oid);
return YASM_ARCH_CHECK_ID_NONE;
}
RET_INSN(threebyte, 0x0F01F8, CPU_Hammer|CPU_64);
L O A D A L L "286" { RET_INSN(twobyte, 0x0F05, CPU_286|CPU_Undoc); }
S A L C {
if (yasm_x86_LTX_mode_bits == 64) {
- cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
+ yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
RET_INSN(not64, 0, CPU_Not64);
}
RET_INSN(onebyte, 0x00D6, CPU_Undoc);
unsigned char bytes_static[16];
/*@dependent@*/ static yasm_arch *cur_arch;
-/*@dependent@*/ static yasm_errwarn *cur_we;
void
-yasm_bc_initialize(yasm_arch *a, yasm_errwarn *we)
+yasm_bc_initialize(yasm_arch *a)
{
cur_arch = a;
- cur_we = we;
}
yasm_immval *
objfmt_data->of->bc_objfmt_data_delete(objfmt_data->type,
objfmt_data->data);
else
- cur_we->internal_error(
+ yasm_internal_error(
N_("objfmt can't handle its own objfmt data bytecode"));
break;
default:
if (bc->type < cur_arch->bc.type_max)
cur_arch->bc.bc_delete(bc);
else
- cur_we->internal_error(N_("Unknown bytecode type"));
+ yasm_internal_error(N_("Unknown bytecode type"));
break;
}
/*@=branchstate@*/
* the circular reference error to filter through.
*/
if (temp && yasm_expr__contains(temp, YASM_EXPR_FLOAT))
- cur_we->error(line,
+ yasm__error(line,
N_("expression must not contain floating point value"));
else
- cur_we->error(line,
+ yasm__error(line,
N_("attempt to reserve non-constant quantity of space"));
retval = YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
} else
/* Open file and determine its length */
f = fopen(incbin->filename, "rb");
if (!f) {
- cur_we->error(line, N_("`incbin': unable to open file `%s'"),
- incbin->filename);
+ yasm__error(line, N_("`incbin': unable to open file `%s'"),
+ incbin->filename);
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
}
if (fseek(f, 0L, SEEK_END) < 0) {
- cur_we->error(line, N_("`incbin': unable to seek on file `%s'"),
- incbin->filename);
+ yasm__error(line, N_("`incbin': unable to seek on file `%s'"),
+ incbin->filename);
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
}
flen = (unsigned long)ftell(f);
/* Compute length of incbin from start, maxlen, and len */
if (start > flen) {
- cur_we->warning(YASM_WARN_GENERAL, line,
- N_("`incbin': start past end of file `%s'"),
- incbin->filename);
+ yasm__warning(YASM_WARN_GENERAL, line,
+ N_("`incbin': start past end of file `%s'"),
+ incbin->filename);
start = flen;
}
flen -= start;
switch (bc->type) {
case YASM_BC__EMPTY:
- cur_we->internal_error(N_("got empty bytecode in bc_calc_len"));
+ yasm_internal_error(N_("got empty bytecode in bc_calc_len"));
/*break;*/
case YASM_BC__DATA:
retval = bc_resolve_data((bytecode_data *)bc, &bc->len);
break;
case YASM_BC__ALIGN:
/* TODO */
- cur_we->internal_error(
- N_("TODO: align bytecode not implemented!"));
+ yasm_internal_error(N_("TODO: align bytecode not implemented!"));
/*break;*/
case YASM_BC__OBJFMT_DATA:
- cur_we->internal_error(N_("resolving objfmt data bytecode?"));
+ yasm_internal_error(N_("resolving objfmt data bytecode?"));
/*break;*/
default:
if (bc->type < cur_arch->bc.type_max)
retval = cur_arch->bc.bc_resolve(bc, save, sect,
calc_bc_dist);
else
- cur_we->internal_error(N_("Unknown bytecode type"));
+ yasm_internal_error(N_("Unknown bytecode type"));
}
/* Multiply len by number of multiples */
if (!num) {
retval = YASM_BC_RESOLVE_UNKNOWN_LEN;
if (temp && yasm_expr__contains(temp, YASM_EXPR_FLOAT)) {
- cur_we->error(bc->line,
+ yasm__error(bc->line,
N_("expression must not contain floating point value"));
retval |= YASM_BC_RESOLVE_ERROR;
}
if (incbin->start) {
num = yasm_expr_get_intnum(&incbin->start, NULL);
if (!num)
- cur_we->internal_error(
+ yasm_internal_error(
N_("could not determine start in bc_tobytes_incbin"));
start = yasm_intnum_get_uint(num);
}
/* Open file */
f = fopen(incbin->filename, "rb");
if (!f) {
- cur_we->error(line, N_("`incbin': unable to open file `%s'"),
- incbin->filename);
+ yasm__error(line, N_("`incbin': unable to open file `%s'"),
+ incbin->filename);
return 1;
}
/* Seek to start of data */
if (fseek(f, (long)start, SEEK_SET) < 0) {
- cur_we->error(line, N_("`incbin': unable to seek on file `%s'"),
- incbin->filename);
+ yasm__error(line, N_("`incbin': unable to seek on file `%s'"),
+ incbin->filename);
fclose(f);
return 1;
}
/* Read len bytes */
if (fread(*bufp, (size_t)len, 1, f) < (size_t)len) {
- cur_we->error(line,
- N_("`incbin': unable to read %lu bytes from file `%s'"),
- len, incbin->filename);
+ yasm__error(line,
+ N_("`incbin': unable to read %lu bytes from file `%s'"),
+ len, incbin->filename);
fclose(f);
return 1;
}
if (bc->multiple) {
num = yasm_expr_get_intnum(&bc->multiple, NULL);
if (!num)
- cur_we->internal_error(
+ yasm_internal_error(
N_("could not determine multiple in bc_tobytes"));
*multiple = yasm_intnum_get_uint(num);
if (*multiple == 0) {
switch (bc->type) {
case YASM_BC__EMPTY:
- cur_we->internal_error(N_("got empty bytecode in bc_tobytes"));
+ yasm_internal_error(N_("got empty bytecode in bc_tobytes"));
/*break;*/
case YASM_BC__DATA:
error = bc_tobytes_data((bytecode_data *)bc, &destbuf, sect, bc, d,
break;
case YASM_BC__ALIGN:
/* TODO */
- cur_we->internal_error(
- N_("TODO: align bytecode not implemented!"));
+ yasm_internal_error(N_("TODO: align bytecode not implemented!"));
/*break;*/
case YASM_BC__OBJFMT_DATA:
objfmt_data = (bytecode_objfmt_data *)bc;
error = output_bc_objfmt_data(objfmt_data->type,
objfmt_data->data, &destbuf);
else
- cur_we->internal_error(
+ yasm_internal_error(
N_("Have objfmt data bytecode but no way to output it"));
break;
default:
error = cur_arch->bc.bc_tobytes(bc, &destbuf, sect, d,
output_expr);
else
- cur_we->internal_error(N_("Unknown bytecode type"));
+ yasm_internal_error(N_("Unknown bytecode type"));
}
if (!error && ((unsigned long)(destbuf - origbuf) != datasize))
- cur_we->internal_error(
+ yasm_internal_error(
N_("written length does not match optimized length"));
return mybuf;
}
} yasm_bytecode_type;
#define YASM_BYTECODE_TYPE_BASE YASM_BC__OBJFMT_DATA+1
-void yasm_bc_initialize(yasm_arch *a, yasm_errwarn *we);
+void yasm_bc_initialize(yasm_arch *a);
/*@only@*/ yasm_immval *yasm_imm_new_int(unsigned long int_val,
unsigned long lindex);
typedef struct yasm_floatnum yasm_floatnum;
typedef struct yasm_linemgr yasm_linemgr;
-typedef struct yasm_errwarn yasm_errwarn;
typedef enum {
YASM_EXPR_ADD,
#define MSG_MAXSIZE 1024
+/* Default handlers for replacable functions */
+static /*@exits@*/ void def_internal_error_
+ (const char *file, unsigned int line, const char *message);
+static /*@exits@*/ void def_fatal(const char *message);
+static const char *def_gettext_hook(const char *msgid);
+
+/* Storage for errwarn's "extern" functions */
+/*@exits@*/ void (*yasm_internal_error_)
+ (const char *file, unsigned int line, const char *message)
+ = def_internal_error_;
+/*@exits@*/ void (*yasm_fatal) (const char *message) = def_fatal;
+const char * (*yasm_gettext_hook) (const char *msgid) = def_gettext_hook;
+
/* Enabled warnings. See errwarn.h for a list. */
static unsigned long warn_class_enabled;
/* Total warning count */
static unsigned int warning_count;
-/* See errwarn.h for constants that match up to these strings.
- * When adding a string here, keep errwarn.h in sync!
- */
-
-/* Fatal error messages. Match up with fatal_num enum in errwarn.h. */
-/*@-observertrans@*/
-static const char *fatal_msgs[] = {
- N_("unknown"),
- N_("out of memory")
-};
-/*@=observertrans@*/
-
typedef /*@reldef@*/ SLIST_HEAD(errwarndatahead_s, errwarn_data)
errwarndatahead;
static /*@only@*/ /*@null@*/ errwarndatahead errwarns;
static char unprint[5];
-static void
-yasm_std_errwarn_initialize(void)
+static const char *
+def_gettext_hook(const char *msgid)
+{
+ return msgid;
+}
+
+void
+yasm_errwarn_initialize(void)
{
/* Default enabled warnings. See errwarn.h for a list. */
warn_class_enabled =
previous_we = NULL;
}
-static void
-yasm_std_errwarn_cleanup(void)
+void
+yasm_errwarn_cleanup(void)
{
errwarn_data *we;
/* Convert a possibly unprintable character into a printable string, using
* standard cat(1) convention for unprintable characters.
*/
-static char *
-yasm_std_errwarn_conv_unprint(char ch)
+char *
+yasm__conv_unprint(char ch)
{
int pos = 0;
* Exit immediately because it's essentially an assert() trap.
*/
static void
-yasm_std_errwarn_internal_error_(const char *file, unsigned int line,
- const char *message)
+def_internal_error_(const char *file, unsigned int line, const char *message)
{
- fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
- gettext(message));
+ fprintf(stderr,
+ yasm_gettext_hook(N_("INTERNAL ERROR at %s, line %u: %s\n")),
+ file, line, yasm_gettext_hook(message));
#ifdef HAVE_ABORT
abort();
#else
* memory), so just exit immediately.
*/
static void
-yasm_std_errwarn_fatal(yasm_fatal_cause num)
+def_fatal(const char *message)
{
- fprintf(stderr, _("FATAL: %s\n"), gettext(fatal_msgs[num]));
+ fprintf(stderr, yasm_gettext_hook(N_("FATAL: %s\n")),
+ yasm_gettext_hook(message));
#ifdef HAVE_ABORT
abort();
#else
assert(ins_we != NULL);
SLIST_INSERT_AFTER(ins_we, we, link);
} else
- yasm_std_errwarn_internal_error_(__FILE__, __LINE__,
- N_("Unexpected errwarn insert action"));
+ yasm_internal_error(N_("Unexpected errwarn insert action"));
}
/* Remember previous err/warn */
/* Register an error at line lindex. Does not print the error, only stores it
* for output_all() to print.
*/
-static void
-yasm_std_errwarn_error_va(unsigned long lindex, const char *fmt, va_list va)
+void
+yasm__error_va(unsigned long lindex, const char *fmt, va_list va)
{
errwarn_data *we = errwarn_data_new(lindex, 1);
we->type = WE_ERROR;
#ifdef HAVE_VSNPRINTF
- vsnprintf(we->msg, MSG_MAXSIZE, gettext(fmt), va);
+ vsnprintf(we->msg, MSG_MAXSIZE, yasm_gettext_hook(fmt), va);
#else
- vsprintf(we->msg, gettext(fmt), va);
+ vsprintf(we->msg, yasm_gettext_hook(fmt), va);
#endif
error_count++;
/* Register an warning at line lindex. Does not print the warning, only stores
* it for output_all() to print.
*/
-static void
-yasm_std_errwarn_warning_va(yasm_warn_class num, unsigned long lindex,
- const char *fmt, va_list va)
+void
+yasm__warning_va(yasm_warn_class num, unsigned long lindex, const char *fmt,
+ va_list va)
{
errwarn_data *we;
we->type = WE_WARNING;
#ifdef HAVE_VSNPRINTF
- vsnprintf(we->msg, MSG_MAXSIZE, gettext(fmt), va);
+ vsnprintf(we->msg, MSG_MAXSIZE, yasm_gettext_hook(fmt), va);
#else
- vsprintf(we->msg, gettext(fmt), va);
+ vsprintf(we->msg, yasm_gettext_hook(fmt), va);
#endif
warning_count++;
/* Register an error at line lindex. Does not print the error, only stores it
* for output_all() to print.
*/
-static void
-yasm_std_errwarn_error(unsigned long lindex, const char *fmt, ...)
+void
+yasm__error(unsigned long lindex, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
- yasm_std_errwarn_error_va(lindex, fmt, va);
+ yasm__error_va(lindex, fmt, va);
va_end(va);
}
/* Register an warning at line lindex. Does not print the warning, only stores
* it for output_all() to print.
*/
-static void
-yasm_std_errwarn_warning(yasm_warn_class num, unsigned long lindex,
- const char *fmt, ...)
+void
+yasm__warning(yasm_warn_class num, unsigned long lindex, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
- yasm_std_errwarn_warning_va(num, lindex, fmt, va);
+ yasm__warning_va(num, lindex, fmt, va);
va_end(va);
}
/* Parser error handler. Moves YACC-style error into our error handling
* system.
*/
-static void
-yasm_std_errwarn_parser_error(unsigned long lindex, const char *s)
+void
+yasm__parser_error(unsigned long lindex, const char *s)
{
- yasm_std_errwarn_error(lindex, N_("parser error: %s"), s);
+ yasm__error(lindex, N_("parser error: %s"), s);
previous_we->type = WE_PARSERERROR;
}
-static void
-yasm_std_errwarn_warn_enable(yasm_warn_class num)
+void
+yasm_warn_enable(yasm_warn_class num)
{
warn_class_enabled |= (1UL<<num);
}
-static void
-yasm_std_errwarn_warn_disable(yasm_warn_class num)
+void
+yasm_warn_disable(yasm_warn_class num)
{
warn_class_enabled &= ~(1UL<<num);
}
-static void
-yasm_std_errwarn_warn_disable_all(void)
+void
+yasm_warn_disable_all(void)
{
warn_class_enabled = 0;
}
-/* Get the number of errors (including warnings if warnings are being treated
- * as errors).
- */
-static unsigned int
-yasm_std_errwarn_get_num_errors(int warning_as_error)
+unsigned int
+yasm_get_num_errors(int warning_as_error)
{
if (warning_as_error)
return error_count+warning_count;
return error_count;
}
-/* Output all previously stored errors and warnings to stderr. */
-static void
-yasm_std_errwarn_output_all(yasm_linemgr *lm, int warning_as_error)
+void
+yasm_errwarn_output_all(yasm_linemgr *lm, int warning_as_error,
+ void (*print_error) (const char *fn, unsigned long line, const char *msg),
+ void (*print_warning) (const char *fn, unsigned long line,
+ const char *msg))
{
errwarn_data *we;
const char *filename;
/* If we're treating warnings as errors, tell the user about it. */
if (warning_as_error && warning_as_error != 2) {
- fprintf(stderr, "%s\n", _("warnings being treated as errors"));
+ print_error("", 0,
+ yasm_gettext_hook(N_("warnings being treated as errors")));
warning_as_error = 2;
}
/* Output error/warning */
lm->lookup(we->line, &filename, &line);
if (we->type == WE_ERROR)
- fprintf(stderr, "%s:%lu: %s\n", filename, line, we->msg);
+ print_error(filename, line, we->msg);
else
- fprintf(stderr, "%s:%lu: %s %s\n", filename, line, _("warning:"),
- we->msg);
+ print_warning(filename, line, we->msg);
}
}
-
-yasm_errwarn yasm_std_errwarn = {
- yasm_std_errwarn_initialize,
- yasm_std_errwarn_cleanup,
- yasm_std_errwarn_internal_error_,
- yasm_std_errwarn_fatal,
- yasm_std_errwarn_error_va,
- yasm_std_errwarn_warning_va,
- yasm_std_errwarn_error,
- yasm_std_errwarn_warning,
- yasm_std_errwarn_parser_error,
- yasm_std_errwarn_warn_enable,
- yasm_std_errwarn_warn_disable,
- yasm_std_errwarn_warn_disable_all,
- yasm_std_errwarn_get_num_errors,
- yasm_std_errwarn_output_all,
- yasm_std_errwarn_conv_unprint
-};
YASM_WARN_PREPROC /* preprocessor warnings */
} yasm_warn_class;
-/* Fatal error constants.
- * See fatal_msgs in errwarn.c for strings that match up to these constants.
- * When adding a constant here, keep errwarn.c in sync!
- */
-typedef enum {
- YASM_FATAL_UNKNOWN = 0,
- YASM_FATAL_NOMEM
-} yasm_fatal_cause;
+/* Initialize any internal data structures. */
+void yasm_errwarn_initialize(void);
-struct yasm_errwarn {
- /* Initialize any internal data structures. */
- void (*initialize) (void);
+/* Cleans up any memory allocated by initialize or other functions. */
+void yasm_errwarn_cleanup(void);
- /* Cleans up any memory allocated by initialize or other functions. */
- void (*cleanup) (void);
-
- /* Reporting point of internal errors. These are usually due to sanity
- * check failures in the code.
- * This function must NOT return to calling code. Either exit or longjmp.
- */
- /*@exits@*/ void (*internal_error_) (const char *file, unsigned int line,
- const char *message);
-#define internal_error(msg) internal_error_(__FILE__, __LINE__, msg)
+/* Reporting point of internal errors. These are usually due to sanity
+ * check failures in the code.
+ * This function must NOT return to calling code. Either exit or longjmp.
+ */
+extern /*@exits@*/ void (*yasm_internal_error_)
+ (const char *file, unsigned int line, const char *message);
+#define yasm_internal_error(msg) \
+ yasm_internal_error_(__FILE__, __LINE__, msg)
- /* Reporting point of fatal errors.
- * This function must NOT return to calling code. Either exit or longjmp.
- */
- /*@exits@*/ void (*fatal) (yasm_fatal_cause);
+/* Reporting point of fatal errors.
+ * This function must NOT return to calling code. Either exit or longjmp.
+ */
+extern /*@exits@*/ void (*yasm_fatal) (const char *message);
- /* va_list versions of the below two functions */
- void (*error_va) (unsigned long lindex, const char *, va_list va);
- void (*warning_va) (yasm_warn_class, unsigned long lindex, const char *,
- va_list va);
+/* va_list versions of the below two functions */
+void yasm__error_va(unsigned long lindex, const char *, va_list va);
+void yasm__warning_va(yasm_warn_class, unsigned long lindex, const char *,
+ va_list va);
- void (*error) (unsigned long lindex, const char *, ...) /*@printflike@*/;
- void (*warning) (yasm_warn_class, unsigned long lindex, const char *, ...)
- /*@printflike@*/;
+void yasm__error(unsigned long lindex, const char *, ...) /*@printflike@*/;
+void yasm__warning(yasm_warn_class, unsigned long lindex, const char *, ...)
+ /*@printflike@*/;
- /* Logs a parser error. These can be overwritten by non-parser errors on
- * the same line.
- */
- void (*parser_error) (unsigned long lindex, const char *);
+/* Logs a parser error. These can be overwritten by non-parser errors on
+ * the same line.
+ */
+void yasm__parser_error(unsigned long lindex, const char *);
- /* Enables/disables a class of warnings. */
- void (*warn_enable) (yasm_warn_class);
- void (*warn_disable) (yasm_warn_class);
- void (*warn_disable_all) (void);
+/* Enables/disables a class of warnings. */
+void yasm_warn_enable(yasm_warn_class);
+void yasm_warn_disable(yasm_warn_class);
+void yasm_warn_disable_all(void);
- /* Returns total number of errors logged to this point.
- * If warning_as_error is nonzero, warnings are treated as errors.
- */
- unsigned int (*get_num_errors) (int warning_as_error);
+/* Returns total number of errors logged to this point.
+ * If warning_as_error is nonzero, warnings are treated as errors.
+ */
+unsigned int yasm_get_num_errors(int warning_as_error);
- /* Outputs all errors/warnings (e.g. to stderr or elsewhere). */
- void (*output_all) (yasm_linemgr *lm, int warning_as_error);
+/* Outputs all errors/warnings by calling print_error and print_warning. */
+void yasm_errwarn_output_all
+ (yasm_linemgr *lm, int warning_as_error,
+ void (*print_error) (const char *fn, unsigned long line, const char *msg),
+ void (*print_warning) (const char *fn, unsigned long line,
+ const char *msg));
- /* Convert a possibly unprintable character into a printable string. */
- char * (*conv_unprint) (char ch);
-};
+/* Convert a possibly unprintable character into a printable string. */
+char *yasm__conv_unprint(char ch);
-extern yasm_errwarn yasm_std_errwarn;
+/* Map to gettext() if gettext is being used. */
+extern const char * (*yasm_gettext_hook) (const char *msgid);
#endif
/*@null@*/ void *d));
static /*@dependent@*/ yasm_arch *cur_arch;
-static /*@dependent@*/ yasm_errwarn *cur_we;
void
-yasm_expr_initialize(yasm_arch *a, yasm_errwarn *we)
+yasm_expr_initialize(yasm_arch *a)
{
cur_arch = a;
- cur_we = we;
}
/* allocate a new expression node, with children as defined.
/*@=usereleased@*/
}
} else {
- cur_we->internal_error(N_("Right side of expression must exist"));
+ yasm_internal_error(N_("Right side of expression must exist"));
}
if (right) {
/* Check for circular reference */
SLIST_FOREACH(np, eh, next) {
if (np->e == equ_expr) {
- cur_we->error(e->line,
- N_("circular reference detected."));
+ yasm__error(e->line,
+ N_("circular reference detected."));
return e;
}
}
typedef struct yasm_expr__item yasm_expr__item;
-void yasm_expr_initialize(yasm_arch *a, yasm_errwarn *we);
+void yasm_expr_initialize(yasm_arch *a);
/*@only@*/ yasm_expr *yasm_expr_new(yasm_expr_op, /*@only@*/ yasm_expr__item *,
/*@only@*/ /*@null@*/ yasm_expr__item *,
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80},0x7fff}, /* 1e+0 */
};
-static /*@dependent@*/ yasm_errwarn *cur_we;
-
static void
POT_Table_Init_Entry(/*@out@*/ POT_Entry *e, POT_Entry_Source *s, int dec_exp)
/*@-compdef@*/
void
-yasm_floatnum_initialize(yasm_errwarn *we)
+yasm_floatnum_initialize(void)
/*@globals undef POT_TableN, undef POT_TableP, POT_TableP_Source,
POT_TableN_Source @*/
{
int dec_exp = 1;
int i;
- cur_we = we;
-
/* Allocate space for two POT tables */
POT_TableN = xmalloc(14*sizeof(POT_Entry));
POT_TableP = xmalloc(15*sizeof(POT_Entry)); /* note 1 extra for -1 */
/*@unused@*/ yasm_floatnum *operand, unsigned long lindex)
{
if (op != YASM_EXPR_NEG)
- cur_we->error(lindex,
- N_("Unsupported floating-point arithmetic operation"));
+ yasm__error(lindex,
+ N_("Unsupported floating-point arithmetic operation"));
else
acc->sign ^= 1;
}
/* underflow and overflow both set!? */
if (underflow && overflow)
- cur_we->internal_error(N_("Both underflow and overflow set"));
+ yasm_internal_error(N_("Both underflow and overflow set"));
/* check for underflow or overflow and set up appropriate output */
if (underflow) {
/* get little-endian bytes */
buf = BitVector_Block_Read(output, &len);
if (len < byte_size)
- cur_we->internal_error(
+ yasm_internal_error(
N_("Byte length of BitVector does not match bit length"));
/* copy to output */
case 10:
return floatnum_get_common(flt, ptr, 10, 64, 0, 15);
default:
- cur_we->internal_error(N_("Invalid float conversion size"));
+ yasm_internal_error(N_("Invalid float conversion size"));
/*@notreached@*/
return 1; /* never reached, but silence GCC warning */
}
#ifndef YASM_FLOATNUM_H
#define YASM_FLOATNUM_H
-void yasm_floatnum_initialize(yasm_errwarn *we);
+void yasm_floatnum_initialize(void);
/* Clean up internal allocations */
void yasm_floatnum_cleanup(void);
/* static bitvect used for conversions */
static /*@only@*/ wordptr conv_bv;
-static /*@dependent@*/ yasm_errwarn *cur_we;
void
-yasm_intnum_initialize(yasm_errwarn *we)
+yasm_intnum_initialize(void)
{
- cur_we = we;
-
conv_bv = BitVector_Create(BITVECT_ALLOC_SIZE, FALSE);
BitVector_from_Dec_static_Boot(BITVECT_ALLOC_SIZE);
}
if (BitVector_from_Dec_static(conv_bv,
(unsigned char *)str) == ErrCode_Ovfl)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("Numeric constant too large for internal format"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Numeric constant too large for internal format"));
if (Set_Max(conv_bv) < 32) {
intn->type = INTNUM_UL;
intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0);
intn->origsize = (unsigned char)strlen(str);
if(intn->origsize > BITVECT_ALLOC_SIZE)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("Numeric constant too large for internal format"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Numeric constant too large for internal format"));
BitVector_from_Bin(conv_bv, (unsigned char *)str);
if (Set_Max(conv_bv) < 32) {
intn->origsize = strlen(str)*3;
if(intn->origsize > BITVECT_ALLOC_SIZE)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("Numeric constant too large for internal format"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Numeric constant too large for internal format"));
BitVector_from_Oct(conv_bv, (unsigned char *)str);
if (Set_Max(conv_bv) < 32) {
intn->origsize = strlen(str)*4;
if(intn->origsize > BITVECT_ALLOC_SIZE)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("Numeric constant too large for internal format"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Numeric constant too large for internal format"));
BitVector_from_Hex(conv_bv, (unsigned char *)str);
if (Set_Max(conv_bv) < 32) {
size_t len = strlen(str);
if (len > 4)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("character constant too large, ignoring trailing characters"));
intn->val.ul = 0;
if (!operand && op != YASM_EXPR_NEG && op != YASM_EXPR_NOT &&
op != YASM_EXPR_LNOT)
- cur_we->internal_error(N_("Operation needs an operand"));
+ yasm_internal_error(N_("Operation needs an operand"));
/* A operation does a bitvector computation if result is allocated. */
switch (op) {
BitVector_Copy(result, op1);
break;
default:
- cur_we->internal_error(
- N_("invalid operation in intnum calculation"));
+ yasm_internal_error(N_("invalid operation in intnum calculation"));
}
/* If we were doing a bitvector computation... */
case INTNUM_BV:
return BitVector_Chunk_Read(intn->val.bv, 32, 0);
default:
- cur_we->internal_error(N_("unknown intnum type"));
+ yasm_internal_error(N_("unknown intnum type"));
/*@notreached@*/
return 0;
}
} else
return (long)BitVector_Chunk_Read(intn->val.bv, 32, 0);
default:
- cur_we->internal_error(N_("unknown intnum type"));
+ yasm_internal_error(N_("unknown intnum type"));
/*@notreached@*/
return 0;
}
case INTNUM_BV:
buf = BitVector_Block_Read(intn->val.bv, &len);
if (len < (unsigned int)size)
- cur_we->internal_error(
- N_("Invalid size specified (too large)"));
+ yasm_internal_error(N_("Invalid size specified (too large)"));
memcpy(ptr, buf, size);
xfree(buf);
break;
#ifndef YASM_INTNUM_H
#define YASM_INTNUM_H
-void yasm_intnum_initialize(yasm_errwarn *we);
+void yasm_intnum_initialize(void);
/* Clean up internal allocations */
void yasm_intnum_cleanup(void);
#include "hamt.h"
+#include "errwarn.h"
#include "linemgr.h"
-static /*@exits@*/ void (*efunc) (const char *file, unsigned int line,
- const char *message);
-
/* Source lines tracking */
typedef struct {
struct line_index_mapping *vector;
}
static void
-yasm_std_linemgr_initialize(/*@exits@*/
- void (*error_func) (const char *file,
- unsigned int line,
- const char *message))
+yasm_std_linemgr_initialize(void)
{
int i;
- filename_table = HAMT_new(error_func);
- efunc = error_func;
+ filename_table = HAMT_new(yasm_internal_error_);
line_index = 1;
adrh->vector[line_index-1] = data;
if (adrh->delete_func != delete_func)
- efunc(__FILE__, __LINE__,
- N_("multiple deletion functions specified"));
+ yasm_internal_error(N_("multiple deletion functions specified"));
} else {
- efunc(__FILE__, __LINE__, N_("non-common data not supported yet"));
+ yasm_internal_error(N_("non-common data not supported yet"));
delete_func(data);
}
}
struct yasm_linemgr {
/* Initialize cur_lindex and any manager internal data structures. */
- void (*initialize) (/*@exits@*/
- void (*error_func) (const char *file,
- unsigned int line,
- const char *message));
+ void (*initialize) (void);
/* Cleans up any memory allocated. */
void (*cleanup) (void);
const char *ext, const char *def);
static void print_error(const char *fmt, ...);
+static /*@exits@*/ void handle_yasm_int_error(const char *file,
+ unsigned int line,
+ const char *message);
+static /*@exits@*/ void handle_yasm_fatal(const char *message);
+static const char *handle_yasm_gettext(const char *msgid);
+static void print_yasm_error(const char *filename, unsigned long line,
+ const char *msg);
+static void print_yasm_warning(const char *filename, unsigned long line,
+ const char *msg);
+
/* values for special_options */
#define SPECIAL_SHOW_HELP 0x01
#define SPECIAL_SHOW_VERSION 0x02
textdomain(PACKAGE);
/* Initialize errwarn handling */
- yasm_std_errwarn.initialize();
-
- /* Initialize memory allocation */
- xalloc_initialize((void (*) (int))yasm_std_errwarn.fatal,
- YASM_FATAL_NOMEM);
+ yasm_internal_error_ = handle_yasm_int_error;
+ yasm_fatal = handle_yasm_fatal;
+ yasm_gettext_hook = handle_yasm_gettext;
+ yasm_errwarn_initialize();
/* Set libltdl malloc/free functions. */
#ifdef WITH_DMALLOC
}
/* Initialize line manager */
- yasm_std_linemgr.initialize(yasm_std_errwarn.internal_error_);
+ yasm_std_linemgr.initialize();
yasm_std_linemgr.set(in_filename, 1, 1);
/* Initialize intnum and floatnum */
- yasm_intnum_initialize(&yasm_std_errwarn);
- yasm_floatnum_initialize(&yasm_std_errwarn);
+ yasm_intnum_initialize();
+ yasm_floatnum_initialize();
/* Initialize symbol table */
- yasm_symrec_initialize(&yasm_std_errwarn);
+ yasm_symrec_initialize();
/* handle preproc-only case here */
if (preproc_only) {
}
/* Pre-process until done */
- cur_preproc->initialize(in, in_filename, &yasm_std_linemgr,
- &yasm_std_errwarn);
+ cur_preproc->initialize(in, in_filename, &yasm_std_linemgr);
while ((got = cur_preproc->input(preproc_buf, PREPROC_BUF_SIZE)) != 0)
fwrite(preproc_buf, got, 1, obj);
if (obj != stdout)
fclose(obj);
- if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ if (yasm_get_num_errors(warning_error) > 0) {
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
if (obj != stdout)
remove(obj_filename);
xfree(preproc_buf);
return EXIT_FAILURE;
}
- cur_arch->initialize(&yasm_std_errwarn);
+ cur_arch->initialize();
/* Set basic as the optimizer (TODO: user choice) */
cur_optimizer = load_optimizer("basic");
}
yasm_arch_common_initialize(cur_arch);
- yasm_expr_initialize(cur_arch, &yasm_std_errwarn);
- yasm_bc_initialize(cur_arch, &yasm_std_errwarn);
+ yasm_expr_initialize(cur_arch);
+ yasm_bc_initialize(cur_arch);
/* If not already specified, default to bin as the object format. */
if (!cur_objfmt)
/* Initialize the object format */
if (cur_objfmt->initialize)
cur_objfmt->initialize(in_filename, obj_filename, cur_dbgfmt,
- cur_arch, &yasm_std_errwarn);
+ cur_arch);
/* Set NASM as the parser */
cur_parser = load_parser("nasm");
/* Parse! */
sections = cur_parser->do_parse(cur_preproc, cur_arch, cur_objfmt,
- &yasm_std_linemgr, &yasm_std_errwarn, in,
- in_filename, 0);
+ &yasm_std_linemgr, in, in_filename, 0);
/* Close input file */
if (in != stdin)
fclose(in);
- if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ if (yasm_get_num_errors(warning_error) > 0) {
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
cleanup(sections);
return EXIT_FAILURE;
}
yasm_symrec_parser_finalize();
- cur_optimizer->optimize(sections, &yasm_std_errwarn);
+ cur_optimizer->optimize(sections);
- if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ if (yasm_get_num_errors(warning_error) > 0) {
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
cleanup(sections);
return EXIT_FAILURE;
}
/* If we had an error at this point, we also need to delete the output
* object file (to make sure it's not left newer than the source).
*/
- if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ if (yasm_get_num_errors(warning_error) > 0) {
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
remove(obj_filename);
cleanup(sections);
return EXIT_FAILURE;
}
- yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
+ yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
+ print_yasm_error, print_yasm_warning);
cleanup(sections);
return EXIT_SUCCESS;
yasm_floatnum_cleanup();
yasm_intnum_cleanup();
- yasm_std_errwarn.cleanup();
+ yasm_errwarn_cleanup();
yasm_std_linemgr.cleanup();
BitVector_Shutdown();
if (extra == 1) {
/* -w, disable warnings */
- yasm_std_errwarn.warn_disable_all();
+ yasm_warn_disable_all();
return 0;
}
warning_error = enable;
} else if (strcmp(cmd, "unrecognized-char") == 0) {
if (enable)
- yasm_std_errwarn.warn_enable(YASM_WARN_UNREC_CHAR);
+ yasm_warn_enable(YASM_WARN_UNREC_CHAR);
else
- yasm_std_errwarn.warn_disable(YASM_WARN_UNREC_CHAR);
+ yasm_warn_disable(YASM_WARN_UNREC_CHAR);
} else
return 1;
va_end(va);
fputc('\n', stderr);
}
+
+static /*@exits@*/ void
+handle_yasm_int_error(const char *file, unsigned int line, const char *message)
+{
+ fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
+ gettext(message));
+#ifdef HAVE_ABORT
+ abort();
+#else
+ exit(EXIT_FAILURE);
+#endif
+}
+
+static /*@exits@*/ void
+handle_yasm_fatal(const char *message)
+{
+ fprintf(stderr, _("FATAL: %s\n"), gettext(message));
+#ifdef HAVE_ABORT
+ abort();
+#else
+ exit(EXIT_FAILURE);
+#endif
+}
+
+static const char *
+handle_yasm_gettext(const char *msgid)
+{
+ return gettext(msgid);
+}
+
+static void
+print_yasm_error(const char *filename, unsigned long line, const char *msg)
+{
+ fprintf(stderr, "%s:%lu: %s\n", filename, line, msg);
+}
+
+static void
+print_yasm_warning(const char *filename, unsigned long line, const char *msg)
+{
+ fprintf(stderr, "%s:%lu: %s %s\n", filename, line, _("warning:"), msg);
+}
* provided solely for informational purposes.
*/
void (*initialize) (const char *in_filename, const char *obj_filename,
- yasm_dbgfmt *df, yasm_arch *a, yasm_errwarn *we);
+ yasm_dbgfmt *df, yasm_arch *a);
/* Write out (post-optimized) sections to the object file.
* This function may call symrec functions as necessary (including
yasm_objfmt yasm_bin_LTX_objfmt;
static /*@dependent@*/ yasm_arch *cur_arch;
-static /*@dependent@*/ yasm_errwarn *cur_we;
static void
bin_objfmt_initialize(/*@unused@*/ const char *in_filename,
/*@unused@*/ const char *obj_filename,
- /*@unused@*/ yasm_dbgfmt *df, yasm_arch *a,
- yasm_errwarn *we)
+ /*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
{
cur_arch = a;
- cur_we = we;
}
/* Aligns sect to either its specified alignment (in its objfmt-specific data)
/* Check for complex float expressions */
if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
- cur_we->error((*ep)->line,
- N_("floating point expression too complex"));
+ yasm__error((*ep)->line, N_("floating point expression too complex"));
return 1;
}
/* Couldn't output, assume it contains an external reference. */
- cur_we->error((*ep)->line,
+ yasm__error((*ep)->line,
N_("binary object format does not support external references"));
return 1;
}
/* Warn that gaps are converted to 0 and write out the 0's. */
if (gap) {
unsigned long left;
- cur_we->warning(YASM_WARN_GENERAL, bc->line,
+ yasm__warning(YASM_WARN_GENERAL, bc->line,
N_("uninitialized space declared in code/data section: zeroing"));
/* Write out in chunks */
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
bss = yasm_sections_find_general(sections, ".bss");
if (!text)
- cur_we->internal_error(N_("No `.text' section in bin objfmt output"));
+ yasm_internal_error(N_("No `.text' section in bin objfmt output"));
/* First determine the actual starting offsets for .data and .bss.
* As the order in the file is .text -> .data -> .bss (not present),
assert(startexpr != NULL);
startnum = yasm_expr_get_intnum(&startexpr, NULL);
if (!startnum)
- cur_we->internal_error(
- N_("Complex expr for start in bin objfmt output"));
+ yasm_internal_error(N_("Complex expr for start in bin objfmt output"));
start = yasm_intnum_get_uint(startnum);
yasm_expr_delete(startexpr);
textstart = start;
resonly = 1;
} else {
/* other section names not recognized. */
- cur_we->error(lindex, N_("segment name `%s' not recognized"),
- sectname);
+ yasm__error(lindex, N_("segment name `%s' not recognized"),
+ sectname);
return NULL;
}
unsigned long bitcnt;
if (strcmp(sectname, ".text") == 0) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("cannot specify an alignment to the `%s' section"),
sectname);
return NULL;
align = yasm_expr_get_intnum(&vp->param, NULL);
if (!align) {
- cur_we->error(lindex,
- N_("argument to `%s' is not a power of two"),
- vp->val);
+ yasm__error(lindex,
+ N_("argument to `%s' is not a power of two"),
+ vp->val);
return NULL;
}
alignval = yasm_intnum_get_uint(align);
*/
BitCount(bitcnt, alignval);
if (bitcnt > 1) {
- cur_we->error(lindex,
- N_("argument to `%s' is not a power of two"),
- vp->val);
+ yasm__error(lindex,
+ N_("argument to `%s' is not a power of two"),
+ vp->val);
return NULL;
}
}
retval = yasm_sections_switch_general(headp, sectname, start, resonly,
- &isnew, lindex,
- cur_we->internal_error_);
+ &isnew, lindex);
if (isnew) {
if (have_alignval) {
yasm_symrec_define_label(sectname, retval, (yasm_bytecode *)NULL,
1, lindex);
} else if (have_alignval)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("alignment value ignored on section redeclaration"));
return retval;
unsigned long lindex)
{
yasm_expr_delete(size);
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("binary object format does not support common variables"));
}
/* ORG takes just a simple integer as param */
vp = yasm_vps_first(valparams);
if (vp->val) {
- cur_we->error(lindex, N_("argument to ORG should be numeric"));
+ yasm__error(lindex, N_("argument to ORG should be numeric"));
return 0;
} else if (vp->param)
start = yasm_expr_get_intnum(&vp->param, NULL);
if (!start) {
- cur_we->error(lindex, N_("argument to ORG should be numeric"));
+ yasm__error(lindex, N_("argument to ORG should be numeric"));
return 0;
}
/* ORG changes the start of the .text section */
sect = yasm_sections_find_general(headp, ".text");
if (!sect)
- cur_we->internal_error(
+ yasm_internal_error(
N_("bin objfmt: .text section does not exist before ORG is called?"));
yasm_section_set_start(sect, yasm_intnum_get_uint(start), lindex);
yasm_objfmt yasm_coff_LTX_objfmt;
static /*@dependent@*/ yasm_arch *cur_arch;
-static /*@dependent@*/ yasm_errwarn *cur_we;
static /*@dependent@*/ coff_symtab_entry *
coff_symtab_entry *entry;
if (STAILQ_EMPTY(&coff_symtab))
- cur_we->internal_error(N_("empty COFF symbol table"));
+ yasm_internal_error(N_("empty COFF symbol table"));
entry = STAILQ_LAST(&coff_symtab, coff_symtab_entry, link);
sym_data_prev = yasm_symrec_get_of_data(entry->sym);
assert(sym_data_prev != NULL);
static void
coff_objfmt_initialize(const char *in_filename,
/*@unused@*/ const char *obj_filename,
- /*@unused@*/ yasm_dbgfmt *df, yasm_arch *a,
- yasm_errwarn *we)
+ /*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
{
yasm_symrec *filesym;
coff_symrec_data *data;
coff_symtab_entry *entry;
cur_arch = a;
- cur_we = we;
coff_objfmt_parse_scnum = 1; /* section numbering starts at 1 */
STAILQ_INIT(&coff_symtab);
yasm_sym_vis vis;
if (valsize != 4) {
- cur_we->error((*ep)->line, N_("coff: invalid relocation size"));
+ yasm__error((*ep)->line, N_("coff: invalid relocation size"));
return 1;
}
/* Check for complex float expressions */
if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
- cur_we->error((*ep)->line,
- N_("floating point expression too complex"));
+ yasm__error((*ep)->line, N_("floating point expression too complex"));
return 1;
}
- cur_we->error((*ep)->line, N_("coff: relocation too complex"));
+ yasm__error((*ep)->line, N_("coff: relocation too complex"));
return 1;
}
/* Warn that gaps are converted to 0 and write out the 0's. */
if (gap) {
unsigned long left;
- cur_we->warning(YASM_WARN_GENERAL, bc->line,
+ yasm__warning(YASM_WARN_GENERAL, bc->line,
N_("uninitialized space declared in code/data section: zeroing"));
/* Write out in chunks */
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
} else {
pos = ftell(info->f);
if (pos == -1) {
- cur_we->error(0, N_("could not get file position on output file"));
+ yasm__error(0, N_("could not get file position on output file"));
return 1;
}
pos = ftell(info->f);
if (pos == -1) {
- cur_we->error(0, N_("could not get file position on output file"));
+ yasm__error(0, N_("could not get file position on output file"));
return 1;
}
csd->relptr = (unsigned long)pos;
csymd = yasm_symrec_get_of_data(reloc->sym);
if (!csymd)
- cur_we->internal_error(
+ yasm_internal_error(
N_("coff: no symbol data for relocated symbol"));
YASM_WRITE_32_L(localbuf, reloc->addr); /* address of relocation */
YASM_WRITE_32_L(localbuf, csd->relptr); /* file ptr to relocs */
YASM_WRITE_32_L(localbuf, 0); /* file ptr to line nums */
if (csd->nreloc >= 64*1024) {
- cur_we->warning(YASM_WARN_GENERAL, 0,
- N_("too many relocations in section `%s'"),
- yasm_section_get_name(sect));
+ yasm__warning(YASM_WARN_GENERAL, 0,
+ N_("too many relocations in section `%s'"),
+ yasm_section_get_name(sect));
YASM_WRITE_16_L(localbuf, 0xFFFF); /* max out */
} else
YASM_WRITE_16_L(localbuf, csd->nreloc); /* num of relocation entries */
/* Allocate space for headers by seeking forward */
if (fseek(f, 20+40*(coff_objfmt_parse_scnum-1), SEEK_SET) < 0) {
- cur_we->error(0, N_("could not seek on output file"));
+ yasm__error(0, N_("could not seek on output file"));
return;
}
/* Symbol table */
pos = ftell(f);
if (pos == -1) {
- cur_we->error(0, N_("could not get file position on output file"));
+ yasm__error(0, N_("could not get file position on output file"));
return;
}
symtab_pos = (unsigned long)pos;
/* Get symrec's of_data (needed for storage class) */
csymd = yasm_symrec_get_of_data(entry->sym);
if (!csymd)
- cur_we->internal_error(
- N_("coff: expected sym data to be present"));
+ yasm_internal_error(N_("coff: expected sym data to be present"));
/* Look at symrec for value/scnum/etc. */
if (yasm_symrec_get_label(entry->sym, §, &precbc)) {
intn = yasm_expr_get_intnum(&csymd->size,
yasm_common_calc_bc_dist);
if (!intn)
- cur_we->error(csymd->size->line,
+ yasm__error(csymd->size->line,
N_("COMMON data size not an integer expression"));
else
value = yasm_intnum_get_uint(intn);
strncpy((char *)localbuf, entry->aux[0].fname, 14);
break;
default:
- cur_we->internal_error(
+ yasm_internal_error(
N_("coff: unrecognized aux symtab type"));
}
fwrite(info.buf, 18, 1, f);
/* Write headers */
if (fseek(f, 0, SEEK_SET) < 0) {
- cur_we->error(0, N_("could not seek on output file"));
+ yasm__error(0, N_("could not seek on output file"));
return;
}
sectname = vp->val;
if (strlen(sectname) > 8) {
- cur_we->warning(YASM_WARN_GENERAL, lindex,
+ yasm__warning(YASM_WARN_GENERAL, lindex,
N_("COFF section names limited to 8 characters: truncating"));
sectname[8] = '\0';
}
}
retval = yasm_sections_switch_general(headp, sectname, 0, resonly, &isnew,
- lindex, cur_we->internal_error_);
+ lindex);
if (isnew) {
coff_section_data *data;
COFF_SYMTAB_AUX_SECT);
data->sym = sym;
} else if (flags_override)
- cur_we->warning(YASM_WARN_GENERAL, lindex,
- N_("section flags ignored on section redeclaration"));
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("section flags ignored on section redeclaration"));
return retval;
}
*/
static FILE *dbg_objfmt_file;
-static /*@dependent@*/ yasm_errwarn *cur_we;
static void
dbg_objfmt_initialize(const char *in_filename, const char *obj_filename,
- yasm_dbgfmt *df, yasm_arch *a, yasm_errwarn *we)
+ yasm_dbgfmt *df, yasm_arch *a)
{
- cur_we = we;
-
dbg_objfmt_file = fopen(obj_filename, "wt");
if (!dbg_objfmt_file) {
fprintf(stderr, N_("could not open file `%s'"), obj_filename);
if ((vp = yasm_vps_first(valparams)) && !vp->param && vp->val != NULL) {
retval = yasm_sections_switch_general(headp, vp->val, 200, 0, &isnew,
- lindex, cur_we->internal_error_);
+ lindex);
if (isnew) {
fprintf(dbg_objfmt_file, "(new) ");
yasm_symrec_define_label(vp->val, retval, (yasm_bytecode *)NULL, 1,
* object file. (A failure is indicated by calling ErrorAt() from within
* this function).
*/
- void (*optimize) (yasm_sectionhead *sections, yasm_errwarn *we);
+ void (*optimize) (yasm_sectionhead *sections);
};
#endif
#define BCFLAG_INPROGRESS (1UL<<0)
#define BCFLAG_DONE (1UL<<1)
-static /*@dependent@*/ yasm_errwarn *cur_we;
static int basic_optimize_section_1(yasm_section *sect,
/*@unused@*/ /*@null@*/ void *d);
basic_optimize_calc_bc_dist_1);
if (bcr_retval & YASM_BC_RESOLVE_UNKNOWN_LEN) {
if (!(bcr_retval & YASM_BC_RESOLVE_ERROR))
- cur_we->error(bc->line, N_("circular reference detected."));
+ yasm__error(bc->line, N_("circular reference detected."));
data->saw_unknown = -1;
return 0;
}
assert(data != NULL);
if (bc->opt_flags != BCFLAG_DONE)
- cur_we->internal_error(N_("Optimizer pass 1 missed a bytecode!"));
+ yasm_internal_error(N_("Optimizer pass 1 missed a bytecode!"));
if (!data->precbc)
bc->offset = 0;
data.sect = sect;
if (yasm_section_get_opt_flags(sect) != SECTFLAG_DONE)
- cur_we->internal_error(N_("Optimizer pass 1 missed a section!"));
+ yasm_internal_error(N_("Optimizer pass 1 missed a section!"));
return yasm_bcs_traverse(yasm_section_get_bytecodes(sect), &data,
basic_optimize_bytecode_2);
}
static void
-basic_optimize(yasm_sectionhead *sections, yasm_errwarn *we)
+basic_optimize(yasm_sectionhead *sections)
{
int saw_unknown = 0;
- cur_we = we;
-
/* Optimization process: (essentially NASM's pass 1)
* Determine the size of all bytecodes.
* Forward references are /not/ resolved (only backward references are
*/
yasm_sectionhead *(*do_parse)
(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of, yasm_linemgr *lm,
- yasm_errwarn *we, FILE *f, const char *in_filename, int save_input);
+ FILE *f, const char *in_filename, int save_input);
};
#endif
$$ = (yasm_bytecode *)NULL;
}
| error '\n' {
- cur_we->error(cur_lindex,
- N_("label or instruction expected at start of line"));
+ yasm__error(cur_lindex,
+ N_("label or instruction expected at start of line"));
$$ = (yasm_bytecode *)NULL;
yyerrok;
}
yasm_ops_delete(&$2.operands, 0);
}
| INSN error {
- cur_we->error(cur_lindex, N_("expression syntax error"));
+ yasm__error(cur_lindex, N_("expression syntax error"));
$$ = NULL;
}
| PREFIX instr {
dataval: dvexpr { $$ = yasm_dv_new_expr($1); }
| STRING { $$ = yasm_dv_new_string($1); }
| error {
- cur_we->error(cur_lindex, N_("expression syntax error"));
+ yasm__error(cur_lindex, N_("expression syntax error"));
$$ = (yasm_dataval *)NULL;
}
;
xfree($1);
}
| DIRECTIVE_NAME error {
- cur_we->error(cur_lindex, N_("invalid arguments to [%s]"), $1);
+ yasm__error(cur_lindex, N_("invalid arguments to [%s]"), $1);
xfree($1);
}
;
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 1)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 1;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 2)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 2;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 4)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 4;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 8)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 8;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 10)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 10;
}
$$ = $2;
if ($$->type == YASM_INSN__OPERAND_REG &&
nasm_parser_arch->get_reg_size($$->data.reg) != 16)
- cur_we->error(cur_lindex, N_("cannot override register size"));
+ yasm__error(cur_lindex, N_("cannot override register size"));
else
$$->size = 16;
}
nasm_parser_objfmt->extern_declare(sym, objext_valparams,
lindex);
} else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "EXTERN");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "EXTERN");
} else if (yasm__strcasecmp(name, "global") == 0) {
vp = yasm_vps_first(valparams);
if (vp->val) {
nasm_parser_objfmt->global_declare(sym, objext_valparams,
lindex);
} else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "GLOBAL");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "GLOBAL");
} else if (yasm__strcasecmp(name, "common") == 0) {
vp = yasm_vps_first(valparams);
if (vp->val) {
vp2 = yasm_vps_next(vp);
if (!vp2 || (!vp2->val && !vp2->param))
- cur_we->error(lindex,
- N_("no size specified in %s declaration"),
- "COMMON");
+ yasm__error(lindex, N_("no size specified in %s declaration"),
+ "COMMON");
else {
if (vp2->val) {
sym = yasm_symrec_declare(vp->val, YASM_SYM_COMMON,
}
}
} else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "COMMON");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "COMMON");
} else if (yasm__strcasecmp(name, "section") == 0 ||
yasm__strcasecmp(name, "segment") == 0) {
yasm_section *new_section =
nasm_parser_prev_bc =
yasm_bcs_last(yasm_section_get_bytecodes(new_section));
} else
- cur_we->error(lindex, N_("invalid argument to [%s]"), "SECTION");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "SECTION");
} else if (yasm__strcasecmp(name, "absolute") == 0) {
/* it can be just an ID or a complete expression, so handle both. */
vp = yasm_vps_first(valparams);
nasm_parser_cur_section =
yasm_sections_switch_absolute(&nasm_parser_sections,
p_expr_new_ident(yasm_expr_sym(
- yasm_symrec_use(vp->val, lindex))),
- cur_we->internal_error_);
+ yasm_symrec_use(vp->val, lindex))));
else if (vp->param) {
nasm_parser_cur_section =
- yasm_sections_switch_absolute(&nasm_parser_sections, vp->param,
- cur_we->internal_error_);
+ yasm_sections_switch_absolute(&nasm_parser_sections,
+ vp->param);
vp->param = NULL;
}
nasm_parser_prev_bc = (yasm_bytecode *)NULL;
const yasm_intnum *intcpu;
intcpu = yasm_expr_get_intnum(&vp->param, NULL);
if (!intcpu)
- cur_we->error(lindex, N_("invalid argument to [%s]"),
- "CPU");
+ yasm__error(lindex, N_("invalid argument to [%s]"), "CPU");
else {
char strcpu[16];
sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu));
;
} else if (nasm_parser_objfmt->directive(name, valparams, objext_valparams,
&nasm_parser_sections, lindex)) {
- cur_we->error(lindex, N_("unrecognized directive [%s]"), name);
+ yasm__error(lindex, N_("unrecognized directive [%s]"), name);
}
yasm_vps_delete(valparams);
static void
nasm_parser_error(const char *s)
{
- cur_we->parser_error(cur_lindex, s);
+ yasm__parser_error(cur_lindex, s);
}
/*@dependent@*/ yasm_arch *nasm_parser_arch;
/*@dependent@*/ yasm_objfmt *nasm_parser_objfmt;
/*@dependent@*/ yasm_linemgr *nasm_parser_linemgr;
-/*@dependent@*/ yasm_errwarn *nasm_parser_errwarn;
int nasm_parser_save_input;
static /*@dependent@*/ yasm_sectionhead *
nasm_parser_do_parse(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of,
- yasm_linemgr *lm, yasm_errwarn *we, FILE *f,
- const char *in_filename, int save_input)
+ yasm_linemgr *lm, FILE *f, const char *in_filename,
+ int save_input)
/*@globals killed nasm_parser_locallabel_base @*/
{
- pp->initialize(f, in_filename, lm, we);
+ pp->initialize(f, in_filename, lm);
nasm_parser_in = f;
nasm_parser_input = pp->input;
nasm_parser_arch = a;
nasm_parser_objfmt = of;
nasm_parser_linemgr = lm;
- nasm_parser_errwarn = we;
nasm_parser_save_input = save_input;
/* Initialize section list */
extern /*@dependent@*/ yasm_arch *nasm_parser_arch;
extern /*@dependent@*/ yasm_objfmt *nasm_parser_objfmt;
extern /*@dependent@*/ yasm_linemgr *nasm_parser_linemgr;
-extern /*@dependent@*/ yasm_errwarn *nasm_parser_errwarn;
extern int nasm_parser_save_input;
#define p_expr_new_branch(o,r) yasm_expr_new_branch(o,r,cur_lindex)
#define p_expr_new_ident(r) yasm_expr_new_ident(r,cur_lindex)
-#define cur_we nasm_parser_errwarn
-
#endif
yylval.str_val = xstrndup(s.tok, TOKLEN);
RETURN(ID);
} else if (!nasm_parser_locallabel_base) {
- cur_we->warning(YASM_WARN_GENERAL, cur_lindex,
- N_("no non-local label before `%s'"),
- s.tok[0]);
+ yasm__warning(YASM_WARN_GENERAL, cur_lindex,
+ N_("no non-local label before `%s'"), s.tok[0]);
yylval.str_val = xstrndup(s.tok, TOKLEN);
} else {
len = TOKLEN + nasm_parser_locallabel_base_len;
case YASM_ARCH_CHECK_ID_TARGETMOD:
RETURN(TARGETMOD);
default:
- cur_we->warning(YASM_WARN_GENERAL, cur_lindex,
+ yasm__warning(YASM_WARN_GENERAL, cur_lindex,
N_("Arch feature not supported, treating as identifier"));
yylval.str_val = xstrndup(s.tok, TOKLEN);
RETURN(ID);
}
any {
- cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
- N_("ignoring unrecognized character `%s'"),
- cur_we->conv_unprint(s.tok[0]));
+ yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
+ N_("ignoring unrecognized character `%s'"),
+ yasm__conv_unprint(s.tok[0]));
goto scan;
}
*/
}
any {
- cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
- N_("ignoring unrecognized character `%s'"),
- cur_we->conv_unprint(s.tok[0]));
+ yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
+ N_("ignoring unrecognized character `%s'"),
+ yasm__conv_unprint(s.tok[0]));
goto linechg;
}
*/
}
any {
- cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
- N_("ignoring unrecognized character `%s'"),
- cur_we->conv_unprint(s.tok[0]));
+ yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
+ N_("ignoring unrecognized character `%s'"),
+ yasm__conv_unprint(s.tok[0]));
goto directive;
}
*/
/*!re2c
"\n" {
if (cursor == s.eof)
- cur_we->error(cur_lindex,
- N_("unexpected end of file in string"));
+ yasm__error(cur_lindex,
+ N_("unexpected end of file in string"));
else
- cur_we->error(cur_lindex, N_("unterminated string"));
+ yasm__error(cur_lindex, N_("unterminated string"));
strbuf[count] = '\0';
yylval.str_val = strbuf;
if (nasm_parser_save_input && cursor != s.eof)
* This function also takes the FILE * to the initial starting file and
* the filename.
*/
- void (*initialize) (FILE *f, const char *in_filename, yasm_linemgr *lm,
- yasm_errwarn *we);
+ void (*initialize) (FILE *f, const char *in_filename, yasm_linemgr *lm);
/* Cleans up any allocated memory. */
void (*cleanup) (void);
static FILE *in;
static yasm_linemgr *cur_lm;
-static yasm_errwarn *cur_we;
static char *line, *linepos;
static size_t lineleft;
static char *file_name;
va_start(va, fmt);
switch (severity & ERR_MASK) {
case ERR_WARNING:
- cur_we->warning_va(YASM_WARN_PREPROC, cur_lm->get_current(), fmt,
- va);
+ yasm__warning_va(YASM_WARN_PREPROC, cur_lm->get_current(), fmt,
+ va);
break;
case ERR_NONFATAL:
- cur_we->error_va(cur_lm->get_current(), fmt, va);
+ yasm__error_va(cur_lm->get_current(), fmt, va);
break;
case ERR_FATAL:
- cur_we->fatal(YASM_FATAL_UNKNOWN); /* FIXME */
+ yasm_fatal(N_("unknown")); /* FIXME */
break;
case ERR_PANIC:
- cur_we->internal_error(fmt); /* FIXME */
+ yasm_internal_error(fmt); /* FIXME */
break;
case ERR_DEBUG:
break;
}
static void
-nasm_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
- yasm_errwarn *we)
+nasm_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
{
in = f;
cur_lm = lm;
- cur_we = we;
line = NULL;
file_name = NULL;
prior_linnum = 0;
static int is_interactive;
static FILE *in;
static yasm_linemgr *cur_lm;
-static yasm_errwarn *cur_we;
int isatty(int);
static void
-raw_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
- yasm_errwarn *we)
+raw_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
{
in = f;
cur_lm = lm;
- cur_we = we;
/*@-unrecog@*/
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
/*@=unrecog@*/
if (c == '\n')
buf[n++] = (char)c;
if (c == EOF && ferror(in))
- cur_we->error(cur_lm->get_current(),
- N_("error when reading from file"));
+ yasm__error(cur_lm->get_current(),
+ N_("error when reading from file"));
} else if (((n = fread(buf, 1, max_size, in)) == 0) && ferror(in))
- cur_we->error(cur_lm->get_current(),
- N_("error when reading from file"));
+ yasm__error(cur_lm->get_current(), N_("error when reading from file"));
return n;
}
YYSTYPE yapp_preproc_lval;
/*@dependent@*/ yasm_linemgr *yapp_preproc_linemgr;
-/*@dependent@*/ yasm_errwarn *yapp_preproc_errwarn;
int isatty(int);
void
yapp_macro_error_exists (YAPP_Macro *v)
{
- if (v) cur_we->error(cur_lindex, N_("Redefining macro of the same name %d:%d"), v->type, v->args);
+ if (v) yasm__error(cur_lindex, N_("Redefining macro of the same name %d:%d"), v->type, v->args);
}
void
yapp_macro_error_sameargname (YAPP_Macro *v)
{
- if (v) cur_we->error(cur_lindex, N_("Duplicate argument names in macro"));
+ if (v) yasm__error(cur_lindex, N_("Duplicate argument names in macro"));
}
YAPP_Macro *
if ((argc >= 0 && ym->args < 0)
|| (argc < 0 && ym->args >= 0))
{
- cur_we->warning(YASM_WARN_PREPROC, cur_lindex, N_("Attempted %%define both with and without parameters"));
+ yasm__warning(YASM_WARN_PREPROC, cur_lindex, N_("Attempted %%define both with and without parameters"));
return NULL;
}
}
expand_token_list(struct source_head *paramexp, struct source_head *to_head, source **to_tail);
static void
-yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
- yasm_errwarn *we)
+yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
{
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
yapp_preproc_linemgr = lm;
- yapp_preproc_errwarn = we;
yapp_preproc_current_file = xstrdup(in_filename);
yapp_preproc_line_number = 1;
yapp_lex_initialize(f);
out->out = current_output = YAPP_OUTPUT;
SLIST_INSERT_HEAD(&output_head, out, next);
- macro_table = HAMT_new(we->internal_error_);
+ macro_table = HAMT_new(yasm_internal_error_);
source_tail = SLIST_FIRST(&source_head);
macro_tail = SLIST_FIRST(¯o_head);
while ((token = yapp_preproc_lex()) != '\n') {
if (token == 0)
return 0;
- cur_we->error(cur_lindex, N_("Skipping possibly valid %%define stuff"));
+ yasm__error(cur_lindex, N_("Skipping possibly valid %%define stuff"));
}
append_token('\n', to_head, to_tail);
return '\n';
if (token == WHITESPACE)
token = yapp_preproc_lex();
if (token != IDENT) {
- cur_we->error(cur_lindex, N_("Identifier expected after %%%s"), synlvl);
+ yasm__error(cur_lindex, N_("Identifier expected after %%%s"), synlvl);
}
return token;
}
ydebug(("YAPP: +Expand macro %s...\n", name));
- if (ym->expanding) cur_we->internal_error(N_("Recursively expanding a macro!"));
+ if (ym->expanding) yasm_internal_error(N_("Recursively expanding a macro!"));
if (ym->type == YAPP_DEFINE) {
if (ym->args == -1) {
/* find out what we got */
if (from_head) {
- cur_we->internal_error(N_("Expanding macro with non-null from_head ugh\n"));
+ yasm_internal_error(N_("Expanding macro with non-null from_head ugh\n"));
}
token = yapp_preproc_lex();
append_token(token, &replay_head, &replay_tail);
default:
if (token < 256)
- cur_we->internal_error(N_("Unexpected character token in parameter expansion"));
+ yasm_internal_error(N_("Unexpected character token in parameter expansion"));
else
- cur_we->error(cur_lindex, N_("Cannot handle preprocessor items inside possible macro invocation"));
+ yasm__error(cur_lindex, N_("Cannot handle preprocessor items inside possible macro invocation"));
}
}
ym->expanding = 1;
/* so the macro exists. build a HAMT parameter table */
- param_table = HAMT_new(cur_we->internal_error_);
+ param_table = HAMT_new(yasm_internal_error_);
/* fill the entries by walking the replay buffer and create
* "macros". coincidentally, clear the replay buffer. */
xfree(replay);
}
else if (param) {
- cur_we->internal_error(N_("Got to end of arglist before end of replay!"));
+ yasm_internal_error(N_("Got to end of arglist before end of replay!"));
}
replay = SLIST_FIRST(&replay_head);
if (replay || param)
- cur_we->internal_error(N_("Count and distribution of define args mismatched!"));
+ yasm_internal_error(N_("Count and distribution of define args mismatched!"));
/* the param_table is set up without errors, so expansion is ready
* to go */
}
}
else
- cur_we->internal_error(N_("Invoking Macros not yet supported"));
+ yasm_internal_error(N_("Invoking Macros not yet supported"));
ym->expanding = 0;
}
append_token(token, &source_head, &source_tail);
/*if (append_to_return()==0) state=YAPP_STATE_EOF;*/
ydebug(("YAPP: default: '%c' \"%s\"\n", token, yapp_preproc_lval.str_val));
- /*cur_we->error(cur_lindex, N_("YAPP got an unhandled token."));*/
+ /*yasm__error(cur_lindex, N_("YAPP got an unhandled token."));*/
break;
case IDENT:
case CLEAR:
HAMT_delete(macro_table, (void (*)(void *))yapp_macro_delete);
- macro_table = HAMT_new(cur_we->internal_error_);
+ macro_table = HAMT_new(yasm_internal_error_);
break;
case DEFINE:
break;
}
else if (last_token == ',' || token != ',')
- cur_we->error(cur_lindex, N_("Unexpected token in %%define parameters"));
+ yasm__error(cur_lindex, N_("Unexpected token in %%define parameters"));
last_token = token;
}
if (token == ')') {
append_token('\n', &source_head, &source_tail);
}
else {
- cur_we->internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident"));
+ yasm_internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident"));
}
break;
}
break;
default:
- cur_we->error(cur_lindex, N_("YAPP got into a bad state"));
+ yasm__error(cur_lindex, N_("YAPP got into a bad state"));
}
if (need_line_directive) {
append_token(LINE, &source_head, &source_tail);
void set_inhibit(void);
extern /*@dependent@*/ yasm_linemgr *yapp_preproc_linemgr;
-extern /*@dependent@*/ yasm_errwarn *yapp_preproc_errwarn;
#define cur_lindex (yapp_preproc_linemgr->get_current())
-#define cur_we yapp_preproc_errwarn
}
if(inch == '\n')
- cur_we->error(cur_lindex, _("unterminated string"));
+ yasm__error(cur_lindex, _("unterminated string"));
else if(inch == EOF)
- cur_we->error(cur_lindex, _("unexpected end of file in string"));
+ yasm__error(cur_lindex, _("unexpected end of file in string"));
strbuf[count] = '\0';
/* FIXME: handle includes that aren't relative */
incfile = fopen (yytext, "r");
if(!incfile) {
- cur_we->error(cur_lindex, _("include file `%s': %s"),
- yytext, strerror(errno));
+ yasm__error(cur_lindex, _("include file `%s': %s"),
+ yytext, strerror(errno));
xfree(inc);
}
else {
[][+*/,()-] { return yytext[0]; }
<inhibit>. {
- cur_we->warning(YASM_WARN_PREPROC, cur_lindex, _("Unhandled character in <inhibit> `%s'"), cur_we->conv_unprint(yytext[0]));
+ yasm__warning(YASM_WARN_PREPROC, cur_lindex, _("Unhandled character in <inhibit> `%s'"), yasm__conv_unprint(yytext[0]));
}
. {
- cur_we->warning(YASM_WARN_PREPROC, cur_lindex, _("ignoring unrecognized character `%s'"),
- cur_we->conv_unprint(yytext[0]));
+ yasm__warning(YASM_WARN_PREPROC, cur_lindex, _("ignoring unrecognized character `%s'"),
+ yasm__conv_unprint(yytext[0]));
}
%%
int res_only; /* allow only resb family of bytecodes? */
yasm_bytecodehead bc; /* the bytecodes for the section's contents */
-
- /*@exits@*/ void (*error_func) (const char *file, unsigned int line,
- const char *message);
};
/*@-compdestroy@*/
yasm_section *
yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
unsigned long start, int res_only, int *isnew,
- unsigned long lindex,
- /*@exits@*/ void (*error_func)
- (const char *file, unsigned int line,
- const char *message))
+ unsigned long lindex)
{
yasm_section *s;
s->opt_flags = 0;
s->res_only = res_only;
- s->error_func = error_func;
-
*isnew = 1;
return s;
}
/*@-onlytrans@*/
yasm_section *
-yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start,
- /*@exits@*/ void (*error_func)
- (const char *file, unsigned int line,
- const char *message))
+yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start)
{
yasm_section *s;
s->opt_flags = 0;
s->res_only = 1;
- s->error_func = error_func;
-
return s;
}
/*@=onlytrans@*/
if (of->section_data_delete)
of->section_data_delete(of_data);
else
- sect->error_func(__FILE__, __LINE__,
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific section data"));
return;
}
if (of2->section_data_delete)
of2->section_data_delete(sect->data.general.of_data);
else
- sect->error_func(__FILE__, __LINE__,
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific section data"));
}
if (of->section_data_delete)
of->section_data_delete(sect->data.general.of_data);
else
- sect->error_func(__FILE__, __LINE__,
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific section data"));
}
}
/*@dependent@*/ yasm_section *yasm_sections_switch_general
(yasm_sectionhead *headp, const char *name, unsigned long start,
- int res_only, /*@out@*/ int *isnew, unsigned long lindex,
- /*@exits@*/ void (*error_func) (const char *file, unsigned int line,
- const char *message));
+ int res_only, /*@out@*/ int *isnew, unsigned long lindex);
/*@dependent@*/ yasm_section *yasm_sections_switch_absolute
- (yasm_sectionhead *headp, /*@keep@*/ yasm_expr *start,
- /*@exits@*/ void (*error_func) (const char *file, unsigned int line,
- const char *message));
+ (yasm_sectionhead *headp, /*@keep@*/ yasm_expr *start);
int yasm_section_is_absolute(yasm_section *sect);
nontablesymhead;
static /*@only@*/ nontablesymhead *non_table_syms;
-static /*@dependent@*/ yasm_errwarn *cur_we;
-
void
-yasm_symrec_initialize(yasm_errwarn *we)
+yasm_symrec_initialize(void)
{
- cur_we = we;
-
- sym_table = HAMT_new(cur_we->internal_error_);
+ sym_table = HAMT_new(yasm_internal_error_);
non_table_syms = xmalloc(sizeof(nontablesymhead));
SLIST_INIT(non_table_syms);
}
if (sym->of->symrec_data_delete)
sym->of->symrec_data_delete(sym->of_data);
else
- cur_we->internal_error(
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific data"));
}
xfree(sym);
/* Has it been defined before (either by DEFINED or COMMON/EXTERN)? */
if ((rec->status & SYM_DEFINED) ||
(rec->visibility & (YASM_SYM_COMMON | YASM_SYM_EXTERN))) {
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("duplicate definition of `%s'; first defined on line %lu"),
name, rec->line);
} else {
((rec->visibility & YASM_SYM_EXTERN) && (vis == YASM_SYM_EXTERN)))))
rec->visibility |= vis;
else
- cur_we->error(lindex,
+ yasm__error(lindex,
N_("duplicate definition of `%s'; first defined on line %lu"),
name, rec->line);
return rec;
if (sym->of->symrec_data_delete)
sym->of->symrec_data_delete(sym->of_data);
else
- cur_we->internal_error(
+ yasm_internal_error(
N_("don't know how to delete objfmt-specific data"));
}
sym->of = of;
/* error if a symbol is used but never defined or extern/common declared */
if ((sym->status & SYM_USED) && !(sym->status & SYM_DEFINED) &&
!(sym->visibility & (YASM_SYM_EXTERN | YASM_SYM_COMMON))) {
- cur_we->error(sym->line, N_("undefined symbol `%s' (first use)"),
- sym->name);
+ yasm__error(sym->line, N_("undefined symbol `%s' (first use)"),
+ sym->name);
if (sym->line < firstundef_line)
firstundef_line = sym->line;
}
firstundef_line = ULONG_MAX;
yasm_symrec_traverse(NULL, symrec_parser_finalize_checksym);
if (firstundef_line < ULONG_MAX)
- cur_we->error(firstundef_line,
- N_(" (Each undefined symbol is reported only once.)"));
+ yasm__error(firstundef_line,
+ N_(" (Each undefined symbol is reported only once.)"));
}
void
#ifndef YASM_SYMREC_H
#define YASM_SYMREC_H
-void yasm_symrec_initialize(yasm_errwarn *we);
+void yasm_symrec_initialize(void);
/*@dependent@*/ yasm_symrec *yasm_symrec_use(const char *name,
unsigned long lindex);
Suite *s = floatnum_suite();
SRunner *sr = srunner_create(s);
BitVector_Boot();
- yasm_floatnum_initialize(NULL);
+ yasm_floatnum_initialize();
srunner_run_all(sr, CRNORMAL);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
/*@only@*/ char *xstrdup(const char *str);
/* Error-checking memory allocation routines in xmalloc.c. */
-void xalloc_initialize(/*@exits@*/ void (*fatal_func) (int type),
- int nomem_fatal_type);
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/
#include "util.h"
RCSID("$IdPath$");
+#include "errwarn.h"
-static /*@exits@*/ void (*fatal_func) (int type);
-static int nomem_fatal_type;
-
-
-void
-xalloc_initialize(/*@exits@*/ void (*f) (int type), int t)
-{
- fatal_func = f;
- nomem_fatal_type = t;
-}
#ifndef WITH_DMALLOC
size = 1;
newmem = malloc(size);
if (!newmem)
- fatal_func(nomem_fatal_type);
+ yasm_fatal(N_("out of memory"));
return newmem;
}
newmem = calloc(nelem, elsize);
if (!newmem)
- fatal_func(nomem_fatal_type);
+ yasm_fatal(N_("out of memory"));
return newmem;
}
else
newmem = realloc(oldmem, size);
if (!newmem)
- fatal_func(nomem_fatal_type);
+ yasm_fatal(N_("out of memory"));
return newmem;
}
/*@only@*/ char *xstrdup(const char *str);
/* Error-checking memory allocation routines in xmalloc.c. */
-void xalloc_initialize(/*@exits@*/ void (*fatal_func) (int type),
- int nomem_fatal_type);
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/