summaryrefslogtreecommitdiff
path: root/src/cuchaz
diff options
context:
space:
mode:
authorGravatar jeff2015-03-20 12:42:04 -0400
committerGravatar jeff2015-03-20 12:42:04 -0400
commit03a4d2f0d47dfdce209de58f0530b17649c5b19b (patch)
treef806055911b6f4c29513913a92b684e72e57e991 /src/cuchaz
parentget rid of stupid fucking com.beust.jcommander imports crashing all my downst... (diff)
downloadenigma-fork-03a4d2f0d47dfdce209de58f0530b17649c5b19b.tar.gz
enigma-fork-03a4d2f0d47dfdce209de58f0530b17649c5b19b.tar.xz
enigma-fork-03a4d2f0d47dfdce209de58f0530b17649c5b19b.zip
make sure LVTT names explicitly match the LVT names
Diffstat (limited to 'src/cuchaz')
-rw-r--r--src/cuchaz/enigma/bytecode/LocalVariableRenamer.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/cuchaz/enigma/bytecode/LocalVariableRenamer.java b/src/cuchaz/enigma/bytecode/LocalVariableRenamer.java
index 1179560..215afc5 100644
--- a/src/cuchaz/enigma/bytecode/LocalVariableRenamer.java
+++ b/src/cuchaz/enigma/bytecode/LocalVariableRenamer.java
@@ -35,12 +35,12 @@ public class LocalVariableRenamer {
35 35
36 LocalVariableAttribute table = (LocalVariableAttribute)codeAttribute.getAttribute(LocalVariableAttribute.tag); 36 LocalVariableAttribute table = (LocalVariableAttribute)codeAttribute.getAttribute(LocalVariableAttribute.tag);
37 if (table != null) { 37 if (table != null) {
38 renameTable(behaviorEntry, constants, table); 38 renameLVT(behaviorEntry, constants, table);
39 } 39 }
40 40
41 LocalVariableTypeAttribute typeTable = (LocalVariableTypeAttribute)codeAttribute.getAttribute(LocalVariableAttribute.typeTag); 41 LocalVariableTypeAttribute typeTable = (LocalVariableTypeAttribute)codeAttribute.getAttribute(LocalVariableAttribute.typeTag);
42 if (typeTable != null) { 42 if (typeTable != null) {
43 renameTable(behaviorEntry, constants, typeTable); 43 renameLVTT(typeTable, table);
44 } 44 }
45 } 45 }
46 } 46 }
@@ -55,7 +55,7 @@ public class LocalVariableRenamer {
55 } 55 }
56 } 56 }
57 57
58 private void renameTable(BehaviorEntry behaviorEntry, ConstPool constants, LocalVariableAttribute table) { 58 private void renameLVT(BehaviorEntry behaviorEntry, ConstPool constants, LocalVariableAttribute table) {
59 59
60 // skip empty tables 60 // skip empty tables
61 if (table.tableLength() <= 0) { 61 if (table.tableLength() <= 0) {
@@ -90,8 +90,24 @@ public class LocalVariableRenamer {
90 } 90 }
91 } 91 }
92 92
93 private void renameLVTT(LocalVariableTypeAttribute typeTable, LocalVariableAttribute table) {
94 // rename args to the same names as in the LVT
95 for (int i=0; i<typeTable.tableLength(); i++) {
96 renameVariable(typeTable, i, getNameIndex(table, typeTable.index(i)));
97 }
98 }
99
93 private void renameVariable(LocalVariableAttribute table, int i, int stringId) { 100 private void renameVariable(LocalVariableAttribute table, int i, int stringId) {
94 // based off of LocalVariableAttribute.nameIndex() 101 // based off of LocalVariableAttribute.nameIndex()
95 ByteArray.write16bit(stringId, table.get(), i*10 + 6); 102 ByteArray.write16bit(stringId, table.get(), i*10 + 6);
96 } 103 }
104
105 private int getNameIndex(LocalVariableAttribute table, int index) {
106 for (int i=0; i<table.tableLength(); i++) {
107 if (table.index(i) == index) {
108 return table.nameIndex(i);
109 }
110 }
111 return 0;
112 }
97} 113}