Search in sources :

Example 1 with IndexRefinementInfo

use of org.checkerframework.checker.index.IndexRefinementInfo in project checker-framework by typetools.

the class UpperBoundTransfer method strengthenAnnotationOfEqualTo.

/**
 * Implements case 11.
 */
@Override
protected TransferResult<CFValue, CFStore> strengthenAnnotationOfEqualTo(TransferResult<CFValue, CFStore> res, Node firstNode, Node secondNode, CFValue firstValue, CFValue secondValue, boolean notEqualTo) {
    TransferResult<CFValue, CFStore> result = super.strengthenAnnotationOfEqualTo(res, firstNode, secondNode, firstValue, secondValue, notEqualTo);
    IndexRefinementInfo rfi = new IndexRefinementInfo(result, analysis, firstNode, secondNode);
    if (rfi.leftAnno == null || rfi.rightAnno == null) {
        return result;
    }
    CFStore equalsStore = notEqualTo ? rfi.elseStore : rfi.thenStore;
    CFStore notEqualStore = notEqualTo ? rfi.thenStore : rfi.elseStore;
    refineEq(rfi.left, rfi.leftAnno, rfi.right, rfi.rightAnno, equalsStore);
    refineNeqSequenceLength(rfi.left, rfi.right, rfi.rightAnno, notEqualStore);
    refineNeqSequenceLength(rfi.right, rfi.left, rfi.leftAnno, notEqualStore);
    return rfi.newResult;
}
Also used : CFValue(org.checkerframework.framework.flow.CFValue) CFStore(org.checkerframework.framework.flow.CFStore) IndexRefinementInfo(org.checkerframework.checker.index.IndexRefinementInfo)

Example 2 with IndexRefinementInfo

use of org.checkerframework.checker.index.IndexRefinementInfo in project checker-framework by typetools.

the class LowerBoundTransfer method strengthenAnnotationOfEqualTo.

/**
 * Implements the transfer rules for both equal nodes and not-equals nodes (i.e. cases 5 and 6).
 */
@Override
protected TransferResult<CFValue, CFStore> strengthenAnnotationOfEqualTo(TransferResult<CFValue, CFStore> result, Node firstNode, Node secondNode, CFValue firstValue, CFValue secondValue, boolean notEqualTo) {
    result = super.strengthenAnnotationOfEqualTo(result, firstNode, secondNode, firstValue, secondValue, notEqualTo);
    IndexRefinementInfo rfi = new IndexRefinementInfo(result, analysis, secondNode, firstNode);
    if (rfi.leftAnno == null || rfi.rightAnno == null) {
        return result;
    }
    // There is also special processing to look
    // for literals on one side of the equals and a GTEN1 or NN on the other, so that
    // those types can be promoted in the branch where their values are not equal to certain
    // literals.
    CFStore notEqualsStore = notEqualTo ? rfi.thenStore : rfi.elseStore;
    notEqualToValue(rfi.left, rfi.right, rfi.rightAnno, notEqualsStore);
    notEqualToValue(rfi.right, rfi.left, rfi.leftAnno, notEqualsStore);
    return rfi.newResult;
}
Also used : CFStore(org.checkerframework.framework.flow.CFStore) IndexRefinementInfo(org.checkerframework.checker.index.IndexRefinementInfo)

Aggregations

IndexRefinementInfo (org.checkerframework.checker.index.IndexRefinementInfo)2 CFStore (org.checkerframework.framework.flow.CFStore)2 CFValue (org.checkerframework.framework.flow.CFValue)1