From bbbd60ce0a53f5ab74c06d6a16f9eaf06ac27fe7 Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Fri, 19 Apr 2024 14:44:04 +0100 Subject: [PATCH] feat: add invokedynamic to BytecodeBuilder --- .../bad/framework/BytecodeBuilder.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/dev/ashhhleyyy/bad/framework/BytecodeBuilder.java b/src/main/java/dev/ashhhleyyy/bad/framework/BytecodeBuilder.java index 567559d..11af8ee 100644 --- a/src/main/java/dev/ashhhleyyy/bad/framework/BytecodeBuilder.java +++ b/src/main/java/dev/ashhhleyyy/bad/framework/BytecodeBuilder.java @@ -3,22 +3,10 @@ package dev.ashhhleyyy.bad.framework; import java.util.HashMap; import java.util.Map; +import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldInsnNode; -import org.objectweb.asm.tree.IincInsnNode; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.IntInsnNode; -import org.objectweb.asm.tree.JumpInsnNode; -import org.objectweb.asm.tree.LabelNode; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.LocalVariableNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.TypeInsnNode; -import org.objectweb.asm.tree.VarInsnNode; +import org.objectweb.asm.tree.*; public final class BytecodeBuilder { private final ClassNode classNode; @@ -163,6 +151,10 @@ public final class BytecodeBuilder { this.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, name, desc)); } + public void invokedynamic(String name, String descriptor, Handle bsm, Object... bsmArgs) { + this.add(new InvokeDynamicInsnNode(name, descriptor, bsm, bsmArgs)); + } + private LabelNode getCurrentLabel() { if (this.currentLabel != null) { return this.currentLabel;