Treelite
dump.cc
Go to the documentation of this file.
1 
6 #include <dmlc/registry.h>
7 #include "./builder.h"
8 
9 namespace {
10 
11 void get_dump_from_node(std::ostringstream* oss,
12  const treelite::compiler::ASTNode* node,
13  int indent) {
14  (*oss) << std::string(indent, ' ') << node->GetDump() << "\n";
15  for (const treelite::compiler::ASTNode* child : node->children) {
16  CHECK(child);
17  get_dump_from_node(oss, child, indent + 2);
18  }
19 }
20 
21 } // anonymous namespace
22 
23 namespace treelite {
24 namespace compiler {
25 
26 DMLC_REGISTRY_FILE_TAG(dump);
27 
28 std::string ASTBuilder::GetDump() const {
29  std::ostringstream oss;
30  get_dump_from_node(&oss, this->main_node, 0);
31  return oss.str();
32 }
33 
34 } // namespace compiler
35 } // namespace treelite
AST Builder class.