Make mangler a class and reformat graph.
This commit is contained in:
parent
f2f88ab9ca
commit
55e4e61906
|
@ -17,37 +17,38 @@ struct group {
|
||||||
using group_ptr = std::unique_ptr<group>;
|
using group_ptr = std::unique_ptr<group>;
|
||||||
|
|
||||||
class function_graph {
|
class function_graph {
|
||||||
using group_id = size_t;
|
private:
|
||||||
|
using group_id = size_t;
|
||||||
|
|
||||||
struct group_data {
|
struct group_data {
|
||||||
std::set<function> functions;
|
std::set<function> functions;
|
||||||
std::set<group_id> adjacency_list;
|
std::set<group_id> adjacency_list;
|
||||||
size_t indegree;
|
size_t indegree;
|
||||||
|
|
||||||
group_data() : indegree(0) {}
|
group_data() : indegree(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
using data_ptr = std::shared_ptr<group_data>;
|
using data_ptr = std::shared_ptr<group_data>;
|
||||||
using edge = std::pair<function, function>;
|
using edge = std::pair<function, function>;
|
||||||
using group_edge = std::pair<group_id, group_id>;
|
using group_edge = std::pair<group_id, group_id>;
|
||||||
|
|
||||||
std::map<function, std::set<function>> adjacency_lists;
|
std::map<function, std::set<function>> adjacency_lists;
|
||||||
std::set<edge> edges;
|
std::set<edge> edges;
|
||||||
|
|
||||||
std::set<edge> compute_transitive_edges();
|
std::set<edge> compute_transitive_edges();
|
||||||
void create_groups(
|
void create_groups(
|
||||||
const std::set<edge>&,
|
const std::set<edge>&,
|
||||||
std::map<function, group_id>&,
|
std::map<function, group_id>&,
|
||||||
std::map<group_id, data_ptr>&);
|
std::map<group_id, data_ptr>&);
|
||||||
void create_edges(
|
void create_edges(
|
||||||
std::map<function, group_id>&,
|
std::map<function, group_id>&,
|
||||||
std::map<group_id, data_ptr>&);
|
std::map<group_id, data_ptr>&);
|
||||||
std::vector<group_ptr> generate_order(
|
std::vector<group_ptr> generate_order(
|
||||||
std::map<function, group_id>&,
|
std::map<function, group_id>&,
|
||||||
std::map<group_id, data_ptr>&);
|
std::map<group_id, data_ptr>&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::set<function>& add_function(const function& f);
|
std::set<function>& add_function(const function& f);
|
||||||
void add_edge(const function& from, const function& to);
|
void add_edge(const function& from, const function& to);
|
||||||
std::vector<group_ptr> compute_order();
|
std::vector<group_ptr> compute_order();
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
struct mangler {
|
class mangler {
|
||||||
std::map<std::string, int> occurence_count;
|
private:
|
||||||
|
std::map<std::string, int> occurence_count;
|
||||||
|
|
||||||
std::string new_mangled_name(const std::string& str);
|
public:
|
||||||
|
std::string new_mangled_name(const std::string& str);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user