* XXX */
| 78 | * XXX |
| 79 | */ |
| 80 | FunctionInvocation * |
| 81 | FunctionInvocation::make_random(bool is_std_func, |
| 82 | CGContext &cg_context, |
| 83 | const Type* type, |
| 84 | const CVQualifiers* qfer) |
| 85 | { |
| 86 | FunctionInvocation *fi = 0; |
| 87 | // If we are looking for a program-defined function, try to find one. |
| 88 | if (!is_std_func) { |
| 89 | Function* callee = NULL; |
| 90 | if (pure_rnd_flipcoin(50)) { |
| 91 | callee = Function::choose_func(get_all_functions(), cg_context, type, qfer); |
| 92 | } |
| 93 | if (callee != NULL) { |
| 94 | FunctionInvocationUser *fiu = new FunctionInvocationUser(callee, true, NULL); |
| 95 | fiu->build_invocation(callee, cg_context); |
| 96 | fi = fiu; |
| 97 | if (!fiu->failed) { |
| 98 | cg_context.get_current_func()->fact_changed |= fiu->func->fact_changed; |
| 99 | } |
| 100 | } |
| 101 | else if (!Function::reach_max_functions_cnt()) { |
| 102 | fi = FunctionInvocationUser::build_invocation_and_function(cg_context, type, qfer); |
| 103 | } else { |
| 104 | // we can not find/create a function because we reach the limit, so give up |
| 105 | fi = new FunctionInvocationUser(NULL, false, NULL); |
| 106 | fi->failed = true; |
| 107 | return fi; |
| 108 | } |
| 109 | } |
| 110 | // now use standard functions, i.e., binary/unary operators to create an invocation |
| 111 | if (fi == NULL) { |
| 112 | int rnd_flag = rnd_flipcoin(StdUnaryFuncProb); |
| 113 | if (rnd_flag) { |
| 114 | fi = make_random_unary(cg_context, type); |
| 115 | } else { |
| 116 | fi = make_random_binary(cg_context, type); |
| 117 | } |
| 118 | } |
| 119 | assert(fi != 0); |
| 120 | return fi; |
| 121 | } |
| 122 | |
| 123 | /* |
| 124 | * TODO: FIX! This is a bogus constructor, used only by the `OutputMain'. |
nothing calls this directly
no test coverage detected