From fc95d5086ca845c3a2821bd3305ec01e9107576a Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 10 Aug 2019 22:12:46 +0100 Subject: [PATCH] Add {pre,post}Pass methods to Transformer --- .../openrs2/asm/transform/Transformer.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.java b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.java index 8e20e9e7a1..a3fe2b42fc 100644 --- a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.java +++ b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.java @@ -15,6 +15,7 @@ public abstract class Transformer { do { changed = false; + prePass(classPath); for (var library : classPath.getLibraries()) { for (var clazz : library) { changed |= transformClass(clazz); @@ -32,32 +33,41 @@ public abstract class Transformer { } } } + postPass(classPath); } while (changed); postTransform(classPath); } - public void preTransform(ClassPath classPath) throws AnalyzerException { + protected void preTransform(ClassPath classPath) throws AnalyzerException { /* empty */ } - public boolean transformClass(ClassNode clazz) throws AnalyzerException { + protected void prePass(ClassPath classPath) throws AnalyzerException { + /* empty */ + } + + protected boolean transformClass(ClassNode clazz) throws AnalyzerException { return false; } - public boolean transformField(ClassNode clazz, FieldNode field) throws AnalyzerException { + protected boolean transformField(ClassNode clazz, FieldNode field) throws AnalyzerException { return false; } - public boolean transformMethod(ClassNode clazz, MethodNode method) throws AnalyzerException { + protected boolean transformMethod(ClassNode clazz, MethodNode method) throws AnalyzerException { return false; } - public boolean transformCode(ClassNode clazz, MethodNode method) throws AnalyzerException { + protected boolean transformCode(ClassNode clazz, MethodNode method) throws AnalyzerException { return false; } - public void postTransform(ClassPath classPath) throws AnalyzerException { + protected void postPass(ClassPath classPath) throws AnalyzerException { + /* empty */ + } + + protected void postTransform(ClassPath classPath) throws AnalyzerException { /* empty */ } }