From 5a69bcd7970b9c447d7f73ec81cb7cbf8822bc03 Mon Sep 17 00:00:00 2001 From: Thirumalai-Shaktivel Date: Tue, 13 Aug 2024 21:22:58 +0530 Subject: [PATCH] Remove unused fils in pass_utils and use strings instead of Name_t --- src/libasr/pass/pass_utils.cpp | 42 +-------------------- src/libasr/pass/pass_utils.h | 7 ++-- src/lpython/semantics/python_ast_to_asr.cpp | 8 ++-- 3 files changed, 9 insertions(+), 48 deletions(-) diff --git a/src/libasr/pass/pass_utils.cpp b/src/libasr/pass/pass_utils.cpp index 0451fa12fe..7e8de863f6 100644 --- a/src/libasr/pass/pass_utils.cpp +++ b/src/libasr/pass/pass_utils.cpp @@ -1281,46 +1281,6 @@ namespace LCompilers { } return import_struct_member; } - - ASR::asr_t* make_call_helper(Allocator &al, ASR::symbol_t* s, Vec args, - std::string call_name, const Location &loc) { - - ASR::symbol_t *s_generic = nullptr, *stemp = s; - // Type map for generic functions - std::map subs; - std::map rt_subs; - // handling ExternalSymbol - s = ASRUtils::symbol_get_past_external(s); - - if (ASR::is_a(*s)) { - ASR::Function_t *func = ASR::down_cast(s); - if (args.size() < func->n_args) { - std::string missed_args_names =" "; - size_t missed_args_count =0; - for (size_t def_arg = args.size(); def_arg < func->n_args; def_arg++){ - ASR::Variable_t* var = ASRUtils::EXPR2VAR(func->m_args[def_arg]); - if(var->m_symbolic_value == nullptr) { - missed_args_names+= "'" + std::string(var->m_name) + "' and "; - missed_args_count++; - } else { - ASR::call_arg_t call_arg; - call_arg.m_value = var->m_symbolic_value; - call_arg.loc = (var->m_symbolic_value->base).loc; - args.push_back(al,call_arg); - } - } - if(missed_args_count > 0){ - missed_args_names = missed_args_names.substr(0,missed_args_names.length() - 5); - LCompilersException("Number of arguments does not match in the function call"); - - } - } - return ASRUtils::make_SubroutineCall_t_util(al, loc, stemp, - s_generic, args.p, args.size(), nullptr, nullptr, false, false); - } else { - throw LCompilersException("Unsupported call type for " + call_name); - } - } - } // namespace PassUtils +} // namespace PassUtils } // namespace LCompilers diff --git a/src/libasr/pass/pass_utils.h b/src/libasr/pass/pass_utils.h index 85e8fc5446..9523011b26 100644 --- a/src/libasr/pass/pass_utils.h +++ b/src/libasr/pass/pass_utils.h @@ -604,9 +604,10 @@ namespace LCompilers { std::string call_name = "__init__"; ASR::symbol_t* call_sym = get_struct_member(replacer->al,type->m_derived_type, call_name, x->base.base.loc, replacer->current_scope); - result_vec->push_back(replacer->al, - ASRUtils::STMT(make_call_helper(replacer->al,call_sym, - new_args,call_name,x->base.base.loc))); + result_vec->push_back(replacer->al, ASRUtils::STMT( + ASRUtils::make_SubroutineCall_t_util(replacer->al, + x->base.base.loc, call_sym, nullptr, new_args.p, new_args.size(), + nullptr, nullptr, false, false))); return; } } diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 0050cd0918..7965ff564c 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -3307,13 +3307,13 @@ class CommonVisitor : public AST::BaseVisitor { x.base.base.loc); } else if (x.n_bases == 1) { - AST::Name_t* n = nullptr; + std::string b_name = ""; if ( AST::is_a(*x.m_bases[0]) ) { - n = AST::down_cast(x.m_bases[0]); + b_name = AST::down_cast(x.m_bases[0])->m_id; } else { - throw SemanticError("Expected a Name here",x.base.base.loc); + throw SemanticError("Expected a Name here", x.base.base.loc); } - parent = current_scope->resolve_symbol(n->m_id); + parent = current_scope->resolve_symbol(b_name); LCOMPILERS_ASSERT(ASR::is_a(*parent)); } SymbolTable *parent_scope = current_scope;