Skip to content

Commit

Permalink
Sort dumped symbols for consistent output
Browse files Browse the repository at this point in the history
  • Loading branch information
mungre committed Jun 11, 2024
1 parent 8fba958 commit 7e1c43c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/symboltable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <algorithm>

#include "globaldata.h"
#include "objectcode.h"
Expand Down Expand Up @@ -358,6 +359,9 @@ void SymbolTable::Dump(bool global, bool all, const char * labels_file) const

if (global)
{
typedef vector<pair<double, ScopedSymbolName>> ListType;
ListType list;

for ( MapType::const_iterator it = m_map.begin(); it != m_map.end(); ++it )
{
const ScopedSymbolName& symbolName = it->first;
Expand All @@ -370,17 +374,20 @@ void SymbolTable::Dump(bool global, bool all, const char * labels_file) const
Value value = symbol.GetValue();
if (value.GetType() == Value::NumberValue)
{
if ( !bFirst )
{
our_cout << ",";
}

our_cout << "'" << symbolName.Name() << "':" << value.GetNumber() << "L";

bFirst = false;
list.push_back( ListType::value_type(value.GetNumber(), symbolName) );
}
}
}
sort(list.begin(), list.end());
for ( ListType::const_iterator it = list.begin(); it != list.end(); ++it )
{
if ( it != list.begin() )
{
our_cout << ",";
}

our_cout << "'" << it->second.Name() << "':" << it->first << "L";
}
}

if (all)
Expand Down

0 comments on commit 7e1c43c

Please sign in to comment.