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

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

・WindowInfoクラスをリファクタリング
・MdiInfoを単純配列からvectorに変更した。

File size: 20.1 KB
Line 
1#include "stdafx.h"
2
3#include <ver.h>
4
5#include "BasicCompiler.h"
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(const char *msg){
87 MessageBox(0,FormatEscapeSequenceStringToDefaultString(msg).c_str(),"TestMessage",0);
88}
89void ts(const char *msg,const char *title){
90 MessageBox(0,FormatEscapeSequenceStringToDefaultString(msg).c_str(),title,0);
91}
92void ts(const std::string msg)
93{
94 ts(msg.c_str());
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 std::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 std::string tempBaseDirPath = baseDirPath;
195 if( tempBaseDirPath[tempBaseDirPath.size()-1] != '\\' )
196 {
197 tempBaseDirPath += "\\";
198 }
199
200 i3=(int)tempBaseDirPath.size();i4=0;
201 while(i4<i2){
202 for(i3--;;i3--){
203 if(tempBaseDirPath[i3-1]=='\\'){
204 i4++;
205 break;
206 }
207 }
208 }
209 memcpy(temporary,tempBaseDirPath.c_str(),i3);
210 temporary[i3]=0;
211 lstrcat(temporary,path+i);
212 lstrcpy(path,temporary);
213}
214
215void ShowErrorLine(int LineNum,const char *constFileName){
216 HANDLE hFile;
217 DWORD dw;
218 char FileName[MAX_PATH];
219 char temporary[MAX_PATH];
220
221 lstrcpy( FileName, constFileName );
222
223 if(LineNum==-1) return;
224
225 if(IsWindow(hOwnerEditor)){
226 if(FileName){
227
228 while( !IsFileExist( FileName ) ){
229 char temp2[MAX_PATH],temp3[MAX_PATH];
230 _splitpath(FileName,NULL,NULL,temp2,temp3);
231 lstrcat(temp2,temp3);
232
233 sprintf(temporary,"\"%s\" が見つかりません。格納されているディレクトリを指定してください。",temp2);
234 if(!GetFolder(hOwnerEditor,temp3,temporary)) return;
235
236 if(temp3[lstrlen(temp3)-1]!='\\') lstrcat(temp3,"\\");
237
238 sprintf(FileName,"%s%s",temp3,temp2);
239 }
240
241 hFile=CreateFile(
242 ( ActiveBasic::Common::Environment::GetAbdevRootPath() + "\\pgm.tmp" ).c_str(),
243 GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_TEMPORARY,NULL);
244 WriteFile(hFile,FileName,lstrlen(FileName),&dw,NULL);
245 CloseHandle(hFile);
246
247 SendMessage(hOwnerEditor,WM_SHOWERROR,LineNum,0);
248 }
249 }
250}
251
252BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen){
253 OPENFILENAME ofstr;
254 filename[0]=0;
255 ofstr.lStructSize=sizeof(OPENFILENAME);
256 ofstr.hwndOwner=hwnd;
257 ofstr.hInstance=0;
258 ofstr.lpstrFilter=Filter;
259 ofstr.lpstrCustomFilter=NULL;
260 ofstr.nMaxCustFilter=0;
261 ofstr.nFilterIndex=1;
262 ofstr.lpstrFile=filename;
263 ofstr.nMaxFile=MAX_PATH;
264 ofstr.lpstrFileTitle=NULL;
265 ofstr.nMaxFileTitle=0;
266 ofstr.lpstrInitialDir=0;
267 ofstr.lpstrTitle=Title;
268 ofstr.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;
269 ofstr.nFileOffset=0;
270 ofstr.nFileExtension=0;
271 ofstr.lpstrDefExt="*";
272 ofstr.lCustData=NULL;
273 ofstr.lpfnHook=NULL;
274 ofstr.lpTemplateName=NULL;
275 if(bOpen){
276 if(!GetOpenFileName(&ofstr)) return FALSE;
277 }
278 else{
279 if(!GetSaveFileName(&ofstr)) return FALSE;
280 }
281 return TRUE;
282}
283
284LRESULT CALLBACK ErrorListProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
285 int i,pos;
286 int StartPos,EndPos;
287
288 switch(message){
289 case WM_CHAR:
290 if(GetKeyState(VK_CONTROL)&0x8000){
291 //アクセラレータキーの場合を考慮
292 break;
293 }
294 return 0;
295 case WM_LBUTTONDBLCLK:
296 SendMessage(hwnd,EM_GETSEL,(WPARAM)&pos,0);
297 i=(int)SendMessage(hwnd,EM_LINEFROMCHAR,pos,0);
298 compiler.errorMessenger.ShowErrorLine( i );
299
300 StartPos=(int)SendMessage(hwnd,EM_LINEINDEX,i,0);
301 EndPos=StartPos+(int)SendMessage(hwnd,EM_LINELENGTH,pos,0);
302 SendMessage(hwnd,EM_SETSEL,StartPos,EndPos);
303 return 0;
304 }
305 return CallWindowProc(OldErrorListProc,hwnd,message,wParam,lParam);
306}
307LRESULT CALLBACK DebugListProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
308 switch(message){
309 case WM_CHAR:
310 if(GetKeyState(VK_CONTROL)&0x8000){
311 //アクセラレータキーの場合を考慮
312 break;
313 }
314 return 0;
315 }
316 return CallWindowProc(OldDebugListProc,hwnd,message,wParam,lParam);
317}
318void MakeMessageText(char *buffer,char *msg,int flag){
319 if( program.IsClipCompileView() ){
320 //ProjectView埋め込みがたインターフェイスのとき
321
322 //生成するファイルの相対パスを取得
323 char relationalPath[MAX_PATH];
324 lstrcpy( relationalPath, program.GetOutputFilePath().c_str() );
325 GetRelationalPath( relationalPath, BasicCurDir );
326
327 //////////
328 // 合成
329
330#if defined(JPN)
331 //日本語
332 if(flag==0){
333 if(compiler.IsDll())
334 {
335 sprintf(buffer,"DLLファイル \"%s\" [ %s ]",relationalPath,msg);
336 }
337 else sprintf(buffer,"実行ファイル \"%s\" [ %s ]",relationalPath,msg);
338 }
339 if(flag==1) sprintf(buffer,"\"%s\" を生成しています [ %s ]",relationalPath,msg);
340 if(flag==2) lstrcpy(buffer,msg);
341#else
342 //英語
343 if(flag==0){
344 if(compiler.IsDll()) sprintf(buffer,"DLL file \"%s\" [ %s ]",relationalPath,msg);
345 else sprintf(buffer,"Execution file \"%s\" [ %s ]",relationalPath,msg);
346 }
347 if(flag==1) sprintf(buffer,"Creating \"%s\" [ %s ]",relationalPath,msg);
348 if(flag==2) lstrcpy(buffer,msg);
349#endif
350 }
351 else{
352 //通常ダイアログのとき
353 lstrcpy(buffer,msg);
354 }
355}
356
357void SetPosCenter(HWND hwnd){
358 RECT OwnerRect,rect;
359 int x,y;
360
361 if(IsWindow(hOwnerEditor)) GetWindowRect(hOwnerEditor,&OwnerRect);
362 else{
363 OwnerRect.left=0;
364 OwnerRect.top=0;
365 OwnerRect.right=ScreenX;
366 OwnerRect.bottom=ScreenY;
367 }
368 GetWindowRect(hwnd,&rect);
369
370 x=((OwnerRect.right-OwnerRect.left)-(rect.right-rect.left))/2+OwnerRect.left;
371 y=((OwnerRect.bottom-OwnerRect.top)-(rect.bottom-rect.top))/2+OwnerRect.top;
372 SetWindowPos(hwnd,0,x,y,0,0,SWP_NOSIZE);
373}
374BOOL CALLBACK DlgCompile(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
375 extern HANDLE hDebugProcess;
376 char temporary[MAX_PATH];
377 RECT rect;
378 POINT pos;
379 SIZE size;
380 static POINT pos_List,pos_Progress;
381 static int height_Progress;
382
383 switch(message){
384 case WM_INITDIALOG:
385 pos=pobj_nv->MainDlgPos;
386 GetWindowRect(hwnd,&rect);
387 size.cx=rect.right-rect.left;
388 size.cy=rect.bottom-rect.top;
389 MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
390
391 char relationalPath[MAX_PATH];
392 lstrcpy(relationalPath,program.GetOutputFilePath().c_str());
393 GetRelationalPath(relationalPath,BasicCurDir);
394 SetDlgItemText(hwnd,IDC_EXEPATH,relationalPath);
395
396 //"エラー無し"
397 SetDlgItemText(hwnd,IDC_ERRORLIST,STRING_NOERROR);
398
399 //"デバッグ情報無し"
400 SetDlgItemText(hwnd,IDC_DEBUGLIST,STRING_NODEBUGMSG);
401
402 //リストボックスの初期位置
403 GetWindowRect(GetDlgItem(hwnd,IDC_ERRORLIST),&rect);
404 pos_List.x=rect.left;
405 pos_List.y=rect.top;
406 ScreenToClient(hwnd,&pos_List);
407
408 //プログレスバーの初期位置と高さ
409 GetWindowRect(GetDlgItem(hwnd,IDC_PROGRESS),&rect);
410 pos_Progress.x=rect.left;
411 pos_Progress.y=rect.top;
412 ScreenToClient(hwnd,&pos_Progress);
413 height_Progress=rect.bottom-rect.top;
414
415 //バージョン表記
416 sprintf(temporary,"Version %d.%02d.%02d %s",MAJOR_VER,MINOR_VER,REVISION_VER,VER_INFO);
417 SetDlgItemText(hwnd,IDC_STATIC_VERSION,temporary);
418
419 break;
420 case WM_COMMAND:
421 switch(LOWORD(wParam)){
422 case IDOK:
423 GetDlgItemText(hwnd,IDOK,temporary,MAX_PATH);
424
425 //STRING_COMPILE = "コンパイル"
426 if(lstrcmp(temporary,STRING_COMPILE)==0){
427 char tempOutputFileName[MAX_PATH];
428 GetDlgItemText(hwnd,IDC_EXEPATH,tempOutputFileName,MAX_PATH);
429 program.SetOutputFilePath(
430 Jenga::Common::Path::MakeFullPath( tempOutputFileName, BasicCurDir )
431 );
432 _beginthread( &MainThread, NULL, NULL );
433 }
434
435 //STRING_STOP = "中断"
436 else if(lstrcmp(temporary,STRING_STOP)==0){
437 if(hDebugProcess){
438 //デバッグ中のとき
439
440 //プロセスを終了
441 TerminateProcess(hDebugProcess,0);
442 hDebugProcess=0;
443
444 //デバッグダイアログを終了
445 if(hDebugWnd){
446 DestroyWindow(hDebugWnd);
447 }
448 }
449 else{
450 //コンパイル中のとき
451 bStopCompile=1;
452
453 /* メインスレッドで「閉じる」ボタンに変更することで、
454 コンパイルを中断中の早いタイミングでも終了することが可能 */
455 //"閉じる"
456 SetDlgItemText(hwnd,IDOK,STRING_CLOSE);
457 }
458 }
459
460 else{
461 SetFocus(hOwnerEditor);
462 DestroyWindow(hwnd);
463 }
464 return 1;
465 case IDCANCEL:
466 //×ボタン用
467
468 if(hDebugProcess){
469 //デバッグ中のとき
470
471 //プロセスを終了
472 TerminateProcess(hDebugProcess,0);
473 hDebugProcess=0;
474
475 //デバッグダイアログを終了
476 if(hDebugWnd){
477 DestroyWindow(hDebugWnd);
478 }
479 }
480
481 SetFocus(hOwnerEditor);
482 DestroyWindow(hwnd);
483 return 1;
484 case IDC_SHOWERROR:
485 ShowWindow(GetDlgItem(hwnd,IDC_ERRORLIST),SW_SHOW);
486 ShowWindow(GetDlgItem(hwnd,IDC_DEBUGLIST),SW_HIDE);
487 return 1;
488 case IDC_SHOWDEBUG:
489 ShowWindow(GetDlgItem(hwnd,IDC_ERRORLIST),SW_HIDE);
490 ShowWindow(GetDlgItem(hwnd,IDC_DEBUGLIST),SW_SHOW);
491 return 1;
492 }
493 break;
494 case WM_SHOWVARLIST:
495 if( program.IsClipCompileView() ){
496 //埋め込み表示
497 CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_DEBUGGER),hOwnerEditor,(DLGPROC)DlgDebugger,lParam);
498 ShowWindow(hDebugWnd,SW_SHOW);
499
500 SendMessage(hOwnerEditor,WM_SETDEBUGGERVIEW,0,(LPARAM)hDebugWnd);
501 }
502 else{
503 //ポップアップ表示
504 CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_VARLIST),hOwnerEditor,(DLGPROC)DlgVarList,lParam);
505 SetForegroundWindow(hDebugWnd);
506 }
507 return 1;
508 case WM_SIZE:
509 if( program.IsClipCompileView() ){
510 //エラーリストの位置
511 MoveWindow(GetDlgItem(hwnd,IDC_ERRORLIST),
512 pos_List.x,
513 pos_List.y,
514 LOWORD(lParam)-pos_List.x,
515 HIWORD(lParam)-pos_List.y,
516 1);
517
518 //デバッグリストの位置
519 MoveWindow(GetDlgItem(hwnd,IDC_DEBUGLIST),
520 pos_List.x,
521 pos_List.y,
522 LOWORD(lParam)-pos_List.x,
523 HIWORD(lParam)-pos_List.y,
524 1);
525
526 //プログレスバーの位置
527 MoveWindow(GetDlgItem(hwnd,IDC_PROGRESS),
528 pos_Progress.x,
529 pos_Progress.y,
530 LOWORD(lParam)-pos_Progress.x,
531 height_Progress,
532 1);
533 }
534 return 1;
535 case WM_DESTROY:
536 GetWindowRect(hwnd,&rect);
537
538 if( !program.IsClipCompileView() ){
539 pobj_nv->MainDlgPos.x=rect.left;
540 pobj_nv->MainDlgPos.y=rect.top;
541 }
542
543 PostQuitMessage(0);
544 return 1;
545
546
547
548 ///////////////////////
549 // デバッグコマンド
550 ///////////////////////
551
552 case WM_DEBUG_STOP:
553 Debugger_Stop();
554 return 1;
555 case WM_DEBUG_PAUSE:
556 Debugger_Pause();
557 return 1;
558
559
560 case WM_CLOSE_DEBUGGER:
561 if(hDebugWnd){
562 DestroyWindow(hDebugWnd);
563 }
564 return 1;
565 }
566 return 0;
567}
568
569void _Test()
570{
571 Jenga::Common::LoggerSetting loggerSetting;
572 bool result = loggerSetting.WriteXml( Jenga::Common::Environment::GetAppDir() + "\\logger.setting.xml" );
573}
574
575int main()
576{
577 int i;
578 char temporary[1024],temp2[MAX_PATH];
579
580 hInst = GetModuleHandle( NULL );
581
582 // グローバルローケルを日本語にする
583 std::locale::global(std::locale("japanese"));
584 _setmode(_fileno(stdout), _O_BINARY);
585
586 //_Test();
587
588 //MessageBox(0,"starting compiler/debugger","ActiveBasic",MB_OK);
589 trace( "Start ActiveBasic Compiler!" );
590
591 //コモンコントロールを初期化
592 InitCommonControls();
593
594 hHeap=GetProcessHeap();
595 ScreenX=GetSystemMetrics(SM_CXSCREEN);
596 ScreenY=GetSystemMetrics(SM_CYSCREEN);
597
598 //不揮発性データを取得
599 pobj_nv=new CNonVolatile;
600 pobj_nv->load();
601
602 program.Configurate();
603
604 if( !program.AnalysisCommandLines() )
605 {
606 // コマンドラインが不正
607 return 0;
608 }
609
610 bool isSpecifiedSourceFilePathByCommandLine = false;
611 if( program.GetSourceFilePath().size() > 0 )
612 {
613 // ソースファイル名が与えられていたとき
614 isSpecifiedSourceFilePathByCommandLine = true;
615 }
616 else
617 {
618 // ソースファイル名が与えられなかったとき
619 char temp[MAX_PATH];
620 if(!GetFilePathDialog(0,temp,BasicFileFilter,"コンパイルするファイルを指定して下さい",1))
621 {
622 return 0;
623 }
624 program.SetSourceFilePath( temp );
625 }
626
627 //出力ファイル名が与えられなかったとき
628 if( program.GetOutputFilePath().size() == 0 )
629 {
630 char tempOutputFileName[MAX_PATH];
631 _splitpath( program.GetSourceFilePath().c_str(), tempOutputFileName,temporary,temp2,0);
632 lstrcat(tempOutputFileName,temporary);
633 lstrcat(tempOutputFileName,temp2);
634 if( compiler.IsSll() )
635 {
636 if( program.IsDebugRun() || compiler.IsDebug() )
637 {
638 lstrcat(tempOutputFileName,"_debug.abobj");
639 }
640 else
641 {
642 lstrcat(tempOutputFileName,".abobj");
643 }
644 }
645 else
646 {
647 if( program.IsDebugRun() || compiler.IsDebug() )
648 {
649 lstrcat(tempOutputFileName,"_debug.exe");
650 }
651 else
652 {
653 lstrcat(tempOutputFileName,".exe");
654 }
655 }
656
657 program.SetOutputFilePath( tempOutputFileName );
658 }
659
660 {
661 // カレントディレクトリを取得
662 std::string baseDirPath = Jenga::Common::Environment::GetAppDir()+"\\";
663
664 // インクルードディレクトリが指定されなかったとき
665 if( program.GetIncludeDir().size() == 0 )
666 {
667 program.SetIncludeDir( Jenga::Common::Path::MakeFullPath( ".\\Include", ActiveBasic::Common::Environment::GetAbdevRootPath() ) );
668 }
669 else
670 {
671 // インクルードディレクトリを絶対パスに変更
672 program.SetIncludeDir( Jenga::Common::Path::MakeFullPathByCurrentDirectory( program.GetIncludeDir() ) );
673 }
674
675 // ソースファイル名を絶対パスに変換
676 program.SetSourceFilePath( Jenga::Common::Path::MakeFullPathByCurrentDirectory( program.GetSourceFilePath() ) );
677
678 // 出力ファイル名を絶対パスに変換
679 program.SetOutputFilePath( Jenga::Common::Path::MakeFullPathByCurrentDirectory( program.GetOutputFilePath() ) );
680
681 // モジュール名をセット
682 compiler.SetModuleName( Jenga::Common::Path( program.GetOutputFilePath() ).GetFileName() );
683 }
684
685 if( compiler.IsDll() )
686 {
687 //DLLファイル名を取得
688 _splitpath( program.GetOutputFilePath().c_str(),NULL,NULL,szDllName,temporary);
689 lstrcat(szDllName,temporary);
690 }
691
692 if( program.IsDebugRun() )
693 {
694 //コマンドライン、DLLの実行可能アプリケーションを取得
695 HANDLE hFile;
696 DWORD dwAccessBytes;
697 hFile=CreateFile(
698 ( ActiveBasic::Common::Environment::GetAbdevRootPath() + "\\pgm.tmp" ).c_str(),
699 GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
700 if(hFile!=INVALID_HANDLE_VALUE){
701 ReadFile(hFile,temporary,MAX_PATH,&dwAccessBytes,NULL);
702 CloseHandle(hFile);
703 temporary[dwAccessBytes]=0;
704 }
705 else temporary[0]=0;
706
707 for(i=0;;i++){
708 if(temporary[i]=='\r'&&temporary[i+1]=='\n'||temporary[i]=='\0'){
709 szDebugExeForDll[i]=0;
710 break;
711 }
712 szDebugExeForDll[i]=temporary[i];
713 }
714 if(temporary[i]){
715 lstrcpy(szDebugCmdLine,temporary+i+2);
716 }
717 }
718
719 _splitpath( program.GetSourceFilePath().c_str(), BasicCurDir,temporary,NULL,NULL);
720 lstrcat(BasicCurDir,temporary);
721
722 if( program.IsClipCompileView() ){
723 //ProjectEditor埋め込み型インターフェイス
724 hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_CLIPMAIN),hOwnerEditor,(DLGPROC)DlgCompile);
725 ShowWindow(hMainDlg,SW_SHOW);
726 SendMessage(hOwnerEditor,WM_SETCOMPILEVIEW,0,(LPARAM)hMainDlg);
727
728 //プログレスバーの色をセットする
729 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETBARCOLOR,0,RGB(255,220,192));
730 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETBKCOLOR,0,RGB(255,255,255));
731 }
732 else{
733 //通常ダイアログインターフェイス
734 hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_MAIN),hOwnerEditor,(DLGPROC)DlgCompile);
735
736 if( program.IsKickedFromEditor() )
737 {
738 // エディタから起動されたとき
739 PostMessage( hMainDlg, WM_COMMAND, IDOK, 0 );
740 }
741 else if( program.IsShowDlg() )
742 {
743 // コマンドラインでshow_dlgパラメータが指定された場合、ダイアログを表示する
744 // すぐにビルドを開始する
745 ShowWindow(hMainDlg,SW_SHOW);
746 PostMessage( hMainDlg, WM_COMMAND, IDOK, 0 );
747 }
748 else if( isSpecifiedSourceFilePathByCommandLine )
749 {
750 // コマンドラインでソースコード指定があった場合はウィンドウは表示せず、そのままビルドを開始する。
751 MainThread(0);
752
753 trace("Complete ActiveBasic Compiler!");
754
755 ExitProcess( program.GetExitCode() );
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( program.GetExitCode() );
801
802 return 0;
803}
Note: See TracBrowser for help on using the repository browser.