@@ -62,6 +62,13 @@ Dump::go (AST::Item &item)
item.accept_vis (*this);
}
+template <typename T>
+void
+Dump::visit (std::unique_ptr<T> &node)
+{
+ node->accept_vis (*this);
+}
+
void
Dump::format_function_param (FunctionParam ¶m)
{
@@ -72,6 +72,14 @@ private:
std::ostream &stream;
Indent indentation;
+ /**
+ * Compatibility layer for using the visitor pattern on polymorphic classes
+ * with a unified overload syntax. This allows us to call `visit` both on
+ * types implementing `accept_vis` method and for classes for which the
+ * `visit` method is directly implemented.
+ */
+ template <typename T> void visit (std::unique_ptr<T> &node);
+
/**
* Format together common items of functions: Parameters, return type, block
*/