Exemple #1
0
        /// <summary>
        /// Visits the field to continue traversing memory tree by object field.
        /// </summary>
        /// <param name="fieldSegment">The field segment.</param>
        public void VisitField(FieldPathSegment fieldSegment)
        {
            FieldLocationVisitor visitor = new FieldLocationVisitor(fieldSegment, this);

            foreach (MemoryIndex parentIndex in mustIndexes)
            {
                processField(parentIndex, fieldSegment, visitor);
            }

            foreach (ValueLocation parentLocation in mustLocation)
            {
                parentLocation.Accept(visitor);
            }
        }
Exemple #2
0
        /// <summary>
        /// Visits the field to continue traversing memory tree by object field.
        /// </summary>
        /// <param name="segment">The segment.</param>
        public void VisitField(FieldPathSegment segment)
        {
            FieldLocationVisitor visitor = new FieldLocationVisitor(segment, snapshot.MemoryAssistant, mustLocationProcess, mayLocationProcess);

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

            visitor.IsMust = false;
            foreach (MemoryIndex index in MayIndexes)
            {
                processField(segment, index, visitor, false);
            }
            foreach (ValueLocation location in mayLocation)
            {
                location.Accept(visitor);
            }
        }
Exemple #3
0
        public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment)
        {
            FieldLocationVisitor visitor = new FieldLocationVisitor(collector, fieldSegment, this);

            ValueLocation.Accept(visitor);
        }
Exemple #4
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.Structure.TryGetMemoryEntry(parentIndex, out entry))
            {
                ObjectValueContainer objects = snapshot.Structure.GetObjects(parentIndex);
                if (objects.Count > 0)
                {
                    processOtherValues = entry.Count > objects.Count;
                }
                else if (entry.Count > 0)
                {
                    processOtherValues = true;
                }
                else
                {
                    entry = snapshot.Data.EmptyEntry;
                    processOtherValues = true;
                }
            }
            else
            {
                entry = snapshot.Data.EmptyEntry;
                processOtherValues = true;
            }

            if (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);
                }
            }

            ObjectValueContainer objectValues = snapshot.Structure.GetObjects(parentIndex);

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