use of org.checkerframework.dataflow.cfg.node.NumericalAdditionNode in project checker-framework by typetools.
the class UpperBoundTransfer method propagateToOperands.
/**
* {@code node} is known to be {@code typeOfNode}. If the node is a plus or a minus then the
* types of the left and right operands can be refined to include offsets. If the node is a
* multiplication, its operands can also be refined. See {@link
* #propagateToAdditionOperand(LessThanLengthOf, Node, Node, TransferInput, CFStore)}, {@link
* #propagateToSubtractionOperands(LessThanLengthOf, NumericalSubtractionNode, TransferInput,
* CFStore)}, and {@link #propagateToMultiplicationOperand(LessThanLengthOf, Node, Node,
* TransferInput, CFStore)} for details.
*/
private void propagateToOperands(LessThanLengthOf typeOfNode, Node node, TransferInput<CFValue, CFStore> in, CFStore store) {
if (node instanceof NumericalAdditionNode) {
Node right = ((NumericalAdditionNode) node).getRightOperand();
Node left = ((NumericalAdditionNode) node).getLeftOperand();
propagateToAdditionOperand(typeOfNode, left, right, in, store);
propagateToAdditionOperand(typeOfNode, right, left, in, store);
} else if (node instanceof NumericalSubtractionNode) {
propagateToSubtractionOperands(typeOfNode, (NumericalSubtractionNode) node, in, store);
} else if (node instanceof NumericalMultiplicationNode) {
if (atypeFactory.hasLowerBoundTypeByClass(node, Positive.class)) {
Node right = ((NumericalMultiplicationNode) node).getRightOperand();
Node left = ((NumericalMultiplicationNode) node).getLeftOperand();
propagateToMultiplicationOperand(typeOfNode, left, right, in, store);
propagateToMultiplicationOperand(typeOfNode, right, left, in, store);
}
}
}
use of org.checkerframework.dataflow.cfg.node.NumericalAdditionNode in project checker-framework by typetools.
the class OffsetEquation method createOffsetFromNode.
private static void createOffsetFromNode(Node node, AnnotationProvider factory, OffsetEquation eq, char op) {
Receiver r = FlowExpressions.internalReprOf(factory, node);
if (r instanceof Unknown || r == null) {
if (node instanceof NumericalAdditionNode) {
createOffsetFromNode(((NumericalAdditionNode) node).getLeftOperand(), factory, eq, op);
createOffsetFromNode(((NumericalAdditionNode) node).getRightOperand(), factory, eq, op);
} else if (node instanceof NumericalSubtractionNode) {
createOffsetFromNode(((NumericalSubtractionNode) node).getLeftOperand(), factory, eq, op);
char other = op == '+' ? '-' : '+';
createOffsetFromNode(((NumericalSubtractionNode) node).getRightOperand(), factory, eq, other);
} else {
eq.error = node.toString();
}
} else {
eq.addTerm(op, r.toString());
}
}
Aggregations