Пример #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>
            /// Allews descendant implementation to continue traversing memory by indexing values ar accesing their fields.
            /// </summary>
            /// <param name="parentIndex">Index of the parent.</param>
            /// <param name="values">The values.</param>
            /// <param name="isMust">if set to <c>true</c> is must.</param>
            public override void ProcessValues(MemoryIndex parentIndex, IEnumerable <Value> values, bool isMust)
            {
                HashSet <ValueLocation> targetSet = mayLocationProcess;

                if (isMust && values.Count() == 1)
                {
                    targetSet = mustLocationProcess;
                }

                LastValueVisitor = new ReadIndexVisitor(parentIndex, indexSegment, targetSet);
                LastValueVisitor.VisitValues(values);
            }
Пример #3
0
            /// <summary>
            /// Allews descendant implementation to continue traversing memory by indexing values ar accesing their fields.
            /// </summary>
            /// <param name="parentIndex">Index of the parent.</param>
            /// <param name="values">The values.</param>
            /// <param name="isMust">if set to <c>true</c> is must.</param>
            public override void ProcessValues(MemoryIndex parentIndex, IEnumerable <Value> values, bool isMust)
            {
                ReadIndexVisitor visitor = new ReadIndexVisitor(parentIndex, indexSegment, collector.mustLocationProcess);

                visitor.VisitValues(values);
            }