コード例 #1
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 ReadFieldVisitor(parentIndex, fieldSegment, targetSet);
                LastValueVisitor.VisitValues(values);
            }
コード例 #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)
            {
                ReadFieldVisitor visitor = new ReadFieldVisitor(parentIndex, fieldSegment, collector.mustLocationProcess);

                visitor.VisitValues(values);
            }
コード例 #3
0
        /// <summary>
        /// Processes the field - traverse thru all containing objects. When there is possibility undefined
        /// value in location new object 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 processField(PathSegment segment, MemoryIndex parentIndex, FieldLocationVisitor visitor, bool isMust)
        {
            bool        processOtherValues = false;
            MemoryEntry entry;

            if (snapshot.Data.Readonly.TryGetMemoryEntry(parentIndex, out entry))
            {
                IObjectValueContainer objects = snapshot.Structure.Readonly.GetObjects(parentIndex);
                if (objects.Count > 0)
                {
                    processOtherValues = entry.Count > objects.Count;
                }
                else if (entry.Count > 0)
                {
                    processOtherValues = true;
                }
                else
                {
                    entry = snapshot.EmptyEntry;
                    processOtherValues = true;
                }
            }
            else
            {
                entry = snapshot.EmptyEntry;
                processOtherValues = true;
            }

            if (!snapshot.Structure.Locked && processOtherValues)
            {
                if (entry.Count > 1)
                {
                    isMust = false;
                }

                visitor.ProcessValues(parentIndex, entry.PossibleValues, isMust);
                ReadFieldVisitor valueVisitor    = visitor.LastValueVisitor;
                bool             removeUndefined = isMust;

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

                if (valueVisitor.ContainsUndefinedValue && snapshot.CurrentMode == SnapshotMode.MemoryLevel)
                {
                    ObjectValue objectValue = snapshot.CreateObject(parentIndex, isMust, removeUndefined);
                }
            }

            IObjectValueContainer objectValues = snapshot.Structure.Readonly.GetObjects(parentIndex);

            if (objectValues.Count == 1 && snapshot.HasMustReference(parentIndex))
            {
                IObjectDescriptor descriptor = snapshot.Structure.Readonly.GetDescriptor(objectValues.First());
                creatorVisitor.ObjectValue = objectValues.First();
                processSegment(segment, descriptor, isMust);
            }
            else
            {
                foreach (ObjectValue value in objectValues)
                {
                    IObjectDescriptor descriptor = snapshot.Structure.Readonly.GetDescriptor(value);
                    creatorVisitor.ObjectValue = value;
                    processSegment(segment, descriptor, false);
                }
            }
        }