Changeset 279 in dev for trunk/abdev/BasicCompiler_Common/src/Source.cpp
- Timestamp:
- Aug 14, 2007, 3:22:02 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.