mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Print bytecode listing of a method when decompiler fails to decompile
This commit is contained in:
parent
11d69f15c9
commit
1945e6cb44
|
@ -66,6 +66,7 @@ import org.teavm.model.TryCatchBlock;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.Variable;
|
import org.teavm.model.Variable;
|
||||||
import org.teavm.model.util.AsyncProgramSplitter;
|
import org.teavm.model.util.AsyncProgramSplitter;
|
||||||
|
import org.teavm.model.util.ListingBuilder;
|
||||||
import org.teavm.model.util.ProgramUtils;
|
import org.teavm.model.util.ProgramUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,7 +261,13 @@ public class Decompiler {
|
||||||
Program program = method.getProgram();
|
Program program = method.getProgram();
|
||||||
int[] targetBlocks = new int[program.basicBlockCount()];
|
int[] targetBlocks = new int[program.basicBlockCount()];
|
||||||
Arrays.fill(targetBlocks, -1);
|
Arrays.fill(targetBlocks, -1);
|
||||||
|
try {
|
||||||
methodNode.setBody(getRegularMethodStatement(program, targetBlocks, false).getStatement());
|
methodNode.setBody(getRegularMethodStatement(program, targetBlocks, false).getStatement());
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
StringBuilder sb = new StringBuilder("Error decompiling method " + method.getReference() + ":\n");
|
||||||
|
sb.append(new ListingBuilder().buildListing(program, " "));
|
||||||
|
throw new DecompilationException(sb.toString(), e);
|
||||||
|
}
|
||||||
for (int i = 0; i < program.variableCount(); ++i) {
|
for (int i = 0; i < program.variableCount(); ++i) {
|
||||||
methodNode.getVariables().add(program.variableAt(i).getRegister());
|
methodNode.getVariables().add(program.variableAt(i).getRegister());
|
||||||
}
|
}
|
||||||
|
@ -311,8 +318,15 @@ public class Decompiler {
|
||||||
AsyncProgramSplitter splitter = new AsyncProgramSplitter(classSource, splitMethods);
|
AsyncProgramSplitter splitter = new AsyncProgramSplitter(classSource, splitMethods);
|
||||||
splitter.split(method.getProgram());
|
splitter.split(method.getProgram());
|
||||||
for (int i = 0; i < splitter.size(); ++i) {
|
for (int i = 0; i < splitter.size(); ++i) {
|
||||||
AsyncMethodPart part = getRegularMethodStatement(splitter.getProgram(i), splitter.getBlockSuccessors(i),
|
AsyncMethodPart part;
|
||||||
i > 0);
|
try {
|
||||||
|
part = getRegularMethodStatement(splitter.getProgram(i), splitter.getBlockSuccessors(i), i > 0);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
StringBuilder sb = new StringBuilder("Error decompiling method " + method.getReference() +
|
||||||
|
" part " + i + ":\n");
|
||||||
|
sb.append(new ListingBuilder().buildListing(splitter.getProgram(i), " "));
|
||||||
|
throw new DecompilationException(sb.toString(), e);
|
||||||
|
}
|
||||||
node.getBody().add(part);
|
node.getBody().add(part);
|
||||||
}
|
}
|
||||||
Program program = method.getProgram();
|
Program program = method.getProgram();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user