souffle  2.0.2-371-g6315b36
DebugInfo.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file DebugInfo.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/AbstractLog.h"
18 #include "ram/Node.h"
19 #include "ram/Statement.h"
20 #include "ram/utility/NodeMapper.h"
24 #include <memory>
25 #include <ostream>
26 #include <string>
27 #include <utility>
28 #include <vector>
29 
30 namespace souffle::ram {
31 
32 /**
33  * @class DebugInfo
34  * @brief Debug statement
35  *
36  * For example:
37  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
38  * BEGIN_DEBUG "gen(1) \nin file /file.dl [7:7-7:10]\;"
39  * ...
40  * END_DEBUG
41  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
42  */
43 class DebugInfo : public Statement, public AbstractLog {
44 public:
45  DebugInfo(Own<Statement> stmt, std::string msg) : AbstractLog(std::move(stmt), std::move(msg)) {}
46 
47  std::vector<const Node*> getChildNodes() const override {
49  }
50 
51  DebugInfo* clone() const override {
53  }
54 
55  void apply(const NodeMapper& map) override {
57  }
58 
59 protected:
60  void print(std::ostream& os, int tabpos) const override {
61  os << times(" ", tabpos) << "BEGIN_DEBUG \"" << stringify(message) << "\"" << std::endl;
62  Statement::print(statement.get(), os, tabpos + 1);
63  os << times(" ", tabpos) << "END_DEBUG" << std::endl;
64  }
65 };
66 
67 } // namespace souffle::ram
souffle::map
auto map(const std::vector< A > &xs, F &&f)
Applies a function to each element of a vector and returns the results.
Definition: ContainerUtil.h:158
MiscUtil.h
souffle::ram::AbstractLog::apply
void apply(const NodeMapper &map)
Definition: AbstractLog.h:59
souffle::ram::DebugInfo::clone
DebugInfo * clone() const override
Create a clone (i.e.
Definition: DebugInfo.h:55
souffle::ram::AbstractLog::message
const std::string message
Logging message.
Definition: AbstractLog.h:74
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::stringify
std::string stringify(const std::string &input)
Stringify a string using escapes for escape, newline, tab, double-quotes and semicolons.
Definition: StringUtil.h:334
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
NodeMapper.h
souffle::ram::NodeMapper
An abstract class for manipulating RAM Nodes by substitution.
Definition: NodeMapper.h:38
souffle::times
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
Definition: StreamUtil.h:322
souffle::ram::DebugInfo::getChildNodes
std::vector< const Node * > getChildNodes() const override
Obtain list of all embedded child nodes.
Definition: DebugInfo.h:51
StringUtil.h
souffle::ram::Statement::print
void print(std::ostream &os) const override
Print RAM node.
Definition: Statement.h:42
souffle::ram::AbstractLog::AbstractLog
AbstractLog(Own< Statement > stmt, std::string msg)
Definition: AbstractLog.h:41
souffle::ram::DebugInfo
Debug statement.
Definition: DebugInfo.h:47
souffle::ram::DebugInfo::apply
void apply(const NodeMapper &map) override
Apply the mapper to all child nodes.
Definition: DebugInfo.h:59
AbstractLog.h
Node.h
std
Definition: Brie.h:3053
StreamUtil.h
Statement.h
souffle::ram::AbstractLog::getChildNodes
std::vector< const Node * > getChildNodes() const
Definition: AbstractLog.h:45
souffle::ram::DebugInfo::DebugInfo
DebugInfo(Own< Statement > stmt, std::string msg)
Definition: DebugInfo.h:49
souffle::ram::DebugInfo::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: DebugInfo.h:64
souffle::ram::AbstractLog::statement
Own< Statement > statement
Logging statement.
Definition: AbstractLog.h:71