Changeset 95 in dev


Ignore:
Timestamp:
Apr 15, 2007, 1:34:02 AM (17 years ago)
Author:
dai_9181
Message:

RegisterGlobalRootsの自動生成に対応

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/Compile_ProcOp.cpp

    r94 r95  
    214214
    215215            pobj_DBClass->Compile_System_InitializeUserTypes();
     216    }
     217    else if( userProc.GetName() == "RegisterGlobalRoots"
     218        && userProc.HasParentClass()
     219        && (string)userProc.GetParentClass().name == "_System_CGarbageCollection" ){
     220
     221            Compile_AddGlobalRootsForGc();
    216222    }
    217223    else{
  • BasicCompiler32/Compile_Var.cpp

    r89 r95  
    13181318    }
    13191319}
     1320
     1321bool Compile_AddGlobalRootsForGc(){
     1322    UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );
     1323    if( !pUserProc_AddGlobalRootPtr ){
     1324        SetError(3, "_System_CGarbageCollection.AddGlobalRootPtr", -1 );
     1325        return false;
     1326    }
     1327
     1328    BOOST_FOREACH( const Variable *pVar, globalVars ){
     1329        if( pVar->IsObject() || pVar->IsPointer() || pVar->IsStruct() ){
     1330            // オブジェクトまたはポインタだったとき
     1331            // ※構造体も含む(暫定対応)
     1332
     1333            // 変数領域に要するLONG_PTR単位の個数を引き渡す
     1334            op_push_V( pVar->GetMemorySize()/PTR_SIZE );
     1335
     1336
     1337            /////////////////////////////
     1338            // ルートポインタを引き渡す
     1339
     1340            //mov eax,offset
     1341            op_mov_RV(REG_EAX,(int)pVar->offset);
     1342            obp-=sizeof(long);
     1343            pobj_GlobalVarSchedule->add();
     1344            obp+=sizeof(long);
     1345
     1346            //push eax
     1347            op_push( REG_EAX );
     1348
     1349            //
     1350            /////////////////////////////
     1351
     1352
     1353            /////////////////////////////
     1354            // Thisポインタを引き渡す
     1355
     1356            SetThisPtrToReg(REG_EAX);
     1357
     1358            //push eax
     1359            op_push( REG_EAX );
     1360
     1361            //
     1362            /////////////////////////////
     1363
     1364
     1365            // call AddGlobalRootPtr
     1366            op_call( pUserProc_AddGlobalRootPtr );
     1367
     1368            ReallocNativeCodeBuffer();
     1369        }
     1370    }
     1371
     1372    return true;
     1373}
  • BasicCompiler32/MakePeHdr.cpp

    r91 r95  
    88// 特殊関数の構造体ポインタ
    99////////////////////////////
     10
     11// グローバル関数、静的メソッド
    1012UserProc
    1113    *pSub_System_StartupProgram,
     
    3840   
    3941    *pSub_esp_error;
     42
     43// 動的メソッド
     44UserProc
     45    *pUserProc_System_CGarbageCollection_RegisterGlobalRoots;
    4046
    4147
     
    250256        pSubStaticMethod_System_TypeBase_InitializeUserTypes->Using();
    251257        pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIsAutoGenerationProc();
     258    }
     259
     260    if( pUserProc_System_CGarbageCollection_RegisterGlobalRoots = GetClassMethod( "_System_CGarbageCollection", "RegisterGlobalRoots" ) ){
     261        pUserProc_System_CGarbageCollection_RegisterGlobalRoots->Using();
     262        pUserProc_System_CGarbageCollection_RegisterGlobalRoots->ThisIsAutoGenerationProc();
    252263    }
    253264
  • BasicCompiler32/Opcode.h

    r79 r95  
    192192void dim( char *VarName,int *SubScripts,Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlags);
    193193void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
     194bool Compile_AddGlobalRootsForGc();
    194195
    195196//ParamImpl.cpp
  • BasicCompiler64/Compile_ProcOp.cpp

    r94 r95  
    205205
    206206            pobj_DBClass->Compile_System_InitializeUserTypes();
     207    }
     208    else if( userProc.GetName() == "RegisterGlobalRoots"
     209        && userProc.HasParentClass()
     210        && (string)userProc.GetParentClass().name == "_System_CGarbageCollection" ){
     211
     212            Compile_AddGlobalRootsForGc();
    207213    }
    208214    else{
  • BasicCompiler64/Compile_Var.cpp

    r89 r95  
    13141314    }
    13151315}
     1316
     1317bool Compile_AddGlobalRootsForGc(){
     1318    UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );
     1319    if( !pUserProc_AddGlobalRootPtr ){
     1320        SetError(3, "_System_CGarbageCollection.AddGlobalRootPtr", -1 );
     1321        return false;
     1322    }
     1323
     1324    BOOST_FOREACH( const Variable *pVar, globalVars ){
     1325        if( pVar->IsObject() || pVar->IsPointer() || pVar->IsStruct() ){
     1326            // オブジェクトまたはポインタだったとき
     1327            // ※構造体も含む(暫定対応)
     1328
     1329            // 変数領域に要するLONG_PTR単位の個数を引き渡す
     1330            //mov r8,count
     1331            op_mov_RV(sizeof(_int64), REG_R8,pVar->GetMemorySize()/PTR_SIZE);
     1332
     1333            // ルートポインタを引き渡す
     1334            //mov rdx,offset
     1335            op_mov_RV(sizeof(_int64), REG_RDX,(int)pVar->offset);
     1336            obp-=sizeof(long);
     1337            pobj_GlobalVarSchedule->add();
     1338            obp+=sizeof(long);
     1339
     1340            // Thisポインタを引き渡す
     1341            SetThisPtrToReg(REG_RCX);
     1342
     1343            // call AddGlobalRootPtr
     1344            op_call( pUserProc_AddGlobalRootPtr );
     1345
     1346            ReallocNativeCodeBuffer();
     1347        }
     1348    }
     1349
     1350    return true;
     1351}
  • BasicCompiler64/MakePeHdr.cpp

    r91 r95  
    66// 特殊関数の構造体ポインタ
    77////////////////////////////
     8
     9// グローバル関数、静的メソッド
    810UserProc
    911    *pSub_System_StartupProgram,
     
    2426    *pSub_System_GC_free_for_SweepingDelete,
    2527    *pSubStaticMethod_System_TypeBase_InitializeUserTypes;
     28
     29// 動的メソッド
     30UserProc
     31    *pUserProc_System_CGarbageCollection_RegisterGlobalRoots;
    2632
    2733
     
    231237        pSubStaticMethod_System_TypeBase_InitializeUserTypes->Using();
    232238        pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIsAutoGenerationProc();
     239    }
     240
     241    if( pUserProc_System_CGarbageCollection_RegisterGlobalRoots = GetClassMethod( "_System_CGarbageCollection", "RegisterGlobalRoots" ) ){
     242        pUserProc_System_CGarbageCollection_RegisterGlobalRoots->Using();
     243        pUserProc_System_CGarbageCollection_RegisterGlobalRoots->ThisIsAutoGenerationProc();
    233244    }
    234245
  • BasicCompiler64/Opcode.h

    r79 r95  
    325325void dim( char *VarName,int *SubScripts,Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlags);
    326326void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
     327bool Compile_AddGlobalRootsForGc();
    327328
    328329//ParamImpl.cpp
  • BasicCompiler_Common/common.h

    r94 r95  
    296296CONSTINFO *GetConstHash(char *name);
    297297DllProc *GetDeclareHash(char *name);
     298void GetOverloadSubHash( const char *lpszName, std::vector<UserProc *> &subs );
    298299UserProc *GetSubHash(const char *name,BOOL bError=0);
    299300UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
    300 void GetOverloadSubHash( const char *lpszName, std::vector<UserProc *> &subs );
     301UserProc *GetClassMethod( const char *className, const char *methodName );
    301302
    302303//Object.cpp
  • BasicCompiler_Common/hash.cpp

    r75 r95  
    184184    return pUserProc;
    185185}
     186
     187UserProc *GetClassMethod( const char *className, const char *methodName ){
     188    CClass *pClass = pobj_DBClass->check( className );
     189    if( pClass ){
     190        vector<UserProc *> userProcs;
     191        pClass->EnumMethod( methodName, userProcs );
     192        if( userProcs.size() == 1 ){
     193            return userProcs[0];
     194        }
     195    }
     196
     197    char temporary[VN_SIZE];
     198    sprintf( temporary, "%s.%s", className, methodName );
     199    SetError(3, temporary, -1 );
     200
     201    return NULL;
     202}
  • BasicCompiler_Common/include/Smoothie.h

    r92 r95  
    1414            log = "";
    1515
    16             ofstream ofs( ( (string)BasicSystemDir + "compile.log" ).c_str(), ios_base::trunc );
     16            ofstream ofs( ( (string)BasicSystemDir + "Log\\compile.log" ).c_str(), ios_base::trunc );
    1717            ofs.close();
    1818#endif
     
    2323
    2424            {
    25                 ofstream ofs( ( (string)BasicSystemDir + "compile.log" ).c_str(), ios_base::app );
     25                ofstream ofs( ( (string)BasicSystemDir + "Log\\compile.log" ).c_str(), ios_base::app );
    2626                ofs << text << endl;
    2727                ofs.close();
     
    3030        }
    3131        static void PutFile( const string &fileName, const string &buffer ){
    32             ofstream ofs( ( (string)BasicSystemDir + fileName ).c_str() );
     32            ofstream ofs( ( (string)BasicSystemDir + "Log\\" + fileName ).c_str() );
    3333            ofs << buffer << endl;
    3434            ofs.close();
Note: See TracChangeset for help on using the changeset viewer.