version 1.47, 2003/06/03 02:56:10 |
version 1.48, 2003/06/18 21:08:07 |
|
|
|
|
#define BUILTIN_MARKER "__builtin_" |
#define BUILTIN_MARKER "__builtin_" |
|
|
|
static void setup_definition(ndptr, const char *); |
static void dodefn(const char *); |
static void dodefn(const char *); |
static void dopushdef(const char *, const char *); |
static void dopushdef(const char *, const char *); |
static void dodump(const char *[], int); |
static void dodump(const char *[], int); |
|
|
PUTBACK(*p); |
PUTBACK(*p); |
} |
} |
|
|
|
|
/* |
/* |
* dodefine - install definition in the table |
* common part to dodefine and dopushdef |
*/ |
*/ |
void |
static void |
dodefine(const char *name, const char *defn) |
setup_definition(ndptr p, const char *defn) |
{ |
{ |
ndptr p; |
|
int n; |
int n; |
|
|
if (!*name) |
|
errx(1, "%s at line %lu: null definition.", CURRENT_NAME, |
|
CURRENT_LINE); |
|
if ((p = lookup(name)) == nil) |
|
p = addent(name); |
|
else if (p->defn != null) |
|
free((char *) p->defn); |
|
if (strncmp(defn, BUILTIN_MARKER, sizeof(BUILTIN_MARKER)-1) == 0) { |
if (strncmp(defn, BUILTIN_MARKER, sizeof(BUILTIN_MARKER)-1) == 0) { |
n = builtin_type(defn+sizeof(BUILTIN_MARKER)-1); |
n = builtin_type(defn+sizeof(BUILTIN_MARKER)-1); |
if (n != -1) { |
if (n != -1) { |
p->type = n & TYPEMASK; |
p->type = n & TYPEMASK; |
if ((n & NOARGS) == 0) |
if ((n & NOARGS) == 0) |
p->type |= NEEDARGS; |
p->type |= NEEDARGS; |
p->defn = null; |
p->defn = xstrdup(defn+sizeof(BUILTIN_MARKER)-1); |
return; |
return; |
} |
} |
} |
} |
|
|
else |
else |
p->defn = xstrdup(defn); |
p->defn = xstrdup(defn); |
p->type = MACRTYPE; |
p->type = MACRTYPE; |
|
} |
|
|
|
/* |
|
* dodefine - install definition in the table |
|
*/ |
|
void |
|
dodefine(const char *name, const char *defn) |
|
{ |
|
ndptr p; |
|
|
|
if (!*name) |
|
errx(1, "%s at line %lu: null definition.", CURRENT_NAME, |
|
CURRENT_LINE); |
|
if ((p = lookup(name)) == nil) |
|
p = addent(name); |
|
else if (p->defn != null) |
|
free((char *) p->defn); |
|
setup_definition(p, defn); |
if (STREQ(name, defn)) |
if (STREQ(name, defn)) |
p->type |= RECDEF; |
p->type |= RECDEF; |
} |
} |
|
|
char *real; |
char *real; |
|
|
if ((p = lookup(name)) != nil) { |
if ((p = lookup(name)) != nil) { |
if (p->defn != null) { |
if ((p->type & TYPEMASK) == MACRTYPE) { |
pbstr(rquote); |
pbstr(rquote); |
pbstr(p->defn); |
pbstr(p->defn); |
pbstr(lquote); |
pbstr(lquote); |
} else if ((real = builtin_realname(p->type)) != NULL) { |
} else { |
pbstr(real); |
pbstr(p->defn); |
pbstr(BUILTIN_MARKER); |
pbstr(BUILTIN_MARKER); |
} |
} |
} |
} |
|
|
errx(1, "%s at line %lu: null definition", CURRENT_NAME, |
errx(1, "%s at line %lu: null definition", CURRENT_NAME, |
CURRENT_LINE); |
CURRENT_LINE); |
p = addent(name); |
p = addent(name); |
if (!*defn) |
setup_definition(p, defn); |
p->defn = null; |
|
else |
|
p->defn = xstrdup(defn); |
|
p->type = MACRTYPE; |
|
if (STREQ(name, defn)) |
if (STREQ(name, defn)) |
p->type |= RECDEF; |
p->type |= RECDEF; |
} |
} |
|
|
static void |
static void |
dump_one_def(ndptr p) |
dump_one_def(ndptr p) |
{ |
{ |
char *real; |
|
|
|
if (mimic_gnu) { |
if (mimic_gnu) { |
if ((p->type & TYPEMASK) == MACRTYPE) |
if ((p->type & TYPEMASK) == MACRTYPE) |
fprintf(traceout, "%s:\t%s\n", p->name, p->defn); |
fprintf(traceout, "%s:\t%s\n", p->name, p->defn); |
else { |
else { |
real = builtin_realname(p->type); |
fprintf(traceout, "%s:\t<%s>\n", p->name, p->defn); |
if (real == NULL) |
|
real = null; |
|
fprintf(traceout, "%s:\t<%s>\n", p->name, real); |
|
} |
} |
} else |
} else |
fprintf(traceout, "`%s'\t`%s'\n", p->name, p->defn); |
fprintf(traceout, "`%s'\t`%s'\n", p->name, p->defn); |