Skip to content

Commit

Permalink
Remove unused fils in pass_utils and use strings instead of Name_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirumalai-Shaktivel committed Aug 13, 2024
1 parent 09fa489 commit 5a69bcd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 48 deletions.
42 changes: 1 addition & 41 deletions src/libasr/pass/pass_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,46 +1281,6 @@ namespace LCompilers {
}
return import_struct_member;
}

ASR::asr_t* make_call_helper(Allocator &al, ASR::symbol_t* s, Vec<ASR::call_arg_t> args,
std::string call_name, const Location &loc) {

ASR::symbol_t *s_generic = nullptr, *stemp = s;
// Type map for generic functions
std::map<std::string, ASR::ttype_t*> subs;
std::map<std::string, ASR::symbol_t*> rt_subs;
// handling ExternalSymbol
s = ASRUtils::symbol_get_past_external(s);

if (ASR::is_a<ASR::Function_t>(*s)) {
ASR::Function_t *func = ASR::down_cast<ASR::Function_t>(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
7 changes: 4 additions & 3 deletions src/libasr/pass/pass_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3307,13 +3307,13 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
x.base.base.loc);
}
else if (x.n_bases == 1) {
AST::Name_t* n = nullptr;
std::string b_name = "";
if ( AST::is_a<AST::Name_t>(*x.m_bases[0]) ) {
n = AST::down_cast<AST::Name_t>(x.m_bases[0]);
b_name = AST::down_cast<AST::Name_t>(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<ASR::Struct_t>(*parent));
}
SymbolTable *parent_scope = current_scope;
Expand Down

0 comments on commit 5a69bcd

Please sign in to comment.