Changeset 135 in dev for BasicCompiler_Common
- Timestamp:
- Jun 6, 2007, 12:58:40 AM (17 years ago)
- Location:
- BasicCompiler_Common
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r134 r135 12 12 13 13 CMember *pCompilingMethod; 14 15 16 17 CMember::CMember( CClass *pobj_c, DWORD access, bool isConst, bool isRef, char *buffer, int nowLine ){18 extern int cp;19 20 if( strstr(buffer,"environVarName")){21 int test=0;22 }23 24 //構文を解析25 char VarName[VN_SIZE];26 char init_buf[VN_SIZE];27 char constract_parameter[VN_SIZE];28 GetDimentionFormat(buffer,VarName,SubScripts,*this,init_buf,constract_parameter);29 30 //重複チェック31 if(pobj_c->DupliCheckAll(VarName)){32 SetError(15,VarName,cp);33 }34 35 //メンバ名36 name=(char *)HeapAlloc(hHeap,0,lstrlen(VarName)+1);37 lstrcpy(name,VarName);38 39 //アクセス権40 dwAccess=access;41 42 //定数扱いかどうか43 this->isConst = isConst;44 45 //初期データ46 InitBuf=(char *)HeapAlloc(hHeap,0,lstrlen(init_buf)+1);47 lstrcpy(InitBuf,init_buf);48 49 //コンストラクタ用のパラメータ50 ConstractParameter=(char *)HeapAlloc(hHeap,0,lstrlen(constract_parameter)+1);51 lstrcpy(ConstractParameter,constract_parameter);52 53 //ソースコードの位置54 source_code_address=nowLine;55 }56 CMember::CMember(CMember &member):57 Type( member )58 {59 60 //name61 name=(char *)HeapAlloc(hHeap,0,lstrlen(member.name)+1);62 lstrcpy(name,member.name);63 64 //定数扱いかどうか65 isConst = member.isConst;66 67 //SubScripts68 memcpy(SubScripts,member.SubScripts,MAX_ARRAYDIM*sizeof(int));69 70 //ソースコードの位置71 source_code_address=member.source_code_address;72 }73 CMember::CMember(){74 memset(this,0,sizeof(CMember));75 }76 CMember::~CMember(){77 HeapDefaultFree(name);78 if(InitBuf) HeapDefaultFree(InitBuf);79 if(ConstractParameter) HeapDefaultFree(ConstractParameter);80 }81 82 bool CMember::IsConst(){83 return isConst;84 }85 86 void CMember::InitStaticMember(void){87 //静的メンバをグローバル領域に作成88 89 //イテレータをリセット90 extern CDBClass *pobj_DBClass;91 pobj_DBClass->Iterator_Reset();92 93 int back_cp=cp;94 95 while(pobj_DBClass->Iterator_HasNext()){96 CClass &objClass = *pobj_DBClass->Iterator_GetNext();97 98 // 名前空間をセット99 Smoothie::Lexical::liveingNamespaceScopes = objClass.GetNamespaceScopes();100 101 int i=0;102 foreach( CMember *member, objClass.staticMembers ){103 char temporary[VN_SIZE];104 sprintf(temporary,"%s.%s",objClass.GetName().c_str(),member->name);105 dim(106 temporary,107 member->SubScripts,108 *member,109 member->InitBuf,110 member->ConstractParameter,111 0);112 113 //ネイティブコードバッファの再確保114 ReallocNativeCodeBuffer();115 116 i++;117 }118 }119 120 Smoothie::Lexical::liveingNamespaceScopes.clear();121 122 cp=back_cp;123 }124 125 126 127 //コピーコンストラクタ128 CMethod::CMethod(CMethod *pMethod)129 : pUserProc( pMethod->pUserProc )130 , dwAccess( pMethod->dwAccess )131 , bAbstract( pMethod->bAbstract )132 , bVirtual( pMethod->bVirtual )133 , isConst( pMethod->isConst )134 , isStatic( pMethod->isStatic )135 {136 }137 138 CMethod::CMethod( UserProc *pUserProc, DWORD dwAccess, BOOL bAbstract, BOOL bVirtual, bool isConst, bool isStatic )139 : pUserProc( pUserProc )140 , dwAccess( dwAccess )141 , bAbstract( bAbstract )142 , bVirtual( bVirtual )143 , isConst( isConst )144 , isStatic( isStatic )145 , pobj_InheritsClass( NULL )146 {147 }148 CMethod::~CMethod(){149 }150 151 14 152 15 … … 184 47 delete member; 185 48 } 186 187 //メソッド188 foreach( CMethod *method, methods ){189 delete method;190 }191 192 //静的メソッド193 foreach( CMethod *method, staticMethods ){194 delete method;195 }196 49 } 197 50 … … 321 174 322 175 //メソッドをコピー 323 foreach( CMethod *baseMethod, inheritsClass.methods ){324 CMethod * method = new CMethod( baseMethod );176 foreach( const CMethod *pBaseMethod, inheritsClass.methods ){ 177 CMethod *pMethod = new DynamicMethod( *pBaseMethod ); 325 178 326 179 //dwAccess 327 if( baseMethod->dwAccess==ACCESS_PRIVATE)328 method->dwAccess=ACCESS_NON;329 else method->dwAccess=baseMethod->dwAccess;180 if(pBaseMethod->dwAccess==ACCESS_PRIVATE) 181 pMethod->dwAccess=ACCESS_NON; 182 else pMethod->dwAccess=pBaseMethod->dwAccess; 330 183 331 184 //pobj_Inherits 332 185 // ※継承元のClassIndexをセット(入れ子継承を考慮する) 333 if(baseMethod->pobj_InheritsClass==0) 334 method->pobj_InheritsClass=&inheritsClass; 335 else 336 method->pobj_InheritsClass= 337 baseMethod->pobj_InheritsClass; 338 339 methods.push_back( method ); 186 if(pBaseMethod->GetInheritsClassPtr()==0){ 187 pMethod->SetInheritsClassPtr( &inheritsClass ); 188 } 189 else{ 190 pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() ); 191 } 192 193 methods.push_back( pMethod ); 340 194 } 341 195 … … 364 218 365 219 //メソッドをコピー 366 foreach( CMethod *baseMethod, inheritsInterface.methods ){367 CMethod * method = new CMethod( baseMethod );220 foreach( const CMethod *pBaseMethod, inheritsInterface.methods ){ 221 CMethod *pMethod = new DynamicMethod( *pBaseMethod ); 368 222 369 223 //dwAccess 370 if( baseMethod->dwAccess==ACCESS_PRIVATE)371 method->dwAccess=ACCESS_NON;372 else method->dwAccess=baseMethod->dwAccess;224 if(pBaseMethod->dwAccess==ACCESS_PRIVATE) 225 pMethod->dwAccess=ACCESS_NON; 226 else pMethod->dwAccess=pBaseMethod->dwAccess; 373 227 374 228 //pobj_Inherits 375 229 // ※継承元のClassIndexをセット(入れ子継承を考慮する) 376 if(baseMethod->pobj_InheritsClass==0) 377 method->pobj_InheritsClass=&inheritsInterface; 378 else 379 method->pobj_InheritsClass= 380 baseMethod->pobj_InheritsClass; 381 382 methods.push_back( method ); 230 if(pBaseMethod->GetInheritsClassPtr()==0){ 231 pMethod->SetInheritsClassPtr( &inheritsInterface ); 232 } 233 else{ 234 pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() ); 235 } 236 237 methods.push_back( pMethod ); 383 238 } 384 239 … … 399 254 staticMembers.push_back( member ); 400 255 } 401 void CClass::AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){402 CMethod *method = new CMethod( pUserProc, dwAccess, bAbstract, bVirtual, isConst, false );403 404 methods.push_back( method );405 406 // プロシージャオブジェクトと関連付け407 pUserProc->SetMethod( method );408 }409 void CClass::AddStaticMethod(UserProc *pUserProc,DWORD dwAccess){410 CMethod *method = new CMethod( pUserProc, dwAccess, FALSE, FALSE, false, true );411 412 staticMethods.push_back( method );413 414 // プロシージャオブジェクトと関連付け415 pUserProc->SetMethod( method );416 }417 256 BOOL CClass::DupliCheckAll(const char *name){ 418 257 //重複チェック … … 422 261 423 262 //メソッド 424 foreach( CMethod *method, methods ){425 if( lstrcmp( name, method->pUserProc->GetName().c_str() ) == 0 ){263 foreach( const CMethod *pMethod, methods ){ 264 if( lstrcmp( name, pMethod->pUserProc->GetName().c_str() ) == 0 ){ 426 265 return 1; 427 266 } … … 435 274 //メンバ 436 275 for( int i=0;i<iMemberNum;i++){ 437 if( GetName() == ppobj_Member[i]-> name){276 if( GetName() == ppobj_Member[i]->GetName() ){ 438 277 return 1; 439 278 } … … 442 281 //静的メンバ 443 282 foreach( CMember *member, staticMembers ){ 444 if( GetName() == member-> name){283 if( GetName() == member->GetName() ){ 445 284 return 1; 446 285 } … … 449 288 return 0; 450 289 } 451 CMethod *CClass::GetMethodInfo( UserProc *pUserProc ) const452 {453 for( int i=(int)methods.size()-1; i>=0; i-- ){454 if( pUserProc == methods[i]->pUserProc ){455 return methods[i];456 }457 }458 return NULL;459 }460 CMethod *CClass::GetStaticMethodInfo( UserProc *pUserProc ) const461 {462 for( int i=(int)staticMethods.size()-1; i>=0; i-- ){463 if( pUserProc == staticMethods[i]->pUserProc ) return staticMethods[i];464 }465 return NULL;466 }467 bool CClass::IsExistMethod( const char *name ) const468 {469 foreach( CMethod *method, methods ){470 if( method->pUserProc->GetName() == name ) return true;471 }472 return false;473 }474 bool CClass::IsExistStaticMethod( const char *name ) const475 {476 foreach( CMethod *method, staticMethods ){477 if( method->pUserProc->GetName() == name ) return true;478 }479 return false;480 }481 482 void CClass::EnumStaticMethod( const char *methodName, vector<UserProc *> &subs ) const483 {484 foreach( CMethod *method, staticMethods ){485 if( method->pUserProc->GetName() == methodName ){486 subs.push_back( method->pUserProc );487 }488 }489 }490 491 void CClass::EnumMethod( const char *methodName, vector<UserProc *> &subs ) const492 {493 //オブジェクトのメンバ関数の場合494 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う495 for( int i=(int)methods.size()-1; i>=0; i-- ){496 if( methods[i]->pUserProc->GetName() == methodName ){497 subs.push_back( methods[i]->pUserProc );498 }499 }500 }501 502 void CClass::EnumMethod( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const503 {504 //オブジェクトのメンバ関数の場合505 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う506 for( int i=(int)methods.size()-1; i>=0; i-- ){507 UserProc *pUserProc = methods[i]->pUserProc;508 const char *temp = pUserProc->GetName().c_str();509 if(temp[0]==1&&temp[1]==ESC_OPERATOR){510 if((BYTE)temp[2]==idOperatorCalc){511 subs.push_back( pUserProc );512 }513 }514 }515 }516 290 517 291 //デフォルト コンストラクタ メソッドを取得 518 CMethod *CClass::GetConstructorMethod() const292 const CMethod *CClass::GetConstructorMethod() const 519 293 { 520 294 if( ConstructorMemberSubIndex == -1 ) return NULL; … … 523 297 524 298 //デストラクタ メソッドを取得 525 CMethod *CClass::GetDestructorMethod() const299 const CMethod *CClass::GetDestructorMethod() const 526 300 { 527 301 if( DestructorMemberSubIndex == -1 ) return NULL; … … 584 358 if(memberName){ 585 359 //メンバ指定がある場合は、オフセットを返す 586 if( lstrcmp(pMember->name,memberName)==0){360 if( pMember->GetName() == memberName ){ 587 361 if(pMemberNum) *pMemberNum=i; 588 362 return offset; … … 644 418 { 645 419 int n = 0; 646 foreach( CMethod *method, methods ){647 if( method->pUserProc == pUserProc ) break;648 if( method->bVirtual) n++;420 foreach( const CMethod *pMethod, methods ){ 421 if( pMethod->pUserProc == pUserProc ) break; 422 if( pMethod->IsVirtual() ) n++; 649 423 } 650 424 return n; … … 667 441 //関数テーブルに値をセット 668 442 int i2 = 0; 669 foreach( CMethod *method, methods ){670 if( method->bVirtual){671 method->pUserProc->Using();672 673 if( method->bAbstract){443 foreach( const CMethod *pMethod, methods ){ 444 if(pMethod->IsVirtual()){ 445 pMethod->pUserProc->Using(); 446 447 if(pMethod->IsAbstract()){ 674 448 extern int cp; 675 449 SetError(300,NULL,cp); … … 678 452 } 679 453 else{ 680 ppsi[i2]= method->pUserProc;454 ppsi[i2]=pMethod->pUserProc; 681 455 } 682 456 i2++; … … 712 486 // 未実装(abstract)の仮想関数を持つ場合はtrueを返す 713 487 714 foreach( CMethod *method, methods ){715 if( method->bVirtual){716 if( method->bAbstract){488 foreach( const CMethod *pMethod, methods ){ 489 if(pMethod->IsVirtual()){ 490 if(pMethod->IsAbstract()){ 717 491 return true; 718 492 } … … 1063 837 1064 838 1065 void CDBClass::AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,1066 BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine){839 void CDBClass::AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, bool isAbstract, 840 bool isVirtual, bool isOverride, char *buffer, int nowLine){ 1067 841 int i,i2; 1068 842 char temporary[VN_SIZE]; … … 1080 854 //関数ハッシュへ登録 1081 855 GlobalProc *pUserProc; 1082 pUserProc=AddSubData( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine, bVirtual,pobj_c, (bStatic!=0) );856 pUserProc=AddSubData( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,isVirtual,pobj_c, (bStatic!=0) ); 1083 857 if(!pUserProc) return; 1084 858 … … 1129 903 1130 904 //メソッド 1131 foreach( CMethod *method, pobj_c->methods ){905 foreach( const CMethod *pMethod, pobj_c->methods ){ 1132 906 //基底クラスと重複する場合はオーバーライドを行う 1133 if( method->pobj_InheritsClass) continue;1134 1135 if( method->pUserProc->GetName() == temporary ){1136 if( method->pUserProc->Params().Equals( pUserProc->Params() ) ){907 if( pMethod->GetInheritsClassPtr() ) continue; 908 909 if( pMethod->pUserProc->GetName() == temporary ){ 910 if( pMethod->pUserProc->Params().Equals( pUserProc->Params() ) ){ 1137 911 //関数名、パラメータ属性が合致したとき 1138 912 SetError(15,pUserProc->GetName().c_str(),nowLine); … … 1143 917 1144 918 //仮想関数の場合 1145 if( bAbstract) pUserProc->CompleteCompile();919 if( isAbstract ) pUserProc->CompleteCompile(); 1146 920 1147 921 //メソッドのオーバーライド 1148 foreach( CMethod * method, pobj_c->methods ){1149 if( method->pUserProc->GetName() == temporary ){1150 if( method->pUserProc->Params().Equals( pUserProc->Params() ) ){1151 1152 if( method->bVirtual){922 foreach( CMethod *pMethod, pobj_c->methods ){ 923 if( pMethod->pUserProc->GetName() == temporary ){ 924 if( pMethod->pUserProc->Params().Equals( pUserProc->Params() ) ){ 925 926 if(pMethod->IsVirtual()){ 1153 927 //メンバ関数を上書き 1154 method->pUserProc=pUserProc;1155 method->bAbstract=0;1156 1157 if( !bOverride){928 pMethod->pUserProc=pUserProc; 929 pMethod->Override(); 930 931 if( !isOverride ){ 1158 932 SetError(127,NULL,nowLine); 1159 933 } 1160 if( method->dwAccess!=dwAccess){934 if(pMethod->dwAccess!=dwAccess){ 1161 935 SetError(128,NULL,nowLine); 1162 936 } 1163 937 1164 pUserProc->SetMethod( method );938 pUserProc->SetMethod( pMethod ); 1165 939 return; 1166 940 } … … 1169 943 } 1170 944 1171 if( bVirtual){945 if( isVirtual ){ 1172 946 pobj_c->vtbl_num++; 1173 947 } 1174 948 1175 if( bOverride){949 if( isOverride ){ 1176 950 SetError(12,"Override",nowLine); 1177 951 } 1178 952 1179 953 if(bStatic){ 1180 pobj_c-> AddStaticMethod(pUserProc,dwAccess);954 pobj_c->staticMethods.AddStatic(pUserProc,dwAccess); 1181 955 } 1182 956 else{ 1183 pobj_c-> AddMethod(pUserProc, dwAccess, isConst, bAbstract, bVirtual);957 pobj_c->methods.Add(pUserProc, dwAccess, isConst, isAbstract, isVirtual); 1184 958 } 1185 959 } … … 1517 1291 else i3=0; 1518 1292 1519 BOOL bVirtual=0,bAbstract=0,bOverride=0;1293 bool isVirtual = false, isAbstract = false, isOverride = false; 1520 1294 if(i3==ESC_ABSTRACT){ 1521 bAbstract=1;1522 bVirtual=1;1295 isAbstract=1; 1296 isVirtual=1; 1523 1297 i+=2; 1524 1298 … … 1526 1300 } 1527 1301 else if(i3==ESC_VIRTUAL){ 1528 bAbstract=0;1529 bVirtual=1;1302 isAbstract=0; 1303 isVirtual=1; 1530 1304 i+=2; 1531 1305 … … 1533 1307 } 1534 1308 else if(i3==ESC_OVERRIDE){ 1535 bOverride=1;1536 bVirtual=1;1309 isOverride=1; 1310 isVirtual=1; 1537 1311 1538 1312 i+=2; … … 1619 1393 bStatic, 1620 1394 isConst, 1621 bAbstract,1622 bVirtual,1623 bOverride,1395 isAbstract, 1396 isVirtual, 1397 isOverride, 1624 1398 temporary, 1625 1399 sub_address); 1626 1400 1627 if( bAbstract) continue;1401 if( isAbstract ) continue; 1628 1402 1629 1403 for(;;i++){ … … 1699 1473 sprintf( referenceOffsetsBuffer + lstrlen( referenceOffsetsBuffer ), 1700 1474 "%d", 1701 objClass.GetMemberOffset( member. name) );1475 objClass.GetMemberOffset( member.GetName().c_str() ) ); 1702 1476 1703 1477 numOfReference++; … … 1822 1596 pCompilingClass->Using(); 1823 1597 1824 pCompilingMethod = pCompilingClass-> GetMethodInfo( pUserProc );1598 pCompilingMethod = pCompilingClass->methods.GetMethodPtr( pUserProc ); 1825 1599 if( !pCompilingMethod ){ 1826 pCompilingMethod = pCompilingClass-> GetStaticMethodInfo( pUserProc );1600 pCompilingMethod = pCompilingClass->staticMethods.GetMethodPtr( pUserProc ); 1827 1601 if( !pCompilingMethod ){ 1828 1602 SetError(300,NULL,cp); … … 1838 1612 return pCompilingClass; 1839 1613 } 1840 CMethod *CDBClass::GetNowCompilingMethodInfo(){1614 const CMethod *CDBClass::GetNowCompilingMethodInfo(){ 1841 1615 return pCompilingMethod; 1842 1616 } -
BasicCompiler_Common/Class.h
r134 r135 5 5 6 6 #include <Prototype.h> 7 #include "Type.h" 7 #include <Method.h> 8 #include <Member.h> 8 9 #include "Procedure.h" 9 10 class CClass;11 10 12 11 #define ACCESS_NON 0 … … 14 13 #define ACCESS_PUBLIC 2 15 14 #define ACCESS_PROTECTED 3 16 17 class CMember : public Type18 {19 bool isConst;20 public:21 char *name;22 int SubScripts[MAX_ARRAYDIM];23 24 DWORD dwAccess;25 26 char *InitBuf;27 char *ConstractParameter;28 29 int source_code_address;30 31 32 CMember( CClass *pobj_c, DWORD access, bool idConst, bool isRef, char *buffer, int nowLine=-1 );33 CMember( CMember &member );34 CMember();35 ~CMember();36 37 bool IsConst();38 39 40 static void InitStaticMember(void);41 };42 class CMethod43 {44 public:45 UserProc *pUserProc;46 47 DWORD dwAccess;48 BOOL bAbstract;49 BOOL bVirtual;50 bool isConst;51 bool isStatic;52 53 const CClass *pobj_InheritsClass;54 55 CMethod(CMethod *pobj);56 CMethod( UserProc *pUserProc, DWORD dwAccess, BOOL bAbstract, BOOL bVirtual, bool isConst, bool isStatic );57 ~CMethod();58 };59 15 60 16 class CDBClass; … … 100 56 101 57 //メソッド情報 102 std::vector<CMethod *>methods;58 Methods methods; 103 59 int ConstructorMemberSubIndex; 104 60 int DestructorMemberSubIndex; 105 61 106 62 //静的メソッド情報 107 std::vector<CMethod *>staticMethods;63 Methods staticMethods; 108 64 109 65 enum ClassType{ … … 176 132 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer ); 177 133 void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int nowLine ); 178 void AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );179 void AddStaticMethod(UserProc *pUserProc,DWORD dwAccess);180 134 181 135 //重複チェック … … 183 137 BOOL DupliCheckMember(const char *name); 184 138 185 //メソッド取得 186 CMethod *GetMethodInfo( UserProc *pUserProc ) const; 187 CMethod *GetStaticMethodInfo( UserProc *pUserProc ) const; 188 189 //メソッドの存在を確認 190 bool IsExistMethod( const char *name ) const; 191 bool IsExistStaticMethod( const char *name ) const; 192 193 //メソッドを列挙 194 void EnumStaticMethod( const char *methodName, vector<UserProc *> &subs ) const; 195 void EnumMethod( const char *methodName, vector<UserProc *> &subs ) const; 196 void EnumMethod( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const; 197 const std::vector<CMethod *> &GetMethods() const 139 const Methods &GetMethods() const 198 140 { 199 141 return methods; 200 142 } 201 const std::vector<CMethod *>&GetStaticMethods() const143 const Methods &GetStaticMethods() const 202 144 { 203 145 return staticMethods; … … 205 147 206 148 //デフォルト コンストラクタ メソッドを取得 207 CMethod *GetConstructorMethod() const;149 const CMethod *GetConstructorMethod() const; 208 150 209 151 //デストラクタ メソッドを取得 210 CMethod *GetDestructorMethod() const;152 const CMethod *GetDestructorMethod() const; 211 153 212 154 // メンバの総合サイズを取得 … … 288 230 289 231 private: 290 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,291 BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine);232 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, bool isAbstract, 233 bool isVirtual, bool isOverride, char *buffer, int nowLine); 292 234 BOOL MemberVar_LoopRefCheck(const CClass &objClass); 293 235 public: … … 312 254 private: 313 255 const CClass *pCompilingClass; 314 CMethod *pCompilingMethod;256 const CMethod *pCompilingMethod; 315 257 public: 316 258 //コンパイル開始の通知を受け取るメソッド … … 319 261 //現在コンパイル中のメソッド情報を取得 320 262 const CClass *GetNowCompilingClass() const; 321 CMethod *GetNowCompilingMethodInfo();263 const CMethod *GetNowCompilingMethodInfo(); 322 264 323 265 -
BasicCompiler_Common/DebugMiddleFile.cpp
r131 r135 327 327 i2+=sizeof(long); 328 328 for(i4=0;i4<pobj_c->iMemberNum;i4++){ 329 lstrcpy(buffer+i2,pobj_c->ppobj_Member[i4]-> name);329 lstrcpy(buffer+i2,pobj_c->ppobj_Member[i4]->GetName().c_str()); 330 330 i2+=lstrlen(buffer+i2)+1; 331 331 … … 353 353 *(long *)(buffer+i2)=(long)pobj_c->methods.size(); 354 354 i2+=sizeof(long); 355 foreach( CMethod *method, pobj_c->methods ){356 *(long *)(buffer+i2)= method->dwAccess;357 i2+=sizeof(long); 358 if( method->pobj_InheritsClass){359 lstrcpy(buffer+i2, method->pobj_InheritsClass->GetName().c_str());355 foreach( const CMethod *pMethod, pobj_c->methods ){ 356 *(long *)(buffer+i2)=pMethod->dwAccess; 357 i2+=sizeof(long); 358 if( pMethod->GetInheritsClassPtr() ){ 359 lstrcpy(buffer+i2,pMethod->GetInheritsClassPtr()->GetName().c_str()); 360 360 i2+=lstrlen(buffer+i2)+1; 361 361 } … … 364 364 i2+=lstrlen(buffer+i2)+1; 365 365 } 366 lstrcpy(buffer+i2, method->pUserProc->GetName().c_str());366 lstrcpy(buffer+i2,pMethod->pUserProc->GetName().c_str()); 367 367 i2+=lstrlen(buffer+i2)+1; 368 368 } … … 372 372 i2+=sizeof(long); 373 373 foreach( CMember *member, pobj_c->staticMembers ){ 374 lstrcpy(buffer+i2,member-> name);374 lstrcpy(buffer+i2,member->GetName().c_str()); 375 375 i2+=lstrlen(buffer+i2)+1; 376 376 … … 709 709 pobj_c->ppobj_Member[i4]=new CMember(); 710 710 711 pobj_c->ppobj_Member[i4]->name=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1); 712 lstrcpy(pobj_c->ppobj_Member[i4]->name,buffer+i2); 711 pobj_c->ppobj_Member[i4]->SetName( (char *)(buffer+i2) ); 713 712 i2+=lstrlen(buffer+i2)+1; 714 713 … … 759 758 } 760 759 761 CMethod *method = new CMethod( pUserProc, dwAccess, 0,0,false, false); 762 method->pobj_InheritsClass = pobj_InheritsClass; 763 764 pobj_c->methods.push_back( method ); 760 CMethod *pMethod = new DynamicMethod( pUserProc, dwAccess, 0,0,false, pobj_InheritsClass); 761 762 pobj_c->methods.push_back( pMethod ); 765 763 } 766 764 … … 771 769 CMember *member=new CMember(); 772 770 773 member->name=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1); 774 lstrcpy(member->name,buffer+i2); 771 member->SetName( (char *)(buffer+i2) ); 775 772 i2+=lstrlen(buffer+i2)+1; 776 773 -
BasicCompiler_Common/Diagnose.cpp
r131 r135 77 77 78 78 // 動的メソッド 79 foreach( const CMethod &method, objClass.GetMethods() ){80 if( method.pUserProc->IsCompiled() ){81 codeSizeOfClass += method.pUserProc->GetCodeSize();79 foreach( const CMethod *pMethod, objClass.GetMethods() ){ 80 if( pMethod->pUserProc->IsCompiled() ){ 81 codeSizeOfClass += pMethod->pUserProc->GetCodeSize(); 82 82 } 83 83 } 84 84 85 85 // 静的メソッド 86 foreach( const CMethod &method, objClass.GetStaticMethods() ){87 codeSizeOfClass += method.pUserProc->GetCodeSize();86 foreach( const CMethod *pMethod, objClass.GetStaticMethods() ){ 87 codeSizeOfClass += pMethod->pUserProc->GetCodeSize(); 88 88 } 89 89 … … 112 112 113 113 // 動的メソッド 114 foreach( const CMethod &method, objClass.GetMethods() ){115 if( method.pUserProc->IsCompiled() ){116 codeSizeOfClass += method.pUserProc->GetCodeSize();114 foreach( const CMethod *pMethod, objClass.GetMethods() ){ 115 if( pMethod->pUserProc->IsCompiled() ){ 116 codeSizeOfClass += pMethod->pUserProc->GetCodeSize(); 117 117 } 118 118 } 119 119 120 120 // 静的メソッド 121 foreach( const CMethod &method, objClass.GetStaticMethods() ){122 codeSizeOfClass += method.pUserProc->GetCodeSize();121 foreach( const CMethod *pMethod, objClass.GetStaticMethods() ){ 122 codeSizeOfClass += pMethod->pUserProc->GetCodeSize(); 123 123 } 124 124 -
BasicCompiler_Common/LexicalScoping.cpp
r75 r135 214 214 if(indexSystemGC!=-1){ 215 215 //_System_GCオブジェクトのデストラクタの呼び出し処理 216 CMethod *method = vars[indexSystemGC]->GetClass().GetDestructorMethod();216 const CMethod *method = vars[indexSystemGC]->GetClass().GetDestructorMethod(); 217 217 if( method ){ 218 218 Opcode_CallProc("",method->pUserProc,0,vars[indexSystemGC]->GetName().c_str(),DEF_OBJECT); -
BasicCompiler_Common/NumOpe_GetType.cpp
r129 r135 194 194 195 195 std::vector<UserProc *> subs; 196 pobj_c-> EnumMethod( idCalc, subs );196 pobj_c->GetMethods().Enum( idCalc, subs ); 197 197 if( subs.size() == 0 ){ 198 198 return 0; … … 372 372 GetVarFormatString(methodName,parameter,lpPtrOffset,member,refType); 373 373 374 objClass. EnumMethod( methodName, userProcs );374 objClass.GetMethods().Enum( methodName, userProcs ); 375 375 UserProc *pUserProc; 376 376 if(userProcs.size()){ -
BasicCompiler_Common/Procedure.cpp
r131 r135 382 382 return false; 383 383 } 384 return ( pMethod-> bVirtual!= 0 );384 return ( pMethod->IsVirtual() != 0 ); 385 385 } 386 386 const NamespaceScopes &UserProc::GetNamespaceScopes() const -
BasicCompiler_Common/Subroutine.cpp
r120 r135 300 300 bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ){ 301 301 vector<UserProc *> subs; 302 objClass. EnumMethod( CALC_ARRAY_GET, subs );302 objClass.GetMethods().Enum( CALC_ARRAY_GET, subs ); 303 303 if( subs.size() == 0 ){ 304 304 return false; … … 462 462 } 463 463 464 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine, BOOL bVirtual,CClass *pobj_c, bool isStatic){464 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic){ 465 465 int i2,i3; 466 466 char temporary[8192]; -
BasicCompiler_Common/VarList.cpp
r114 r135 168 168 if(bPtr){ 169 169 lstrcpy(VarName,"->"); 170 lstrcat(VarName,objClass.ppobj_Member[i]-> name);170 lstrcat(VarName,objClass.ppobj_Member[i]->GetName().c_str()); 171 171 } 172 172 else{ 173 173 lstrcpy(VarName,"."); 174 lstrcat(VarName,objClass.ppobj_Member[i]-> name);174 lstrcat(VarName,objClass.ppobj_Member[i]->GetName().c_str()); 175 175 } 176 176 177 177 LONG_PTR offset; 178 178 int i2; 179 offset=objClass.GetMemberOffset( objClass.ppobj_Member[i]-> name, &i2 );179 offset=objClass.GetMemberOffset( objClass.ppobj_Member[i]->GetName().c_str(), &i2 ); 180 180 181 181 if(objClass.ppobj_Member[i]->SubScripts[0]!=-1){ … … 423 423 424 424 for(i=0;i<pUserProc->GetParentClassPtr()->iMemberNum;i++){ 425 offset=pUserProc->GetParentClassPtr()->GetMemberOffset( pUserProc->GetParentClassPtr()->ppobj_Member[i]-> name,&i2);425 offset=pUserProc->GetParentClassPtr()->GetMemberOffset( pUserProc->GetParentClassPtr()->ppobj_Member[i]->GetName().c_str(),&i2); 426 426 427 427 if(pUserProc->GetParentClassPtr()->ppobj_Member[i]->SubScripts[0]!=-1){ 428 428 //配列 429 429 sprintf(temporary,"%s %s(&H%X)", 430 pUserProc->GetParentClassPtr()->ppobj_Member[i]-> name,430 pUserProc->GetParentClassPtr()->ppobj_Member[i]->GetName().c_str(), 431 431 STRING_ARRAY, 432 432 (ULONG_PTR)offset); … … 442 442 else{ 443 443 VarList_Insert(hVarTree_This,&tv, 444 pUserProc->GetParentClassPtr()->ppobj_Member[i]-> name,444 pUserProc->GetParentClassPtr()->ppobj_Member[i]->GetName().c_str(), 445 445 *pUserProc->GetParentClassPtr()->ppobj_Member[i], 446 446 pThis+offset); -
BasicCompiler_Common/VariableOpe.cpp
r131 r135 559 559 560 560 for(i=0;i<objClass.iMemberNum;i++){ 561 if(lstrcmp(objClass.ppobj_Member[i]->name,VarName)==0) break; 561 if( objClass.ppobj_Member[i]->GetName() == VarName ){ 562 break; 563 } 562 564 } 563 565 if(i==objClass.iMemberNum){ … … 692 694 693 695 for(i=0;i<pobj_CompilingClass->iMemberNum;i++){ 694 if(lstrcmp(VarName,pobj_CompilingClass->ppobj_Member[i]->name)==0) break; 696 if( pobj_CompilingClass->ppobj_Member[i]->GetName() == VarName ){ 697 break; 698 } 695 699 } 696 700 if(i==pobj_CompilingClass->iMemberNum) goto NonClassMember; … … 1136 1140 if( type.IsObject() ){ 1137 1141 //デストラクタの利用フラグをオンにする 1138 CMethod *method = type.GetClass().GetDestructorMethod();1142 const CMethod *method = type.GetClass().GetDestructorMethod(); 1139 1143 if( method ){ 1140 1144 method->pUserProc->Using(); -
BasicCompiler_Common/WatchList.cpp
r100 r135 380 380 381 381 for(i=0;i<pobj_CompilingClass->iMemberNum;i++){ 382 if(lstrcmp(VarName,pobj_CompilingClass->ppobj_Member[i]->name)==0) break; 382 if( pobj_CompilingClass->ppobj_Member[i]->GetName() == VarName ){ 383 break; 384 } 383 385 } 384 386 if(i==pobj_CompilingClass->iMemberNum) goto NonClassMember; -
BasicCompiler_Common/common.h
r131 r135 430 430 BOOL GetConstCalcBuffer(const char *name,const char *Parameter,char *pCalcBuffer); 431 431 DWORD GetConstValue(char *name,double *dbl,char *buffer,LONG_PTR *plpIndex); 432 bool IsStringObjectType(const Type &TypeInfo);433 432 int IsStrCalculation(char *Command); 434 433 BYTE GetCalcId(const char *Command,int *pi); … … 452 451 bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType ); 453 452 bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ); 454 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine, BOOL bVirtual,CClass *pobj_c, bool isStatic = false );453 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic = false ); 455 454 void GetSubInfo(void); 456 455 void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum); -
BasicCompiler_Common/hash.cpp
r114 r135 99 99 if( isStatic ){ 100 100 // 静的メソッドから列挙 101 pobj_c-> EnumStaticMethod( NestMember, subs );101 pobj_c->GetStaticMethods().EnumStatic( NestMember, subs ); 102 102 } 103 103 else{ 104 104 //動的メソッドから列挙 105 pobj_c-> EnumMethod( NestMember, subs );105 pobj_c->GetMethods().Enum( NestMember, subs ); 106 106 } 107 107 return; … … 114 114 115 115 // 静的メソッド 116 pobj_CompilingClass-> EnumStaticMethod( name, subs );116 pobj_CompilingClass->GetStaticMethods().EnumStatic( name, subs ); 117 117 118 118 // 動的メソッド 119 pobj_CompilingClass-> EnumMethod( name, subs );119 pobj_CompilingClass->GetMethods().Enum( name, subs ); 120 120 } 121 121 … … 190 190 if( pClass ){ 191 191 vector<UserProc *> userProcs; 192 pClass-> EnumMethod( methodName, userProcs );192 pClass->GetMethods().Enum( methodName, userProcs ); 193 193 if( userProcs.size() == 1 ){ 194 194 return userProcs[0]; -
BasicCompiler_Common/include/Prototype.h
r134 r135 7 7 8 8 using namespace std; 9 10 class CMethod; 11 class UserProc; 9 12 10 13 class Prototype … … 52 55 // シンボル比較 53 56 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 54 bool IsEqualSymbol( const Prototype & objClass) const;57 bool IsEqualSymbol( const Prototype &prototype ) const; 55 58 bool IsEqualSymbol( const string &name ) const; 56 59
Note:
See TracChangeset
for help on using the changeset viewer.