use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.
the class ValueTransfer method visitIntegerDivision.
@Override
public TransferResult<CFValue, CFStore> visitIntegerDivision(IntegerDivisionNode n, TransferInput<CFValue, CFStore> p) {
TransferResult<CFValue, CFStore> transferResult = super.visitIntegerDivision(n, p);
AnnotationMirror resultAnno = calculateNumericalBinaryOp(n.getLeftOperand(), n.getRightOperand(), NumericalBinaryOps.DIVISION, p);
return createNewResult(transferResult, resultAnno);
}
use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.
the class ValueTransfer method visitNumericalPlus.
@Override
public TransferResult<CFValue, CFStore> visitNumericalPlus(NumericalPlusNode n, TransferInput<CFValue, CFStore> p) {
TransferResult<CFValue, CFStore> transferResult = super.visitNumericalPlus(n, p);
AnnotationMirror resultAnno = calculateNumericalUnaryOp(n.getOperand(), NumericalUnaryOps.PLUS, p);
return createNewResult(transferResult, resultAnno);
}
use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.
the class ValueTransfer method getStringLengthRange.
/**
* Returns a range of possible lengths for {@code subNode}, as casted to a String.
*/
private Range getStringLengthRange(Node subNode, TransferInput<CFValue, CFStore> p) {
CFValue value = p.getValueOfSubNode(subNode);
AnnotationMirror arrayLenRangeAnno = AnnotationUtils.getAnnotationByClass(value.getAnnotations(), ArrayLenRange.class);
if (arrayLenRangeAnno != null) {
return ValueAnnotatedTypeFactory.getRange(arrayLenRangeAnno);
}
// @BottomVal
if (AnnotationUtils.containsSameByClass(value.getAnnotations(), BottomVal.class)) {
return Range.NOTHING;
}
TypeKind subNodeTypeKind = subNode.getType().getKind();
// handle values converted to string (ints, longs, longs with @IntRange)
if (subNode instanceof StringConversionNode) {
return getStringLengthRange(((StringConversionNode) subNode).getOperand(), p);
} else if (isIntRange(subNode, p)) {
return getIntRangeStringLengthRange(subNode, p);
} else if (subNodeTypeKind == TypeKind.INT) {
// ints are between 1 and 11 characters long
return new Range(1, 11);
} else if (subNodeTypeKind == TypeKind.LONG) {
// longs are between 1 and 20 characters long
return new Range(1, 20);
}
return new Range(0, Integer.MAX_VALUE);
}
use of org.checkerframework.framework.flow.CFValue in project checker-framework by typetools.
the class ValueTransfer method visitNumericalAddition.
@Override
public TransferResult<CFValue, CFStore> visitNumericalAddition(NumericalAdditionNode n, TransferInput<CFValue, CFStore> p) {
TransferResult<CFValue, CFStore> transferResult = super.visitNumericalAddition(n, p);
AnnotationMirror resultAnno = calculateNumericalBinaryOp(n.getLeftOperand(), n.getRightOperand(), NumericalBinaryOps.ADDITION, p);
return createNewResult(transferResult, resultAnno);
}
Aggregations