Ejemplo n.º 1
0
        private void ChunkIf(IfNode p_node)
        {
            ChunkIt(p_node.Condition);
            int then_address = instructionCounter;

            Add(OpCode.JUMP_IF_NOT_TRUE, 0, p_node.PositionData);
            ChunkIt(p_node.ThenBranch);
            int else_address = instructionCounter;

            Add(OpCode.JUMP, 0, p_node.PositionData);
            chunk.FixInstruction(then_address, null, (Operand)(instructionCounter - then_address), null, null);
            if (p_node.ElseBranch != null)
            {
                ChunkIt(p_node.ElseBranch);
            }
            chunk.FixInstruction(else_address, null, (Operand)(instructionCounter - else_address), null, null);
        }
Ejemplo n.º 2
0
 private void PrintIf(IfNode p_node)
 {
     Console.Write(identString + "[IF ");
     Print(p_node.Condition);
     Console.WriteLine();
     IdentPlus();
     Print(p_node.ThenBranch);
     if (p_node.ElseBranch != null)
     {
         IdentMinus();
         Console.WriteLine(identString + "ELSE ");
         IdentPlus();
         Print(p_node.ElseBranch);
         IdentMinus();
         IdentPlus();
     }
     IdentMinus();
     Console.WriteLine(identString + "]");
 }