Add hashCode to pool entry

This commit is contained in:
Adam
2015-11-19 19:38:29 -05:00
parent 946016afea
commit d6958e2684
8 changed files with 63 additions and 0 deletions

View File

@@ -35,6 +35,14 @@ public class Double extends PoolEntry
return value == d.value; return value == d.value;
} }
@Override
public int hashCode()
{
int hash = 5;
hash = 79 * hash + (int) (java.lang.Double.doubleToLongBits(this.value) ^ (java.lang.Double.doubleToLongBits(this.value) >>> 32));
return hash;
}
@Override @Override
public int getSlots() public int getSlots()
{ {

View File

@@ -35,6 +35,14 @@ public class Float extends PoolEntry
return value == f.value; return value == f.value;
} }
@Override
public int hashCode()
{
int hash = 7;
hash = 37 * hash + java.lang.Float.floatToIntBits(this.value);
return hash;
}
@Override @Override
public Type getTypeClass() public Type getTypeClass()
{ {

View File

@@ -34,6 +34,14 @@ public class Integer extends PoolEntry
Integer i = (Integer) other; Integer i = (Integer) other;
return value == i.value; return value == i.value;
} }
@Override
public int hashCode()
{
int hash = 3;
hash = 97 * hash + this.value;
return hash;
}
@Override @Override
public java.lang.String toString() public java.lang.String toString()

View File

@@ -5,6 +5,7 @@ import net.runelite.deob.ConstantPool;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
public class InterfaceMethod extends PoolEntry public class InterfaceMethod extends PoolEntry
{ {
@@ -51,6 +52,15 @@ public class InterfaceMethod extends PoolEntry
InterfaceMethod i = (InterfaceMethod) other; InterfaceMethod i = (InterfaceMethod) other;
return clazz.equals(i.clazz) && nat.equals(i.nat); return clazz.equals(i.clazz) && nat.equals(i.nat);
} }
@Override
public int hashCode()
{
int hash = 5;
hash = 23 * hash + Objects.hashCode(this.clazz);
hash = 23 * hash + Objects.hashCode(this.nat);
return hash;
}
public Class getClassEntry() public Class getClassEntry()
{ {

View File

@@ -35,6 +35,14 @@ public class Long extends PoolEntry
return value == l.value; return value == l.value;
} }
@Override
public int hashCode()
{
int hash = 3;
hash = 37 * hash + (int) (this.value ^ (this.value >>> 32));
return hash;
}
@Override @Override
public int getSlots() public int getSlots()
{ {

View File

@@ -29,6 +29,9 @@ public abstract class PoolEntry
@Override @Override
public abstract boolean equals(Object other); public abstract boolean equals(Object other);
@Override
public abstract int hashCode();
public abstract void write(DataOutputStream out) throws IOException; public abstract void write(DataOutputStream out) throws IOException;
public ConstantType getType() public ConstantType getType()

View File

@@ -6,6 +6,7 @@ import net.runelite.deob.execution.Type;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
public class String extends PoolEntry public class String extends PoolEntry
{ {
@@ -54,6 +55,14 @@ public class String extends PoolEntry
return string.equals(s.string); return string.equals(s.string);
} }
@Override
public int hashCode()
{
int hash = 5;
hash = 83 * hash + Objects.hashCode(this.string);
return hash;
}
@Override @Override
public void write(DataOutputStream out) throws IOException public void write(DataOutputStream out) throws IOException
{ {

View File

@@ -5,6 +5,7 @@ import net.runelite.deob.ConstantPool;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
public class UTF8 extends PoolEntry public class UTF8 extends PoolEntry
{ {
@@ -34,6 +35,14 @@ public class UTF8 extends PoolEntry
return string.equals(u.string); return string.equals(u.string);
} }
@Override
public int hashCode()
{
int hash = 5;
hash = 29 * hash + Objects.hashCode(this.string);
return hash;
}
public java.lang.String getValue() public java.lang.String getValue()
{ {
return string; return string;