Пример #1
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;
 }
Пример #2
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.Readonly.TryGetMemoryEntry(parentIndex, out entry))
            {
                bool             processOtherValues = false;
                AssociativeArray arrayValue;
                if (snapshot.Structure.Readonly.TryGetArray(parentIndex, out arrayValue))
                {
                    IArrayDescriptor descriptor = snapshot.Structure.Readonly.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;
            }
        }
Пример #3
0
 public void VisitIndex(IndexPathSegment indexSegment)
 {
     foreach (LocationCollectorNode node in currentNodes)
     {
         node.CollectIndex(this, indexSegment);
     }
 }
Пример #4
0
 public IndexLocationVisitor(TreeIndexCollector collector, IndexPathSegment indexSegment,
                             ValueCollectorNode node)
     : base(collector.Snapshot.MemoryAssistant)
 {
     this.collector    = collector;
     this.indexSegment = indexSegment;
     this.node         = node;
 }
Пример #5
0
        public CollectIndexValueVisitor(IndexPathSegment indexSegment, TreeIndexCollector treeIndexCollector, CollectorNode node, bool isMust)
        {
            this.indexSegment       = indexSegment;
            this.treeIndexCollector = treeIndexCollector;
            this.node   = node;
            this.isMust = isMust;

            index = new MemberIdentifier(indexSegment.Names);
        }
Пример #6
0
        /// <summary>
        /// Collects the index segment from values.
        /// </summary>
        /// <param name="indexSegment">The index segment.</param>
        /// <param name="node">The node.</param>
        /// <param name="values">The values.</param>
        /// <param name="isMust">if set to <c>true</c> [is must].</param>
        public void CollectIndexSegmentFromValues(IndexPathSegment indexSegment, CollectorNode node,
                                                  IEnumerable <Value> values, bool isMust)
        {
            isMust = isMust && values.Count() == 1;

            CollectIndexValueVisitor visitor = new CollectIndexValueVisitor(indexSegment, this, node, isMust);

            visitor.VisitValues(values);
        }
Пример #7
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);
        }
Пример #8
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);
            }
        }
Пример #9
0
        /// <summary>
        /// Collects the index of the index from memory.
        /// </summary>
        /// <param name="collector">The collector.</param>
        /// <param name="indexSegment">The index segment.</param>
        /// <param name="index">The index.</param>
        protected void CollectIndexFromMemoryIndex(TreeIndexCollector collector, IndexPathSegment indexSegment, MemoryIndex index)
        {
            MemoryEntry entry = collector.GetMemoryEntry(index);

            this.ContainsUndefinedValue = entry.ContainsUndefinedValue;
            bool processOtherValues = false;

            AssociativeArray arrayValue;

            if (collector.Structure.TryGetArray(index, out arrayValue))
            {
                if (entry.ContainsUndefinedValue)
                {
                    processOtherValues = entry.Count > 2;
                }
                else
                {
                    processOtherValues = entry.Count > 1;
                }

                IArrayDescriptor descriptor = collector.Structure.GetDescriptor(arrayValue);
                collector.CollectSegmentFromStructure(indexSegment, this, descriptor, !processOtherValues);
            }
            else if (entry.ContainsUndefinedValue)
            {
                processOtherValues = entry.Count > 1;

                this.HasNewImplicitArray = true;
                collector.CollectSegmentWithoutStructure(indexSegment, this, !processOtherValues);
            }
            else
            {
                processOtherValues = true;
            }

            if (processOtherValues)
            {
                collector.CollectIndexSegmentFromValues(indexSegment, this, entry.PossibleValues, true);
            }
        }
Пример #10
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);
            }
        }
Пример #11
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;
 }
Пример #12
0
 public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment)
 {
     HasNewImplicitArray = true;
     collector.CollectSegmentWithoutStructure(indexSegment, this, true);
 }
Пример #13
0
 public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment)
 {
     CollectIndexFromMemoryIndex(collector, indexSegment, sourceMemoryIndex);
 }
Пример #14
0
        public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment)
        {
            IndexLocationVisitor visitor = new IndexLocationVisitor(collector, indexSegment, this);

            ValueLocation.Accept(visitor);
        }
Пример #15
0
 /// <summary>
 /// Collects all nodes by index access.
 /// </summary>
 /// <param name="collector">The collector.</param>
 /// <param name="indexSegment">The index segment.</param>
 public abstract void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment);
Пример #16
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);
 }