decompiler: generate line number matching for return and some other statements

master
Egor.Ushakov 10 years ago
parent f3af4dd681
commit 7e30facd33
  1. 3
      src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java
  2. 12
      testData/results/TestClassLoop.dec
  3. 1
      testData/results/TestClassVar.dec
  4. 9
      testData/results/TestTryCatchFinally.dec

@ -889,13 +889,16 @@ public class FinallyProcessor {
if (seqPattern.length() < seqSample.length()) { // split in two blocks if (seqPattern.length() < seqSample.length()) { // split in two blocks
SimpleInstructionSequence seq = new SimpleInstructionSequence(); SimpleInstructionSequence seq = new SimpleInstructionSequence();
LinkedList<Integer> oldOffsets = new LinkedList<Integer>();
for (int i = seqSample.length() - 1; i >= seqPattern.length(); i--) { for (int i = seqSample.length() - 1; i >= seqPattern.length(); i--) {
seq.addInstruction(0, seqSample.getInstr(i), -1); seq.addInstruction(0, seqSample.getInstr(i), -1);
oldOffsets.addFirst(sample.getOldOffset(i));
seqSample.removeInstruction(i); seqSample.removeInstruction(i);
} }
BasicBlock newblock = new BasicBlock(++graph.last_id); BasicBlock newblock = new BasicBlock(++graph.last_id);
newblock.setSeq(seq); newblock.setSeq(seq);
newblock.getInstrOldOffsets().addAll(oldOffsets);
List<BasicBlock> lstTemp = new ArrayList<BasicBlock>(); List<BasicBlock> lstTemp = new ArrayList<BasicBlock>();
lstTemp.addAll(sample.getSuccs()); lstTemp.addAll(sample.getSuccs());

@ -13,7 +13,7 @@ public class TestClassLoop {
while(true) { while(true) {
try { try {
if(!var0) {// 33 if(!var0) {// 33
return; return;// 34
} }
} finally { } finally {
System.out.println("1");// 38 System.out.println("1");// 38
@ -37,7 +37,7 @@ public class TestClassLoop {
} }
} }
System.out.println("4"); System.out.println("4");// 58
} }
} }
} }
@ -54,6 +54,7 @@ class 'pkg/TestClassLoop' {
4 10 4 10
d 10 d 10
f 14 f 14
1a 15
26 18 26 18
27 18 27 18
2a 18 2a 18
@ -71,6 +72,9 @@ class 'pkg/TestClassLoop' {
2a 33 2a 33
2d 33 2d 33
2f 33 2f 33
37 39
3a 39
3c 39
} }
} }
@ -78,13 +82,13 @@ Lines mapping:
23 <-> 6 23 <-> 6
29 <-> 11 29 <-> 11
33 <-> 15 33 <-> 15
34 <-> 16
38 <-> 19 38 <-> 19
45 <-> 25 45 <-> 25
49 <-> 30 49 <-> 30
52 <-> 33 52 <-> 33
53 <-> 34 53 <-> 34
58 <-> 40
Not mapped: Not mapped:
34
39 39
54 54
58

@ -50,6 +50,7 @@ class 'pkg/TestClassVar' {
20 11 20 11
26 12 26 12
29 12 29 12
2e 7
34 18 34 18
} }

@ -36,7 +36,7 @@ public class TestTryCatchFinally {
System.out.println("Finally");// 55 System.out.println("Finally");// 55
} }
return -1; return -1;// 56
} }
} }
@ -67,13 +67,16 @@ class 'pkg/TestTryCatchFinally' {
method 'test (Ljava/lang/String;)I' { method 'test (Ljava/lang/String;)I' {
1 30 1 30
4 30 4 30
e 31
10 33 10 33
1a 33 1a 33
23 33 23 33
26 33 26 33
31 38
34 35 34 35
35 35 35 35
38 35 38 35
3f 38
} }
} }
@ -90,11 +93,11 @@ Lines mapping:
51 <-> 31 51 <-> 31
53 <-> 34 53 <-> 34
55 <-> 36 55 <-> 36
56 <-> 39
57 <-> 39
Not mapped: Not mapped:
25 25
28 28
32 32
35 35
52 52
56
57

Loading…
Cancel
Save