use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class ConstructorMapper method toOtherSignature.
private Signature toOtherSignature(Signature s) {
Signature.Builder builder = new Signature.Builder().setReturnType(toOtherType(s.getReturnValue()));
for (Type t : s.getArguments()) {
Type other = toOtherType(t);
if (other == null) {
return null;
}
builder.addArgument(other);
}
return builder.build();
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class UnusedParameters method findUnusedParameters.
private Set<Integer> findUnusedParameters(Method method) {
int offset = method.isStatic() ? 0 : 1;
Signature signature = method.getDescriptor();
List<Integer> unusedParams = new ArrayList<>();
for (int variableIndex = 0, lvtIndex = offset; variableIndex < signature.size(); lvtIndex += signature.getTypeOfArg(variableIndex++).getSize()) {
List<? extends Instruction> lv = method.findLVTInstructionsForVariable(lvtIndex);
if (lv == null || lv.isEmpty()) {
unusedParams.add(variableIndex);
}
}
return ImmutableSet.copyOf(unusedParams);
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class UnusedParameters method processUnused.
private int processUnused(Execution execution, ClassGroup group) {
int count = 0;
for (List<Method> m : unused.keySet()) {
Collection<Integer> u = unused.get(m);
int offset = m.size() == 1 && m.get(0).isStatic() ? 0 : 1;
for (int unusedParameter : u) {
if (!shouldRemove(m.get(0), unusedParameter)) {
continue;
}
Signature signature = m.get(0).getDescriptor();
int lvtIndex = this.getLvtIndex(signature, offset, unusedParameter);
/* removing the parameter can't cause collisions on other (overloaded) methods because prior to this we rename
* all classes/fields/methods to have unique names.
*/
logger.debug("Removing parameter {} at index {} from {}", unusedParameter, lvtIndex, m);
removeParameter(group, m, signature, execution, unusedParameter, lvtIndex);
break;
}
++count;
}
return count;
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class ClassGroupFactory method generateGroup.
public static ClassGroup generateGroup() {
ClassGroup group = new ClassGroup();
ClassFile cf = new ClassFile(group);
cf.setName("test");
cf.setSuperName("java/lang/Object");
group.addClass(cf);
Field field = new Field(cf, "field", Type.INT);
field.setStatic();
cf.addField(field);
Method method = new Method(cf, "func", new Signature("()V"));
method.setStatic();
cf.addMethod(method);
Code code = new Code(method);
method.setCode(code);
{
method = new Method(cf, "func2", new Signature("(III)V"));
method.setStatic();
cf.addMethod(method);
code = new Code(method);
method.setCode(code);
Instructions ins = code.getInstructions();
ins.addInstruction(new VReturn(ins));
}
addVoidMethod(cf, "void1");
addVoidMethod(cf, "void2");
addVoidMethod(cf, "void3");
addVoidMethod(cf, "void4");
return group;
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class Inject method getMethodSignature.
public Signature getMethodSignature(Method m) {
Signature signature = m.getDescriptor();
Annotation obfSignature = m.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obfSignature != null) {
// Annotation exists. Signature was updated by us during deobfuscation
signature = DeobAnnotations.getObfuscatedSignature(m);
}
return signature;
}
Aggregations