/** Our internal representation of a ParenExpr * in the Q0 language. * See http://www.radford.edu/itec380/2009fall-ibarland/Hw06/hw06.html * * @author Ian Barland * @version 2015.Nov.15 */ public class ParenExpr extends Expr { Expr e; ParenExpr( Expr _e ) { this.e = _e; } public String toString(/* ParenExpr this */) { return "[[" + this.e.toString() + "]]" ; } public Value eval() { return this.e.eval(); } public Expr subst( /* ParityExpr this, */ IdExpr id, Value v ) { return new ParenExpr( this.e.subst(id,v) ); } @Override public boolean equals( /* ParenExpr this, */ Object that) { if (this==that) { return true; } else if (that==null) { return false; } else if (this.getClass() != that.getClass()) { return false; } else { ParenExpr thatt = (ParenExpr) that; return this.e.equals(thatt.e); } } @Override public int hashCode() { if (cachedHash == null) { int hashSoFar = 0x815F58D4; // fingerprint hashSoFar += this.e.hashCode(); cachedHash = hashSoFar; } return cachedHash; } private Integer cachedHash = null; }