source: dev/BasicCompiler_Common/BasicCompiler.cpp@ 37

Last change on this file since 37 was 15, checked in by dai_9181, 18 years ago

LexicalAnalysisを廃止。

File size: 19.6 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 //コモンコントロールを初期化
543 InitCommonControls();
544
545 hHeap=GetProcessHeap();
546 ScreenX=GetSystemMetrics(SM_CXSCREEN);
547 ScreenY=GetSystemMetrics(SM_CYSCREEN);
548
549 hInst=hThisInst;
550
551 GetModuleFileName(hInst,temporary,MAX_PATH);
552 _splitpath(temporary,BasicSystemDir,temp2,NULL,NULL);
553 lstrcat(BasicSystemDir,temp2);
554
555 //不揮発性データを取得
556 pobj_nv=new CNonVolatile;
557 pobj_nv->load();
558
559 //ソースファイル名を取得
560 i=0;
561 if(lpCmdLine[0]!='/'){
562 if(lpCmdLine[0]=='\"'){
563 for(i=1,i2=0;;i++,i2++){
564 if(lpCmdLine[i]=='\"'){
565 SourceFileName[i2]=0;
566 break;
567 }
568 SourceFileName[i2]=lpCmdLine[i];
569 if(lpCmdLine[i]=='\0') break;
570 }
571 i++;
572 while(lpCmdLine[i]==' ') i++;
573 }
574 else{
575 for(i=0;;i++){
576 if(lpCmdLine[i]==' '){
577 SourceFileName[i]=0;
578 break;
579 }
580 SourceFileName[i]=lpCmdLine[i];
581 if(lpCmdLine[i]=='\0') break;
582 }
583 while(lpCmdLine[i]==' ') i++;
584 }
585 }
586
587 BOOL bFromEditor=0;
588 bDll=0;
589 OutputFileName[0]=0;
590 if(lpCmdLine[i]&&lpCmdLine[i]!='/'){
591 if(lpCmdLine[i]=='\"'){
592 for(i++,i2=0;;i++,i2++){
593 if(lpCmdLine[i]=='\"'){
594 OutputFileName[i2]=0;
595 break;
596 }
597 OutputFileName[i2]=lpCmdLine[i];
598 if(lpCmdLine[i]=='\0') break;
599 }
600 i++;
601 while(lpCmdLine[i]==' ') i++;
602 }
603 else{
604 for(i2=0;;i++,i2++){
605 if(lpCmdLine[i]==' '){
606 OutputFileName[i2]=0;
607 break;
608 }
609 OutputFileName[i2]=lpCmdLine[i];
610 if(lpCmdLine[i]=='\0') break;
611 }
612 while(lpCmdLine[i]==' ') i++;
613 }
614 }
615
616 KillSpaces(lpCmdLine+i,temporary);
617 i=0;
618 while(temporary[i]=='/'){
619 for(i++,i2=0;;i++,i2++){
620 if(temporary[i]=='/'){
621 temp2[i2]=0;
622 break;
623 }
624 if(temporary[i]==':'){
625 temp2[i2]=0;
626 break;
627 }
628 temp2[i2]=temporary[i];
629 if(temporary[i]=='\0') break;
630 }
631
632 char temp3[MAX_PATH];
633 if(temporary[i]==':'){
634 i++;
635 if(temporary[i]=='\"'){
636 for(i++,i2=0;;i++,i2++){
637 if(temporary[i]=='\"'){
638 temp3[i2]=0;
639 RemoveStringQuotes(temp3);
640 i++;
641 break;
642 }
643 temp3[i2]=temporary[i];
644 if(temporary[i]=='\0') break;
645 }
646 }
647 else{
648 for(i2=0;;i++,i2++){
649 if(temporary[i]=='/'){
650 temp3[i2]=0;
651 break;
652 }
653 if(temporary[i]==':'){
654 temp3[i2]=0;
655 break;
656 }
657 temp3[i2]=temporary[i];
658 if(temporary[i]=='\0') break;
659 }
660 }
661 }
662 else temp3[0]=0;
663
664
665 /////////////////////////
666 // コマンドラインを調査
667 /////////////////////////
668
669 //ウィンドウハンドル
670 if(lstrcmp(temp2,"wnd")==0){
671 bFromEditor=1;
672
673 if(temp3[0]) sscanf(temp3,"%08x",&hOwnerEditor);
674 }
675
676 //デバッグコンパイル
677 else if(lstrcmp(temp2,"debug")==0) bDebugCompile=1;
678
679 //デバッグ実行
680 else if(lstrcmp(temp2,"run")==0) bDebugRun=1;
681
682 //デバッグ実行(アタッチする)
683 else if(lstrcmp(temp2,"attach")==0){
684 bDebugRun=1;
685 bAttach=1;
686
687 if(temp3[0]) sscanf(temp3,"%08x",&dwAttachProcessId);
688 }
689
690 //DLL生成
691 else if(lstrcmp(temp2,"dll")==0) bDll=1;
692
693 //埋め込み型コンパイラビュー
694 else if(lstrcmp(temp2,"clip_compile_view")==0) bClipCompileView=1;
695
696 //インクルードディレクトリ
697 else if(lstrcmp(temp2,"include_dir")==0){
698 lstrcpy(szIncludeDir,temp3);
699 }
700 }
701
702 //ソースファイル名が与えられなかったとき
703 if(SourceFileName[0]=='\0'){
704 if(!GetFilePathDialog(0,SourceFileName,BasicFileFilter,"コンパイルするファイルを指定して下さい",1))
705 return 0;
706 }
707
708 //出力ファイル名が与えられなかったとき
709 if(OutputFileName[0]=='\0'){
710 _splitpath(SourceFileName,OutputFileName,temporary,temp2,0);
711 lstrcat(OutputFileName,temporary);
712 lstrcat(OutputFileName,temp2);
713 if(bDebugCompile||bDebugRun) lstrcat(OutputFileName,"_debug.exe");
714 else lstrcat(OutputFileName,".exe");
715 }
716
717 //インクルードディレクトリが指定されなかったとき
718 if(szIncludeDir[0]=='\0'){
719 lstrcpy(szIncludeDir,".\\Include\\");
720 }
721
722 //インクルードディレクトリを絶対パスに変更
723 GetFullPath(szIncludeDir,BasicSystemDir);
724
725 if(bDll){
726 //DLLファイル名を取得
727 _splitpath(OutputFileName,NULL,NULL,szDllName,temporary);
728 lstrcat(szDllName,temporary);
729 }
730
731 if(bDebugRun){
732 //コマンドライン、DLLの実行可能アプリケーションを取得
733 HANDLE hFile;
734 DWORD dwAccessBytes;
735 sprintf(temporary,"%spgm.tmp",BasicSystemDir);
736 hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
737 if(hFile!=INVALID_HANDLE_VALUE){
738 ReadFile(hFile,temporary,MAX_PATH,&dwAccessBytes,NULL);
739 CloseHandle(hFile);
740 temporary[dwAccessBytes]=0;
741 }
742 else temporary[0]=0;
743
744 for(i=0;;i++){
745 if(temporary[i]=='\r'&&temporary[i+1]=='\n'||temporary[i]=='\0'){
746 szDebugExeForDll[i]=0;
747 break;
748 }
749 szDebugExeForDll[i]=temporary[i];
750 }
751 if(temporary[i]){
752 lstrcpy(szDebugCmdLine,temporary+i+2);
753 }
754 }
755
756 _splitpath(SourceFileName,BasicCurDir,temporary,NULL,NULL);
757 lstrcat(BasicCurDir,temporary);
758
759 //エラーリスト情報を初期化
760 pErrorInfo=(ERRORINFO *)HeapAlloc(hHeap,0,1);
761 ErrorNum=0;
762 CompileMsgNum=0;
763 WarningNum=0;
764 bError=0;
765
766 if(bClipCompileView){
767 //ProjectEditor埋め込み型インターフェイス
768 hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_CLIPMAIN),hOwnerEditor,(DLGPROC)DlgCompile);
769 ShowWindow(hMainDlg,SW_SHOW);
770 SendMessage(hOwnerEditor,WM_SETCOMPILEVIEW,0,(LPARAM)hMainDlg);
771
772 //プログレスバーの色をセットする
773 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETBARCOLOR,0,RGB(255,220,192));
774 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETBKCOLOR,0,RGB(255,255,255));
775 }
776 else{
777 //通常ダイアログインターフェイス
778 hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_MAIN),hOwnerEditor,(DLGPROC)DlgCompile);
779 ShowWindow(hMainDlg,SW_SHOW);
780 }
781 SendDlgItemMessage(hMainDlg,IDC_SHOWERROR,BM_SETCHECK,BST_CHECKED,0);
782
783 //エラーリストをサブクラス化
784 OldErrorListProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hMainDlg,IDC_ERRORLIST),GWLP_WNDPROC);
785 SetWindowLongPtr(GetDlgItem(hMainDlg,IDC_ERRORLIST),GWLP_WNDPROC,(LONG_PTR)ErrorListProc);
786
787 //デバッグリストをサブクラス化
788 OldDebugListProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hMainDlg,IDC_DEBUGLIST),GWLP_WNDPROC);
789 SetWindowLongPtr(GetDlgItem(hMainDlg,IDC_DEBUGLIST),GWLP_WNDPROC,(LONG_PTR)DebugListProc);
790
791 if(bFromEditor) SendMessage(hMainDlg,WM_COMMAND,IDOK,0);
792
793 MSG msg;
794 while(GetMessage(&msg,0,0,0)){
795 if(IsDialogMessage(hMainDlg,&msg)) continue;
796 TranslateMessage(&msg);
797 DispatchMessage(&msg);
798 }
799
800 //エラーリスト情報を解放
801 for(i=0;i<ErrorNum;i++){
802 if(pErrorInfo[i].FileName) HeapDefaultFree(pErrorInfo[i].FileName);
803 }
804 HeapDefaultFree(pErrorInfo);
805
806 //不揮発性データを保存
807 pobj_nv->save();
808 delete pobj_nv;
809 pobj_nv=0;
810
811#if defined HeapAlloc
812 CheckHeapCheck();
813#endif
814
815 if(bClipCompileView){
816 SendMessage(hOwnerEditor,WM_DESTROYCOMPILEVIEW,0,0);
817 }
818
819
820 return 0;
821}
Note: See TracBrowser for help on using the repository browser.