Implement new ordered typing in compiler series

This commit is contained in:
2020-03-24 22:00:09 -07:00
parent c286c9edcc
commit e07da0c9b1
3 changed files with 54 additions and 31 deletions

View File

@@ -46,6 +46,7 @@ class function_graph {
std::map<group_id, data_ptr>&);
public:
std::set<function>& add_function(const function& f);
void add_edge(const function& from, const function& to);
std::vector<group_ptr> compute_order();
};
@@ -139,13 +140,17 @@ std::vector<group_ptr> function_graph::generate_order(
return output;
}
void function_graph::add_edge(const function& from, const function& to) {
auto adjacency_list_it = adjacency_lists.find(from);
std::set<function>& function_graph::add_function(const function& f) {
auto adjacency_list_it = adjacency_lists.find(f);
if(adjacency_list_it != adjacency_lists.end()) {
adjacency_list_it->second.insert(to);
return adjacency_list_it->second;
} else {
adjacency_lists[from] = { to };
return adjacency_lists[f] = { };
}
}
void function_graph::add_edge(const function& from, const function& to) {
add_function(from).insert(to);
edges.insert({ from, to });
}