source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.cpp@ 471

Last change on this file since 471 was 471, checked in by dai_9181, 16 years ago

show_dlgコマンドライン引数を実装。

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