@Override public Boolean visit(Eq ast) { boolean checkLhs = ast.getLhs().accept(this); boolean checkRhs = ast.getRhs().accept(this); if (!(checkLhs && checkRhs)) return false; Type lhsType = ast.getLhs().typeOf(env); Type rhsType = ast.getRhs().typeOf(env); if (!lhsType.isCompatibleTo(rhsType)) { addToErrorList( ast, "the operator == can not be applied to instances of type " + lhsType.getClass() + " and type " + rhsType.getClass()); return false; } return true; }
@Override public Boolean visit(Not ast) { boolean checkArg = ast.getArg().accept(this); if (!checkArg) return false; Type argType = ast.getArg().typeOf(env); if (!argType.isCompatibleToBool()) { addToErrorList( ast, "the unary operator ! can not be applied to instances of type " + argType.getClass()); return false; } return true; }