diff --git a/compiler/add_pragma_decl.m b/compiler/add_pragma_decl.m index 1936147f9..f2219e358 100644 --- a/compiler/add_pragma_decl.m +++ b/compiler/add_pragma_decl.m @@ -45,7 +45,8 @@ list(err_spec)::in, list(err_spec)::out, list(warn_spec)::in, list(warn_spec)::out) is det. -:- pred add_decl_pragmas_input_spec(ims_list(decl_pragma_input_spec_info)::in, +:- pred add_decl_pragmas_input_mode_spec( + ims_list(decl_pragma_input_mode_spec_info)::in, module_info::in, module_info::out, list(err_spec)::in, list(err_spec)::out) is det. @@ -150,12 +151,13 @@ add_decl_pragmas_type_spec([Pragma | Pragmas], !ModuleInfo, !QualInfo, add_decl_pragmas_type_spec(Pragmas, !ModuleInfo, !QualInfo, !ErrSpecs, !WarnSpecs). -add_decl_pragmas_input_spec([], !ModuleInfo, !ErrSpecsWarnSpecs). -add_decl_pragmas_input_spec([ImsList | ImsLists], !ModuleInfo, !ErrSpecs) :- +add_decl_pragmas_input_mode_spec([], !ModuleInfo, !ErrSpecsWarnSpecs). +add_decl_pragmas_input_mode_spec([ImsList | ImsLists], + !ModuleInfo, !ErrSpecs) :- ImsList = ims_sub_list(ItemMercuryStatus, Pragmas), - list.foldl2(add_pragma_input_spec(ItemMercuryStatus), Pragmas, + list.foldl2(add_pragma_input_mode_spec(ItemMercuryStatus), Pragmas, !ModuleInfo, !ErrSpecs), - add_decl_pragmas_input_spec(ImsLists, !ModuleInfo, !ErrSpecs). + add_decl_pragmas_input_mode_spec(ImsLists, !ModuleInfo, !ErrSpecs). add_decl_pragmas_termination([], !ModuleInfo, !ErrSpecs). add_decl_pragmas_termination([Pragma | Pragmas], !ModuleInfo, !ErrSpecs) :- @@ -209,8 +211,8 @@ add_decl_pragma(ProgressStream, ItemMercuryStatus, Pragma, add_pragma_type_spec(TypeSpecInfo, !ModuleInfo, !QualInfo, !ErrSpecs, !WarnSpecs) ; - Pragma = decl_pragma_input_spec(InputSpecInfo), - add_pragma_input_spec(ItemMercuryStatus, InputSpecInfo, + Pragma = decl_pragma_input_mode_spec(InputSpecInfo), + add_pragma_input_mode_spec(ItemMercuryStatus, InputSpecInfo, !ModuleInfo, !ErrSpecs) ; Pragma = decl_pragma_oisu(OISUInfo), @@ -391,15 +393,16 @@ mark_pred_as_format_call(FormatCallInfo, PragmaStatus, !ModuleInfo, %---------------------% -:- pred add_pragma_input_spec(item_mercury_status::in, - decl_pragma_input_spec_info::in, module_info::in, module_info::out, +:- pred add_pragma_input_mode_spec(item_mercury_status::in, + decl_pragma_input_mode_spec_info::in, module_info::in, module_info::out, list(err_spec)::in, list(err_spec)::out) is det. -add_pragma_input_spec(ItemMercuryStatus, InputSpec, !ModuleInfo, !ErrSpecs) :- +add_pragma_input_mode_spec(ItemMercuryStatus, InputSpec, + !ModuleInfo, !ErrSpecs) :- % XXX If we ever want to get smart recompilation working, we may % have to do something with _RecompIds. What we do for type_spec pragmas % may, or may not, be appropriate for input spec pragmas as well. - InputSpec = decl_pragma_input_spec_info(ContainingModuleName, Type, + InputSpec = decl_pragma_input_mode_spec_info(ContainingModuleName, Type, ReplaceOrAdd, OoMInstCtors, OoMInsts, _RecompIds, TVarSet, Context, _), some [!InputSpecs] ( @@ -413,7 +416,7 @@ add_pragma_input_spec(ItemMercuryStatus, InputSpec, !ModuleInfo, !ErrSpecs) :- ( ReplaceOrAdd = replace_in_mode, StatusPieces = [words("Error: a"), - pragma_decl("input_spec"), words("declaration"), + pragma_decl("input_mode_spec"), words("declaration"), words("that occurs in the interface of its module"), words("is not allowed to specify")] ++ color_as_incorrect([words("replace_in_mode,")]) ++ @@ -434,7 +437,7 @@ add_pragma_input_spec(ItemMercuryStatus, InputSpec, !ModuleInfo, !ErrSpecs) :- ) ), module_info_get_type_table(!.ModuleInfo, TypeTable), - check_input_spec_type(TypeTable, Type, + check_input_mode_spec_type(TypeTable, Type, [], UnknownTypeCtors, [], NonDuTypeCtors, bag.init, TVars), ( UnknownTypeCtors = [] @@ -499,7 +502,7 @@ add_pragma_input_spec(ItemMercuryStatus, InputSpec, !ModuleInfo, !ErrSpecs) :- % XXX We could relax that requirement to allow non-repeated tvars, % which would make Type effectively a template. However, for that to work, % input_specialization.m would need to use a more complex method than -% a simple map lookup to test whether an input_spec pragma is applicable +% a simple map lookup to test whether an input_mode_spec pragma is applicable % to a given predicate or function argument. % % bag.to_list_only_duplicates(TVars, DupTVars), @@ -524,7 +527,7 @@ add_pragma_input_spec(ItemMercuryStatus, InputSpec, !ModuleInfo, !ErrSpecs) :- % ), module_info_get_inst_table(!.ModuleInfo, InstTable), inst_table_get_user_insts(InstTable, UserInstTable), - one_or_more.foldl(check_input_spec_inst_ctor(UserInstTable), + one_or_more.foldl(check_input_mode_spec_inst_ctor(UserInstTable), OoMInstCtors, [], _UndefInstCtors), ( !.InputSpecs = [], @@ -547,7 +550,8 @@ add_pragma_input_spec(ItemMercuryStatus, InputSpec, !ModuleInfo, !ErrSpecs) :- TypeStr = mercury_type_to_string(TVarSet, print_name_only, Type), DupDeclPiecesNew = [words("Error: duplicate"), - pragma_decl("input_spec"), words("declaration for")] ++ + pragma_decl("input_mode_spec"), + words("declaration for")] ++ color_as_subject([words(TypeStr), suffix(".")]) ++ [nl], DupDeclMsgNew = msg(Context, DupDeclPiecesNew), @@ -570,26 +574,26 @@ add_pragma_input_spec(ItemMercuryStatus, InputSpec, !ModuleInfo, !ErrSpecs) :- !:ErrSpecs = !.InputSpecs ++ !.ErrSpecs ). -:- pred check_input_spec_types(type_table::in, list(mer_type)::in, +:- pred check_input_mode_spec_types(type_table::in, list(mer_type)::in, list(format_piece)::in, list(format_piece)::out, list(format_piece)::in, list(format_piece)::out, bag(tvar)::in, bag(tvar)::out) is det. -check_input_spec_types(_TypeTable, [], +check_input_mode_spec_types(_TypeTable, [], !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag). -check_input_spec_types(TypeTable, [Type | Types], +check_input_mode_spec_types(TypeTable, [Type | Types], !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag) :- - check_input_spec_type(TypeTable, Type, + check_input_mode_spec_type(TypeTable, Type, !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag), - check_input_spec_types(TypeTable, Types, + check_input_mode_spec_types(TypeTable, Types, !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag). -:- pred check_input_spec_type(type_table::in, mer_type::in, +:- pred check_input_mode_spec_type(type_table::in, mer_type::in, list(format_piece)::in, list(format_piece)::out, list(format_piece)::in, list(format_piece)::out, bag(tvar)::in, bag(tvar)::out) is det. -check_input_spec_type(TypeTable, Type, +check_input_mode_spec_type(TypeTable, Type, !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag) :- ( Type = type_variable(TVar, _), @@ -617,26 +621,26 @@ check_input_spec_type(TypeTable, Type, !:UnknownTypeCtors = [unqual_type_ctor(TypeCtor) | !.UnknownTypeCtors] ), - check_input_spec_types(TypeTable, ArgTypes, + check_input_mode_spec_types(TypeTable, ArgTypes, !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag) ; Type = tuple_type(ArgTypes, _Kind), - check_input_spec_types(TypeTable, ArgTypes, + check_input_mode_spec_types(TypeTable, ArgTypes, !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag) ; Type = higher_order_type(_PorF, ArgTypes, _HOInstInfo, _Purity), - check_input_spec_types(TypeTable, ArgTypes, + check_input_mode_spec_types(TypeTable, ArgTypes, !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag) ; Type = kinded_type(SubType, _Kind), - check_input_spec_type(TypeTable, SubType, + check_input_mode_spec_type(TypeTable, SubType, !UnknownTypeCtors, !NonDuTypeCtors, !TVarBag) ). -:- pred check_input_spec_inst_ctor(user_inst_table::in, inst_ctor::in, +:- pred check_input_mode_spec_inst_ctor(user_inst_table::in, inst_ctor::in, list(format_piece)::in, list(format_piece)::out) is det. -check_input_spec_inst_ctor(UserInstTable, InstCtor, !UnknownInstCtors) :- +check_input_mode_spec_inst_ctor(UserInstTable, InstCtor, !UnknownInstCtors) :- % XXX Any problems with _InstDefn (for example, it may not be applicable % to the type of the selected argument) should be reported by the mode % analysis pass. diff --git a/compiler/convert_parse_tree.m b/compiler/convert_parse_tree.m index d784c823b..4d3ea3733 100644 --- a/compiler/convert_parse_tree.m +++ b/compiler/convert_parse_tree.m @@ -1091,8 +1091,8 @@ check_convert_parse_tree_opt_to_plain_opt(ParseTreeOpt, ParseTreePlainOpt, list(item_impl_marker_info_opt)::in, list(item_impl_marker_info_opt)::out, list(decl_pragma_type_spec_info)::in, list(decl_pragma_type_spec_info)::out, - list(decl_pragma_input_spec_info)::in, - list(decl_pragma_input_spec_info)::out, + list(decl_pragma_input_mode_spec_info)::in, + list(decl_pragma_input_mode_spec_info)::out, list(decl_pragma_termination_info)::in, list(decl_pragma_termination_info)::out, list(decl_pragma_termination2_info)::in, @@ -1161,7 +1161,7 @@ classify_plain_opt_items([Item | Items], !TypeDefns, !ForeignEnums, DeclPragma = decl_pragma_type_spec(TypeSpec), !:TypeSpecs = [TypeSpec | !.TypeSpecs] ; - DeclPragma = decl_pragma_input_spec(InputSpec), + DeclPragma = decl_pragma_input_mode_spec(InputSpec), !:InputSpecs = [InputSpec | !.InputSpecs] ; DeclPragma = decl_pragma_termination(Term), @@ -1421,7 +1421,7 @@ classify_trans_opt_items([Item | Items], !TermInfos, !Term2Infos, ; DeclPragma = decl_pragma_format_call(_) ; DeclPragma = decl_pragma_type_spec(_) ; DeclPragma = decl_pragma_type_spec_constr(_) - ; DeclPragma = decl_pragma_input_spec(_) + ; DeclPragma = decl_pragma_input_mode_spec(_) ; DeclPragma = decl_pragma_oisu(_) ), Pieces = [words("A .trans_opt file may not contain")] ++ diff --git a/compiler/equiv_type_parse_tree.m b/compiler/equiv_type_parse_tree.m index 180c97bd5..bee216114 100644 --- a/compiler/equiv_type_parse_tree.m +++ b/compiler/equiv_type_parse_tree.m @@ -576,7 +576,7 @@ replace_in_parse_tree_plain_opt(Params, replace_in_decl_pragma_type_spec, TypeSpecs0, TypeSpecs, !RecompInfo, !UsedModules, !Specs), replace_in_list(Params, MaybeRecord, - replace_in_decl_pragma_input_spec, InputSpecs0, InputSpecs, + replace_in_decl_pragma_input_mode_spec, InputSpecs0, InputSpecs, !RecompInfo, !UsedModules, !Specs), ParseTreePlainOpt = parse_tree_plain_opt( @@ -1340,10 +1340,10 @@ replace_in_decl_pragma_info(Params, MaybeRecord, DeclPragma0, DeclPragma, TypeSpec0, TypeSpec, !RecompInfo, !UsedModules, Specs), DeclPragma = decl_pragma_type_spec(TypeSpec) ; - DeclPragma0 = decl_pragma_input_spec(InputSpec0), - replace_in_decl_pragma_input_spec(Params, MaybeRecord, + DeclPragma0 = decl_pragma_input_mode_spec(InputSpec0), + replace_in_decl_pragma_input_mode_spec(Params, MaybeRecord, InputSpec0, InputSpec, !RecompInfo, !UsedModules, Specs), - DeclPragma = decl_pragma_input_spec(InputSpec) + DeclPragma = decl_pragma_input_mode_spec(InputSpec) ; ( DeclPragma0 = decl_pragma_obsolete_pred(_) ; DeclPragma0 = decl_pragma_obsolete_proc(_) @@ -1457,13 +1457,14 @@ replace_in_decl_pragma_type_spec(Params, MaybeRecord, %---------------------% -:- pred replace_in_decl_pragma_input_spec(equiv_params::in, +:- pred replace_in_decl_pragma_input_mode_spec(equiv_params::in, maybe_record_sym_name_use::in, - decl_pragma_input_spec_info::in, decl_pragma_input_spec_info::out, + decl_pragma_input_mode_spec_info::in, + decl_pragma_input_mode_spec_info::out, maybe(recompilation_info)::in, maybe(recompilation_info)::out, used_eqv_modules::in, used_eqv_modules::out, list(err_spec)::out) is det. -replace_in_decl_pragma_input_spec(Params, MaybeRecord, +replace_in_decl_pragma_input_mode_spec(Params, MaybeRecord, InputSpecInfo0, InputSpecInfo, RecompInfo, RecompInfo, !UsedModules, []) :- % RecompInfo is unused, but its presence is required @@ -1471,7 +1472,7 @@ replace_in_decl_pragma_input_spec(Params, MaybeRecord, % % The XXX at the start of replace_in_decl_pragma_type_spec_constr % applies here as well. - InputSpecInfo0 = decl_pragma_input_spec_info(ContainingModuleName, + InputSpecInfo0 = decl_pragma_input_mode_spec_info(ContainingModuleName, Type0, ReplaceOrAdd, OoMInstCtors, OoMInsts0, GatheredItemIds0, TVarSet0, Context, SeqNum), ModuleName = Params ^ ep_module_name, @@ -1489,7 +1490,7 @@ replace_in_decl_pragma_input_spec(Params, MaybeRecord, ; ItemRecompDeps = item_recomp_deps(_, GatheredItemIds) ), - InputSpecInfo = decl_pragma_input_spec_info(ContainingModuleName, + InputSpecInfo = decl_pragma_input_mode_spec_info(ContainingModuleName, Type, ReplaceOrAdd, OoMInstCtors, OoMInsts, GatheredItemIds, TVarSet, Context, SeqNum). diff --git a/compiler/item_util.m b/compiler/item_util.m index a86d5bf3a..db8e51a34 100644 --- a/compiler/item_util.m +++ b/compiler/item_util.m @@ -431,8 +431,8 @@ decl_pragma_desc_pieces(Pragma) = Pieces :- Pragma = decl_pragma_type_spec(_), Pieces = [pragma_decl("type_spec"), words("declaration")] ; - Pragma = decl_pragma_input_spec(_), - Pieces = [pragma_decl("input_spec"), words("declaration")] + Pragma = decl_pragma_input_mode_spec(_), + Pieces = [pragma_decl("input_mode_spec"), words("declaration")] ; Pragma = decl_pragma_oisu(_), Pieces = [pragma_decl("oisu"), words("declaration")] diff --git a/compiler/make_hlds_passes.m b/compiler/make_hlds_passes.m index 5a1b0b74a..4b32d7eef 100644 --- a/compiler/make_hlds_passes.m +++ b/compiler/make_hlds_passes.m @@ -580,7 +580,7 @@ parse_tree_to_hlds(ProgressStream, AugCompUnit, Globals, DumpBaseFileName, !ModuleInfo, !QualInfo, !ErrSpecs, !WarnSpecs, !InfoSpecs), add_decl_pragmas_type_spec(DeclTypeSpec, !ModuleInfo, !QualInfo, !ErrSpecs, !WarnSpecs), - add_decl_pragmas_input_spec(DeclInputSpec, + add_decl_pragmas_input_mode_spec(DeclInputSpec, !ModuleInfo, !ErrSpecs), add_decl_pragmas_termination(DeclTermination, !ModuleInfo, !ErrSpecs), diff --git a/compiler/make_hlds_separate_items.m b/compiler/make_hlds_separate_items.m index 3e24552d4..ea54874af 100644 --- a/compiler/make_hlds_separate_items.m +++ b/compiler/make_hlds_separate_items.m @@ -90,7 +90,7 @@ ims_list(item_decl_marker_info)::out, list(decl_pragma_type_spec_constr_info)::out, list(decl_pragma_type_spec_info)::out, - ims_list(decl_pragma_input_spec_info)::out, + ims_list(decl_pragma_input_mode_spec_info)::out, list(decl_pragma_termination_info)::out, list(decl_pragma_termination2_info)::out, list(decl_pragma_struct_sharing_info)::out, @@ -155,7 +155,8 @@ ia_decl_type_spec_constr :: cord(decl_pragma_type_spec_constr_info), ia_decl_type_spec :: cord(decl_pragma_type_spec_info), - ia_decl_input_spec :: ims_cord(decl_pragma_input_spec_info), + ia_decl_input_spec :: + ims_cord(decl_pragma_input_mode_spec_info), ia_decl_term :: cord(decl_pragma_termination_info), ia_decl_term2 :: cord(decl_pragma_termination2_info), ia_decl_str_sharing :: cord(decl_pragma_struct_sharing_info), diff --git a/compiler/module_qual.qualify_items.m b/compiler/module_qual.qualify_items.m index 5b90e92e0..b5c12e71a 100644 --- a/compiler/module_qual.qualify_items.m +++ b/compiler/module_qual.qualify_items.m @@ -1929,8 +1929,8 @@ module_qualify_item_decl_pragma(InInt, Pragma0, Pragma, !Info) :- SpecPredName, Subst, TVarSet, Items, Context, SeqNum), Pragma = decl_pragma_type_spec(TypeSpecInfo) ; - Pragma0 = decl_pragma_input_spec(InputSpecInfo0), - InputSpecInfo0 = decl_pragma_input_spec_info(ContainingModuleName, + Pragma0 = decl_pragma_input_mode_spec(InputSpecInfo0), + InputSpecInfo0 = decl_pragma_input_mode_spec_info(ContainingModuleName, Type0, ReplaceOrAdd, OoMInstCtors0, OoMInsts0, RecompItems, TVarSet, Context, SeqNum), ErrorContext = mqec_pragma_decl(Context, Pragma0), @@ -1939,10 +1939,10 @@ module_qualify_item_decl_pragma(InInt, Pragma0, Pragma, !Info) :- OoMInstCtors0, OoMInstCtors, !Info), one_or_more.map_foldl(qualify_inst(InInt, ErrorContext), OoMInsts0, OoMInsts, !Info), - InputSpecInfo = decl_pragma_input_spec_info(ContainingModuleName, + InputSpecInfo = decl_pragma_input_mode_spec_info(ContainingModuleName, Type, ReplaceOrAdd, OoMInstCtors, OoMInsts, RecompItems, TVarSet, Context, SeqNum), - Pragma = decl_pragma_input_spec(InputSpecInfo) + Pragma = decl_pragma_input_mode_spec(InputSpecInfo) ; Pragma0 = decl_pragma_oisu(OISUInfo0), OISUInfo0 = decl_pragma_oisu_info(TypeCtor0, CreatorPreds, diff --git a/compiler/parse_pragma.m b/compiler/parse_pragma.m index 20d8d1c78..ef986411a 100644 --- a/compiler/parse_pragma.m +++ b/compiler/parse_pragma.m @@ -254,8 +254,8 @@ parse_named_pragma(ModuleName, VarSet, ErrorTerm, PragmaName, PragmaTerms, parse_pragma_type_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, Context, SeqNum, MaybeIOM) ; - PragmaName = "input_spec", - parse_pragma_input_spec(ModuleName, VarSet, ErrorTerm, + PragmaName = "input_mode_spec", + parse_pragma_input_mode_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, Context, SeqNum, MaybeIOM) ; PragmaName = "fact_table", @@ -2128,20 +2128,20 @@ name_anonymous_variable(NamedVarNames, AnonVar, !Counter, !VarSet) :- %---------------------------------------------------------------------------% % -% Parse input_spec pragmas. +% Parse input_mode_spec pragmas. % -:- pred parse_pragma_input_spec(module_name::in, varset::in, term::in, +:- pred parse_pragma_input_mode_spec(module_name::in, varset::in, term::in, list(term)::in, prog_context::in, item_seq_num::in, maybe1(item_or_marker)::out) is det. -parse_pragma_input_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, +parse_pragma_input_mode_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, Context, SeqNum, MaybeIOM) :- ( if PragmaTerms = [TypeTerm, ReplaceOrAddTerm, InstsTerm] then TypeContextPieces = cord.from_list( - [words("In the first argument of"), pragma_decl("input_spec"), + [words("In the first argument of"), pragma_decl("input_mode_spec"), words("declaration:"), nl]), - parse_type(no_allow_ho_inst_info(wnhii_pragma_input_spec), + parse_type(no_allow_ho_inst_info(wnhii_pragma_input_mode_spec), VarSet, TypeContextPieces, TypeTerm, MaybeType), ( if ReplaceOrAddTerm = term.functor(atom(RoAStr), [], _), @@ -2154,7 +2154,7 @@ parse_pragma_input_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, ReplaceOrAddTermStr = mercury_term_to_string_vs(VarSet, print_name_only, ReplaceOrAddTerm), RoAPieces = [words("In the second argument of"), - pragma_decl("input_spec"), words("declaration:"), nl, + pragma_decl("input_mode_spec"), words("declaration:"), nl, words("error: expected either")] ++ color_as_correct([fixed("replace_in_mode")]) ++ [words("or")] ++ @@ -2169,7 +2169,7 @@ parse_pragma_input_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, ), ( if list_term_to_term_list(InstsTerm, InstTerms) then ListContextPieces = [words("In the third argument of"), - pragma_decl("input_spec"), words("declaration:"), nl], + pragma_decl("input_mode_spec"), words("declaration:"), nl], list.filter_map(term_to_inst_ctor, InstTerms, InstCtors, BadInstTerms), ( @@ -2215,7 +2215,7 @@ parse_pragma_input_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, InstsTermStr = mercury_term_to_string_vs(VarSet, print_name_only, InstsTerm), ListPieces = [words("In the third argument of"), - pragma_decl("input_spec"), words("declaration:"), nl, + pragma_decl("input_mode_spec"), words("declaration:"), nl, words("error: expected a nonempty")] ++ color_as_correct([words("list of inst names,")]) ++ [words("got")] ++ @@ -2234,10 +2234,10 @@ parse_pragma_input_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, (func(inst_ctor(SN, _)) = defined_inst(user_inst(SN, []))), OoMInsts = one_or_more.map(InstCtorToInst, OoMInstCtors), varset.coerce(VarSet, TVarSet), - InputSpec = decl_pragma_input_spec_info(ModuleName, Type, + InputSpec = decl_pragma_input_mode_spec_info(ModuleName, Type, ReplaceOrAdd, OoMInstCtors, OoMInsts, set.init, TVarSet, Context, SeqNum), - Item = item_decl_pragma(decl_pragma_input_spec(InputSpec)), + Item = item_decl_pragma(decl_pragma_input_mode_spec(InputSpec)), MaybeIOM = ok1(iom_item(Item)) else Specs = get_any_errors1(MaybeType) ++ @@ -2250,7 +2250,7 @@ parse_pragma_input_spec(ModuleName, VarSet, ErrorTerm, PragmaTerms, % HeadTypeSubstTerm, TailTypeSubstTerms, % TVarSubsts, [], TypeSpecs) else - Spec = report_pragma_arity_error(ErrorTerm, "input_spec", + Spec = report_pragma_arity_error(ErrorTerm, "input_mode_spec", "three arguments"), MaybeIOM = error1(one_or_more(Spec, [])) ). diff --git a/compiler/parse_tree_out.m b/compiler/parse_tree_out.m index 5cec6471a..577cc0f54 100644 --- a/compiler/parse_tree_out.m +++ b/compiler/parse_tree_out.m @@ -910,7 +910,7 @@ mercury_format_parse_tree_plain_opt(Info, S, ParseTree, !U) :- list.foldl(mercury_format_item_impl_marker(S), coerce(ImplMarkers), !U), list.foldl(mercury_format_pragma_type_spec(S, Lang), TypeSpecs, !U), - list.foldl(mercury_format_pragma_input_spec(S, Lang), InputSpecs, !U), + list.foldl(mercury_format_pragma_input_mode_spec(S, Lang), InputSpecs, !U), list.foldl(mercury_format_item_clause(Info, S), Clauses, !U), list.foldl(mercury_format_item_foreign_proc(S, Lang), ForeignProcs, !U), list.foldl(mercury_format_item_promise(Info, S), Promises, !U), diff --git a/compiler/parse_tree_out_pragma.m b/compiler/parse_tree_out_pragma.m index bcef0dcd0..8b8536168 100644 --- a/compiler/parse_tree_out_pragma.m +++ b/compiler/parse_tree_out_pragma.m @@ -76,8 +76,9 @@ :- pred mercury_format_pragma_type_spec(S::in, output_lang::in, decl_pragma_type_spec_info::in, U::di, U::uo) is det <= pt_output(S, U). -:- pred mercury_format_pragma_input_spec(S::in, output_lang::in, - decl_pragma_input_spec_info::in, U::di, U::uo) is det <= pt_output(S, U). +:- pred mercury_format_pragma_input_mode_spec(S::in, output_lang::in, + decl_pragma_input_mode_spec_info::in, U::di, U::uo) is det + <= pt_output(S, U). :- pred mercury_format_pragma_unused_args(S::in, gen_pragma_unused_args_info::in, U::di, U::uo) is det <= pt_output(S, U). @@ -194,8 +195,8 @@ mercury_format_item_decl_pragma(Info, Stream, DeclPragma, !IO) :- DeclPragma = decl_pragma_type_spec(TypeSpec), mercury_format_pragma_type_spec(Stream, Lang, TypeSpec, !IO) ; - DeclPragma = decl_pragma_input_spec(InputSpec), - mercury_format_pragma_input_spec(Stream, Lang, InputSpec, !IO) + DeclPragma = decl_pragma_input_mode_spec(InputSpec), + mercury_format_pragma_input_mode_spec(Stream, Lang, InputSpec, !IO) ; DeclPragma = decl_pragma_oisu(OISU), mercury_format_pragma_oisu(OISU, Stream, !IO) @@ -1081,18 +1082,18 @@ mercury_format_tvar_subst(VarSet, TVarSubst, S, !U) :- %---------------------------------------------------------------------------% % -% Output an input_spec pragma. +% Output an input_mode_spec pragma. % -mercury_format_pragma_input_spec(S, _Lang, InputSpec, !U) :- - InputSpec = decl_pragma_input_spec_info(_ContainingModuleName, +mercury_format_pragma_input_mode_spec(S, _Lang, InputSpec, !U) :- + InputSpec = decl_pragma_input_mode_spec_info(_ContainingModuleName, Type, ReplaceOrAdd, OoMInstCtors, _OoMInsts, _, TVarSet, _, _), InstCtors = one_or_more_to_list(OoMInstCtors), InstStrs0 = list.map(get_zero_arity_inst_ctor_name, InstCtors), list.sort(InstStrs0, InstStrs), InstsStr = string.join_list(", ", InstStrs), IndentStr = " ", - add_string(":- pragma input_spec(", S, !U), + add_string(":- pragma input_mode_spec(", S, !U), mercury_format_type(TVarSet, print_name_only, Type, S, !U), add_string(", ", S, !U), ( diff --git a/compiler/parse_type_name.m b/compiler/parse_type_name.m index 9282fecca..95fdba244 100644 --- a/compiler/parse_type_name.m +++ b/compiler/parse_type_name.m @@ -49,7 +49,7 @@ ; wnhii_pragma_struct_reuse ; wnhii_pragma_type_spec_constr ; wnhii_pragma_type_spec - ; wnhii_pragma_input_spec. + ; wnhii_pragma_input_mode_spec. :- pred maybe_parse_type(allow_ho_inst_info::in, term::in, mer_type::out) is semidet. @@ -956,8 +956,8 @@ no_ho_inst_allowed_desc(WNHII, Place, WhyNot) :- WNHII = wnhii_pragma_type_spec, Place = "a type_spec pragma" ; - WNHII = wnhii_pragma_input_spec, - Place = "an input_spec pragma" + WNHII = wnhii_pragma_input_mode_spec, + Place = "an input_mode_spec pragma" ), WhyNot = wna_by_design ). diff --git a/compiler/prog_item_pragma.m b/compiler/prog_item_pragma.m index e212bb63c..79b9a44d8 100644 --- a/compiler/prog_item_pragma.m +++ b/compiler/prog_item_pragma.m @@ -40,7 +40,7 @@ ; decl_pragma_format_call(decl_pragma_format_call_info) ; decl_pragma_type_spec_constr(decl_pragma_type_spec_constr_info) ; decl_pragma_type_spec(decl_pragma_type_spec_info) - ; decl_pragma_input_spec(decl_pragma_input_spec_info) + ; decl_pragma_input_mode_spec(decl_pragma_input_mode_spec_info) ; decl_pragma_oisu(decl_pragma_oisu_info) ; decl_pragma_termination(decl_pragma_termination_info) ; decl_pragma_termination2(decl_pragma_termination2_info) @@ -225,8 +225,8 @@ %---------------------% -:- type decl_pragma_input_spec_info - ---> decl_pragma_input_spec_info( +:- type decl_pragma_input_mode_spec_info + ---> decl_pragma_input_mode_spec_info( % This pragma tells the compiler to replace code % that switches on values of a control type at runtime % with code that switches on those values at compile time. @@ -244,7 +244,7 @@ % :- inst chain for action/0 % ---> chain_gc_stack_frames. % - % input_spec pragma for type action with insts + % input_mode_spec pragma for type action with insts % hoist and chain can replace a mode that contains % an "in" argument of the action type with two modes % that contain "in(hoist)" and "in(chain)" respectively. @@ -258,7 +258,7 @@ % in this module. % % If and when we start --intermod-opt to include - % input_spec pragmas in .opt files, we may also + % input_mode_spec pragmas in .opt files, we may also % need to record the section (interface vs implementation) % in which the pragma occurred. ispec_module_name :: module_name, @@ -697,7 +697,7 @@ get_decl_pragma_context(DeclPragma) = Context :- DeclPragma = decl_pragma_type_spec(TypeSpec), Context = TypeSpec ^ tspec_context ; - DeclPragma = decl_pragma_input_spec(InputSpec), + DeclPragma = decl_pragma_input_mode_spec(InputSpec), Context = InputSpec ^ ispec_context ; DeclPragma = decl_pragma_oisu(OISU), diff --git a/compiler/prog_item_stats.m b/compiler/prog_item_stats.m index 7fcd53561..cde7aa40b 100644 --- a/compiler/prog_item_stats.m +++ b/compiler/prog_item_stats.m @@ -332,7 +332,7 @@ gather_stats_in_item_decl_pragma(DeclPragma, !ItemStats) :- ( DeclPragma = decl_pragma_format_call(_) ; DeclPragma = decl_pragma_type_spec(_) ; DeclPragma = decl_pragma_type_spec_constr(_) - ; DeclPragma = decl_pragma_input_spec(_) + ; DeclPragma = decl_pragma_input_mode_spec(_) ; DeclPragma = decl_pragma_obsolete_pred(_) ; DeclPragma = decl_pragma_obsolete_proc(_) ; DeclPragma = decl_pragma_oisu(_) diff --git a/compiler/prog_parse_tree.m b/compiler/prog_parse_tree.m index 44356b806..24c2ca998 100644 --- a/compiler/prog_parse_tree.m +++ b/compiler/prog_parse_tree.m @@ -633,7 +633,7 @@ ptpo_decl_markers :: list(item_decl_marker_info_opt), ptpo_impl_markers :: list(item_impl_marker_info_opt), ptpo_type_specs :: list(decl_pragma_type_spec_info), - ptpo_input_specs :: list(decl_pragma_input_spec_info), + ptpo_input_specs :: list(decl_pragma_input_mode_spec_info), ptpo_termination :: list(decl_pragma_termination_info), ptpo_termination2 :: list(decl_pragma_termination2_info), ptpo_struct_sharing :: list(decl_pragma_struct_sharing_info), diff --git a/compiler/recompilation.version.m b/compiler/recompilation.version.m index e972e6852..a594dacb9 100644 --- a/compiler/recompilation.version.m +++ b/compiler/recompilation.version.m @@ -977,7 +977,7 @@ gather_decl_pragma_for_what_pf_id(DeclPragma, MaybePredOrFuncId) :- % when we add this pragma to the HLDS. MaybePredOrFuncId = no ; - DeclPragma = decl_pragma_input_spec(_InputSpec), + DeclPragma = decl_pragma_input_mode_spec(_InputSpec), % XXX Like decl_pragma_type_spec_constr, this kind of pragma % applies to all predicates/functions that have arguments % of the specified type. @@ -1476,12 +1476,12 @@ is_decl_pragma_changed(DeclPragma1, DeclPragma2, Changed) :- is_type_subst_changed(TVarSet1, TVarSet2, TypeSubst1, TypeSubst2, unchanged) ; - DeclPragma1 = decl_pragma_input_spec(TypeSpec1), - DeclPragma2 = decl_pragma_input_spec(TypeSpec2), - TypeSpec1 = decl_pragma_input_spec_info(ContainingModule, + DeclPragma1 = decl_pragma_input_mode_spec(TypeSpec1), + DeclPragma2 = decl_pragma_input_mode_spec(TypeSpec2), + TypeSpec1 = decl_pragma_input_mode_spec_info(ContainingModule, Type1, ReplaceOrAdd, OoMInstCtors, OoMInsts, _, TVarSet1, _, _), - TypeSpec2 = decl_pragma_input_spec_info(ContainingModule, + TypeSpec2 = decl_pragma_input_mode_spec_info(ContainingModule, Type2, ReplaceOrAdd, OoMInstCtors, OoMInsts, _, TVarSet2, _, _), type_list_is_unchanged(TVarSet1, TVarSet2, [Type1], [Type2], diff --git a/tests/hard_coded/test_input_spec.m b/tests/hard_coded/test_input_spec.m index 72d58cd7a..b54e9babb 100644 --- a/tests/hard_coded/test_input_spec.m +++ b/tests/hard_coded/test_input_spec.m @@ -2,7 +2,7 @@ % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% % -% Test the operation of input_spec pragmas. +% Test the operation of input_mode_spec pragmas. % %---------------------------------------------------------------------------% @@ -47,8 +47,8 @@ main(!IO) :- :- inst aux_d for aux/0 ---> aux_d. -:- pragma input_spec(control, add_to_in_mode, [ctrl_a, ctrl_b]). -:- pragma input_spec(aux, replace_in_mode, [aux_c, aux_d]). +:- pragma input_mode_spec(control, add_to_in_mode, [ctrl_a, ctrl_b]). +:- pragma input_mode_spec(aux, replace_in_mode, [aux_c, aux_d]). %---------------------------------------------------------------------------% diff --git a/tests/invalid/bad_input_spec.err_exp b/tests/invalid/bad_input_spec.err_exp index acf39e23c..c0f5de944 100644 --- a/tests/invalid/bad_input_spec.err_exp +++ b/tests/invalid/bad_input_spec.err_exp @@ -1,34 +1,34 @@ -bad_input_spec.m:050: Error: an `:- pragma input_spec' declaration must have -bad_input_spec.m:050: three arguments. -bad_input_spec.m:051: In the third argument of `:- pragma input_spec' +bad_input_spec.m:050: Error: an `:- pragma input_mode_spec' declaration must +bad_input_spec.m:050: have three arguments. +bad_input_spec.m:051: In the third argument of `:- pragma input_mode_spec' bad_input_spec.m:051: declaration: bad_input_spec.m:051: error: expected a nonempty list of inst names, got an bad_input_spec.m:051: empty list. -bad_input_spec.m:052: In the second argument of `:- pragma input_spec' +bad_input_spec.m:052: In the second argument of `:- pragma input_mode_spec' bad_input_spec.m:052: declaration: bad_input_spec.m:052: error: expected either replace_in_mode or bad_input_spec.m:052: add_to_in_mode, got add_to_in_mod. -bad_input_spec.m:052: In the third argument of `:- pragma input_spec' +bad_input_spec.m:052: In the third argument of `:- pragma input_mode_spec' bad_input_spec.m:052: declaration: bad_input_spec.m:052: error: expected a nonempty list of inst names, but 9 is bad_input_spec.m:052: not an inst name. -bad_input_spec.m:053: In the third argument of `:- pragma input_spec' +bad_input_spec.m:053: In the third argument of `:- pragma input_mode_spec' bad_input_spec.m:053: declaration: bad_input_spec.m:053: error: expected a nonempty list of inst names, but 42 bad_input_spec.m:053: and "fortytwo" are not inst names. bad_input_spec.m:054: Error: the type constructor `au'/0 has no visible bad_input_spec.m:054: definition. -bad_input_spec.m:054: In `:- pragma input_spec' declaration: +bad_input_spec.m:054: In `:- pragma input_mode_spec' declaration: bad_input_spec.m:054: error: the type `au'/0 is undefined. bad_input_spec.m:054: (Did you mean `aux'?) bad_input_spec.m:055: Error: the type being specialized must be a ground type, bad_input_spec.m:055: but it contains the type variable T. -bad_input_spec.m:056: In `:- pragma input_spec' declaration: +bad_input_spec.m:056: In `:- pragma input_mode_spec' declaration: bad_input_spec.m:056: error: the inst `au_c'/0 is undefined. bad_input_spec.m:056: (Did you mean `aux_c'?) -bad_input_spec.m:056: In `:- pragma input_spec' declaration: +bad_input_spec.m:056: In `:- pragma input_mode_spec' declaration: bad_input_spec.m:056: error: the inst `aux_'/0 is undefined. bad_input_spec.m:056: (Did you mean `aux_c' or `aux_d'?) -bad_input_spec.m:057: Error: duplicate `:- pragma input_spec' declaration for -bad_input_spec.m:057: bad_input_spec.aux. +bad_input_spec.m:057: Error: duplicate `:- pragma input_mode_spec' declaration +bad_input_spec.m:057: for bad_input_spec.aux. bad_input_spec.m:056: The previous declaration was here. diff --git a/tests/invalid/bad_input_spec.m b/tests/invalid/bad_input_spec.m index 4b41adbb1..53c82bfb9 100644 --- a/tests/invalid/bad_input_spec.m +++ b/tests/invalid/bad_input_spec.m @@ -2,7 +2,7 @@ % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% % -% Test errors in input_spec pragmas. +% Test errors in input_mode_spec pragmas. % %---------------------------------------------------------------------------% @@ -47,14 +47,14 @@ main(!IO) :- :- inst aux_d for aux/0 ---> aux_d. -:- pragma input_spec(aux, replace_in_mode). -:- pragma input_spec(aux, replace_in_mode, []). -:- pragma input_spec(control, add_to_in_mod, [9, ctrl_b]). -:- pragma input_spec(control, add_to_in_mode, [42, "fortytwo", ctrl_b]). -:- pragma input_spec(au, replace_in_mode, [aux_c, aux_d]). -:- pragma input_spec(list(T), replace_in_mode, [aux_c, aux_d]). -:- pragma input_spec(aux, replace_in_mode, [au_c, aux_]). -:- pragma input_spec(aux, replace_in_mode, [aux_c, aux_d]). +:- pragma input_mode_spec(aux, replace_in_mode). +:- pragma input_mode_spec(aux, replace_in_mode, []). +:- pragma input_mode_spec(control, add_to_in_mod, [9, ctrl_b]). +:- pragma input_mode_spec(control, add_to_in_mode, [42, "fortytwo", ctrl_b]). +:- pragma input_mode_spec(au, replace_in_mode, [aux_c, aux_d]). +:- pragma input_mode_spec(list(T), replace_in_mode, [aux_c, aux_d]). +:- pragma input_mode_spec(aux, replace_in_mode, [au_c, aux_]). +:- pragma input_mode_spec(aux, replace_in_mode, [aux_c, aux_d]). %---------------------------------------------------------------------------%