Expr* admit_call_expr(Context& cxt, Usage& c, Call_expr& e) { Call_expr& a = cast<Call_expr>(c.expression()); // Build the list of parameter types from the declared types // of operands in the constraint. Type_list ts {&declared_type(a.function())}; for (Expr& e0 : a.arguments()) ts.push_back(declared_type(e0)); // Build the list of arguments from e. Note that the first // argument is actually the function. Expr_list es {&e.function()}; for (Expr& e0 : e.arguments()) es.push_back(e0); // If conversion fails, this is not accessible. try { initialize_parameters(cxt, ts, es); } catch (Translation_error&) { return nullptr; } // Adjust the type and admit the expression. e.type_ = &a.type(); return &e; }
// Returns a tuple type with each of it element types qualified by q. static inline Type& qual_tuple_type(Builder& b, Tuple_type& t, Qualifier_set q) { Type_list elems; for (Type& elem : t.element_types()) elems.push_back(b.get_qualified_type(elem, q)); return b.get_tuple_type(t.category(), std::move(elems)); }
// Parse a type list. // // type-list: // type // type-list ',' type Type_list Parser::type_list() { Type_list types; types.push_back(type()); while (match_if(comma_tok)) types.push_back(type()); return types; }
Function_type& Builder::get_function_type(Decl_list const& ps, Type& r) { Type_list ts; for (Decl& d : *modify(&ps)) { Object_parm& p = cast<Object_parm>(d); ts.push_back(p.type()); } return get_function_type(ts, r); }
// Build and declare the function or method. A method is a non-static // function declared in class scope. Decl& Parser::start_function_declaration(Name& n, Decl_list& ps, Type& t) { // Form the (initial) function type. Type_list ts; for (Decl& p : ps) ts.push_back(cast<Typed_decl>(p).type()); Type& ft = cxt.get_function_type(std::move(ts), t); // Generate the declaration. Decl* d; if (parsing_nonstatic_member()) d = &cxt.make_method_declaration(n, ft, ps); else d = &cxt.make_function_declaration(n, ft, ps); d->spec_ = take_decl_specs(); declare(cxt, *d); return *d; }