~ubuntu-branches/ubuntu/utopic/openmsx-debugger/utopic

« back to all changes in this revision

Viewing changes to src/SymbolTable.h

  • Committer: Bazaar Package Importer
  • Author(s): Joost Yervante Damad
  • Date: 2009-12-06 07:40:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091206074002-kssfkg1d6xbp6w9e
Tags: 0.0.0.svn20091206-1
New svn snapshot (Closes: #559612)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// $Id: SymbolTable.h 7348 2007-12-03 21:43:10Z arnoldmnl $
2
 
#ifndef _SYMBOLTABLE_H
3
 
#define _SYMBOLTABLE_H
 
1
// $Id: SymbolTable.h 9782 2009-05-09 21:14:27Z turbor $
 
2
 
 
3
#ifndef SYMBOLTABLE_H
 
4
#define SYMBOLTABLE_H
4
5
 
5
6
#include <QString>
6
7
#include <QList>
7
8
#include <QMultiMap>
8
9
#include <QMultiHash>
 
10
#include <QDateTime>
 
11
#include <QXmlStreamReader>
 
12
#include <QXmlStreamWriter>
9
13
 
10
14
struct MemoryLayout;
11
 
 
12
15
class SymbolTable;
13
16
 
14
17
class Symbol
15
18
{
16
19
public:
17
 
        Symbol( const QString& str, int addr, int val = 0xFFFF );
18
 
        
19
 
        friend class SymbolTable;
 
20
        Symbol(const QString& str, int addr, int val = 0xFFFF);
 
21
        Symbol(const Symbol& symbol);
20
22
 
 
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,
29
 
                        REG_ALL = 65535 };
30
 
        
 
38
                        REG_ALL = 0x3FFFF };
 
39
 
31
40
        const QString& text() const;
32
 
        void setText( const QString& str );
 
41
        void setText(const QString& str);
33
42
        int value() const;
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 );
45
 
        
46
 
        bool isSlotValid( MemoryLayout *ml = 0 );
 
53
        void setType(SymbolType t);
 
54
 
 
55
        bool isSlotValid(MemoryLayout* ml = 0);
47
56
 
48
57
private:
49
 
        SymbolTable *table;
 
58
        SymbolTable* table;
50
59
 
51
60
        QString symText;
52
61
        int symValue;
53
62
        int symSlots;
54
63
        QList<unsigned char> symSegments;
55
64
        int symRegisters;
56
 
        QString *symSource;
 
65
        const QString* symSource;
57
66
        SymbolStatus symStatus;
58
67
        SymbolType symType;
 
68
 
 
69
        friend class SymbolTable;
59
70
};
60
71
 
61
72
 
62
73
class SymbolTable
63
74
{
64
75
public:
65
 
        SymbolTable();
 
76
        enum FileType { DETECT_FILE, TNIASM_FILE, SJASM_FILE,  ASMSX_FILE, LINKMAP_FILE };
 
77
 
66
78
        ~SymbolTable();
67
79
 
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);
 
83
        void clear();
 
84
 
 
85
        /* xml session file functions */
 
86
        void saveSymbols(QXmlStreamWriter& xml);
 
87
        void loadSymbols(QXmlStreamReader& xml);
70
88
 
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);
77
95
 
78
 
        void symbolTypeChanged( Symbol *symbol );
79
 
        void symbolValueChanged( Symbol *symbol );
 
96
        void symbolTypeChanged(Symbol* symbol);
 
97
        void symbolValueChanged(Symbol* symbol);
80
98
 
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;
83
102
 
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);
89
106
 
90
107
private:
 
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);
 
113
 
 
114
        void mapSymbol(Symbol* symbol);
 
115
        void unmapSymbol(Symbol* symbol);
 
116
 
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;
96
121
 
97
 
        void mapSymbol( Symbol *symbol );
98
 
        void unmapSymbol( Symbol *symbol );
 
122
        struct SymbolFileRecord {
 
123
                QString fileName;
 
124
                QDateTime refreshTime;
 
125
                FileType fileType;
 
126
        };
 
127
        QList<SymbolFileRecord> symbolFiles;
99
128
};
100
129
 
101
 
 
102
 
#endif // _SYMBOLTABLE_H
 
130
#endif // SYMBOLTABLE_H