cg_name CgDtorStatic( // DTOR STATIC OBJECT SYMBOL sym ) // - object symbol { STAB_CTL sctl; // - state-table instance STAB_DEFN dctl; // - state-table definition RT_DEF def; // - control for run-time call SE* se; // - state entry segment_id old_seg; // - old segment StabCtlInit( &sctl, &dctl ); StabDefnInit( &dctl, DTRG_STATIC_INITLS ); #ifndef NDEBUG if( PragDbgToggle.dump_stab ) { printf( "State Table for static object: %p\n", &dctl.state_table ); } #endif sctl.rw = CgVarRw( CgbkInfo.size_rw_base + CgbkInfo.size_data_ptr, SC_STATIC ); dctl.ro = CgVarRo( 1, SC_STATIC, NULL ); se = SeAlloc( DTC_SYM_STATIC ); se->base.gen = true; se->sym_static.sym = sym; se->sym_static.dtor = RoDtorFind( sym ); se = StateTableAdd( se, &sctl ); StabGenerate( &sctl ); old_seg = DgSetSegSym( sctl.rw ); CgBackGenLabelInternal( sctl.rw ); DgInitBytes( CgbkInfo.size_data_ptr, 0 ); DgPtrSymData( dctl.ro ); DgOffset( 1 ); DgPtrSymData( sym ); BESetSeg( old_seg ); CgRtCallInit( &def, RTF_REG_LCL ); CgRtParamAddrSym( &def, sctl.rw ); return( CgRtCallExec( &def ) ); }
static SYMBOL cgStateTableCmd( // GENERATE A STATE-TABLE ENTRY FOR A CMD SYMBOL sym, // - symbol referenced or NULL unsigned offset ) // - offset from symbol { DgPtrSymCode( NULL ); if( sym == NULL ) { DgPtrSymData( sym ); } else { DgPtrSymOff( sym, offset ); } return sym; }
bool StabGenerate( // GENERATE A STATE TABLE STAB_CTL* sctl ) // - state-table information { STAB_DEFN* defn; // - state-table definition SE* se; // - current state entry SE* state_table; // - the state table segment_id old_seg; // - old segment if( sctl->rw == NULL ) return FALSE; defn = sctl->defn; old_seg = DgSetSegSym( defn->ro ); CgBackGenLabelInternal( defn->ro ); DgOffset( defn->kind ); #if _CPU == _AXP if( defn->kind == DTRG_FUN ) { DgOffset( - CgOffsetRw( 0 ) ); } #endif state_table = defn->state_table; RingIterBeg( state_table, se ) { if( se->base.gen ) { switch( se->base.se_type ) { case DTC_SYM_AUTO : DbgVerify( UNDEF_AREL != se->sym_auto.offset, "cgStateTable -- no offset for SYM_AUTO" ); DgPtrSymCode( se->sym_auto.dtor ); DgOffset( CgOffsetRw( se->sym_auto.offset ) ); padOffsetToPtrSize(); break; case DTC_SYM_STATIC : DgPtrSymCode( se->sym_static.dtor ); DgPtrSymData( se->sym_static.sym ); break; case DTC_TEST_FLAG : cgStateTableCmd( CgCmdTestFlag( se ), 0 ); break; case DTC_TRY : se->try_blk.sym = cgStateTableCmd( CgCmdTry( se ), 0 ); break; case DTC_CATCH : cgStateTableCmd( se->catch_blk.try_blk->try_blk.sym, sizeof( DTOR_CMD_CODE ) ); break; case DTC_FN_EXC : cgStateTableCmd( CgCmdFnExc( se ), 0 ); break; case DTC_SET_SV : if( se != state_table ) { cgStateTableCmd( CgCmdSetSv( se ), 0 ); } break; case DTC_ACTUAL_DBASE : case DTC_ACTUAL_VBASE : case DTC_COMP_VBASE : case DTC_COMP_DBASE : case DTC_COMP_MEMB : cgStateTableCmd( CgCmdComponent( se ), 0 ); break; case DTC_ARRAY_INIT : cgStateTableCmd( CgCmdArrayInit( se ), 0 ); break; case DTC_DLT_1 : cgStateTableCmd( CgCmdDlt1( se ), 0 ); break; case DTC_DLT_2 : cgStateTableCmd( CgCmdDlt2( se ), 0 ); break; case DTC_DLT_1_ARRAY : cgStateTableCmd( CgCmdDlt1Array( se ), 0 ); break; case DTC_DLT_2_ARRAY : cgStateTableCmd( CgCmdDlt2Array( se ), 0 ); break; case DTC_CTOR_TEST : cgStateTableCmd( CgCmdCtorTest( se ), 0 ); break; DbgDefault( "cgStateTable -- impossible" ); } } } RingIterEnd( se ) #if !defined( NDEBUG ) || !defined( _INTEL_CPU ) DgPtrSymCode( NULL ); DgPtrSymData( NULL ); #endif BESetSeg( old_seg ); StabDefnFreeStateTable( defn ); return TRUE; }