Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixing symbolic attributes
  • Loading branch information
anutosh491 committed Sep 25, 2023
commit 962dcd88193137efdf48447e857a094490f3f927
30 changes: 30 additions & 0 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7241,6 +7241,36 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
std::string res = n->m_value;
handle_constant_string_attributes(res, args, at->m_attr, loc);
return;
} else if (AST::is_a<AST::Call_t>(*at->m_value)) {
AST::Call_t* call = AST::down_cast<AST::Call_t>(at->m_value);
std::set<std::string> symbolic_functions = {
"sin", "cos", "log", "exp", "Abs"
};
if (AST::is_a<AST::Attribute_t>(*call->m_func)) {
visit_Call(*call);
Vec<ASR::expr_t*> eles;
eles.reserve(al, args.size());
for (size_t i=0; i<args.size(); i++) {
eles.push_back(al, args[i].m_value);
}
handle_symbolic_attribute(ASRUtils::EXPR(tmp), at->m_attr, loc, eles);
return;
} else if (AST::is_a<AST::Name_t>(*call->m_func)) {
AST::Name_t *n = AST::down_cast<AST::Name_t>(call->m_func);
std::string call_name = n->m_id;
if (symbolic_functions.find(call_name) != symbolic_functions.end()) {
visit_Call(*call);
Vec<ASR::expr_t*> eles;
eles.reserve(al, args.size());
for (size_t i=0; i<args.size(); i++) {
eles.push_back(al, args[i].m_value);
}
handle_symbolic_attribute(ASRUtils::EXPR(tmp), at->m_attr, loc, eles);
return;
} else {
throw SemanticError(std::string(call_name) + " not supported in Call", loc);
}
}
} else {
throw SemanticError("Only Name type and constant integers supported in Call", loc);
}
Expand Down