diff options
| author | 2016-07-02 18:04:57 +1000 | |
|---|---|---|
| committer | 2016-07-02 18:04:57 +1000 | |
| commit | 64c359d3c1d2347001e5c6becb1d7561457f52cc (patch) | |
| tree | bc2f37325b770475237437d204e95254dbfa0b3d /src/main/java/cuchaz/enigma/mapping/MethodMapping.java | |
| parent | Fixed Null.json and #4 (diff) | |
| download | enigma-fork-64c359d3c1d2347001e5c6becb1d7561457f52cc.tar.gz enigma-fork-64c359d3c1d2347001e5c6becb1d7561457f52cc.tar.xz enigma-fork-64c359d3c1d2347001e5c6becb1d7561457f52cc.zip | |
Renamed Fields
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/MethodMapping.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/MethodMapping.java | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/MethodMapping.java b/src/main/java/cuchaz/enigma/mapping/MethodMapping.java index d1beddd..ff14ccd 100644 --- a/src/main/java/cuchaz/enigma/mapping/MethodMapping.java +++ b/src/main/java/cuchaz/enigma/mapping/MethodMapping.java | |||
| @@ -36,62 +36,62 @@ public class MethodMapping implements Serializable, Comparable<MethodMapping>, M | |||
| 36 | if (obfSignature == null) { | 36 | if (obfSignature == null) { |
| 37 | throw new IllegalArgumentException("obf signature cannot be null!"); | 37 | throw new IllegalArgumentException("obf signature cannot be null!"); |
| 38 | } | 38 | } |
| 39 | m_obfName = obfName; | 39 | this.m_obfName = obfName; |
| 40 | m_deobfName = NameValidator.validateMethodName(deobfName); | 40 | this.m_deobfName = NameValidator.validateMethodName(deobfName); |
| 41 | m_obfSignature = obfSignature; | 41 | this.m_obfSignature = obfSignature; |
| 42 | m_arguments = Maps.newTreeMap(); | 42 | this.m_arguments = Maps.newTreeMap(); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | public MethodMapping(MethodMapping other, ClassNameReplacer obfClassNameReplacer) { | 45 | public MethodMapping(MethodMapping other, ClassNameReplacer obfClassNameReplacer) { |
| 46 | m_obfName = other.m_obfName; | 46 | this.m_obfName = other.m_obfName; |
| 47 | m_deobfName = other.m_deobfName; | 47 | this.m_deobfName = other.m_deobfName; |
| 48 | m_obfSignature = new Signature(other.m_obfSignature, obfClassNameReplacer); | 48 | this.m_obfSignature = new Signature(other.m_obfSignature, obfClassNameReplacer); |
| 49 | m_arguments = Maps.newTreeMap(); | 49 | this.m_arguments = Maps.newTreeMap(); |
| 50 | for (Entry<Integer, ArgumentMapping> entry : other.m_arguments.entrySet()) { | 50 | for (Entry<Integer, ArgumentMapping> entry : other.m_arguments.entrySet()) { |
| 51 | m_arguments.put(entry.getKey(), new ArgumentMapping(entry.getValue())); | 51 | this.m_arguments.put(entry.getKey(), new ArgumentMapping(entry.getValue())); |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | @Override | 55 | @Override |
| 56 | public String getObfName() { | 56 | public String getObfName() { |
| 57 | return m_obfName; | 57 | return this.m_obfName; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | public void setObfName(String val) { | 60 | public void setObfName(String val) { |
| 61 | m_obfName = NameValidator.validateMethodName(val); | 61 | this.m_obfName = NameValidator.validateMethodName(val); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | public String getDeobfName() { | 64 | public String getDeobfName() { |
| 65 | return m_deobfName; | 65 | return this.m_deobfName; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | public void setDeobfName(String val) { | 68 | public void setDeobfName(String val) { |
| 69 | m_deobfName = NameValidator.validateMethodName(val); | 69 | this.m_deobfName = NameValidator.validateMethodName(val); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | public Signature getObfSignature() { | 72 | public Signature getObfSignature() { |
| 73 | return m_obfSignature; | 73 | return this.m_obfSignature; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | public void setObfSignature(Signature val) { | 76 | public void setObfSignature(Signature val) { |
| 77 | m_obfSignature = val; | 77 | this.m_obfSignature = val; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | public Iterable<ArgumentMapping> arguments() { | 80 | public Iterable<ArgumentMapping> arguments() { |
| 81 | return m_arguments.values(); | 81 | return this.m_arguments.values(); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | public boolean isConstructor() { | 84 | public boolean isConstructor() { |
| 85 | return m_obfName.startsWith("<"); | 85 | return this.m_obfName.startsWith("<"); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | public void addArgumentMapping(ArgumentMapping argumentMapping) { | 88 | public void addArgumentMapping(ArgumentMapping argumentMapping) { |
| 89 | boolean wasAdded = m_arguments.put(argumentMapping.getIndex(), argumentMapping) == null; | 89 | boolean wasAdded = this.m_arguments.put(argumentMapping.getIndex(), argumentMapping) == null; |
| 90 | assert (wasAdded); | 90 | assert (wasAdded); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | public String getObfArgumentName(int index) { | 93 | public String getObfArgumentName(int index) { |
| 94 | ArgumentMapping argumentMapping = m_arguments.get(index); | 94 | ArgumentMapping argumentMapping = this.m_arguments.get(index); |
| 95 | if (argumentMapping != null) { | 95 | if (argumentMapping != null) { |
| 96 | return argumentMapping.getName(); | 96 | return argumentMapping.getName(); |
| 97 | } | 97 | } |
| @@ -100,7 +100,7 @@ public class MethodMapping implements Serializable, Comparable<MethodMapping>, M | |||
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | public String getDeobfArgumentName(int index) { | 102 | public String getDeobfArgumentName(int index) { |
| 103 | ArgumentMapping argumentMapping = m_arguments.get(index); | 103 | ArgumentMapping argumentMapping = this.m_arguments.get(index); |
| 104 | if (argumentMapping != null) { | 104 | if (argumentMapping != null) { |
| 105 | return argumentMapping.getName(); | 105 | return argumentMapping.getName(); |
| 106 | } | 106 | } |
| @@ -109,10 +109,10 @@ public class MethodMapping implements Serializable, Comparable<MethodMapping>, M | |||
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | public void setArgumentName(int index, String name) { | 111 | public void setArgumentName(int index, String name) { |
| 112 | ArgumentMapping argumentMapping = m_arguments.get(index); | 112 | ArgumentMapping argumentMapping = this.m_arguments.get(index); |
| 113 | if (argumentMapping == null) { | 113 | if (argumentMapping == null) { |
| 114 | argumentMapping = new ArgumentMapping(index, name); | 114 | argumentMapping = new ArgumentMapping(index, name); |
| 115 | boolean wasAdded = m_arguments.put(index, argumentMapping) == null; | 115 | boolean wasAdded = this.m_arguments.put(index, argumentMapping) == null; |
| 116 | assert (wasAdded); | 116 | assert (wasAdded); |
| 117 | } else { | 117 | } else { |
| 118 | argumentMapping.setName(name); | 118 | argumentMapping.setName(name); |
| @@ -120,7 +120,7 @@ public class MethodMapping implements Serializable, Comparable<MethodMapping>, M | |||
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | public void removeArgumentName(int index) { | 122 | public void removeArgumentName(int index) { |
| 123 | boolean wasRemoved = m_arguments.remove(index) != null; | 123 | boolean wasRemoved = this.m_arguments.remove(index) != null; |
| 124 | assert (wasRemoved); | 124 | assert (wasRemoved); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| @@ -136,7 +136,7 @@ public class MethodMapping implements Serializable, Comparable<MethodMapping>, M | |||
| 136 | buf.append(m_obfSignature); | 136 | buf.append(m_obfSignature); |
| 137 | buf.append("\n"); | 137 | buf.append("\n"); |
| 138 | buf.append("\tArguments:\n"); | 138 | buf.append("\tArguments:\n"); |
| 139 | for (ArgumentMapping argumentMapping : m_arguments.values()) { | 139 | for (ArgumentMapping argumentMapping : this.m_arguments.values()) { |
| 140 | buf.append("\t\t"); | 140 | buf.append("\t\t"); |
| 141 | buf.append(argumentMapping.getIndex()); | 141 | buf.append(argumentMapping.getIndex()); |
| 142 | buf.append(" -> "); | 142 | buf.append(" -> "); |
| @@ -148,31 +148,28 @@ public class MethodMapping implements Serializable, Comparable<MethodMapping>, M | |||
| 148 | 148 | ||
| 149 | @Override | 149 | @Override |
| 150 | public int compareTo(MethodMapping other) { | 150 | public int compareTo(MethodMapping other) { |
| 151 | return (m_obfName + m_obfSignature).compareTo(other.m_obfName + other.m_obfSignature); | 151 | return (this.m_obfName + this.m_obfSignature).compareTo(other.m_obfName + other.m_obfSignature); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | public boolean renameObfClass(final String oldObfClassName, final String newObfClassName) { | 154 | public boolean renameObfClass(final String oldObfClassName, final String newObfClassName) { |
| 155 | 155 | ||
| 156 | // rename obf classes in the signature | 156 | // rename obf classes in the signature |
| 157 | Signature newSignature = new Signature(m_obfSignature, new ClassNameReplacer() { | 157 | Signature newSignature = new Signature(this.m_obfSignature, className -> { |
| 158 | @Override | 158 | if (className.equals(oldObfClassName)) { |
| 159 | public String replace(String className) { | 159 | return newObfClassName; |
| 160 | if (className.equals(oldObfClassName)) { | ||
| 161 | return newObfClassName; | ||
| 162 | } | ||
| 163 | return null; | ||
| 164 | } | 160 | } |
| 161 | return null; | ||
| 165 | }); | 162 | }); |
| 166 | 163 | ||
| 167 | if (!newSignature.equals(m_obfSignature)) { | 164 | if (!newSignature.equals(this.m_obfSignature)) { |
| 168 | m_obfSignature = newSignature; | 165 | this.m_obfSignature = newSignature; |
| 169 | return true; | 166 | return true; |
| 170 | } | 167 | } |
| 171 | return false; | 168 | return false; |
| 172 | } | 169 | } |
| 173 | 170 | ||
| 174 | public boolean containsArgument(String name) { | 171 | public boolean containsArgument(String name) { |
| 175 | for (ArgumentMapping argumentMapping : m_arguments.values()) { | 172 | for (ArgumentMapping argumentMapping : this.m_arguments.values()) { |
| 176 | if (argumentMapping.getName().equals(name)) { | 173 | if (argumentMapping.getName().equals(name)) { |
| 177 | return true; | 174 | return true; |
| 178 | } | 175 | } |
| @@ -183,9 +180,9 @@ public class MethodMapping implements Serializable, Comparable<MethodMapping>, M | |||
| 183 | @Override | 180 | @Override |
| 184 | public BehaviorEntry getObfEntry(ClassEntry classEntry) { | 181 | public BehaviorEntry getObfEntry(ClassEntry classEntry) { |
| 185 | if (isConstructor()) { | 182 | if (isConstructor()) { |
| 186 | return new ConstructorEntry(classEntry, m_obfSignature); | 183 | return new ConstructorEntry(classEntry, this.m_obfSignature); |
| 187 | } else { | 184 | } else { |
| 188 | return new MethodEntry(classEntry, m_obfName, m_obfSignature); | 185 | return new MethodEntry(classEntry, this.m_obfName, this.m_obfSignature); |
| 189 | } | 186 | } |
| 190 | } | 187 | } |
| 191 | } | 188 | } |