summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/analysis/EntryReference.java
diff options
context:
space:
mode:
authorGravatar jeff2014-09-28 15:20:54 -0400
committerGravatar jeff2014-09-28 15:20:54 -0400
commitcf3ffcee30083a71e68e3edb9ecbb936cc255992 (patch)
treef9a6415d7eef1e76640b07238d2d08daecedde17 /src/cuchaz/enigma/analysis/EntryReference.java
parentimplemented mark-as-deobfuscated and reset-to-obfuscated (diff)
downloadenigma-fork-cf3ffcee30083a71e68e3edb9ecbb936cc255992.tar.gz
enigma-fork-cf3ffcee30083a71e68e3edb9ecbb936cc255992.tar.xz
enigma-fork-cf3ffcee30083a71e68e3edb9ecbb936cc255992.zip
added proper support for renaming constructors
Diffstat (limited to '')
-rw-r--r--src/cuchaz/enigma/analysis/EntryReference.java43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/cuchaz/enigma/analysis/EntryReference.java b/src/cuchaz/enigma/analysis/EntryReference.java
index 768c113..df977fb 100644
--- a/src/cuchaz/enigma/analysis/EntryReference.java
+++ b/src/cuchaz/enigma/analysis/EntryReference.java
@@ -10,21 +10,28 @@
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma.analysis; 11package cuchaz.enigma.analysis;
12 12
13import java.util.Arrays;
14import java.util.List;
15
13import cuchaz.enigma.Util; 16import cuchaz.enigma.Util;
14import cuchaz.enigma.mapping.ClassEntry; 17import cuchaz.enigma.mapping.ClassEntry;
18import cuchaz.enigma.mapping.ConstructorEntry;
15import cuchaz.enigma.mapping.Entry; 19import cuchaz.enigma.mapping.Entry;
16 20
17public class EntryReference<E extends Entry, C extends Entry> 21public class EntryReference<E extends Entry, C extends Entry>
18{ 22{
23 private static final List<String> ConstructorNonNames = Arrays.asList( "this", "super" );
19 public E entry; 24 public E entry;
20 public C context; 25 public C context;
21 26
22 public EntryReference( E entry ) 27 private boolean m_isNamed;
28
29 public EntryReference( E entry, String sourceName )
23 { 30 {
24 this( entry, null ); 31 this( entry, sourceName, null );
25 } 32 }
26 33
27 public EntryReference( E entry, C context ) 34 public EntryReference( E entry, String sourceName, C context )
28 { 35 {
29 if( entry == null ) 36 if( entry == null )
30 { 37 {
@@ -33,9 +40,22 @@ public class EntryReference<E extends Entry, C extends Entry>
33 40
34 this.entry = entry; 41 this.entry = entry;
35 this.context = context; 42 this.context = context;
43
44 m_isNamed = sourceName != null && sourceName.length() > 0;
45 if( entry instanceof ConstructorEntry && ConstructorNonNames.contains( sourceName ) )
46 {
47 m_isNamed = false;
48 }
49 }
50
51 public EntryReference( E entry, C context, EntryReference<E,C> other )
52 {
53 this.entry = entry;
54 this.context = context;
55 m_isNamed = other.m_isNamed;
36 } 56 }
37 57
38 public ClassEntry getClassEntry( ) 58 public ClassEntry getLocationClassEntry( )
39 { 59 {
40 if( context != null ) 60 if( context != null )
41 { 61 {
@@ -44,6 +64,21 @@ public class EntryReference<E extends Entry, C extends Entry>
44 return entry.getClassEntry(); 64 return entry.getClassEntry();
45 } 65 }
46 66
67 public boolean isNamed( )
68 {
69 return m_isNamed;
70 }
71
72 public Entry getNameableEntry( )
73 {
74 if( entry instanceof ConstructorEntry )
75 {
76 // renaming a constructor really means renaming the class
77 return entry.getClassEntry();
78 }
79 return entry;
80 }
81
47 @Override 82 @Override
48 public int hashCode( ) 83 public int hashCode( )
49 { 84 {