コード例 #1
0
  protected static Region booleanOperation(
      final Region[] l,
      final Region[] r,
      final BitvectorManager bvmgr,
      final BinaryOperator op,
      final CType calculationType,
      final MachineModel machineModel) {

    boolean signed = true;
    if (calculationType instanceof CSimpleType) {
      signed = !((CSimpleType) calculationType).isUnsigned();
    }

    switch (op) {
      case EQUALS:
        return bvmgr.makeLogicalEqual(l, r);
      case NOT_EQUALS:
        return bvmgr.makeNot(bvmgr.makeLogicalEqual(l, r));
      case GREATER_THAN: // A>B <--> B<A
        return bvmgr.makeLess(r, l, signed);
      case GREATER_EQUAL: // A>=B <--> B<=A
        return bvmgr.makeLessOrEqual(r, l, signed);
      case LESS_THAN:
        return bvmgr.makeLess(l, r, signed);
      case LESS_EQUAL:
        return bvmgr.makeLessOrEqual(l, r, signed);

      default:
        throw new AssertionError("unknown binary operation: " + op);
    }
  }