/// <summary> /// Processes the index - traverse thru array or sets path to undefined. When memory location contains /// no array and undefined value new array 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 processIndex(PathSegment segment, MemoryIndex parentIndex, IndexLocationVisitor visitor, bool isMust) { AssociativeArray arrayValue = null; bool processOtherValues = false; MemoryEntry entry; if (snapshot.Data.Readonly.TryGetMemoryEntry(parentIndex, out entry)) { if (snapshot.Structure.Readonly.TryGetArray(parentIndex, out arrayValue)) { processOtherValues = entry.Count > 1; } else if (entry.Count > 0) { processOtherValues = true; } else { entry = snapshot.EmptyEntry; processOtherValues = true; } } else { entry = snapshot.EmptyEntry; processOtherValues = true; snapshot.Structure.Readonly.TryGetArray(parentIndex, out arrayValue); } if (!snapshot.Structure.Locked && processOtherValues) { visitor.ProcessValues(parentIndex, entry.PossibleValues, isMust); ReadIndexVisitor valueVisitor = visitor.LastValueVisitor; bool removeUndefined = isMust; if (valueVisitor.ContainsDefinedValue || valueVisitor.ContainsAnyValue) { isMust = false; } if (valueVisitor.ContainsUndefinedValue) { if (arrayValue == null) { arrayValue = snapshot.CreateArray(parentIndex, isMust, removeUndefined); } else if (removeUndefined) { snapshot.RemoveUndefinedFromMemoryEntry(parentIndex); } } } if (arrayValue != null) { IArrayDescriptor descriptor = snapshot.Structure.Readonly.GetDescriptor(arrayValue); creatorVisitor.ArrayValue = arrayValue; processSegment(segment, descriptor, isMust); } }
/// <summary> /// Allows 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 ReadIndexVisitor(parentIndex, indexSegment, targetSet); LastValueVisitor.VisitValues(values); }
/// <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) { ReadIndexVisitor visitor = new ReadIndexVisitor(parentIndex, indexSegment, collector.mustLocationProcess); visitor.VisitValues(values); }