Exemplo n.º 1
0
static THROW_RO *throwRoGet(    // GET THROW R/O BLOCK
    TYPE type )                 // - type being thrown
{
    THROW_RO *srch;             // - search R/O block for symbol
    THROW_RO *ro;               // - R/O block for symbol
    SYMBOL sym;                 // - symbol for throw object
    THROW_CNV_CTL ctl;          // - control area
    target_offset_t offset;     // - offset ( not used )

    type = TypeCanonicalThr( type );
    ro = NULL;
    RingIterBeg( ring_throw_ro, srch ) {
        if( TypesIdentical( srch->sig->type, type ) ) {
            ro = srch;
            break;
        }
    } RingIterEnd( srch );
    if( ro == NULL ) {
        ro = RingCarveAlloc( carveTHROW_RO, &ring_throw_ro );
        ro->sig = BeTypeSignature( type );
        ro->emitted = false;
        sym = CgVarRo( CgbkInfo.size_offset + sizeOfThrowCnv() * ThrowCnvInit( &ctl, type ),
                     SC_PUBLIC, CppNameThrowRo( type ) );
        ro->sym = sym;
        for( ; ; ) {
            type = ThrowCnvType( &ctl, &offset );
            if( type == NULL )
                break;
            BeTypeSignature( type );
        }
        ThrowCnvFini( &ctl );
    }
    return( ro );
}
Exemplo n.º 2
0
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 ) );
}