forked from openrs2/openrs2
parent
8aa3a79166
commit
84f18c4d10
@ -1,78 +0,0 @@ |
||||
package dev.openrs2.deob.analysis; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
import com.google.common.base.MoreObjects; |
||||
import com.google.common.base.Preconditions; |
||||
import org.objectweb.asm.tree.AbstractInsnNode; |
||||
import org.objectweb.asm.tree.analysis.BasicValue; |
||||
import org.objectweb.asm.tree.analysis.Value; |
||||
|
||||
public final class ConstSourceValue implements Value { |
||||
public static ConstSourceValue createUnknown(BasicValue basicValue) { |
||||
Preconditions.checkNotNull(basicValue); |
||||
return new ConstSourceValue(basicValue, null); |
||||
} |
||||
|
||||
public static ConstSourceValue createSingleSourceConstant(BasicValue basicValue, AbstractInsnNode source) { |
||||
Preconditions.checkArgument(basicValue == BasicValue.INT_VALUE); |
||||
Preconditions.checkNotNull(source); |
||||
return new ConstSourceValue(basicValue, source); |
||||
} |
||||
|
||||
private final BasicValue basicValue; |
||||
private final AbstractInsnNode source; |
||||
|
||||
private ConstSourceValue(BasicValue basicValue, AbstractInsnNode source) { |
||||
this.basicValue = basicValue; |
||||
this.source = source; |
||||
} |
||||
|
||||
public BasicValue getBasicValue() { |
||||
return basicValue; |
||||
} |
||||
|
||||
public boolean isUnknown() { |
||||
return source == null; |
||||
} |
||||
|
||||
public boolean isSingleSourceConstant() { |
||||
return source != null; |
||||
} |
||||
|
||||
public AbstractInsnNode getSource() { |
||||
Preconditions.checkState(source != null); |
||||
return source; |
||||
} |
||||
|
||||
@Override |
||||
public int getSize() { |
||||
return basicValue.getSize(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) { |
||||
return true; |
||||
} |
||||
if (o == null || getClass() != o.getClass()) { |
||||
return false; |
||||
} |
||||
ConstSourceValue that = (ConstSourceValue) o; |
||||
return basicValue.equals(that.basicValue) && |
||||
Objects.equals(source, that.source); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hash(basicValue, source); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("basicValue", basicValue) |
||||
.add("source", source) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,16 @@ |
||||
package dev.openrs2.deob.analysis |
||||
|
||||
import org.objectweb.asm.tree.AbstractInsnNode |
||||
import org.objectweb.asm.tree.analysis.BasicValue |
||||
import org.objectweb.asm.tree.analysis.Value |
||||
|
||||
sealed class ConstSourceValue : Value { |
||||
data class Unknown(override val basicValue: BasicValue) : ConstSourceValue() |
||||
data class Single(override val basicValue: BasicValue, val source: AbstractInsnNode) : ConstSourceValue() |
||||
|
||||
abstract val basicValue: BasicValue |
||||
|
||||
override fun getSize(): Int { |
||||
return basicValue.size |
||||
} |
||||
} |
Loading…
Reference in new issue