From d02751a38bbd6d3ff2fbb65c00a6a5aeab20be56 Mon Sep 17 00:00:00 2001 From: Zoltan Somogyi Date: Sun, 27 Jun 2021 20:39:50 +1000 Subject: [PATCH] Add name_arity as a format_component. compiler/error_util.m: As above. compiler/prog_data.m: To make this possible, move the existing definitions of name_arity here. compiler/hlds_defns.m: compiler/pred_table.m: Delete two the old copies of that definition. --- compiler/error_util.m | 17 +++++++++++++++++ compiler/hlds_defns.m | 3 --- compiler/pred_table.m | 2 -- compiler/prog_data.m | 3 +++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/compiler/error_util.m b/compiler/error_util.m index b63a8698d..e01466ffe 100644 --- a/compiler/error_util.m +++ b/compiler/error_util.m @@ -508,6 +508,10 @@ % The output should contain the string form of the sym_name, % surrounded by `' quotes. + ; name_arity(name_arity) + % The output should contain the name, surrounded by `' quotes, + % followed by '/' and the arity. + ; qual_sym_name_arity(sym_name_arity) ; unqual_sym_name_arity(sym_name_arity) % The output should contain the string form of the sym_name, @@ -2045,6 +2049,10 @@ error_pieces_to_string_2(FirstInMsg, [Component | Components]) = Str :- ), Word = sym_name_to_word(SymName), Str = join_string_and_tail(Word, Components, TailStr) + ; + Component = name_arity(NameAndArity), + Word = name_arity_to_word(NameAndArity), + Str = join_string_and_tail(Word, Components, TailStr) ; ( Component = qual_sym_name_arity(SymNameAndArity) @@ -2267,6 +2275,10 @@ convert_components_to_paragraphs_acc(FirstInMsg, [Component | Components], SymName = unqualified(unqualify_name(SymName0)) ), RevWords1 = [plain_word(sym_name_to_word(SymName)) | RevWords0] + ; + Component = name_arity(NameAndArity), + Word = name_arity_to_word(NameAndArity), + RevWords1 = [plain_word(Word) | RevWords0] ; ( Component = qual_sym_name_arity(SymNameAndArity) @@ -2461,6 +2473,11 @@ join_prefixes([Head | Tail]) = Strings :- sym_name_to_word(SymName) = add_quotes(sym_name_to_string(SymName)). +:- func name_arity_to_word(name_arity) = string. + +name_arity_to_word(name_arity(Name, Arity)) = + add_quotes(Name) ++ "/" ++ int_to_string(Arity). + :- func sym_name_arity_to_word(sym_name_arity) = string. sym_name_arity_to_word(sym_name_arity(SymName, Arity)) = diff --git a/compiler/hlds_defns.m b/compiler/hlds_defns.m index 0376b2974..6135d1e5f 100644 --- a/compiler/hlds_defns.m +++ b/compiler/hlds_defns.m @@ -80,9 +80,6 @@ :- import_module string. :- import_module term. -:- type name_arity - ---> name_arity(string, arity). - %-----------------------------------------------------------------------------% write_hlds_defns(Stream, ModuleInfo, !IO) :- diff --git a/compiler/pred_table.m b/compiler/pred_table.m index 3a3d5de7f..49b9a858a 100644 --- a/compiler/pred_table.m +++ b/compiler/pred_table.m @@ -425,8 +425,6 @@ :- type name_index == map(string, list(pred_id)). :- type name_arity_index == map(name_arity, list(pred_id)). -:- type name_arity - ---> name_arity(string, arity). :- type module_and_name ---> module_and_name(module_name, string). diff --git a/compiler/prog_data.m b/compiler/prog_data.m index 6648cb5fb..d854f50b1 100644 --- a/compiler/prog_data.m +++ b/compiler/prog_data.m @@ -1976,6 +1976,9 @@ valid_trace_grade_name(GradeName) :- :- interface. +:- type name_arity + ---> name_arity(string, arity). + :- type sym_name_specifier ---> sym_name_specifier_name(sym_name) ; sym_name_specifier_name_arity(sym_name, arity).