1
// $Id: SymbolTable.h 7348 2007-12-03 21:43:10Z arnoldmnl $
1
// $Id: SymbolTable.h 9782 2009-05-09 21:14:27Z turbor $
8
9
#include <QMultiHash>
11
#include <QXmlStreamReader>
12
#include <QXmlStreamWriter>
10
14
struct MemoryLayout;
17
Symbol( const QString& str, int addr, int val = 0xFFFF );
19
friend class SymbolTable;
20
Symbol(const QString& str, int addr, int val = 0xFFFF);
21
Symbol(const Symbol& symbol);
23
// ACTIVE status is for regular symbols. HIDDEN is for symbols
24
// that are in the list but not shown anywhere. LOST is a special
25
// status for symbols that were once loaded from a symbol file, but
26
// weren't found later. These aren't deleted immediately because
27
// the possible custom settings would be lost even if the reload
28
// was of a bad file (after a failed assembler run for instance).
21
29
enum SymbolStatus { ACTIVE, HIDDEN, LOST };
22
30
enum SymbolType { JUMPLABEL, VARIABLELABEL, VALUE };
23
31
enum Register { REG_A = 1, REG_B = 2, REG_C = 4, REG_D = 8, REG_E = 16,
24
32
REG_H = 32, REG_L = 64, REG_BC = 128, REG_DE = 256,
25
33
REG_HL = 512, REG_IX = 1024, REG_IY = 2048, REG_IXL = 4096,
26
34
REG_IXH = 8192, REG_IYL = 16384, REG_IYH = 32768,
27
REG_ALL8 = 1+2+4+8+16+32+64+4096+8192+16384+32768,
35
REG_OFFSET = 65536, REG_I = 131072,
36
REG_ALL8 = 1+2+4+8+16+32+64+4096+8192+16384+32768+65536+131072,
28
37
REG_ALL16 = 128+256+512+1024+2048,
31
40
const QString& text() const;
32
void setText( const QString& str );
41
void setText(const QString& str);
34
void setValue( int addr );
43
void setValue(int addr);
35
44
int validSlots() const;
36
void setValidSlots( int val );
45
void setValidSlots(int val);
37
46
int validRegisters() const;
38
void setValidRegisters( int regs );
39
const QString *source() const;
40
void setSource( QString* name );
47
void setValidRegisters(int regs);
48
const QString* source() const;
49
void setSource(const QString* name);
41
50
SymbolStatus status() const;
42
void setStatus( SymbolStatus s );
51
void setStatus(SymbolStatus s);
43
52
SymbolType type() const;
44
void setType( SymbolType t );
46
bool isSlotValid( MemoryLayout *ml = 0 );
53
void setType(SymbolType t);
55
bool isSlotValid(MemoryLayout* ml = 0);
54
63
QList<unsigned char> symSegments;
65
const QString* symSource;
57
66
SymbolStatus symStatus;
58
67
SymbolType symType;
69
friend class SymbolTable;
76
enum FileType { DETECT_FILE, TNIASM_FILE, SJASM_FILE, ASMSX_FILE, LINKMAP_FILE };
68
void add( Symbol *symbol );
69
void removeAt( int index );
80
void add(Symbol* symbol);
81
void removeAt(int index);
82
void remove(Symbol *symbol);
85
/* xml session file functions */
86
void saveSymbols(QXmlStreamWriter& xml);
87
void loadSymbols(QXmlStreamReader& xml);
71
89
/* Symbol access functions */
72
Symbol *findFirstAddressSymbol( int addr, MemoryLayout *ml = 0 );
73
Symbol *getCurrentAddressSymbol();
74
Symbol *findNextAddressSymbol( MemoryLayout *ml = 0 );
75
Symbol *getValueSymbol( int val, Symbol::Register reg, MemoryLayout *ml = 0 );
76
Symbol *getAddressSymbol( int val, MemoryLayout *ml = 0 );
90
Symbol* findFirstAddressSymbol(int addr, MemoryLayout* ml = 0);
91
Symbol* getCurrentAddressSymbol();
92
Symbol* findNextAddressSymbol(MemoryLayout* ml = 0);
93
Symbol* getValueSymbol(int val, Symbol::Register reg, MemoryLayout* ml = 0);
94
Symbol* getAddressSymbol(int val, MemoryLayout* ml = 0);
78
void symbolTypeChanged( Symbol *symbol );
79
void symbolValueChanged( Symbol *symbol );
96
void symbolTypeChanged(Symbol* symbol);
97
void symbolValueChanged(Symbol* symbol);
81
99
int symbolFilesSize() const;
82
const QString& symbolFile( int index ) const;
100
const QString& symbolFile(int index) const;
101
const QDateTime& symbolFileRefresh(int index) const;
84
bool readTNIASM0File( const QString& filename );
85
bool readASMSXFile( const QString& filename );
86
bool readLinkMapFile( const QString& filename );
103
bool readFile(const QString& filename, FileType type = DETECT_FILE);
87
104
void reloadFiles();
88
void unloadFile( const QString& file, bool keepSymbols = false );
105
void unloadFile(const QString& file, bool keepSymbols = false);
108
void appendFile(const QString& file, FileType type);
109
bool readTNIASM0File(const QString& filename);
110
bool readASMSXFile(const QString& filename);
111
bool readSJASMFile(const QString& filename);
112
bool readLinkMapFile(const QString& filename);
114
void mapSymbol(Symbol* symbol);
115
void unmapSymbol(Symbol* symbol);
91
117
QList<Symbol*> symbols;
92
118
QMultiMap<int, Symbol*> addressSymbols;
93
119
QMultiHash<int, Symbol*> valueSymbols;
94
120
QMultiMap<int, Symbol*>::iterator currentAddress;
95
QList<QString*> symbolFiles;
97
void mapSymbol( Symbol *symbol );
98
void unmapSymbol( Symbol *symbol );
122
struct SymbolFileRecord {
124
QDateTime refreshTime;
127
QList<SymbolFileRecord> symbolFiles;
102
#endif // _SYMBOLTABLE_H
130
#endif // SYMBOLTABLE_H