1 #pragma once
2 #include "../Util/FileClasses.h"
3 #include <set>
4 
5 class AssemblerFile;
6 
7 struct SymDataSymbol
8 {
9 	std::wstring name;
10 	int64_t address;
11 
12 	bool operator<(const SymDataSymbol& other) const
13 	{
14 		return address < other.address;
15 	}
16 };
17 
18 struct SymDataAddressInfo
19 {
20 	int64_t address;
21 	size_t fileIndex;
22 	size_t lineNumber;
23 
24 	bool operator<(const SymDataAddressInfo& other) const
25 	{
26 		return address < other.address;
27 	}
28 };
29 
30 struct SymDataFunction
31 {
32 	int64_t address;
33 	size_t size;
34 
35 	bool operator<(const SymDataFunction& other) const
36 	{
37 		return address < other.address;
38 	}
39 };
40 
41 struct SymDataData
42 {
43 	int64_t address;
44 	size_t size;
45 	int type;
46 
47 	bool operator<(const SymDataData& other) const
48 	{
49 		if (address != other.address)
50 			return address < other.address;
51 
52 		if (size != other.size)
53 			return size < other.size;
54 
55 		return type < other.type;
56 	}
57 };
58 
59 struct SymDataModule
60 {
61 	AssemblerFile* file;
62 	std::vector<SymDataSymbol> symbols;
63 	std::vector<SymDataFunction> functions;
64 	std::set<SymDataData> data;
65 };
66 
67 struct SymDataModuleInfo
68 {
69 	unsigned int crc32;
70 };
71 
72 class SymbolData
73 {
74 public:
75 	enum DataType { Data8, Data16, Data32, Data64, DataAscii };
76 
77 	SymbolData();
78 	void clear();
setNocashSymFileName(const std::wstring & name,int version)79 	void setNocashSymFileName(const std::wstring& name, int version) { nocashSymFileName = name; nocashSymVersion = version; };
80 	void write();
setEnabled(bool b)81 	void setEnabled(bool b) { enabled = b; };
82 
83 	void addLabel(int64_t address, const std::wstring& name);
84 	void addData(int64_t address, size_t size, DataType type);
85 	void startModule(AssemblerFile* file);
86 	void endModule(AssemblerFile* file);
87 	void startFunction(int64_t address);
88 	void endFunction(int64_t address);
89 private:
90 	void writeNocashSym();
91 	size_t addFileName(const std::wstring& fileName);
92 
93 	std::wstring nocashSymFileName;
94 	bool enabled;
95 	int nocashSymVersion;
96 
97 	// entry 0 is for data without parent modules
98 	std::vector<SymDataModule> modules;
99 	std::vector<std::wstring> files;
100 	int currentModule;
101 	int currentFunction;
102 };
103