mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-28 00:55:37 +00:00
Fix functionality of LVT generator in production
This commit is contained in:
1 parent
a3a9993a78
commit
110882d719
3 files changed
+114
-4
No files matched your search
@@ -343,10 +343,11 @@ public class CallbackInjector extends Injector {
|
||||
* @return generated message
|
||||
*/
|
||||
private String generateBadLVTMessage(final Callback callback) {
|
||||
int position = callback.target.method.instructions.indexOf(callback.node);
|
||||
List<String> expected = CallbackInjector.summariseLocals(this.methodNode.desc, callback.target.arguments.length + 1);
|
||||
List<String> found = CallbackInjector.summariseLocals(callback.localTypes, callback.frameSize);
|
||||
String message = String.format("Local variable table in %s::%s has incompatible changes. Expected %s but found %s. Callback %s%s",
|
||||
this.classNode.name.replace('/', '.'), callback.target.method.name, expected, found, this.methodNode.name, this.methodNode.desc);
|
||||
String message = String.format("LVT in %s::%s has incompatible changes at opcode %d. Expected %s but found %s. Callback %s%s",
|
||||
this.classNode.name, callback.target.method.name, position, expected, found, this.methodNode.name, this.methodNode.desc);
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* This file is part of Sponge, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) SpongePowered.org <http://www.spongepowered.org>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.analysis.SimpleVerifier;
|
||||
|
||||
|
||||
/**
|
||||
* Verifier which handles class info lookups via {@link ClassInfo}
|
||||
*/
|
||||
public class MixinVerifier extends SimpleVerifier {
|
||||
|
||||
private Type currentClass;
|
||||
private Type currentSuperClass;
|
||||
private List<Type> currentClassInterfaces;
|
||||
private boolean isInterface;
|
||||
|
||||
public MixinVerifier(Type currentClass, Type currentSuperClass, List<Type> currentClassInterfaces, boolean isInterface) {
|
||||
super(currentClass, currentSuperClass, currentClassInterfaces, isInterface);
|
||||
this.currentClass = currentClass;
|
||||
this.currentSuperClass = currentSuperClass;
|
||||
this.currentClassInterfaces = currentClassInterfaces;
|
||||
this.isInterface = isInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInterface(final Type t) {
|
||||
if (this.currentClass != null && t.equals(this.currentClass)) {
|
||||
return this.isInterface;
|
||||
}
|
||||
return this.getClassInfo(t).isInterface();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Type getSuperClass(final Type t) {
|
||||
if (this.currentClass != null && t.equals(this.currentClass)) {
|
||||
return this.currentSuperClass;
|
||||
}
|
||||
ClassInfo c = this.getClassInfo(t).getSuperClass();
|
||||
return c == null ? null : Type.getType("L" + c.getName() + ";");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAssignableFrom(final Type t, final Type u) {
|
||||
if (t.equals(u)) {
|
||||
return true;
|
||||
}
|
||||
if (this.currentClass != null && t.equals(this.currentClass)) {
|
||||
if (this.getSuperClass(u) == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.isInterface) {
|
||||
return u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY;
|
||||
}
|
||||
return this.isAssignableFrom(t, this.getSuperClass(u));
|
||||
}
|
||||
if (this.currentClass != null && u.equals(this.currentClass)) {
|
||||
if (this.isAssignableFrom(t, this.currentSuperClass)) {
|
||||
return true;
|
||||
}
|
||||
if (this.currentClassInterfaces != null) {
|
||||
for (int i = 0; i < this.currentClassInterfaces.size(); ++i) {
|
||||
Type v = this.currentClassInterfaces.get(i);
|
||||
if (this.isAssignableFrom(t, v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ClassInfo tc = this.getClassInfo(t);
|
||||
if (tc.isInterface()) {
|
||||
tc = ClassInfo.forName("java/lang/Object");
|
||||
}
|
||||
return this.getClassInfo(u).hasSuperClass(tc);
|
||||
}
|
||||
|
||||
protected ClassInfo getClassInfo(final Type t) {
|
||||
if (t.getSort() == Type.ARRAY) {
|
||||
return ClassInfo.forName(t.getDescriptor().replace('/', '.'));
|
||||
}
|
||||
return ClassInfo.forName(t.getClassName().replace('.', '/'));
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ import org.objectweb.asm.tree.analysis.Analyzer;
|
||||
import org.objectweb.asm.tree.analysis.AnalyzerException;
|
||||
import org.objectweb.asm.tree.analysis.BasicValue;
|
||||
import org.objectweb.asm.tree.analysis.Frame;
|
||||
import org.objectweb.asm.tree.analysis.SimpleVerifier;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinVerifier;
|
||||
|
||||
|
||||
/**
|
||||
@@ -263,7 +263,7 @@ public class Locals {
|
||||
|
||||
// Use Analyzer to generate the bytecode frames
|
||||
Analyzer<BasicValue> analyzer = new Analyzer<BasicValue>(
|
||||
new SimpleVerifier(Type.getObjectType(classNode.name), objectType, interfaces, false));
|
||||
new MixinVerifier(Type.getObjectType(classNode.name), objectType, interfaces, false));
|
||||
try {
|
||||
analyzer.analyze(classNode.name, method);
|
||||
} catch (AnalyzerException ex) {
|
||||
|
||||
Reference in new issue
Block a user