public void Visit(UnaryOperatorAstNode visitable)
        {
            if (visitable.Operator == "+" || visitable.Operator == "-")
            {
                BasicAstNode lhs;
                if (visitable.Expr.GetType() == typeof(IntegerAstNode))
                {
                    lhs = new IntegerAstNode(0);
                }
                else
                {
                    lhs = new FloatAstNode(0);
                }

                Visit(new BinaryOperatorAstNode(visitable.Operator, lhs, visitable.Expr));
                return;
            }

            switch (visitable.Operator)
            {
            case "address_of":
                throw new NotSupportedException(
                          "It seems that clr does not support pointer");

            case "not":
                Visit(visitable.Expr);
                Gen.Emit(OpCodes.Not);
                break;

            default:
                throw new Exception(
                          "Unknown unary operator: " + visitable.Operator);
            }
        }
示例#2
0
 public void Visit(FloatAstNode visitable)
 {
     _exprType = "f64";
 }
 public void Visit(FloatAstNode visitable)
 {
     Gen.Emit(OpCodes.Ldc_R8, visitable.Value);
 }