decompiler: do not fail on nested lambdas

This commit is contained in:
Egor.Ushakov
2014-12-31 15:09:51 +03:00
parent f4e6c8d56f
commit 5a96486853
12 changed files with 74 additions and 46 deletions

View File

@@ -49,8 +49,8 @@ public class NestedClassProcessor {
// hide synthetic lambda content methods
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.lambdaInformation.content_method_key);
if (node_content != null && node_content.getWrapper() != null) {
node_content.getWrapper().getHiddenMembers().add(node.lambdaInformation.content_method_key);
}
}
@@ -91,7 +91,7 @@ public class NestedClassProcessor {
insertLocalVars(node, child);
if (child.type == ClassNode.CLASS_LOCAL) {
setLocalClassDefinition(node.wrapper.getMethods().getWithKey(child.enclosingMethod), child);
setLocalClassDefinition(node.getWrapper().getMethods().getWithKey(child.enclosingMethod), child);
}
}
}
@@ -107,8 +107,8 @@ public class NestedClassProcessor {
return;
}
final MethodWrapper meth = parent.wrapper.getMethods().getWithKey(child.lambdaInformation.content_method_key);
final MethodWrapper encmeth = parent.wrapper.getMethods().getWithKey(child.enclosingMethod);
final MethodWrapper meth = parent.getWrapper().getMethods().getWithKey(child.lambdaInformation.content_method_key);
final MethodWrapper encmeth = parent.getWrapper().getMethods().getWithKey(child.enclosingMethod);
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(child.lambdaInformation.method_descriptor);
final MethodDescriptor md_content = MethodDescriptor.parseDescriptor(child.lambdaInformation.content_method_descriptor);
@@ -120,7 +120,7 @@ public class NestedClassProcessor {
final boolean is_static_lambda_content = child.lambdaInformation.is_content_method_static;
final String parent_class_name = parent.wrapper.getClassStruct().qualifiedName;
final String parent_class_name = parent.getWrapper().getClassStruct().qualifiedName;
final String lambda_class_name = child.simpleName;
final VarType lambda_class_type = new VarType(lambda_class_name, true);
@@ -272,7 +272,7 @@ public class NestedClassProcessor {
cltypes |= nd.type;
HashMap<String, List<VarFieldPair>> mask = getMaskLocalVars(nd.wrapper);
HashMap<String, List<VarFieldPair>> mask = getMaskLocalVars(nd.getWrapper());
if (mask.isEmpty()) {
String message = "Nested class " + nd.classStruct.qualifiedName + " has no constructor!";
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
@@ -291,7 +291,7 @@ public class NestedClassProcessor {
if (cltypes != ClassNode.CLASS_MEMBER) {
// iterate enclosing class
for (final MethodWrapper meth : node.wrapper.getMethods()) {
for (final MethodWrapper meth : node.getWrapper().getMethods()) {
if (meth.root != null) { // neither abstract, nor native
DirectGraph graph = meth.getOrBuildGraph();
@@ -423,7 +423,7 @@ public class NestedClassProcessor {
for (Entry<String, List<VarFieldPair>> entmt : entcl.getValue().entrySet()) {
mergeListSignatures(entmt.getValue(), intrPairMask, false);
MethodWrapper meth = nestedNode.wrapper.getMethodWrapper("<init>", entmt.getKey());
MethodWrapper meth = nestedNode.getWrapper().getMethodWrapper("<init>", entmt.getKey());
meth.signatureFields = new ArrayList<VarVersionPair>();
for (VarFieldPair pair : entmt.getValue()) {
@@ -436,10 +436,10 @@ public class NestedClassProcessor {
private static void insertLocalVars(final ClassNode parent, final ClassNode child) {
// enclosing method, is null iff member class
MethodWrapper encmeth = parent.wrapper.getMethods().getWithKey(child.enclosingMethod);
MethodWrapper encmeth = parent.getWrapper().getMethods().getWithKey(child.enclosingMethod);
// iterate all child methods
for (final MethodWrapper meth : child.wrapper.getMethods()) {
for (final MethodWrapper meth : child.getWrapper().getMethods()) {
if (meth.root != null) { // neither abstract nor native
@@ -503,7 +503,7 @@ public class NestedClassProcessor {
if (clnode.type != ClassNode.CLASS_MEMBER) {
MethodWrapper enclosing_method = clnode.parent.wrapper.getMethods().getWithKey(clnode.enclosingMethod);
MethodWrapper enclosing_method = clnode.parent.getWrapper().getMethods().getWithKey(clnode.enclosingMethod);
varname = enclosing_method.varproc.getVarName(entr.getValue());
vartype = enclosing_method.varproc.getVarType(entr.getValue());
@@ -528,7 +528,7 @@ public class NestedClassProcessor {
// hide synthetic field
if (clnode == child) { // fields higher up the chain were already handled with their classes
StructField fd = child.classStruct.getFields().getWithKey(entr.getKey());
child.wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(fd.getName(), fd.getDescriptor()));
child.getWrapper().getHiddenMembers().add(InterpreterUtil.makeUniqueKey(fd.getName(), fd.getDescriptor()));
}
}
}

View File

@@ -67,7 +67,7 @@ public class NestedMemberAccess {
computeMethodTypes(nd);
}
for (MethodWrapper method : node.wrapper.getMethods()) {
for (MethodWrapper method : node.getWrapper().getMethods()) {
computeMethodType(node, method);
}
}
@@ -220,7 +220,7 @@ public class NestedMemberAccess {
return;
}
for (MethodWrapper meth : node.wrapper.getMethods()) {
for (MethodWrapper meth : node.getWrapper().getMethods()) {
if (meth.root != null) {
@@ -327,8 +327,8 @@ public class NestedMemberAccess {
ClassNode node = DecompilerContext.getClassProcessor().getMapRootClasses().get(invexpr.getClassname());
MethodWrapper methsource = null;
if (node != null && node.wrapper != null) {
methsource = node.wrapper.getMethodWrapper(invexpr.getName(), invexpr.getStringDescriptor());
if (node != null && node.getWrapper() != null) {
methsource = node.getWrapper().getMethodWrapper(invexpr.getName(), invexpr.getStringDescriptor());
}
if (methsource == null || !mapMethodType.containsKey(methsource)) {
@@ -440,7 +440,7 @@ public class NestedMemberAccess {
}
}
if (hide) {
node.wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(invexpr.getName(), invexpr.getStringDescriptor()));
node.getWrapper().getHiddenMembers().add(InterpreterUtil.makeUniqueKey(invexpr.getName(), invexpr.getStringDescriptor()));
}
}