decompiler: use more TextBuffer methods
This commit is contained in:
@@ -258,7 +258,6 @@ public class ClassesProcessor {
|
|||||||
TextBuffer classBuffer = new TextBuffer(AVERAGE_CLASS_SIZE);
|
TextBuffer classBuffer = new TextBuffer(AVERAGE_CLASS_SIZE);
|
||||||
new ClassWriter().classToJava(root, classBuffer, 0, null);
|
new ClassWriter().classToJava(root, classBuffer, 0, null);
|
||||||
|
|
||||||
String lineSeparator = DecompilerContext.getNewLineSeparator();
|
|
||||||
int total_offset_lines = 0;
|
int total_offset_lines = 0;
|
||||||
|
|
||||||
int index = cl.qualifiedName.lastIndexOf("/");
|
int index = cl.qualifiedName.lastIndexOf("/");
|
||||||
@@ -269,13 +268,13 @@ public class ClassesProcessor {
|
|||||||
buffer.append("package ");
|
buffer.append("package ");
|
||||||
buffer.append(packageName);
|
buffer.append(packageName);
|
||||||
buffer.append(";");
|
buffer.append(";");
|
||||||
buffer.append(lineSeparator);
|
buffer.appendLineSeparator();
|
||||||
buffer.append(lineSeparator);
|
buffer.appendLineSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
int import_lines_written = importCollector.writeImports(buffer);
|
int import_lines_written = importCollector.writeImports(buffer);
|
||||||
if (import_lines_written > 0) {
|
if (import_lines_written > 0) {
|
||||||
buffer.append(lineSeparator);
|
buffer.appendLineSeparator();
|
||||||
total_offset_lines += import_lines_written + 1;
|
total_offset_lines += import_lines_written + 1;
|
||||||
}
|
}
|
||||||
//buffer.append(lineSeparator);
|
//buffer.append(lineSeparator);
|
||||||
@@ -287,7 +286,7 @@ public class ClassesProcessor {
|
|||||||
BytecodeSourceMapper mapper = DecompilerContext.getBytecodeSourceMapper();
|
BytecodeSourceMapper mapper = DecompilerContext.getBytecodeSourceMapper();
|
||||||
mapper.addTotalOffset(total_offset_lines);
|
mapper.addTotalOffset(total_offset_lines);
|
||||||
if (DecompilerContext.getOption(IFernflowerPreferences.UNIT_TEST_MODE)) {
|
if (DecompilerContext.getOption(IFernflowerPreferences.UNIT_TEST_MODE)) {
|
||||||
buffer.append(lineSeparator);
|
buffer.appendLineSeparator();
|
||||||
mapper.dumpMapping(buffer, true);
|
mapper.dumpMapping(buffer, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,9 +109,7 @@ public class ImportCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int writeImports(TextBuffer buffer) {
|
public int writeImports(TextBuffer buffer) {
|
||||||
|
|
||||||
int importlines_written = 0;
|
int importlines_written = 0;
|
||||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
|
||||||
|
|
||||||
List<String> imports = packImports();
|
List<String> imports = packImports();
|
||||||
|
|
||||||
@@ -119,7 +117,7 @@ public class ImportCollector {
|
|||||||
buffer.append("import ");
|
buffer.append("import ");
|
||||||
buffer.append(s);
|
buffer.append(s);
|
||||||
buffer.append(";");
|
buffer.append(";");
|
||||||
buffer.append(new_line_separator);
|
buffer.appendLineSeparator();
|
||||||
|
|
||||||
importlines_written++;
|
importlines_written++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,13 +49,9 @@ public class AnnotationExprent extends Exprent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
||||||
|
|
||||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
|
||||||
|
|
||||||
TextBuffer buffer = new TextBuffer();
|
TextBuffer buffer = new TextBuffer();
|
||||||
String indstr = InterpreterUtil.getIndentString(indent);
|
|
||||||
|
|
||||||
buffer.append(indstr);
|
buffer.appendIndent(indent);
|
||||||
buffer.append("@");
|
buffer.append("@");
|
||||||
buffer.append(DecompilerContext.getImportCollector().getShortName(ExprProcessor.buildJavaClassName(classname)));
|
buffer.append(DecompilerContext.getImportCollector().getShortName(ExprProcessor.buildJavaClassName(classname)));
|
||||||
|
|
||||||
@@ -65,10 +61,8 @@ public class AnnotationExprent extends Exprent {
|
|||||||
buffer.append(parvalues.get(0).toJava(indent + 1, tracer));
|
buffer.append(parvalues.get(0).toJava(indent + 1, tracer));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String indstr1 = InterpreterUtil.getIndentString(indent + 1);
|
|
||||||
|
|
||||||
for (int i = 0; i < parnames.size(); i++) {
|
for (int i = 0; i < parnames.size(); i++) {
|
||||||
buffer.append(new_line_separator).append(indstr1);
|
buffer.appendLineSeparator().appendIndent(indent + 1);
|
||||||
buffer.append(parnames.get(i));
|
buffer.append(parnames.get(i));
|
||||||
buffer.append(" = ");
|
buffer.append(" = ");
|
||||||
buffer.append(parvalues.get(i).toJava(indent + 2, tracer));
|
buffer.append(parvalues.get(i).toJava(indent + 2, tracer));
|
||||||
@@ -77,7 +71,7 @@ public class AnnotationExprent extends Exprent {
|
|||||||
buffer.append(",");
|
buffer.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer.append(new_line_separator).append(indstr);
|
buffer.appendLineSeparator().appendIndent(indent);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.append(")");
|
buffer.append(")");
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import org.jetbrains.java.decompiler.modules.decompiler.StatEdge;
|
|||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor;
|
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor;
|
||||||
import org.jetbrains.java.decompiler.struct.gen.VarType;
|
import org.jetbrains.java.decompiler.struct.gen.VarType;
|
||||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -152,23 +151,20 @@ public class CatchStatement extends Statement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
||||||
String indstr = InterpreterUtil.getIndentString(indent);
|
|
||||||
TextBuffer buf = new TextBuffer();
|
TextBuffer buf = new TextBuffer();
|
||||||
|
|
||||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
|
||||||
|
|
||||||
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
||||||
|
|
||||||
if (isLabeled()) {
|
if (isLabeled()) {
|
||||||
buf.append(indstr).append("label").append(this.id.toString()).append(":").append(new_line_separator);
|
buf.appendIndent(indent).append("label").append(this.id.toString()).append(":").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.append(indstr).append("try {").append(new_line_separator);
|
buf.appendIndent(indent).append("try {").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
|
|
||||||
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
||||||
buf.append(indstr).append("}");
|
buf.appendIndent(indent).append("}");
|
||||||
|
|
||||||
for (int i = 1; i < stats.size(); i++) {
|
for (int i = 1; i < stats.size(); i++) {
|
||||||
List<String> exception_types = exctstrings.get(i - 1);
|
List<String> exception_types = exctstrings.get(i - 1);
|
||||||
@@ -183,12 +179,12 @@ public class CatchStatement extends Statement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf.append(vars.get(i - 1).toJava(indent, tracer));
|
buf.append(vars.get(i - 1).toJava(indent, tracer));
|
||||||
buf.append(") {").append(new_line_separator);
|
buf.append(") {").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
buf.append(ExprProcessor.jmpWrapper(stats.get(i), indent + 1, true, tracer)).append(indstr)
|
buf.append(ExprProcessor.jmpWrapper(stats.get(i), indent + 1, true, tracer)).appendIndent(indent)
|
||||||
.append("}");
|
.append("}");
|
||||||
}
|
}
|
||||||
buf.append(new_line_separator);
|
buf.appendLineSeparator();
|
||||||
|
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
return buf;
|
return buf;
|
||||||
|
|||||||
@@ -15,13 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.java.decompiler.modules.decompiler.stats;
|
package org.jetbrains.java.decompiler.modules.decompiler.stats;
|
||||||
|
|
||||||
import org.jetbrains.java.decompiler.main.DecompilerContext;
|
|
||||||
import org.jetbrains.java.decompiler.main.TextBuffer;
|
import org.jetbrains.java.decompiler.main.TextBuffer;
|
||||||
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
|
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.StatEdge;
|
import org.jetbrains.java.decompiler.modules.decompiler.StatEdge;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
||||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -94,51 +92,48 @@ public class DoStatement extends Statement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
||||||
String indstr = InterpreterUtil.getIndentString(indent);
|
|
||||||
TextBuffer buf = new TextBuffer();
|
TextBuffer buf = new TextBuffer();
|
||||||
|
|
||||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
|
||||||
|
|
||||||
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
||||||
|
|
||||||
if (isLabeled()) {
|
if (isLabeled()) {
|
||||||
buf.append(indstr).append("label").append(this.id.toString()).append(":").append(new_line_separator);
|
buf.appendIndent(indent).append("label").append(this.id.toString()).append(":").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (looptype) {
|
switch (looptype) {
|
||||||
case LOOP_DO:
|
case LOOP_DO:
|
||||||
buf.append(indstr).append("while(true) {").append(new_line_separator);
|
buf.appendIndent(indent).append("while(true) {").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
||||||
buf.append(indstr).append("}").append(new_line_separator);
|
buf.appendIndent(indent).append("}").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
break;
|
break;
|
||||||
case LOOP_DOWHILE:
|
case LOOP_DOWHILE:
|
||||||
buf.append(indstr).append("do {").append(new_line_separator);
|
buf.appendIndent(indent).append("do {").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
||||||
buf.append(indstr).append("} while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(");").append(new_line_separator);
|
buf.appendIndent(indent).append("} while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(");").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
break;
|
break;
|
||||||
case LOOP_WHILE:
|
case LOOP_WHILE:
|
||||||
buf.append(indstr).append("while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(") {").append(new_line_separator);
|
buf.appendIndent(indent).append("while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(") {").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
||||||
buf.append(indstr).append("}").append(new_line_separator);
|
buf.appendIndent(indent).append("}").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
break;
|
break;
|
||||||
case LOOP_FOR:
|
case LOOP_FOR:
|
||||||
buf.append(indstr).append("for(");
|
buf.appendIndent(indent).append("for(");
|
||||||
if (initExprent.get(0) != null) {
|
if (initExprent.get(0) != null) {
|
||||||
buf.append(initExprent.get(0).toJava(indent, tracer));
|
buf.append(initExprent.get(0).toJava(indent, tracer));
|
||||||
}
|
}
|
||||||
buf.append("; ")
|
buf.append("; ")
|
||||||
.append(conditionExprent.get(0).toJava(indent, tracer)).append("; ").append(incExprent.get(0).toJava(indent, tracer)).append(") {")
|
.append(conditionExprent.get(0).toJava(indent, tracer)).append("; ").append(incExprent.get(0).toJava(indent, tracer)).append(") {")
|
||||||
.append(new_line_separator);
|
.appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
|
||||||
buf.append(indstr).append("}").append(new_line_separator);
|
buf.appendIndent(indent).append("}").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.java.decompiler.modules.decompiler.stats;
|
package org.jetbrains.java.decompiler.modules.decompiler.stats;
|
||||||
|
|
||||||
import org.jetbrains.java.decompiler.main.DecompilerContext;
|
|
||||||
import org.jetbrains.java.decompiler.main.TextBuffer;
|
import org.jetbrains.java.decompiler.main.TextBuffer;
|
||||||
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
||||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -56,20 +54,17 @@ public class GeneralStatement extends Statement {
|
|||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
|
|
||||||
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
||||||
String indstr = InterpreterUtil.getIndentString(indent);
|
|
||||||
TextBuffer buf = new TextBuffer();
|
TextBuffer buf = new TextBuffer();
|
||||||
|
|
||||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
|
||||||
|
|
||||||
if (isLabeled()) {
|
if (isLabeled()) {
|
||||||
buf.append(indstr).append("label").append(this.id.toString()).append(":").append(new_line_separator);
|
buf.appendIndent(indent).append("label").append(this.id.toString()).append(":").appendLineSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.append(indstr).append("abstract statement {").append(new_line_separator);
|
buf.appendIndent(indent).append("abstract statement {").appendLineSeparator();
|
||||||
for (int i = 0; i < stats.size(); i++) {
|
for (Statement stat : stats) {
|
||||||
buf.append(stats.get(i).toJava(indent + 1, tracer));
|
buf.append(stat.toJava(indent + 1, tracer));
|
||||||
}
|
}
|
||||||
buf.append(indstr).append("}");
|
buf.appendIndent(indent).append("}");
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.java.decompiler.modules.decompiler.stats;
|
package org.jetbrains.java.decompiler.modules.decompiler.stats;
|
||||||
|
|
||||||
import org.jetbrains.java.decompiler.main.DecompilerContext;
|
|
||||||
import org.jetbrains.java.decompiler.main.TextBuffer;
|
import org.jetbrains.java.decompiler.main.TextBuffer;
|
||||||
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.DecHelper;
|
import org.jetbrains.java.decompiler.modules.decompiler.DecHelper;
|
||||||
@@ -205,17 +204,15 @@ public class IfStatement extends Statement {
|
|||||||
String indstr = InterpreterUtil.getIndentString(indent);
|
String indstr = InterpreterUtil.getIndentString(indent);
|
||||||
TextBuffer buf = new TextBuffer();
|
TextBuffer buf = new TextBuffer();
|
||||||
|
|
||||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
|
||||||
|
|
||||||
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
||||||
buf.append(first.toJava(indent, tracer));
|
buf.append(first.toJava(indent, tracer));
|
||||||
|
|
||||||
if (isLabeled()) {
|
if (isLabeled()) {
|
||||||
buf.append(indstr).append("label").append(this.id.toString()).append(":").append(new_line_separator);
|
buf.appendIndent(indent).append("label").append(this.id.toString()).append(":").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.append(indstr).append(headexprent.get(0).toJava(indent, tracer)).append(" {").append(new_line_separator);
|
buf.appendIndent(indent).append(headexprent.get(0).toJava(indent, tracer)).append(" {").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
|
|
||||||
if (ifstat == null) {
|
if (ifstat == null) {
|
||||||
@@ -235,7 +232,7 @@ public class IfStatement extends Statement {
|
|||||||
buf.append(" label").append(ifedge.closure.id.toString());
|
buf.append(" label").append(ifedge.closure.id.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf.append(";").append(new_line_separator);
|
buf.append(";").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -253,7 +250,7 @@ public class IfStatement extends Statement {
|
|||||||
TextBuffer content = ExprProcessor.jmpWrapper(elsestat, indent, false, tracer);
|
TextBuffer content = ExprProcessor.jmpWrapper(elsestat, indent, false, tracer);
|
||||||
content.setStart(indstr.length());
|
content.setStart(indstr.length());
|
||||||
|
|
||||||
buf.append(indstr).append("} else ");
|
buf.appendIndent(indent).append("} else ");
|
||||||
buf.append(content);
|
buf.append(content);
|
||||||
|
|
||||||
elseif = true;
|
elseif = true;
|
||||||
@@ -263,7 +260,7 @@ public class IfStatement extends Statement {
|
|||||||
TextBuffer content = ExprProcessor.jmpWrapper(elsestat, indent + 1, false, else_tracer);
|
TextBuffer content = ExprProcessor.jmpWrapper(elsestat, indent + 1, false, else_tracer);
|
||||||
|
|
||||||
if (content.length() > 0) {
|
if (content.length() > 0) {
|
||||||
buf.append(indstr).append("} else {").append(new_line_separator);
|
buf.appendIndent(indent).append("} else {").appendLineSeparator();
|
||||||
|
|
||||||
else_tracer.shiftSourceLines(1);
|
else_tracer.shiftSourceLines(1);
|
||||||
tracer.setCurrentSourceLine(else_tracer.getCurrentSourceLine() + 1);
|
tracer.setCurrentSourceLine(else_tracer.getCurrentSourceLine() + 1);
|
||||||
@@ -275,7 +272,7 @@ public class IfStatement extends Statement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!elseif) {
|
if (!elseif) {
|
||||||
buf.append(indstr).append("}").append(new_line_separator);
|
buf.appendIndent(indent).append("}").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import org.jetbrains.java.decompiler.modules.decompiler.exps.ConstExprent;
|
|||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.SwitchExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.SwitchExprent;
|
||||||
import org.jetbrains.java.decompiler.struct.gen.VarType;
|
import org.jetbrains.java.decompiler.struct.gen.VarType;
|
||||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -109,21 +108,16 @@ public class SwitchStatement extends Statement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
||||||
|
|
||||||
String indstr = InterpreterUtil.getIndentString(indent);
|
|
||||||
|
|
||||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
|
||||||
|
|
||||||
TextBuffer buf = new TextBuffer();
|
TextBuffer buf = new TextBuffer();
|
||||||
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
||||||
buf.append(first.toJava(indent, tracer));
|
buf.append(first.toJava(indent, tracer));
|
||||||
|
|
||||||
if (isLabeled()) {
|
if (isLabeled()) {
|
||||||
buf.append(indstr).append("label").append(this.id.toString()).append(":").append(new_line_separator);
|
buf.appendIndent(indent).append("label").append(this.id.toString()).append(":").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.append(indstr).append(headexprent.get(0).toJava(indent, tracer)).append(" {").append(new_line_separator);
|
buf.appendIndent(indent).append(headexprent.get(0).toJava(indent, tracer)).append(" {").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
|
|
||||||
VarType switch_type = headexprent.get(0).getExprType();
|
VarType switch_type = headexprent.get(0).getExprType();
|
||||||
@@ -136,14 +130,14 @@ public class SwitchStatement extends Statement {
|
|||||||
|
|
||||||
for (int j = 0; j < edges.size(); j++) {
|
for (int j = 0; j < edges.size(); j++) {
|
||||||
if (edges.get(j) == default_edge) {
|
if (edges.get(j) == default_edge) {
|
||||||
buf.append(indstr).append("default:").append(new_line_separator);
|
buf.appendIndent(indent).append("default:").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ConstExprent value = (ConstExprent)values.get(j).copy();
|
ConstExprent value = (ConstExprent)values.get(j).copy();
|
||||||
value.setConsttype(switch_type);
|
value.setConsttype(switch_type);
|
||||||
|
|
||||||
buf.append(indstr).append("case ").append(value.toJava(indent, tracer)).append(":").append(new_line_separator);
|
buf.appendIndent(indent).append("case ").append(value.toJava(indent, tracer)).append(":").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +145,7 @@ public class SwitchStatement extends Statement {
|
|||||||
buf.append(ExprProcessor.jmpWrapper(stat, indent + 1, false, tracer));
|
buf.append(ExprProcessor.jmpWrapper(stat, indent + 1, false, tracer));
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.append(indstr).append("}").append(new_line_separator);
|
buf.appendIndent(indent).append("}").appendLineSeparator();
|
||||||
tracer.incrementCurrentSourceLine();
|
tracer.incrementCurrentSourceLine();
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|||||||
Reference in New Issue
Block a user