summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/analysis
diff options
context:
space:
mode:
authorGravatar jeff2015-03-16 19:22:22 -0400
committerGravatar jeff2015-03-16 19:22:22 -0400
commit5e3743a0aca3529eacf9be400c8b8d7547f66e7f (patch)
treeea601747547f78e1b83ab828650932126440e221 /src/cuchaz/enigma/analysis
parentupdate to new javassist version to (hopefully) get bug fixes (diff)
downloadenigma-fork-5e3743a0aca3529eacf9be400c8b8d7547f66e7f.tar.gz
enigma-fork-5e3743a0aca3529eacf9be400c8b8d7547f66e7f.tar.xz
enigma-fork-5e3743a0aca3529eacf9be400c8b8d7547f66e7f.zip
started adding minimal support for generics
fixed mark-as-deobfuscated issue
Diffstat (limited to 'src/cuchaz/enigma/analysis')
-rw-r--r--src/cuchaz/enigma/analysis/JarIndex.java31
-rw-r--r--src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java7
2 files changed, 24 insertions, 14 deletions
diff --git a/src/cuchaz/enigma/analysis/JarIndex.java b/src/cuchaz/enigma/analysis/JarIndex.java
index 7ebbd97..e255468 100644
--- a/src/cuchaz/enigma/analysis/JarIndex.java
+++ b/src/cuchaz/enigma/analysis/JarIndex.java
@@ -28,6 +28,7 @@ import javassist.CtMethod;
28import javassist.NotFoundException; 28import javassist.NotFoundException;
29import javassist.bytecode.AccessFlag; 29import javassist.bytecode.AccessFlag;
30import javassist.bytecode.Descriptor; 30import javassist.bytecode.Descriptor;
31import javassist.bytecode.EnclosingMethodAttribute;
31import javassist.bytecode.FieldInfo; 32import javassist.bytecode.FieldInfo;
32import javassist.bytecode.InnerClassesAttribute; 33import javassist.bytecode.InnerClassesAttribute;
33import javassist.expr.ConstructorCall; 34import javassist.expr.ConstructorCall;
@@ -314,15 +315,6 @@ public class JarIndex {
314 if (classEntry.isInnerClass()) { 315 if (classEntry.isInnerClass()) {
315 return classEntry.getOuterClassEntry(); 316 return classEntry.getOuterClassEntry();
316 } 317 }
317 InnerClassesAttribute innerClassesAttribute = (InnerClassesAttribute)c.getClassFile().getAttribute(InnerClassesAttribute.tag);
318 if (innerClassesAttribute != null) {
319 for (int i=0; i<innerClassesAttribute.tableLength(); i++) {
320 ClassEntry innerClassEntry = new ClassEntry(Descriptor.toJvmName(innerClassesAttribute.innerClass(i)));
321 if (classEntry.equals(innerClassEntry)) {
322 return new ClassEntry(Descriptor.toJvmName(innerClassesAttribute.outerClass(i)));
323 }
324 }
325 }
326 318
327 // inner classes: 319 // inner classes:
328 // have constructors that can (illegally) set synthetic fields 320 // have constructors that can (illegally) set synthetic fields
@@ -481,6 +473,27 @@ public class JarIndex {
481 473
482 private BehaviorEntry isAnonymousClass(CtClass c, ClassEntry outerClassEntry) { 474 private BehaviorEntry isAnonymousClass(CtClass c, ClassEntry outerClassEntry) {
483 475
476 // is this class already marked anonymous?
477 EnclosingMethodAttribute enclosingMethodAttribute = (EnclosingMethodAttribute)c.getClassFile().getAttribute(EnclosingMethodAttribute.tag);
478 if (enclosingMethodAttribute != null) {
479 if (enclosingMethodAttribute.methodIndex() > 0) {
480 return EntryFactory.getBehaviorEntry(
481 Descriptor.toJvmName(enclosingMethodAttribute.className()),
482 enclosingMethodAttribute.methodName(),
483 enclosingMethodAttribute.methodDescriptor()
484 );
485 } else {
486 // an attribute but no method? assume not anonymous
487 return null;
488 }
489 }
490
491 // if there's an inner class attribute, but not an enclosing method attribute, then it's not anonymous
492 InnerClassesAttribute innerClassesAttribute = (InnerClassesAttribute)c.getClassFile().getAttribute(InnerClassesAttribute.tag);
493 if (innerClassesAttribute != null) {
494 return null;
495 }
496
484 ClassEntry innerClassEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); 497 ClassEntry innerClassEntry = new ClassEntry(Descriptor.toJvmName(c.getName()));
485 498
486 // anonymous classes: 499 // anonymous classes:
diff --git a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java
index f4f4956..f4202b5 100644
--- a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java
+++ b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java
@@ -30,7 +30,6 @@ import cuchaz.enigma.mapping.ClassEntry;
30import cuchaz.enigma.mapping.ConstructorEntry; 30import cuchaz.enigma.mapping.ConstructorEntry;
31import cuchaz.enigma.mapping.EntryFactory; 31import cuchaz.enigma.mapping.EntryFactory;
32import cuchaz.enigma.mapping.FieldEntry; 32import cuchaz.enigma.mapping.FieldEntry;
33import cuchaz.enigma.mapping.Type;
34 33
35public class SourceIndexClassVisitor extends SourceIndexVisitor { 34public class SourceIndexClassVisitor extends SourceIndexVisitor {
36 35
@@ -93,8 +92,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor {
93 @Override 92 @Override
94 public Void visitFieldDeclaration(FieldDeclaration node, SourceIndex index) { 93 public Void visitFieldDeclaration(FieldDeclaration node, SourceIndex index) {
95 FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); 94 FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION);
96 ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); 95 FieldEntry fieldEntry = EntryFactory.getFieldEntry(def);
97 FieldEntry fieldEntry = new FieldEntry(classEntry, def.getName(), new Type(def.getErasedSignature()));
98 assert (node.getVariables().size() == 1); 96 assert (node.getVariables().size() == 1);
99 VariableInitializer variable = node.getVariables().firstOrNullObject(); 97 VariableInitializer variable = node.getVariables().firstOrNullObject();
100 index.addDeclaration(variable.getNameToken(), fieldEntry); 98 index.addDeclaration(variable.getNameToken(), fieldEntry);
@@ -106,8 +104,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor {
106 public Void visitEnumValueDeclaration(EnumValueDeclaration node, SourceIndex index) { 104 public Void visitEnumValueDeclaration(EnumValueDeclaration node, SourceIndex index) {
107 // treat enum declarations as field declarations 105 // treat enum declarations as field declarations
108 FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); 106 FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION);
109 ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); 107 FieldEntry fieldEntry = EntryFactory.getFieldEntry(def);
110 FieldEntry fieldEntry = new FieldEntry(classEntry, def.getName(), new Type(def.getErasedSignature()));
111 index.addDeclaration(node.getNameToken(), fieldEntry); 108 index.addDeclaration(node.getNameToken(), fieldEntry);
112 109
113 return recurse(node, index); 110 return recurse(node, index);