2016-11-22 22:38:14 -05:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <unordered_map>
|
2017-03-09 23:50:20 -05:00
|
|
|
#include <functional>
|
2016-11-22 22:38:14 -05:00
|
|
|
using std::unordered_map;
|
|
|
|
|
|
|
|
class BaseMapper;
|
|
|
|
enum class AddressType;
|
|
|
|
|
2017-03-24 18:33:15 -04:00
|
|
|
class AddressHasher
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
size_t operator()(const uint32_t& addr) const
|
|
|
|
{
|
|
|
|
//Quick hash for addresses
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
class LabelManager
|
|
|
|
{
|
|
|
|
private:
|
2017-03-24 18:33:15 -04:00
|
|
|
unordered_map<uint32_t, string, AddressHasher> _codeLabels;
|
|
|
|
unordered_map<uint32_t, string, AddressHasher> _codeComments;
|
2016-11-22 22:38:14 -05:00
|
|
|
unordered_map<string, uint32_t> _codeLabelReverseLookup;
|
|
|
|
|
|
|
|
shared_ptr<BaseMapper> _mapper;
|
|
|
|
|
2017-12-27 12:03:35 -05:00
|
|
|
int32_t GetLabelAddress(uint32_t absoluteAddr, AddressType addressType);
|
2018-12-10 19:52:16 -05:00
|
|
|
int32_t GetLabelAddress(uint16_t relativeAddr);
|
2016-11-22 22:38:14 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
LabelManager(shared_ptr<BaseMapper> mapper);
|
|
|
|
|
|
|
|
void SetLabel(uint32_t address, AddressType addressType, string label, string comment);
|
2018-06-09 21:25:49 -04:00
|
|
|
void DeleteLabels();
|
|
|
|
|
2018-08-02 20:44:48 -04:00
|
|
|
int32_t GetLabelRelativeAddress(string &label);
|
2016-11-22 22:38:14 -05:00
|
|
|
|
2016-11-23 18:48:29 -05:00
|
|
|
string GetLabel(uint16_t relativeAddr, bool checkRegisters);
|
2016-11-22 22:38:14 -05:00
|
|
|
string GetComment(uint16_t relativeAddr);
|
2017-03-09 23:50:20 -05:00
|
|
|
void GetLabelAndComment(uint16_t relativeAddr, string &label, string &comment);
|
2017-12-27 12:03:35 -05:00
|
|
|
|
2018-08-02 20:44:48 -04:00
|
|
|
bool ContainsLabel(string &label);
|
|
|
|
|
2017-12-27 12:03:35 -05:00
|
|
|
bool HasLabelOrComment(uint16_t relativeAddr);
|
|
|
|
bool HasLabelOrComment(uint32_t absoluteAddr, AddressType addressType);
|
2016-11-22 22:38:14 -05:00
|
|
|
};
|