Skip to content

Commit

Permalink
allow use of @CreateStatic on non-static methods (will convert to sta…
Browse files Browse the repository at this point in the history
…tic) to get around mixin validations
  • Loading branch information
Nolij committed Sep 24, 2023
1 parent 230f3ac commit cc78376
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Mod Properties
mod_version = 0.2.2
mod_version = 0.3.0
maven_group = net.feltmc
archives_base_name = feltasm
asm_version=9.5
22 changes: 19 additions & 3 deletions src/main/java/net/feltmc/feltasm/asm/FeltASMBootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,25 @@ public static void apply(String targetClassName, ClassNode targetClass, String m

var method = new MethodNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, methodNode.name, methodNode.desc, methodNode.signature, methodNode.exceptions != null ? methodNode.exceptions.toArray(String[]::new) : null);
method.visitCode();

method.instructions.add(methodNode.instructions);
method.localVariables.addAll(methodNode.localVariables);

for (var insnNode : methodNode.instructions) {
if (insnNode instanceof FieldInsnNode fieldInsnNode &&
fieldInsnNode.owner.equals(slashedMixinClassName)) {
fieldInsnNode.owner = slashedTargetClassName;
method.instructions.add(fieldInsnNode);
} else if (insnNode instanceof MethodInsnNode methodInsnNode &&
methodInsnNode.owner.equals(slashedMixinClassName)) {
methodInsnNode.owner = slashedTargetClassName;
method.instructions.add(methodInsnNode);
} else {
method.instructions.add(insnNode);
}
}

for (LocalVariableNode localVariable : methodNode.localVariables) {
if (!localVariable.name.equals("this"))
method.localVariables.add(localVariable);
}

method.visitEnd();

Expand Down

0 comments on commit cc78376

Please sign in to comment.