mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-27 01:30:35 +08:00
JS: fix deobfuscated parameter names. Generate less local variables
This commit is contained in:
parent
e6bb91bfb0
commit
91cf9917c7
@ -792,6 +792,7 @@ public class Renderer implements RenderingManager {
|
||||
|
||||
private void renderBody(PreparedMethod method) throws IOException {
|
||||
StatementRenderer statementRenderer = new StatementRenderer(context, writer);
|
||||
statementRenderer.setCurrentMethod(method.node);
|
||||
|
||||
MethodReference ref = method.reference;
|
||||
debugEmitter.emitMethod(ref.getDescriptor());
|
||||
@ -812,7 +813,6 @@ public class Renderer implements RenderingManager {
|
||||
writer.append(")").ws().append("{").softNewLine().indent();
|
||||
|
||||
MethodBodyRenderer renderer = new MethodBodyRenderer(statementRenderer);
|
||||
statementRenderer.setCurrentMethod(method.node);
|
||||
if (method.node != null) {
|
||||
method.node.acceptVisitor(renderer);
|
||||
} else {
|
||||
|
@ -33,9 +33,14 @@ import org.teavm.model.ProgramReader;
|
||||
import org.teavm.model.Variable;
|
||||
import org.teavm.model.instructions.AssignInstruction;
|
||||
import org.teavm.model.instructions.JumpInstruction;
|
||||
import org.teavm.model.text.ListingBuilder;
|
||||
|
||||
public class RegisterAllocator {
|
||||
public void allocateRegisters(MethodReference method, Program program, boolean debuggerFriendly) {
|
||||
if (method.getName().equals("importFromJs")) {
|
||||
System.out.println(new ListingBuilder().buildListing(program, ""));
|
||||
}
|
||||
|
||||
insertPhiArgumentsCopies(program);
|
||||
InterferenceGraphBuilder interferenceBuilder = new InterferenceGraphBuilder();
|
||||
LivenessAnalyzer liveness = new LivenessAnalyzer();
|
||||
@ -93,12 +98,29 @@ public class RegisterAllocator {
|
||||
inferer.inferTypes(program, method);
|
||||
int[] categories = new int[program.variableCount()];
|
||||
for (int i = 0; i < program.variableCount(); ++i) {
|
||||
VariableType type = inferer.typeOf(i);
|
||||
categories[i] = type != null ? type.ordinal() : 255;
|
||||
categories[i] = getCategory(inferer.typeOf(i));
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
|
||||
private int getCategory(VariableType type) {
|
||||
if (type == null) {
|
||||
return 255;
|
||||
}
|
||||
switch (type) {
|
||||
case INT:
|
||||
return 0;
|
||||
case LONG:
|
||||
return 1;
|
||||
case FLOAT:
|
||||
return 2;
|
||||
case DOUBLE:
|
||||
return 2;
|
||||
default:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
private String[] getVariableNames(ProgramReader program, boolean debuggerFriendly) {
|
||||
String[] names = new String[program.variableCount()];
|
||||
for (int i = 0; i < names.length; ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user