10 std::pair<
int,
int> printStmtSubgraph(utils::
DotPrinter& dp, ast::
Stmt* stmt) {
13 if(
auto block = dyn_cast_or_null<ast::BlockStatement*>(stmt)) {
16 dp
.print("label=\"Statement body\"");
18 firstId = printDotNodeList(dp, block->stmts());
25 firstId = stmt->printDotNode(dp);
27 return {firstId, subgraphId};
32 std::ostream& BlockStatement::print(std::ostream& os,
int indentation)
const {
35 return os << i1 <<
"BlockStatement {}\n";
37 os << i1 <<
"BlockStatement {\n";
38 for(
auto stmt : stmts()) {
39 stmt->print(os, indentation + 1) <<
"\n";
45 int BlockStatement::printDotNode(DotPrinter& dp)
const {
48 for(
auto stmt : stmts_) {
49 dp.printConnection(id, stmt->printDotNode(dp));
56 std::ostream& DeclStmt::print(std::ostream& os,
int indentation)
const {
61 int DeclStmt::printDotNode(DotPrinter& dp)
const {
62 return decl_->printDotNode(dp);
67 std::ostream& ExprStmt::print(std::ostream& os,
int indentation)
const {
68 expr_->print(os, indentation);
72 int ExprStmt::printDotNode(DotPrinter& dp)
const {
74 std::ostringstream expr;
75 expr_->print(expr, -1);
85 std::ostream& IfStmt::print(std::ostream& os,
int indentation)
const {
91 int IfStmt::printDotNode(DotPrinter& dp)
const {
93 std::ostringstream expr;
94 condition_->print(expr, -1);
98 "condition", expr.str()
, {
"port",
"condition"}
, {
"balign",
"left"}
);
102 auto ids = printStmtSubgraph(dp, thenStmt_);
104 dp.printConnection(id,
":then:c", ids.first, ids.second);
106 dp.printConnection(id,
":then:c", ids.first);
109 ids = printStmtSubgraph(dp, elseStmt_);
111 dp.printConnection(id,
":else:c", ids.first, ids.second);
113 dp.printConnection(id,
":else:c", ids.first);
120 std::ostream& WhileStmt::print(std::ostream& os,
int indentation)
const {
126 int WhileStmt::printDotNode(DotPrinter& dp)
const {
131 "condition", "body", {
"port",
"condition"}
, {
"port",
"body"}
);
134 auto ids = printStmtSubgraph(dp, body_);
136 dp.printConnection(id,
":body", ids.first, ids.second);
138 dp.printConnection(id,
":body", ids.first);
144 std::ostream& ForStmt::print(std::ostream& os,
int indentation)
const {
150 int ForStmt::printDotNode(DotPrinter& dp)
const {
152 std::ostringstream expr;
153 if(condition_) condition_->print(expr, -1);
157 "condition", expr.str()
, {
"port",
"condition"}
, {
"balign",
"left"}
);
167 auto ids = printStmtSubgraph(dp, body_);
169 dp.printConnection(id,
":body", ids.first, ids.second);
171 dp.printConnection(id,
":body", ids.first);
177 std::ostream& ReturnStmt::print(std::ostream& os,
int indentation)
const {
182 int ReturnStmt::printDotNode(DotPrinter& dp)
const {
187 std::ostringstream expr;
188 expr_->print(expr, -1);
190 "expr", expr.str()
, {
"port",
"condition"}
, {
"balign",
"left"}
);
198 std::ostream& NullStmt::print(std::ostream& os,
int indentation)
const {
203 int NullStmt::printDotNode(DotPrinter& dp)
const {