mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-26 20:53:06 +00:00
Clean CallbackInfo from locals and fix CallbackInjector local args logic
Fixes #337
This commit is contained in:
1 parent
08980b28a4
commit
5c995b21de
1 file changed
+9
-3
@@ -170,7 +170,7 @@ public class CallbackInjector extends Injector {
|
||||
this.node = node;
|
||||
this.locals = locals;
|
||||
this.localTypes = locals != null ? new Type[locals.length] : null;
|
||||
this.frameSize = Bytecode.getFirstNonArgLocalIndex(target.arguments, !CallbackInjector.this.isStatic());
|
||||
this.frameSize = Bytecode.getFirstNonArgLocalIndex(target.arguments, !target.isStatic);
|
||||
List<String> argNames = null;
|
||||
|
||||
if (locals != null) {
|
||||
@@ -190,7 +190,8 @@ public class CallbackInjector extends Injector {
|
||||
}
|
||||
|
||||
// Calc number of args for the handler method, additional 1 is to ignore the CallbackInfo arg
|
||||
this.extraArgs = Math.max(0, Bytecode.getFirstNonArgLocalIndex(this.handler) - (this.frameSize + 1));
|
||||
Type[] handlerArgs = Type.getArgumentTypes(this.handler.desc);
|
||||
this.extraArgs = Math.max(0, handlerArgs.length - target.arguments.length - 1);
|
||||
this.argNames = argNames != null ? argNames.toArray(new String[argNames.size()]) : null;
|
||||
this.canCaptureLocals = captureLocals && locals != null && locals.length > this.frameSize;
|
||||
this.isAtReturn = this.node.getCurrentTarget() instanceof InsnNode && this.isValueReturnOpcode(this.node.getCurrentTarget().getOpcode());
|
||||
@@ -426,6 +427,11 @@ public class CallbackInjector extends Injector {
|
||||
|
||||
if (this.localCapture.isCaptureLocals() || this.localCapture.isPrintLocals()) {
|
||||
locals = Locals.getLocalsAt(this.classNode, target.method, node.getCurrentTarget());
|
||||
for (int j = 0; j < locals.length; j++) {
|
||||
if (locals[j] != null && locals[j].desc != null && locals[j].desc.startsWith("Lorg/spongepowered/asm/mixin/injection/callback/")) {
|
||||
locals[j] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.inject(new Callback(this.methodNode, target, node, locals, this.localCapture.isCaptureLocals()));
|
||||
@@ -524,7 +530,7 @@ public class CallbackInjector extends Injector {
|
||||
private String generateBadLVTMessage(final Callback callback) {
|
||||
int position = callback.target.indexOf(callback.node);
|
||||
List<String> expected = CallbackInjector.summariseLocals(this.methodNode.desc, callback.target.arguments.length + 1);
|
||||
List<String> found = CallbackInjector.summariseLocals(callback.getDescriptorWithAllLocals(), callback.frameSize);
|
||||
List<String> found = CallbackInjector.summariseLocals(callback.getDescriptor(), callback.frameSize + (callback.target.isStatic ? 1 : 0));
|
||||
return String.format("LVT in %s has incompatible changes at opcode %d in callback %s.\nExpected: %s\n Found: %s",
|
||||
callback.target, position, this, expected, found);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user