blob: fbd5f5c311ebae30ba8c34b85cbe35477f89ea57 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package ftbsc.lll.tools;
import ftbsc.lll.exception.InstructionMismatchException;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnList;
import java.util.Objects;
/**
* Represents a sequence of instructions contained within two given nodes.
* Extends InsnList, but provides additional flexibility.
*/
public class InsnSequence extends InsnList implements Opcodes {
/**
* Public constructor.
* Must be given two non-null, connected nodes.
* @param startNode the starting node of the pattern
* @param endNode the first node of the pattern
*/
public InsnSequence(AbstractInsnNode startNode, AbstractInsnNode endNode) {
Objects.requireNonNull(startNode);
Objects.requireNonNull(endNode);
for(; startNode != endNode && startNode != null; startNode = startNode.getNext())
super.add(startNode);
if (startNode == null)
throw new InstructionMismatchException("Nodes" + getFirst() + " and " + getLast() + " are not connected.");
}
//TODO replace
}
|