From: Brian Alliet Date: Mon, 13 Feb 2006 04:53:48 +0000 (+0000) Subject: add equals/hashCode methods for Type.Class.Member (these seem to have been removed... X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=commitdiff_plain;h=582bed9ac8d5e11965e69ac0b44fcf9be2967e2e add equals/hashCode methods for Type.Class.Member (these seem to have been removed at least once before, they NEED to be there for the constant pool hashtable) darcs-hash:20060213045348-931ed-0c59d20c0a1b8bcd39dfaa5931a7d2694b939713.gz --- diff --git a/src/org/ibex/classgen/Type.java b/src/org/ibex/classgen/Type.java index 85ff169..cf9e4a7 100644 --- a/src/org/ibex/classgen/Type.java +++ b/src/org/ibex/classgen/Type.java @@ -189,6 +189,8 @@ public abstract class Type implements CGConst { public String getName() { return name; } public abstract String getTypeDescriptor(); public abstract String toString(); + public abstract int hashCode(); + public abstract boolean equals(Object o); } public class Field extends Member { @@ -204,6 +206,15 @@ public abstract class Type implements CGConst { if ((flags & ~VALID_FIELD_FLAGS) != 0) throw new IllegalArgumentException("invalid flags"); } } + public int hashCode() { + return type.hashCode() ^ name.hashCode() ^ getDeclaringClass().hashCode(); + } + public boolean equals(Object o_) { + if(o_ == this) return true; + if(!(o_ instanceof Field)) return false; + Field o = (Field) o_; + return o.getDeclaringClass() == getDeclaringClass() && o.type == type && o.name.equals(name); + } } public class Method extends Member { @@ -279,6 +290,21 @@ public abstract class Type implements CGConst { } } } + public int hashCode() { + int h = returnType.hashCode() ^ name.hashCode() ^ getDeclaringClass().hashCode(); + for(int i=0;i