source: dev/branches/egtra/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.cpp@ 778

Last change on this file since 778 was 773, checked in by イグトランス (egtra), 14 years ago

セキュリティ対策の機能を有効化

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