Turn allocate_value_lazy into a static "constructor"

This changes allocate_value_lazy to be a static "constructor" of
struct value.

I considered trying to change value to use ordinary new/delete, but it
seems to me that due to reference counting, we may someday want to
change these static constructors to return value_ref_ptr instead.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey
2023-01-31 13:24:00 -07:00
parent f29de66504
commit cbe793af88
6 changed files with 29 additions and 21 deletions

View File

@ -144,6 +144,9 @@ typedef gdb::ref_ptr<struct value, value_ref_policy> value_ref_ptr;
struct value
{
private:
/* Values can only be created via "static constructors". */
explicit value (struct type *type_)
: m_modifiable (1),
m_lazy (1),
@ -156,6 +159,13 @@ struct value
{
}
public:
/* Allocate a lazy value for type TYPE. Its actual content is
"lazily" allocated too: the content field of the return value is
NULL; it will be allocated when it is fetched from the target. */
static struct value *allocate_lazy (struct type *type);
~value ();
DISABLE_COPY_AND_ASSIGN (value);
@ -1002,7 +1012,7 @@ extern struct value *read_var_value (struct symbol *var,
frame_info_ptr frame);
extern struct value *allocate_value (struct type *type);
extern struct value *allocate_value_lazy (struct type *type);
extern void value_contents_copy (struct value *dst, LONGEST dst_offset,
struct value *src, LONGEST src_offset,
LONGEST length);