From 55e4e6190619c8ca4f76e8d0a9e12dd3babfaedf Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 15 Sep 2020 19:13:48 -0700 Subject: [PATCH] Make mangler a class and reformat graph. --- code/compiler/13/graph.hpp | 53 ++++++++++++++++++------------------ code/compiler/13/mangler.hpp | 8 ++++-- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/code/compiler/13/graph.hpp b/code/compiler/13/graph.hpp index 8a654aa..072e085 100644 --- a/code/compiler/13/graph.hpp +++ b/code/compiler/13/graph.hpp @@ -17,37 +17,38 @@ struct group { using group_ptr = std::unique_ptr; class function_graph { - using group_id = size_t; + private: + using group_id = size_t; - struct group_data { - std::set functions; - std::set adjacency_list; - size_t indegree; + struct group_data { + std::set functions; + std::set adjacency_list; + size_t indegree; - group_data() : indegree(0) {} - }; + group_data() : indegree(0) {} + }; - using data_ptr = std::shared_ptr; - using edge = std::pair; - using group_edge = std::pair; + using data_ptr = std::shared_ptr; + using edge = std::pair; + using group_edge = std::pair; - std::map> adjacency_lists; - std::set edges; + std::map> adjacency_lists; + std::set edges; - std::set compute_transitive_edges(); - void create_groups( - const std::set&, - std::map&, - std::map&); - void create_edges( - std::map&, - std::map&); - std::vector generate_order( - std::map&, - std::map&); + std::set compute_transitive_edges(); + void create_groups( + const std::set&, + std::map&, + std::map&); + void create_edges( + std::map&, + std::map&); + std::vector generate_order( + std::map&, + std::map&); public: - std::set& add_function(const function& f); - void add_edge(const function& from, const function& to); - std::vector compute_order(); + std::set& add_function(const function& f); + void add_edge(const function& from, const function& to); + std::vector compute_order(); }; diff --git a/code/compiler/13/mangler.hpp b/code/compiler/13/mangler.hpp index d1017c9..0df8efd 100644 --- a/code/compiler/13/mangler.hpp +++ b/code/compiler/13/mangler.hpp @@ -2,8 +2,10 @@ #include #include -struct mangler { - std::map occurence_count; +class mangler { + private: + std::map occurence_count; - std::string new_mangled_name(const std::string& str); + public: + std::string new_mangled_name(const std::string& str); };