use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.
the class Method method findLVTInstructionsForVariable.
@SuppressWarnings("unchecked")
public <T extends Instruction & LVTInstruction> List<T> findLVTInstructionsForVariable(int index) {
List<T> list = new ArrayList<>();
if (getCode() == null) {
return null;
}
for (Instruction ins : getCode().getInstructions().getInstructions()) {
if (ins instanceof LVTInstruction) {
LVTInstruction lv = (LVTInstruction) ins;
if (lv.getVariableIndex() != index) {
continue;
}
list.add((T) ins);
}
}
return list;
}
use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.
the class Method method accept.
public void accept(MethodVisitor visitor) {
for (Annotation annotation : annotations.getAnnotations()) {
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
}
if (code != null) {
code.getInstructions().rebuildLabels();
visitor.visitCode();
net.runelite.asm.attributes.code.Exceptions exceptions = code.getExceptions();
for (net.runelite.asm.attributes.code.Exception exception : exceptions.getExceptions()) {
assert exception.getStart().getLabel() != null;
assert exception.getEnd().getLabel() != null;
assert exception.getHandler().getLabel() != null;
int idxStart = code.getInstructions().getInstructions().indexOf(exception.getStart());
int idxEnd = code.getInstructions().getInstructions().indexOf(exception.getEnd());
assert idxStart != -1;
assert idxEnd != -1;
assert code.getInstructions().getInstructions().contains(exception.getHandler());
assert idxEnd > idxStart;
visitor.visitTryCatchBlock(exception.getStart().getLabel(), exception.getEnd().getLabel(), exception.getHandler().getLabel(), exception.getCatchType() != null ? exception.getCatchType().getName() : null);
}
for (Instruction i : code.getInstructions().getInstructions()) {
i.accept(visitor);
}
visitor.visitMaxs(code.getMaxStack(), code.getMaxLocals());
}
visitor.visitEnd();
}
use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.
the class Code method getMaxLocals.
/**
* calculates the size of the lvt required for this method
* @return
*/
public int getMaxLocals() {
int max = -1;
for (Instruction ins : instructions.getInstructions()) {
if (ins instanceof LVTInstruction) {
LVTInstruction lvt = (LVTInstruction) ins;
int sizeRequired = lvt.getVariableIndex() + lvt.type().getSlots();
if (sizeRequired > max) {
max = sizeRequired;
}
}
}
int fromSig = getMaxLocalsFromSig();
if (fromSig > max)
max = fromSig;
return max;
}
use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.
the class PacketWriteDeobfuscator method insert.
private void insert(Instructions ins, InstructionContext ic, Instruction before) {
List<StackContext> pops = new ArrayList<>(ic.getPops());
Collections.reverse(pops);
for (StackContext sc : pops) {
insert(ins, sc.getPushed(), before);
}
Instruction i = ic.getInstruction().clone();
i = translate(i);
assert i.getInstructions() == ins;
int idx = ins.getInstructions().indexOf(before);
assert idx != -1;
ins.addInstruction(idx, i);
}
use of net.runelite.asm.attributes.code.Instruction in project runelite by runelite.
the class GetPathTransformer method transform.
private void transform(Method m) {
int count = 0;
if (m.getCode() == null) {
return;
}
for (Instruction i : m.getCode().getInstructions().getInstructions()) {
if (i instanceof InvokeInstruction) {
InvokeInstruction ii = (InvokeInstruction) i;
if (ii.getMethod().getName().equals("getPath")) {
if (++count == 2) {
removeInvoke(i);
done = true;
break;
}
}
}
}
}
Aggregations