Implement new ordered typing in compiler series
This commit is contained in:
13
10/graph.hpp
13
10/graph.hpp
@@ -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 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user