Fixed some errors in line counting

This commit is contained in:
Stiver
2014-10-07 07:31:22 +02:00
parent bef17b44fc
commit 9f9da912f6
12 changed files with 77 additions and 52 deletions

View File

@@ -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();
}
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();
}

View File

@@ -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();
}