source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/Method.h@ 497

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

Messenger/ErrorMessengerクラスを導入。SetError関数によるエラー生成を廃止した。

File size: 6.6 KB
Line 
1#pragma once
2
3using namespace std;
4
5class UserProc;
6class CClass;
7
8class CMethod : public MemberPrototype
9{
10 const UserProc *pUserProc;
11
12 // XMLシリアライズ用
13private:
14 friend class boost::serialization::access;
15 template<class Archive> void serialize(Archive& ar, const unsigned int version)
16 {
17 trace_for_serialize( "serializing - CMethod" );
18
19 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( MemberPrototype );
20 ar & boost::serialization::make_nvp("pUserProc", const_cast<UserProc *&>(pUserProc));
21 }
22
23public:
24 CMethod( const UserProc *pUserProc, Prototype::Accessibility accessibility )
25 : MemberPrototype( accessibility )
26 , pUserProc( pUserProc )
27 {
28 }
29 CMethod()
30 {
31 }
32
33 const UserProc &GetUserProc() const
34 {
35 return *pUserProc;
36 }
37 void SetUserProcPtr( const UserProc *pUserProc )
38 {
39 this->pUserProc = pUserProc;
40 }
41
42 virtual bool Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier ) = 0;
43
44 virtual bool IsAbstract() const = 0;
45 virtual void SetAbstractMark( bool isAbstractMark ) = 0;
46 virtual bool IsVirtual() const = 0;
47 virtual bool IsConst() const = 0;
48 virtual bool IsDynamic() const = 0;
49 virtual bool IsStatic() const = 0;
50 virtual const CClass *GetInheritsClassPtr() const = 0;
51 virtual void SetInheritsClassPtr( const CClass *pInheritsClass ) = 0;
52 virtual bool IsNotUse() const = 0;
53 virtual void SetNotUseMark( bool isNotUse ) = 0;
54};
55
56class DynamicMethod : public CMethod
57{
58 bool isAbstract;
59 bool isVirtual;
60 bool isConst;
61 const CClass *pInheritsClass;
62
63 // 他のインターフェイスへ実装が移った場合(基底クラスメソッドのインターフェイス実装)はこのフラグをオンにする
64 bool isNotUse;
65
66 // XMLシリアライズ用
67private:
68 friend class boost::serialization::access;
69 template<class Archive> void serialize(Archive& ar, const unsigned int version)
70 {
71 trace_for_serialize( "serializing - DynamicMethod" );
72
73 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CMethod );
74 ar & BOOST_SERIALIZATION_NVP( isAbstract );
75 ar & BOOST_SERIALIZATION_NVP( isVirtual );
76 ar & BOOST_SERIALIZATION_NVP( isConst );
77 ar & boost::serialization::make_nvp("pInheritsClass", const_cast<CClass *&>(pInheritsClass));
78 ar & BOOST_SERIALIZATION_NVP( isNotUse );
79 }
80
81public:
82 DynamicMethod( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isAbstract, bool isVirtual, bool isConst, const CClass *pInheritsClass = NULL )
83 : CMethod( pUserProc, accessibility )
84 , isAbstract( isAbstract )
85 , isVirtual( isVirtual )
86 , isConst( isConst )
87 , pInheritsClass( pInheritsClass )
88 , isNotUse( false )
89 {
90 }
91 DynamicMethod( const CMethod &method )
92 : CMethod( &method.GetUserProc(), method.GetAccessibility() )
93 , isAbstract( method.IsAbstract() )
94 , isVirtual( method.IsVirtual() )
95 , isConst( method.IsConst() )
96 , pInheritsClass( method.GetInheritsClassPtr() )
97 , isNotUse( false )
98 {
99 }
100 DynamicMethod()
101 {
102 }
103
104 virtual bool Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier );
105
106 virtual bool IsAbstract() const
107 {
108 return isAbstract;
109 }
110 virtual void SetAbstractMark( bool isAbstract )
111 {
112 this->isAbstract = isAbstract;
113 }
114 virtual bool IsVirtual() const
115 {
116 return isVirtual;
117 }
118 virtual bool IsConst() const
119 {
120 return isConst;
121 }
122 virtual bool IsDynamic() const
123 {
124 return true;
125 }
126 virtual bool IsStatic() const
127 {
128 return false;
129 }
130 virtual const CClass *GetInheritsClassPtr() const
131 {
132 return pInheritsClass;
133 }
134 virtual void SetInheritsClassPtr( const CClass *pInheritsClass )
135 {
136 this->pInheritsClass = pInheritsClass;
137 }
138 virtual bool IsNotUse() const
139 {
140 return isNotUse;
141 }
142 virtual void SetNotUseMark( bool isNotUse )
143 {
144 this->isNotUse = isNotUse;
145 }
146};
147BOOST_CLASS_EXPORT( DynamicMethod );
148class StaticMethod : public CMethod
149{
150 // XMLシリアライズ用
151private:
152 friend class boost::serialization::access;
153 template<class Archive> void serialize(Archive& ar, const unsigned int version)
154 {
155 trace_for_serialize( "serializing - StaticMethod" );
156
157 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CMethod );
158 }
159
160public:
161
162 // コンストラクタ
163 StaticMethod( UserProc *pUserProc, Prototype::Accessibility accessibility )
164 : CMethod( pUserProc, accessibility )
165 {
166 }
167
168 // コピーコンストラクタ
169 StaticMethod( const StaticMethod &staticMethod );
170
171 // デストラクタ
172 StaticMethod()
173 {
174 }
175
176 virtual bool Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier )
177 {
178 throw;
179 }
180
181 virtual bool IsAbstract() const
182 {
183 throw;
184 }
185 virtual void SetAbstractMark( bool isAbstract )
186 {
187 throw;
188 }
189 virtual bool IsVirtual() const{
190 return false;
191 }
192 virtual bool IsConst() const
193 {
194 throw;
195 }
196 virtual bool IsDynamic() const
197 {
198 return false;
199 }
200 virtual bool IsStatic() const
201 {
202 return true;
203 }
204 virtual const CClass *GetInheritsClassPtr() const
205 {
206 throw;
207 }
208 virtual void SetInheritsClassPtr( const CClass *pInheritsClass )
209 {
210 throw;
211 }
212 virtual bool IsNotUse() const
213 {
214 return false;
215 }
216 virtual void SetNotUseMark( bool isNotUse )
217 {
218 throw;
219 }
220};
221BOOST_CLASS_EXPORT( StaticMethod );
222
223class Methods : public vector<CMethod *>
224{
225 // XMLシリアライズ用
226private:
227 friend class boost::serialization::access;
228 template<class Archive> void serialize(Archive& ar, const unsigned int version)
229 {
230 trace_for_serialize( "serializing - Methods" );
231
232 ar & boost::serialization::make_nvp("vector_CMethod", boost::serialization::base_object<vector<CMethod *>>(*this));
233 }
234
235public:
236 // コンストラクタ
237 Methods();
238
239 // コピーコンストラクタ
240 Methods( const Methods &methods );
241
242 // デストラクタ
243 ~Methods();
244
245 //メンバ、メソッドの追加
246 void Add( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual );
247 void AddStatic(UserProc *pUserProc,Prototype::Accessibility accessibility);
248
249 /*!
250 @brief オーバーライドのための検索
251 @param actualTypeParametersForThisMethods thisオブジェクトで保有するメソッド群を対象とした実型パラメータ
252 pUserProc 照らし合わせる関数
253 */
254 CMethod *FindForOverride( const Types &actualTypeParametersForThisMethods, const UserProc *pUserProc );
255
256 const CMethod *GetMethodPtr( const UserProc *pUserProc ) const;
257 bool IsExist( const char *name ) const;
258 virtual void Enum( const char *methodName, vector<const UserProc *> &subs ) const;
259 virtual void Enum( BYTE idOperatorCalc, vector<const UserProc *> &subs ) const;
260
261 // 仮想メソッドの個数を取得
262 int GetVtblNum() const;
263
264 // vtblを生成
265 void GenerateVTablePart( long &vtableDataTableOffset ) const;
266};
Note: See TracBrowser for help on using the repository browser.