Exemplo n.º 1
0
        protected internal override void VisitSwitch(Switch node, object data)
        {
            BasicBlock basicBlock = data as BasicBlock;

            basicBlock.AddNode(node);

            if (node.Next.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION))
            {
                basicBlock.AddNextBasicBlock(node.Next.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock);
            }
            else
            {
                BasicBlock nextBlock = createBasicBlock();
                basicBlock.AddNextBasicBlock(nextBlock);
                AddTask(node.Next, nextBlock);
            }

            foreach (Node alt in node)
            {
                if (alt.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION))
                {
                    basicBlock.AddNextBasicBlock(alt.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock);
                }
                else
                {
                    BasicBlock altBlock = createBasicBlock();
                    basicBlock.AddNextBasicBlock(altBlock);
                    AddTask(alt, altBlock);
                }
            }
        }
Exemplo n.º 2
0
        protected internal override void VisitBranch(Branch node, object data)
        {
            if (node.Next == node.Alt)
            {
                SiftSerials(node, data);
            }
            else
            {
                BasicBlock basicBlock = data as BasicBlock;
                basicBlock.AddNode(node);

                if (node.Next.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION))
                {
                    basicBlock.AddNextBasicBlock(node.Next.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock);
                }
                else
                {
                    BasicBlock nextBlock = createBasicBlock();
                    basicBlock.AddNextBasicBlock(nextBlock);
                    AddTask(node.Next, nextBlock);
                }

                if (node.Alt.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION))
                {
                    basicBlock.AddNextBasicBlock(node.Alt.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock);
                }
                else
                {
                    BasicBlock altBlock = createBasicBlock();
                    basicBlock.AddNextBasicBlock(altBlock);
                    AddTask(node.Alt, altBlock);
                }
            }
        }
Exemplo n.º 3
0
        protected void SiftBlocks(Block node, object data)
        {
            BasicBlock basicBlock = data as BasicBlock;

            basicBlock.AddNode(node);

            if (node is ProtectedBlock)
            {
                foreach (EHBlock block in (node as ProtectedBlock))
                {
                    if (block.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION))
                    {
                        basicBlock.AddLink(block.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock);
                    }
                    else
                    {
                        BasicBlock newBlock = createBasicBlock();
                        basicBlock.AddLink(newBlock);
                        AddTask(block, newBlock);
                    }
                }
            }
            else if (node is UserFilteredBlock)
            {
                FilterBlock block = (node as UserFilteredBlock).Filter;

                if (block.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION))
                {
                    basicBlock.AddLink(block.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock);
                }
                else
                {
                    BasicBlock newBlock = createBasicBlock();
                    basicBlock.AddLink(newBlock);
                    AddTask(block, newBlock);
                }
            }

            if (node.Next.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION))
            {
                basicBlock.AddNextBasicBlock(node.Next.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock);
            }
            else
            {
                BasicBlock nextBlock = createBasicBlock();
                basicBlock.AddNextBasicBlock(nextBlock);
                AddTask(node.Next, nextBlock);
            }
        }
Exemplo n.º 4
0
        protected void SiftNodes(Node node, ref object data)
        {
            BasicBlock basicBlock = data as BasicBlock;

            if (basicBlock.Body.Count > 0 && (node.PrevArray.Count > 1 || node is Block))
            {
                BasicBlock newBlock = createBasicBlock();
                basicBlock.AddNextBasicBlock(newBlock);
                data = newBlock;
            }
        }
Exemplo n.º 5
0
        protected void SiftSerials(Node node, object data)
        {
            BasicBlock basicBlock = data as BasicBlock;

            basicBlock.AddNode(node);

            if (node.Next != null)
            {
                if (node.Next.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION))
                {
                    basicBlock.AddNextBasicBlock(node.Next.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock);
                }
                else if (node is Leave)
                {
                    BasicBlock nextBlock = createBasicBlock();
                    basicBlock.AddNextBasicBlock(nextBlock);
                    AddTask(node.Next, nextBlock);
                }
                else
                {
                    AddTask(node.Next, basicBlock);
                }
            }
        }