41 lines
1.2 KiB
Java
41 lines
1.2 KiB
Java
package ch.usi.inf.sp.cfg.builder;
|
|
|
|
import ch.usi.inf.sp.cfg.BasicBlock;
|
|
import ch.usi.inf.sp.cfg.ControlFlowEdge;
|
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
|
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
|
|
public final class JumpSource {
|
|
private final AbstractInsnNode instruction;
|
|
private final String condition;
|
|
|
|
public JumpSource(AbstractInsnNode instruction, String condition) {
|
|
this.instruction = instruction;
|
|
this.condition = condition;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (obj == this) return true;
|
|
if (obj == null || obj.getClass() != this.getClass()) return false;
|
|
var that = (JumpSource) obj;
|
|
return Objects.equals(this.instruction, that.instruction) &&
|
|
Objects.equals(this.condition, that.condition);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(instruction, condition);
|
|
}
|
|
|
|
public BasicBlock block(Map<AbstractInsnNode, BasicBlock> insnToBlock) {
|
|
return Objects.requireNonNull(insnToBlock.get(this.instruction));
|
|
}
|
|
|
|
public ControlFlowEdge edge() {
|
|
return new ControlFlowEdge(this.condition);
|
|
}
|
|
}
|