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

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

Location:
trunk/ab5.0/abdev/BasicCompiler_Common/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.