summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java
diff options
context:
space:
mode:
authorGravatar gegy10002018-05-19 17:02:46 +0200
committerGravatar gegy10002018-05-19 17:02:46 +0200
commit2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021 (patch)
tree14c8b1e806449ace1641a1dbafae162855f79670 /src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java
parentFix build (diff)
downloadenigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.tar.gz
enigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.tar.xz
enigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.zip
Initial port to ASM
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java')
-rw-r--r--src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java65
1 files changed, 22 insertions, 43 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java b/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java
index 2bb5e3f..dcfd0ff 100644
--- a/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java
+++ b/src/main/java/cuchaz/enigma/mapping/LocalVariableEntry.java
@@ -1,52 +1,31 @@
1package cuchaz.enigma.mapping; 1package cuchaz.enigma.mapping;
2 2
3import com.google.common.base.Preconditions;
3import cuchaz.enigma.utils.Utils; 4import cuchaz.enigma.utils.Utils;
4 5
5/** 6/**
6 * Desc... 7 * TypeDescriptor...
7 * Created by Thog 8 * Created by Thog
8 * 19/10/2016 9 * 19/10/2016
9 */ 10 */
10public class LocalVariableEntry implements Entry { 11public class LocalVariableEntry implements Entry {
11 12
12 protected final BehaviorEntry behaviorEntry; 13 protected final MethodEntry ownerEntry;
13 protected final String name; 14 protected final String name;
14 protected final Type type;
15 protected final int index; 15 protected final int index;
16 16
17 public LocalVariableEntry(BehaviorEntry behaviorEntry, int index, String name, Type type) { 17 public LocalVariableEntry(MethodEntry ownerEntry, int index, String name) {
18 if (behaviorEntry == null) { 18 Preconditions.checkNotNull(ownerEntry, "Variable owner cannot be null");
19 throw new IllegalArgumentException("Behavior cannot be null!"); 19 Preconditions.checkNotNull(name, "Variable name cannot be null");
20 } 20 Preconditions.checkArgument(index >= 0, "Index must be positive");
21 if (index < 0) { 21
22 throw new IllegalArgumentException("Index must be non-negative!"); 22 this.ownerEntry = ownerEntry;
23 }
24 if (name == null) {
25 throw new IllegalArgumentException("Variable name cannot be null!");
26 }
27 if (type == null) {
28 throw new IllegalArgumentException("Variable type cannot be null!");
29 }
30
31 this.behaviorEntry = behaviorEntry;
32 this.name = name; 23 this.name = name;
33 this.type = type;
34 this.index = index; 24 this.index = index;
35 } 25 }
36 26
37 public LocalVariableEntry(LocalVariableEntry other, ClassEntry newClassEntry) { 27 public MethodEntry getOwnerEntry() {
38 this.behaviorEntry = (BehaviorEntry) other.behaviorEntry.cloneToNewClass(newClassEntry); 28 return this.ownerEntry;
39 this.name = other.name;
40 this.type = other.type;
41 this.index = other.index;
42 }
43
44 public BehaviorEntry getBehaviorEntry() {
45 return this.behaviorEntry;
46 }
47
48 public Type getType() {
49 return type;
50 } 29 }
51 30
52 public int getIndex() { 31 public int getIndex() {
@@ -59,31 +38,31 @@ public class LocalVariableEntry implements Entry {
59 } 38 }
60 39
61 @Override 40 @Override
62 public ClassEntry getClassEntry() { 41 public ClassEntry getOwnerClassEntry() {
63 return this.behaviorEntry.getClassEntry(); 42 return this.ownerEntry.getOwnerClassEntry();
64 } 43 }
65 44
66 @Override 45 @Override
67 public String getClassName() { 46 public String getClassName() {
68 return this.behaviorEntry.getClassName(); 47 return this.ownerEntry.getClassName();
69 } 48 }
70 49
71 @Override 50 @Override
72 public LocalVariableEntry cloneToNewClass(ClassEntry classEntry) { 51 public LocalVariableEntry updateOwnership(ClassEntry classEntry) {
73 return new LocalVariableEntry(this, classEntry); 52 return new LocalVariableEntry(ownerEntry.updateOwnership(classEntry), index, name);
74 } 53 }
75 54
76 public String getMethodName() { 55 public String getMethodName() {
77 return this.behaviorEntry.getName(); 56 return this.ownerEntry.getName();
78 } 57 }
79 58
80 public Signature getMethodSignature() { 59 public MethodDescriptor getMethodDesc() {
81 return this.behaviorEntry.getSignature(); 60 return this.ownerEntry.getDesc();
82 } 61 }
83 62
84 @Override 63 @Override
85 public int hashCode() { 64 public int hashCode() {
86 return Utils.combineHashesOrdered(this.behaviorEntry, this.type.hashCode(), this.name.hashCode(), Integer.hashCode(this.index)); 65 return Utils.combineHashesOrdered(this.ownerEntry, this.name.hashCode(), Integer.hashCode(this.index));
87 } 66 }
88 67
89 @Override 68 @Override
@@ -92,11 +71,11 @@ public class LocalVariableEntry implements Entry {
92 } 71 }
93 72
94 public boolean equals(LocalVariableEntry other) { 73 public boolean equals(LocalVariableEntry other) {
95 return this.behaviorEntry.equals(other.behaviorEntry) && this.type.equals(other.type) && this.name.equals(other.name) && this.index == other.index; 74 return this.ownerEntry.equals(other.ownerEntry) && this.name.equals(other.name) && this.index == other.index;
96 } 75 }
97 76
98 @Override 77 @Override
99 public String toString() { 78 public String toString() {
100 return this.behaviorEntry + "(" + this.index + ":" + this.name + ":" + this.type + ")"; 79 return this.ownerEntry + "(" + this.index + ":" + this.name + ")";
101 } 80 }
102} 81}