Finds the basic blocks that belong to the subroutine starting with the basic block corresponding to this label, and marks these blocks as belonging to this subroutine. This method follows the control flow graph to find all the blocks that are reachable from the current basic block WITHOUT following
(final short subroutineId)
| 498 | * this label. |
| 499 | */ |
| 500 | final void markSubroutine(final short subroutineId) { |
| 501 | // Data flow algorithm: put this basic block in a list of blocks to process (which are blocks |
| 502 | // belonging to subroutine subroutineId) and, while there are blocks to process, remove one from |
| 503 | // the list, mark it as belonging to the subroutine, and add its successor basic blocks in the |
| 504 | // control flow graph to the list of blocks to process (if not already done). |
| 505 | Label listOfBlocksToProcess = this; |
| 506 | listOfBlocksToProcess.nextListElement = EMPTY_LIST; |
| 507 | while (listOfBlocksToProcess != EMPTY_LIST) { |
| 508 | // Remove a basic block from the list of blocks to process. |
| 509 | Label basicBlock = listOfBlocksToProcess; |
| 510 | listOfBlocksToProcess = listOfBlocksToProcess.nextListElement; |
| 511 | basicBlock.nextListElement = null; |
| 512 | |
| 513 | // If it is not already marked as belonging to a subroutine, mark it as belonging to |
| 514 | // subroutineId and add its successors to the list of blocks to process (unless already done). |
| 515 | if (basicBlock.subroutineId == 0) { |
| 516 | basicBlock.subroutineId = subroutineId; |
| 517 | listOfBlocksToProcess = basicBlock.pushSuccessors(listOfBlocksToProcess); |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * Finds the basic blocks that end a subroutine starting with the basic block corresponding to |
no test coverage detected