* */
| 57 | * |
| 58 | */ |
| 59 | StatementBreak * |
| 60 | StatementBreak::make_random(CGContext &cg_context) |
| 61 | { |
| 62 | // quick fix: don't generate break statement for nested loops (this including multi-dimension array operations) |
| 63 | // JYTODO: treat "break" for nested loops as "continue", because it's effect is going back to the |
| 64 | // head of loop body, same as continue |
| 65 | //if (cg_context.focus_var && cg_context.focus_var->get_dimension() > 1) { |
| 66 | // return 0; |
| 67 | //} |
| 68 | //FactMgr* fm = get_fact_mgr(&cg_context); |
| 69 | // find the closest looping parent block: the one "continue" |
| 70 | // would apply to |
| 71 | Block* b = cg_context.get_current_block(); |
| 72 | while (b && !b->looping) { |
| 73 | b = b->parent; |
| 74 | } |
| 75 | assert(b); |
| 76 | cg_context.get_effect_stm().clear(); |
| 77 | Expression *expr = Expression::make_random(cg_context, get_int_type(), 0, true, true, eVariable); |
| 78 | ERROR_GUARD(NULL); |
| 79 | StatementBreak* sc = new StatementBreak(cg_context.get_current_block(), *expr, *b); |
| 80 | b->break_stms.push_back(sc); |
| 81 | return sc; |
| 82 | } |
| 83 | |
| 84 | /* |
| 85 | * |
nothing calls this directly
no test coverage detected