示例#1
0
        public void add_successor(BasicBlock block)
        {
            if (Successors.Contains(block))
                return;

            Successors.Add(block);
        }
示例#2
0
 public void add_jump_unoptimized(Opcode op, BasicBlock first)
 {
     Opcodes.Add(op);
     if (Dead == 2)
         return;
     do_add_jump(first);
 }
示例#3
0
        public void add_predecessor(BasicBlock block)
        {
            if (Predecessors.Contains(block))
                return;

            Predecessors.Add(block);
        }
示例#4
0
        // TODO generate from Perl code
        public void add_jump(Opcode op, BasicBlock first)
        {
            if (Opcodes.Count == 0 && Predecessors.Count > 0 && first != this)
            {
                while (first.Successors.Count > 0 && first.Opcodes.Count == 0)
                    first = first.Successors[0];

                var pred = new List<BasicBlock>(Predecessors);
                foreach (var p in pred)
                    p._change_successor(this, first);

                add_successor(first);
            }
            else
                add_jump_unoptimized(op, first);
        }
示例#5
0
 public void GenerateBlock(Subroutine sub, BasicBlock bb,
                           List<Expression> expressions)
 {
     foreach (var o in bb.Opcodes)
     {
         if (o.Position.File != null)
             UpdateFileLine(o, expressions);
         expressions.Add(Generate(sub, o));
     }
 }
示例#6
0
 public void add_jump(Opcode op, BasicBlock first, BasicBlock second)
 {
     add_jump_unoptimized(op, first, second);
 }
示例#7
0
 public void set_exception(BasicBlock exc)
 {
     Exception = exc;
 }
示例#8
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]);
 }
示例#9
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;
                }
            }
        }