From dcbbbdef5a6e868ebbc0e75567965e40c8c8396e Mon Sep 17 00:00:00 2001 From: Charles Reilly Date: Tue, 11 Jun 2024 16:52:33 +0100 Subject: [PATCH] Sort dumped symbols for consistent output --- src/symboltable.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/symboltable.cpp b/src/symboltable.cpp index 67cb30b..b2fe799 100644 --- a/src/symboltable.cpp +++ b/src/symboltable.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #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 > 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)