]> granicus.if.org Git - re2c/commitdiff
Abstracted common used constant in a class variable.
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 18 Mar 2015 11:08:44 +0000 (11:08 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 18 Mar 2015 11:08:44 +0000 (11:08 +0000)
re2c/go.h
re2c/go_construct.cc
re2c/go_emit.cc

index b9e183e6c6c7b031aaa1ed5ee921dacd12b9faa1..a53e4103280d6049ecfd2f96490d09ce7c242aeb 100644 (file)
--- a/re2c/go.h
+++ b/re2c/go.h
@@ -106,6 +106,7 @@ struct Bitmap
 
 struct CpgotoTable
 {
+       static const uint TABLE_SIZE;
        uint * table;
        CpgotoTable (const Span * span, uint nSpans);
        void emit (OutputFile & o, uint ind);
index 99ec7776e3722b4ff3e99561738f8079d8e68eca..524aca3753ca043d7791a2b6c5d946ce7ec74d7b 100644 (file)
@@ -137,14 +137,16 @@ Bitmap::Bitmap (const Span * span, uint nSpans, const Span * hspan, uint hSpans,
        delete bspan;
 }
 
+const uint CpgotoTable::TABLE_SIZE = 0x100;
+
 CpgotoTable::CpgotoTable (const Span * span, uint nSpans)
-       : table (new uint [0x100])
+       : table (new uint [TABLE_SIZE])
 {
        uint c = 0;
        for (uint i = 0; i < nSpans; ++i)
        {
                vUsedLabels.insert(span[i].to->label);
-               for(; c < span[i].ub && c < 0x100; ++c)
+               for(; c < span[i].ub && c < TABLE_SIZE; ++c)
                {
                        table[c] = span[i].to->label;
                }
index 2dc260322248dffc9e0a0941a2b8ee0f50b862b9..91118437abf93ad741bbf3bace88da25191361d2 100644 (file)
@@ -188,10 +188,10 @@ void CpgotoTable::emit (OutputFile & o, uint ind)
 {
        o << indent (ind) << "static void *" << mapCodeName["yytarget"] << "[256] = {\n";
        o << indent (++ind);
-       for (uint i = 0; i <= 0xFF; ++i)
+       for (uint i = 0; i < TABLE_SIZE; ++i)
        {
                o << "&&" << labelPrefix << table[i];
-               if (i == 0xFF)
+               if (i == TABLE_SIZE - 1)
                {
                        o << "\n";
                }