/* Make a duplicate for concating and set the fin bits to graph 2 so we
* can pick out it's final states after the optional style concat. */
FsmAp *dup = new FsmAp( *copyFrom );
- dup->setFinBits( SB_GRAPH2 );
+ dup->setFinBits( STB_GRAPH2 );
doConcat( dup, &lastFinSet, true );
/* Clear the last final state set and make the new one by taking only
/* If the state came from graph 2, add it to the last set and clear
* the bits. */
StateAp *fs = finStateSet[i];
- if ( fs->stateBits & SB_GRAPH2 ) {
+ if ( fs->stateBits & STB_GRAPH2 ) {
lastFinSet.insert( fs );
- fs->stateBits &= ~SB_GRAPH2;
+ fs->stateBits &= ~STB_GRAPH2;
}
}
}
other->setMisfitAccounting( true );
/* Set the fin bits on this and other to want each other. */
- setFinBits( SB_GRAPH1 );
- other->setFinBits( SB_GRAPH2 );
+ setFinBits( STB_GRAPH1 );
+ other->setFinBits( STB_GRAPH2 );
/* Call worker Or routine. */
doOr( other );
other->setMisfitAccounting( true );
/* Set the fin bits of other to be killers. */
- other->setFinBits( SB_GRAPH1 );
+ other->setFinBits( STB_GRAPH1 );
/* Call worker Or routine. */
doOr( other );
/* Invoke the relinquish final callback on any states that did not get
* final state status back. */
for ( StateSet::Iter st = finStateSetCopy; st.lte(); st++ ) {
- if ( !((*st)->stateBits & SB_ISFINAL) )
+ if ( !((*st)->stateBits & STB_ISFINAL) )
clearOutData( *st );
}
for ( int s = 0; s < fin.length(); s++ ) {
/* Check for killing bit. */
StateAp *state = fin.data[s];
- if ( state->stateBits & SB_GRAPH1 ) {
+ if ( state->stateBits & STB_GRAPH1 ) {
/* One final state is a killer, set to non-final. */
unsetFinState( state );
}
/* Clear all killing bits. Non final states should never have had those
* state bits set in the first place. */
- state->stateBits &= ~SB_GRAPH1;
+ state->stateBits &= ~STB_GRAPH1;
}
}
for ( int s = 0; s < fin.length(); s++ ) {
/* Check for one set but not the other. */
StateAp *state = fin.data[s];
- if ( state->stateBits & SB_BOTH &&
- (state->stateBits & SB_BOTH) != SB_BOTH )
+ if ( state->stateBits & STB_BOTH &&
+ (state->stateBits & STB_BOTH) != STB_BOTH )
{
/* One state wants the other but it is not there. */
unsetFinState( state );
/* Clear wanting bits. Non final states should never have had those
* state bits set in the first place. */
- state->stateBits &= ~SB_BOTH;
+ state->stateBits &= ~STB_BOTH;
}
}
}
/* A state merge which represents the drawing in of leaving transitions. If
- * there is any out data then we duplicate the souce state, transfer the out
+ * there is any out data then we duplicate the source state, transfer the out
* data, then merge in the state. The new state will be reaped because it will
* not be given any in transitions. */
void FsmAp::mergeStatesLeaving( MergeData &md, StateAp *destState, StateAp *srcState )
mergeStates( md, ssMutable, srcState );
transferOutData( ssMutable, destState );
- for ( ActionSet::Iter cond = destState->outCondSet; cond.lte(); cond++ )
- embedCondition( md, ssMutable, *cond );
+ for ( OutCondSet::Iter cond = destState->outCondSet; cond.lte(); cond++ )
+ embedCondition( md, ssMutable, cond->action, cond->sense );
mergeStates( md, destState, ssMutable );
}
expList2.empty();
/* Get its bits and final state status. */
- destState->stateBits |= ( srcState->stateBits & ~SB_ISFINAL );
+ destState->stateBits |= ( srcState->stateBits & ~STB_ISFINAL );
if ( srcState->isFinState() )
setFinState( destState );
destState->fromStateActionTable.setActions(
ActionTable( srcState->fromStateActionTable ) );
destState->outActionTable.setActions( ActionTable( srcState->outActionTable ) );
- destState->outCondSet.insert( ActionSet( srcState->outCondSet ) );
+ destState->outCondSet.insert( OutCondSet( srcState->outCondSet ) );
destState->errActionTable.setActions( ErrActionTable( srcState->errActionTable ) );
destState->eofActionTable.setActions( ActionTable( srcState->eofActionTable ) );
}
}
void FsmAp::findEmbedExpansions( ExpansionList &expansionList,
- StateAp *destState, Action *condAction )
+ StateAp *destState, Action *condAction, bool sense )
{
StateCondList destList;
PairIter<TransAp, StateCond> transCond( destState->outList.head,
expansion->fromCondSpace = 0;
expansion->fromVals = 0;
expansion->toCondSpace = newStateCond->condSpace;
- expansion->toValsList.append( 1 );
+ expansion->toValsList.append( sense?1:0 );
#ifdef LOG_CONDS
logNewExpansion( expansion );
#endif
long targVals = basicVals;
Action **cim = mergedCS.find( condAction );
long bitPos = (cim - mergedCS.data);
- targVals |= 1 << bitPos;
+ targVals |= (sense?1:0) << bitPos;
LongVect expandToVals( targVals );
findCondExpInTrans( expansionList, destState,
destState->stateCondList.transfer( destList );
}
-void FsmAp::embedCondition( StateAp *state, Action *condAction )
+void FsmAp::embedCondition( StateAp *state, Action *condAction, bool sense )
{
MergeData md;
ExpansionList expList;
setMisfitAccounting( true );
/* Worker. */
- embedCondition( md, state, condAction );
+ embedCondition( md, state, condAction, sense );
/* Fill in any states that were newed up as combinations of others. */
fillInStates( md );
setMisfitAccounting( false );
}
-void FsmAp::embedCondition( MergeData &md, StateAp *state, Action *condAction )
+void FsmAp::embedCondition( MergeData &md, StateAp *state, Action *condAction, bool sense )
{
ExpansionList expList;
- findEmbedExpansions( expList, state, condAction );
+ findEmbedExpansions( expList, state, condAction, sense );
doExpand( md, state, expList );
doRemove( md, state, expList );
expList.empty();