Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
GraphvizGenerator.cpp
Go to the documentation of this file.
1
20#include <boost/algorithm/string.hpp>
21
22namespace Pyston {
23
24static std::string escape(const std::string& str) {
25 return boost::replace_all_copy(str, "\"", "\\\"");
26}
27
28GraphvizGenerator::GraphvizGenerator(const std::string& label) : m_unique_id(0) {
29 m_stream << "digraph G {" << std::endl << "\tlabel=\"" << escape(label) << "\"" << std::endl;
30}
31
33 m_stream << "\t" << '"' << m_unique_id << '"' << " [label=\"" << escape(node->repr()) << "\"];" << std::endl;
34 if (!m_stack.empty()) {
35 m_stream << "\t\"" << m_stack.back() << '"' << " -> \"" << m_unique_id << "\"" << std::endl;
36 }
39}
40
44
46 return m_stream.str() + "}";
47}
48
49} // end of namespace Pyston
T back(T... args)
void exit(const NodeBase *) override
std::list< int64_t > m_stack
GraphvizGenerator(const std::string &label)
void enter(const NodeBase *node) override
virtual std::string repr() const =0
T empty(T... args)
T endl(T... args)
static std::string escape(const std::string &str)
T pop_back(T... args)
T push_back(T... args)
T str(T... args)