Search in sources :

Example 1 with NumericalMultiplicationNode

use of org.checkerframework.dataflow.cfg.node.NumericalMultiplicationNode 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);
        }
    }
}
Also used : NumericalAdditionNode(org.checkerframework.dataflow.cfg.node.NumericalAdditionNode) TypeCastNode(org.checkerframework.dataflow.cfg.node.TypeCastNode) NumericalMultiplicationNode(org.checkerframework.dataflow.cfg.node.NumericalMultiplicationNode) ArrayCreationNode(org.checkerframework.dataflow.cfg.node.ArrayCreationNode) AssignmentNode(org.checkerframework.dataflow.cfg.node.AssignmentNode) CaseNode(org.checkerframework.dataflow.cfg.node.CaseNode) FieldAccessNode(org.checkerframework.dataflow.cfg.node.FieldAccessNode) NumericalAdditionNode(org.checkerframework.dataflow.cfg.node.NumericalAdditionNode) NumericalSubtractionNode(org.checkerframework.dataflow.cfg.node.NumericalSubtractionNode) MethodInvocationNode(org.checkerframework.dataflow.cfg.node.MethodInvocationNode) Node(org.checkerframework.dataflow.cfg.node.Node) NumericalMultiplicationNode(org.checkerframework.dataflow.cfg.node.NumericalMultiplicationNode) NumericalSubtractionNode(org.checkerframework.dataflow.cfg.node.NumericalSubtractionNode)

Aggregations

ArrayCreationNode (org.checkerframework.dataflow.cfg.node.ArrayCreationNode)1 AssignmentNode (org.checkerframework.dataflow.cfg.node.AssignmentNode)1 CaseNode (org.checkerframework.dataflow.cfg.node.CaseNode)1 FieldAccessNode (org.checkerframework.dataflow.cfg.node.FieldAccessNode)1 MethodInvocationNode (org.checkerframework.dataflow.cfg.node.MethodInvocationNode)1 Node (org.checkerframework.dataflow.cfg.node.Node)1 NumericalAdditionNode (org.checkerframework.dataflow.cfg.node.NumericalAdditionNode)1 NumericalMultiplicationNode (org.checkerframework.dataflow.cfg.node.NumericalMultiplicationNode)1 NumericalSubtractionNode (org.checkerframework.dataflow.cfg.node.NumericalSubtractionNode)1 TypeCastNode (org.checkerframework.dataflow.cfg.node.TypeCastNode)1