示例#1
0
        /// <summary>
        /// Processes the index - traverse thru array or sets path to undefined.
        /// </summary>
        /// <param name="parentIndex">Index of the parent.</param>
        /// <param name="indexSegment">The index segment.</param>
        /// <param name="visitor">The visitor to process scalar values.</param>
        private void processIndex(MemoryIndex parentIndex, IndexPathSegment indexSegment, ProcessValueAsLocationVisitor visitor)
        {
            MemoryEntry entry;

            if (snapshot.Data.TryGetMemoryEntry(parentIndex, out entry))
            {
                bool             processOtherValues = false;
                AssociativeArray arrayValue;
                if (snapshot.Structure.TryGetArray(parentIndex, out arrayValue))
                {
                    ArrayDescriptor descriptor = snapshot.Structure.GetDescriptor(arrayValue);
                    process(indexSegment, descriptor);

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

                if (processOtherValues)
                {
                    visitor.ProcessValues(parentIndex, entry.PossibleValues, true);
                }
            }
            else
            {
                IsDefined = false;
            }
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IndexLocationVisitor"/> class.
 /// </summary>
 /// <param name="indexSegment">The index 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 IndexLocationVisitor(IndexPathSegment indexSegment, MemoryAssistantBase assistant, HashSet <ValueLocation> mustLocationProcess, HashSet <ValueLocation> mayLocationProcess)
     : base(assistant)
 {
     this.indexSegment        = indexSegment;
     this.mustLocationProcess = mustLocationProcess;
     this.mayLocationProcess  = mayLocationProcess;
 }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadIndexVisitor"/> class.
        /// </summary>
        /// <param name="containingIndex">Index of the containing.</param>
        /// <param name="indexSegment">The index segment.</param>
        /// <param name="locations">The locations.</param>
        public ReadIndexVisitor(MemoryIndex containingIndex, IndexPathSegment indexSegment, ICollection <ValueLocation> locations)
        {
            this.containingIndex = containingIndex;
            this.locations       = locations;

            ContainsUndefinedValue = false;
            ContainsDefinedValue   = false;
            ContainsArrayValue     = false;
            ContainsAnyValue       = false;

            index = new MemberIdentifier(indexSegment.Names);
        }
示例#4
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);
            }
        }
示例#5
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);
            }
        }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IndexLocationVisitor"/> class.
 /// </summary>
 /// <param name="indexSegment">The index segment.</param>
 /// <param name="collector">The collector.</param>
 public IndexLocationVisitor(IndexPathSegment indexSegment, ReadCollector collector)
     : base(collector.snapshot.MemoryAssistant)
 {
     this.indexSegment = indexSegment;
     this.collector    = collector;
 }
示例#7
0
 /// <summary>
 /// Visits the index.
 /// </summary>
 /// <param name="indexSegment">The index segment.</param>
 public void VisitIndex(IndexPathSegment indexSegment)
 {
     CreatedIndex = snapshot.CreateIndex(Name, ArrayValue, IsMust, true);
 }