Пример #1
0
 private void do_add_jump(BasicBlock block)
 {
     add_successor(block);
     block.add_predecessor(this);
     if (block.Opcodes.Count == 0 && block.Successors.Count != 0)
         _change_successor(block, block.Successors[0]);
 }
Пример #2
0
        // TODO rename or remove access
        public void _change_successor(BasicBlock from, BasicBlock to)
        {
            for (int i = 0; i < Successors.Count; ++i)
            {
                if (Successors[i] == from)
                {
                    Successors[i] = to;
                    break;
                }
            }

            var jump = Opcodes[Opcodes.Count - 1] as Jump;
            var cond_jump = Opcodes[Opcodes.Count - 1] as CondJump;
            if (jump != null && jump.To == from)
                jump.To = to;
            else if (cond_jump.True == from)
                cond_jump.True = to;
            else if (cond_jump.False == from)
                cond_jump.False = to;
            // TODO else die

            to.add_predecessor(this);
            for (int i = 0; i < from.Predecessors.Count; ++i)
            {
                if (from.Predecessors[i] == this)
                {
                    from.Predecessors.RemoveAt(i);
                    break;
                }
            }
        }