This converts block_static_block and block_global_block to be methods.
This was mostly written by script. It was simpler to convert them at
the same time because they're often used near each other.
sym = ada_lookup_symbol (name,
(block == nullptr
? nullptr
- : block_static_block (block)),
+ : block->static_block ()),
domain);
if (sym.symbol != NULL)
return sym;
if (function () != nullptr)
return function ()->objfile ();
- global_block = (struct global_block *) block_global_block (this);
+ global_block = (struct global_block *) this->global_block ();
return global_block->compunit_symtab->objfile ();
}
m_namespace_info->using_decl = using_decl;
}
-/* Return the static block associated to BLOCK. Return NULL if block
- is a global block. */
+/* See block.h. */
const struct block *
-block_static_block (const struct block *block)
+block::static_block () const
{
- if (block->superblock () == NULL)
- return NULL;
+ if (superblock () == nullptr)
+ return nullptr;
+ const block *block = this;
while (block->superblock ()->superblock () != NULL)
block = block->superblock ();
return block;
}
-/* Return the static block associated to BLOCK. */
+/* See block.h. */
const struct block *
-block_global_block (const struct block *block)
+block::global_block () const
{
+ const block *block = this;
+
while (block->superblock () != NULL)
block = block->superblock ();
struct symbol *containing_function () const;
+ /* Return the static block associated with this block. Return NULL
+ if block is a global block. */
+
+ const struct block *static_block () const;
+
+ /* Return the static block associated with block. */
+
+ const struct block *global_block () const;
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
extern const struct block *block_for_pc_sect (CORE_ADDR, struct obj_section *);
-extern const struct block *block_static_block (const struct block *block);
-
-extern const struct block *block_global_block (const struct block *block);
-
extern struct block *allocate_block (struct obstack *obstack);
extern struct block *allocate_global_block (struct obstack *obstack);
const struct block *static_block = nullptr;
if (sym.block != nullptr)
- static_block = block_static_block (sym.block);
+ static_block = sym.block->static_block ();
/* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */
is_local_symbol = (sym.block != static_block && static_block != NULL);
if (is_local_symbol)
/* If the outer symbol is in the static block, we ignore it, as
it cannot be referenced. */
if (global_sym.symbol != NULL
- && global_sym.block != block_static_block (global_sym.block))
+ && global_sym.block != global_sym.block->static_block ())
{
if (compile_debug)
gdb_printf (gdb_stdlog,
if (block == nullptr)
return {};
- const struct block *static_block = block_static_block (block);
+ const struct block *static_block = block->static_block ();
/* If we're already in the static or global block, there is nothing
to write. */
const struct block *static_block = nullptr;
if (sym.block != nullptr)
- static_block = block_static_block (sym.block);
+ static_block = sym.block->static_block ();
/* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */
bool is_local_symbol = (sym.block != static_block && static_block != nullptr);
if (is_local_symbol)
/* If the outer symbol is in the static block, we ignore it, as
it cannot be referenced. */
if (global_sym.symbol != nullptr
- && global_sym.block != block_static_block (global_sym.block))
+ && global_sym.block != global_sym.block->static_block ())
{
if (compile_debug)
gdb_printf (gdb_stdlog,
but should be treated as local to a single file nonetheless.
So we only search the current file's global block. */
- const struct block *global_block = block_global_block (block);
+ const struct block *global_block = block->global_block ();
if (global_block != NULL)
{
/* Look in the static block. */
block = get_selected_block (0);
- block = block == nullptr ? nullptr : block_static_block (block);
+ block = block == nullptr ? nullptr : block->static_block ();
if (block != nullptr)
{
add_symbol_overload_list_block (name, block, overload_list);
/* Look in the global block. */
- block = block_global_block (block);
+ block = block->global_block ();
if (block)
add_symbol_overload_list_block (name, block, overload_list);
}
b = b->superblock ())
add_symbol_overload_list_block (func_name, b, overload_list);
- surrounding_static_block = block_static_block (get_selected_block (0));
+ surrounding_static_block = get_selected_block (0);
surrounding_static_block = (surrounding_static_block == nullptr
? nullptr
- : block_static_block (surrounding_static_block));
+ : surrounding_static_block->static_block ());
/* Go through the symtabs and check the externs and statics for
symbols which match. */
tests that embed global/static symbols with null location lists.
We want to get <optimized out> instead of <frame required> when evaluating
them so return a frame instead of raising an error. */
- else if (var_block == block_global_block (var_block)
- || var_block == block_static_block (var_block))
+ else if (var_block == var_block->global_block ()
+ || var_block == var_block->static_block ())
return frame;
/* We have to handle the "my_func::my_local_var" notation. This requires us
/* If we failed to find the proper frame, fallback to the heuristic
method below. */
- else if (frame_block == block_global_block (frame_block))
+ else if (frame_block == frame_block->global_block ())
{
frame = NULL;
break;
const struct block *block = b_smob->block;
const struct block *global_block;
- global_block = block_global_block (block);
+ global_block = block->global_block ();
return bkscm_scm_from_block (global_block, b_smob->objfile);
}
if (block->superblock () == NULL)
return SCM_BOOL_F;
- static_block = block_static_block (block);
+ static_block = block->static_block ();
return bkscm_scm_from_block (static_block, b_smob->objfile);
}
BLPY_REQUIRE_VALID (self, block);
- global_block = block_global_block (block);
+ global_block = block->global_block ();
return block_to_block_object (global_block,
self_obj->objfile);
if (block->superblock () == NULL)
Py_RETURN_NONE;
- static_block = block_static_block (block);
+ static_block = block->static_block ();
return block_to_block_object (static_block, self_obj->objfile);
}
if (startswith (*name, "::"))
{
*name += 2;
- *block = block_static_block (*block);
+ *block = (*block)->static_block ();
}
}
return {};
struct symbol *sym;
- const struct block *static_block = block_static_block (block);
+ const struct block *static_block = block->static_block ();
const char *scope = block->scope ();
/* Check if it's a global block. */
if (block == nullptr)
return {};
- const struct block *static_block = block_static_block (block);
+ const struct block *static_block = block->static_block ();
struct symbol *sym;
if (static_block == NULL)
global block first. This yields "more expected" behavior, and is
needed to support 'FILENAME'::VARIABLE lookups. */
const struct block *global_block
- = block == nullptr ? nullptr : block_global_block (block);
+ = block == nullptr ? nullptr : block->global_block ();
symbol *sym = NULL;
if (global_block != nullptr)
{
visible from current context. */
b = get_selected_block (0);
- surrounding_static_block = b == nullptr ? nullptr : block_static_block (b);
- surrounding_global_block = b == nullptr : nullptr : block_global_block (b);
+ surrounding_static_block = b == nullptr ? nullptr : b->static_block ();
+ surrounding_global_block = b == nullptr ? nullptr : b->global_block ();
if (surrounding_static_block != NULL)
while (b != surrounding_static_block)
{