* */
| 69 | * |
| 70 | */ |
| 71 | Expression * |
| 72 | ExpressionFuncall::make_random(CGContext &cg_context, const Type* type, const CVQualifiers* qfer) |
| 73 | { |
| 74 | Expression *e = 0; |
| 75 | bool std_func = ExpressionFunctionProbability(cg_context); |
| 76 | ERROR_GUARD(NULL); |
| 77 | // unary/binary "functions" produce scalar types only |
| 78 | if (type && (type->eType != eSimple || type->simple_type == eVoid)) |
| 79 | std_func = false; |
| 80 | |
| 81 | Effect effect_accum = cg_context.get_accum_effect(); |
| 82 | Effect effect_stm = cg_context.get_effect_stm(); |
| 83 | FactMgr* fm = get_fact_mgr(&cg_context); |
| 84 | vector<const Fact*> facts_copy = fm->global_facts; |
| 85 | FunctionInvocation *fi = FunctionInvocation::make_random(std_func, cg_context, type, qfer); |
| 86 | ERROR_GUARD(NULL); |
| 87 | |
| 88 | if (fi->failed) { |
| 89 | // if it's a invalid invocation, (see FunctionInvocationUser::revisit) |
| 90 | // restore the env, and replace invocation with a simple var |
| 91 | cg_context.reset_effect_accum(effect_accum); |
| 92 | cg_context.reset_effect_stm(effect_stm); |
| 93 | fm->restore_facts(facts_copy); |
| 94 | e = ExpressionVariable::make_random(cg_context, type, qfer); |
| 95 | delete fi; |
| 96 | } |
| 97 | else { |
| 98 | e = new ExpressionFuncall(*fi); |
| 99 | } |
| 100 | return e; |
| 101 | } |
| 102 | |
| 103 | /* |
| 104 | * |
nothing calls this directly
no test coverage detected