decompiler: fixed line mapping in synchronized block
This commit is contained in:
@@ -15,14 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.modules.decompiler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jetbrains.java.decompiler.code.CodeConstants;
|
||||
import org.jetbrains.java.decompiler.code.Instruction;
|
||||
import org.jetbrains.java.decompiler.code.InstructionSequence;
|
||||
@@ -30,28 +22,12 @@ import org.jetbrains.java.decompiler.code.cfg.BasicBlock;
|
||||
import org.jetbrains.java.decompiler.main.DecompilerContext;
|
||||
import org.jetbrains.java.decompiler.main.TextBuffer;
|
||||
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.ArrayExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.AssignmentExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.ConstExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.ExitExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.FieldExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.FunctionExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.IfExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.MonitorExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.NewExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.SwitchExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.*;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.sforms.DirectGraph;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.sforms.DirectNode;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.sforms.FlattenStatementsHelper;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.sforms.FlattenStatementsHelper.FinallyPathWrapper;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.BasicBlockStatement;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.CatchAllStatement;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.CatchStatement;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.*;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor;
|
||||
import org.jetbrains.java.decompiler.struct.StructClass;
|
||||
import org.jetbrains.java.decompiler.struct.attr.StructBootstrapMethodsAttribute;
|
||||
@@ -62,7 +38,8 @@ import org.jetbrains.java.decompiler.struct.consts.PooledConstant;
|
||||
import org.jetbrains.java.decompiler.struct.consts.PrimitiveConstant;
|
||||
import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor;
|
||||
import org.jetbrains.java.decompiler.struct.gen.VarType;
|
||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ExprProcessor implements CodeConstants {
|
||||
|
||||
@@ -784,13 +761,11 @@ public class ExprProcessor implements CodeConstants {
|
||||
public static TextBuffer jmpWrapper(Statement stat, int indent, boolean semicolon, BytecodeMappingTracer tracer) {
|
||||
TextBuffer buf = stat.toJava(indent, tracer);
|
||||
|
||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
||||
|
||||
List<StatEdge> lstSuccs = stat.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL);
|
||||
if (lstSuccs.size() == 1) {
|
||||
StatEdge edge = lstSuccs.get(0);
|
||||
if (edge.getType() != StatEdge.TYPE_REGULAR && edge.explicit && edge.getDestination().type != Statement.TYPE_DUMMYEXIT) {
|
||||
buf.append(InterpreterUtil.getIndentString(indent));
|
||||
buf.appendIndent(indent);
|
||||
|
||||
switch (edge.getType()) {
|
||||
case StatEdge.TYPE_BREAK:
|
||||
@@ -803,13 +778,13 @@ public class ExprProcessor implements CodeConstants {
|
||||
if (edge.labeled) {
|
||||
buf.append(" label").append(edge.closure.id.toString());
|
||||
}
|
||||
buf.append(";").append(new_line_separator);
|
||||
buf.append(";").appendLineSeparator();
|
||||
tracer.incrementCurrentSourceLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (buf.length() == 0 && semicolon) {
|
||||
buf.append(InterpreterUtil.getIndentString(indent)).append(";").append(new_line_separator);
|
||||
buf.appendIndent(indent).append(";").appendLineSeparator();
|
||||
tracer.incrementCurrentSourceLine();
|
||||
}
|
||||
|
||||
@@ -835,16 +810,13 @@ public class ExprProcessor implements CodeConstants {
|
||||
return new TextBuffer();
|
||||
}
|
||||
|
||||
String indstr = InterpreterUtil.getIndentString(indent);
|
||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
||||
|
||||
TextBuffer buf = new TextBuffer();
|
||||
|
||||
for (Exprent expr : lst) {
|
||||
TextBuffer content = expr.toJava(indent, tracer);
|
||||
if (content.length() > 0) {
|
||||
if (expr.type != Exprent.EXPRENT_VAR || !((VarExprent)expr).isClassdef()) {
|
||||
buf.append(indstr);
|
||||
buf.appendIndent(indent);
|
||||
}
|
||||
buf.append(content);
|
||||
if (expr.type == Exprent.EXPRENT_MONITOR && ((MonitorExprent)expr).getMontype() == MonitorExprent.MONITOR_ENTER) {
|
||||
@@ -853,7 +825,7 @@ public class ExprProcessor implements CodeConstants {
|
||||
if (endsWithSemikolon(expr)) {
|
||||
buf.append(";");
|
||||
}
|
||||
buf.append(new_line_separator);
|
||||
buf.appendLineSeparator();
|
||||
tracer.incrementCurrentSourceLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
*/
|
||||
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.collectors.BytecodeMappingTracer;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.DecHelper;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.StatEdge;
|
||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -101,20 +99,13 @@ public class SequenceStatement extends Statement {
|
||||
}
|
||||
|
||||
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
||||
|
||||
TextBuffer buf = new TextBuffer();
|
||||
|
||||
String indstr = null;
|
||||
boolean islabeled = isLabeled();
|
||||
|
||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
||||
|
||||
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
||||
|
||||
if (islabeled) {
|
||||
indstr = InterpreterUtil.getIndentString(indent);
|
||||
indent++;
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -125,7 +116,7 @@ public class SequenceStatement extends Statement {
|
||||
Statement st = stats.get(i);
|
||||
|
||||
if (i > 0 && notempty) {
|
||||
buf.append(new_line_separator);
|
||||
buf.appendLineSeparator();
|
||||
tracer.incrementCurrentSourceLine();
|
||||
}
|
||||
|
||||
@@ -136,7 +127,7 @@ public class SequenceStatement extends Statement {
|
||||
}
|
||||
|
||||
if (islabeled) {
|
||||
buf.append(indstr).append("}").append(new_line_separator);
|
||||
buf.appendIndent(indent-1).append("}").appendLineSeparator();
|
||||
tracer.incrementCurrentSourceLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,14 +15,12 @@
|
||||
*/
|
||||
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.collectors.BytecodeMappingTracer;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.SequenceHelper;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.StatEdge;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -71,26 +69,21 @@ public class SynchronizedStatement extends Statement {
|
||||
// *****************************************************************************
|
||||
|
||||
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
||||
String indstr = InterpreterUtil.getIndentString(indent);
|
||||
|
||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
||||
|
||||
TextBuffer buf = new TextBuffer();
|
||||
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
||||
buf.append(first.toJava(indent, tracer));
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
buf.append(ExprProcessor.jmpWrapper(body, indent + 1, true, tracer));
|
||||
tracer.incrementCurrentSourceLine();
|
||||
|
||||
buf.append(indstr).append("}").append(new_line_separator);
|
||||
buf.appendIndent(indent).append("}").appendLineSeparator();
|
||||
tracer.incrementCurrentSourceLine();
|
||||
|
||||
return buf;
|
||||
|
||||
Reference in New Issue
Block a user