/// <summary> /// Collects the control variables. /// </summary> /// <param name="collector">The collector.</param> /// <param name="controlPathSegment">The control path segment.</param> public void CollectControl(TreeIndexCollector collector, ControlPathSegment controlPathSegment) { int currentCallLevel = collector.GetCurrentCallLevel(); ContainerCollectorNode controlStackNode = GetOrCreateControlStackNode(collector, currentCallLevel); controlStackNode.Collect(collector, controlPathSegment); HasRootNode = true; }
public IndexLocationVisitor(TreeIndexCollector collector, IndexPathSegment indexSegment, ValueCollectorNode node) : base(collector.Snapshot.MemoryAssistant) { this.collector = collector; this.indexSegment = indexSegment; this.node = node; }
/// <summary> /// Collects the variable. /// </summary> /// <param name="collector">The collector.</param> /// <param name="variableSegment">The variable segment.</param> public void CollectVariable(TreeIndexCollector collector, VariablePathSegment variableSegment) { int currentCallLevel = collector.GetCurrentCallLevel(); ContainerCollectorNode variableStackNode = GetOrCreateVariableStackNode(collector, currentCallLevel); variableStackNode.Collect(collector, variableSegment); HasRootNode = true; }
public FieldLocationVisitor(TreeIndexCollector collector, FieldPathSegment fieldSegment, ValueCollectorNode node) : base(collector.Snapshot.MemoryAssistant) { this.collector = collector; this.fieldSegment = fieldSegment; this.node = node; }
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); }
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> /// Gets the or create object node. /// </summary> /// <param name="collector">The collector.</param> /// <param name="objectValue">The object value.</param> /// <returns>Node representing given object</returns> public ContainerCollectorNode GetOrCreateObjectNode(TreeIndexCollector collector, ObjectValue objectValue) { ContainerCollectorNode objectNode; if (!ObjectNodes.TryGetValue(objectValue, out objectNode)) { IObjectDescriptor descriptor = collector.Structure.GetDescriptor(objectValue); objectNode = new ContainerCollectorNode(descriptor); ObjectNodes.Add(objectValue, objectNode); } return(objectNode); }
/// <summary> /// Gets the or create control stack node. /// </summary> /// <param name="collector">The collector.</param> /// <param name="callLevel">The call level.</param> /// <returns>Node representing stack context on specified level.</returns> public ContainerCollectorNode GetOrCreateControlStackNode(TreeIndexCollector collector, int callLevel) { ContainerCollectorNode controlStackNode; if (!ControlStackNodes.TryGetValue(callLevel, out controlStackNode)) { IReadonlyIndexContainer indexContainer = collector.Structure .GetReadonlyStackContext(callLevel).ReadonlyControllVariables; controlStackNode = new ContainerCollectorNode(indexContainer); ControlStackNodes.Add(callLevel, controlStackNode); } return(controlStackNode); }
/// <summary> /// Collects the temporary variables. /// </summary> /// <param name="treeIndexCollector">The tree index collector.</param> /// <param name="temporaryPathSegment">The temporary path segment.</param> /// <exception cref="System.NotImplementedException">Temporary memory index is visited more than once</exception> public void CollectTemporary(TreeIndexCollector treeIndexCollector, TemporaryPathSegment temporaryPathSegment) { if (TemporaryNodes.ContainsKey(temporaryPathSegment.TemporaryIndex)) { throw new NotImplementedException("Temporary memory index is visited more than once"); } MemoryIndexCollectorNode node = new MemoryIndexCollectorNode(temporaryPathSegment.TemporaryIndex); node.IsMust = true; TemporaryNodes.Add(temporaryPathSegment.TemporaryIndex, node); treeIndexCollector.AddNode(node); HasRootNode = true; }
/// <summary> /// Gets the or create variable stack node. /// </summary> /// <param name="collector">The collector.</param> /// <param name="callLevel">The call level.</param> /// <returns></returns> public ContainerCollectorNode GetOrCreateVariableStackNode(TreeIndexCollector collector, int callLevel) { ContainerCollectorNode variableStackNode; if (!VariableStackNodes.TryGetValue(callLevel, out variableStackNode)) { IReadonlyIndexContainer indexContainer = collector.Structure .GetReadonlyStackContext(callLevel).ReadonlyVariables; variableStackNode = new ContainerCollectorNode(indexContainer); VariableStackNodes.Add(callLevel, variableStackNode); } return(variableStackNode); }
/// <summary> /// Collects the index of the aliases from memory. /// </summary> /// <param name="collector">The collector.</param> /// <param name="index">The index.</param> protected void CollectAliasesFromMemoryIndex(TreeIndexCollector collector, MemoryIndex index) { IMemoryAlias aliases; if (collector.Structure.TryGetAliases(index, out aliases)) { foreach (MemoryIndex alias in aliases.MustAliases) { collector.CollectAlias(this, alias, IsMust); } foreach (MemoryIndex alias in aliases.MayAliases) { collector.CollectAlias(this, alias, false); } } }
/// <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> /// 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); } }
public void Collect(TreeIndexCollector collector, PathSegment pathSegment) { collector.CollectSegmentFromStructure(pathSegment, this, indexContainer, true); }
public CollectAliasMemoryIndexVisitor(TreeIndexCollector collector, RootCollectorNode rootNode, bool isMust) { this.rootNode = rootNode; this.collector = collector; this.isMust = isMust; }
public override void CollectAliases(TreeIndexCollector collector) { // Do nothing - values can not have any alias }
public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment) { IndexLocationVisitor visitor = new IndexLocationVisitor(collector, indexSegment, this); ValueLocation.Accept(visitor); }
/// <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); }
public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment) { FieldLocationVisitor visitor = new FieldLocationVisitor(collector, fieldSegment, this); ValueLocation.Accept(visitor); }
/// <summary> /// Collects the alias. /// </summary> /// <param name="collector">The collector.</param> /// <param name="aliasIndex">Index of the alias.</param> /// <param name="isMust">if set to <c>true</c> [is must].</param> public void CollectAlias(TreeIndexCollector collector, MemoryIndex aliasIndex, bool isMust) { CollectAliasMemoryIndexVisitor visitor = new CollectAliasMemoryIndexVisitor(collector, this, isMust); aliasIndex.Accept(visitor); }
public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment) { HasNewImplicitArray = true; collector.CollectSegmentWithoutStructure(indexSegment, this, true); }
public override void CollectAliases(TreeIndexCollector collector) { CollectAliasesFromMemoryIndex(collector, sourceMemoryIndex); }
public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment) { collectFieldFromMemoryIndex(collector, fieldSegment, sourceMemoryIndex); }
public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment) { CollectIndexFromMemoryIndex(collector, indexSegment, 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);
public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment) { AddNewImplicitObjectNode(true); collector.CollectSegmentWithoutStructure(fieldSegment, ImplicitObjectNode, true); }
/// <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);
public override void CollectAliases(TreeIndexCollector collector) { // Do nothing - undefined index can not have any alias }
/// <summary> /// Collects all aliases to target node. /// </summary> /// <param name="collector">The collector.</param> public abstract void CollectAliases(TreeIndexCollector collector);