    001    package escjava.translate;
    002
    003    import javafe.ast.*;
    004
    005    public class RepHelper {
    006
    007        public TypeDecl td;
    008        public ASTNode a;
    009
    010        public RepHelper(TypeDecl td, FieldDecl fd) {
    011            this.td = td;
    012            this.a = fd;
    013        }
    014
    015        public RepHelper(TypeDecl td, RoutineDecl rd) {
    016            this.td = td;
    017            this.a = rd;
    018        }
    019
    020        public RepHelper(/*@ non_null @*/ FieldAccess fa) {
    021            this.a = fa.decl;
    022            ObjectDesignator od = fa.od;
    023            Type t = null;
    024            if (od instanceof ExprObjectDesignator) {
    025                t = javafe.tc.FlowInsensitiveChecks.getType(
    026                            ((ExprObjectDesignator)od).expr );
    027            } else if (od instanceof TypeObjectDesignator) {
    028                t = ((TypeObjectDesignator)od).type;
    029            }
    030            if (t instanceof javafe.tc.TypeSig)
    031                    this.td = ((javafe.tc.TypeSig)t).getTypeDecl();
    032        }
    033
    034        public boolean equals(Object o) {
    035            if (!(o instanceof RepHelper)) return false;
    036            RepHelper r = (RepHelper)o;
    037            return td == r.td && a == r.a;
    038        }
    039
    040        public int hashCode() {
    041            return (td==null?0:td.hashCode()) + (a==null?0:a.hashCode());
    042        }
    043    }