source: dev/BasicCompiler_Common/Procedure.h@ 82

Last change on this file since 82 was 78, checked in by dai_9181, 18 years ago

CTypeDef → TypeDef
Houseクラスを追加。
オーバーロードレベルの種類を追加(レベル1に挿入)

File size: 4.8 KB
Line 
1#pragma once
2
3class Procedure{
4public:
5 // 種類
6 enum Kind{
7 Sub,
8 Function,
9 };
10
11private:
12 const string name;
13
14 Kind kind;
15
16 bool isCdecl;
17 bool isUsing;
18
19protected:
20
21 // パラメータ
22 Parameters params;
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;
93 Parameters realParams;
94 int realSecondParmNum;
95
96 // 親クラスと対応するメソッド
97 CClass *pParentClass;
98 CMethod *pMethod;
99
100 // 各種フラグ
101 bool isExport;
102 bool isSystem;
103 bool isCompiled;
104
105public:
106 // ハッシュリスト用
107 UserProc *pNextData;
108
109 UserProc( const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ):
110 Procedure( name, kind, isCdecl ),
111 isMacro( isMacro ),
112 pParentClass( NULL ),
113 pMethod( NULL ),
114 isExport( isExport ),
115 isSystem( false ),
116 isCompiled( false ),
117 pNextData( NULL )
118 {
119 }
120 ~UserProc(){
121 foreach( Parameter *pParam, realParams ){
122 delete pParam;
123 }
124 }
125
126 bool IsMacro() const
127 {
128 return isMacro;
129 }
130
131 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic );
132
133 int GetSecondParmNum() const
134 {
135 return secondParmNum;
136 }
137 const Parameters &RealParams() const
138 {
139 return realParams;
140 }
141 int GetRealSecondParmNum() const
142 {
143 return realSecondParmNum;
144 }
145
146 void SetParentClass( CClass *pParentClass ){
147 this->pParentClass = pParentClass;
148 }
149 CClass *GetParentClassPtr()
150 {
151 return pParentClass;
152 }
153 const CClass &GetParentClass() const
154 {
155 return *pParentClass;
156 }
157 void SetMethod( CMethod *pMethod ){
158 this->pMethod = pMethod;
159 }
160
161 void ExportOff(){
162 isExport = false;
163 }
164 bool IsExport() const
165 {
166 return isExport;
167 }
168 void ThisIsSystemProc(){
169 isSystem = true;
170 }
171 bool IsSystem() const
172 {
173 return isSystem;
174 }
175 void CompleteCompile(){
176 isCompiled = true;
177 }
178 void KillCompileStatus(){
179 isCompiled = false;
180 }
181 bool IsCompiled() const
182 {
183 return isCompiled;
184 }
185 bool IsDestructor() const
186 {
187 return ( GetName()[0] == '~' );
188 }
189 bool IsVirtual() const
190 {
191 if( pMethod == NULL ){
192 return false;
193 }
194 return ( pMethod->bVirtual != 0 );
195 }
196
197
198 // バイナリコードの位置
199 DWORD beginOpAddress;
200 DWORD endOpAddress;
201
202 // ローカル変数
203 Variables localVars;
204
205 // TODO: 適切なコードへ直す
206 long id;
207
208
209 /////////////////////////////////////////////////////////////////
210 // コンパイル中の関数を管理
211 /////////////////////////////////////////////////////////////////
212private:
213 static UserProc *pCompilingUserProc;
214public:
215 static void CompileStartForGlobalArea(){
216 pCompilingUserProc = NULL;
217 }
218 static void CompileStartForUserProc( UserProc *pUserProc ){
219 pCompilingUserProc = pUserProc;
220 }
221 static bool IsGlobalAreaCompiling(){
222 return ( pCompilingUserProc == NULL );
223 }
224 static bool IsLocalAreaCompiling(){
225 return ( pCompilingUserProc != NULL );
226 }
227 static UserProc &CompilingUserProc(){
228 return *pCompilingUserProc;
229 }
230};
231
232class DllProc : public Procedure
233{
234 const string dllFileName;
235 const string alias;
236 int lookupAddress;
237
238public:
239 // ハッシュリスト用
240 DllProc *pNextData;
241
242 DllProc( const string &name, Kind kind, bool isCdecl, const string &dllFileName, const string &alias ):
243 Procedure( name, kind, isCdecl ),
244 dllFileName( dllFileName ),
245 alias( alias ),
246 lookupAddress( 0 ),
247 pNextData( NULL )
248 {
249 }
250 ~DllProc(){}
251
252 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine );
253
254 const string &GetDllFileName() const
255 {
256 return dllFileName;
257 }
258 const string &GetAlias() const
259 {
260 return alias;
261 }
262
263 void SetLookupAddress( int lookupAddress ){
264 this->lookupAddress = lookupAddress;
265 }
266 int GetLookupAddress() const
267 {
268 return lookupAddress;
269 }
270
271};
272
273class ProcPointer : public Procedure
274{
275public:
276 ProcPointer( Kind kind ):
277 Procedure( "", kind, false )
278 {
279 }
280 ~ProcPointer(){}
281
282 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine );
283};
Note: See TracBrowser for help on using the repository browser.