correct the end position of CATCH blocks

This commit is contained in:
Volker Berlin 2022-07-18 21:23:28 +02:00
parent bf7518e5d4
commit fd3c698ef5
No known key found for this signature in database
GPG Key ID: 988423EF815BE4CB

View File

@ -191,9 +191,11 @@ class BranchManager {
TryCatchParsedBlock node = new TryCatchParsedBlock( tryCatch );
parsedOperations.add( node );
int gotoPos = tryCatch.getHandler() - 3; //tryCatch.getEnd() points some time before and some time after the goto
int handlerPos = tryCatch.getHandler();
int gotoPos = handlerPos - 3; //tryCatch.getEnd() points some time before and some time after the goto
int endPos = root.endPos;
// find all try blocks and the end position of the last catch/finally handler
int idx;
for( idx = 0; idx < countOps; idx++ ) {
@ -209,7 +211,7 @@ class BranchManager {
break;
}
if( gotoPos < parsedBlock.endPosition && endPos > parsedBlock.endPosition ) {
if( handlerPos < parsedBlock.endPosition && endPos > parsedBlock.endPosition ) {
endPos = parsedBlock.endPosition;
}
}
@ -1230,7 +1232,8 @@ class BranchManager {
ArrayList<TryCatchFinally> catches = new ArrayList<>();
catches.add( tryCatch );
int gotoPos = tryCatch.getHandler()-3; //tryCatch.getEnd() points some time before and some time after the goto
int handlerPos = tryCatch.getHandler();
int gotoPos = handlerPos - 3; //tryCatch.getEnd() points some time before and some time after the goto
int endPos = parent.endPos;
// find all try blocks and the end position of the last catch/finally handler
@ -1257,7 +1260,7 @@ class BranchManager {
break;
}
if( gotoPos < parsedBlock.endPosition && endPos > parsedBlock.endPosition ) {
if( handlerPos < parsedBlock.endPosition && endPos > parsedBlock.endPosition ) {
endPos = parsedBlock.endPosition;
}
}