Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 04c6906

Browse files
committed
Update to ASM7
1 parent 1ea7a85 commit 04c6906

File tree

4 files changed

+43
-50
lines changed

4 files changed

+43
-50
lines changed

‎pom.xml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,30 @@
153153
<artifactId>modasm</artifactId>
154154
<version>0.0.1-ALPHA</version>
155155
</dependency>
156+
<dependency>
157+
<groupId>org.mapleir</groupId>
158+
<artifactId>stdlib</artifactId>
159+
<version>0.0.1-ALPHA</version>
160+
</dependency>
161+
<dependency>
162+
<groupId>org.ow2.asm</groupId>
163+
<artifactId>asm</artifactId>
164+
<version>7.1</version>
165+
</dependency>
166+
<dependency>
167+
<groupId>org.ow2.asm</groupId>
168+
<artifactId>asm-tree</artifactId>
169+
<version>7.1</version>
170+
</dependency>
171+
<dependency>
172+
<groupId>org.ow2.asm</groupId>
173+
<artifactId>asm-util</artifactId>
174+
<version>7.1</version>
175+
</dependency>
176+
<dependency>
177+
<groupId>org.ow2.asm</groupId>
178+
<artifactId>asm-commons</artifactId>
179+
<version>7.1</version>
180+
</dependency>
156181
</dependencies>
157182
</project>

‎src/main/java/club/bytecode/the/jda/decompilers/bytecode/InstructionPrinter.java‎

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public ArrayList<String> createPrint() {
142142
} else if (ain instanceof MultiANewArrayInsnNode) {
143143
line = printMultiANewArrayInsnNode((MultiANewArrayInsnNode) ain);
144144
} else {
145-
line = "// UNADDED OPCODE: " + nameOpcode(ain.opcode()) + " " + ain.toString();
145+
line = "// UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " " + ain.toString();
146146
}
147147
if (!line.equals("")) {
148148
if (match)
@@ -159,7 +159,7 @@ public ArrayList<String> createPrint() {
159159

160160
protected String printVarInsnNode(VarInsnNode vin, ListIterator<?> it) {
161161
StringBuilder sb = new StringBuilder();
162-
sb.append(nameOpcode(vin.opcode()));
162+
sb.append(nameOpcode(vin.getOpcode()));
163163
sb.append(" ");
164164
sb.append(vin.var);
165165
if (parent.createComments()) {
@@ -177,31 +177,19 @@ protected String printVarInsnNode(VarInsnNode vin, ListIterator<?> it) {
177177
}
178178

179179
protected String printIntInsnNode(IntInsnNode iin, ListIterator<?> it) {
180-
return nameOpcode(iin.opcode()) + " " + iin.operand;
180+
return nameOpcode(iin.getOpcode()) + " " + iin.operand;
181181
}
182182

183183
protected String printFieldInsnNode(FieldInsnNode fin, ListIterator<?> it) {
184-
String desc = Type.getType(fin.desc).getClassName();
185-
if (desc == null || desc.equals("null"))
186-
desc = fin.desc;
187-
return nameOpcode(fin.opcode()) + " " + fin.owner + "." + fin.name + ":" + desc;
184+
String desc = fin.desc;
185+
return nameOpcode(fin.getOpcode()) + " " + fin.owner + "." + fin.name + ":" + desc;
188186
}
189187

190188
protected String printMethodInsnNode(MethodInsnNode min, ListIterator<?> it) {
191189
StringBuilder sb = new StringBuilder();
192-
sb.append(nameOpcode(min.opcode())).append(" ").append(min.owner).append(" ").append(min.name).append("(");
190+
sb.append(nameOpcode(min.getOpcode())).append(" ").append(min.owner).append(" ").append(min.name).append("(");
193191

194192
String desc = min.desc;
195-
try {
196-
if (Type.getType(min.desc) != null)
197-
desc = Type.getType(min.desc).getClassName();
198-
199-
if (desc == null || desc.equals("null"))
200-
desc = min.desc;
201-
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
202-
203-
}
204-
205193
sb.append(desc);
206194

207195
sb.append(");");
@@ -211,17 +199,17 @@ protected String printMethodInsnNode(MethodInsnNode min, ListIterator<?> it) {
211199

212200
protected String printLdcInsnNode(LdcInsnNode ldc, ListIterator<?> it) {
213201
if (ldc.cst instanceof String)
214-
return nameOpcode(ldc.opcode()) + " \"" + StringEscapeUtils.escapeJava(ldc.cst.toString()) + "\" (" + ldc.cst.getClass().getCanonicalName() + ")";
202+
return nameOpcode(ldc.getOpcode()) + " \"" + StringEscapeUtils.escapeJava(ldc.cst.toString()) + "\" (" + ldc.cst.getClass().getCanonicalName() + ")";
215203

216-
return nameOpcode(ldc.opcode()) + " " + StringEscapeUtils.escapeJava(ldc.cst.toString()) + " (" + ldc.cst.getClass().getCanonicalName() + ")";
204+
return nameOpcode(ldc.getOpcode()) + " " + StringEscapeUtils.escapeJava(ldc.cst.toString()) + " (" + ldc.cst.getClass().getCanonicalName() + ")";
217205
}
218206

219207
protected String printInsnNode(InsnNode in, ListIterator<?> it) {
220-
return nameOpcode(in.opcode());
208+
return nameOpcode(in.getOpcode());
221209
}
222210

223211
protected String printJumpInsnNode(JumpInsnNode jin, ListIterator<?> it) {
224-
String line = nameOpcode(jin.opcode()) + " L" + resolveLabel(jin.label);
212+
String line = nameOpcode(jin.getOpcode()) + " L" + resolveLabel(jin.label);
225213
return line;
226214
}
227215

@@ -236,28 +224,19 @@ protected String printLabelnode(LabelNode label) {
236224
protected String printTypeInsnNode(TypeInsnNode tin) {
237225
try {
238226
String desc = tin.desc;
239-
try {
240-
if (Type.getType(tin.desc) != null)
241-
desc = Type.getType(tin.desc).getClassName();
242-
243-
if (desc == null || desc.equals("null"))
244-
desc = tin.desc;
245-
} catch (java.lang.ArrayIndexOutOfBoundsException | UnsupportedOperationException e) {
246-
247-
}
248-
return nameOpcode(tin.opcode()) + " " + desc;
227+
return nameOpcode(tin.getOpcode()) + " " + desc;
249228
} catch (Exception e) {
250229
new ExceptionUI(e, "printing instruction");
251230
}
252231
return "// error";
253232
}
254233

255234
protected String printIincInsnNode(IincInsnNode iin) {
256-
return nameOpcode(iin.opcode()) + " " + iin.var + " " + iin.incr;
235+
return nameOpcode(iin.getOpcode()) + " " + iin.var + " " + iin.incr;
257236
}
258237

259238
protected String printTableSwitchInsnNode(TableSwitchInsnNode tin) {
260-
String line = nameOpcode(tin.opcode()) + " \n";
239+
String line = nameOpcode(tin.getOpcode()) + " \n";
261240
List<?> labels = tin.labels;
262241
int count = 0;
263242
for (int i = tin.min; i < tin.max + 1; i++) {
@@ -268,7 +247,7 @@ protected String printTableSwitchInsnNode(TableSwitchInsnNode tin) {
268247
}
269248

270249
protected String printLookupSwitchInsnNode(LookupSwitchInsnNode lin) {
271-
String line = nameOpcode(lin.opcode()) + ": \n";
250+
String line = nameOpcode(lin.getOpcode()) + ": \n";
272251
List<?> keys = lin.keys;
273252
List<?> labels = lin.labels;
274253

@@ -284,20 +263,9 @@ protected String printLookupSwitchInsnNode(LookupSwitchInsnNode lin) {
284263
protected String printInvokeDynamicInsNode(InvokeDynamicInsnNode idin) {
285264
StringBuilder sb = new StringBuilder();
286265
final String bsmName = idin.bsm.getName();
287-
sb.append(nameOpcode(idin.opcode())).append(" ").append(bsmName).append("<");
266+
sb.append(nameOpcode(idin.getOpcode())).append(" ").append(bsmName).append("<");
288267

289268
String desc = idin.desc;
290-
String partedDesc = idin.desc.substring(2);
291-
try {
292-
if (Type.getType(partedDesc) != null)
293-
desc = Type.getType(partedDesc).getClassName();
294-
295-
if (desc == null || desc.equals("null"))
296-
desc = idin.desc;
297-
} catch (java.lang.ArrayIndexOutOfBoundsException | UnsupportedOperationException e) {
298-
299-
}
300-
301269
sb.append(desc);
302270
sb.append(">(\n");
303271
Object[] bsmArgs = idin.bsmArgs;
@@ -328,7 +296,7 @@ protected String printInvokeDynamicInsNode(InvokeDynamicInsnNode idin) {
328296
}
329297

330298
protected String printMultiANewArrayInsnNode(MultiANewArrayInsnNode manain) {
331-
return nameOpcode(manain.opcode()) + " " + manain.desc;
299+
return nameOpcode(manain.getOpcode()) + " " + manain.desc;
332300
}
333301

334302
protected String nameOpcode(int opcode) {

‎src/main/java/club/bytecode/the/jda/decompilers/bytecode/MethodNodeDecompiler.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public PrefixedStringBuilder decompile() {
4141
// Descriptor
4242
if (createDescriptors()) {
4343
sb.append(" // ");
44-
sb.append(mn.owner.name);
44+
sb.append(cn.name);
4545
sb.append(".");
4646
sb.append(mn.name);
4747
sb.append(mn.desc);

‎src/main/java/club/bytecode/the/jda/decompilers/bytecode/OpcodeInfo.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static final int[] toOpcodes(String opcodeString) {
7272
public static final String opcodesToString(AbstractInsnNode[] ains) {
7373
String[] ops = new String[ains.length];
7474
for(int i = 0; i < ains.length; i++) {
75-
ops[i] = OPCODES.get(ains[i].opcode());
75+
ops[i] = OPCODES.get(ains[i].getOpcode());
7676
}
7777
return Arrays.toString(ops).replace("[", "").replace("]", "");
7878
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /