Skip to content

Commit

Permalink
Fix text printer
Browse files Browse the repository at this point in the history
  • Loading branch information
icemelon committed Jun 11, 2020
1 parent 06ae06d commit 2411e2b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/printer/relay_text_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,21 @@ Doc RelayTextPrinter::VisitExpr_(const IfNode* op) {
}

Doc RelayTextPrinter::VisitExpr_(const LetNode* op) {
Doc doc;
int n = 0;
Expr let = GetRef<Let>(op);
while (auto let_node = let.as<LetNode>()) {
Doc doc;
doc << "let " << AllocVar(let_node->var) << " = " << Print(let_node->value, false, true) << ";"
<< Doc::NewLine();
doc_stack_.push_back(doc);
let = let_node->body;
++n;
}
Doc doc = PrintScope(let);
for (int i = 0; i < n; ++i) {
doc = doc_stack_.back() << doc;
doc_stack_.pop_back();
}
// we use a scope here so GNF hoisting doesn't escape too far
// and nested, unique lets are not hoisted
doc << PrintScope(let);
return doc;
}

Expand Down

0 comments on commit 2411e2b

Please sign in to comment.