}
/* Pre-process until done */
- cur_preproc = yasm_preproc_create(cur_preproc_module, in_filename,
+ cur_preproc = yasm_preproc_create(cur_preproc_module, in_filename, NULL,
linemap, errwarns);
apply_preproc_builtins();
}
cur_preproc = yasm_preproc_create(cur_preproc_module, in_filename,
- linemap, errwarns);
+ object->symtab, linemap, errwarns);
apply_preproc_builtins();
apply_preproc_saved_options();
*
* \param in_filename initial starting filename, or "-" to read from
* stdin
+ * \param symtab symbol table (may be NULL if none)
* \param lm line mapping repository
* \param errwarns error/warnning set.
* \return New preprocessor.
* \note Any preprocessor errors and warnings are stored into errwarns.
*/
/*@only@*/ yasm_preproc * (*create) (const char *in_filename,
+ yasm_symtab *symtab,
yasm_linemap *lm,
yasm_errwarns *errwarns);
* any output format specific macros.
* \param module preprocessor module
* \param in_filename initial starting filename, or "-" to read from stdin
+ * \param symtab symbol table (may be NULL if none)
* \param lm line mapping repository
* \param errwarns error/warning set
* \return New preprocessor.
*/
/*@only@*/ yasm_preproc *yasm_preproc_create
(yasm_preproc_module *module, const char *in_filename,
- yasm_linemap *lm, yasm_errwarns *errwarns);
+ yasm_symtab *symtab, yasm_linemap *lm, yasm_errwarns *errwarns);
/** Cleans up any allocated preproc memory.
* \param preproc preprocessor
/* Inline macro implementations for preproc functions */
-#define yasm_preproc_create(module, in_filename, lm, ews) \
- module->create(in_filename, lm, ews)
+#define yasm_preproc_create(module, in_filename, symtab, lm, ews) \
+ module->create(in_filename, symtab, lm, ews)
#define yasm_preproc_destroy(preproc) \
((yasm_preproc_base *)preproc)->module->destroy(preproc)
Interface functions.
*******************************************************************************/
static yasm_preproc *
-cpp_preproc_create(const char *in, yasm_linemap *lm, yasm_errwarns *errwarns)
+cpp_preproc_create(const char *in, yasm_symtab *symtab, yasm_linemap *lm,
+ yasm_errwarns *errwarns)
{
yasm_preproc_cpp *pp = yasm_xmalloc(sizeof(yasm_preproc_cpp));
void * iter;
#include <libyasm/coretype.h>
#include <libyasm/intnum.h>
#include <libyasm/expr.h>
+#include <libyasm/symrec.h>
#include <ctype.h>
#include "nasm.h"
#include "nasmlib.h"
#include "nasm-eval.h"
+/* The assembler symbol table. */
+extern yasm_symtab *nasm_symtab;
+
static scanner scan; /* Address of scanner routine */
static efunc error; /* Address of error reporting routine */
e = yasm_expr_create_ident(yasm_expr_int(tokval->t_integer), 0);
break;
case TOKEN_ID:
+ if (nasm_symtab) {
+ yasm_symrec *sym =
+ yasm_symtab_get(nasm_symtab, tokval->t_charptr);
+ if (sym) {
+ e = yasm_expr_create_ident(yasm_expr_sym(sym), 0);
+ } else {
+ error(ERR_NONFATAL,
+ "undefined symbol `%s' in preprocessor",
+ tokval->t_charptr);
+ e = yasm_expr_create_ident(yasm_expr_int(
+ yasm_intnum_create_int(1)), 0);
+ }
+ break;
+ }
+ /*fallthrough*/
case TOKEN_HERE:
case TOKEN_BASE:
error(ERR_NONFATAL,
long prior_linnum;
int lineinc;
} yasm_preproc_nasm;
+yasm_symtab *nasm_symtab;
static yasm_linemap *cur_lm;
static yasm_errwarns *cur_errwarns;
int tasm_compatible_mode = 0;
}
static yasm_preproc *
-nasm_preproc_create(const char *in_filename, yasm_linemap *lm,
- yasm_errwarns *errwarns)
+nasm_preproc_create(const char *in_filename, yasm_symtab *symtab,
+ yasm_linemap *lm, yasm_errwarns *errwarns)
{
FILE *f;
yasm_preproc_nasm *preproc_nasm = yasm_xmalloc(sizeof(yasm_preproc_nasm));
f = stdin;
preproc_nasm->in = f;
+ nasm_symtab = symtab;
cur_lm = lm;
cur_errwarns = errwarns;
preproc_deps = NULL;
--:5: cannot reference symbol `teststringlen' in preprocessor
+-:5: non-constant value given to `%if'
yasm_preproc_module yasm_raw_LTX_preproc;
static yasm_preproc *
-raw_preproc_create(const char *in_filename, yasm_linemap *lm,
- yasm_errwarns *errwarns)
+raw_preproc_create(const char *in_filename, yasm_symtab *symtab,
+ yasm_linemap *lm, yasm_errwarns *errwarns)
{
FILE *f;
yasm_preproc_raw *preproc_raw = yasm_xmalloc(sizeof(yasm_preproc_raw));