Changeset 91 in dev


Ignore:
Timestamp:
Apr 7, 2007, 10:07:26 PM (17 years ago)
Author:
dai_9181
Message:

ログ機構(Smoothie::Logger)を導入。
動的型情報生成において、未使用クラスの登録は行わないようにした。

Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/BasicCompiler.vcproj

    r89 r91  
    430430                        />
    431431                    </FileConfiguration>
     432                </File>
     433                <File
     434                    RelativePath="..\BasicCompiler_Common\Diagnose.cpp"
     435                    >
    432436                </File>
    433437                <File
  • BasicCompiler32/Compile_ProcOp.cpp

    r90 r91  
    220220}
    221221
    222 void CompileBufferInProcedure(UserProc *pUserProc){
     222void _compile_proc(UserProc *pUserProc){
    223223    extern char *basbuf;
    224224    extern HANDLE hHeap;
     
    842842    //ローカル変数のネーム情報は後に解放する
    843843}
     844
     845void CompileBufferInProcedure( UserProc &userProc ){
     846    if( userProc.IsUsing() == false || userProc.IsCompiled() ) return;
     847
     848    _compile_proc( &userProc );
     849
     850    // ログを履く
     851    char temporary[8192];
     852    temporary[0]=0;
     853    lstrcat( temporary, "------------------------------------------------------------------\n" );
     854    sprintf( temporary + lstrlen(temporary), "【 %s のコード情報】\n", userProc.GetFullName().c_str() );
     855    sprintf( temporary + lstrlen(temporary), "code size: %d bytes\n", userProc.GetCodeSize() );
     856    lstrcat( temporary, "------------------------------------------------------------------\n" );
     857    lstrcat( temporary, "\n" );
     858    Smoothie::Logger::Put( temporary );
     859}
    844860void CompileLocal(){
    845861    extern UserProc **ppSubHash;
     
    852868        pUserProc=GetSubHash("_System_InitDllGlobalVariables");
    853869        if(pUserProc){
    854             CompileBufferInProcedure(pUserProc);
     870            CompileBufferInProcedure( *pUserProc );
    855871        }
    856872        else SetError(300,NULL,cp);
     
    870886        pUserProc=ppSubHash[i2];
    871887        while(pUserProc){
    872             CompileBufferInProcedure(pUserProc);
     888            CompileBufferInProcedure( *pUserProc );
    873889            pUserProc=pUserProc->pNextData;
    874890        }
     
    889905    //_System_InitStaticLocalVariablesは一番最後にコンパイル
    890906    pSub_System_InitStaticLocalVariables->KillCompileStatus();
    891     CompileBufferInProcedure(pSub_System_InitStaticLocalVariables);
     907    CompileBufferInProcedure( *pSub_System_InitStaticLocalVariables );
    892908
    893909    //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル
    894910    pSub_System_Call_Destructor_of_GlobalObject->KillCompileStatus();
    895     CompileBufferInProcedure(pSub_System_Call_Destructor_of_GlobalObject);
     911    CompileBufferInProcedure( *pSub_System_Call_Destructor_of_GlobalObject );
    896912}
  • BasicCompiler32/MakePeHdr.cpp

    r90 r91  
    463463
    464464    StepCompileProgress();
     465
     466
     467
     468    ////////////////////////////////
     469    // ここで一旦ログを取る
     470    ////////////////////////////////
     471    Diagnose();
    465472
    466473
  • BasicCompiler64/BasicCompiler.vcproj

    r89 r91  
    12891289                </File>
    12901290                <File
     1291                    RelativePath="..\BasicCompiler_Common\Diagnose.cpp"
     1292                    >
     1293                </File>
     1294                <File
    12911295                    RelativePath="..\BasicCompiler_Common\error.cpp"
    12921296                    >
  • BasicCompiler64/Compile_ProcOp.cpp

    r90 r91  
    210210    }
    211211}
    212 void CompileBufferInProcedure(UserProc *pUserProc){
     212void _compile_proc(UserProc *pUserProc){
    213213    extern char *basbuf;
    214214    extern HANDLE hHeap;
     
    814814    HeapDefaultFree(SynonymErrorWords);
    815815}
     816
     817void CompileBufferInProcedure( UserProc &userProc ){
     818    if( userProc.IsUsing() == false || userProc.IsCompiled() ) return;
     819
     820    _compile_proc( &userProc );
     821
     822    // ログを履く
     823    char temporary[8192];
     824    temporary[0]=0;
     825    lstrcat( temporary, "------------------------------------------------------------------\n" );
     826    sprintf( temporary + lstrlen(temporary), "【 %s のコード情報】\n", userProc.GetFullName().c_str() );
     827    sprintf( temporary + lstrlen(temporary), "code size: %d bytes\n", userProc.GetCodeSize() );
     828    lstrcat( temporary, "------------------------------------------------------------------\n" );
     829    lstrcat( temporary, "\n" );
     830    Smoothie::Logger::Put( temporary );
     831}
    816832void CompileLocal(){
    817833    extern UserProc **ppSubHash;
     
    824840        pUserProc=GetSubHash("_System_InitDllGlobalVariables");
    825841        if(pUserProc){
    826             CompileBufferInProcedure(pUserProc);
     842            CompileBufferInProcedure( *pUserProc );
    827843        }
    828844        else SetError(300,NULL,cp);
     
    842858        pUserProc=ppSubHash[i2];
    843859        while(pUserProc){
    844             CompileBufferInProcedure(pUserProc);
     860            CompileBufferInProcedure( *pUserProc );
    845861            pUserProc=pUserProc->pNextData;
    846862        }
     
    861877    //_System_InitStaticLocalVariablesは一番最後にコンパイル
    862878    pSub_System_InitStaticLocalVariables->KillCompileStatus();
    863     CompileBufferInProcedure(pSub_System_InitStaticLocalVariables);
     879    CompileBufferInProcedure( *pSub_System_InitStaticLocalVariables );
    864880
    865881    //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル
    866882    pSub_System_Call_Destructor_of_GlobalObject->KillCompileStatus();
    867     CompileBufferInProcedure(pSub_System_Call_Destructor_of_GlobalObject);
     883    CompileBufferInProcedure( *pSub_System_Call_Destructor_of_GlobalObject );
    868884}
  • BasicCompiler64/MakePeHdr.cpp

    r90 r91  
    436436    //ネイティブコード生成はここまで
    437437    //////////////////////////////////////////////////////////
     438
     439
     440
     441    ////////////////////////////////
     442    // ここで一旦ログを取る
     443    ////////////////////////////////
     444    Diagnose();
    438445
    439446
  • BasicCompiler_Common/Class.cpp

    r90 r91  
    150150    DestructorMemberSubIndex( 0 ),
    151151    classType( Class ),
     152    isUsing( false ),
    152153    pobj_InheritsClass( NULL ),
    153154    ppobj_Member( NULL ),
     
    192193        delete method;
    193194    }
     195}
     196
     197bool CClass::IsUsing() const
     198{
     199    return isUsing;
     200}
     201void CClass::Using(){
     202    isUsing = true;
    194203}
    195204
     
    15091518
    15101519    while( Iterator_HasNext() ){
    1511         CClass *pClass = Iterator_GetNext();
     1520        const CClass &objClass = *Iterator_GetNext();
     1521
     1522        if( !objClass.IsUsing() ){
     1523            // 未使用のクラスは無視する
     1524            continue;
     1525        }
    15121526
    15131527        sprintf( temporary
     
    15161530            , ESC_NEW
    15171531            , ""                // 名前空間 (TODO: 実装)
    1518             , pClass->name      // クラス名
     1532            , objClass.name     // クラス名
    15191533            );
    15201534
     
    15431557
    15441558    while( Iterator_HasNext() ){
    1545         CClass *pClass = Iterator_GetNext();
    1546 
    1547         if( pClass->pobj_InheritsClass ){
     1559        const CClass &objClass = *Iterator_GetNext();
     1560
     1561        if( !objClass.IsUsing() ){
     1562            // 未使用のクラスは無視する
     1563            continue;
     1564        }
     1565
     1566        if( objClass.pobj_InheritsClass ){
    15481567            sprintf( temporary
    15491568                , "tempType=Search(\"%s\",\"%s\")"
    15501569                , ""                // 名前空間 (TODO: 実装)
    1551                 , pClass->name      // クラス名
     1570                , objClass.name     // クラス名
    15521571                );
    15531572
     
    15581577                , "tempType.SetBaseType(Search(\"%s\",\"%s\"))"
    15591578                , ""                                // 名前空間 (TODO: 実装)
    1560                 , pClass->pobj_InheritsClass->name  // 基底クラス名
     1579                , objClass.pobj_InheritsClass->name // 基底クラス名
    15611580                );
    15621581
     
    16191638    pCompilingClass = pUserProc->GetParentClassPtr();
    16201639    if( pCompilingClass ){
     1640        pCompilingClass->Using();
     1641
    16211642        pCompilingMethod = pCompilingClass->GetMethodInfo( pUserProc );
    16221643        if( !pCompilingMethod ){
  • BasicCompiler_Common/Class.h

    r90 r91  
    5959
    6060    //静的メンバ情報
    61     std::vector<CMember *>staticMembers;
     61    std::vector<CMember *> staticMembers;
    6262
    6363    //メソッド情報
     
    7979    ClassType classType;
    8080
     81    bool isUsing;
     82
    8183public:
    8284    //クラス名
     
    100102    CClass(const char *name);
    101103    ~CClass();
     104
     105    bool IsUsing() const;
     106    void Using();
    102107
    103108    bool IsClass() const;
     
    133138    void EnumMethod( const char *methodName, std::vector<UserProc *> &subs ) const;
    134139    void EnumMethod( const BYTE idOperatorCalc, std::vector<UserProc *> &subs ) const;
     140    const std::vector<CMethod *> &GetMethods() const
     141    {
     142        return methods;
     143    }
     144    const std::vector<CMethod *> &GetStaticMethods() const
     145    {
     146        return staticMethods;
     147    }
    135148
    136149    //デフォルト コンストラクタ メソッドを取得
  • BasicCompiler_Common/MakeExe.cpp

    r88 r91  
    5959    int i2,i3;
    6060    char temp2[MAX_PATH];
     61
     62    //ログ用バッファを初期化
     63    Smoothie::Logger::Initialize();
    6164
    6265    //プログレスバーの設定
  • BasicCompiler_Common/Procedure.h

    r90 r91  
    126126    }
    127127
     128    string GetFullName() const
     129    {
     130        if( HasParentClass() ){
     131            return (string)GetParentClass().name + "." + GetName();
     132        }
     133
     134        return GetName();
     135    }
     136
    128137    bool IsMacro() const
    129138    {
     
    211220    DWORD beginOpAddress;
    212221    DWORD endOpAddress;
     222    int GetCodeSize() const
     223    {
     224        return endOpAddress - beginOpAddress;
     225    }
    213226
    214227    // ローカル変数
  • BasicCompiler_Common/common.h

    r90 r91  
    502502void Compile(void);
    503503
     504//Diagnose.cpp
     505void Diagnose();
     506
    504507//gc.cpp
    505508void InitGCVariables(void);
  • BasicCompiler_Common/include/Smoothie.h

    r88 r91  
    66class Smoothie{
    77public:
     8
     9    class Logger{
     10        static string log;
     11    public:
     12        static void Initialize(){
     13#ifdef _DEBUG
     14            log = "";
     15
     16            ofstream ofs( ( (string)BasicSystemDir + "compile.log" ).c_str(), ios_base::trunc );
     17            ofs.close();
     18#endif
     19        }
     20        static void Put( const string &text ){
     21#ifdef _DEBUG
     22            log += text + "\r\n";
     23
     24            {
     25                ofstream ofs( ( (string)BasicSystemDir + "compile.log" ).c_str(), ios_base::app );
     26                ofs << text << endl;
     27                ofs.close();
     28            }
     29#endif
     30        }
     31    };
    832
    933    class Lexical{
  • BasicCompiler_Common/src/Smoothie.cpp

    r88 r91  
    11#include <..\common.h>
     2
     3string Smoothie::Logger::log = "";
    24
    35BasicSource Smoothie::Lexical::source;
Note: See TracChangeset for help on using the changeset viewer.