From 8966d7b531ffb3be36ac8e0724a4ae6f597c1eb4 Mon Sep 17 00:00:00 2001 From: Graham Date: Mon, 29 Jul 2019 13:58:29 +0100 Subject: [PATCH] Add abstract Transformer class --- .../java/dev/openrs2/asm/Transformer.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 asm/src/main/java/dev/openrs2/asm/Transformer.java diff --git a/asm/src/main/java/dev/openrs2/asm/Transformer.java b/asm/src/main/java/dev/openrs2/asm/Transformer.java new file mode 100644 index 00000000..177a8123 --- /dev/null +++ b/asm/src/main/java/dev/openrs2/asm/Transformer.java @@ -0,0 +1,39 @@ +package dev.openrs2.asm; + +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.MethodNode; + +public abstract class Transformer { + public final void transform(Library library) { + preTransform(library); + + for (var clazz : library) { + transformClass(clazz); + + for (var method : clazz.methods) { + if ((method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) == 0) { + transformMethod(clazz, method); + } + } + } + + postTransform(library); + } + + public void preTransform(Library library) { + /* empty */ + } + + public void transformClass(ClassNode clazz) { + /* empty */ + } + + public void transformMethod(ClassNode clazz, MethodNode method) { + /* empty */ + } + + public void postTransform(Library library) { + /* empty */ + } +}