diff options
| author | 2016-07-04 18:14:22 +1000 | |
|---|---|---|
| committer | 2016-07-04 18:14:22 +1000 | |
| commit | 59e189bef2b5e6d129fb7c2c988ed0b2130e36ac (patch) | |
| tree | 2b638e60905251de85a4917152d6fc39a4112194 /src/main/java/cuchaz/enigma/mapping/Signature.java | |
| parent | Fixed Obf Class list order (diff) | |
| download | enigma-fork-59e189bef2b5e6d129fb7c2c988ed0b2130e36ac.tar.gz enigma-fork-59e189bef2b5e6d129fb7c2c988ed0b2130e36ac.tar.xz enigma-fork-59e189bef2b5e6d129fb7c2c988ed0b2130e36ac.zip | |
Reformat
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/Signature.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/Signature.java | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/Signature.java b/src/main/java/cuchaz/enigma/mapping/Signature.java index e2f9f09..f30b606 100644 --- a/src/main/java/cuchaz/enigma/mapping/Signature.java +++ b/src/main/java/cuchaz/enigma/mapping/Signature.java | |||
| @@ -12,80 +12,72 @@ package cuchaz.enigma.mapping; | |||
| 12 | 12 | ||
| 13 | import com.google.common.collect.Lists; | 13 | import com.google.common.collect.Lists; |
| 14 | 14 | ||
| 15 | import java.io.Serializable; | ||
| 16 | import java.util.List; | 15 | import java.util.List; |
| 17 | 16 | ||
| 18 | import cuchaz.enigma.Util; | 17 | import cuchaz.enigma.utils.Utils; |
| 19 | 18 | ||
| 20 | public class Signature implements Serializable { | 19 | public class Signature { |
| 21 | 20 | ||
| 22 | private static final long serialVersionUID = -5843719505729497539L; | 21 | private List<Type> argumentTypes; |
| 23 | 22 | private Type returnType; | |
| 24 | private List<Type> m_argumentTypes; | ||
| 25 | private Type m_returnType; | ||
| 26 | 23 | ||
| 27 | public Signature(String signature) { | 24 | public Signature(String signature) { |
| 28 | try { | 25 | try { |
| 29 | m_argumentTypes = Lists.newArrayList(); | 26 | this.argumentTypes = Lists.newArrayList(); |
| 30 | int i = 0; | 27 | int i = 0; |
| 31 | while (i < signature.length()) { | 28 | while (i < signature.length()) { |
| 32 | char c = signature.charAt(i); | 29 | char c = signature.charAt(i); |
| 33 | if (c == '(') { | 30 | if (c == '(') { |
| 34 | assert (m_argumentTypes.isEmpty()); | 31 | assert (this.argumentTypes.isEmpty()); |
| 35 | assert (m_returnType == null); | 32 | assert (this.returnType == null); |
| 36 | i++; | 33 | i++; |
| 37 | } else if (c == ')') { | 34 | } else if (c == ')') { |
| 38 | i++; | 35 | i++; |
| 39 | break; | 36 | break; |
| 40 | } else { | 37 | } else { |
| 41 | String type = Type.parseFirst(signature.substring(i)); | 38 | String type = Type.parseFirst(signature.substring(i)); |
| 42 | m_argumentTypes.add(new Type(type)); | 39 | this.argumentTypes.add(new Type(type)); |
| 43 | i += type.length(); | 40 | i += type.length(); |
| 44 | } | 41 | } |
| 45 | } | 42 | } |
| 46 | m_returnType = new Type(Type.parseFirst(signature.substring(i))); | 43 | this.returnType = new Type(Type.parseFirst(signature.substring(i))); |
| 47 | } catch (Exception ex) { | 44 | } catch (Exception ex) { |
| 48 | throw new IllegalArgumentException("Unable to parse signature: " + signature, ex); | 45 | throw new IllegalArgumentException("Unable to parse signature: " + signature, ex); |
| 49 | } | 46 | } |
| 50 | } | 47 | } |
| 51 | 48 | ||
| 52 | public Signature(Signature other) { | ||
| 53 | m_argumentTypes = Lists.newArrayList(other.m_argumentTypes); | ||
| 54 | m_returnType = new Type(other.m_returnType); | ||
| 55 | } | ||
| 56 | |||
| 57 | public Signature(Signature other, ClassNameReplacer replacer) { | 49 | public Signature(Signature other, ClassNameReplacer replacer) { |
| 58 | m_argumentTypes = Lists.newArrayList(other.m_argumentTypes); | 50 | this.argumentTypes = Lists.newArrayList(other.argumentTypes); |
| 59 | for (int i = 0; i < m_argumentTypes.size(); i++) { | 51 | for (int i = 0; i < this.argumentTypes.size(); i++) { |
| 60 | m_argumentTypes.set(i, new Type(m_argumentTypes.get(i), replacer)); | 52 | this.argumentTypes.set(i, new Type(this.argumentTypes.get(i), replacer)); |
| 61 | } | 53 | } |
| 62 | m_returnType = new Type(other.m_returnType, replacer); | 54 | this.returnType = new Type(other.returnType, replacer); |
| 63 | } | 55 | } |
| 64 | 56 | ||
| 65 | public List<Type> getArgumentTypes() { | 57 | public List<Type> getArgumentTypes() { |
| 66 | return m_argumentTypes; | 58 | return this.argumentTypes; |
| 67 | } | 59 | } |
| 68 | 60 | ||
| 69 | public Type getReturnType() { | 61 | public Type getReturnType() { |
| 70 | return m_returnType; | 62 | return this.returnType; |
| 71 | } | 63 | } |
| 72 | 64 | ||
| 73 | @Override | 65 | @Override |
| 74 | public String toString() { | 66 | public String toString() { |
| 75 | StringBuilder buf = new StringBuilder(); | 67 | StringBuilder buf = new StringBuilder(); |
| 76 | buf.append("("); | 68 | buf.append("("); |
| 77 | for (Type type : m_argumentTypes) { | 69 | for (Type type : this.argumentTypes) { |
| 78 | buf.append(type.toString()); | 70 | buf.append(type.toString()); |
| 79 | } | 71 | } |
| 80 | buf.append(")"); | 72 | buf.append(")"); |
| 81 | buf.append(m_returnType.toString()); | 73 | buf.append(this.returnType.toString()); |
| 82 | return buf.toString(); | 74 | return buf.toString(); |
| 83 | } | 75 | } |
| 84 | 76 | ||
| 85 | public Iterable<Type> types() { | 77 | public Iterable<Type> types() { |
| 86 | List<Type> types = Lists.newArrayList(); | 78 | List<Type> types = Lists.newArrayList(); |
| 87 | types.addAll(m_argumentTypes); | 79 | types.addAll(this.argumentTypes); |
| 88 | types.add(m_returnType); | 80 | types.add(this.returnType); |
| 89 | return types; | 81 | return types; |
| 90 | } | 82 | } |
| 91 | 83 | ||
| @@ -95,12 +87,12 @@ public class Signature implements Serializable { | |||
| 95 | } | 87 | } |
| 96 | 88 | ||
| 97 | public boolean equals(Signature other) { | 89 | public boolean equals(Signature other) { |
| 98 | return m_argumentTypes.equals(other.m_argumentTypes) && m_returnType.equals(other.m_returnType); | 90 | return this.argumentTypes.equals(other.argumentTypes) && this.returnType.equals(other.returnType); |
| 99 | } | 91 | } |
| 100 | 92 | ||
| 101 | @Override | 93 | @Override |
| 102 | public int hashCode() { | 94 | public int hashCode() { |
| 103 | return Util.combineHashesOrdered(m_argumentTypes.hashCode(), m_returnType.hashCode()); | 95 | return Utils.combineHashesOrdered(this.argumentTypes.hashCode(), this.returnType.hashCode()); |
| 104 | } | 96 | } |
| 105 | 97 | ||
| 106 | public boolean hasClass(ClassEntry classEntry) { | 98 | public boolean hasClass(ClassEntry classEntry) { |