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

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

構成管理を大幅に改良。

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