{@code version & V_PREVIEW == V_PREVIEW} tests if a version is flagged with {@code
+ * V_PREVIEW}.
+ */
+ V_PREVIEW: number
+
+ // Access flags values, defined in
+ // - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.1-200-E.1
+ // - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.5-200-A.1
+ // - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.6-200-A.1
+ // - https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.25
+
+ ACC_PUBLIC: number
+ ACC_PRIVATE: number
+ ACC_PROTECTED: number
+ ACC_STATIC: number
+ ACC_FINAL: number
+ ACC_SUPER: number
+ ACC_SYNCHRONIZED: number
+ ACC_OPEN: number
+ ACC_TRANSITIVE: number
+ ACC_VOLATILE: number
+ ACC_BRIDGE: number
+ ACC_STATIC_PHASE: number
+ ACC_VARARGS: number
+ ACC_TRANSIENT: number
+ ACC_NATIVE: number
+ ACC_INTERFACE: number
+ ACC_ABSTRACT: number
+ ACC_STRICT: number
+ ACC_SYNTHETIC: number
+ ACC_ANNOTATION: number
+ ACC_ENUM: number
+ ACC_MANDATED: number
+ ACC_MODULE: number
+
+ // ASM specific access flags.
+ // WARNING: the 16 least significant bits must NOT be used, to avoid conflicts with standard
+ // access flags, and also to make sure that these flags are automatically filtered out when
+ // written in class files (because access flags are stored using 16 bits only).
+
+ ACC_RECORD: number
+ ACC_DEPRECATED: number
+
+ // Possible values for the type operand of the NEWARRAY instruction.
+ // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html#jvms-6.5.newarray.
+
+ T_BOOLEAN: number
+ T_CHAR: number
+ T_FLOAT: number
+ T_DOUBLE: number
+ T_BYTE: number
+ T_SHORT: number
+ T_INT: number
+ T_LONG: number
+
+ // Possible values for the reference_kind field of CONSTANT_MethodHandle_info structures.
+ // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.8.
+
+ H_GETFIELD: number
+ H_GETSTATIC: number
+ H_PUTFIELD: number
+ H_PUTSTATIC: number
+ H_INVOKEVIRTUAL: number
+ H_INVOKESTATIC: number
+ H_INVOKESPECIAL: number
+ H_NEWINVOKESPECIAL: number
+ H_INVOKEINTERFACE: number
+
+ // ASM specific stack map frame types, used in {@link ClassVisitor#visitFrame}.
+
+ /** An expanded frame. See {@link ClassReader#EXPAND_FRAMES}. */
+ F_NEW: number
+
+ /** A compressed frame with complete frame data. */
+ F_FULL: number
+
+ /**
+ * A compressed frame where locals are the same as the locals in the previous frame, except that
+ * additional 1-3 locals are defined, and with an empty stack.
+ */
+ F_APPEND: number
+
+ /**
+ * A compressed frame where locals are the same as the locals in the previous frame, except that
+ * the last 1-3 locals are absent and with an empty stack.
+ */
+ F_CHOP: number
+
+ /**
+ * A compressed frame with exactly the same locals as the previous frame and with an empty stack.
+ */
+ F_SAME: number
+
+ /**
+ * A compressed frame with exactly the same locals as the previous frame and with a single value
+ * on the stack.
+ */
+ F_SAME1: number
+
+ // Standard stack map frame element types, used in {@link ClassVisitor#visitFrame}.
+
+ TOP: number
+ INTEGER: number
+ FLOAT: number
+ DOUBLE: number
+ LONG: number
+ NULL: number
+ UNINITIALIZED_THIS: number
+
+ // The JVM opcode values (with the MethodVisitor method name used to visit them in comment, and
+ // where '-' means 'same method name as on the previous line').
+ // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html.
+
+ NOP: number
+ ACONST_NULL: number
+ ICONST_M1: number
+ ICONST_0: number
+ ICONST_1: number
+ ICONST_2: number
+ ICONST_3: number
+ ICONST_4: number
+ ICONST_5: number
+ LCONST_0: number
+ LCONST_1: number
+ FCONST_0: number
+ FCONST_1: number
+ FCONST_2: number
+ DCONST_0: number
+ DCONST_1: number
+ BIPUSH: number
+ SIPUSH: number
+ LDC: number
+ ILOAD: number
+ LLOAD: number
+ FLOAD: number
+ DLOAD: number
+ ALOAD: number
+ IALOAD: number
+ LALOAD: number
+ FALOAD: number
+ DALOAD: number
+ AALOAD: number
+ BALOAD: number
+ CALOAD: number
+ SALOAD: number
+ ISTORE: number
+ LSTORE: number
+ FSTORE: number
+ DSTORE: number
+ ASTORE: number
+ IASTORE: number
+ LASTORE: number
+ FASTORE: number
+ DASTORE: number
+ AASTORE: number
+ BASTORE: number
+ CASTORE: number
+ SASTORE: number
+ POP: number
+ POP2: number
+ DUP: number
+ DUP_X1: number
+ DUP_X2: number
+ DUP2: number
+ DUP2_X1: number
+ DUP2_X2: number
+ SWAP: number
+ IADD: number
+ LADD: number
+ FADD: number
+ DADD: number
+ ISUB: number
+ LSUB: number
+ FSUB: number
+ DSUB: number
+ IMUL: number
+ LMUL: number
+ FMUL: number
+ DMUL: number
+ IDIV: number
+ LDIV: number
+ FDIV: number
+ DDIV: number
+ IREM: number
+ LREM: number
+ FREM: number
+ DREM: number
+ INEG: number
+ LNEG: number
+ FNEG: number
+ DNEG: number
+ ISHL: number
+ LSHL: number
+ ISHR: number
+ LSHR: number
+ IUSHR: number
+ LUSHR: number
+ IAND: number
+ LAND: number
+ IOR: number
+ LOR: number
+ IXOR: number
+ LXOR: number
+ IINC: number
+ I2L: number
+ I2F: number
+ I2D: number
+ L2I: number
+ L2F: number
+ L2D: number
+ F2I: number
+ F2L: number
+ F2D: number
+ D2I: number
+ D2L: number
+ D2F: number
+ I2B: number
+ I2C: number
+ I2S: number
+ LCMP: number
+ FCMPL: number
+ FCMPG: number
+ DCMPL: number
+ DCMPG: number
+ IFEQ: number
+ IFNE: number
+ IFLT: number
+ IFGE: number
+ IFGT: number
+ IFLE: number
+ IF_ICMPEQ: number
+ IF_ICMPNE: number
+ IF_ICMPLT: number
+ IF_ICMPGE: number
+ IF_ICMPGT: number
+ IF_ICMPLE: number
+ IF_ACMPEQ: number
+ IF_ACMPNE: number
+ GOTO: number
+ JSR: number
+ RET: number
+ TABLESWITCH: number
+ LOOKUPSWITCH: number
+ IRETURN: number
+ LRETURN: number
+ FRETURN: number
+ DRETURN: number
+ ARETURN: number
+ RETURN: number
+ GETSTATIC: number
+ PUTSTATIC: number
+ GETFIELD: number
+ PUTFIELD: number
+ INVOKEVIRTUAL: number
+ INVOKESPECIAL: number
+ INVOKESTATIC: number
+ INVOKEINTERFACE: number
+ INVOKEDYNAMIC: number
+ NEW: number
+ NEWARRAY: number
+ ANEWARRAY: number
+ ARRAYLENGTH: number
+ ATHROW: number
+ CHECKCAST: number
+ INSTANCEOF: number
+ MONITORENTER: number
+ MONITOREXIT: number
+ MULTIANEWARRAY: number
+ IFNULL: number
+ IFNONNULL: number
+}
+
+declare interface Java {
+ type(name: 'org.objectweb.asm.tree.InsnList'): _InsnList
+
+ type(name: 'org.objectweb.asm.tree.AbstractInsnNode'): _AbstractInsnNode
+
+ type(name: 'org.objectweb.asm.tree.InsnNode'): _InsnNode
+
+ type(name: 'org.objectweb.asm.tree.LdcInsnNode'): _LdcInsnNode
+
+ type(name: 'org.objectweb.asm.tree.MethodInsnNode'): _MethodInsnNode
+
+ type(name: 'org.objectweb.asm.tree.VarInsnNode'): _VarInsnNode
+
+ type(name: 'org.objectweb.asm.tree.MethodNode'): _MethodNode
+
+ type(name: 'org.objectweb.asm.tree.TypeInsnNode'): _TypeInsnNode
+
+ type(name: 'org.objectweb.asm.Opcodes'): _Opcodes
+}
+
+
+
diff --git a/src/main/resources/asmapi.d.ts b/src/main/resources/asmapi.d.ts
new file mode 100644
index 0000000..85d3fe8
--- /dev/null
+++ b/src/main/resources/asmapi.d.ts
@@ -0,0 +1,206 @@
+import MethodType = ASMAPI.MethodType;
+import InsertMode = ASMAPI.InsertMode;
+
+type MethodNode = any
+type MethodInsnNode = any
+type AbstractInsnNode = any
+type ClassNode = any
+type FieldNode = any
+type InsnList = any
+
+
+
+
+declare interface ASMAPI {
+
+ /**
+ * Helper to construct a new empty MethodNode.
+ */
+ getMethodNode(): MethodNode
+
+ /**
+ * Add a MethodInsnNode to the beginning of the target MethodNode's instructions list.
+ * @param node
+ * @param methodCall
+ */
+ appendMethodCall(node: MethodNode, methodCall: MethodInsnNode): void
+
+
+
+
+ /**
+ * Helper to build a MethodInsnNode.
+ * @param ownerName The name of the owner, from bytecode.
+ * @param methodName The method name, from bytecode.
+ * @param methodDescriptor The method descriptor, from bytecode.
+ * @param type The type of the method to be invoked.
+ */
+ buildMethodCall(ownerName: String, methodName: String, methodDescriptor: String, type: MethodType): MethodInsnNode
+
+ /**
+ * Convert a method name from SRG to deobfuscated.
+ * @param name The SRG name of a method.
+ */
+ mapMethod(name: String): String
+
+ /**
+ * Convert a field name from SRG to deobfuscated.
+ * @param name The SRG name of a field.
+ */
+ mapField(name: String): String
+
+ /**
+ * Checks if the given JVM property (or if the property prepended with {@code "coremod."}) is {@code true}.
+ *
+ * @param propertyName the property to check
+ * @return true if the property is true
+ */
+ getSystemPropertyFlag(propertyName: String): boolean
+
+
+
+ /**
+ * Finds the first instruction with matching opcode
+ *
+ * @param method the method to search in
+ * @param opCode the opcode to search for
+ * @return the found instruction node or null if none matched
+ */
+ findFirstInstruction(method: MethodNode, opCode: number): AbstractInsnNode
+
+ /**
+ * Finds the first instruction with matching opcode after the given start index
+ *
+ * @param method the method to search in
+ * @param opCode the opcode to search for
+ * @param startIndex the index to start search after (inclusive)
+ * @return the found instruction node or null if none matched after the given index
+ */
+ findFirstInstructionAfter(method: MethodNode, opCode: number, startIndex: number): AbstractInsnNode ;
+
+ /**
+ * Finds the first instruction with matching opcode before the given index in reverse search
+ *
+ * @param method the method to search in
+ * @param opCode the opcode to search for
+ * @param startIndex the index at which to start searching (inclusive)
+ * @return the found instruction node or null if none matched before the given startIndex
+ */
+ findFirstInstructionBefore(method: MethodNode, opCode: number, startIndex: number): AbstractInsnNode;
+
+ /**
+ * Finds the first method call in the given method matching the given type, owner, name and descriptor
+ *
+ * @param method the method to search in
+ * @param type the type of method call to search for
+ * @param owner the method call's owner to search for
+ * @param name the method call's name
+ * @param descriptor the method call's descriptor
+ * @return the found method call node or null if none matched
+ */
+ findFirstMethodCall(method: MethodNode, type: MethodType, owner: String, name: String, descriptor: String): MethodInsnNode
+
+ /**
+ * Finds the first method call in the given method matching the given type, owner, name and descriptor
+ * after the instruction given index
+ *
+ * @param method the method to search in
+ * @param type the type of method call to search for
+ * @param owner the method call's owner to search for
+ * @param name the method call's name
+ * @param descriptor the method call's descriptor
+ * @param startIndex the index after which to start searching (inclusive)
+ * @return the found method call node, null if none matched after the given index
+ */
+ findFirstMethodCallAfter(method: MethodNode, type: MethodType, owner: String, name: String, descriptor: String, startIndex: number): MethodInsnNode;
+
+ /**
+ * Finds the first method call in the given method matching the given type, owner, name and descriptor
+ * before the given index in reverse search
+ *
+ * @param method the method to search in
+ * @param type the type of method call to search for
+ * @param owner the method call's owner to search for
+ * @param name the method call's name
+ * @param descriptor the method call's descriptor
+ * @param startIndex the index at which to start searching (inclusive)
+ * @return the found method call node or null if none matched before the given startIndex
+ */
+ findFirstMethodCallBefore(method: MethodNode, type: MethodType, owner: String, name: String, descriptor: String, startIndex: number): MethodInsnNode;
+
+ /**
+ * Inserts/replaces a list after/before first {@link MethodInsnNode} that matches the parameters of these functions in the method provided.
+ * Only the first node matching is targeted, all other matches are ignored.
+ * @param method The method where you want to find the node
+ * @param type The type of the old method node.
+ * @param owner The owner of the old method node.
+ * @param name The name of the old method node. You may want to use {@link #mapMethod(String)} if this is a srg name
+ * @param desc The desc of the old method node.
+ * @param list The list that should be inserted
+ * @param mode How the given code should be inserted
+ * @return True if the node was found, false otherwise
+ */
+ insertInsnList(method: MethodNode, type: MethodType, owner: String, name: String, desc: String, list: InsnList, mode: InsertMode): boolean;
+
+ /**
+ * Builds a new {@link InsnList} out of the specified AbstractInsnNodes
+ * @param nodes The nodes you want to add
+ * @return A new list with the nodes
+ */
+ listOf(...nodes: AbstractInsnNode): InsnList
+
+ /**
+ * Rewrites accesses to a specific field in the given class to a method-call.
+ *
+ * The field specified by fieldName must be private and non-static.
+ * The method-call the field-access is redirected to does not take any parameters and returns an object of the
+ * same type as the field.
+ * If no methodName is passed, any method matching the described signature will be used as callable method.
+ *
+ * @param classNode the class to rewrite the accesses in
+ * @param fieldName the field accesses should be redirected to
+ * @param methodName the name of the method to redirect accesses through,
+ * or null if any method with matching signature should be applicable
+ */
+ redirectFieldToMethod(classNode: ClassNode, fieldName: String, methodName: String): void
+
+ loadFile(file: String): boolean
+
+ /**
+ * Load a JSON file as an object.
+ * @param file Path to the file, from the resources directory/root of the jar.
+ */
+ loadData