diff options
| author | 2019-01-24 14:48:32 +0200 | |
|---|---|---|
| committer | 2019-01-24 13:48:32 +0100 | |
| commit | 00fcd0550fcdda621c2e4662f6ddd55ce673b931 (patch) | |
| tree | 6f9e4c24dbcc6d118fceec56adf7bf9d747a485c /src/main/java/cuchaz/enigma/mapping/Signature.java | |
| parent | mark as 0.13.0-SNAPSHOT for preliminary development (diff) | |
| download | enigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.tar.gz enigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.tar.xz enigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.zip | |
[WIP] Mapping rework (#91)
* Move packages
* Mapping & entry refactor: first pass
* Fix deobf -> obf tree remapping
* Resolve various issues
* Give all entries the potential for parents and treat inner classes as children
* Deobf UI tree elements
* Tests pass
* Sort mapping output
* Fix delta tracking
* Index separation and first pass for #97
* Keep track of remapped jar index
* Fix child entries not being remapped
* Drop non-root entries
* Track dropped mappings
* Fix enigma mapping ordering
* EntryTreeNode interface
* Small tweaks
* Naive full index remap on rename
* Entries can resolve to more than one root entry
* Support alternative resolution strategies
* Bridge method resolution
* Tests pass
* Fix mappings being used where there are none
* Fix methods with different descriptors being considered unique. closes #89
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/Signature.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/Signature.java | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/Signature.java b/src/main/java/cuchaz/enigma/mapping/Signature.java deleted file mode 100644 index 071e4af..0000000 --- a/src/main/java/cuchaz/enigma/mapping/Signature.java +++ /dev/null | |||
| @@ -1,82 +0,0 @@ | |||
| 1 | package cuchaz.enigma.mapping; | ||
| 2 | |||
| 3 | import cuchaz.enigma.bytecode.translators.TranslationSignatureVisitor; | ||
| 4 | import org.objectweb.asm.signature.SignatureReader; | ||
| 5 | import org.objectweb.asm.signature.SignatureVisitor; | ||
| 6 | import org.objectweb.asm.signature.SignatureWriter; | ||
| 7 | |||
| 8 | import java.util.function.Function; | ||
| 9 | import java.util.regex.Pattern; | ||
| 10 | |||
| 11 | public class Signature { | ||
| 12 | private static final Pattern OBJECT_PATTERN = Pattern.compile(".*:Ljava/lang/Object;:.*"); | ||
| 13 | |||
| 14 | private final String signature; | ||
| 15 | private final boolean isType; | ||
| 16 | |||
| 17 | private Signature(String signature, boolean isType) { | ||
| 18 | if (signature != null && OBJECT_PATTERN.matcher(signature).matches()) { | ||
| 19 | signature = signature.replaceAll(":Ljava/lang/Object;:", "::"); | ||
| 20 | } | ||
| 21 | |||
| 22 | this.signature = signature; | ||
| 23 | this.isType = isType; | ||
| 24 | } | ||
| 25 | |||
| 26 | public static Signature createTypedSignature(String signature) { | ||
| 27 | if (signature != null && !signature.isEmpty()) { | ||
| 28 | return new Signature(signature, true); | ||
| 29 | } | ||
| 30 | return new Signature(null, true); | ||
| 31 | } | ||
| 32 | |||
| 33 | public static Signature createSignature(String signature) { | ||
| 34 | if (signature != null && !signature.isEmpty()) { | ||
| 35 | return new Signature(signature, false); | ||
| 36 | } | ||
| 37 | return new Signature(null, false); | ||
| 38 | } | ||
| 39 | |||
| 40 | public String getSignature() { | ||
| 41 | return signature; | ||
| 42 | } | ||
| 43 | |||
| 44 | public boolean isType() { | ||
| 45 | return isType; | ||
| 46 | } | ||
| 47 | |||
| 48 | public Signature remap(Function<String, String> remapper) { | ||
| 49 | if (signature == null) { | ||
| 50 | return this; | ||
| 51 | } | ||
| 52 | SignatureWriter writer = new SignatureWriter(); | ||
| 53 | SignatureVisitor visitor = new TranslationSignatureVisitor(remapper, writer); | ||
| 54 | if (isType) { | ||
| 55 | new SignatureReader(signature).acceptType(visitor); | ||
| 56 | } else { | ||
| 57 | new SignatureReader(signature).accept(visitor); | ||
| 58 | } | ||
| 59 | return new Signature(writer.toString(), isType); | ||
| 60 | } | ||
| 61 | |||
| 62 | @Override | ||
| 63 | public boolean equals(Object obj) { | ||
| 64 | if (obj instanceof Signature) { | ||
| 65 | Signature other = (Signature) obj; | ||
| 66 | return (other.signature == null && signature == null || other.signature != null | ||
| 67 | && signature != null && other.signature.equals(signature)) | ||
| 68 | && other.isType == this.isType; | ||
| 69 | } | ||
| 70 | return false; | ||
| 71 | } | ||
| 72 | |||
| 73 | @Override | ||
| 74 | public int hashCode() { | ||
| 75 | return signature.hashCode() | (isType ? 1 : 0) << 16; | ||
| 76 | } | ||
| 77 | |||
| 78 | @Override | ||
| 79 | public String toString() { | ||
| 80 | return signature; | ||
| 81 | } | ||
| 82 | } | ||