143 std::vector<Type> idents;
145 idents.push_back(u.second->type);
148 if (
funcs.count(f) != 0)
149 throw std::exception((
"Function '" + f.
name +
"' was already declared in the current scope").c_str());
155 std::vector<std::pair<int, Function>> functions;
156 for (
auto& u :
funcs) {
158 if (u.first.name != name)
continue;
159 if (params.size() < u.first.not_default_pref)
continue;
160 if (params.size() > u.first.identifiers.size())
continue;
162 for (
int i = 0; i < params.size(); ++i) {
163 if (params[i].expr_type != u.first.identifiers[i].expr_type) {
171 if (params[i].is_array != u.first.identifiers[i].is_array) {
178 functions.push_back({ curr_level, u.first });
181 if (functions.empty()) {
182 throw std::exception((
"Function '" + name +
"' was not declared in the current scope").c_str());
184 std::sort(functions.begin(), functions.end(), [&](std::pair<int, Function> f, std::pair<int, Function> s) {
185 return f.first < s.first;
187 if (functions.size() == 1 || functions[1].first > functions[0].first)
188 return functions[0].second;
189 throw std::exception((name +
" function call is ambiguous").c_str());