internal FAContext(FSM fa, StateProvider stateProvider, ReductName reductName, ModelProgram mp) { this.fa = fa; this.stateProvider = stateProvider; this.reductName = reductName; this.mp = mp; this.deadNodes = FsmTraversals.GetDeadStates(fa); this.unsafeNodes = Set<Node>.EmptySet; this.groupingTransitions = Set<Transition>.EmptySet; }
//do postorder traversal private Sequence<ReductName> GetSubFANames(Sequence<FSMBuilder.Branch> treePosition, ModelProgram mp1) { ProductModelProgram pmp = mp1 as ProductModelProgram; if (pmp != null) { Sequence<ReductName> leftChildren = GetSubFANames(treePosition.AddLast(FSMBuilder.Branch.Left), pmp.M1); Sequence<ReductName> rightChildren = GetSubFANames(treePosition.AddLast(FSMBuilder.Branch.Right), pmp.M2); ReductName name = new ReductName(treePosition, new FAName(leftChildren.Last.name,rightChildren.Last.name)); return leftChildren.Concatentate(rightChildren).AddLast(name); } else { return new Sequence<ReductName>(new ReductName(treePosition, GetModelName(mp1))); } }
//Dictionary<ReductName, FAContext> reductCache = new Dictionary<ReductName, FAContext>(); private void ShowReduct(ReductName reductName) { FAContext faContext1; //if (!reductCache.TryGetValue(reductName, out faContext1)) //{ Dictionary<Term, IState> reductStateMap; Dictionary<Term, IState> stateMap = new Dictionary<Term, IState>(); foreach (Term t in faInfo.fa.States) { stateMap[t] = faInfo.stateProvider(t); } FSM fa = FSMBuilder.ProjectFromProduct(faInfo.fa, ProjectedActionSymbols(reductName.treePosition), reductName.treePosition, stateMap, out reductStateMap); faContext1 = new FAContext(fa, delegate(Term n) { return reductStateMap[n]; }, reductName, ProjectedModelProgram(reductName.treePosition));//+++ //reductCache[reductName] = faContext1; //} finiteAutomatonContext = faContext1; graphChanged = true; this.selectedAglNode = null; //forget previous selected glee node this.selectedNode = null; //forget previous selected corresponding node PerformLayout(); }