Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldLocationVisitor"/> class.
 /// </summary>
 /// <param name="fieldSegment">The field segment.</param>
 /// <param name="assistant">The assistant.</param>
 /// <param name="mustLocationProcess">The must location process.</param>
 /// <param name="mayLocationProcess">The may location process.</param>
 public FieldLocationVisitor(FieldPathSegment fieldSegment, MemoryAssistantBase assistant, HashSet <ValueLocation> mustLocationProcess, HashSet <ValueLocation> mayLocationProcess)
     : base(assistant)
 {
     this.fieldSegment        = fieldSegment;
     this.mustLocationProcess = mustLocationProcess;
     this.mayLocationProcess  = mayLocationProcess;
 }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadFieldVisitor"/> class.
        /// </summary>
        /// <param name="containingIndex">Index of the containing.</param>
        /// <param name="fieldSegment">The field segment.</param>
        /// <param name="locations">The locations.</param>
        public ReadFieldVisitor(MemoryIndex containingIndex, FieldPathSegment fieldSegment, ICollection <ValueLocation> locations)
        {
            this.containingIndex = containingIndex;
            this.locations       = locations;

            ContainsUndefinedValue = false;
            ContainsDefinedValue   = false;
            ContainsObjectValue    = false;
            ContainsAnyValue       = false;

            index = new VariableIdentifier(fieldSegment.Names);
        }
Пример #3
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);
            }
        }
Пример #4
0
        /// <summary>
        /// Processes the field - traverse thru all containing objects or sets path to undefined.
        /// </summary>
        /// <param name="parentIndex">Index of the parent.</param>
        /// <param name="fieldSegment">The field segment.</param>
        /// <param name="visitor">The visitor to process scalar values.</param>
        private void processField(MemoryIndex parentIndex, FieldPathSegment fieldSegment, ProcessValueAsLocationVisitor visitor)
        {
            MemoryEntry entry;

            if (snapshot.Data.TryGetMemoryEntry(parentIndex, out entry))
            {
                bool processOtherValues           = false;
                ObjectValueContainer objectValues = snapshot.Structure.GetObjects(parentIndex);
                if (objectValues.Count > 0)
                {
                    foreach (ObjectValue objectValue in objectValues)
                    {
                        ObjectDescriptor descriptor = snapshot.Structure.GetDescriptor(objectValue);
                        process(fieldSegment, descriptor);
                    }

                    processOtherValues = entry.Count > objectValues.Count;
                }
                else if (entry.Count > 0)
                {
                    processOtherValues = true;
                }
                else
                {
                    IsDefined = false;
                }

                if (processOtherValues)
                {
                    visitor.ProcessValues(parentIndex, entry.PossibleValues, true);
                }
            }
            else
            {
                IsDefined = false;
            }
        }
Пример #5
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);
            }
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldLocationVisitor"/> class.
 /// </summary>
 /// <param name="fieldSegment">The field segment.</param>
 /// <param name="collector">The collector.</param>
 public FieldLocationVisitor(FieldPathSegment fieldSegment, ReadCollector collector)
     : base(collector.snapshot.MemoryAssistant)
 {
     this.fieldSegment = fieldSegment;
     this.collector    = collector;
 }
Пример #7
0
 /// <summary>
 /// Visits the field.
 /// </summary>
 /// <param name="fieldSegment">The field segment.</param>
 public void VisitField(FieldPathSegment fieldSegment)
 {
     CreatedIndex = snapshot.CreateField(Name, ObjectValue, IsMust, true);
 }