java-decompiler: post-import cleanup (typos)

This commit is contained in:
Roman Shevchenko
2014-09-01 16:08:53 +04:00
parent 3104531729
commit 984af2e7d0
39 changed files with 115 additions and 131 deletions

View File

@@ -191,7 +191,7 @@ public class AssertProcessor {
AssertExprent asexpr = new AssertExprent(lstParams);
Statement newstat = new BasicBlockStatement(new BasicBlock(
DecompilerContext.getCountercontainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER)));
DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER)));
newstat.setExprents(Arrays.asList(new Exprent[]{asexpr}));
Statement first = stat.getFirst();

View File

@@ -263,7 +263,7 @@ public class ClassReference14Processor {
((ConstExprent)headexpr.getLstOperands().get(1)).getConsttype().equals(VarType.VARTYPE_NULL)) {
FieldExprent field = (FieldExprent)headexpr.getLstOperands().get(0);
ClassNode fieldnode = DecompilerContext.getClassprocessor().getMapRootClasses().get(field.getClassname());
ClassNode fieldnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(field.getClassname());
if (fieldnode != null && fieldnode.classStruct.qualifiedName.equals(wrapper.getClassStruct().qualifiedName)) { // source class
StructField fd =

View File

@@ -122,8 +122,8 @@ public class ClassWriter {
boolean lambda_to_anonymous = DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS);
ClassNode nodeold = (ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASSNODE);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASSNODE, node);
ClassNode nodeold = (ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_NODE);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, node);
ClassWrapper wrapper = node_content.wrapper;
StructClass cl = wrapper.getClassStruct();
@@ -206,7 +206,7 @@ public class ClassWriter {
writer.flush();
}
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASSNODE, nodeold);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, nodeold);
DecompilerContext.getLogger().endWriteClass();
}
@@ -216,8 +216,8 @@ public class ClassWriter {
ClassWrapper wrapper = node.wrapper;
StructClass cl = wrapper.getClassStruct();
ClassNode nodeold = (ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASSNODE);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASSNODE, node);
ClassNode nodeold = (ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_NODE);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, node);
// last minute processing
invokeProcessors(node);
@@ -329,7 +329,7 @@ public class ClassWriter {
}
writer.flush();
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASSNODE, nodeold);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, nodeold);
DecompilerContext.getLogger().endWriteClass();
}

View File

@@ -243,15 +243,15 @@ public class ClassesProcessor {
}
try {
DecompilerContext.setImpcollector(new ImportCollector(root));
DecompilerContext.setCountercontainer(new CounterContainer());
DecompilerContext.setImportCollector(new ImportCollector(root));
DecompilerContext.setCounterContainer(new CounterContainer());
// lambda processing
LambdaProcessor lambda_proc = new LambdaProcessor();
lambda_proc.processClass(root);
// add simple class names to implicit import
addClassnameToImport(root, DecompilerContext.getImpcollector());
addClassnameToImport(root, DecompilerContext.getImportCollector());
// build wrappers for all nested classes
// that's where the actual processing takes place
initWrappers(root);
@@ -277,9 +277,9 @@ public class ClassesProcessor {
outwriter.write(DecompilerContext.getNewLineSeparator());
}
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASSNODE, root);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, root);
DecompilerContext.getImpcollector().writeImports(outwriter);
DecompilerContext.getImportCollector().writeImports(outwriter);
outwriter.write(DecompilerContext.getNewLineSeparator());
outwriter.write(strwriter.toString());

View File

@@ -27,33 +27,23 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class DecompilerContext {
public static final String CURRENT_CLASS = "CURRENT_CLASS";
public static final String CURRENT_CLASS_NODE = "CURRENT_CLASS_NODE";
public static final String CURRENT_METHOD = "CURRENT_METHOD";
public static final String CURRENT_METHOD_DESCRIPTOR = "CURRENT_METHOD_DESCRIPTOR";
public static final String CURRENT_VAR_PROCESSOR = "CURRENT_VAR_PROCESSOR";
public static final String CURRENT_CLASSNODE = "CURRENT_CLASSNODE";
public static final String CURRENT_METHOD_WRAPPER = "CURRENT_METHOD_WRAPPER";
public static final String CURRENT_VAR_PROCESSOR = "CURRENT_VAR_PROCESSOR";
private static ThreadLocal<DecompilerContext> currentContext = new ThreadLocal<DecompilerContext>();
private final Map<String, Object> properties;
private StructContext structcontext;
private ImportCollector impcollector;
private VarNamesCollector varncollector;
private CounterContainer countercontainer;
private ClassesProcessor classprocessor;
private PoolInterceptor poolinterceptor;
private StructContext structContext;
private ImportCollector importCollector;
private VarNamesCollector varNamescollector;
private CounterContainer counterContainer;
private ClassesProcessor classProcessor;
private PoolInterceptor poolInterceptor;
private IFernflowerLogger logger;
private DecompilerContext(Map<String, Object> properties) {
@@ -88,52 +78,52 @@ public class DecompilerContext {
return "1".equals(getCurrentContext().properties.get(key));
}
public static ImportCollector getImpcollector() {
return getCurrentContext().impcollector;
public static ImportCollector getImportCollector() {
return getCurrentContext().importCollector;
}
public static void setImpcollector(ImportCollector impcollector) {
getCurrentContext().impcollector = impcollector;
public static void setImportCollector(ImportCollector importCollector) {
getCurrentContext().importCollector = importCollector;
}
public static VarNamesCollector getVarncollector() {
return getCurrentContext().varncollector;
public static VarNamesCollector getVarNamesCollector() {
return getCurrentContext().varNamescollector;
}
public static void setVarncollector(VarNamesCollector varncollector) {
getCurrentContext().varncollector = varncollector;
public static void setVarNamesCollector(VarNamesCollector varNamesCollector) {
getCurrentContext().varNamescollector = varNamesCollector;
}
public static StructContext getStructcontext() {
return getCurrentContext().structcontext;
public static StructContext getStructContext() {
return getCurrentContext().structContext;
}
public static void setStructcontext(StructContext structcontext) {
getCurrentContext().structcontext = structcontext;
public static void setStructContext(StructContext structContext) {
getCurrentContext().structContext = structContext;
}
public static CounterContainer getCountercontainer() {
return getCurrentContext().countercontainer;
public static CounterContainer getCounterContainer() {
return getCurrentContext().counterContainer;
}
public static void setCountercontainer(CounterContainer countercontainer) {
getCurrentContext().countercontainer = countercontainer;
public static void setCounterContainer(CounterContainer counterContainer) {
getCurrentContext().counterContainer = counterContainer;
}
public static ClassesProcessor getClassprocessor() {
return getCurrentContext().classprocessor;
public static ClassesProcessor getClassProcessor() {
return getCurrentContext().classProcessor;
}
public static void setClassprocessor(ClassesProcessor classprocessor) {
getCurrentContext().classprocessor = classprocessor;
public static void setClassProcessor(ClassesProcessor classProcessor) {
getCurrentContext().classProcessor = classProcessor;
}
public static PoolInterceptor getPoolInterceptor() {
return getCurrentContext().poolinterceptor;
return getCurrentContext().poolInterceptor;
}
public static void setPoolInterceptor(PoolInterceptor poolinterceptor) {
getCurrentContext().poolinterceptor = poolinterceptor;
getCurrentContext().poolInterceptor = poolinterceptor;
}
public static IFernflowerLogger getLogger() {
@@ -141,13 +131,6 @@ public class DecompilerContext {
}
public static void setLogger(IFernflowerLogger logger) {
getCurrentContext().logger = logger;
setLogSeverity();
}
private static void setLogSeverity() {
IFernflowerLogger logger = getCurrentContext().logger;
if (logger != null) {
String severity = (String)getProperty(IFernflowerPreferences.LOG_LEVEL);
if (severity != null) {
@@ -157,6 +140,7 @@ public class DecompilerContext {
}
}
}
getCurrentContext().logger = logger;
}
public static String getNewLineSeparator() {

View File

@@ -88,7 +88,7 @@ public class EnumProcessor {
if (initializer != null && initializer.type == Exprent.EXPRENT_NEW) {
NewExprent nexpr = (NewExprent)initializer;
if (nexpr.isAnonymous()) {
ClassNode child = DecompilerContext.getClassprocessor().getMapRootClasses().get(nexpr.getNewtype().value);
ClassNode child = DecompilerContext.getClassProcessor().getMapRootClasses().get(nexpr.getNewtype().value);
hideDummyFieldInConstant(child.wrapper);
}
}

View File

@@ -44,7 +44,7 @@ public class Fernflower implements IDecompiledData {
structcontext = new StructContext(saver, this, new LazyLoader(provider));
DecompilerContext.initContext(propertiesCustom);
DecompilerContext.setCountercontainer(new CounterContainer());
DecompilerContext.setCounterContainer(new CounterContainer());
}
public void decompileContext() {
@@ -55,8 +55,8 @@ public class Fernflower implements IDecompiledData {
clprocessor = new ClassesProcessor(structcontext);
DecompilerContext.setClassprocessor(clprocessor);
DecompilerContext.setStructcontext(structcontext);
DecompilerContext.setClassProcessor(clprocessor);
DecompilerContext.setStructContext(structcontext);
structcontext.saveContext();
}

View File

@@ -163,7 +163,7 @@ public class InitializerProcessor {
StructClass cl = wrapper.getClassStruct();
boolean isAnonymous = DecompilerContext.getClassprocessor().getMapRootClasses().get(cl.qualifiedName).type == ClassNode.CLASS_ANONYMOUS;
boolean isAnonymous = DecompilerContext.getClassProcessor().getMapRootClasses().get(cl.qualifiedName).type == ClassNode.CLASS_ANONYMOUS;
List<List<Exprent>> lstFirst = new ArrayList<List<Exprent>>();
List<MethodWrapper> lstMethWrappers = new ArrayList<MethodWrapper>();

View File

@@ -55,7 +55,7 @@ public class ImportCollector {
public String getShortName(String fullname, boolean imported) {
ClassesProcessor clproc = DecompilerContext.getClassprocessor();
ClassesProcessor clproc = DecompilerContext.getClassProcessor();
ClassNode node = clproc.getMapRootClasses().get(fullname.replace('.', '/'));
String retname = null;
@@ -91,7 +91,7 @@ public class ImportCollector {
npackage = fullname.substring(0, lastpoint);
}
StructContext context = DecompilerContext.getStructcontext();
StructContext context = DecompilerContext.getStructContext();
boolean existsDefaultClass = (context.getClass(currentPackageSlash + nshort) != null
&& !npackage.equals(currentPackagePoint)) // current package

View File

@@ -30,13 +30,13 @@ public interface IFernflowerPreferences {
String DECOMPILE_GENERIC_SIGNATURES = "dgs";
String NO_EXCEPTIONS_RETURN = "ner";
String DECOMPILE_ENUM = "den";
String REMOVE_GETCLASS_NEW = "rgn";
String REMOVE_GET_CLASS_NEW = "rgn";
String LITERALS_AS_IS = "lit";
String BOOLEAN_TRUE_ONE = "bto";
String ASCII_STRING_CHARACTERS = "asc";
String SYNTHETIC_NOT_SET = "nns";
String UNDEFINED_PARAM_TYPE_OBJECT = "uto";
String USE_DEBUG_VARNAMES = "udv";
String USE_DEBUG_VAR_NAMES = "udv";
String REMOVE_EMPTY_RANGES = "rer";
String FINALLY_DEINLINE = "fdi";
String IDEA_NOT_NULL_ANNOTATION = "inn";
@@ -63,13 +63,13 @@ public interface IFernflowerPreferences {
put(DECOMPILE_GENERIC_SIGNATURES, "0");
put(NO_EXCEPTIONS_RETURN, "1");
put(DECOMPILE_ENUM, "1");
put(REMOVE_GETCLASS_NEW, "1");
put(REMOVE_GET_CLASS_NEW, "1");
put(LITERALS_AS_IS, "0");
put(BOOLEAN_TRUE_ONE, "1");
put(ASCII_STRING_CHARACTERS, "0");
put(SYNTHETIC_NOT_SET, "1");
put(UNDEFINED_PARAM_TYPE_OBJECT, "1");
put(USE_DEBUG_VARNAMES, "1");
put(USE_DEBUG_VAR_NAMES, "1");
put(REMOVE_EMPTY_RANGES, "1");
put(FINALLY_DEINLINE, "1");
put(IDEA_NOT_NULL_ANNOTATION, "1");

View File

@@ -74,10 +74,10 @@ public class ClassWrapper {
DecompilerContext.getLogger().startMethod(mt.getName() + " " + mt.getDescriptor());
VarNamesCollector vc = new VarNamesCollector();
DecompilerContext.setVarncollector(vc);
DecompilerContext.setVarNamesCollector(vc);
CounterContainer counter = new CounterContainer();
DecompilerContext.setCountercontainer(counter);
DecompilerContext.setCounterContainer(counter);
DecompilerContext.setProperty(DecompilerContext.CURRENT_METHOD, mt);
DecompilerContext.setProperty(DecompilerContext.CURRENT_METHOD_DESCRIPTOR, MethodDescriptor.parseDescriptor(mt.getDescriptor()));
@@ -165,7 +165,7 @@ public class ClassWrapper {
varproc.refreshVarNames(new VarNamesCollector(setFieldNames));
// if debug information present and should be used
if (DecompilerContext.getOption(IFernflowerPreferences.USE_DEBUG_VARNAMES)) {
if (DecompilerContext.getOption(IFernflowerPreferences.USE_DEBUG_VAR_NAMES)) {
StructLocalVariableTableAttribute attr = (StructLocalVariableTableAttribute)mt.getAttributes().getWithKey(
StructGeneralAttribute.ATTRIBUTE_LOCAL_VARIABLE_TABLE);

View File

@@ -54,7 +54,7 @@ public class LambdaProcessor {
public boolean hasLambda(ClassNode node) throws IOException {
ClassesProcessor clprocessor = DecompilerContext.getClassprocessor();
ClassesProcessor clprocessor = DecompilerContext.getClassProcessor();
StructClass cl = node.classStruct;
if (cl.getBytecodeVersion() < CodeConstants.BYTECODE_JAVA_8) { // lamda beginning with Java 8

View File

@@ -124,7 +124,7 @@ public class MethodProcessorThread implements Runnable {
DeadCodeHelper.mergeBasicBlocks(graph);
DecompilerContext.getCountercontainer().setCounter(CounterContainer.VAR_COUNTER, mt.getLocalVariables());
DecompilerContext.getCounterContainer().setCounter(CounterContainer.VAR_COUNTER, mt.getLocalVariables());
//DotExporter.toDotFile(graph, new File("c:\\Temp\\fern3.dot"), true);
//System.out.println(graph.toString());

View File

@@ -48,7 +48,7 @@ public class NestedClassProcessor {
// hide synthetic lambda content methods
if (node.type == ClassNode.CLASS_LAMBDA && !node.lambda_information.is_method_reference) {
ClassNode node_content = DecompilerContext.getClassprocessor().getMapRootClasses().get(node.classStruct.qualifiedName);
ClassNode node_content = DecompilerContext.getClassProcessor().getMapRootClasses().get(node.classStruct.qualifiedName);
if (node_content != null && node_content.wrapper != null) {
node_content.wrapper.getHideMembers().add(node.lambda_information.content_method_key);
}

View File

@@ -329,7 +329,7 @@ public class NestedMemberAccess {
private Exprent replaceAccessExprent(ClassNode caller, MethodWrapper methdest, InvocationExprent invexpr) {
ClassNode node = DecompilerContext.getClassprocessor().getMapRootClasses().get(invexpr.getClassname());
ClassNode node = DecompilerContext.getClassProcessor().getMapRootClasses().get(invexpr.getClassname());
MethodWrapper methsource = null;
if (node != null && node.wrapper != null) {