(struct type *expect_type, struct expression *exp, enum noside noside,
const std::vector<operation_up> &args)
{
- /* Allocate space for the function call arguments. Include space for a
- `this' pointer at the start, and a trailing nullptr. */
- std::vector<value *> vals (args.size () + 2);
+ /* Allocate space for the function call arguments, Including space for a
+ `this' pointer at the start. */
+ std::vector<value *> vals (args.size () + 1);
/* First, evaluate the structure into vals[0]. */
enum exp_opcode op = opcode ();
if (op == STRUCTOP_STRUCT)
}
}
- /* Evaluate the arguments, and add the trailing nullptr. The '+ 1' here
- is to allow for the `this' pointer we placed into vals[0]. */
+ /* Evaluate the arguments. The '+ 1' here is to allow for the `this'
+ pointer we placed into vals[0]. */
for (int i = 0; i < args.size (); ++i)
vals[i + 1] = args[i]->evaluate_with_coercion (exp, noside);
- vals[args.size () + 1] = nullptr;
- /* The array view includes the `this' pointer, but not the trailing
- nullptr. */
- gdb::array_view<value *> arg_view
- = gdb::make_array_view (&vals[0], args.size () + 1);
+ /* The array view includes the `this' pointer. */
+ gdb::array_view<value *> arg_view (vals);
int static_memfuncp;
value *callee;
{
struct value *temp = vals[0];
- callee = value_struct_elt (&temp, &vals[0], tstr,
+ callee = value_struct_elt (&temp, &arg_view, tstr,
&static_memfuncp,
op == STRUCTOP_STRUCT
? "structure" : "structure pointer");
/* Local functions. */
-static int typecmp (int staticp, int varargs, int nargs,
- struct field t1[], struct value *t2[]);
+static int typecmp (bool staticp, bool varargs, int nargs,
+ struct field t1[], const gdb::array_view<value *> t2);
static struct value *search_struct_field (const char *, struct value *,
struct type *, int);
static struct value *search_struct_method (const char *, struct value **,
- struct value **,
+ gdb::array_view<value *> *,
LONGEST, int *, struct type *);
static int find_oload_champ_namespace (gdb::array_view<value *> args,
}
\f
-/* See if we can pass arguments in T2 to a function which takes
- arguments of types T1. T1 is a list of NARGS arguments, and T2 is
- a NULL-terminated vector. If some arguments need coercion of some
- sort, then the coerced values are written into T2. Return value is
+/* See if we can pass arguments in T2 to a function which takes arguments
+ of types T1. T1 is a list of NARGS arguments, and T2 is an array_view
+ of the values we're trying to pass. If some arguments need coercion of
+ some sort, then the coerced values are written into T2. Return value is
0 if the arguments could be matched, or the position at which they
differ if not.
STATICP is nonzero if the T1 argument list came from a static
- member function. T2 will still include the ``this'' pointer, but
+ member function. T2 must still include the ``this'' pointer, but
it will be skipped.
For non-static member functions, we ignore the first argument,
requested operation is type secure, shouldn't we? FIXME. */
static int
-typecmp (int staticp, int varargs, int nargs,
- struct field t1[], struct value *t2[])
+typecmp (bool staticp, bool varargs, int nargs,
+ struct field t1[], gdb::array_view<value *> t2)
{
int i;
- if (t2 == 0)
- internal_error (__FILE__, __LINE__,
- _("typecmp: no argument list"));
-
/* Skip ``this'' argument if applicable. T2 will always include
THIS. */
if (staticp)
- t2 ++;
+ t2 = t2.slice (1);
for (i = 0;
(i < nargs) && t1[i].type ()->code () != TYPE_CODE_VOID;
{
struct type *tt1, *tt2;
- if (!t2[i])
+ if (i == t2.size ())
return i + 1;
tt1 = check_typedef (t1[i].type ());
if (t1[i].type ()->code () != value_type (t2[i])->code ())
return i + 1;
}
- if (varargs || t2[i] == NULL)
+ if (varargs || i == t2.size ())
return 0;
return i + 1;
}
ARG1 by OFFSET bytes, and search in it assuming it has (class) type
TYPE.
- The ARGS array is a list of argument values used to help finding NAME,
- though ARGS can be nullptr. If ARGS is not nullptr then the list itself
- must have a NULL at the end.
+ The ARGS array pointer is to a list of argument values used to help
+ finding NAME, though ARGS can be nullptr. The contents of ARGS can be
+ adjusted if type coercion is required in order to find a matching NAME.
If found, return value, else if name matched and args not return
(value) -1, else return NULL. */
static struct value *
search_struct_method (const char *name, struct value **arg1p,
- struct value **args, LONGEST offset,
+ gdb::array_view<value *> *args, LONGEST offset,
int *static_memfuncp, struct type *type)
{
int i;
name_matched = 1;
check_stub_method_group (type, i);
- if (j > 0 && args == 0)
+ if (j > 0 && args == nullptr)
error (_("cannot resolve overloaded method "
"`%s': no arguments supplied"), name);
- else if (j == 0 && args == 0)
+ else if (j == 0 && args == nullptr)
{
v = value_fn_field (arg1p, f, j, type, offset);
if (v != NULL)
else
while (j >= 0)
{
+ gdb_assert (args != nullptr);
if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j),
TYPE_FN_FIELD_TYPE (f, j)->has_varargs (),
TYPE_FN_FIELD_TYPE (f, j)->num_fields (),
- TYPE_FN_FIELD_ARGS (f, j), args))
+ TYPE_FN_FIELD_ARGS (f, j), *args))
{
if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
return value_virtual_fn_field (arg1p, f, j,
ERR is used in the error message if *ARGP's type is wrong.
C++: ARGS is a list of argument types to aid in the selection of
- an appropriate method. Also, handle derived types. The array ARGS must
- have a NULL at the end.
+ an appropriate method. Also, handle derived types.
STATIC_MEMFUNCP, if non-NULL, points to a caller-supplied location
where the truthvalue of whether the function that was resolved was
found. */
struct value *
-value_struct_elt (struct value **argp, struct value **args,
+value_struct_elt (struct value **argp, gdb::array_view<value *> *args,
const char *name, int *static_memfuncp, const char *err)
{
struct type *t;
if (static_memfuncp)
*static_memfuncp = 0;
- if (!args)
+ if (args == nullptr)
{
/* if there are no arguments ...do this... */
/* C++: If it was not found as a data field, then try to
return it as a pointer to a method. */
- v = search_struct_method (name, argp, args, 0,
+ v = search_struct_method (name, argp, args, 0,
static_memfuncp, t);
if (v == (struct value *) - 1)
return v;
}
- v = search_struct_method (name, argp, args, 0,
+ v = search_struct_method (name, argp, args, 0,
static_memfuncp, t);
-
+
if (v == (struct value *) - 1)
{
error (_("One of the arguments you tried to pass to %s could not "