Changeset 14 in dev for BasicCompiler_Common
- Timestamp:
- Dec 10, 2006, 10:58:26 AM (18 years ago)
- Location:
- BasicCompiler_Common
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/BasicCompiler.cpp
r5 r14 1 #ifdef _AMD64_ 2 #include "../BasicCompiler64/BasicCompiler.h" 3 #else 4 #include "../BasicCompiler32/BasicCompiler.h" 5 #endif 1 #include "BasicCompiler.h" 2 6 3 7 4 #if defined HeapAlloc -
BasicCompiler_Common/BasicCompiler.h
r12 r14 1 #include " ../BasicCompiler_Common/common.h"1 #include "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"; -
BasicCompiler_Common/DebugMiddleFile.cpp
r5 r14 474 474 //ソースコード 475 475 i2++; 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; 476 CSource::obj.SetSourceCode(buffer + i2); 477 this->basbuf=CSource::obj.SourceCode; 480 478 extern char *basbuf; 481 479 basbuf=this->basbuf; 480 i2+=lstrlen(buffer+i2)+1; 482 481 483 482 //コードと行番号の関係 … … 934 933 935 934 //ソースコード 936 extern char *pBaseBuffer;937 935 extern char *basbuf; 938 pBaseBuffer=this->pBaseBuffer;939 936 basbuf=this->basbuf; 940 937 … … 1016 1013 DeleteConstInfo(ppConstHash); 1017 1014 1018 //ソースコードを解放1019 HeapDefaultFree(pBaseBuffer);1020 1021 1015 //コードと行番号の関係を解放 1022 1016 HeapDefaultFree(pLineInfo); -
BasicCompiler_Common/DebugSection.h
r4 r14 25 25 26 26 //ソースコード 27 char *pBaseBuffer;28 27 char *basbuf; 29 28 -
BasicCompiler_Common/MakeExe.cpp
r4 r14 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 63 36 void OutputExe(void){ 64 37 extern HANDLE hHeap; 65 38 extern char *basbuf; 66 extern char *pBaseBuffer;67 39 extern int ErrorNum; 68 40 extern BOOL bStopCompile; … … 87 59 //プログラムをファイルから読み込む 88 60 extern char SourceFileName[MAX_PATH]; 89 pBaseBuffer=OpenBasicFile(SourceFileName); 90 if(!pBaseBuffer){ 91 SetError(201,SourceFileName,-1); 92 goto EndCompile; 93 } 94 basbuf=pBaseBuffer+2; 61 CSource::obj.OpenFile(SourceFileName); 62 63 //未完成 64 basbuf = CSource::obj.SourceCode; 95 65 96 66 //イメージベースの設定 … … 172 142 173 143 StepCompileProgress(); 144 145 146 //字句解析 147 CSource::obj.LexicalAnalysis(0); 174 148 175 149 … … 291 265 HeapDefaultFree(IncludeFileInfo.ppFileNames[i2]); 292 266 HeapDefaultFree(IncludeFileInfo.ppFileNames); 293 294 if(pBaseBuffer) HeapDefaultFree(pBaseBuffer);295 267 } 296 268 int MainThread(DWORD dummy){ -
BasicCompiler_Common/calculation.cpp
r11 r14 10 10 _int64 i64stack[255]; 11 11 12 bool IsNumberTopChar(char *buffer){ 13 int c = buffer[0]; 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; 16 17 return false; 18 } 19 bool IsNumberChar(char c){ 20 if('0' <= c && c <= '9') return true; 21 if('a' <= c && c <= 'f') return true; 22 if('A' <= c && c <= 'F') return true; 23 24 return false; 25 } 12 26 BOOL IsJudgMark(char *Command,int p){ 13 27 if(Command[p]==1){ -
BasicCompiler_Common/common.h
r11 r14 1 #define _CRT_SECURE_NO_DEPRECATE 1 //#define _CRT_SECURE_NO_DEPRECATE 2 #pragma warning(disable : 4996) 2 3 3 4 #include <windows.h> … … 28 29 #include "../BasicCompiler_Common/psapi.h" 29 30 #include "../BasicCompiler_Common/BreakPoint.h" 31 #include "../BasicCompiler_Common/LexicalAnalysis.h" 30 32 31 33 … … 150 152 int FilesNum; 151 153 int LineOfFile[MAX_LEN]; 154 }; 155 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); 152 167 }; 153 168 … … 451 466 void DeleteConstInfo(CONSTINFO **ppConstHash); 452 467 void DeleteDeclareInfo(void); 453 void AddSourceCode(char *buffer);454 468 void OutputExe(void); 455 469 int MainThread(DWORD dummy); … … 473 487 474 488 //preprocessor.cpp 475 char *OpenBasicFile(char *FileName); 489 void DirectiveIfdef(char *buffer); 490 char *IncludeFiles(char *base); 476 491 477 492 //Resource.cpp … … 516 531 517 532 //calculation.cpp 533 bool IsNumberTopChar(char *buffer); 534 bool IsNumberChar(char c); 518 535 BOOL IsNumCalcMark(char *Command,int p); 519 536 BOOL IsNumCalcMark_Back(char *Command,int p); -
BasicCompiler_Common/preprocessor.cpp
r5 r14 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 };21 10 CDefine::CDefine(){ 22 11 extern HANDLE hHeap; … … 311 300 312 301 char *IncludeFiles(char *base){ 313 extern HANDLE hHeap;314 302 extern char szIncludeDir[MAX_PATH]; 315 303 extern char BasicCurDir[MAX_PATH]; … … 435 423 436 424 i3=lstrlen(buffer)+FileSize; 437 base=(char *) HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,base,i3*2);425 base=(char *)realloc(base,i3*2); 438 426 buffer=base+2; 439 427 SlideString(buffer+i2,FileSize+(i-i2)); … … 463 451 return base; 464 452 } 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.