source: dev/BasicCompiler_Common/BasicCompiler.cpp@ 14

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

LexicalAnalysisのベース部分を用意。

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