Changeset 89 in dev for BasicCompiler_Common
- Timestamp:
- Apr 4, 2007, 2:03:09 AM (18 years ago)
- Location:
- BasicCompiler_Common
- Files:
-
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r87 r89 117 117 118 118 //ネイティブコードバッファの再確保 119 extern int obp_AllocSize; 120 if(obp_AllocSize<obp+8192){ 121 obp_AllocSize+=8192; 122 OpBuffer=(char *)HeapReAlloc(hHeap,0,OpBuffer,obp_AllocSize); //matea 123 } 119 ReallocNativeCodeBuffer(); 120 124 121 i++; 125 122 } … … 198 195 199 196 void CClass::Inherits( CClass *pInheritsClass ){ 200 int i3;201 197 202 198 //メンバをコピー … … 207 203 pInheritsClass->iMemberNum*sizeof(CMember *)); 208 204 iMemberNum=pInheritsClass->iMemberNum; 209 for(i 3=0;i3<pInheritsClass->iMemberNum;i3++){205 for(int i3=0;i3<pInheritsClass->iMemberNum;i3++){ 210 206 ppobj_Member[i3]=new CMember( *pInheritsClass->ppobj_Member[i3] ); 211 207 … … 315 311 { 316 312 for( int i=(int)methods.size()-1; i>=0; i-- ){ 317 if( pUserProc == methods[i]->pUserProc ) return methods[i]; 313 if( pUserProc == methods[i]->pUserProc ){ 314 return methods[i]; 315 } 318 316 } 319 317 return NULL; … … 1350 1348 1351 1349 1352 if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->IsObject()|| 1353 pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->IsStruct()){ 1350 if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->IsStruct()){ 1354 1351 if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->GetClass().ppobj_Member==0){ 1355 1352 //参照先が読み取られていないとき … … 1359 1356 1360 1357 1361 if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->Is Object()){1358 if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->IsStruct()){ 1362 1359 //循環参照のチェック 1363 1360 pobj_LoopRefCheck->add(pobj_c->name); … … 1422 1419 delete pobj_LoopRefCheck; 1423 1420 pobj_LoopRefCheck=0; 1424 } 1425 1426 void CDBClass::GenerateRuntimeTypeInfo(){ 1421 1422 // イテレータ用のデータを作る 1423 pobj_DBClass->Iterator_Init(); 1424 } 1425 1426 void CDBClass::Compile_System_InitializeUserTypes(){ 1427 1428 //////////////////////////////////////////////////////////////////// 1429 // クラス登録 1430 //////////////////////////////////////////////////////////////////// 1431 1432 // イテレータをリセット 1433 Iterator_Reset(); 1434 1435 while( Iterator_HasNext() ){ 1436 CClass *pClass = Iterator_GetNext(); 1437 1438 char temporary[VN_SIZE]; 1439 sprintf( temporary 1440 , "Add(%c%c_System_TypeForClass(\"%s\",\"%s\"))" 1441 , 1 1442 , ESC_NEW 1443 , "" // 名前空間 (TODO: 実装) 1444 , pClass->name // クラス名 1445 ); 1446 1447 // コンパイル 1448 ChangeOpcode( temporary ); 1449 1450 // ネイティブコードバッファの再確保 1451 ReallocNativeCodeBuffer(); 1452 } 1453 1454 1455 //////////////////////////////////////////////////////////////////// 1456 // 継承関係登録 1457 //////////////////////////////////////////////////////////////////// 1458 // TODO: 未完成 1459 /* 1460 1461 // イテレータをリセット 1462 Iterator_Reset(); 1463 1464 while( Iterator_HasNext() ){ 1465 CClass *pClass = Iterator_GetNext(); 1466 1467 sprintf( genBuffer + length 1468 , "obj.Search( \"%s\" ).SetBaseType( Search( \"%s\" ) ):" 1469 , "" // クラス名 1470 , pClass->name // クラス名 1471 ); 1472 length += lstrlen( genBuffer + length ); 1473 1474 while( length + 8192 > max ){ 1475 max += 8192; 1476 genBuffer = (char *)realloc( genBuffer, max ); 1477 } 1478 }*/ 1427 1479 } 1428 1480 … … 1475 1527 ////////////////////// 1476 1528 1477 void CDBClass::Iterator_ Reset(void){1529 void CDBClass::Iterator_Init(void){ 1478 1530 if(ppobj_IteClass) HeapDefaultFree(ppobj_IteClass); 1479 1531 … … 1498 1550 } 1499 1551 } 1552 void CDBClass::Iterator_Reset(void){ 1553 iIteNextNum = 0; 1554 } 1500 1555 BOOL CDBClass::Iterator_HasNext(void){ 1501 1556 if(iIteNextNum<iIteMaxNum) return 1; -
BasicCompiler_Common/Class.h
r87 r89 217 217 void GetClass_recur(const char *lpszInheritsClass); 218 218 void GetAllClassInfo(void); 219 void GenerateRuntimeTypeInfo();219 void Compile_System_InitializeUserTypes(); 220 220 221 221 … … 252 252 int iIteNextNum; 253 253 public: 254 void Iterator_Init(void); 254 255 void Iterator_Reset(void); 255 256 BOOL Iterator_HasNext(void); -
BasicCompiler_Common/Compile.cpp
r78 r89 7 7 #endif 8 8 9 int obp,obp_AllocSize;10 int GlobalOpBufferSize;11 char *OpBuffer;12 13 9 //ラベルアドレス 14 10 LABEL *pLabelNames; … … 36 32 //With情報 37 33 WITHINFO WithInfo; 34 35 36 int obp,obp_AllocSize; 37 int GlobalOpBufferSize; 38 char *OpBuffer; 39 void ReallocNativeCodeBuffer(){ 40 if(obp_AllocSize<obp+8192){ 41 obp_AllocSize+=8192; 42 OpBuffer=(char *)HeapReAlloc(hHeap,0,OpBuffer,obp_AllocSize); //matea 43 } 44 } 38 45 39 46 … … 428 435 OpcodeDim(Command+2,0); 429 436 430 if(obp_AllocSize<obp+8192){ 431 obp_AllocSize+=8192; 432 OpBuffer=(char *)HeapReAlloc(hHeap,0,OpBuffer,obp_AllocSize); 433 } 437 // ネイティブコードバッファの再確保 438 ReallocNativeCodeBuffer(); 434 439 435 440 if(basbuf[cp]=='\0') break; -
BasicCompiler_Common/Object.cpp
r75 r89 64 64 65 65 //ネイティブコードバッファの再確保 66 extern int obp_AllocSize; 67 if(obp_AllocSize<obp+8192){ 68 obp_AllocSize+=8192; 69 OpBuffer=(char *)HeapReAlloc(hHeap,0,OpBuffer,obp_AllocSize); //matea 70 } 66 ReallocNativeCodeBuffer(); 71 67 } 72 68 } -
BasicCompiler_Common/Procedure.h
r78 r89 155 155 return *pParentClass; 156 156 } 157 bool HasParentClass() const 158 { 159 return ( pParentClass != NULL ); 160 } 157 161 void SetMethod( CMethod *pMethod ){ 158 162 this->pMethod = pMethod; -
BasicCompiler_Common/common.h
r88 r89 496 496 497 497 //Compile.cpp 498 void ReallocNativeCodeBuffer(); 498 499 void GetIdentifierToken( char *token, const char *source, int &pos ); 499 500 int JumpStatement(const char *source, int &pos); -
BasicCompiler_Common/include/Source.h
r88 r89 29 29 class BasicSource : public Text 30 30 { 31 static const string generateDirectiveName; 32 31 33 void Realloc( int newLength ){ 32 34 buffer = (char *)realloc( buffer, newLength + 255 ); -
BasicCompiler_Common/src/Source.cpp
r88 r89 4 4 #include <windows.h> 5 5 6 7 const string BasicSource::generateDirectiveName = "#generate"; 6 8 7 9 … … 409 411 410 412 void BasicSource::ChangeReturnLineChar(){ 413 int i,i2; 414 411 415 #ifdef _DEBUG 412 416 //改行コードの整合性チェック 413 for( i nt i=0; ; i++ ){417 for( i=0; ; i++ ){ 414 418 if( buffer[i] == '\0' ){ 415 419 break; … … 433 437 434 438 //改行コードのCRLFをLFに変換 435 int i,i2;436 439 for(i=0,i2=0;;i++,i2++){ 437 440 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i++; … … 551 554 if(i>LastFileByte[layer]){ 552 555 HeapDefaultFree(LayerDir[layer]); 556 LayerDir[layer]=0; 553 557 layer--; 554 558 } … … 842 846 } 843 847 844 bool BasicSource::Generate( const string &genName, const char *buffer ){ 845 return true; 848 bool BasicSource::Generate( const string &genName, const char *genBuffer ){ 849 const int genBufferLength = lstrlen( genBuffer ); 850 851 #ifdef _DEBUG 852 // 挿入ソースに改行コードが含まれていないかを検査する 853 for( int i=0; genBuffer[i] ; i++ ){ 854 if( genBuffer[i] == '\n' ){ 855 SetError(); 856 break; 857 } 858 } 859 #endif 860 861 bool isFound = false; 862 863 for( int i=0; ; i++ ){ 864 if( i == 0 || buffer[i] == '\n' ){ 865 if( buffer[i] == '\n' ){ 866 i++; 867 } 868 while( IsBlank( buffer[i] ) ){ 869 i++; 870 } 871 872 int startIndex = i; 873 874 if( memicmp( buffer + i, generateDirectiveName.c_str(), generateDirectiveName.size() ) == 0 ){ 875 i += (int)generateDirectiveName.size(); 876 while( IsBlank( buffer[i] ) ){ 877 i++; 878 } 879 880 char temporary[VN_SIZE]; 881 for( int i2=0; ; i++, i2++ ){ 882 if( buffer[i] == '\n' ){ 883 temporary[i2] = 0; 884 break; 885 } 886 temporary[i2] = buffer[i]; 887 } 888 if( genName == temporary ){ 889 // 一致 890 891 int endIndex = i; 892 893 int lengthOffset = genBufferLength - ( endIndex - startIndex ); 894 895 Realloc( length + lengthOffset ); 896 SlideString( buffer + endIndex, lengthOffset ); 897 memcpy( buffer + startIndex, genBuffer, genBufferLength ); 898 899 isFound = true; 900 901 break; 902 } 903 } 904 } 905 } 906 907 return isFound; 846 908 } 847 909
Note:
See TracChangeset
for help on using the changeset viewer.