Пример #1
0
        /* throws Exception */
        // Relop ---
        // int op;
        // Exp e1, e2;
        public AstType visit(AstRelop n)
        {
            AstType t1 = n.e1.accept(this);
            AstType t2 = n.e2.accept(this);

            if (n.op == AstRelop.OP.EQ || n.op == AstRelop.OP.NE)
            {
                if (compatible(t1,t2) || compatible(t2,t1))
                    return BoolType;
            }
            else if (isIntType(t1) && isIntType(t2))
            {
                return BoolType;
            }

            throw new TypeException("Incorrect operand types in Relop: " + t1 + n.opName(n.op) + t2);
        }