symbol_name_matcher_ftype *name_match
= ada_get_symbol_name_matcher (lookup_name);
- for (renaming = block_using (block);
+ for (renaming = block->get_using ();
renaming != NULL;
renaming = renaming->next)
{
/* Now come some functions designed to deal with C++ namespace issues.
The accessors are safe to use even in the non-C++ case. */
-/* This returns the namespace that BLOCK is enclosed in, or "" if it
- isn't enclosed in a namespace at all. This travels the chain of
- superblocks looking for a scope, if necessary. */
+/* See block.h. */
const char *
-block_scope (const struct block *block)
+block::scope () const
{
- for (; block != NULL; block = block->superblock ())
+ for (const block *block = this;
+ block != nullptr;
+ block = block->superblock ())
{
- if (block->namespace_info () != NULL
- && block->namespace_info ()->scope != NULL)
- return block->namespace_info ()->scope;
+ if (block->m_namespace_info != nullptr
+ && block->m_namespace_info->scope != nullptr)
+ return block->m_namespace_info->scope;
}
return "";
}
-/* If block->namespace_info () is NULL, allocate it via OBSTACK and
- initialize its members to zero. */
+/* See block.h. */
-static void
-block_initialize_namespace (struct block *block, struct obstack *obstack)
+void
+block::initialize_namespace (struct obstack *obstack)
{
- if (block->namespace_info () == NULL)
- block->set_namespace_info (new (obstack) struct block_namespace_info ());
+ if (m_namespace_info == nullptr)
+ m_namespace_info = new (obstack) struct block_namespace_info;
}
-/* Set BLOCK's scope member to SCOPE; if needed, allocate memory via
- OBSTACK. (It won't make a copy of SCOPE, however, so that already
- has to be allocated correctly.) */
+/* See block.h. */
void
-block_set_scope (struct block *block, const char *scope,
- struct obstack *obstack)
+block::set_scope (const char *scope, struct obstack *obstack)
{
if (scope == nullptr || scope[0] == '\0')
{
return;
}
- block_initialize_namespace (block, obstack);
-
- block->namespace_info ()->scope = scope;
+ initialize_namespace (obstack);
+ m_namespace_info->scope = scope;
}
-/* This returns the using directives list associated with BLOCK, if
- any. */
+/* See block.h. */
struct using_direct *
-block_using (const struct block *block)
+block::get_using () const
{
- if (block->namespace_info () == NULL)
- return NULL;
+ if (m_namespace_info == nullptr)
+ return nullptr;
else
- return block->namespace_info ()->using_decl;
+ return m_namespace_info->using_decl;
}
-/* Set BLOCK's using member to USING; if needed, allocate memory via
- OBSTACK. (It won't make a copy of USING, however, so that already
- has to be allocated correctly.) */
+/* See block.h. */
void
-block_set_using (struct block *block,
- struct using_direct *using_decl,
- struct obstack *obstack)
+block::set_using (struct using_direct *using_decl, struct obstack *obstack)
{
if (using_decl == nullptr)
{
return;
}
- block_initialize_namespace (block, obstack);
-
- block->namespace_info ()->using_decl = using_decl;
+ initialize_namespace (obstack);
+ m_namespace_info->using_decl = using_decl;
}
/* Return the static block associated to BLOCK. Return NULL if block
void set_multidict (multidictionary *multidict)
{ m_multidict = multidict; }
- /* Return this block's namespace info. */
- block_namespace_info *namespace_info () const
- { return m_namespace_info; }
-
- /* Set this block's namespace info. */
- void set_namespace_info (block_namespace_info *namespace_info)
- { m_namespace_info = namespace_info; }
-
/* Return a view on this block's ranges. */
gdb::array_view<blockrange> ranges ()
{
bool inlined_p () const;
+ /* This returns the namespace that this block is enclosed in, or ""
+ if it isn't enclosed in a namespace at all. This travels the
+ chain of superblocks looking for a scope, if necessary. */
+
+ const char *scope () const;
+
+ /* Set this block's scope member to SCOPE; if needed, allocate
+ memory via OBSTACK. (It won't make a copy of SCOPE, however, so
+ that already has to be allocated correctly.) */
+
+ void set_scope (const char *scope, struct obstack *obstack);
+
+ /* This returns the using directives list associated with this
+ block, if any. */
+
+ struct using_direct *get_using () const;
+
+ /* Set this block's using member to USING; if needed, allocate
+ memory via OBSTACK. (It won't make a copy of USING, however, so
+ that already has to be allocated correctly.) */
+
+ void set_using (struct using_direct *using_decl, struct obstack *obstack);
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
startaddr and endaddr above. */
struct blockranges *m_ranges;
+
+private:
+
+ /* If the namespace_info is NULL, allocate it via OBSTACK and
+ initialize its members to zero. */
+ void initialize_namespace (struct obstack *obstack);
};
/* The global block is singled out so that we can provide a back-link
extern const struct block *block_for_pc_sect (CORE_ADDR, struct obj_section *);
-extern const char *block_scope (const struct block *block);
-
-extern void block_set_scope (struct block *block, const char *scope,
- struct obstack *obstack);
-
-extern struct using_direct *block_using (const struct block *block);
-
-extern void block_set_using (struct block *block,
- struct using_direct *using_decl,
- struct obstack *obstack);
-
extern const struct block *block_static_block (const struct block *block);
extern const struct block *block_global_block (const struct block *block);
opblock = pblock;
}
- block_set_using (block,
- (is_global
- ? m_global_using_directives
- : m_local_using_directives),
- &m_objfile->objfile_obstack);
+ block->set_using ((is_global
+ ? m_global_using_directives
+ : m_local_using_directives),
+ &m_objfile->objfile_obstack);
if (is_global)
m_global_using_directives = NULL;
else
/* Go through the using directives. If any of them add new names to
the namespace we're searching in, see if we can find a match by
applying them. */
- for (current = block_using (block);
+ for (current = block->get_using ();
current != NULL;
current = current->next)
{
const domain_enum domain)
{
struct block_symbol sym;
- const char *scope = block_scope (block);
+ const char *scope = block == nullptr ? "" : block->scope ();
symbol_lookup_debug_printf
("cp_lookup_symbol_non_local (%s, %s (scope %s), %s)",
/* If that doesn't work and we're within a namespace, look there
instead. */
- scope = block_scope (get_selected_block (0));
+ scope = get_selected_block (0)->scope ();
if (scope[0] == '\0')
return NULL;
for (block = get_selected_block (0);
block != NULL;
block = block->superblock ())
- for (current = block_using (block);
+ for (current = block->get_using ();
current != NULL;
current = current->next)
{
the module we're searching in, see if we can find a match by
applying them. */
- for (current = block_using (block);
+ for (current = block->get_using ();
current != NULL;
current = current->next)
{
const domain_enum domain)
{
struct block_symbol sym;
- const char *scope = block == nullptr ? "" : block_scope (block);
+ const char *scope = block == nullptr ? "" : block->scope ();
sym = lookup_module_scope (langdef, name, block, domain, scope, 0);
if (sym.symbol != NULL)
const char *name = symbol->demangled_name ();
unsigned int prefix_len = cp_entire_prefix_len (name);
- block_set_scope (block, obstack_strndup (obstack, name, prefix_len),
- obstack);
+ block->set_scope (obstack_strndup (obstack, name, prefix_len),
+ obstack);
}
}
|| cu->lang () == language_d
|| cu->lang () == language_rust)
&& cu->processing_has_namespace_info)
- block_set_scope (block, determine_prefix (die, cu),
- &objfile->objfile_obstack);
+ block->set_scope (determine_prefix (die, cu),
+ &objfile->objfile_obstack);
/* If we have address ranges, record them. */
dwarf2_record_block_ranges (die, block, baseaddr, cu);
std::string
rust_crate_for_block (const struct block *block)
{
- const char *scope = block_scope (block);
+ const char *scope = block->scope ();
if (scope[0] == '\0')
return std::string ();
{
struct block_symbol result = {};
- const char *scope = block == nullptr ? "" : block_scope (block);
+ const char *scope = block == nullptr ? "" : block->scope ();
symbol_lookup_debug_printf
("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)",
name, host_address_to_string (block), scope,
{
const char *scope = "";
if (pstate->expression_context_block != nullptr)
- scope = block_scope (pstate->expression_context_block);
+ scope = pstate->expression_context_block->scope ();
int offset;
if (scope[0] == '\0')
struct symbol *sym;
const struct block *static_block = block_static_block (block);
- const char *scope = block_scope (block);
+ const char *scope = block->scope ();
/* Check if it's a global block. */
if (static_block == nullptr)