Cleanup (formatting; naming)

This commit is contained in:
Roman Shevchenko 2014-10-14 14:14:49 +02:00
parent 848c420977
commit 373ca99e37
4 changed files with 41 additions and 56 deletions

View File

@ -99,31 +99,31 @@ public class ClassWriter {
DecompilerContext.getLogger().startWriteClass(node.simpleName);
if (node.lambda_information.is_method_reference) {
if (!node.lambda_information.is_content_method_static && method_object != null) {
if (node.lambdaInformation.is_method_reference) {
if (!node.lambdaInformation.is_content_method_static && method_object != null) {
// reference to a virtual method
buffer.append(method_object.toJava(indent, tracer));
}
else {
// reference to a static method
buffer.append(ExprProcessor.getCastTypeName(new VarType(node.lambda_information.content_class_name, false)));
buffer.append(ExprProcessor.getCastTypeName(new VarType(node.lambdaInformation.content_class_name, false)));
}
buffer.append("::");
buffer.append(node.lambda_information.content_method_name);
buffer.append(node.lambdaInformation.content_method_name);
}
else {
// lambda method
StructMethod mt = cl.getMethod(node.lambda_information.content_method_key);
StructMethod mt = cl.getMethod(node.lambdaInformation.content_method_key);
MethodWrapper methodWrapper = wrapper.getMethodWrapper(mt.getName(), mt.getDescriptor());
MethodDescriptor md_content = MethodDescriptor.parseDescriptor(node.lambda_information.content_method_descriptor);
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(node.lambda_information.method_descriptor);
MethodDescriptor md_content = MethodDescriptor.parseDescriptor(node.lambdaInformation.content_method_descriptor);
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(node.lambdaInformation.method_descriptor);
if (!lambdaToAnonymous) {
buffer.append('(');
boolean firstParameter = true;
int index = node.lambda_information.is_content_method_static ? 0 : 1;
int index = node.lambdaInformation.is_content_method_static ? 0 : 1;
int start_index = md_content.params.length - md_lambda.params.length;
for (int i = 0; i < md_content.params.length; i++) {
@ -485,9 +485,9 @@ public class ClassWriter {
DecompilerContext.setProperty(DecompilerContext.CURRENT_METHOD_WRAPPER, methodWrapper);
try {
String method_name = lambdaNode.lambda_information.method_name;
MethodDescriptor md_content = MethodDescriptor.parseDescriptor(lambdaNode.lambda_information.content_method_descriptor);
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(lambdaNode.lambda_information.method_descriptor);
String method_name = lambdaNode.lambdaInformation.method_name;
MethodDescriptor md_content = MethodDescriptor.parseDescriptor(lambdaNode.lambdaInformation.content_method_descriptor);
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(lambdaNode.lambdaInformation.method_descriptor);
if (!codeOnly) {
buffer.appendIndent(indent);
@ -496,7 +496,7 @@ public class ClassWriter {
buffer.append("(");
boolean firstParameter = true;
int index = lambdaNode.lambda_information.is_content_method_static ? 0 : 1;
int index = lambdaNode.lambdaInformation.is_content_method_static ? 0 : 1;
int start_index = md_content.params.length - md_lambda.params.length;
for (int i = 0; i < md_content.params.length; i++) {

View File

@ -347,30 +347,18 @@ public class ClassesProcessor {
public static final int CLASS_LAMBDA = 8;
public int type;
public int access;
public String simpleName;
public StructClass classStruct;
public ClassWrapper wrapper;
public String enclosingMethod;
public InvocationExprent superInvocation;
public HashMap<String, VarVersionPaar> mapFieldsToVars = new HashMap<String, VarVersionPaar>();
public Map<String, VarVersionPaar> mapFieldsToVars = new HashMap<String, VarVersionPaar>();
public VarType anonymousClassType;
public List<ClassNode> nested = new ArrayList<ClassNode>();
public Set<String> enclosingClasses = new HashSet<String>();
public ClassNode parent;
public LambdaInformation lambda_information;
public LambdaInformation lambdaInformation;
public ClassNode(String content_class_name,
String content_method_name,
@ -383,19 +371,19 @@ public class ClassesProcessor {
this.type = CLASS_LAMBDA;
this.classStruct = classStruct; // 'parent' class containing the static function
lambda_information = new LambdaInformation();
lambdaInformation = new LambdaInformation();
lambda_information.class_name = lambda_class_name;
lambda_information.method_name = lambda_method_name;
lambda_information.method_descriptor = lambda_method_descriptor;
lambdaInformation.class_name = lambda_class_name;
lambdaInformation.method_name = lambda_method_name;
lambdaInformation.method_descriptor = lambda_method_descriptor;
lambda_information.content_class_name = content_class_name;
lambda_information.content_method_name = content_method_name;
lambda_information.content_method_descriptor = content_method_descriptor;
lambda_information.content_method_invocation_type = content_method_invocation_type;
lambdaInformation.content_class_name = content_class_name;
lambdaInformation.content_method_name = content_method_name;
lambdaInformation.content_method_descriptor = content_method_descriptor;
lambdaInformation.content_method_invocation_type = content_method_invocation_type;
lambda_information.content_method_key =
InterpreterUtil.makeUniqueKey(lambda_information.content_method_name, lambda_information.content_method_descriptor);
lambdaInformation.content_method_key =
InterpreterUtil.makeUniqueKey(lambdaInformation.content_method_name, lambdaInformation.content_method_descriptor);
anonymousClassType = new VarType(lambda_class_name, true);
@ -405,9 +393,9 @@ public class ClassesProcessor {
is_method_reference = !mt.isSynthetic(); // if not synthetic -> method reference
}
lambda_information.is_method_reference = is_method_reference;
lambda_information.is_content_method_static =
(lambda_information.content_method_invocation_type == CodeConstants.CONSTANT_MethodHandle_REF_invokeStatic); // FIXME: redundant?
lambdaInformation.is_method_reference = is_method_reference;
lambdaInformation.is_content_method_static =
(lambdaInformation.content_method_invocation_type == CodeConstants.CONSTANT_MethodHandle_REF_invokeStatic); // FIXME: redundant?
}
public ClassNode(int type, StructClass classStruct) {
@ -435,7 +423,6 @@ public class ClassesProcessor {
public String content_method_name;
public String content_method_descriptor;
public int content_method_invocation_type; // values from CONSTANT_MethodHandle_REF_*
public String content_method_key;
public boolean is_method_reference;

View File

@ -122,7 +122,7 @@ public class LambdaProcessor {
node_lambda.parent = node;
clprocessor.getMapRootClasses().put(node_lambda.simpleName, node_lambda);
mapMethodsLambda.put(node_lambda.lambda_information.content_method_key, node_lambda.simpleName);
mapMethodsLambda.put(node_lambda.lambdaInformation.content_method_key, node_lambda.simpleName);
}
}
}

View File

@ -47,10 +47,10 @@ public class NestedClassProcessor {
public void processClass(ClassNode root, ClassNode node) {
// hide synthetic lambda content methods
if (node.type == ClassNode.CLASS_LAMBDA && !node.lambda_information.is_method_reference) {
if (node.type == ClassNode.CLASS_LAMBDA && !node.lambdaInformation.is_method_reference) {
ClassNode node_content = DecompilerContext.getClassProcessor().getMapRootClasses().get(node.classStruct.qualifiedName);
if (node_content != null && node_content.wrapper != null) {
node_content.wrapper.getHiddenMembers().add(node.lambda_information.content_method_key);
node_content.wrapper.getHiddenMembers().add(node.lambdaInformation.content_method_key);
}
}
@ -75,8 +75,8 @@ public class NestedClassProcessor {
child.simpleName = "SyntheticClass_" + (++synthetics);
}
else {
DecompilerContext.getLogger().writeMessage("Nameless local or member class " + cl.qualifiedName + "!",
IFernflowerLogger.Severity.WARN);
String message = "Nameless local or member class " + cl.qualifiedName + "!";
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
child.simpleName = "NamelessClass_" + (++nameless);
}
}
@ -86,8 +86,7 @@ public class NestedClassProcessor {
if (child.type == ClassNode.CLASS_LAMBDA) {
setLambdaVars(node, child);
}
else {
if (child.type != ClassNode.CLASS_MEMBER || (child.access & CodeConstants.ACC_STATIC) == 0) {
else if (child.type != ClassNode.CLASS_MEMBER || (child.access & CodeConstants.ACC_STATIC) == 0) {
insertLocalVars(node, child);
if (child.type == ClassNode.CLASS_LOCAL) {
@ -95,7 +94,6 @@ public class NestedClassProcessor {
}
}
}
}
for (ClassNode child : node.nested) {
processClass(root, child);
@ -104,22 +102,22 @@ public class NestedClassProcessor {
private static void setLambdaVars(ClassNode parent, ClassNode child) {
if (child.lambda_information.is_method_reference) { // method reference, no code and no parameters
if (child.lambdaInformation.is_method_reference) { // method reference, no code and no parameters
return;
}
final MethodWrapper meth = parent.wrapper.getMethods().getWithKey(child.lambda_information.content_method_key);
final MethodWrapper meth = parent.wrapper.getMethods().getWithKey(child.lambdaInformation.content_method_key);
final MethodWrapper encmeth = parent.wrapper.getMethods().getWithKey(child.enclosingMethod);
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(child.lambda_information.method_descriptor);
final MethodDescriptor md_content = MethodDescriptor.parseDescriptor(child.lambda_information.content_method_descriptor);
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(child.lambdaInformation.method_descriptor);
final MethodDescriptor md_content = MethodDescriptor.parseDescriptor(child.lambdaInformation.content_method_descriptor);
final int vars_count = md_content.params.length - md_lambda.params.length;
// if(vars_count < 0) { // should not happen, but just in case...
// vars_count = 0;
// }
final boolean is_static_lambda_content = child.lambda_information.is_content_method_static;
final boolean is_static_lambda_content = child.lambdaInformation.is_content_method_static;
final String parent_class_name = parent.wrapper.getClassStruct().qualifiedName;
final String lambda_class_name = child.simpleName;