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); }
internal FA SynthesizeOneOrNone(FA synth) { FA tempFA = new FA(); //2.Merge graph CGraph.CMergeGraphOperation merged = tempFA.Merge(synth, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT); merged.MergeGraphInfo(synth, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); merged.MergeGraphInfo(synth, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); merged.MergeGraphInfo(synth, GraphElementType.ET_NODE, FA.m_FAINFOKEY); CGraphNode il = tempFA.CreateGraphNode <CGraphNode>(); tempFA.AddGraphEdge <CGraphEdge, CGraphNode>(il, merged.GetMirrorNode(synth.M_Initial), GraphType.GT_DIRECTED); CGraphNode fl = tempFA.CreateGraphNode <CGraphNode>(); tempFA.AddGraphEdge <CGraphEdge, CGraphNode>(merged.GetMirrorNode(synth.GetFinalStates()[0]), fl, GraphType.GT_DIRECTED); //4.Create the initial and the final node tempFA.M_Initial = il; tempFA.SetFinalState(fl); tempFA.UpdateAlphabet(); tempFA.AddGraphEdge <CGraphEdge, CGraphNode>(il, fl, GraphType.GT_DIRECTED); //7.Return result return(tempFA); }
internal FA Synthesize(FA l, FA r) { FA tempFA = new FA(); //2.Merge left graph CGraph.CMergeGraphOperation lmerge = tempFA.Merge(l, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT); lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY); CGraphNode il = lmerge.GetMirrorNode(l.M_Initial); CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]); //3.Merge right graph CGraph.CMergeGraphOperation rmerge = tempFA.Merge(r, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT); rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY); CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial); CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]); //4.Create the initial and the final node tempFA.M_Initial = il; tempFA.SetFinalState(fr); tempFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, ir, GraphType.GT_DIRECTED); //7.Return result return(tempFA); }
internal FA Sythesize(FA l, FA r, CGraph.CMergeGraphOperation.MergeOptions options) { //1.Create FA m_currentFA = new FA(); m_ThompsonInfo = new ThompsonInfo(m_currentFA, m_ThompsonInfoKey); //2.Merge left graph CGraph.CMergeGraphOperation lmerge = m_currentFA.Merge(l, options); //Console.WriteLine(l.ToString()); lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, m_ThompsonInfoKey); lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, m_ThompsonInfoKey); lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, m_ThompsonInfoKey); CGraphNode il = lmerge.GetMirrorNode(l.M_Initial); CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]); //3.Merge right graph CGraph.CMergeGraphOperation rmerge = m_currentFA.Merge(r, options); rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, m_ThompsonInfoKey); rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, m_ThompsonInfoKey); rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, m_ThompsonInfoKey); CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial); CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]); //4.Create the initial and the final node CGraphNode FAinit = m_currentFA.CreateGraphNode <CGraphNode>(); CGraphNode FAfinal = m_currentFA.CreateGraphNode <CGraphNode>(); m_ThompsonInfo.InitNodeInfo(FAinit, new ThompsonNodeFAInfo()); m_ThompsonInfo.InitNodeInfo(FAfinal, new ThompsonNodeFAInfo()); m_currentFA.M_Initial = FAinit; m_currentFA.SetFinalState(FAfinal); m_currentFA.UpdateAlphabet(); m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, il, GraphType.GT_DIRECTED); m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, ir, GraphType.GT_DIRECTED); m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(fr, FAfinal, GraphType.GT_DIRECTED); m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, FAfinal, GraphType.GT_DIRECTED); // Update closure information from operand closure // Update closure information from operand closure UpdateClosureInformation(l, m_currentFA, lmerge); UpdateClosureInformation(r, m_currentFA, rmerge); //7.Return result return(m_currentFA); }
internal FA Synthesize(FA l, FA r) { FA m_currentFA = new FA(); m_ThompsonInfo = new ThompsonInfo(m_currentFA, m_ThompsonInfoKey); //2.Merge left graph CGraph.CMergeGraphOperation lmerge = m_currentFA.Merge(l, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT); lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, m_ThompsonInfoKey); lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, m_ThompsonInfoKey); lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, m_ThompsonInfoKey); CGraphNode il = lmerge.GetMirrorNode(l.M_Initial); CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]); //3.Merge right graph CGraph.CMergeGraphOperation rmerge = m_currentFA.Merge(r, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT); rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, m_ThompsonInfoKey); rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, m_ThompsonInfoKey); rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, m_ThompsonInfoKey); CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial); CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]); //4.Create the initial and the final node m_currentFA.M_Initial = il; m_currentFA.SetFinalState(fr); m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, ir, GraphType.GT_DIRECTED); // Update closure information from operand closure UpdateClosureInformation(l, m_currentFA, lmerge); UpdateClosureInformation(r, m_currentFA, rmerge); //7.Return result return(m_currentFA); }
internal FA Sythesize(FA l, FA r, CGraph.CMergeGraphOperation.MergeOptions options) { //1.Create FA FA templateFA = new FA(); //2.Merge left graph CGraph.CMergeGraphOperation lmerge = templateFA.Merge(l, options); //Console.WriteLine(l.ToString()); lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY); CGraphNode il = lmerge.GetMirrorNode(l.M_Initial); CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]); //3.Merge right graph CGraph.CMergeGraphOperation rmerge = templateFA.Merge(r, options); rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY); rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY); CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial); CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]); //4.Create the initial and the final node CGraphNode FAinit = templateFA.CreateGraphNode <CGraphNode>(); CGraphNode FAfinal = templateFA.CreateGraphNode <CGraphNode>(); templateFA.M_Initial = FAinit; templateFA.SetFinalState(FAfinal); templateFA.UpdateAlphabet(); templateFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, il, GraphType.GT_DIRECTED); templateFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, ir, GraphType.GT_DIRECTED); templateFA.AddGraphEdge <CGraphEdge, CGraphNode>(fr, FAfinal, GraphType.GT_DIRECTED); templateFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, FAfinal, GraphType.GT_DIRECTED); //7.Return result return(templateFA); }