Package-level declarations

Public API available for use in scripts

Types

Link copied to clipboard
class ClassTransformer(val scriptIdentifier: Identifier, val props: TransformerPropertiesStore, val targetClassName: String, block: ClassNode.() -> Unit) : Transformer<ClassNode>

Applies transformations to a Class.

Link copied to clipboard
data class ClassTransformerParams(val name: String)

Stores Class Transformer parameters for mapping with wtf.gofancy.koremods.launch.KoremodsLaunchPlugin.mapClassTransformer.

Link copied to clipboard
class FieldTransformer(val scriptIdentifier: Identifier, val props: TransformerPropertiesStore, val targetClassName: String, val name: String, block: FieldNode.() -> Unit) : Transformer<FieldNode>

Applies transformations to a Field.

Link copied to clipboard
data class FieldTransformerParams(val owner: String, val name: String)

Stores Field Transformer parameters for mapping with wtf.gofancy.koremods.launch.KoremodsLaunchPlugin.mapFieldTransformer.

Link copied to clipboard
interface InsnTarget

Used for manipulating bytecode around a target sequence of bytecode instructions in an InsnList. Because ASM's instruction classes don't implement equals, a custom method is used for matching instructions, which currently supports most of them. See insnEquals for a full list.

Link copied to clipboard
class MethodTransformer(val scriptIdentifier: Identifier, val props: TransformerPropertiesStore, val targetClassName: String, val name: String, val desc: String, block: MethodNode.() -> Unit) : Transformer<MethodNode>

Applies transformations to a Method.

Link copied to clipboard
data class MethodTransformerParams(val owner: String, val name: String, val desc: String)

Stores Method Transformer parameters for mapping with wtf.gofancy.koremods.launch.KoremodsLaunchPlugin.mapMethodTransformer.

Link copied to clipboard
class SharedLabelRegistry(labels: MutableMap<String, LabelNode>, insns: InstructionAssembly)

Stores labels that can be shared between assemblies

Link copied to clipboard
class TargetedAssembly(val instructions: InsnList, val tryCatchBlocks: MutableList<TryCatchBlockNode>, labels: MutableMap<String, LabelNode>, val target: AbstractInsnNode) : InstructionAssembly, TryCatchContainer, ModifiersAccess, TypesAccess

An extended version of BlockAssembly with information about the target node we're inserting bytecode at.

Link copied to clipboard
interface Transformer<T>

Represents an arbitrary transformer that belongs to a Script.

Link copied to clipboard
class TransformerBuilder(scriptIdentifier: Identifier, transformers: MutableList<Transformer<*>>)

Allows the easy creation of Transformers.

Link copied to clipboard
class TransformerHandler(scriptIdentifier: Identifier)

Stores the script's transformers.

Link copied to clipboard
open class TransformerPropertiesStore(baseConfigurations: Iterable<TransformerPropertiesStore>, body: TransformerPropertiesStore.Builder.() -> Unit) : PropertiesCollection

Stores configured transformer properties.

Link copied to clipboard

Common extension point for Transformer extension properties.

Properties

Link copied to clipboard
val InstructionAssembly.f_same: Unit

Add a compressed frame with exactly the same locals as the previous frame and with an empty stack.

Functions

Link copied to clipboard
fun assemble(routine: BlockAssembly.() -> Unit): InsnList

Create an InsnList used to represent an instruction list, using a BlockAssembly.

Link copied to clipboard
fun constructMethodDescriptor(returnType: TypeLike, vararg parameterTypes: TypeLike): String

Construct a method descriptor

Link copied to clipboard
fun InstructionAssembly.f_append(nLocal: Int, local: Array<Any>)

Add 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.

Link copied to clipboard
fun InstructionAssembly.f_chop(nLocal: Int)

Add 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.

Link copied to clipboard
fun InstructionAssembly.f_full(nLocal: Int, local: Array<Any>, nStack: Int, stack: Array<Any>)

Add a compressed frame with complete frame data to the instructions.

Link copied to clipboard
fun InstructionAssembly.f_new(nLocal: Int, local: Array<Any>, nStack: Int, stack: Array<Any>)

Add an expanded frame node to the instructions.

Link copied to clipboard
fun InstructionAssembly.f_same1(stack: Array<Any>)

Add a compressed frame with exactly the same locals as the previous frame and with a single value on the stack.

Link copied to clipboard
fun InsnList.findTarget(failIfNotFound: Boolean = true, block: BlockAssembly.() -> Unit): InsnTarget

Find a sequence of instructions matching the assembly returned by block in this InsnList.

fun InsnList.findTarget(insns: InsnList, failIfNotFound: Boolean = true): InsnTarget

Find a sequence of instructions matching insns in this InsnList.

fun MethodNode.findTarget(failIfNotFound: Boolean = true, block: BlockAssembly.() -> Unit): InsnTarget

Find a sequence of instructions matching the assembly returned by block in this method's instructions.

Link copied to clipboard
fun MethodNode.insert(target: AbstractInsnNode? = null, routine: BlockAssembly.() -> Unit)

Insert instructions into this method after the specified target, or at the beginning if the target is null.

Link copied to clipboard
fun MethodNode.insertBefore(target: AbstractInsnNode, routine: BlockAssembly.() -> Unit)

Insert instructions into this method before the specified target.

Link copied to clipboard
fun AbstractInsnNode.insnEquals(other: AbstractInsnNode): Boolean

Used as a replacement for ASM's missing equals implementation on AbstractInsnNode and its subclasses. This is used along with InsnTarget to match bytecode instructions in lists, and therefore only supports necessary attributes. LabelNodes, LineNumberNodes and FrameNodes are not supported.

Link copied to clipboard
fun InstructionAssembly.invokestatic(owner: TypeLike, name: String, returnType: TypeLike, vararg parameterTypes: TypeLike, isInterface: Boolean = false)

Used to invoke a static method.

Link copied to clipboard
fun InstructionAssembly.label(label: LabelLike)

Add a label node to the instructions.

Link copied to clipboard
fun InsnList.locateTargetOrNull(list: InsnList): InsnTarget?

Find a sequence of bytecode instructions matching list in this InsnList