Exemple #1
0
            /// <summary>
            /// If there is a complex projection and new entry is inserted that breaks the complex projection
            /// invariants, then this node needs to be refactored.
            /// </summary>
            private void RefectorComplexProjections()
            {
                //// Not in a complex projection state.
                Term cp = null;

                if (refinements != null || projections == null || projections.Count != 1 || (cp = projections.GetSomeKey()).Symbol.Arity == 0)
                {
                    return;
                }

                //// Otherwise, need to expand on constructor and push complex projections down into refinements.
                Term      t;
                ShapeNode n;
                var       children = new ShapeNode[cp.Symbol.Arity];
                var       entries  = projections[cp];

                for (int i = 0; i < children.Length; ++i)
                {
                    t           = cp.Args[i];
                    children[i] = n = new ShapeNode();
                    foreach (var e in entries)
                    {
                        n.AddProjection(t, e);
                        ++n.NEntries;
                    }
                }

                refinements = new Map <UserSymbol, ShapeNode[]>(Symbol.Compare);
                refinements.Add((UserSymbol)cp.Symbol, children);
                projections.Remove(cp);
            }