001package org.clafer.ir; 002 003import java.util.Arrays; 004import org.clafer.common.Check; 005 006/** 007 * 008 * @author jimmy 009 */ 010public class IrUnreachable extends IrAbstractBool implements IrBoolExpr { 011 012 private final IrIntExpr[] edges; 013 private final int from, to; 014 015 public IrUnreachable(IrIntExpr[] edges, int from, int to, IrBoolDomain domain) { 016 super(domain); 017 this.edges = Check.noNullsNotEmpty(edges); 018 this.from = from; 019 this.to = to; 020 } 021 022 public IrIntExpr[] getEdges() { 023 return edges; 024 } 025 026 public int getFrom() { 027 return from; 028 } 029 030 public int getTo() { 031 return to; 032 } 033 034 @Override 035 public IrBoolExpr negate() { 036 return new IrNot(this, getDomain().invert()); 037 } 038 039 @Override 040 public boolean isNegative() { 041 return false; 042 } 043 044 @Override 045 public <A, B> B accept(IrBoolExprVisitor<A, B> visitor, A a) { 046 return visitor.visit(this, a); 047 } 048 049 @Override 050 public <A, B> B accept(IrIntExprVisitor<A, B> visitor, A a) { 051 return visitor.visit(this, a); 052 } 053 054 @Override 055 public boolean equals(Object obj) { 056 if (obj instanceof IrUnreachable) { 057 IrUnreachable other = (IrUnreachable) obj; 058 return Arrays.equals(edges, other.edges) 059 && from == other.from && to == other.to 060 && super.equals(other); 061 } 062 return false; 063 } 064 065 @Override 066 public int hashCode() { 067 return 17 * Arrays.hashCode(edges); 068 } 069 070 @Override 071 public String toString() { 072 return "unreachable(from=" + from + ", to=" + to + ", " + Arrays.toString(edges) + ")"; 073 } 074}