source: dev/BasicCompiler_Common/BasicCompiler.cpp@ 78

Last change on this file since 78 was 78, checked in by dai_9181, 17 years ago

CTypeDef → TypeDef
Houseクラスを追加。
オーバーロードレベルの種類を追加(レベル1に挿入)

File size: 19.8 KB
Line 
1#include "BasicCompiler.h"
2
3#if defined HeapAlloc
4#define MEM_MAX 65536
5LPVOID pCheckMem[MEM_MAX];
6int now;
7#undef HeapAlloc
8#undef HeapReAlloc
9LPVOID CheckHeapAlloc(HANDLE hf,DWORD dwFlags,DWORD dwBytes){
10 LPVOID ret;
11 ret=HeapAlloc(hf,dwFlags,dwBytes);
12 pCheckMem[now]=ret;
13
14 //この部分にnowのチェックを挿入
15
16 now++;
17 if(now>=MEM_MAX){
18 MessageBox(0,"pCheckMemの最大値を超えました","Check - BasicCompiler.exe",0);
19 }
20 return ret;
21}
22LPVOID CheckHeapReAlloc(HANDLE hf,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes){
23 int i;
24 LPVOID ret;
25 for(i=0;;i++){
26 if(lpMem==pCheckMem[i]) break;
27 if(i>=MEM_MAX){
28 MessageBox(0,"エラー","Check - BasicCompiler.exe",0);
29 break;
30 }
31 }
32 ret=HeapReAlloc(hf,dwFlags,lpMem,dwBytes);
33 pCheckMem[i]=ret;
34 return ret;
35}
36void HeapDefaultFree(LPVOID lpMem){
37 int i;
38 for(i=0;;i++){
39 if(lpMem==pCheckMem[i]) break;
40 if(i>=MEM_MAX||lpMem==0){
41 MessageBox(0,"エラー","Check - BasicCompiler.exe",0);
42 break;
43 }
44 }
45 pCheckMem[i]=0;
46 HeapFree(hHeap,0,lpMem);
47}
48void CheckHeapCheck(){
49 int i,i2;
50 char temp[100];
51 temp[0]=0;
52 for(i=0,i2=0;i<MEM_MAX;i++){
53 if(pCheckMem[i]){
54 sprintf(temp+lstrlen(temp),"%d\r\n",i);
55 i2++;
56 if(i2==10){
57 lstrcat(temp,"これ以上の未解放が確認されています");
58 break;
59 }
60 }
61 }
62 if(temp[0]) MessageBox(0,temp,"Check - BasicCompiler.exe",0);
63}
64#define HeapAlloc CheckHeapAlloc
65#define HeapReAlloc CheckHeapReAlloc
66#else
67void HeapDefaultFree(LPVOID lpMem){
68 HeapFree(hHeap,0,lpMem);
69}
70#endif
71
72void ts(int i){
73 char temporary[255];
74 sprintf(temporary,"0x%08x",i);
75 MessageBox(0,temporary,"TestMessage",0);
76}
77void ts(int i,int i2){
78 char temporary[255];
79 sprintf(temporary,"0x%08x\r\n0x%08x",i,i2);
80 MessageBox(0,temporary,"TestMessage",0);
81}
82void ts(char *msg){
83 MessageBox(0,msg,"TestMessage",0);
84}
85void ts(char *msg,char *title){
86 MessageBox(0,msg,title,0);
87}
88
89void epi_check(){
90 //この部分にobpのチェックを挿入
91 //※例 … epi=0x41999 → obp>=0x0999
92
93 extern int obp;
94 if(obp==1115){
95 }
96}
97
98void GetRelationalPath(char *path,char *dir){
99 //相対パスを取得
100 int i,i2,i3,i4,i5;
101 char temporary[MAX_PATH],temp2[MAX_PATH],temp3[MAX_PATH],temp4[MAX_PATH];
102
103 //ドライブ名をチェック
104 _splitpath(path,temporary,0,0,0);
105 _splitpath(dir,temp2,0,0,0);
106 if(lstrcmpi(temporary,temp2)!=0) return;
107
108 _splitpath(path,0,temporary,0,0);
109 _splitpath(dir,0,temp2,0,0);
110 i=1;i2=1;
111 while(1){
112 i4=i;
113 if(temporary[i-1]=='\\'&&temporary[i]){ //path側
114 for(i3=0;;i++,i3++){
115 if(temporary[i]=='\\'){
116 temp3[i3]=0;
117 i++;
118 break;
119 }
120 temp3[i3]=temporary[i];
121 }
122 }
123 else temp3[0]=0;
124
125 i5=i2;
126 if(temp2[i2-1]=='\\'&&temp2[i2]){ //dir側
127 for(i3=0;;i2++,i3++){
128 if(temp2[i2]=='\\'){
129 temp4[i3]=0;
130 i2++;
131 break;
132 }
133 temp4[i3]=temp2[i2];
134 }
135 }
136 else temp4[0]=0;
137
138 if(temp3[0]=='\0'&&temp4[0]=='\0'){
139 lstrcpy(temp3,".\\");
140 break;
141 }
142
143 if(lstrcmpi(temp3,temp4)!=0){
144 for(i3=0;;i5++){
145 if(temp2[i5]=='\0') break;
146 if(temp2[i5]=='\\') i3++;
147 }
148 if(i3==0) lstrcpy(temp3,".\\");
149 else{
150 temp3[0]=0;
151 for(i2=0;i2<i3;i2++) lstrcat(temp3,"..\\");
152 }
153 lstrcat(temp3,temporary+i4);
154 break;
155 }
156 }
157 _splitpath(path,0,0,temporary,temp2);
158 lstrcat(temp3,temporary);
159 lstrcat(temp3,temp2);
160 lstrcpy(path,temp3);
161}
162void GetFullPath(char *path,char *dir){
163 int i,i2,i3,i4;
164 char temporary[MAX_PATH];
165
166 if(strstr(path,":")||strstr(path,"\\\\")) return;
167
168 i=0;i2=0;
169 while(1){
170 if(path[i]=='.'&&path[i+1]=='\\') i+=2;
171 if(path[i]=='.'&&path[i+1]=='.'&&path[i+2]=='\\'){
172 i2++;
173 i+=3;
174 }
175 else break;
176 }
177
178 i3=lstrlen(dir);i4=0;
179 while(i4<i2){
180 for(i3--;;i3--){
181 if(dir[i3-1]=='\\'){
182 i4++;
183 break;
184 }
185 }
186 }
187 memcpy(temporary,dir,i3);
188 temporary[i3]=0;
189 lstrcat(temporary,path+i);
190 lstrcpy(path,temporary);
191}
192
193void ShowErrorLine(int LineNum,char *FileName){
194 HANDLE hFile;
195 DWORD dw;
196 char temporary[MAX_PATH];
197
198 if(LineNum==-1) return;
199
200 if(IsWindow(hOwnerEditor)){
201 if(FileName){
202
203 while(!IsFile(FileName)){
204 char temp2[MAX_PATH],temp3[MAX_PATH];
205 _splitpath(FileName,NULL,NULL,temp2,temp3);
206 lstrcat(temp2,temp3);
207
208 sprintf(temporary,"\"%s\" が見つかりません。格納されているディレクトリを指定してください。",temp2);
209 if(!GetFolder(hOwnerEditor,temp3,temporary)) return;
210
211 if(temp3[lstrlen(temp3)-1]!='\\') lstrcat(temp3,"\\");
212
213 sprintf(FileName,"%s%s",temp3,temp2);
214 }
215
216 sprintf(temporary,"%spgm.tmp",BasicSystemDir);
217 hFile=CreateFile(temporary,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_TEMPORARY,NULL);
218 WriteFile(hFile,FileName,lstrlen(FileName),&dw,NULL);
219 CloseHandle(hFile);
220
221 SendMessage(hOwnerEditor,WM_SHOWERROR,LineNum,0);
222 }
223 }
224}
225
226BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen){
227 OPENFILENAME ofstr;
228 filename[0]=0;
229 ofstr.lStructSize=sizeof(OPENFILENAME);
230 ofstr.hwndOwner=hwnd;
231 ofstr.hInstance=0;
232 ofstr.lpstrFilter=Filter;
233 ofstr.lpstrCustomFilter=NULL;
234 ofstr.nMaxCustFilter=0;
235 ofstr.nFilterIndex=1;
236 ofstr.lpstrFile=filename;
237 ofstr.nMaxFile=MAX_PATH;
238 ofstr.lpstrFileTitle=NULL;
239 ofstr.nMaxFileTitle=0;
240 ofstr.lpstrInitialDir=0;
241 ofstr.lpstrTitle=Title;
242 ofstr.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;
243 ofstr.nFileOffset=0;
244 ofstr.nFileExtension=0;
245 ofstr.lpstrDefExt="*";
246 ofstr.lCustData=NULL;
247 ofstr.lpfnHook=NULL;
248 ofstr.lpTemplateName=NULL;
249 if(bOpen){
250 if(!GetOpenFileName(&ofstr)) return FALSE;
251 }
252 else{
253 if(!GetSaveFileName(&ofstr)) return FALSE;
254 }
255 return TRUE;
256}
257
258LRESULT CALLBACK ErrorListProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
259 int i,pos;
260 int StartPos,EndPos;
261
262 switch(message){
263 case WM_CHAR:
264 if(GetKeyState(VK_CONTROL)&0x8000){
265 //アクセラレータキーの場合を考慮
266 break;
267 }
268 return 0;
269 case WM_LBUTTONDBLCLK:
270 SendMessage(hwnd,EM_GETSEL,(WPARAM)&pos,0);
271 i=(int)SendMessage(hwnd,EM_LINEFROMCHAR,pos,0);
272 ShowErrorLine(pErrorInfo[i].line,pErrorInfo[i].FileName);
273
274 StartPos=(int)SendMessage(hwnd,EM_LINEINDEX,i,0);
275 EndPos=StartPos+(int)SendMessage(hwnd,EM_LINELENGTH,pos,0);
276 SendMessage(hwnd,EM_SETSEL,StartPos,EndPos);
277 return 0;
278 }
279 return CallWindowProc(OldErrorListProc,hwnd,message,wParam,lParam);
280}
281LRESULT CALLBACK DebugListProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
282 switch(message){
283 case WM_CHAR:
284 if(GetKeyState(VK_CONTROL)&0x8000){
285 //アクセラレータキーの場合を考慮
286 break;
287 }
288 return 0;
289 }
290 return CallWindowProc(OldDebugListProc,hwnd,message,wParam,lParam);
291}
292void MakeMessageText(char *buffer,char *msg,int flag){
293 extern BOOL bDll;
294 char temporary[MAX_PATH];
295 if(bClipCompileView){
296 //ProjectView埋め込みがたインターフェイスのとき
297
298 //生成するファイルの相対パスを取得
299 lstrcpy(temporary,OutputFileName);
300 GetRelationalPath(temporary,BasicCurDir);
301
302 //////////
303 // 合成
304
305#if defined(JPN)
306 //日本語
307 if(flag==0){
308 if(bDll) sprintf(buffer,"DLLファイル \"%s\" [ %s ]",temporary,msg);
309 else sprintf(buffer,"実行ファイル \"%s\" [ %s ]",temporary,msg);
310 }
311 if(flag==1) sprintf(buffer,"\"%s\" を生成しています [ %s ]",temporary,msg);
312 if(flag==2) lstrcpy(buffer,msg);
313#else
314 //英語
315 if(flag==0){
316 if(bDll) sprintf(buffer,"DLL file \"%s\" [ %s ]",temporary,msg);
317 else sprintf(buffer,"Execution file \"%s\" [ %s ]",temporary,msg);
318 }
319 if(flag==1) sprintf(buffer,"Creating \"%s\" [ %s ]",temporary,msg);
320 if(flag==2) lstrcpy(buffer,msg);
321#endif
322 }
323 else{
324 //通常ダイアログのとき
325 lstrcpy(buffer,msg);
326 }
327}
328
329void SetPosCenter(HWND hwnd){
330 RECT OwnerRect,rect;
331 int x,y;
332
333 if(IsWindow(hOwnerEditor)) GetWindowRect(hOwnerEditor,&OwnerRect);
334 else{
335 OwnerRect.left=0;
336 OwnerRect.top=0;
337 OwnerRect.right=ScreenX;
338 OwnerRect.bottom=ScreenY;
339 }
340 GetWindowRect(hwnd,&rect);
341
342 x=((OwnerRect.right-OwnerRect.left)-(rect.right-rect.left))/2+OwnerRect.left;
343 y=((OwnerRect.bottom-OwnerRect.top)-(rect.bottom-rect.top))/2+OwnerRect.top;
344 SetWindowPos(hwnd,0,x,y,0,0,SWP_NOSIZE);
345}
346BOOL CALLBACK DlgCompile(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
347 extern HANDLE hDebugProcess;
348 char temporary[MAX_PATH];
349 DWORD dw;
350 RECT rect;
351 POINT pos;
352 SIZE size;
353 static POINT pos_List,pos_Progress;
354 static int height_Progress;
355
356 switch(message){
357 case WM_INITDIALOG:
358 pos=pobj_nv->MainDlgPos;
359 GetWindowRect(hwnd,&rect);
360 size.cx=rect.right-rect.left;
361 size.cy=rect.bottom-rect.top;
362 MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
363
364 lstrcpy(temporary,OutputFileName);
365 GetRelationalPath(temporary,BasicCurDir);
366 SetDlgItemText(hwnd,IDC_EXEPATH,temporary);
367
368 //"エラー無し"
369 SetDlgItemText(hwnd,IDC_ERRORLIST,STRING_NOERROR);
370
371 //"デバッグ情報無し"
372 SetDlgItemText(hwnd,IDC_DEBUGLIST,STRING_NODEBUGMSG);
373
374 //リストボックスの初期位置
375 GetWindowRect(GetDlgItem(hwnd,IDC_ERRORLIST),&rect);
376 pos_List.x=rect.left;
377 pos_List.y=rect.top;
378 ScreenToClient(hwnd,&pos_List);
379
380 //プログレスバーの初期位置と高さ
381 GetWindowRect(GetDlgItem(hwnd,IDC_PROGRESS),&rect);
382 pos_Progress.x=rect.left;
383 pos_Progress.y=rect.top;
384 ScreenToClient(hwnd,&pos_Progress);
385 height_Progress=rect.bottom-rect.top;
386
387 //バージョン表記
388 sprintf(temporary,"Version %d.%02d.%02d %s",MAJOR_VER,MINOR_VER,REVISION_VER,VER_INFO);
389 SetDlgItemText(hwnd,IDC_STATIC_VERSION,temporary);
390
391 break;
392 case WM_COMMAND:
393 switch(LOWORD(wParam)){
394 case IDOK:
395 GetDlgItemText(hwnd,IDOK,temporary,MAX_PATH);
396
397 //STRING_COMPILE = "コンパイル"
398 if(lstrcmp(temporary,STRING_COMPILE)==0){
399 GetDlgItemText(hwnd,IDC_EXEPATH,OutputFileName,MAX_PATH);
400 GetFullPath(OutputFileName,BasicCurDir);
401 CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)MainThread,0,0,&dw);
402 }
403
404 //STRING_STOP = "中断"
405 else if(lstrcmp(temporary,STRING_STOP)==0){
406 if(hDebugProcess){
407 //デバッグ中のとき
408
409 //プロセスを終了
410 TerminateProcess(hDebugProcess,0);
411 hDebugProcess=0;
412
413 //デバッグダイアログを終了
414 if(hDebugWnd){
415 DestroyWindow(hDebugWnd);
416 }
417 }
418 else{
419 //コンパイル中のとき
420 bStopCompile=1;
421
422 /* メインスレッドで「閉じる」ボタンに変更することで、
423 コンパイルを中断中の早いタイミングでも終了することが可能 */
424 //"閉じる"
425 SetDlgItemText(hwnd,IDOK,STRING_CLOSE);
426 }
427 }
428
429 else{
430 SetFocus(hOwnerEditor);
431 DestroyWindow(hwnd);
432 }
433 return 1;
434 case IDCANCEL:
435 //×ボタン用
436
437 if(hDebugProcess){
438 //デバッグ中のとき
439
440 //プロセスを終了
441 TerminateProcess(hDebugProcess,0);
442 hDebugProcess=0;
443
444 //デバッグダイアログを終了
445 if(hDebugWnd){
446 DestroyWindow(hDebugWnd);
447 }
448 }
449
450 SetFocus(hOwnerEditor);
451 DestroyWindow(hwnd);
452 return 1;
453 case IDC_SHOWERROR:
454 ShowWindow(GetDlgItem(hwnd,IDC_ERRORLIST),SW_SHOW);
455 ShowWindow(GetDlgItem(hwnd,IDC_DEBUGLIST),SW_HIDE);
456 return 1;
457 case IDC_SHOWDEBUG:
458 ShowWindow(GetDlgItem(hwnd,IDC_ERRORLIST),SW_HIDE);
459 ShowWindow(GetDlgItem(hwnd,IDC_DEBUGLIST),SW_SHOW);
460 return 1;
461 }
462 break;
463 case WM_SHOWVARLIST:
464 if(bClipCompileView){
465 //埋め込み表示
466 CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_DEBUGGER),hOwnerEditor,(DLGPROC)DlgDebugger,lParam);
467 ShowWindow(hDebugWnd,SW_SHOW);
468
469 SendMessage(hOwnerEditor,WM_SETDEBUGGERVIEW,0,(LPARAM)hDebugWnd);
470 }
471 else{
472 //ポップアップ表示
473 CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_VARLIST),hOwnerEditor,(DLGPROC)DlgVarList,lParam);
474 SetForegroundWindow(hDebugWnd);
475 }
476 return 1;
477 case WM_SIZE:
478 if(bClipCompileView){
479 //エラーリストの位置
480 MoveWindow(GetDlgItem(hwnd,IDC_ERRORLIST),
481 pos_List.x,
482 pos_List.y,
483 LOWORD(lParam)-pos_List.x,
484 HIWORD(lParam)-pos_List.y,
485 1);
486
487 //デバッグリストの位置
488 MoveWindow(GetDlgItem(hwnd,IDC_DEBUGLIST),
489 pos_List.x,
490 pos_List.y,
491 LOWORD(lParam)-pos_List.x,
492 HIWORD(lParam)-pos_List.y,
493 1);
494
495 //プログレスバーの位置
496 MoveWindow(GetDlgItem(hwnd,IDC_PROGRESS),
497 pos_Progress.x,
498 pos_Progress.y,
499 LOWORD(lParam)-pos_Progress.x,
500 height_Progress,
501 1);
502 }
503 return 1;
504 case WM_DESTROY:
505 GetWindowRect(hwnd,&rect);
506
507 if(!bClipCompileView){
508 pobj_nv->MainDlgPos.x=rect.left;
509 pobj_nv->MainDlgPos.y=rect.top;
510 }
511
512 PostQuitMessage(0);
513 return 1;
514
515
516
517 ///////////////////////
518 // デバッグコマンド
519 ///////////////////////
520
521 case WM_DEBUG_STOP:
522 Debugger_Stop();
523 return 1;
524 case WM_DEBUG_PAUSE:
525 Debugger_Pause();
526 return 1;
527
528
529 case WM_CLOSE_DEBUGGER:
530 if(hDebugWnd){
531 DestroyWindow(hDebugWnd);
532 }
533 return 1;
534 }
535 return 0;
536}
537
538int PASCAL WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nShowCmd){
539 int i,i2;
540 char temporary[1024],temp2[MAX_PATH];
541
542 //MessageBox(0,"starting compiler/debugger","ActiveBasic",MB_OK);
543
544 //コモンコントロールを初期化
545 InitCommonControls();
546
547 hHeap=GetProcessHeap();
548 ScreenX=GetSystemMetrics(SM_CXSCREEN);
549 ScreenY=GetSystemMetrics(SM_CYSCREEN);
550
551 hInst=hThisInst;
552
553 GetModuleFileName(hInst,temporary,MAX_PATH);
554 _splitpath(temporary,BasicSystemDir,temp2,NULL,NULL);
555 lstrcat(BasicSystemDir,temp2);
556
557 //不揮発性データを取得
558 pobj_nv=new CNonVolatile;
559 pobj_nv->load();
560
561 //ソースファイル名を取得
562 i=0;
563 if(lpCmdLine[0]!='/'){
564 if(lpCmdLine[0]=='\"'){
565 for(i=1,i2=0;;i++,i2++){
566 if(lpCmdLine[i]=='\"'){
567 SourceFileName[i2]=0;
568 break;
569 }
570 SourceFileName[i2]=lpCmdLine[i];
571 if(lpCmdLine[i]=='\0') break;
572 }
573 i++;
574 while(lpCmdLine[i]==' ') i++;
575 }
576 else{
577 for(i=0;;i++){
578 if(lpCmdLine[i]==' '){
579 SourceFileName[i]=0;
580 break;
581 }
582 SourceFileName[i]=lpCmdLine[i];
583 if(lpCmdLine[i]=='\0') break;
584 }
585 while(lpCmdLine[i]==' ') i++;
586 }
587 }
588
589 BOOL bFromEditor=0;
590 bDll=0;
591 OutputFileName[0]=0;
592 if(lpCmdLine[i]&&lpCmdLine[i]!='/'){
593 if(lpCmdLine[i]=='\"'){
594 for(i++,i2=0;;i++,i2++){
595 if(lpCmdLine[i]=='\"'){
596 OutputFileName[i2]=0;
597 break;
598 }
599 OutputFileName[i2]=lpCmdLine[i];
600 if(lpCmdLine[i]=='\0') break;
601 }
602 i++;
603 while(lpCmdLine[i]==' ') i++;
604 }
605 else{
606 for(i2=0;;i++,i2++){
607 if(lpCmdLine[i]==' '){
608 OutputFileName[i2]=0;
609 break;
610 }
611 OutputFileName[i2]=lpCmdLine[i];
612 if(lpCmdLine[i]=='\0') break;
613 }
614 while(lpCmdLine[i]==' ') i++;
615 }
616 }
617
618 KillSpaces(lpCmdLine+i,temporary);
619 i=0;
620 while(temporary[i]=='/'){
621 for(i++,i2=0;;i++,i2++){
622 if(temporary[i]=='/'){
623 temp2[i2]=0;
624 break;
625 }
626 if(temporary[i]==':'){
627 temp2[i2]=0;
628 break;
629 }
630 temp2[i2]=temporary[i];
631 if(temporary[i]=='\0') break;
632 }
633
634 char temp3[MAX_PATH];
635 if(temporary[i]==':'){
636 i++;
637 if(temporary[i]=='\"'){
638 for(i++,i2=0;;i++,i2++){
639 if(temporary[i]=='\"'){
640 temp3[i2]=0;
641 RemoveStringQuotes(temp3);
642 i++;
643 break;
644 }
645 temp3[i2]=temporary[i];
646 if(temporary[i]=='\0') break;
647 }
648 }
649 else{
650 for(i2=0;;i++,i2++){
651 if(temporary[i]=='/'){
652 temp3[i2]=0;
653 break;
654 }
655 if(temporary[i]==':'){
656 temp3[i2]=0;
657 break;
658 }
659 temp3[i2]=temporary[i];
660 if(temporary[i]=='\0') break;
661 }
662 }
663 }
664 else temp3[0]=0;
665
666
667 /////////////////////////
668 // コマンドラインを調査
669 /////////////////////////
670
671 //ウィンドウハンドル
672 if(lstrcmp(temp2,"wnd")==0){
673 bFromEditor=1;
674
675 if(temp3[0]) sscanf(temp3,"%08x",&hOwnerEditor);
676 }
677
678 //デバッグコンパイル
679 else if(lstrcmp(temp2,"debug")==0) bDebugCompile=1;
680
681 //デバッグ実行
682 else if(lstrcmp(temp2,"run")==0) bDebugRun=1;
683
684 //デバッグ実行(アタッチする)
685 else if(lstrcmp(temp2,"attach")==0){
686 bDebugRun=1;
687 bAttach=1;
688
689 if(temp3[0]) sscanf(temp3,"%08x",&dwAttachProcessId);
690 }
691
692 //DLL生成
693 else if(lstrcmp(temp2,"dll")==0) bDll=1;
694
695 //Unicode
696 else if( lstrcmp( temp2, "unicode" ) ==0 ){
697 isUnicode = true;
698 typeOfPtrChar = MAKE_PTR_TYPE(DEF_WORD,1);
699 }
700
701 //埋め込み型コンパイラビュー
702 else if(lstrcmp(temp2,"clip_compile_view")==0) bClipCompileView=1;
703
704 //インクルードディレクトリ
705 else if(lstrcmp(temp2,"include_dir")==0){
706 lstrcpy(szIncludeDir,temp3);
707 }
708 }
709
710 //ソースファイル名が与えられなかったとき
711 if(SourceFileName[0]=='\0'){
712 if(!GetFilePathDialog(0,SourceFileName,BasicFileFilter,"コンパイルするファイルを指定して下さい",1))
713 return 0;
714 }
715
716 //出力ファイル名が与えられなかったとき
717 if(OutputFileName[0]=='\0'){
718 _splitpath(SourceFileName,OutputFileName,temporary,temp2,0);
719 lstrcat(OutputFileName,temporary);
720 lstrcat(OutputFileName,temp2);
721 if(bDebugCompile||bDebugRun) lstrcat(OutputFileName,"_debug.exe");
722 else lstrcat(OutputFileName,".exe");
723 }
724
725 //インクルードディレクトリが指定されなかったとき
726 if(szIncludeDir[0]=='\0'){
727 lstrcpy(szIncludeDir,".\\Include\\");
728 }
729
730 //インクルードディレクトリを絶対パスに変更
731 GetFullPath(szIncludeDir,BasicSystemDir);
732
733 if(bDll){
734 //DLLファイル名を取得
735 _splitpath(OutputFileName,NULL,NULL,szDllName,temporary);
736 lstrcat(szDllName,temporary);
737 }
738
739 if(bDebugRun){
740 //コマンドライン、DLLの実行可能アプリケーションを取得
741 HANDLE hFile;
742 DWORD dwAccessBytes;
743 sprintf(temporary,"%spgm.tmp",BasicSystemDir);
744 hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
745 if(hFile!=INVALID_HANDLE_VALUE){
746 ReadFile(hFile,temporary,MAX_PATH,&dwAccessBytes,NULL);
747 CloseHandle(hFile);
748 temporary[dwAccessBytes]=0;
749 }
750 else temporary[0]=0;
751
752 for(i=0;;i++){
753 if(temporary[i]=='\r'&&temporary[i+1]=='\n'||temporary[i]=='\0'){
754 szDebugExeForDll[i]=0;
755 break;
756 }
757 szDebugExeForDll[i]=temporary[i];
758 }
759 if(temporary[i]){
760 lstrcpy(szDebugCmdLine,temporary+i+2);
761 }
762 }
763
764 _splitpath(SourceFileName,BasicCurDir,temporary,NULL,NULL);
765 lstrcat(BasicCurDir,temporary);
766
767 //エラーリスト情報を初期化
768 pErrorInfo=(ERRORINFO *)HeapAlloc(hHeap,0,1);
769 ErrorNum=0;
770 CompileMsgNum=0;
771 WarningNum=0;
772 bError=0;
773
774 if(bClipCompileView){
775 //ProjectEditor埋め込み型インターフェイス
776 hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_CLIPMAIN),hOwnerEditor,(DLGPROC)DlgCompile);
777 ShowWindow(hMainDlg,SW_SHOW);
778 SendMessage(hOwnerEditor,WM_SETCOMPILEVIEW,0,(LPARAM)hMainDlg);
779
780 //プログレスバーの色をセットする
781 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETBARCOLOR,0,RGB(255,220,192));
782 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETBKCOLOR,0,RGB(255,255,255));
783 }
784 else{
785 //通常ダイアログインターフェイス
786 hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_MAIN),hOwnerEditor,(DLGPROC)DlgCompile);
787 ShowWindow(hMainDlg,SW_SHOW);
788 }
789 SendDlgItemMessage(hMainDlg,IDC_SHOWERROR,BM_SETCHECK,BST_CHECKED,0);
790
791 //エラーリストをサブクラス化
792 OldErrorListProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hMainDlg,IDC_ERRORLIST),GWLP_WNDPROC);
793 SetWindowLongPtr(GetDlgItem(hMainDlg,IDC_ERRORLIST),GWLP_WNDPROC,(LONG_PTR)ErrorListProc);
794
795 //デバッグリストをサブクラス化
796 OldDebugListProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hMainDlg,IDC_DEBUGLIST),GWLP_WNDPROC);
797 SetWindowLongPtr(GetDlgItem(hMainDlg,IDC_DEBUGLIST),GWLP_WNDPROC,(LONG_PTR)DebugListProc);
798
799 if(bFromEditor) SendMessage(hMainDlg,WM_COMMAND,IDOK,0);
800
801 MSG msg;
802 while(GetMessage(&msg,0,0,0)){
803 if(IsDialogMessage(hMainDlg,&msg)) continue;
804 TranslateMessage(&msg);
805 DispatchMessage(&msg);
806 }
807
808 //エラーリスト情報を解放
809 for(i=0;i<ErrorNum;i++){
810 if(pErrorInfo[i].FileName) HeapDefaultFree(pErrorInfo[i].FileName);
811 }
812 HeapDefaultFree(pErrorInfo);
813
814 //不揮発性データを保存
815 pobj_nv->save();
816 delete pobj_nv;
817 pobj_nv=0;
818
819#if defined HeapAlloc
820 CheckHeapCheck();
821#endif
822
823 if(bClipCompileView){
824 SendMessage(hOwnerEditor,WM_DESTROYCOMPILEVIEW,0,0);
825 }
826
827
828 return 0;
829}
Note: See TracBrowser for help on using the repository browser.