Changeset 95 in dev for BasicCompiler32/Compile_Var.cpp


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

RegisterGlobalRootsの自動生成に対応

File:
1 edited

Legend:

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