return "unknown";
}
+template <typename T, typename FN>
void
-Dump::go ()
+print_comma_separated (std::ostream &stream, const std::vector<T> &collection,
+ FN printer)
{
- stream << "fn " << name << "(";
- for (PlaceId arg : func.arguments)
+ if (collection.empty ())
+ return;
+ printer (collection[0]);
+ for (auto it = collection.begin () + 1; it != collection.end (); ++it)
{
- stream << "_" << get_place_name (arg) << ": "
- << get_tyty_name (place_db[arg].tyty) << ", ";
+ stream << ", ";
+ printer (*it);
}
+}
+
+static constexpr bool FOLD_CFG = true;
+
+void
+Dump::go ()
+{
+ stream << "fn " << name << "(";
+ print_comma_separated (stream, func.arguments, [this] (PlaceId place_id) {
+ stream << "_" << get_place_name (place_id) << ": "
+ << get_tyty_name (place_db[place_id].tyty);
+ });
stream << ") -> " << get_tyty_name (place_db[RETURN_VALUE_PLACE].tyty)
<< " {\n";
Dump::visit (InitializerExpr &expr)
{
stream << "{";
- for (auto &place : expr.get_values ())
- {
- visit_move_place (place);
- stream << ", ";
- }
+ print_comma_separated (stream, expr.get_values (), [this] (PlaceId place_id) {
+ visit_move_place (place_id);
+ });
stream << "}";
}