source: dev/trunk/abdev/BasicCompiler_Common/BasicCompiler.cpp@ 212

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

BoostXmlSupportクラスの名前をBoostSerializationSupportに変更

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