Search in sources :

Example 1 with ReturnNode

use of org.checkerframework.dataflow.cfg.node.ReturnNode in project bazel by bazelbuild.

the class Analysis method callTransferFunction.

/**
     * Call the transfer function for node {@code node}, and set that node as
     * current node first.
     */
protected TransferResult<A, S> callTransferFunction(Node node, TransferInput<A, S> store) {
    if (node.isLValue()) {
        // store.hasTwoStores()), or is the following correct?
        return new RegularTransferResult<A, S>(null, store.getRegularStore());
    }
    store.node = node;
    currentNode = node;
    TransferResult<A, S> transferResult = node.accept(transferFunction, store);
    currentNode = null;
    if (node instanceof ReturnNode) {
        // save a copy of the store to later check if some property held at
        // a given return statement
        storesAtReturnStatements.put((ReturnNode) node, transferResult);
    }
    if (node instanceof AssignmentNode) {
        // store the flow-refined value for effectively final local variables
        AssignmentNode assignment = (AssignmentNode) node;
        Node lhst = assignment.getTarget();
        if (lhst instanceof LocalVariableNode) {
            LocalVariableNode lhs = (LocalVariableNode) lhst;
            Element elem = lhs.getElement();
            if (ElementUtils.isEffectivelyFinal(elem)) {
                finalLocalValues.put(elem, transferResult.getResultValue());
            }
        }
    }
    return transferResult;
}
Also used : ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) AssignmentNode(org.checkerframework.dataflow.cfg.node.AssignmentNode) AssignmentNode(org.checkerframework.dataflow.cfg.node.AssignmentNode) ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) LocalVariableNode(org.checkerframework.dataflow.cfg.node.LocalVariableNode) Node(org.checkerframework.dataflow.cfg.node.Node) Element(javax.lang.model.element.Element) LocalVariableNode(org.checkerframework.dataflow.cfg.node.LocalVariableNode)

Example 2 with ReturnNode

use of org.checkerframework.dataflow.cfg.node.ReturnNode in project bazel by bazelbuild.

the class Analysis method getReturnStatementStores.

public List<Pair<ReturnNode, TransferResult<A, S>>> getReturnStatementStores() {
    List<Pair<ReturnNode, TransferResult<A, S>>> result = new ArrayList<>();
    for (ReturnNode returnNode : cfg.getReturnNodes()) {
        TransferResult<A, S> store = storesAtReturnStatements.get(returnNode);
        result.add(Pair.of(returnNode, store));
    }
    return result;
}
Also used : ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) ArrayList(java.util.ArrayList) Pair(org.checkerframework.javacutil.Pair)

Aggregations

ReturnNode (org.checkerframework.dataflow.cfg.node.ReturnNode)2 ArrayList (java.util.ArrayList)1 Element (javax.lang.model.element.Element)1 AssignmentNode (org.checkerframework.dataflow.cfg.node.AssignmentNode)1 LocalVariableNode (org.checkerframework.dataflow.cfg.node.LocalVariableNode)1 Node (org.checkerframework.dataflow.cfg.node.Node)1 Pair (org.checkerframework.javacutil.Pair)1