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

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

ヘッダファイルを整理中

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