Example #1
0
        private bool testAndProcessReturnedNode(string name, CollectorNode node, bool isMust)
        {
            MemoryCollectorNode childNode;

            if (node.NamedChildNodes != null && node.NamedChildNodes.TryGetValue(name, out childNode))
            {
                if (isMust)
                {
                    node.NamedChildNodes.Remove(name);

                    return(true);
                }
                else
                {
                    AddNode(childNode);
                    childNode.IsMust = false;

                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Example #2
0
        /// <summary>
        /// Collects the segment from structure.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="node">The node.</param>
        /// <param name="indexContainer">The index container.</param>
        /// <param name="isMust">if set to <c>true</c> [is must].</param>
        public void CollectSegmentFromStructure(PathSegment segment, CollectorNode node,
                                                IReadonlyIndexContainer indexContainer, bool isMust)
        {
            isMust = isMust && node.IsMust;

            if (segment.IsAny)
            {
                collectMemoryIndexAnyNode(indexContainer.UnknownIndex, node);

                foreach (var item in indexContainer.Indexes)
                {
                    collectMemoryIndexExpandedNode(item.Key, item.Value, node);
                }
            }
            else if (segment.IsUnknown)
            {
                collectMemoryIndexAnyNode(indexContainer.UnknownIndex, node);
            }
            else if (segment.Names.Count == 1)
            {
                string name = segment.Names[0];
                collectMemoryIndexNode(name, node, indexContainer, isMust);
            }
            else
            {
                foreach (string name in segment.Names)
                {
                    collectMemoryIndexNode(name, node, indexContainer, false);
                }
            }
        }
Example #3
0
        /// <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);
        }
Example #4
0
 private void collectImplicitAnyNode(CollectorNode node)
 {
     if (testAndProcessReturnedAnyNode(node))
     {
         LocationCollectorNode nextNode = node.CreateUndefinedAnyChild();
         AddNode(nextNode);
     }
 }
Example #5
0
            public void VisitControlIndex(ControlIndex index)
            {
                currentNode = rootNode.GetOrCreateControlStackNode(collector, index.CallLevel);

                processIndexName(index);
                processIndexPath(index);

                processAlias(index);
            }
Example #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);
        }
Example #7
0
        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);
        }
Example #8
0
            public void VisitObjectIndex(ObjectIndex index)
            {
                currentNode = rootNode.GetOrCreateObjectNode(collector, index.Object);

                processIndexName(index);
                processIndexPath(index);

                processAlias(index);
            }
Example #9
0
 private void collectImplicitNode(string name, CollectorNode node, bool isMust)
 {
     if (testAndProcessReturnedNode(name, node, isMust))
     {
         LocationCollectorNode nextNode = node.CreateUndefinedChild(name);
         nextNode.IsMust = isMust;
         AddNode(nextNode);
     }
 }
Example #10
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);
        }
Example #11
0
 private void collectMemoryIndexAnyNode(MemoryIndex unknownIndex, CollectorNode node)
 {
     if (testAndProcessReturnedAnyNode(node))
     {
         LocationCollectorNode nextNode = node.CreateMemoryIndexAnyChild(unknownIndex);
         nextNode.IsMust = false;
         AddNode(nextNode);
     }
 }
Example #12
0
            public void VisitVariableIndex(VariableIndex index)
            {
                currentNode = rootNode.GetOrCreateVariableStackNode(collector, index.CallLevel);

                processIndexName(index);
                processIndexPath(index);

                processAlias(index);
            }
Example #13
0
 private bool testAndProcessReturnedAnyNode(CollectorNode node)
 {
     if (node.AnyChildNode != null)
     {
         AddNode(node.AnyChildNode);
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #14
0
 private bool testAndProcessReturnedAnyNode(CollectorNode node, MemoryIndex index)
 {
     if (node.AnyChildNode != null)
     {
         collector.AddNode(node.AnyChildNode);
         node.AnyChildNode.TargetIndex = index;
         node.AnyChildNode.SourceIndex = index;
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #15
0
        private void collectMemoryIndexNode(string name, CollectorNode node,
                                            IReadonlyIndexContainer indexContainer, bool isMust)
        {
            if (testAndProcessReturnedNode(name, node, isMust))
            {
                LocationCollectorNode nextNode;
                MemoryIndex           memoryIndex;
                if (indexContainer.TryGetIndex(name, out memoryIndex))
                {
                    nextNode = node.CreateMemoryIndexChild(name, memoryIndex);
                }
                else
                {
                    nextNode = node.CreateMemoryIndexChildFromAny(name, indexContainer.UnknownIndex);
                }

                nextNode.IsMust = isMust;
                AddNode(nextNode);
            }
        }
Example #16
0
        /// <summary>
        /// Collects the segment without structure.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="node">The node.</param>
        /// <param name="isMust">if set to <c>true</c> [is must].</param>
        public void CollectSegmentWithoutStructure(PathSegment segment, CollectorNode node, bool isMust)
        {
            isMust = isMust && node.IsMust;

            if (segment.IsAny || segment.IsUnknown)
            {
                collectImplicitAnyNode(node);
            }
            else if (segment.Names.Count == 1)
            {
                String name = segment.Names[0];
                collectImplicitNode(name, node, isMust);
            }
            else
            {
                foreach (string name in segment.Names)
                {
                    collectImplicitNode(name, node, false);
                }
            }
        }
Example #17
0
            public void VisitTemporaryIndex(TemporaryIndex index)
            {
                MemoryIndexCollectorNode node;

                if (!rootNode.TemporaryNodes.TryGetValue(index.RootIndex, out node))
                {
                    MemoryIndexCollectorNode newNode = new MemoryIndexCollectorNode(index.RootIndex);
                    newNode.IsMust = isMust;
                    rootNode.TemporaryNodes.Add(index.RootIndex, newNode);

                    currentNode = newNode;
                }
                else
                {
                    currentNode = node;
                }

                processIndexPath(index);

                if (!processAlias(index))
                {
                    if (isMust)
                    {
                        rootNode.TemporaryNodes.Remove(index.RootIndex);

                        MemoryIndexCollectorNode newNode = new MemoryIndexCollectorNode(index.RootIndex);
                        newNode.IsMust = isMust;
                        rootNode.TemporaryNodes.Add(index.RootIndex, newNode);
                    }
                    else
                    {
                        MemoryIndexCollectorNode childNode = rootNode.TemporaryNodes[index.RootIndex];

                        collector.AddNode(childNode);
                        childNode.TargetIndex = index;
                        childNode.SourceIndex = index;
                        childNode.IsMust      = false;
                    }
                }
            }
Example #18
0
            private void processIndexSegment(IndexSegment segment)
            {
                lastSegment = segment;
                if (segment.IsAny)
                {
                    if (currentNode.AnyChildNode != null)
                    {
                        parentNode  = currentNode;
                        currentNode = currentNode.AnyChildNode;
                    }
                    else
                    {
                        MemoryIndexCollectorNode newNode = new MemoryIndexCollectorNode(null);
                        newNode.IsMust = false;
                        currentNode.addAnyChild(newNode);

                        parentNode      = currentNode;
                        currentNode     = newNode;
                        lastCreatedNode = newNode;
                    }
                }
                else
                {
                    if (currentNode.NamedChildNodes != null && currentNode.NamedChildNodes.ContainsKey(segment.Name))
                    {
                        parentNode  = currentNode;
                        currentNode = currentNode.NamedChildNodes[segment.Name];
                    }
                    else
                    {
                        MemoryIndexCollectorNode newNode = new MemoryIndexCollectorNode(null);
                        newNode.IsMust = isMust;
                        currentNode.addChild(newNode, segment.Name);

                        parentNode      = currentNode;
                        currentNode     = newNode;
                        lastCreatedNode = newNode;
                    }
                }
            }
Example #19
0
 private void collectMemoryIndexExpandedNode(string name, MemoryIndex memoryIndex, CollectorNode node)
 {
     if (testAndProcessReturnedNode(name, node, false))
     {
         LocationCollectorNode nextNode = node.CreateMemoryIndexChild(name, memoryIndex);
         nextNode.IsMust = false;
         AddNode(nextNode);
     }
 }