Skip to content

Commit

Permalink
refactor: Remove sequence symbol map from the code stack
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Nov 3, 2023
1 parent 32e986c commit dd5fca9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 0 additions & 2 deletions parser_library/src/context/code_scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ struct code_scope
set_sym_storage variables;
// local system variables of scope
sys_sym_storage system_variables;
// local sequence symbols of scope
label_storage sequence_symbols;
// gets macro to which this scope belong (nullptr if in open code)
macro_invo_ptr this_macro;
// the ACTR branch counter
Expand Down
10 changes: 4 additions & 6 deletions parser_library/src/context/hlasm_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,7 @@ var_sym_ptr hlasm_context::get_var_sym(id_index name) const

void hlasm_context::add_opencode_sequence_symbol(std::unique_ptr<opencode_sequence_symbol> seq_sym)
{
auto& opencode = scope_stack_.front();
opencode.sequence_symbols.try_emplace(seq_sym->name, std::move(seq_sym));
opencode_sequence_symbols.try_emplace(seq_sym->name, std::move(seq_sym));
}

const sequence_symbol* hlasm_context::get_sequence_symbol(id_index name) const
Expand All @@ -688,8 +687,8 @@ const sequence_symbol* hlasm_context::get_sequence_symbol(id_index name) const
}
else
{
found = scope->sequence_symbols.find(name);
end = scope->sequence_symbols.end();
found = opencode_sequence_symbols.find(name);
end = opencode_sequence_symbols.end();
}

if (found != end)
Expand All @@ -700,8 +699,7 @@ const sequence_symbol* hlasm_context::get_sequence_symbol(id_index name) const

const sequence_symbol* hlasm_context::get_opencode_sequence_symbol(id_index name) const
{
if (const auto& sym = scope_stack_.front().sequence_symbols.find(name);
sym != scope_stack_.front().sequence_symbols.end())
if (const auto& sym = opencode_sequence_symbols.find(name); sym != opencode_sequence_symbols.end())
return sym->second.get();
return nullptr;
}
Expand Down
4 changes: 4 additions & 0 deletions parser_library/src/context/hlasm_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class hlasm_context
unsigned mnote_max = 0;
unsigned mnote_last_max = 0;

label_storage opencode_sequence_symbols;

public:
hlasm_context(utils::resource::resource_location file_loc = utils::resource::resource_location(""),
asm_option asm_opts = {},
Expand Down Expand Up @@ -342,6 +344,8 @@ class hlasm_context
void set_title_name(std::string name) { m_title_name = std::move(name); }

void update_mnote_max(unsigned mnote_level);

const auto& get_opencode_sequence_symbols() const noexcept { return opencode_sequence_symbols; }
};

bool test_symbol_for_read(const var_sym_ptr& var,
Expand Down
4 changes: 2 additions & 2 deletions parser_library/src/lsp/lsp_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ completion_list_source lsp_context::complete_seq(const file_info& file, position
{
auto macro_i = file.find_scope(pos);

return macro_i ? &macro_i->macro_definition->labels : &m_hlasm_ctx->current_scope().sequence_symbols;
return macro_i ? &macro_i->macro_definition->labels : &m_hlasm_ctx->get_opencode_sequence_symbols();
}

completion_list_source lsp_context::complete_instr(const file_info& fi, position pos) const
Expand Down Expand Up @@ -898,7 +898,7 @@ std::optional<location> lsp_context::find_definition_location(const symbol_occur
}
case lsp::occurrence_kind::SEQ: {
const context::label_storage& seq_syms =
macro_scope_i ? macro_scope_i->macro_definition->labels : m_hlasm_ctx->current_scope().sequence_symbols;
macro_scope_i ? macro_scope_i->macro_definition->labels : m_hlasm_ctx->get_opencode_sequence_symbols();
if (auto sym = seq_syms.find(occ.name); sym != seq_syms.end())
return sym->second->symbol_location;
break;
Expand Down

0 comments on commit dd5fca9

Please sign in to comment.