| 1 | #pragma once | 
|---|
| 2 |  | 
|---|
| 3 | #include <option.h> | 
|---|
| 4 | #include <Program.h> | 
|---|
| 5 | #include <Prototype.h> | 
|---|
| 6 | #include <Type.h> | 
|---|
| 7 | #include <Method.h> | 
|---|
| 8 | #include <Member.h> | 
|---|
| 9 | #include <Source.h> | 
|---|
| 10 |  | 
|---|
| 11 | class UserProc; | 
|---|
| 12 | class CClass; | 
|---|
| 13 | class Delegate; | 
|---|
| 14 |  | 
|---|
| 15 | class DynamicMethodsPrototype | 
|---|
| 16 | { | 
|---|
| 17 | // 動的メソッド | 
|---|
| 18 | Methods dynamicMethods; | 
|---|
| 19 |  | 
|---|
| 20 | // XMLシリアライズ用 | 
|---|
| 21 | private: | 
|---|
| 22 | friend class boost::serialization::access; | 
|---|
| 23 | template<class Archive> void serialize(Archive& ar, const unsigned int version) | 
|---|
| 24 | { | 
|---|
| 25 | ar & BOOST_SERIALIZATION_NVP( dynamicMethods ); | 
|---|
| 26 | } | 
|---|
| 27 |  | 
|---|
| 28 | public: | 
|---|
| 29 | DynamicMethodsPrototype(){} | 
|---|
| 30 | DynamicMethodsPrototype( const DynamicMethodsPrototype &dynamicMethodsPrototype ) | 
|---|
| 31 | : dynamicMethods( dynamicMethodsPrototype.dynamicMethods ) | 
|---|
| 32 | { | 
|---|
| 33 | } | 
|---|
| 34 | ~DynamicMethodsPrototype(){} | 
|---|
| 35 |  | 
|---|
| 36 | const Methods &GetDynamicMethods() const | 
|---|
| 37 | { | 
|---|
| 38 | return dynamicMethods; | 
|---|
| 39 | } | 
|---|
| 40 | Methods &GetDynamicMethods() | 
|---|
| 41 | { | 
|---|
| 42 | return dynamicMethods; | 
|---|
| 43 | } | 
|---|
| 44 |  | 
|---|
| 45 | void AddDynamicMethods( CMethod *pMethod ) | 
|---|
| 46 | { | 
|---|
| 47 | dynamicMethods.push_back( pMethod ); | 
|---|
| 48 | } | 
|---|
| 49 | }; | 
|---|
| 50 |  | 
|---|
| 51 | class ClassPrototype : public Prototype, public DynamicMethodsPrototype | 
|---|
| 52 | { | 
|---|
| 53 | // XMLシリアライズ用 | 
|---|
| 54 | private: | 
|---|
| 55 | friend class boost::serialization::access; | 
|---|
| 56 | template<class Archive> void serialize(Archive& ar, const unsigned int version) | 
|---|
| 57 | { | 
|---|
| 58 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Prototype ); | 
|---|
| 59 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( DynamicMethodsPrototype ); | 
|---|
| 60 | } | 
|---|
| 61 |  | 
|---|
| 62 | public: | 
|---|
| 63 | ClassPrototype( const NamespaceScopes &namespaceScopes, const string &name ) | 
|---|
| 64 | : Prototype( namespaceScopes, name ) | 
|---|
| 65 | , DynamicMethodsPrototype() | 
|---|
| 66 | { | 
|---|
| 67 | } | 
|---|
| 68 | ClassPrototype() | 
|---|
| 69 | : Prototype() | 
|---|
| 70 | , DynamicMethodsPrototype() | 
|---|
| 71 | { | 
|---|
| 72 | } | 
|---|
| 73 | }; | 
|---|
| 74 |  | 
|---|
| 75 | class Interface : public DynamicMethodsPrototype | 
|---|
| 76 | { | 
|---|
| 77 | const CClass *pInterfaceClass; | 
|---|
| 78 | mutable LONG_PTR vtblOffset; | 
|---|
| 79 |  | 
|---|
| 80 | // 型パラメータ(実パラメータ) | 
|---|
| 81 | Types actualTypeParameters; | 
|---|
| 82 |  | 
|---|
| 83 | // XMLシリアライズ用 | 
|---|
| 84 | private: | 
|---|
| 85 | friend class boost::serialization::access; | 
|---|
| 86 | template<class Archive> void serialize(Archive& ar, const unsigned int version) | 
|---|
| 87 | { | 
|---|
| 88 | trace_for_serialize( "serializing - Interface" ); | 
|---|
| 89 |  | 
|---|
| 90 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( DynamicMethodsPrototype ); | 
|---|
| 91 | ar & boost::serialization::make_nvp("pInterfaceClass", const_cast<CClass *&>(pInterfaceClass) ); | 
|---|
| 92 | ar & BOOST_SERIALIZATION_NVP( vtblOffset ); | 
|---|
| 93 | ar & BOOST_SERIALIZATION_NVP( actualTypeParameters ); | 
|---|
| 94 | } | 
|---|
| 95 |  | 
|---|
| 96 | public: | 
|---|
| 97 | Interface( const CClass *pInterfaceClass, const Types &actualTypeParameters ); | 
|---|
| 98 | Interface( const Interface &objInterface ) | 
|---|
| 99 | : DynamicMethodsPrototype( objInterface ) | 
|---|
| 100 | , pInterfaceClass( objInterface.pInterfaceClass ) | 
|---|
| 101 | , vtblOffset( objInterface.vtblOffset ) | 
|---|
| 102 | { | 
|---|
| 103 | } | 
|---|
| 104 | Interface() | 
|---|
| 105 | { | 
|---|
| 106 | } | 
|---|
| 107 |  | 
|---|
| 108 | const CClass &GetClass() const{ | 
|---|
| 109 | return *pInterfaceClass; | 
|---|
| 110 | } | 
|---|
| 111 | LONG_PTR GetVtblOffset() const | 
|---|
| 112 | { | 
|---|
| 113 | return vtblOffset; | 
|---|
| 114 | } | 
|---|
| 115 | void SetVtblOffset( LONG_PTR vtblOffset ) const | 
|---|
| 116 | { | 
|---|
| 117 | this->vtblOffset = vtblOffset; | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | const Types &GetActualTypeParameters() const | 
|---|
| 121 | { | 
|---|
| 122 | return actualTypeParameters; | 
|---|
| 123 | } | 
|---|
| 124 |  | 
|---|
| 125 | std::string GetFullNameWithActualGenericTypeParameters() const; | 
|---|
| 126 | }; | 
|---|
| 127 | typedef std::vector<Interface *> Interfaces; | 
|---|
| 128 |  | 
|---|
| 129 | class CClass: public ClassPrototype, public Jenga::Common::ObjectInHashmap<CClass> | 
|---|
| 130 | { | 
|---|
| 131 | public: | 
|---|
| 132 | // 型の種類 | 
|---|
| 133 | enum ClassType{ | 
|---|
| 134 | Class, | 
|---|
| 135 | Interface, | 
|---|
| 136 | ComInterface, | 
|---|
| 137 | Enum, | 
|---|
| 138 | Delegate, | 
|---|
| 139 | Structure, | 
|---|
| 140 | }; | 
|---|
| 141 |  | 
|---|
| 142 | private: | 
|---|
| 143 | ClassType classType; | 
|---|
| 144 |  | 
|---|
| 145 | // importされている名前空間 | 
|---|
| 146 | NamespaceScopesCollection importedNamespaces; | 
|---|
| 147 |  | 
|---|
| 148 | // 型パラメータ | 
|---|
| 149 | GenericTypes formalGenericTypes; | 
|---|
| 150 |  | 
|---|
| 151 | // 基底クラス | 
|---|
| 152 | const CClass *pSuperClass; | 
|---|
| 153 |  | 
|---|
| 154 | // 基底クラスの型パラメータ(実パラメータ) | 
|---|
| 155 | Types superClassActualTypeParameters; | 
|---|
| 156 |  | 
|---|
| 157 | // Blittable型情報 | 
|---|
| 158 | Type blittableType; | 
|---|
| 159 |  | 
|---|
| 160 | // 実装するインターフェイス | 
|---|
| 161 | Interfaces interfaces; | 
|---|
| 162 |  | 
|---|
| 163 | // 動的メンバ | 
|---|
| 164 | Members dynamicMembers; | 
|---|
| 165 |  | 
|---|
| 166 | // 静的メンバ | 
|---|
| 167 | Members staticMembers; | 
|---|
| 168 |  | 
|---|
| 169 | // 動的メソッド | 
|---|
| 170 | int ConstructorMemberSubIndex; | 
|---|
| 171 | int DestructorMemberSubIndex; | 
|---|
| 172 | int vtblNum;                    // 仮想関数の数 | 
|---|
| 173 |  | 
|---|
| 174 | // 静的メソッド | 
|---|
| 175 | Methods staticMethods; | 
|---|
| 176 |  | 
|---|
| 177 | //アラインメント値 | 
|---|
| 178 | int fixedAlignment; | 
|---|
| 179 |  | 
|---|
| 180 | // XMLシリアライズ用 | 
|---|
| 181 | private: | 
|---|
| 182 | friend class boost::serialization::access; | 
|---|
| 183 | template<class Archive> void serialize(Archive& ar, const unsigned int version) | 
|---|
| 184 | { | 
|---|
| 185 | trace_for_serialize( "serializing - CClass" ); | 
|---|
| 186 |  | 
|---|
| 187 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( ClassPrototype ); | 
|---|
| 188 | ar & BOOST_SERIALIZATION_NVP( classType ); | 
|---|
| 189 | ar & BOOST_SERIALIZATION_NVP( importedNamespaces ); | 
|---|
| 190 | ar & BOOST_SERIALIZATION_NVP( formalGenericTypes ); | 
|---|
| 191 | ar & boost::serialization::make_nvp( "pSuperClass", const_cast<CClass *&>(pSuperClass) ); | 
|---|
| 192 | ar & BOOST_SERIALIZATION_NVP( superClassActualTypeParameters ); | 
|---|
| 193 | ar & BOOST_SERIALIZATION_NVP( blittableType ); | 
|---|
| 194 | ar & BOOST_SERIALIZATION_NVP( interfaces ); | 
|---|
| 195 | ar & BOOST_SERIALIZATION_NVP( dynamicMembers ); | 
|---|
| 196 | ar & BOOST_SERIALIZATION_NVP( staticMembers ); | 
|---|
| 197 | ar & BOOST_SERIALIZATION_NVP( ConstructorMemberSubIndex ); | 
|---|
| 198 | ar & BOOST_SERIALIZATION_NVP( DestructorMemberSubIndex ); | 
|---|
| 199 | ar & BOOST_SERIALIZATION_NVP( vtblNum ); | 
|---|
| 200 | ar & BOOST_SERIALIZATION_NVP( staticMethods ); | 
|---|
| 201 | ar & BOOST_SERIALIZATION_NVP( fixedAlignment ); | 
|---|
| 202 | } | 
|---|
| 203 |  | 
|---|
| 204 | bool isReady; | 
|---|
| 205 | public: | 
|---|
| 206 |  | 
|---|
| 207 | CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ) | 
|---|
| 208 | : ClassPrototype( namespaceScopes, name ) | 
|---|
| 209 | , importedNamespaces( importedNamespaces ) | 
|---|
| 210 | , classType( Class ) | 
|---|
| 211 | , pSuperClass( NULL ) | 
|---|
| 212 | , blittableType( Type() ) | 
|---|
| 213 | , isReady( false ) | 
|---|
| 214 | , fixedAlignment( 0 ) | 
|---|
| 215 | , ConstructorMemberSubIndex( -1 ) | 
|---|
| 216 | , DestructorMemberSubIndex( -1 ) | 
|---|
| 217 | , vtblNum( 0 ) | 
|---|
| 218 | , vtbl_offset( -1 ) | 
|---|
| 219 | , comVtblOffset( 0 ) | 
|---|
| 220 | , isCompilingConstructor( false ) | 
|---|
| 221 | , isCompilingDestructor( false ) | 
|---|
| 222 | , pobj_NextClass( NULL ) | 
|---|
| 223 | , cacheSize( 0 ) | 
|---|
| 224 | { | 
|---|
| 225 | } | 
|---|
| 226 | CClass() | 
|---|
| 227 | : ClassPrototype() | 
|---|
| 228 | , importedNamespaces() | 
|---|
| 229 | , classType() | 
|---|
| 230 | , pSuperClass( NULL ) | 
|---|
| 231 | , blittableType( Type() ) | 
|---|
| 232 | , isReady( false ) | 
|---|
| 233 | , fixedAlignment( 0 ) | 
|---|
| 234 | , ConstructorMemberSubIndex( -1 ) | 
|---|
| 235 | , DestructorMemberSubIndex( -1 ) | 
|---|
| 236 | , vtblNum( 0 ) | 
|---|
| 237 | , vtbl_offset( -1 ) | 
|---|
| 238 | , comVtblOffset( 0 ) | 
|---|
| 239 | , isCompilingConstructor( false ) | 
|---|
| 240 | , isCompilingDestructor( false ) | 
|---|
| 241 | , pobj_NextClass( NULL ) | 
|---|
| 242 | , cacheSize( 0 ) | 
|---|
| 243 | { | 
|---|
| 244 | } | 
|---|
| 245 | ~CClass() | 
|---|
| 246 | { | 
|---|
| 247 | // 動的メンバ | 
|---|
| 248 | BOOST_FOREACH( CMember *member, dynamicMembers ) | 
|---|
| 249 | { | 
|---|
| 250 | delete member; | 
|---|
| 251 | } | 
|---|
| 252 |  | 
|---|
| 253 | // 静的メンバ | 
|---|
| 254 | BOOST_FOREACH( CMember *member, staticMembers ) | 
|---|
| 255 | { | 
|---|
| 256 | delete member; | 
|---|
| 257 | } | 
|---|
| 258 |  | 
|---|
| 259 | // インターフェイス | 
|---|
| 260 | BOOST_FOREACH( ::Interface *pInterface, interfaces ) | 
|---|
| 261 | { | 
|---|
| 262 | delete pInterface; | 
|---|
| 263 | } | 
|---|
| 264 | } | 
|---|
| 265 |  | 
|---|
| 266 | virtual const std::string &GetKeyName() const | 
|---|
| 267 | { | 
|---|
| 268 | return GetName(); | 
|---|
| 269 | } | 
|---|
| 270 | virtual bool IsDuplication( const CClass *pClass ) const | 
|---|
| 271 | { | 
|---|
| 272 | if( pClass->IsEqualSymbol( *this ) ) | 
|---|
| 273 | { | 
|---|
| 274 | return true; | 
|---|
| 275 | } | 
|---|
| 276 | return false; | 
|---|
| 277 | } | 
|---|
| 278 |  | 
|---|
| 279 | void Readed(){ | 
|---|
| 280 | isReady = true; | 
|---|
| 281 | } | 
|---|
| 282 | bool IsReady() const{ | 
|---|
| 283 | return isReady; | 
|---|
| 284 | } | 
|---|
| 285 |  | 
|---|
| 286 | const NamespaceScopesCollection &GetImportedNamespaces() const | 
|---|
| 287 | { | 
|---|
| 288 | return importedNamespaces; | 
|---|
| 289 | } | 
|---|
| 290 |  | 
|---|
| 291 | // 型パラメータ | 
|---|
| 292 | void AddFormalGenericType( GenericType genericType ) | 
|---|
| 293 | { | 
|---|
| 294 | this->formalGenericTypes.push_back( genericType ); | 
|---|
| 295 | } | 
|---|
| 296 | int GetFormalGenericTypeParameterIndex( const std::string &name ) const | 
|---|
| 297 | { | 
|---|
| 298 | int i = 0; | 
|---|
| 299 | BOOST_FOREACH( const GenericType &genericType, formalGenericTypes ) | 
|---|
| 300 | { | 
|---|
| 301 | if( genericType.GetName() == name ) | 
|---|
| 302 | { | 
|---|
| 303 | return i; | 
|---|
| 304 | } | 
|---|
| 305 | i++; | 
|---|
| 306 | } | 
|---|
| 307 | return -1; | 
|---|
| 308 | } | 
|---|
| 309 | bool IsExistFormalGenericTypeParameter( const std::string &name ) const | 
|---|
| 310 | { | 
|---|
| 311 | BOOST_FOREACH( const GenericType &genericType, formalGenericTypes ) | 
|---|
| 312 | { | 
|---|
| 313 | if( genericType.GetName() == name ) | 
|---|
| 314 | { | 
|---|
| 315 | return true; | 
|---|
| 316 | } | 
|---|
| 317 | } | 
|---|
| 318 | return false; | 
|---|
| 319 | } | 
|---|
| 320 | bool IsGeneric() const | 
|---|
| 321 | { | 
|---|
| 322 | return ( this->formalGenericTypes.size() != 0 ); | 
|---|
| 323 | } | 
|---|
| 324 |  | 
|---|
| 325 | // 継承元クラス | 
|---|
| 326 | bool HasSuperClass() const | 
|---|
| 327 | { | 
|---|
| 328 | return ( pSuperClass != NULL ); | 
|---|
| 329 | } | 
|---|
| 330 | const CClass &GetSuperClass() const | 
|---|
| 331 | { | 
|---|
| 332 | return *pSuperClass; | 
|---|
| 333 | } | 
|---|
| 334 | void SetSuperClass( const CClass *pSuperClass ) | 
|---|
| 335 | { | 
|---|
| 336 | this->pSuperClass = pSuperClass; | 
|---|
| 337 | } | 
|---|
| 338 | const Types &GetSuperClassActualTypeParameters() const | 
|---|
| 339 | { | 
|---|
| 340 | return superClassActualTypeParameters; | 
|---|
| 341 | } | 
|---|
| 342 | void SetSuperClassActualTypeParameters( const Types &actualTypeParameters ) | 
|---|
| 343 | { | 
|---|
| 344 | this->superClassActualTypeParameters = actualTypeParameters; | 
|---|
| 345 | } | 
|---|
| 346 |  | 
|---|
| 347 | // Blittable型 | 
|---|
| 348 | bool IsBlittableType() const | 
|---|
| 349 | { | 
|---|
| 350 | return !blittableType.IsNull(); | 
|---|
| 351 | } | 
|---|
| 352 | const Type &GetBlittableType() const | 
|---|
| 353 | { | 
|---|
| 354 | return blittableType; | 
|---|
| 355 | } | 
|---|
| 356 | void SetBlittableType( const Type &type ){ | 
|---|
| 357 | blittableType = type; | 
|---|
| 358 | } | 
|---|
| 359 |  | 
|---|
| 360 | bool IsClass() const; | 
|---|
| 361 | bool IsInterface() const; | 
|---|
| 362 | bool IsComInterface() const; | 
|---|
| 363 | bool IsEnum() const; | 
|---|
| 364 | bool IsDelegate() const; | 
|---|
| 365 | bool IsStructure() const; | 
|---|
| 366 | void SetClassType( ClassType classType ) | 
|---|
| 367 | { | 
|---|
| 368 | this->classType = classType; | 
|---|
| 369 | } | 
|---|
| 370 |  | 
|---|
| 371 |  | 
|---|
| 372 | //コンストラクタをコンパイルしているかどうかのチェックフラグ | 
|---|
| 373 | private: | 
|---|
| 374 | mutable bool isCompilingConstructor; | 
|---|
| 375 | public: | 
|---|
| 376 | void NotifyStartConstructorCompile() const; | 
|---|
| 377 | void NotifyFinishConstructorCompile() const; | 
|---|
| 378 | bool IsCompilingConstructor() const; | 
|---|
| 379 |  | 
|---|
| 380 | //デストラクタをコンパイルしているかどうかのチェックフラグ | 
|---|
| 381 | private: | 
|---|
| 382 | mutable bool isCompilingDestructor; | 
|---|
| 383 | public: | 
|---|
| 384 | void NotifyStartDestructorCompile() const; | 
|---|
| 385 | void NotifyFinishDestructorCompile() const; | 
|---|
| 386 | bool IsCompilingDestructor() const; | 
|---|
| 387 |  | 
|---|
| 388 |  | 
|---|
| 389 | //自身の派生クラスかどうかを確認 | 
|---|
| 390 | bool IsSubClass( const CClass *pClass ) const; | 
|---|
| 391 |  | 
|---|
| 392 | //自身と等しいまたは派生クラスかどうかを確認 | 
|---|
| 393 | bool IsEqualsOrSubClass( const CClass *pClass ) const; | 
|---|
| 394 |  | 
|---|
| 395 | // 自身と等しいまたは派生クラス、基底クラスかどうかを確認 | 
|---|
| 396 | bool IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const; | 
|---|
| 397 |  | 
|---|
| 398 | // インターフェイス | 
|---|
| 399 | bool HasInterfaces() const | 
|---|
| 400 | { | 
|---|
| 401 | return ( interfaces.size() != 0 ); | 
|---|
| 402 | } | 
|---|
| 403 | const Interfaces &GetInterfaces() const | 
|---|
| 404 | { | 
|---|
| 405 | return interfaces; | 
|---|
| 406 | } | 
|---|
| 407 | bool IsInheritsInterface( const CClass *pInterfaceClass ) const; | 
|---|
| 408 |  | 
|---|
| 409 | // クラス継承 | 
|---|
| 410 | bool Inherits( const char *inheritNames, int nowLine ); | 
|---|
| 411 | bool InheritsClass( const CClass &inheritsClass, const Types &actualTypeParameters, int nowLine ); | 
|---|
| 412 | bool InheritsInterface( const CClass &inheritsClass, int nowLine ); | 
|---|
| 413 |  | 
|---|
| 414 | // インターフェイス実装 | 
|---|
| 415 | bool Implements( const CClass &interfaceClass, const Types &actualTypeParameters, int nowLine ); | 
|---|
| 416 | bool Implements( const char *interfaceNames, int nowLine ); | 
|---|
| 417 |  | 
|---|
| 418 | //メンバ、メソッドの追加 | 
|---|
| 419 | CMember *CreateMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ); | 
|---|
| 420 | void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer, int nowLine ); | 
|---|
| 421 | void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ); | 
|---|
| 422 |  | 
|---|
| 423 | void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, | 
|---|
| 424 | bool isVirtual, bool isOverride, bool isAutoGeneration, char *buffer, int nowLine); | 
|---|
| 425 |  | 
|---|
| 426 | //重複チェック | 
|---|
| 427 | bool DupliCheckAll(const char *name) const; | 
|---|
| 428 | bool DupliCheckMember(const char *name) const; | 
|---|
| 429 |  | 
|---|
| 430 | const Members &GetDynamicMembers() const | 
|---|
| 431 | { | 
|---|
| 432 | return dynamicMembers; | 
|---|
| 433 | } | 
|---|
| 434 | const Members &GetStaticMembers() const | 
|---|
| 435 | { | 
|---|
| 436 | return staticMembers; | 
|---|
| 437 | } | 
|---|
| 438 | Members &GetDynamicMembers() | 
|---|
| 439 | { | 
|---|
| 440 | return dynamicMembers; | 
|---|
| 441 | } | 
|---|
| 442 | Members &GetStaticMembers() | 
|---|
| 443 | { | 
|---|
| 444 | return staticMembers; | 
|---|
| 445 | } | 
|---|
| 446 |  | 
|---|
| 447 | const CMember *FindDynamicMember( const char *memberName ) const; | 
|---|
| 448 | bool HasDynamicMember( const char *memberName ) const | 
|---|
| 449 | { | 
|---|
| 450 | return ( FindDynamicMember( memberName ) != NULL ); | 
|---|
| 451 | } | 
|---|
| 452 |  | 
|---|
| 453 | void EnumDynamicMethodsOrInterfaceMethods( const char *methodName, std::vector<const UserProc *> &subs ) const; | 
|---|
| 454 | const CMethod *GetDynamicMethodOrInterfaceMethod( const UserProc *pUserProc ) const; | 
|---|
| 455 |  | 
|---|
| 456 | const Methods &GetStaticMethods() const | 
|---|
| 457 | { | 
|---|
| 458 | return staticMethods; | 
|---|
| 459 | } | 
|---|
| 460 | Methods &GetStaticMethods() | 
|---|
| 461 | { | 
|---|
| 462 | return staticMethods; | 
|---|
| 463 | } | 
|---|
| 464 |  | 
|---|
| 465 | //デフォルト コンストラクタ | 
|---|
| 466 | const CMethod *GetConstructorMethod() const | 
|---|
| 467 | { | 
|---|
| 468 | if( ConstructorMemberSubIndex == -1 ) return NULL; | 
|---|
| 469 | return GetDynamicMethods()[ConstructorMemberSubIndex]; | 
|---|
| 470 | } | 
|---|
| 471 | void SetConstructorMemberSubIndex( int constructorMemberSubIndex ) | 
|---|
| 472 | { | 
|---|
| 473 | this->ConstructorMemberSubIndex = constructorMemberSubIndex; | 
|---|
| 474 | } | 
|---|
| 475 |  | 
|---|
| 476 | //デストラクタ メソッドを取得 | 
|---|
| 477 | const CMethod *GetDestructorMethod() const | 
|---|
| 478 | { | 
|---|
| 479 | if( DestructorMemberSubIndex == -1 ) return NULL; | 
|---|
| 480 | return GetDynamicMethods()[DestructorMemberSubIndex]; | 
|---|
| 481 | } | 
|---|
| 482 | void SetDestructorMemberSubIndex( int destructorMemberSubIndex ) | 
|---|
| 483 | { | 
|---|
| 484 | this->DestructorMemberSubIndex = destructorMemberSubIndex; | 
|---|
| 485 | } | 
|---|
| 486 |  | 
|---|
| 487 | // デリゲート情報を取得 | 
|---|
| 488 | const ::Delegate &GetDelegate() const; | 
|---|
| 489 |  | 
|---|
| 490 | // ユーザ指定のアラインメント固定値 | 
|---|
| 491 | int GetFixedAlignment() const | 
|---|
| 492 | { | 
|---|
| 493 | return fixedAlignment; | 
|---|
| 494 | } | 
|---|
| 495 | void SetFixedAlignment( int fixedAlignment ) | 
|---|
| 496 | { | 
|---|
| 497 | this->fixedAlignment = fixedAlignment; | 
|---|
| 498 | } | 
|---|
| 499 |  | 
|---|
| 500 | // メンバの総合サイズを取得 | 
|---|
| 501 | private: | 
|---|
| 502 | int cacheSize; | 
|---|
| 503 | public: | 
|---|
| 504 | int GetSize() const; | 
|---|
| 505 |  | 
|---|
| 506 | // メンバのオフセットを取得 | 
|---|
| 507 | int GetMemberOffset( const char *memberName ) const; | 
|---|
| 508 | private: | 
|---|
| 509 | // アラインメント値を取得 | 
|---|
| 510 | int GetAlignment() const; | 
|---|
| 511 |  | 
|---|
| 512 |  | 
|---|
| 513 | ///////////////////////////////////////////////////////////////// | 
|---|
| 514 | // vtbl | 
|---|
| 515 | ///////////////////////////////////////////////////////////////// | 
|---|
| 516 | public: | 
|---|
| 517 | // vtblに存在する仮想関数の数 | 
|---|
| 518 | int GetVtblNum() const | 
|---|
| 519 | { | 
|---|
| 520 | return vtblNum; | 
|---|
| 521 | } | 
|---|
| 522 | void SetVtblNum( int vtblNum ) | 
|---|
| 523 | { | 
|---|
| 524 | this->vtblNum = vtblNum; | 
|---|
| 525 | } | 
|---|
| 526 | void AddVtblNum( int vtblNum ) | 
|---|
| 527 | { | 
|---|
| 528 | this->vtblNum += vtblNum; | 
|---|
| 529 | } | 
|---|
| 530 | bool IsExistVirtualFunctions() const | 
|---|
| 531 | { | 
|---|
| 532 | // 構造体以外は仮想関数を持つ | 
|---|
| 533 | return !IsStructure(); | 
|---|
| 534 | } | 
|---|
| 535 |  | 
|---|
| 536 | private: | 
|---|
| 537 | long vtbl_offset; | 
|---|
| 538 | long comVtblOffset; | 
|---|
| 539 | long vtblMasterListOffset; | 
|---|
| 540 | std::vector<long> vtblMasterList; | 
|---|
| 541 | public: | 
|---|
| 542 | void GetVtblMasterListIndexAndVtblIndex( const UserProc *pUserProc, int &vtblMasterListIndex, int &vtblIndex ) const; | 
|---|
| 543 | int GetVtblMasterListIndex( const CClass *pClass ) const; | 
|---|
| 544 | long GetComVtblOffset() const; | 
|---|
| 545 | long GetVtblMasterListOffset() const; | 
|---|
| 546 | void GenerateVTableMasterList( const std::vector<long> &vtableMasterList, long &offset ); | 
|---|
| 547 | void GenerateFullVTables(); | 
|---|
| 548 | void ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ); | 
|---|
| 549 | bool IsAbstract() const; | 
|---|
| 550 |  | 
|---|
| 551 |  | 
|---|
| 552 | // TypeInfo用 | 
|---|
| 553 | mutable int typeInfoDataTableOffset; | 
|---|
| 554 | void SetTypeInfoDataTableOffset( int typeInfoDataTableOffset ) const | 
|---|
| 555 | { | 
|---|
| 556 | this->typeInfoDataTableOffset = typeInfoDataTableOffset; | 
|---|
| 557 | } | 
|---|
| 558 | int GetTypeInfoDataTableOffset() const | 
|---|
| 559 | { | 
|---|
| 560 | return typeInfoDataTableOffset; | 
|---|
| 561 | } | 
|---|
| 562 |  | 
|---|
| 563 | // 動的型データ用のメンバデータを取得 | 
|---|
| 564 | std::string GetStaticDefiningStringAsMemberNames() const; | 
|---|
| 565 | std::string GetStaticDefiningStringAsMemberTypeInfoNames() const; | 
|---|
| 566 | std::string GetStaticDefiningStringAsMemberOffsets() const; | 
|---|
| 567 | void GetReferenceOffsetsInitializeBuffer( std::string &referenceOffsetsBuffer, int &numOfReference, int baseOffset = 0 ) const; | 
|---|
| 568 |  | 
|---|
| 569 |  | 
|---|
| 570 | //線形リスト用 | 
|---|
| 571 | CClass *pobj_NextClass; | 
|---|
| 572 | }; | 
|---|
| 573 |  | 
|---|
| 574 | class Classes : public Jenga::Common::Hashmap<CClass> | 
|---|
| 575 | { | 
|---|
| 576 | // XMLシリアライズ用 | 
|---|
| 577 | public: | 
|---|
| 578 | Classes() | 
|---|
| 579 | : pCompilingMethod( NULL ) | 
|---|
| 580 | , pStringClass( NULL ) | 
|---|
| 581 | , pObjectClass( NULL ) | 
|---|
| 582 | , pInterfaceInfo( NULL ) | 
|---|
| 583 | { | 
|---|
| 584 | } | 
|---|
| 585 | ~Classes() | 
|---|
| 586 | { | 
|---|
| 587 | } | 
|---|
| 588 |  | 
|---|
| 589 | virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name); | 
|---|
| 590 | bool Insert( CClass *pClass, int nowLine ); | 
|---|
| 591 | CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); | 
|---|
| 592 | virtual void CollectClassesForNameOnly( const BasicSource &source ); | 
|---|
| 593 |  | 
|---|
| 594 | // vtblを一時的に生成 | 
|---|
| 595 | void GenerateVTables(); | 
|---|
| 596 |  | 
|---|
| 597 | // vtblのを正規のオフセットで再構築 | 
|---|
| 598 | void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ); | 
|---|
| 599 |  | 
|---|
| 600 | virtual void InitStaticMember(); | 
|---|
| 601 |  | 
|---|
| 602 | private: | 
|---|
| 603 | bool MemberVar_LoopRefCheck(const CClass &objClass); | 
|---|
| 604 | public: | 
|---|
| 605 | virtual void GetClass_recur(const char *lpszInheritsClass); | 
|---|
| 606 | void LookaheadClass( const char *className ); | 
|---|
| 607 | bool LoopRefCheck( const CClass &objClass ); | 
|---|
| 608 | virtual void GetAllClassInfo(); | 
|---|
| 609 | virtual void Compile_System_InitializeUserTypes(); | 
|---|
| 610 | virtual void Compile_System_InitializeUserTypesForBaseType(); | 
|---|
| 611 |  | 
|---|
| 612 | const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const; | 
|---|
| 613 | const CClass *Find( const string &fullName ) const; | 
|---|
| 614 |  | 
|---|
| 615 |  | 
|---|
| 616 | ///////////////////////////// | 
|---|
| 617 | // 現在コンパイル中の情報 | 
|---|
| 618 | ///////////////////////////// | 
|---|
| 619 | private: | 
|---|
| 620 | const CMethod *pCompilingMethod; | 
|---|
| 621 | public: | 
|---|
| 622 | void StartCompile( const UserProc *pUserProc ); | 
|---|
| 623 |  | 
|---|
| 624 | //現在コンパイル中のメソッド情報を取得 | 
|---|
| 625 | const CMethod *GetNowCompilingMethodInfo(){ | 
|---|
| 626 | return pCompilingMethod; | 
|---|
| 627 | } | 
|---|
| 628 |  | 
|---|
| 629 |  | 
|---|
| 630 | ///////////////////////////// | 
|---|
| 631 | // 特殊クラス | 
|---|
| 632 | ///////////////////////////// | 
|---|
| 633 | mutable const CClass *pStringClass; | 
|---|
| 634 | mutable const CClass *pObjectClass; | 
|---|
| 635 | mutable const CClass *pInterfaceInfo; | 
|---|
| 636 | const CClass *GetStringClassPtr() const; | 
|---|
| 637 | const CClass *GetObjectClassPtr() const; | 
|---|
| 638 | const CClass *GetInterfaceInfoClassPtr() const; | 
|---|
| 639 | }; | 
|---|