Example #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 );
}
Example #2
0
cg_name CgCallBackRight(        // MAKE A RIGHT CALL-BACK
    cg_name expr,               // - expression
    void (*fun)( void* ),       // - call-back function
    void* data,                 // - data for call back
    cg_type type )              // - type of expression
{
    return CgSideEffect( expr, CGCallback( fun, data ), type );
}
Example #3
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 );
    }
}
Example #4
0
static cg_name emitPatchCallBack( // EMIT CODE FOR CALL-BACK FOR STATE PATCH
    cg_name expr,               // - current expression
    cg_name emit,               // - code for state patch
    cg_type type,               // - type of current expression
    void (*rtn)(void*),         // - patch routine
    patch_handle patch,         // - handle for patching
    SE* se )                    // - state entry for patch
{
    patch_entry* pe;            // - entry when patching

    expr = CgSideEffect( expr, emit, type );
    pe = CarveAlloc( carve_patch_se );
    pe->se = se;
    pe->patch = patch;
    return CgCallBackRight( expr, rtn, pe, type );
}
Example #5
0
cg_name CgCallBackTempCtor(     // SET CALL BACKS FOR TEMP CTORED
    cg_name expr,               // - expression
    cg_type type,               // - type of expression
    SE* se )                    // - state entry to be inserted on call back
{
    temp_entry* te;             // - entry for ctored temporary
    cg_name emit;               // - emitted expression

    te = CarveAlloc( carve_temp_entry );
    te->se = se;
    te->patch = NULL;
    expr = CgCallBackLeft( expr, &setTempStart, te, type );
    emit = emitPatch( &te->patch );
    if( emit != NULL ) {
        expr = CgSideEffect( expr, emit, type );
    }
    expr = CgCallBackRight( expr, &setTempDone, te, type );
    return expr;
}