Exemplo n.º 1
0
bool
eq_algo::operator()(const expr& a, const expr& b) const
{
  assert(a.get_kind() == b.get_kind());
  switch (a.get_kind()) {
    case bool_expr_kind:
      return eq_bool_expr(cast<bool_expr>(a), cast<bool_expr>(b));
    
    case and_expr_kind:
    case or_expr_kind:
    case imp_expr_kind:
    case eq_expr_kind:
      return equivalent_binary_expr(cast<binary_expr>(a), cast<binary_expr>(b));
    
    case not_expr_kind: 
      return equivalent_unary_expr(cast<unary_expr>(a), cast<unary_expr>(b));

    default:
      break;
  }
  assert(false && "not a logical expression");
}
Exemplo n.º 2
0
void
hash_algo::operator()(hasher& h, const expr& t) const
{
  switch (t.get_kind()) {
    case start_expr_kind:
    case end_expr_kind:
    case arg_expr_kind:
      return hash_unary_expr(h, cast<unary_expr>(t));
    case copy_expr_kind:
      return hash_binary_expr(h, cast<binary_expr>(t));
    default:
      break;
  }
  assert(false && "not a variadic expression");
}
Exemplo n.º 3
0
void
print_expr(std::ostream& os, const expr& e) 
{
  switch (e.get_kind()) {
    case nop_expr_kind:
      os << "nop";
      return;
    case ref_expr_kind:
      return print(os, cast<ref_expr>(e).get_name());
    case obj_expr_kind:
      return print(os, cast<obj_expr>(e).get_source());
    case call_expr_kind:
      return print_call_expr(os, cast<call_expr>(e));
    default:
      break;
  }
  assert(false && "not a common expression");
}
Exemplo n.º 4
0
// Returns true when a and b are equivalent logical expressions.
void
hash_algo::operator()(hasher& h, const expr& e) const
{
  switch (e.get_kind()) {
    case bool_expr_kind:
      return hash_bool_expr(h, cast<bool_expr>(e));
    case and_expr_kind:
    case or_expr_kind:
    case imp_expr_kind:
    case eq_expr_kind:
      return hash_binary_expr(h, cast<binary_expr>(e));
    case not_expr_kind:
      return hash_unary_expr(h, cast<unary_expr>(e));
    default:
      break;
  }
  assert(false && "not a logical expression");
}
Exemplo n.º 5
0
// FIXME: This is incomplete.
void
print_algo::operator()(std::ostream& os, const expr& e) const
{
  switch (e.get_kind()) {
    case nop_expr_kind:
      os << "nop";
      return;
    case ref_expr_kind:
      return print(os, cast<ref_expr>(e).get_name());
    case call_expr_kind:
      return print_call_expr(os, cast<call_expr>(e));

    case zero_init_kind:
      return print_zero_init(os, cast<zero_init>(e));
    case copy_init_kind:
      return print_copy_init(os, cast<copy_init>(e));
    default:
      break;
  }
  assert(false && "not a core expression");
}