summaryrefslogtreecommitdiffstats
path: root/src/org/jetbrains/java/decompiler/modules
diff options
context:
space:
mode:
authorStiver <stiver.mail@gmail.com>2014-10-07 07:31:22 +0200
committerStiver <stiver.mail@gmail.com>2014-10-07 07:31:22 +0200
commit9f9da912f666dc2d25b7ba7e03283f13b4c5b4bf (patch)
tree79cfac0861d24140bd8a3fa1f334fe3465260bed /src/org/jetbrains/java/decompiler/modules
parentbef17b44fce71dfce6345f19695949eb4432e25d (diff)
downloadfernflower-9f9da912f666dc2d25b7ba7e03283f13b4c5b4bf.tar
fernflower-9f9da912f666dc2d25b7ba7e03283f13b4c5b4bf.tar.gz
fernflower-9f9da912f666dc2d25b7ba7e03283f13b4c5b4bf.tar.lz
fernflower-9f9da912f666dc2d25b7ba7e03283f13b4c5b4bf.tar.xz
fernflower-9f9da912f666dc2d25b7ba7e03283f13b4c5b4bf.zip
Fixed some errors in line counting
Diffstat (limited to 'src/org/jetbrains/java/decompiler/modules')
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java6
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java12
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchStatement.java10
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/stats/DoStatement.java18
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java16
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/stats/SequenceStatement.java6
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/stats/SwitchStatement.java10
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/stats/SynchronizedStatement.java8
8 files changed, 45 insertions, 41 deletions
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
index f4b7aa2..dc28485 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
@@ -778,13 +778,13 @@ public class ExprProcessor implements CodeConstants {
buf.append(" label").append(edge.closure.id);
}
buf.append(";").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
}
if (buf.length() == 0 && semicolon) {
buf.append(InterpreterUtil.getIndentString(indent)).append(";").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
return buf.toString();
@@ -828,7 +828,7 @@ public class ExprProcessor implements CodeConstants {
buf.append(";");
}
buf.append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
}
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java
index 9ab7ec2..f22d1b1 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java
@@ -124,7 +124,7 @@ public class CatchAllStatement extends Statement {
boolean labeled = isLabeled();
if (labeled) {
buf.append(indstr).append("label").append(this.id).append(":").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
List<StatEdge> lstSuccs = first.getSuccessorEdges(STATEDGE_DIRECT_ALL);
@@ -137,30 +137,30 @@ public class CatchAllStatement extends Statement {
}
else {
buf.append(indstr).append("try {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(indstr).append("}");
}
buf.append(isFinally ? " finally" :
" catch (" + vars.get(0).toJava(indent, tracer) + ")").append(" {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
if (monitor != null) {
indstr1 = InterpreterUtil.getIndentString(indent + 1);
buf.append(indstr1).append("if(").append(monitor.toJava(indent, tracer)).append(") {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
buf.append(ExprProcessor.jmpWrapper(handler, indent + 1 + (monitor != null ? 1 : 0), true, tracer));
if (monitor != null) {
buf.append(indstr1).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
buf.append(indstr).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
return buf.toString();
}
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchStatement.java b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchStatement.java
index 7162f15..a096258 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchStatement.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchStatement.java
@@ -160,11 +160,11 @@ public class CatchStatement extends Statement {
if (isLabeled()) {
buf.append(indstr).append("label").append(this.id).append(":").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
buf.append(indstr).append("try {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(indstr).append("}");
@@ -183,14 +183,14 @@ public class CatchStatement extends Statement {
}
buf.append(vars.get(i - 1).toJava(indent, tracer));
buf.append(") {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(stats.get(i), indent + 1, true, tracer)).append(indstr)
.append("}");
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
buf.append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
return buf.toString();
}
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/DoStatement.java b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/DoStatement.java
index 299659a..1ddce1b 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/DoStatement.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/DoStatement.java
@@ -102,39 +102,39 @@ public class DoStatement extends Statement {
if (isLabeled()) {
buf.append(indstr).append("label").append(this.id).append(":").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
switch (looptype) {
case LOOP_DO:
buf.append(indstr).append("while(true) {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(indstr).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
break;
case LOOP_DOWHILE:
buf.append(indstr).append("do {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
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);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
break;
case LOOP_WHILE:
buf.append(indstr).append("while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(") {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(indstr).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
break;
case LOOP_FOR:
buf.append(indstr).append("for(").append(initExprent.get(0) == null ? "" : initExprent.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);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(indstr).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
return buf.toString();
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java
index 343d99e..ebe2bd7 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java
@@ -211,11 +211,11 @@ public class IfStatement extends Statement {
if (isLabeled()) {
buf.append(indstr).append("label").append(this.id).append(":").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
buf.append(indstr).append(headexprent.get(0).toJava(indent, tracer)).append(" {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
if (ifstat == null) {
buf.append(InterpreterUtil.getIndentString(indent + 1));
@@ -235,7 +235,7 @@ public class IfStatement extends Statement {
}
}
buf.append(";").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
else {
buf.append(ExprProcessor.jmpWrapper(ifstat, indent + 1, true, tracer));
@@ -258,11 +258,15 @@ public class IfStatement extends Statement {
elseif = true;
}
else {
- String content = ExprProcessor.jmpWrapper(elsestat, indent + 1, false, tracer);
+ BytecodeMappingTracer else_tracer = new BytecodeMappingTracer(tracer.getCurrentSourceLine());
+ String content = ExprProcessor.jmpWrapper(elsestat, indent + 1, false, else_tracer);
if (content.length() > 0) {
buf.append(indstr).append("} else {").append(new_line_separator);
- tracer.incrementSourceLine(); // FIXME: wrong order
+
+ else_tracer.shiftSourceLines(1);
+ tracer.setCurrentSourceLine(else_tracer.getCurrentSourceLine() + 1);
+ tracer.addTracer(else_tracer);
buf.append(content);
}
@@ -271,7 +275,7 @@ public class IfStatement extends Statement {
if (!elseif) {
buf.append(indstr).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
return buf.toString();
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SequenceStatement.java b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SequenceStatement.java
index 24152f3..38420e0 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SequenceStatement.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SequenceStatement.java
@@ -114,7 +114,7 @@ public class SequenceStatement extends Statement {
indstr = InterpreterUtil.getIndentString(indent);
indent++;
buf.append(indstr).append("label").append(this.id).append(": {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
boolean notempty = false;
@@ -125,7 +125,7 @@ public class SequenceStatement extends Statement {
if (i > 0 && notempty) {
buf.append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
String str = ExprProcessor.jmpWrapper(st, indent, false, tracer);
@@ -136,7 +136,7 @@ public class SequenceStatement extends Statement {
if (islabeled) {
buf.append(indstr).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
return buf.toString();
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SwitchStatement.java b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SwitchStatement.java
index 3b75fdc..aea44de 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SwitchStatement.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SwitchStatement.java
@@ -119,11 +119,11 @@ public class SwitchStatement extends Statement {
if (isLabeled()) {
buf.append(indstr).append("label").append(this.id).append(":").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
buf.append(indstr).append(headexprent.get(0).toJava(indent, tracer)).append(" {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
VarType switch_type = headexprent.get(0).getExprType();
@@ -136,14 +136,14 @@ public class SwitchStatement extends Statement {
for (int j = 0; j < edges.size(); j++) {
if (edges.get(j) == default_edge) {
buf.append(indstr).append("default:").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
else {
ConstExprent value = (ConstExprent)values.get(j).copy();
value.setConsttype(switch_type);
buf.append(indstr).append("case ").append(value.toJava(indent, tracer)).append(":").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
}
@@ -151,7 +151,7 @@ public class SwitchStatement extends Statement {
}
buf.append(indstr).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
return buf.toString();
}
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SynchronizedStatement.java b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SynchronizedStatement.java
index 3d61198..eb94ddc 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SynchronizedStatement.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/SynchronizedStatement.java
@@ -80,17 +80,17 @@ public class SynchronizedStatement extends Statement {
if (isLabeled()) {
buf.append(indstr).append("label").append(this.id).append(":").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
}
buf.append(indstr).append(headexprent.get(0).toJava(indent, tracer)).append(" {").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(body, indent + 1, true, tracer));
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
buf.append(indstr).append("}").append(new_line_separator);
- tracer.incrementSourceLine();
+ tracer.incrementCurrentSourceLine();
return buf.toString();
}