Changeset 114 in dev for BasicCompiler_Common
- Timestamp:
- May 10, 2007, 8:52:40 PM (18 years ago)
- Location:
- BasicCompiler_Common
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r108 r114 9 9 CDBClass *pobj_DBClass; 10 10 11 CClass *pobj_CompilingClass;12 CClass *pobj_StringClass;11 const CClass *pobj_CompilingClass; 12 const CClass *pobj_StringClass; 13 13 14 14 CMember *pCompilingMethod; … … 224 224 return isUsing; 225 225 } 226 void CClass::Using(){ 226 void CClass::Using() const 227 { 227 228 isUsing = true; 228 229 } … … 249 250 } 250 251 251 bool CClass::Inherits( CClass &inheritsClass, int nowLine ){252 bool CClass::Inherits( const CClass &inheritsClass, int nowLine ){ 252 253 253 254 //ループ継承でないかをチェック … … 309 310 return true; 310 311 } 311 bool CClass::InheritsInterface( CClass &inheritsInterface, int nowLine ){312 bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){ 312 313 313 314 //ループ継承でないかをチェック … … 615 616 return n; 616 617 } 617 LONG_PTR CClass::GetVtblGlobalOffset(void){ 618 LONG_PTR CClass::GetVtblGlobalOffset(void) const 619 { 618 620 619 621 //既に存在する場合はそれを返す … … 688 690 689 691 // コンストラクタのコンパイルを開始 690 void CClass::NotifyStartConstructorCompile(){ 692 void CClass::NotifyStartConstructorCompile() const 693 { 691 694 isCompilingConstructor = true; 692 695 } 693 696 694 697 //コンストラクタのコンパイルを終了 695 void CClass::NotifyFinishConstructorCompile(){ 698 void CClass::NotifyFinishConstructorCompile() const 699 { 696 700 isCompilingConstructor = false; 697 701 } … … 704 708 705 709 //デストラクタのコンパイルを開始 706 void CClass::NotifyStartDestructorCompile() {710 void CClass::NotifyStartDestructorCompile() const{ 707 711 isCompilingDestructor = true; 708 712 } 709 713 710 714 //デストラクタのコンパイルを終了 711 void CClass::NotifyFinishDestructorCompile() {715 void CClass::NotifyFinishDestructorCompile() const{ 712 716 isCompilingDestructor = false; 713 717 } … … 810 814 } 811 815 812 CClass *CDBClass::Find( const string &fullName ) const 813 { 814 char AreaName[VN_SIZE] = ""; //オブジェクト変数 815 char NestName[VN_SIZE] = ""; //入れ子メンバ 816 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 817 818 int key; 819 key=hash(NestName); 820 821 if(pobj_ClassHash[key]){ 822 CClass *pobj_c; 823 pobj_c=pobj_ClassHash[key]; 824 while(1){ 825 if( pobj_c->IsEqualSymbol( fullName ) ){ 826 //名前空間とクラス名が一致した 827 return pobj_c; 828 } 829 830 if(pobj_c->pobj_NextClass==0) break; 831 pobj_c=pobj_c->pobj_NextClass; 832 } 833 } 834 return NULL; 835 } 836 CClass *CDBClass::Find( const NamespaceScopes &namespaceScopes, const string &name ) const 816 const CClass *CDBClass::Find( const NamespaceScopes &namespaceScopes, const string &name ) const 837 817 { 838 818 int key; … … 852 832 } 853 833 } 834 835 // TypeDefも見る 836 int index = Smoothie::Meta::typeDefs.GetIndex( namespaceScopes, name ); 837 if( index != -1 ){ 838 Type type = Smoothie::Meta::typeDefs[index].GetBaseType(); 839 if( type.IsObject() ){ 840 return &type.GetClass(); 841 } 842 } 843 854 844 return NULL; 845 } 846 const CClass *CDBClass::Find( const string &fullName ) const 847 { 848 char AreaName[VN_SIZE] = ""; //オブジェクト変数 849 char NestName[VN_SIZE] = ""; //入れ子メンバ 850 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 851 852 return Find( NamespaceScopes( AreaName ), NestName ); 855 853 } 856 854 … … 1213 1211 GetIdentifierToken( temporary, basbuf, i ); 1214 1212 1215 CClass *pobj_c =pobj_DBClass->Find(namespaceScopes, temporary);1213 CClass *pobj_c = const_cast<CClass *>( pobj_DBClass->Find(namespaceScopes, temporary) ); 1216 1214 if(!pobj_c) continue; 1217 1215 … … 1251 1249 1252 1250 //継承元クラスを取得 1253 CClass *pInheritsClass = Find(temporary);1251 const CClass *pInheritsClass = Find(temporary); 1254 1252 if( !pInheritsClass ){ 1255 1253 SetError(106,temporary,i); … … 1359 1357 GetIdentifierToken( temporary, basbuf, i ); 1360 1358 1361 CClass *pobj_c =pobj_DBClass->Find(namespaceScopes, temporary);1359 CClass *pobj_c = const_cast<CClass *>( pobj_DBClass->Find(namespaceScopes, temporary) ); 1362 1360 if(!pobj_c) continue; 1363 1361 … … 1416 1414 1417 1415 //継承元クラスを取得 1418 CClass *pInheritsClass = Find(temporary);1416 const CClass *pInheritsClass = Find(temporary); 1419 1417 if( !pInheritsClass ){ 1420 1418 SetError(106,temporary,i); … … 1424 1422 if( pInheritsClass->IsInterface() ){ 1425 1423 // クラスを継承していないとき 1426 CClass *pObjectClass = Find("Object");1424 const CClass *pObjectClass = Find("Object"); 1427 1425 if( !pObjectClass ){ 1428 1426 SetError(106,"Object",i); … … 1806 1804 } 1807 1805 } 1808 CClass *CDBClass::GetNowCompilingClass(){ 1806 const CClass *CDBClass::GetNowCompilingClass() const 1807 { 1809 1808 return pCompilingClass; 1810 1809 } -
BasicCompiler_Common/Class.h
r108 r114 48 48 bool isStatic; 49 49 50 CClass *pobj_InheritsClass;50 const CClass *pobj_InheritsClass; 51 51 52 52 CMethod(CMethod *pobj); … … 87 87 ClassType classType; 88 88 89 bool isUsing;89 mutable bool isUsing; 90 90 91 91 public: … … 94 94 95 95 //継承クラスへのポインタ 96 CClass *pobj_InheritsClass;96 const CClass *pobj_InheritsClass; 97 97 98 98 //メンバ情報 … … 130 130 131 131 bool IsUsing() const; 132 void Using() ;132 void Using() const; 133 133 134 134 bool IsClass() const; … … 139 139 140 140 //継承させる 141 bool Inherits( CClass &inheritsClass, int nowLine );142 bool InheritsInterface( CClass &inheritsClass, int nowLine );141 bool Inherits( const CClass &inheritsClass, int nowLine ); 142 bool InheritsInterface( const CClass &inheritsClass, int nowLine ); 143 143 144 144 //メンバ、メソッドの追加 … … 192 192 //vtbl 193 193 private: 194 long vtbl_offset;194 mutable long vtbl_offset; 195 195 public: 196 196 int GetFuncNumInVtbl( const UserProc *pUserProc ) const; 197 LONG_PTR GetVtblGlobalOffset(void) ;197 LONG_PTR GetVtblGlobalOffset(void) const; 198 198 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 199 199 bool IsAbstract() const; … … 202 202 //コンストラクタをコンパイルしているかどうかのチェックフラグ 203 203 private: 204 bool isCompilingConstructor;205 public: 206 void NotifyStartConstructorCompile() ;207 void NotifyFinishConstructorCompile() ;204 mutable bool isCompilingConstructor; 205 public: 206 void NotifyStartConstructorCompile() const; 207 void NotifyFinishConstructorCompile() const; 208 208 bool IsCompilingConstructor() const; 209 209 210 210 //デストラクタをコンパイルしているかどうかのチェックフラグ 211 211 private: 212 bool isCompilingDestructor;213 public: 214 void NotifyStartDestructorCompile() ;215 void NotifyFinishDestructorCompile() ;212 mutable bool isCompilingDestructor; 213 public: 214 void NotifyStartDestructorCompile() const; 215 void NotifyFinishDestructorCompile() const; 216 216 bool IsCompilingDestructor() const; 217 217 … … 252 252 ~CDBClass(); 253 253 254 CClass *Find( const string &fullName ) const;255 CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const;254 const CClass *Find( const string &fullName ) const; 255 const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const; 256 256 257 257 CClass *AddClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); … … 283 283 ///////////////////////////// 284 284 private: 285 CClass *pCompilingClass;285 const CClass *pCompilingClass; 286 286 CMethod *pCompilingMethod; 287 287 public: … … 290 290 291 291 //現在コンパイル中のメソッド情報を取得 292 CClass *GetNowCompilingClass();292 const CClass *GetNowCompilingClass() const; 293 293 CMethod *GetNowCompilingMethodInfo(); 294 294 … … 311 311 312 312 extern CDBClass *pobj_DBClass; 313 extern CClass *pobj_CompilingClass;313 extern const CClass *pobj_CompilingClass; -
BasicCompiler_Common/DebugMiddleFile.cpp
r113 r114 428 428 char temp2[MAX_PATH],*temp5; 429 429 430 extern CClass *pobj_CompilingClass; 431 pobj_CompilingClass=0; 430 pobj_CompilingClass = NULL; 432 431 433 432 i2=0; … … 585 584 i2+=lstrlen(buffer+i2)+1; 586 585 587 CClass *pClass = NULL;588 if(szParentClassName[0]) 586 const CClass *pClass = NULL; 587 if(szParentClassName[0]){ 589 588 pClass=pobj_DBClass->Find(szParentClassName); 589 } 590 590 591 591 //ID … … 691 691 i2+=lstrlen(buffer+i2)+1; 692 692 693 pobj_c =pobj_DBClass->Find(szClassName);693 pobj_c = const_cast<CClass *>( pobj_DBClass->Find(szClassName) ); 694 694 695 695 //仮想関数の数 … … 741 741 i2+=lstrlen(buffer+i2)+1; 742 742 743 CClass *pobj_InheritsClass = NULL;743 const CClass *pobj_InheritsClass = NULL; 744 744 if(szInherits[0]){ 745 745 pobj_InheritsClass=pobj_DBClass->Find(szInherits); … … 749 749 i2+=lstrlen(buffer+i2)+1; 750 750 751 CClass *pobj_temp_c;751 const CClass *pobj_temp_c; 752 752 pobj_temp_c=pobj_InheritsClass; 753 753 if(pobj_temp_c==0) pobj_temp_c=pobj_c; -
BasicCompiler_Common/NumOpe_GetType.cpp
r103 r114 634 634 if( baseType.IsObject() || baseType.IsNull() ){ 635 635 //要求タイプがオブジェクト、または未定のとき 636 extern CClass *pobj_StringClass;636 extern const CClass *pobj_StringClass; 637 637 type_stack[sp]=DEF_OBJECT; 638 638 index_stack[sp]=(LONG_PTR)pobj_StringClass; … … 658 658 // 何らかの識別子 659 659 660 if( (string)term=="ParentArea2.xxxxxx"){660 if( strstr(term,"T.B")){ 661 661 int test=0; 662 662 } -
BasicCompiler_Common/Procedure.h
r113 r114 106 106 107 107 // 親クラスと対応するメソッド 108 CClass *pParentClass;108 const CClass *pParentClass; 109 109 CMethod *pMethod; 110 110 … … 158 158 } 159 159 160 void SetParentClass( CClass *pParentClass ){160 void SetParentClass( const CClass *pParentClass ){ 161 161 this->pParentClass = pParentClass; 162 162 } 163 CClass *GetParentClassPtr()163 const CClass *GetParentClassPtr() 164 164 { 165 165 return pParentClass; -
BasicCompiler_Common/Type.cpp
r102 r114 96 96 97 97 //クラス 98 CClass *pobj_c = pobj_DBClass->Find( typeName.c_str() );98 const CClass *pobj_c = pobj_DBClass->Find( typeName.c_str() ); 99 99 if(pobj_c){ 100 100 type.pClass = pobj_c; … … 507 507 508 508 Type Type::String(){ 509 extern CClass *pobj_StringClass;509 extern const CClass *pobj_StringClass; 510 510 if( pobj_StringClass == NULL ){ 511 511 SetError(); -
BasicCompiler_Common/Type.h
r97 r114 7 7 union{ 8 8 LONG_PTR index; 9 CClass *pClass;9 const CClass *pClass; 10 10 }; 11 11 … … 59 59 SetIndex( index ); 60 60 } 61 void SetType( int basicType, CClass *pClass ){61 void SetType( int basicType, const CClass *pClass ){ 62 62 SetBasicType( basicType ); 63 63 this->pClass = pClass; -
BasicCompiler_Common/TypeDef.cpp
r113 r114 57 57 this->push_back( typeDef ); 58 58 } 59 int TypeDefCollection::GetIndex( const string &typeName ) const{59 int TypeDefCollection::GetIndex( const NamespaceScopes &namespaceScopes, const string &name ) const{ 60 60 int max = (int)(*this).size(); 61 61 for( int i=0; i<max; i++ ){ 62 if( (*this)[i].IsEqualSymbol( typeName ) ){62 if( (*this)[i].IsEqualSymbol( namespaceScopes, name ) ){ 63 63 return i; 64 64 } 65 65 } 66 66 return -1; 67 } 68 int TypeDefCollection::GetIndex( const string &fullName ) const{ 69 char AreaName[VN_SIZE] = ""; //オブジェクト変数 70 char NestName[VN_SIZE] = ""; //入れ子メンバ 71 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 72 73 return GetIndex( NamespaceScopes( AreaName ), NestName ); 67 74 } 68 75 -
BasicCompiler_Common/TypeDef.h
r113 r114 46 46 47 47 void Add( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName ); 48 int GetIndex( const string &typeName ) const; 48 int GetIndex( const NamespaceScopes &namespaceScopes, const string &name ) const; 49 int GetIndex( const string &fullName ) const; 49 50 50 51 private: -
BasicCompiler_Common/VarList.cpp
r100 r114 726 726 727 727 if(pUserProc){ 728 pobj_CompilingClass =pUserProc->GetParentClassPtr();728 pobj_CompilingClass = pUserProc->GetParentClassPtr(); 729 729 UserProc::CompileStartForUserProc( pUserProc ); 730 730 } -
BasicCompiler_Common/VariableOpe.cpp
r106 r114 235 235 236 236 Type GetStringTypeInfo(){ 237 extern CClass *pobj_StringClass;237 extern const CClass *pobj_StringClass; 238 238 Type type( DEF_OBJECT, *pobj_StringClass ); 239 239 return type; … … 732 732 } 733 733 734 // TODO: TypeDefされたクラスの静的メンバに未対応 735 734 736 char temp2[VN_SIZE]; 735 737 sprintf(temp2,"%s.%s",VarName,temporary); -
BasicCompiler_Common/common.h
r112 r114 47 47 48 48 #ifdef _AMD64_ 49 #define VER_INFO "(x64) β rev.2 34"49 #define VER_INFO "(x64) β rev.243" 50 50 #else 51 #define VER_INFO "β rev.2 34"51 #define VER_INFO "β rev.243" 52 52 #endif 53 53 -
BasicCompiler_Common/error.cpp
r113 r114 465 465 //双方がオブジェクトポインタ型の場合 466 466 if(lpVarIndex!=lpCalcIndex){ 467 CClass *pobj_tempClass;467 const CClass *pobj_tempClass; 468 468 pobj_tempClass=(CClass *)lpCalcIndex; 469 469 while(pobj_tempClass&&(!IS_LITERAL((LONG_PTR)pobj_tempClass))){ -
BasicCompiler_Common/hash.cpp
r113 r114 187 187 188 188 UserProc *GetClassMethod( const char *className, const char *methodName ){ 189 CClass *pClass = pobj_DBClass->Find( className );189 const CClass *pClass = pobj_DBClass->Find( className ); 190 190 if( pClass ){ 191 191 vector<UserProc *> userProcs;
Note:
See TracChangeset
for help on using the changeset viewer.