Skip to content

Commit

Permalink
fix(arc): assembler label collision (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
ineedbots authored Nov 30, 2023
1 parent 9e2dcf8 commit cf8a756
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/arc/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ auto assembler::assemble(assembly const& data, std::string const& name) -> buffe

auto assembler::assemble_function(function& func) -> void
{
auto labels = std::unordered_map<u32, std::string>();
func.index = script_.pos();
func.size = 0;
func_ = &func;
Expand All @@ -245,11 +246,12 @@ auto assembler::assemble_function(function& func) -> void

if (itr != func.labels.end())
{
func.labels.insert({ inst->index, itr->second });
func.labels.erase(old_idx);
labels.insert({ inst->index, itr->second });
}
}

func.labels = std::move(labels);

script_.pos(func.index);

for (auto const& inst : func.instructions)
Expand Down

0 comments on commit cf8a756

Please sign in to comment.