From: Ulya Trofimovich Date: Sun, 18 Dec 2016 16:37:05 +0000 (+0000) Subject: Removed variable from global scope. X-Git-Tag: 1.0~39^2~188 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30904073871f61bccad7b32f8650ef487d2c13ef;p=re2c Removed variable from global scope. --- diff --git a/re2c/src/codegen/emit_action.cc b/re2c/src/codegen/emit_action.cc index 923112e1..063ac851 100644 --- a/re2c/src/codegen/emit_action.cc +++ b/re2c/src/codegen/emit_action.cc @@ -250,10 +250,10 @@ void need(OutputFile &o, uint32_t ind, size_t some) std::string s; if (opts->fFlag) { - strrreplace(s = opts->state_set, opts->state_set_arg, last_fill_index); + strrreplace(s = opts->state_set, opts->state_set_arg, o.fill_index); o.wind(ind).wstring(s); if (!opts->state_set_naked) { - o.ws("(").wu32(last_fill_index).ws(");"); + o.ws("(").wu32(o.fill_index).ws(");"); } o.ws("\n"); } @@ -275,8 +275,8 @@ void need(OutputFile &o, uint32_t ind, size_t some) } if (opts->fFlag) { - o.wstring(opts->yyfilllabel).wu32(last_fill_index).ws(":\n"); - ++last_fill_index; + o.wstring(opts->yyfilllabel).wu32(o.fill_index).ws(":\n"); + ++o.fill_index; } } diff --git a/re2c/src/codegen/output.cc b/re2c/src/codegen/output.cc index 76411dbd..874080c3 100644 --- a/re2c/src/codegen/output.cc +++ b/re2c/src/codegen/output.cc @@ -64,6 +64,7 @@ OutputBlock::~OutputBlock () OutputFile::OutputFile(Opt &o, Warn &w) : blocks () , label_counter () + , fill_index(0) , warn_condition_order (!o->tFlag) // see note [condition order] , opts(o) , warn(w) @@ -296,7 +297,7 @@ bool OutputFile::emit(const uniq_vector_t &global_types, output_line_info(f.stream, line_count + 1, filename, opts); break; case OutputFragment::STATE_GOTO: - output_state_goto(f.stream, f.indent, 0, opts); + output_state_goto(f.stream, f.indent, 0, fill_index, opts); break; case OutputFragment::TAGS: output_tags(f.stream, *f.tags, global_tags); @@ -395,7 +396,8 @@ void output_tags(std::ostream &o, const ConfTags &conf, } } -void output_state_goto (std::ostream & o, uint32_t ind, uint32_t start_label, Opt &opts) +void output_state_goto(std::ostream & o, uint32_t ind, + uint32_t start_label, uint32_t fill_index, Opt &opts) { const std::string indstr = indent(ind, opts->indString); o << indstr << "switch (" << output_get_state(opts) << ") {\n"; @@ -408,7 +410,7 @@ void output_state_goto (std::ostream & o, uint32_t ind, uint32_t start_label, Op { o << indstr << "default: goto " << opts->labelPrefix << start_label << ";\n"; } - for (uint32_t i = 0; i < last_fill_index; ++i) + for (uint32_t i = 0; i < fill_index; ++i) { o << indstr << "case " << i << ": goto " << opts->yyfilllabel << i << ";\n"; } diff --git a/re2c/src/codegen/output.h b/re2c/src/codegen/output.h index 083e02d6..5e3afbb8 100644 --- a/re2c/src/codegen/output.h +++ b/re2c/src/codegen/output.h @@ -77,6 +77,7 @@ class OutputFile public: counter_t label_counter; + uint32_t fill_index; bool warn_condition_order; Opt &opts; Warn &warn; @@ -146,13 +147,13 @@ struct Output bool emit(); }; -void output_tags(std::ostream &o, const ConfTags &conf, const std::set &tags); -void output_line_info (std::ostream &, uint32_t, const std::string&, Opt &opts); -void output_state_goto (std::ostream &, uint32_t, uint32_t, Opt &opts); -void output_types(std::ostream &o, uint32_t, const uniq_vector_t &types, Opt &opts); -void output_version_time (std::ostream &, Opt &opts); -void output_yyaccept_init (std::ostream &, uint32_t, bool, Opt &opts); -void output_yymaxfill (std::ostream &, size_t); +void output_tags (std::ostream &o, const ConfTags &conf, const std::set &tags); +void output_line_info (std::ostream &o, uint32_t ind, const std::string &file_name, Opt &opts); +void output_state_goto (std::ostream &o, uint32_t ind, uint32_t start_label, uint32_t fill_index, Opt &opts); +void output_types (std::ostream &o, uint32_t ind, const uniq_vector_t &types, Opt &opts); +void output_version_time (std::ostream &o, Opt &opts); +void output_yyaccept_init (std::ostream &o, uint32_t ind, bool, Opt &opts); +void output_yymaxfill (std::ostream &o, size_t max_fill); // helpers std::string output_get_state (Opt &opts); diff --git a/re2c/src/globals.h b/re2c/src/globals.h index cf8370bb..d1bfc51d 100644 --- a/re2c/src/globals.h +++ b/re2c/src/globals.h @@ -1,15 +1,12 @@ #ifndef _RE2C_GLOBALS_ #define _RE2C_GLOBALS_ -#include "src/util/c99_stdint.h" - namespace re2c { extern bool bUsedYYBitmap; extern bool bWroteGetState; extern bool bWroteCondCheck; -extern uint32_t last_fill_index; } // end namespace re2c diff --git a/re2c/src/main.cc b/re2c/src/main.cc index 54d28011..6760a4e3 100644 --- a/re2c/src/main.cc +++ b/re2c/src/main.cc @@ -16,7 +16,6 @@ namespace re2c bool bUsedYYBitmap = false; bool bWroteGetState = false; bool bWroteCondCheck = false; -uint32_t last_fill_index = 0; } // end namespace re2c diff --git a/re2c/src/parse/scanner.cc b/re2c/src/parse/scanner.cc index 3ef425f7..b7658207 100644 --- a/re2c/src/parse/scanner.cc +++ b/re2c/src/parse/scanner.cc @@ -181,7 +181,7 @@ Scanner::~Scanner() void Scanner::reuse() { out.label_counter.reset (); - last_fill_index = 0; + out.fill_index = 0; bWroteGetState = false; bWroteCondCheck = false; opts.reset_mapCodeName ();