private void buildBreakStatement(BreakStatementTree tree) { IdentifierTree label = tree.label(); Block targetBlock; if (label == null) { if (breakTargets.isEmpty()) { throw new IllegalStateException("'break' statement not in loop or switch statement"); } targetBlock = breakTargets.getLast(); } else { targetBlock = labelsBreakTarget.get(label.name()); } currentBlock = createUnconditionalJump(tree, targetBlock); }
private void buildContinueStatement(ContinueStatementTree tree) { IdentifierTree label = tree.label(); Block targetBlock; if (label == null) { if (continueTargets.isEmpty()) { throw new IllegalStateException("'continue' statement not in loop or switch statement"); } targetBlock = continueTargets.getLast(); } else { targetBlock = labelsContinueTarget.get(label.name()); } currentBlock = createUnconditionalJump(tree, targetBlock); }
private void buildBreakStatement(BreakStatementTree tree) { IdentifierTree label = tree.label(); Block targetBlock = null; if (label == null) { if (breakTargets.isEmpty()) { if (!ignoreBreakAndContinue) { throw new IllegalStateException("'break' statement not in loop or switch statement"); } } else { targetBlock = breakTargets.getLast(); } } else { targetBlock = labelsBreakTarget.get(label.name()); } currentBlock = createUnconditionalJump(tree, targetBlock, currentBlock); if(currentBlock.exitBlock != null) { currentBlock.exitBlock = null; } }
private void buildContinueStatement(ContinueStatementTree tree) { IdentifierTree label = tree.label(); Block targetBlock = null; if (label == null) { if (continueTargets.isEmpty()) { if (!ignoreBreakAndContinue) { throw new IllegalStateException("'continue' statement not in loop or switch statement"); } } else { targetBlock = continueTargets.getLast(); } } else { targetBlock = labelsContinueTarget.get(label.name()); } currentBlock = createUnconditionalJump(tree, targetBlock, currentBlock); // cleanup for continue statement to a finally: continue block can't have an exit block. currentBlock.exitBlock = null; }
private void buildContinueStatement(ContinueStatementTree tree) { IdentifierTree label = tree.label(); Block targetBlock = null; if (label == null) { if (continueTargets.isEmpty()) { if (!ignoreBreakAndContinue) { throw new IllegalStateException("'continue' statement not in loop or switch statement"); } } else { targetBlock = continueTargets.getLast(); } } else { targetBlock = labelsContinueTarget.get(label.name()); } currentBlock = createUnconditionalJump(tree, targetBlock, currentBlock); // cleanup for continue statement to a finally: continue block can't have an exit block. currentBlock.exitBlock = null; }
private void buildBreakStatement(BreakStatementTree tree) { IdentifierTree label = tree.label(); Block targetBlock = null; if (label == null) { if (breakTargets.isEmpty()) { if (!ignoreBreakAndContinue) { throw new IllegalStateException("'break' statement not in loop or switch statement"); } } else { targetBlock = breakTargets.getLast(); } } else { targetBlock = labelsBreakTarget.get(label.name()); } currentBlock = createUnconditionalJump(tree, targetBlock, currentBlock); if(currentBlock.exitBlock != null) { currentBlock.exitBlock = null; } }
private void buildThrowStatement(ThrowStatementTree throwStatementTree) { Block jumpTo = exitBlock(); TryStatement enclosingTryCatch = enclosingTry.peek(); if(enclosingTryCatch != null){ jumpTo = enclosingTryCatch.catches.keySet().stream() .filter(t -> throwStatementTree.expression().symbolType().isSubtypeOf(t)) .findFirst() .map(t -> enclosingTryCatch.catches.get(t)) .orElse(exitBlock()); } currentBlock = createUnconditionalJump(throwStatementTree, jumpTo, currentBlock); build(throwStatementTree.expression()); }
private void buildThrowStatement(ThrowStatementTree throwStatementTree) { Block jumpTo = exitBlock(); TryStatement enclosingTryCatch = enclosingTry.peek(); if(enclosingTryCatch != null){ jumpTo = enclosingTryCatch.catches.keySet().stream() .filter(t -> throwStatementTree.expression().symbolType().isSubtypeOf(t)) .findFirst() .map(t -> enclosingTryCatch.catches.get(t)) .orElse(exitBlock()); } currentBlock = createUnconditionalJump(throwStatementTree, jumpTo, currentBlock); build(throwStatementTree.expression()); }
private void buildReturnStatement(ReturnStatementTree returnStatement) { currentBlock = createUnconditionalJump(returnStatement, exitBlock(), currentBlock); ExpressionTree expression = returnStatement.expression(); if (expression != null) { build(expression); } }
private void buildReturnStatement(ReturnStatementTree returnStatement) { currentBlock = createUnconditionalJump(returnStatement, exitBlock(), currentBlock); ExpressionTree expression = returnStatement.expression(); if (expression != null) { build(expression); } }
private void buildThrowStatement(ThrowStatementTree throwStatementTree) { // FIXME this won't work if it is intended to be caught by a try statement. currentBlock = createUnconditionalJump(throwStatementTree, exitBlock()); build(throwStatementTree.expression()); }
private void buildReturnStatement(ReturnStatementTree returnStatement) { currentBlock = createUnconditionalJump(returnStatement, exitBlock()); ExpressionTree expression = returnStatement.expression(); if (expression != null) { build(expression); } }
private void buildSynchronizedStatement(SynchronizedStatementTree sst) { // First create the block of the statement, build(sst.block()); // Then create a single block with the SYNCHRONIZED tree as terminator currentBlock = createUnconditionalJump(sst, currentBlock, null); build(sst.expression()); }
private void buildSynchronizedStatement(SynchronizedStatementTree sst) { // First create the block of the statement, build(sst.block()); // Then create a single block with the SYNCHRONIZED tree as terminator currentBlock = createUnconditionalJump(sst, currentBlock, null); build(sst.expression()); }
private void buildSynchronizedStatement(SynchronizedStatementTree sst) { // First create the block of the statement, build(sst.block()); // Then create a single block with the SYNCHRONIZED tree as terminator currentBlock = createUnconditionalJump(sst, currentBlock); build(sst.expression()); }
buildCondition(condition, body, falseBranch); } else { currentBlock = createUnconditionalJump(tree, body);
private void buildForStatement(ForStatementTree tree) { Block falseBranch = currentBlock; // process step currentBlock = createBlock(); Block updateBlock = currentBlock; build(tree.update()); addContinueTarget(currentBlock); // process body currentBlock = createBlock(currentBlock); breakTargets.addLast(falseBranch); build(tree.statement()); breakTargets.removeLast(); continueTargets.removeLast(); Block body = currentBlock; // process condition ExpressionTree condition = tree.condition(); if (condition != null) { currentBlock = createBranch(tree, body, falseBranch); buildCondition(condition, body, falseBranch); } else { currentBlock = createUnconditionalJump(tree, body, falseBranch); } updateBlock.addSuccessor(currentBlock); // process init currentBlock = createBlock(currentBlock); build(tree.initializer()); }
private void buildForStatement(ForStatementTree tree) { Block falseBranch = currentBlock; // process step currentBlock = createBlock(); Block updateBlock = currentBlock; build(tree.update()); addContinueTarget(currentBlock); // process body currentBlock = createBlock(currentBlock); breakTargets.addLast(falseBranch); build(tree.statement()); breakTargets.removeLast(); continueTargets.removeLast(); Block body = currentBlock; // process condition ExpressionTree condition = tree.condition(); if (condition != null) { currentBlock = createBranch(tree, body, falseBranch); buildCondition(condition, body, falseBranch); } else { currentBlock = createUnconditionalJump(tree, body, falseBranch); } updateBlock.addSuccessor(currentBlock); // process init currentBlock = createBlock(currentBlock); build(tree.initializer()); }