diff options
| author | 2014-08-21 01:10:37 -0400 | |
|---|---|---|
| committer | 2014-08-21 01:10:37 -0400 | |
| commit | 237b2ed2a6b6f537cdbdf9fc9c6d0c7743f34375 (patch) | |
| tree | ebad059c7fa0bc7723858cb25eed0bb6e95fe42a /src/cuchaz/enigma/mapping | |
| parent | fixed recognition of inner class tokens (diff) | |
| download | enigma-fork-237b2ed2a6b6f537cdbdf9fc9c6d0c7743f34375.tar.gz enigma-fork-237b2ed2a6b6f537cdbdf9fc9c6d0c7743f34375.tar.xz enigma-fork-237b2ed2a6b6f537cdbdf9fc9c6d0c7743f34375.zip | |
fixed call graph searching
added system to navigate multiple tokens for the same entry in a behavior
Diffstat (limited to 'src/cuchaz/enigma/mapping')
| -rw-r--r-- | src/cuchaz/enigma/mapping/ConstructorEntry.java | 54 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/Translator.java | 28 |
2 files changed, 63 insertions, 19 deletions
diff --git a/src/cuchaz/enigma/mapping/ConstructorEntry.java b/src/cuchaz/enigma/mapping/ConstructorEntry.java index 0f7dab6..ad029e1 100644 --- a/src/cuchaz/enigma/mapping/ConstructorEntry.java +++ b/src/cuchaz/enigma/mapping/ConstructorEntry.java | |||
| @@ -21,16 +21,17 @@ public class ConstructorEntry implements BehaviorEntry, Serializable | |||
| 21 | private ClassEntry m_classEntry; | 21 | private ClassEntry m_classEntry; |
| 22 | private String m_signature; | 22 | private String m_signature; |
| 23 | 23 | ||
| 24 | public ConstructorEntry( ClassEntry classEntry ) | ||
| 25 | { | ||
| 26 | this( classEntry, null ); | ||
| 27 | } | ||
| 28 | |||
| 24 | public ConstructorEntry( ClassEntry classEntry, String signature ) | 29 | public ConstructorEntry( ClassEntry classEntry, String signature ) |
| 25 | { | 30 | { |
| 26 | if( classEntry == null ) | 31 | if( classEntry == null ) |
| 27 | { | 32 | { |
| 28 | throw new IllegalArgumentException( "Class cannot be null!" ); | 33 | throw new IllegalArgumentException( "Class cannot be null!" ); |
| 29 | } | 34 | } |
| 30 | if( signature == null ) | ||
| 31 | { | ||
| 32 | throw new IllegalArgumentException( "Method signature cannot be null!" ); | ||
| 33 | } | ||
| 34 | 35 | ||
| 35 | m_classEntry = classEntry; | 36 | m_classEntry = classEntry; |
| 36 | m_signature = signature; | 37 | m_signature = signature; |
| @@ -47,11 +48,20 @@ public class ConstructorEntry implements BehaviorEntry, Serializable | |||
| 47 | { | 48 | { |
| 48 | return m_classEntry; | 49 | return m_classEntry; |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | @Override | 52 | @Override |
| 52 | public String getName( ) | 53 | public String getName( ) |
| 53 | { | 54 | { |
| 54 | return m_classEntry.getName(); | 55 | if( isStatic() ) |
| 56 | { | ||
| 57 | return "<clinit>"; | ||
| 58 | } | ||
| 59 | return "<init>"; | ||
| 60 | } | ||
| 61 | |||
| 62 | public boolean isStatic( ) | ||
| 63 | { | ||
| 64 | return m_signature == null; | ||
| 55 | } | 65 | } |
| 56 | 66 | ||
| 57 | @Override | 67 | @Override |
| @@ -69,7 +79,14 @@ public class ConstructorEntry implements BehaviorEntry, Serializable | |||
| 69 | @Override | 79 | @Override |
| 70 | public int hashCode( ) | 80 | public int hashCode( ) |
| 71 | { | 81 | { |
| 72 | return Util.combineHashesOrdered( m_classEntry, m_signature ); | 82 | if( isStatic() ) |
| 83 | { | ||
| 84 | return Util.combineHashesOrdered( m_classEntry ); | ||
| 85 | } | ||
| 86 | else | ||
| 87 | { | ||
| 88 | return Util.combineHashesOrdered( m_classEntry, m_signature ); | ||
| 89 | } | ||
| 73 | } | 90 | } |
| 74 | 91 | ||
| 75 | @Override | 92 | @Override |
| @@ -84,12 +101,31 @@ public class ConstructorEntry implements BehaviorEntry, Serializable | |||
| 84 | 101 | ||
| 85 | public boolean equals( ConstructorEntry other ) | 102 | public boolean equals( ConstructorEntry other ) |
| 86 | { | 103 | { |
| 87 | return m_classEntry.equals( other.m_classEntry ) && m_signature.equals( other.m_signature ); | 104 | if( isStatic() != other.isStatic() ) |
| 105 | { | ||
| 106 | return false; | ||
| 107 | } | ||
| 108 | |||
| 109 | if( isStatic() ) | ||
| 110 | { | ||
| 111 | return m_classEntry.equals( other.m_classEntry ); | ||
| 112 | } | ||
| 113 | else | ||
| 114 | { | ||
| 115 | return m_classEntry.equals( other.m_classEntry ) && m_signature.equals( other.m_signature ); | ||
| 116 | } | ||
| 88 | } | 117 | } |
| 89 | 118 | ||
| 90 | @Override | 119 | @Override |
| 91 | public String toString( ) | 120 | public String toString( ) |
| 92 | { | 121 | { |
| 93 | return m_classEntry.getName() + m_signature; | 122 | if( isStatic() ) |
| 123 | { | ||
| 124 | return m_classEntry.getName() + "." + getName(); | ||
| 125 | } | ||
| 126 | else | ||
| 127 | { | ||
| 128 | return m_classEntry.getName() + "." + getName() + m_signature; | ||
| 129 | } | ||
| 94 | } | 130 | } |
| 95 | } | 131 | } |
diff --git a/src/cuchaz/enigma/mapping/Translator.java b/src/cuchaz/enigma/mapping/Translator.java index e34c31b..a671c27 100644 --- a/src/cuchaz/enigma/mapping/Translator.java +++ b/src/cuchaz/enigma/mapping/Translator.java | |||
| @@ -30,27 +30,28 @@ public class Translator | |||
| 30 | m_ancestries = ancestries; | 30 | m_ancestries = ancestries; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | public Entry translateEntry( Entry entry ) | 33 | @SuppressWarnings( "unchecked" ) |
| 34 | public <T extends Entry> T translateEntry( T entry ) | ||
| 34 | { | 35 | { |
| 35 | if( entry instanceof ClassEntry ) | 36 | if( entry instanceof ClassEntry ) |
| 36 | { | 37 | { |
| 37 | return translateEntry( (ClassEntry)entry ); | 38 | return (T)translateEntry( (ClassEntry)entry ); |
| 38 | } | 39 | } |
| 39 | else if( entry instanceof FieldEntry ) | 40 | else if( entry instanceof FieldEntry ) |
| 40 | { | 41 | { |
| 41 | return translateEntry( (FieldEntry)entry ); | 42 | return (T)translateEntry( (FieldEntry)entry ); |
| 42 | } | 43 | } |
| 43 | else if( entry instanceof MethodEntry ) | 44 | else if( entry instanceof MethodEntry ) |
| 44 | { | 45 | { |
| 45 | return translateEntry( (MethodEntry)entry ); | 46 | return (T)translateEntry( (MethodEntry)entry ); |
| 46 | } | 47 | } |
| 47 | else if( entry instanceof ConstructorEntry ) | 48 | else if( entry instanceof ConstructorEntry ) |
| 48 | { | 49 | { |
| 49 | return translateEntry( (ConstructorEntry)entry ); | 50 | return (T)translateEntry( (ConstructorEntry)entry ); |
| 50 | } | 51 | } |
| 51 | else if( entry instanceof ArgumentEntry ) | 52 | else if( entry instanceof ArgumentEntry ) |
| 52 | { | 53 | { |
| 53 | return translateEntry( (ArgumentEntry)entry ); | 54 | return (T)translateEntry( (ArgumentEntry)entry ); |
| 54 | } | 55 | } |
| 55 | else | 56 | else |
| 56 | { | 57 | { |
| @@ -194,10 +195,17 @@ public class Translator | |||
| 194 | 195 | ||
| 195 | public ConstructorEntry translateEntry( ConstructorEntry in ) | 196 | public ConstructorEntry translateEntry( ConstructorEntry in ) |
| 196 | { | 197 | { |
| 197 | return new ConstructorEntry( | 198 | if( in.isStatic() ) |
| 198 | translateEntry( in.getClassEntry() ), | 199 | { |
| 199 | translateSignature( in.getSignature() ) | 200 | return new ConstructorEntry( translateEntry( in.getClassEntry() ) ); |
| 200 | ); | 201 | } |
| 202 | else | ||
| 203 | { | ||
| 204 | return new ConstructorEntry( | ||
| 205 | translateEntry( in.getClassEntry() ), | ||
| 206 | translateSignature( in.getSignature() ) | ||
| 207 | ); | ||
| 208 | } | ||
| 201 | } | 209 | } |
| 202 | 210 | ||
| 203 | public BehaviorEntry translateEntry( BehaviorEntry in ) | 211 | public BehaviorEntry translateEntry( BehaviorEntry in ) |