Automatic date update in version.in
[deliverable/binutils-gdb.git] / gdb / value.c
index 1d1e619accbf19d0d0fc46103d2938f8544064e8..9cd9a2fcc72717d32f94e5be3854c879fb694211 100644 (file)
@@ -1,6 +1,6 @@
 /* Low level packing and unpacking of values for GDB, the GNU Debugger.
 
-   Copyright (C) 1986-2017 Free Software Foundation, Inc.
+   Copyright (C) 1986-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -808,7 +808,7 @@ find_first_range_overlap_and_match (struct ranges_and_idx *rp1,
    with LENGTH bits of VAL2's contents starting at OFFSET2 bits.
    Return true if the available bits match.  */
 
-static int
+static bool
 value_contents_bits_eq (const struct value *val1, int offset1,
                        const struct value *val2, int offset2,
                        int length)
@@ -847,7 +847,7 @@ value_contents_bits_eq (const struct value *val1, int offset1,
          if (!find_first_range_overlap_and_match (&rp1[i], &rp2[i],
                                                   offset1, offset2, length,
                                                   &l_tmp, &h_tmp))
-           return 0;
+           return false;
 
          /* We're interested in the lowest/first range found.  */
          if (i == 0 || l_tmp < l)
@@ -860,17 +860,17 @@ value_contents_bits_eq (const struct value *val1, int offset1,
       /* Compare the available/valid contents.  */
       if (memcmp_with_bit_offsets (val1->contents, offset1,
                                   val2->contents, offset2, l) != 0)
-       return 0;
+       return false;
 
       length -= h;
       offset1 += h;
       offset2 += h;
     }
 
-  return 1;
+  return true;
 }
 
-int
+bool
 value_contents_eq (const struct value *val1, LONGEST offset1,
                   const struct value *val2, LONGEST offset2,
                   LONGEST length)
@@ -1627,7 +1627,7 @@ value_free (struct value *val)
            funcs->free_closure (val);
        }
       else if (VALUE_LVAL (val) == lval_xcallable)
-         free_xmethod_worker (val->location.xm_worker);
+         delete val->location.xm_worker;
 
       xfree (val->contents);
       VEC_free (range_s, val->unavailable);
@@ -2697,23 +2697,20 @@ show_convenience (const char *ignore, int from_tty)
     }
 }
 \f
-/* Return the TYPE_CODE_XMETHOD value corresponding to WORKER.  */
+
+/* See value.h.  */
 
 struct value *
-value_of_xmethod (struct xmethod_worker *worker)
+value_from_xmethod (xmethod_worker_up &&worker)
 {
-  if (worker->value == NULL)
-    {
-      struct value *v;
+  struct value *v;
 
-      v = allocate_value (builtin_type (target_gdbarch ())->xmethod);
-      v->lval = lval_xcallable;
-      v->location.xm_worker = worker;
-      v->modifiable = 0;
-      worker->value = v;
-    }
+  v = allocate_value (builtin_type (target_gdbarch ())->xmethod);
+  v->lval = lval_xcallable;
+  v->location.xm_worker = worker.release ();
+  v->modifiable = 0;
 
-  return worker->value;
+  return v;
 }
 
 /* Return the type of the result of TYPE_CODE_XMETHOD value METHOD.  */
@@ -2724,8 +2721,8 @@ result_type_of_xmethod (struct value *method, int argc, struct value **argv)
   gdb_assert (TYPE_CODE (value_type (method)) == TYPE_CODE_XMETHOD
              && method->lval == lval_xcallable && argc > 0);
 
-  return get_xmethod_result_type (method->location.xm_worker,
-                                 argv[0], argv + 1, argc - 1);
+  return method->location.xm_worker->get_result_type
+    (argv[0], argv + 1, argc - 1);
 }
 
 /* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value METHOD.  */
@@ -2736,8 +2733,7 @@ call_xmethod (struct value *method, int argc, struct value **argv)
   gdb_assert (TYPE_CODE (value_type (method)) == TYPE_CODE_XMETHOD
              && method->lval == lval_xcallable && argc > 0);
 
-  return invoke_xmethod (method->location.xm_worker,
-                        argv[0], argv + 1, argc - 1);
+  return method->location.xm_worker->invoke (argv[0], argv + 1, argc - 1);
 }
 \f
 /* Extract a value as a C number (either long or double).
@@ -2980,14 +2976,12 @@ value_static_field (struct type *type, int fieldno)
             reported as non-debuggable symbols.  */
          struct bound_minimal_symbol msym
            = lookup_minimal_symbol (phys_name, NULL, NULL);
+         struct type *field_type = TYPE_FIELD_TYPE (type, fieldno);
 
          if (!msym.minsym)
-           return allocate_optimized_out_value (type);
+           retval = allocate_optimized_out_value (field_type);
          else
-           {
-             retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),
-                                     BMSYMBOL_VALUE_ADDRESS (msym));
-           }
+           retval = value_at_lazy (field_type, BMSYMBOL_VALUE_ADDRESS (msym));
        }
       else
        retval = value_of_variable (sym.symbol, sym.block);
This page took 0.025338 seconds and 4 git commands to generate.