source: dev/BasicCompiler_Common/Procedure.h@ 92

Last change on this file since 92 was 92, checked in by dai_9181, 17 years ago

列挙型クラスの自動生成コードを修正した(派生クラスでのToStringメソッドを廃止し、サイズを軽減した)。

File size: 5.3 KB
RevLine 
[78]1#pragma once
[74]2
[75]3class Procedure{
[74]4public:
[75]5 // 種類
6 enum Kind{
7 Sub,
8 Function,
9 };
[74]10
[75]11private:
12 const string name;
[74]13
[75]14 Kind kind;
[74]15
[75]16 bool isCdecl;
17 bool isUsing;
[74]18
[75]19protected:
[74]20
[75]21 // パラメータ
[74]22 Parameters params;
[75]23
24 // 戻り値の型
25 Type returnType;
26
27 // ソースコードの位置
28 int codePos;
29
30public:
31 Procedure( const string &name, Kind kind, bool isCdecl ):
32 name( name ),
33 kind( kind ),
34 isCdecl( isCdecl ),
35 isUsing( false ),
36 codePos( -1 )
37 {}
38 ~Procedure(){
39 foreach( Parameter *pParam, params ){
40 delete pParam;
41 }
42 }
43
44 const string &GetName() const
45 {
46 return name;
47 }
48
49 bool IsSub() const
50 {
51 return ( kind == Sub );
52 }
53 bool IsFunction() const
54 {
55 return ( kind == Function );
56 }
57
58 bool IsCdecl() const
59 {
60 return isCdecl;
61 }
62 void Using(){
63 isUsing = true;
64 }
65 bool IsUsing() const
66 {
67 return isUsing;
68 }
69
70 int GetCodePos() const
71 {
72 return codePos;
73 }
74
75 const Parameters &Params() const
76 {
77 return params;
78 }
79 const Type &ReturnType() const
80 {
81 return returnType;
82 }
83};
84
85class UserProc : public Procedure
86{
87
88private:
89 bool isMacro;
90
91 // パラメータの追加情報
92 int secondParmNum;
[74]93 Parameters realParams;
[75]94 int realSecondParmNum;
[74]95
[75]96 // 親クラスと対応するメソッド
97 CClass *pParentClass;
98 CMethod *pMethod;
[74]99
[75]100 // 各種フラグ
101 bool isExport;
102 bool isSystem;
[90]103 bool isAutoGeneration;
[75]104 bool isCompiled;
[74]105
[75]106public:
107 // ハッシュリスト用
108 UserProc *pNextData;
[74]109
[75]110 UserProc( const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ):
111 Procedure( name, kind, isCdecl ),
112 isMacro( isMacro ),
113 pParentClass( NULL ),
114 pMethod( NULL ),
115 isExport( isExport ),
116 isSystem( false ),
[90]117 isAutoGeneration( false ),
[75]118 isCompiled( false ),
[92]119 pNextData( NULL ),
120 beginOpAddress( 0 ),
121 endOpAddress( 0 )
[75]122 {
123 }
124 ~UserProc(){
125 foreach( Parameter *pParam, realParams ){
126 delete pParam;
127 }
128 }
129
[91]130 string GetFullName() const
131 {
132 if( HasParentClass() ){
133 return (string)GetParentClass().name + "." + GetName();
134 }
135
136 return GetName();
137 }
138
[75]139 bool IsMacro() const
140 {
141 return isMacro;
142 }
143
144 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic );
145
146 int GetSecondParmNum() const
147 {
148 return secondParmNum;
149 }
150 const Parameters &RealParams() const
151 {
152 return realParams;
153 }
154 int GetRealSecondParmNum() const
155 {
156 return realSecondParmNum;
157 }
158
159 void SetParentClass( CClass *pParentClass ){
160 this->pParentClass = pParentClass;
161 }
162 CClass *GetParentClassPtr()
163 {
164 return pParentClass;
165 }
166 const CClass &GetParentClass() const
167 {
168 return *pParentClass;
169 }
[89]170 bool HasParentClass() const
171 {
172 return ( pParentClass != NULL );
173 }
[75]174 void SetMethod( CMethod *pMethod ){
175 this->pMethod = pMethod;
176 }
177
178 void ExportOff(){
179 isExport = false;
180 }
181 bool IsExport() const
182 {
183 return isExport;
184 }
185 void ThisIsSystemProc(){
186 isSystem = true;
187 }
188 bool IsSystem() const
189 {
190 return isSystem;
191 }
[90]192 void ThisIsAutoGenerationProc(){
193 isAutoGeneration = true;
194 }
195 bool IsAutoGeneration(){
196 return isAutoGeneration;
197 }
[75]198 void CompleteCompile(){
199 isCompiled = true;
200 }
201 void KillCompileStatus(){
202 isCompiled = false;
203 }
204 bool IsCompiled() const
205 {
206 return isCompiled;
207 }
208 bool IsDestructor() const
209 {
210 return ( GetName()[0] == '~' );
211 }
212 bool IsVirtual() const
213 {
214 if( pMethod == NULL ){
215 return false;
216 }
217 return ( pMethod->bVirtual != 0 );
218 }
219
220
221 // バイナリコードの位置
222 DWORD beginOpAddress;
223 DWORD endOpAddress;
[91]224 int GetCodeSize() const
225 {
226 return endOpAddress - beginOpAddress;
227 }
[75]228
229 // ローカル変数
230 Variables localVars;
231
232 // TODO: 適切なコードへ直す
233 long id;
234
235
236 /////////////////////////////////////////////////////////////////
237 // コンパイル中の関数を管理
238 /////////////////////////////////////////////////////////////////
239private:
240 static UserProc *pCompilingUserProc;
241public:
242 static void CompileStartForGlobalArea(){
243 pCompilingUserProc = NULL;
244 }
245 static void CompileStartForUserProc( UserProc *pUserProc ){
246 pCompilingUserProc = pUserProc;
247 }
248 static bool IsGlobalAreaCompiling(){
249 return ( pCompilingUserProc == NULL );
250 }
251 static bool IsLocalAreaCompiling(){
252 return ( pCompilingUserProc != NULL );
253 }
254 static UserProc &CompilingUserProc(){
255 return *pCompilingUserProc;
256 }
[74]257};
[75]258
259class DllProc : public Procedure
260{
261 const string dllFileName;
262 const string alias;
263 int lookupAddress;
264
265public:
266 // ハッシュリスト用
267 DllProc *pNextData;
268
269 DllProc( const string &name, Kind kind, bool isCdecl, const string &dllFileName, const string &alias ):
270 Procedure( name, kind, isCdecl ),
271 dllFileName( dllFileName ),
272 alias( alias ),
273 lookupAddress( 0 ),
274 pNextData( NULL )
275 {
276 }
277 ~DllProc(){}
278
279 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine );
280
281 const string &GetDllFileName() const
282 {
283 return dllFileName;
284 }
285 const string &GetAlias() const
286 {
287 return alias;
288 }
289
290 void SetLookupAddress( int lookupAddress ){
291 this->lookupAddress = lookupAddress;
292 }
293 int GetLookupAddress() const
294 {
295 return lookupAddress;
296 }
297
298};
299
300class ProcPointer : public Procedure
301{
302public:
303 ProcPointer( Kind kind ):
304 Procedure( "", kind, false )
305 {
306 }
307 ~ProcPointer(){}
308
309 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine );
310};
Note: See TracBrowser for help on using the repository browser.