Changeset 330 for trunk/optimizer.c


Ignore:
Timestamp:
2006-12-16T13:10:15+01:00 (8 years ago)
Author:
moo
Message:

rebuild zend_try_catch_element

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/optimizer.c

    r326 r330  
    225225#endif 
    226226 
    227 #define bbs_get(bbs, n) ((bb_t *) xc_stack_get(bbs, n)) 
    228 #define bbs_count(bbs) xc_stack_count(bbs) 
     227static bb_t *bbs_get(bbs_t *bbs, int n) /* {{{ */ 
     228{ 
     229    return (bb_t *) xc_stack_get(bbs, n); 
     230} 
     231/* }}} */ 
     232static int bbs_count(bbs_t *bbs) /* {{{ */ 
     233{ 
     234    return xc_stack_count(bbs); 
     235} 
     236/* }}} */ 
    229237static void bbs_destroy(bbs_t *bbs) /* {{{ */ 
    230238{ 
     
    398406} 
    399407/* }}} */ 
    400 static void bbs_restore_opnum(bbs_t *bbs) /* {{{ */ 
     408static void bbs_restore_opnum(bbs_t *bbs, zend_op_array *op_array) /* {{{ */ 
    401409{ 
    402410    int i; 
     411    bbid_t lasttrybbid; 
     412 
    403413    for (i = 0; i < bbs_count(bbs); i ++) { 
    404414        op_flowinfo_t fi; 
     
    422432    } 
    423433 
    424     /* TODO: rebuild zend_try_catch_element here */ 
     434    lasttrybbid = BBID_INVALID; 
     435    op_array->last_try_catch = 0; 
     436    for (i = 0; i < bbs_count(bbs); i ++) { 
     437        bb_t *bb = bbs_get(bbs, i); 
     438 
     439        if (lasttrybbid != bb->catch) { 
     440            if (lasttrybbid != BBID_INVALID) { 
     441                int try_catch_offset = op_array->last_try_catch ++; 
     442 
     443                op_array->try_catch_array = erealloc(op_array->try_catch_array, sizeof(zend_try_catch_element) * op_array->last_try_catch); 
     444                op_array->try_catch_array[try_catch_offset].try_op = bbs_get(bbs, lasttrybbid)->opnum; 
     445                op_array->try_catch_array[try_catch_offset].catch_op = bbs_get(bbs, bb->id)->opnum; 
     446            } 
     447            lasttrybbid = bb->catch; 
     448        } 
     449    } 
     450    /* it is impossible to have last bb catched */ 
    425451} 
    426452/* }}} */ 
     
    456482                bb->opnum = bb->opcodes - op_array->opcodes; 
    457483            } 
    458             bbs_restore_opnum(&bbs); 
     484            bbs_restore_opnum(&bbs, op_array); 
    459485        } 
    460486        bbs_destroy(&bbs); 
Note: See TracChangeset for help on using the changeset viewer.