Commit 89c7b9a8 authored by Skylot's avatar Skylot

core: fix ArgType.equals

parent 1358a05a
......@@ -173,7 +173,12 @@ public class RegionGen extends InsnGen {
if (sb.length() != 0) {
sb.append(mode);
}
sb.append('(').append(makeCondition(arg)).append(')');
String s = makeCondition(arg);
if (arg.isCompare()) {
sb.append(s);
} else {
sb.append('(').append(s).append(')');
}
}
return sb.toString();
default:
......@@ -209,7 +214,7 @@ public class RegionGen extends InsnGen {
return false;
}
InsnNode insn = ((InsnWrapArg) arg).getWrapInsn();
if(insn.getType() == InsnType.ARITH) {
if (insn.getType() == InsnType.ARITH) {
ArithNode arith = ((ArithNode) insn);
switch (arith.getOp()) {
case ADD:
......
......@@ -46,10 +46,6 @@ public abstract class ArgType {
private static ClspGraph clsp;
public static ClspGraph getClsp() {
return clsp;
}
public static void setClsp(ClspGraph clsp) {
ArgType.clsp = clsp;
}
......@@ -108,6 +104,11 @@ public abstract class ArgType {
}
@Override
boolean internalEquals(Object obj) {
return type == ((PrimitiveArg) obj).type;
}
@Override
public String toString() {
return type.toString();
}
......@@ -118,7 +119,7 @@ public abstract class ArgType {
public ObjectArg(String obj) {
this.object = Utils.cleanObjectName(obj);
this.hash = obj.hashCode();
this.hash = object.hashCode();
}
@Override
......@@ -137,6 +138,11 @@ public abstract class ArgType {
}
@Override
boolean internalEquals(Object obj) {
return object.equals(((ObjectArg) obj).object);
}
@Override
public String toString() {
return object;
}
......@@ -168,6 +174,12 @@ public abstract class ArgType {
}
@Override
boolean internalEquals(Object obj) {
return super.internalEquals(obj)
&& Arrays.equals(generics, ((GenericObjectArg) obj).generics);
}
@Override
public String toString() {
return super.toString() + "<" + Utils.arrayToString(generics) + ">";
}
......@@ -207,6 +219,11 @@ public abstract class ArgType {
}
@Override
boolean internalEquals(Object obj) {
return arrayElement.equals(((ArrayArg) obj).arrayElement);
}
@Override
public String toString() {
return arrayElement.toString() + "[]";
}
......@@ -248,6 +265,11 @@ public abstract class ArgType {
}
@Override
boolean internalEquals(Object obj) {
return Arrays.equals(possibleTypes, ((UnknownArg) obj).possibleTypes);
}
@Override
public String toString() {
if (possibleTypes.length == PrimitiveType.values().length)
return "?";
......@@ -591,13 +613,14 @@ public abstract class ArgType {
return hash;
}
abstract boolean internalEquals(Object obj);
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (hash != obj.hashCode()) return false;
if (getClass() != obj.getClass()) return false;
// TODO: don't use toString
return toString().equals(obj.toString());
return internalEquals(obj);
}
}
......@@ -107,7 +107,7 @@ public final class IfCondition {
case AND:
return "&& " + args;
case OR:
return "||" + args;
return "|| " + args;
}
return "??";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment