2010-12-01 Kai Tietz <kai.tietz@onevision.com>
[deliverable/binutils-gdb.git] / gdb / valops.c
index 07b62a165c7c7336324e04762c7d545ffb5ce736..e115b311302344f9d3d83dcd8332ec9df5d26ec5 100644 (file)
@@ -335,7 +335,7 @@ value_cast_pointers (struct type *type, struct value *arg2)
   /* 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;
 }
@@ -544,14 +544,17 @@ value_cast (struct type *type, struct value *arg2)
       /* Widen the scalar to a vector.  */
       struct type *eltype;
       struct value *val;
-      int i, n;
+      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);
-      n = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
 
-      for (i = 0; i < n; i++)
+      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)),
@@ -566,7 +569,7 @@ value_cast (struct type *type, struct value *arg2)
 
       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;
     }
@@ -871,6 +874,20 @@ value_one (struct type *type, enum lval_type lv)
     {
       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."));
@@ -1122,11 +1139,9 @@ value_assign (struct value *toval, struct value *fromval)
     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:
@@ -1317,8 +1332,7 @@ value_assign (struct value *toval, struct value *fromval)
   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));
 
@@ -1566,7 +1580,8 @@ value_addr (struct value *arg1)
 
   /* 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));
@@ -1603,6 +1618,19 @@ value_ind (struct value *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;
@@ -1627,7 +1655,7 @@ value_ind (struct value *arg1)
       /* 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.  */
@@ -2888,7 +2916,7 @@ find_oload_champ (struct type **arg_types, int nargs, int method,
          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);
@@ -2922,9 +2950,15 @@ classify_oload_match (struct badness_vector *oload_champ_bv,
 
   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.  */
     }
@@ -3060,9 +3094,9 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial)
 
       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;
        }
 
@@ -3390,7 +3424,8 @@ value_full_object (struct value *argp,
   /* 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;
     }
 
This page took 0.027518 seconds and 4 git commands to generate.