Changeset 467 in dev


Ignore:
Timestamp:
Mar 27, 2008, 2:29:35 AM (16 years ago)
Author:
dai_9181
Message:

いくつかのグローバル変数をProgram/Debuggerクラスにまとめた。

Location:
trunk/ab5.0
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler32/BasicCompiler.vcproj

    r465 r467  
    13541354                    </File>
    13551355                    <File
    1356                         RelativePath="..\BasicCompiler_Common\src\Program.cpp"
    1357                         >
    1358                     </File>
    1359                     <File
    13601356                        RelativePath="..\BasicCompiler_Common\src\Source.cpp"
    13611357                        >
     
    13781374                    </File>
    13791375                </Filter>
     1376            </Filter>
     1377            <Filter
     1378                Name="Application Classes"
     1379                >
     1380                <File
     1381                    RelativePath="..\BasicCompiler_Common\src\Program.cpp"
     1382                    >
     1383                </File>
    13801384            </Filter>
    13811385        </Filter>
     
    15801584                </File>
    15811585            </Filter>
     1586            <Filter
     1587                Name="Debugger Classes"
     1588                >
     1589                <File
     1590                    RelativePath="..\BasicCompiler_Common\include\Debugger.h"
     1591                    >
     1592                </File>
     1593            </Filter>
    15821594        </Filter>
    15831595        <Filter
  • trunk/ab5.0/abdev/BasicCompiler32/MakePeHdr.cpp

    r465 r467  
    104104    extern DWORD ImageBase;
    105105    extern char *basbuf;
    106     extern char OutputFileName[MAX_PATH];
    107106
    108107    int i,i2,i3,i4,i5;
     
    493492
    494493        // 格納先ディレクトリを作る
    495         Jenga::Common::Path path( OutputFileName );
     494        Jenga::Common::Path path( program.GetOutputFilePath() );
    496495        Jenga::Common::Directory dir( path.GetDriveName() + path.GetDirName(), true );
    497496
    498497        // 書き込む
    499         if( !compiler.GetObjectModule().Write( OutputFileName ) )
     498        if( !compiler.GetObjectModule().Write( program.GetOutputFilePath() ) )
    500499        {
    501500            MessageBox(0,"XML書き込みに失敗","test",0);
     
    548547        hLib=LoadLibrary( pDllProc->GetDllFileName().c_str() );
    549548        if(!hLib){
    550             extern char OutputFileName[MAX_PATH];
    551549            char temp2[MAX_PATH],temp3[MAX_PATH];
    552             _splitpath(OutputFileName,temp2,temp3,NULL,NULL);
     550            _splitpath(program.GetOutputFilePath().c_str(),temp2,temp3,NULL,NULL);
    553551            lstrcat(temp2,temp3);
    554552            lstrcpy(temp3,pDllProc->GetDllFileName().c_str());
     
    599597
    600598    if(bUse_ExportSection){
    601         _splitpath(OutputFileName,NULL,NULL,lpExportNames,temporary);
     599        _splitpath(program.GetOutputFilePath().c_str(),NULL,NULL,lpExportNames,temporary);
    602600        lstrcat(lpExportNames,temporary);
    603601        ExportNamesLength=lstrlen(lpExportNames)+1;
     
    14121410
    14131411
    1414     hFile=CreateFile(OutputFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
     1412    hFile=CreateFile(program.GetOutputFilePath().c_str(),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
    14151413    if(hFile==INVALID_HANDLE_VALUE){
    1416         compiler.errorMessenger.Output(53,OutputFileName,-1);
     1414        compiler.errorMessenger.Output(53,program.GetOutputFilePath().c_str(),-1);
    14171415        goto EndWriteOpcode;
    14181416    }
  • trunk/ab5.0/abdev/BasicCompiler32/stdafx.h

    r465 r467  
    55#include <vector>
    66#include <fstream>
     7#include <iostream>
    78
    89#include <windows.h>
     
    1415#include <limits.h>
    1516#include <shlobj.h>
    16 #include <iostream>
     17#include <process.h>
    1718
    1819//boost libraries
     
    3031#include <Program.h>
    3132#include <Compiler.h>
     33#include <Debugger.h>
  • trunk/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.cpp

    r465 r467  
    11#include "stdafx.h"
    2 
    3 #include <shlwapi.h>
    42
    53#include <jenga/include/common/Path.h>
     
    320318}
    321319void MakeMessageText(char *buffer,char *msg,int flag){
    322     char temporary[MAX_PATH];
    323     if(bClipCompileView){
     320    if( program.IsClipCompileView() ){
    324321        //ProjectView埋め込みがたインターフェイスのとき
    325322
    326323        //生成するファイルの相対パスを取得
    327         lstrcpy(temporary,OutputFileName);
    328         GetRelationalPath(temporary,BasicCurDir);
     324        char relationalPath[MAX_PATH];
     325        lstrcpy( relationalPath, program.GetOutputFilePath().c_str() );
     326        GetRelationalPath( relationalPath, BasicCurDir );
    329327
    330328        //////////
     
    336334            if(compiler.IsDll())
    337335            {
    338                 sprintf(buffer,"DLLファイル \"%s\"     [ %s ]",temporary,msg);
    339             }
    340             else sprintf(buffer,"実行ファイル \"%s\"     [ %s ]",temporary,msg);
    341         }
    342         if(flag==1) sprintf(buffer,"\"%s\" を生成しています     [ %s ]",temporary,msg);
     336                sprintf(buffer,"DLLファイル \"%s\"     [ %s ]",relationalPath,msg);
     337            }
     338            else sprintf(buffer,"実行ファイル \"%s\"     [ %s ]",relationalPath,msg);
     339        }
     340        if(flag==1) sprintf(buffer,"\"%s\" を生成しています     [ %s ]",relationalPath,msg);
    343341        if(flag==2) lstrcpy(buffer,msg);
    344342#else
    345343        //英語
    346344        if(flag==0){
    347             if(compiler.IsDll()) sprintf(buffer,"DLL file \"%s\"     [ %s ]",temporary,msg);
    348             else sprintf(buffer,"Execution file \"%s\"     [ %s ]",temporary,msg);
    349         }
    350         if(flag==1) sprintf(buffer,"Creating \"%s\"     [ %s ]",temporary,msg);
     345            if(compiler.IsDll()) sprintf(buffer,"DLL file \"%s\"     [ %s ]",relationalPath,msg);
     346            else sprintf(buffer,"Execution file \"%s\"     [ %s ]",relationalPath,msg);
     347        }
     348        if(flag==1) sprintf(buffer,"Creating \"%s\"     [ %s ]",relationalPath,msg);
    351349        if(flag==2) lstrcpy(buffer,msg);
    352350#endif
     
    378376    extern HANDLE hDebugProcess;
    379377    char temporary[MAX_PATH];
    380     DWORD dw;
    381378    RECT rect;
    382379    POINT pos;
     
    393390            MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
    394391
    395             lstrcpy(temporary,OutputFileName);
    396             GetRelationalPath(temporary,BasicCurDir);
    397             SetDlgItemText(hwnd,IDC_EXEPATH,temporary);
     392            char relationalPath[MAX_PATH];
     393            lstrcpy(relationalPath,program.GetOutputFilePath().c_str());
     394            GetRelationalPath(relationalPath,BasicCurDir);
     395            SetDlgItemText(hwnd,IDC_EXEPATH,relationalPath);
    398396
    399397            //"エラー無し"
     
    428426                    //STRING_COMPILE = "コンパイル"
    429427                    if(lstrcmp(temporary,STRING_COMPILE)==0){
    430                         GetDlgItemText(hwnd,IDC_EXEPATH,OutputFileName,MAX_PATH);
    431                         GetFullPath(OutputFileName,BasicCurDir);
    432                         CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)MainThread,0,0,&dw);
     428                        char tempOutputFileName[MAX_PATH];
     429                        GetDlgItemText(hwnd,IDC_EXEPATH,tempOutputFileName,MAX_PATH);
     430                        program.SetOutputFilePath(
     431                            Jenga::Common::Path::MakeFullPath( tempOutputFileName, BasicCurDir )
     432                        );
     433                        _beginthread( &MainThread, NULL, NULL );
    433434                    }
    434435
     
    493494            break;
    494495        case WM_SHOWVARLIST:
    495             if(bClipCompileView){
     496            if( program.IsClipCompileView() ){
    496497                //埋め込み表示
    497498                CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_DEBUGGER),hOwnerEditor,(DLGPROC)DlgDebugger,lParam);
     
    507508            return 1;
    508509        case WM_SIZE:
    509             if(bClipCompileView){
     510            if( program.IsClipCompileView() ){
    510511                //エラーリストの位置
    511512                MoveWindow(GetDlgItem(hwnd,IDC_ERRORLIST),
     
    536537            GetWindowRect(hwnd,&rect);
    537538
    538             if(!bClipCompileView){
     539            if( !program.IsClipCompileView() ){
    539540                pobj_nv->MainDlgPos.x=rect.left;
    540541                pobj_nv->MainDlgPos.y=rect.top;
     
    567568}
    568569
    569 bool AnalysisCommandLines( bool &isFromEditor )
    570 {
    571     // 値を初期化
    572     isFromEditor = false;
    573 
    574     // コマンドラインを解析
    575     const Jenga::Common::CmdLines cmdLines( PathGetArgs( GetCommandLine() ) );
    576     int cmdLineIndex = 0;
    577 
    578     if( cmdLines.size() == 0 )
    579     {
    580         // 何も指定されていないとき
    581         return true;
    582     }
    583 
    584     if( cmdLines[cmdLineIndex].IsNamelessCommand() )
    585     {
    586         // 先頭に無名コマンドがきた場合、ソースファイル名として認識する
    587         lstrcpy( SourceFileName, cmdLines[cmdLineIndex].GetParameter().c_str() );
    588 
    589         cmdLineIndex ++;
    590 
    591         if( cmdLines.size() == 1 )
    592         {
    593             // ソースファイル名のみの指定だったとき
    594             return true;
    595         }
    596 
    597         // 出力ファイル名を取得
    598         if( cmdLines[cmdLineIndex].IsNamelessCommand() )
    599         {
    600             // 二番目にも無名コマンドがきた場合、ソースファイル名として認識する
    601             lstrcpy( OutputFileName, cmdLines[cmdLineIndex].GetParameter().c_str() );
    602 
    603             cmdLineIndex ++;
    604         }
    605     }
    606 
    607     for( ; cmdLineIndex < static_cast<int>(cmdLines.size()); cmdLineIndex++ )
    608     {
    609         const Jenga::Common::CmdLine &cmdLine = cmdLines[cmdLineIndex];
    610 
    611         if( cmdLine.GetCommand() == "wnd" )
    612         {
    613             // 親エディタのウィンドウ ハンドル
    614             isFromEditor = true;
    615             sscanf( cmdLine.GetParameter().c_str(), "%08x", &hOwnerEditor );
    616         }
    617         else if( cmdLine.GetCommand() == "debug" )
    618         {
    619             // デバッグ ビルド
    620             compiler.SetDebugMark( true );
    621         }
    622         else if( cmdLine.GetCommand() == "run" )
    623         {
    624             // デバッグ実行
    625             bDebugRun = 1;
    626         }
    627         else if( cmdLine.GetCommand() == "attach" )
    628         {
    629             // アタッチ
    630             bDebugRun=1;
    631             bAttach=1;
    632             sscanf( cmdLine.GetParameter().c_str(), "%08x", &dwAttachProcessId );
    633         }
    634         else if( cmdLine.GetCommand() == "dll" )
    635         {
    636             // DLLとしてビルド
    637             compiler.SetTargetModuleType( Compiler::Dll );
    638         }
    639         else if( cmdLine.GetCommand() == "static_library" )
    640         {
    641             // 静的リンクライブラリとしてビルド
    642             compiler.SetTargetModuleType( Compiler::StaticLibrary );
    643         }
    644         else if( cmdLine.GetCommand() == "unicode" )
    645         {
    646             // Unicode
    647             compiler.SetUnicodeMark( true );
    648             typeOfPtrChar = MAKE_PTR_TYPE(DEF_WORD,1);
    649             typeOfPtrUChar = MAKE_PTR_TYPE(DEF_WORD,1);
    650         }
    651         else if( cmdLine.GetCommand() == "clip_compile_view" )
    652         {
    653             //埋め込み型コンパイラビュー
    654             bClipCompileView = 1;
    655         }
    656         else if( cmdLine.GetCommand() == "include_dir" )
    657         {
    658             //インクルード ディレクトリ
    659             lstrcpy( szIncludeDir, cmdLine.GetParameter().c_str() );
    660         }
    661         else
    662         {
    663             // 不正なコマンド
    664             std::string keyword = cmdLine.GetCommand();
    665             if( keyword.size() == 0 )
    666             {
    667                 keyword = cmdLine.GetParameter();
    668             }
    669             std::cout << keyword << " コマンドとして認識できません。" << std::endl;
    670             return false;
    671         }
    672     }
    673 
    674     return true;
    675 }
    676 
    677570void _Test()
    678571{
     
    704597    pobj_nv->load();
    705598
    706     bool isFromEditor;
    707     if( !AnalysisCommandLines( isFromEditor ) )
     599    if( !program.AnalysisCommandLines() )
    708600    {
    709601        // コマンドラインが不正
     
    712604
    713605    //ソースファイル名が与えられなかったとき
    714     if(SourceFileName[0]=='\0'){
    715         if(!GetFilePathDialog(0,SourceFileName,BasicFileFilter,"コンパイルするファイルを指定して下さい",1))
     606    if( program.GetSourceFilePath().size() == 0 )
     607    {
     608        char temp[MAX_PATH];
     609        if(!GetFilePathDialog(0,temp,BasicFileFilter,"コンパイルするファイルを指定して下さい",1))
     610        {
    716611            return 0;
     612        }
     613        program.SetSourceFilePath( temp );
    717614    }
    718615
    719616    //出力ファイル名が与えられなかったとき
    720     if(OutputFileName[0]=='\0'){
    721         _splitpath(SourceFileName,OutputFileName,temporary,temp2,0);
    722         lstrcat(OutputFileName,temporary);
    723         lstrcat(OutputFileName,temp2);
     617    if( program.GetOutputFilePath().size() == 0 )
     618    {
     619        char tempOutputFileName[MAX_PATH];
     620        _splitpath( program.GetSourceFilePath().c_str(), tempOutputFileName,temporary,temp2,0);
     621        lstrcat(tempOutputFileName,temporary);
     622        lstrcat(tempOutputFileName,temp2);
    724623        if( compiler.IsStaticLibrary() )
    725624        {
    726             if( bDebugRun || compiler.IsDebug() )
     625            if( program.IsDebugRun() || compiler.IsDebug() )
    727626            {
    728                 lstrcat(OutputFileName,"_debug.abobj");
     627                lstrcat(tempOutputFileName,"_debug.abobj");
    729628            }
    730629            else
    731630            {
    732                 lstrcat(OutputFileName,".abobj");
     631                lstrcat(tempOutputFileName,".abobj");
    733632            }
    734633        }
    735634        else
    736635        {
    737             if( bDebugRun || compiler.IsDebug() )
     636            if( program.IsDebugRun() || compiler.IsDebug() )
    738637            {
    739                 lstrcat(OutputFileName,"_debug.exe");
     638                lstrcat(tempOutputFileName,"_debug.exe");
    740639            }
    741640            else
    742641            {
    743                 lstrcat(OutputFileName,".exe");
    744             }
    745         }
     642                lstrcat(tempOutputFileName,".exe");
     643            }
     644        }
     645
     646        program.SetOutputFilePath( tempOutputFileName );
    746647    }
    747648
     
    751652
    752653        // インクルードディレクトリが指定されなかったとき
    753         if(szIncludeDir[0]=='\0'){
    754             lstrcpy(szIncludeDir,".\\Include\\");
    755 
    756             // インクルードディレクトリを絶対パスに変更
    757             GetFullPath(szIncludeDir,baseDirPath.c_str());
     654        if( program.GetIncludeDir().size() == 0 )
     655        {
     656            program.SetIncludeDir( Jenga::Common::Path::MakeFullPath( ".\\Include\\", baseDirPath ) );
    758657        }
    759658        else
    760659        {
    761660            // インクルードディレクトリを絶対パスに変更
    762             GetFullPath(szIncludeDir,baseDirPath.c_str());
     661            program.SetIncludeDir( Jenga::Common::Path::MakeFullPath( program.GetIncludeDir(), baseDirPath ) );
    763662        }
    764663
    765664        // ソースファイル名を絶対パスに変換
    766         GetFullPath(SourceFileName,baseDirPath.c_str());
     665        program.SetSourceFilePath( Jenga::Common::Path::MakeFullPath( program.GetSourceFilePath(), baseDirPath ) );
    767666
    768667        // 出力ファイル名を絶対パスに変換
    769         GetFullPath(OutputFileName,baseDirPath.c_str());
     668        program.SetOutputFilePath( Jenga::Common::Path::MakeFullPath( program.GetOutputFilePath(), baseDirPath ) );
    770669
    771670        // モジュール名をセット
    772         compiler.SetModuleName( Jenga::Common::Path( OutputFileName ).GetFileName() );
    773     }
    774 
    775     if( compiler.IsDll() ){
     671        compiler.SetModuleName( Jenga::Common::Path( program.GetOutputFilePath() ).GetFileName() );
     672    }
     673
     674    if( compiler.IsDll() )
     675    {
    776676        //DLLファイル名を取得
    777         _splitpath(OutputFileName,NULL,NULL,szDllName,temporary);
     677        _splitpath( program.GetOutputFilePath().c_str(),NULL,NULL,szDllName,temporary);
    778678        lstrcat(szDllName,temporary);
    779679    }
    780680
    781     if(bDebugRun){
     681    if( program.IsDebugRun() )
     682    {
    782683        //コマンドライン、DLLの実行可能アプリケーションを取得
    783684        HANDLE hFile;
     
    805706    }
    806707
    807     _splitpath(SourceFileName,BasicCurDir,temporary,NULL,NULL);
     708    _splitpath( program.GetSourceFilePath().c_str(), BasicCurDir,temporary,NULL,NULL);
    808709    lstrcat(BasicCurDir,temporary);
    809710
    810     if(bClipCompileView){
     711    if( program.IsClipCompileView() ){
    811712        //ProjectEditor埋め込み型インターフェイス
    812713        hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_CLIPMAIN),hOwnerEditor,(DLGPROC)DlgCompile);
     
    840741    SetWindowLongPtr(GetDlgItem(hMainDlg,IDC_DEBUGLIST),GWLP_WNDPROC,(LONG_PTR)DebugListProc);
    841742
    842     if( isFromEditor )
     743    if( program.IsKickedFromEditor() )
    843744    {
    844745        SendMessage(hMainDlg,WM_COMMAND,IDOK,0);
     
    861762#endif
    862763
    863     if(bClipCompileView){
     764    if( program.IsClipCompileView() ){
    864765        SendMessage(hOwnerEditor,WM_DESTROYCOMPILEVIEW,0,0);
    865766    }
  • trunk/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.h

    r465 r467  
    1414WNDPROC OldProcComboProc;
    1515unsigned short TypeOfSubSystem;
    16 BOOL bClipCompileView;
    1716
    1817//不揮発性データ(レジストリに保存される)
     
    3837
    3938//デバッグ
    40 BOOL bDebugRun=0;
    41 BOOL bAttach=0;
    42 DWORD dwAttachProcessId;
    4339BOOL bDebugSupportProc;
    4440BOOL bSystemProc;
     
    6258
    6359char BasicCurDir[MAX_PATH];     //コンパイルするファイルが存在するディレクトリ
    64 char SourceFileName[MAX_PATH];
    65 char OutputFileName[MAX_PATH];
    6660char szDllName[MAX_PATH];
    67 char szIncludeDir[MAX_PATH]="";
  • trunk/ab5.0/abdev/BasicCompiler_Common/Debug.cpp

    r455 r467  
    377377void DebugProgram(void){
    378378    extern HWND hMainDlg;
    379     extern char OutputFileName[MAX_PATH];
    380379    extern DWORD ImageBase;
    381380    extern int MemPos_CodeSection;
     
    419418
    420419
    421     extern BOOL bAttach;
    422     if(bAttach){
    423         extern DWORD dwAttachProcessId;
    424 
     420    // デバッグをスタート
     421    debugger.DebugStart();
     422
     423
     424    if( program.IsAttach() )
     425    {
    425426        //プロセスIDを元にハンドルを取得
    426427        HANDLE hProcess;
    427         hProcess=OpenProcess(PROCESS_ALL_ACCESS,0,dwAttachProcessId);
     428        hProcess=OpenProcess(PROCESS_ALL_ACCESS,0, program.GetAttachProcessId() );
    428429        if(!hProcess) goto AttachError;
    429430
     
    434435
    435436        //実行ファイル名を取得
    436         GetModuleFileNameEx(hProcess,hModule,OutputFileName,MAX_PATH);
     437        char tempOutputFileName[MAX_PATH];
     438        GetModuleFileNameEx(hProcess,hModule,tempOutputFileName,MAX_PATH);
     439        program.SetOutputFilePath( tempOutputFileName );
    437440
    438441        CloseHandle(hProcess);
     
    440443/*
    441444        //デバッグ用の拡張情報を取得
    442         pobj_DebugSection->load(OutputFileName);*/
    443 
    444         if(!DebugActiveProcess(dwAttachProcessId)){
     445        pobj_DebugSection->load(program.GetOutputFilePath().c_str());*/
     446
     447        if(!DebugActiveProcess( program.GetAttachProcessId() )){
    445448AttachError:
    446449            DebugMessage("アタッチに失敗しました。");
     
    449452    }
    450453    else{
    451         /*if(!pobj_DebugSection->load(OutputFileName)){
     454        /*if(!pobj_DebugSection->load(program.GetOutputFilePath().c_str())){
    452455            extern BOOL bDebugCompile;
    453456            bDebugCompile=1;
    454457            OutputExe();
    455             pobj_DebugSection->load(OutputFileName);
     458            pobj_DebugSection->load(program.GetOutputFilePath().c_str());
    456459        }*/
    457460
     
    464467        if( !compiler.IsDll() ){
    465468            //EXEファイルをデバッグ
    466             CreateProcess(OutputFileName,szDebugCmdLine,NULL,NULL,0,NORMAL_PRIORITY_CLASS|DEBUG_ONLY_THIS_PROCESS|CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi);
     469            CreateProcess(program.GetOutputFilePath().c_str(),szDebugCmdLine,NULL,NULL,0,NORMAL_PRIORITY_CLASS|DEBUG_ONLY_THIS_PROCESS|CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi);
    467470        }
    468471        else{
     
    537540
    538541
    539             /*if(lstrcmpi(temporary, OutputFileName)==0){
     542            /*if(lstrcmpi(temporary, program.GetOutputFilePath().c_str())==0){
    540543                ImageBase=(DWORD)de.u.LoadDll.lpBaseOfDll;
    541544
     
    817820    SetDlgItemText(hMainDlg,IDOK,STRING_CLOSE);
    818821
     822    debugger.FinishDebug();
     823
    819824    SendMessage(hOwnerEditor,WM_DESTROYDEBUGGERBASE,0,0);
    820825}
  • trunk/ab5.0/abdev/BasicCompiler_Common/MakeExe.cpp

    r466 r467  
    6666
    6767    //プログラムをファイルから読み込む
    68     extern char SourceFileName[MAX_PATH];
    6968    compiler.GetObjectModule().SetCurrentSourceIndex( (int)compiler.GetObjectModule().GetSources().size() );
    7069    compiler.GetObjectModule().GetSources().push_back( BasicSource() );
    71     if( !compiler.GetObjectModule().GetCurrentSource().ReadFile( SourceFileName ) ){
    72         compiler.errorMessenger.Output(201,SourceFileName,-1);
     70    if( !compiler.GetObjectModule().GetCurrentSource().ReadFile( program.GetSourceFilePath() ) ){
     71        compiler.errorMessenger.Output(201,program.GetSourceFilePath(),-1);
    7372        goto EndCompile;
    7473    }
     
    8483    //////////////////////////
    8584    // 中間コードの生成を開始
    86     extern BOOL bClipCompileView;
    8785
    8886    //"最適化中..."
     
    158156            // コアモジュールをロードする
    159157            extern BOOL bDebugCompile;
    160             extern char szIncludeDir[MAX_PATH];
    161158
    162159            const char *coreFileName = "core.lib";
     
    172169            sprintf( coreFilePath, "..\\lib\\%s", coreFileName );
    173170#endif
    174             GetFullPath( coreFilePath, szIncludeDir );
     171            GetFullPath( coreFilePath, program.GetIncludeDir() );
    175172
    176173            Jenga::Common::Path path( coreFilePath );
     
    288285#endif
    289286}
    290 int MainThread(DWORD dummy){
    291     extern BOOL bDebugRun;
    292 
    293     if(bDebugRun){
     287void MainThread(void *dummy)
     288{
     289    if( program.IsDebugRun() )
     290    {
    294291        if( compiler.IsDebug() )
    295292        {
    296             bDebugRun=0;
    297 
    298293            //デバッグコンパイル
    299294            OutputExe();
    300 
    301             bDebugRun=1;
    302295        }
    303296
     
    312305        OutputExe();
    313306    }
    314 
    315     return 0;
    316 }
     307}
  • trunk/ab5.0/abdev/BasicCompiler_Common/RSrcSection.cpp

    r465 r467  
    856856
    857857        //アプリケーション名をセット
    858         extern char OutputFileName[MAX_PATH];
    859858        char szAppliName[MAX_PATH];
    860         _splitpath(OutputFileName,NULL,NULL,szAppliName,temp2);
     859        _splitpath( program.GetOutputFilePath().c_str(),NULL,NULL,szAppliName,temp2);
    861860        lstrcat(szAppliName,temp2);
    862861        temporary=PermutationString(temporary,"#APPLI_FILE_NAME#",szAppliName);
  • trunk/ab5.0/abdev/BasicCompiler_Common/VarList.cpp

    r461 r467  
    12731273            hDebugWnd=0;
    12741274
    1275             extern BOOL bClipCompileView;
    1276             if(bClipCompileView){
     1275            if( program.IsClipCompileView() ){
    12771276                extern HWND hOwnerEditor;
    12781277                SendMessage(hOwnerEditor,WM_DESTROYDEBUGGERVIEW,0,0);
  • trunk/ab5.0/abdev/BasicCompiler_Common/calculation.cpp

    r465 r467  
    10821082                else if((value[i2]=='+'||value[i2]=='-')&&sw1==1&&sw2==0) sw2=1;
    10831083                else{
    1084                     extern BOOL bDebugRun;
    1085                     if(bDebugRun) return DEF_DOUBLE;
     1084                    if( debugger.IsRunning() )
     1085                    {
     1086                        return DEF_DOUBLE;
     1087                    }
    10861088
    10871089                    if( !isNotifyError )
     
    11281130    }
    11291131
    1130     extern BOOL bDebugRun;
    1131     if(bDebugRun) return DEF_DOUBLE;
     1132    if( debugger.IsRunning() )
     1133    {
     1134        return DEF_DOUBLE;
     1135    }
    11321136
    11331137    if( !isNotifyError )
  • trunk/ab5.0/abdev/BasicCompiler_Common/common.h

    r465 r467  
    276276void AddSourceCode(const char *buffer);
    277277void OutputExe(void);
    278 int MainThread(DWORD dummy);
     278void MainThread(void *dummy);
    279279
    280280//Intermediate_Step1.cpp
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Program.h

    r215 r467  
    55class Program
    66{
     7    std::string sourceFilePath;
     8    std::string outputFilePath;
     9
     10    bool isKickedFromEditor;
     11    bool isDebugRun;
     12    bool isAttach;
     13    DWORD attachProcessId;
     14    bool isClipCompileView;
     15    std::string includeDir;
     16
    717public:
    818    static Jenga::Common::Logger logger;
     19
     20    Program()
     21        : isKickedFromEditor( false )
     22        , isDebugRun( false )
     23        , isAttach( false )
     24        , attachProcessId( 0 )
     25        , isClipCompileView( false )
     26    {
     27    }
     28
     29    bool AnalysisCommandLines();
     30
     31    const std::string &GetSourceFilePath() const
     32    {
     33        return sourceFilePath;
     34    }
     35    void SetSourceFilePath( const std::string &sourceFilePath )
     36    {
     37        this->sourceFilePath = sourceFilePath;
     38    }
     39    const std::string &GetOutputFilePath() const
     40    {
     41        return outputFilePath;
     42    }
     43    void SetOutputFilePath( const std::string &outputFilePath )
     44    {
     45        this->outputFilePath = outputFilePath;
     46    }
     47
     48    bool IsKickedFromEditor() const
     49    {
     50        return isKickedFromEditor;
     51    }
     52
     53    bool IsDebugRun() const
     54    {
     55        return isDebugRun;
     56    }
     57
     58    bool IsAttach() const
     59    {
     60        return isAttach;
     61    }
     62
     63    DWORD GetAttachProcessId() const
     64    {
     65        return attachProcessId;
     66    }
     67
     68    bool IsClipCompileView() const
     69    {
     70        return isClipCompileView;
     71    }
     72
     73    const std::string &GetIncludeDir() const
     74    {
     75        return includeDir;
     76    }
     77    void SetIncludeDir( const std::string &includeDir )
     78    {
     79        this->includeDir = includeDir;
     80    }
    981};
     82
     83extern Program program;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Program.cpp

    r206 r467  
    11#include "stdafx.h"
     2
     3#include <shlwapi.h>
    24
    35#include <jenga/include/common/Environment.h>
     
    68
    79Jenga::Common::Logger Program::logger( Jenga::Common::Environment::GetAppDir() + "\\logger.log", true );
     10
     11Program program;
     12
     13bool Program::AnalysisCommandLines()
     14{
     15    // コマンドラインを解析
     16    const Jenga::Common::CmdLines cmdLines( PathGetArgs( GetCommandLine() ) );
     17    int cmdLineIndex = 0;
     18
     19    if( cmdLines.size() == 0 )
     20    {
     21        // 何も指定されていないとき
     22        return true;
     23    }
     24
     25    if( cmdLines[cmdLineIndex].IsNamelessCommand() )
     26    {
     27        // 先頭に無名コマンドがきた場合、ソースファイル名として認識する
     28        Program::SetSourceFilePath( cmdLines[cmdLineIndex].GetParameter() );
     29
     30        cmdLineIndex ++;
     31
     32        if( cmdLines.size() == 1 )
     33        {
     34            // ソースファイル名のみの指定だったとき
     35            return true;
     36        }
     37
     38        // 出力ファイル名を取得
     39        if( cmdLines[cmdLineIndex].IsNamelessCommand() )
     40        {
     41            // 二番目にも無名コマンドがきた場合、ソースファイル名として認識する
     42            SetOutputFilePath( cmdLines[cmdLineIndex].GetParameter() );
     43
     44            cmdLineIndex ++;
     45        }
     46    }
     47
     48    for( ; cmdLineIndex < static_cast<int>(cmdLines.size()); cmdLineIndex++ )
     49    {
     50        const Jenga::Common::CmdLine &cmdLine = cmdLines[cmdLineIndex];
     51
     52        if( cmdLine.GetCommand() == "wnd" )
     53        {
     54            // 親エディタのウィンドウ ハンドル
     55            isKickedFromEditor = true;
     56            sscanf( cmdLine.GetParameter().c_str(), "%08x", &hOwnerEditor );
     57        }
     58        else if( cmdLine.GetCommand() == "debug" )
     59        {
     60            // デバッグ ビルド
     61            compiler.SetDebugMark( true );
     62        }
     63        else if( cmdLine.GetCommand() == "run" )
     64        {
     65            // デバッグ実行
     66            isDebugRun = true;
     67        }
     68        else if( cmdLine.GetCommand() == "attach" )
     69        {
     70            // アタッチ
     71            isDebugRun = true;
     72            isAttach = true;
     73            sscanf( cmdLine.GetParameter().c_str(), "%08x", &attachProcessId );
     74        }
     75        else if( cmdLine.GetCommand() == "dll" )
     76        {
     77            // DLLとしてビルド
     78            compiler.SetTargetModuleType( Compiler::Dll );
     79        }
     80        else if( cmdLine.GetCommand() == "static_library" )
     81        {
     82            // 静的リンクライブラリとしてビルド
     83            compiler.SetTargetModuleType( Compiler::StaticLibrary );
     84        }
     85        else if( cmdLine.GetCommand() == "unicode" )
     86        {
     87            // Unicode
     88            compiler.SetUnicodeMark( true );
     89            typeOfPtrChar = MAKE_PTR_TYPE(DEF_WORD,1);
     90            typeOfPtrUChar = MAKE_PTR_TYPE(DEF_WORD,1);
     91        }
     92        else if( cmdLine.GetCommand() == "clip_compile_view" )
     93        {
     94            //埋め込み型コンパイラビュー
     95            isClipCompileView = true;
     96        }
     97        else if( cmdLine.GetCommand() == "include_dir" )
     98        {
     99            //インクルード ディレクトリ
     100            includeDir = cmdLine.GetParameter();
     101        }
     102        else
     103        {
     104            // 不正なコマンド
     105            std::string keyword = cmdLine.GetCommand();
     106            if( keyword.size() == 0 )
     107            {
     108                keyword = cmdLine.GetParameter();
     109            }
     110            std::cout << keyword << " コマンドとして認識できません。" << std::endl;
     111            return false;
     112        }
     113    }
     114
     115    return true;
     116}
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Source.cpp

    r465 r467  
    556556void BasicSource::DirectiveIncludeOrRequire(){
    557557    extern HANDLE hHeap;
    558     extern char szIncludeDir[MAX_PATH];
    559558    extern char BasicCurDir[MAX_PATH];
    560559    int i,i2,i3,sw1,LineNum,FileLayer[255],layer,LastFileByte[255];
     
    572571
    573572    // メインソースコード
    574     extern char SourceFileName[MAX_PATH];
    575     FileLayer[layer] = includedFilesRelation.AddFile( SourceFileName );
     573    FileLayer[layer] = includedFilesRelation.AddFile( program.GetSourceFilePath() );
    576574
    577575    //参照ディレクトリ
     
    616614
    617615                    if(sw1){
    618                         sprintf(temp2,"%s%s",szIncludeDir,temporary);
     616                        sprintf(temp2,"%s%s", program.GetIncludeDir().c_str(), temporary );
    619617                        lstrcpy(temporary,temp2);
    620618                    }
     
    626624            else if(memcmp(buffer+i+1,"prompt",6)==0){
    627625                i2=i+7;
    628                 sprintf(temporary,"%sbasic\\prompt.sbp",szIncludeDir);
     626                sprintf(temporary,"%sbasic\\prompt.sbp", program.GetIncludeDir().c_str() );
    629627            }
    630628            else if(memcmp(buffer+i+1,"N88BASIC",8)==0){
    631629                i2=i+9;
    632                 sprintf(temporary,"%sbasic\\prompt.sbp",szIncludeDir);
     630                sprintf(temporary,"%sbasic\\prompt.sbp", program.GetIncludeDir().c_str() );
    633631            }
    634632            else if(memcmp(buffer+i+1,"console",7)==0){
     
    638636
    639637                i2=i+8;
    640                 sprintf(temporary,"%sbasic\\dos_console.sbp",szIncludeDir);
     638                sprintf(temporary,"%sbasic\\dos_console.sbp", program.GetIncludeDir().c_str() );
    641639            }
    642640            else continue;
  • trunk/ab5.0/jenga/include/common/Path.h

    r314 r467  
    6262        return fullPath;
    6363    }
     64
     65    static std::string MakeFullPath( const std::string &relativePath, const std::string &baseDirPath );
    6466};
    6567
  • trunk/ab5.0/jenga/src/common/Path.cpp

    r314 r467  
    2222    return false;
    2323}
     24
     25std::string Jenga::Common::Path::MakeFullPath( const std::string &relativePath, const std::string &baseDirPath )
     26{
     27    int i,i2,i3,i4;
     28    char temporary[MAX_PATH];
     29
     30    char resultPath[MAX_PATH];
     31    lstrcpy( resultPath, relativePath.c_str() );
     32
     33    // '/'→'\'
     34    for( i=0;resultPath[i];i++ ){
     35        if( resultPath[i] == '/' ){
     36            resultPath[i]='\\';
     37        }
     38    }
     39
     40    if(strstr(resultPath,":")||strstr(resultPath,"\\\\")) return resultPath;
     41
     42    i=0;i2=0;
     43    while(1){
     44        if(resultPath[i]=='.'&&resultPath[i+1]=='\\') i+=2;
     45        if(resultPath[i]=='.'&&resultPath[i+1]=='.'&&resultPath[i+2]=='\\'){
     46            i2++;
     47            i+=3;
     48        }
     49        else break;
     50    }
     51
     52    i3=(int)baseDirPath.size();i4=0;
     53    while(i4<i2){
     54        for(i3--;;i3--){
     55            if(baseDirPath[i3-1]=='\\'){
     56                i4++;
     57                break;
     58            }
     59        }
     60    }
     61    memcpy(temporary,baseDirPath.c_str(),i3);
     62    temporary[i3]=0;
     63    lstrcat(temporary,resultPath+i);
     64    lstrcpy(resultPath,temporary);
     65
     66    return resultPath;
     67}
Note: See TracChangeset for help on using the changeset viewer.