Skip to content

Commit

Permalink
Removed allow_return_stmts variable
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Jul 1, 2022
1 parent 6ce2a24 commit afcfa42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
8 changes: 1 addition & 7 deletions grammar/asdl_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,8 @@ def visitModule(self, mod):
self.emit("public:")
self.emit(" bool success;")
self.emit(" bool allow_procedure_calls;")
self.emit(" bool allow_return_stmts;")
self.emit("")
self.emit(" ExprStmtDuplicator(Allocator& al_) : al(al_), success(false), allow_procedure_calls(true), allow_return_stmts(false) {}")
self.emit(" ExprStmtDuplicator(Allocator& al_) : al(al_), success(false), allow_procedure_calls(true) {}")
self.emit("")
self.duplicate_stmt.append((" ASR::stmt_t* duplicate_stmt(ASR::stmt_t* x) {", 0))
self.duplicate_stmt.append((" if( !x ) {", 1))
Expand Down Expand Up @@ -765,11 +764,6 @@ def make_visitor(self, name, fields):
self.duplicate_stmt.append((" success = false;", 4))
self.duplicate_stmt.append((" return nullptr;", 4))
self.duplicate_stmt.append((" }", 3))
elif name == "Return":
self.duplicate_stmt.append((" if( !allow_return_stmts ) {", 3))
self.duplicate_stmt.append((" success = false;", 4))
self.duplicate_stmt.append((" return nullptr;", 4))
self.duplicate_stmt.append((" }", 3))
self.duplicate_stmt.append((" return down_cast<ASR::stmt_t>(duplicate_%s(down_cast<ASR::%s_t>(x)));" % (name, name), 3))
self.duplicate_stmt.append((" }", 2))
elif self.is_expr:
Expand Down
7 changes: 3 additions & 4 deletions src/libasr/pass/inline_function_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ class InlineFunctionCallVisitor : public PassUtils::PassVisitor<InlineFunctionCa
pass_result.reserve(al, 1);
}

void configure_node_duplicator(bool allow_procedure_calls_, bool allow_return_stmts_) {
void configure_node_duplicator(bool allow_procedure_calls_) {
node_duplicator.allow_procedure_calls = allow_procedure_calls_;
node_duplicator.allow_return_stmts = allow_return_stmts_;
}

void visit_Function(const ASR::Function_t &x) {
Expand Down Expand Up @@ -450,9 +449,9 @@ void pass_inline_function_calls(Allocator &al, ASR::TranslationUnit_t &unit,
const std::string& rl_path,
bool inline_external_symbol_calls) {
InlineFunctionCallVisitor v(al, rl_path, inline_external_symbol_calls);
v.configure_node_duplicator(false, true);
v.configure_node_duplicator(false);
v.visit_TranslationUnit(unit);
v.configure_node_duplicator(true, true);
v.configure_node_duplicator(true);
v.visit_TranslationUnit(unit);
LFORTRAN_ASSERT(asr_verify(unit));
}
Expand Down

0 comments on commit afcfa42

Please sign in to comment.