Changeset 15 in dev
- Timestamp:
- Dec 11, 2006, 3:07:59 AM (18 years ago)
- Files:
-
- 2 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/BasicCompiler.vcproj
r14 r15 1277 1277 <File 1278 1278 RelativePath="..\BasicCompiler_Common\Variable.h" 1279 >1280 </File>1281 </Filter>1282 <Filter1283 Name="LexicalAnalysis"1284 >1285 <File1286 RelativePath="..\BasicCompiler_Common\LexicalAnalysis.cpp"1287 >1288 </File>1289 <File1290 RelativePath="..\BasicCompiler_Common\LexicalAnalysis.h"1291 1279 > 1292 1280 </File> -
BasicCompiler32/MakePeHdr.cpp
r14 r15 166 166 char *temp; 167 167 temp=CEnumParent::GenerateCodes(); 168 CSource::obj.AddSourceCode(temp); 169 basbuf = CSource::obj.SourceCode; 168 AddSourceCode(temp); 170 169 HeapDefaultFree(temp); 171 170 -
BasicCompiler64/BasicCompiler.vcproj
r14 r15 1522 1522 </File> 1523 1523 </Filter> 1524 <Filter1525 Name="LexicalAnalysis"1526 >1527 <File1528 RelativePath="..\BasicCompiler_Common\LexicalAnalysis.cpp"1529 >1530 </File>1531 <File1532 RelativePath="..\BasicCompiler_Common\LexicalAnalysis.h"1533 >1534 </File>1535 </Filter>1536 1524 </Filter> 1537 1525 </Filter> -
BasicCompiler64/Compile_Object.cpp
r3 r15 75 75 } 76 76 } 77 int Operator_New(c har *Parameter,LONG_PTR *plpIndex){77 int Operator_New(const char *Parameter,LONG_PTR *plpIndex){ 78 78 char TypeName[VN_SIZE],CreateParameter[VN_SIZE],ObjectSize[VN_SIZE]; 79 79 int i,i2; … … 237 237 } 238 238 239 void OpcodeDelete(c har *Parameter){239 void OpcodeDelete(const char *Parameter){ 240 240 int type; 241 241 -
BasicCompiler64/MakePeHdr.cpp
r14 r15 154 154 char *temp; 155 155 temp=CEnumParent::GenerateCodes(); 156 CSource::obj.AddSourceCode(temp); 157 basbuf = CSource::obj.SourceCode; 156 AddSourceCode(temp); 158 157 HeapDefaultFree(temp); 159 158 -
BasicCompiler64/NumOpe.cpp
r11 r15 108 108 } 109 109 110 int NumOpe(int *pReg,c har *Command,int BaseType,LONG_PTR lpBaseIndex,LONG_PTR *plpIndex,BOOL *pbUseHeap){110 int NumOpe(int *pReg,const char *Command,int BaseType,LONG_PTR lpBaseIndex,LONG_PTR *plpIndex,BOOL *pbUseHeap){ 111 111 extern HANDLE hHeap; 112 112 int i,i2,i3,i4; -
BasicCompiler64/Opcode.h
r11 r15 250 250 251 251 //NumOpe.cpp 252 int NumOpe(int *pReg,c har *Command,int BaseType,LONG_PTR lpBaseIndex,LONG_PTR *plpIndex,BOOL *pbUseHeap=0);252 int NumOpe(int *pReg,const char *Command,int BaseType,LONG_PTR lpBaseIndex,LONG_PTR *plpIndex,BOOL *pbUseHeap=0); 253 253 254 254 //NumOpe_Arithmetic.cpp … … 311 311 312 312 //Compile_Object.cpp 313 int Operator_New(c har *Parameter,LONG_PTR *plpIndex);314 void OpcodeDelete(c har *Parameter);313 int Operator_New(const char *Parameter,LONG_PTR *plpIndex); 314 void OpcodeDelete(const char *Parameter); 315 315 316 316 //Compile_Var.cpp -
BasicCompiler_Common/BasicCompiler.cpp
r14 r15 1 1 #include "BasicCompiler.h" 2 3 2 4 3 #if defined HeapAlloc -
BasicCompiler_Common/BasicCompiler.h
r14 r15 1 #include " common.h"1 #include "../BasicCompiler_Common/common.h" 2 2 3 3 LPSTR BasicFileFilter="プログラム ファイル(*.ab;*.bas;*.abp;*.sbp)\0*.ab;*.bas;*.abp;*sbp\0テキスト ファイル(*.txt)\0*.txt\0すべてのファイル(*.*)\0*\0\0"; … … 83 83 BOOL bDll; 84 84 85 char *basbuf; 86 char *pBaseBuffer; 87 85 88 char BasicSystemDir[MAX_PATH]; //BasicCompiler.exeが存在するディレクトリ 86 89 char BasicCurDir[MAX_PATH]; //コンパイルするファイルが存在するディレクトリ -
BasicCompiler_Common/Compile.cpp
r7 r15 392 392 BufferSize=128; 393 393 Command=(char *)HeapAlloc(hHeap,0,BufferSize); 394 /* 395 i = CSource::obj.GetTokenIndex(cp); 396 CToken *ptoken; 397 do{ 398 //次のトークン 399 ptoken = CSource::obj.GetToken(i++); 400 401 //ステップ区切り(改行またはコロン)の場合 402 while(ptoken->GetType() == TOKEN_DELIMITATION){ 403 ptoken = CSource::obj.GetToken(i++); 404 continue; 405 } 406 407 if(ptoken->GetType() == TOKEN_ESCAPESEQUENCE){ 408 //////////////////////////// 409 // 特殊記号 410 //////////////////////////// 411 412 if(ptoken->GetExtended() == ESC_LINENUM){ 413 414 //行番号 415 ptoken = CSource::obj.GetToken(i++); 416 417 i3=atoi(ptoken->ToString()); 418 i4=i+1; 419 420 //Goto先ラベル 421 pLabelNames=(LABEL *)HeapReAlloc(hHeap,0,pLabelNames,(MaxLabelNum+1)*sizeof(LABEL)); 422 pLabelNames[MaxLabelNum].pName=0; 423 pLabelNames[MaxLabelNum].line=i3; 424 pLabelNames[MaxLabelNum].address=obp; 425 MaxLabelNum++; 426 427 //書き込みスケジュール 428 for(i=0;i<GotoLabelScheduleNum;i++){ 429 if(pGotoLabelSchedule[i].pName==0&& 430 pGotoLabelSchedule[i].line==i3){ 431 *((long *)(OpBuffer+pGotoLabelSchedule[i].pos))=obp-(pGotoLabelSchedule[i].pos+sizeof(long)); 432 433 //詰める 434 GotoLabelScheduleNum--; 435 for(i2=i;i2<GotoLabelScheduleNum;i2++){ 436 pGotoLabelSchedule[i2].pName=pGotoLabelSchedule[i2+1].pName; 437 pGotoLabelSchedule[i2].line=pGotoLabelSchedule[i2+1].line; 438 pGotoLabelSchedule[i2].pos=pGotoLabelSchedule[i2+1].pos; 439 } 440 i--; 441 } 442 } 443 444 //カンマ 445 i++; 446 447 //次のトークン 448 ptoken = CSource::obj.GetToken(i++); 449 } 450 } 451 }while(ptoken->GetType() == TOKEN_EOF); 452 */ 394 453 for(cp++,i2=0;;cp++,i2++){ 395 454 if(i2>=BufferSize){ -
BasicCompiler_Common/DebugMiddleFile.cpp
r14 r15 474 474 //ソースコード 475 475 i2++; 476 CSource::obj.SetSourceCode(buffer + i2); 477 this->basbuf=CSource::obj.SourceCode; 476 pBaseBuffer=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+3); 477 basbuf=pBaseBuffer+2; 478 lstrcpy(basbuf,buffer+i2); 479 i2+=lstrlen(buffer+i2)+1; 478 480 extern char *basbuf; 479 481 basbuf=this->basbuf; 480 i2+=lstrlen(buffer+i2)+1;481 482 482 483 //コードと行番号の関係 … … 933 934 934 935 //ソースコード 936 extern char *pBaseBuffer; 935 937 extern char *basbuf; 938 pBaseBuffer=this->pBaseBuffer; 936 939 basbuf=this->basbuf; 937 940 … … 1013 1016 DeleteConstInfo(ppConstHash); 1014 1017 1018 //ソースコードを解放 1019 HeapDefaultFree(pBaseBuffer); 1020 1015 1021 //コードと行番号の関係を解放 1016 1022 HeapDefaultFree(pLineInfo); -
BasicCompiler_Common/DebugSection.h
r14 r15 25 25 26 26 //ソースコード 27 char *pBaseBuffer; 27 28 char *basbuf; 28 29 -
BasicCompiler_Common/MakeExe.cpp
r14 r15 34 34 } 35 35 36 void AddSourceCode(char *buffer){ 37 char *temp; 38 temp=(char *)HeapAlloc(hHeap,0,lstrlen(buffer)+8192); 39 lstrcpy(temp,buffer); 40 41 //エスケープシーケンス設定 42 SetEscapeSequenceFormat(temp); 43 44 //コマンド対応 45 ChangeCommandToCode(temp); 46 47 //新しいソースコードバッファの容量 48 extern char *basbuf; 49 int NewSize; 50 NewSize=lstrlen(basbuf)+lstrlen(temp); 51 NewSize*=2; 52 NewSize+=255; 53 54 //最後尾に貼り付け 55 extern char *pBaseBuffer; 56 pBaseBuffer=(char *)HeapReAlloc(hHeap,0,pBaseBuffer,NewSize); 57 basbuf=pBaseBuffer+2; 58 lstrcat(basbuf,temp); 59 60 HeapDefaultFree(temp); 61 } 62 36 63 void OutputExe(void){ 37 64 extern HANDLE hHeap; 38 65 extern char *basbuf; 66 extern char *pBaseBuffer; 39 67 extern int ErrorNum; 40 68 extern BOOL bStopCompile; … … 59 87 //プログラムをファイルから読み込む 60 88 extern char SourceFileName[MAX_PATH]; 61 CSource::obj.OpenFile(SourceFileName); 62 63 //未完成 64 basbuf = CSource::obj.SourceCode; 89 pBaseBuffer=OpenBasicFile(SourceFileName); 90 if(!pBaseBuffer){ 91 SetError(201,SourceFileName,-1); 92 goto EndCompile; 93 } 94 basbuf=pBaseBuffer+2; 65 95 66 96 //イメージベースの設定 … … 142 172 143 173 StepCompileProgress(); 144 145 146 //字句解析147 CSource::obj.LexicalAnalysis(0);148 174 149 175 … … 265 291 HeapDefaultFree(IncludeFileInfo.ppFileNames[i2]); 266 292 HeapDefaultFree(IncludeFileInfo.ppFileNames); 293 294 if(pBaseBuffer) HeapDefaultFree(pBaseBuffer); 267 295 } 268 296 int MainThread(DWORD dummy){ -
BasicCompiler_Common/StrOperation.cpp
r4 r15 249 249 return i; 250 250 } 251 int GetStringInPare(char *buffer,c har *ReadBuffer){251 int GetStringInPare(char *buffer,const char *ReadBuffer){ 252 252 int i,IsStr,PareNum; 253 253 for(i=0,IsStr=0,PareNum=0;;i++){ … … 294 294 return i; 295 295 } 296 int GetStringInBracket(char *buffer,c har *ReadBuffer){296 int GetStringInBracket(char *buffer,const char *ReadBuffer){ 297 297 int i,IsStr,PareNum; 298 298 for(i=0,IsStr=0,PareNum=0;;i++){ -
BasicCompiler_Common/calculation.cpp
r14 r15 10 10 _int64 i64stack[255]; 11 11 12 bool IsNumberTopChar(c har *buffer){12 bool IsNumberTopChar(const char *buffer){ 13 13 int c = buffer[0]; 14 14 if('0' <= c && c <= '9') return true; 15 if( buffer[0]== '&' && (buffer[1] == 'h' || buffer[1] == 'H' || buffer[1] == 'o' || buffer[1] == 'O')) return true;15 if(c == '&' && (buffer[1] == 'h' || buffer[1] == 'H' || buffer[1] == 'o' || buffer[1] == 'O')) return true; 16 16 17 17 return false; 18 18 } 19 bool IsNumberChar(c har c){19 bool IsNumberChar(const char c){ 20 20 if('0' <= c && c <= '9') return true; 21 21 if('a' <= c && c <= 'f') return true; 22 22 if('A' <= c && c <= 'F') return true; 23 if(c=='.' || c=='e'||c=='E') return true; 23 24 24 25 return false; 25 26 } 26 BOOL IsJudgMark(c har *Command,int p){27 BOOL IsJudgMark(const char *Command,int p){ 27 28 if(Command[p]==1){ 28 29 if(Command[p+1]==ESC_AND) return 1; … … 33 34 return 0; 34 35 } 35 BOOL IsNumCalcMark(c har *Command,int p){36 BOOL IsNumCalcMark(const char *Command,int p){ 36 37 if(Command[p]=='^'||Command[p]=='*'||Command[p]=='/'||Command[p]=='\\'|| 37 38 (Command[p]==1&&Command[p+1]==ESC_MOD)||Command[p]=='+'||Command[p]=='-'|| … … 41 42 return 0; 42 43 } 43 BOOL IsNumCalcMark_Back(c har *Command,int p){44 BOOL IsNumCalcMark_Back(const char *Command,int p){ 44 45 if(p==0){ 45 46 if(Command[p]=='^'||Command[p]=='*'||Command[p]=='/'||Command[p]=='\\'|| … … 56 57 return 0; 57 58 } 58 BOOL IsStrCalcMark(c har c){59 BOOL IsStrCalcMark(const char c){ 59 60 if(c=='+'||c=='&') return 1; 60 61 return 0; 61 62 } 62 BOOL IsExponent(c har *Command,int p){63 BOOL IsExponent(const char *Command,int p){ 63 64 int i,sw; 64 65 for(i=p-2,sw=FALSE;i>=0;i--){ … … 388 389 } 389 390 390 int StaticCalculation(bool enableerror, c har *Command,int BaseType,_int64 *pi64data,LONG_PTR *plpIndex,BOOL bDebuggingWatchList){391 int StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,LONG_PTR *plpIndex,BOOL bDebuggingWatchList){ 391 392 extern HANDLE hHeap; 392 393 extern int cp; … … 1346 1347 } 1347 1348 1348 BYTE GetCalcId(c har *Command,int *pi){1349 BYTE GetCalcId(const char *Command,int *pi){ 1349 1350 *pi=0; 1350 1351 … … 1400 1401 return 0; 1401 1402 } 1402 BOOL GetNumOpeElements(c har *Command,int *pnum,1403 BOOL GetNumOpeElements(const char *Command,int *pnum, 1403 1404 char *values[255],long calc[255],long stack[255]){ 1404 1405 extern int cp; -
BasicCompiler_Common/common.h
r14 r15 29 29 #include "../BasicCompiler_Common/psapi.h" 30 30 #include "../BasicCompiler_Common/BreakPoint.h" 31 #include "../BasicCompiler_Common/LexicalAnalysis.h"32 31 33 32 … … 154 153 }; 155 154 156 //#define情報157 class CDefine{158 int num;159 char **ppNames;160 public:161 CDefine();162 ~CDefine();163 164 BOOL add(char *name);165 BOOL undef(char *name);166 BOOL check(char *name);167 };168 155 169 156 //変数 … … 405 392 406 393 407 int StaticCalculation(bool enableerror, c har *Command,int BaseType,_int64 *pi64data,LONG_PTR *plpIndex,BOOL bDebuggingWatchList=0);394 int StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,LONG_PTR *plpIndex,BOOL bDebuggingWatchList=0); 408 395 409 396 … … 466 453 void DeleteConstInfo(CONSTINFO **ppConstHash); 467 454 void DeleteDeclareInfo(void); 455 void AddSourceCode(char *buffer); 468 456 void OutputExe(void); 469 457 int MainThread(DWORD dummy); … … 487 475 488 476 //preprocessor.cpp 489 void DirectiveIfdef(char *buffer); 490 char *IncludeFiles(char *base); 477 char *OpenBasicFile(char *FileName); 491 478 492 479 //Resource.cpp … … 517 504 int JumpOneParameter(char *Parameter,int i); 518 505 int GetStringInQuotation(char *buffer,char *ReadBuffer); 519 int GetStringInPare(char *buffer,c har *ReadBuffer);506 int GetStringInPare(char *buffer,const char *ReadBuffer); 520 507 int GetStringInPare_RemovePare(char *buffer,char *ReadBuffer); 521 int GetStringInBracket(char *buffer,c har *ReadBuffer);508 int GetStringInBracket(char *buffer,const char *ReadBuffer); 522 509 int JumpStringInPare(char *buffer,int pos); 523 510 int JumpStringInBracket(char *buffer,int pos); … … 531 518 532 519 //calculation.cpp 533 bool IsNumberTopChar(c har *buffer);534 bool IsNumberChar(c har c);535 BOOL IsNumCalcMark(c har *Command,int p);536 BOOL IsNumCalcMark_Back(c har *Command,int p);537 BOOL IsStrCalcMark(c har c);538 BOOL IsExponent(c har *Command,int p);520 bool IsNumberTopChar(const char *buffer); 521 bool IsNumberChar(const char c); 522 BOOL IsNumCalcMark(const char *Command,int p); 523 BOOL IsNumCalcMark_Back(const char *Command,int p); 524 BOOL IsStrCalcMark(const char c); 525 BOOL IsExponent(const char *Command,int p); 539 526 int GetLiteralIndex(_int64 i64data); 540 527 int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2); … … 545 532 BOOL IsStringSubsituation(CClass *pobj_c); 546 533 int IsStrCalculation(char *Command); 547 BYTE GetCalcId(c har *Command,int *pi);548 BOOL GetNumOpeElements(c har *Command,int *pnum,534 BYTE GetCalcId(const char *Command,int *pi); 535 BOOL GetNumOpeElements(const char *Command,int *pnum, 549 536 char *values[255],long calc[255],long stack[255]); 550 537 -
BasicCompiler_Common/preprocessor.cpp
r14 r15 8 8 9 9 10 class CDefine{ 11 int num; 12 char **ppNames; 13 public: 14 CDefine(); 15 ~CDefine(); 16 17 BOOL add(char *name); 18 BOOL undef(char *name); 19 BOOL check(char *name); 20 }; 10 21 CDefine::CDefine(){ 11 22 extern HANDLE hHeap; … … 300 311 301 312 char *IncludeFiles(char *base){ 313 extern HANDLE hHeap; 302 314 extern char szIncludeDir[MAX_PATH]; 303 315 extern char BasicCurDir[MAX_PATH]; … … 423 435 424 436 i3=lstrlen(buffer)+FileSize; 425 base=(char *) realloc(base,i3*2);437 base=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,base,i3*2); 426 438 buffer=base+2; 427 439 SlideString(buffer+i2,FileSize+(i-i2)); … … 451 463 return base; 452 464 } 465 char *OpenBasicFile(char *FileName){ 466 extern HANDLE hHeap; 467 char *base,*buffer; 468 DWORD dwFileSize,dwAccBytes; 469 HANDLE hFile; 470 471 //ファイルオープン 472 hFile=CreateFile(FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); 473 if(hFile==INVALID_HANDLE_VALUE) return 0; 474 475 //#define情報を初期化 476 pobj_define=new CDefine; 477 478 //バッファ領域確保 479 dwFileSize=GetFileSize(hFile,0); 480 base=(char *)HeapAlloc(hHeap,0,dwFileSize*2+255); 481 base[0]='\n'; 482 base[1]='\n'; 483 buffer=base+2; 484 lstrcpy(buffer,"#include <basic.sbp>\n"); 485 buffer+=lstrlen(buffer); 486 487 //読み込み 488 ReadFile(hFile,buffer,dwFileSize,&dwAccBytes,0); 489 buffer[dwAccBytes]=0; 490 491 //CRLFをLFに変換 492 ChangeReturnCode(buffer); 493 494 //コメント削除 495 DeleteComment(buffer); 496 497 //#ifdefディレクティブ 498 DirectiveIfdef(buffer); 499 500 //最終行には文字を含ませないようにする 501 lstrcat(buffer,"\n"); 502 503 //ファイルクローズ 504 CloseHandle(hFile); 505 506 //インクルードファイルを読み込む 507 base=IncludeFiles(base); 508 509 //#define情報を破棄 510 delete pobj_define; 511 pobj_define=0; 512 513 return base; 514 }
Note:
See TracChangeset
for help on using the changeset viewer.