Exemple #1
0
            /// <summary>
            /// Creates a new ArithmeticInstruction.
            /// </summary>
            public override Node ExitArithmetic(Production node)
            {
                ArrayList             values = GetChildValues(node);
                ArithmeticInstruction i      = new ArithmeticInstruction();

                switch (node[0].Id)
                {
                case (int)PicoConstants.ADD: i.Type = ArithmeticTypes.Add; break;

                case (int)PicoConstants.SUB: i.Type = ArithmeticTypes.Sub; break;

                case (int)PicoConstants.MUL: i.Type = ArithmeticTypes.Mul; break;

                case (int)PicoConstants.DIV: i.Type = ArithmeticTypes.Div; break;
                }
                i.Address   = Assembler.NextInstructionAddress;
                i.Argument1 = (Argument)values[0];
                i.Argument2 = (Argument)values[1];
                i.Argument3 = (Argument)values[2];
                i.Line      = node.StartLine;
                i.Column    = node.StartColumn;
                i.Assembler = Assembler;
                Assembler.Instructions.Add(i);
                return(node);
            }
Exemple #2
0
 /// <summary>
 /// Creates a new ArithmeticInstruction.
 /// </summary>
 public override Node ExitArithmetic(Production node)
 {
     ArrayList values = GetChildValues(node);
     ArithmeticInstruction i = new ArithmeticInstruction();
     switch (node[0].Id)
     {
         case (int)PicoConstants.ADD: i.Type = ArithmeticTypes.Add; break;
         case (int)PicoConstants.SUB: i.Type = ArithmeticTypes.Sub; break;
         case (int)PicoConstants.MUL: i.Type = ArithmeticTypes.Mul; break;
         case (int)PicoConstants.DIV: i.Type = ArithmeticTypes.Div; break;
     }
     i.Address = Assembler.NextInstructionAddress;
     i.Argument1 = (Argument)values[0];
     i.Argument2 = (Argument)values[1];
     i.Argument3 = (Argument)values[2];
     i.Line = node.StartLine;
     i.Column = node.StartColumn;
     i.Assembler = Assembler;
     Assembler.Instructions.Add(i);
     return node;
 }