/* Perform non-arithmetic operations on values, for GDB.
- Copyright (C) 1986-2017 Free Software Foundation, Inc.
+ Copyright (C) 1986-2018 Free Software Foundation, Inc.
This file is part of GDB.
#include "infcall.h"
#include "dictionary.h"
#include "cp-support.h"
-#include "dfp.h"
+#include "target-float.h"
#include "tracepoint.h"
#include "observer.h"
#include "objfiles.h"
const int no_adl);
static int find_oload_champ (struct value **, int, int,
- struct fn_field *, VEC (xmethod_worker_ptr) *,
+ struct fn_field *,
+ const std::vector<xmethod_worker_up> *,
struct symbol **, struct badness_vector **);
static int oload_method_static_p (struct fn_field *, int);
static void find_method_list (struct value **, const char *,
LONGEST, struct type *, struct fn_field **, int *,
- VEC (xmethod_worker_ptr) **,
+ std::vector<xmethod_worker_up> *,
struct type **, LONGEST *);
-void _initialize_valops (void);
-
#if 0
/* Flag for whether we want to abandon failed expression evals by
default. */
struct value *blocklen;
blocklen = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
- val = call_function_by_hand (val, 1, &blocklen);
+ val = call_function_by_hand (val, NULL, 1, &blocklen);
if (value_logical_not (val))
{
if (!target_has_execution)
return v;
}
- if (code1 == TYPE_CODE_FLT && scalar)
- return value_from_double (to_type, value_as_double (arg2));
- else if (code1 == TYPE_CODE_DECFLOAT && scalar)
+ if (is_floating_type (type) && scalar)
{
- enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
- int dec_len = TYPE_LENGTH (type);
- gdb_byte dec[16];
+ if (is_floating_value (arg2))
+ {
+ struct value *v = allocate_value (to_type);
+ target_float_convert (value_contents (arg2), type2,
+ value_contents_raw (v), type);
+ return v;
+ }
- if (code2 == TYPE_CODE_FLT)
- decimal_from_floating (arg2, dec, dec_len, byte_order);
- else if (code2 == TYPE_CODE_DECFLOAT)
- decimal_convert (value_contents (arg2), TYPE_LENGTH (type2),
- byte_order, dec, dec_len, byte_order);
+ /* The only option left is an integral type. */
+ if (TYPE_UNSIGNED (type2))
+ return value_from_ulongest (to_type, value_as_long (arg2));
else
- /* The only option left is an integral type. */
- decimal_from_integral (arg2, dec, dec_len, byte_order);
-
- return value_from_decfloat (to_type, dec);
+ return value_from_longest (to_type, value_as_long (arg2));
}
else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM
|| code1 == TYPE_CODE_RANGE)
struct type *type1 = check_typedef (type);
struct value *val;
- if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
- {
- enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
- gdb_byte v[16];
-
- decimal_from_string (v, TYPE_LENGTH (type), byte_order, "1");
- val = value_from_decfloat (type, v);
- }
- else if (TYPE_CODE (type1) == TYPE_CODE_FLT)
- {
- val = value_from_double (type, (DOUBLEST) 1);
- }
- else if (is_integral_type (type1))
+ if (is_integral_type (type1) || is_floating_type (type1))
{
val = value_from_longest (type, (LONGEST) 1);
}
find_method_list (struct value **argp, const char *method,
LONGEST offset, struct type *type,
struct fn_field **fn_list, int *num_fns,
- VEC (xmethod_worker_ptr) **xm_worker_vec,
+ std::vector<xmethod_worker_up> *xm_worker_vec,
struct type **basetype, LONGEST *boffset)
{
int i;
struct fn_field *f = NULL;
- VEC (xmethod_worker_ptr) *worker_vec = NULL, *new_vec = NULL;
gdb_assert (fn_list != NULL && xm_worker_vec != NULL);
type = check_typedef (type);
and hence there is no point restricting them with something like method
hiding. Moreover, if hiding is done for xmethods as well, then we will
have to provide a mechanism to un-hide (like the 'using' construct). */
- worker_vec = get_matching_xmethod_workers (type, method);
- new_vec = VEC_merge (xmethod_worker_ptr, *xm_worker_vec, worker_vec);
-
- VEC_free (xmethod_worker_ptr, *xm_worker_vec);
- VEC_free (xmethod_worker_ptr, worker_vec);
- *xm_worker_vec = new_vec;
+ get_matching_xmethod_workers (type, method, xm_worker_vec);
/* If source methods are not found in current class, look for them in the
base classes. We also have to go through the base classes to gather
value_find_oload_method_list (struct value **argp, const char *method,
LONGEST offset, struct fn_field **fn_list,
int *num_fns,
- VEC (xmethod_worker_ptr) **xm_worker_vec,
+ std::vector<xmethod_worker_up> *xm_worker_vec,
struct type **basetype, LONGEST *boffset)
{
struct type *t;
/* Clear the lists. */
*fn_list = NULL;
*num_fns = 0;
- *xm_worker_vec = NULL;
+ xm_worker_vec->clear ();
find_method_list (argp, method, 0, t, fn_list, num_fns, xm_worker_vec,
basetype, boffset);
struct fn_field *fns_ptr = NULL;
/* For non-methods, the list of overloaded function symbols. */
struct symbol **oload_syms = NULL;
- /* For xmethods, the VEC of xmethod workers. */
- VEC (xmethod_worker_ptr) *xm_worker_vec = NULL;
+ /* For xmethods, the vector of xmethod workers. */
+ std::vector<xmethod_worker_up> xm_worker_vec;
/* Number of overloaded instances being considered. */
int num_fns = 0;
struct type *basetype = NULL;
value_find_oload_method_list (&temp, name, 0, &fns_ptr, &num_fns,
&xm_worker_vec, &basetype, &boffset);
/* If this is a method only search, and no methods were found
- the search has faild. */
- if (method == METHOD && (!fns_ptr || !num_fns) && !xm_worker_vec)
+ the search has failed. */
+ if (method == METHOD && (!fns_ptr || !num_fns) && xm_worker_vec.empty ())
error (_("Couldn't find method %s%s%s"),
obj_type_name,
(obj_type_name && *obj_type_name) ? "::" : "",
make_cleanup (xfree, src_method_badness);
}
- if (VEC_length (xmethod_worker_ptr, xm_worker_vec) > 0)
+ if (!xm_worker_vec.empty ())
{
ext_method_oload_champ = find_oload_champ (args, nargs,
- 0, NULL, xm_worker_vec,
+ 0, NULL, &xm_worker_vec,
NULL, &ext_method_badness);
ext_method_match_quality = classify_oload_match (ext_method_badness,
nargs, 0);
make_cleanup (xfree, ext_method_badness);
- make_cleanup (free_xmethod_worker_vec, xm_worker_vec);
}
if (src_method_oload_champ >= 0 && ext_method_oload_champ >= 0)
basetype, boffset);
}
else
- {
- *valp = value_of_xmethod (clone_xmethod_worker
- (VEC_index (xmethod_worker_ptr, xm_worker_vec,
- ext_method_oload_champ)));
- }
+ *valp = value_from_xmethod
+ (std::move (xm_worker_vec[ext_method_oload_champ]));
}
else
*symp = oload_syms[func_oload_champ];
static int
find_oload_champ (struct value **args, int nargs,
int num_fns, struct fn_field *fns_ptr,
- VEC (xmethod_worker_ptr) *xm_worker_vec,
+ const std::vector<xmethod_worker_up> *xm_worker_vec,
struct symbol **oload_syms,
struct badness_vector **oload_champ_bv)
{
int ix;
- int fn_count;
/* A measure of how good an overloaded instance is. */
struct badness_vector *bv;
/* Index of best overloaded function. */
*oload_champ_bv = NULL;
- fn_count = (xm_worker_vec != NULL
- ? VEC_length (xmethod_worker_ptr, xm_worker_vec)
- : num_fns);
+ int fn_count = xm_worker_vec != NULL ? xm_worker_vec->size () : num_fns;
+
/* Consider each candidate in turn. */
for (ix = 0; ix < fn_count; ix++)
{
int static_offset = 0;
int nparms;
struct type **parm_types;
- struct xmethod_worker *worker = NULL;
if (xm_worker_vec != NULL)
{
- worker = VEC_index (xmethod_worker_ptr, xm_worker_vec, ix);
- parm_types = get_xmethod_arg_types (worker, &nparms);
+ xmethod_worker *worker = (*xm_worker_vec)[ix].get ();
+ parm_types = worker->get_arg_types (&nparms);
}
else
{
{
for (j = 0; j < len; ++j)
{
+ if (TYPE_CONST (intype) != TYPE_FN_FIELD_CONST (f, j))
+ continue;
+ if (TYPE_VOLATILE (intype) != TYPE_FN_FIELD_VOLATILE (f, j))
+ continue;
+
if (compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype, 0)
|| compare_parameters (TYPE_FN_FIELD_TYPE (f, j),
intype, 1))