예제 #1
0
파일: integer.cpp 프로젝트: quytc/TARA
pair<integer::mapit,integer::mapit> integer::get_locs(const z3::expr& hb, bool& possibly_equal) const {
  // we need to flip that bool parameter in to know if we are sure about this result or not (two locations can be assigned an equal integer)
  auto loc1 = location_lookup.end();
  auto loc2 = location_lookup.end();
  switch(hb.kind()) {
    case Z3_APP_AST:
    {
      z3::func_decl d = hb.decl();
      Z3_decl_kind dk = d.decl_kind();
      switch(dk) {
        case Z3_OP_LE:
          possibly_equal = true; // fallthrough
        case Z3_OP_LT: 
          if (hb.arg(1).kind() == Z3_NUMERAL_AST)
            return get_locs(hb.arg(0), possibly_equal);
          loc1 = location_lookup.find(hb.arg(0));
          loc2 = location_lookup.find(hb.arg(1));
          break;
        case Z3_OP_GE: 
          possibly_equal = true; // fallthrough
        case Z3_OP_GT: 
          if (hb.arg(1).kind() == Z3_NUMERAL_AST) {
            return swap_pair(get_locs(hb.arg(0), possibly_equal));
          }
          loc1 = location_lookup.find(hb.arg(1));
          loc2 = location_lookup.find(hb.arg(0));
          break;
        case Z3_OP_NOT:
        {
          auto res = swap_pair(get_locs(hb.arg(0), possibly_equal));
          possibly_equal = !possibly_equal;
          return res;
          break;
        }
        case Z3_OP_ADD:
        {
          loc1 = location_lookup.find(hb.arg(0));
          z3::expr t1 = hb.arg(1);
          if (t1.decl().decl_kind() == Z3_OP_MUL) {
            loc2 = location_lookup.find(t1.arg(1));
          }
        }
        default:
          break;
      }
      break;
    }
    default:
      break;
  }
  return make_pair<integer::mapit,integer::mapit>(std::move(loc1),std::move(loc2));
}
예제 #2
0
파일: integer.cpp 프로젝트: thorstent/TARA
pair<integer::mapit,integer::mapit>
integer::get_locs( const z3::expr& hb,
                   bool& possibly_equal,
                   bool& is_partial ) const {
  // we need to flip that bool parameter in to know if we are sure about
  // this result or not (two tstamps can be assigned an equal integer)
  auto loc1 = tstamp_lookup.end();
  auto loc2 = tstamp_lookup.end();
  switch(hb.kind()) {
  case Z3_APP_AST: {
    z3::func_decl d = hb.decl();
    Z3_decl_kind dk = d.decl_kind();
    switch(dk) {
    case Z3_OP_LE:
      possibly_equal = true; // fallthrough
    case Z3_OP_LT:
      if (hb.arg(1).kind() == Z3_NUMERAL_AST)
        return get_locs(hb.arg(0), possibly_equal, is_partial);
      loc1 = tstamp_lookup.find(hb.arg(0));
      loc2 = tstamp_lookup.find(hb.arg(1));
      break;
    case Z3_OP_GE:
      possibly_equal = true; // fallthrough
    case Z3_OP_GT:
      if (hb.arg(1).kind() == Z3_NUMERAL_AST) {
        return swap_pair(get_locs(hb.arg(0), possibly_equal, is_partial));
      }
      loc1 = tstamp_lookup.find(hb.arg(1));
      loc2 = tstamp_lookup.find(hb.arg(0));
      break;
    case Z3_OP_NOT: {
      auto neg_hb = get_locs(hb.arg(0), possibly_equal, is_partial);
      auto res = swap_pair( neg_hb );
      possibly_equal = !possibly_equal;
      return res;
      break;
    }
    case Z3_OP_ADD: {
      loc1 = tstamp_lookup.find(hb.arg(0));
      z3::expr t1 = hb.arg(1);
      if (t1.decl().decl_kind() == Z3_OP_MUL) {
        // todo: check the the other multiplicant is -1
        loc2 = tstamp_lookup.find(t1.arg(1));
      }
      break;
    }
    case Z3_OP_SPECIAL_RELATION_PO: {
      is_partial = true;
      loc1 = tstamp_lookup.find(hb.arg(0));
      loc2 = tstamp_lookup.find(hb.arg(1));
      break;
    }
    default:
      break;
    }
    break;
  }
  default:
    break;
  }
  return make_pair<integer::mapit,integer::mapit>(std::move(loc1),std::move(loc2));
}