Some more cleanup. Put a pointer to CodeGenData in ParseData and eliminate codeGenMap...
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 15 Mar 2009 14:18:58 +0000 (14:18 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 15 Mar 2009 14:18:58 +0000 (14:18 +0000)
git-svn-id: http://svn.complang.org/ragel/trunk@738 052ea7fc-9027-0410-9066-f65837a77df0

ragel/inputdata.cpp
ragel/inputdata.h
ragel/parsedata.cpp
ragel/parsedata.h
ragel/rlscan.rl

index 5d65470..47d4681 100644 (file)
@@ -196,8 +196,7 @@ void InputData::writeOutput()
 {
        for ( InputItemList::Iter ii = inputItems; ii.lte(); ii++ ) {
                if ( ii->type == InputItem::Write ) {
-                       CodeGenMapEl *mapEl = codeGenMap.find( (char*)ii->name.c_str() );
-                       CodeGenData *cgd = mapEl->value;
+                       CodeGenData *cgd = ii->pd->cgd;
                        ::keyOps = &cgd->thisKeyOps;
 
                        cgd->writeStatement( ii->loc, ii->writeArgs.length()-1, ii->writeArgs.data );
index c1cdfef..11d4928 100644 (file)
@@ -39,8 +39,6 @@ struct InputData
        bool outputActive;
        bool wantComplete;
 
-       CodeGenMap codeGenMap;
-
        void writeOutput();
        void generateSpecificReduced();
        void openOutput();
index cb5208f..a534348 100644 (file)
@@ -454,7 +454,8 @@ ParseData::ParseData( const char *fileName, char *sectionName,
        exportsRootName(0),
        nextEpsilonResolvedLink(0),
        nextLongestMatchId(1),
-       lmRequiresErrorState(false)
+       lmRequiresErrorState(false),
+       cgd(0)
 {
        /* Initialize the dictionary of graphs. This is our symbol table. The
         * initialization needs to be done on construction which happens at the
@@ -1432,16 +1433,8 @@ void ParseData::generateReduced( InputData &inputData )
 {
        beginProcessing();
 
-       /* Open the definition. */
-       CodeGenMapEl *mapEl = inputData.codeGenMap.find( sectionName );
-       CodeGenData *cgd = 0;
-       if ( mapEl != 0 )
-               cgd = mapEl->value;
-       else {
-               cgd = makeCodeGen( inputData.inputFileName, sectionName, 
-                               *inputData.outStream, inputData.wantComplete );
-               inputData.codeGenMap.insert( sectionName, cgd );
-       }
+       cgd = makeCodeGen( inputData.inputFileName, sectionName, 
+                       *inputData.outStream, inputData.wantComplete );
 
        /* Make the generator. */
        BackendGen backendGen( sectionName, this, sectionGraph, cgd );
index ef23850..578b2a8 100644 (file)
@@ -55,6 +55,7 @@ struct ReOrBlock;
 struct ReOrItem;
 struct LongestMatch;
 struct InputData;
+struct CodeGenData;
 typedef DList<LongestMatch> LmList;
 
 
@@ -356,6 +357,8 @@ struct ParseData
        KeyOps thisKeyOps;
 
        ExportList exportList;
+
+       CodeGenData *cgd;
 };
 
 void afterOpMinimize( FsmAp *fsm, bool lastInSeq = true );
@@ -382,6 +385,7 @@ struct InputItem
        Type type;
        std::ostringstream data;
        std::string name;
+       ParseData *pd;
        Vector<char *> writeArgs;
 
        InputLoc loc;
index f31dd37..58a5def 100644 (file)
@@ -414,6 +414,7 @@ void Scanner::handleImport()
                        inputItem->loc.line = line;
                        inputItem->loc.col = column;
                        inputItem->name = parser->sectionName;
+                       inputItem->pd = parser->pd;
                        inputItems.append( inputItem );
                }
        }