示例#1
0
        /// <summary>
        /// Create new instace of CatchBlocks. It inserts new block on the old stack.
        /// </summary>
        /// <param name="blocks">old stack</param>
        /// <param name="catchBlocks">new inserted information</param>
        public TryBlockStack(TryBlockStack blocks, IEnumerable <CatchBlockDescription> catchBlocks)
        {
            var list = new List <IEnumerable <CatchBlockDescription> >(blocks.blocks);

            list.Add(catchBlocks);
            this.blocks = new ReadOnlyCollection <IEnumerable <CatchBlockDescription> >(list);
        }
示例#2
0
        /// <inheritdoc />
        public override void TryScopeEnd(FlowOutputSet outSet, IEnumerable <CatchBlockDescription> catchBlockStarts)
        {
            var          catchBlocks = outSet.GetControlVariable(new VariableName(".catchBlocks"));
            List <Value> result      = new List <Value>();

            foreach (var value in catchBlocks.ReadMemory(outSet.Snapshot).PossibleValues)
            {
                TryBlockStack stack = (value as InfoValue <TryBlockStack>).Data;
                result.Add(outSet.CreateInfo(stack.Pop()));
            }
            catchBlocks.WriteMemory(outSet.Snapshot, new MemoryEntry(result));
        }
示例#3
0
        /// <inheritdoc />
        public override bool Equals(object obj)
        {
            TryBlockStack other = obj as TryBlockStack;

            if (other == this)
            {
                return(true);
            }

            if (other == null)
            {
                return(base.Equals(other));
            }

            if (obj != null)
            {
                if (this.blocks.Count != other.blocks.Count)
                {
                    return(false);
                }
                for (int i = 0; i < this.blocks.Count; i++)
                {
                    var thisBlocks  = this.blocks[i].ToList();
                    var otherBlocks = this.blocks[i].ToList();
                    if (thisBlocks.Count() != otherBlocks.Count())
                    {
                        return(false);
                    }
                    for (int j = 0; j < thisBlocks.Count(); j++)
                    {
                        if (!thisBlocks[j].Equals(otherBlocks[j]))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }