source: dev/trunk/abdev/BasicCompiler_Common/include/Method.h@ 348

Last change on this file since 348 was 347, checked in by dai_9181, 17 years ago
File size: 5.3 KB
Line 
1#pragma once
2
3#include <string>
4#include <vector>
5
6#include <option.h>
7#include <Program.h>
8#include <Class.h>
9#include <Procedure.h>
10
11#include <windows.h>
12
13using namespace std;
14
15class UserProc;
16class CClass;
17void SetError();
18
19class CMethod : public MemberPrototype
20{
21 const UserProc *pUserProc;
22
23 // XMLシリアライズ用
24private:
25 friend class boost::serialization::access;
26 template<class Archive> void serialize(Archive& ar, const unsigned int version)
27 {
28 trace_for_serialize( "serializing - CMethod" );
29
30 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( MemberPrototype );
31 ar & boost::serialization::make_nvp("pUserProc", const_cast<UserProc *&>(pUserProc));
32 }
33
34public:
35 CMethod( const UserProc *pUserProc, Prototype::Accessibility accessibility )
36 : MemberPrototype( accessibility )
37 , pUserProc( pUserProc )
38 {
39 }
40 CMethod()
41 {
42 }
43
44 const UserProc &GetUserProc() const
45 {
46 return *pUserProc;
47 }
48 void SetUserProcPtr( const UserProc *pUserProc )
49 {
50 this->pUserProc = pUserProc;
51 }
52
53 virtual bool IsAbstract() const = 0;
54 virtual void Override() = 0;
55 virtual bool IsVirtual() const = 0;
56 virtual bool IsConst() const = 0;
57 virtual bool IsDynamic() const = 0;
58 virtual bool IsStatic() const = 0;
59 virtual const CClass *GetInheritsClassPtr() const = 0;
60 virtual void SetInheritsClassPtr( const CClass *pInheritsClass ) = 0;
61};
62
63class DynamicMethod : public CMethod
64{
65 bool isAbstract;
66 bool isVirtual;
67 bool isConst;
68 const CClass *pInheritsClass;
69
70 // XMLシリアライズ用
71private:
72 friend class boost::serialization::access;
73 template<class Archive> void serialize(Archive& ar, const unsigned int version)
74 {
75 trace_for_serialize( "serializing - DynamicMethod" );
76
77 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CMethod );
78 ar & BOOST_SERIALIZATION_NVP( isAbstract );
79 ar & BOOST_SERIALIZATION_NVP( isVirtual );
80 ar & BOOST_SERIALIZATION_NVP( isConst );
81 ar & boost::serialization::make_nvp("pInheritsClass", const_cast<CClass *&>(pInheritsClass));
82 }
83
84public:
85 DynamicMethod( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isAbstract, bool isVirtual, bool isConst, const CClass *pInheritsClass = NULL )
86 : CMethod( pUserProc, accessibility )
87 , isAbstract( isAbstract )
88 , isVirtual( isVirtual )
89 , isConst( isConst )
90 , pInheritsClass( pInheritsClass )
91 {
92 }
93 DynamicMethod( const CMethod &method )
94 : CMethod( &method.GetUserProc(), method.GetAccessibility() )
95 , isAbstract( method.IsAbstract() )
96 , isVirtual( method.IsVirtual() )
97 , isConst( method.IsConst() )
98 , pInheritsClass( method.GetInheritsClassPtr() )
99 {
100 }
101 DynamicMethod()
102 {
103 }
104
105 virtual bool IsAbstract() const
106 {
107 return isAbstract;
108 }
109 virtual void Override()
110 {
111 isAbstract = false;
112 }
113 virtual bool IsVirtual() const
114 {
115 return isVirtual;
116 }
117 virtual bool IsConst() const
118 {
119 return isConst;
120 }
121 virtual bool IsDynamic() const
122 {
123 return true;
124 }
125 virtual bool IsStatic() const
126 {
127 return false;
128 }
129 virtual const CClass *GetInheritsClassPtr() const
130 {
131 return pInheritsClass;
132 }
133 virtual void SetInheritsClassPtr( const CClass *pInheritsClass )
134 {
135 this->pInheritsClass = pInheritsClass;
136 }
137};
138BOOST_CLASS_EXPORT( DynamicMethod );
139class StaticMethod : public CMethod
140{
141 // XMLシリアライズ用
142private:
143 friend class boost::serialization::access;
144 template<class Archive> void serialize(Archive& ar, const unsigned int version)
145 {
146 trace_for_serialize( "serializing - StaticMethod" );
147
148 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CMethod );
149 }
150
151public:
152 StaticMethod( UserProc *pUserProc, Prototype::Accessibility accessibility )
153 : CMethod( pUserProc, accessibility )
154 {
155 }
156 StaticMethod()
157 {
158 }
159
160 virtual bool IsAbstract() const{SetError();return false;}
161 virtual void Override(){SetError();}
162 virtual bool IsVirtual() const{
163 return false;
164 }
165 virtual bool IsConst() const{SetError();return false;}
166 virtual bool IsDynamic() const
167 {
168 return false;
169 }
170 virtual bool IsStatic() const
171 {
172 return true;
173 }
174 virtual const CClass *GetInheritsClassPtr() const{SetError();return NULL;}
175 virtual void SetInheritsClassPtr( const CClass *pInheritsClass ){SetError();}
176};
177BOOST_CLASS_EXPORT( StaticMethod );
178
179class Methods : public vector<CMethod *>
180{
181 // XMLシリアライズ用
182private:
183 friend class boost::serialization::access;
184 template<class Archive> void serialize(Archive& ar, const unsigned int version)
185 {
186 trace_for_serialize( "serializing - Methods" );
187
188 ar & boost::serialization::make_nvp("vector_CMethod", boost::serialization::base_object<vector<CMethod *>>(*this));
189 }
190
191public:
192 Methods();
193 ~Methods();
194
195 //メンバ、メソッドの追加
196 void Add( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual );
197 void AddStatic(UserProc *pUserProc,Prototype::Accessibility accessibility);
198
199 // オーバーライド
200 bool Override( UserProc *pUserProc, Prototype::Accessibility accessibility );
201
202 const CMethod *GetMethodPtr( const UserProc *pUserProc ) const;
203 bool IsExist( const char *name ) const;
204 virtual void Enum( const char *methodName, vector<const UserProc *> &subs ) const;
205 virtual void Enum( BYTE idOperatorCalc, vector<const UserProc *> &subs ) const;
206
207 // 仮想メソッドの個数を取得
208 int GetVtblNum() const;
209
210 // vtblを生成
211 void GenerateVTablePart( long &vtableDataTableOffset ) const;
212};
Note: See TracBrowser for help on using the repository browser.