#include "observer.h"
#include "objfiles.h"
#include "symtab.h"
+#include "exceptions.h"
extern int overload_debug;
/* Local functions. */
/* No superclass found, just change the pointer type. */
arg2 = value_copy (arg2);
deprecated_set_value_type (arg2, type);
- arg2 = value_change_enclosing_type (arg2, type);
+ set_value_enclosing_type (arg2, type);
set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */
return arg2;
}
}
if (current_language->c_style_arrays
- && TYPE_CODE (type2) == TYPE_CODE_ARRAY)
+ && TYPE_CODE (type2) == TYPE_CODE_ARRAY
+ && !TYPE_VECTOR (type2))
arg2 = value_coerce_array (arg2);
if (TYPE_CODE (type2) == TYPE_CODE_FUNC)
minus one, instead of biasing the normal case. */
return value_from_longest (type, -1);
}
+ else if (code1 == TYPE_CODE_ARRAY && TYPE_VECTOR (type) && scalar)
+ {
+ /* Widen the scalar to a vector. */
+ struct type *eltype;
+ struct value *val;
+ LONGEST low_bound, high_bound;
+ int i;
+
+ if (!get_array_bounds (type, &low_bound, &high_bound))
+ error (_("Could not determine the vector bounds"));
+
+ eltype = check_typedef (TYPE_TARGET_TYPE (type));
+ arg2 = value_cast (eltype, arg2);
+ val = allocate_value (type);
+
+ for (i = 0; i < high_bound - low_bound + 1; i++)
+ {
+ /* Duplicate the contents of arg2 into the destination vector. */
+ memcpy (value_contents_writeable (val) + (i * TYPE_LENGTH (eltype)),
+ value_contents_all (arg2), TYPE_LENGTH (eltype));
+ }
+ return val;
+ }
else if (TYPE_LENGTH (type) == TYPE_LENGTH (type2))
{
if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)
arg2 = value_copy (arg2);
deprecated_set_value_type (arg2, type);
- arg2 = value_change_enclosing_type (arg2, type);
+ set_value_enclosing_type (arg2, type);
set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */
return arg2;
}
{
val = value_from_longest (type, (LONGEST) 1);
}
+ else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+ {
+ struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type1));
+ int i, n = TYPE_LENGTH (type1) / TYPE_LENGTH (eltype);
+ struct value *tmp;
+
+ val = allocate_value (type);
+ for (i = 0; i < n; i++)
+ {
+ tmp = value_one (eltype, lv);
+ memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype),
+ value_contents_all (tmp), TYPE_LENGTH (eltype));
+ }
+ }
else
{
error (_("Not a numeric type."));
struct value *parent = value_parent (val);
LONGEST offset = value_offset (val);
LONGEST num = unpack_bits_as_long (value_type (val),
- value_contents (parent) + offset,
+ (value_contents_for_printing (parent)
+ + offset),
value_bitpos (val),
value_bitsize (val));
int length = TYPE_LENGTH (type);
+ if (!value_bits_valid (val,
+ TARGET_CHAR_BIT * offset + value_bitpos (val),
+ value_bitsize (val)))
+ error (_("value has been optimized out"));
+
store_signed_integer (value_contents_raw (val), length, byte_order, num);
}
else if (VALUE_LVAL (val) == lval_memory)
type = value_type (toval);
if (VALUE_LVAL (toval) != lval_internalvar)
- {
- toval = value_coerce_to_target (toval);
- fromval = value_cast (type, fromval);
- }
+ fromval = value_cast (type, fromval);
else
{
/* Coerce arrays and functions to pointers, except for arrays
case lval_internalvar:
set_internalvar (VALUE_INTERNALVAR (toval), fromval);
val = value_copy (fromval);
- val = value_change_enclosing_type (val,
- value_enclosing_type (fromval));
+ set_value_enclosing_type (val, value_enclosing_type (fromval));
set_value_embedded_offset (val, value_embedded_offset (fromval));
- set_value_pointed_to_offset (val,
- value_pointed_to_offset (fromval));
+ set_value_pointed_to_offset (val, value_pointed_to_offset (fromval));
return val;
case lval_internalvar_component:
{
case lval_memory:
case lval_register:
+ case lval_computed:
reinit_frame_cache ();
memcpy (value_contents_raw (val), value_contents (fromval),
TYPE_LENGTH (type));
deprecated_set_value_type (val, type);
- val = value_change_enclosing_type (val,
- value_enclosing_type (fromval));
+ set_value_enclosing_type (val, value_enclosing_type (fromval));
set_value_embedded_offset (val, value_embedded_offset (fromval));
set_value_pointed_to_offset (val, value_pointed_to_offset (fromval));
switch (TYPE_CODE (valtype))
{
case TYPE_CODE_ARRAY:
+ return TYPE_VECTOR (valtype) ? 0 : 1;
case TYPE_CODE_STRING:
return 1;
default:
/* This may be a pointer to a base subobject; so remember the
full derived object's type ... */
- arg2 = value_change_enclosing_type (arg2, lookup_pointer_type (value_enclosing_type (arg1)));
+ set_value_enclosing_type (arg2,
+ lookup_pointer_type (value_enclosing_type (arg1)));
/* ... and also the relative position of the subobject in the full
object. */
set_value_pointed_to_offset (arg2, value_embedded_offset (arg1));
base_type = check_typedef (value_type (arg1));
+ if (VALUE_LVAL (arg1) == lval_computed)
+ {
+ struct lval_funcs *funcs = value_computed_funcs (arg1);
+
+ if (funcs->indirect)
+ {
+ struct value *result = funcs->indirect (arg1);
+
+ if (result)
+ return result;
+ }
+ }
+
if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
{
struct type *enc_type;
/* Re-adjust type. */
deprecated_set_value_type (arg2, TYPE_TARGET_TYPE (base_type));
/* Add embedding info. */
- arg2 = value_change_enclosing_type (arg2, enc_type);
+ set_value_enclosing_type (arg2, enc_type);
set_value_embedded_offset (arg2, value_pointed_to_offset (arg1));
/* We may be pointing to an object of some derived type. */
{
v = value_static_field (type, i);
if (v == 0)
- error (_("field %s is nonexistent or has been optimised out"),
+ error (_("field %s is nonexistent or has been optimized out"),
name);
}
else
}
if (!v)
- error (_("Structure has no component named %s."), name);
+ throw_error (NOT_FOUND_ERROR,
+ _("Structure has no component named %s."), name);
return v;
}
/* Did we find a match ? */
if (method_oload_champ == -1 && func_oload_champ == -1)
- error (_("No symbol \"%s\" in current context."), name);
+ throw_error (NOT_FOUND_ERROR,
+ _("No symbol \"%s\" in current context."),
+ name);
/* If we have found both a method match and a function
match, find out which one is better, and calculate match
function symbol to start off with.) */
old_cleanups = make_cleanup (xfree, *oload_syms);
- old_cleanups = make_cleanup (xfree, *oload_champ_bv);
+ make_cleanup (xfree, *oload_champ_bv);
new_namespace = alloca (namespace_len + 1);
strncpy (new_namespace, qualified_name, namespace_len);
new_namespace[namespace_len] = '\0';
*oload_syms = new_oload_syms;
*oload_champ = new_oload_champ;
*oload_champ_bv = new_oload_champ_bv;
- discard_cleanups (old_cleanups);
+ do_cleanups (old_cleanups);
return 0;
}
}
for (jj = 0; jj < nargs - static_offset; jj++)
fprintf_filtered (gdb_stderr,
"...Badness @ %d : %d\n",
- jj, bv->rank[jj]);
+ jj, bv->rank[jj].rank);
fprintf_filtered (gdb_stderr,
"Overload resolution champion is %d, ambiguous? %d\n",
oload_champ, oload_ambiguous);
for (ix = 1; ix <= nargs - static_offset; ix++)
{
- if (oload_champ_bv->rank[ix] >= 100)
+ /* If this conversion is as bad as INCOMPATIBLE_TYPE_BADNESS
+ or worse return INCOMPATIBLE. */
+ if (compare_ranks (oload_champ_bv->rank[ix],
+ INCOMPATIBLE_TYPE_BADNESS) <= 0)
return INCOMPATIBLE; /* Truly mismatched types. */
- else if (oload_champ_bv->rank[ix] >= 10)
+ /* Otherwise If this conversion is as bad as
+ NS_POINTER_CONVERSION_BADNESS or worse return NON_STANDARD. */
+ else if (compare_ranks (oload_champ_bv->rank[ix],
+ NS_POINTER_CONVERSION_BADNESS) <= 0)
return NON_STANDARD; /* Non-standard type conversions
needed. */
}
for (i = 0; i < TYPE_NFIELDS (t2); ++i)
{
- if (rank_one_type (TYPE_FIELD_TYPE (t1, start + i),
- TYPE_FIELD_TYPE (t2, i))
- != 0)
+ if (compare_ranks (rank_one_type (TYPE_FIELD_TYPE (t1, start + i),
+ TYPE_FIELD_TYPE (t2, i)),
+ EXACT_MATCH_BADNESS) != 0)
return 0;
}
struct value *result;
sym = cp_lookup_symbol_namespace (namespace_name, name,
- get_selected_block (0),
- VAR_DOMAIN);
+ get_selected_block (0), VAR_DOMAIN);
+
+ if (sym == NULL)
+ {
+ char *concatenated_name = alloca (strlen (namespace_name) + 2
+ + strlen (name) + 1);
+
+ sprintf (concatenated_name, "%s::%s", namespace_name, name);
+ sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
+ }
if (sym == NULL)
return NULL;
/* pai: FIXME -- sounds iffy */
if (full)
{
- argp = value_change_enclosing_type (argp, real_type);
+ argp = value_copy (argp);
+ set_value_enclosing_type (argp, real_type);
return argp;
}