001package org.clafer.ir;
002
003import org.clafer.domain.BoolDomain;
004
005/**
006 *
007 * @author jimmy
008 */
009public class IrRegister extends IrAbstractBool {
010
011    private final IrVar variable;
012
013    public IrRegister(IrVar variable) {
014        super(variable.isConstant()
015                ? BoolDomain.TrueDomain
016                : BoolDomain.TrueFalseDomain);
017        this.variable = variable;
018    }
019
020    public IrVar getVariable() {
021        return variable;
022    }
023
024    @Override
025    public boolean isNegative() {
026        throw new UnsupportedOperationException();
027    }
028
029    @Override
030    public IrBoolExpr negate() {
031        throw new UnsupportedOperationException();
032    }
033
034    @Override
035    public <A, B> B accept(IrBoolExprVisitor<A, B> visitor, A a) {
036        return visitor.visit(this, a);
037    }
038
039    @Override
040    public <A, B> B accept(IrIntExprVisitor<A, B> visitor, A a) {
041        return visitor.visit(this, a);
042    }
043
044    @Override
045    public boolean equals(Object obj) {
046        if (obj instanceof IrRegister) {
047            IrRegister other = (IrRegister) obj;
048            return variable.equals(other.variable);
049        }
050        return false;
051    }
052
053    @Override
054    public int hashCode() {
055        return 973 ^ variable.hashCode();
056    }
057
058    @Override
059    public String toString() {
060        return "register(" + variable + ")";
061    }
062}