From 9596508671da1b48eced4710e05b9524fff0f9a6 Mon Sep 17 00:00:00 2001 From: thurston Date: Sun, 15 Mar 2009 14:18:58 +0000 Subject: [PATCH] Some more cleanup. Put a pointer to CodeGenData in ParseData and eliminate codeGenMap from InputData. git-svn-id: http://svn.complang.org/ragel/trunk@738 052ea7fc-9027-0410-9066-f65837a77df0 --- ragel/inputdata.cpp | 3 +-- ragel/inputdata.h | 2 -- ragel/parsedata.cpp | 15 ++++----------- ragel/parsedata.h | 4 ++++ ragel/rlscan.rl | 1 + 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ragel/inputdata.cpp b/ragel/inputdata.cpp index 5d65470..47d4681 100644 --- a/ragel/inputdata.cpp +++ b/ragel/inputdata.cpp @@ -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 ); diff --git a/ragel/inputdata.h b/ragel/inputdata.h index c1cdfef..11d4928 100644 --- a/ragel/inputdata.h +++ b/ragel/inputdata.h @@ -39,8 +39,6 @@ struct InputData bool outputActive; bool wantComplete; - CodeGenMap codeGenMap; - void writeOutput(); void generateSpecificReduced(); void openOutput(); diff --git a/ragel/parsedata.cpp b/ragel/parsedata.cpp index cb5208f..a534348 100644 --- a/ragel/parsedata.cpp +++ b/ragel/parsedata.cpp @@ -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 ); diff --git a/ragel/parsedata.h b/ragel/parsedata.h index ef23850..578b2a8 100644 --- a/ragel/parsedata.h +++ b/ragel/parsedata.h @@ -55,6 +55,7 @@ struct ReOrBlock; struct ReOrItem; struct LongestMatch; struct InputData; +struct CodeGenData; typedef DList 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 writeArgs; InputLoc loc; diff --git a/ragel/rlscan.rl b/ragel/rlscan.rl index f31dd37..58a5def 100644 --- a/ragel/rlscan.rl +++ b/ragel/rlscan.rl @@ -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 ); } } -- 2.7.4