use of org.checkerframework.dataflow.cfg.node.LambdaResultExpressionNode in project checker-framework by typetools.
the class CFGTranslationPhaseOne method process.
/**
* Performs the actual work of phase one.
*
* @param bodyPath path to the body of the underlying AST's method
* @param underlyingAST the AST for which the CFG is to be built
* @return the result of phase one
*/
public PhaseOneResult process(TreePath bodyPath, UnderlyingAST underlyingAST) {
// traverse AST of the method body
this.path = bodyPath;
try {
// "finally" clause is "this.path = null"
Node finalNode = scan(path.getLeaf(), null);
// add an extra node for the result of that lambda
if (underlyingAST.getKind() == UnderlyingAST.Kind.LAMBDA) {
LambdaExpressionTree lambdaTree = ((UnderlyingAST.CFGLambda) underlyingAST).getLambdaTree();
if (lambdaTree.getBodyKind() == LambdaExpressionTree.BodyKind.EXPRESSION) {
Node resultNode = new LambdaResultExpressionNode((ExpressionTree) lambdaTree.getBody(), finalNode);
extendWithNode(resultNode);
}
}
// Add marker to indicate that the next block will be the exit block.
// Note: if there is a return statement earlier in the method (which is always the case for
// non-void methods), then this is not strictly necessary. However, it is also not a problem,
// as it will just generate a degenerate control graph case that will be removed in a later
// phase.
nodeList.add(new UnconditionalJump(regularExitLabel));
return new PhaseOneResult(underlyingAST, treeLookupMap, convertedTreeLookupMap, unaryAssignNodeLookupMap, nodeList, bindings, leaders, returnNodes, regularExitLabel, exceptionalExitLabel, declaredClasses, declaredLambdas);
} finally {
this.path = null;
}
}
Aggregations