예제 #1
0
        /// <summary>
        /// Processes the index - traverse thru array or sets path to undefined. When memory location contains
        /// no array and undefined value new array is created.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="parentIndex">Index of the parent.</param>
        /// <param name="visitor">The visitor to process scalar values.</param>
        /// <param name="isMust">if set to <c>true</c> [is must].</param>
        private void processIndex(PathSegment segment, MemoryIndex parentIndex, IndexLocationVisitor visitor, bool isMust)
        {
            AssociativeArray arrayValue         = null;
            bool             processOtherValues = false;
            MemoryEntry      entry;

            if (snapshot.Data.TryGetMemoryEntry(parentIndex, out entry))
            {
                if (snapshot.Structure.TryGetArray(parentIndex, out arrayValue))
                {
                    processOtherValues = entry.Count > 1;
                }
                else if (entry.Count > 0)
                {
                    processOtherValues = true;
                }
                else
                {
                    entry = snapshot.Data.EmptyEntry;
                    processOtherValues = true;
                }
            }
            else
            {
                entry = snapshot.Data.EmptyEntry;
                processOtherValues = true;
                snapshot.Structure.TryGetArray(parentIndex, out arrayValue);
            }

            if (processOtherValues)
            {
                visitor.ProcessValues(parentIndex, entry.PossibleValues, isMust);
                ReadIndexVisitor valueVisitor    = visitor.LastValueVisitor;
                bool             removeUndefined = isMust;

                if (valueVisitor.ContainsDefinedValue || valueVisitor.ContainsAnyValue)
                {
                    isMust = false;
                }

                if (valueVisitor.ContainsUndefinedValue)
                {
                    if (arrayValue == null)
                    {
                        arrayValue = snapshot.CreateArray(parentIndex, isMust, removeUndefined);
                    }
                    else if (removeUndefined)
                    {
                        snapshot.Structure.Data.RemoveUndefined(parentIndex);
                    }
                }
            }

            if (arrayValue != null)
            {
                ArrayDescriptor descriptor = snapshot.Structure.GetDescriptor(arrayValue);
                creatorVisitor.ArrayValue = arrayValue;
                processSegment(segment, descriptor, isMust);
            }
        }
예제 #2
0
        /// <summary>
        /// Visits the index to continue traversing memory tree by array index.
        /// </summary>
        /// <param name="indexSegment">The index segment.</param>
        public void VisitIndex(IndexPathSegment indexSegment)
        {
            IndexLocationVisitor visitor = new IndexLocationVisitor(indexSegment, this);

            foreach (MemoryIndex parentIndex in mustIndexes)
            {
                processIndex(parentIndex, indexSegment, visitor);
            }

            foreach (ValueLocation parentLocation in mustLocation)
            {
                parentLocation.Accept(visitor);
            }
        }
예제 #3
0
        /// <summary>
        /// Visits the index to continue traversing memory tree by array index.
        /// </summary>
        /// <param name="segment">The segment.</param>
        public void VisitIndex(IndexPathSegment segment)
        {
            IndexLocationVisitor visitor = new IndexLocationVisitor(segment, snapshot.MemoryAssistant, mustLocationProcess, mayLocationProcess);

            visitor.IsMust = true;
            foreach (MemoryIndex index in mustIndexes)
            {
                processIndex(segment, index, visitor, true);
            }
            foreach (ValueLocation location in mustLocation)
            {
                location.Accept(visitor);
            }

            visitor.IsMust = false;
            foreach (MemoryIndex index in mayIndexes)
            {
                processIndex(segment, index, visitor, false);
            }
            foreach (ValueLocation location in mayLocation)
            {
                location.Accept(visitor);
            }
        }
예제 #4
0
        public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment)
        {
            IndexLocationVisitor visitor = new IndexLocationVisitor(collector, indexSegment, this);

            ValueLocation.Accept(visitor);
        }