Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
 public IndexLocationVisitor(TreeIndexCollector collector, IndexPathSegment indexSegment,
                             ValueCollectorNode node)
     : base(collector.Snapshot.MemoryAssistant)
 {
     this.collector    = collector;
     this.indexSegment = indexSegment;
     this.node         = node;
 }
Ejemplo n.º 3
0
        /// <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;
        }
Ejemplo n.º 4
0
 public FieldLocationVisitor(TreeIndexCollector collector, FieldPathSegment fieldSegment,
                             ValueCollectorNode node)
     : base(collector.Snapshot.MemoryAssistant)
 {
     this.collector    = collector;
     this.fieldSegment = fieldSegment;
     this.node         = node;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 8
0
        /// <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);
        }
Ejemplo n.º 9
0
        /// <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;
        }
Ejemplo n.º 10
0
        /// <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);
        }
Ejemplo n.º 11
0
        /// <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);
                }
            }
        }
Ejemplo n.º 12
0
        /// <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);
            }
        }
Ejemplo n.º 13
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);
            }
        }
Ejemplo n.º 14
0
 public void Collect(TreeIndexCollector collector, PathSegment pathSegment)
 {
     collector.CollectSegmentFromStructure(pathSegment, this, indexContainer, true);
 }
Ejemplo n.º 15
0
 public CollectAliasMemoryIndexVisitor(TreeIndexCollector collector, RootCollectorNode rootNode, bool isMust)
 {
     this.rootNode  = rootNode;
     this.collector = collector;
     this.isMust    = isMust;
 }
Ejemplo n.º 16
0
 public override void CollectAliases(TreeIndexCollector collector)
 {
     // Do nothing - values can not have any alias
 }
Ejemplo n.º 17
0
        public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment)
        {
            IndexLocationVisitor visitor = new IndexLocationVisitor(collector, indexSegment, this);

            ValueLocation.Accept(visitor);
        }
Ejemplo n.º 18
0
        /// <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);
        }
Ejemplo n.º 19
0
        public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment)
        {
            FieldLocationVisitor visitor = new FieldLocationVisitor(collector, fieldSegment, this);

            ValueLocation.Accept(visitor);
        }
Ejemplo n.º 20
0
        /// <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);
        }
Ejemplo n.º 21
0
 public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment)
 {
     HasNewImplicitArray = true;
     collector.CollectSegmentWithoutStructure(indexSegment, this, true);
 }
Ejemplo n.º 22
0
 public override void CollectAliases(TreeIndexCollector collector)
 {
     CollectAliasesFromMemoryIndex(collector, sourceMemoryIndex);
 }
Ejemplo n.º 23
0
 public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment)
 {
     collectFieldFromMemoryIndex(collector, fieldSegment, sourceMemoryIndex);
 }
Ejemplo n.º 24
0
 public override void CollectIndex(TreeIndexCollector collector, IndexPathSegment indexSegment)
 {
     CollectIndexFromMemoryIndex(collector, indexSegment, sourceMemoryIndex);
 }
Ejemplo n.º 25
0
 /// <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);
Ejemplo n.º 26
0
 public override void CollectField(TreeIndexCollector collector, FieldPathSegment fieldSegment)
 {
     AddNewImplicitObjectNode(true);
     collector.CollectSegmentWithoutStructure(fieldSegment, ImplicitObjectNode, true);
 }
Ejemplo n.º 27
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);
Ejemplo n.º 28
0
 public override void CollectAliases(TreeIndexCollector collector)
 {
     // Do nothing - undefined index can not have any alias
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Collects all aliases to target node.
 /// </summary>
 /// <param name="collector">The collector.</param>
 public abstract void CollectAliases(TreeIndexCollector collector);