| 1235 | } |
| 1236 | |
| 1237 | std::unordered_map<instruction_ref, std::string> module::print( |
| 1238 | const std::function<void(instruction_ref, |
| 1239 | const std::unordered_map<instruction_ref, std::string>&)>& print_func, |
| 1240 | std::unordered_map<instruction_ref, std::string> names) const |
| 1241 | { |
| 1242 | const bool is_root = names.empty(); |
| 1243 | int count = 0; |
| 1244 | for(auto ins : iterator_for(*this)) |
| 1245 | { |
| 1246 | std::string var_name; |
| 1247 | if(not this->name().empty() and not is_root) |
| 1248 | var_name = this->name() + ":"; |
| 1249 | if(ins->name() == "@param") |
| 1250 | { |
| 1251 | var_name.append(any_cast<builtin::param>(ins->get_operator()).parameter); |
| 1252 | } |
| 1253 | else |
| 1254 | { |
| 1255 | var_name.append("@" + std::to_string(count)); |
| 1256 | } |
| 1257 | // count every instruction so index matches loc in the printout program |
| 1258 | count++; |
| 1259 | names.emplace(ins, var_name); |
| 1260 | |
| 1261 | print_func(ins, names); |
| 1262 | } |
| 1263 | return names; |
| 1264 | } |
| 1265 | |
| 1266 | void module::print(const std::function< |
| 1267 | void(instruction_ref, const std::unordered_map<instruction_ref, std::string>&)>& |