From 72fbc7c3b9211138097b09e232d3b3918f0b3c4a Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Mon, 3 Feb 2020 12:46:26 +0100
Subject: [PATCH] Add DebugFrameworkPrinter

---
 .../framework_integration/printer.py                 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/pystencils_autodiff/framework_integration/printer.py b/src/pystencils_autodiff/framework_integration/printer.py
index 2b9a771..cf94e95 100644
--- a/src/pystencils_autodiff/framework_integration/printer.py
+++ b/src/pystencils_autodiff/framework_integration/printer.py
@@ -104,3 +104,15 @@ class FrameworkIntegrationPrinter(pystencils.backends.cbackend.CBackend):
 
     def _print_SwapBuffer(self, node):
         return f"""std::swap({node.first_array}, {node.second_array});"""
+
+
+class DebugFrameworkPrinter(FrameworkIntegrationPrinter):
+
+    def _print(self, node):
+        if isinstance(node, sp.Expr):
+            return self.sympy_printer._print(node)
+        elif isinstance(node, pystencils.astnodes.Node):
+            return super()._print(node) + f'/* {node.__class__.__name__} symbols_undefined: {node.undefined_symbols}, symbols_defined: {node.symbols_defined}, args {[a if isinstance(a,str) else a.__class__.__name__ for a in node.args]} */'  # noqa
+
+        else:
+            return super()._print(node)
-- 
GitLab