source: dev/BasicCompiler_Common/BasicCompiler.cpp@ 13

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