use of org.checkerframework.dataflow.cfg.node.AssertionErrorNode in project checker-framework by typetools.
the class CFGTranslationPhaseOne method translateAssertWithAssertionsEnabled.
/**
* Translates an assertion statement to the correct CFG nodes. The translation assumes that
* assertions are enabled.
*/
protected void translateAssertWithAssertionsEnabled(AssertTree tree) {
// all necessary labels
Label assertEnd = new Label();
Label elseEntry = new Label();
// basic block for the condition
Node condition = unbox(scan(tree.getCondition(), null));
ConditionalJump cjump = new ConditionalJump(assertEnd, elseEntry);
extendWithExtendedNode(cjump);
// else branch
Node detail = null;
addLabelForNextNode(elseEntry);
if (tree.getDetail() != null) {
detail = scan(tree.getDetail(), null);
}
AssertionErrorNode assertNode = new AssertionErrorNode(tree, condition, detail, assertionErrorType);
extendWithNode(assertNode);
NodeWithExceptionsHolder exNode = extendWithNodeWithException(new ThrowNode(null, assertNode, env.getTypeUtils()), assertionErrorType);
exNode.setTerminatesExecution(true);
// then branch (nothing happens)
addLabelForNextNode(assertEnd);
}
Aggregations