Beispiel #1
0
void
test_basics(Context& cxt)
{
  std::cout << "--- basics ---\n";

  Builder build(cxt);
  {
    Enter_template_parameter_scope scope(cxt);
    lingo_assert(cxt.current_template_level() == 0);
    lingo_assert(cxt.current_template_index() == -1);

    Type_parm& p1 = build.make_type_parameter("T");
    lingo_assert(cxt.current_template_index() == 0);

    Type_parm& p2 = build.make_type_parameter("U");
    lingo_assert(cxt.current_template_index() == 1);

    Value_parm& p3 = build.make_value_parm("N", build.get_int_type());
    lingo_assert(cxt.current_template_index() == 2);

    Decl& var = build.make_variable("v1", build.get_typename_type(p1));
    Decl& tmp = build.make_template({&p1, &p2, &p3}, var);
    std::cout << tmp << '\n';
  }

  // {
  //   Type_parm& p = build.make_type_parameter("T");
  //   Decl& var = build.make_variable("v2", build.get_typename_type(p));
  //   Template_decl& tmp = build.make_template({&p}, var);
  //   tmp.constrain(build.get_true());
  //   std::cout << tmp << '\n';
  // }
}
Beispiel #2
0
// Determine if the qualification signature a can be converted
// to b. This is the case when...
//
// TODO: Document me. This is [conv.qual]/p3.2-3.
bool
can_convert_signature(Qualifier_list const& a, Qualifier_list const& b)
{
  lingo_assert(a.size() == b.size());
  std::size_t n = 0;
  for (std::size_t i = 1; i < a.size(); ++i) {
    // If const is in a, then const must be in b.
    if (has_const(a[i]) && !has_const(b[i]))
      return false;

    // And similarly for volatile.
    if (has_volatile(a[i]) && !has_volatile(b[i]))
      return false;

    // If the qualifiers differ, then each qualifier 0 < k < i
    // must have const. There could be many differences.
    // Save the furthest in the chain and check after later.
    if (a[i] != b[i])
      n = i;
  }

  // Check for const propagation in differing signatures.
  for (std::size_t k = 1; k < n; ++k) {
    if (!has_const(b[k]))
      return false;
  }

  return true;
}
Beispiel #3
0
inline void
Standard_conversion_seq::adjustment(Conv& e)
{
  lingo_assert(!adjust);
  adjust = &e;
}
Beispiel #4
0
inline void
Standard_conversion_seq::conversion(Conv& e)
{
  lingo_assert(!conv);
  conv = &e;
}
Beispiel #5
0
inline void
Standard_conversion_seq::transformation(Conv& e)
{
  lingo_assert(!xform);
  xform = &e;
}
Beispiel #6
0
// Returns a simple identifier for the given symbol.
Simple_id&
Builder::get_id(Symbol const& sym)
{
  lingo_assert(is<Identifier_sym>(&sym));
  return make<Simple_id>(sym);
}
Beispiel #7
0
Variable_decl&
Builder::make_variable(Name& n, Type& t, Expr& i)
{
  lingo_assert(is<Init>(&i));
  return make<Variable_decl>(n, t, i);
}
Beispiel #8
0
Integer_type&
Builder::get_integer_type(Type_category c, bool s, int p, Qualifier_set q)
{
  lingo_assert(c != function_type);
  return Integer_type::make(alloc_, c, s, p, q);
}
Beispiel #9
0
Byte_type&
Builder::get_byte_type(Type_category c, Qualifier_set q)
{
  lingo_assert(c != function_type);
  return Byte_type::make(alloc_, c, q);
}
Beispiel #10
0
// FIXME: Guarantee that the start and end lines are the same.
Line const&
Region::line() const
{
  lingo_assert(!is_multiline());
  return buf_->lines().line(start_);
}
Beispiel #11
0
Function_decl::Function_decl(Location loc, String const* n, Type const* t, Decl_seq const& a, Stmt const* b)
  : Decl(loc, n, t), first(a), second(b)
{ 
  lingo_assert(is<Function_type>(t));
}