예제 #1
0
void CgCallBackNewCtored(       // NEW OBJECT WAS CTOR'ED
    SE* se_del,                 // - state entry for delete during CTOR throw
    FN_CTL* fctl )              // - function information
{
    cg_name expr;               // - emitted expression
    patch_entry* pe;            // - entry when patching
    cg_type type;               // - not used

    CondInfoNewCtorBeg( fctl );
    expr = CgExprPopType( &type );
    CgCommaBefore( expr, type );
    pe = CarveAlloc( carve_patch_se );
    pe->se = se_del;
    expr = CgExprPopType( &type );
    expr = CgCallBackLeft( expr
                         , &callBackNewCtorBeg
                         , pe
                         , type );
    expr = CgComma( emitPatch( &pe->patch ), expr, type );
    CgExprPush( expr, type );
    CondInfoNewCtorEnd( fctl );
    expr = CgExprPopType( &type );
    CgCommaOptional( expr, type );
    pe = CarveAlloc( carve_patch_se );
    pe->se = se_del;
    expr = CgExprPopType( &type );
    expr = CgSideEffect( expr, emitPatch( &pe->patch ), type );
    expr = CgCallBackRight( expr
                          , &callBackNewCtorEnd
                          , pe
                          , type );
    CgExprPush( expr, type );
}
예제 #2
0
cg_name CgExprPop(              // POP CG EXPRESSION
    void )
{
    cg_type not_used;

    return CgExprPopType( &not_used );
}
예제 #3
0
void CgExprAttr(                // SET CONST/VOLATILE/etc. ATTRIBUTES FOR EXPR
    cg_sym_attr attr )          // - attribute
{
    cg_type type;                   // - expression type
    cg_name expr;                   // - top expression

    expr = CgExprPopType( &type );
    expr = CGAttr( expr, attr );
    CgExprPush( expr, type );
}
예제 #4
0
label_handle CgSwitchBeg        // GENERATE CODE FOR START OF SWITCH STMT
    ( FN_CTL* fctl )            // - function control
{
    SW_CTL *ctl;                // - control for switch
    cg_name sw_expr;            // - switch expression
    cg_type sw_type;            // - switch type

    sw_expr = CgExprPopType( &sw_type );
    CgExprDtored( sw_expr, sw_type, DGRP_TEMPS, fctl );
    sw_expr = CgExprPopType( &sw_type );
    ctl = VstkPush( &stack_switches );
    ctl->id = CGSelInit();
    ctl->cases = 0;
    ctl->temp = CGTemp( sw_type );
    ctl->type = sw_type;
    ctl->label = BENewLabel();
    CgAssign( CGTempName( ctl->temp, sw_type ), sw_expr, sw_type );
    return ctl->label;
}
예제 #5
0
// when expr is non-null, top of stack is replaced by:
//
//                      COMMA
//                       | |
//             +---------+ +-------+
//             |                   |
//           COMMA               temp
//            | |
//       +----+ +----+
//       |           |
//    ASSIGN        expr
//      | |
//    +-+ +-+
//    |     |
//  temp   top
//
void CgCommaOptional(           // EMIT OPTIONAL COMMA'ED EXPRESSION
    cg_name expr,               // - expression or NULL
    cg_type type )              // - type of expression
{
    cg_name orig;               // - original expression
    cg_type orig_type;          // - original expression type

    if( expr != NULL ) {
        if( ! CgExprPopGarbage() ) {
            orig = CgExprPopType( &orig_type );
            expr = CgSideEffect( orig, expr, type );
        }
        CgExprPush( expr, type );
    }
}
예제 #6
0
void CgCommaBefore(             // EMIT COMMA'ED EXPRESSION BEFORE
    cg_name expr,               // - expression
    cg_type type )              // - type of above expression
{
    cg_name top_expr;           // - expression on top
    cg_type top_type;           // - type on top

    top_expr = CgExprPopType( &top_type );
    if( top_expr == NULL ) {
        if( expr != NULL ) {
            CgDone( expr, type );
        }
    } else {
        CgExprPush( CgComma( expr, top_expr, top_type ), top_type );
    }
}
예제 #7
0
static void condInfoCallBack(   // SET A CALL-BACK
    void (*rtn)( void* ),       // - call-back routine
    bool on_left )              // - true ==> call-back on left
{
    cg_name expr;               // - top expression
    cg_type type;               // - top type
    COND_STK* stk;              // - stack ptr

    stk = PstkTopElement( &stack_cond_blks );
    expr = CgExprPopType( &type );
    if( on_left ) {
        expr = CgCallBackLeft( expr, rtn, stk, type );
    } else {
        expr = CgCallBackRight( expr, rtn, stk, type );
    }
    CgExprPush( expr, type );
}
예제 #8
0
SE* DtorForDelBeg(              // DTORING AREA TO BE DELETED: start
    FN_CTL* fctl,               // - function information
    target_size_t elem_size,    // - size of one element in area
    unsigned dlt1,              // - entry type when one arg
    unsigned dlt2,              // - entry type when two args
    SYMBOL op_del )             // - operator delete to be used
{
    SE* se_dlt;                 // - entry allocated
    SYMBOL var;                 // - var containing address of delete area
    cg_name top_expr;           // - top expression
    cg_type top_type;           // - type of top expression
    cg_name emit;               // - expression for state update
    patch_handle patch;         // - patch handle for area

    if( DtmTabular( fctl ) ) {
        if( 2 == SymFuncArgList( op_del )->num_args ) {
            se_dlt = SeAlloc( dlt2 );
            se_dlt->del_2_array.size = elem_size;
        } else {
            se_dlt = SeAlloc( dlt1 );
        }
        se_dlt->del_1_array.op_del = op_del;
        var = CgVarRw( TY_POINTER, SC_AUTO );
        if( se_dlt->base.gen ) {
            AutoRelRegister( var, &se_dlt->del_1_array.offset );
        }
        top_expr = CgExprPopType( &top_type );
        top_expr = CGLVAssign( CgSymbol( var ), top_expr, top_type );
        top_expr = CgFetchType( top_expr, top_type );
        emit = emitPatch( &patch );
        top_expr = emitPatchCallBack( top_expr
                                    , emit
                                    , top_type
                                    , &patchForDtorDelBeg
                                    , patch
                                    , se_dlt );
        CgExprPush( top_expr, top_type );
        DbgSetState( "patchForDtorDelBeg", se_dlt );
    } else {
        se_dlt = NULL;
    }
    return se_dlt;
}
예제 #9
0
void DtorForDelEnd(             // DTORING AREA TO BE DELETED: end
    FN_CTL* fctl,               // - function information
    SE* se_dlt )                // - entry
{
    cg_name emit;               // - expression for state update
    patch_handle patch;         // - patch handle for area
    cg_name top_expr;           // - top expression
    cg_type top_type;           // - type of top expression

    if( DtmTabular( fctl ) ) {
        DbgVerify( se_dlt != NULL, "DtorForDelEnd -- NULL entry" );
        emit = emitPatch( &patch );
        top_expr = CgExprPopType( &top_type );
        top_expr = emitPatchCallBack( top_expr
                                    , emit
                                    , top_type
                                    , &patchForDtorDelEnd
                                    , patch
                                    , se_dlt );
        CgExprPush( top_expr, top_type );
    }
}