Search in sources :

Example 1 with LambdaResultExpressionNode

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;
    }
}
Also used : LambdaExpressionTree(com.sun.source.tree.LambdaExpressionTree) NumericalMultiplicationNode(org.checkerframework.dataflow.cfg.node.NumericalMultiplicationNode) ArrayCreationNode(org.checkerframework.dataflow.cfg.node.ArrayCreationNode) ValueLiteralNode(org.checkerframework.dataflow.cfg.node.ValueLiteralNode) StringConversionNode(org.checkerframework.dataflow.cfg.node.StringConversionNode) UnsignedRightShiftNode(org.checkerframework.dataflow.cfg.node.UnsignedRightShiftNode) LeftShiftNode(org.checkerframework.dataflow.cfg.node.LeftShiftNode) PrimitiveTypeNode(org.checkerframework.dataflow.cfg.node.PrimitiveTypeNode) FloatLiteralNode(org.checkerframework.dataflow.cfg.node.FloatLiteralNode) LessThanNode(org.checkerframework.dataflow.cfg.node.LessThanNode) BitwiseOrNode(org.checkerframework.dataflow.cfg.node.BitwiseOrNode) LocalVariableNode(org.checkerframework.dataflow.cfg.node.LocalVariableNode) NarrowingConversionNode(org.checkerframework.dataflow.cfg.node.NarrowingConversionNode) EqualToNode(org.checkerframework.dataflow.cfg.node.EqualToNode) NumericalPlusNode(org.checkerframework.dataflow.cfg.node.NumericalPlusNode) ConditionalAndNode(org.checkerframework.dataflow.cfg.node.ConditionalAndNode) VariableDeclarationNode(org.checkerframework.dataflow.cfg.node.VariableDeclarationNode) ClassDeclarationNode(org.checkerframework.dataflow.cfg.node.ClassDeclarationNode) IntegerDivisionNode(org.checkerframework.dataflow.cfg.node.IntegerDivisionNode) AssertionErrorNode(org.checkerframework.dataflow.cfg.node.AssertionErrorNode) InstanceOfNode(org.checkerframework.dataflow.cfg.node.InstanceOfNode) BooleanLiteralNode(org.checkerframework.dataflow.cfg.node.BooleanLiteralNode) ThisNode(org.checkerframework.dataflow.cfg.node.ThisNode) AssignmentNode(org.checkerframework.dataflow.cfg.node.AssignmentNode) NullLiteralNode(org.checkerframework.dataflow.cfg.node.NullLiteralNode) ArrayTypeNode(org.checkerframework.dataflow.cfg.node.ArrayTypeNode) LambdaResultExpressionNode(org.checkerframework.dataflow.cfg.node.LambdaResultExpressionNode) IntegerRemainderNode(org.checkerframework.dataflow.cfg.node.IntegerRemainderNode) FieldAccessNode(org.checkerframework.dataflow.cfg.node.FieldAccessNode) ConditionalOrNode(org.checkerframework.dataflow.cfg.node.ConditionalOrNode) NotEqualNode(org.checkerframework.dataflow.cfg.node.NotEqualNode) BitwiseXorNode(org.checkerframework.dataflow.cfg.node.BitwiseXorNode) ArrayAccessNode(org.checkerframework.dataflow.cfg.node.ArrayAccessNode) ExplicitThisNode(org.checkerframework.dataflow.cfg.node.ExplicitThisNode) StringConcatenateNode(org.checkerframework.dataflow.cfg.node.StringConcatenateNode) NullChkNode(org.checkerframework.dataflow.cfg.node.NullChkNode) CharacterLiteralNode(org.checkerframework.dataflow.cfg.node.CharacterLiteralNode) FloatingDivisionNode(org.checkerframework.dataflow.cfg.node.FloatingDivisionNode) FunctionalInterfaceNode(org.checkerframework.dataflow.cfg.node.FunctionalInterfaceNode) StringConcatenateAssignmentNode(org.checkerframework.dataflow.cfg.node.StringConcatenateAssignmentNode) TypeCastNode(org.checkerframework.dataflow.cfg.node.TypeCastNode) MethodAccessNode(org.checkerframework.dataflow.cfg.node.MethodAccessNode) WideningConversionNode(org.checkerframework.dataflow.cfg.node.WideningConversionNode) LongLiteralNode(org.checkerframework.dataflow.cfg.node.LongLiteralNode) MarkerNode(org.checkerframework.dataflow.cfg.node.MarkerNode) ImplicitThisNode(org.checkerframework.dataflow.cfg.node.ImplicitThisNode) FloatingRemainderNode(org.checkerframework.dataflow.cfg.node.FloatingRemainderNode) ClassNameNode(org.checkerframework.dataflow.cfg.node.ClassNameNode) ObjectCreationNode(org.checkerframework.dataflow.cfg.node.ObjectCreationNode) PackageNameNode(org.checkerframework.dataflow.cfg.node.PackageNameNode) DoubleLiteralNode(org.checkerframework.dataflow.cfg.node.DoubleLiteralNode) SuperNode(org.checkerframework.dataflow.cfg.node.SuperNode) IntegerLiteralNode(org.checkerframework.dataflow.cfg.node.IntegerLiteralNode) SignedRightShiftNode(org.checkerframework.dataflow.cfg.node.SignedRightShiftNode) ThrowNode(org.checkerframework.dataflow.cfg.node.ThrowNode) GreaterThanOrEqualNode(org.checkerframework.dataflow.cfg.node.GreaterThanOrEqualNode) StringLiteralNode(org.checkerframework.dataflow.cfg.node.StringLiteralNode) TernaryExpressionNode(org.checkerframework.dataflow.cfg.node.TernaryExpressionNode) BitwiseAndNode(org.checkerframework.dataflow.cfg.node.BitwiseAndNode) ParameterizedTypeNode(org.checkerframework.dataflow.cfg.node.ParameterizedTypeNode) CaseNode(org.checkerframework.dataflow.cfg.node.CaseNode) SwitchExpressionNode(org.checkerframework.dataflow.cfg.node.SwitchExpressionNode) NumericalAdditionNode(org.checkerframework.dataflow.cfg.node.NumericalAdditionNode) NumericalSubtractionNode(org.checkerframework.dataflow.cfg.node.NumericalSubtractionNode) BitwiseComplementNode(org.checkerframework.dataflow.cfg.node.BitwiseComplementNode) ConditionalNotNode(org.checkerframework.dataflow.cfg.node.ConditionalNotNode) NumericalMinusNode(org.checkerframework.dataflow.cfg.node.NumericalMinusNode) ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) MethodInvocationNode(org.checkerframework.dataflow.cfg.node.MethodInvocationNode) GreaterThanNode(org.checkerframework.dataflow.cfg.node.GreaterThanNode) LessThanOrEqualNode(org.checkerframework.dataflow.cfg.node.LessThanOrEqualNode) SynchronizedNode(org.checkerframework.dataflow.cfg.node.SynchronizedNode) Node(org.checkerframework.dataflow.cfg.node.Node) LambdaResultExpressionNode(org.checkerframework.dataflow.cfg.node.LambdaResultExpressionNode)

Aggregations

LambdaExpressionTree (com.sun.source.tree.LambdaExpressionTree)1 ArrayAccessNode (org.checkerframework.dataflow.cfg.node.ArrayAccessNode)1 ArrayCreationNode (org.checkerframework.dataflow.cfg.node.ArrayCreationNode)1 ArrayTypeNode (org.checkerframework.dataflow.cfg.node.ArrayTypeNode)1 AssertionErrorNode (org.checkerframework.dataflow.cfg.node.AssertionErrorNode)1 AssignmentNode (org.checkerframework.dataflow.cfg.node.AssignmentNode)1 BitwiseAndNode (org.checkerframework.dataflow.cfg.node.BitwiseAndNode)1 BitwiseComplementNode (org.checkerframework.dataflow.cfg.node.BitwiseComplementNode)1 BitwiseOrNode (org.checkerframework.dataflow.cfg.node.BitwiseOrNode)1 BitwiseXorNode (org.checkerframework.dataflow.cfg.node.BitwiseXorNode)1 BooleanLiteralNode (org.checkerframework.dataflow.cfg.node.BooleanLiteralNode)1 CaseNode (org.checkerframework.dataflow.cfg.node.CaseNode)1 CharacterLiteralNode (org.checkerframework.dataflow.cfg.node.CharacterLiteralNode)1 ClassDeclarationNode (org.checkerframework.dataflow.cfg.node.ClassDeclarationNode)1 ClassNameNode (org.checkerframework.dataflow.cfg.node.ClassNameNode)1 ConditionalAndNode (org.checkerframework.dataflow.cfg.node.ConditionalAndNode)1 ConditionalNotNode (org.checkerframework.dataflow.cfg.node.ConditionalNotNode)1 ConditionalOrNode (org.checkerframework.dataflow.cfg.node.ConditionalOrNode)1 DoubleLiteralNode (org.checkerframework.dataflow.cfg.node.DoubleLiteralNode)1 EqualToNode (org.checkerframework.dataflow.cfg.node.EqualToNode)1