Debian Codegraph @

code.h

raw symbols SCIP
1 // File: code.h
2 /*
3 Pep8-1 is a virtual machine for writing machine language and assembly
4 language programs.
5
6 Copyright (C) 2009 J. Stanley Warford, Pepperdine University
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CODE_H
23 #define CODE_H
24
25 #include "pep.h"
26 #include "enu.h"
27
28 class Argument; // Forward declaration for attributes of code classes.
29
30 // Abstract Code class
31 class Code
32 {
33 friend class Asm;
34 public:
35 virtual ~Code() { }
36 virtual void appendObjectCode(QList<int> &objectCode) = 0;
37 virtual void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox) = 0;
38 void adjustMemAddress(int addressDelta) { memAddress += addressDelta; }
39 virtual bool processFormatTraceTags(int &, QString &) { return true; }
40 virtual bool processSymbolTraceTags(int &, QString &) { return true; }
41
42 protected:
43 int memAddress;
44 int sourceCodeLine;
45 QString symbolDef;
46 QString comment;
47 };
48
49 // Concrete code classes
50 class UnaryInstruction: public Code
51 {
52 friend class Asm;
53 private:
54 Enu::EMnemonic mnemonic;
55 public:
56 void appendObjectCode(QList<int> &objectCode);
57 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
58 bool processSymbolTraceTags(int &sourceLine, QString &errorString);
59 };
60
61 class NonUnaryInstruction: public Code
62 {
63 friend class Asm;
64 private:
65 Enu::EMnemonic mnemonic;
66 Enu::EAddrMode addressingMode;
67 Argument *argument;
68 public:
69 // ~NonUnaryInstruction() { delete argument; }
70 void appendObjectCode(QList<int> &objectCode);
71 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
72 bool processSymbolTraceTags(int &sourceLine, QString &errorString);
73 };
74
75 class DotAddrss: public Code
76 {
77 friend class Asm;
78 private:
79 Argument *argument;
80 public:
81 void appendObjectCode(QList<int> &objectCode);
82 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
83 };
84
85 class DotAscii: public Code
86 {
87 friend class Asm;
88 private:
89 Argument *argument;
90 public:
91 void appendObjectCode(QList<int> &objectCode);
92 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
93 };
94
95 class DotBlock: public Code
96 {
97 friend class Asm;
98 private:
99 Argument *argument;
100 public:
101 void appendObjectCode(QList<int> &objectCode);
102 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
103 bool processFormatTraceTags(int &sourceLine, QString &errorString);
104 bool processSymbolTraceTags(int &sourceLine, QString &errorString);
105 };
106
107 class DotBurn: public Code
108 {
109 friend class Asm;
110 private:
111 Argument *argument;
112 public:
113 void appendObjectCode(QList<int> &objectCode);
114 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
115 };
116
117 class DotByte: public Code
118 {
119 friend class Asm;
120 private:
121 Argument *argument;
122 public:
123 void appendObjectCode(QList<int> &objectCode);
124 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
125 };
126
127 class DotEnd: public Code
128 {
129 friend class Asm;
130 public:
131 void appendObjectCode(QList<int> &objectCode);
132 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
133 };
134
135 class DotEquate: public Code
136 {
137 friend class Asm;
138 private:
139 Argument *argument;
140 public:
141 void appendObjectCode(QList<int> &objectCode);
142 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
143 bool processFormatTraceTags(int &sourceLine, QString &errorString);
144 };
145
146 class DotWord: public Code
147 {
148 friend class Asm;
149 private:
150 Argument *argument;
151 public:
152 void appendObjectCode(QList<int> &objectCode);
153 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
154 };
155
156 class CommentOnly: public Code
157 {
158 friend class Asm;
159 public:
160 void appendObjectCode(QList<int> &objectCode);
161 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
162 };
163
164 class BlankLine: public Code
165 {
166 friend class Asm;
167 public:
168 void appendObjectCode(QList<int> &objectCode);
169 void appendSourceLine(QStringList &assemblerListingList, QStringList &listingTraceList, QList<bool> &hasCheckBox);
170 };
171
172 #endif // CODE_H