public override void Visit(SubtractExpressionNode node)
 {
     node.expression1.Accept(this);
     Gen("push", "eax");
     node.expression2.Accept(this);
     Gen("pop", "edx");
     Gen("sub", "edx", "eax");
     Gen("mov", "eax", "edx");
 }
        public override void Visit(SubtractExpressionNode node)
        {
            node.expression1.Accept(this);
            node.expression2.Accept(this);

            if (!AreTypeCompatible(node.expression1.ExpressionType.GetType(), typeof(IntType)))
                throw new Exception("Expression 1 for - operation is not of type Int!");

            if (!AreTypeCompatible(node.expression2.ExpressionType.GetType(), typeof(IntType)))
                throw new Exception("Expression 2 for - operation is not of type Int!");

            node.ExpressionType = IntType.Instance;
        }
Exemple #3
0
 public virtual void Visit(SubtractExpressionNode node)
 {
     node.expression1.Accept(this);
     node.expression2.Accept(this);
 }
 public override void Visit(SubtractExpressionNode node)
 {
     Console.WriteLine(this.indentation + "-");
     indentation = indentation + "   ";
     node.expression1.Accept(this);
     node.expression2.Accept(this);
     indentation = indentation.Substring(0, indentation.Length - 3);
 }