From 48473e23b8f65a9e0acf5b67c87b88866056dce6 Mon Sep 17 00:00:00 2001 From: Zoltan Somogyi Date: Wed, 24 Oct 2012 05:33:07 +0000 Subject: [PATCH] On the module summary page, display the link to the module representation page Estimated hours taken: 0.3 Branches: main On the module summary page, display the link to the module representation page only if we actually have access to the module representation. deep_profiler/report.m: Add a field giving this information to the data structure representing the module summary page. deep_profiler/create_report.m: Fill in this field when generating module summary information. deep_profiler/display_report.m: Act on this field when displaying module summary pages. --- deep_profiler/create_report.m | 12 +++++++++++- deep_profiler/display_report.m | 31 ++++++++++++++++++++----------- deep_profiler/report.m | 5 +++++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/deep_profiler/create_report.m b/deep_profiler/create_report.m index 08574fe8a..61ab90fb4 100644 --- a/deep_profiler/create_report.m +++ b/deep_profiler/create_report.m @@ -582,9 +582,19 @@ module_pair_to_row_data(Deep, ModuleName - ModuleData) = ModuleRowData :- create_module_report(Deep, ModuleName, MaybeModuleReport) :- ( map.search(Deep ^ module_data, ModuleName, ModuleData) -> + deep_get_maybe_progrep(Deep, MaybeProgRep), + ( + MaybeProgRep = ok(ProgRep), + ProgRep = prog_rep(ModuleMap), + map.search(ModuleMap, ModuleName, _) + -> + HaveModuleRep = have_module_rep + ; + HaveModuleRep = do_not_have_module_rep + ), PSPtrs = ModuleData ^ module_procs, ProcRowDatas = list.map(proc_to_active_row_data(Deep), PSPtrs), - ModuleReport = module_report(ModuleName, ProcRowDatas), + ModuleReport = module_report(ModuleName, HaveModuleRep, ProcRowDatas), MaybeModuleReport = ok(ModuleReport) ; Msg = string.format("There is no module named `%s'.\n", diff --git a/deep_profiler/display_report.m b/deep_profiler/display_report.m index 5283f0545..084871563 100644 --- a/deep_profiler/display_report.m +++ b/deep_profiler/display_report.m @@ -1127,7 +1127,7 @@ avoid_sort_self_and_desc(Prefs) = SortPrefs :- is det. display_report_module(Prefs, ModuleReport, Display) :- - ModuleReport = module_report(ModuleName, ProcRowDatas0), + ModuleReport = module_report(ModuleName, HaveModuleRep, ProcRowDatas0), Cmd = deep_cmd_module(ModuleName), Title = string.format("The procedures of module %s:", [s(ModuleName)]), @@ -1174,23 +1174,32 @@ display_report_module(Prefs, ModuleReport, Display) :- GetterSetterCmd = deep_cmd_module_getter_setters(ModuleName), GetterSetterControl = display_link(deep_link(GetterSetterCmd, yes(Prefs), attr_str([], "Show field getters and setters"), link_class_link)), - RepCmd = deep_cmd_module_rep(ModuleName), - RepControl = display_link(deep_link(RepCmd, yes(Prefs), - attr_str([], "Show module representation"), link_class_link)), + ( + HaveModuleRep = do_not_have_module_rep, + ModuleControls = + [display_paragraph_break, GetterSetterControl] + ; + HaveModuleRep = have_module_rep, + RepCmd = deep_cmd_module_rep(ModuleName), + RepControl = display_link(deep_link(RepCmd, yes(Prefs), + attr_str([], "Show module representation"), link_class_link)), + ModuleControls = + [display_paragraph_break, GetterSetterControl, + display_paragraph_break, RepControl] + ), InactiveControls = inactive_proc_controls(Prefs, Cmd), FieldControls = field_controls(Prefs, Cmd), FormatControls = format_controls(Prefs, Cmd), MenuRestartQuitControls = cmds_menu_restart_quit(yes(Prefs)), - - Display = display(yes(Title), - [DisplayTable, - display_paragraph_break, GetterSetterControl, - display_paragraph_break, RepControl, - display_paragraph_break, InactiveControls, + GeneralControls = + [display_paragraph_break, InactiveControls, display_paragraph_break, FieldControls, display_paragraph_break, FormatControls, - display_paragraph_break, MenuRestartQuitControls]). + display_paragraph_break, MenuRestartQuitControls], + + Display = display(yes(Title), + [DisplayTable] ++ ModuleControls ++ GeneralControls). :- pred active_proc(perf_row_data(proc_active)::in) is semidet. diff --git a/deep_profiler/report.m b/deep_profiler/report.m index 4e08aad25..104906b46 100644 --- a/deep_profiler/report.m +++ b/deep_profiler/report.m @@ -322,9 +322,14 @@ % Summary information about all the procedures in one module % of the program. mr_module_name :: string, + mr_have_module_rep :: maybe_have_module_rep, mr_procs :: list(perf_row_data(proc_active)) ). +:- type maybe_have_module_rep + ---> do_not_have_module_rep + ; have_module_rep. + :- type data_struct_name ---> data_struct_name(string).