Skip to content

Commit

Permalink
Sort dumped symbols for consistent output
Browse files Browse the repository at this point in the history
mungre committed Jun 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 8fba958 commit dcbbbde
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
@@ -25,6 +25,7 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <algorithm>

#include "globaldata.h"
#include "objectcode.h"
@@ -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;
@@ -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)

0 comments on commit dcbbbde

Please sign in to comment.