Changeset 279 in dev for trunk/abdev
- Timestamp:
- Aug 14, 2007, 3:22:02 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r278 r279 174 174 // 名前空間情報を取得 175 175 NamespaceSupporter::CollectNamespaces( 176 compiler. source.GetBuffer(),176 compiler.GetObjectModule().source.GetBuffer(), 177 177 compiler.GetObjectModule().meta.GetNamespaces() 178 178 ); … … 181 181 // CollectProcedures関数の中で参照されるオブジェクト名を事前に取得する。 182 182 // ※オブジェクトの内容までは取得しない 183 compiler.GetObjectModule().meta.GetClasses().CollectClassesForNameOnly( compiler. source );183 compiler.GetObjectModule().meta.GetClasses().CollectClassesForNameOnly( compiler.GetObjectModule().source ); 184 184 185 185 //TypeDef情報を初期化 … … 192 192 compiler.pCompilingClass = NULL; 193 193 CollectProcedures( 194 compiler. source,194 compiler.GetObjectModule().source, 195 195 compiler.GetObjectModule().meta.GetUserProcs(), 196 196 compiler.GetObjectModule().meta.GetDllProcs() … … 203 203 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Init(); 204 204 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Init(); 205 206 /*207 if( !compiler.GetObjectModule().WriteXml( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.xml" ) )208 {209 MessageBox(0,"XML書き込みに失敗","test",0);210 }211 ObjectModule *pTempObjectModule = new ObjectModule();212 if( !pTempObjectModule->ReadXml( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.xml" ) )213 {214 MessageBox(0,"XML読み込みに失敗","test",0);215 }216 217 if( !compiler.GetObjectModule().meta.WriteBinary( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.dat" ) )218 {219 MessageBox(0,"バイナリ書き込みに失敗","test",0);220 }221 Meta *pTempMeta = new Meta();222 if( !pTempMeta->ReadBinary( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.dat" ) )223 {224 MessageBox(0,"バイナリ読み込みに失敗","test",0);225 }226 if( !compiler.GetObjectModule().meta.WriteText( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.dat" ) )227 {228 MessageBox(0,"バイナリ書き込みに失敗","test",0);229 }230 Meta *pTempMeta = new Meta();231 if( !pTempMeta->ReadText( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.dat" ) )232 {233 MessageBox(0,"バイナリ読み込みに失敗","test",0);234 }235 compiler.objectModule = (*pTempObjectModule);*/236 205 237 206 … … 526 495 // 静的リンクライブラリ 527 496 528 if( !compiler.GetObjectModule().Write Text( OutputFileName ) )497 if( !compiler.GetObjectModule().Write( OutputFileName ) ) 529 498 { 530 499 MessageBox(0,"XML書き込みに失敗","test",0); … … 537 506 538 507 oldSourceLines = compiler.linker.GetNativeCode().GetSourceLines(); 539 540 /*541 int t,t2;542 t=GetTickCount();543 if( !compiler.GetObjectModule().WriteText( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.xml" ) )544 {545 MessageBox(0,"XML書き込みに失敗","test",0);546 }547 if( !compiler.GetObjectModule().ReadText( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.xml" ) )548 {549 MessageBox(0,"XML読み込みに失敗","test",0);550 }551 t2=GetTickCount();552 t2-=t;553 char s[100];554 sprintf(s,"%d",t2);555 MessageBox(0,s,"test",0);556 557 if( !compiler.GetObjectModule().meta.WriteBinary( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.dat" ) )558 {559 MessageBox(0,"バイナリ書き込みに失敗","test",0);560 }561 Meta *pTempMeta = new Meta();562 if( !pTempMeta->ReadBinary( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.dat" ) )563 {564 MessageBox(0,"バイナリ読み込みに失敗","test",0);565 }566 if( !compiler.GetObjectModule().meta.WriteText( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.dat" ) )567 {568 MessageBox(0,"バイナリ書き込みに失敗","test",0);569 }570 Meta *pTempMeta = new Meta();571 if( !pTempMeta->ReadText( Jenga::Common::Environment::GetAppDir() + "\\objectModule_test.dat" ) )572 {573 MessageBox(0,"バイナリ読み込みに失敗","test",0);574 }*/575 508 576 509 -
trunk/abdev/BasicCompiler_Common/BasicCompiler.cpp
r276 r279 206 206 } 207 207 208 void ShowErrorLine(int LineNum,c har *FileName){208 void ShowErrorLine(int LineNum,const char *constFileName){ 209 209 HANDLE hFile; 210 210 DWORD dw; 211 char FileName[MAX_PATH]; 211 212 char temporary[MAX_PATH]; 213 214 lstrcpy( FileName, constFileName ); 212 215 213 216 if(LineNum==-1) return; … … 216 219 if(FileName){ 217 220 218 while( !IsFile(FileName)){221 while( !IsFileExist( FileName ) ){ 219 222 char temp2[MAX_PATH],temp3[MAX_PATH]; 220 223 _splitpath(FileName,NULL,NULL,temp2,temp3); -
trunk/abdev/BasicCompiler_Common/BreakPoint.cpp
r266 r279 45 45 46 46 void CFileBreakPoint::update(char *nativeCodeBuffer){ 47 extern INCLUDEFILEINFO IncludeFileInfo;48 49 47 int FileNum; 50 for(FileNum=0;FileNum< IncludeFileInfo.FilesNum;FileNum++){51 if(lstrcmpi( IncludeFileInfo.ppFileNames[FileNum],lpszFileName)==0) break;48 for(FileNum=0;FileNum<compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileCounts();FileNum++){ 49 if(lstrcmpi(compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFilePathFromFileNumber(FileNum).c_str(),lpszFileName)==0) break; 52 50 } 53 if(FileNum==IncludeFileInfo.FilesNum) return; 51 if( FileNum == compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileCounts() ) 52 { 53 return; 54 } 54 55 55 56 int i; 56 57 for(i=0;;i++){ 57 if(IncludeFileInfo.LineOfFile[i]==FileNum|| 58 IncludeFileInfo.LineOfFile[i]==-1) break; 58 if( compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( i ) == FileNum 59 || compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( i ) == -1 ) 60 { 61 break; 62 } 59 63 } 60 if(IncludeFileInfo.LineOfFile[i]==-1) return; 64 if( compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( i ) == -1 ) 65 { 66 return; 67 } 61 68 62 69 int FileBaseLine; … … 65 72 int i2,nCount=0; 66 73 for(i2=0;;i2++){ 67 if(IncludeFileInfo.LineOfFile[FileBaseLine+i2]==-1){ 74 if( compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( FileBaseLine+i2 ) == -1 ) 75 { 68 76 //ソースコードの終端行 69 77 break; -
trunk/abdev/BasicCompiler_Common/Debug.cpp
r276 r279 55 55 ///////////////////////////////////////////////////////// 56 56 57 extern INCLUDEFILEINFO IncludeFileInfo;58 59 57 int FileNum; 60 for(FileNum=0;FileNum<IncludeFileInfo.FilesNum;FileNum++){ 61 if(lstrcmpi(IncludeFileInfo.ppFileNames[FileNum],szFilePath)==0) break; 62 } 63 if(FileNum==IncludeFileInfo.FilesNum) return; 58 for(FileNum=0;FileNum<compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileCounts();FileNum++){ 59 if(lstrcmpi(compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFilePathFromFileNumber(FileNum).c_str(),szFilePath)==0) break; 60 } 61 if( FileNum == compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileCounts() ) 62 { 63 return; 64 } 64 65 65 66 for(i=0;;i++){ 66 if(IncludeFileInfo.LineOfFile[i]==FileNum|| 67 IncludeFileInfo.LineOfFile[i]==-1) break; 68 } 69 if(IncludeFileInfo.LineOfFile[i]==-1) return; 67 if( compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( i ) == FileNum 68 || compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( i ) == -1 ) 69 { 70 break; 71 } 72 } 73 if( compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( i ) == -1 ) 74 { 75 return; 76 } 70 77 71 78 int FileBaseLine; … … 73 80 74 81 int i2; 75 for(i2=0;;i++,i2++){ 76 if(FileNum<IncludeFileInfo.LineOfFile[i]){ 77 while(FileNum!=IncludeFileInfo.LineOfFile[i]) i++; 82 for(i2=0;;i++,i2++) 83 { 84 if( FileNum < compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( i ) ) 85 { 86 while( FileNum != compiler.GetObjectModule().source.GetIncludedFilesRelation().GetFileNumber( i ) ) 87 { 88 i++; 89 } 78 90 } 79 91 -
trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp
r268 r279 55 55 } 56 56 void CDebugSection::make(void){ 57 int i2, i3,BufferSize;57 int i2,BufferSize; 58 58 59 59 if(buffer){ … … 81 81 // テキストデータにシリアライズ 82 82 std::string textString; 83 compiler.GetObjectModule().Write TextString( textString );83 compiler.GetObjectModule().WriteString( textString ); 84 84 85 85 // サイズ … … 100 100 memcpy( buffer+i2, textString.c_str(), textString.size() ); 101 101 i2 += (int)textString.size(); 102 }103 104 // ソースコード105 {106 int length = compiler.source.GetLength();107 if(BufferSize<i2+(int)length+32768){108 while( BufferSize<i2+(int)length+32768 )109 {110 BufferSize+=32768;111 }112 113 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);114 }115 116 // バッファ117 lstrcpy( buffer + i2, compiler.source.GetBuffer() );118 i2 += lstrlen(buffer + i2) + 1;119 }120 121 //インクルード情報122 extern INCLUDEFILEINFO IncludeFileInfo;123 *(long *)(buffer+i2)=IncludeFileInfo.FilesNum;124 i2+=sizeof(long);125 for(i3=0;i3<IncludeFileInfo.FilesNum;i3++){126 lstrcpy(buffer+i2,IncludeFileInfo.ppFileNames[i3]);127 i2+=lstrlen(buffer+i2)+1;128 }129 for(i3=0;;i3++){130 buffer[i2++]=(char)IncludeFileInfo.LineOfFile[i3];131 if(IncludeFileInfo.LineOfFile[i3]==-1) break;132 133 //バッファが足りない場合は再確保134 if(BufferSize<i2+32768){135 BufferSize+=32768;136 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);137 }138 102 } 139 103 … … 226 190 227 191 // テキストデータからシリアライズ 228 this->objectModule.Read TextString( textString );192 this->objectModule.ReadString( textString ); 229 193 230 194 compiler.SelectObjectModule( this->objectModule ); 231 195 } 232 196 233 // ソースコード234 {235 // バッファ236 compiler.source.SetBuffer(buffer+i2);237 i2 += lstrlen( buffer+i2 ) + 1;238 }239 240 //インクルード情報241 _IncludeFileInfo.FilesNum=*(long *)(buffer+i2);242 i2+=sizeof(long);243 _IncludeFileInfo.ppFileNames=(char **)malloc(_IncludeFileInfo.FilesNum*sizeof(char *));244 for(i3=0;i3<_IncludeFileInfo.FilesNum;i3++){245 if(buffer[i2]=='\0') break;246 _IncludeFileInfo.ppFileNames[i3]=(char *)malloc(lstrlen(buffer+i2)+1);247 lstrcpy(_IncludeFileInfo.ppFileNames[i3],buffer+i2);248 i2+=lstrlen(buffer+i2)+1;249 }250 for(i3=0;;i3++){251 _IncludeFileInfo.LineOfFile[i3]=(long)buffer[i2++];252 if(_IncludeFileInfo.LineOfFile[i3]==-1) break;253 }254 197 255 198 //コードと行番号の関係 … … 294 237 // ブレークポイントを適用 295 238 ///////////////////////////// 296 297 //インクルード情報298 extern INCLUDEFILEINFO IncludeFileInfo;299 IncludeFileInfo=this->_IncludeFileInfo;300 239 301 240 //コードと行番号の関係 … … 412 351 compiler.SelectObjectModule( this->objectModule ); 413 352 414 //インクルード情報415 extern INCLUDEFILEINFO IncludeFileInfo;416 IncludeFileInfo=this->_IncludeFileInfo;417 418 353 //コードと行番号の関係 419 354 extern SourceLines oldSourceLines; … … 433 368 434 369 void CDebugSection::DeleteDebugInfo(void){ 435 int i2;436 437 //インクルード情報を解放438 for(i2=0;i2<_IncludeFileInfo.FilesNum;i2++)439 {440 free(_IncludeFileInfo.ppFileNames[i2]);441 }442 free(_IncludeFileInfo.ppFileNames);443 444 370 //コードバッファを解放 445 371 free(OpBuffer); -
trunk/abdev/BasicCompiler_Common/DebugSection.h
r266 r279 27 27 // オブジェクトモジュール 28 28 ObjectModule objectModule; 29 30 //インクルード情報31 INCLUDEFILEINFO _IncludeFileInfo;32 29 33 30 //コードと行番号の関係 -
trunk/abdev/BasicCompiler_Common/Enum.cpp
r268 r279 115 115 iEnumParentNum=0; 116 116 117 const char *source = compiler. source.GetBuffer();117 const char *source = compiler.GetObjectModule().source.GetBuffer(); 118 118 119 119 // 名前空間管理 -
trunk/abdev/BasicCompiler_Common/Intermediate_Step1.cpp
r271 r279 255 255 256 256 compiler.staticLibraries.push_back( new ObjectModule() ); 257 compiler.staticLibraries.back()->Read Text( temporary );257 compiler.staticLibraries.back()->Read( temporary ); 258 258 259 259 for(;;i2++){ -
trunk/abdev/BasicCompiler_Common/MakeExe.cpp
r273 r279 24 24 25 25 //最後尾に貼り付け 26 compiler. source.Addition( temp );26 compiler.GetObjectModule().source.Addition( temp ); 27 27 28 28 HeapDefaultFree(temp); … … 35 35 extern BOOL bStopCompile; 36 36 extern HWND hMainDlg; 37 int i 2,i3;37 int i3; 38 38 char temp2[MAX_PATH]; 39 39 … … 57 57 //プログラムをファイルから読み込む 58 58 extern char SourceFileName[MAX_PATH]; 59 if( !compiler. source.ReadFile( SourceFileName ) ){59 if( !compiler.GetObjectModule().source.ReadFile( SourceFileName ) ){ 60 60 SetError(201,SourceFileName,-1); 61 61 goto EndCompile; … … 188 188 ShowWindow(hMainDlg,SW_SHOW); 189 189 #endif 190 191 //#include情報を解放192 extern INCLUDEFILEINFO IncludeFileInfo;193 for(i2=0;i2<IncludeFileInfo.FilesNum;i2++)194 {195 free(IncludeFileInfo.ppFileNames[i2]);196 }197 free(IncludeFileInfo.ppFileNames);198 190 } 199 191 int MainThread(DWORD dummy){ -
trunk/abdev/BasicCompiler_Common/StrOperation.cpp
r266 r279 190 190 } 191 191 } 192 BOOL GetLineNum(int pos,int *pLine,char *FileName){193 extern INCLUDEFILEINFO IncludeFileInfo;194 extern char *basbuf;195 int i,i2,i3,i4,i5;196 197 i=pos;198 if(basbuf[i]=='\n') i--;199 for(i3=0,i2=0;i3<i;i3++){200 if(basbuf[i3]=='\n') i2++;201 if(basbuf[i3]=='\0') return 0;202 }203 i4=0;204 while(IncludeFileInfo.LineOfFile[i2]!=IncludeFileInfo.LineOfFile[i4]) i4++;205 for(i3=0,i5=0;i5<i4;i3++){206 if(basbuf[i3]=='\n') i5++;207 if(basbuf[i3]=='\0') return 0;208 }209 for(i5=0;i4<i2;i3++){210 if(basbuf[i3]=='\n'){211 i4++;212 i5++;213 if(IncludeFileInfo.LineOfFile[i2]<IncludeFileInfo.LineOfFile[i4]){214 for(;IncludeFileInfo.LineOfFile[i2]!=IncludeFileInfo.LineOfFile[i4];i3++){215 if(basbuf[i3]=='\n') i4++;216 }217 }218 }219 if(basbuf[i3]=='\0') return 0;220 }221 222 if(IncludeFileInfo.LineOfFile[i2]==-1){223 //ファイル・行番号を特定できなかった場合224 *pLine=-1;225 FileName[0]=0;226 }227 else{228 //行番号をセット229 *pLine=i5;230 231 //ファイル名をセット232 lstrcpy(FileName,IncludeFileInfo.ppFileNames[IncludeFileInfo.LineOfFile[i2]]);233 }234 235 return 1;236 }237 192 238 193 char GetEndXXXCommand(char es){ … … 449 404 } 450 405 451 BOOL IsFile(char *path){406 bool IsFileExist(const char *path){ 452 407 WIN32_FIND_DATA wfd; 453 408 HANDLE hFind; … … 455 410 hFind=FindFirstFile(path,&wfd); 456 411 if(hFind==INVALID_HANDLE_VALUE){ 457 return 0;412 return false; 458 413 } 459 414 FindClose(hFind); 460 415 461 return 1;416 return true; 462 417 } 463 418 BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle){ -
trunk/abdev/BasicCompiler_Common/VarList.cpp
r265 r279 591 591 } 592 592 593 if(!GetLineNum(pobj_dti->lpdwCp[pobj_dti->iProcLevel],&i2,temporary)){ 593 std::string dummyStr; 594 if(!compiler.GetObjectModule().source.GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){ 594 595 extern HWND hMainDlg; 595 596 //"デバッグ情報の取得に失敗" … … 597 598 return 0; 598 599 } 599 ShowErrorLine(i2, temporary);600 ShowErrorLine(i2,dummyStr.c_str()); 600 601 601 602 //プロシージャ コンボボックス … … 666 667 extern WNDPROC OldProcComboProc; 667 668 int i2,i3; 668 char temporary[MAX_PATH];669 669 670 670 switch(message){ … … 672 672 if(HIWORD(wParam)==CBN_SELCHANGE){ 673 673 i2=(int)SendMessage(hwnd,CB_GETCURSEL,0,0); 674 GetLineNum(pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2],&i3,temporary); 675 ShowErrorLine(i3,temporary); 674 675 std::string dummyStr; 676 compiler.GetObjectModule().source.GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr ); 677 ShowErrorLine(i3,dummyStr.c_str()); 676 678 677 679 RefreshLocalVar_with_WindowLock(); -
trunk/abdev/BasicCompiler_Common/common.h
r263 r279 219 219 void GetRelationalPath(char *path,char *dir); 220 220 void GetFullPath( char *path, const string &baseDirPath ); 221 void ShowErrorLine(int LineNum,c har *FileName);221 void ShowErrorLine(int LineNum,const char *FileName); 222 222 BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen); 223 223 void MakeMessageText(char *buffer,char *msg,int flag); … … 318 318 void SlideBuffer(char *buffer,int length,int slide); 319 319 int GetCpFromLine(int LineNum); 320 BOOL GetLineNum(int pos,int *pLine,char *FileName);321 320 char GetEndXXXCommand(char es); 322 321 void GetDefaultNameFromES(char es,char *name); 323 322 const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source ); 324 BOOL IsFile(char *path);323 bool IsFileExist(const char *path); 325 324 BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath); 326 325 BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle); -
trunk/abdev/BasicCompiler_Common/error.cpp
r206 r279 4 4 5 5 #include <Program.h> 6 #include <C lass.h>6 #include <Compiler.h> 7 7 8 8 #include "../BasicCompiler_Common/common.h" … … 291 291 extern ERRORINFO *pErrorInfo; 292 292 extern int ErrorNum; 293 char temporary[1024],temp2[1024],temp3[32] ,FileName[MAX_PATH];293 char temporary[1024],temp2[1024],temp3[32]; 294 294 BOOL bFirst; 295 295 int i2; … … 329 329 } 330 330 else{ 331 GetLineNum(pos,&pErrorInfo[ErrorNum].line,FileName); 332 333 pErrorInfo[ErrorNum].FileName=(char *)HeapAlloc(hHeap,0,lstrlen(FileName)+1); 334 lstrcpy(pErrorInfo[ErrorNum].FileName,FileName); 331 std::string dummyStr; 332 compiler.GetObjectModule().source.GetLineInfo( pos, pErrorInfo[ErrorNum].line, dummyStr ); 333 334 pErrorInfo[ErrorNum].FileName=(char *)HeapAlloc(hHeap,0,lstrlen(dummyStr.c_str())+1); 335 lstrcpy(pErrorInfo[ErrorNum].FileName,dummyStr.c_str()); 335 336 336 337 _splitpath(pErrorInfo[ErrorNum].FileName,0,0,temp2,temp3); -
trunk/abdev/BasicCompiler_Common/include/BoostSerializationSupport.h
r264 r279 25 25 bool ReadXml( const std::string &xmlFilePath, bool isShowExceptionMessage = true ); 26 26 bool WriteXml( const std::string &xmlFilePath, bool isShowExceptionMessage = true ) const; 27 bool ReadXmlString( const std::string &xmlString ); 28 bool WriteXmlString( std::string &xmlString ) const; 27 29 28 30 bool ReadBinary( const std::string &filePath, bool isShowExceptionMessage = true ); -
trunk/abdev/BasicCompiler_Common/include/Compiler.h
r270 r279 46 46 return namespaceSupporter; 47 47 } 48 49 // ソースコード50 BasicSource source;51 48 52 49 // コード生成機構 -
trunk/abdev/BasicCompiler_Common/include/DataTable.h
r273 r279 28 28 for( int i=0; i<size; i++ ) 29 29 { 30 if( _buffer[i*3+2] != ',' ) 31 { 32 //エラー 33 DebugBreak(); 34 } 35 ULONG_PTR l; 36 sscanf( _buffer.c_str() + i*3, "%02x,", &l ); 37 buffer[i] = (char)l; 30 ULONG_PTR l1 = ( ( _buffer[i*3] >= 'a' ) ? ( _buffer[i*3] - 'a' + 0x0a ) : ( _buffer[i*3] - '0' ) ) * 0x10; 31 ULONG_PTR l2 = ( _buffer[i*3+1] >= 'a' ) ? ( _buffer[i*3+1] - 'a' + 0x0a ) : ( _buffer[i*3+1] - '0' ); 32 ULONG_PTR l = l1 + l2; 33 buffer[i] = static_cast<char>(l); 38 34 } 39 35 } -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r278 r279 219 219 for( int i=0; i<size; i++ ) 220 220 { 221 ULONG_PTR l; 222 sscanf( code.c_str() + i*3, "%02x,", &l ); 223 codeBuffer[i] = (char)l; 221 ULONG_PTR l1 = ( ( code[i*3] >= 'a' ) ? ( code[i*3] - 'a' + 0x0a ) : ( code[i*3] - '0' ) ) * 0x10; 222 ULONG_PTR l2 = ( code[i*3+1] >= 'a' ) ? ( code[i*3+1] - 'a' + 0x0a ) : ( code[i*3+1] - '0' ); 223 ULONG_PTR l = l1 + l2; 224 codeBuffer[i] = static_cast<char>(l); 224 225 } 225 226 } -
trunk/abdev/BasicCompiler_Common/include/ObjectModule.h
r273 r279 12 12 // データテーブル 13 13 DataTable dataTable; 14 15 // ソースコード 16 BasicSource source; 14 17 15 18 // XMLシリアライズ用 … … 27 30 ar & BOOST_SERIALIZATION_NVP( globalNativeCode ); 28 31 ar & BOOST_SERIALIZATION_NVP( dataTable ); 32 ar & BOOST_SERIALIZATION_NVP( source ); 29 33 } 30 34 31 35 public: 32 36 void StaticLink( ObjectModule &objectModule ); 37 38 bool Read( const std::string &filePath ); 39 bool Write( const std::string &filePath ) const; 40 bool ReadString( const std::string &str ); 41 bool WriteString( std::string &str ) const; 33 42 }; 34 43 typedef std::vector<ObjectModule *> ObjectModules; -
trunk/abdev/BasicCompiler_Common/include/Source.h
r268 r279 18 18 int FilesNum; 19 19 int LineOfFile[MAX_LEN]; 20 }; 21 22 class IncludedFilesRelation 23 { 24 std::vector<std::string> filePaths; 25 std::vector<int> lineFileNumbers; 26 27 // XMLシリアライズ用 28 private: 29 friend class boost::serialization::access; 30 template<class Archive> void serialize(Archive& ar, const unsigned int version) 31 { 32 trace_for_serialize( "serializing - IncludedFilesRelation" ); 33 34 ar & BOOST_SERIALIZATION_NVP( filePaths ); 35 ar & BOOST_SERIALIZATION_NVP( lineFileNumbers ); 36 } 37 38 public: 39 IncludedFilesRelation() 40 { 41 } 42 ~IncludedFilesRelation() 43 { 44 } 45 46 const int GetFileNumber( int lineNumber ) const 47 { 48 return lineFileNumbers[lineNumber]; 49 } 50 const std::string &GetFilePath( int lineNumber ) const 51 { 52 return filePaths[GetFileNumber( lineNumber )]; 53 } 54 const std::string &GetFilePathFromFileNumber( int fileNumber ) const 55 { 56 return filePaths[fileNumber]; 57 } 58 int GetFileCounts() const 59 { 60 return filePaths.size(); 61 } 62 63 int AddFile( const std::string &filePath ) 64 { 65 filePaths.push_back( filePath ); 66 return filePaths.size()-1; 67 } 68 void AddLine( int fileNumber ) 69 { 70 lineFileNumbers.push_back( fileNumber ); 71 } 72 73 int GetLineCounts() const 74 { 75 return lineFileNumbers.size(); 76 } 20 77 }; 21 78 … … 66 123 static const string generateDirectiveName; 67 124 125 IncludedFilesRelation includedFilesRelation; 126 127 // XMLシリアライズ用 128 private: 129 friend class boost::serialization::access; 130 BOOST_SERIALIZATION_SPLIT_MEMBER(); 131 template<class Archive> void load(Archive& ar, const unsigned int version) 132 { 133 trace_for_serialize( "serializing(load) - BasicSource" ); 134 135 std::string _buffer; 136 ar & BOOST_SERIALIZATION_NVP( _buffer ); 137 ar & BOOST_SERIALIZATION_NVP( length ); 138 ar & BOOST_SERIALIZATION_NVP( includedFilesRelation ); 139 140 // 読み込み後の処理 141 Realloc( length ); 142 for( int i=0; i<length; i++ ) 143 { 144 ULONG_PTR l1 = ( ( _buffer[i*3] >= 'a' ) ? ( _buffer[i*3] - 'a' + 0x0a ) : ( _buffer[i*3] - '0' ) ) * 0x10; 145 ULONG_PTR l2 = ( _buffer[i*3+1] >= 'a' ) ? ( _buffer[i*3+1] - 'a' + 0x0a ) : ( _buffer[i*3+1] - '0' ); 146 ULONG_PTR l = l1 + l2; 147 buffer[i] = static_cast<char>(l); 148 } 149 buffer[length] = 0; 150 } 151 template<class Archive> void save(Archive& ar, const unsigned int version) const 152 { 153 trace_for_serialize( "serializing(save) - BasicSource" ); 154 155 // 保存準備 156 char *tempCode = (char *)calloc( (length+1) * 3, 1 ); 157 for( int i=0; i<length; i++ ) 158 { 159 char temp[32]; 160 sprintf( temp, "%02x,", (unsigned char)buffer[i] ); 161 tempCode[i*3] = temp[0]; 162 tempCode[i*3+1] = temp[1]; 163 tempCode[i*3+2] = temp[2]; 164 } 165 166 std::string _buffer = tempCode; 167 free( tempCode ); 168 169 ar & BOOST_SERIALIZATION_NVP( _buffer ); 170 ar & BOOST_SERIALIZATION_NVP( length ); 171 ar & BOOST_SERIALIZATION_NVP( includedFilesRelation ); 172 } 173 174 private: 68 175 void Realloc( int newLength ){ 69 176 buffer = (char *)realloc( buffer, newLength + 255 ); … … 102 209 } 103 210 211 const IncludedFilesRelation &GetIncludedFilesRelation() const 212 { 213 return includedFilesRelation; 214 } 215 104 216 void SetBuffer( const char *buffer ); 105 217 … … 109 221 110 222 void Addition( const char *buffer ); 223 224 bool GetLineInfo( int sourceCodePos, int &line, std::string &fileName ); 111 225 112 226 void operator = ( const BasicSource &source ){ -
trunk/abdev/BasicCompiler_Common/src/BoostSerializationSupport.cpp
r264 r279 115 115 return result; 116 116 } 117 template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXmlString( const std::string &xmlString ) 118 { 119 bool isSuccessful = false; 120 121 // 入力アーカイブの作成 122 std::istringstream iss( xmlString ); 123 124 try{ 125 boost::archive::xml_iarchive ia(iss); 126 127 // 文字列ストリームから読込 128 ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this ); 129 130 isSuccessful = true; 131 } 132 catch(...){ 133 // 失敗 134 } 135 136 if( !isSuccessful ) 137 { 138 return false; 139 } 140 141 return true; 142 } 143 template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteXmlString( std::string &xmlString ) const 144 { 145 // 出力アーカイブの作成 146 std::ostringstream oss; 147 148 bool isSuccessful = false; 149 try{ 150 boost::archive::xml_oarchive oa(oss); 151 152 // 文字列ストリームに書き出し 153 oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this ); 154 155 isSuccessful = true; 156 } 157 catch( boost::archive::archive_exception e ) 158 { 159 echo( e.what() ); 160 } 161 catch(...){ 162 echo( "archive_exception以外の不明な例外" ); 163 } 164 165 if( !isSuccessful ) 166 { 167 return false; 168 } 169 170 xmlString = oss.str(); 171 172 return true; 173 } 117 174 118 175 template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadBinary( const string &filePath, bool isShowExceptionMessage ) -
trunk/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r276 r279 2 2 3 3 #include <Compiler.h> 4 5 enum ObjectModuleDataType 6 { 7 ObjectModuleDataTypeXml, 8 ObjectModuleDataTypeText, 9 ObjectModuleDataTypeBinaly, 10 }; 11 const ObjectModuleDataType objectModuleDataType = ObjectModuleDataTypeText; 12 4 13 5 14 void ObjectModule::StaticLink( ObjectModule &objectModule ) … … 15 24 dataTable.Add( objectModule.dataTable ); 16 25 } 26 27 bool ObjectModule::Read( const std::string &filePath ) 28 { 29 switch( objectModuleDataType ) 30 { 31 case ObjectModuleDataTypeXml: 32 return ReadXml( filePath ); 33 case ObjectModuleDataTypeText: 34 return ReadText( filePath ); 35 case ObjectModuleDataTypeBinaly: 36 return ReadBinary( filePath ); 37 default: 38 Jenga::Throw( "" ); 39 break; 40 } 41 return false; 42 } 43 bool ObjectModule::Write( const std::string &filePath ) const 44 { 45 switch( objectModuleDataType ) 46 { 47 case ObjectModuleDataTypeXml: 48 return WriteXml( filePath ); 49 case ObjectModuleDataTypeText: 50 return WriteText( filePath ); 51 case ObjectModuleDataTypeBinaly: 52 return WriteBinary( filePath ); 53 default: 54 Jenga::Throw( "" ); 55 break; 56 } 57 return false; 58 } 59 bool ObjectModule::ReadString( const std::string &str ) 60 { 61 switch( objectModuleDataType ) 62 { 63 case ObjectModuleDataTypeXml: 64 return ReadXmlString( str ); 65 case ObjectModuleDataTypeText: 66 return ReadTextString( str ); 67 case ObjectModuleDataTypeBinaly: 68 Jenga::Throw( "" ); 69 break; 70 default: 71 Jenga::Throw( "" ); 72 break; 73 } 74 return false; 75 } 76 bool ObjectModule::WriteString( std::string &str ) const 77 { 78 switch( objectModuleDataType ) 79 { 80 case ObjectModuleDataTypeXml: 81 return WriteXmlString( str ); 82 case ObjectModuleDataTypeText: 83 return WriteTextString( str ); 84 case ObjectModuleDataTypeBinaly: 85 Jenga::Throw( "" ); 86 break; 87 default: 88 Jenga::Throw( "" ); 89 break; 90 } 91 return false; 92 } -
trunk/abdev/BasicCompiler_Common/src/Source.cpp
r270 r279 13 13 #include <Compiler.h> 14 14 15 16 INCLUDEFILEINFO IncludeFileInfo;17 15 18 16 const string BasicSource::generateDirectiveName = "#generate"; … … 537 535 char temporary[MAX_PATH],temp2[MAX_PATH+255],*LayerDir[255]; 538 536 539 IncludeFileInfo.ppFileNames=(char **)calloc(sizeof(char *),1);540 extern char SourceFileName[MAX_PATH];541 IncludeFileInfo.ppFileNames[0]=(char *)malloc(lstrlen(SourceFileName)+1);542 lstrcpy(IncludeFileInfo.ppFileNames[0],SourceFileName);543 IncludeFileInfo.FilesNum=1;544 545 537 layer=0; 546 538 FileLayer[layer]=0; … … 548 540 LineNum=0; 549 541 542 if( includedFilesRelation.GetLineCounts() != 0 ) 543 { 544 Jenga::Throw( "インクルードファイル構造の初期値が不正" ); 545 } 546 547 // メインソースコード 548 extern char SourceFileName[MAX_PATH]; 549 FileLayer[layer] = includedFilesRelation.AddFile( SourceFileName ); 550 550 551 //参照ディレクトリ 551 552 LayerDir[0]=(char *)malloc(lstrlen(BasicCurDir)+1); … … 554 555 for(i=0;;i++){ 555 556 if(buffer[i]=='\0'){ 556 IncludeFileInfo.LineOfFile[LineNum]=-1;557 557 break; 558 558 } 559 559 if(buffer[i]=='\n'){ 560 IncludeFileInfo.LineOfFile[LineNum]=FileLayer[layer]; 561 LineNum++; 560 includedFilesRelation.AddLine( FileLayer[layer] ); 562 561 } 563 562 if(i>LastFileByte[layer]){ … … 624 623 } 625 624 626 IncludeFileInfo.ppFileNames=(char **)realloc(IncludeFileInfo.ppFileNames,(IncludeFileInfo.FilesNum+1)*sizeof(char *));627 IncludeFileInfo.ppFileNames[IncludeFileInfo.FilesNum]=(char *)malloc(lstrlen(temporary)+1);628 lstrcpy(IncludeFileInfo.ppFileNames[IncludeFileInfo.FilesNum],temporary);629 630 625 layer++; 631 FileLayer[layer]=IncludeFileInfo.FilesNum; 632 IncludeFileInfo.FilesNum++; 626 FileLayer[layer] = includedFilesRelation.AddFile( temporary ); 633 627 634 628 //#requireの場合では、既に読み込まれているファイルは読み込まないようにする … … 926 920 lstrcat( this->buffer, buffer ); 927 921 } 922 923 bool BasicSource::GetLineInfo( int sourceCodePos, int &line, std::string &filePath ) 924 { 925 int i2,i3,i4,i5; 926 927 char *buffer = GetBuffer(); 928 int i = sourceCodePos; 929 930 if(buffer[i]=='\n') i--; 931 for(i3=0,i2=0;i3<i;i3++){ 932 if(buffer[i3]=='\n') i2++; 933 if(buffer[i3]=='\0') return 0; 934 } 935 936 if( includedFilesRelation.GetLineCounts() < i2 ) 937 { 938 Jenga::Throw( "BasicSource::GetLineInfoメソッドで不正な行の情報を取得しようとした" ); 939 940 //ファイル・行番号を特定できなかった場合 941 line = -1; 942 filePath = ""; 943 return false; 944 } 945 946 i4=0; 947 while( includedFilesRelation.GetFileNumber( i2 ) != includedFilesRelation.GetFileNumber( i4 ) ) 948 { 949 i4++; 950 } 951 for(i3=0,i5=0;i5<i4;i3++){ 952 if(buffer[i3]=='\n') i5++; 953 if(buffer[i3]=='\0') return 0; 954 } 955 for(i5=0;i4<i2;i3++){ 956 if(buffer[i3]=='\n'){ 957 i4++; 958 i5++; 959 if( includedFilesRelation.GetFileNumber( i2 ) < includedFilesRelation.GetFileNumber( i4 ) ) 960 { 961 for( ;includedFilesRelation.GetFileNumber( i2 ) != includedFilesRelation.GetFileNumber( i4 ); i3++ ){ 962 if(buffer[i3]=='\n') i4++; 963 } 964 } 965 } 966 if(buffer[i3]=='\0') return 0; 967 } 968 969 //行番号をセット 970 line = i5; 971 972 //ファイル名をセット 973 filePath = includedFilesRelation.GetFilePath( i2 ); 974 975 return 1; 976 }
Note:
See TracChangeset
for help on using the changeset viewer.