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

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

jenga.hを追加。

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