+2019-03-07 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * f-lang.c (value_from_host_double): Moved to...
+ * value.c (value_from_host_double): ...here.
+ * value.h (value_from_host_double): Declare.
+ * guile/scm-math.c (vlscm_convert_typed_number): Use
+ value_from_host_double.
+ (vlscm_convert_number): Likewise.
+ * guile/scm-value.c (gdbscm_value_to_real): Likewise.
+ * python/py-value.c (convert_value_from_python): Likewise.
+
2019-03-06 Tom Tromey <tom@tromey.com>
* gcore.c (write_gcore_file): Use SCOPE_EXIT.
text, word, ":", code);
}
-/* Create and return a value object of TYPE containing the value D. The
- TYPE must be of TYPE_CODE_FLT, and must be large enough to hold D once
- it is converted to target format. */
-
-static struct value *
-value_from_host_double (struct type *type, double d)
-{
- struct value *value = allocate_value (type);
- gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
- target_float_from_host_double (value_contents_raw (value),
- value_type (value), d);
- return value;
-}
-
/* Special expression evaluation cases for Fortran. */
struct value *
evaluate_subexp_f (struct type *expect_type, struct expression *exp,
}
}
else if (TYPE_CODE (type) == TYPE_CODE_FLT)
- {
- struct value *value = allocate_value (type);
- target_float_from_host_double (value_contents_raw (value),
- value_type (value),
- scm_to_double (obj));
- return value;
- }
+ return value_from_host_double (type, scm_to_double (obj));
else
{
*except_scmp = gdbscm_make_type_error (func_name, obj_arg_pos, obj,
gdbscm_scm_to_ulongest (obj));
}
else if (scm_is_real (obj))
- {
- struct value *value = allocate_value (bt->builtin_double);
- target_float_from_host_double (value_contents_raw (value),
- value_type (value),
- scm_to_double (obj));
- return value;
- }
+ return value_from_host_double (bt->builtin_double, scm_to_double (obj));
*except_scmp = gdbscm_make_out_of_range_error (func_name, obj_arg_pos, obj,
_("value not a number representable on the target"));
if (is_floating_value (value))
{
d = target_float_to_host_double (value_contents (value), type);
- check = allocate_value (type);
- target_float_from_host_double (value_contents_raw (check), type, d);
+ check = value_from_host_double (type, d);
}
else if (TYPE_UNSIGNED (type))
{
double d = PyFloat_AsDouble (obj);
if (! PyErr_Occurred ())
- {
- value = allocate_value (builtin_type_pyfloat);
- target_float_from_host_double (value_contents_raw (value),
- value_type (value), d);
- }
+ value = value_from_host_double (builtin_type_pyfloat, d);
}
else if (gdbpy_is_string (obj))
{
return val;
}
+/* Create and return a value object of TYPE containing the value D. The
+ TYPE must be of TYPE_CODE_FLT, and must be large enough to hold D once
+ it is converted to target format. */
+
+struct value *
+value_from_host_double (struct type *type, double d)
+{
+ struct value *value = allocate_value (type);
+ gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
+ target_float_from_host_double (value_contents_raw (value),
+ value_type (value), d);
+ return value;
+}
/* Create a value of type TYPE whose contents come from VALADDR, if it
is non-null, and whose memory address (in the inferior) is
extern struct value *value_from_longest (struct type *type, LONGEST num);
extern struct value *value_from_ulongest (struct type *type, ULONGEST num);
extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
+extern struct value *value_from_host_double (struct type *type, double d);
extern struct value *value_from_history_ref (const char *, const char **);
extern struct value *value_from_component (struct value *, struct type *,
LONGEST);