/// <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; }
public void VisitField(FieldPathSegment fieldSegment) { foreach (LocationCollectorNode node in currentNodes) { node.CollectField(this, fieldSegment); } }
public FieldLocationVisitor(TreeIndexCollector collector, FieldPathSegment fieldSegment, ValueCollectorNode node) : base(collector.Snapshot.MemoryAssistant) { this.collector = collector; this.fieldSegment = fieldSegment; this.node = node; }
/// <summary> /// Collects the field segment from values. /// </summary> /// <param name="fieldSegment">The field 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 CollectFieldSegmentFromValues(FieldPathSegment fieldSegment, CollectorNode node, IEnumerable <Value> values, bool isMust) { isMust = isMust && values.Count() == 1; CollectFieldValueVisitor visitor = new CollectFieldValueVisitor(fieldSegment, this, node, isMust); visitor.VisitValues(values); }
public CollectFieldValueVisitor(FieldPathSegment fieldSegment, TreeIndexCollector treeIndexCollector, CollectorNode node, bool isMust) { this.fieldSegment = fieldSegment; this.treeIndexCollector = treeIndexCollector; this.node = node; this.isMust = isMust; index = new VariableIdentifier(fieldSegment.Names); }
/// <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); }
/// <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); } }
/// <summary> /// Collects the index of the field from memory. /// </summary> /// <param name="collector">The collector.</param> /// <param name="fieldSegment">The field segment.</param> /// <param name="index">The index.</param> protected void collectFieldFromMemoryIndex(TreeIndexCollector collector, FieldPathSegment fieldSegment, MemoryIndex index) { MemoryEntry entry = collector.GetMemoryEntry(index); this.ContainsUndefinedValue = entry.ContainsUndefinedValue; bool processOtherValues = false; IObjectValueContainer objects = collector.Structure.GetObjects(index); if (objects.Count > 0) { processOtherValues = entry.Count > objects.Count || entry.ContainsUndefinedValue && entry.Count > objects.Count + 1; bool isMustObject = objects.Count == 1 && !processOtherValues && !entry.ContainsUndefinedValue; foreach (var objectValue in objects) { collector.RootNode.CollectObject(collector, objectValue, fieldSegment); } if (entry.ContainsUndefinedValue) { AddNewImplicitObjectNode(false); collector.CollectSegmentWithoutStructure(fieldSegment, ImplicitObjectNode, false); } } else if (entry.ContainsUndefinedValue) { processOtherValues = entry.Count > 1; AddNewImplicitObjectNode(!processOtherValues); collector.CollectSegmentWithoutStructure(fieldSegment, ImplicitObjectNode, !processOtherValues); } else { processOtherValues = true; } if (processOtherValues) { collector.CollectFieldSegmentFromValues(fieldSegment, this, entry.PossibleValues, true); } }
/// <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.Readonly.TryGetMemoryEntry(parentIndex, out entry)) { bool processOtherValues = false; IObjectValueContainer objectValues = snapshot.Structure.Readonly.GetObjects(parentIndex); if (objectValues.Count > 0) { foreach (ObjectValue objectValue in objectValues) { IObjectDescriptor descriptor = snapshot.Structure.Readonly.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; } }
/// <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); } }
public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment) { AddNewImplicitObjectNode(true); collector.CollectSegmentWithoutStructure(fieldSegment, ImplicitObjectNode, true); }
public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment) { collectFieldFromMemoryIndex(collector, fieldSegment, sourceMemoryIndex); }
/// <summary> /// Collects all child nodes by field access. /// </summary> /// <param name="collector">The collector.</param> /// <param name="fieldSegment">The field segment.</param> public abstract void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment);
/// <summary> /// Visits the field. /// </summary> /// <param name="fieldSegment">The field segment.</param> public void VisitField(FieldPathSegment fieldSegment) { CreatedIndex = snapshot.CreateField(Name, ObjectValue, IsMust, true); }
public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment) { FieldLocationVisitor visitor = new FieldLocationVisitor(collector, fieldSegment, this); ValueLocation.Accept(visitor); }
/// <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; }
/// <summary> /// Collects the object. /// </summary> /// <param name="collector">The collector.</param> /// <param name="objectValue">The object value.</param> /// <param name="fieldPathSegment">The field path segment.</param> public void CollectObject(TreeIndexCollector collector, ObjectValue objectValue, FieldPathSegment fieldPathSegment) { ContainerCollectorNode objectNode = GetOrCreateObjectNode(collector, objectValue); objectNode.Collect(collector, fieldPathSegment); }