added support for 45cc and METHOD_PROTO

This commit is contained in:
Sriteja Sugoor 2021-11-17 23:56:23 +05:30 committed by Ben Gruver
parent 3fb538f202
commit c70b71709f
3 changed files with 74 additions and 1 deletions

View File

@ -657,6 +657,9 @@ public class MutableMethodImplementation implements MethodImplementation {
case Format3rms: case Format3rms:
setInstruction(location, newBuilderInstruction3rms((Instruction3rms)instruction)); setInstruction(location, newBuilderInstruction3rms((Instruction3rms)instruction));
return; return;
case Format45cc:
setInstruction(location, newBuilderInstruction45cc((Instruction45cc) instruction));
return;
case Format51l: case Format51l:
setInstruction(location, newBuilderInstruction51l((Instruction51l)instruction)); setInstruction(location, newBuilderInstruction51l((Instruction51l)instruction));
return; return;
@ -948,6 +951,21 @@ public class MutableMethodImplementation implements MethodImplementation {
instruction.getVtableIndex()); instruction.getVtableIndex());
} }
@Nonnull
private BuilderInstruction45cc newBuilderInstruction45cc(@Nonnull Instruction45cc instruction) {
return new BuilderInstruction45cc(
instruction.getOpcode(),
instruction.getRegisterCount(),
instruction.getRegisterC(),
instruction.getRegisterD(),
instruction.getRegisterE(),
instruction.getRegisterF(),
instruction.getRegisterG(),
instruction.getReference(),
instruction.getReference2()
);
}
@Nonnull @Nonnull
private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) { private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) {
return new BuilderInstruction51l( return new BuilderInstruction51l(

View File

@ -65,6 +65,8 @@ public class InstructionRewriter implements Rewriter<Instruction> {
return new RewrittenInstruction35c((Instruction35c)instruction); return new RewrittenInstruction35c((Instruction35c)instruction);
case Format3rc: case Format3rc:
return new RewrittenInstruction3rc((Instruction3rc)instruction); return new RewrittenInstruction3rc((Instruction3rc)instruction);
case Format45cc:
return new RewrittenInstruction45cc((Instruction45cc) instruction);
default: default:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@ -202,4 +204,57 @@ public class InstructionRewriter implements Rewriter<Instruction> {
return instruction.getRegisterCount(); return instruction.getRegisterCount();
} }
} }
protected class RewrittenInstruction45cc extends BaseRewrittenReferenceInstruction<Instruction45cc>
implements Instruction45cc {
public RewrittenInstruction45cc(@Nonnull Instruction45cc instruction) {
super(instruction);
}
@Nonnull public Reference getReference2() {
switch (instruction.getReferenceType2()) {
case ReferenceType.TYPE:
return RewriterUtils.rewriteTypeReference(rewriters.getTypeRewriter(),
(TypeReference)instruction.getReference2());
case ReferenceType.FIELD:
return rewriters.getFieldReferenceRewriter().rewrite((FieldReference)instruction.getReference2());
case ReferenceType.METHOD:
return rewriters.getMethodReferenceRewriter().rewrite((MethodReference)instruction.getReference2());
case ReferenceType.STRING:
return instruction.getReference2();
case ReferenceType.METHOD_PROTO:
return instruction.getReference2();
default:
throw new IllegalArgumentException();
}
}
public int getReferenceType2() {
return instruction.getReferenceType2();
}
public int getRegisterC() {
return instruction.getRegisterC();
}
public int getRegisterE() {
return instruction.getRegisterE();
}
public int getRegisterG() {
return instruction.getRegisterG();
}
public int getRegisterCount() {
return instruction.getRegisterCount();
}
public int getRegisterD() {
return instruction.getRegisterD();
}
public int getRegisterF() {
return instruction.getRegisterF();
}
}
} }

View File

@ -138,7 +138,7 @@ public class ClassPool extends BasePool<String, PoolClassDef> implements ClassSe
internReference(refInst.getReference(), refInst.getReferenceType()); internReference(refInst.getReference(), refInst.getReferenceType());
} }
if (instruction instanceof DualReferenceInstruction) { if (instruction instanceof DualReferenceInstruction) {
DualReferenceInstruction dualRefInst = (DualReferenceInstruction)instruction; DualReferenceInstruction dualRefInst = (DualReferenceInstruction) instruction;
internReference(dualRefInst.getReference2(), dualRefInst.getReferenceType2()); internReference(dualRefInst.getReference2(), dualRefInst.getReferenceType2());
} }
} }