summaryrefslogtreecommitdiff
path: root/enigma/src/main/java/cuchaz/enigma/source/cfr/CfrDecompiler.java
diff options
context:
space:
mode:
Diffstat (limited to 'enigma/src/main/java/cuchaz/enigma/source/cfr/CfrDecompiler.java')
-rw-r--r--enigma/src/main/java/cuchaz/enigma/source/cfr/CfrDecompiler.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/enigma/src/main/java/cuchaz/enigma/source/cfr/CfrDecompiler.java b/enigma/src/main/java/cuchaz/enigma/source/cfr/CfrDecompiler.java
index 941a699f..ffc4788c 100644
--- a/enigma/src/main/java/cuchaz/enigma/source/cfr/CfrDecompiler.java
+++ b/enigma/src/main/java/cuchaz/enigma/source/cfr/CfrDecompiler.java
@@ -4,6 +4,7 @@ import cuchaz.enigma.classprovider.ClassProvider;
4import cuchaz.enigma.source.Decompiler; 4import cuchaz.enigma.source.Decompiler;
5import cuchaz.enigma.source.Source; 5import cuchaz.enigma.source.Source;
6import cuchaz.enigma.source.SourceSettings; 6import cuchaz.enigma.source.SourceSettings;
7import cuchaz.enigma.translation.mapping.EntryRemapper;
7import cuchaz.enigma.utils.AsmUtil; 8import cuchaz.enigma.utils.AsmUtil;
8import org.benf.cfr.reader.apiunreleased.ClassFileSource2; 9import org.benf.cfr.reader.apiunreleased.ClassFileSource2;
9import org.benf.cfr.reader.apiunreleased.JarContent; 10import org.benf.cfr.reader.apiunreleased.JarContent;
@@ -19,6 +20,7 @@ import org.benf.cfr.reader.util.CannotLoadClassException;
19import org.benf.cfr.reader.util.collections.ListFactory; 20import org.benf.cfr.reader.util.collections.ListFactory;
20import org.benf.cfr.reader.util.getopt.Options; 21import org.benf.cfr.reader.util.getopt.Options;
21import org.benf.cfr.reader.util.getopt.OptionsImpl; 22import org.benf.cfr.reader.util.getopt.OptionsImpl;
23import org.checkerframework.checker.nullness.qual.Nullable;
22import org.objectweb.asm.tree.ClassNode; 24import org.objectweb.asm.tree.ClassNode;
23 25
24import java.util.Collection; 26import java.util.Collection;
@@ -27,6 +29,8 @@ import java.util.Map;
27 29
28public class CfrDecompiler implements Decompiler { 30public class CfrDecompiler implements Decompiler {
29 private final DCCommonState state; 31 private final DCCommonState state;
32 // cfr doesn't add final on params so final setting is ignored
33 private final SourceSettings settings;
30 34
31 public CfrDecompiler(ClassProvider classProvider, SourceSettings sourceSettings) { 35 public CfrDecompiler(ClassProvider classProvider, SourceSettings sourceSettings) {
32 Map<String, String> options = new HashMap<>(); 36 Map<String, String> options = new HashMap<>();
@@ -63,10 +67,12 @@ public class CfrDecompiler implements Decompiler {
63 return new Pair<>(AsmUtil.nodeToBytes(node), path); 67 return new Pair<>(AsmUtil.nodeToBytes(node), path);
64 } 68 }
65 }); 69 });
70
71 this.settings = sourceSettings;
66 } 72 }
67 73
68 @Override 74 @Override
69 public Source getSource(String className) { 75 public Source getSource(String className, @Nullable EntryRemapper mapper) {
70 DCCommonState state = this.state; 76 DCCommonState state = this.state;
71 Options options = state.getOptions(); 77 Options options = state.getOptions();
72 78
@@ -79,7 +85,8 @@ public class CfrDecompiler implements Decompiler {
79 // To make sure we're analysing the cached version 85 // To make sure we're analysing the cached version
80 try { 86 try {
81 tree = state.getClassFile(tree.getClassType()); 87 tree = state.getClassFile(tree.getClassType());
82 } catch (CannotLoadClassException ignored) {} 88 } catch (CannotLoadClassException ignored) {
89 }
83 90
84 if (options.getOption(OptionsImpl.DECOMPILE_INNER_CLASSES)) { 91 if (options.getOption(OptionsImpl.DECOMPILE_INNER_CLASSES)) {
85 tree.loadInnerClasses(state); 92 tree.loadInnerClasses(state);
@@ -91,6 +98,6 @@ public class CfrDecompiler implements Decompiler {
91 98
92 TypeUsageCollectingDumper typeUsageCollector = new TypeUsageCollectingDumper(options, tree); 99 TypeUsageCollectingDumper typeUsageCollector = new TypeUsageCollectingDumper(options, tree);
93 tree.analyseTop(state, typeUsageCollector); 100 tree.analyseTop(state, typeUsageCollector);
94 return new CfrSource(tree, state, typeUsageCollector.getRealTypeUsageInformation()); 101 return new CfrSource(settings, tree, state, typeUsageCollector.getRealTypeUsageInformation(), options, mapper);
95 } 102 }
96} 103}