mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-09 16:38:45 +00:00
fixes
This commit is contained in:
parent
3abac1b643
commit
b901078956
6 changed files with 291 additions and 155 deletions
|
|
@ -492,28 +492,41 @@ std::vector<utils::IdType>
|
|||
return typeclasses_vector;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, TypeclassGraph::FunctionInfo*>
|
||||
GlobalInfo::GetAnnotatedTypeFunctionsMap(interpreter::tokens::AnnotatedType* node) {
|
||||
std::unordered_map<std::string, TypeclassGraph::FunctionInfo> // TODO: optimize, cache
|
||||
GlobalInfo::GetAnnotatedTypeFunctionsMap(interpreter::tokens::AnnotatedType* node,
|
||||
const interpreter::tokens::BaseNode& base_node) {
|
||||
|
||||
std::unordered_map<std::string, TypeclassGraph::FunctionInfo*> functions;
|
||||
std::unordered_map<std::string, TypeclassGraph::FunctionInfo> functions;
|
||||
|
||||
for (auto& typeclass : node->typeclasses) {
|
||||
utils::IdType graph_id = typeclasses_[typeclass->typeclass_id_].graph_id_;
|
||||
|
||||
auto requirements = typeclass_graph_.GetTypeclassFunctions(graph_id);
|
||||
for (auto& requirement : requirements) {
|
||||
functions[requirement.first] = requirement.second;
|
||||
auto requirement_iter = functions.find(requirement.first);
|
||||
if (requirement_iter == functions.end()) {
|
||||
functions[requirement.first] = *requirement.second;
|
||||
} else {
|
||||
if (requirement_iter->second.definition.has_value()) {
|
||||
if (requirement.second->definition.has_value()) {
|
||||
error_handling::HandleTypecheckError("Function defined more then in one type requirement", base_node);
|
||||
}
|
||||
} else {
|
||||
requirement_iter->second.definition = requirement.second->definition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return functions;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, TypeclassGraph::FunctionInfo*>>
|
||||
GlobalInfo::GetAnnotatedTypeFunctionsVector(interpreter::tokens::AnnotatedType* node) {
|
||||
std::vector<std::pair<std::string, TypeclassGraph::FunctionInfo>> // TODO: optimize, cache
|
||||
GlobalInfo::GetAnnotatedTypeFunctionsVector(interpreter::tokens::AnnotatedType* node,
|
||||
const interpreter::tokens::BaseNode& base_node) {
|
||||
|
||||
std::unordered_map<std::string, TypeclassGraph::FunctionInfo*> functions_set = GetAnnotatedTypeFunctionsMap(node);
|
||||
auto functions_set = GetAnnotatedTypeFunctionsMap(node, base_node);
|
||||
|
||||
std::vector<std::pair<std::string, TypeclassGraph::FunctionInfo*>> functions_vector;
|
||||
std::vector<std::pair<std::string, TypeclassGraph::FunctionInfo>> functions_vector;
|
||||
functions_vector.reserve(functions_vector.size());
|
||||
for (auto& typeclass : functions_set) {
|
||||
functions_vector.push_back(typeclass);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue