| 1097 | } |
| 1098 | |
| 1099 | void |
| 1100 | Reducer::config_binary_reduction(string cmd) |
| 1101 | { |
| 1102 | if (cmd.find(":") == string::npos) { |
| 1103 | // the reducer treats func_1 as main |
| 1104 | reduce_binaries = (cmd == "all"); |
| 1105 | } |
| 1106 | else { |
| 1107 | size_t i; |
| 1108 | // for rollback, ignore this reduction if ends with a '-', keep vars as used_vars if ends with '+' |
| 1109 | char last = cmd[cmd.length()-1]; |
| 1110 | if (last == '-') return; |
| 1111 | if (last == '+') { |
| 1112 | cmd = cmd.substr(0, cmd.length()-1); |
| 1113 | } |
| 1114 | vector<int> ints; |
| 1115 | StringUtils::split_int_string(cmd, ints, "[:]"); |
| 1116 | assert(ints.size() >= 2); |
| 1117 | const Statement* stm = find_stm_by_id(ints[0]); |
| 1118 | assert(stm); |
| 1119 | ints.erase(ints.begin()); |
| 1120 | // must be pairs of "<exp_id>:<choice>" where choice is 1 (select left) or 2 (select right) |
| 1121 | assert(ints.size() % 2 == 0); |
| 1122 | |
| 1123 | for (i = 0; i < ints.size(); i += 2) { |
| 1124 | // special case: reduce if (...) to if (1) |
| 1125 | if (ints[i] == 0) { |
| 1126 | assert(ints[i+1] == -1); |
| 1127 | assert(stm->eType == eIfElse); |
| 1128 | const FunctionInvocation* fi = stm->get_direct_invocation(); |
| 1129 | assert(fi); |
| 1130 | map_reduced_invocations[fi] = new Constant(&fi->get_type(), "1"); |
| 1131 | break; |
| 1132 | } |
| 1133 | const FunctionInvocation* fi = find_invoke_by_eid(stm, ints[i]); |
| 1134 | assert(fi && fi->invoke_type == eBinaryPrim); |
| 1135 | int choice = ints[i+1] - 1; |
| 1136 | assert(choice == 0 || choice == 1); |
| 1137 | const Expression* op = fi->param_value[choice]; |
| 1138 | if (last == '+') { |
| 1139 | must_use_var_invocations.push_back(fi); |
| 1140 | } |
| 1141 | map_reduced_invocations[fi] = op; |
| 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | void |
| 1147 | Reducer::config_if_reduction(string cmd) |
nothing calls this directly
no test coverage detected