Disabled the setting of state ids in the backend to go live with the equivalent
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 4 Feb 2007 04:40:40 +0000 (04:40 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 4 Feb 2007 04:40:40 +0000 (04:40 +0000)
work done in the frontend.

git-svn-id: http://svn.complang.org/ragel/trunk@74 052ea7fc-9027-0410-9066-f65837a77df0

redfsm/gendata.cpp
redfsm/redfsm.cpp
redfsm/redfsm.h
rlcodegen/fsmcodegen.cpp
rlgen-java/javacodegen.cpp
rlgen-ruby/rubycodegen.cpp

index dd212a6..e8a6ca6 100644 (file)
@@ -92,6 +92,11 @@ void CodeGenData::initStateList( unsigned long length )
                redFsm->errState = allStates + errState;
        for ( EntryIdVect::Iter en = entryPointIds; en.lte(); en++ )
                redFsm->entryPoints.insert( allStates + *en );
+
+       /* The nextStateId is no longer used to assign state ids (they come in set
+        * from the frontend now), however generation code still depends on it.
+        * Should eventually remove this variable. */
+       redFsm->nextStateId = redFsm->stateList.length();
 }
 
 void CodeGenData::setStartState( unsigned long startState )
index 9b1af9b..1b6d419 100644 (file)
@@ -164,6 +164,11 @@ void RedFsmAp::sortStateIdsByFinal()
        }
 }
 
+void RedFsmAp::sortByStateId()
+{
+       /* FIXME: Implement. */
+}
+
 /* Find the final state with the lowest id. */
 void RedFsmAp::findFirstFinState()
 {
index b37898b..e1f7511 100644 (file)
@@ -508,6 +508,9 @@ struct RedFsmAp
        /* Arrange states in by final id. This is a stable sort. */
        void sortStatesByFinal();
 
+       /* Sorting states by id. */
+       void sortByStateId();
+
        /* Locating the first final state. This is the final state with the lowest
         * id. */
        void findFirstFinState();
index 2ca7e87..888f534 100644 (file)
@@ -622,25 +622,18 @@ void FsmCodeGen::prepareMachine()
 
        redFsm->assignActionLocs();
 
-       /* Order the states. */
-       redFsm->depthFirstOrdering();
-
        if ( codeStyle == GenGoto || codeStyle == GenFGoto || 
                        codeStyle == GenIpGoto || codeStyle == GenSplit )
        {
-               /* For goto driven machines we can keep the original depth
-                * first ordering because it's ok if the state ids are not
-                * sequential. Split the the ids by final state status. */
-               redFsm->sortStateIdsByFinal();
+               /* For directly executable machines there is no required state
+                * ordering. Choose a depth-first ordering to increase the
+                * potential for fall-throughs. */
+               redFsm->depthFirstOrdering();
        }
        else {
-               /* For table driven machines the location of the state is used to
-                * identify it so the states must be sorted by their final ids.
-                * Though having a deterministic ordering is important,
-                * specifically preserving the depth first ordering is not because
-                * states are stored in tables. */
-               redFsm->sortStatesByFinal();
-               redFsm->sequentialStateIds();
+               /* The frontend will do this for us, but it may be a good idea to
+                * force it if the intermediate file is edited. */
+               redFsm->sortByStateId();
        }
 
        /* Find the first final state. This is the final state with the lowest
index 86bea88..ad74c73 100644 (file)
@@ -1474,16 +1474,9 @@ void JavaTabCodeGen::prepareMachine()
 
        redFsm->assignActionLocs();
 
-       /* Order the states. */
-       redFsm->depthFirstOrdering();
-
-       /* For table driven machines the location of the state is used to
-        * identify it so the states must be sorted by their final ids.
-        * Though having a deterministic ordering is important,
-        * specifically preserving the depth first ordering is not because
-        * states are stored in tables. */
-       redFsm->sortStatesByFinal();
-       redFsm->sequentialStateIds();
+       /* The frontend will do this for us, but it may be a good idea to force it
+        * if the intermediate file is edited. */
+       redFsm->sortByStateId();
 
        /* Find the first final state. This is the final state with the lowest
         * id.  */
index f27d5f0..ad7d11b 100644 (file)
@@ -1467,16 +1467,9 @@ void RubyCodeGen::prepareMachine()
 
        redFsm->assignActionLocs();
 
-       /* Order the states. */
-       redFsm->depthFirstOrdering();
-
-       /* For table driven machines the location of the state is used to
-        * identify it so the states must be sorted by their final ids.
-        * Though having a deterministic ordering is important,
-        * specifically preserving the depth first ordering is not because
-        * states are stored in tables. */
-       redFsm->sortStatesByFinal();
-       redFsm->sequentialStateIds();
+       /* The frontend will do this for us, but it may be a good idea to force it
+        * if the intermediate file is edited. */
+       redFsm->sortByStateId();
 
        /* Find the first final state. This is the final state with the lowest
         * id.  */