diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2016-02-18 01:25:46 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2016-02-18 01:25:46 -0800 |
commit | cd7893d02ddba6c10935a36cda6e9d41eac3ac2a (patch) | |
tree | cd3377c7027d18be0b24c6512aaab8b728bdf3c9 | |
parent | 36034ec65203acfd1419992743a143b33bfc8ab1 (diff) | |
download | nasm-cd7893d02ddba6c10935a36cda6e9d41eac3ac2a.tar.gz |
Remove additional function pointers that never change
Remove additional cached function pointers which point to static
variables which are never actually changed. Just refer to the global
variable instead.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | eval.c | 22 | ||||
-rw-r--r-- | eval.h | 7 | ||||
-rw-r--r-- | nasm.c | 4 | ||||
-rw-r--r-- | nasm.h | 1 | ||||
-rw-r--r-- | parser.c | 12 | ||||
-rw-r--r-- | parser.h | 1 |
6 files changed, 12 insertions, 35 deletions
@@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2012 The NASM Authors - All Rights Reserved + * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -54,7 +54,6 @@ #define TEMPEXPR_DELTA 8 static scanner scan; /* Address of scanner routine */ -static lfunc labelfunc; /* Address of label routine */ static expr **tempexprs = NULL; static int ntempexprs; @@ -68,7 +67,6 @@ static struct tokenval *tokval; /* The current token */ static int i; /* The t_type of tokval */ static void *scpriv; -static struct location *location; /* Pointer to current line's segment,offset */ static int *opflags; static struct eval_hints *hint; @@ -890,11 +888,11 @@ static expr *expr6(int critical) case TOKEN_HERE: case TOKEN_BASE: /* - * If !location->known, this indicates that no + * If !location.known, this indicates that no * symbol, Here or Base references are valid because we * are in preprocess-only mode. */ - if (!location->known) { + if (!location.known) { nasm_error(ERR_NONFATAL, "%s not supported in preprocess-only mode", (i == TOKEN_HERE ? "`$'" : @@ -906,13 +904,13 @@ static expr *expr6(int critical) type = EXPR_SIMPLE; /* might get overridden by UNKNOWN */ if (i == TOKEN_BASE) { - label_seg = in_abs_seg ? abs_seg : location->segment; + label_seg = in_abs_seg ? abs_seg : location.segment; label_ofs = 0; } else if (i == TOKEN_HERE) { - label_seg = in_abs_seg ? abs_seg : location->segment; - label_ofs = in_abs_seg ? abs_offset : location->offset; + label_seg = in_abs_seg ? abs_seg : location.segment; + label_ofs = in_abs_seg ? abs_offset : location.offset; } else { - if (!labelfunc(tokval->t_charptr, &label_seg, &label_ofs)) { + if (!lookup_label(tokval->t_charptr, &label_seg, &label_ofs)) { scope = local_scope(tokval->t_charptr); if (critical == 2) { nasm_error(ERR_NONFATAL, "symbol `%s%s' undefined", @@ -951,12 +949,6 @@ static expr *expr6(int critical) } } -void eval_global_info(lfunc lookup_label, struct location * locp) -{ - labelfunc = lookup_label; - location = locp; -} - expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, int *fwref, int critical, struct eval_hints *hints) { @@ -39,13 +39,6 @@ #define NASM_EVAL_H /* - * Called once to tell the evaluator what output format is - * providing segment-base details, and what function can be used to - * look labels up. - */ -void eval_global_info(lfunc lookup_label, struct location * locp); - -/* * The evaluator itself. */ expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, @@ -116,7 +116,7 @@ int64_t global_offset_changed; /* referenced in labels.c */ int64_t prev_offset_changed; int32_t stall_count; -static struct location location; +struct location location; int in_abs_seg; /* Flag we are in ABSOLUTE seg */ int32_t abs_seg; /* ABSOLUTE segment basis */ int32_t abs_offset; /* ABSOLUTE offset */ @@ -364,8 +364,6 @@ int main(int argc, char **argv) if (ofmt->stdmac) preproc->extra_stdmac(ofmt->stdmac); - parser_global_info(&location); - eval_global_info(ofmt, lookup_label, &location); /* define some macros dependent of command-line */ define_macros_late(); @@ -220,6 +220,7 @@ struct location { int32_t segment; int known; }; +extern struct location location; /* * Expression-evaluator datatype. Expressions, within the @@ -61,12 +61,6 @@ static int is_comma_next(void); static int i; static struct tokenval tokval; -static struct location *location; /* Pointer to current line's segment,offset */ - -void parser_global_info(struct location * locp) -{ - location = locp; -} static int prefix_slot(int prefix) { @@ -431,14 +425,14 @@ restart_parse: } if (i != TOKEN_INSN || tokval.t_integer != I_EQU) { /* - * FIXME: location->segment could be NO_SEG, in which case + * FIXME: location.segment could be NO_SEG, in which case * it is possible we should be passing 'abs_seg'. Look into this. * Work out whether that is *really* what we should be doing. * Generally fix things. I think this is right as it is, but * am still not certain. */ - ldef(result->label, in_abs_seg ? abs_seg : location->segment, - location->offset, NULL, true, false); + ldef(result->label, in_abs_seg ? abs_seg : location.segment, + location.offset, NULL, true, false); } } @@ -39,7 +39,6 @@ #ifndef NASM_PARSER_H #define NASM_PARSER_H -void parser_global_info(struct location *locp); insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef); void cleanup_insn(insn *instruction); |