示例#1
0
    protected FAInfo UpdateClosureInformation(FA synth, FA currentFA, CGraph.CMergeGraphOperation mergeOperation)
    {
        FAInfo closureOperandInfo = synth.GetFAInfo();     // get access to the closure operand FA
        FAInfo currentFAInfo      = currentFA.GetFAInfo(); // get access to the current FA info

        foreach (FALoop faLoop in closureOperandInfo.MLoopsInFa.Values)
        {
            FALoop     newloop = new FALoop();
            CGraphNode entry   = faLoop.MEntryNode;
            newloop.MEntryNode = mergeOperation.GetMirrorNode(entry);
            CGraphNode exit = faLoop.MExitNode;
            newloop.MExitNode = mergeOperation.GetMirrorNode(exit);
            foreach (CGraphNode cGraphNode in faLoop.MParticipatingNodes)
            {
                newloop.MParticipatingNodes.Add(mergeOperation.GetMirrorNode(cGraphNode));
            }
            FALoop.ClosureType closureType = faLoop.MClosureType;
            Range <int>        clsrng      = faLoop.MClosureRange;
            if (clsrng != null)
            {
                newloop.MClosureRange = new Range <int>(clsrng);
            }
            newloop.MClosureType = faLoop.MClosureType;
            newloop.MLoopSerial  = faLoop.MLoopSerial;
            currentFAInfo.AddFALoop(newloop);
        }

        return(currentFAInfo);
    }
示例#2
0
    private FA CreateNewFA(FA synth)
    {
        CGraphNode oldEntryNode, oldExitNode;
        FA         m_currentFA = new FA();

        m_ThompsonInfo = new ThompsonInfo(m_currentFA, m_ThompsonInfoKey);
        m_ThompsonInfo.InitFAInfo(new ThompsonFAInfo());

        //2.Merge graph
        m_mergeOperation = m_currentFA.Merge(synth, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        // Create boundary nodes
        m_newFASource = m_currentFA.CreateGraphNode <CGraphNode>();
        m_ThompsonInfo.InitNodeInfo(m_newFASource, new ThompsonNodeFAInfo());

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(m_newFASource, m_mergeOperation.GetMirrorNode(synth.M_Initial), GraphType.GT_DIRECTED);
        m_newFATarget = m_currentFA.CreateGraphNode <CGraphNode>();
        m_ThompsonInfo.InitNodeInfo(m_newFATarget, new ThompsonNodeFAInfo());

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(m_mergeOperation.GetMirrorNode(synth.GetFinalStates()[0]), m_newFATarget, GraphType.GT_DIRECTED);

        //4.Create the initial and the final node
        oldEntryNode          = m_mergeOperation.GetMirrorNode(synth.M_Initial);
        oldExitNode           = m_mergeOperation.GetMirrorNode(synth.GetFinalStates()[0]);
        m_currentFA.M_Initial = m_newFASource;
        m_currentFA.SetFinalState(m_newFATarget);
        m_currentFA.UpdateAlphabet();

        // Update closure information from operand closure
        FAInfo currentFAInfo = UpdateClosureInformation(synth, m_currentFA, m_mergeOperation);

        // Update closure information from current closure
        m_currentFAloop             = new FALoop();
        m_currentFAloop.MEntryNode  = oldEntryNode;
        m_currentFAloop.MExitNode   = oldExitNode;
        m_currentFAloop.MLoopSerial = m_currentClosureSerial;
        CIt_GraphNodes it = new CIt_GraphNodes(m_currentFA);

        for (it.Begin(); !it.End(); it.Next())
        {
            if (it.M_CurrentItem != m_currentFA.M_Initial &&
                it.M_CurrentItem != m_currentFA.GetFinalStates()[0])
            {
                m_currentFAloop.MParticipatingNodes.Add(it.M_CurrentItem);
            }
        }
        // Add new closure to the current FA
        currentFAInfo.AddFALoop(m_currentFAloop);

        return(m_currentFA);
    }