diff --git a/compiler/accumulator.m b/compiler/accumulator.m index f179f07db..51d7aa0d2 100644 --- a/compiler/accumulator.m +++ b/compiler/accumulator.m @@ -143,7 +143,7 @@ %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- module transform_hlds__accumulator. +:- module transform_hlds.accumulator. :- interface. :- import_module hlds.hlds_module. @@ -151,7 +151,7 @@ :- import_module io. -:- pred accumulator__process_proc(pred_id::in, proc_id::in, +:- pred accumulator.process_proc(pred_id::in, proc_id::in, proc_info::in, proc_info::out, module_info::in, module_info::out, io::di, io::uo) is det. @@ -227,25 +227,25 @@ % Attempt to transform a procedure into accumulator recursive form. % process_proc(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :- - globals__io_lookup_bool_option(optimize_constructor_last_call_accumulator, + globals.io_lookup_bool_option(optimize_constructor_last_call_accumulator, DoLCO, !IO), - globals__io_lookup_bool_option(fully_strict, FullyStrict, !IO), + globals.io_lookup_bool_option(fully_strict, FullyStrict, !IO), ( module_info_pred_info(!.ModuleInfo, PredId, PredInfo), attempt_transform(ProcId, PredId, PredInfo, DoLCO, FullyStrict, !ProcInfo, !ModuleInfo, Warnings) -> - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string("% Accumulators introduced into ", !IO), - hlds_out__write_pred_id(!.ModuleInfo, PredId, !IO), - io__write_string("\n", !IO) + io.write_string("% Accumulators introduced into ", !IO), + hlds_out.write_pred_id(!.ModuleInfo, PredId, !IO), + io.write_string("\n", !IO) ; VeryVerbose = no ), - globals__io_lookup_bool_option(inhibit_accumulator_warnings, + globals.io_lookup_bool_option(inhibit_accumulator_warnings, InhibitWarnings, !IO), ( ( InhibitWarnings = yes @@ -269,7 +269,7 @@ process_proc(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :- words("`--inhibit-accumulator-warnings'.")], write_error_pieces(Context, 2, Pieces1, !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, Pieces2 = [words("If a predicate has been declared"), @@ -288,12 +288,12 @@ process_proc(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :- write_error_pieces(Context, 2, Pieces2, !IO) ; VerboseErrors = no, - globals__io_set_extra_error_info(yes, !IO) + globals.io_set_extra_error_info(yes, !IO) ), - globals__io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO), + globals.io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO), ( HaltAtWarn = yes, - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), module_info_incr_errors(!ModuleInfo) ; HaltAtWarn = no @@ -323,10 +323,10 @@ output_warning(warn(Context, PredId, VarA, VarB), VarSet, ModuleInfo, PredPieces = describe_one_pred_name(ModuleInfo, should_module_qualify, PredId), - varset__lookup_name(VarSet, VarA, VarAStr0), - varset__lookup_name(VarSet, VarB, VarBStr0), - VarAStr = string__append_list(["`", VarAStr0, "'"]), - VarBStr = string__append_list(["`", VarBStr0, "'"]), + varset.lookup_name(VarSet, VarA, VarAStr0), + varset.lookup_name(VarSet, VarB, VarBStr0), + VarAStr = string.append_list(["`", VarAStr0, "'"]), + VarBStr = string.append_list(["`", VarBStr0, "'"]), Formats = [words("warning: the call to")] ++ PredPieces ++ [words("has had the location of the variables"), @@ -356,7 +356,7 @@ attempt_transform(ProcId, PredId, PredInfo, DoLCO, FullyStrict, C = initialize_goal_store(Rec, RecInstMap, Base, BaseInstMap), identify_recursive_calls(PredId, ProcId, C, RecCallIds), - M = list__length(Rec), + M = list.length(Rec), attempt_transform_2(RecCallIds, C, M, Rec, HeadVars, InitialInstMap, TopLevel, DoLCO, FullyStrict, PredId, PredInfo, !ProcInfo, !ModuleInfo, Warnings). @@ -366,11 +366,11 @@ attempt_transform(ProcId, PredId, PredInfo, DoLCO, FullyStrict, % recursive calls, stopping at the first one that succeeds. % This catches the following case, as selecting the first % recursive call allows the second recursive call to be moved - % before it, and OutA is in the correct spot in list__append. + % before it, and OutA is in the correct spot in list.append. % % p(InA, OutA), % p(InB, OutB), - % list__append(OutB, OutA, Out) + % list.append(OutB, OutA, Out) % :- pred attempt_transform_2(list(goal_id)::in, goal_store::in, int::in, hlds_goals::in, prog_vars::in, instmap::in, top_level::in, @@ -496,7 +496,7 @@ identify_goal_type(PredId, ProcId, Goal, InitialInstMap, Rec = GoalAList, BaseInstMap = InitialInstMap, - instmap__apply_instmap_delta(InitialInstMap, IfInstMapDelta, + instmap.apply_instmap_delta(InitialInstMap, IfInstMapDelta, RecInstMap) ; is_recursive_case(GoalBList, proc(PredId, ProcId)) -> Type = ite_base_rec, @@ -504,7 +504,7 @@ identify_goal_type(PredId, ProcId, Goal, InitialInstMap, Rec = GoalBList, RecInstMap = InitialInstMap, - instmap__apply_instmap_delta(InitialInstMap, IfInstMapDelta, + instmap.apply_instmap_delta(InitialInstMap, IfInstMapDelta, BaseInstMap) ; fail @@ -521,7 +521,7 @@ identify_goal_type(PredId, ProcId, Goal, InitialInstMap, :- pred is_recursive_case(list(hlds_goal)::in, pred_proc_id::in) is semidet. is_recursive_case(Goals, proc(PredId, ProcId)) :- - list__append(_Initial, [RecursiveCall | _Final], Goals), + list.append(_Initial, [RecursiveCall | _Final], Goals), RecursiveCall = call(PredId, ProcId, _, _, _, _) - _. %-----------------------------------------------------------------------------% @@ -543,10 +543,10 @@ is_recursive_case(Goals, proc(PredId, ProcId)) :- = goal_store. initialize_goal_store(Rec, RecInstMap, Base, BaseInstMap) = C :- - goal_store__init(C0), - list__foldl(store(rec), Rec, store_info(1, RecInstMap, C0), + goal_store_init(C0), + list.foldl(store(rec), Rec, store_info(1, RecInstMap, C0), store_info(_, _, C1)), - list__foldl(store(base), Base, store_info(1, BaseInstMap, C1), + list.foldl(store(base), Base, store_info(1, BaseInstMap, C1), store_info(_, _, C)). % store(Id, G, SI0, SI) is true iff the goal G is stored inside @@ -558,9 +558,9 @@ initialize_goal_store(Rec, RecInstMap, Base, BaseInstMap) = C :- store(Identifier, Goal, store_info(N, IM0, GS0), store_info(N+1, IM, GS)) :- Goal = _ - GoalInfo, goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(IM0, InstMapDelta, IM), + instmap.apply_instmap_delta(IM0, InstMapDelta, IM), - goal_store__det_insert(Identifier - N, Goal - IM0, GS0, GS). + goal_store_det_insert(Identifier - N, Goal - IM0, GS0, GS). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -574,7 +574,7 @@ store(Identifier, Goal, store_info(N, IM0, GS0), store_info(N+1, IM, GS)) :- identify_recursive_calls(PredId, ProcId, GoalStore, Ids) :- P = (pred(Key::out) is nondet :- - goal_store__member(GoalStore, Key, Goal - _InstMap), + goal_store_member(GoalStore, Key, Goal - _InstMap), Key = rec - _, Goal = call(PredId, ProcId, _, _, _, _) - _ ), @@ -601,35 +601,35 @@ identify_recursive_calls(PredId, ProcId, GoalStore, Ids) :- identify_out_and_out_prime(_N - K, Rec, HeadVars, InitialInstMap, VarTypes, ModuleInfo, Out, OutPrime, HeadToCallSubst, CallToHeadSubst) :- ( - list__take(K, Rec, InitialGoals), - list__drop(K-1, Rec, FinalGoals), + list.take(K, Rec, InitialGoals), + list.drop(K-1, Rec, FinalGoals), FinalGoals = [call(_, _, Args, _, _, _) - _ | Rest] -> goal_list_instmap_delta(InitialGoals, InitInstMapDelta), - instmap__apply_instmap_delta(InitialInstMap, + instmap.apply_instmap_delta(InitialInstMap, InitInstMapDelta, InstMapBeforeRest), goal_list_instmap_delta(Rest, InstMapDelta), - instmap__apply_instmap_delta(InstMapBeforeRest, + instmap.apply_instmap_delta(InstMapBeforeRest, InstMapDelta, InstMapAfterRest), instmap_changed_vars(InstMapBeforeRest, InstMapAfterRest, VarTypes, ModuleInfo, ChangedVars), - assoc_list__from_corresponding_lists(HeadVars, Args, HeadArg0), + assoc_list.from_corresponding_lists(HeadVars, Args, HeadArg0), Member = (pred(M::in) is semidet :- M = HeadVar - _, - set__member(HeadVar, ChangedVars) + set.member(HeadVar, ChangedVars) ), - list__filter(Member, HeadArg0, HeadArg), - list__map(fst, HeadArg, Out), - list__map(snd, HeadArg, OutPrime), + list.filter(Member, HeadArg0, HeadArg), + list.map(fst, HeadArg, Out), + list.map(snd, HeadArg, OutPrime), - map__from_assoc_list(HeadArg, HeadToCallSubst), + map.from_assoc_list(HeadArg, HeadToCallSubst), - list__map((pred(X-Y::in, Y-X::out) is det), HeadArg, ArgHead), - map__from_assoc_list(ArgHead, CallToHeadSubst) + list.map((pred(X-Y::in, Y-X::out) is det), HeadArg, ArgHead), + map.from_assoc_list(ArgHead, CallToHeadSubst) ; unexpected(this_file, "identify_out_and_out_prime") ). @@ -664,25 +664,25 @@ stage1(N - K, M, GoalStore, DoLCO, FullyStrict, VarTypes, ModuleInfo, Sets) :- stage1_2(N - (K+1), K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, Sets0, Sets1), Sets1 = sets(Before, Assoc, ConstructAssoc, Construct, Update, Reject), - Sets = sets(Before `set__union` set_upto(N, (K-1)), Assoc, + Sets = sets(Before `set.union` set_upto(N, (K-1)), Assoc, ConstructAssoc, Construct, Update, Reject), % Continue the transformation only if the set reject is % empty and the set assoc or update contains something % that needs to be moved before the recursive call. - set__empty(Reject), + set.empty(Reject), ( - not set__empty(Assoc) + not set.empty(Assoc) ; - not set__empty(Update) + not set.empty(Update) ), ( DoLCO = no, % If LCMC is not turned on then there must be no % construction unifications after the recursive % call. - set__empty(Construct), - set__empty(ConstructAssoc) + set.empty(Construct), + set.empty(ConstructAssoc) ; DoLCO = yes ). @@ -701,14 +701,14 @@ stage1_2(N - I, K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) :- before(N - I, K, GoalStore, !.Sets, FullyStrict, VarTypes, ModuleInfo) -> - !:Sets = !.Sets ^ before := set__insert(!.Sets ^ before, N - I), + !:Sets = !.Sets ^ before := set.insert(!.Sets ^ before, N - I), stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) ; assoc(N - I, K, GoalStore, !.Sets, FullyStrict, VarTypes, ModuleInfo) -> - !:Sets = !.Sets ^ assoc := set__insert(!.Sets ^ assoc, N - I), + !:Sets = !.Sets ^ assoc := set.insert(!.Sets ^ assoc, N - I), stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) ; @@ -716,7 +716,7 @@ stage1_2(N - I, K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) :- ModuleInfo) -> !:Sets = !.Sets ^ construct := - set__insert(!.Sets ^ construct, N - I), + set.insert(!.Sets ^ construct, N - I), stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) ; @@ -724,18 +724,18 @@ stage1_2(N - I, K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) :- ModuleInfo) -> !:Sets = !.Sets ^ construct_assoc := - set__insert(!.Sets ^ construct_assoc, N-I), + set.insert(!.Sets ^ construct_assoc, N-I), stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) ; update(N - I, K, GoalStore, !.Sets, FullyStrict, VarTypes, ModuleInfo) -> - !:Sets = !.Sets ^ update := set__insert(!.Sets ^ update, N - I), + !:Sets = !.Sets ^ update := set.insert(!.Sets ^ update, N - I), stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) ; - !:Sets = !.Sets ^ reject := set__insert(!.Sets ^ reject, N - I) + !:Sets = !.Sets ^ reject := set.insert(!.Sets ^ reject, N - I) ) ). @@ -744,7 +744,7 @@ stage1_2(N - I, K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) :- :- pred sets_init(sets::out) is det. sets_init(Sets) :- - set__init(EmptySet), + set.init(EmptySet), Before = EmptySet, Assoc = EmptySet, ConstructAssoc = EmptySet, @@ -759,15 +759,14 @@ sets_init(Sets) :- set_upto(N, K) = Set :- ( K =< 0 -> - set__init(Set) + set.init(Set) ; Set0 = set_upto(N, K-1), - set__insert(Set0, pair(N, K), Set) + set.insert(Set0, pair(N, K), Set) ). %-----------------------------------------------------------------------------% - % % A goal is a member of the before set iff the goal only depends on % goals which are before the recursive call or can be moved % before the recursive call (member of the before set). @@ -777,17 +776,17 @@ set_upto(N, K) = Set :- before(N - I, K, GoalStore, sets(Before, _, _, _, _, _), FullyStrict, VarTypes, ModuleInfo) :- - goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap), + goal_store_lookup(GoalStore, N - I, LaterGoal - LaterInstMap), ( member_lessthan_goalid(GoalStore, N - I, N - J, EarlierGoal - EarlierInstMap), - not goal_util__can_reorder_goals(ModuleInfo, VarTypes, + not goal_util.can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal) ) => ( - set__member(N - J, set_upto(N, K-1) `union` Before) + set.member(N - J, set_upto(N, K-1) `union` Before) ). % A goal is a member of the assoc set iff the goal only depends @@ -800,18 +799,18 @@ before(N - I, K, GoalStore, sets(Before, _, _, _, _, _), assoc(N - I, K, GoalStore, sets(Before, _, _, _, _, _), FullyStrict, VarTypes, ModuleInfo) :- - goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap), + goal_store_lookup(GoalStore, N - I, LaterGoal - LaterInstMap), LaterGoal = call(PredId, _, Args, _, _, _) - _, is_associative(PredId, ModuleInfo, Args, _), ( member_lessthan_goalid(GoalStore, N - I, _N - J, EarlierGoal - EarlierInstMap), - not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, + not goal_util.can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal) ) => ( - set__member(N - J, set_upto(N, K) `union` Before) + set.member(N - J, set_upto(N, K) `union` Before) ). % A goal is a member of the construct set iff the goal only depends @@ -824,19 +823,18 @@ assoc(N - I, K, GoalStore, sets(Before, _, _, _, _, _), construct(N - I, K, GoalStore, sets(Before, _, _, Construct, _, _), FullyStrict, VarTypes, ModuleInfo) :- - goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap), + goal_store_lookup(GoalStore, N - I, LaterGoal - LaterInstMap), LaterGoal = unify(_, _, _, Unify, _) - _GoalInfo, Unify = construct(_, _, _, _, _, _, _), ( member_lessthan_goalid(GoalStore, N - I, _N - J, EarlierGoal - EarlierInstMap), - not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, + not goal_util.can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal) ) => ( - set__member(N - J, set_upto(N, K) `union` Before `union` - Construct) + set.member(N - J, set_upto(N, K) `union` Before `union` Construct) ). % A goal is a member of the construct_assoc set iff the goal @@ -854,27 +852,27 @@ construct(N - I, K, GoalStore, sets(Before, _, _, Construct, _, _), construct_assoc(N - I, K, GoalStore, sets(Before, Assoc, ConstructAssoc, _, _, _), FullyStrict, VarTypes, ModuleInfo) :- - goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap), + goal_store_lookup(GoalStore, N - I, LaterGoal - LaterInstMap), LaterGoal = unify(_, _, _, Unify, _) - _GoalInfo, Unify = construct(_, ConsId, _, _, _, _, _), - goal_store__all_ancestors(GoalStore, N - I, VarTypes, ModuleInfo, + goal_store_all_ancestors(GoalStore, N - I, VarTypes, ModuleInfo, FullyStrict, Ancestors), - set__singleton_set(Assoc `intersect` Ancestors, AssocId), - goal_store__lookup(GoalStore, AssocId, AssocGoal - _AssocInstMap), + set.singleton_set(Assoc `intersect` Ancestors, AssocId), + goal_store_lookup(GoalStore, AssocId, AssocGoal - _AssocInstMap), AssocGoal = call(PredId, _, _, _, _, _) - _, is_associative_construction(ConsId, PredId, ModuleInfo), ( member_lessthan_goalid(GoalStore, N - I, _N - J, EarlierGoal - EarlierInstMap), - not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, + not goal_util.can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal) ) => ( - set__member(N - J, set_upto(N, K) `union` Before `union` + set.member(N - J, set_upto(N, K) `union` Before `union` Assoc `union` ConstructAssoc) ). @@ -888,18 +886,18 @@ construct_assoc(N - I, K, GoalStore, sets(Before, Assoc, ConstructAssoc, update(N - I, K, GoalStore, sets(Before, _, _, _, _, _), FullyStrict, VarTypes, ModuleInfo) :- - goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap), + goal_store_lookup(GoalStore, N - I, LaterGoal - LaterInstMap), LaterGoal = call(PredId, _, Args, _, _, _) - _, is_update(PredId, ModuleInfo, Args, _), ( member_lessthan_goalid(GoalStore, N - I, _N - J, EarlierGoal - EarlierInstMap), - not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, + not goal_util.can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal) ) => ( - set__member(N - J, set_upto(N, K) `union` Before) + set.member(N - J, set_upto(N, K) `union` Before) ). % member_lessthan_goalid(GS, IdA, IdB, GB) is true iff the @@ -910,7 +908,7 @@ update(N - I, K, GoalStore, sets(Before, _, _, _, _, _), goal_id::out, stored_goal::out) is nondet. member_lessthan_goalid(GoalStore, N - I, N - J, Goal) :- - goal_store__member(GoalStore, N - J, Goal), + goal_store_member(GoalStore, N - J, Goal), J < I. %-----------------------------------------------------------------------------% @@ -933,10 +931,10 @@ member_lessthan_goalid(GoalStore, N - I, N - J, Goal) :- is_associative(PredId, ModuleInfo, Args, Result) :- module_info_pred_info(ModuleInfo, PredId, PredInfo), pred_info_get_assertions(PredInfo, Assertions), - associativity_assertion(set__to_sorted_list(Assertions), ModuleInfo, + associativity_assertion(set.to_sorted_list(Assertions), ModuleInfo, Args, AssociativeVars, OutputVar), ( - commutativity_assertion(set__to_sorted_list(Assertions), + commutativity_assertion(set.to_sorted_list(Assertions), ModuleInfo, Args, _CommutativeVars) -> IsCommutative = yes @@ -958,11 +956,11 @@ is_associative(PredId, ModuleInfo, Args, Result) :- associativity_assertion([AssertId | AssertIds], ModuleInfo, Args0, VarAB, OutputVar) :- ( - assertion__is_associativity_assertion(AssertId, ModuleInfo, + assertion.is_associativity_assertion(AssertId, ModuleInfo, Args0, VarA - VarB, OutputVar0) -> \+ associativity_assertion(AssertIds, ModuleInfo, Args0, _, _), - VarAB = set__list_to_set([VarA, VarB]), + VarAB = set.list_to_set([VarA, VarB]), OutputVar = OutputVar0 ; associativity_assertion(AssertIds, ModuleInfo, Args0, VarAB, OutputVar) @@ -981,11 +979,11 @@ associativity_assertion([AssertId | AssertIds], ModuleInfo, Args0, VarAB, commutativity_assertion([AssertId | AssertIds], ModuleInfo, Args0, PossibleStaticVars) :- ( - assertion__is_commutativity_assertion(AssertId, ModuleInfo, + assertion.is_commutativity_assertion(AssertId, ModuleInfo, Args0, StaticVarA - StaticVarB) -> \+ commutativity_assertion(AssertIds, ModuleInfo, Args0, _), - PossibleStaticVars = set__list_to_set([StaticVarA, StaticVarB]) + PossibleStaticVars = set.list_to_set([StaticVarA, StaticVarB]) ; commutativity_assertion(AssertIds, ModuleInfo, Args0, PossibleStaticVars) @@ -1003,12 +1001,12 @@ is_update(PredId, ModuleInfo, Args, ResultStateVars) :- pred_info_get_assertions(PredInfo, Assertions), - list__filter_map( + list.filter_map( (pred(AssertId::in, StateVars::out) is semidet :- - assertion__is_update_assertion(AssertId, ModuleInfo, + assertion.is_update_assertion(AssertId, ModuleInfo, PredId, Args, StateVars) ), - set__to_sorted_list(Assertions), Result), + set.to_sorted_list(Assertions), Result), % XXX maybe we should just match on the first result, % just in case there is duplicate promises. @@ -1025,34 +1023,34 @@ is_update(PredId, ModuleInfo, Args, ResultStateVars) :- is_associative_construction(ConsId, PredId, ModuleInfo) :- module_info_pred_info(ModuleInfo, PredId, PredInfo), pred_info_get_assertions(PredInfo, Assertions), - list__filter( + list.filter( (pred(AssertId::in) is semidet :- - assertion__is_construction_equivalence_assertion( - AssertId, ModuleInfo, ConsId, PredId) + assertion.is_construction_equivalence_assertion(AssertId, + ModuleInfo, ConsId, PredId) ), - set__to_sorted_list(Assertions), Result), - Result \= []. + set.to_sorted_list(Assertions), Result), + Result = [_ | _]. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- type substs ---> - substs( - acc_var_subst :: subst, - rec_call_subst :: subst, - assoc_call_subst :: subst, - update_subst :: subst - ). +:- type substs + ---> substs( + acc_var_subst :: subst, + rec_call_subst :: subst, + assoc_call_subst :: subst, + update_subst :: subst + ). -:- type base ---> - base( - init_update :: set(goal_id), - % goals which initialize update - init_assoc :: set(goal_id), - % goals which initialize assoc - other :: set(goal_id) - % other goals - ). +:- type base + ---> base( + init_update :: set(goal_id), + % goals which initialize update + init_assoc :: set(goal_id), + % goals which initialize assoc + other :: set(goal_id) + % other goals + ). % Stage 2 is responsible for identifying the substitutions which % are needed to mimic the unfold/fold process that was used as @@ -1082,29 +1080,29 @@ stage2(N - K, GoalStore, Sets, OutPrime, Out, ModuleInfo, ProcInfo0, After = Assoc `union` ConstructAssoc `union` Construct, P = (pred(Id::in, Set0::in, Set::out) is det :- - goal_store__lookup(GoalStore, Id, Goal - _InstMap), + goal_store_lookup(GoalStore, Id, Goal - _InstMap), Goal = _GoalExpr - GoalInfo, goal_info_get_nonlocals(GoalInfo, NonLocals), Set = NonLocals `union` Set0 ), - list__foldl(P, set__to_sorted_list(Before), set__init, BeforeNonLocals), - list__foldl(P, set__to_sorted_list(After), set__init, AfterNonLocals), + list.foldl(P, set.to_sorted_list(Before), set.init, BeforeNonLocals), + list.foldl(P, set.to_sorted_list(After), set.init, AfterNonLocals), InitAccs = BeforeNonLocals `intersect` AfterNonLocals, proc_info_varset(ProcInfo0, !:VarSet), proc_info_vartypes(ProcInfo0, !:VarTypes), - substs_init(set__to_sorted_list(InitAccs), !VarSet, !VarTypes, !:Substs), + substs_init(set.to_sorted_list(InitAccs), !VarSet, !VarTypes, !:Substs), - set__list_to_set(OutPrime, OutPrimeSet), - process_assoc_set(set__to_sorted_list(Assoc), GoalStore, OutPrimeSet, + set.list_to_set(OutPrime, OutPrimeSet), + process_assoc_set(set.to_sorted_list(Assoc), GoalStore, OutPrimeSet, ModuleInfo, !Substs, !VarSet, !VarTypes, CS, Warnings), - process_update_set(set__to_sorted_list(Update), GoalStore, OutPrimeSet, + process_update_set(set.to_sorted_list(Update), GoalStore, OutPrimeSet, ModuleInfo, !Substs, !VarSet, !VarTypes, UpdateOut, UpdateAccOut, BasePairs), - Accs = set__to_sorted_list(InitAccs) ++ UpdateAccOut, + Accs = set.to_sorted_list(InitAccs) ++ UpdateAccOut, divide_base_case(UpdateOut, Out, GoalStore, !.VarTypes, ModuleInfo, UpdateBase, AssocBase, OtherBase), @@ -1117,7 +1115,7 @@ stage2(N - K, GoalStore, Sets, OutPrime, Out, ModuleInfo, ProcInfo0, vartypes::in, vartypes::out, substs::out) is det. substs_init(InitAccs, !VarSet, !VarTypes, Substs) :- - map__init(Subst), + map.init(Subst), acc_var_subst_init(InitAccs, !VarSet, !VarTypes, AccVarSubst), RecCallSubst = Subst, AssocCallSubst = Subst, @@ -1132,11 +1130,11 @@ substs_init(InitAccs, !VarSet, !VarTypes, Substs) :- :- pred acc_var_subst_init(prog_vars::in, prog_varset::in, prog_varset::out, vartypes::in, vartypes::out, subst::out) is det. -acc_var_subst_init([], !VarSet, !VarTypes, map__init). +acc_var_subst_init([], !VarSet, !VarTypes, map.init). acc_var_subst_init([Var | Vars], !VarSet, !VarTypes, Subst) :- create_new_var(Var, "A_", AccVar, !VarSet, !VarTypes), acc_var_subst_init(Vars, !VarSet, !VarTypes, Subst0), - map__det_insert(Subst0, Var, AccVar, Subst). + map.det_insert(Subst0, Var, AccVar, Subst). % Create a fresh variable which is the same type as the old % variable and has the same name except that it begins with the @@ -1146,11 +1144,11 @@ acc_var_subst_init([Var | Vars], !VarSet, !VarTypes, Subst) :- prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det. create_new_var(OldVar, Prefix, NewVar, !VarSet, !VarTypes) :- - varset__lookup_name(!.VarSet, OldVar, OldName), - string__append(Prefix, OldName, NewName), - varset__new_named_var(!.VarSet, NewName, NewVar, !:VarSet), - map__lookup(!.VarTypes, OldVar, Type), - map__det_insert(!.VarTypes, NewVar, Type, !:VarTypes). + varset.lookup_name(!.VarSet, OldVar, OldName), + string.append(Prefix, OldName, NewName), + varset.new_named_var(!.VarSet, NewName, NewVar, !:VarSet), + map.lookup(!.VarTypes, OldVar, Type), + map.det_insert(!.VarTypes, NewVar, Type, !:VarTypes). %-----------------------------------------------------------------------------% @@ -1165,7 +1163,7 @@ create_new_var(OldVar, Prefix, NewVar, !VarSet, !VarTypes) :- process_assoc_set([], _GS, _OutPrime, _ModuleInfo, !Substs, !VarSet, !VarTypes, CS, []) :- - goal_store__init(CS). + goal_store_init(CS). process_assoc_set([Id | Ids], GS, OutPrime, ModuleInfo, !Substs, !VarSet, !VarTypes, CS, Warnings) :- !.Substs = substs(AccVarSubst, RecCallSubst0, AssocCallSubst0, @@ -1176,17 +1174,17 @@ process_assoc_set([Id | Ids], GS, OutPrime, ModuleInfo, !Substs, Goal = call(PredId, _, Args, _, _, _) - GoalInfo, is_associative(PredId, ModuleInfo, Args, AssocInfo), AssocInfo = assoc(Vars, AssocOutput, IsCommutative), - set__singleton_set(Vars `intersect` OutPrime, DuringAssocVar), - set__singleton_set(Vars `difference` (Vars `intersect` OutPrime), + set.singleton_set(Vars `intersect` OutPrime, DuringAssocVar), + set.singleton_set(Vars `difference` (Vars `intersect` OutPrime), BeforeAssocVar), - map__lookup(AccVarSubst, BeforeAssocVar, AccVar), + map.lookup(AccVarSubst, BeforeAssocVar, AccVar), create_new_var(BeforeAssocVar, "NewAcc_", NewAcc, !VarSet, !VarTypes), - map__det_insert(AssocCallSubst0, DuringAssocVar, AccVar, AssocCallSubst1), - map__det_insert(AssocCallSubst1, AssocOutput, NewAcc, AssocCallSubst), - map__det_insert(RecCallSubst0, DuringAssocVar, AssocOutput, RecCallSubst1), - map__det_insert(RecCallSubst1, BeforeAssocVar, NewAcc, RecCallSubst), + map.det_insert(AssocCallSubst0, DuringAssocVar, AccVar, AssocCallSubst1), + map.det_insert(AssocCallSubst1, AssocOutput, NewAcc, AssocCallSubst), + map.det_insert(RecCallSubst0, DuringAssocVar, AssocOutput, RecCallSubst1), + map.det_insert(RecCallSubst1, BeforeAssocVar, NewAcc, RecCallSubst), !:Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst, UpdateSubst), @@ -1212,7 +1210,7 @@ process_assoc_set([Id | Ids], GS, OutPrime, ModuleInfo, !Substs, % of the predicate. heuristic(ModuleName, PredName, Arity, Args, PossibleDuringAssocVars), - set__member(DuringAssocVar, PossibleDuringAssocVars), + set.member(DuringAssocVar, PossibleDuringAssocVars), Warning = [] ; goal_info_get_context(GoalInfo, ProgContext), @@ -1220,16 +1218,16 @@ process_assoc_set([Id | Ids], GS, OutPrime, ModuleInfo, !Substs, DuringAssocVar)] ), % Swap the arguments. - [A, B] = set__to_sorted_list(Vars), - map__from_assoc_list([A-B, B-A], Subst), - goal_util__rename_vars_in_goal(Subst, Goal, SwappedGoal), + [A, B] = set.to_sorted_list(Vars), + map.from_assoc_list([A-B, B-A], Subst), + goal_util.rename_vars_in_goal(Subst, Goal, SwappedGoal), CSGoal = SwappedGoal - InstMap ), process_assoc_set(Ids, GS, OutPrime, ModuleInfo, !Substs, !VarSet, !VarTypes, CS0, Warnings0), - goal_store__det_insert(Id, CSGoal, CS0, CS), - list__append(Warnings0, Warning, Warnings). + goal_store_det_insert(Id, CSGoal, CS0, CS), + list.append(Warnings0, Warning, Warnings). :- pred has_heuristic(module_name::in, string::in, arity::in) is semidet. @@ -1242,7 +1240,7 @@ has_heuristic(unqualified("list"), "append", 3). set(prog_var)::out) is semidet. heuristic(unqualified("list"), "append", 3, [_Typeinfo, A, _B, _C], Set) :- - set__list_to_set([A], Set). + set.list_to_set([A], Set). %-----------------------------------------------------------------------------% @@ -1267,7 +1265,7 @@ process_update_set([Id | Ids], GS, OutPrime, ModuleInfo, !Substs, Goal = call(PredId, _, Args, _, _, _) - _GoalInfo, is_update(PredId, ModuleInfo, Args, StateVarA - StateVarB), - ( set__member(StateVarA, OutPrime) -> + ( set.member(StateVarA, OutPrime) -> StateInputVar = StateVarA, StateOutputVar = StateVarB ; @@ -1278,11 +1276,11 @@ process_update_set([Id | Ids], GS, OutPrime, ModuleInfo, !Substs, create_new_var(StateInputVar, "Acc_", Acc0, !VarSet, !VarTypes), create_new_var(StateOutputVar, "Acc_", Acc, !VarSet, !VarTypes), - map__det_insert(UpdateSubst0, StateInputVar, Acc0, UpdateSubst1), - map__det_insert(UpdateSubst1, StateOutputVar, Acc, UpdateSubst), - map__det_insert(RecCallSubst0, StateInputVar, StateOutputVar, + map.det_insert(UpdateSubst0, StateInputVar, Acc0, UpdateSubst1), + map.det_insert(UpdateSubst1, StateOutputVar, Acc, UpdateSubst), + map.det_insert(RecCallSubst0, StateInputVar, StateOutputVar, RecCallSubst), - map__det_insert(AccVarSubst0, Acc, Acc0, AccVarSubst), + map.det_insert(AccVarSubst0, Acc, Acc0, AccVarSubst), !:Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst, UpdateSubst), process_update_set(Ids, GS, OutPrime, ModuleInfo, !Substs, @@ -1318,25 +1316,25 @@ process_update_set([Id | Ids], GS, OutPrime, ModuleInfo, !Substs, divide_base_case(UpdateOut, Out, C, VarTypes, ModuleInfo, UpdateBase, AssocBase, OtherBase) :- - list__delete_elems(Out, UpdateOut, AssocOut), + list.delete_elems(Out, UpdateOut, AssocOut), - list__map(related(C, VarTypes, ModuleInfo), UpdateOut, UpdateBaseList), - list__map(related(C, VarTypes, ModuleInfo), AssocOut, AssocBaseList), - UpdateBase = set__power_union(set__list_to_set(UpdateBaseList)), - AssocBase = set__power_union(set__list_to_set(AssocBaseList)), + list.map(related(C, VarTypes, ModuleInfo), UpdateOut, UpdateBaseList), + list.map(related(C, VarTypes, ModuleInfo), AssocOut, AssocBaseList), + UpdateBase = set.power_union(set.list_to_set(UpdateBaseList)), + AssocBase = set.power_union(set.list_to_set(AssocBaseList)), Set = base_case_ids_set(C) `difference` (UpdateBase `union` AssocBase), - set__to_sorted_list(Set, List), + set.to_sorted_list(Set, List), - list__map( + list.map( (pred(GoalId::in, Ancestors::out) is det :- - goal_store__all_ancestors(C, GoalId, VarTypes, + goal_store_all_ancestors(C, GoalId, VarTypes, ModuleInfo, no, Ancestors) ), List, OtherBaseList), - OtherBase = set__list_to_set(List) `union` + OtherBase = set.list_to_set(List) `union` (base_case_ids_set(C) `intersect` - set__power_union(set__list_to_set(OtherBaseList))). + set.power_union(set.list_to_set(OtherBaseList))). % related(GS, MI, V, Ids): % @@ -1349,20 +1347,20 @@ divide_base_case(UpdateOut, Out, C, VarTypes, ModuleInfo, related(GS, VarTypes, ModuleInfo, Var, Related) :- solutions( (pred(Key::out) is nondet :- - goal_store__member(GS, Key, Goal - InstMap0), + goal_store_member(GS, Key, Goal - InstMap0), Key = base - _, Goal = _GoalExpr - GoalInfo, goal_info_get_instmap_delta(GoalInfo, InstMapDelta), apply_instmap_delta(InstMap0, InstMapDelta, InstMap), instmap_changed_vars(InstMap0, InstMap, VarTypes, ModuleInfo, ChangedVars), - set__singleton_set(ChangedVars, Var) + set.singleton_set(ChangedVars, Var) ), Ids), ( Ids = [Id] -> - goal_store__all_ancestors(GS, Id, VarTypes, ModuleInfo, no, Ancestors), - list__filter((pred((base - _)::in) is semidet), - set__to_sorted_list(set__insert(Ancestors, Id)), RelatedList), - Related = set__list_to_set(RelatedList) + goal_store_all_ancestors(GS, Id, VarTypes, ModuleInfo, no, Ancestors), + list.filter((pred((base - _)::in) is semidet), + set.to_sorted_list(set.insert(Ancestors, Id)), RelatedList), + Related = set.list_to_set(RelatedList) ; unexpected(this_file, "related") ). @@ -1373,13 +1371,13 @@ related(GS, VarTypes, ModuleInfo, Var, Related) :- :- inst hlds_call ---> call - ground. :- inst call_goal ---> hlds_call - ground. - % Do a goal_store__lookup where the result is known to be a call. + % Do a goal_store_lookup where the result is known to be a call. % -:- pred lookup_call(goal_store::in, goal_id::in, - stored_goal::out(call_goal)) is det. +:- pred lookup_call(goal_store::in, goal_id::in, stored_goal::out(call_goal)) + is det. lookup_call(GoalStore, Id, Call - InstMap) :- - goal_store__lookup(GoalStore, Id, Goal - InstMap), + goal_store_lookup(GoalStore, Id, Goal - InstMap), ( Goal = call(_, _, _, _, _, _) - _ -> Call = Goal ; @@ -1398,13 +1396,11 @@ lookup_call(GoalStore, Id, Call - InstMap) :- goal_store::in, goal_store::in, substs::in, subst::in, subst::in, base::in, list(pair(prog_var))::in, sets::in, prog_vars::in, top_level::in, pred_id::in, pred_info::in, - proc_info::in, proc_info::out, module_info::in, module_info::out) - is det. + proc_info::in, proc_info::out, module_info::in, module_info::out) is det. stage3(RecCallId, Accs, VarSet, VarTypes, C, CS, Substs, - HeadToCallSubst, CallToHeadSubst, BaseCase, BasePairs, - Sets, Out, TopLevel, OrigPredId, OrigPredInfo, !OrigProcInfo, - !ModuleInfo) :- + HeadToCallSubst, CallToHeadSubst, BaseCase, BasePairs, Sets, Out, + TopLevel, OrigPredId, OrigPredInfo, !OrigProcInfo, !ModuleInfo) :- acc_proc_info(Accs, VarSet, VarTypes, Substs, !.OrigProcInfo, AccTypes, AccProcInfo), acc_pred_info(AccTypes, Out, AccProcInfo, OrigPredId, OrigPredInfo, @@ -1436,8 +1432,8 @@ stage3(RecCallId, Accs, VarSet, VarTypes, C, CS, Substs, :- pred acc_proc_info(prog_vars::in, prog_varset::in, vartypes::in, substs::in, proc_info::in, list(mer_type)::out, proc_info::out) is det. -acc_proc_info(Accs0, VarSet, VarTypes, Substs, - OrigProcInfo, AccTypes, AccProcInfo) :- +acc_proc_info(Accs0, VarSet, VarTypes, Substs, OrigProcInfo, + AccTypes, AccProcInfo) :- % ProcInfo Stuff that must change. proc_info_headvars(OrigProcInfo, HeadVars0), proc_info_argmodes(OrigProcInfo, HeadModes0), @@ -1451,7 +1447,7 @@ acc_proc_info(Accs0, VarSet, VarTypes, Substs, Substs = substs(AccVarSubst, _RecCallSubst, _AssocCallSubst, _UpdateSubst), - list__map(map__lookup(AccVarSubst), Accs0, Accs), + list.map(map.lookup(AccVarSubst), Accs0, Accs), % We place the extra accumulator variables at the start, because placing % them at the end breaks the convention that the last variable of a @@ -1464,10 +1460,10 @@ acc_proc_info(Accs0, VarSet, VarTypes, Substs, % structures. Inst = ground(shared, none), inst_lists_to_mode_list([Inst], [Inst], Mode), - list__duplicate(list__length(Accs), list__det_head(Mode), AccModes), + list.duplicate(list.length(Accs), list.det_head(Mode), AccModes), HeadModes = AccModes ++ HeadModes0, - list__map(map__lookup(VarTypes), Accs, AccTypes), + list.map(map.lookup(VarTypes), Accs, AccTypes), proc_info_create(Context, VarSet, VarTypes, HeadVars, InstVarSet, HeadModes, Detism, Goal, RttiVarMaps, IsAddressTaken, AccProcInfo). @@ -1492,10 +1488,10 @@ acc_pred_info(NewTypes, OutVars, NewProcInfo, OrigPredId, OrigPredInfo, pred_info_get_class_context(OrigPredInfo, ClassContext), pred_info_get_origin(OrigPredInfo, OldOrigin), - set__init(Assertions), + set.init(Assertions), proc_info_context(NewProcInfo, Context), - term__context_line(Context, Line), + term.context_line(Context, Line), Counter = 0, Types = NewTypes ++ Types0, @@ -1503,7 +1499,7 @@ acc_pred_info(NewTypes, OutVars, NewProcInfo, OrigPredId, OrigPredInfo, make_pred_name_with_context(ModuleName, "AccFrom", PredOrFunc, Name, Line, Counter, SymName), - OutVarNums = list__map(term__var_to_int, OutVars), + OutVarNums = list.map(term.var_to_int, OutVars), Origin = transformed(accumulator(OutVarNums), OldOrigin, OrigPredId), pred_info_create(ModuleName, SymName, PredOrFunc, PredContext, Origin, local, Markers, Types, TypeVarSet, ExistQVars, ClassContext, @@ -1524,7 +1520,6 @@ acc_pred_info(NewTypes, OutVars, NewProcInfo, OrigPredId, OrigPredInfo, create_goal(RecCallId, Accs, AccPredId, AccProcId, AccName, Substs, HeadToCallSubst, CallToHeadSubst, BaseIds, BasePairs, Sets, C, CS, OrigBaseGoal, OrigRecGoal, AccBaseGoal, AccRecGoal) :- - lookup_call(C, RecCallId, OrigCall - _InstMap), Call = create_acc_call(OrigCall, Accs, AccPredId, AccProcId, AccName), create_orig_goal(Call, Substs, HeadToCallSubst, CallToHeadSubst, @@ -1560,10 +1555,10 @@ create_orig_goal(Call, Substs, HeadToCallSubst, CallToHeadSubst, U = create_new_orig_recursive_goals(UpdateBase, Update, HeadToCallSubst, UpdateSubst, C), - goal_util__rename_vars_in_goal(CallToHeadSubst, Call, BaseCall), - Cbefore = goal_list(set__to_sorted_list(Before), C), - Uupdate = goal_list(set__to_sorted_list(UpdateBase) ++ - set__to_sorted_list(Update), U), + goal_util.rename_vars_in_goal(CallToHeadSubst, Call, BaseCall), + Cbefore = goal_list(set.to_sorted_list(Before), C), + Uupdate = goal_list(set.to_sorted_list(UpdateBase) ++ + set.to_sorted_list(Update), U), Cbase = goal_list(base_case_ids(C), C), calculate_goal_info(conj(plain_conj, Cbefore ++ Uupdate ++ [BaseCall]), OrigRecGoal), @@ -1583,29 +1578,29 @@ create_acc_goal(Call, Substs, HeadToCallSubst, BaseIds, BasePairs, Sets, BaseIds = base(_UpdateBase, AssocBase, OtherBase), Sets = sets(Before, Assoc, ConstructAssoc, Construct, Update, _Reject), - goal_util__rename_vars_in_goal(RecCallSubst, Call, RecCall), + goal_util.rename_vars_in_goal(RecCallSubst, Call, RecCall), - Cbefore = goal_list(set__to_sorted_list(Before), C), + Cbefore = goal_list(set.to_sorted_list(Before), C), % Create the goals which will be used in the new recursive case. R = create_new_recursive_goals(Assoc, Construct `union` ConstructAssoc, Update, AssocCallSubst, AccVarSubst, UpdateSubst, C, CS), - Rassoc = goal_list(set__to_sorted_list(Assoc), R), - Rupdate = goal_list(set__to_sorted_list(Update), R), - Rconstruct = goal_list(set__to_sorted_list(Construct `union` + Rassoc = goal_list(set.to_sorted_list(Assoc), R), + Rupdate = goal_list(set.to_sorted_list(Update), R), + Rconstruct = goal_list(set.to_sorted_list(Construct `union` ConstructAssoc), R), % Create the goals which will be used in the new base case. B = create_new_base_goals(Assoc `union` Construct `union` ConstructAssoc, C, AccVarSubst, HeadToCallSubst), - Bafter = set__to_sorted_list(Assoc `union` + Bafter = set.to_sorted_list(Assoc `union` Construct `union` ConstructAssoc), - BaseCase = goal_list(set__to_sorted_list(AssocBase `union` OtherBase) + BaseCase = goal_list(set.to_sorted_list(AssocBase `union` OtherBase) ++ Bafter, B), - list__map(acc_unification, BasePairs, UpdateBase), + list.map(acc_unification, BasePairs, UpdateBase), calculate_goal_info(conj(plain_conj, Cbefore ++ Rassoc ++ Rupdate ++ [RecCall] ++ Rconstruct), AccRecGoal), @@ -1622,9 +1617,9 @@ create_acc_goal(Call, Substs, HeadToCallSubst, BaseIds, BasePairs, Sets, create_new_orig_recursive_goals(UpdateBase, Update, HeadToCallSubst, UpdateSubst, C) - = rename(set__to_sorted_list(Update), UpdateSubst, C, Ubase) :- - Ubase = rename(set__to_sorted_list(UpdateBase), - chain_subst(HeadToCallSubst, UpdateSubst), C, goal_store__init). + = rename(set.to_sorted_list(Update), UpdateSubst, C, Ubase) :- + Ubase = rename(set.to_sorted_list(UpdateBase), + chain_subst(HeadToCallSubst, UpdateSubst), C, goal_store_init). % Create the R set of goals (those that will be used in the new % recursive case) by renaming all the members of assoc in CS @@ -1636,10 +1631,10 @@ create_new_orig_recursive_goals(UpdateBase, Update, HeadToCallSubst, create_new_recursive_goals(Assoc, Constructs, Update, AssocCallSubst, AccVarSubst, UpdateSubst, C, CS) - = rename(set__to_sorted_list(Constructs), AccVarSubst, C, RBase) :- - RBase0 = rename(set__to_sorted_list(Assoc), AssocCallSubst, CS, - goal_store__init), - RBase = rename(set__to_sorted_list(Update), UpdateSubst, C, RBase0). + = rename(set.to_sorted_list(Constructs), AccVarSubst, C, RBase) :- + RBase0 = rename(set.to_sorted_list(Assoc), AssocCallSubst, CS, + goal_store_init), + RBase = rename(set.to_sorted_list(Update), UpdateSubst, C, RBase0). % Create the B set of goals (those that will be used in the new % base case) by renaming all the base case goals of C with @@ -1650,8 +1645,8 @@ create_new_recursive_goals(Assoc, Constructs, Update, = goal_store. create_new_base_goals(Ids, C, AccVarSubst, HeadToCallSubst) - = rename(set__to_sorted_list(Ids), AccVarSubst, C, Bbase) :- - Bbase = rename(base_case_ids(C), HeadToCallSubst, C, goal_store__init). + = rename(set.to_sorted_list(Ids), AccVarSubst, C, Bbase) :- + Bbase = rename(base_case_ids(C), HeadToCallSubst, C, goal_store_init). % acc_unification(O-A, G): % @@ -1665,7 +1660,7 @@ acc_unification(Out - Acc, Goal) :- UniMode = LHSMode - RHSMode, Context = unify_context(explicit, []), Expr = unify(Out, var(Acc), UniMode, assign(Out,Acc), Context), - set__list_to_set([Out,Acc], NonLocalVars), + set.list_to_set([Out,Acc], NonLocalVars), instmap_delta_from_assoc_list([Out - ground(shared, none)], InstMapDelta), goal_info_init(NonLocalVars, InstMapDelta, det, purity_pure, Info), Goal = Expr - Info. @@ -1737,12 +1732,9 @@ top_level(disj_rec_base, Goal, OrigBaseGoal, ). top_level(ite_base_rec, Goal, OrigBaseGoal, OrigRecGoal, NewBaseGoal, NewRecGoal, OrigGoal, NewGoal) :- - ( - Goal = if_then_else(Vars, If, _, _) - GoalInfo - -> + ( Goal = if_then_else(Vars, If, _, _) - GoalInfo -> OrigGoal = if_then_else(Vars, If, OrigBaseGoal, OrigRecGoal) - GoalInfo, - NewGoal = if_then_else(Vars, If, NewBaseGoal, NewRecGoal) - GoalInfo ; @@ -1750,12 +1742,9 @@ top_level(ite_base_rec, Goal, OrigBaseGoal, ). top_level(ite_rec_base, Goal, OrigBaseGoal, OrigRecGoal, NewBaseGoal, NewRecGoal, OrigGoal, NewGoal) :- - ( - Goal = if_then_else(Vars, If, _, _) - GoalInfo - -> + ( Goal = if_then_else(Vars, If, _, _) - GoalInfo -> OrigGoal = if_then_else(Vars, If, OrigRecGoal, OrigBaseGoal) - GoalInfo, - NewGoal = if_then_else(Vars, If, NewRecGoal, NewBaseGoal) - GoalInfo ; @@ -1790,11 +1779,11 @@ update_accumulator_pred(NewPredId, NewProcId, AccGoal, !ModuleInfo) :- :- func rename(list(goal_id), subst, goal_store, goal_store) = goal_store. rename(Ids, Subst, From, Initial) = Final :- - list__foldl( + list.foldl( (pred(Id::in, GS0::in, GS::out) is det :- - goal_store__lookup(From, Id, Goal0 - InstMap), - goal_util__rename_vars_in_goal(Subst, Goal0, Goal), - goal_store__det_insert(Id, Goal - InstMap, GS0, GS) + goal_store_lookup(From, Id, Goal0 - InstMap), + goal_util.rename_vars_in_goal(Subst, Goal0, Goal), + goal_store_det_insert(Id, Goal - InstMap, GS0, GS) ), Ids, Initial, Final). % Return all the goal_ids which belong in the base case. @@ -1804,13 +1793,13 @@ rename(Ids, Subst, From, Initial) = Final :- base_case_ids(GS) = Base :- solutions( (pred(Key::out) is nondet :- - goal_store__member(GS, Key, _Goal), + goal_store_member(GS, Key, _Goal), Key = base - _ ), Base). :- func base_case_ids_set(goal_store) = set(goal_id). -base_case_ids_set(GS) = set__list_to_set(base_case_ids(GS)). +base_case_ids_set(GS) = set.list_to_set(base_case_ids(GS)). % Given a list of goal_ids, return the list of hlds_goals from % the goal_store. @@ -1818,9 +1807,9 @@ base_case_ids_set(GS) = set__list_to_set(base_case_ids(GS)). :- func goal_list(list(goal_id), goal_store) = hlds_goals. goal_list(Ids, GS) = Goals :- - list__map( + list.map( (pred(Key::in, G::out) is det :- - goal_store__lookup(GS, Key, G - _) + goal_store_lookup(GS, Key, G - _) ), Ids, Goals). %-----------------------------------------------------------------------------% @@ -1832,10 +1821,9 @@ calculate_goal_info(GoalExpr, GoalExpr - GoalInfo) :- ( GoalExpr = conj(plain_conj, GoalList) -> goal_list_nonlocals(GoalList, NonLocals), goal_list_instmap_delta(GoalList, InstMapDelta), - goal_list_determinism(GoalList, Determinism), + goal_list_determinism(GoalList, Detism), - goal_info_init(NonLocals, InstMapDelta, Determinism, purity_pure, - GoalInfo) + goal_info_init(NonLocals, InstMapDelta, Detism, purity_pure, GoalInfo) ; unexpected(this_file, "calculate_goal_info: not a conj.") ). @@ -1861,26 +1849,26 @@ rec = 1. :- func reverse_subst(subst) = subst. reverse_subst(Subst0) = Subst :- - map__to_assoc_list(Subst0, List0), - assoc_list__reverse_members(List0, List), - map__from_assoc_list(List, Subst). + map.to_assoc_list(Subst0, List0), + assoc_list.reverse_members(List0, List), + map.from_assoc_list(List, Subst). :- func chain_subst(subst, subst) = subst. chain_subst(AtoB, BtoC) = AtoC :- - map__keys(AtoB, Keys), + map.keys(AtoB, Keys), chain_subst_2(Keys, AtoB, BtoC, AtoC). :- pred chain_subst_2(list(A)::in, map(A, B)::in, map(B, C)::in, map(A, C)::out) is det. chain_subst_2([], _, _, AtoC) :- - map__init(AtoC). + map.init(AtoC). chain_subst_2([A|As], AtoB, BtoC, AtoC) :- chain_subst_2(As, AtoB, BtoC, AtoC0), - map__lookup(AtoB, A, B), - ( map__search(BtoC, B, C) -> - map__det_insert(AtoC0, A, C, AtoC) + map.lookup(AtoB, A, B), + ( map.search(BtoC, B, C) -> + map.det_insert(AtoC0, A, C, AtoC) ; AtoC = AtoC0 ). diff --git a/compiler/add_class.m b/compiler/add_class.m index 88b85ea64..6293fddd5 100644 --- a/compiler/add_class.m +++ b/compiler/add_class.m @@ -6,7 +6,7 @@ % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__add_class. +:- module hlds.make_hlds.add_class. :- interface. :- import_module hlds.hlds_module. @@ -38,7 +38,7 @@ % :- pred do_produce_instance_method_clauses(instance_proc_def::in, pred_or_func::in, arity::in, list(mer_type)::in, pred_markers::in, - term__context::in, import_status::in, clauses_info::out, + term.context::in, import_status::in, clauses_info::out, module_info::in, module_info::out, qual_info::in, qual_info::out, io::di, io::uo) is det. @@ -76,7 +76,7 @@ module_add_class_defn(Constraints, FunDeps, Name, Vars, Interface, VarSet, Context, Status, !ModuleInfo, !IO) :- module_info_get_class_table(!.ModuleInfo, Classes0), module_info_get_superclass_table(!.ModuleInfo, SuperClasses0), - list__length(Vars, ClassArity), + list.length(Vars, ClassArity), ClassId = class_id(Name, ClassArity), Status = item_status(ImportStatus0, _), ( Interface = abstract -> @@ -84,11 +84,11 @@ module_add_class_defn(Constraints, FunDeps, Name, Vars, Interface, VarSet, ; ImportStatus1 = ImportStatus0 ), - HLDSFunDeps = list__map(make_hlds_fundep(Vars), FunDeps), + HLDSFunDeps = list.map(make_hlds_fundep(Vars), FunDeps), ( % The typeclass is exported if *any* occurrence is exported, % even a previous abstract occurrence. - map__search(Classes0, ClassId, OldDefn) + map.search(Classes0, ClassId, OldDefn) -> OldDefn = hlds_class_defn(OldStatus, OldConstraints, OldFunDeps, _OldAncestors, OldVars, _OldKinds, OldInterface, OldMethods, @@ -111,10 +111,10 @@ module_add_class_defn(Constraints, FunDeps, Name, Vars, Interface, VarSet, DummyStatus = local, multiple_def_error(DummyStatus, Name, ClassArity, "typeclass", Context, OldContext, _, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" The superclass constraints do not match.\n", + prog_out.write_context(Context, !IO), + io.write_string(" The superclass constraints do not match.\n", !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), ErrorOrPrevDef = yes ; \+ class_fundeps_are_identical(OldFunDeps, HLDSFunDeps) @@ -123,10 +123,10 @@ module_add_class_defn(Constraints, FunDeps, Name, Vars, Interface, VarSet, DummyStatus = local, multiple_def_error(DummyStatus, Name, ClassArity, "typeclass", Context, OldContext, _, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" The functional dependencies do not match.\n", + prog_out.write_context(Context, !IO), + io.write_string(" The functional dependencies do not match.\n", !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), ErrorOrPrevDef = yes ; Interface = concrete(_), @@ -158,7 +158,7 @@ module_add_class_defn(Constraints, FunDeps, Name, Vars, Interface, VarSet, Maybe = yes(Pred - Proc), PredProcId = hlds_class_proc(Pred, Proc) ), - list__filter_map(IsYes, PredProcIds0, PredProcIds1), + list.filter_map(IsYes, PredProcIds0, PredProcIds1), % % The list must be sorted on pred_id and then @@ -166,7 +166,7 @@ module_add_class_defn(Constraints, FunDeps, Name, Vars, Interface, VarSet, % when it is generating the corresponding list % of pred_proc_ids for instance definitions. % - list__sort(PredProcIds1, ClassMethods) + list.sort(PredProcIds1, ClassMethods) ; Interface = abstract, ClassMethods = ClassMethods0 @@ -181,7 +181,7 @@ module_add_class_defn(Constraints, FunDeps, Name, Vars, Interface, VarSet, Defn = hlds_class_defn(ImportStatus, Constraints, HLDSFunDeps, Ancestors, Vars, Kinds, ClassInterface, ClassMethods, VarSet, Context), - map__set(Classes0, ClassId, Defn, Classes), + map.set(Classes0, ClassId, Defn, Classes), module_info_set_class_table(Classes, !ModuleInfo), ( @@ -194,7 +194,7 @@ module_add_class_defn(Constraints, FunDeps, Name, Vars, Interface, VarSet, % When we find the class declaration, make an % entry for the instances. module_info_get_instance_table(!.ModuleInfo, Instances0), - map__det_insert(Instances0, ClassId, [], Instances), + map.det_insert(Instances0, ClassId, [], Instances), module_info_set_instance_table(Instances, !ModuleInfo) ; IsNewDefn = no @@ -238,7 +238,7 @@ superclass_constraints_are_identical(OldVars0, OldVarSet, OldConstraints0, OldConstraints1), apply_variable_renaming_to_tvar_list(Renaming, OldVars0, OldVars), - map__from_corresponding_lists(OldVars, Vars, VarRenaming), + map.from_corresponding_lists(OldVars, Vars, VarRenaming), apply_variable_renaming_to_prog_constraint_list(VarRenaming, OldConstraints1, OldConstraints), OldConstraints = Constraints. @@ -414,10 +414,10 @@ update_superclass_table(ClassId, Vars, VarSet, Constraints, !Supers) :- update_superclass_table_2(ClassId, Vars, VarSet, Constraint, !Supers) :- Constraint = constraint(SuperName, SuperTypes), - list__length(SuperTypes, SuperClassArity), + list.length(SuperTypes, SuperClassArity), SuperClassId = class_id(SuperName, SuperClassArity), SubClassDetails = subclass_details(SuperTypes, ClassId, Vars, VarSet), - multi_map__set(!.Supers, SuperClassId, SubClassDetails, !:Supers). + multi_map.set(!.Supers, SuperClassId, SubClassDetails, !:Supers). % Go through the list of class methods, looking for % - functions without mode declarations: add a default mode @@ -446,7 +446,7 @@ check_method_modes([Method | Methods], !PredProcIds, !ModuleInfo, !IO) :- unexpected(this_file, "add_default_class_method_func_modes: unqualified func") ), - list__length(TypesAndModes, PredArity), + list.length(TypesAndModes, PredArity), module_info_get_predicate_table(!.ModuleInfo, PredTable), ( predicate_table_search_pf_m_n_a(PredTable, is_fully_qualified, @@ -467,7 +467,7 @@ check_method_modes([Method | Methods], !PredProcIds, !ModuleInfo, !IO) :- ; PorF = predicate, pred_info_procedures(PredInfo0, Procs), - ( map__is_empty(Procs) -> + ( map.is_empty(Procs) -> pred_method_with_no_modes_error(PredInfo0, !IO) ; true @@ -485,19 +485,17 @@ module_add_instance_defn(InstanceModuleName, Constraints, ClassName, Types, Body0, VarSet, Status, Context, !ModuleInfo, !IO) :- module_info_get_class_table(!.ModuleInfo, Classes), module_info_get_instance_table(!.ModuleInfo, Instances0), - list__length(Types, ClassArity), + list.length(Types, ClassArity), ClassId = class_id(ClassName, ClassArity), Body = expand_bang_state_var_args_in_instance_method_heads(Body0), - ( - map__search(Classes, ClassId, _) - -> - map__init(Empty), + ( map.search(Classes, ClassId, _) -> + map.init(Empty), NewInstanceDefn = hlds_instance_defn(InstanceModuleName, Status, Context, Constraints, Types, Body, no, VarSet, Empty), - map__lookup(Instances0, ClassId, InstanceDefns), + map.lookup(Instances0, ClassId, InstanceDefns), check_for_overlapping_instances(NewInstanceDefn, InstanceDefns, ClassId, !IO), - map__det_update(Instances0, ClassId, + map.det_update(Instances0, ClassId, [NewInstanceDefn | InstanceDefns], Instances), module_info_set_instance_table(Instances, !ModuleInfo) ; @@ -514,7 +512,7 @@ check_for_overlapping_instances(NewInstanceDefn, InstanceDefns, ClassId, NewInstanceDefn = hlds_instance_defn(_, _Status, Context, _, Types, Body, _, VarSet, _), Body \= abstract, % XXX - list__member(OtherInstanceDefn, InstanceDefns), + list.member(OtherInstanceDefn, InstanceDefns), OtherInstanceDefn = hlds_instance_defn(_, _OtherStatus, OtherContext, _, OtherTypes, OtherBody, _, OtherVarSet, _), OtherBody \= abstract, % XXX @@ -531,7 +529,7 @@ check_for_overlapping_instances(NewInstanceDefn, InstanceDefns, ClassId, report_overlapping_instance_declaration(class_id(ClassName, ClassArity), Context - OtherContext, !IO) :- - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), Pieces1 = [words("Error: multiply defined (or overlapping)"), words("instance declarations for class"), sym_name_and_arity(ClassName / ClassArity), @@ -550,7 +548,7 @@ do_produce_instance_method_clauses(InstanceProcDefn, PredOrFunc, PredArity, % First the goal info, ... goal_info_init(GoalInfo0), goal_info_set_context(Context, GoalInfo0, GoalInfo1), - set__list_to_set(HeadVars, NonLocals), + set.list_to_set(HeadVars, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo1, GoalInfo2), ( check_marker(Markers, is_impure) -> goal_info_add_feature(impure_goal, GoalInfo2, GoalInfo) @@ -560,14 +558,14 @@ do_produce_instance_method_clauses(InstanceProcDefn, PredOrFunc, PredArity, GoalInfo = GoalInfo2 ), % ... and then the goal itself. - varset__init(VarSet0), + varset.init(VarSet0), make_n_fresh_vars("HeadVar__", PredArity, HeadVars, VarSet0, VarSet), construct_pred_or_func_call(invalid_pred_id, PredOrFunc, InstancePredName, HeadVars, GoalInfo, IntroducedGoal, !QualInfo), IntroducedClause = clause([], IntroducedGoal, mercury, Context), - map__from_corresponding_lists(HeadVars, ArgTypes, VarTypes), - map__init(TVarNameMap), + map.from_corresponding_lists(HeadVars, ArgTypes, VarTypes), + map.init(TVarNameMap), rtti_varmaps_init(RttiVarMaps), HasForeignClauses = no, set_clause_list([IntroducedClause], ClausesRep), @@ -577,7 +575,7 @@ do_produce_instance_method_clauses(InstanceProcDefn, PredOrFunc, PredArity, % Handle the arbitrary clauses syntax. InstanceProcDefn = clauses(InstanceClauses), clauses_info_init(PredArity, ClausesInfo0), - list__foldl4( + list.foldl4( produce_instance_method_clause(PredOrFunc, Context, Status), InstanceClauses, !ModuleInfo, !QualInfo, ClausesInfo0, ClausesInfo, !IO) @@ -598,12 +596,12 @@ produce_instance_method_clause(PredOrFunc, Context, Status, InstanceClause, report_illegal_func_svar_result(Context, CVarSet, StateVar, !IO) ; HeadTerms = expand_bang_state_var_args(HeadTerms0), - PredArity = list__length(HeadTerms), + PredArity = list.length(HeadTerms), adjust_func_arity(PredOrFunc, Arity, PredArity), % The tvarset argument is only used for explicit type % qualifications, of which there are none in this % clause, so it is set to a dummy value. - varset__init(TVarSet0), + varset.init(TVarSet0), ProcIds = [], % means this clause applies to _every_ mode of the procedure @@ -637,7 +635,7 @@ pred_method_with_no_modes_error(PredInfo, !IO) :- words("predicate"), sym_name_and_arity(qualified(Module, Name) / Arity), suffix(".")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred undefined_type_class_error(sym_name::in, arity::in, prog_context::in, string::in, io::di, io::uo) is det. @@ -647,7 +645,7 @@ undefined_type_class_error(ClassName, Arity, Context, Description, !IO) :- sym_name_and_arity(ClassName / Arity), words("without preceding typeclass declaration.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred missing_pred_or_func_method_error(sym_name::in, arity::in, pred_or_func::in, prog_context::in, module_info::in, module_info::out, diff --git a/compiler/add_clause.m b/compiler/add_clause.m index 3450b5215..48758b4ee 100644 --- a/compiler/add_clause.m +++ b/compiler/add_clause.m @@ -6,7 +6,7 @@ % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__add_clause. +:- module hlds.make_hlds.add_clause. :- interface. :- import_module hlds.hlds_goal. @@ -97,17 +97,17 @@ module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status, ), ArityAdjustment = ( if IllegalSVarResult = yes(_) then -1 else 0 ), Args = expand_bang_state_var_args(Args0), - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string("% Processing clause for ", !IO), + io.write_string("% Processing clause for ", !IO), write_pred_or_func(PredOrFunc, !IO), - io__write_string(" `", !IO), - list__length(Args, PredArity0), + io.write_string(" `", !IO), + list.length(Args, PredArity0), PredArity = PredArity0 + ArityAdjustment, adjust_func_arity(PredOrFunc, OrigArity, PredArity), - prog_out__write_sym_name_and_arity(PredName/OrigArity, !IO), - io__write_string("'...\n", !IO) + prog_out.write_sym_name_and_arity(PredName/OrigArity, !IO), + io.write_string("'...\n", !IO) ; VeryVerbose = no ), @@ -116,7 +116,7 @@ module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status, % (If it's not there, call maybe_undefined_pred_error % and insert an implicit declaration for the predicate.) module_info_get_name(!.ModuleInfo, ModuleName), - list__length(Args, Arity0), + list.length(Args, Arity0), Arity = Arity0 + ArityAdjustment, some [!PredInfo, !PredicateTable] ( module_info_get_predicate_table(!.ModuleInfo, !:PredicateTable), @@ -126,8 +126,8 @@ module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status, -> PredId = PredId0, ( GoalType = promise(_) -> - mdbcomp__prim_data__sym_name_to_string(PredName, NameString), - string__format("%s %s %s (%s).\n", + sym_name_to_string(PredName, NameString), + string.format("%s %s %s (%s).\n", [s("Attempted to introduce a predicate"), s("for a promise with an identical"), s("name to an existing predicate"), @@ -141,7 +141,7 @@ module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status, ( GoalType = promise(_) -> - term__term_list_to_var_list(Args, HeadVars), + term.term_list_to_var_list(Args, HeadVars), preds_add_implicit_for_assertion(HeadVars, !.ModuleInfo, ModuleName, PredName, Arity, Status, Context, PredOrFunc, PredId, !PredicateTable), @@ -157,7 +157,7 @@ module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status, % add an `infer_modes' marker, and then save the pred_info. module_info_get_predicate_table(!.ModuleInfo, !:PredicateTable), predicate_table_get_preds(!.PredicateTable, Preds0), - map__lookup(Preds0, PredId, !:PredInfo), + map.lookup(Preds0, PredId, !:PredInfo), % opt_imported preds are initially tagged as imported and are % tagged as opt_imported only if/when we see a clause for them ( Status = opt_imported -> @@ -191,12 +191,12 @@ module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status, module_info_incr_errors(!ModuleInfo), CallIdString0 = simple_call_id_to_string( PredOrFunc - PredName/Arity), - string__append(CallIdString0, ".", CallIdString), + string.append(CallIdString0, ".", CallIdString), ErrorPieces0 = [ words("Error: clause for automatically generated"), words("field access"), fixed(CallIdString), nl ], - globals__io_lookup_bool_option(verbose_errors, Verbose, !IO), + globals.io_lookup_bool_option(verbose_errors, Verbose, !IO), ( Verbose = yes, ErrorPieces1 = [ @@ -209,13 +209,13 @@ module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status, words("give the field of the constructor a"), words("different name.") ], - list__append(ErrorPieces0, ErrorPieces1, ErrorPieces) + list.append(ErrorPieces0, ErrorPieces1, ErrorPieces) ; Verbose = no, - globals__io_set_extra_error_info(yes, !IO), + globals.io_set_extra_error_info(yes, !IO), ErrorPieces = ErrorPieces0 ), - error_util__write_error_pieces(Context, 0, ErrorPieces, !IO) + write_error_pieces(Context, 0, ErrorPieces, !IO) ; % Ignore clauses for builtins. This makes bootstrapping % easier when redefining builtins to use normal Mercury code. @@ -257,7 +257,7 @@ module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status, ; ProcIds = [_ | _] ), - map__det_update(Preds0, PredId, !.PredInfo, Preds), + map.det_update(Preds0, PredId, !.PredInfo, Preds), predicate_table_set_preds(Preds, !PredicateTable), module_info_set_predicate_table(!.PredicateTable, !ModuleInfo), ( Status = opt_imported -> @@ -298,7 +298,7 @@ select_applicable_modes(Args0, VarSet, Status, Context, PredId, PredInfo, ModeList = ModeList0 ; qual_info_get_mq_info(!.QualInfo, MQInfo0), - module_qual__qualify_clause_mode_list(ModeList0, ModeList, Context, + module_qual.qualify_clause_mode_list(ModeList0, ModeList, Context, MQInfo0, MQInfo, !IO), qual_info_set_mq_info(MQInfo, !QualInfo) ), @@ -307,7 +307,7 @@ select_applicable_modes(Args0, VarSet, Status, Context, PredId, PredInfo, % Now find the procedure which matches these mode annotations. % pred_info_procedures(PredInfo, Procs), - map__to_assoc_list(Procs, ExistingProcs), + map.to_assoc_list(Procs, ExistingProcs), ( get_procedure_matching_declmodes(ExistingProcs, ModeList, !.ModuleInfo, ProcId) @@ -403,8 +403,8 @@ add_annotation(_, mixed, mixed). get_mode_annotation(Arg0, Arg, MaybeAnnotation) :- ( - Arg0 = term__functor(term__atom("::"), [Arg1, ModeTerm], _), - convert_mode(allow_constrained_inst_var, term__coerce(ModeTerm), Mode) + Arg0 = term.functor(term.atom("::"), [Arg1, ModeTerm], _), + convert_mode(allow_constrained_inst_var, term.coerce(ModeTerm), Mode) -> Arg = Arg1, MaybeAnnotation = yes(Mode) @@ -429,14 +429,14 @@ clauses_info_add_clause(ModeIds0, CVarSet, TVarSet0, Args, Body, Context, % which occur in the argument types of the predicate. % Type variables which only occur in explicit type % qualifications are local to the clause in which they appear. - varset__create_name_var_map(TVarSet0, TVarNameMap) + varset.create_name_var_map(TVarSet0, TVarNameMap) ; IsEmpty = no, TVarNameMap = TVarNameMap0 ), update_qual_info(TVarNameMap, TVarSet0, ExplicitVarTypes0, Status, !QualInfo), - varset__merge_subst(VarSet0, CVarSet, VarSet1, Subst), + varset.merge_subst(VarSet0, CVarSet, VarSet1, Subst), add_clause_transform(Subst, HeadVars, Args, Body, Context, PredOrFunc, Arity, GoalType, Goal0, VarSet1, VarSet, Warnings, !ModuleInfo, !QualInfo, !IO), @@ -459,13 +459,13 @@ clauses_info_add_clause(ModeIds0, CVarSet, TVarSet0, Args, Body, Context, ( HasForeignClauses = yes, get_clause_list_any_order(ClausesRep0, AnyOrderClauseList), - ForeignModeIds = list__condense(list__filter_map( + ForeignModeIds = list.condense(list.filter_map( (func(C) = ProcIds is semidet :- C = clause(ProcIds, _, ClauseLang, _), not ClauseLang = mercury ), AnyOrderClauseList)), - ModeIds = list__delete_elems(ModeIds0, ForeignModeIds), + ModeIds = list.delete_elems(ModeIds0, ForeignModeIds), ( ModeIds = [], ClausesRep = ClausesRep0 @@ -496,7 +496,7 @@ add_clause_transform(Subst, HeadVars, Args0, Body0, Context, PredOrFunc, Arity, GoalType, Goal, !VarSet, Warnings, !ModuleInfo, !QualInfo, !IO) :- some [!SInfo] ( prepare_for_head(!:SInfo), - term__apply_substitution_to_list(Args0, Subst, Args1), + term.apply_substitution_to_list(Args0, Subst, Args1), substitute_state_var_mappings(Args1, Args, !VarSet, !SInfo, !IO), HeadGoal0 = true_goal, ( GoalType = promise(_) -> @@ -536,11 +536,11 @@ transform_goal(Goal0 - Context, Subst, Goal - GoalInfo, !VarSet, transform_goal_2(fail, _, _, disj([]) - GoalInfo, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) :- goal_info_init(GoalInfo), - prepare_for_next_conjunct(set__init, !VarSet, !SInfo). + prepare_for_next_conjunct(set.init, !VarSet, !SInfo). transform_goal_2(true, _, _, conj(plain_conj, []) - GoalInfo, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) :- goal_info_init(GoalInfo), - prepare_for_next_conjunct(set__init, !VarSet, !SInfo). + prepare_for_next_conjunct(set.init, !VarSet, !SInfo). transform_goal_2(all(Vars0, Goal0), Context, Subst, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) :- % Convert `all [Vars] Goal' into `not some [Vars] not Goal'. @@ -628,7 +628,7 @@ transform_goal_2((A0, B0), _, Subst, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), get_rev_conj(B0, Subst, R0, R, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), - L = list__reverse(R), + L = list.reverse(R), goal_info_init(GoalInfo), conj_list_to_goal(L, GoalInfo, Goal). transform_goal_2((A0 & B0), _, Subst, Goal, !VarSet, !ModuleInfo, !QualInfo, @@ -637,7 +637,7 @@ transform_goal_2((A0 & B0), _, Subst, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), get_rev_par_conj(A0, Subst, R0, R, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), - L = list__reverse(R), + L = list.reverse(R), goal_info_init(GoalInfo), par_conj_list_to_goal(L, GoalInfo, Goal). transform_goal_2((A0 ; B0), Context, Subst, Goal, !VarSet, !ModuleInfo, @@ -690,15 +690,15 @@ transform_goal_2(call(Name, Args0, Purity), Context, Subst, Goal, !VarSet, ) -> prepare_for_call(!SInfo), - term__apply_substitution_to_list(Args1, Subst, Args2), + term.apply_substitution_to_list(Args1, Subst, Args2), transform_dcg_record_syntax(Operator, Args2, Context, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), finish_call(!VarSet, !SInfo) ; prepare_for_call(!SInfo), - term__apply_substitution_to_list(Args1, Subst, Args), + term.apply_substitution_to_list(Args1, Subst, Args), make_fresh_arg_vars(Args, HeadVars, !VarSet, !SInfo, !IO), - list__length(Args, Arity), + list.length(Args, Arity), ( % Check for a higher-order call, % i.e. a call to either call/N or ''/N. @@ -707,14 +707,14 @@ transform_goal_2(call(Name, Args0, Purity), Context, Subst, Goal, !VarSet, ), HeadVars = [PredVar | RealHeadVars] -> - % initialize some fields to junk + % Initialize some fields to junk. Modes = [], Det = erroneous, GenericCall = higher_order(PredVar, Purity, predicate, Arity), Call = generic_call(GenericCall, RealHeadVars, Modes, Det), - hlds_goal__generic_call_id(GenericCall, CallId) + hlds_goal.generic_call_id(GenericCall, CallId) ; % initialize some fields to junk PredId = invalid_pred_id, @@ -746,8 +746,8 @@ transform_goal_2(unify(A0, B0, Purity), Context, Subst, Goal, !VarSet, Goal = true_goal ; prepare_for_call(!SInfo), - term__apply_substitution(A0, Subst, A), - term__apply_substitution(B0, Subst, B), + term.apply_substitution(A0, Subst, A), + term.apply_substitution(B0, Subst, B), unravel_unification(A, B, Context, explicit, [], Purity, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), finish_call(!VarSet, !SInfo) @@ -777,7 +777,7 @@ convert_colon_state_vars(Context, [Colon0 | Colons0], [Colon | Colons], io::di, io::uo) is det. report_svar_unify_error(Context, VarSet, StateVar, !IO) :- - Name = varset__lookup_name(VarSet, StateVar), + Name = varset.lookup_name(VarSet, StateVar), Pieces = [nl, words("Error:"), fixed("!" ++ Name), words("cannot appear as a unification argument."), nl, words("You probably meant"), fixed("!." ++ Name), @@ -805,7 +805,7 @@ transform_dcg_record_syntax(Operator, ArgTerms0, Context, Goal, !VarSet, ; Operator = ":=", AccessType = set, - LHSTerm = term__functor(term__atom("^"), [FieldNameTerm0], _), + LHSTerm = term.functor(term.atom("^"), [FieldNameTerm0], _), FieldNameTerm = FieldNameTerm0, FieldValueTerm = RHSTerm ) @@ -820,35 +820,35 @@ transform_dcg_record_syntax(Operator, ArgTerms0, Context, Goal, !VarSet, MaybeFieldNames = error(Msg, ErrorTerm), invalid_goal("^", ArgTerms0, GoalInfo, Goal, !VarSet, !SInfo, !IO), qual_info_set_found_syntax_error(yes, !QualInfo), - io__set_exit_status(1, !IO), - prog_out__write_context(Context, !IO), - io__write_string("In DCG field ", !IO), + io.set_exit_status(1, !IO), + prog_out.write_context(Context, !IO), + io.write_string("In DCG field ", !IO), ( AccessType = set, - io__write_string("update", !IO) + io.write_string("update", !IO) ; AccessType = get, - io__write_string("extraction", !IO) + io.write_string("extraction", !IO) ), - io__write_string(" goal:\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" error: ", !IO), - io__write_string(Msg, !IO), - io__write_string(" at term `", !IO), - term_io__write_term(!.VarSet, ErrorTerm, !IO), - io__write_string("'.\n", !IO) + io.write_string(" goal:\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" error: ", !IO), + io.write_string(Msg, !IO), + io.write_string(" at term `", !IO), + term_io.write_term(!.VarSet, ErrorTerm, !IO), + io.write_string("'.\n", !IO) ) ; invalid_goal("^", ArgTerms0, GoalInfo, Goal, !VarSet, !SInfo, !IO), qual_info_set_found_syntax_error(yes, !QualInfo), - io__set_exit_status(1, !IO), - prog_out__write_context(Context, !IO), - io__write_string("Error: expected " ++ + io.set_exit_status(1, !IO), + prog_out.write_context(Context, !IO), + io.write_string("Error: expected " ++ "`Field =^ field1 ^ ... ^ fieldN'\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" or `^ field1 ^ ... ^ fieldN := Field'.\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" in DCG field access goal.\n", !IO) + prog_out.write_context(Context, !IO), + io.write_string(" or `^ field1 ^ ... ^ fieldN := Field'.\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" in DCG field access goal.\n", !IO) ). % Produce an invalid goal. @@ -944,7 +944,7 @@ qualify_lambda_mode_list(Modes0, Modes, Context, !QualInfo, !IO) :- qual_info_get_import_status(!.QualInfo, ImportStatus), ( ImportStatus \= opt_imported -> qual_info_get_mq_info(!.QualInfo, MQInfo0), - module_qual__qualify_lambda_mode_list(Modes0, Modes, Context, + module_qual.qualify_lambda_mode_list(Modes0, Modes, Context, MQInfo0, MQInfo, !IO), qual_info_set_mq_info(MQInfo, !QualInfo) ; @@ -972,7 +972,7 @@ get_rev_conj(Goal, Subst, RevConj0, RevConj, !VarSet, !ModuleInfo, !QualInfo, transform_goal(Goal, Subst, Goal1, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), goal_to_conj_list(Goal1, ConjList), - RevConj = list__reverse(ConjList) ++ RevConj0 + RevConj = list.reverse(ConjList) ++ RevConj0 ). % get_rev_par_conj(Goal, Subst, RevParConj0, RevParConj) : @@ -996,7 +996,7 @@ get_rev_par_conj(Goal, Subst, RevParConj0, RevParConj, !VarSet, !ModuleInfo, transform_goal(Goal, Subst, Goal1, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), goal_to_par_conj_list(Goal1, ParConjList), - RevParConj = list__reverse(ParConjList) ++ RevParConj0 + RevParConj = list.reverse(ParConjList) ++ RevParConj0 ). % get_disj(Goal, Subst, Disj0, Disj): diff --git a/compiler/add_heap_ops.m b/compiler/add_heap_ops.m index 9dec51b6c..21dc24cd4 100644 --- a/compiler/add_heap_ops.m +++ b/compiler/add_heap_ops.m @@ -30,7 +30,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__add_heap_ops. +:- module ml_backend.add_heap_ops. :- interface. :- import_module hlds.hlds_module. @@ -158,7 +158,7 @@ goal_expr_add_heap_ops(not(InnerGoal), OuterGoalInfo, Goal, !Info) :- % The "then" part of the if-then-else will be unreachable, but to % preserve the invariants that the MLDS back-end relies on, we need to % make sure that it can't fail. So we use a call to - % `private_builtin__unused' (which will call error/1) rather than + % `private_builtin.unused' (which will call error/1) rather than % `fail' for the "then" part. generate_call("unused", det, [], [], [], ModuleInfo, Context, ThenGoal) ; @@ -227,7 +227,7 @@ goal_expr_add_heap_ops(shorthand(_), _, _, !Info) :- heap_ops_info::in, heap_ops_info::out) is det. conj_add_heap_ops(Goals0, Goals, !Info) :- - list__map_foldl(goal_add_heap_ops, Goals0, Goals, !Info). + list.map_foldl(goal_add_heap_ops, Goals0, Goals, !Info). :- pred disj_add_heap_ops(hlds_goals::in, bool::in, maybe(prog_var)::in, hlds_goal_info::in, hlds_goals::out, @@ -324,8 +324,8 @@ new_saved_hp_var(Var, !Info) :- new_var(Name, Type, Var, !Info) :- VarSet0 = !.Info ^ varset, VarTypes0 = !.Info ^ var_types, - varset__new_named_var(VarSet0, Name, Var, VarSet), - map__det_insert(VarTypes0, Var, Type, VarTypes), + varset.new_named_var(VarSet0, Name, Var, VarSet), + map.det_insert(VarTypes0, Var, Type, VarTypes), !:Info = !.Info ^ varset := VarSet, !:Info = !.Info ^ var_types := VarTypes. @@ -333,12 +333,12 @@ new_var(Name, Type, Var, !Info) :- :- pred generate_call(string::in, determinism::in, list(prog_var)::in, list(goal_feature)::in, assoc_list(prog_var, mer_inst)::in, - module_info::in, term__context::in, hlds_goal::out) is det. + module_info::in, term.context::in, hlds_goal::out) is det. generate_call(PredName, Detism, Args, Features, InstMap, ModuleInfo, Context, CallGoal) :- mercury_private_builtin_module(BuiltinModule), - goal_util__generate_simple_call(BuiltinModule, PredName, predicate, + goal_util.generate_simple_call(BuiltinModule, PredName, predicate, only_mode, Detism, Args, Features, InstMap, ModuleInfo, Context, CallGoal). diff --git a/compiler/add_mode.m b/compiler/add_mode.m index ac5137de7..5fa42022f 100644 --- a/compiler/add_mode.m +++ b/compiler/add_mode.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1993-2005 The University of Melbourne. +% Copyright (C) 1993-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -12,7 +12,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__add_mode. +:- module hlds.make_hlds.add_mode. :- interface. :- import_module hlds.hlds_module. @@ -64,9 +64,9 @@ module_add_inst_defn(VarSet, Name, Args, InstDefn, Cond, Context, % % check if the inst is infinitely recursive (at the top level) % - Arity = list__length(Args), + Arity = list.length(Args), InstId = Name - Arity, - TestArgs = list__duplicate(Arity, not_reached), + TestArgs = list.duplicate(Arity, not_reached), check_for_cyclic_inst(Insts, InstId, InstId, TestArgs, [], Context, InvalidMode, !IO). @@ -80,7 +80,7 @@ insts_add(_, _, _, abstract_inst, _, _, _, !Insts, !IO) :- sorry(this_file, "abstract insts not implemented"). insts_add(VarSet, Name, Args, eqv_inst(Body), _Cond, Context, Status, !Insts, !IO) :- - list__length(Args, Arity), + list.length(Args, Arity), ( I = hlds_inst_defn(VarSet, Args, eqv_inst(Body), Context, Status), user_inst_table_insert(Name - Arity, I, !Insts) @@ -93,7 +93,7 @@ insts_add(VarSet, Name, Args, eqv_inst(Body), _Cond, Context, Status, !Insts, % XXX we should record each error using % module_info_incr_errors user_inst_table_get_inst_defns(!.Insts, InstDefns), - map__lookup(InstDefns, Name - Arity, OrigI), + map.lookup(InstDefns, Name - Arity, OrigI), OrigI = hlds_inst_defn(_, _, _, OrigContext, _), multiple_def_error(Status, Name, Arity, "inst", Context, OrigContext, _, !IO) @@ -107,20 +107,20 @@ insts_add(VarSet, Name, Args, eqv_inst(Body), _Cond, Context, Status, !Insts, check_for_cyclic_inst(UserInstTable, OrigInstId, InstId0, Args0, Expansions0, Context, InvalidMode, !IO) :- - ( list__member(InstId0, Expansions0) -> + ( list.member(InstId0, Expansions0) -> report_circular_equiv_error("inst", OrigInstId, InstId0, Expansions0, Context, !IO), InvalidMode = yes ; user_inst_table_get_inst_defns(UserInstTable, InstDefns), ( - map__search(InstDefns, InstId0, InstDefn), + map.search(InstDefns, InstId0, InstDefn), InstDefn = hlds_inst_defn(_, Params, Body, _, _), Body = eqv_inst(EqvInst0), inst_substitute_arg_list(Params, Args0, EqvInst0, EqvInst), EqvInst = defined_inst(user_inst(Name, Args)) -> - Arity = list__length(Args), + Arity = list.length(Args), InstId = Name - Arity, Expansions = [InstId0 | Expansions0], check_for_cyclic_inst(UserInstTable, OrigInstId, InstId, Args, @@ -145,7 +145,7 @@ module_add_mode_defn(VarSet, Name, Params, ModeDefn, Cond, Context, modes_add(VarSet, Name, Args, eqv_mode(Body), _Cond, Context, Status, !Modes, InvalidMode, !IO) :- - list__length(Args, Arity), + list.length(Args, Arity), ModeId = Name - Arity, ( I = hlds_mode_defn(VarSet, Args, eqv_mode(Body), Context, Status), @@ -154,7 +154,7 @@ modes_add(VarSet, Name, Args, eqv_mode(Body), _Cond, Context, Status, true ; mode_table_get_mode_defns(!.Modes, ModeDefns), - map__lookup(ModeDefns, ModeId, OrigI), + map.lookup(ModeDefns, ModeId, OrigI), OrigI = hlds_mode_defn(_, _, _, OrigContext, _), % XXX we should record each error using % module_info_incr_errors @@ -171,19 +171,19 @@ modes_add(VarSet, Name, Args, eqv_mode(Body), _Cond, Context, Status, check_for_cyclic_mode(ModeTable, OrigModeId, ModeId0, Expansions0, Context, InvalidMode, !IO) :- - ( list__member(ModeId0, Expansions0) -> + ( list.member(ModeId0, Expansions0) -> report_circular_equiv_error("mode", OrigModeId, ModeId0, Expansions0, Context, !IO), InvalidMode = yes ; mode_table_get_mode_defns(ModeTable, ModeDefns), ( - map__search(ModeDefns, ModeId0, ModeDefn), + map.search(ModeDefns, ModeId0, ModeDefn), ModeDefn = hlds_mode_defn(_, _, Body, _, _), Body = eqv_mode(EqvMode), EqvMode = user_defined_mode(Name, Args) -> - Arity = list__length(Args), + Arity = list.length(Args), ModeId = Name - Arity, Expansions = [ModeId0 | Expansions0], check_for_cyclic_mode(ModeTable, OrigModeId, ModeId, Expansions, @@ -211,14 +211,14 @@ report_circular_equiv_error(Kind, OrigId, Id, Expansions, Context, !IO) :- % where is either "inst" or "mode". % Kinds = (if Expansions = [_] then Kind else Kind ++ "s"), - ExpansionPieces = list__map( + ExpansionPieces = list.map( (func(SymName - Arity) = sym_name_and_arity(SymName / Arity)), Expansions), Pieces = [words("Error: circular equivalence"), fixed(Kinds)] ++ component_list_to_pieces(ExpansionPieces) ++ [suffix(".")], - error_util__write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO) + write_error_pieces(Context, 0, Pieces, !IO), + io.set_exit_status(1, !IO) ; % We have an inst `OrigId' which is not itself circular, % but which is defined in terms of `Id' which is circular. diff --git a/compiler/add_pragma.m b/compiler/add_pragma.m index ba1d3898f..0361f0f8e 100644 --- a/compiler/add_pragma.m +++ b/compiler/add_pragma.m @@ -6,7 +6,7 @@ % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__add_pragma. +:- module hlds.make_hlds.add_pragma. :- interface. :- import_module hlds.hlds_module. @@ -37,7 +37,7 @@ prog_context::in, module_info::in, module_info::out, io::di, io::uo) is det. -:- pred add_pragma_type_spec(pragma_type::in(type_spec), term__context::in, +:- pred add_pragma_type_spec(pragma_type::in(type_spec), term.context::in, module_info::in, module_info::out, qual_info::in, qual_info::out, io::di, io::uo) is det. @@ -319,20 +319,20 @@ add_pragma(Origin, Pragma, Context, !Status, !ModuleInfo, !IO) :- add_pragma_export(Origin, Name, PredOrFunc, Modes, C_Function, Context, !ModuleInfo, !IO) :- module_info_get_predicate_table(!.ModuleInfo, PredTable), - list__length(Modes, Arity), + list.length(Modes, Arity), ( predicate_table_search_pf_sym_arity(PredTable, may_be_partially_qualified, PredOrFunc, Name, Arity, [PredId]) -> predicate_table_get_preds(PredTable, Preds), - map__lookup(Preds, PredId, PredInfo), + map.lookup(Preds, PredId, PredInfo), pred_info_procedures(PredInfo, Procs), - map__to_assoc_list(Procs, ExistingProcs), + map.to_assoc_list(Procs, ExistingProcs), ( get_procedure_matching_declmodes(ExistingProcs, Modes, !.ModuleInfo, ProcId) -> - map__lookup(Procs, ProcId, ProcInfo), + map.lookup(Procs, ProcId, ProcInfo), proc_info_declared_determinism(ProcInfo, MaybeDet), % We cannot catch those multi or nondet procedures that % don't have a determinism declaration until after @@ -407,16 +407,16 @@ add_pragma_reserve_tag(TypeName, TypeArity, PragmaStatus, Context, !ModuleInfo, !IO) :- TypeCtor = TypeName - TypeArity, module_info_get_type_table(!.ModuleInfo, Types0), - TypeStr = error_util__describe_sym_name_and_arity(TypeName / TypeArity), + TypeStr = describe_sym_name_and_arity(TypeName / TypeArity), ErrorPieces1 = [ words("In"), fixed("`pragma reserve_tag'"), words("declaration for"), fixed(TypeStr ++ ":") ], - ( map__search(Types0, TypeCtor, TypeDefn0) -> - hlds_data__get_type_defn_body(TypeDefn0, TypeBody0), - hlds_data__get_type_defn_status(TypeDefn0, TypeStatus), + ( map.search(Types0, TypeCtor, TypeDefn0) -> + hlds_data.get_type_defn_body(TypeDefn0, TypeBody0), + hlds_data.get_type_defn_status(TypeDefn0, TypeStatus), ( not ( TypeStatus = PragmaStatus @@ -434,7 +434,7 @@ add_pragma_reserve_tag(TypeName, TypeArity, PragmaStatus, Context, !ModuleInfo, words("type definition.") ], write_error_pieces_not_first_line(Context, 0, ErrorPieces2, !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), module_info_incr_errors(!ModuleInfo) ; @@ -470,8 +470,8 @@ add_pragma_reserve_tag(TypeName, TypeArity, PragmaStatus, Context, !ModuleInfo, ReservedTag, Globals, CtorTags, EnumDummy), TypeBody = du_type(Body, CtorTags, EnumDummy, MaybeUserEqComp, ReservedTag, IsForeign), - hlds_data__set_type_defn_body(TypeBody, TypeDefn0, TypeDefn), - map__set(Types0, TypeCtor, TypeDefn, Types), + hlds_data.set_type_defn_body(TypeBody, TypeDefn0, TypeDefn), + map.set(Types0, TypeCtor, TypeDefn, Types), module_info_set_type_table(Types, !ModuleInfo) ; write_error_pieces(Context, 0, ErrorPieces1, !IO), @@ -481,7 +481,7 @@ add_pragma_reserve_tag(TypeName, TypeArity, PragmaStatus, Context, !ModuleInfo, words("is not a discriminated union type.") ], write_error_pieces_not_first_line(Context, 0, ErrorPieces2, !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), module_info_incr_errors(!ModuleInfo) ) ; @@ -491,7 +491,7 @@ add_pragma_reserve_tag(TypeName, TypeArity, PragmaStatus, Context, !ModuleInfo, fixed(TypeStr ++ ".") ], write_error_pieces_not_first_line(Context, 0, ErrorPieces2, !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), module_info_incr_errors(!ModuleInfo) ). @@ -511,7 +511,7 @@ add_pragma_unused_args(PredOrFunc, SymName, Arity, ModeNum, UnusedArgs, module_info_get_unused_arg_info(!.ModuleInfo, UnusedArgInfo0), % convert the mode number to a proc_id proc_id_to_int(ProcId, ModeNum), - map__set(UnusedArgInfo0, proc(PredId, ProcId), UnusedArgs, + map.set(UnusedArgInfo0, proc(PredId, ProcId), UnusedArgs, UnusedArgInfo), module_info_set_unused_arg_info(UnusedArgInfo, !ModuleInfo) ; @@ -546,10 +546,10 @@ add_pragma_exceptions(PredOrFunc, SymName, Arity, ModeNum, ThrowStatus, ; % XXX We'll just ignore this for the time being - % it causes errors with transitive-intermodule optimization. - %prog_out__write_context(Context, !IO), - %io__write_string("Internal compiler error: " ++ + % prog_out.write_context(Context, !IO), + % io.write_string("Internal compiler error: " ++ % "unknown predicate in `pragma exceptions'.\n", !IO), - %module_info_incr_errors(!ModuleInfo) + % module_info_incr_errors(!ModuleInfo) true ). @@ -575,10 +575,10 @@ add_pragma_trailing_info(PredOrFunc, SymName, Arity, ModeNum, TrailingStatus, ; % XXX We'll just ignore this for the time being - % it causes errors with transitive-intermodule optimization. - %prog_out__write_context(Context, !IO), - %io__write_string("Internal compiler error: " ++ + % prog_out.write_context(Context, !IO), + % io.write_string("Internal compiler error: " ++ % "unknown predicate in `pragma trailing_info'.\n", !IO), - %module_info_incr_errors(!ModuleInfo) + % module_info_incr_errors(!ModuleInfo) true ). @@ -600,7 +600,7 @@ add_pragma_type_spec(Pragma, Context, !ModuleInfo, !QualInfo, !IO) :- ), PredIds \= [] -> - list__foldl3(add_pragma_type_spec_2(Pragma, Context), PredIds, + list.foldl3(add_pragma_type_spec_2(Pragma, Context), PredIds, !ModuleInfo, !QualInfo, !IO) ; undefined_pred_or_func_error(SymName, Arity, Context, @@ -625,9 +625,9 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, pred_info_procedures(PredInfo0, Procs0), handle_pragma_type_spec_modes(SymName, Arity, Context, MaybeModes, ProcIds, Procs0, Procs, ModesOk, !ModuleInfo, !IO), - globals__io_lookup_bool_option(user_guided_type_specialization, + globals.io_lookup_bool_option(user_guided_type_specialization, DoTypeSpec, !IO), - globals__io_lookup_bool_option(smart_recompilation, Smart, !IO), + globals.io_lookup_bool_option(smart_recompilation, Smart, !IO), ( ModesOk = yes, % Even if we aren't doing type specialization, we need @@ -654,7 +654,7 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, % PredOrFunc = pred_info_is_pred_or_func(PredInfo0), adjust_func_arity(PredOrFunc, Arity, PredArity), - varset__init(ArgVarSet0), + varset.init(ArgVarSet0), make_n_fresh_vars("HeadVar__", PredArity, Args, ArgVarSet0, ArgVarSet), % XXX We could use explicit type qualifications here @@ -664,10 +664,10 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, % -- the explicitly declared types are not kept in % sync with the predicate's tvarset after the first % pass of type checking. - % map__from_corresponding_lists(Args, Types, VarTypes0) - map__init(VarTypes0), + % map.from_corresponding_lists(Args, Types, VarTypes0) + map.init(VarTypes0), goal_info_init(GoalInfo0), - set__list_to_set(Args, NonLocals), + set.list_to_set(Args, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo1), goal_info_set_context(Context, GoalInfo1, GoalInfo), @@ -681,7 +681,7 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, do_construct_pred_or_func_call(PredId, PredOrFunc, SymName, Args, GoalInfo, Goal), Clause = clause(ProcIds, Goal, mercury, Context), - map__init(TVarNameMap), + map.init(TVarNameMap), rtti_varmaps_init(RttiVarMaps), HasForeignClauses = no, set_clause_list([Clause], ClausesRep), @@ -689,8 +689,8 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, VarTypes0, Args, ClausesRep, RttiVarMaps, HasForeignClauses), pred_info_get_markers(PredInfo0, Markers0), add_marker(calls_are_fully_qualified, Markers0, Markers), - map__init(Proofs), - map__init(ConstraintMap), + map.init(Proofs), + map.init(ConstraintMap), ( pred_info_is_imported(PredInfo0) -> Status = opt_imported @@ -700,7 +700,7 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, ModuleName = pred_info_module(PredInfo0), pred_info_get_origin(PredInfo0, OrigOrigin), - SubstDesc = list__map(subst_desc, Subst), + SubstDesc = list.map(subst_desc, Subst), Origin = transformed(type_specialization(SubstDesc), OrigOrigin, PredId), pred_info_init(ModuleName, SpecName, PredArity, PredOrFunc, @@ -719,12 +719,11 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, module_info_get_type_spec_info(!.ModuleInfo, TypeSpecInfo0), TypeSpecInfo0 = type_spec_info(ProcsToSpec0, ForceVersions0, SpecMap0, PragmaMap0), - list__map((pred(ProcId::in, PredProcId::out) is det :- + list.map((pred(ProcId::in, PredProcId::out) is det :- PredProcId = proc(PredId, ProcId) ), ProcIds, PredProcIds), - set__insert_list(ProcsToSpec0, PredProcIds, - ProcsToSpec), - set__insert(ForceVersions0, NewPredId, ForceVersions), + set.insert_list(ProcsToSpec0, PredProcIds, ProcsToSpec), + set.insert(ForceVersions0, NewPredId, ForceVersions), ( Status = opt_imported -> % For imported predicates dead_proc_elim.m @@ -732,14 +731,14 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, % is used, the predicate to force the % production of the specialised interface is % also used. - multi_map__set(SpecMap0, PredId, NewPredId, SpecMap) + multi_map.set(SpecMap0, PredId, NewPredId, SpecMap) ; SpecMap = SpecMap0 ), Pragma = type_spec(SymName, SpecName, Arity, yes(PredOrFunc), - MaybeModes, map__to_assoc_list(RenamedSubst), TVarSet, + MaybeModes, map.to_assoc_list(RenamedSubst), TVarSet, ExpandedItems), - multi_map__set(PragmaMap0, PredId, Pragma, PragmaMap), + multi_map.set(PragmaMap0, PredId, Pragma, PragmaMap), TypeSpecInfo = type_spec_info(ProcsToSpec, ForceVersions, SpecMap, PragmaMap), module_info_set_type_spec_info(TypeSpecInfo, @@ -750,7 +749,7 @@ add_pragma_type_spec_2(Pragma0, Context, PredId, !ModuleInfo, !QualInfo, IsImported = yes, ItemType = pred_or_func_to_item_type(PredOrFunc), apply_to_recompilation_info( - recompilation__record_expanded_items( + recompilation.record_expanded_items( item_id(ItemType, SymName - Arity), ExpandedItems), !QualInfo) ; @@ -775,6 +774,7 @@ subst_desc(TVar - Type) = var_to_int(TVar) - Type. % Type substitutions are also invalid if the replacement types are % not ground, however this is a (hopefully temporary) limitation % of the current implementation, so it only results in a warning. + % :- pred handle_pragma_type_spec_subst(prog_context::in, assoc_list(tvar, mer_type)::in, pred_info::in, tvarset::in, tvarset::out, list(mer_type)::out, existq_tvars::out, prog_constraints::out, @@ -783,7 +783,7 @@ subst_desc(TVar - Type) = var_to_int(TVar) - Type. handle_pragma_type_spec_subst(Context, Subst, PredInfo0, TVarSet0, TVarSet, Types, ExistQVars, ClassContext, SubstOk, !ModuleInfo, !IO) :- - assoc_list__keys(Subst, VarsToSub), + assoc_list.keys(Subst, VarsToSub), ( Subst = [] -> @@ -791,60 +791,60 @@ handle_pragma_type_spec_subst(Context, Subst, PredInfo0, TVarSet0, TVarSet, "handle_pragma_type_spec_subst: empty substitution") ; find_duplicate_list_elements(VarsToSub, MultiSubstVars0), - MultiSubstVars0 \= [] + MultiSubstVars0 = [_ | _] -> - list__sort_and_remove_dups(MultiSubstVars0, MultiSubstVars), + list.sort_and_remove_dups(MultiSubstVars0, MultiSubstVars), report_multiple_subst_vars(PredInfo0, Context, TVarSet0, MultiSubstVars, !IO), module_info_incr_errors(!ModuleInfo), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), ExistQVars = [], Types = [], ClassContext = constraints([], []), - varset__init(TVarSet), + varset.init(TVarSet), SubstOk = no ; pred_info_typevarset(PredInfo0, CalledTVarSet), - varset__create_name_var_map(CalledTVarSet, NameVarIndex0), - list__filter((pred(Var::in) is semidet :- - varset__lookup_name(TVarSet0, Var, VarName), - \+ map__contains(NameVarIndex0, VarName) + varset.create_name_var_map(CalledTVarSet, NameVarIndex0), + list.filter((pred(Var::in) is semidet :- + varset.lookup_name(TVarSet0, Var, VarName), + \+ map.contains(NameVarIndex0, VarName) ), VarsToSub, UnknownVarsToSub), ( UnknownVarsToSub = [], % Check that the substitution is not recursive. - set__list_to_set(VarsToSub, VarsToSubSet), + set.list_to_set(VarsToSub, VarsToSubSet), - assoc_list__values(Subst, SubstTypes0), - prog_type__vars_list(SubstTypes0, TVarsInSubstTypes0), - set__list_to_set(TVarsInSubstTypes0, - TVarsInSubstTypes), + assoc_list.values(Subst, SubstTypes0), + prog_type.vars_list(SubstTypes0, TVarsInSubstTypes0), + set.list_to_set(TVarsInSubstTypes0, TVarsInSubstTypes), - set__intersect(TVarsInSubstTypes, VarsToSubSet, RecSubstTVars0), - set__to_sorted_list(RecSubstTVars0, RecSubstTVars), + set.intersect(TVarsInSubstTypes, VarsToSubSet, RecSubstTVars0), + set.to_sorted_list(RecSubstTVars0, RecSubstTVars), - ( RecSubstTVars = [] -> - map__init(TVarRenaming0), - list__append(VarsToSub, TVarsInSubstTypes0, VarsToReplace), + ( + RecSubstTVars = [], + map.init(TVarRenaming0), + list.append(VarsToSub, TVarsInSubstTypes0, VarsToReplace), get_new_tvars(VarsToReplace, TVarSet0, CalledTVarSet, TVarSet, NameVarIndex0, _, TVarRenaming0, TVarRenaming), % Check that none of the existentially % quantified variables were substituted. - map__apply_to_list(VarsToSub, TVarRenaming, RenamedVarsToSub), + map.apply_to_list(VarsToSub, TVarRenaming, RenamedVarsToSub), pred_info_get_exist_quant_tvars(PredInfo0, ExistQVars), - list__filter((pred(RenamedVar::in) is semidet :- - list__member(RenamedVar, ExistQVars) + list.filter((pred(RenamedVar::in) is semidet :- + list.member(RenamedVar, ExistQVars) ), RenamedVarsToSub, SubExistQVars), ( SubExistQVars = [], - map__init(TypeSubst0), + map.init(TypeSubst0), apply_variable_renaming_to_type_list(TVarRenaming, SubstTypes0, SubstTypes), - assoc_list__from_corresponding_lists(RenamedVarsToSub, + assoc_list.from_corresponding_lists(RenamedVarsToSub, SubstTypes, SubAL), - list__foldl(map_set_from_pair, SubAL, + list.foldl(map_set_from_pair, SubAL, TypeSubst0, TypeSubst), % Apply the substitution. @@ -858,21 +858,22 @@ handle_pragma_type_spec_subst(Context, Subst, PredInfo0, TVarSet0, TVarSet, SubExistQVars = [_ | _], report_subst_existq_tvars(PredInfo0, Context, SubExistQVars, !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), module_info_incr_errors(!ModuleInfo), Types = [], ClassContext = constraints([], []), SubstOk = no ) ; + RecSubstTVars = [_ | _], report_recursive_subst(PredInfo0, Context, TVarSet0, RecSubstTVars, !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), module_info_incr_errors(!ModuleInfo), ExistQVars = [], Types = [], ClassContext = constraints([], []), - varset__init(TVarSet), + varset.init(TVarSet), SubstOk = no ) ; @@ -880,11 +881,11 @@ handle_pragma_type_spec_subst(Context, Subst, PredInfo0, TVarSet0, TVarSet, report_unknown_vars_to_subst(PredInfo0, Context, TVarSet0, UnknownVarsToSub, !IO), module_info_incr_errors(!ModuleInfo), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), ExistQVars = [], Types = [], ClassContext = constraints([], []), - varset__init(TVarSet), + varset.init(TVarSet), SubstOk = no ) ). @@ -893,14 +894,14 @@ handle_pragma_type_spec_subst(Context, Subst, PredInfo0, TVarSet0, TVarSet, is det. map_set_from_pair(K - V, !Map) :- - svmap__set(K, V, !Map). + svmap.set(K, V, !Map). :- pred find_duplicate_list_elements(list(T)::in, list(T)::out) is det. find_duplicate_list_elements([], []). find_duplicate_list_elements([H | T], Vars) :- find_duplicate_list_elements(T, Vars0), - ( list__member(H, T) -> + ( list.member(H, T) -> Vars = [H | Vars0] ; Vars = Vars0 @@ -1001,13 +1002,13 @@ handle_pragma_type_spec_modes(SymName, Arity, Context, MaybeModes, ProcIds, !Procs, ModesOk, !ModuleInfo, !IO) :- ( MaybeModes = yes(Modes), - map__to_assoc_list(!.Procs, ExistingProcs), + map.to_assoc_list(!.Procs, ExistingProcs), ( get_procedure_matching_argmodes(ExistingProcs, Modes, !.ModuleInfo, ProcId) -> - map__lookup(!.Procs, ProcId, ProcInfo), - map__det_insert(map__init, ProcId, ProcInfo, !:Procs), + map.lookup(!.Procs, ProcId, ProcInfo), + map.det_insert(map.init, ProcId, ProcInfo, !:Procs), ProcIds = [ProcId], ModesOk = yes ; @@ -1019,7 +1020,7 @@ handle_pragma_type_spec_modes(SymName, Arity, Context, MaybeModes, ProcIds, ) ; MaybeModes = no, - map__keys(!.Procs, ProcIds), + map.keys(!.Procs, ProcIds), ModesOk = yes ). @@ -1062,11 +1063,11 @@ add_pragma_termination2_info(PredOrFunc, SymName, ModeList, proc_info_set_termination2_info(!.TermInfo, ProcInfo0, ProcInfo) ), - map__det_update(ProcTable0, ProcId, ProcInfo, + map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo) ; @@ -1100,7 +1101,7 @@ add_pragma_structure_sharing(_PredOrFunc, _SymName, _ModeList, _HeadVars, add_pragma_structure_sharing(PredOrFunc, SymName, ModeList, HeadVars, Types, yes(SharingDomain), Context, !ModuleInfo, !IO):- module_info_get_predicate_table(!.ModuleInfo, Preds), - list__length(ModeList, Arity), + list.length(ModeList, Arity), ( predicate_table_search_pf_sym_arity(Preds, is_fully_qualified, PredOrFunc, SymName, Arity, PredIds), @@ -1108,14 +1109,14 @@ add_pragma_structure_sharing(PredOrFunc, SymName, ModeList, HeadVars, -> ( PredIds = [PredId] -> module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - map__to_assoc_list(ProcTable0, ProcList), + map.to_assoc_list(ProcTable0, ProcList), ( get_procedure_matching_declmodes(ProcList, ModeList, !.ModuleInfo, ProcId) -> - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), % Rename headvars/types to those used in the proc_info. proc_info_headvars(ProcInfo0, ProcHeadVars), @@ -1134,7 +1135,7 @@ add_pragma_structure_sharing(PredOrFunc, SymName, ModeList, HeadVars, ; unexpected(this_file, "Impossible situation.") ), - map__from_corresponding_lists(RemHeadVars, ProcHeadVars, + map.from_corresponding_lists(RemHeadVars, ProcHeadVars, MapHeadVars), pred_info_arg_types(PredInfo0, ArgTypes), TypeSubst0 = map.init, @@ -1150,9 +1151,9 @@ add_pragma_structure_sharing(PredOrFunc, SymName, ModeList, HeadVars, SharingDomain, RenamedSharingDomain), proc_info_set_structure_sharing(RenamedSharingDomain, ProcInfo0, ProcInfo), - map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable), + map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo) ; module_info_incr_errors(!ModuleInfo), @@ -1185,7 +1186,7 @@ add_pragma_termination_info(PredOrFunc, SymName, ModeList, MaybePragmaArgSizeInfo, MaybePragmaTerminationInfo, Context, !ModuleInfo, !IO) :- module_info_get_predicate_table(!.ModuleInfo, Preds), - list__length(ModeList, Arity), + list.length(ModeList, Arity), ( predicate_table_search_pf_sym_arity(Preds, is_fully_qualified, PredOrFunc, SymName, Arity, PredIds), @@ -1193,9 +1194,9 @@ add_pragma_termination_info(PredOrFunc, SymName, ModeList, -> ( PredIds = [PredId] -> module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - map__to_assoc_list(ProcTable0, ProcList), + map.to_assoc_list(ProcTable0, ProcList), ( get_procedure_matching_declmodes(ProcList, ModeList, !.ModuleInfo, ProcId) @@ -1204,14 +1205,14 @@ add_pragma_termination_info(PredOrFunc, SymName, ModeList, Context, MaybeArgSizeInfo), add_context_to_termination_info(MaybePragmaTerminationInfo, Context, MaybeTerminationInfo), - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), proc_info_set_maybe_arg_size_info(MaybeArgSizeInfo, ProcInfo0, ProcInfo1), proc_info_set_maybe_termination_info(MaybeTerminationInfo, ProcInfo1, ProcInfo), - map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable), + map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo) ; module_info_incr_errors(!ModuleInfo), @@ -1240,14 +1241,14 @@ add_pragma_termination_info(PredOrFunc, SymName, ModeList, module_add_pragma_import(PredName, PredOrFunc, Modes, Attributes, C_Function, Status, Context, !ModuleInfo, !QualInfo, !IO) :- module_info_get_name(!.ModuleInfo, ModuleName), - list__length(Modes, Arity), + list.length(Modes, Arity), - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string("% Processing `:- pragma import' for ", !IO), + io.write_string("% Processing `:- pragma import' for ", !IO), write_simple_call_id(PredOrFunc, PredName/Arity, !IO), - io__write_string("...\n", !IO) + io.write_string("...\n", !IO) ; VeryVerbose = no ), @@ -1268,7 +1269,7 @@ module_add_pragma_import(PredName, PredOrFunc, Modes, Attributes, C_Function, % Lookup the pred_info for this pred, and check that it is valid. module_info_get_predicate_table(!.ModuleInfo, PredicateTable2), predicate_table_get_preds(PredicateTable2, Preds0), - map__lookup(Preds0, PredId, PredInfo0), + map.lookup(Preds0, PredId, PredInfo0), % Opt_imported preds are initially tagged as imported and are tagged as % opt_imported only if/when we see a clause (including a `pragma import' % clause) for them. @@ -1292,14 +1293,14 @@ module_add_pragma_import(PredName, PredOrFunc, Modes, Attributes, C_Function, pred_info_update_goal_type(pragmas, PredInfo1, PredInfo2), % Add the pragma declaration to the proc_info for this procedure. pred_info_procedures(PredInfo2, Procs), - map__to_assoc_list(Procs, ExistingProcs), + map.to_assoc_list(Procs, ExistingProcs), ( get_procedure_matching_argmodes(ExistingProcs, Modes, !.ModuleInfo, ProcId) -> pred_add_pragma_import(PredId, ProcId, Attributes, C_Function, Context, PredInfo2, PredInfo, !ModuleInfo, !QualInfo, !IO), - map__det_update(Preds0, PredId, PredInfo, Preds), + map.det_update(Preds0, PredId, PredInfo, Preds), predicate_table_set_preds(Preds, PredicateTable2, PredicateTable), module_info_set_predicate_table(PredicateTable, !ModuleInfo) @@ -1323,8 +1324,8 @@ module_add_pragma_import(PredName, PredOrFunc, Modes, Attributes, C_Function, pred_add_pragma_import(PredId, ProcId, Attributes, C_Function, Context, !PredInfo, !ModuleInfo, !QualInfo, !IO) :- pred_info_procedures(!.PredInfo, Procs), - map__lookup(Procs, ProcId, ProcInfo), - foreign__make_pragma_import(!.PredInfo, ProcInfo, C_Function, Context, + map.lookup(Procs, ProcId, ProcInfo), + foreign.make_pragma_import(!.PredInfo, ProcInfo, C_Function, Context, PragmaImpl, VarSet, PragmaVars, ArgTypes, Arity, PredOrFunc, !ModuleInfo, !IO), @@ -1353,8 +1354,8 @@ module_add_pragma_foreign_proc(Attributes0, PredName, PredOrFunc, PVars, % with the actual thread safety attributes which we get from the % `--maybe-thread-safe' option. % - globals__io_get_globals(Globals, !IO), - globals__get_maybe_thread_safe(Globals, MaybeThreadSafe), + globals.io_get_globals(Globals, !IO), + globals.get_maybe_thread_safe(Globals, MaybeThreadSafe), ThreadSafe = Attributes0 ^ thread_safe, ( ThreadSafe = maybe_thread_safe -> ( @@ -1369,19 +1370,19 @@ module_add_pragma_foreign_proc(Attributes0, PredName, PredOrFunc, PVars, ), module_info_get_name(!.ModuleInfo, ModuleName), PragmaForeignLanguage = foreign_language(Attributes), - list__length(PVars, Arity), + list.length(PVars, Arity), % print out a progress message - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string("% Processing `:- pragma foreign_proc' for ", !IO), + io.write_string("% Processing `:- pragma foreign_proc' for ", !IO), write_simple_call_id(PredOrFunc, PredName/Arity, !IO), - io__write_string("...\n", !IO) + io.write_string("...\n", !IO) ; VeryVerbose = no ), - globals__io_get_backend_foreign_languages(BackendForeignLangs, !IO), + globals.io_get_backend_foreign_languages(BackendForeignLangs, !IO), % Lookup the pred declaration in the predicate table. % (If it's not there, print an error message and insert @@ -1404,7 +1405,7 @@ module_add_pragma_foreign_proc(Attributes0, PredName, PredOrFunc, PVars, module_info_get_predicate_table(!.ModuleInfo, PredTable1), predicate_table_get_preds(PredTable1, Preds0), some [!PredInfo] ( - map__lookup(Preds0, PredId, !:PredInfo), + map.lookup(Preds0, PredId, !:PredInfo), PredInfo0 = !.PredInfo, % opt_imported preds are initially tagged as imported and are @@ -1423,7 +1424,7 @@ module_add_pragma_foreign_proc(Attributes0, PredName, PredOrFunc, PVars, -> pred_info_clauses_info(!.PredInfo, CInfo0), clauses_info_clauses_only(CInfo0, ClauseList0), - ClauseList = list__map( + ClauseList = list.map( (func(C) = Res :- AllProcIds = pred_info_all_procids(!.PredInfo), ( C = clause([], Goal, mercury, Ctxt) -> @@ -1454,16 +1455,16 @@ module_add_pragma_foreign_proc(Attributes0, PredName, PredOrFunc, PVars, simple_call_id(PredOrFunc - PredName/Arity), suffix(".")], write_error_pieces(Context, 0, Pieces, !IO) ; - % Don't add clauses for foreign languages other - % than the ones we can generate code for. - not list__member(PragmaForeignLanguage, BackendForeignLangs) + % Don't add clauses for foreign languages other than the ones + % we can generate code for. + not list.member(PragmaForeignLanguage, BackendForeignLangs) -> pred_info_update_goal_type(pragmas, PredInfo0, !:PredInfo), module_info_set_pred_info(PredId, !.PredInfo, !ModuleInfo) ; % add the pragma declaration to the proc_info for this procedure pred_info_procedures(!.PredInfo, Procs), - map__to_assoc_list(Procs, ExistingProcs), + map.to_assoc_list(Procs, ExistingProcs), pragma_get_modes(PVars, Modes), ( % The inst variables for the foreign_proc declaration @@ -1488,7 +1489,7 @@ module_add_pragma_foreign_proc(Attributes0, PredName, PredOrFunc, PVars, !ModuleInfo, !IO), pred_info_set_clauses_info(Clauses, !PredInfo), pred_info_update_goal_type(pragmas, !PredInfo), - map__det_update(Preds0, PredId, !.PredInfo, Preds), + map.det_update(Preds0, PredId, !.PredInfo, Preds), predicate_table_set_preds(Preds, PredTable1, PredTable), module_info_set_predicate_table(PredTable, !ModuleInfo), pragma_get_var_infos(PVars, ArgInfoBox), @@ -1527,7 +1528,7 @@ module_add_pragma_tabled(EvalMethod, PredName, Arity, MaybePredOrFunc, PredIds = PredIds0 ; module_info_get_name(!.ModuleInfo, ModuleName), - string__format("`:- pragma %s' declaration", + string.format("`:- pragma %s' declaration", [s(EvalMethodStr)], Message1), preds_add_implicit_report_error(ModuleName, PredOrFunc, PredName, Arity, Status, no, Context, user(PredName), Message1, PredId, @@ -1543,7 +1544,7 @@ module_add_pragma_tabled(EvalMethod, PredName, Arity, MaybePredOrFunc, PredIds = PredIds0 ; module_info_get_name(!.ModuleInfo, ModuleName), - string__format("`:- pragma %s' declaration", + string.format("`:- pragma %s' declaration", [s(EvalMethodStr)], Message1), preds_add_implicit_report_error(ModuleName, predicate, PredName, Arity, Status, no, Context, user(PredName), Message1, PredId, @@ -1551,7 +1552,7 @@ module_add_pragma_tabled(EvalMethod, PredName, Arity, MaybePredOrFunc, PredIds = [PredId] ) ), - list__foldl2( + list.foldl2( module_add_pragma_tabled_2(EvalMethod, PredName, Arity, MaybePredOrFunc, MaybeModes, Context), PredIds, !ModuleInfo, !IO). @@ -1563,7 +1564,7 @@ module_add_pragma_tabled(EvalMethod, PredName, Arity, MaybePredOrFunc, module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc, MaybeModes, Context, PredId, !ModuleInfo, !IO) :- ( EvalMethod0 = eval_minimal(_) -> - globals__io_lookup_bool_option(use_minimal_model_own_stacks, + globals.io_lookup_bool_option(use_minimal_model_own_stacks, OwnStacks, !IO), ( OwnStacks = yes, @@ -1579,7 +1580,7 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc, % Lookup the pred_info for this pred. module_info_get_predicate_table(!.ModuleInfo, PredicateTable), predicate_table_get_preds(PredicateTable, Preds), - map__lookup(Preds, PredId, PredInfo0), + map.lookup(Preds, PredId, PredInfo0), ( MaybePredOrFunc = yes(PredOrFunc0), PredOrFunc = PredOrFunc0 @@ -1590,14 +1591,14 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc, adjust_func_arity(PredOrFunc, Arity0, Arity), EvalMethodStr = eval_method_to_one_string(EvalMethod), - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string("% Processing `:- pragma ", !IO), - io__write_string(EvalMethodStr, !IO), - io__write_string("' for ", !IO), + io.write_string("% Processing `:- pragma ", !IO), + io.write_string(EvalMethodStr, !IO), + io.write_string("' for ", !IO), write_simple_call_id(PredOrFunc, PredName/Arity, !IO), - io__write_string("...\n", !IO) + io.write_string("...\n", !IO) ; VeryVerbose = no ), @@ -1636,7 +1637,7 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc, % Do we have to make sure the tabled preds are stratified? ( eval_method_needs_stratification(EvalMethod) = yes -> module_info_get_stratified_preds(!.ModuleInfo, StratPredIds0), - set__insert(StratPredIds0, PredId, StratPredIds), + set.insert(StratPredIds0, PredId, StratPredIds), module_info_set_stratified_preds(StratPredIds, !ModuleInfo) ; true @@ -1644,7 +1645,7 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc, % Add the eval model to the proc_info for this procedure. pred_info_procedures(PredInfo0, ProcTable0), - map__to_assoc_list(ProcTable0, ExistingProcs), + map.to_assoc_list(ProcTable0, ExistingProcs), SimpleCallId = PredOrFunc - PredName/Arity, ( MaybeModes = yes(Modes), @@ -1652,7 +1653,7 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc, get_procedure_matching_argmodes(ExistingProcs, Modes, !.ModuleInfo, ProcId) -> - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), set_eval_method(ProcId, ProcInfo0, Context, SimpleCallId, EvalMethod, ProcTable0, ProcTable, !ModuleInfo, !IO), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), @@ -1746,7 +1747,7 @@ set_eval_method(ProcId, ProcInfo0, Context, SimpleCallId, EvalMethod, ( MaybeError = no, proc_info_set_eval_method(EvalMethod, ProcInfo0, ProcInfo), - svmap__det_update(ProcId, ProcInfo, !ProcTable) + svmap.det_update(ProcId, ProcInfo, !ProcTable) ; MaybeError = yes(ArgMsg - ErrorMsg), EvalMethodStr = eval_method_to_one_string(EvalMethod), @@ -1883,7 +1884,7 @@ module_add_pragma_fact_table(Pred, Arity, FileName, Status, Context, module_add_fact_table_file(FileName, !ModuleInfo), - io__get_exit_status(ExitStatus, !IO), + io.get_exit_status(ExitStatus, !IO), ( ExitStatus = 1 -> true ; @@ -1895,7 +1896,7 @@ module_add_pragma_fact_table(Pred, Arity, FileName, Status, Context, ) ; PredIDs1 = [_ | _], % >1 predicate found - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), Pieces = [words("In pragma fact_table for"), sym_name_and_arity(Pred/Arity), suffix(":"), nl, words("error: ambiguous predicate/function name.")], @@ -1937,9 +1938,9 @@ module_add_fact_table_procedures([ProcID | ProcIDs], PrimaryProcID, ProcTable, module_add_fact_table_proc(ProcID, PrimaryProcID, ProcTable, SymName, PredOrFunc, Arity, ArgTypes, Status, Context, !ModuleInfo, !QualInfo, !IO) :- - map__lookup(ProcTable, ProcID, ProcInfo), - varset__init(ProgVarSet0), - varset__new_vars(ProgVarSet0, Arity, Vars, ProgVarSet), + map.lookup(ProcTable, ProcID, ProcInfo), + varset.init(ProgVarSet0), + varset.new_vars(ProgVarSet0, Arity, Vars, ProgVarSet), proc_info_argmodes(ProcInfo, Modes), proc_info_inst_varset(ProcInfo, InstVarSet), fact_table_pragma_vars(Vars, Modes, ProgVarSet, PragmaVars), @@ -1982,7 +1983,7 @@ fact_table_pragma_vars(Vars0, Modes0, VarSet, PragmaVars0) :- Vars0 = [Var | VarsTail], Modes0 = [Mode | ModesTail] -> - varset__lookup_name(VarSet, Var, Name), + varset.lookup_name(VarSet, Var, Name), PragmaVar = pragma_var(Var, Name, Mode, native_if_possible), fact_table_pragma_vars(VarsTail, ModesTail, VarSet, PragmaVarsTail), PragmaVars0 = [PragmaVar | PragmaVarsTail] @@ -2014,13 +2015,13 @@ clauses_info_add_pragma_foreign_proc(Purity, Attributes0, PredId, ProcId, % Find all the existing clauses for this mode, and % extract their implementation language and clause number % (that is, their index in the list). - globals__io_get_globals(Globals, !IO), - globals__io_get_target(Target, !IO), + globals.io_get_globals(Globals, !IO), + globals.io_get_target(Target, !IO), NewLang = foreign_language(Attributes0), - list__foldl2(decide_action(Globals, Target, NewLang, ProcId), ClauseList, + list.foldl2(decide_action(Globals, Target, NewLang, ProcId), ClauseList, add, FinalAction, 1, _), - globals__io_get_backend_foreign_languages(BackendForeignLanguages, !IO), + globals.io_get_backend_foreign_languages(BackendForeignLanguages, !IO), pragma_get_vars(PVars, Args0), pragma_get_var_infos(PVars, ArgInfo), @@ -2028,26 +2029,26 @@ clauses_info_add_pragma_foreign_proc(Purity, Attributes0, PredId, ProcId, % If the foreign language not one of the backend languages, we will % have to generate an interface to it in a backend language. % - foreign__extrude_pragma_implementation(BackendForeignLanguages, + foreign.extrude_pragma_implementation(BackendForeignLanguages, PVars, PredName, PredOrFunc, Context, !ModuleInfo, Attributes0, Attributes, PragmaImpl0, PragmaImpl), % % Check for arguments occurring multiple times. % - bag__init(ArgBag0), - bag__insert_list(ArgBag0, Args0, ArgBag), - bag__to_assoc_list(ArgBag, ArgBagAL0), - list__filter( + bag.init(ArgBag0), + bag.insert_list(ArgBag0, Args0, ArgBag), + bag.to_assoc_list(ArgBag, ArgBagAL0), + list.filter( (pred(Arg::in) is semidet :- Arg = _ - Occurrences, Occurrences > 1 ), ArgBagAL0, ArgBagAL), - assoc_list__keys(ArgBagAL, MultipleArgs), + assoc_list.keys(ArgBagAL, MultipleArgs), ( MultipleArgs = [_ | _], - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), adjust_func_arity(PredOrFunc, OrigArity, Arity), Pieces1 = [words("In `:- pragma foreign_proc' declaration for"), simple_call_id(PredOrFunc - PredName/OrigArity), suffix(":"), nl], @@ -2073,7 +2074,7 @@ clauses_info_add_pragma_foreign_proc(Purity, Attributes0, PredId, ProcId, make_foreign_args(HeadVars, ArgInfo, OrigArgTypes, ForeignArgs), HldsGoal0 = foreign_proc(Attributes, PredId, ProcId, ForeignArgs, [], PragmaImpl) - GoalInfo, - map__init(EmptyVarTypes), + map.init(EmptyVarTypes), implicitly_quantify_clause_body(HeadVars, _Warnings, HldsGoal0, HldsGoal, VarSet0, VarSet, EmptyVarTypes, _), NewClause = clause([ProcId], HldsGoal, foreign_language(NewLang), @@ -2086,10 +2087,10 @@ clauses_info_add_pragma_foreign_proc(Purity, Attributes0, PredId, ProcId, NewClauseList = [NewClause | ClauseList] ; FinalAction = replace(N), - list__replace_nth_det(ClauseList, N, NewClause, NewClauseList) + list.replace_nth_det(ClauseList, N, NewClause, NewClauseList) ; FinalAction = split_add(N, Clause), - list__replace_nth_det(ClauseList, N, Clause, NewClauseListTail), + list.replace_nth_det(ClauseList, N, Clause, NewClauseListTail), NewClauseList = [NewClause | NewClauseListTail] ), HasForeignClauses = yes, @@ -2117,7 +2118,7 @@ is_applicable_for_current_backend(CurrentBackend, [Attr | Attrs]) = Result :- ). lookup_current_backend(CurrentBackend, !IO) :- - globals__io_lookup_bool_option(highlevel_code, HighLevel, !IO), + globals.io_lookup_bool_option(highlevel_code, HighLevel, !IO), ( HighLevel = yes, CurrentBackend = high_level_backend @@ -2156,7 +2157,7 @@ decide_action(Globals, Target, NewLang, ProcId, Clause, !Action, !ClauseNum) :- ClauseLang = mercury, ( ProcIds = [ProcId] -> !:Action = replace(!.ClauseNum) - ; list__delete_first(ProcIds, ProcId, MercuryProcIds) -> + ; list.delete_first(ProcIds, ProcId, MercuryProcIds) -> NewMercuryClause = clause(MercuryProcIds, Body, ClauseLang, Context), !:Action = split_add(!.ClauseNum, NewMercuryClause) @@ -2165,7 +2166,7 @@ decide_action(Globals, Target, NewLang, ProcId, Clause, !Action, !ClauseNum) :- ) ; ClauseLang = foreign_language(OldLang), - ( list__member(ProcId, ProcIds) -> + ( list.member(ProcId, ProcIds) -> ( yes = prefer_foreign_language(Globals, Target, OldLang, NewLang) @@ -2189,7 +2190,7 @@ decide_action(Globals, Target, NewLang, ProcId, Clause, !Action, !ClauseNum) :- list(mer_mode)::in, module_info::in, proc_id::out) is semidet. get_procedure_matching_argmodes(Procs, Modes0, ModuleInfo, ProcId) :- - list__map(constrain_inst_vars_in_mode, Modes0, Modes), + list.map(constrain_inst_vars_in_mode, Modes0, Modes), get_procedure_matching_argmodes_2(Procs, Modes, ModuleInfo, ProcId). :- pred get_procedure_matching_argmodes_2(assoc_list(proc_id, proc_info)::in, @@ -2213,7 +2214,7 @@ get_procedure_matching_argmodes_2([P | Procs], Modes, ModuleInfo, OurProcId) :- get_procedure_matching_argmodes_with_renaming(Procs, Modes0, ModuleInfo, ProcId) :- - list__map(constrain_inst_vars_in_mode, Modes0, Modes), + list.map(constrain_inst_vars_in_mode, Modes0, Modes), get_procedure_matching_argmodes_with_renaming_2(Procs, Modes, ModuleInfo, ProcId). @@ -2233,7 +2234,7 @@ get_procedure_matching_argmodes_with_renaming_2([P | Procs], Modes, ). get_procedure_matching_declmodes(Procs, Modes0, ModuleInfo, ProcId) :- - list__map(constrain_inst_vars_in_mode, Modes0, Modes), + list.map(constrain_inst_vars_in_mode, Modes0, Modes), get_procedure_matching_declmodes_2(Procs, Modes, ModuleInfo, ProcId). :- pred get_procedure_matching_declmodes_2(assoc_list(proc_id, proc_info)::in, diff --git a/compiler/add_pred.m b/compiler/add_pred.m index 4e2c03e54..2df6fefaa 100644 --- a/compiler/add_pred.m +++ b/compiler/add_pred.m @@ -9,7 +9,7 @@ % This submodule of make_hlds handles the type and mode declarations % for predicates. -:- module hlds__make_hlds__add_pred. +:- module hlds.make_hlds.add_pred. :- interface. :- import_module hlds.hlds_module. @@ -104,12 +104,12 @@ module_add_pred_or_func(TypeVarSet, InstVarSet, ExistQVars, MaybeModes0 = no, MaybeDet = yes(_) -> - list__length(Types, Arity), + list.length(Types, Arity), adjust_func_arity(function, FuncArity, Arity), in_mode(InMode), - list__duplicate(FuncArity, InMode, InModes), + list.duplicate(FuncArity, InMode, InModes), out_mode(OutMode), - list__append(InModes, [OutMode], ArgModes), + list.append(InModes, [OutMode], ArgModes), MaybeModes = yes(ArgModes) ; MaybeModes = MaybeModes0 @@ -151,7 +151,7 @@ add_new_pred(TVarSet, ExistQVars, PredName, Types, Purity, ClassContext, Status = ItemStatus ), module_info_get_name(!.ModuleInfo, ModuleName), - list__length(Types, Arity), + list.length(Types, Arity), ( PredName = unqualified(_PName), module_info_incr_errors(!ModuleInfo), @@ -162,11 +162,11 @@ add_new_pred(TVarSet, ExistQVars, PredName, Types, Purity, ClassContext, PredName = qualified(MNameOfPred, PName), module_info_get_predicate_table(!.ModuleInfo, PredTable0), clauses_info_init(Arity, ClausesInfo), - map__init(Proofs), - map__init(ConstraintMap), + map.init(Proofs), + map.init(ConstraintMap), purity_to_markers(Purity, PurityMarkers), markers_to_marker_list(PurityMarkers, MarkersList), - list__foldl(add_marker, MarkersList, Markers0, Markers), + list.foldl(add_marker, MarkersList, Markers0, Markers), pred_info_init(ModuleName, PredName, Arity, PredOrFunc, Context, user(PredName), Status, none, Markers, Types, TVarSet, ExistQVars, ClassContext, Proofs, ConstraintMap, ClausesInfo, PredInfo0), @@ -194,7 +194,7 @@ add_new_pred(TVarSet, ExistQVars, PredName, Types, Purity, ClassContext, ( pred_info_is_builtin(PredInfo0) -> add_builtin(PredId, Types, PredInfo0, PredInfo), predicate_table_get_preds(PredTable1, Preds1), - map__det_update(Preds1, PredId, PredInfo, Preds), + map.det_update(Preds1, PredId, PredInfo, Preds), predicate_table_set_preds(Preds, PredTable1, PredTable) ; PredTable = PredTable1 @@ -242,15 +242,15 @@ add_builtin(PredId, Types, !PredInfo) :- % Construct a clause containing that pseudo-recursive call. goal_info_init(Context, GoalInfo0), - set__list_to_set(HeadVars, NonLocals), + set.list_to_set(HeadVars, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo), Goal = GoalExpr - GoalInfo, Clause = clause([], Goal, mercury, Context), % Put the clause we just built into the pred_info, % annotateed with the appropriate types. - map__from_corresponding_lists(HeadVars, Types, VarTypes), - map__init(TVarNameMap), + map.from_corresponding_lists(HeadVars, Types, VarTypes), + map.init(TVarNameMap), rtti_varmaps_init(RttiVarMaps), HasForeignClauses = no, set_clause_list([Clause], ClausesRep), @@ -278,7 +278,7 @@ do_add_new_proc(InstVarSet, Arity, ArgModes, MaybeDeclaredArgModes, proc_info_init(Context, Arity, ArgTypes, MaybeDeclaredArgModes, ArgModes, MaybeArgLives, MaybeDet, IsAddressTaken, NewProc0), proc_info_set_inst_varset(InstVarSet, NewProc0, NewProc), - map__det_insert(Procs0, ModeId, NewProc, Procs), + map.det_insert(Procs0, ModeId, NewProc, Procs), pred_info_set_procedures(Procs, PredInfo0, PredInfo). %-----------------------------------------------------------------------------% @@ -296,7 +296,7 @@ module_add_mode(InstVarSet, PredName, Modes, MaybeDet, Status, MContext, module_info_get_name(!.ModuleInfo, ModuleName0), sym_name_get_module_name(PredName, ModuleName0, ModuleName), - list__length(Modes, Arity), + list.length(Modes, Arity), module_info_get_predicate_table(!.ModuleInfo, PredicateTable0), ( predicate_table_search_pf_sym_arity(PredicateTable0, @@ -310,11 +310,11 @@ module_add_mode(InstVarSet, PredName, Modes, MaybeDet, Status, MContext, ), module_info_get_predicate_table(!.ModuleInfo, PredicateTable1), predicate_table_get_preds(PredicateTable1, Preds0), - map__lookup(Preds0, PredId, PredInfo0), + map.lookup(Preds0, PredId, PredInfo0), module_do_add_mode(InstVarSet, Arity, Modes, MaybeDet, IsClassMethod, MContext, PredInfo0, PredInfo, ProcId, !IO), - map__det_update(Preds0, PredId, PredInfo, Preds), + map.det_update(Preds0, PredId, PredInfo, Preds), predicate_table_set_preds(Preds, PredicateTable1, PredicateTable), module_info_set_predicate_table(PredicateTable, !ModuleInfo), PredProcId = PredId - ProcId. @@ -340,7 +340,7 @@ module_do_add_mode(InstVarSet, Arity, Modes, MaybeDet, IsClassMethod, MContext, unspecified_det_for_exported(PredSymName, Arity, PredOrFunc, MContext, !IO) ; - globals__io_lookup_bool_option(infer_det, InferDet, !IO), + globals.io_lookup_bool_option(infer_det, InferDet, !IO), ( InferDet = no, unspecified_det_for_local(PredSymName, Arity, PredOrFunc, @@ -389,8 +389,8 @@ preds_add_implicit(ModuleInfo, ModuleName, PredName, Arity, Status, Context, preds_add_implicit_for_assertion(HeadVars, ModuleInfo, ModuleName, PredName, Arity, Status, Context, PredOrFunc, PredId, !PredicateTable) :- clauses_info_init_for_assertion(HeadVars, ClausesInfo), - term__context_file(Context, FileName), - term__context_line(Context, LineNum), + term.context_file(Context, FileName), + term.context_line(Context, LineNum), preds_add_implicit_2(ClausesInfo, ModuleInfo, ModuleName, PredName, Arity, Status, Context, assertion(FileName, LineNum), PredOrFunc, PredId, !PredicateTable). @@ -402,11 +402,11 @@ preds_add_implicit_for_assertion(HeadVars, ModuleInfo, ModuleName, PredName, preds_add_implicit_2(ClausesInfo, ModuleInfo, ModuleName, PredName, Arity, Status, Context, Origin, PredOrFunc, PredId, !PredicateTable) :- - varset__init(TVarSet0), + varset.init(TVarSet0), make_n_fresh_vars("T", Arity, TypeVars, TVarSet0, TVarSet), - prog_type.var_list_to_type_list(map__init, TypeVars, Types), - map__init(Proofs), - map__init(ConstraintMap), + prog_type.var_list_to_type_list(map.init, TypeVars, Types), + map.init(Proofs), + map.init(ConstraintMap), % The class context is empty since this is an implicit % definition. Inference will fill it in. ClassContext = constraints([], []), @@ -441,7 +441,7 @@ unspecified_det_for_local(Name, Arity, PredOrFunc, Context, !IO) :- suffix(".")], write_error_pieces(Context, 0, Pieces, !IO), record_warning(!IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, VerbosePieces = [words("(This is an error because"), @@ -465,7 +465,7 @@ unspecified_det_for_method(Name, Arity, PredOrFunc, Context, !IO) :- sym_name_and_arity(Name / Arity), suffix(".")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred unspecified_det_for_exported(sym_name::in, arity::in, pred_or_func::in, prog_context::in, io::di, io::uo) is det. @@ -476,7 +476,7 @@ unspecified_det_for_exported(Name, Arity, PredOrFunc, Context, !IO) :- sym_name_and_arity(Name / Arity), suffix(".")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred unqualified_pred_error(sym_name::in, int::in, prog_context::in, io::di, io::uo) is det. @@ -486,7 +486,7 @@ unqualified_pred_error(PredName, Arity, Context, !IO) :- sym_name_and_arity(PredName / Arity), words("should have been qualified by prog_io.m.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/add_solver.m b/compiler/add_solver.m index 54627389b..44570e6df 100644 --- a/compiler/add_solver.m +++ b/compiler/add_solver.m @@ -6,7 +6,7 @@ % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__add_solver. +:- module hlds.make_hlds.add_solver. :- interface. :- import_module hlds.hlds_module. @@ -76,7 +76,7 @@ add_solver_type_decl_items(TVarSet, TypeSymName, TypeParams, % XXX kind inference: % We set the kinds to `star'. This will be different when we have a % kind system. - prog_type.var_list_to_type_list(map__init, TypeParams, Args), + prog_type.var_list_to_type_list(map.init, TypeParams, Args), SolverType = defined(TypeSymName, Args, star), Arity = length(TypeParams), @@ -90,7 +90,7 @@ add_solver_type_decl_items(TVarSet, TypeSymName, TypeParams, OutAnyMode = out_mode(AnyInst), OutGroundMode = out_mode(GroundInst), - InstVarSet = varset__init, + InstVarSet = varset.init, ExistQTVars = [], init_markers(NoMarkers), @@ -189,11 +189,11 @@ add_solver_type_clause_items(TypeSymName, TypeParams, SolverTypeDetails, OutAnyMode = out_mode(AnyInst), OutGroundMode = out_mode(GroundInst), - ProgVarSet0 = varset__init, - varset__new_var(ProgVarSet0, X, ProgVarSet1), - varset__new_var(ProgVarSet1, Y, ProgVarSet), + ProgVarSet0 = varset.init, + varset.new_var(ProgVarSet0, X, ProgVarSet1), + varset.new_var(ProgVarSet1, Y, ProgVarSet), - InstVarSet = varset__init, + InstVarSet = varset.init, Attrs0 = default_attributes(c), some [!Attrs] ( diff --git a/compiler/add_special_pred.m b/compiler/add_special_pred.m index d3f713f43..57f1ff749 100644 --- a/compiler/add_special_pred.m +++ b/compiler/add_special_pred.m @@ -10,7 +10,7 @@ % (if needed) index and init predicates for the types defined or imported % by the module being compiled. -:- module hlds__make_hlds__add_special_pred. +:- module hlds.make_hlds.add_special_pred. :- interface. :- import_module hlds.hlds_data. @@ -107,7 +107,7 @@ % % Note: this predicate should include index in the list of special % predicates to be defined only for the kinds of types which do not - % lead unify_proc__generate_index_clauses to abort. + % lead unify_proc.generate_index_clauses to abort. % add_special_preds(TVarSet, Type, TypeCtor, Body, Context, Status, !ModuleInfo) :- @@ -129,9 +129,9 @@ add_special_preds(TVarSet, Type, TypeCtor, Body, Context, Status, Body ^ du_type_is_enum = not_enum_or_dummy, Body ^ du_type_usereq = no, module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_int_option(Globals, compare_specialization, + globals.lookup_int_option(Globals, compare_specialization, CompareSpec), - list__length(Ctors, CtorCount), + list.length(Ctors, CtorCount), CtorCount > CompareSpec -> SpecialPredIds = [spec_pred_index, spec_pred_compare] @@ -145,7 +145,7 @@ add_special_preds(TVarSet, Type, TypeCtor, Body, Context, Status, % Never add clauses for comparison predicates % for imported types -- they will never be used. module_info_get_special_pred_map(!.ModuleInfo, SpecialPreds), - ( map__contains(SpecialPreds, spec_pred_compare - TypeCtor) -> + ( map.contains(SpecialPreds, spec_pred_compare - TypeCtor) -> true ; add_special_pred_decl(spec_pred_compare, TVarSet, Type, @@ -153,7 +153,7 @@ add_special_preds(TVarSet, Type, TypeCtor, Body, Context, Status, ) ), ( - type_util__type_body_is_solver_type(!.ModuleInfo, Body) + type_util.type_body_is_solver_type(!.ModuleInfo, Body) -> add_special_pred(spec_pred_init, TVarSet, Type, TypeCtor, Body, Context, Status, !ModuleInfo) @@ -161,7 +161,7 @@ add_special_preds(TVarSet, Type, TypeCtor, Body, Context, Status, true ) ; - ( type_util__type_body_is_solver_type(!.ModuleInfo, Body) -> + ( type_util.type_body_is_solver_type(!.ModuleInfo, Body) -> SpecialPredIds = [spec_pred_unify, spec_pred_compare, spec_pred_init] ; @@ -190,7 +190,7 @@ add_special_pred_list([SpecialPredId | SpecialPredIds], TVarSet, Type, add_special_pred(SpecialPredId, TVarSet, Type, TypeCtor, TypeBody, Context, Status0, !ModuleInfo) :- module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, special_preds, GenSpecialPreds), + globals.lookup_bool_option(Globals, special_preds, GenSpecialPreds), ( GenSpecialPreds = yes, do_add_special_pred_for_real(SpecialPredId, TVarSet, @@ -239,16 +239,16 @@ do_add_special_pred_for_real(SpecialPredId, TVarSet, Type0, TypeCtor, Type = adjust_types_with_special_preds_in_private_builtin(Type0), adjust_special_pred_status(SpecialPredId, Status0, Status), module_info_get_special_pred_map(!.ModuleInfo, SpecialPredMap0), - ( map__contains(SpecialPredMap0, SpecialPredId - TypeCtor) -> + ( map.contains(SpecialPredMap0, SpecialPredId - TypeCtor) -> true ; do_add_special_pred_decl_for_real(SpecialPredId, TVarSet, Type, TypeCtor, Context, Status, !ModuleInfo) ), module_info_get_special_pred_map(!.ModuleInfo, SpecialPredMap1), - map__lookup(SpecialPredMap1, SpecialPredId - TypeCtor, PredId), + map.lookup(SpecialPredMap1, SpecialPredId - TypeCtor, PredId), module_info_preds(!.ModuleInfo, Preds0), - map__lookup(Preds0, PredId, PredInfo0), + map.lookup(Preds0, PredId, PredInfo0), % if the type was imported, then the special preds for that % type should be imported too ( @@ -276,7 +276,7 @@ do_add_special_pred_for_real(SpecialPredId, TVarSet, Type0, TypeCtor, ; PredInfo1 = PredInfo0 ), - unify_proc__generate_clause_info(SpecialPredId, Type, TypeBody, + unify_proc.generate_clause_info(SpecialPredId, Type, TypeBody, Context, !.ModuleInfo, ClausesInfo), pred_info_set_clauses_info(ClausesInfo, PredInfo1, PredInfo2), pred_info_get_markers(PredInfo2, Markers2), @@ -284,7 +284,7 @@ do_add_special_pred_for_real(SpecialPredId, TVarSet, Type0, TypeCtor, pred_info_set_markers(Markers, PredInfo2, PredInfo3), pred_info_set_origin(special_pred(SpecialPredId - TypeCtor), PredInfo3, PredInfo), - map__det_update(Preds0, PredId, PredInfo, Preds), + map.det_update(Preds0, PredId, PredInfo, Preds), module_info_set_preds(Preds, !ModuleInfo). % These types need to have the builtin qualifier removed @@ -323,7 +323,7 @@ add_special_pred_decl_list([SpecialPredId | SpecialPredIds], TVarSet, Type, add_special_pred_decl(SpecialPredId, TVarSet, Type, TypeCtor, TypeBody, Context, Status0, !ModuleInfo) :- module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, special_preds, GenSpecialPreds), + globals.lookup_bool_option(Globals, special_preds, GenSpecialPreds), ( GenSpecialPreds = yes -> do_add_special_pred_decl_for_real(SpecialPredId, TVarSet, Type, TypeCtor, Context, Status0, !ModuleInfo) @@ -351,8 +351,8 @@ do_add_special_pred_decl_for_real(SpecialPredId, TVarSet, Type, TypeCtor, clauses_info_init(Arity, ClausesInfo0), Origin = special_pred(SpecialPredId - TypeCtor), adjust_special_pred_status(SpecialPredId, Status0, Status), - map__init(Proofs), - map__init(ConstraintMap), + map.init(Proofs), + map.init(ConstraintMap), init_markers(Markers), % XXX If/when we have "comparable" or "unifiable" typeclasses, % XXX this context might not be empty @@ -362,7 +362,7 @@ do_add_special_pred_decl_for_real(SpecialPredId, TVarSet, Type, TypeCtor, Origin, Status, none, Markers, ArgTypes, TVarSet, ExistQVars, ClassContext, Proofs, ConstraintMap, ClausesInfo0, PredInfo0), ArgLives = no, - varset__init(InstVarSet), + varset.init(InstVarSet), % Should not be any inst vars here so it's ok to use a % fresh inst_varset. do_add_new_proc(InstVarSet, Arity, ArgModes, yes(ArgModes), ArgLives, @@ -372,7 +372,7 @@ do_add_special_pred_decl_for_real(SpecialPredId, TVarSet, Type, TypeCtor, predicate_table_insert(PredInfo, PredId, PredicateTable0, PredicateTable), module_info_set_predicate_table(PredicateTable, !ModuleInfo), module_info_get_special_pred_map(!.ModuleInfo, SpecialPredMap0), - map__set(SpecialPredMap0, SpecialPredId - TypeCtor, PredId, + map.set(SpecialPredMap0, SpecialPredId - TypeCtor, PredId, SpecialPredMap), module_info_set_special_pred_map(SpecialPredMap, !ModuleInfo). @@ -381,15 +381,13 @@ do_add_special_pred_decl_for_real(SpecialPredId, TVarSet, Type, TypeCtor, add_special_pred_unify_status(TypeBody, Status0, Status) :- ( TypeBody ^ du_type_usereq = yes(_) -> - % If the type has user-defined equality, - % then we create a real unify predicate - % for it, whose body calls the user-specified - % predicate. The compiler's usual type checking - % algorithm will handle any necessary - % disambiguation from predicates with the same - % name but different argument types, and the - % usual mode checking algorithm will select - % the right mode of the chosen predicate. + % If the type has user-defined equality, then we create a real + % unify predicate for it, whose body calls the user-specified + % predicate. The compiler's usual type checking algorithm + % will handle any necessary disambiguation from predicates + % with the same name but different argument types, and the usual + % mode checking algorithm will select the right mode of the chosen + % predicate. Status = Status0 ; Status = pseudo_imported diff --git a/compiler/add_trail_ops.m b/compiler/add_trail_ops.m index 4ded5fb71..d4021d1aa 100644 --- a/compiler/add_trail_ops.m +++ b/compiler/add_trail_ops.m @@ -50,7 +50,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__add_trail_ops. +:- module ml_backend.add_trail_ops. :- interface. :- import_module hlds.hlds_module. @@ -187,7 +187,7 @@ goal_expr_add_trail_ops(not(InnerGoal), OuterGoalInfo, Goal, !Info) :- % The "then" part of the if-then-else will be unreachable, but to % preserve the invariants that the MLDS back-end relies on, we need to % make sure that it can't fail. So we use a call to - % `private_builtin__unused' (which will call error/1) rather than + % `private_builtin.unused' (which will call error/1) rather than % `fail' for the "then" part. mercury_private_builtin_module(PrivateBuiltin), generate_simple_call(PrivateBuiltin, "unused", predicate, only_mode, @@ -323,7 +323,7 @@ goal_expr_add_trail_ops(shorthand(_), _, _, !Info) :- trail_ops_info::in, trail_ops_info::out) is det. conj_add_trail_ops(Goals0, Goals, !Info) :- - list__map_foldl(goal_add_trail_ops, Goals0, Goals, !Info). + list.map_foldl(goal_add_trail_ops, Goals0, Goals, !Info). :- pred disj_add_trail_ops(hlds_goals::in, bool::in, bool::in, code_model::in, prog_var::in, hlds_goals::out, @@ -602,8 +602,8 @@ new_ticket_counter_var(Var, !Info) :- new_var(Name, Type, Var, !Info) :- VarSet0 = !.Info ^ varset, VarTypes0 = !.Info ^ var_types, - varset__new_named_var(VarSet0, Name, Var, VarSet), - map__det_insert(VarTypes0, Var, Type, VarTypes), + varset.new_named_var(VarSet0, Name, Var, VarSet), + map.det_insert(VarTypes0, Var, Type, VarTypes), !:Info = !.Info ^ varset := VarSet, !:Info = !.Info ^ var_types := VarTypes. @@ -621,12 +621,12 @@ ticket_counter_type = c_pointer_type. :- pred trail_generate_call(string::in, determinism::in, list(prog_var)::in, list(goal_feature)::in, assoc_list(prog_var, mer_inst)::in, - module_info::in, term__context::in, hlds_goal::out) is det. + module_info::in, term.context::in, hlds_goal::out) is det. trail_generate_call(PredName, Detism, Args, Features, InstMap, ModuleInfo, Context, CallGoal) :- mercury_private_builtin_module(BuiltinModule), - goal_util__generate_simple_call(BuiltinModule, PredName, predicate, + goal_util.generate_simple_call(BuiltinModule, PredName, predicate, only_mode, Detism, Args, Features, InstMap, ModuleInfo, Context, CallGoal). diff --git a/compiler/add_type.m b/compiler/add_type.m index 2823ec25d..22cd675e3 100644 --- a/compiler/add_type.m +++ b/compiler/add_type.m @@ -8,7 +8,7 @@ % % This submodule of make_hlds handles the declarations of new types. -:- module hlds__make_hlds__add_type. +:- module hlds.make_hlds.add_type. :- interface. :- import_module hlds.hlds_data. @@ -76,8 +76,8 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, item_status(Status0, NeedQual), !ModuleInfo, !IO) :- - globals__io_get_globals(Globals, !IO), - list__length(Args, Arity), + globals.io_get_globals(Globals, !IO), + list.length(Args, Arity), TypeCtor = Name - Arity, convert_type_defn(TypeDefn, TypeCtor, Globals, Body0), module_info_get_type_table(!.ModuleInfo, Types0), @@ -86,7 +86,7 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, Body0 = abstract_type(_) ; Body0 = du_type(_, _, _, _, _, _), - string__suffix(term__context_file(Context), ".int2") + string.suffix(term.context_file(Context), ".int2") % If the type definition comes from a .int2 file then % we need to treat it as abstract. The constructors % may only be used by the mode system for comparing @@ -100,11 +100,11 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, ( % the type is exported if *any* occurrence is exported, % even a previous abstract occurrence - map__search(Types0, TypeCtor, OldDefn0) + map.search(Types0, TypeCtor, OldDefn0) -> - hlds_data__get_type_defn_status(OldDefn0, OldStatus), + hlds_data.get_type_defn_status(OldDefn0, OldStatus), combine_status(Status1, OldStatus, Status), - hlds_data__get_type_defn_body(OldDefn0, OldBody0), + hlds_data.get_type_defn_body(OldDefn0, OldBody0), combine_is_solver_type(OldBody0, OldBody, Body0, Body), ( is_solver_type_is_inconsistent(OldBody, Body) -> % The existing definition has an is_solver_type @@ -116,11 +116,10 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, words("error: all definitions of a type must"), words("have consistent `solver'"), words("annotations")], - error_util__write_error_pieces(Context, 0, Pieces0, - !IO), + write_error_pieces(Context, 0, Pieces0, !IO), MaybeOldDefn = no ; - hlds_data__set_type_defn_body(OldBody, OldDefn0, OldDefn), + hlds_data.set_type_defn_body(OldBody, OldDefn0, OldDefn), MaybeOldDefn = yes(OldDefn) ) ; @@ -131,53 +130,53 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, % XXX kind inference: % We set the kinds to `star'. This will be different when we have a % kind system. - map__init(KindMap), - hlds_data__set_type_defn(TVarSet, Args, KindMap, Body, Status, no, + map.init(KindMap), + hlds_data.set_type_defn(TVarSet, Args, KindMap, Body, Status, no, NeedQual, Context, T), ( MaybeOldDefn = no, Body = foreign_type(_) -> - TypeStr = error_util__describe_sym_name_and_arity(Name / Arity), + TypeStr = describe_sym_name_and_arity(Name / Arity), ErrorPieces = [ words("Error: type "), fixed(TypeStr), words("defined as foreign_type without being declared.") ], - error_util__write_error_pieces(Context, 0, ErrorPieces, !IO), + write_error_pieces(Context, 0, ErrorPieces, !IO), module_info_incr_errors(!ModuleInfo) ; MaybeOldDefn = yes(OldDefn1), Body = foreign_type(_), - hlds_data__get_type_defn_status(OldDefn1, OldStatus1), - hlds_data__get_type_defn_body(OldDefn1, OldBody1), + hlds_data.get_type_defn_status(OldDefn1, OldStatus1), + hlds_data.get_type_defn_body(OldDefn1, OldBody1), OldBody1 = abstract_type(_), status_is_exported_to_non_submodules(OldStatus1, no), status_is_exported_to_non_submodules(Status0, yes) -> - TypeStr = error_util__describe_sym_name_and_arity(Name / Arity), + TypeStr = describe_sym_name_and_arity(Name / Arity), ErrorPieces = [ words("Error: pragma foreign_type "), fixed(TypeStr), words("must have the same visibility as the type declaration.") ], - error_util__write_error_pieces(Context, 0, ErrorPieces, !IO), + write_error_pieces(Context, 0, ErrorPieces, !IO), module_info_incr_errors(!ModuleInfo) ; % if there was an existing non-abstract definition for the type MaybeOldDefn = yes(T2), - hlds_data__get_type_defn_tvarset(T2, TVarSet_2), - hlds_data__get_type_defn_tparams(T2, Params_2), - hlds_data__get_type_defn_kind_map(T2, KindMap_2), - hlds_data__get_type_defn_body(T2, Body_2), - hlds_data__get_type_defn_context(T2, OrigContext), - hlds_data__get_type_defn_status(T2, OrigStatus), - hlds_data__get_type_defn_in_exported_eqv(T2, OrigInExportedEqv), - hlds_data__get_type_defn_need_qualifier(T2, OrigNeedQual), + hlds_data.get_type_defn_tvarset(T2, TVarSet_2), + hlds_data.get_type_defn_tparams(T2, Params_2), + hlds_data.get_type_defn_kind_map(T2, KindMap_2), + hlds_data.get_type_defn_body(T2, Body_2), + hlds_data.get_type_defn_context(T2, OrigContext), + hlds_data.get_type_defn_status(T2, OrigStatus), + hlds_data.get_type_defn_in_exported_eqv(T2, OrigInExportedEqv), + hlds_data.get_type_defn_need_qualifier(T2, OrigNeedQual), Body_2 \= abstract_type(_) -> - globals__io_get_target(Target, !IO), - globals__io_lookup_bool_option(make_optimization_interface, + globals.io_get_target(Target, !IO), + globals.io_lookup_bool_option(make_optimization_interface, MakeOptInt, !IO), ( Body = foreign_type(_) -> module_info_contains_foreign_type(!ModuleInfo) @@ -192,10 +191,10 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, ( Status = OrigStatus -> true ; - hlds_data__set_type_defn(TVarSet_2, Params_2, KindMap_2, + hlds_data.set_type_defn(TVarSet_2, Params_2, KindMap_2, Body_2, Status, OrigInExportedEqv, OrigNeedQual, OrigContext, T3), - map__det_update(Types0, TypeCtor, T3, Types), + map.det_update(Types0, TypeCtor, T3, Types), module_info_set_type_table(Types, !ModuleInfo) ) ; @@ -203,9 +202,9 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, NewBody) -> ( check_foreign_type_visibility(OrigStatus, Status1) -> - hlds_data__set_type_defn(TVarSet_2, Params_2, KindMap_2, + hlds_data.set_type_defn(TVarSet_2, Params_2, KindMap_2, NewBody, Status, OrigInExportedEqv, NeedQual, Context, T3), - map__det_update(Types0, TypeCtor, T3, Types), + map.det_update(Types0, TypeCtor, T3, Types), module_info_set_type_table(Types, !ModuleInfo) ; module_info_incr_errors(!ModuleInfo), @@ -215,7 +214,7 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, words("error: all definitions of a"), words("type must have the same"), words("visibility")], - error_util__write_error_pieces(Context, 0, + write_error_pieces(Context, 0, Pieces, !IO) ) ; @@ -230,7 +229,7 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, OrigContext, _, !IO) ) ; - map__set(Types0, TypeCtor, T, Types), + map.set(Types0, TypeCtor, T, Types), module_info_set_type_table(Types, !ModuleInfo), ( % XXX we can't handle abstract exported @@ -240,7 +239,7 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, % but the callee expects no type_infos Body = eqv_type(EqvType), Status = abstract_exported, - list__member(Var, Args), + list.member(Var, Args), \+ type_contains_var(EqvType, Var) -> Pieces = [words("Sorry, not implemented:"), @@ -248,8 +247,7 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, words("with monomorphic definition,"), words("exported as abstract type.")], write_error_pieces(Context, 0, Pieces, !IO), - globals__io_lookup_bool_option(verbose_errors, - VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, write_error_pieces(Context, 0, abstract_monotype_workaround, @@ -258,7 +256,7 @@ module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context, VerboseErrors = no, globals.io_set_extra_error_info(yes, !IO) ), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; true ) @@ -328,12 +326,12 @@ check_foreign_type_visibility(OldStatus, NewDefnStatus) :- ). process_type_defn(TypeCtor, TypeDefn, !FoundError, !ModuleInfo, !IO) :- - hlds_data__get_type_defn_context(TypeDefn, Context), - hlds_data__get_type_defn_tvarset(TypeDefn, TVarSet), - hlds_data__get_type_defn_tparams(TypeDefn, Args), - hlds_data__get_type_defn_body(TypeDefn, Body), - hlds_data__get_type_defn_status(TypeDefn, Status), - hlds_data__get_type_defn_need_qualifier(TypeDefn, NeedQual), + hlds_data.get_type_defn_context(TypeDefn, Context), + hlds_data.get_type_defn_tvarset(TypeDefn, TVarSet), + hlds_data.get_type_defn_tparams(TypeDefn, Args), + hlds_data.get_type_defn_body(TypeDefn, Body), + hlds_data.get_type_defn_status(TypeDefn, Status), + hlds_data.get_type_defn_need_qualifier(TypeDefn, NeedQual), ( ConsList = Body ^ du_type_ctors, UserEqCmp = Body ^ du_type_usereq, @@ -350,14 +348,14 @@ process_type_defn(TypeCtor, TypeDefn, !FoundError, !ModuleInfo, !IO) :- module_info_set_ctor_field_table(CtorFields, M1, M) ), NewFoundError, !ModuleInfo, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), ( type_with_constructors_should_be_no_tag(Globals, TypeCtor, ReservedTag, ConsList, UserEqCmp, Name, CtorArgType, _) -> NoTagType = no_tag_type(Args, Name, CtorArgType), module_info_get_no_tag_types(!.ModuleInfo, NoTagTypes0), - map__set(NoTagTypes0, TypeCtor, NoTagType, NoTagTypes), + map.set(NoTagTypes0, TypeCtor, NoTagType, NoTagTypes), module_info_set_no_tag_types(NoTagTypes, !ModuleInfo) ; true @@ -392,7 +390,7 @@ process_type_defn(TypeCtor, TypeDefn, !FoundError, !ModuleInfo, !IO) :- % XXX kind inference: % We set the kinds to `star'. This will be different when we have % a kind system. - prog_type.var_list_to_type_list(map__init, Args, ArgTypes), + prog_type.var_list_to_type_list(map.init, Args, ArgTypes), construct_type(TypeCtor, ArgTypes, Type), add_special_preds(TVarSet, Type, TypeCtor, Body, Context, Status, !ModuleInfo) @@ -411,7 +409,7 @@ check_foreign_type(TypeCtor, ForeignTypeBody, Context, FoundError, !ModuleInfo, TypeCtor = Name - Arity, module_info_get_globals(!.ModuleInfo, Globals), generating_code(GeneratingCode, !IO), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( have_foreign_type_for_backend(Target, ForeignTypeBody, yes) -> FoundError = no ; GeneratingCode = yes -> @@ -437,13 +435,13 @@ check_foreign_type(TypeCtor, ForeignTypeBody, Context, FoundError, !ModuleInfo, ; Target = java, LangStr = "Java" ; Target = asm, LangStr = "C" ), - TypeStr = error_util__describe_sym_name_and_arity(Name/Arity), + TypeStr = describe_sym_name_and_arity(Name/Arity), ErrorPieces = [ words("Error: no"), words(LangStr), words("`pragma foreign_type' declaration for"), fixed(TypeStr) | VerboseErrorPieces ], - error_util__write_error_pieces(Context, 0, ErrorPieces, !IO), + write_error_pieces(Context, 0, ErrorPieces, !IO), FoundError = yes, module_info_incr_errors(!ModuleInfo) ; @@ -455,7 +453,7 @@ check_foreign_type(TypeCtor, ForeignTypeBody, Context, FoundError, !ModuleInfo, % :- pred generating_code(bool::out, io::di, io::uo) is det. -generating_code(bool__not(NotGeneratingCode), !IO) :- +generating_code(bool.not(NotGeneratingCode), !IO) :- io_lookup_bool_option(make_short_interface, MakeShortInterface, !IO), io_lookup_bool_option(make_interface, MakeInterface, !IO), io_lookup_bool_option(make_private_interface, MakePrivateInterface, !IO), @@ -469,7 +467,7 @@ generating_code(bool__not(NotGeneratingCode), !IO) :- io_lookup_bool_option(typecheck_only, TypeCheckOnly, !IO), io_lookup_bool_option(errorcheck_only, ErrorCheckOnly, !IO), io_lookup_bool_option(output_grade_string, OutputGradeString, !IO), - bool__or_list([MakeShortInterface, MakeInterface, + bool.or_list([MakeShortInterface, MakeInterface, MakePrivateInterface, MakeTransOptInterface, GenSrcFileMapping, GenDepends, GenDependFile, ConvertToMercury, TypeCheckOnly, ErrorCheckOnly, OutputGradeString], @@ -665,13 +663,13 @@ ctors_add([Ctor | Rest], TypeCtor, TVarSet, NeedQual, PQInfo, Context, % Also check that there is at most one definition of a given % cons_id in each type. % - ( map__search(!.Ctors, QualifiedConsId, QualifiedConsDefns0) -> + ( map.search(!.Ctors, QualifiedConsId, QualifiedConsDefns0) -> QualifiedConsDefns1 = QualifiedConsDefns0 ; QualifiedConsDefns1 = [] ), ( - list__member(OtherConsDefn, QualifiedConsDefns1), + list.member(OtherConsDefn, QualifiedConsDefns1), OtherConsDefn = hlds_cons_defn(_, _, _, TypeCtor, _) -> % XXX we should record each error using module_info_incr_errors @@ -685,29 +683,29 @@ ctors_add([Ctor | Rest], TypeCtor, TVarSet, NeedQual, PQInfo, Context, words("multiply defined.") ], write_error_pieces(Context, 0, ErrMsg, !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), QualifiedConsDefns = QualifiedConsDefns1 ; QualifiedConsDefns = [ConsDefn | QualifiedConsDefns1] ), - svmap__set(QualifiedConsId, QualifiedConsDefns, !Ctors), + svmap.set(QualifiedConsId, QualifiedConsDefns, !Ctors), ( QualifiedConsId = cons(qualified(Module, ConsName), Arity) -> % Add unqualified version of the cons_id to the % cons_table, if appropriate. ( NeedQual = may_be_unqualified -> UnqualifiedConsId = cons(unqualified(ConsName), Arity), - multi_map__set(!.Ctors, UnqualifiedConsId, ConsDefn, !:Ctors) + multi_map.set(!.Ctors, UnqualifiedConsId, ConsDefn, !:Ctors) ; true ), % Add partially qualified versions of the cons_id get_partial_qualifiers(Module, PQInfo, PartialQuals), - list__map_foldl(add_ctor(ConsName, Arity, ConsDefn), + list.map_foldl(add_ctor(ConsName, Arity, ConsDefn), PartialQuals, _PartiallyQualifiedConsIds, !Ctors), - assoc_list__keys(Args, FieldNames), + assoc_list.keys(Args, FieldNames), FirstField = 1, add_ctor_field_names(FieldNames, NeedQual, PartialQuals, TypeCtor, @@ -724,7 +722,7 @@ ctors_add([Ctor | Rest], TypeCtor, TVarSet, NeedQual, PQInfo, Context, add_ctor(ConsName, Arity, ConsDefn, ModuleQual, ConsId, CtorsIn, CtorsOut) :- ConsId = cons(qualified(ModuleQual, ConsName), Arity), - multi_map__set(CtorsIn, ConsId, ConsDefn, CtorsOut). + multi_map.set(CtorsIn, ConsId, ConsDefn, CtorsOut). :- pred add_ctor_field_names(list(maybe(ctor_field_name))::in, need_qualifier::in, list(module_name)::in, type_ctor::in, cons_id::in, @@ -766,7 +764,7 @@ add_ctor_field_name(FieldName, FieldDefn, NeedQual, PartialQuals, % user-defined override functions for the builtin field % access functions must be unique within a module. % - map__search(!.FieldNameTable, FieldName, ConflictingDefns) + map.search(!.FieldNameTable, FieldName, ConflictingDefns) -> ( ConflictingDefns = [ConflictingDefn] -> ConflictingDefn = hlds_ctor_field_defn(OrigContext, _, _, _, _) @@ -778,36 +776,29 @@ add_ctor_field_name(FieldName, FieldDefn, NeedQual, PartialQuals, % XXX we should record each error % using module_info_incr_errors FieldDefn = hlds_ctor_field_defn(Context, _, _, _, _), - mdbcomp__prim_data__sym_name_to_string(FieldName, FieldString), - ErrorPieces = [ - words("Error: field"), - fixed(string__append_list(["`", FieldString, "'"])), - words("multiply defined.") - ], - error_util__write_error_pieces(Context, 0, ErrorPieces, !IO), + sym_name_to_string(FieldName, FieldString), + ErrorPieces = [words("Error: field"), quote(FieldString), + words("multiply defined.")], + write_error_pieces(Context, 0, ErrorPieces, !IO), - % This type of error doesn't fit well with - % how error_util does things -- error_util.m - % wants to write everything with a single context. - prog_out__write_context(OrigContext, !IO), - io__write_string(" Here is the previous definition of field `", !IO), - io__write_string(FieldString, !IO), - io__write_string("'.\n", !IO), - io__set_exit_status(1, !IO) + PrevPieces = [words("Here is the previous definition of field"), + quote(FieldString), suffix(".")], + write_error_pieces_not_first_line(OrigContext, 0, PrevPieces, !IO), + io.set_exit_status(1, !IO) ; unqualify_name(FieldName, UnqualFieldName), % Add an unqualified version of the field name to the % table, if appropriate. ( NeedQual = may_be_unqualified -> - multi_map__set(!.FieldNameTable, unqualified(UnqualFieldName), + multi_map.set(!.FieldNameTable, unqualified(UnqualFieldName), FieldDefn, !:FieldNameTable) ; true ), % Add partially qualified versions of the cons_id - list__foldl(do_add_ctor_field(UnqualFieldName, FieldDefn), + list.foldl(do_add_ctor_field(UnqualFieldName, FieldDefn), [FieldModule | PartialQuals], !FieldNameTable) ). @@ -815,7 +806,7 @@ add_ctor_field_name(FieldName, FieldDefn, NeedQual, PartialQuals, module_name::in, ctor_field_table::in, ctor_field_table::out) is det. do_add_ctor_field(FieldName, FieldNameDefn, ModuleName, !FieldNameTable) :- - multi_map__set(!.FieldNameTable, qualified(ModuleName, FieldName), + multi_map.set(!.FieldNameTable, qualified(ModuleName, FieldName), FieldNameDefn, !:FieldNameTable). %----------------------------------------------------------------------------% diff --git a/compiler/arg_info.m b/compiler/arg_info.m index 24664885d..7f0d3e7e3 100644 --- a/compiler/arg_info.m +++ b/compiler/arg_info.m @@ -23,7 +23,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__arg_info. +:- module hlds.arg_info. :- interface. :- import_module hlds.code_model. @@ -128,7 +128,7 @@ generate_arg_info(ModuleInfo0, ModuleInfo) :- module_info_preds(ModuleInfo0, Preds), - map__keys(Preds, PredIds), + map.keys(Preds, PredIds), generate_pred_arg_info(PredIds, ModuleInfo0, ModuleInfo). :- pred generate_pred_arg_info(list(pred_id)::in, @@ -137,7 +137,7 @@ generate_arg_info(ModuleInfo0, ModuleInfo) :- generate_pred_arg_info([], !ModuleInfo). generate_pred_arg_info([PredId | PredIds], !ModuleInfo) :- module_info_preds(!.ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), generate_proc_list_arg_info(PredId, pred_info_procids(PredInfo), !ModuleInfo), generate_pred_arg_info(PredIds, !ModuleInfo). @@ -148,16 +148,16 @@ generate_pred_arg_info([PredId | PredIds], !ModuleInfo) :- generate_proc_list_arg_info(_PredId, [], !ModuleInfo). generate_proc_list_arg_info(PredId, [ProcId | ProcIds], !ModuleInfo) :- module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), pred_info_arg_types(PredInfo0, ArgTypes), - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), generate_proc_arg_info(ArgTypes, !.ModuleInfo, ProcInfo0, ProcInfo), - map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable), + map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo), generate_proc_list_arg_info(PredId, ProcIds, !ModuleInfo). @@ -261,7 +261,7 @@ unify_arg_info(model_non, _) :- partition_args(Args, Ins, Outs) :- partition_args(Args, Ins, Outs0, Unuseds), - list__append(Outs0, Unuseds, Outs). + list.append(Outs0, Unuseds, Outs). partition_args([], [], [], []). partition_args([Var - ArgInfo | Rest], !:Ins, !:Outs, !:Unuseds) :- @@ -297,14 +297,14 @@ partition_proc_args(ProcInfo, ModuleInfo, Inputs, Outputs, Unuseds) :- proc_info_headvars(ProcInfo, Vars), proc_info_argmodes(ProcInfo, Modes), proc_info_vartypes(ProcInfo, VarTypes), - map__apply_to_list(Vars, VarTypes, Types), + map.apply_to_list(Vars, VarTypes, Types), do_partition_proc_args(ModuleInfo, Vars, Types, Modes, Inputs, Outputs, Unuseds). partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, Vars, Inputs, Outputs, Unuseds) :- proc_info_argmodes(ProcInfo, Modes), - map__apply_to_list(Vars, VarTypes, Types), + map.apply_to_list(Vars, VarTypes, Types), do_partition_proc_args(ModuleInfo, Vars, Types, Modes, Inputs, Outputs, Unuseds). @@ -321,8 +321,8 @@ do_partition_proc_args(ModuleInfo, Vars, Types, Modes, !:Inputs, !:Outputs, !:Unuseds) :- ( partition_proc_args_2(Vars, Types, Modes, ModuleInfo, - set__init, !:Inputs, set__init, !:Outputs, - set__init, !:Unuseds) + set.init, !:Inputs, set.init, !:Outputs, + set.init, !:Unuseds) -> true ; @@ -342,13 +342,13 @@ partition_proc_args_2([Var | Vars], [Type | Types], [Mode | Modes], mode_to_arg_mode(ModuleInfo, Mode, Type, ArgMode), ( ArgMode = top_in, - svset__insert(Var, !Inputs) + svset.insert(Var, !Inputs) ; ArgMode = top_out, - svset__insert(Var, !Outputs) + svset.insert(Var, !Outputs) ; ArgMode = top_unused, - svset__insert(Var, !Unuseds) + svset.insert(Var, !Unuseds) ), partition_proc_args_2(Vars, Types, Modes, ModuleInfo, !Inputs, !Outputs, !Unuseds). diff --git a/compiler/atsort.m b/compiler/atsort.m index 57b21fd13..670da4654 100644 --- a/compiler/atsort.m +++ b/compiler/atsort.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-1995, 1997, 2004-2005 The University of Melbourne. +% Copyright (C) 1994-1995, 1997, 2004-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module libs__atsort. +:- module libs.atsort. :- interface. :- import_module list. @@ -34,13 +34,13 @@ :- pred atsort(relmap(T)::in, relmap(T)::in, relmap(T)::in, relmap(T)::in, list(T)::in, list(list(T))::out) is det. - % atsort__closure(Nodes, Map, Reachable): + % atsort_closure(Nodes, Map, Reachable): % % Set Reachable to the set of nodes reachable from Nodes via Map. % Reachable is in no particular order, and won't include members of % Nodes unless they are reachable from other members. % -:- pred atsort__closure(list(T)::in, relmap(T)::in, list(T)::out) is det. +:- pred atsort_closure(list(T)::in, relmap(T)::in, list(T)::out) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -62,42 +62,42 @@ % :- mode test1(out, out) is det. % % test1(S, P) :- -% map__init(S0), -% map__set(S0, 1, [2, 3], S1), -% map__set(S1, 2, [], S2), -% map__set(S2, 3, [4, 5], S3), -% map__set(S3, 4, [], S4), -% map__set(S4, 5, [3], S), -% map__init(P0), -% map__set(P0, 1, [], P1), -% map__set(P1, 2, [1], P2), -% map__set(P2, 3, [1, 5], P3), -% map__set(P3, 4, [3], P4), -% map__set(P4, 5, [3], P). +% map.init(S0), +% map.set(S0, 1, [2, 3], S1), +% map.set(S1, 2, [], S2), +% map.set(S2, 3, [4, 5], S3), +% map.set(S3, 4, [], S4), +% map.set(S4, 5, [3], S), +% map.init(P0), +% map.set(P0, 1, [], P1), +% map.set(P1, 2, [1], P2), +% map.set(P2, 3, [1, 5], P3), +% map.set(P3, 4, [3], P4), +% map.set(P4, 5, [3], P). atsort(Succmap, Predmap, MustSuccmap, MustPredmap, PrefOrder, Sortlist) :- - map__keys(Succmap, Snodelist), - map__keys(Predmap, Pnodelist), + map.keys(Succmap, Snodelist), + map.keys(Predmap, Pnodelist), ( Snodelist = Pnodelist -> Nodelist = Snodelist ; unexpected(this_file, "succ and pred nodelists differ in atsort") ), - atsort__main(Nodelist, Succmap, Predmap, MustSuccmap, MustPredmap, + atsort_main(Nodelist, Succmap, Predmap, MustSuccmap, MustPredmap, PrefOrder, Sortlist). -:- pred atsort__main(list(T)::in, relmap(T)::in, relmap(T)::in, +:- pred atsort_main(list(T)::in, relmap(T)::in, relmap(T)::in, relmap(T)::in, relmap(T)::in, list(T)::in, list(list(T))::out) is det. -atsort__main(Nodes0, !.Succmap, !.Predmap, MustSuccmap, MustPredmap, PrefOrder, +atsort_main(Nodes0, !.Succmap, !.Predmap, MustSuccmap, MustPredmap, PrefOrder, Sorted) :- - atsort__repeat_source_sink(Nodes0, !Succmap, !Predmap, + atsort_repeat_source_sink(Nodes0, !Succmap, !Predmap, [], Source1, Mid1, [], Sink1), ( Mid1 = [] -> - list__reverse(Source1, Source1rev), - list__append(Source1rev, Sink1, Sorted) + list.reverse(Source1, Source1rev), + list.append(Source1rev, Sink1, Sorted) ; - atsort__choose(Mid1, !Succmap, !Predmap, MustSuccmap, MustPredmap, + atsort_choose(Mid1, !Succmap, !Predmap, MustSuccmap, MustPredmap, PrefOrder, Chosen, Mid2), % write('Chosen: '), % write(Chosen), @@ -105,40 +105,40 @@ atsort__main(Nodes0, !.Succmap, !.Predmap, MustSuccmap, MustPredmap, PrefOrder, % write('Not chosen: '), % write(Mid2), % nl, - atsort__main(Mid2, !.Succmap, !.Predmap, MustSuccmap, MustPredmap, + atsort_main(Mid2, !.Succmap, !.Predmap, MustSuccmap, MustPredmap, PrefOrder, MidSorted), - list__reverse(Source1, Source1rev), - list__condense([Source1rev, [[Chosen]], MidSorted, Sink1], Sorted) + list.reverse(Source1, Source1rev), + list.condense([Source1rev, [[Chosen]], MidSorted, Sink1], Sorted) ). %-----------------------------------------------------------------------------% -:- pred atsort__choose(list(T)::in, +:- pred atsort_choose(list(T)::in, relmap(T)::in, relmap(T)::out, relmap(T)::in, relmap(T)::out, relmap(T)::in, relmap(T)::in, list(T)::in, T::out, list(T)::out) is det. -atsort__choose(Nodes, !Succmap, !Predmap, _MustSuccmap, MustPredmap, PrefOrder, +atsort_choose(Nodes, !Succmap, !Predmap, _MustSuccmap, MustPredmap, PrefOrder, Chosen, NotChosen) :- - atsort__can_choose(Nodes, Nodes, MustPredmap, [], CanChoose), - atsort__choose_pref(PrefOrder, CanChoose, Chosen), - list__delete_all(Nodes, Chosen, NotChosen), + atsort_can_choose(Nodes, Nodes, MustPredmap, [], CanChoose), + atsort_choose_pref(PrefOrder, CanChoose, Chosen), + list.delete_all(Nodes, Chosen, NotChosen), Succmap0 = !.Succmap, Predmap0 = !.Predmap, - atsort__map_delete_all_source_links([Chosen], Succmap0, !Predmap), - atsort__map_delete_all_sink_links([Chosen], Predmap0, !Succmap), - atsort__map_delete_all_nodes([Chosen], !Succmap), - atsort__map_delete_all_nodes([Chosen], !Predmap). + atsort_map_delete_all_source_links([Chosen], Succmap0, !Predmap), + atsort_map_delete_all_sink_links([Chosen], Predmap0, !Succmap), + atsort_map_delete_all_nodes([Chosen], !Succmap), + atsort_map_delete_all_nodes([Chosen], !Predmap). % See whether this node can be chosen ahead of the given list of nodes. % Do not give preference to nodes that occur in MustPredmap. % -:- pred atsort__can_choose(list(T)::in, list(T)::in, relmap(T)::in, +:- pred atsort_can_choose(list(T)::in, list(T)::in, relmap(T)::in, list(T)::in, list(T)::out) is det. -atsort__can_choose([], _All, _MustPredmap, !CanChoose). -atsort__can_choose([Node | Nodes], All, MustPredmap, !CanChoose) :- - ( map__search(MustPredmap, Node, MustPrednodes) -> - ( atsort__must_avoid(All, MustPrednodes) -> +atsort_can_choose([], _All, _MustPredmap, !CanChoose). +atsort_can_choose([Node | Nodes], All, MustPredmap, !CanChoose) :- + ( map.search(MustPredmap, Node, MustPrednodes) -> + ( atsort_must_avoid(All, MustPrednodes) -> !:CanChoose = [Node | !.CanChoose] ; true @@ -146,38 +146,38 @@ atsort__can_choose([Node | Nodes], All, MustPredmap, !CanChoose) :- ; !:CanChoose = [Node | !.CanChoose] ), - atsort__can_choose(Nodes, All, MustPredmap, !CanChoose). + atsort_can_choose(Nodes, All, MustPredmap, !CanChoose). % None of the members of the first list occur in the second. % -:- pred atsort__must_avoid(list(T)::in, list(T)::in) is semidet. +:- pred atsort_must_avoid(list(T)::in, list(T)::in) is semidet. -atsort__must_avoid([], _). -atsort__must_avoid([Head | Tail], Avoidlist) :- - \+ list__member(Head, Avoidlist), - atsort__must_avoid(Tail, Avoidlist). +atsort_must_avoid([], _). +atsort_must_avoid([Head | Tail], Avoidlist) :- + \+ list.member(Head, Avoidlist), + atsort_must_avoid(Tail, Avoidlist). -:- pred atsort__choose_pref(list(T)::in, list(T)::in, T::out) is det. +:- pred atsort_choose_pref(list(T)::in, list(T)::in, T::out) is det. -atsort__choose_pref([], _CanChoose, _Chosen) :- +atsort_choose_pref([], _CanChoose, _Chosen) :- unexpected(this_file, "cannot choose any node in atsort"). -atsort__choose_pref([Pref | Prefs], CanChoose, Chosen) :- - ( list__member(Pref, CanChoose) -> +atsort_choose_pref([Pref | Prefs], CanChoose, Chosen) :- + ( list.member(Pref, CanChoose) -> Chosen = Pref ; - atsort__choose_pref(Prefs, CanChoose, Chosen) + atsort_choose_pref(Prefs, CanChoose, Chosen) ). %-----------------------------------------------------------------------------% -:- pred atsort__repeat_source_sink(list(T)::in, +:- pred atsort_repeat_source_sink(list(T)::in, relmap(T)::in, relmap(T)::out, relmap(T)::in, relmap(T)::out, list(list(T))::in, list(list(T))::out, list(T)::out, list(list(T))::in, list(list(T))::out) is det. -atsort__repeat_source_sink(Nodes0, !Succmap, !Predmap, Source0, Source, Mid, +atsort_repeat_source_sink(Nodes0, !Succmap, !Predmap, Source0, Source, Mid, Sink0, Sink) :- - atsort__source_sink(Nodes0, !.Succmap, !.Predmap, + atsort_source_sink(Nodes0, !.Succmap, !.Predmap, [], Source1, [], Mid1, [], Sink1), ( Source1 = [], @@ -187,16 +187,16 @@ atsort__repeat_source_sink(Nodes0, !Succmap, !Predmap, Source0, Source, Mid, Sink = Sink0, Mid = Mid1 ; - list__delete_elems(Nodes0, Source1, Nodes1), - list__delete_elems(Nodes1, Sink1, Nodes2), + list.delete_elems(Nodes0, Source1, Nodes1), + list.delete_elems(Nodes1, Sink1, Nodes2), Succmap0 = !.Succmap, Predmap0 = !.Predmap, - atsort__map_delete_all_source_links(Source1, Succmap0, !Predmap), - atsort__map_delete_all_sink_links(Sink1, Predmap0, !Succmap), - atsort__map_delete_all_nodes(Source1, !Succmap), - atsort__map_delete_all_nodes(Source1, !Predmap), - atsort__map_delete_all_nodes(Sink1, !Succmap), - atsort__map_delete_all_nodes(Sink1, !Predmap), + atsort_map_delete_all_source_links(Source1, Succmap0, !Predmap), + atsort_map_delete_all_sink_links(Sink1, Predmap0, !Succmap), + atsort_map_delete_all_nodes(Source1, !Succmap), + atsort_map_delete_all_nodes(Source1, !Predmap), + atsort_map_delete_all_nodes(Sink1, !Succmap), + atsort_map_delete_all_nodes(Sink1, !Predmap), ( Source1 = [], Source2 = Source0 @@ -211,78 +211,78 @@ atsort__repeat_source_sink(Nodes0, !Succmap, !Predmap, Source0, Source, Mid, Sink1 = [_ | _], Sink2 = [Sink1 | Sink0] ), - atsort__repeat_source_sink(Nodes2, !Succmap, !Predmap, + atsort_repeat_source_sink(Nodes2, !Succmap, !Predmap, Source2, Source, Mid, Sink2, Sink) ). %-----------------------------------------------------------------------------% -:- pred atsort__source_sink(list(T)::in, relmap(T)::in, relmap(T)::in, +:- pred atsort_source_sink(list(T)::in, relmap(T)::in, relmap(T)::in, list(T)::in, list(T)::out, list(T)::in, list(T)::out, list(T)::in, list(T)::out) is det. -atsort__source_sink([], _, _, !Source, !Mid, !Sink). -atsort__source_sink([Node | Nodes], Succmap, Predmap, !Source, !Mid, !Sink) :- +atsort_source_sink([], _, _, !Source, !Mid, !Sink). +atsort_source_sink([Node | Nodes], Succmap, Predmap, !Source, !Mid, !Sink) :- ( - map__search(Succmap, Node, Succnodes), + map.search(Succmap, Node, Succnodes), Succnodes = [] -> !:Sink = [Node | !.Sink] ; - map__search(Predmap, Node, Prednodes), + map.search(Predmap, Node, Prednodes), Prednodes = [] -> !:Source = [Node | !.Source] ; !:Mid = [Node | !.Mid] ), - atsort__source_sink(Nodes, Succmap, Predmap, !Source, !Mid, !Sink). + atsort_source_sink(Nodes, Succmap, Predmap, !Source, !Mid, !Sink). %-----------------------------------------------------------------------------% -:- pred atsort__map_delete_all_source_links(list(T)::in, +:- pred atsort_map_delete_all_source_links(list(T)::in, relmap(T)::in, relmap(T)::in, relmap(T)::out) is det. -atsort__map_delete_all_source_links([], _Succmap, !Predmap). -atsort__map_delete_all_source_links([Source | Sources], Succmap, !Predmap) :- - map__lookup(Succmap, Source, Succnodes), - atsort__map_delete_this_element(Succnodes, Source, !Predmap), - atsort__map_delete_all_source_links(Sources, Succmap, !Predmap). +atsort_map_delete_all_source_links([], _Succmap, !Predmap). +atsort_map_delete_all_source_links([Source | Sources], Succmap, !Predmap) :- + map.lookup(Succmap, Source, Succnodes), + atsort_map_delete_this_element(Succnodes, Source, !Predmap), + atsort_map_delete_all_source_links(Sources, Succmap, !Predmap). -:- pred atsort__map_delete_all_sink_links(list(T)::in, +:- pred atsort_map_delete_all_sink_links(list(T)::in, relmap(T)::in, relmap(T)::in, relmap(T)::out) is det. -atsort__map_delete_all_sink_links([], _Predmap, !Succmap). -atsort__map_delete_all_sink_links([Sink | Sinks], Predmap, !Succmap) :- - map__lookup(Predmap, Sink, Prednodes), - atsort__map_delete_this_element(Prednodes, Sink, !Succmap), - atsort__map_delete_all_sink_links(Sinks, Predmap, !Succmap). +atsort_map_delete_all_sink_links([], _Predmap, !Succmap). +atsort_map_delete_all_sink_links([Sink | Sinks], Predmap, !Succmap) :- + map.lookup(Predmap, Sink, Prednodes), + atsort_map_delete_this_element(Prednodes, Sink, !Succmap), + atsort_map_delete_all_sink_links(Sinks, Predmap, !Succmap). -:- pred atsort__map_delete_this_element(list(T)::in, T::in, +:- pred atsort_map_delete_this_element(list(T)::in, T::in, relmap(T)::in, relmap(T)::out) is det. -atsort__map_delete_this_element([], _, !Map). -atsort__map_delete_this_element([Node | Nodes], Elt, !Map) :- - ( map__search(!.Map, Node, List0) -> - list__delete_all(List0, Elt, List1), - map__det_update(!.Map, Node, List1, !:Map) +atsort_map_delete_this_element([], _, !Map). +atsort_map_delete_this_element([Node | Nodes], Elt, !Map) :- + ( map.search(!.Map, Node, List0) -> + list.delete_all(List0, Elt, List1), + map.det_update(!.Map, Node, List1, !:Map) ; true ), - atsort__map_delete_this_element(Nodes, Elt, !Map). + atsort_map_delete_this_element(Nodes, Elt, !Map). -:- pred atsort__map_delete_all_nodes(list(T)::in, +:- pred atsort_map_delete_all_nodes(list(T)::in, relmap(T)::in, relmap(T)::out) is det. -atsort__map_delete_all_nodes([], !Map). -atsort__map_delete_all_nodes([Node | Nodes], !Map) :- - map__delete(!.Map, Node, !:Map), - atsort__map_delete_all_nodes(Nodes, !Map). +atsort_map_delete_all_nodes([], !Map). +atsort_map_delete_all_nodes([Node | Nodes], !Map) :- + map.delete(!.Map, Node, !:Map), + atsort_map_delete_all_nodes(Nodes, !Map). %-----------------------------------------------------------------------------% -atsort__closure(Nodes, Map, Reachable) :- - atsort__closure_2(Nodes, Map, [], Reachable). +atsort_closure(Nodes, Map, Reachable) :- + atsort_closure_2(Nodes, Map, [], Reachable). % The first argument is a list of nodes to look at. If they have % not been seen before, we insert them into the reachable list, @@ -290,30 +290,30 @@ atsort__closure(Nodes, Map, Reachable) :- % % XXX Should think about making Reachable be a bintree set. % -:- pred atsort__closure_2(list(T)::in, relmap(T)::in, +:- pred atsort_closure_2(list(T)::in, relmap(T)::in, list(T)::in, list(T)::out) is det. -atsort__closure_2([], _, !Reachable). -atsort__closure_2([Node | Nodes0], Map, !Reachable) :- - ( list__member(Node, !.Reachable) -> +atsort_closure_2([], _, !Reachable). +atsort_closure_2([Node | Nodes0], Map, !Reachable) :- + ( list.member(Node, !.Reachable) -> Nodes1 = Nodes0 ; - map__lookup(Map, Node, Neighbours), - atsort__maybe_insert(Neighbours, Nodes0, Nodes1), + map.lookup(Map, Node, Neighbours), + atsort_maybe_insert(Neighbours, Nodes0, Nodes1), !:Reachable = [Node | !.Reachable] ), - atsort__closure_2(Nodes1, Map, !Reachable). + atsort_closure_2(Nodes1, Map, !Reachable). -:- pred atsort__maybe_insert(list(T)::in, list(T)::in, list(T)::out) is det. +:- pred atsort_maybe_insert(list(T)::in, list(T)::in, list(T)::out) is det. -atsort__maybe_insert([], !List). -atsort__maybe_insert([Node | Nodes], !List) :- - ( list__member(Node, !.List) -> +atsort_maybe_insert([], !List). +atsort_maybe_insert([Node | Nodes], !List) :- + ( list.member(Node, !.List) -> !:List = !.List ; !:List = [Node | !.List] ), - atsort__maybe_insert(Nodes, !List). + atsort_maybe_insert(Nodes, !List). %-----------------------------------------------------------------------------% diff --git a/compiler/base_typeclass_info.m b/compiler/base_typeclass_info.m index e3a390650..50de125dc 100644 --- a/compiler/base_typeclass_info.m +++ b/compiler/base_typeclass_info.m @@ -1,5 +1,7 @@ %---------------------------------------------------------------------------% -% Copyright (C) 1996-2000, 2003-2005 The University of Melbourne. +% vim: ft=mercury ts=4 sw=4 et +%---------------------------------------------------------------------------% +% Copyright (C) 1996-2000, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -19,7 +21,7 @@ %---------------------------------------------------------------------------% -:- module backend_libs__base_typeclass_info. +:- module backend_libs.base_typeclass_info. :- interface. :- import_module backend_libs.rtti. @@ -29,8 +31,8 @@ %---------------------------------------------------------------------------% -:- pred base_typeclass_info__generate_rtti(module_info::in, - list(rtti_data)::out) is det. +:- pred generate_base_typeclass_info_rtti(module_info::in, + list(rtti_data)::out) is det. %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% @@ -62,103 +64,101 @@ %---------------------------------------------------------------------------% -generate_rtti(ModuleInfo, RttiDataList) :- - module_info_get_name(ModuleInfo, ModuleName), - module_info_get_instance_table(ModuleInfo, InstanceTable), - map__to_assoc_list(InstanceTable, AllInstances), - gen_infos_for_classes(AllInstances, ModuleName, ModuleInfo, - [], RttiDataList). +generate_base_typeclass_info_rtti(ModuleInfo, RttiDataList) :- + module_info_get_name(ModuleInfo, ModuleName), + module_info_get_instance_table(ModuleInfo, InstanceTable), + map.to_assoc_list(InstanceTable, AllInstances), + gen_infos_for_classes(AllInstances, ModuleName, ModuleInfo, + [], RttiDataList). :- pred gen_infos_for_classes( - assoc_list(class_id, list(hlds_instance_defn))::in, module_name::in, - module_info::in, list(rtti_data)::in, list(rtti_data)::out) is det. + assoc_list(class_id, list(hlds_instance_defn))::in, module_name::in, + module_info::in, list(rtti_data)::in, list(rtti_data)::out) is det. gen_infos_for_classes([], _ModuleName, _ModuleInfo, !RttiDataList). gen_infos_for_classes([C|Cs], ModuleName, ModuleInfo, !RttiDataList) :- - gen_infos_for_instance_list(C, ModuleName, ModuleInfo, !RttiDataList), - gen_infos_for_classes(Cs, ModuleName, ModuleInfo, !RttiDataList). + gen_infos_for_instance_list(C, ModuleName, ModuleInfo, !RttiDataList), + gen_infos_for_classes(Cs, ModuleName, ModuleInfo, !RttiDataList). - % XXX make it use an accumulator + % XXX make it use an accumulator :- pred gen_infos_for_instance_list( - pair(class_id, list(hlds_instance_defn))::in, module_name::in, - module_info::in, list(rtti_data)::in, list(rtti_data)::out) is det. + pair(class_id, list(hlds_instance_defn))::in, module_name::in, + module_info::in, list(rtti_data)::in, list(rtti_data)::out) is det. gen_infos_for_instance_list(_ - [], _, _, !RttiDataList). gen_infos_for_instance_list(ClassId - [InstanceDefn | Is], ModuleName, - ModuleInfo, !RttiDataList) :- - gen_infos_for_instance_list(ClassId - Is, ModuleName, ModuleInfo, - !RttiDataList), - InstanceDefn = hlds_instance_defn(InstanceModule, ImportStatus, - _TermContext, InstanceConstraints, InstanceTypes, Body, - PredProcIds, _Varset, _SuperClassProofs), - ( - Body = concrete(_), - % Only make the base_typeclass_info if the instance - % declaration originally came from _this_ module. - status_defined_in_this_module(ImportStatus, yes) - -> - make_instance_string(InstanceTypes, InstanceString), - gen_body(PredProcIds, InstanceTypes, InstanceConstraints, - ModuleInfo, ClassId, BaseTypeClassInfo), - TCName = generate_class_name(ClassId), - RttiData = base_typeclass_info(TCName, InstanceModule, - InstanceString, BaseTypeClassInfo), - !:RttiDataList = [RttiData | !.RttiDataList] - ; - % The instance decl is from another module, - % or is abstract, so we don't bother including it. - true - ). + ModuleInfo, !RttiDataList) :- + gen_infos_for_instance_list(ClassId - Is, ModuleName, ModuleInfo, + !RttiDataList), + InstanceDefn = hlds_instance_defn(InstanceModule, ImportStatus, + _TermContext, InstanceConstraints, InstanceTypes, Body, + PredProcIds, _Varset, _SuperClassProofs), + ( + Body = concrete(_), + % Only make the base_typeclass_info if the instance + % declaration originally came from _this_ module. + status_defined_in_this_module(ImportStatus, yes) + -> + make_instance_string(InstanceTypes, InstanceString), + gen_body(PredProcIds, InstanceTypes, InstanceConstraints, + ModuleInfo, ClassId, BaseTypeClassInfo), + TCName = generate_class_name(ClassId), + RttiData = base_typeclass_info(TCName, InstanceModule, + InstanceString, BaseTypeClassInfo), + !:RttiDataList = [RttiData | !.RttiDataList] + ; + % The instance decl is from another module, + % or is abstract, so we don't bother including it. + true + ). %----------------------------------------------------------------------------% :- pred gen_body(maybe(list(hlds_class_proc))::in, list(mer_type)::in, - list(prog_constraint)::in, module_info::in, class_id::in, - base_typeclass_info::out) is det. + list(prog_constraint)::in, module_info::in, class_id::in, + base_typeclass_info::out) is det. gen_body(no, _, _, _, _, _) :- - unexpected(this_file, "pred_proc_ids should have " ++ - "been filled in by check_typeclass.m"). + unexpected(this_file, "pred_proc_ids should have " ++ + "been filled in by check_typeclass.m"). gen_body(yes(PredProcIds0), Types, Constraints, ModuleInfo, ClassId, - BaseTypeClassInfo) :- - prog_type__vars_list(Types, TypeVars), - get_unconstrained_tvars(TypeVars, Constraints, Unconstrained), - list__length(Constraints, NumConstraints), - list__length(Unconstrained, NumUnconstrained), - NumExtra = NumConstraints + NumUnconstrained, - ExtractPredProcId = (pred(HldsPredProc::in, PredProc::out) is det :- - ( - HldsPredProc = hlds_class_proc(PredId, ProcId), - PredProc = proc(PredId, ProcId) - )), - list__map(ExtractPredProcId, PredProcIds0, PredProcIds), - construct_proc_labels(PredProcIds, ModuleInfo, - ProcLabels), - gen_superclass_count(ClassId, ModuleInfo, - SuperClassCount, ClassArity), - list__length(ProcLabels, NumMethods), - BaseTypeClassInfo = base_typeclass_info(NumExtra, NumConstraints, - SuperClassCount, ClassArity, NumMethods, ProcLabels). + BaseTypeClassInfo) :- + prog_type.vars_list(Types, TypeVars), + get_unconstrained_tvars(TypeVars, Constraints, Unconstrained), + list.length(Constraints, NumConstraints), + list.length(Unconstrained, NumUnconstrained), + NumExtra = NumConstraints + NumUnconstrained, + ExtractPredProcId = (pred(HldsPredProc::in, PredProc::out) is det :- + ( + HldsPredProc = hlds_class_proc(PredId, ProcId), + PredProc = proc(PredId, ProcId) + )), + list.map(ExtractPredProcId, PredProcIds0, PredProcIds), + construct_proc_labels(PredProcIds, ModuleInfo, ProcLabels), + gen_superclass_count(ClassId, ModuleInfo, SuperClassCount, ClassArity), + list.length(ProcLabels, NumMethods), + BaseTypeClassInfo = base_typeclass_info(NumExtra, NumConstraints, + SuperClassCount, ClassArity, NumMethods, ProcLabels). :- pred construct_proc_labels(list(pred_proc_id)::in, - module_info::in, list(rtti_proc_label)::out) is det. + module_info::in, list(rtti_proc_label)::out) is det. construct_proc_labels([], _, []). construct_proc_labels([proc(PredId, ProcId) | Procs], ModuleInfo, - [ProcLabel | ProcLabels]) :- - ProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId), - construct_proc_labels(Procs, ModuleInfo, ProcLabels). + [ProcLabel | ProcLabels]) :- + ProcLabel = rtti.make_rtti_proc_label(ModuleInfo, PredId, ProcId), + construct_proc_labels(Procs, ModuleInfo, ProcLabels). %----------------------------------------------------------------------------% :- pred gen_superclass_count(class_id::in, module_info::in, - int::out, int::out) is det. + int::out, int::out) is det. gen_superclass_count(ClassId, ModuleInfo, NumSuperClasses, ClassArity) :- - module_info_get_class_table(ModuleInfo, ClassTable), - map__lookup(ClassTable, ClassId, ClassDefn), - list__length(ClassDefn ^ class_supers, NumSuperClasses), - list__length(ClassDefn ^ class_vars, ClassArity). + module_info_get_class_table(ModuleInfo, ClassTable), + map.lookup(ClassTable, ClassId, ClassDefn), + list.length(ClassDefn ^ class_supers, NumSuperClasses), + list.length(ClassDefn ^ class_vars, ClassArity). %----------------------------------------------------------------------------% diff --git a/compiler/basic_block.m b/compiler/basic_block.m index 5edb5b427..2ce81c966 100644 --- a/compiler/basic_block.m +++ b/compiler/basic_block.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1997-2001,2003-2005 The University of Melbourne. +% Copyright (C) 1997-2001,2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__basic_block. +:- module ll_backend.basic_block. :- interface. :- import_module ll_backend.llds. @@ -110,10 +110,10 @@ create_basic_blocks(Instrs0, Comments, ProcLabel, !C, NewLabels, LabelSeq, BlockMap) :- - opt_util__get_prologue(Instrs0, LabelInstr, Comments, AfterLabelInstrs), + opt_util.get_prologue(Instrs0, LabelInstr, Comments, AfterLabelInstrs), Instrs1 = [LabelInstr | AfterLabelInstrs], - build_block_map(Instrs1, LabelSeq, ProcLabel, no, map__init, BlockMap, - set__init, NewLabels, !C). + build_block_map(Instrs1, LabelSeq, ProcLabel, no, map.init, BlockMap, + set.init, NewLabels, !C). %-----------------------------------------------------------------------------% @@ -132,9 +132,9 @@ build_block_map([OrigInstr0 | OrigInstrs0], LabelSeq, ProcLabel, FallInto, LabelInstr = OrigInstr0, RestInstrs = OrigInstrs0 ; - counter__allocate(N, !C), + counter.allocate(N, !C), Label = internal(N, ProcLabel), - svset__insert(Label, !NewLabels), + svset.insert(Label, !NewLabels), LabelInstr = label(Label) - "", RestInstrs = [OrigInstr0 | OrigInstrs0] ), @@ -142,10 +142,10 @@ build_block_map([OrigInstr0 | OrigInstrs0], LabelSeq, ProcLabel, FallInto, take_until_end_of_block(RestInstrs, BlockInstrs, Instrs1), build_block_map(Instrs1, LabelSeq1, ProcLabel, NextFallInto, !BlockMap, !NewLabels, !C), - ( list__last(BlockInstrs, LastInstr) -> + ( list.last(BlockInstrs, LastInstr) -> LastInstr = LastUinstr - _, - opt_util__possible_targets(LastUinstr, SideLabels, _SideCodeAddrs), - opt_util__can_instr_fall_through(LastUinstr, NextFallInto) + opt_util.possible_targets(LastUinstr, SideLabels, _SideCodeAddrs), + opt_util.can_instr_fall_through(LastUinstr, NextFallInto) ; SideLabels = [], NextFallInto = yes @@ -159,7 +159,7 @@ build_block_map([OrigInstr0 | OrigInstrs0], LabelSeq, ProcLabel, FallInto, ), BlockInfo = block_info(Label, LabelInstr, BlockInstrs, FallInto, SideLabels, MaybeFallThrough), - map__det_insert(!.BlockMap, Label, BlockInfo, !:BlockMap), + map.det_insert(!.BlockMap, Label, BlockInfo, !:BlockMap), LabelSeq = [Label | LabelSeq1] ). @@ -174,7 +174,7 @@ take_until_end_of_block([Instr0 | Instrs0], BlockInstrs, Rest) :- ( Uinstr0 = label(_) -> BlockInstrs = [], Rest = [Instr0 | Instrs0] - ; opt_util__can_instr_branch_away(Uinstr0, yes) -> + ; opt_util.can_instr_branch_away(Uinstr0, yes) -> BlockInstrs = [Instr0], Rest = Instrs0 ; @@ -199,10 +199,10 @@ extend_basic_blocks([], [], !BlockMap, _NewLabels). extend_basic_blocks([Label | Labels], LabelSeq, !BlockMap, NewLabels) :- ( Labels = [NextLabel | RestLabels], - set__member(NextLabel, NewLabels) + set.member(NextLabel, NewLabels) -> - map__lookup(!.BlockMap, Label, BlockInfo), - map__lookup(!.BlockMap, NextLabel, NextBlockInfo), + map.lookup(!.BlockMap, Label, BlockInfo), + map.lookup(!.BlockMap, NextLabel, NextBlockInfo), BlockInfo = block_info(BlockLabel, BlockLabelInstr, BlockInstrs, BlockFallInto, BlockSideLabels, BlockMaybeFallThrough), NextBlockInfo = block_info(NextBlockLabel, _, NextBlockInstrs, @@ -218,8 +218,8 @@ extend_basic_blocks([Label | Labels], LabelSeq, !BlockMap, NewLabels) :- NewBlockInfo = block_info(BlockLabel, BlockLabelInstr, BlockInstrs ++ NextBlockInstrs, BlockFallInto, BlockSideLabels ++ NextBlockSideLabels, NextBlockMaybeFallThrough), - svmap__det_update(Label, NewBlockInfo, !BlockMap), - svmap__delete(NextLabel, !BlockMap), + svmap.det_update(Label, NewBlockInfo, !BlockMap), + svmap.delete(NextLabel, !BlockMap), extend_basic_blocks([Label | RestLabels], LabelSeq, !BlockMap, NewLabels) ; @@ -232,9 +232,9 @@ extend_basic_blocks([Label | Labels], LabelSeq, !BlockMap, NewLabels) :- flatten_basic_blocks([], _, []). flatten_basic_blocks([Label | Labels], BlockMap, Instrs) :- flatten_basic_blocks(Labels, BlockMap, RestInstrs), - map__lookup(BlockMap, Label, BlockInfo), + map.lookup(BlockMap, Label, BlockInfo), BlockInfo = block_info(_, BlockLabelInstr, BlockInstrs, _, _, _), - list__append([BlockLabelInstr | BlockInstrs], RestInstrs, Instrs). + list.append([BlockLabelInstr | BlockInstrs], RestInstrs, Instrs). %-----------------------------------------------------------------------------% diff --git a/compiler/builtin_ops.m b/compiler/builtin_ops.m index 83f338e01..af3497e72 100644 --- a/compiler/builtin_ops.m +++ b/compiler/builtin_ops.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1999-2001, 2003-2005 The University of Melbourne. +% Copyright (C) 1999-2001, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -92,8 +92,8 @@ % for this module to depend on back-end specific stuff like MLDS types. :- type array_elem_type ---> elem_type_string % ml_string_type - ; elem_type_int % mlds__native_int_type - ; elem_type_generic. % mlds__generic_type + ; elem_type_int % mlds_native_int_type + ; elem_type_generic. % mlds_generic_type % translate_builtin: % diff --git a/compiler/bytecode.m b/compiler/bytecode.m index 4c33d85e9..bbf64251b 100644 --- a/compiler/bytecode.m +++ b/compiler/bytecode.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 1996-2005 The University of Melbourne. +% Copyright (C) 1996-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %---------------------------------------------------------------------------% -:- module bytecode_backend__bytecode. +:- module bytecode_backend.bytecode. :- interface. :- import_module backend_libs.builtin_ops. @@ -158,52 +158,52 @@ %---------------------------------------------------------------------------% -:- pred bytecode__version(int::out) is det. +:- pred bytecode.version(int::out) is det. -bytecode__version(9). +bytecode.version(9). output_bytecode_file(FileName, ByteCodes, !IO) :- - io__open_binary_output(FileName, Result, !IO), + io.open_binary_output(FileName, Result, !IO), ( Result = ok(FileStream) -> - io__set_binary_output_stream(FileStream, OutputStream, !IO), - bytecode__version(Version), + io.set_binary_output_stream(FileStream, OutputStream, !IO), + bytecode.version(Version), output_short(Version, !IO), output_bytecode_list(ByteCodes, !IO), - io__set_binary_output_stream(OutputStream, _, !IO), - io__close_binary_output(FileStream, !IO) + io.set_binary_output_stream(OutputStream, _, !IO), + io.close_binary_output(FileStream, !IO) ; - io__progname_base("byte.m", ProgName, !IO), - io__write_string("\n", !IO), - io__write_string(ProgName, !IO), - io__write_string(": can't open `", !IO), - io__write_string(FileName, !IO), - io__write_string("' for output\n", !IO), - io__set_exit_status(1, !IO) + io.progname_base("byte.m", ProgName, !IO), + io.write_string("\n", !IO), + io.write_string(ProgName, !IO), + io.write_string(": can't open `", !IO), + io.write_string(FileName, !IO), + io.write_string("' for output\n", !IO), + io.set_exit_status(1, !IO) ). debug_bytecode_file(FileName, ByteCodes, !IO) :- - io__open_output(FileName, Result, !IO), + io.open_output(FileName, Result, !IO), ( Result = ok(FileStream) -> - io__set_output_stream(FileStream, OutputStream, !IO), - bytecode__version(Version), - io__write_string("bytecode_version ", !IO), - io__write_int(Version, !IO), - io__write_string("\n", !IO), + io.set_output_stream(FileStream, OutputStream, !IO), + bytecode.version(Version), + io.write_string("bytecode_version ", !IO), + io.write_int(Version, !IO), + io.write_string("\n", !IO), debug_bytecode_list(ByteCodes, !IO), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO) + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO) ; - io__progname_base("byte.m", ProgName, !IO), - io__write_string("\n", !IO), - io__write_string(ProgName, !IO), - io__write_string(": can't open `", !IO), - io__write_string(FileName, !IO), - io__write_string("' for output\n", !IO), - io__set_exit_status(1, !IO) + io.progname_base("byte.m", ProgName, !IO), + io.write_string("\n", !IO), + io.write_string(ProgName, !IO), + io.write_string(": can't open `", !IO), + io.write_string(FileName, !IO), + io.write_string("' for output\n", !IO), + io.set_exit_status(1, !IO) ). :- pred output_bytecode_list(list(byte_code)::in, io::di, io::uo) is det. @@ -211,7 +211,7 @@ debug_bytecode_file(FileName, ByteCodes, !IO) :- output_bytecode_list([], !IO). output_bytecode_list([ByteCode | ByteCodes], !IO) :- byte_code(ByteCode, Byte), - io__write_byte(Byte, !IO), + io.write_byte(Byte, !IO), output_args(ByteCode, !IO), output_bytecode_list(ByteCodes, !IO). @@ -222,7 +222,7 @@ debug_bytecode_list([ByteCode | ByteCodes], !IO) :- byte_debug(ByteCode, Debug), debug_string(Debug, !IO), debug_args(ByteCode, !IO), - io__write_char('\n', !IO), + io.write_char('\n', !IO), debug_bytecode_list(ByteCodes, !IO). :- pred output_args(byte_code::in, io::di, io::uo) is det. @@ -240,7 +240,7 @@ output_args(enter_proc(ProcId, Detism, LabelCount, LabelId, TempCount, Vars), output_length(LabelCount, !IO), output_label_id(LabelId, !IO), output_length(TempCount, !IO), - list__length(Vars, VarCount), + list.length(Vars, VarCount), output_length(VarCount, !IO), output_var_infos(Vars, !IO). output_args(endof_proc, !IO). @@ -293,25 +293,25 @@ output_args(test(Var1, Var2, TestId), !IO) :- output_args(construct(Var, ConsId, Vars), !IO) :- output_var(Var, !IO), output_cons_id(ConsId, !IO), - list__length(Vars, Length), + list.length(Vars, Length), output_length(Length, !IO), output_vars(Vars, !IO). output_args(deconstruct(Var, ConsId, Vars), !IO) :- output_var(Var, !IO), output_cons_id(ConsId, !IO), - list__length(Vars, Length), + list.length(Vars, Length), output_length(Length, !IO), output_vars(Vars, !IO). output_args(complex_construct(Var, ConsId, VarDirs), !IO) :- output_var(Var, !IO), output_cons_id(ConsId, !IO), - list__length(VarDirs, Length), + list.length(VarDirs, Length), output_length(Length, !IO), output_var_dirs(VarDirs, !IO). output_args(complex_deconstruct(Var, ConsId, VarDirs), !IO) :- output_var(Var, !IO), output_cons_id(ConsId, !IO), - list__length(VarDirs, Length), + list.length(VarDirs, Length), output_length(Length, !IO), output_var_dirs(VarDirs, !IO). output_args(place_arg(RegType, RegNum, Var), !IO) :- @@ -370,7 +370,7 @@ debug_args(enter_proc(ProcId, Detism, LabelCount, LabelId, TempCount, Vars), debug_length(LabelCount, !IO), debug_label_id(LabelId, !IO), debug_length(TempCount, !IO), - list__length(Vars, VarCount), + list.length(Vars, VarCount), debug_length(VarCount, !IO), debug_var_infos(Vars, !IO). debug_args(endof_proc, !IO). @@ -423,25 +423,25 @@ debug_args(test(Var1, Var2, TestId), !IO) :- debug_args(construct(Var, ConsId, Vars), !IO) :- debug_var(Var, !IO), debug_cons_id(ConsId, !IO), - list__length(Vars, Length), + list.length(Vars, Length), debug_length(Length, !IO), debug_vars(Vars, !IO). debug_args(deconstruct(Var, ConsId, Vars), !IO) :- debug_var(Var, !IO), debug_cons_id(ConsId, !IO), - list__length(Vars, Length), + list.length(Vars, Length), debug_length(Length, !IO), debug_vars(Vars, !IO). debug_args(complex_construct(Var, ConsId, VarDirs), !IO) :- debug_var(Var, !IO), debug_cons_id(ConsId, !IO), - list__length(VarDirs, Length), + list.length(VarDirs, Length), debug_length(Length, !IO), debug_var_dirs(VarDirs, !IO). debug_args(complex_deconstruct(Var, ConsId, VarDirs), !IO) :- debug_var(Var, !IO), debug_cons_id(ConsId, !IO), - list__length(VarDirs, Length), + list.length(VarDirs, Length), debug_length(Length, !IO), debug_var_dirs(VarDirs, !IO). debug_args(place_arg(RegType, RegNum, Var), !IO) :- @@ -776,7 +776,7 @@ output_cons_id(type_ctor_info_const(ModuleId, TypeName, TypeArity), !IO) :- output_byte(TypeArity, !IO). output_cons_id(char_const(Char), !IO) :- output_byte(7, !IO), - char__to_int(Char, Byte), + char.to_int(Char, Byte), output_byte(Byte, !IO). % XXX output_cons_id(base_typeclass_info_const(_, _, _), !IO) :- @@ -831,7 +831,7 @@ debug_cons_id(base_typeclass_info_const(ModuleId, debug_string(Instance, !IO). debug_cons_id(char_const(Char), !IO) :- debug_string("char_const", !IO), - string__from_char_list([Char], String), + string.from_char_list([Char], String), debug_string(String, !IO). debug_cons_id(type_info_cell_constructor, !IO) :- debug_string("type_info_cell_constructor", !IO). @@ -1131,41 +1131,41 @@ unop_debug(logical_not, "not"). :- pred debug_cstring(string::in, io::di, io::uo) is det. debug_cstring(Str, !IO) :- - io__write_char('"', !IO), - c_util__output_quoted_string(Str, !IO), - io__write_char('"', !IO), + io.write_char('"', !IO), + c_util.output_quoted_string(Str, !IO), + io.write_char('"', !IO), % XXX: We need the trailing space in case something follows % the string as a bytecode argument. This is not very elegant. - io__write_char(' ', !IO). + io.write_char(' ', !IO). :- pred debug_string(string::in, io::di, io::uo) is det. debug_string(Val, !IO) :- - io__write_string(Val, !IO), - io__write_char(' ', !IO). + io.write_string(Val, !IO), + io.write_char(' ', !IO). :- pred debug_int(int::in, io::di, io::uo) is det. debug_int(Val, !IO) :- - io__write_int(Val, !IO), - io__write_char(' ', !IO). + io.write_int(Val, !IO), + io.write_char(' ', !IO). :- pred debug_float(float::in, io::di, io::uo) is det. debug_float(Val, !IO) :- - io__write_float(Val, !IO), - io__write_char(' ', !IO). + io.write_float(Val, !IO), + io.write_char(' ', !IO). :- pred debug_sym_name(sym_name::in, io::di, io::uo) is det. debug_sym_name(unqualified(Val), !IO) :- - io__write_string(Val, !IO), - io__write_char(' ', !IO). + io.write_string(Val, !IO), + io.write_char(' ', !IO). debug_sym_name(qualified(Module, Val), !IO) :- debug_sym_name(Module, !IO), - io__write_char(':', !IO), - io__write_string(Val, !IO), - io__write_char(' ', !IO). + io.write_char(':', !IO), + io.write_string(Val, !IO), + io.write_char(' ', !IO). %---------------------------------------------------------------------------% diff --git a/compiler/bytecode_data.m b/compiler/bytecode_data.m index 2e7dbcee9..de85a6748 100644 --- a/compiler/bytecode_data.m +++ b/compiler/bytecode_data.m @@ -14,7 +14,7 @@ % %---------------------------------------------------------------------------% -:- module backend_libs__bytecode_data. +:- module backend_libs.bytecode_data. :- interface. :- import_module int. @@ -77,24 +77,24 @@ output_string(Val, !IO) :- % so it may be different for different Mercury implementations. % In particular, it will do the wrong thing for Mercury % implementations which represent characters in Unicode. - io__write_bytes(Val, !IO), - io__write_byte(0, !IO). + io.write_bytes(Val, !IO), + io.write_byte(0, !IO). string_to_byte_list(Val, List) :- % XXX this assumes strings contain 8-bit characters - % Using char__to_int here is wrong; the output will depend + % Using char.to_int here is wrong; the output will depend % on the Mercury implementation's representation of chars, % so it may be different for different Mercury implementations. % In particular, it will do the wrong thing for Mercury % implementations which represent characters in Unicode. - string__to_char_list(Val, Chars), - ToInt = (pred(C::in, I::out) is det :- char__to_int(C, I)), - list__map(ToInt, Chars, List0), - list__append(List0, [0], List). + string.to_char_list(Val, Chars), + ToInt = (pred(C::in, I::out) is det :- char.to_int(C, I)), + list.map(ToInt, Chars, List0), + list.append(List0, [0], List). output_byte(Val, !IO) :- ( Val < 256 -> - io__write_byte(Val, !IO) + io.write_byte(Val, !IO) ; unexpected(this_file, "output_byte: byte does not fit in eight bits") ). @@ -112,7 +112,7 @@ int32_to_byte_list(IntVal, List) :- int_to_byte_list(32, IntVal, List). output_int(IntVal, !IO) :- - int__bits_per_int(IntBits), + int.bits_per_int(IntBits), ( IntBits > bytecode_int_bits -> unexpected(this_file, "output_int: " ++ "size of int is larger than size of bytecode integer.") @@ -121,7 +121,7 @@ output_int(IntVal, !IO) :- ). int_to_byte_list(IntVal, Bytes) :- - int__bits_per_int(IntBits), + int.bits_per_int(IntBits), ( IntBits > bytecode_int_bits -> unexpected(this_file, "int_to_byte_list: " ++ "size of int is larger than size of bytecode integer.") @@ -132,28 +132,28 @@ int_to_byte_list(IntVal, Bytes) :- :- pred output_int(int::in, int::in, io::di, io::uo) is det. output_int(Bits, IntVal, !IO) :- - output_int(io__write_byte, Bits, IntVal, !IO). + output_int(io.write_byte, Bits, IntVal, !IO). :- pred int_to_byte_list(int::in, int::in, list(int)::out) is det. int_to_byte_list(Bits, IntVal, Bytes) :- - output_int(list__cons, Bits, IntVal, [], RevBytes), - list__reverse(RevBytes, Bytes). + output_int(list.cons, Bits, IntVal, [], RevBytes), + list.reverse(RevBytes, Bytes). :- pred output_int(pred(int, T, T), int, int, T, T). :- mode output_int(pred(in, in, out) is det, in, in, in, out) is det. :- mode output_int(pred(in, di, uo) is det, in, in, di, uo) is det. output_int(Writer, Bits, IntVal, !IO) :- - int__bits_per_int(IntBits), + int.bits_per_int(IntBits), ( Bits < IntBits, - int__pow(2, Bits - 1, MaxVal), + int.pow(2, Bits - 1, MaxVal), ( IntVal >= MaxVal ; IntVal < -MaxVal ) -> - string__format( + string.format( "error: bytecode_data.output_int: " ++ "%d does not fit in %d bits", [i(IntVal), i(Bits)], Msg), diff --git a/compiler/bytecode_gen.m b/compiler/bytecode_gen.m index 1e77017bd..d3cdc0de8 100644 --- a/compiler/bytecode_gen.m +++ b/compiler/bytecode_gen.m @@ -14,7 +14,7 @@ %---------------------------------------------------------------------------% -:- module bytecode_backend__bytecode_gen. +:- module bytecode_backend.bytecode_gen. :- interface. :- import_module bytecode_backend.bytecode. @@ -80,8 +80,8 @@ gen_module(ModuleInfo, Code, !IO) :- module_info_predids(ModuleInfo, PredIds), gen_preds(PredIds, ModuleInfo, CodeTree, !IO), - tree__flatten(CodeTree, CodeList), - list__condense(CodeList, Code). + tree.flatten(CodeTree, CodeList), + list.condense(CodeList, Code). :- pred gen_preds(list(pred_id)::in, module_info::in, byte_tree::out, io::di, io::uo) is det. @@ -89,7 +89,7 @@ gen_module(ModuleInfo, Code, !IO) :- gen_preds([], _ModuleInfo, empty, !IO). gen_preds([PredId | PredIds], ModuleInfo, Code, !IO) :- module_info_preds(ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), ProcIds = pred_info_non_imported_procids(PredInfo), ( ProcIds = [], @@ -98,7 +98,7 @@ gen_preds([PredId | PredIds], ModuleInfo, Code, !IO) :- ProcIds = [_ | _], gen_pred(PredId, ProcIds, PredInfo, ModuleInfo, ProcsCode, !IO), predicate_name(ModuleInfo, PredId, PredName), - list__length(ProcIds, ProcsCount), + list.length(ProcIds, ProcsCount), Arity = pred_info_orig_arity(PredInfo), get_is_func(PredInfo, IsFunc), EnterCode = node([enter_pred(PredName, Arity, IsFunc, @@ -125,7 +125,7 @@ gen_pred(PredId, [ProcId | ProcIds], PredInfo, ModuleInfo, Code, !IO) :- gen_proc(ProcId, PredInfo, ModuleInfo, Code) :- pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, ProcInfo), + map.lookup(ProcTable, ProcId, ProcInfo), proc_info_goal(ProcInfo, Goal), proc_info_vartypes(ProcInfo, VarTypes), @@ -133,23 +133,23 @@ gen_proc(ProcId, PredInfo, ModuleInfo, Code) :- proc_info_interface_determinism(ProcInfo, Detism), determinism_to_code_model(Detism, CodeModel), - goal_util__goal_vars(Goal, GoalVars), + goal_util.goal_vars(Goal, GoalVars), proc_info_headvars(ProcInfo, ArgVars), - set__insert_list(GoalVars, ArgVars, Vars), - set__to_sorted_list(Vars, VarList), - map__init(VarMap0), + set.insert_list(GoalVars, ArgVars, Vars), + set.to_sorted_list(Vars, VarList), + map.init(VarMap0), create_varmap(VarList, VarSet, VarTypes, 0, VarMap0, VarMap, VarInfos), init_byte_info(ModuleInfo, VarMap, VarTypes, ByteInfo0), get_next_label(ZeroLabel, ByteInfo0, ByteInfo1), proc_info_arg_info(ProcInfo, ArgInfo), - assoc_list__from_corresponding_lists(ArgVars, ArgInfo, Args), + assoc_list.from_corresponding_lists(ArgVars, ArgInfo, Args), - call_gen__input_arg_locs(Args, InputArgs), + call_gen.input_arg_locs(Args, InputArgs), gen_pickups(InputArgs, ByteInfo, PickupCode), - call_gen__output_arg_locs(Args, OutputArgs), + call_gen.output_arg_locs(Args, OutputArgs), gen_places(OutputArgs, ByteInfo, PlaceCode), % If semideterministic, reserve temp slot 0 for the return value @@ -165,9 +165,9 @@ gen_proc(ProcId, PredInfo, ModuleInfo, Code) :- ZeroLabelCode = node([label(ZeroLabel)]), BodyTree = tree_list([PickupCode, ZeroLabelCode, GoalCode, PlaceCode]), - tree__flatten(BodyTree, BodyList), - list__condense(BodyList, BodyCode0), - ( list__member(not_supported, BodyCode0) -> + tree.flatten(BodyTree, BodyList), + list.condense(BodyList, BodyCode0), + ( list.member(not_supported, BodyCode0) -> BodyCode = node([not_supported]) ; BodyCode = node(BodyCode0) @@ -190,7 +190,7 @@ gen_proc(ProcId, PredInfo, ModuleInfo, Code) :- gen_goal(GoalExpr - GoalInfo, !ByteInfo, Code) :- gen_goal_expr(GoalExpr, GoalInfo, !ByteInfo, GoalCode), goal_info_get_context(GoalInfo, Context), - term__context_line(Context, Line), + term.context_line(Context, Line), Code = tree(node([context(Line)]), GoalCode). :- pred gen_goal_expr(hlds_goal_expr::in, hlds_goal_info::in, @@ -205,7 +205,7 @@ gen_goal_expr(GoalExpr, GoalInfo, !ByteInfo, Code) :- !.ByteInfo, Code) ; % XXX - % string__append_list([ + % string.append_list([ % "bytecode for ", GenericCallFunctor, " calls"], Msg), % sorry(this_file, Msg) functor(GenericCallType, _GenericCallFunctor, _), @@ -328,18 +328,18 @@ gen_pickups([Var - Loc | OutputArgs], ByteInfo, Code) :- gen_higher_order_call(PredVar, ArgVars, ArgModes, Detism, ByteInfo, Code) :- determinism_to_code_model(Detism, CodeModel), get_module_info(ByteInfo, ModuleInfo), - list__map(get_var_type(ByteInfo), ArgVars, ArgTypes), + list.map(get_var_type(ByteInfo), ArgVars, ArgTypes), make_arg_infos(ArgTypes, ArgModes, CodeModel, ModuleInfo, ArgInfo), - assoc_list__from_corresponding_lists(ArgVars, ArgInfo, ArgVarsInfos), + assoc_list.from_corresponding_lists(ArgVars, ArgInfo, ArgVarsInfos), - arg_info__partition_args(ArgVarsInfos, InVars, OutVars), - list__length(InVars, NInVars), - list__length(OutVars, NOutVars), + arg_info.partition_args(ArgVarsInfos, InVars, OutVars), + list.length(InVars, NInVars), + list.length(OutVars, NOutVars), - call_gen__input_arg_locs(ArgVarsInfos, InputArgs), + call_gen.input_arg_locs(ArgVarsInfos, InputArgs), gen_places(InputArgs, ByteInfo, PlaceArgs), - call_gen__output_arg_locs(ArgVarsInfos, OutputArgs), + call_gen.output_arg_locs(ArgVarsInfos, OutputArgs), gen_pickups(OutputArgs, ByteInfo, PickupArgs), map_var(ByteInfo, PredVar, BytePredVar), @@ -360,15 +360,15 @@ gen_call(PredId, ProcId, ArgVars, Detism, ByteInfo, Code) :- get_module_info(ByteInfo, ModuleInfo), module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo), proc_info_arg_info(ProcInfo, ArgInfo), - assoc_list__from_corresponding_lists(ArgVars, ArgInfo, ArgVarsInfos), + assoc_list.from_corresponding_lists(ArgVars, ArgInfo, ArgVarsInfos), module_info_pred_info(ModuleInfo, PredId, PredInfo), get_is_func(PredInfo, IsFunc), - call_gen__input_arg_locs(ArgVarsInfos, InputArgs), + call_gen.input_arg_locs(ArgVarsInfos, InputArgs), gen_places(InputArgs, ByteInfo, PlaceArgs), - call_gen__output_arg_locs(ArgVarsInfos, OutputArgs), + call_gen.output_arg_locs(ArgVarsInfos, OutputArgs), gen_pickups(OutputArgs, ByteInfo, PickupArgs), predicate_id(ModuleInfo, PredId, ModuleName, PredName, Arity), @@ -392,7 +392,7 @@ gen_builtin(PredId, ProcId, Args, ByteInfo, Code) :- predicate_module(ModuleInfo, PredId, ModuleName), predicate_name(ModuleInfo, PredId, PredName), ( - builtin_ops__translate_builtin(ModuleName, PredName, ProcId, + builtin_ops.translate_builtin(ModuleName, PredName, ProcId, Args, SimpleCode) -> ( @@ -406,7 +406,7 @@ gen_builtin(PredId, ProcId, Args, ByteInfo, Code) :- unexpected(this_file, "ref_assign") ) ; - string__append("unknown builtin predicate ", PredName, Msg), + string.append("unknown builtin predicate ", PredName, Msg), unexpected(this_file, Msg) ). @@ -485,7 +485,7 @@ gen_unify(construct(Var, ConsId, Args, UniModes, _, _, _), _, _, ( all_dirs_same(Dirs, to_var) -> Code = node([construct(ByteVar, ByteConsId, ByteArgs)]) ; - assoc_list__from_corresponding_lists(ByteArgs, Dirs, Pairs), + assoc_list.from_corresponding_lists(ByteArgs, Dirs, Pairs), Code = node([complex_construct(ByteVar, ByteConsId, Pairs)]) ) ). @@ -498,7 +498,7 @@ gen_unify(deconstruct(Var, ConsId, Args, UniModes, _, _), _, _, ( all_dirs_same(Dirs, to_arg) -> Code = node([deconstruct(ByteVar, ByteConsId, ByteArgs)]) ; - assoc_list__from_corresponding_lists(ByteArgs, Dirs, Pairs), + assoc_list.from_corresponding_lists(ByteArgs, Dirs, Pairs), Code = node([complex_deconstruct(ByteVar, ByteConsId, Pairs)]) ). gen_unify(assign(Target, Source), _, _, ByteInfo, Code) :- @@ -689,7 +689,7 @@ map_cons_id(ByteInfo, Var, ConsId, ByteConsId) :- Functor = unqualified(FunctorName), \+ type_is_tuple(Type, _) -> - string__to_char_list(FunctorName, FunctorList), + string.to_char_list(FunctorName, FunctorList), ( FunctorList = [Char] -> ByteConsId = char_const(Char) ; @@ -804,10 +804,10 @@ map_cons_tag(shared_with_reserved_addresses(_, _), _) :- create_varmap([], _, _, _, !VarMap, []). create_varmap([Var | VarList], VarSet, VarTypes, N0, !VarMap, VarInfos) :- - map__det_insert(!.VarMap, Var, N0, !:VarMap), + map.det_insert(!.VarMap, Var, N0, !:VarMap), N1 = N0 + 1, - varset__lookup_name(VarSet, Var, VarName), - map__lookup(VarTypes, Var, VarType), + varset.lookup_name(VarSet, Var, VarName), + map.lookup(VarTypes, Var, VarType), create_varmap(VarList, VarSet, VarTypes, N1, !VarMap, VarInfosTail), VarInfos = [var_info(VarName, VarType) | VarInfosTail]. @@ -827,7 +827,7 @@ create_varmap([Var | VarList], VarSet, VarTypes, N0, !VarMap, VarInfos) :- init_byte_info(ModuleInfo, VarMap, VarTypes, ByteInfo) :- ByteInfo = byte_info(VarMap, VarTypes, ModuleInfo, - counter__init(0), counter__init(0)). + counter.init(0), counter.init(0)). :- pred get_module_info(byte_info::in, module_info::out) is det. @@ -844,27 +844,27 @@ map_vars(ByteInfo, Vars, ByteVars) :- map_vars_2(_VarMap, [], []). map_vars_2(VarMap, [Var | Vars], [ByteVar | ByteVars]) :- - map__lookup(VarMap, Var, ByteVar), + map.lookup(VarMap, Var, ByteVar), map_vars_2(VarMap, Vars, ByteVars). :- pred map_var(byte_info::in, prog_var::in, byte_var::out) is det. map_var(ByteInfo, Var, ByteVar) :- - map__lookup(ByteInfo ^ byteinfo_varmap, Var, ByteVar). + map.lookup(ByteInfo ^ byteinfo_varmap, Var, ByteVar). :- pred get_var_type(byte_info::in, prog_var::in, mer_type::out) is det. get_var_type(ByteInfo, Var, Type) :- - map__lookup(ByteInfo ^ byteinfo_vartypes, Var, Type). + map.lookup(ByteInfo ^ byteinfo_vartypes, Var, Type). :- pred get_next_label(int::out, byte_info::in, byte_info::out) is det. get_next_label(Label, !ByteInfo) :- LabelCounter0 = !.ByteInfo ^ byteinfo_label_counter, - counter__allocate(Label, LabelCounter0, LabelCounter), + counter.allocate(Label, LabelCounter0, LabelCounter), !:ByteInfo = !.ByteInfo ^ byteinfo_label_counter := LabelCounter. :- pred get_next_temp(int::out, byte_info::in, byte_info::out) @@ -872,16 +872,16 @@ get_next_label(Label, !ByteInfo) :- get_next_temp(Temp, !ByteInfo) :- TempCounter0 = !.ByteInfo ^ byteinfo_temp_counter, - counter__allocate(Temp, TempCounter0, TempCounter), + counter.allocate(Temp, TempCounter0, TempCounter), !:ByteInfo = !.ByteInfo ^ byteinfo_temp_counter := TempCounter. :- pred get_counts(byte_info::in, int::out, int::out) is det. get_counts(ByteInfo0, Label, Temp) :- LabelCounter0 = ByteInfo0 ^ byteinfo_label_counter, - counter__allocate(Label, LabelCounter0, _LabelCounter), + counter.allocate(Label, LabelCounter0, _LabelCounter), TempCounter0 = ByteInfo0 ^ byteinfo_temp_counter, - counter__allocate(Temp, TempCounter0, _TempCounter). + counter.allocate(Temp, TempCounter0, _TempCounter). %---------------------------------------------------------------------------% diff --git a/compiler/c_util.m b/compiler/c_util.m index 375ff5cdb..a809cc6eb 100644 --- a/compiler/c_util.m +++ b/compiler/c_util.m @@ -17,7 +17,7 @@ % %-----------------------------------------------------------------------------% -:- module backend_libs__c_util. +:- module backend_libs.c_util. :- interface. :- import_module backend_libs.builtin_ops. @@ -167,18 +167,18 @@ % Line numbering. set_line_num(File, Line, !IO) :- - globals__io_lookup_bool_option(line_numbers, LineNumbers, !IO), + globals.io_lookup_bool_option(line_numbers, LineNumbers, !IO), ( LineNumbers = yes, ( Line > 0, File \= "" -> - io__write_string("#line ", !IO), - io__write_int(Line, !IO), - io__write_string(" """, !IO), + io.write_string("#line ", !IO), + io.write_int(Line, !IO), + io.write_string(" """, !IO), output_quoted_string(File, !IO), - io__write_string("""\n", !IO) + io.write_string("""\n", !IO) ; reset_line_num(!IO) ) @@ -189,19 +189,19 @@ set_line_num(File, Line, !IO) :- reset_line_num(!IO) :- % We want to generate another #line directive to reset the C compiler's % idea of what it is processing back to the file we are generating. - io__get_output_line_number(Line, !IO), - io__output_stream_name(FileName, !IO), - globals__io_lookup_bool_option(line_numbers, LineNumbers, !IO), + io.get_output_line_number(Line, !IO), + io.output_stream_name(FileName, !IO), + globals.io_lookup_bool_option(line_numbers, LineNumbers, !IO), ( Line > 0, FileName \= "", LineNumbers = yes -> - io__write_string("#line ", !IO), - io__write_int(Line + 1, !IO), - io__write_string(" """, !IO), + io.write_string("#line ", !IO), + io.write_int(Line + 1, !IO), + io.write_string(" """, !IO), output_quoted_string(FileName, !IO), - io__write_string("""\n", !IO) + io.write_string("""\n", !IO) ; true ). @@ -211,7 +211,7 @@ reset_line_num(!IO) :- % String and character handling. output_quoted_string(S0, !IO) :- - output_quoted_multi_string(string__length(S0), S0, !IO). + output_quoted_multi_string(string.length(S0), S0, !IO). output_quoted_multi_string(Len, S, !IO) :- output_quoted_multi_string_2(0, Len, S, !IO). @@ -229,14 +229,14 @@ output_quoted_multi_string_2(Cur, Len, S, !IO) :- Cur \= 0, Cur mod 512 = 0 -> - io__write_string("\" \"", !IO) + io.write_string("\" \"", !IO) ; true ), % We must use unsafe index, because we want to be able to access chars % beyond the first NUL. - string__unsafe_index(S, Cur, Char), + string.unsafe_index(S, Cur, Char), output_quoted_char(Char, !IO), % Check for trigraph sequences in string literals. We break the @@ -247,11 +247,11 @@ output_quoted_multi_string_2(Cur, Len, S, !IO) :- Cur < Len + 2 -> ( - string__unsafe_index(S, Cur + 1, '?'), - string__unsafe_index(S, Cur + 2, ThirdChar), + string.unsafe_index(S, Cur + 1, '?'), + string.unsafe_index(S, Cur + 2, ThirdChar), is_trigraph_char(ThirdChar) -> - io__write_string("\" \"", !IO) + io.write_string("\" \"", !IO) ; true ) @@ -266,15 +266,15 @@ output_quoted_multi_string_2(Cur, Len, S, !IO) :- output_quoted_char(Char, !IO) :- quote_char(Char, EscapedChars), - io__write_string(EscapedChars, !IO). + io.write_string(EscapedChars, !IO). quote_char(Char, QuotedChar) :- quote_one_char(Char, [], RevQuotedChar), - string__from_rev_char_list(RevQuotedChar, QuotedChar). + string.from_rev_char_list(RevQuotedChar, QuotedChar). quote_string(String, QuotedString) :- - string__foldl(quote_one_char, String, [], RevQuotedChars), - string__from_rev_char_list(RevQuotedChars, QuotedString). + string.foldl(quote_one_char, String, [], RevQuotedChars), + string.from_rev_char_list(RevQuotedChars, QuotedString). :- pred quote_one_char(char::in, list(char)::in, list(char)::out) is det. @@ -283,7 +283,7 @@ quote_one_char(Char, RevChars0, RevChars) :- RevChars = [EscapeChar, '\\' | RevChars0] ; is_c_source_char(Char) -> RevChars = [Char | RevChars0] - ; char__to_int(Char, 0) -> + ; char.to_int(Char, 0) -> RevChars = ['0', '\\' | RevChars0] ; escape_any_char(Char, EscapeChars), @@ -323,8 +323,8 @@ is_trigraph_char('-'). :- pred is_c_source_char(char::in) is semidet. is_c_source_char(Char) :- - ( char__is_alnum(Char) - ; string__contains_char(c_graphic_chars, Char) + ( char.is_alnum(Char) + ; string.contains_char(c_graphic_chars, Char) ). % This returns a string containing all the characters that the C standard @@ -335,7 +335,7 @@ is_c_source_char(Char) :- c_graphic_chars = " !\"#%&'()*+,-./:;<=>?[\\]^_{|}~". - % reverse_append(Xs, Ys, Zs) <=> Zs = list__reverse(Xs) ++ Ys. + % reverse_append(Xs, Ys, Zs) <=> Zs = list.reverse(Xs) ++ Ys. % :- pred reverse_append(list(T)::in, list(T)::in, list(T)::out) is det. @@ -350,10 +350,10 @@ reverse_append([X | Xs], L0, L) :- % of characters is the same as the Mercury compiler's. % escape_any_char(Char, EscapeCodeChars) :- - char__to_int(Char, Int), - string__int_to_base_string(Int, 8, OctalString0), - string__pad_left(OctalString0, '0', 3, OctalString), - EscapeCodeChars = ['\\' | string__to_char_list(OctalString)]. + char.to_int(Char, Int), + string.int_to_base_string(Int, 8, OctalString0), + string.pad_left(OctalString0, '0', 3, OctalString), + EscapeCodeChars = ['\\' | string.to_char_list(OctalString)]. %-----------------------------------------------------------------------------% % @@ -361,7 +361,7 @@ escape_any_char(Char, EscapeCodeChars) :- % % XXX These routines do not yet handle infinities and NaNs properly. -make_float_literal(Float) = string__format("%#.17g", [f(Float)]). +make_float_literal(Float) = string.format("%#.17g", [f(Float)]). % This is used by the C, Java, and IL back-ends, % so the output must be valid syntax in all three languages. % @@ -370,7 +370,7 @@ make_float_literal(Float) = string__format("%#.17g", [f(Float)]). % to strings and back again without losing precision. output_float_literal(Float, !IO) :- - io__write_string(make_float_literal(Float), !IO). + io.write_string(make_float_literal(Float), !IO). %-----------------------------------------------------------------------------% % @@ -429,12 +429,12 @@ binary_infix_op(int_ge, ">="). %-----------------------------------------------------------------------------% output_c_file_intro_and_grade(SourceFileName, Version, !IO) :- - globals__io_lookup_int_option(num_tag_bits, NumTagBits, !IO), - string__int_to_string(NumTagBits, NumTagBitsStr), - globals__io_lookup_bool_option(unboxed_float, UnboxedFloat, !IO), + globals.io_lookup_int_option(num_tag_bits, NumTagBits, !IO), + string.int_to_string(NumTagBits, NumTagBitsStr), + globals.io_lookup_bool_option(unboxed_float, UnboxedFloat, !IO), UnboxedFloatStr = convert_bool_to_string(UnboxedFloat), - io__write_strings([ + io.write_strings([ "/*\n", "** Automatically generated from `", SourceFileName, "'\n", "** by the Mercury compiler,\n", diff --git a/compiler/call_gen.m b/compiler/call_gen.m index 7e9c3de55..1631a8d6a 100644 --- a/compiler/call_gen.m +++ b/compiler/call_gen.m @@ -15,7 +15,7 @@ %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% -:- module ll_backend__call_gen. +:- module ll_backend.call_gen. :- interface. :- import_module hlds.code_model. @@ -48,17 +48,17 @@ ---> known_num ; unknown. - % call_gen__generic_call_info(Globals, GenericCall, NumImmediateInputArgs, + % call_gen.generic_call_info(Globals, GenericCall, NumImmediateInputArgs, % CodeAddr, SpecifierArgInfos, FirstImmediateInputReg, HoCallVariant). % -:- pred call_gen__generic_call_info(globals::in, generic_call::in, int::in, +:- pred call_gen.generic_call_info(globals::in, generic_call::in, int::in, code_addr::out, assoc_list(prog_var, arg_info)::out, int::out, known_call_variant::out) is det. -:- pred call_gen__input_arg_locs(assoc_list(prog_var, arg_info)::in, +:- pred call_gen.input_arg_locs(assoc_list(prog_var, arg_info)::in, assoc_list(prog_var, arg_loc)::out) is det. -:- pred call_gen__output_arg_locs(assoc_list(prog_var, arg_info)::in, +:- pred call_gen.output_arg_locs(assoc_list(prog_var, arg_info)::in, assoc_list(prog_var, arg_loc)::out) is det. %---------------------------------------------------------------------------% @@ -96,24 +96,24 @@ generate_call(CodeModel, PredId, ProcId, ArgVars, GoalInfo, Code, !CI) :- % Find out which arguments are input and which are output. - ArgInfo = code_info__get_pred_proc_arginfo(!.CI, PredId, ProcId), - assoc_list__from_corresponding_lists(ArgVars, ArgInfo, ArgsInfos), + ArgInfo = code_info.get_pred_proc_arginfo(!.CI, PredId, ProcId), + assoc_list.from_corresponding_lists(ArgVars, ArgInfo, ArgsInfos), % Save the necessary vars on the stack and move the input args % to their registers. - code_info__setup_call(GoalInfo, ArgsInfos, LiveVals, SetupCode, !CI), - call_gen__kill_dead_input_vars(ArgsInfos, GoalInfo, NonLiveOutputs, + code_info.setup_call(GoalInfo, ArgsInfos, LiveVals, SetupCode, !CI), + call_gen.kill_dead_input_vars(ArgsInfos, GoalInfo, NonLiveOutputs, !CI), % Figure out what the call model is. - call_gen__prepare_for_call(CodeModel, CallModel, TraceCode, !CI), + call_gen.prepare_for_call(CodeModel, CallModel, TraceCode, !CI), % Make the call. - code_info__get_module_info(!.CI, ModuleInfo), - Address = code_info__make_entry_label(!.CI, ModuleInfo, + code_info.get_module_info(!.CI, ModuleInfo), + Address = code_info.make_entry_label(!.CI, ModuleInfo, PredId, ProcId, yes), - code_info__get_next_label(ReturnLabel, !CI), - call_gen__call_comment(CodeModel, CallComment), + code_info.get_next_label(ReturnLabel, !CI), + call_gen.call_comment(CodeModel, CallComment), goal_info_get_context(GoalInfo, Context), goal_info_get_goal_path(GoalInfo, GoalPath), CallCode = node([ @@ -126,18 +126,18 @@ generate_call(CodeModel, PredId, ProcId, ArgVars, GoalInfo, Code, !CI) :- % Figure out what variables will be live at the return point, % and where, for use in the accurate garbage collector, and % in the debugger. - code_info__get_instmap(!.CI, InstMap), + code_info.get_instmap(!.CI, InstMap), goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap, InstMapDelta, ReturnInstMap), + instmap.apply_instmap_delta(InstMap, InstMapDelta, ReturnInstMap), % Update the code generator state to reflect the situation % after the call. - call_gen__handle_return(ArgsInfos, GoalInfo, NonLiveOutputs, + call_gen.handle_return(ArgsInfos, GoalInfo, NonLiveOutputs, ReturnInstMap, ReturnLiveLvalues, !CI), % If the call can fail, generate code to check for and % handle the failure. - call_gen__handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI), + call_gen.handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI), Code = tree_list([SetupCode, TraceCode, CallCode, FailHandlingCode]). @@ -146,7 +146,7 @@ generate_call(CodeModel, PredId, ProcId, ArgVars, GoalInfo, Code, !CI) :- generate_generic_call(OuterCodeModel, GenericCall, Args0, Modes0, Det, GoalInfo, Code, !CI) :- % For a generic_call, we split the arguments into inputs and outputs, - % put the inputs in the locations expected by mercury__do_call_closure in + % put the inputs in the locations expected by mercury.do_call_closure in % runtime/mercury_ho_call.c, generate the call to that code, and pick up % the outputs from the locations that we know the runtime system leaves % them in. @@ -156,14 +156,14 @@ generate_generic_call(OuterCodeModel, GenericCall, Args0, % variables to be saved to the stack. ( GenericCall = cast(_) -> ( Args0 = [InputArg, OutputArg] -> - call_gen__generate_assign_builtin(OutputArg, + call_gen.generate_assign_builtin(OutputArg, leaf(InputArg), Code, !CI) ; unexpected(this_file, "generate_generic_call: invalid type/inst cast call") ) ; - call_gen__generate_generic_call_2(OuterCodeModel, + call_gen.generate_generic_call_2(OuterCodeModel, GenericCall, Args0, Modes0, Det, GoalInfo, Code, !CI) ). @@ -174,13 +174,13 @@ generate_generic_call(OuterCodeModel, GenericCall, Args0, generate_generic_call_2(_OuterCodeModel, GenericCall, Args, Modes, Det, GoalInfo, Code, !CI) :- - Types = list__map(code_info__variable_type(!.CI), Args), + Types = list.map(code_info.variable_type(!.CI), Args), - code_info__get_module_info(!.CI, ModuleInfo), - arg_info__compute_in_and_out_vars(ModuleInfo, Args, Modes, Types, + code_info.get_module_info(!.CI, ModuleInfo), + arg_info.compute_in_and_out_vars(ModuleInfo, Args, Modes, Types, InVars, OutVars), module_info_get_globals(ModuleInfo, Globals), - call_gen__generic_call_info(Globals, GenericCall, length(InVars), + call_gen.generic_call_info(Globals, GenericCall, length(InVars), CodeAddr, SpecifierArgInfos, FirstImmInput, HoCallVariant), determinism_to_code_model(Det, CodeModel), ( CodeModel = model_semi -> @@ -193,42 +193,42 @@ generate_generic_call_2(_OuterCodeModel, GenericCall, Args, Modes, Det, InVarArgInfos), give_vars_consecutive_arg_infos(OutVars, FirstOutput, top_out, OutArgsInfos), - list__append(SpecifierArgInfos, InVarArgInfos, InArgInfos), - list__append(InArgInfos, OutArgsInfos, ArgInfos), + list.append(SpecifierArgInfos, InVarArgInfos, InArgInfos), + list.append(InArgInfos, OutArgsInfos, ArgInfos), % Save the necessary vars on the stack and move the input args % defined by variables to their registers. - code_info__setup_call(GoalInfo, ArgInfos, LiveVals0, SetupCode, !CI), - call_gen__kill_dead_input_vars(ArgInfos, GoalInfo, NonLiveOutputs, + code_info.setup_call(GoalInfo, ArgInfos, LiveVals0, SetupCode, !CI), + call_gen.kill_dead_input_vars(ArgInfos, GoalInfo, NonLiveOutputs, !CI), % Move the input args not defined by variables to their % registers. Setting up these arguments last results in % slightly more efficient code, since we can use their % registers when placing the variables. - call_gen__generic_call_nonvar_setup(GenericCall, HoCallVariant, + call_gen.generic_call_nonvar_setup(GenericCall, HoCallVariant, InVars, OutVars, NonVarCode, !CI), - call_gen__extra_livevals(FirstImmInput, ExtraLiveVals), - set__insert_list(LiveVals0, ExtraLiveVals, LiveVals), + call_gen.extra_livevals(FirstImmInput, ExtraLiveVals), + set.insert_list(LiveVals0, ExtraLiveVals, LiveVals), - call_gen__prepare_for_call(CodeModel, CallModel, TraceCode, !CI), + call_gen.prepare_for_call(CodeModel, CallModel, TraceCode, !CI), % Make the call. - code_info__get_next_label(ReturnLabel, !CI), + code_info.get_next_label(ReturnLabel, !CI), goal_info_get_context(GoalInfo, Context), goal_info_get_goal_path(GoalInfo, GoalPath), % Figure out what variables will be live at the return point, % and where, for use in the accurate garbage collector, and % in the debugger. - code_info__get_instmap(!.CI, InstMap), + code_info.get_instmap(!.CI, InstMap), goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap, InstMapDelta, ReturnInstMap), + instmap.apply_instmap_delta(InstMap, InstMapDelta, ReturnInstMap), % Update the code generator state to reflect the situation % after the call. - call_gen__handle_return(OutArgsInfos, GoalInfo, NonLiveOutputs, + call_gen.handle_return(OutArgsInfos, GoalInfo, NonLiveOutputs, ReturnInstMap, ReturnLiveLvalues, !CI), CallCode = node([ @@ -240,7 +240,7 @@ generate_generic_call_2(_OuterCodeModel, GenericCall, Args, Modes, Det, % If the call can fail, generate code to check for and % handle the failure. - call_gen__handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI), + call_gen.handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI), Code = tree_list([SetupCode, NonVarCode, TraceCode, CallCode, FailHandlingCode]). @@ -249,28 +249,28 @@ generate_generic_call_2(_OuterCodeModel, GenericCall, Args, Modes, Det, % The registers before the first input argument are all live. % -:- pred call_gen__extra_livevals(int::in, list(lval)::out) is det. +:- pred call_gen.extra_livevals(int::in, list(lval)::out) is det. -call_gen__extra_livevals(FirstInput, ExtraLiveVals) :- - call_gen__extra_livevals(1, FirstInput, ExtraLiveVals). +call_gen.extra_livevals(FirstInput, ExtraLiveVals) :- + call_gen.extra_livevals(1, FirstInput, ExtraLiveVals). -:- pred call_gen__extra_livevals(int::in, int::in, list(lval)::out) is det. +:- pred call_gen.extra_livevals(int::in, int::in, list(lval)::out) is det. -call_gen__extra_livevals(Reg, FirstInput, ExtraLiveVals) :- +call_gen.extra_livevals(Reg, FirstInput, ExtraLiveVals) :- ( Reg < FirstInput -> ExtraLiveVals = [reg(r, Reg) | ExtraLiveVals1], NextReg = Reg + 1, - call_gen__extra_livevals(NextReg, FirstInput, ExtraLiveVals1) + call_gen.extra_livevals(NextReg, FirstInput, ExtraLiveVals1) ; ExtraLiveVals = [] ). -call_gen__generic_call_info(Globals, GenericCall, NumInputArgs, CodeAddr, +call_gen.generic_call_info(Globals, GenericCall, NumInputArgs, CodeAddr, SpecifierArgInfos, FirstImmediateInputReg, HoCallVariant) :- ( GenericCall = higher_order(PredVar, _, _, _), SpecifierArgInfos = [PredVar - arg_info(1, top_in)], - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, max_specialized_do_call_closure, MaxSpec), ( MaxSpec >= 0, @@ -287,7 +287,7 @@ call_gen__generic_call_info(Globals, GenericCall, NumInputArgs, CodeAddr, ; GenericCall = class_method(TCVar, _, _, _), SpecifierArgInfos = [TCVar - arg_info(1, top_in)], - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, max_specialized_do_call_class_method, MaxSpec), ( MaxSpec >= 0, @@ -318,41 +318,41 @@ call_gen__generic_call_info(Globals, GenericCall, NumInputArgs, CodeAddr, % arguments being passed the indirectly called code, since with eager % code generation this ensures that each target register is reserved % for the variable destined for it. This is set up by - % call_gen__generic_call_info. call_gen__generic_call_nonvar_setup + % call_gen.generic_call_info. call_gen.generic_call_nonvar_setup % generates code to pass to the dispatch routine the parts of the % indirectly called code's identifier that come from constants. % -:- pred call_gen__generic_call_nonvar_setup(generic_call::in, +:- pred call_gen.generic_call_nonvar_setup(generic_call::in, known_call_variant::in, list(prog_var)::in, list(prog_var)::in, code_tree::out, code_info::in, code_info::out) is det. -call_gen__generic_call_nonvar_setup(higher_order(_, _, _, _), +call_gen.generic_call_nonvar_setup(higher_order(_, _, _, _), HoCallVariant, InVars, _OutVars, Code, !CI) :- ( HoCallVariant = known_num, Code = empty ; HoCallVariant = unknown, - code_info__clobber_regs([reg(r, 2)], !CI), - list__length(InVars, NInVars), + code_info.clobber_regs([reg(r, 2)], !CI), + list.length(InVars, NInVars), Code = node([ assign(reg(r, 2), const(int_const(NInVars))) - "Assign number of immediate input arguments" ]) ). -call_gen__generic_call_nonvar_setup(class_method(_, Method, _, _), +call_gen.generic_call_nonvar_setup(class_method(_, Method, _, _), HoCallVariant, InVars, _OutVars, Code, !CI) :- ( HoCallVariant = known_num, - code_info__clobber_regs([reg(r, 2)], !CI), + code_info.clobber_regs([reg(r, 2)], !CI), Code = node([ assign(reg(r, 2), const(int_const(Method))) - "Index of class method in typeclass info" ]) ; HoCallVariant = unknown, - code_info__clobber_regs([reg(r, 2), reg(r, 3)], !CI), - list__length(InVars, NInVars), + code_info.clobber_regs([reg(r, 2), reg(r, 3)], !CI), + list.length(InVars, NInVars), Code = node([ assign(reg(r, 2), const(int_const(Method))) - "Index of class method in typeclass info", @@ -360,16 +360,16 @@ call_gen__generic_call_nonvar_setup(class_method(_, Method, _, _), "Assign number of immediate input arguments" ]) ). -call_gen__generic_call_nonvar_setup(cast(_), _, _, _, _, !CI) :- +call_gen.generic_call_nonvar_setup(cast(_), _, _, _, _, !CI) :- unexpected(this_file, "generic_call_nonvar_setup: cast"). %---------------------------------------------------------------------------% -:- pred call_gen__prepare_for_call(code_model::in, call_model::out, +:- pred call_gen.prepare_for_call(code_model::in, call_model::out, code_tree::out, code_info::in, code_info::out) is det. -call_gen__prepare_for_call(CodeModel, CallModel, TraceCode, !CI) :- - code_info__succip_is_used(!CI), +call_gen.prepare_for_call(CodeModel, CallModel, TraceCode, !CI) :- + code_info.succip_is_used(!CI), ( CodeModel = model_det, CallModel = det @@ -378,26 +378,26 @@ call_gen__prepare_for_call(CodeModel, CallModel, TraceCode, !CI) :- CallModel = semidet ; CodeModel = model_non, - code_info__may_use_nondet_tailcall(!.CI, TailCallStatus), + code_info.may_use_nondet_tailcall(!.CI, TailCallStatus), CallModel = nondet(TailCallStatus), - code_info__set_resume_point_and_frame_to_unknown(!CI) + code_info.set_resume_point_and_frame_to_unknown(!CI) ), - trace__prepare_for_call(!.CI, TraceCode). + trace.prepare_for_call(!.CI, TraceCode). -:- pred call_gen__handle_failure(code_model::in, hlds_goal_info::in, +:- pred call_gen.handle_failure(code_model::in, hlds_goal_info::in, code_tree::out, code_info::in, code_info::out) is det. -call_gen__handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI) :- +call_gen.handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI) :- ( CodeModel = model_semi -> goal_info_get_determinism(GoalInfo, Detism), ( Detism = failure -> - code_info__generate_failure(FailHandlingCode, !CI) + code_info.generate_failure(FailHandlingCode, !CI) ; - code_info__get_next_label(ContLab, !CI), + code_info.get_next_label(ContLab, !CI), FailTestCode = node([ if_val(lval(reg(r, 1)), label(ContLab)) - "test for success" ]), - code_info__generate_failure(FailCode, !CI), + code_info.generate_failure(FailCode, !CI), ContLabelCode = node([ label(ContLab) - "" ]), @@ -408,11 +408,11 @@ call_gen__handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI) :- FailHandlingCode = empty ). -:- pred call_gen__call_comment(code_model::in, string::out) is det. +:- pred call_gen.call_comment(code_model::in, string::out) is det. -call_gen__call_comment(model_det, "branch to det procedure"). -call_gen__call_comment(model_semi, "branch to semidet procedure"). -call_gen__call_comment(model_non, "branch to nondet procedure"). +call_gen.call_comment(model_det, "branch to det procedure"). +call_gen.call_comment(model_semi, "branch to semidet procedure"). +call_gen.call_comment(model_non, "branch to nondet procedure"). %---------------------------------------------------------------------------% @@ -435,23 +435,23 @@ call_gen__call_comment(model_non, "branch to nondet procedure"). % It may contain the input arguments as well; kill_dead_input_vars % and handle_return ignore them. % -:- pred call_gen__kill_dead_input_vars(assoc_list(prog_var, arg_info)::in, +:- pred call_gen.kill_dead_input_vars(assoc_list(prog_var, arg_info)::in, hlds_goal_info::in, set(prog_var)::out, code_info::in, code_info::out) is det. -call_gen__kill_dead_input_vars(ArgsInfos, GoalInfo, NonLiveOutputs, !CI) :- - code_info__get_forward_live_vars(!.CI, Liveness), - call_gen__find_nonlive_outputs(ArgsInfos, Liveness, - set__init, NonLiveOutputs), +call_gen.kill_dead_input_vars(ArgsInfos, GoalInfo, NonLiveOutputs, !CI) :- + code_info.get_forward_live_vars(!.CI, Liveness), + call_gen.find_nonlive_outputs(ArgsInfos, Liveness, + set.init, NonLiveOutputs), goal_info_get_post_deaths(GoalInfo, PostDeaths), - set__difference(PostDeaths, NonLiveOutputs, ImmediatePostDeaths), - code_info__make_vars_forward_dead(ImmediatePostDeaths, !CI). + set.difference(PostDeaths, NonLiveOutputs, ImmediatePostDeaths), + code_info.make_vars_forward_dead(ImmediatePostDeaths, !CI). -:- pred call_gen__handle_return(assoc_list(prog_var, arg_info)::in, +:- pred call_gen.handle_return(assoc_list(prog_var, arg_info)::in, hlds_goal_info::in, set(prog_var)::in, instmap::in, list(liveinfo)::out, code_info::in, code_info::out) is det. -call_gen__handle_return(ArgsInfos, GoalInfo, _NonLiveOutputs, ReturnInstMap, +call_gen.handle_return(ArgsInfos, GoalInfo, _NonLiveOutputs, ReturnInstMap, ReturnLiveLvalues, !CI) :- goal_info_get_instmap_delta(GoalInfo, InstMapDelta), ( instmap_delta_is_reachable(InstMapDelta) -> @@ -459,44 +459,44 @@ call_gen__handle_return(ArgsInfos, GoalInfo, _NonLiveOutputs, ReturnInstMap, ; OkToDeleteAny = yes ), - code_info__clear_all_registers(OkToDeleteAny, !CI), - code_info__get_forward_live_vars(!.CI, Liveness), - call_gen__rebuild_registers(ArgsInfos, Liveness, OutputArgLocs, !CI), - code_info__generate_return_live_lvalues(!.CI, OutputArgLocs, + code_info.clear_all_registers(OkToDeleteAny, !CI), + code_info.get_forward_live_vars(!.CI, Liveness), + call_gen.rebuild_registers(ArgsInfos, Liveness, OutputArgLocs, !CI), + code_info.generate_return_live_lvalues(!.CI, OutputArgLocs, ReturnInstMap, OkToDeleteAny, ReturnLiveLvalues). -:- pred call_gen__find_nonlive_outputs(assoc_list(prog_var, arg_info)::in, +:- pred call_gen.find_nonlive_outputs(assoc_list(prog_var, arg_info)::in, set(prog_var)::in, set(prog_var)::in, set(prog_var)::out) is det. -call_gen__find_nonlive_outputs([], _, NonLiveOutputs, NonLiveOutputs). -call_gen__find_nonlive_outputs([Var - arg_info(_ArgLoc, Mode) | Args], +call_gen.find_nonlive_outputs([], _, NonLiveOutputs, NonLiveOutputs). +call_gen.find_nonlive_outputs([Var - arg_info(_ArgLoc, Mode) | Args], Liveness, NonLiveOutputs0, NonLiveOutputs) :- ( Mode = top_out -> - ( set__member(Var, Liveness) -> + ( set.member(Var, Liveness) -> NonLiveOutputs1 = NonLiveOutputs0 ; - set__insert(NonLiveOutputs0, Var, NonLiveOutputs1) + set.insert(NonLiveOutputs0, Var, NonLiveOutputs1) ) ; NonLiveOutputs1 = NonLiveOutputs0 ), - call_gen__find_nonlive_outputs(Args, Liveness, + call_gen.find_nonlive_outputs(Args, Liveness, NonLiveOutputs1, NonLiveOutputs). -:- pred call_gen__rebuild_registers(assoc_list(prog_var, arg_info)::in, +:- pred call_gen.rebuild_registers(assoc_list(prog_var, arg_info)::in, set(prog_var)::in, assoc_list(prog_var, arg_loc)::out, code_info::in, code_info::out) is det. -call_gen__rebuild_registers([], _, [], !CI). -call_gen__rebuild_registers([Var - arg_info(ArgLoc, Mode) | Args], Liveness, +call_gen.rebuild_registers([], _, [], !CI). +call_gen.rebuild_registers([Var - arg_info(ArgLoc, Mode) | Args], Liveness, OutputArgLocs, !CI) :- - call_gen__rebuild_registers(Args, Liveness, OutputArgLocs1, !CI), + call_gen.rebuild_registers(Args, Liveness, OutputArgLocs1, !CI), ( Mode = top_out, - set__member(Var, Liveness) + set.member(Var, Liveness) -> - code_util__arg_loc_to_register(ArgLoc, Register), - code_info__set_var_location(Var, Register, !CI), + code_util.arg_loc_to_register(ArgLoc, Register), + code_info.set_var_location(Var, Register, !CI), OutputArgLocs = [Var - ArgLoc | OutputArgLocs1] ; OutputArgLocs = OutputArgLocs1 @@ -504,12 +504,12 @@ call_gen__rebuild_registers([Var - arg_info(ArgLoc, Mode) | Args], Liveness, %---------------------------------------------------------------------------% -call_gen__generate_builtin(CodeModel, PredId, ProcId, Args, Code, !CI) :- - code_info__get_module_info(!.CI, ModuleInfo), +call_gen.generate_builtin(CodeModel, PredId, ProcId, Args, Code, !CI) :- + code_info.get_module_info(!.CI, ModuleInfo), predicate_module(ModuleInfo, PredId, ModuleName), predicate_name(ModuleInfo, PredId, PredName), ( - builtin_ops__translate_builtin(ModuleName, PredName, + builtin_ops.translate_builtin(ModuleName, PredName, ProcId, Args, SimpleCode0) -> SimpleCode = SimpleCode0 @@ -523,7 +523,7 @@ call_gen__generate_builtin(CodeModel, PredId, ProcId, Args, Code, !CI) :- CodeModel = model_det, ( SimpleCode = assign(Var, AssignExpr), - call_gen__generate_assign_builtin(Var, AssignExpr, Code, !CI) + call_gen.generate_assign_builtin(Var, AssignExpr, Code, !CI) ; SimpleCode = ref_assign(AddrVar, ValueVar), produce_variable(AddrVar, AddrVarCode, AddrRval, !CI), @@ -538,9 +538,9 @@ call_gen__generate_builtin(CodeModel, PredId, ProcId, Args, Code, !CI) :- CodeModel = model_semi, ( SimpleCode = test(TestExpr), - call_gen__generate_simple_test(TestExpr, Rval, + call_gen.generate_simple_test(TestExpr, Rval, ArgCode, !CI), - code_info__fail_if_rval_is_false(Rval, TestCode, !CI), + code_info.fail_if_rval_is_false(Rval, TestCode, !CI), Code = tree(ArgCode, TestCode) ; SimpleCode = assign(_, _), @@ -554,14 +554,14 @@ call_gen__generate_builtin(CodeModel, PredId, ProcId, Args, Code, !CI) :- unexpected(this_file, "nondet builtin predicate") ). -:- pred call_gen__generate_assign_builtin(prog_var::in, +:- pred call_gen.generate_assign_builtin(prog_var::in, simple_expr(prog_var)::in, code_tree::out, code_info::in, code_info::out) is det. -call_gen__generate_assign_builtin(Var, AssignExpr, Code, !CI) :- - ( code_info__variable_is_forward_live(!.CI, Var) -> +call_gen.generate_assign_builtin(Var, AssignExpr, Code, !CI) :- + ( code_info.variable_is_forward_live(!.CI, Var) -> Rval = convert_simple_expr(AssignExpr), - code_info__assign_expr_to_var(Var, Rval, Code, !CI) + code_info.assign_expr_to_var(Var, Rval, Code, !CI) ; Code = empty ). @@ -576,32 +576,32 @@ convert_simple_expr(unary(UnOp, Expr)) = convert_simple_expr(binary(BinOp, Expr1, Expr2)) = binop(BinOp, convert_simple_expr(Expr1), convert_simple_expr(Expr2)). -:- pred call_gen__generate_simple_test( +:- pred call_gen.generate_simple_test( simple_expr(prog_var)::in(simple_test_expr), rval::out, code_tree::out, code_info::in, code_info::out) is det. -call_gen__generate_simple_test(TestExpr, Rval, ArgCode, !CI) :- +call_gen.generate_simple_test(TestExpr, Rval, ArgCode, !CI) :- ( TestExpr = binary(BinOp, X0, Y0), X1 = convert_simple_expr(X0), Y1 = convert_simple_expr(Y0), - call_gen__generate_builtin_arg(X1, X, CodeX, !CI), - call_gen__generate_builtin_arg(Y1, Y, CodeY, !CI), + call_gen.generate_builtin_arg(X1, X, CodeX, !CI), + call_gen.generate_builtin_arg(Y1, Y, CodeY, !CI), Rval = binop(BinOp, X, Y), ArgCode = tree(CodeX, CodeY) ; TestExpr = unary(UnOp, X0), X1 = convert_simple_expr(X0), - call_gen__generate_builtin_arg(X1, X, ArgCode, !CI), + call_gen.generate_builtin_arg(X1, X, ArgCode, !CI), Rval = unop(UnOp, X) ). -:- pred call_gen__generate_builtin_arg(rval::in, rval::out, code_tree::out, +:- pred call_gen.generate_builtin_arg(rval::in, rval::out, code_tree::out, code_info::in, code_info::out) is det. -call_gen__generate_builtin_arg(Rval0, Rval, Code, !CI) :- +call_gen.generate_builtin_arg(Rval0, Rval, Code, !CI) :- ( Rval0 = var(Var) -> - code_info__produce_variable(Var, Code, Rval, !CI) + code_info.produce_variable(Var, Code, Rval, !CI) ; Rval = Rval0, Code = empty @@ -610,18 +610,18 @@ call_gen__generate_builtin_arg(Rval0, Rval, Code, !CI) :- %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% -call_gen__input_arg_locs([], []). -call_gen__input_arg_locs([Var - arg_info(Loc, Mode) | Args], Vs) :- - call_gen__input_arg_locs(Args, Vs0), +call_gen.input_arg_locs([], []). +call_gen.input_arg_locs([Var - arg_info(Loc, Mode) | Args], Vs) :- + call_gen.input_arg_locs(Args, Vs0), ( Mode = top_in -> Vs = [Var - Loc | Vs0] ; Vs = Vs0 ). -call_gen__output_arg_locs([], []). -call_gen__output_arg_locs([Var - arg_info(Loc, Mode) | Args], Vs) :- - call_gen__output_arg_locs(Args, Vs0), +call_gen.output_arg_locs([], []). +call_gen.output_arg_locs([Var - arg_info(Loc, Mode) | Args], Vs) :- + call_gen.output_arg_locs(Args, Vs0), ( Mode = top_out -> Vs = [Var - Loc | Vs0] ; @@ -630,12 +630,12 @@ call_gen__output_arg_locs([Var - arg_info(Loc, Mode) | Args], Vs) :- %---------------------------------------------------------------------------% -:- pred call_gen__generate_call_vn_livevals(list(arg_loc)::in, +:- pred call_gen.generate_call_vn_livevals(list(arg_loc)::in, set(prog_var)::in, code_tree::out, code_info::in, code_info::out) is det. -call_gen__generate_call_vn_livevals(InputArgLocs, OutputArgs, Code, !CI) :- - code_info__generate_call_vn_livevals(!.CI, InputArgLocs, OutputArgs, +call_gen.generate_call_vn_livevals(InputArgLocs, OutputArgs, Code, !CI) :- + code_info.generate_call_vn_livevals(!.CI, InputArgLocs, OutputArgs, LiveVals), Code = node([ livevals(LiveVals) - "" diff --git a/compiler/check_typeclass.m b/compiler/check_typeclass.m index 4c6fb1875..00e331e57 100644 --- a/compiler/check_typeclass.m +++ b/compiler/check_typeclass.m @@ -64,7 +64,7 @@ %---------------------------------------------------------------------------% -:- module check_hlds__check_typeclass. +:- module check_hlds.check_typeclass. :- interface. :- import_module hlds.hlds_module. @@ -73,9 +73,8 @@ :- import_module bool. :- import_module io. -:- pred check_typeclass__check_typeclasses(make_hlds_qual_info::in, - make_hlds_qual_info::out, module_info::in, module_info::out, bool::out, - io::di, io::uo) is det. +:- pred check_typeclasses(make_hlds_qual_info::in, make_hlds_qual_info::out, + module_info::in, module_info::out, bool::out, io::di, io::uo) is det. %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% @@ -121,10 +120,10 @@ %---------------------------------------------------------------------------% -check_typeclass__check_typeclasses(!QualInfo, !ModuleInfo, FoundError, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), +check_typeclasses(!QualInfo, !ModuleInfo, FoundError, !IO) :- + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Checking typeclass instances...\n", !IO), - check_typeclass__check_instance_decls(!QualInfo, !ModuleInfo, + check_typeclass.check_instance_decls(!QualInfo, !ModuleInfo, FoundInstanceError, !IO), maybe_write_string(Verbose, "% Checking for cyclic classes...\n", !IO), @@ -149,32 +148,30 @@ check_typeclass__check_typeclasses(!QualInfo, !ModuleInfo, FoundError, !IO) :- :- type error_message == pair(prog_context, list(format_component)). :- type error_messages == list(error_message). -:- pred check_typeclass__check_instance_decls(make_hlds_qual_info::in, - make_hlds_qual_info::out, module_info::in, module_info::out, - bool::out, io::di, io::uo) is det. +:- pred check_instance_decls(make_hlds_qual_info::in, make_hlds_qual_info::out, + module_info::in, module_info::out, bool::out, io::di, io::uo) is det. -check_typeclass__check_instance_decls(!QualInfo, !ModuleInfo, FoundError, - !IO) :- +check_instance_decls(!QualInfo, !ModuleInfo, FoundError, !IO) :- module_info_get_class_table(!.ModuleInfo, ClassTable), module_info_get_instance_table(!.ModuleInfo, InstanceTable0), - map__to_assoc_list(InstanceTable0, InstanceList0), - list__map_foldl2(check_one_class(ClassTable), InstanceList0, + map.to_assoc_list(InstanceTable0, InstanceList0), + list.map_foldl2(check_one_class(ClassTable), InstanceList0, InstanceList, check_tc_info([], !.ModuleInfo, !.QualInfo), check_tc_info(Errors, !:ModuleInfo, !:QualInfo), !IO), ( Errors = [], - map__from_assoc_list(InstanceList, InstanceTable), + map.from_assoc_list(InstanceList, InstanceTable), module_info_set_instance_table(InstanceTable, !ModuleInfo), FoundError = no ; Errors = [_ | _], - list__reverse(Errors, ErrorList), + list.reverse(Errors, ErrorList), WriteError = (pred(E::in, IO0::di, IO::uo) is det :- E = ErrorContext - ErrorPieces, write_error_pieces(ErrorContext, 0, ErrorPieces, IO0, IO) ), - list__foldl(WriteError, ErrorList, !IO), - io__set_exit_status(1, !IO), + list.foldl(WriteError, ErrorList, !IO), + io.set_exit_status(1, !IO), FoundError = yes ). @@ -196,7 +193,7 @@ check_typeclass__check_instance_decls(!QualInfo, !ModuleInfo, FoundError, check_one_class(ClassTable, ClassId - InstanceDefns0, ClassId - InstanceDefns, !CheckTCInfo, !IO) :- - map__lookup(ClassTable, ClassId, ClassDefn), + map.lookup(ClassTable, ClassId, ClassDefn), ClassDefn = hlds_class_defn(ImportStatus, SuperClasses, _FunDeps, _Ancestors, ClassVars, _Kinds, Interface, ClassInterface, ClassVarSet, TermContext), @@ -216,11 +213,11 @@ check_one_class(ClassTable, ClassId - InstanceDefns0, ; solutions( ( pred(PredId::out) is nondet :- - list__member(ClassProc, ClassInterface), + list.member(ClassProc, ClassInterface), ClassProc = hlds_class_proc(PredId, _) ), PredIds), - list__map_foldl2( + list.map_foldl2( check_class_instance(ClassId, SuperClasses, ClassVars, ClassInterface, Interface, ClassVarSet, PredIds), InstanceDefns0, InstanceDefns, @@ -265,7 +262,7 @@ check_class_instance(ClassId, SuperClasses, Vars, HLDSClassInterface, :- pred check_concrete_class_instance(class_id::in, list(tvar)::in, hlds_class_interface::in, class_interface::in, - list(pred_id)::in, term__context::in, + list(pred_id)::in, term.context::in, instance_methods::in, hlds_instance_defn::in, hlds_instance_defn::out, error_messages::in, error_messages::out, module_info::in, module_info::out, @@ -288,7 +285,7 @@ check_concrete_class_instance(ClassId, Vars, HLDSClassInterface, ClassInterface = concrete(_), InstanceCheckInfo0 = instance_check_info(!.InstanceDefn, [], !.Errors, !.ModuleInfo, !.QualInfo), - list__foldl2(check_instance_pred(ClassId, Vars, HLDSClassInterface), + list.foldl2(check_instance_pred(ClassId, Vars, HLDSClassInterface), PredIds, InstanceCheckInfo0, InstanceCheckInfo, !IO), InstanceCheckInfo = instance_check_info(!:InstanceDefn, RevInstanceMethods, !:Errors, !:ModuleInfo, !:QualInfo), @@ -308,7 +305,7 @@ check_concrete_class_instance(ClassId, Vars, HLDSClassInterface, % Make sure the list of instance methods is in the same order % as the methods in the class definition. intermod.m relies on this. - OrderedInstanceMethods = list__reverse(RevInstanceMethods), + OrderedInstanceMethods = list.reverse(RevInstanceMethods), !:InstanceDefn = !.InstanceDefn ^ instance_hlds_interface := MaybePredProcs, @@ -344,11 +341,11 @@ check_for_bogus_methods(InstanceMethods, ClassId, ClassPredIds, Context, predicate_table_search_pf_sym_arity(PredTable, is_fully_qualified, MethodPredOrFunc, MethodName, MethodPredArity, MatchingPredIds), some [PredId] ( - list__member(PredId, MatchingPredIds), - list__member(PredId, ClassPredIds) + list.member(PredId, MatchingPredIds), + list.member(PredId, ClassPredIds) ) ), - list__filter(DefnIsOK, InstanceMethods, _OKInstanceMethods, + list.filter(DefnIsOK, InstanceMethods, _OKInstanceMethods, BogusInstanceMethods), ( BogusInstanceMethods = [] @@ -365,7 +362,7 @@ check_for_bogus_methods(InstanceMethods, ClassId, ClassPredIds, Context, ], ErrorMsgBody0 = list.map(format_method_name, BogusInstanceMethods), ErrorMsgBody1 = list.condense(ErrorMsgBody0), - ErrorMsgBody = list__append(ErrorMsgBody1, [suffix(".")]), + ErrorMsgBody = list.append(ErrorMsgBody1, [suffix(".")]), NewError = Context - ( ErrorMsgStart ++ ErrorMsgBody ), !:Errors = [NewError | !.Errors] ). @@ -433,7 +430,7 @@ check_instance_pred(ClassId, ClassVars, ClassInterface, PredId, !.InstanceCheckInfo = instance_check_info(InstanceDefn0, OrderedMethods0, Errors0, ModuleInfo0, QualInfo0), solutions((pred(ProcId::out) is nondet :- - list__member(ClassProc, ClassInterface), + list.member(ClassProc, ClassInterface), ClassProc = hlds_class_proc(PredId, ProcId) ), ProcIds), module_info_pred_info(ModuleInfo0, PredId, PredInfo), @@ -459,9 +456,9 @@ check_instance_pred(ClassId, ClassVars, ClassInterface, PredId, PredOrFunc = pred_info_is_pred_or_func(PredInfo), adjust_func_arity(PredOrFunc, Arity, PredArity), pred_info_procedures(PredInfo, ProcTable), - list__map( + list.map( (pred(TheProcId::in, ModesAndDetism::out) is det :- - map__lookup(ProcTable, TheProcId, ProcInfo), + map.lookup(ProcTable, TheProcId, ProcInfo), proc_info_argmodes(ProcInfo, Modes), % If the determinism declaration on the method was omitted, % then make_hlds will have already issued an error message, @@ -531,11 +528,10 @@ check_instance_pred_procs(ClassId, ClassVars, MethodName, Markers, MakeClassProc = (pred(TheProcId::in, PredProcId::out) is det :- PredProcId = hlds_class_proc(InstancePredId, TheProcId) ), - list__map(MakeClassProc, InstanceProcIds, InstancePredProcs1), + list.map(MakeClassProc, InstanceProcIds, InstancePredProcs1), ( MaybeInstancePredProcs = yes(InstancePredProcs0), - list__append(InstancePredProcs0, - InstancePredProcs1, InstancePredProcs) + InstancePredProcs = InstancePredProcs0 ++ InstancePredProcs1 ; MaybeInstancePredProcs = no, InstancePredProcs = InstancePredProcs1 @@ -552,10 +548,10 @@ check_instance_pred_procs(ClassId, ClassVars, MethodName, Markers, sym_name_to_string(MethodName, MethodNameString), sym_name_to_string(ClassName, ClassNameString), PredOrFuncString = pred_or_func_to_string(PredOrFunc), - string__int_to_string(Arity, ArityString), + string.int_to_string(Arity, ArityString), InstanceTypesString = mercury_type_list_to_string(InstanceVarSet, InstanceTypes), - string__append_list([ + string.append_list([ "In instance declaration for `", ClassNameString, "(", InstanceTypesString, ")': ", "multiple implementations of type class ", @@ -566,15 +562,15 @@ check_instance_pred_procs(ClassId, ClassVars, MethodName, Markers, Heading = [I1Context - [words("First definition appears here.")], InstanceContext - [words(ErrorHeader)]], - list__map((pred(Definition::in, ContextAndError::out) is det :- + list.map((pred(Definition::in, ContextAndError::out) is det :- Definition = instance_method(_, _, _, _, TheContext), Error = [words("Subsequent definition appears here.")], ContextAndError = TheContext - Error ), [I2 | Is], SubsequentErrors), % Errors are built up in reverse. - list__append(SubsequentErrors, Heading, NewErrors), - list__append(NewErrors, Errors0, Errors), + list.append(SubsequentErrors, Heading, NewErrors), + list.append(NewErrors, Errors0, Errors), Info = instance_method_info(ModuleInfo, QualInfo, PredName, Arity, ExistQVars, ArgTypes, ClassContext, ArgModes, Errors, ArgTypeVars, Status, PredOrFunc) @@ -618,7 +614,7 @@ get_matching_instance_defns(concrete(InstanceMethods), PredOrFunc, MethodName, MethodArity, ResultList) :- % First find the instance method definitions that match this % predicate/function's name and arity - list__filter( + list.filter( (pred(Method::in) is semidet :- Method = instance_method(PredOrFunc, MethodName, _MethodDefn, MethodArity, _Context) @@ -628,7 +624,7 @@ get_matching_instance_defns(concrete(InstanceMethods), PredOrFunc, MethodName, MatchingMethods = [First, _Second | _], First = instance_method(_, _, _, _, FirstContext), \+ ( - list__member(DefnViaName, MatchingMethods), + list.member(DefnViaName, MatchingMethods), DefnViaName = instance_method(_, _, name(_), _, _) ) -> @@ -638,8 +634,8 @@ get_matching_instance_defns(concrete(InstanceMethods), PredOrFunc, MethodName, MethodToClause = (pred(Method::in, Clauses::out) is semidet :- Method = instance_method(_, _, Defn, _, _), Defn = clauses(Clauses)), - list__filter_map(MethodToClause, MatchingMethods, ClausesList), - list__condense(ClausesList, FlattenedClauses), + list.filter_map(MethodToClause, MatchingMethods, ClausesList), + list.condense(ClausesList, FlattenedClauses), CombinedMethod = instance_method(PredOrFunc, MethodName, clauses(FlattenedClauses), MethodArity, FirstContext), ResultList = [CombinedMethod] @@ -675,7 +671,7 @@ produce_auxiliary_procs(ClassId, ClassVars, Markers0, % Work out what the type variables are bound to for this % instance, and update the class types appropriately. - map__from_corresponding_lists(ClassVars, InstanceTypes1, TypeSubst), + map.from_corresponding_lists(ClassVars, InstanceTypes1, TypeSubst), apply_subst_to_type_list(TypeSubst, ArgTypes0, ArgTypes1), apply_subst_to_prog_constraints(TypeSubst, ClassMethodClassContext0, ClassMethodClassContext1), @@ -685,14 +681,14 @@ produce_auxiliary_procs(ClassId, ClassVars, Markers0, % the instance constraints. (Type variables in the existq_tvars must % occur either in the argument types or in the class method context; % type variables in the instance types must appear in the arguments.) - prog_type__vars_list(ArgTypes1, ArgTVars), + prog_type.vars_list(ArgTypes1, ArgTVars), prog_constraints_get_tvars(ClassMethodClassContext1, MethodContextTVars), constraint_list_get_tvars(InstanceConstraints1, InstanceTVars), - list__condense([ArgTVars, MethodContextTVars, InstanceTVars], VarsToKeep0), - list__sort_and_remove_dups(VarsToKeep0, VarsToKeep), + list.condense([ArgTVars, MethodContextTVars, InstanceTVars], VarsToKeep0), + list.sort_and_remove_dups(VarsToKeep0, VarsToKeep), % Project away the unwanted type variables. - varset__squash(TVarSet1, VarsToKeep, TVarSet, SquashSubst), + varset.squash(TVarSet1, VarsToKeep, TVarSet, SquashSubst), apply_variable_renaming_to_type_list(SquashSubst, ArgTypes1, ArgTypes), apply_variable_renaming_to_prog_constraints(SquashSubst, ClassMethodClassContext1, ClassMethodClassContext), @@ -706,13 +702,13 @@ produce_auxiliary_procs(ClassId, ClassVars, Markers0, % from the class method. This allows an instance method to have constraints % on it which are not part of the instance declaration as a whole. ClassMethodClassContext = constraints(UnivConstraints1, ExistConstraints), - list__append(InstanceConstraints, UnivConstraints1, UnivConstraints), + list.append(InstanceConstraints, UnivConstraints1, UnivConstraints), ClassContext = constraints(UnivConstraints, ExistConstraints), % Introduce a new predicate which calls the implementation % given in the instance declaration. - map__init(Proofs), - map__init(ConstraintMap), + map.init(Proofs), + map.init(ConstraintMap), add_marker(class_instance_method, Markers0, Markers1), ( InstancePredDefn = name(_) -> % For instance methods which are defined using the named syntax @@ -754,7 +750,7 @@ produce_auxiliary_procs(ClassId, ClassVars, Markers0, MaybeDet, Context, address_is_taken, OldPredInfo, NewPredInfo, NewProcId) ), - list__map_foldl(AddProc, ArgModes, InstanceProcIds, PredInfo1, PredInfo), + list.map_foldl(AddProc, ArgModes, InstanceProcIds, PredInfo1, PredInfo), module_info_get_predicate_table(ModuleInfo1, PredicateTable1), module_info_get_partial_qualifier_info(ModuleInfo1, PQInfo), @@ -784,10 +780,10 @@ make_introduced_pred_name(ClassId, MethodName, Arity, InstanceTypes, sym_name_to_string(ClassName, "__", ClassNameString), sym_name_to_string(MethodName, "__", MethodNameString), % Perhaps we should include the arity in this mangled string? - string__int_to_string(Arity, ArityString), + string.int_to_string(Arity, ArityString), make_instance_string(InstanceTypes, InstanceString), - string__append_list( - [check_typeclass__introduced_pred_name_prefix, + string.append_list( + [introduced_pred_name_prefix, ClassNameString, "____", InstanceString, "____", MethodNameString, "_", @@ -798,9 +794,9 @@ make_introduced_pred_name(ClassId, MethodName, Arity, InstanceTypes, % The prefix added to the class method name for the predicate % used to call a class method for a specific instance. % -:- func check_typeclass__introduced_pred_name_prefix = string. +:- func introduced_pred_name_prefix = string. -check_typeclass__introduced_pred_name_prefix = "ClassMethod_for_". +introduced_pred_name_prefix = "ClassMethod_for_". %---------------------------------------------------------------------------% @@ -828,7 +824,7 @@ check_superclass_conformance(ClassId, ProgSuperClasses0, ClassVars0, apply_variable_renaming_to_tvar_list(Renaming, ClassVars0, ClassVars), % Calculate the bindings. - map__from_corresponding_lists(ClassVars, InstanceTypes, TypeSubst), + map.from_corresponding_lists(ClassVars, InstanceTypes, TypeSubst), module_info_get_class_table(ModuleInfo, ClassTable), module_info_get_instance_table(ModuleInfo, InstanceTable), @@ -850,8 +846,8 @@ check_superclass_conformance(ClassId, ProgSuperClasses0, ClassVars0, % Try to reduce the superclass constraints, using the declared instance % constraints and the usual context reduction rules. - map__init(ConstraintMap0), - typeclasses__reduce_context_by_rule_application(ClassTable, + map.init(ConstraintMap0), + typeclasses.reduce_context_by_rule_application(ClassTable, InstanceTable, SuperClassTable, ClassVars, TypeSubst, _, InstanceVarSet1, InstanceVarSet2, Proofs0, Proofs1, ConstraintMap0, _, @@ -871,7 +867,7 @@ check_superclass_conformance(ClassId, ProgSuperClasses0, ClassVars0, InstanceTypes), constraint_list_to_string(ClassVarSet, UnprovenConstraints, ConstraintsString), - string__append_list([ + string.append_list([ "In instance declaration for `", ClassNameString, "(", InstanceTypesString, ")': ", "superclass constraint(s) not satisfied: ", @@ -889,7 +885,7 @@ constraint_list_to_string(VarSet, [C | Cs], String) :- retrieve_prog_constraint(C, P), String0 = mercury_constraint_to_string(VarSet, P), constraint_list_to_string_2(VarSet, Cs, String1), - string__append_list(["`", String0, "'", String1], String). + string.append_list(["`", String0, "'", String1], String). :- pred constraint_list_to_string_2(tvarset::in, list(hlds_constraint)::in, string::out) is det. @@ -899,7 +895,7 @@ constraint_list_to_string_2(VarSet, [C | Cs], String) :- retrieve_prog_constraint(C, P), String0 = mercury_constraint_to_string(VarSet, P), constraint_list_to_string_2(VarSet, Cs, String1), - string__append_list([", `", String0, "'", String1], String). + string.append_list([", `", String0, "'", String1], String). %---------------------------------------------------------------------------% @@ -1042,7 +1038,7 @@ check_for_corresponding_instances_2(Concretes, ClassId, AbstractInstance, check_for_cyclic_classes(!ModuleInfo, Errors, !IO) :- module_info_get_class_table(!.ModuleInfo, ClassTable0), - ClassIds = map__keys(ClassTable0), + ClassIds = map.keys(ClassTable0), foldl3(find_cycles([]), ClassIds, ClassTable0, ClassTable, set.init, _, [], Cycles), ( @@ -1290,7 +1286,7 @@ report_range_restriction_error(ClassId, InstanceDefn, Vars, !IO) :- words(choose_number(Vars, "is", "are")), words("not in the domain.")], write_error_pieces(Context, 0, Msg, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). % Check the consistency of each (unordered) pair of instances. % @@ -1386,7 +1382,7 @@ report_consistency_error(ClassId, ClassDefn, InstanceA, InstanceB, FunDep, write_error_pieces(ContextA, 0, ErrorPiecesA, !IO), write_error_pieces(ContextB, 0, ErrorPiecesB, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %---------------------------------------------------------------------------% @@ -1631,7 +1627,7 @@ report_unbound_tvars_in_pred_context(Vars, PredInfo, !IO) :- ), write_error_pieces(Context, 0, Msg, !IO), maybe_report_unbound_tvars_explanation(Context, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred report_unbound_tvars_in_ctor_context(list(tvar)::in, type_ctor::in, hlds_type_defn::in, io::di, io::uo) is det. @@ -1656,7 +1652,7 @@ report_unbound_tvars_in_ctor_context(Vars, TypeCtor, TypeDefn, !IO) :- words("not determined by the constructor's argument types.")], write_error_pieces(Context, 0, Msg, !IO), maybe_report_unbound_tvars_explanation(Context, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred maybe_report_unbound_tvars_explanation(prog_context::in, io::di, io::uo) is det. diff --git a/compiler/clause_to_proc.m b/compiler/clause_to_proc.m index a6fa67558..d10cef194 100644 --- a/compiler/clause_to_proc.m +++ b/compiler/clause_to_proc.m @@ -6,7 +6,7 @@ % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% -:- module check_hlds__clause_to_proc. +:- module check_hlds.clause_to_proc. :- interface. :- import_module hlds.hlds_module. @@ -90,9 +90,9 @@ maybe_add_default_func_modes([], Preds, Preds). maybe_add_default_func_modes([PredId | PredIds], Preds0, Preds) :- - map__lookup(Preds0, PredId, PredInfo0), + map.lookup(Preds0, PredId, PredInfo0), maybe_add_default_func_mode(PredInfo0, PredInfo, _), - map__det_update(Preds0, PredId, PredInfo, Preds1), + map.det_update(Preds0, PredId, PredInfo, Preds1), maybe_add_default_func_modes(PredIds, Preds1, Preds). maybe_add_default_func_mode(PredInfo0, PredInfo, MaybeProcId) :- @@ -103,7 +103,7 @@ maybe_add_default_func_mode(PredInfo0, PredInfo, MaybeProcId) :- % Is this a function with no modes? % PredOrFunc = function, - map__is_empty(Procs0) + map.is_empty(Procs0) -> % % If so, add a default mode of @@ -117,13 +117,13 @@ maybe_add_default_func_mode(PredInfo0, PredInfo, MaybeProcId) :- FuncArity = PredArity - 1, in_mode(InMode), out_mode(OutMode), - list__duplicate(FuncArity, InMode, FuncArgModes), + list.duplicate(FuncArity, InMode, FuncArgModes), FuncRetMode = OutMode, - list__append(FuncArgModes, [FuncRetMode], PredArgModes), + list.append(FuncArgModes, [FuncRetMode], PredArgModes), Determinism = det, pred_info_context(PredInfo0, Context), MaybePredArgLives = no, - varset__init(InstVarSet), + varset.init(InstVarSet), % No inst_vars in default func mode. add_new_proc(InstVarSet, PredArity, PredArgModes, yes(PredArgModes), MaybePredArgLives, yes(Determinism), @@ -136,25 +136,25 @@ maybe_add_default_func_mode(PredInfo0, PredInfo, MaybeProcId) :- copy_module_clauses_to_procs(PredIds, !ModuleInfo) :- module_info_preds(!.ModuleInfo, PredTable0), - list__foldl(copy_pred_clauses_to_procs, PredIds, PredTable0, PredTable), + list.foldl(copy_pred_clauses_to_procs, PredIds, PredTable0, PredTable), module_info_set_preds(PredTable, !ModuleInfo). % For each mode of the given predicate, copy the clauses relevant % to the mode and the current backend to the proc_info. % % This is not the only predicate in the compiler that does this task; - % the other is polymorphism__process_proc. + % the other is polymorphism.process_proc. % :- pred copy_pred_clauses_to_procs(pred_id::in, pred_table::in, pred_table::out) is det. copy_pred_clauses_to_procs(PredId, !PredTable) :- - map__lookup(!.PredTable, PredId, PredInfo0), + map.lookup(!.PredTable, PredId, PredInfo0), ( do_copy_clauses_to_procs(PredInfo0) -> copy_clauses_to_procs(PredInfo0, PredInfo), - map__det_update(!.PredTable, PredId, PredInfo, !:PredTable) + map.det_update(!.PredTable, PredId, PredInfo, !:PredTable) ; true ). @@ -181,9 +181,9 @@ copy_clauses_to_procs(!PredInfo) :- copy_clauses_to_procs_2([], _, !Procs). copy_clauses_to_procs_2([ProcId | ProcIds], ClausesInfo, !Procs) :- - map__lookup(!.Procs, ProcId, Proc0), + map.lookup(!.Procs, ProcId, Proc0), copy_clauses_to_proc(ProcId, ClausesInfo, Proc0, Proc), - map__det_update(!.Procs, ProcId, Proc, !:Procs), + map.det_update(!.Procs, ProcId, Proc, !:Procs), copy_clauses_to_procs_2(ProcIds, ClausesInfo, !Procs). copy_clauses_to_proc(ProcId, ClausesInfo, !Proc) :- @@ -198,9 +198,9 @@ copy_clauses_to_proc(ProcId, ClausesInfo, !Proc) :- % % Use the original variable names for the headvars % of foreign_proc clauses, not the introduced - % `HeadVar__n' names. + % `HeadVar.n' names. % - VarSet = list__foldl(set_arg_names, Args, VarSet0), + VarSet = list.foldl(set_arg_names, Args, VarSet0), expect(unify(ExtraArgs, []), this_file, "copy_clauses_to_proc: extra_args") ; @@ -232,7 +232,7 @@ copy_clauses_to_proc(ProcId, ClausesInfo, !Proc) :- % % The non-local vars are just the head variables. % - set__list_to_set(HeadVars, NonLocalVars), + set.list_to_set(HeadVars, NonLocalVars), goal_info_set_nonlocals(NonLocalVars, GoalInfo1, GoalInfo2), % @@ -240,8 +240,8 @@ copy_clauses_to_proc(ProcId, ClausesInfo, !Proc) :- % is impure/semipure. % ( contains_nonpure_goal(GoalList) -> - list__map(get_purity, GoalList, PurityList), - Purity = list__foldl(worst_purity, PurityList, purity_pure), + list.map(get_purity, GoalList, PurityList), + Purity = list.foldl(worst_purity, PurityList, purity_pure), add_goal_info_purity_feature(Purity, GoalInfo2, GoalInfo) ; GoalInfo2 = GoalInfo @@ -268,7 +268,7 @@ set_arg_names(Arg, Vars0) = Vars :- MaybeNameMode = foreign_arg_maybe_name_mode(Arg), ( MaybeNameMode = yes(Name - _), - varset__name_var(Vars0, Var, Name, Vars) + varset.name_var(Vars0, Var, Name, Vars) ; MaybeNameMode = no, Vars = Vars0 @@ -288,7 +288,7 @@ select_matching_clauses([Clause | Clauses], ProcId, MatchingClauses) :- % An empty list here means that the clause applies to all procs. ( ProcIds = [] -> MatchingClauses = [Clause | MatchingClauses1] - ; list__member(ProcId, ProcIds) -> + ; list.member(ProcId, ProcIds) -> MatchingClauses = [Clause | MatchingClauses1] ; MatchingClauses = MatchingClauses1 @@ -302,13 +302,13 @@ get_clause_goals([Clause | Clauses], Goals) :- get_clause_goals(Clauses, Goals1), Clause = clause(_, Goal, _, _), goal_to_disj_list(Goal, GoalList), - list__append(GoalList, Goals1, Goals). + list.append(GoalList, Goals1, Goals). %-----------------------------------------------------------------------------% introduce_exists_casts(PredIds, !ModuleInfo) :- module_info_preds(!.ModuleInfo, PredTable0), - list__foldl(introduce_exists_casts_pred(!.ModuleInfo), PredIds, + list.foldl(introduce_exists_casts_pred(!.ModuleInfo), PredIds, PredTable0, PredTable), module_info_set_preds(PredTable, !ModuleInfo). @@ -316,11 +316,11 @@ introduce_exists_casts(PredIds, !ModuleInfo) :- pred_table::in, pred_table::out) is det. introduce_exists_casts_pred(ModuleInfo, PredId, !PredTable) :- - map__lookup(!.PredTable, PredId, PredInfo0), + map.lookup(!.PredTable, PredId, PredInfo0), ( % Optimise the common case. pred_info_get_existq_tvar_binding(PredInfo0, Subn), - \+ map__is_empty(Subn), + \+ map.is_empty(Subn), % Only process preds for which we copied clauses to procs. do_copy_clauses_to_procs(PredInfo0) @@ -330,7 +330,7 @@ introduce_exists_casts_pred(ModuleInfo, PredId, !PredTable) :- introduce_exists_casts_procs(ModuleInfo, PredInfo0, ProcIds, Procs0, Procs), pred_info_set_procedures(Procs, PredInfo0, PredInfo), - svmap__det_update(PredId, PredInfo, !PredTable) + svmap.det_update(PredId, PredInfo, !PredTable) ; true ). @@ -341,9 +341,9 @@ introduce_exists_casts_pred(ModuleInfo, PredId, !PredTable) :- introduce_exists_casts_procs(_, _, [], !Procs). introduce_exists_casts_procs(ModuleInfo, PredInfo, [ProcId | ProcIds], !Procs) :- - map__lookup(!.Procs, ProcId, ProcInfo0), + map.lookup(!.Procs, ProcId, ProcInfo0), introduce_exists_casts_proc(ModuleInfo, PredInfo, ProcInfo0, ProcInfo), - svmap__det_update(ProcId, ProcInfo, !Procs), + svmap.det_update(ProcId, ProcInfo, !Procs), introduce_exists_casts_procs(ModuleInfo, PredInfo, ProcIds, !Procs). introduce_exists_casts_proc(ModuleInfo, PredInfo, !ProcInfo) :- @@ -351,7 +351,7 @@ introduce_exists_casts_proc(ModuleInfo, PredInfo, !ProcInfo) :- pred_info_get_existq_tvar_binding(PredInfo, Subn), pred_info_get_class_context(PredInfo, PredConstraints), OrigArity = pred_info_orig_arity(PredInfo), - NumExtraHeadVars = list__length(ArgTypes) - OrigArity, + NumExtraHeadVars = list.length(ArgTypes) - OrigArity, proc_info_varset(!.ProcInfo, VarSet0), proc_info_vartypes(!.ProcInfo, VarTypes0), @@ -361,11 +361,11 @@ introduce_exists_casts_proc(ModuleInfo, PredInfo, !ProcInfo) :- proc_info_argmodes(!.ProcInfo, ArgModes), ( - list__split_list(NumExtraHeadVars, ArgTypes, ExtraArgTypes0, + list.split_list(NumExtraHeadVars, ArgTypes, ExtraArgTypes0, OrigArgTypes0), - list__split_list(NumExtraHeadVars, HeadVars0, ExtraHeadVars0, + list.split_list(NumExtraHeadVars, HeadVars0, ExtraHeadVars0, OrigHeadVars0), - list__split_list(NumExtraHeadVars, ArgModes, ExtraArgModes0, + list.split_list(NumExtraHeadVars, ArgModes, ExtraArgModes0, OrigArgModes0) -> ExtraArgTypes = ExtraArgTypes0, @@ -392,10 +392,10 @@ introduce_exists_casts_proc(ModuleInfo, PredInfo, !ProcInfo) :- % type_infos and typeclass_infos can be looked up. When the arguments % of these two types are removed, we will no longer need to do this. % - map__from_corresponding_lists(ExtraHeadVars1, ExtraArgTypes, + map.from_corresponding_lists(ExtraHeadVars1, ExtraArgTypes, ExternalTypes), ExistConstraints = PredConstraints ^ exist_constraints, - assoc_list__from_corresponding_lists(ExtraArgModes, ExtraHeadVars1, + assoc_list.from_corresponding_lists(ExtraArgModes, ExtraHeadVars1, ExtraModesAndVars), introduce_exists_casts_extra(ModuleInfo, ExternalTypes, Subn, ExistConstraints, ExtraModesAndVars, ExtraHeadVars, VarSet1, VarSet, @@ -406,7 +406,7 @@ introduce_exists_casts_proc(ModuleInfo, PredInfo, !ProcInfo) :- goal_to_conj_list(Body0, Goals0), Goals = Goals0 ++ ExistsCastHeadGoals ++ ExistsCastExtraGoals, HeadVars = ExtraHeadVars ++ OrigHeadVars, - set__list_to_set(HeadVars, NonLocals), + set.list_to_set(HeadVars, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo), Body = conj(plain_conj, Goals) - GoalInfo, proc_info_set_body(VarSet, VarTypes, HeadVars, Body, RttiVarMaps, @@ -456,10 +456,10 @@ introduce_exists_casts_for_arg(ModuleInfo, Subn, ExternalType, ArgMode, % interface. InternalType \= ExternalType -> - term__context_init(Context), - svmap__det_update(HeadVar0, InternalType, !VarTypes), + term.context_init(Context), + svmap.det_update(HeadVar0, InternalType, !VarTypes), make_new_exist_cast_var(HeadVar0, HeadVar, !VarSet), - svmap__det_insert(HeadVar, ExternalType, !VarTypes), + svmap.det_insert(HeadVar, ExternalType, !VarTypes), mode_get_insts(ModuleInfo, ArgMode, _, Inst), generate_cast(exists_cast, HeadVar0, HeadVar, Inst, Inst, Context, ExtraGoal), @@ -494,15 +494,15 @@ introduce_exists_casts_extra(ModuleInfo, ExternalTypes, Subn, % because type_info/1 and typeclass_info/1 have types in their % respective arguments. % - map__lookup(ExternalTypes, Var0, ExternalType), + map.lookup(ExternalTypes, Var0, ExternalType), apply_rec_subst_to_type(Subn, ExternalType, InternalType), - svmap__det_update(Var0, InternalType, !VarTypes), + svmap.det_update(Var0, InternalType, !VarTypes), % Create the exists_cast goal. % - term__context_init(Context), + term.context_init(Context), make_new_exist_cast_var(Var0, Var, !VarSet), - svmap__det_insert(Var, ExternalType, !VarTypes), + svmap.det_insert(Var, ExternalType, !VarTypes), generate_cast(exists_cast, Var0, Var, Context, ExtraGoal), !:ExtraGoals = [ExtraGoal | !.ExtraGoals], @@ -574,10 +574,10 @@ maybe_add_type_info_locns([Arg | Args], Var, Num, !RttiVarMaps) :- prog_varset::in, prog_varset::out) is det. make_new_exist_cast_var(InternalVar, ExternalVar, !VarSet) :- - svvarset__new_var(ExternalVar, !VarSet), - varset__lookup_name(!.VarSet, InternalVar, InternalName), - string__append("ExistQ", InternalName, ExternalName), - svvarset__name_var(ExternalVar, ExternalName, !VarSet). + svvarset.new_var(ExternalVar, !VarSet), + varset.lookup_name(!.VarSet, InternalVar, InternalName), + string.append("ExistQ", InternalName, ExternalName), + svvarset.name_var(ExternalVar, ExternalName, !VarSet). %-----------------------------------------------------------------------------% diff --git a/compiler/code_gen.m b/compiler/code_gen.m index e8720b610..5e0c7266b 100644 --- a/compiler/code_gen.m +++ b/compiler/code_gen.m @@ -29,7 +29,7 @@ %---------------------------------------------------------------------------% -:- module ll_backend__code_gen. +:- module ll_backend.code_gen. :- interface. :- import_module hlds.code_model. @@ -142,19 +142,19 @@ generate_pred_list_code(ModuleInfo, !GlobalData, [PredId | PredIds], Predicates0, !IO), generate_pred_list_code(ModuleInfo, !GlobalData, PredIds, Predicates1, !IO), - list__append(Predicates0, Predicates1, Predicates). + list.append(Predicates0, Predicates1, Predicates). :- pred generate_maybe_pred_code(module_info::in, global_data::in, global_data::out, pred_id::in, list(c_procedure)::out, io::di, io::uo) is det. % Note that some of the logic of generate_maybe_pred_code is duplicated - % by mercury_compile__backend_pass_by_preds, so modifications here may + % by mercury_compile.backend_pass_by_preds, so modifications here may % also need to be repeated there. % generate_maybe_pred_code(ModuleInfo, !GlobalData, PredId, Predicates, !IO) :- module_info_preds(ModuleInfo, PredInfos), - map__lookup(PredInfos, PredId, PredInfo), + map.lookup(PredInfos, PredId, PredInfo), ProcIds = pred_info_non_imported_procids(PredInfo), ( ProcIds = [], @@ -162,13 +162,13 @@ generate_maybe_pred_code(ModuleInfo, !GlobalData, PredId, Predicates, !IO) :- ; ProcIds = [_ | _], module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, very_verbose, VeryVerbose), + globals.lookup_bool_option(Globals, very_verbose, VeryVerbose), ( VeryVerbose = yes, - io__write_string("% Generating code for ", !IO), - hlds_out__write_pred_id(ModuleInfo, PredId, !IO), - io__write_string("\n", !IO), - globals__lookup_bool_option(Globals, detailed_statistics, + io.write_string("% Generating code for ", !IO), + hlds_out.write_pred_id(ModuleInfo, PredId, !IO), + io.write_string("\n", !IO), + globals.lookup_bool_option(Globals, detailed_statistics, Statistics), maybe_report_stats(Statistics, !IO) ; @@ -199,7 +199,7 @@ generate_proc_list_code([], _PredId, _PredInfo, _ModuleInfo, generate_proc_list_code([ProcId | ProcIds], PredId, PredInfo, ModuleInfo0, !GlobalData, !Procs) :- pred_info_procedures(PredInfo, ProcInfos), - map__lookup(ProcInfos, ProcId, ProcInfo), + map.lookup(ProcInfos, ProcId, ProcInfo), generate_proc_code(PredInfo, ProcInfo, ProcId, PredId, ModuleInfo0, !GlobalData, Proc), !:Procs = [Proc | !.Procs], @@ -241,11 +241,11 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, MaybeFollowVars = yes(FollowVars) ; MaybeFollowVars = no, - map__init(FollowVarsMap), + map.init(FollowVarsMap), FollowVars = abs_follow_vars(FollowVarsMap, 1) ), module_info_get_globals(ModuleInfo, Globals), - continuation_info__basic_stack_layout_for_proc(PredInfo, Globals, + continuation_info.basic_stack_layout_for_proc(PredInfo, Globals, BasicStackLayout, ForceProcId), SaveSuccip = BasicStackLayout, @@ -263,12 +263,12 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, generate_category_code(CodeModel, Goal, OutsideResumePoint, TraceSlotInfo, CodeTree, MaybeTraceCallLabel, FrameInfo, CodeInfo0, CodeInfo), - code_info__get_max_reg_in_use_at_trace(CodeInfo, MaxTraceReg), - code_info__get_static_cell_info(CodeInfo, StaticCellInfo), + code_info.get_max_reg_in_use_at_trace(CodeInfo, MaxTraceReg), + code_info.get_static_cell_info(CodeInfo, StaticCellInfo), global_data_set_static_cell_info(StaticCellInfo, !GlobalData), - globals__get_trace_level(Globals, TraceLevel), - code_info__get_created_temp_frame(CodeInfo, CreatedTempFrame), + globals.get_trace_level(Globals, TraceLevel), + code_info.get_created_temp_frame(CodeInfo, CreatedTempFrame), EffTraceIsNone = eff_trace_level_is_none(PredInfo, ProcInfo, TraceLevel), ( @@ -289,10 +289,10 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, ), % Turn the code tree into a list. - tree__flatten(CodeTree, FragmentList), + tree.flatten(CodeTree, FragmentList), % Now the code is a list of code fragments (== list(instr)), % so we need to do a level of unwinding to get a flat list. - list__condense(FragmentList, Instructions0), + list.condense(FragmentList, Instructions0), FrameInfo = frame(TotalSlots, MaybeSuccipSlot, _), ( MaybeSuccipSlot = yes(SuccipSlot), @@ -313,10 +313,10 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, ) -> % Create the procedure layout structure. - RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, + RttiProcLabel = rtti.make_rtti_proc_label(ModuleInfo, PredId, ProcId), - code_info__get_layout_info(CodeInfo, InternalMap), - code_util__make_local_entry_label(ModuleInfo, PredId, ProcId, + code_info.get_layout_info(CodeInfo, InternalMap), + code_util.make_local_entry_label(ModuleInfo, PredId, ProcId, no, EntryLabel), proc_info_eval_method(ProcInfo, EvalMethod), proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap0), @@ -324,7 +324,7 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, proc_info_varset(ProcInfo, VarSet), proc_info_argmodes(ProcInfo, ArgModes), proc_info_vartypes(ProcInfo, VarTypes), - globals__get_trace_suppress(Globals, TraceSuppress), + globals.get_trace_suppress(Globals, TraceSuppress), ( eff_trace_needs_proc_body_reps(PredInfo, ProcInfo, TraceLevel, TraceSuppress) = yes @@ -360,7 +360,7 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, true ), - code_info__get_closure_layouts(CodeInfo, ClosureLayouts), + code_info.get_closure_layouts(CodeInfo, ClosureLayouts), global_data_add_new_closure_layouts(ClosureLayouts, !GlobalData), ProcLabel = make_proc_label(ModuleInfo, PredId, ProcId), maybe_add_tabling_pointer_var(ModuleInfo, PredId, ProcId, ProcInfo, @@ -369,7 +369,7 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, Name = pred_info_name(PredInfo), Arity = pred_info_orig_arity(PredInfo), - code_info__get_label_counter(CodeInfo, LabelCounter), + code_info.get_label_counter(CodeInfo, LabelCounter), ( EffTraceIsNone = yes, MayAlterRtti = may_alter_rtti @@ -378,7 +378,7 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, MayAlterRtti = must_not_alter_rtti ), - globals__lookup_bool_option(Globals, generate_bytecode, GenBytecode), + globals.lookup_bool_option(Globals, generate_bytecode, GenBytecode), ( % XXX: There is a mass of calls above that the bytecode doesn't need; % work out which is and isn't needed and put % inside the else case @@ -393,7 +393,7 @@ generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0, % Don't generate bytecode for procs with foreign code goal_has_foreign(Goal) = no -> - EmptyLabelCounter = counter__init(0), + EmptyLabelCounter = counter.init(0), bytecode_stub(ModuleInfo, PredId, ProcId, BytecodeInstructions), Proc = c_procedure(Name, Arity, proc(PredId, ProcId), @@ -418,14 +418,14 @@ maybe_set_trace_level(PredInfo, !ModuleInfo) :- % typeinfo_liveness. Since they may be opt_imported into other % modules, we must switch off the tracing of such preds on a % pred-by-pred basis. - globals__set_trace_level_none(Globals0, Globals1), + globals.set_trace_level_none(Globals0, Globals1), module_info_set_globals(Globals1, !ModuleInfo) ; pred_info_get_origin(PredInfo, special_pred(_)), - globals__get_trace_level(Globals0, TraceLevel), + globals.get_trace_level(Globals0, TraceLevel), UC_TraceLevel = trace_level_for_unify_compare(TraceLevel) -> - globals__set_trace_level(UC_TraceLevel, Globals0, Globals1), + globals.set_trace_level(UC_TraceLevel, Globals0, Globals1), module_info_set_globals(Globals1, !ModuleInfo) ; true @@ -447,13 +447,13 @@ generate_deep_prof_info(ProcInfo, HLDSDeepInfo) = DeepProfInfo :- HLDSExcpVars = hlds_deep_excp_vars(TopCSDVar, MiddleCSDVar, MaybeOldOutermostVar), proc_info_stack_slots(ProcInfo, StackSlots), - ( map__search(StackSlots, TopCSDVar, TopCSDSlot) -> + ( map.search(StackSlots, TopCSDVar, TopCSDSlot) -> TopCSDSlotNum = stack_slot_num(TopCSDSlot), - map__lookup(StackSlots, MiddleCSDVar, MiddleCSDSlot), + map.lookup(StackSlots, MiddleCSDVar, MiddleCSDSlot), MiddleCSDSlotNum = stack_slot_num(MiddleCSDSlot), ( MaybeOldOutermostVar = yes(OldOutermostVar), - map__lookup(StackSlots, OldOutermostVar, OldOutermostSlot), + map.lookup(StackSlots, OldOutermostVar, OldOutermostSlot), OldOutermostSlotNum = stack_slot_num(OldOutermostSlot) ; MaybeOldOutermostVar = no, @@ -512,7 +512,7 @@ maybe_add_tabling_pointer_var(ModuleInfo, PredId, ProcId, ProcInfo, ProcLabel, % code generator may allocate temporary variables to hold values % such as saved heap and trail pointers. % - % Code_gen__generate_entry cannot depend on the code generator + % Code_gen.generate_entry cannot depend on the code generator % state, since when it is invoked this state is not appropriate % for the procedure entry. Nor can it change the code generator state, % since that would confuse generate_exit. @@ -539,9 +539,9 @@ generate_category_code(model_det, Goal, ResumePoint, TraceSlotInfo, Code, MaybeTraceCallLabel, FrameInfo, !CI) :- % Generate the code for the body of the procedure. ( - code_info__get_globals(!.CI, Globals), - globals__lookup_bool_option(Globals, middle_rec, yes), - middle_rec__match_and_generate(Goal, MiddleRecCode, !CI) + code_info.get_globals(!.CI, Globals), + globals.lookup_bool_option(Globals, middle_rec, yes), + middle_rec.match_and_generate(Goal, MiddleRecCode, !CI) -> Code = MiddleRecCode, MaybeTraceCallLabel = no, @@ -549,10 +549,10 @@ generate_category_code(model_det, Goal, ResumePoint, TraceSlotInfo, Code, ; Goal = _ - GoalInfo, goal_info_get_context(GoalInfo, BodyContext), - code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo), + code_info.get_maybe_trace_info(!.CI, MaybeTraceInfo), ( MaybeTraceInfo = yes(TraceInfo), - trace__generate_external_event_code(call, TraceInfo, + trace.generate_external_event_code(call, TraceInfo, BodyContext, MaybeCallExternalInfo, !CI), ( MaybeCallExternalInfo = yes(CallExternalInfo), @@ -579,7 +579,7 @@ generate_category_code(model_det, Goal, ResumePoint, TraceSlotInfo, Code, generate_category_code(model_semi, Goal, ResumePoint, TraceSlotInfo, Code, MaybeTraceCallLabel, FrameInfo, !CI) :- - set__singleton_set(FailureLiveRegs, reg(r, 1)), + set.singleton_set(FailureLiveRegs, reg(r, 1)), FailCode = node([ assign(reg(r, 1), const(false)) - "Fail", livevals(FailureLiveRegs) - "", @@ -587,10 +587,10 @@ generate_category_code(model_semi, Goal, ResumePoint, TraceSlotInfo, Code, ]), Goal = _ - GoalInfo, goal_info_get_context(GoalInfo, BodyContext), - code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo), + code_info.get_maybe_trace_info(!.CI, MaybeTraceInfo), ( MaybeTraceInfo = yes(TraceInfo), - trace__generate_external_event_code(call, TraceInfo, BodyContext, + trace.generate_external_event_code(call, TraceInfo, BodyContext, MaybeCallExternalInfo, !CI), ( MaybeCallExternalInfo = yes(CallExternalInfo), @@ -608,13 +608,13 @@ generate_category_code(model_semi, Goal, ResumePoint, TraceSlotInfo, Code, generate_exit(model_semi, FrameInfo, TraceSlotInfo, BodyContext, RestoreDeallocCode, ExitCode, !CI), - code_info__generate_resume_point(ResumePoint, ResumeCode, !CI), - code_info__resume_point_vars(ResumePoint, ResumeVarList), - set__list_to_set(ResumeVarList, ResumeVars), - code_info__set_forward_live_vars(ResumeVars, !CI), + code_info.generate_resume_point(ResumePoint, ResumeCode, !CI), + code_info.resume_point_vars(ResumePoint, ResumeVarList), + set.list_to_set(ResumeVarList, ResumeVars), + code_info.set_forward_live_vars(ResumeVars, !CI), % XXX A context that gives the end of the procedure % definition would be better than BodyContext. - trace__generate_external_event_code(fail, TraceInfo, BodyContext, + trace.generate_external_event_code(fail, TraceInfo, BodyContext, MaybeFailExternalInfo, !CI), ( MaybeFailExternalInfo = yes(FailExternalInfo), @@ -633,19 +633,19 @@ generate_category_code(model_semi, Goal, ResumePoint, TraceSlotInfo, Code, FrameInfo, EntryCode), generate_exit(model_semi, FrameInfo, TraceSlotInfo, BodyContext, RestoreDeallocCode, ExitCode, !CI), - code_info__generate_resume_point(ResumePoint, ResumeCode, !CI), + code_info.generate_resume_point(ResumePoint, ResumeCode, !CI), Code = tree_list([EntryCode, BodyCode, ExitCode, ResumeCode, RestoreDeallocCode, FailCode]) ). generate_category_code(model_non, Goal, ResumePoint, TraceSlotInfo, Code, MaybeTraceCallLabel, FrameInfo, !CI) :- - code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo), + code_info.get_maybe_trace_info(!.CI, MaybeTraceInfo), Goal = _ - GoalInfo, goal_info_get_context(GoalInfo, BodyContext), ( MaybeTraceInfo = yes(TraceInfo), - trace__generate_external_event_code(call, TraceInfo, BodyContext, + trace.generate_external_event_code(call, TraceInfo, BodyContext, MaybeCallExternalInfo, !CI), ( MaybeCallExternalInfo = yes(CallExternalInfo), @@ -663,13 +663,13 @@ generate_category_code(model_non, Goal, ResumePoint, TraceSlotInfo, Code, generate_exit(model_non, FrameInfo, TraceSlotInfo, BodyContext, _, ExitCode, !CI), - code_info__generate_resume_point(ResumePoint, ResumeCode, !CI), - code_info__resume_point_vars(ResumePoint, ResumeVarList), - set__list_to_set(ResumeVarList, ResumeVars), - code_info__set_forward_live_vars(ResumeVars, !CI), + code_info.generate_resume_point(ResumePoint, ResumeCode, !CI), + code_info.resume_point_vars(ResumePoint, ResumeVarList), + set.list_to_set(ResumeVarList, ResumeVars), + code_info.set_forward_live_vars(ResumeVars, !CI), % XXX A context that gives the end of the procedure % definition would be better than BodyContext. - trace__generate_external_event_code(fail, TraceInfo, BodyContext, + trace.generate_external_event_code(fail, TraceInfo, BodyContext, MaybeFailExternalInfo, !CI), ( MaybeFailExternalInfo = yes(FailExternalInfo), @@ -685,8 +685,8 @@ generate_category_code(model_non, Goal, ResumePoint, TraceSlotInfo, Code, % Generate code which discards the ticket only if it was % allocated, i.e. only if MR_trace_from_full was true on entry. FromFullSlotLval = - llds__stack_slot_num_to_lval(model_non, FromFullSlot), - code_info__get_next_label(SkipLabel, !CI), + llds.stack_slot_num_to_lval(model_non, FromFullSlot), + code_info.get_next_label(SkipLabel, !CI), DiscardTraceTicketCode = node([ if_val(unop(logical_not, lval(FromFullSlotLval)), label(SkipLabel)) - "", @@ -744,22 +744,22 @@ generate_category_code(model_non, Goal, ResumePoint, TraceSlotInfo, Code, generate_entry(CI, CodeModel, Goal, OutsideResumePoint, FrameInfo, EntryCode) :- - code_info__get_stack_slots(CI, StackSlots), - code_info__get_varset(CI, VarSet), + code_info.get_stack_slots(CI, StackSlots), + code_info.get_varset(CI, VarSet), SlotsComment = explain_stack_slots(StackSlots, VarSet), StartComment = node([ comment("Start of procedure prologue") - "", comment(SlotsComment) - "" ]), - code_info__get_total_stackslot_count(CI, MainSlots), - code_info__get_pred_id(CI, PredId), - code_info__get_proc_id(CI, ProcId), - code_info__get_module_info(CI, ModuleInfo), - code_util__make_local_entry_label(ModuleInfo, PredId, ProcId, no, Entry), + code_info.get_total_stackslot_count(CI, MainSlots), + code_info.get_pred_id(CI, PredId), + code_info.get_proc_id(CI, ProcId), + code_info.get_module_info(CI, ModuleInfo), + code_util.make_local_entry_label(ModuleInfo, PredId, ProcId, no, Entry), LabelCode = node([ label(Entry) - "Procedure entry point" ]), - code_info__get_succip_used(CI, Used), + code_info.get_succip_used(CI, Used), ( % Do we need to save the succip across calls? Used = yes, @@ -777,10 +777,10 @@ generate_entry(CI, CodeModel, Goal, OutsideResumePoint, FrameInfo, TotalSlots = MainSlots, MaybeSuccipSlot = no ), - code_info__get_maybe_trace_info(CI, MaybeTraceInfo), + code_info.get_maybe_trace_info(CI, MaybeTraceInfo), ( MaybeTraceInfo = yes(TraceInfo), - trace__generate_slot_fill_code(CI, TraceInfo, TraceFillCode) + trace.generate_slot_fill_code(CI, TraceInfo, TraceFillCode) ; MaybeTraceInfo = no, TraceFillCode = empty @@ -792,20 +792,20 @@ generate_entry(CI, CodeModel, Goal, OutsideResumePoint, FrameInfo, PushMsg = push_msg(ModuleInfo, PredId, ProcId), ( CodeModel = model_non -> - code_info__resume_point_stack_addr(OutsideResumePoint, + code_info.resume_point_stack_addr(OutsideResumePoint, OutsideResumeAddress), ( Goal = foreign_proc(_, _, _, _, _, PragmaCode) - _, PragmaCode = nondet(Fields, FieldsContext, _, _, _, _, _, _, _) -> - pragma_c_gen__struct_name(ModuleName, PredName, Arity, ProcId, - StructName), + StructName = pragma_c_gen.struct_name(ModuleName, PredName, Arity, + ProcId), Struct = pragma_c_struct(StructName, Fields, FieldsContext), - string__format("#define\tMR_ORDINARY_SLOTS\t%d\n", + string.format("#define\tMR_ORDINARY_SLOTS\t%d\n", [i(TotalSlots)], DefineStr), DefineComponents = [pragma_c_raw_code(DefineStr, - cannot_branch_away, live_lvals_info(set__init))], + cannot_branch_away, live_lvals_info(set.init))], NondetFrameInfo = ordinary_frame(PushMsg, TotalSlots, yes(Struct)), AllocCode = node([ mkframe(NondetFrameInfo, yes(OutsideResumeAddress)) @@ -885,7 +885,7 @@ generate_exit(CodeModel, FrameInfo, TraceSlotInfo, BodyContext, ( NondetPragma = yes -> UndefStr = "#undef\tMR_ORDINARY_SLOTS\n", UndefComponents = [pragma_c_raw_code(UndefStr, cannot_branch_away, - live_lvals_info(set__init))], + live_lvals_info(set.init))], UndefCode = node([ pragma_c([], UndefComponents, will_not_call_mercury, no, no, no, no, no, no) - "" @@ -893,15 +893,15 @@ generate_exit(CodeModel, FrameInfo, TraceSlotInfo, BodyContext, RestoreDeallocCode = empty, % always empty for nondet code ExitCode = tree_list([StartComment, UndefCode, EndComment]) ; - code_info__get_instmap(!.CI, Instmap), - ArgModes = code_info__get_arginfo(!.CI), - HeadVars = code_info__get_headvars(!.CI), - assoc_list__from_corresponding_lists(HeadVars, ArgModes, Args), - ( instmap__is_unreachable(Instmap) -> - OutLvals = set__init, + code_info.get_instmap(!.CI, Instmap), + ArgModes = code_info.get_arginfo(!.CI), + HeadVars = code_info.get_headvars(!.CI), + assoc_list.from_corresponding_lists(HeadVars, ArgModes, Args), + ( instmap.is_unreachable(Instmap) -> + OutLvals = set.init, FlushCode = empty ; - code_info__setup_return(Args, OutLvals, FlushCode, !CI) + code_info.setup_return(Args, OutLvals, FlushCode, !CI) ), ( MaybeSuccipSlot = yes(SuccipSlot), @@ -940,9 +940,9 @@ generate_exit(CodeModel, FrameInfo, TraceSlotInfo, BodyContext, % in the success epilogue and one copy in the failure epilogue. % FromFullSlotLval = - llds__stack_slot_num_to_lval(CodeModel, FromFullSlot), - code_info__get_next_label(SkipLabel, !CI), - code_info__get_next_label(SkipLabelCopy, !CI), + llds.stack_slot_num_to_lval(CodeModel, FromFullSlot), + code_info.get_next_label(SkipLabel, !CI), + code_info.get_next_label(SkipLabelCopy, !CI), PruneTraceTicketCode = node([ if_val(unop(logical_not, lval(FromFullSlotLval)), label(SkipLabel)) - "", @@ -972,12 +972,12 @@ generate_exit(CodeModel, FrameInfo, TraceSlotInfo, BodyContext, RestoreDeallocCodeCopy = tree_list([RestoreSuccipCode, PruneTraceTicketCodeCopy, DeallocCode]), - code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo), + code_info.get_maybe_trace_info(!.CI, MaybeTraceInfo), ( MaybeTraceInfo = yes(TraceInfo), % XXX A context that gives the end of the procedure definition % would be better than CallContext. - trace__generate_external_event_code(exit, TraceInfo, BodyContext, + trace.generate_external_event_code(exit, TraceInfo, BodyContext, MaybeExitExternalInfo, !CI), ( MaybeExitExternalInfo = yes(ExitExternalInfo), @@ -985,13 +985,13 @@ generate_exit(CodeModel, FrameInfo, TraceSlotInfo, BodyContext, TraceExitCode) ; MaybeExitExternalInfo = no, - TypeInfoDatas = map__init, + TypeInfoDatas = map.init, TraceExitCode = empty ), - map__values(TypeInfoDatas, TypeInfoLocnSets), + map.values(TypeInfoDatas, TypeInfoLocnSets), FindBaseLvals = (pred(Lval::out) is nondet :- - list__member(LocnSet, TypeInfoLocnSets), - set__member(Locn, LocnSet), + list.member(LocnSet, TypeInfoLocnSets), + set.member(Locn, LocnSet), ( Locn = direct(Lval) ; @@ -999,7 +999,7 @@ generate_exit(CodeModel, FrameInfo, TraceSlotInfo, BodyContext, ) ), solutions(FindBaseLvals, TypeInfoLvals), - set__insert_list(OutLvals, TypeInfoLvals, LiveLvals) + set.insert_list(OutLvals, TypeInfoLvals, LiveLvals) ; MaybeTraceInfo = no, TraceExitCode = empty, @@ -1016,7 +1016,7 @@ generate_exit(CodeModel, FrameInfo, TraceSlotInfo, BodyContext, SuccessCode]) ; CodeModel = model_semi, - set__insert(LiveLvals, reg(r, 1), SuccessLiveRegs), + set.insert(LiveLvals, reg(r, 1), SuccessLiveRegs), SuccessCode = node([ assign(reg(r, 1), const(true)) - "Succeed", livevals(SuccessLiveRegs) - "", @@ -1028,7 +1028,7 @@ generate_exit(CodeModel, FrameInfo, TraceSlotInfo, BodyContext, CodeModel = model_non, ( MaybeTraceInfo = yes(TraceInfo2), - trace__maybe_setup_redo_event(TraceInfo2, SetupRedoCode) + trace.maybe_setup_redo_event(TraceInfo2, SetupRedoCode) ; MaybeTraceInfo = no, SetupRedoCode = empty @@ -1057,9 +1057,9 @@ generate_goal(ContextModel, Goal - GoalInfo, Code, !CI) :- ; IsAtomic = no ), - code_info__pre_goal_update(GoalInfo, IsAtomic, !CI), - code_info__get_instmap(!.CI, Instmap), - ( instmap__is_reachable(Instmap) -> + code_info.pre_goal_update(GoalInfo, IsAtomic, !CI), + code_info.get_instmap(!.CI, Instmap), + ( instmap.is_reachable(Instmap) -> goal_info_get_code_model(GoalInfo, CodeModel), % Sanity check: code of some code models should occur % only in limited contexts. @@ -1084,12 +1084,12 @@ generate_goal(ContextModel, Goal - GoalInfo, Code, !CI) :- % Check if we need to add trail ops, and if so, whether it is safe to % omit them. We only do the latter if we are optimizing trail usage. % - code_info__get_globals(!.CI, Globals), + code_info.get_globals(!.CI, Globals), AddTrailOps = should_add_trail_ops(Globals, Goal - GoalInfo), generate_goal_2(Goal, GoalInfo, CodeModel, AddTrailOps, GoalCode, !CI), goal_info_get_features(GoalInfo, Features), - code_info__get_proc_info(!.CI, ProcInfo), + code_info.get_proc_info(!.CI, ProcInfo), % If the predicate's evaluation method is memo, loopcheck or minimal % model, the goal generated the variable that represents the call table @@ -1101,13 +1101,13 @@ generate_goal(ContextModel, Goal - GoalInfo, Code, !CI) :- % If tracing is not enabled, then CallTableVar isn't guaranteed % to have a stack slot. ( - set__member(call_table_gen, Features), - code_info__get_proc_info(!.CI, ProcInfo), + set.member(call_table_gen, Features), + code_info.get_proc_info(!.CI, ProcInfo), proc_info_get_call_table_tip(ProcInfo, MaybeCallTableVar), MaybeCallTableVar = yes(CallTableVar), - code_info__get_maybe_trace_info(!.CI, yes(_)) + code_info.get_maybe_trace_info(!.CI, yes(_)) -> - code_info__save_variables_on_stack([CallTableVar], TipSaveCode, + code_info.save_variables_on_stack([CallTableVar], TipSaveCode, !CI), CodeUptoTip = tree(GoalCode, TipSaveCode) ; @@ -1127,9 +1127,9 @@ generate_goal(ContextModel, Goal - GoalInfo, Code, !CI) :- % doesn't make any such calls, then the variables won't have stack % slots, but they won't *need* stack slots either, since there is no % way for such a leaf procedure to throw an exception. (Throwing - % requires calling exception__throw, directly or indirectly.) + % requires calling exception.throw, directly or indirectly.) ( - set__member(save_deep_excp_vars, Features) + set.member(save_deep_excp_vars, Features) -> DeepSaveVars = compute_deep_save_excp_vars(ProcInfo), save_variables_on_stack(DeepSaveVars, DeepSaveCode, !CI), @@ -1140,8 +1140,8 @@ generate_goal(ContextModel, Goal - GoalInfo, Code, !CI) :- % Make live any variables which subsequent goals will expect to be % live, but were not generated. - code_info__set_instmap(Instmap, !CI), - code_info__post_goal_update(GoalInfo, !CI) + code_info.set_instmap(Instmap, !CI), + code_info.post_goal_update(GoalInfo, !CI) ; Code = empty ). @@ -1159,7 +1159,7 @@ compute_deep_save_excp_vars(ProcInfo) = DeepSaveVars :- ExcpVars = hlds_deep_excp_vars(TopCSDVar, MiddleCSDVar, MaybeOldOutermostVar), proc_info_stack_slots(ProcInfo, StackSlots), - ( map__search(StackSlots, TopCSDVar, _) -> + ( map.search(StackSlots, TopCSDVar, _) -> % If one of these variables has a stack slot, the others must % have one too. ( @@ -1185,49 +1185,49 @@ compute_deep_save_excp_vars(ProcInfo) = DeepSaveVars :- generate_goal_2(Goal, GoalInfo, CodeModel, _, Code, !CI) :- Goal = unify(_, _, _, Uni, _), - unify_gen__generate_unification(CodeModel, Uni, GoalInfo, Code, !CI). + unify_gen.generate_unification(CodeModel, Uni, GoalInfo, Code, !CI). generate_goal_2(conj(ConjType, Goals), GoalInfo, CodeModel, _, Code, !CI) :- ( ConjType = plain_conj, generate_goals(Goals, CodeModel, Code, !CI) ; ConjType = parallel_conj, - par_conj_gen__generate_par_conj(Goals, GoalInfo, CodeModel, Code, !CI) + par_conj_gen.generate_par_conj(Goals, GoalInfo, CodeModel, Code, !CI) ). generate_goal_2(disj(Goals), GoalInfo, CodeModel, AddTrailOps, Code, !CI) :- - disj_gen__generate_disj(AddTrailOps, CodeModel, Goals, GoalInfo, Code, !CI). + disj_gen.generate_disj(AddTrailOps, CodeModel, Goals, GoalInfo, Code, !CI). generate_goal_2(not(Goal), GoalInfo, CodeModel, AddTrailOps, Code, !CI) :- - ite_gen__generate_negation(AddTrailOps, CodeModel, Goal, GoalInfo, + ite_gen.generate_negation(AddTrailOps, CodeModel, Goal, GoalInfo, Code, !CI). generate_goal_2(Goal, GoalInfo, CodeModel, AddTrailOps, Code, !CI) :- Goal = if_then_else(_Vars, Cond, Then, Else), - ite_gen__generate_ite(AddTrailOps, CodeModel, Cond, Then, Else, GoalInfo, + ite_gen.generate_ite(AddTrailOps, CodeModel, Cond, Then, Else, GoalInfo, Code, !CI). generate_goal_2(Goal, GoalInfo, CodeModel, _, Code, !CI) :- Goal = switch(Var, CanFail, CaseList), - switch_gen__generate_switch(CodeModel, Var, CanFail, CaseList, + switch_gen.generate_switch(CodeModel, Var, CanFail, CaseList, GoalInfo, Code, !CI). generate_goal_2(scope(_, Goal), _GoalInfo, CodeModel, AddTrailOps, Code, !CI) :- - commit_gen__generate_commit(AddTrailOps, CodeModel, Goal, Code, !CI). + commit_gen.generate_commit(AddTrailOps, CodeModel, Goal, Code, !CI). generate_goal_2(Goal, GoalInfo, CodeModel, _, Code, !CI) :- Goal = generic_call(GenericCall, Args, Modes, Det), - call_gen__generate_generic_call(CodeModel, GenericCall, Args, + call_gen.generate_generic_call(CodeModel, GenericCall, Args, Modes, Det, GoalInfo, Code, !CI). generate_goal_2(Goal, GoalInfo, CodeModel, _, Code, !CI) :- Goal = call(PredId, ProcId, Args, BuiltinState, _, _), ( BuiltinState = not_builtin -> - call_gen__generate_call(CodeModel, PredId, ProcId, Args, + call_gen.generate_call(CodeModel, PredId, ProcId, Args, GoalInfo, Code, !CI) ; - call_gen__generate_builtin(CodeModel, PredId, ProcId, Args, + call_gen.generate_builtin(CodeModel, PredId, ProcId, Args, Code, !CI) ). generate_goal_2(Goal, GoalInfo, CodeModel, _, Code, !CI) :- Goal = foreign_proc(Attributes, PredId, ProcId, Args, ExtraArgs, PragmaCode), ( c = foreign_language(Attributes) -> - pragma_c_gen__generate_pragma_c_code(CodeModel, Attributes, + pragma_c_gen.generate_pragma_c_code(CodeModel, Attributes, PredId, ProcId, Args, ExtraArgs, GoalInfo, PragmaCode, Code, !CI) ; unexpected(this_file, @@ -1249,8 +1249,8 @@ generate_goal_2(shorthand(_), _, _, _, _, !CI) :- generate_goals([], _, empty, !CI). generate_goals([Goal | Goals], CodeModel, Code, !CI) :- generate_goal(CodeModel, Goal, Code1, !CI), - code_info__get_instmap(!.CI, Instmap), - ( instmap__is_unreachable(Instmap) -> + code_info.get_instmap(!.CI, Instmap), + ( instmap.is_unreachable(Instmap) -> Code = Code1 ; generate_goals(Goals, CodeModel, Code2, !CI), @@ -1275,12 +1275,12 @@ add_saved_succip([Instrn0 - Comment | Instrns0 ], StackLoc, % XXX We should also test for tailcalls % once we start generating them directly. -> - set__insert(LiveVals0, stackvar(StackLoc), LiveVals1), + set.insert(LiveVals0, stackvar(StackLoc), LiveVals1), Instrn = livevals(LiveVals1) ; Instrn0 = call(Target, ReturnLabel, LiveVals0, Context, GP, CM) -> - map__init(Empty), + map.init(Empty), LiveVals = [live_lvalue(direct(stackvar(StackLoc)), succip, Empty) | LiveVals0], Instrn = call(Target, ReturnLabel, LiveVals, Context, GP, CM) @@ -1301,11 +1301,11 @@ bytecode_stub(ModuleInfo, PredId, ProcId, BytecodeInstructions) :- sym_name_to_string(ModuleSymName, "__", ModuleName), - code_util__make_local_entry_label(ModuleInfo, PredId, ProcId, no, Entry), + code_util.make_local_entry_label(ModuleInfo, PredId, ProcId, no, Entry), PredName = pred_info_name(PredInfo), proc_id_to_int(ProcId, ProcNum), - string__int_to_string(ProcNum, ProcStr), + string.int_to_string(ProcNum, ProcStr), Arity = pred_info_orig_arity(PredInfo), int_to_string(Arity, ArityStr), PredOrFunc = pred_info_is_pred_or_func(PredInfo), @@ -1333,13 +1333,13 @@ bytecode_stub(ModuleInfo, PredId, ProcId, BytecodeInstructions) :- BytecodeInstructionsComponents = [ pragma_c_raw_code("\t{\n", cannot_branch_away, - live_lvals_info(set__init)), + live_lvals_info(set.init)), pragma_c_raw_code(CallStruct, cannot_branch_away, - live_lvals_info(set__init)), + live_lvals_info(set.init)), pragma_c_raw_code(BytecodeCall, cannot_branch_away, no_live_lvals_info), pragma_c_raw_code("\t}\n", cannot_branch_away, - live_lvals_info(set__init)) + live_lvals_info(set.init)) ], BytecodeInstructions = [ @@ -1380,9 +1380,9 @@ push_msg(ModuleInfo, PredId, ProcId) = PushMsg :- find_arg_type_ctor_name(TypeCtor, TypeName) :- TypeCtor = TypeCtorSymName - TypeCtorArity, - mdbcomp__prim_data__sym_name_to_string(TypeCtorSymName, TypeCtorName), - string__int_to_string(TypeCtorArity, ArityStr), - string__append_list([TypeCtorName, "_", ArityStr], TypeName). + mdbcomp.prim_data.sym_name_to_string(TypeCtorSymName, TypeCtorName), + string.int_to_string(TypeCtorArity, ArityStr), + string.append_list([TypeCtorName, "_", ArityStr], TypeName). %---------------------------------------------------------------------------% diff --git a/compiler/code_info.m b/compiler/code_info.m index 4a388b49d..674d5734d 100644 --- a/compiler/code_info.m +++ b/compiler/code_info.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -26,7 +26,7 @@ %---------------------------------------------------------------------------% -:- module ll_backend__code_info. +:- module ll_backend.code_info. :- interface. :- import_module hlds.code_model. @@ -420,20 +420,20 @@ code_info_init(SaveSuccip, Globals, PredId, ProcId, PredInfo, ProcInfo, proc_info_varset(ProcInfo, VarSet), proc_info_vartypes(ProcInfo, VarTypes), proc_info_stack_slots(ProcInfo, StackSlots), - globals__get_options(Globals, Options), - globals__get_trace_level(Globals, TraceLevel), + globals.get_options(Globals, Options), + globals.get_trace_level(Globals, TraceLevel), ( eff_trace_level_is_none(PredInfo, ProcInfo, TraceLevel) = no -> - trace__fail_vars(ModuleInfo, ProcInfo, FailVars), + trace.fail_vars(ModuleInfo, ProcInfo, FailVars), MaybeFailVars = yes(FailVars), - set__union(Liveness, FailVars, EffLiveness) + set.union(Liveness, FailVars, EffLiveness) ; MaybeFailVars = no, EffLiveness = Liveness ), - var_locn__init_state(ArgList, EffLiveness, VarSet, VarTypes, StackSlots, + var_locn.init_state(ArgList, EffLiveness, VarSet, VarTypes, StackSlots, FollowVars, Options, VarLocnInfo), - stack__init(ResumePoints), - globals__lookup_bool_option(Globals, allow_hijacks, AllowHijack), + stack.init(ResumePoints), + globals.lookup_bool_option(Globals, allow_hijacks, AllowHijack), ( AllowHijack = yes, Hijack = allowed @@ -443,15 +443,15 @@ code_info_init(SaveSuccip, Globals, PredId, ProcId, PredInfo, ProcInfo, ), DummyFailInfo = fail_info(ResumePoints, resume_point_unknown, may_be_different, not_inside_non_condition, Hijack), - map__init(TempContentMap), - set__init(TempsInUse), - set__init(Zombies), - map__init(LayoutMap), + map.init(TempContentMap), + set.init(TempsInUse), + set.init(Zombies), + map.init(LayoutMap), max_var_slot(StackSlots, VarSlotMax), - trace__reserved_slots(ModuleInfo, PredInfo, ProcInfo, Globals, + trace.reserved_slots(ModuleInfo, PredInfo, ProcInfo, Globals, FixedSlots, _), - int__max(VarSlotMax, FixedSlots, SlotMax), - globals__lookup_bool_option(Globals, opt_no_return_calls, + int.max(VarSlotMax, FixedSlots, SlotMax), + globals.lookup_bool_option(Globals, opt_no_return_calls, OptNoReturnCalls), CodeInfo0 = code_info( code_info_static( @@ -475,12 +475,12 @@ code_info_init(SaveSuccip, Globals, PredId, ProcId, PredInfo, ProcInfo, DummyFailInfo % init_fail_info will override this dummy value ), code_info_persistent( - counter__init(1), + counter.init(1), SaveSuccip, LayoutMap, 0, TempContentMap, - counter__init(1), + counter.init(1), [], -1, no, @@ -499,7 +499,7 @@ code_info_init(SaveSuccip, Globals, PredId, ProcId, PredInfo, ProcInfo, init_maybe_trace_info(TraceLevel, Globals, ModuleInfo, PredInfo, ProcInfo, TraceSlotInfo, !CI) :- ( eff_trace_level_is_none(PredInfo, ProcInfo, TraceLevel) = no -> - trace__setup(ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, + trace.setup(ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, TraceInfo, !CI), set_maybe_trace_info(yes(TraceInfo), !CI) ; @@ -710,7 +710,7 @@ set_static_cell_info(SCI, CI, % :- pred succip_is_used(code_info::in, code_info::out) is det. -:- pred add_trace_layout_for_label(label::in, term__context::in, +:- pred add_trace_layout_for_label(label::in, term.context::in, trace_port::in, bool::in, goal_path::in, layout_label_info::in, code_info::in, code_info::out) is det. @@ -737,19 +737,19 @@ set_static_cell_info(SCI, CI, get_stack_slots(CI, StackSlots) :- get_var_locn_info(CI, VarLocnInfo), - var_locn__get_stack_slots(VarLocnInfo, StackSlots). + var_locn.get_stack_slots(VarLocnInfo, StackSlots). get_follow_var_map(CI, FollowVarMap) :- get_var_locn_info(CI, VarLocnInfo), - var_locn__get_follow_var_map(VarLocnInfo, FollowVarMap). + var_locn.get_follow_var_map(VarLocnInfo, FollowVarMap). get_next_non_reserved(CI, NextNonReserved) :- get_var_locn_info(CI, VarLocnInfo), - var_locn__get_next_non_reserved(VarLocnInfo, NextNonReserved). + var_locn.get_next_non_reserved(VarLocnInfo, NextNonReserved). set_follow_vars(FollowVars, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__set_follow_vars(FollowVars, VarLocnInfo0, VarLocnInfo), + var_locn.set_follow_vars(FollowVars, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). %-----------------------------------------------------------------------------% @@ -798,7 +798,7 @@ post_goal_update(GoalInfo, !CI) :- make_vars_forward_live(PostBirths, !CI), goal_info_get_instmap_delta(GoalInfo, InstMapDelta), get_instmap(!.CI, InstMap0), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap), set_instmap(InstMap, !CI). %---------------------------------------------------------------------------% @@ -815,7 +815,7 @@ get_var_types(CI) = VarTypes :- proc_info_vartypes(ProcInfo, VarTypes). variable_type(CI, Var) = Type :- - map__lookup(get_var_types(CI), Var, Type). + map.lookup(get_var_types(CI), Var, Type). lookup_type_defn(CI, Type) = TypeDefn :- get_module_info(CI, ModuleInfo), @@ -825,7 +825,7 @@ lookup_type_defn(CI, Type) = TypeDefn :- unexpected(this_file, "unknown type in lookup_type_defn") ), module_info_get_type_table(ModuleInfo, TypeTable), - map__lookup(TypeTable, TypeCtor, TypeDefn). + map.lookup(TypeTable, TypeCtor, TypeDefn). cons_id_to_tag(CI, Var, ConsId) = ConsTag :- get_module_info(CI, ModuleInfo), @@ -857,14 +857,14 @@ get_pred_proc_arginfo(CI, PredId, ProcId) = ArgInfo :- current_resume_point_vars(CI) = ResumeVars :- get_fail_info(CI, FailInfo), FailInfo = fail_info(ResumePointStack, _, _, _, _), - stack__top_det(ResumePointStack, ResumePointInfo), + stack.top_det(ResumePointStack, ResumePointInfo), pick_first_resume_point(ResumePointInfo, ResumeMap, _), - map__keys(ResumeMap, ResumeMapVarList), - set__list_to_set(ResumeMapVarList, ResumeVars). + map.keys(ResumeMap, ResumeMapVarList), + set.list_to_set(ResumeMapVarList, ResumeVars). variable_to_string(CI, Var) = Name :- get_varset(CI, Varset), - varset__lookup_name(Varset, Var, Name). + varset.lookup_name(Varset, Var, Name). %---------------------------------------------------------------------------% @@ -875,7 +875,7 @@ make_entry_label(CI, ModuleInfo, PredId, ProcId, Immed0) = PredAddress :- ; Immed0 = yes, get_globals(CI, Globals), - globals__lookup_int_option(Globals, procs_per_c_function, + globals.lookup_int_option(Globals, procs_per_c_function, ProcsPerFunc), get_pred_id(CI, CurPredId), get_proc_id(CI, CurProcId), @@ -888,7 +888,7 @@ get_next_label(Label, !CI) :- get_pred_id(!.CI, PredId), get_proc_id(!.CI, ProcId), get_label_counter(!.CI, C0), - counter__allocate(N, C0, C), + counter.allocate(N, C0, C), set_label_counter(C, !CI), make_internal_label(ModuleInfo, PredId, ProcId, N, Label). @@ -905,7 +905,7 @@ add_trace_layout_for_label(Label, Context, Port, IsHidden, Path, Layout, Label = entry(_, _), unexpected(this_file, "add_trace_layout_for_label: entry") ), - ( map__search(Internals0, LabelNum, Internal0) -> + ( map.search(Internals0, LabelNum, Internal0) -> Internal0 = internal_layout_info(Exec0, Resume, Return), ( Exec0 = no @@ -915,10 +915,10 @@ add_trace_layout_for_label(Label, Context, Port, IsHidden, Path, Layout, "adding trace layout for already known label") ), Internal = internal_layout_info(Exec, Resume, Return), - map__det_update(Internals0, LabelNum, Internal, Internals) + map.det_update(Internals0, LabelNum, Internal, Internals) ; Internal = internal_layout_info(Exec, no, no), - map__det_insert(Internals0, LabelNum, Internal, Internals) + map.det_insert(Internals0, LabelNum, Internal, Internals) ), set_layout_info(Internals, !CI). @@ -931,7 +931,7 @@ add_resume_layout_for_label(Label, LayoutInfo, !CI) :- Label = entry(_, _), unexpected(this_file, "add_trace_layout_for_label: entry") ), - ( map__search(Internals0, LabelNum, Internal0) -> + ( map.search(Internals0, LabelNum, Internal0) -> Internal0 = internal_layout_info(Exec, Resume0, Return), ( Resume0 = no @@ -940,10 +940,10 @@ add_resume_layout_for_label(Label, LayoutInfo, !CI) :- unexpected(this_file, "adding gc layout for already known label") ), Internal = internal_layout_info(Exec, Resume, Return), - map__det_update(Internals0, LabelNum, Internal, Internals) + map.det_update(Internals0, LabelNum, Internal, Internals) ; Internal = internal_layout_info(no, Resume, no), - map__det_insert(Internals0, LabelNum, Internal, Internals) + map.det_insert(Internals0, LabelNum, Internal, Internals) ), set_layout_info(Internals, !CI). @@ -953,8 +953,8 @@ add_resume_layout_for_label(Label, LayoutInfo, !CI) :- get_active_temps_data(CI, Temps) :- get_temps_in_use(CI, TempsInUse), get_temp_content_map(CI, TempContentMap), - map__select(TempContentMap, TempsInUse, TempsInUseContentMap), - map__to_assoc_list(TempsInUseContentMap, Temps). + map.select(TempContentMap, TempsInUse, TempsInUseContentMap), + map.to_assoc_list(TempsInUseContentMap, Temps). get_cur_proc_label(CI, ProcLabel) :- get_module_info(CI, ModuleInfo), @@ -964,7 +964,7 @@ get_cur_proc_label(CI, ProcLabel) :- get_next_closure_seq_no(SeqNo, !CI) :- get_closure_seq_counter(!.CI, C0), - counter__allocate(SeqNo, C0, C), + counter.allocate(SeqNo, C0, C), set_closure_seq_counter(C, !CI). add_closure_layout(ClosureLayout, !CI) :- @@ -1048,14 +1048,14 @@ generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, Code, !CI) :- % each variable should go. We don't need to reset the follow_vars % afterwards, since every goal following a branched control structure % must in any case be annotated with its own follow_var set. - map__to_assoc_list(StoreMap, AbsVarLocs), - map__from_assoc_list(AbsVarLocs, FollowVarsMap), - assoc_list__values(AbsVarLocs, AbsLocs), - code_util__max_mentioned_abs_reg(AbsLocs, MaxMentionedReg), + map.to_assoc_list(StoreMap, AbsVarLocs), + map.from_assoc_list(AbsVarLocs, FollowVarsMap), + assoc_list.values(AbsVarLocs, AbsLocs), + code_util.max_mentioned_abs_reg(AbsLocs, MaxMentionedReg), set_follow_vars(abs_follow_vars(FollowVarsMap, MaxMentionedReg + 1), !CI), get_instmap(!.CI, InstMap), - ( instmap__is_reachable(InstMap) -> - VarLocs = assoc_list__map_values(key_abs_locn_to_lval, AbsVarLocs), + ( instmap.is_reachable(InstMap) -> + VarLocs = assoc_list.map_values(key_abs_locn_to_lval, AbsVarLocs), place_vars(VarLocs, Code, !CI) ; % With --opt-no-return-call, the variables that we would have @@ -1116,7 +1116,7 @@ generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, Code, !CI) :- % structure includes every slot in use at the end of any branch. get_temps_in_use(EndCodeInfo0, TempsInUse0), get_temps_in_use(EndCodeInfo1, TempsInUse1), - set__union(TempsInUse0, TempsInUse1, TempsInUse), + set.union(TempsInUse0, TempsInUse1, TempsInUse), set_temps_in_use(TempsInUse, EndCodeInfoA, EndCodeInfo) ), MaybeEnd = yes(branch_end_info(EndCodeInfo)). @@ -1142,10 +1142,10 @@ after_all_branches(StoreMap, MaybeEnd, !CI) :- code_info::in, code_info::out) is det. remake_with_store_map(StoreMap, !CI) :- - map__to_assoc_list(StoreMap, VarLocns), - VarLvals = assoc_list__map_values(key_abs_locn_to_lval, VarLocns), + map.to_assoc_list(StoreMap, VarLocns), + VarLvals = assoc_list.map_values(key_abs_locn_to_lval, VarLocns), get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__reinit_state(VarLvals, VarLocnInfo0, VarLocnInfo), + var_locn.reinit_state(VarLvals, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). save_hp_in_branch(Code, Slot, Pos0, Pos) :- @@ -1441,8 +1441,8 @@ prepare_for_disj_hijack(CodeModel, HijackInfo, Code, !CI) :- ( CurfrMaxfr = must_be_equal, ResumeKnown = resume_point_known(has_been_done), - stack__pop(ResumePoints, TopResumePoint, RestResumePoints), - stack__is_empty(RestResumePoints), + stack.pop(ResumePoints, TopResumePoint, RestResumePoints), + stack.is_empty(RestResumePoints), TopResumePoint = stack_only(_, do_fail) -> HijackInfo = disj_quarter_hijack, @@ -1504,7 +1504,7 @@ undo_disj_hijack(HijackInfo, Code, !CI) :- HijackInfo = disj_quarter_hijack, expect(unify(CurfrMaxfr, must_be_equal), this_file, "maxfr may differ from curfr in disj_quarter_hijack"), - stack__top_det(ResumePoints, ResumePoint), + stack.top_det(ResumePoints, ResumePoint), pick_stack_resume_point(ResumePoint, _, StackLabel), LabelConst = const(code_addr_const(StackLabel)), % peephole.m looks for the "curfr==maxfr" pattern in the comment. @@ -1641,7 +1641,7 @@ prepare_for_ite_hijack(EffCodeModel, HijackInfo, Code, !CI) :- ite_enter_then(HijackInfo, ThenCode, ElseCode, !CI) :- get_fail_info(!.CI, FailInfo0), FailInfo0 = fail_info(ResumePoints0, ResumeKnown0, CurfrMaxfr, _, Allow), - stack__pop_det(ResumePoints0, _, ResumePoints), + stack.pop_det(ResumePoints0, _, ResumePoints), HijackInfo = ite_info(HijackResumeKnown, OldCondEnv, HijackType), ( HijackType = ite_no_hijack, @@ -1661,7 +1661,7 @@ ite_enter_then(HijackInfo, ThenCode, ElseCode, !CI) :- ]) ; HijackType = ite_quarter_hijack, - stack__top_det(ResumePoints, ResumePoint), + stack.top_det(ResumePoints, ResumePoint), ( maybe_pick_stack_resume_point(ResumePoint, _, StackLabel) -> LabelConst = const(code_addr_const(StackLabel)), ThenCode = node([ @@ -1717,8 +1717,8 @@ enter_simple_neg(ResumeVars, GoalInfo, FailInfo0, !CI) :- % Therefore the only part of ResumePoint that matters is the set of % variables in the resume map; the other parts of ResumePoint % (the locations, the code address) will not be referenced. - set__to_sorted_list(ResumeVars, ResumeVarList), - map__init(ResumeMap0), + set.to_sorted_list(ResumeVars, ResumeVarList), + map.init(ResumeMap0), make_fake_resume_map(ResumeVarList, ResumeMap0, ResumeMap), ResumePoint = orig_only(ResumeMap, do_redo), effect_resume_point(ResumePoint, model_semi, Code, !CI), @@ -1735,8 +1735,8 @@ leave_simple_neg(GoalInfo, FailInfo, !CI) :- make_fake_resume_map([], ResumeMap, ResumeMap). make_fake_resume_map([Var | Vars], ResumeMap0, ResumeMap) :- % a visibly fake location - set__singleton_set(Locns, reg(r, -1)), - map__det_insert(ResumeMap0, Var, Locns, ResumeMap1), + set.singleton_set(Locns, reg(r, -1)), + map.det_insert(ResumeMap0, Var, Locns, ResumeMap1), make_fake_resume_map(Vars, ResumeMap1, ResumeMap). %---------------------------------------------------------------------------% @@ -1822,9 +1822,9 @@ prepare_for_semi_commit(AddTrailOps, SemiCommitInfo, Code, !CI) :- get_fail_info(!.CI, FailInfo0), FailInfo0 = fail_info(ResumePoints0, ResumeKnown, CurfrMaxfr, CondEnv, Allow), - stack__top_det(ResumePoints0, TopResumePoint), + stack.top_det(ResumePoints0, TopResumePoint), clone_resume_point(TopResumePoint, NewResumePoint, !CI), - stack__push(ResumePoints0, NewResumePoint, ResumePoints), + stack.push(ResumePoints0, NewResumePoint, ResumePoints), FailInfo = fail_info(ResumePoints, resume_point_known(has_been_done), CurfrMaxfr, CondEnv, Allow), set_fail_info(FailInfo, !CI), @@ -1842,7 +1842,7 @@ prepare_for_semi_commit(AddTrailOps, SemiCommitInfo, Code, !CI) :- create_temp_frame(StackLabel, "prepare for temp frame commit", TempFrameCode, !CI), get_globals(!.CI, Globals), - globals__lookup_bool_option(Globals, use_minimal_model_stack_copy_cut, + globals.lookup_bool_option(Globals, use_minimal_model_stack_copy_cut, UseMinimalModelStackCopyCut), HijackInfo = commit_temp_frame(MaxfrSlot, UseMinimalModelStackCopyCut), ( @@ -1860,13 +1860,13 @@ prepare_for_semi_commit(AddTrailOps, SemiCommitInfo, Code, !CI) :- Components = [ pragma_c_raw_code( "\t\tMR_save_transient_registers();\n", - cannot_branch_away, live_lvals_info(set__init)), + cannot_branch_away, live_lvals_info(set.init)), pragma_c_raw_code( "\t\tMR_commit_mark();\n", - cannot_branch_away, live_lvals_info(set__init)), + cannot_branch_away, live_lvals_info(set.init)), pragma_c_raw_code( "\t\tMR_restore_transient_registers();\n", - cannot_branch_away, live_lvals_info(set__init)) + cannot_branch_away, live_lvals_info(set.init)) ], MarkCode = node([ pragma_c([], Components, will_not_call_mercury, @@ -1941,7 +1941,7 @@ generate_semi_commit(SemiCommitInfo, Code, !CI) :- % See the comment in prepare_for_semi_commit above. Components = [ pragma_c_raw_code("\t\tMR_commit_cut();\n", - cannot_branch_away, live_lvals_info(set__init)) + cannot_branch_away, live_lvals_info(set.init)) ], CutCode = node([ pragma_c([], Components, will_not_call_mercury, no, no, no, @@ -1956,7 +1956,7 @@ generate_semi_commit(SemiCommitInfo, Code, !CI) :- ; HijackInfo = commit_quarter_hijack, FailInfo = fail_info(ResumePoints, _, _, _, _), - stack__top_det(ResumePoints, TopResumePoint), + stack.top_det(ResumePoints, TopResumePoint), pick_stack_resume_point(TopResumePoint, _, StackLabel), StackLabelConst = const(code_addr_const(StackLabel)), SuccessUndoCode = node([ @@ -2056,19 +2056,19 @@ effect_resume_point(ResumePoint, CodeModel, Code, !CI) :- get_fail_info(!.CI, FailInfo0), FailInfo0 = fail_info(ResumePoints0, _ResumeKnown, CurfrMaxfr, CondEnv, Allow), - ( stack__top(ResumePoints0, OldResumePoint) -> + ( stack.top(ResumePoints0, OldResumePoint) -> pick_first_resume_point(OldResumePoint, OldMap, _), pick_first_resume_point(ResumePoint, NewMap, _), - map__keys(OldMap, OldKeys), - map__keys(NewMap, NewKeys), - set__list_to_set(OldKeys, OldKeySet), - set__list_to_set(NewKeys, NewKeySet), - expect(set__subset(OldKeySet, NewKeySet), this_file, + map.keys(OldMap, OldKeys), + map.keys(NewMap, NewKeys), + set.list_to_set(OldKeys, OldKeySet), + set.list_to_set(NewKeys, NewKeySet), + expect(set.subset(OldKeySet, NewKeySet), this_file, "non-nested resume point variable sets") ; true ), - stack__push(ResumePoints0, ResumePoint, ResumePoints), + stack.push(ResumePoints0, ResumePoint, ResumePoints), ( CodeModel = model_non -> pick_stack_resume_point(ResumePoint, _, StackLabel), LabelConst = const(code_addr_const(StackLabel)), @@ -2089,7 +2089,7 @@ pop_resume_point(!CI) :- get_fail_info(!.CI, FailInfo0), FailInfo0 = fail_info(ResumePoints0, ResumeKnown, CurfrMaxfr, CondEnv, Allow), - stack__pop_det(ResumePoints0, _, ResumePoints), + stack.pop_det(ResumePoints0, _, ResumePoints), FailInfo = fail_info(ResumePoints, ResumeKnown, CurfrMaxfr, CondEnv, Allow), set_fail_info(FailInfo, !CI). @@ -2099,7 +2099,7 @@ pop_resume_point(!CI) :- top_resume_point(CI, ResumePoint) :- get_fail_info(CI, FailInfo), FailInfo = fail_info(ResumePoints, _, _, _, _), - stack__top_det(ResumePoints, ResumePoint). + stack.top_det(ResumePoints, ResumePoint). set_resume_point_to_unknown(!CI) :- get_fail_info(!.CI, FailInfo0), @@ -2122,13 +2122,13 @@ generate_failure(Code, !CI) :- FailInfo = fail_info(ResumePoints, ResumeKnown, _, _, _), ( ResumeKnown = resume_point_known(_), - stack__top_det(ResumePoints, TopResumePoint), + stack.top_det(ResumePoints, TopResumePoint), ( pick_matching_resume_addr(!.CI, TopResumePoint, FailureAddress0) -> FailureAddress = FailureAddress0, PlaceCode = empty ; pick_first_resume_point(TopResumePoint, Map, FailureAddress), - map__to_assoc_list(Map, AssocList), + map.to_assoc_list(Map, AssocList), remember_position(!.CI, CurPos), pick_and_place_vars(AssocList, _, PlaceCode, !CI), reset_to_position(CurPos, !CI) @@ -2145,16 +2145,16 @@ fail_if_rval_is_false(Rval0, Code, !CI) :- FailInfo = fail_info(ResumePoints, ResumeKnown, _, _, _), ( ResumeKnown = resume_point_known(_), - stack__top_det(ResumePoints, TopResumePoint), + stack.top_det(ResumePoints, TopResumePoint), ( pick_matching_resume_addr(!.CI, TopResumePoint, FailureAddress0) -> % We branch away if the test *fails* - code_util__neg_rval(Rval0, Rval), + code_util.neg_rval(Rval0, Rval), Code = node([ if_val(Rval, FailureAddress0) - "Test for failure" ]) ; pick_first_resume_point(TopResumePoint, Map, FailureAddress), - map__to_assoc_list(Map, AssocList), + map.to_assoc_list(Map, AssocList), get_next_label(SuccessLabel, !CI), remember_position(!.CI, CurPos), pick_and_place_vars(AssocList, _, PlaceCode, !CI), @@ -2176,7 +2176,7 @@ fail_if_rval_is_false(Rval0, Code, !CI) :- ; ResumeKnown = resume_point_unknown, % We branch away if the test *fails* - code_util__neg_rval(Rval0, Rval), + code_util.neg_rval(Rval0, Rval), Code = node([ if_val(Rval, do_redo) - "Test for failure" ]) @@ -2187,15 +2187,15 @@ fail_if_rval_is_false(Rval0, Code, !CI) :- failure_is_direct_branch(CI, CodeAddr) :- get_fail_info(CI, FailInfo), FailInfo = fail_info(ResumePoints, resume_point_known(_), _, _, _), - stack__top(ResumePoints, TopResumePoint), + stack.top(ResumePoints, TopResumePoint), pick_matching_resume_addr(CI, TopResumePoint, CodeAddr). may_use_nondet_tailcall(CI, TailCallStatus) :- get_fail_info(CI, FailInfo), FailInfo = fail_info(ResumePoints0, ResumeKnown, _, _, _), ( - stack__pop(ResumePoints0, ResumePoint1, ResumePoints1), - stack__is_empty(ResumePoints1), + stack.pop(ResumePoints0, ResumePoint1, ResumePoints1), + stack.is_empty(ResumePoints1), ResumePoint1 = stack_only(_, do_fail) -> ( @@ -2257,16 +2257,16 @@ pick_matching_resume_addr(CI, ResumeMaps, Addr) :- :- pred match_resume_loc(resume_map::in, resume_map::in) is semidet. match_resume_loc(Map, Locations0) :- - map__keys(Map, KeyList), - set__list_to_set(KeyList, Keys), - map__select(Locations0, Keys, Locations), - map__to_assoc_list(Locations, List), + map.keys(Map, KeyList), + set.list_to_set(KeyList, Keys), + map.select(Locations0, Keys, Locations), + map.to_assoc_list(Locations, List), ( - list__member(Var - Actual, List) + list.member(Var - Actual, List) => ( - map__search(Map, Var, Lvals), - set__subset(Lvals, Actual) + map.search(Map, Var, Lvals), + set.subset(Lvals, Actual) ) ). @@ -2301,7 +2301,7 @@ maybe_pick_stack_resume_point(stack_and_orig(Map, Addr, _, _), %---------------------------------------------------------------------------% produce_vars(Vars, Map, Code, !CI) :- - set__to_sorted_list(Vars, VarList), + set.to_sorted_list(Vars, VarList), produce_vars_2(VarList, Map, Code, !CI). :- pred produce_vars_2(list(prog_var)::in, @@ -2309,12 +2309,12 @@ produce_vars(Vars, Map, Code, !CI) :- code_tree::out, code_info::in, code_info::out) is det. produce_vars_2([], Map, empty, !CI) :- - map__init(Map). + map.init(Map). produce_vars_2([V | Vs], Map, Code, !CI) :- produce_vars_2(Vs, Map0, Code0, !CI), produce_variable_in_reg_or_stack(V, Code1, Lval, !CI), - set__singleton_set(Lvals, Lval), - map__set(Map0, V, Lvals, Map), + set.singleton_set(Lvals, Lval), + map.set(Map0, V, Lvals, Map), Code = tree(Code0, Code1). flush_resume_vars_to_stack(Code, !CI) :- @@ -2327,9 +2327,9 @@ flush_resume_vars_to_stack(Code, !CI) :- compute_resume_var_stack_locs(CI, VarLocs) :- get_fail_info(CI, FailInfo), FailInfo = fail_info(ResumePointStack, _, _, _, _), - stack__top_det(ResumePointStack, ResumePoint), + stack.top_det(ResumePointStack, ResumePoint), pick_stack_resume_point(ResumePoint, StackMap, _), - map__to_assoc_list(StackMap, VarLocSets), + map.to_assoc_list(StackMap, VarLocSets), pick_var_places(VarLocSets, VarLocs). %---------------------------------------------------------------------------% @@ -2367,19 +2367,19 @@ init_fail_info(CodeModel, MaybeFailVars, ResumePoint, !CI) :- ( MaybeFailVars = yes(FailVars), get_stack_slots(!.CI, StackSlots), - map__select(StackSlots, FailVars, AbsStackMap), - map__to_assoc_list(AbsStackMap, AbsStackList), - StackList0 = assoc_list__map_values(key_stack_slot_to_lval, + map.select(StackSlots, FailVars, AbsStackMap), + map.to_assoc_list(AbsStackMap, AbsStackList), + StackList0 = assoc_list.map_values(key_stack_slot_to_lval, AbsStackList), make_singleton_sets(StackList0, StackList), - map__from_assoc_list(StackList, StackMap) + map.from_assoc_list(StackList, StackMap) ; MaybeFailVars = no, - map__init(StackMap) + map.init(StackMap) ), ResumePoint = stack_only(StackMap, ResumeAddress), - stack__init(ResumeStack0), - stack__push(ResumeStack0, ResumePoint, ResumeStack), + stack.init(ResumeStack0), + stack.push(ResumeStack0, ResumePoint, ResumeStack), get_fail_info(!.CI, FailInfo0), FailInfo0 = fail_info(_, _, _, _, Allow), FailInfo = fail_info(ResumeStack, ResumeKnown, CurfrMaxfr, @@ -2390,7 +2390,7 @@ init_fail_info(CodeModel, MaybeFailVars, ResumePoint, !CI) :- make_resume_point(ResumeVars, ResumeLocs, FullMap, ResumePoint, !CI) :- get_stack_slots(!.CI, StackSlots), - map__select(FullMap, ResumeVars, OrigMap), + map.select(FullMap, ResumeVars, OrigMap), ( ResumeLocs = orig_only, get_next_label(OrigLabel, !CI), @@ -2424,18 +2424,18 @@ make_resume_point(ResumeVars, ResumeLocs, FullMap, ResumePoint, !CI) :- map(prog_var, set(lval))::out) is det. make_stack_resume_map(ResumeVars, StackSlots, StackMap) :- - map__select(StackSlots, ResumeVars, StackMap0), - map__to_assoc_list(StackMap0, AbsStackList), - StackList0 = assoc_list__map_values(key_stack_slot_to_lval, AbsStackList), + map.select(StackSlots, ResumeVars, StackMap0), + map.to_assoc_list(StackMap0, AbsStackList), + StackList0 = assoc_list.map_values(key_stack_slot_to_lval, AbsStackList), make_singleton_sets(StackList0, StackList), - map__from_assoc_list(StackList, StackMap). + map.from_assoc_list(StackList, StackMap). :- pred make_singleton_sets(assoc_list(prog_var, lval)::in, assoc_list(prog_var, set(lval))::out) is det. make_singleton_sets([], []). make_singleton_sets([V - L | Rest0], [V - Ls | Rest]) :- - set__singleton_set(Ls, L), + set.singleton_set(Ls, L), make_singleton_sets(Rest0, Rest). %---------------------------------------------------------------------------% @@ -2493,7 +2493,7 @@ generate_resume_point(ResumePoint, Code, !CI) :- ]), set_var_locations(Map1, !CI), generate_resume_layout(Label1, Map1, !CI), - map__to_assoc_list(Map2, AssocList2), + map.to_assoc_list(Map2, AssocList2), place_resume_vars(AssocList2, PlaceCode, !CI), Label2Code = node([ label(Label2) - "orig failure continuation after stack" @@ -2508,7 +2508,7 @@ generate_resume_point(ResumePoint, Code, !CI) :- label(Label1) - "orig failure continuation before stack" ]), set_var_locations(Map1, !CI), - map__to_assoc_list(Map2, AssocList2), + map.to_assoc_list(Map2, AssocList2), place_resume_vars(AssocList2, PlaceCode, !CI), Label2Code = node([ label(Label2) - "stack failure continuation after orig" @@ -2532,7 +2532,7 @@ extract_label_from_code_addr(CodeAddr, Label) :- place_resume_vars([], empty, !CI). place_resume_vars([Var - TargetSet | Rest], Code, !CI) :- - set__to_sorted_list(TargetSet, Targets), + set.to_sorted_list(TargetSet, Targets), place_resume_var(Var, Targets, FirstCode, !CI), Code = tree(FirstCode, RestCode), place_resume_vars(Rest, RestCode, !CI). @@ -2554,10 +2554,10 @@ place_resume_var(Var, [Target | Targets], Code, !CI) :- code_info::in, code_info::out) is det. set_var_locations(Map, !CI) :- - map__to_assoc_list(Map, LvalList0), + map.to_assoc_list(Map, LvalList0), flatten_varlval_list(LvalList0, LvalList), get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__reinit_state(LvalList, VarLocnInfo0, VarLocnInfo), + var_locn.reinit_state(LvalList, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). :- pred flatten_varlval_list(assoc_list(prog_var, set(lval))::in, @@ -2566,9 +2566,9 @@ set_var_locations(Map, !CI) :- flatten_varlval_list([], []). flatten_varlval_list([V - Rvals | Rest0], All) :- flatten_varlval_list(Rest0, Rest), - set__to_sorted_list(Rvals, RvalList), + set.to_sorted_list(Rvals, RvalList), flatten_varlval_list_2(RvalList, V, Rest1), - list__append(Rest1, Rest, All). + list.append(Rest1, Rest, All). :- pred flatten_varlval_list_2(list(lval)::in, prog_var::in, assoc_list(prog_var, lval)::out) is det. @@ -2579,7 +2579,7 @@ flatten_varlval_list_2([R | Rs], V, [V - R | Rest]) :- resume_point_vars(ResumePoint, Vars) :- pick_first_resume_point(ResumePoint, ResumeMap, _), - map__keys(ResumeMap, Vars). + map.keys(ResumeMap, Vars). resume_point_stack_addr(ResumePoint, StackAddr) :- pick_stack_resume_point(ResumePoint, _, StackAddr). @@ -2702,27 +2702,27 @@ clone_resume_point(ResumePoint0, ResumePoint, !CI) :- get_known_variables(CI, VarList) :- get_forward_live_vars(CI, ForwardLiveVars), ResumeVars = current_resume_point_vars(CI), - set__union(ForwardLiveVars, ResumeVars, Vars), - set__to_sorted_list(Vars, VarList). + set.union(ForwardLiveVars, ResumeVars, Vars), + set.to_sorted_list(Vars, VarList). variable_is_forward_live(CI, Var) :- get_forward_live_vars(CI, Liveness), - set__member(Var, Liveness). + set.member(Var, Liveness). add_forward_live_vars(Births, !CI) :- get_forward_live_vars(!.CI, Liveness0), - set__union(Liveness0, Births, Liveness), + set.union(Liveness0, Births, Liveness), set_forward_live_vars(Liveness, !CI). rem_forward_live_vars(Deaths, !CI) :- get_forward_live_vars(!.CI, Liveness0), - set__difference(Liveness0, Deaths, Liveness), + set.difference(Liveness0, Deaths, Liveness), set_forward_live_vars(Liveness, !CI). make_vars_forward_live(Vars, !CI) :- get_stack_slots(!.CI, StackSlots), get_var_locn_info(!.CI, VarLocnInfo0), - set__to_sorted_list(Vars, VarList), + set.to_sorted_list(Vars, VarList), make_vars_forward_live_2(VarList, StackSlots, 1, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). @@ -2733,20 +2733,20 @@ make_vars_forward_live(Vars, !CI) :- make_vars_forward_live_2([], _, _, !VarLocnInfo). make_vars_forward_live_2([Var | Vars], StackSlots, N0, !VarLocnInfo) :- - ( map__search(StackSlots, Var, Slot) -> + ( map.search(StackSlots, Var, Slot) -> Lval = stack_slot_to_lval(Slot), N1 = N0 ; find_unused_reg(!.VarLocnInfo, N0, N1), Lval = reg(r, N1) ), - var_locn__set_magic_var_location(Var, Lval, !VarLocnInfo), + var_locn.set_magic_var_location(Var, Lval, !VarLocnInfo), make_vars_forward_live_2(Vars, StackSlots, N1, !VarLocnInfo). :- pred find_unused_reg(var_locn_info::in, int::in, int::out) is det. find_unused_reg(VLI, N0, N) :- - ( var_locn__lval_in_use(VLI, reg(r, N0)) -> + ( var_locn.lval_in_use(VLI, reg(r, N0)) -> find_unused_reg(VLI, N0 + 1, N) ; N = N0 @@ -2760,12 +2760,12 @@ make_vars_forward_dead(Vars, !CI) :- maybe_make_vars_forward_dead(Vars0, FirstTime, !CI) :- ResumeVars = current_resume_point_vars(!.CI), - set__intersect(Vars0, ResumeVars, FlushVars), + set.intersect(Vars0, ResumeVars, FlushVars), get_zombies(!.CI, Zombies0), - set__union(Zombies0, FlushVars, Zombies), + set.union(Zombies0, FlushVars, Zombies), set_zombies(Zombies, !CI), - set__difference(Vars0, Zombies, Vars), - set__to_sorted_list(Vars, VarList), + set.difference(Vars0, Zombies, Vars), + set.to_sorted_list(Vars, VarList), maybe_make_vars_forward_dead_2(VarList, FirstTime, !CI). :- pred maybe_make_vars_forward_dead_2(list(prog_var)::in, bool::in, @@ -2774,13 +2774,13 @@ maybe_make_vars_forward_dead(Vars0, FirstTime, !CI) :- maybe_make_vars_forward_dead_2([], _, !CI). maybe_make_vars_forward_dead_2([V | Vs], FirstTime, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__var_becomes_dead(V, FirstTime, VarLocnInfo0, VarLocnInfo), + var_locn.var_becomes_dead(V, FirstTime, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI), maybe_make_vars_forward_dead_2(Vs, FirstTime, !CI). pickup_zombies(Zombies, !CI) :- get_zombies(!.CI, Zombies), - set_zombies(set__init, !CI). + set_zombies(set.init, !CI). %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% @@ -3170,12 +3170,12 @@ maybe_discard_and_release_ticket(MaybeTicketSlot, Code, !CI) :- variable_locations(CI, Lvals) :- get_var_locn_info(CI, VarLocnInfo), - var_locn__get_var_locations(VarLocnInfo, Lvals). + var_locn.get_var_locations(VarLocnInfo, Lvals). :- func rval_map_to_lval_map(prog_var, set(rval)) = set(lval). rval_map_to_lval_map(_Var, Rvals) = - set__filter_map(rval_is_lval, Rvals). + set.filter_map(rval_is_lval, Rvals). :- func rval_is_lval(rval) = lval is semidet. @@ -3183,35 +3183,35 @@ rval_is_lval(lval(Lval)) = Lval. set_var_location(Var, Lval, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__check_and_set_magic_var_location(Var, Lval, + var_locn.check_and_set_magic_var_location(Var, Lval, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). assign_var_to_var(Var, AssignedVar, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__assign_var_to_var(Var, AssignedVar, VarLocnInfo0, VarLocnInfo), + var_locn.assign_var_to_var(Var, AssignedVar, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). assign_lval_to_var(Var, Lval, Code, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), get_static_cell_info(!.CI, StaticCellInfo), get_module_info(!.CI, ModuleInfo), - var_locn__assign_lval_to_var(ModuleInfo, Var, Lval, StaticCellInfo, Code, + var_locn.assign_lval_to_var(ModuleInfo, Var, Lval, StaticCellInfo, Code, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). assign_const_to_var(Var, ConstRval, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__assign_const_to_var(Var, ConstRval, VarLocnInfo0, VarLocnInfo), + var_locn.assign_const_to_var(Var, ConstRval, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). assign_expr_to_var(Var, Rval, Code, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), ( - code_util__lvals_in_rval(Rval, Lvals), + code_util.lvals_in_rval(Rval, Lvals), Lvals = [] -> - var_locn__assign_expr_to_var(Var, Rval, Code, + var_locn.assign_expr_to_var(Var, Rval, Code, VarLocnInfo0, VarLocnInfo) ; unexpected(this_file, "assign_expr_to_var: non-var lvals") @@ -3223,7 +3223,7 @@ assign_cell_to_var(Var, ReserveWordAtStart, Ptag, Vector, MaybeSize, get_var_locn_info(!.CI, VarLocnInfo0), get_static_cell_info(!.CI, StaticCellInfo0), get_module_info(!.CI, ModuleInfo), - var_locn__assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag, + var_locn.assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag, Vector, MaybeSize, TypeMsg, Code, StaticCellInfo0, StaticCellInfo, VarLocnInfo0, VarLocnInfo), set_static_cell_info(StaticCellInfo, !CI), @@ -3232,7 +3232,7 @@ assign_cell_to_var(Var, ReserveWordAtStart, Ptag, Vector, MaybeSize, place_var(Var, Lval, Code, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), get_module_info(!.CI, ModuleInfo), - var_locn__place_var(ModuleInfo, Var, Lval, Code, + var_locn.place_var(ModuleInfo, Var, Lval, Code, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). @@ -3241,8 +3241,8 @@ place_var(Var, Lval, Code, !CI) :- pick_and_place_vars(VarLocSets, LiveLocs, Code, !CI) :- pick_var_places(VarLocSets, VarLocs), - assoc_list__values(VarLocs, Locs), - set__list_to_set(Locs, LiveLocs), + assoc_list.values(VarLocs, Locs), + set.list_to_set(Locs, LiveLocs), place_vars(VarLocs, Code, !CI). :- pred pick_var_places(assoc_list(prog_var, set(lval))::in, @@ -3252,7 +3252,7 @@ pick_var_places([], []). pick_var_places([Var - LvalSet | VarLvalSets], VarLvals) :- pick_var_places(VarLvalSets, VarLvals0), ( - set__to_sorted_list(LvalSet, LvalList), + set.to_sorted_list(LvalSet, LvalList), LvalList = [Lval | _] -> VarLvals = [Var - Lval | VarLvals0] @@ -3266,34 +3266,34 @@ pick_var_places([Var - LvalSet | VarLvalSets], VarLvals) :- place_vars(VarLocs, Code, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), get_module_info(!.CI, ModuleInfo), - var_locn__place_vars(ModuleInfo, VarLocs, Code, VarLocnInfo0, VarLocnInfo), + var_locn.place_vars(ModuleInfo, VarLocs, Code, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). produce_variable(Var, Code, Rval, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), get_module_info(!.CI, ModuleInfo), - var_locn__produce_var(ModuleInfo, Var, Rval, Code, + var_locn.produce_var(ModuleInfo, Var, Rval, Code, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). produce_variable_in_reg(Var, Code, Lval, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), get_module_info(!.CI, ModuleInfo), - var_locn__produce_var_in_reg(ModuleInfo, Var, Lval, Code, + var_locn.produce_var_in_reg(ModuleInfo, Var, Lval, Code, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). produce_variable_in_reg_or_stack(Var, Code, Lval, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), get_module_info(!.CI, ModuleInfo), - var_locn__produce_var_in_reg_or_stack(ModuleInfo, Var, Lval, Code, + var_locn.produce_var_in_reg_or_stack(ModuleInfo, Var, Lval, Code, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). materialize_vars_in_lval(Lval0, Lval, Code, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), get_module_info(!.CI, ModuleInfo), - var_locn__materialize_vars_in_lval(ModuleInfo, Lval0, Lval, Code, + var_locn.materialize_vars_in_lval(ModuleInfo, Lval0, Lval, Code, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). @@ -3302,16 +3302,16 @@ acquire_reg_for_var(Var, Lval, !CI) :- get_next_non_reserved(!.CI, NextNonReserved), get_var_locn_info(!.CI, VarLocnInfo0), ( - map__search(FollowVarsMap, Var, PrefLocn), + map.search(FollowVarsMap, Var, PrefLocn), PrefLocn = abs_reg(PrefRegNum), PrefRegNum >= 1 -> - var_locn__acquire_reg_prefer_given(PrefRegNum, Lval, + var_locn.acquire_reg_prefer_given(PrefRegNum, Lval, VarLocnInfo0, VarLocnInfo) ; - % XXX We should only get a register if the map__search + % XXX We should only get a register if the map.search % succeeded; otherwise we should put the var in its stack slot. - var_locn__acquire_reg_start_at_given(NextNonReserved, Lval, + var_locn.acquire_reg_start_at_given(NextNonReserved, Lval, VarLocnInfo0, VarLocnInfo) ), set_var_locn_info(VarLocnInfo, !CI). @@ -3319,24 +3319,24 @@ acquire_reg_for_var(Var, Lval, !CI) :- acquire_reg(Type, Lval, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), expect(unify(Type, r), this_file, "acquire_reg: unknown reg type"), - var_locn__acquire_reg(Lval, VarLocnInfo0, VarLocnInfo), + var_locn.acquire_reg(Lval, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). release_reg(Lval, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__release_reg(Lval, VarLocnInfo0, VarLocnInfo), + var_locn.release_reg(Lval, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). reserve_r1(Code, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), get_module_info(!.CI, ModuleInfo), - var_locn__clear_r1(ModuleInfo, Code, VarLocnInfo0, VarLocnInfo1), - var_locn__acquire_reg_require_given(reg(r, 1), VarLocnInfo1, VarLocnInfo), + var_locn.clear_r1(ModuleInfo, Code, VarLocnInfo0, VarLocnInfo1), + var_locn.acquire_reg_require_given(reg(r, 1), VarLocnInfo1, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). clear_r1(empty, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__release_reg(reg(r, 1), VarLocnInfo0, VarLocnInfo), + var_locn.release_reg(reg(r, 1), VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). %---------------------------------------------------------------------------% @@ -3346,8 +3346,8 @@ setup_return(VarArgInfos, OutLocs, Code, !CI) :- setup_call(GoalInfo, ArgInfos, LiveLocs, Code, !CI) :- partition_args(ArgInfos, InArgInfos, OutArgInfos, _UnusedArgInfos), - assoc_list__keys(OutArgInfos, OutVars), - set__list_to_set(OutVars, OutVarSet), + assoc_list.keys(OutArgInfos, OutVars), + set.list_to_set(OutVars, OutVarSet), goal_info_get_determinism(GoalInfo, Detism), get_opt_no_return_calls(!.CI, OptNoReturnCalls), get_module_info(!.CI, ModuleInfo), @@ -3371,28 +3371,28 @@ setup_call(GoalInfo, ArgInfos, LiveLocs, Code, !CI) :- % is delayed until the first call after the setup of the % resume point. compute_resume_var_stack_locs(!.CI, ResumeVarLocs), - list__append(ResumeVarLocs, ForwardVarLocs, StackVarLocs) + list.append(ResumeVarLocs, ForwardVarLocs, StackVarLocs) ; StackVarLocs = ForwardVarLocs ), VarTypes = get_var_types(!.CI), - list__filter(valid_stack_slot(ModuleInfo, VarTypes), StackVarLocs, + list.filter(valid_stack_slot(ModuleInfo, VarTypes), StackVarLocs, RealStackVarLocs, DummyStackVarLocs) ), get_var_locn_info(!.CI, VarLocnInfo0), var_arg_info_to_lval(InArgInfos, InArgLocs), - list__append(RealStackVarLocs, InArgLocs, AllRealLocs), - var_locn__place_vars(ModuleInfo, DummyStackVarLocs ++ AllRealLocs, Code, + list.append(RealStackVarLocs, InArgLocs, AllRealLocs), + var_locn.place_vars(ModuleInfo, DummyStackVarLocs ++ AllRealLocs, Code, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI), - assoc_list__values(AllRealLocs, LiveLocList), - set__list_to_set(LiveLocList, LiveLocs). + assoc_list.values(AllRealLocs, LiveLocList), + set.list_to_set(LiveLocList, LiveLocs). :- pred valid_stack_slot(module_info::in, vartypes::in, pair(prog_var, lval)::in) is semidet. valid_stack_slot(ModuleInfo, VarTypes, Var - Lval) :- - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ( is_dummy_argument_type(ModuleInfo, Type) -> fail ; @@ -3414,19 +3414,19 @@ valid_stack_slot(ModuleInfo, VarTypes, Var - Lval) :- code_info::in, code_info::out) is det. setup_call_args(AllArgsInfos, Direction, LiveLocs, Code, !CI) :- - list__filter(call_arg_in_selected_dir(Direction), + list.filter(call_arg_in_selected_dir(Direction), AllArgsInfos, ArgsInfos), var_arg_info_to_lval(ArgsInfos, ArgsLocns), get_module_info(!.CI, ModuleInfo), get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__place_vars(ModuleInfo, ArgsLocns, Code, + var_locn.place_vars(ModuleInfo, ArgsLocns, Code, VarLocnInfo0, VarLocnInfo1), set_var_locn_info(VarLocnInfo1, !CI), - assoc_list__values(ArgsLocns, LiveLocList), - set__list_to_set(LiveLocList, LiveLocs), - assoc_list__keys(ArgsLocns, ArgVars), + assoc_list.values(ArgsLocns, LiveLocList), + set.list_to_set(LiveLocList, LiveLocs), + assoc_list.keys(ArgsLocns, ArgVars), which_variables_are_forward_live(!.CI, ArgVars, - set__init, DeadVars), + set.init, DeadVars), make_vars_forward_dead(DeadVars, !CI). :- pred var_arg_info_to_lval(assoc_list(prog_var, arg_info)::in, @@ -3436,7 +3436,7 @@ var_arg_info_to_lval([], []). var_arg_info_to_lval([Var - ArgInfo | RestInfos], [Var - Lval | RestLvals]) :- ArgInfo = arg_info(Loc, _Mode), - code_util__arg_loc_to_register(Loc, Lval), + code_util.arg_loc_to_register(Loc, Lval), var_arg_info_to_lval(RestInfos, RestLvals). :- pred which_variables_are_forward_live(code_info::in, @@ -3447,7 +3447,7 @@ which_variables_are_forward_live(CI, [Var | Vars], !DeadVars) :- ( variable_is_forward_live(CI, Var) -> true ; - set__insert(!.DeadVars, Var, !:DeadVars) + set.insert(!.DeadVars, Var, !:DeadVars) ), which_variables_are_forward_live(CI, Vars, !DeadVars). @@ -3465,32 +3465,32 @@ call_arg_in_selected_dir(Direction, _ - arg_info(_, Mode)) :- lock_regs(N, Exceptions, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__lock_regs(N, Exceptions, VarLocnInfo0, VarLocnInfo), + var_locn.lock_regs(N, Exceptions, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). unlock_regs(!CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__unlock_regs(VarLocnInfo0, VarLocnInfo), + var_locn.unlock_regs(VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). clear_all_registers(OkToDeleteAny, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__clobber_all_regs(OkToDeleteAny, VarLocnInfo0, VarLocnInfo), + var_locn.clobber_all_regs(OkToDeleteAny, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). clobber_regs(Regs, !CI) :- get_var_locn_info(!.CI, VarLocnInfo0), - var_locn__clobber_regs(Regs, VarLocnInfo0, VarLocnInfo), + var_locn.clobber_regs(Regs, VarLocnInfo0, VarLocnInfo), set_var_locn_info(VarLocnInfo, !CI). save_variables(OutArgs, SavedLocs, Code, !CI) :- compute_forward_live_var_saves(!.CI, OutArgs, VarLocs), - assoc_list__values(VarLocs, SavedLocList), - set__list_to_set(SavedLocList, SavedLocs), + assoc_list.values(VarLocs, SavedLocList), + set.list_to_set(SavedLocList, SavedLocs), place_vars(VarLocs, Code, !CI). save_variables_on_stack(Vars, Code, !CI) :- - list__map(associate_stack_slot(!.CI), Vars, VarLocs), + list.map(associate_stack_slot(!.CI), Vars, VarLocs), place_vars(VarLocs, Code, !CI). :- pred compute_forward_live_var_saves(code_info::in, @@ -3498,16 +3498,16 @@ save_variables_on_stack(Vars, Code, !CI) :- compute_forward_live_var_saves(CI, OutArgs, VarLocs) :- get_known_variables(CI, Variables0), - set__list_to_set(Variables0, Vars0), + set.list_to_set(Variables0, Vars0), TypeInfoLiveness = body_typeinfo_liveness(CI), get_proc_info(CI, ProcInfo), proc_info_vartypes(ProcInfo, VarTypes), proc_info_rtti_varmaps(ProcInfo, RttiVarMaps), proc_info_maybe_complete_with_typeinfo_vars(Vars0, TypeInfoLiveness, VarTypes, RttiVarMaps, Vars1), - set__difference(Vars1, OutArgs, Vars), - set__to_sorted_list(Vars, Variables), - list__map(associate_stack_slot(CI), Variables, VarLocs). + set.difference(Vars1, OutArgs, Vars), + set.to_sorted_list(Vars, Variables), + list.map(associate_stack_slot(CI), Variables, VarLocs). :- pred associate_stack_slot(code_info::in, prog_var::in, pair(prog_var, lval)::out) is det. @@ -3517,7 +3517,7 @@ associate_stack_slot(CI, Var, Var - Slot) :- max_reg_in_use(CI, Max) :- get_var_locn_info(CI, VarLocnInfo), - var_locn__max_reg_in_use(VarLocnInfo, Max). + var_locn.max_reg_in_use(VarLocnInfo, Max). %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% @@ -3553,12 +3553,12 @@ generate_call_stack_vn_livevals(CI, OutputArgs, LiveVals) :- get_known_variables(CI, KnownVarList0), get_module_info(CI, ModuleInfo), VarTypes = get_var_types(CI), - list__filter(var_is_of_dummy_type(ModuleInfo, VarTypes), KnownVarList0, + list.filter(var_is_of_dummy_type(ModuleInfo, VarTypes), KnownVarList0, _, KnownVarList), - set__list_to_set(KnownVarList, KnownVars), - set__difference(KnownVars, OutputArgs, LiveVars), - set__to_sorted_list(LiveVars, LiveVarList), - generate_stack_var_vn(CI, LiveVarList, set__init, LiveVals1), + set.list_to_set(KnownVarList, KnownVars), + set.difference(KnownVars, OutputArgs, LiveVars), + set.to_sorted_list(LiveVars, LiveVarList), + generate_stack_var_vn(CI, LiveVarList, set.init, LiveVals1), get_active_temps_data(CI, Temps), generate_call_temp_vn(Temps, LiveVals1, LiveVals). @@ -3568,7 +3568,7 @@ generate_call_stack_vn_livevals(CI, OutputArgs, LiveVals) :- generate_stack_var_vn(_, [], !Vals). generate_stack_var_vn(CI, [V | Vs], !Vals) :- get_variable_slot(CI, V, Lval), - set__insert(!.Vals, Lval, !:Vals), + set.insert(!.Vals, Lval, !:Vals), generate_stack_var_vn(CI, Vs, !Vals). :- pred generate_call_temp_vn(assoc_list(lval, slot_contents)::in, @@ -3576,7 +3576,7 @@ generate_stack_var_vn(CI, [V | Vs], !Vals) :- generate_call_temp_vn([], !Vals). generate_call_temp_vn([Lval - _ | Temps], !Vals) :- - set__insert(!.Vals, Lval, !:Vals), + set.insert(!.Vals, Lval, !:Vals), generate_call_temp_vn(Temps, !Vals). :- pred generate_input_var_vn(list(arg_loc)::in, @@ -3584,8 +3584,8 @@ generate_call_temp_vn([Lval - _ | Temps], !Vals) :- generate_input_var_vn([], !Vals). generate_input_var_vn([InputArgLoc | InputArgLocs], !Vals) :- - code_util__arg_loc_to_register(InputArgLoc, Lval), - set__insert(!.Vals, Lval, !:Vals), + code_util.arg_loc_to_register(InputArgLoc, Lval), + set.insert(!.Vals, Lval, !:Vals), generate_input_var_vn(InputArgLocs, !Vals). %---------------------------------------------------------------------------% @@ -3596,11 +3596,11 @@ generate_return_live_lvalues(CI, OutputArgLocs, ReturnInstMap, get_known_variables(CI, Vars0), get_module_info(CI, ModuleInfo), VarTypes = get_var_types(CI), - list__filter(var_is_of_dummy_type(ModuleInfo, VarTypes), Vars0, _, Vars), + list.filter(var_is_of_dummy_type(ModuleInfo, VarTypes), Vars0, _, Vars), get_active_temps_data(CI, Temps), get_proc_info(CI, ProcInfo), get_globals(CI, Globals), - continuation_info__generate_return_live_lvalues(OutputArgLocs, + continuation_info.generate_return_live_lvalues(OutputArgLocs, ReturnInstMap, Vars, VarLocs, Temps, ProcInfo, ModuleInfo, Globals, OkToDeleteAny, LiveLvalues). @@ -3609,14 +3609,14 @@ generate_return_live_lvalues(CI, OutputArgLocs, ReturnInstMap, generate_resume_layout(Label, ResumeMap, !CI) :- get_globals(!.CI, Globals), - globals__lookup_bool_option(Globals, agc_stack_layout, AgcStackLayout), + globals.lookup_bool_option(Globals, agc_stack_layout, AgcStackLayout), ( AgcStackLayout = yes, get_active_temps_data(!.CI, Temps), get_instmap(!.CI, InstMap), get_proc_info(!.CI, ProcInfo), get_module_info(!.CI, ModuleInfo), - continuation_info__generate_resume_layout(ResumeMap, Temps, InstMap, + continuation_info.generate_resume_layout(ResumeMap, Temps, InstMap, ProcInfo, ModuleInfo, Layout), add_resume_layout_for_label(Label, Layout, !CI) ; @@ -3691,11 +3691,11 @@ acquire_temp_slot(Item, StackVar, !CI) :- IsTempUsable = (pred(TempContent::in, Lval::out) is semidet :- TempContent = Lval - ContentType, ContentType = Item, - \+ set__member(Lval, TempsInUse0) + \+ set.member(Lval, TempsInUse0) ), get_temp_content_map(!.CI, TempContentMap0), - map__to_assoc_list(TempContentMap0, TempContentList), - list__filter_map(IsTempUsable, TempContentList, UsableLvals), + map.to_assoc_list(TempContentMap0, TempContentList), + list.filter_map(IsTempUsable, TempContentList, UsableLvals), ( UsableLvals = [UsableLval | _], StackVar = UsableLval @@ -3707,28 +3707,28 @@ acquire_temp_slot(Item, StackVar, !CI) :- Slot = VarSlots + TempSlots, stack_variable(!.CI, Slot, StackVar), set_max_temp_slot_count(TempSlots, !CI), - map__det_insert(TempContentMap0, StackVar, Item, TempContentMap), + map.det_insert(TempContentMap0, StackVar, Item, TempContentMap), set_temp_content_map(TempContentMap, !CI) ), - set__insert(TempsInUse0, StackVar, TempsInUse), + set.insert(TempsInUse0, StackVar, TempsInUse), set_temps_in_use(TempsInUse, !CI). release_temp_slot(StackVar, !CI) :- get_temps_in_use(!.CI, TempsInUse0), - set__delete(TempsInUse0, StackVar, TempsInUse), + set.delete(TempsInUse0, StackVar, TempsInUse), set_temps_in_use(TempsInUse, !CI). %---------------------------------------------------------------------------% get_variable_slot(CI, Var, Slot) :- get_stack_slots(CI, StackSlots), - ( map__search(StackSlots, Var, SlotLocn) -> + ( map.search(StackSlots, Var, SlotLocn) -> Slot = stack_slot_to_lval(SlotLocn) ; Name = variable_to_string(CI, Var), - term__var_to_int(Var, Num), - string__int_to_string(Num, NumStr), - string__append_list(["get_variable_slot: variable `", + term.var_to_int(Var, Num), + string.int_to_string(Num, NumStr), + string.append_list(["get_variable_slot: variable `", Name, "' (", NumStr, ") not found"], Str), unexpected(this_file, Str) ). @@ -3741,20 +3741,19 @@ get_total_stackslot_count(CI, NumSlots) :- :- pred max_var_slot(stack_slots::in, int::out) is det. max_var_slot(StackSlots, SlotCount) :- - map__values(StackSlots, StackSlotList), + map.values(StackSlots, StackSlotList), max_var_slot_2(StackSlotList, 0, SlotCount). -:- pred max_var_slot_2(list(stack_slot)::in, int::in, int::out) - is det. +:- pred max_var_slot_2(list(stack_slot)::in, int::in, int::out) is det. max_var_slot_2([], !Max). max_var_slot_2([L | Ls], !Max) :- ( L = det_slot(N), - int__max(N, !Max) + int.max(N, !Max) ; L = nondet_slot(N), - int__max(N, !Max) + int.max(N, !Max) ), max_var_slot_2(Ls, !Max). diff --git a/compiler/code_util.m b/compiler/code_util.m index 33863e6cc..fd8d5bb0a 100644 --- a/compiler/code_util.m +++ b/compiler/code_util.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__code_util. +:- module ll_backend.code_util. :- interface. :- import_module hlds.hlds_goal. @@ -129,7 +129,7 @@ %---------------------------------------------------------------------------% make_entry_label(ModuleInfo, PredId, ProcId, Immed, ProcAddr) :- - RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId), + RttiProcLabel = rtti.make_rtti_proc_label(ModuleInfo, PredId, ProcId), make_entry_label_from_rtti(RttiProcLabel, Immed, ProcAddr). make_entry_label_from_rtti(RttiProcLabel, Immed, ProcAddr) :- @@ -142,7 +142,7 @@ make_entry_label_from_rtti(RttiProcLabel, Immed, ProcAddr) :- ). make_local_entry_label(ModuleInfo, PredId, ProcId, Immed, Label) :- - RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId), + RttiProcLabel = rtti.make_rtti_proc_label(ModuleInfo, PredId, ProcId), make_local_entry_label_from_rtti(RttiProcLabel, Immed, Label). :- pred make_local_entry_label_from_rtti(rtti_proc_label::in, @@ -219,7 +219,7 @@ max_mentioned_reg(Lvals, MaxRegNum) :- max_mentioned_reg_2([], !MaxRegNum). max_mentioned_reg_2([Lval | Lvals], !MaxRegNum) :- ( Lval = reg(r, N) -> - int__max(N, !MaxRegNum) + int.max(N, !MaxRegNum) ; true ), @@ -233,7 +233,7 @@ max_mentioned_abs_reg(Lvals, MaxRegNum) :- max_mentioned_abs_reg_2([], !MaxRegNum). max_mentioned_abs_reg_2([Lval | Lvals], !MaxRegNum) :- ( Lval = abs_reg(N) -> - int__max(N, !MaxRegNum) + int.max(N, !MaxRegNum) ; true ), @@ -378,7 +378,7 @@ lvals_in_lvals([], []). lvals_in_lvals([First | Rest], Lvals) :- lvals_in_lval(First, FirstLvals), lvals_in_lvals(Rest, RestLvals), - list__append(FirstLvals, RestLvals, Lvals). + list.append(FirstLvals, RestLvals, Lvals). lvals_in_rval(lval(Lval), [Lval | Lvals]) :- lvals_in_lval(Lval, Lvals). @@ -391,7 +391,7 @@ lvals_in_rval(unop(_, Rval), Lvals) :- lvals_in_rval(binop(_, Rval1, Rval2), Lvals) :- lvals_in_rval(Rval1, Lvals1), lvals_in_rval(Rval2, Lvals2), - list__append(Lvals1, Lvals2, Lvals). + list.append(Lvals1, Lvals2, Lvals). lvals_in_rval(mem_addr(MemRef), Lvals) :- lvals_in_mem_ref(MemRef, Lvals). @@ -416,7 +416,7 @@ lvals_in_lval(sp, []). lvals_in_lval(field(_, Rval1, Rval2), Lvals) :- lvals_in_rval(Rval1, Lvals1), lvals_in_rval(Rval2, Lvals2), - list__append(Lvals1, Lvals2, Lvals). + list.append(Lvals1, Lvals2, Lvals). lvals_in_lval(lvar(_), []). lvals_in_lval(temp(_, _), []). lvals_in_lval(mem_ref(Rval), Lvals) :- @@ -434,7 +434,7 @@ lvals_in_mem_ref(heap_ref(Rval, _, _), Lvals) :- build_input_arg_list(ProcInfo, VarLvals) :- proc_info_headvars(ProcInfo, HeadVars), proc_info_arg_info(ProcInfo, ArgInfos), - assoc_list__from_corresponding_lists(HeadVars, ArgInfos, VarArgInfos), + assoc_list.from_corresponding_lists(HeadVars, ArgInfos, VarArgInfos), build_input_arg_list_2(VarArgInfos, VarLvals). :- pred build_input_arg_list_2(assoc_list(prog_var, arg_info)::in, diff --git a/compiler/commit_gen.m b/compiler/commit_gen.m index 41006bfbc..623bebfda 100644 --- a/compiler/commit_gen.m +++ b/compiler/commit_gen.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 1997-1998, 2003-2005 The University of Melbourne. +% Copyright (C) 1997-1998, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -13,7 +13,7 @@ % %---------------------------------------------------------------------------% -:- module ll_backend__commit_gen. +:- module ll_backend.commit_gen. :- interface. :- import_module hlds.code_model. @@ -47,38 +47,38 @@ generate_commit(AddTrailOps, OuterCodeModel, Goal, Code, !Info) :- OuterCodeModel = model_det, ( InnerCodeModel = model_det, - code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info) + code_gen.generate_goal(InnerCodeModel, Goal, Code, !Info) ; InnerCodeModel = model_semi, unexpected(this_file, "generate_commit: " ++ "semidet model in det context") ; InnerCodeModel = model_non, - code_info__prepare_for_det_commit(AddTrailOps, CommitInfo, + code_info.prepare_for_det_commit(AddTrailOps, CommitInfo, PreCommit, !Info), - code_gen__generate_goal(InnerCodeModel, Goal, GoalCode, !Info), - code_info__generate_det_commit(CommitInfo, Commit, !Info), + code_gen.generate_goal(InnerCodeModel, Goal, GoalCode, !Info), + code_info.generate_det_commit(CommitInfo, Commit, !Info), Code = tree(PreCommit, tree(GoalCode, Commit)) ) ; OuterCodeModel = model_semi, ( InnerCodeModel = model_det, - code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info) + code_gen.generate_goal(InnerCodeModel, Goal, Code, !Info) ; InnerCodeModel = model_semi, - code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info) + code_gen.generate_goal(InnerCodeModel, Goal, Code, !Info) ; InnerCodeModel = model_non, - code_info__prepare_for_semi_commit(AddTrailOps, CommitInfo, + code_info.prepare_for_semi_commit(AddTrailOps, CommitInfo, PreCommit, !Info), - code_gen__generate_goal(InnerCodeModel, Goal, GoalCode, !Info), - code_info__generate_semi_commit(CommitInfo, Commit, !Info), + code_gen.generate_goal(InnerCodeModel, Goal, GoalCode, !Info), + code_info.generate_semi_commit(CommitInfo, Commit, !Info), Code = tree(PreCommit, tree(GoalCode, Commit)) ) ; OuterCodeModel = model_non, - code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info) + code_gen.generate_goal(InnerCodeModel, Goal, Code, !Info) ). %---------------------------------------------------------------------------% diff --git a/compiler/common.m b/compiler/common.m index 850579f3f..936c85ea3 100644 --- a/compiler/common.m +++ b/compiler/common.m @@ -28,7 +28,7 @@ %---------------------------------------------------------------------------% -:- module check_hlds__common. +:- module check_hlds.common. :- interface. :- import_module check_hlds.simplify. @@ -225,13 +225,13 @@ %---------------------------------------------------------------------------% common_info_init = CommonInfo :- - eqvclass__init(VarEqv0), - map__init(StructMap0), - map__init(SeenCalls0), + eqvclass.init(VarEqv0), + map.init(StructMap0), + map.init(SeenCalls0), CommonInfo = common_info(VarEqv0, StructMap0, StructMap0, SeenCalls0). common_info_clear_structs(!Info) :- - !:Info = !.Info ^ since_call_structs := map__init. + !:Info = !.Info ^ since_call_structs := map.init. %---------------------------------------------------------------------------% @@ -293,7 +293,7 @@ optimise_construct(Var, ConsId, ArgVars, Mode, Goal0, Goal, TypeCtor = lookup_var_type_ctor(!.Info, Var), simplify_info_get_common_info(!.Info, CommonInfo0), VarEqv0 = CommonInfo0 ^ var_eqv, - list__map_foldl(eqvclass__ensure_element_partition_id, + list.map_foldl(eqvclass.ensure_element_partition_id, ArgVars, ArgVarIds, VarEqv0, VarEqv1), AllStructMap0 = CommonInfo0 ^ all_structs, ( @@ -304,13 +304,13 @@ optimise_construct(Var, ConsId, ArgVars, Mode, Goal0, Goal, goal_info_get_instmap_delta(GoalInfo0, InstMapDelta), instmap_delta_search_var(InstMapDelta, Var, _), - map__search(AllStructMap0, TypeCtor, ConsIdMap0), - map__search(ConsIdMap0, ConsId, Structs), + map.search(AllStructMap0, TypeCtor, ConsIdMap0), + map.search(ConsIdMap0, ConsId, Structs), find_matching_cell_construct(Structs, VarEqv1, ArgVarIds, OldStruct) -> OldStruct = structure(OldVar, _), - sveqvclass__ensure_equivalence(Var, OldVar, VarEqv1, VarEqv), + sveqvclass.ensure_equivalence(Var, OldVar, VarEqv1, VarEqv), CommonInfo = CommonInfo0 ^ var_eqv := VarEqv, simplify_info_set_common_info(CommonInfo, !Info), ( @@ -326,7 +326,7 @@ optimise_construct(Var, ConsId, ArgVars, Mode, Goal0, Goal, generate_assign(Var, OldVar, UniMode, GoalInfo0, Goal - GoalInfo, !Info), simplify_info_set_requantify(!Info), - pd_cost__goal(Goal0 - GoalInfo0, Cost), + goal_cost(Goal0 - GoalInfo0, Cost), simplify_info_incr_cost_delta(Cost, !Info) ) ; @@ -360,7 +360,7 @@ optimise_deconstruct(Var, ConsId, ArgVars, UniModes, CanFail, Mode, TypeCtor = lookup_var_type_ctor(!.Info, Var), simplify_info_get_common_info(!.Info, CommonInfo0), VarEqv0 = CommonInfo0 ^ var_eqv, - eqvclass__ensure_element_partition_id(Var, VarId, VarEqv0, VarEqv1), + eqvclass.ensure_element_partition_id(Var, VarId, VarEqv0, VarEqv1), SinceCallStructMap0 = CommonInfo0 ^ since_call_structs, ( % Do not delete deconstruction unifications inserted by @@ -369,19 +369,19 @@ optimise_deconstruct(Var, ConsId, ArgVars, UniModes, CanFail, Mode, \+ goal_info_has_feature(GoalInfo, stack_opt), \+ goal_info_has_feature(GoalInfo, tuple_opt), - map__search(SinceCallStructMap0, TypeCtor, ConsIdMap0), - map__search(ConsIdMap0, ConsId, Structs), + map.search(SinceCallStructMap0, TypeCtor, ConsIdMap0), + map.search(ConsIdMap0, ConsId, Structs), find_matching_cell_deconstruct(Structs, VarEqv1, VarId, OldStruct) -> OldStruct = structure(_, OldArgVars), - eqvclass__ensure_corresponding_equivalences(ArgVars, + eqvclass.ensure_corresponding_equivalences(ArgVars, OldArgVars, VarEqv1, VarEqv), CommonInfo = CommonInfo0 ^ var_eqv := VarEqv, simplify_info_set_common_info(CommonInfo, !Info), create_output_unifications(GoalInfo0, ArgVars, OldArgVars, UniModes, Goals, !Info), Goal = conj(plain_conj, Goals), - pd_cost__goal(Goal0 - GoalInfo0, Cost), + goal_cost(Goal0 - GoalInfo0, Cost), simplify_info_incr_cost_delta(Cost, !Info), simplify_info_set_requantify(!Info), ( @@ -402,7 +402,7 @@ optimise_deconstruct(Var, ConsId, ArgVars, UniModes, CanFail, Mode, lookup_var_type_ctor(Info, Var) = TypeCtor :- simplify_info_get_var_types(Info, VarTypes), - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ( type_to_ctor_and_args(Type, TypeCtorPrime, _) -> TypeCtor = TypeCtorPrime ; @@ -448,7 +448,7 @@ ids_vars_match([Id | Ids], [Var | Vars], VarEqv) :- eqvclass(prog_var)::in) is semidet. id_var_match(Id, Var, VarEqv) :- - eqvclass__partition_id(VarEqv, Var, VarId), + eqvclass.partition_id(VarEqv, Var, VarId), Id = VarId. %---------------------------------------------------------------------------% @@ -475,17 +475,17 @@ record_cell_in_maps(TypeCtor, ConsId, Struct, VarEqv, !Info) :- structure::in, struct_map::in, struct_map::out) is det. do_record_cell_in_struct_map(TypeCtor, ConsId, Struct, !StructMap) :- - ( map__search(!.StructMap, TypeCtor, ConsIdMap0) -> - ( map__search(ConsIdMap0, ConsId, Structs0) -> + ( map.search(!.StructMap, TypeCtor, ConsIdMap0) -> + ( map.search(ConsIdMap0, ConsId, Structs0) -> Structs = [Struct | Structs0], - map__det_update(ConsIdMap0, ConsId, Structs, ConsIdMap) + map.det_update(ConsIdMap0, ConsId, Structs, ConsIdMap) ; - map__det_insert(ConsIdMap0, ConsId, [Struct], ConsIdMap) + map.det_insert(ConsIdMap0, ConsId, [Struct], ConsIdMap) ), - svmap__det_update(TypeCtor, ConsIdMap, !StructMap) + svmap.det_update(TypeCtor, ConsIdMap, !StructMap) ; - map__det_insert(map__init, ConsId, [Struct], ConsIdMap), - svmap__det_insert(TypeCtor, ConsIdMap, !StructMap) + map.det_insert(map.init, ConsId, [Struct], ConsIdMap), + svmap.det_insert(TypeCtor, ConsIdMap, !StructMap) ). %---------------------------------------------------------------------------% @@ -496,7 +496,7 @@ do_record_cell_in_struct_map(TypeCtor, ConsId, Struct, !StructMap) :- record_equivalence(Var1, Var2, !Info) :- simplify_info_get_common_info(!.Info, CommonInfo0), VarEqv0 = CommonInfo0 ^ var_eqv, - eqvclass__ensure_equivalence(VarEqv0, Var1, Var2, VarEqv), + eqvclass.ensure_equivalence(VarEqv0, Var1, Var2, VarEqv), CommonInfo = CommonInfo0 ^ var_eqv := VarEqv, simplify_info_set_common_info(CommonInfo, !Info). @@ -555,7 +555,7 @@ optimise_call_2(SeenCall, InputArgs, OutputArgs, Modes, GoalInfo, simplify_info_get_common_info(!.Info, CommonInfo0), Eqv0 = CommonInfo0 ^ var_eqv, SeenCalls0 = CommonInfo0 ^ seen_calls, - ( map__search(SeenCalls0, SeenCall, SeenCallsList0) -> + ( map.search(SeenCalls0, SeenCall, SeenCallsList0) -> ( find_previous_call(SeenCallsList0, InputArgs, Eqv0, OutputArgs2, PrevContext) @@ -569,10 +569,10 @@ optimise_call_2(SeenCall, InputArgs, OutputArgs, Modes, GoalInfo, ( simplify_do_warn_calls(!.Info), % Don't warn for cases such as: - % set__init(Set1 : set(int)), - % set__init(Set2 : set(float)). - map__apply_to_list(OutputArgs, VarTypes, OutputArgTypes1), - map__apply_to_list(OutputArgs2, VarTypes, OutputArgTypes2), + % set.init(Set1 : set(int)), + % set.init(Set2 : set(float)). + map.apply_to_list(OutputArgs, VarTypes, OutputArgTypes1), + map.apply_to_list(OutputArgs2, VarTypes, OutputArgTypes2), types_match_exactly_list(OutputArgTypes1, OutputArgTypes2) -> goal_info_get_context(GoalInfo, Context), @@ -583,7 +583,7 @@ optimise_call_2(SeenCall, InputArgs, OutputArgs, Modes, GoalInfo, true ), CommonInfo = CommonInfo0, - pd_cost__goal(Goal0 - GoalInfo, Cost), + goal_cost(Goal0 - GoalInfo, Cost), simplify_info_incr_cost_delta(Cost, !Info), simplify_info_set_requantify(!Info), goal_info_get_determinism(GoalInfo, Detism0), @@ -595,7 +595,7 @@ optimise_call_2(SeenCall, InputArgs, OutputArgs, Modes, GoalInfo, ; goal_info_get_context(GoalInfo, Context), ThisCall = call_args(Context, InputArgs, OutputArgs), - map__det_update(SeenCalls0, SeenCall, [ThisCall | SeenCallsList0], + map.det_update(SeenCalls0, SeenCall, [ThisCall | SeenCallsList0], SeenCalls), CommonInfo = CommonInfo0 ^ seen_calls := SeenCalls, Goal = Goal0 @@ -603,7 +603,7 @@ optimise_call_2(SeenCall, InputArgs, OutputArgs, Modes, GoalInfo, ; goal_info_get_context(GoalInfo, Context), ThisCall = call_args(Context, InputArgs, OutputArgs), - map__det_insert(SeenCalls0, SeenCall, [ThisCall], SeenCalls), + map.det_insert(SeenCalls0, SeenCall, [ThisCall], SeenCalls), CommonInfo = CommonInfo0 ^ seen_calls := SeenCalls, Goal = Goal0 ), @@ -628,7 +628,7 @@ partition_call_args(VarTypes, ModuleInfo, [ArgMode | ArgModes], partition_call_args(VarTypes, ModuleInfo, ArgModes, Args, InputArgs1, OutputArgs1, OutputModes1), mode_get_insts(ModuleInfo, ArgMode, InitialInst, FinalInst), - map__lookup(VarTypes, Arg, Type), + map.lookup(VarTypes, Arg, Type), ( inst_matches_binding(InitialInst, FinalInst, Type, ModuleInfo) -> InputArgs = [Arg | InputArgs1], OutputArgs = OutputArgs1, @@ -695,8 +695,8 @@ vars_are_equiv(X, Y, VarEqv) :- ( X = Y ; - eqvclass__partition_id(VarEqv, X, Id), - eqvclass__partition_id(VarEqv, Y, Id) + eqvclass.partition_id(VarEqv, X, Id), + eqvclass.partition_id(VarEqv, Y, Id) ). %---------------------------------------------------------------------------% @@ -753,10 +753,10 @@ create_output_unifications(GoalInfo, OutputArgs, OldOutputArgs, UniModes, generate_assign(ToVar, FromVar, UniMode, _, Goal, !Info) :- apply_induced_tsubst(ToVar, FromVar, !Info), simplify_info_get_var_types(!.Info, VarTypes), - map__lookup(VarTypes, ToVar, ToVarType), - map__lookup(VarTypes, FromVar, FromVarType), + map.lookup(VarTypes, ToVar, ToVarType), + map.lookup(VarTypes, FromVar, FromVarType), - set__list_to_set([ToVar, FromVar], NonLocals), + set.list_to_set([ToVar, FromVar], NonLocals), UniMode = ((_ - ToVarInst0) -> (_ - ToVarInst)), ( types_match_exactly(ToVarType, FromVarType) -> UnifyMode = (ToVarInst0 -> ToVarInst) - (ToVarInst -> ToVarInst), @@ -839,7 +839,7 @@ apply_induced_tsubst(ToVar, FromVar, !Info) :- ( calculate_induced_tsubst(ToVarRttiInfo, FromVarRttiInfo, TSubst) -> - ( map__is_empty(TSubst) -> + ( map.is_empty(TSubst) -> true ; simplify_info_apply_type_substitution(TSubst, !Info) @@ -876,17 +876,17 @@ calculate_induced_tsubst(ToVarRttiInfo, FromVarRttiInfo, TSubst) :- FromVarRttiInfo = type_info_var(FromVarTypeInfoType), ToVarRttiInfo = type_info_var(ToVarTypeInfoType), type_unify(FromVarTypeInfoType, ToVarTypeInfoType, [], - map__init, TSubst) + map.init, TSubst) ; FromVarRttiInfo = typeclass_info_var(FromVarConstraint), ToVarRttiInfo = typeclass_info_var(ToVarConstraint), FromVarConstraint = constraint(Name, FromArgs), ToVarConstraint = constraint(Name, ToArgs), - type_unify_list(FromArgs, ToArgs, [], map__init, TSubst) + type_unify_list(FromArgs, ToArgs, [], map.init, TSubst) ; FromVarRttiInfo = non_rtti_var, ToVarRttiInfo = non_rtti_var, - map__init(TSubst) + map.init(TSubst) ). %---------------------------------------------------------------------------% diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m index 6e5be58cf..780db75d6 100644 --- a/compiler/compile_target_code.m +++ b/compiler/compile_target_code.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module backend_libs__compile_target_code. +:- module backend_libs.compile_target_code. :- interface. :- import_module parse_tree.prog_io. @@ -39,55 +39,55 @@ % compile_c_file(ErrorStream, PIC, CFile, ObjFile, Succeeded) % -:- pred compile_c_file(io__output_stream::in, pic::in, string::in, string::in, +:- pred compile_c_file(io.output_stream::in, pic::in, string::in, string::in, bool::out, io::di, io::uo) is det. % compile_c_file(ErrorStream, PIC, ModuleName, Succeeded) % -:- pred compile_c_file(io__output_stream::in, pic::in, module_name::in, +:- pred compile_c_file(io.output_stream::in, pic::in, module_name::in, bool::out, io::di, io::uo) is det. % assemble(ErrorStream, PIC, ModuleName, Succeeded) % -:- pred assemble(io__output_stream::in, pic::in, module_name::in, +:- pred assemble(io.output_stream::in, pic::in, module_name::in, bool::out, io::di, io::uo) is det. % compile_java_file(ErrorStream, JavaFile, Succeeded) % -:- pred compile_java_file(io__output_stream::in, string::in, bool::out, +:- pred compile_java_file(io.output_stream::in, string::in, bool::out, io::di, io::uo) is det. % il_assemble(ErrorStream, ModuleName, HasMain, Succeeded) % -:- pred il_assemble(io__output_stream::in, module_name::in, has_main::in, +:- pred il_assemble(io.output_stream::in, module_name::in, has_main::in, bool::out, io::di, io::uo) is det. % il_assemble(ErrorStream, ILFile, DLLFile, HasMain, Succeeded) % -:- pred il_assemble(io__output_stream::in, file_name::in, file_name::in, +:- pred il_assemble(io.output_stream::in, file_name::in, file_name::in, has_main::in, bool::out, io::di, io::uo) is det. % compile_managed_cplusplus_file(ErrorStream, MCPPFile, DLLFile, Succeeded) % -:- pred compile_managed_cplusplus_file(io__output_stream::in, +:- pred compile_managed_cplusplus_file(io.output_stream::in, file_name::in, file_name::in, bool::out, io::di, io::uo) is det. % compile_csharp_file(ErrorStream, C#File, DLLFile, Succeeded) % -:- pred compile_csharp_file(io__output_stream::in, module_imports::in, +:- pred compile_csharp_file(io.output_stream::in, module_imports::in, file_name::in, file_name::in, bool::out, io::di, io::uo) is det. % make_init_file(ErrorStream, MainModuleName, ModuleNames, Succeeded): % % Make the `.init' file for a library containing the given modules. % -:- pred make_init_file(io__output_stream::in, module_name::in, +:- pred make_init_file(io.output_stream::in, module_name::in, list(module_name)::in, bool::out, io::di, io::uo) is det. % make_init_obj_file(ErrorStream, MainModuleName, AllModuleNames, % MaybeInitObjFileName) % -:- pred make_init_obj_file(io__output_stream::in, module_name::in, +:- pred make_init_obj_file(io.output_stream::in, module_name::in, list(module_name)::in, maybe(file_name)::out, io::di, io::uo) is det. :- type linked_target_type @@ -98,7 +98,7 @@ % link(TargetType, MainModuleName, ObjectFileNames, Succeeded) % -:- pred link(io__output_stream::in, linked_target_type::in, module_name::in, +:- pred link(io.output_stream::in, linked_target_type::in, module_name::in, list(string)::in, bool::out, io::di, io::uo) is det. % post_link_make_symlink_or_copy(TargetType, MainModuleName, Succeeded) @@ -106,7 +106,7 @@ % If `--use-grade-subdirs' is enabled, link or copy the executable or % library into the user's directory after having successfully built it. % -:- pred post_link_make_symlink_or_copy(io__output_stream::in, +:- pred post_link_make_symlink_or_copy(io.output_stream::in, linked_target_type::in, module_name::in, bool::out, io::di, io::uo) is det. % link_module_list(ModulesToLink, FactTableObjFiles, Succeeded): @@ -158,7 +158,7 @@ :- mode maybe_pic_object_file_extension(in, in, out) is det. :- mode maybe_pic_object_file_extension(in, out, in) is semidet. - % Same as above except the globals are obtained from the io__state. + % Same as above except the globals are obtained from the io.state. % :- pred maybe_pic_object_file_extension(pic::in, string::out, io::di, io::uo) is det. @@ -208,13 +208,13 @@ il_assemble(ErrorStream, ModuleName, HasMain, Succeeded, !IO) :- ). il_assemble(ErrorStream, IL_File, TargetFile, HasMain, Succeeded, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(sign_assembly, SignAssembly, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(sign_assembly, SignAssembly, !IO), maybe_write_string(Verbose, "% Assembling `", !IO), maybe_write_string(Verbose, IL_File, !IO), maybe_write_string(Verbose, "':\n", !IO), - globals__io_lookup_string_option(il_assembler, ILASM, !IO), - globals__io_lookup_accumulating_option(ilasm_flags, ILASMFlagsList, !IO), + globals.io_lookup_string_option(il_assembler, ILASM, !IO), + globals.io_lookup_accumulating_option(ilasm_flags, ILASMFlagsList, !IO), join_string_list(ILASMFlagsList, "", "", " ", ILASMFlags), ( SignAssembly = yes, @@ -230,7 +230,7 @@ il_assemble(ErrorStream, IL_File, TargetFile, HasMain, Succeeded, !IO) :- Verbose = no, VerboseOpt = "/quiet " ), - globals__io_lookup_bool_option(target_debug, Debug, !IO), + globals.io_lookup_bool_option(target_debug, Debug, !IO), ( Debug = yes, DebugOpt = "/debug " @@ -245,21 +245,21 @@ il_assemble(ErrorStream, IL_File, TargetFile, HasMain, Succeeded, !IO) :- HasMain = no_main, TargetOpt = "/dll " ), - string__append_list([ILASM, " ", SignOpt, VerboseOpt, DebugOpt, + string.append_list([ILASM, " ", SignOpt, VerboseOpt, DebugOpt, TargetOpt, ILASMFlags, " /out=", TargetFile, " ", IL_File], Command), invoke_system_command(ErrorStream, verbose_commands, Command, Succeeded, !IO). compile_managed_cplusplus_file(ErrorStream, MCPPFileName, DLLFileName, Succeeded, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Compiling `", !IO), maybe_write_string(Verbose, MCPPFileName, !IO), maybe_write_string(Verbose, "':\n", !IO), - globals__io_lookup_string_option(mcpp_compiler, MCPP, !IO), - globals__io_lookup_accumulating_option(mcpp_flags, MCPPFlagsList, !IO), + globals.io_lookup_string_option(mcpp_compiler, MCPP, !IO), + globals.io_lookup_accumulating_option(mcpp_flags, MCPPFlagsList, !IO), join_string_list(MCPPFlagsList, "", "", " ", MCPPFlags), - globals__io_lookup_bool_option(target_debug, Debug, !IO), + globals.io_lookup_bool_option(target_debug, Debug, !IO), ( Debug = yes, DebugOpt = "/Zi " @@ -269,38 +269,38 @@ compile_managed_cplusplus_file(ErrorStream, MCPPFileName, DLLFileName, ), % XXX Should we introduce a `--mcpp-include-directory' option? - globals__io_lookup_accumulating_option(c_include_directory, + globals.io_lookup_accumulating_option(c_include_directory, C_Incl_Dirs, !IO), - InclOpts = string__append_list(list__condense(list__map( + InclOpts = string.append_list(list.condense(list.map( (func(C_INCL) = ["-I", C_INCL, " "]), C_Incl_Dirs))), % XXX Should we use a separate dll_directories options? - globals__io_lookup_accumulating_option(link_library_directories, + globals.io_lookup_accumulating_option(link_library_directories, DLLDirs, !IO), DLLDirOpts = "-AIMercury/dlls " ++ - string__append_list(list__condense(list__map( + string.append_list(list.condense(list.map( (func(DLLDir) = ["-AI", DLLDir, " "]), DLLDirs))), - string__append_list([MCPP, " -CLR ", DebugOpt, InclOpts, DLLDirOpts, + string.append_list([MCPP, " -CLR ", DebugOpt, InclOpts, DLLDirOpts, MCPPFlags, " ", MCPPFileName, " -LD -o ", DLLFileName], Command), invoke_system_command(ErrorStream, verbose_commands, Command, Succeeded, !IO). compile_csharp_file(ErrorStream, Imports, CSharpFileName0, DLLFileName, Succeeded, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Compiling `", !IO), maybe_write_string(Verbose, CSharpFileName, !IO), maybe_write_string(Verbose, "':\n", !IO), - globals__io_lookup_string_option(csharp_compiler, CSC, !IO), - globals__io_lookup_accumulating_option(csharp_flags, CSCFlagsList, !IO), + globals.io_lookup_string_option(csharp_compiler, CSC, !IO), + globals.io_lookup_accumulating_option(csharp_flags, CSCFlagsList, !IO), join_string_list(CSCFlagsList, "", "", " ", CSCFlags), % XXX This is because the MS C# compiler doesn't understand % / as a directory separator. - CSharpFileName = string__replace_all(CSharpFileName0, "/", "\\\\"), + CSharpFileName = string.replace_all(CSharpFileName0, "/", "\\\\"), - globals__io_lookup_bool_option(target_debug, Debug, !IO), + globals.io_lookup_bool_option(target_debug, Debug, !IO), ( Debug = yes, % XXX This needs testing before it can be enabled (see the comments @@ -314,10 +314,10 @@ compile_csharp_file(ErrorStream, Imports, CSharpFileName0, DLLFileName, ), % XXX Should we use a separate dll_directories options? - globals__io_lookup_accumulating_option(link_library_directories, DLLDirs, + globals.io_lookup_accumulating_option(link_library_directories, DLLDirs, !IO), DLLDirOpts = "/lib:Mercury/dlls " ++ - string__append_list(list__condense(list__map( + string.append_list(list.condense(list.map( (func(DLLDir) = ["/lib:", DLLDir, " "]), DLLDirs))), ( mercury_std_library_module_name(Imports ^ module_name) -> @@ -325,20 +325,20 @@ compile_csharp_file(ErrorStream, Imports, CSharpFileName0, DLLFileName, ; Prefix = "/r:" ), - ForeignDeps = list__map( + ForeignDeps = list.map( (func(M) = foreign_import_module_name(M, Imports ^ module_name)), Imports ^ foreign_import_module_info ), ReferencedDlls = referenced_dlls(Imports ^ module_name, Imports ^ int_deps ++ Imports ^ impl_deps ++ ForeignDeps), - list__map_foldl( + list.map_foldl( (pred(Mod::in, Result::out, IO0::di, IO::uo) is det :- module_name_to_file_name(Mod, ".dll", no, FileName, IO0, IO), Result = [Prefix, FileName, " "] ), ReferencedDlls, ReferencedDllsList, !IO), - ReferencedDllsStr = string__append_list( - list__condense(ReferencedDllsList)), + ReferencedDllsStr = string.append_list( + list.condense(ReferencedDllsList)), - string__append_list([CSC, DebugOpt, + string.append_list([CSC, DebugOpt, " /t:library ", DLLDirOpts, CSCFlags, ReferencedDllsStr, " /out:", DLLFileName, " ", CSharpFileName], Command), invoke_system_command(ErrorStream, verbose_commands, Command, @@ -362,17 +362,17 @@ compile_c_file(ErrorStream, PIC, ModuleName, Succeeded, !IO) :- compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO). compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_string_option(c_flag_to_name_object_file, + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_string_option(c_flag_to_name_object_file, NameObjectFile, !IO), maybe_write_string(Verbose, "% Compiling `", !IO), maybe_write_string(Verbose, C_File, !IO), maybe_write_string(Verbose, "':\n", !IO), - globals__io_lookup_string_option(cc, CC, !IO), - globals__io_lookup_accumulating_option(cflags, C_Flags_List, !IO), + globals.io_lookup_string_option(cc, CC, !IO), + globals.io_lookup_accumulating_option(cflags, C_Flags_List, !IO), join_string_list(C_Flags_List, "", "", " ", CFLAGS), - globals__io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), + globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), ( UseSubdirs = yes, % The source file (foo.c) will be compiled in a subdirectory @@ -384,11 +384,11 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- UseSubdirs = no, SubDirInclOpt = "" ), - globals__io_lookup_accumulating_option(c_include_directory, + globals.io_lookup_accumulating_option(c_include_directory, C_Incl_Dirs, !IO), - InclOpt = string__append_list(list__condense(list__map( + InclOpt = string.append_list(list.condense(list.map( (func(C_INCL) = ["-I", quote_arg(C_INCL), " "] ), C_Incl_Dirs))), - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), ( HighLevelCode = yes, HighLevelCodeOpt = "-DMR_HIGHLEVEL_CODE " @@ -396,7 +396,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- HighLevelCode = no, HighLevelCodeOpt = "" ), - globals__io_lookup_bool_option(gcc_nested_functions, + globals.io_lookup_bool_option(gcc_nested_functions, GCC_NestedFunctions, !IO), ( GCC_NestedFunctions = yes, @@ -405,7 +405,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- GCC_NestedFunctions = no, NestedFunctionsOpt = "" ), - globals__io_lookup_bool_option(highlevel_data, HighLevelData, !IO), + globals.io_lookup_bool_option(highlevel_data, HighLevelData, !IO), ( HighLevelData = yes, HighLevelDataOpt = "-DMR_HIGHLEVEL_DATA " @@ -413,10 +413,10 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- HighLevelData = no, HighLevelDataOpt = "" ), - globals__io_lookup_bool_option(gcc_global_registers, GCC_Regs, !IO), + globals.io_lookup_bool_option(gcc_global_registers, GCC_Regs, !IO), ( GCC_Regs = yes, - globals__io_lookup_string_option(cflags_for_regs, CFLAGS_FOR_REGS, + globals.io_lookup_string_option(cflags_for_regs, CFLAGS_FOR_REGS, !IO), RegOpt = "-DMR_USE_GCC_GLOBAL_REGISTERS " ; @@ -424,18 +424,18 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- CFLAGS_FOR_REGS = "", RegOpt = "" ), - globals__io_lookup_bool_option(gcc_non_local_gotos, GCC_Gotos, !IO), + globals.io_lookup_bool_option(gcc_non_local_gotos, GCC_Gotos, !IO), ( GCC_Gotos = yes, GotoOpt = "-DMR_USE_GCC_NONLOCAL_GOTOS ", - globals__io_lookup_string_option(cflags_for_gotos, + globals.io_lookup_string_option(cflags_for_gotos, CFLAGS_FOR_GOTOS, !IO) ; GCC_Gotos = no, GotoOpt = "", CFLAGS_FOR_GOTOS = "" ), - globals__io_lookup_bool_option(asm_labels, ASM_Labels, !IO), + globals.io_lookup_bool_option(asm_labels, ASM_Labels, !IO), ( ASM_Labels = yes, AsmOpt = "-DMR_USE_ASM_LABELS " @@ -443,16 +443,16 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ASM_Labels = no, AsmOpt = "" ), - globals__io_lookup_bool_option(parallel, Parallel, !IO), + globals.io_lookup_bool_option(parallel, Parallel, !IO), ( Parallel = yes, - globals__io_lookup_string_option(cflags_for_threads, + globals.io_lookup_string_option(cflags_for_threads, CFLAGS_FOR_THREADS, !IO) ; Parallel = no, CFLAGS_FOR_THREADS = "" ), - globals__io_get_gc_method(GC_Method, !IO), + globals.io_get_gc_method(GC_Method, !IO), ( GC_Method = automatic, GC_Opt = "" @@ -469,7 +469,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- GC_Method = accurate, GC_Opt = "-DMR_NATIVE_GC " ), - globals__io_lookup_bool_option(profile_calls, ProfileCalls, !IO), + globals.io_lookup_bool_option(profile_calls, ProfileCalls, !IO), ( ProfileCalls = yes, ProfileCallsOpt = "-DMR_MPROF_PROFILE_CALLS " @@ -477,7 +477,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ProfileCalls = no, ProfileCallsOpt = "" ), - globals__io_lookup_bool_option(profile_time, ProfileTime, !IO), + globals.io_lookup_bool_option(profile_time, ProfileTime, !IO), ( ProfileTime = yes, ProfileTimeOpt = "-DMR_MPROF_PROFILE_TIME " @@ -485,7 +485,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ProfileTime = no, ProfileTimeOpt = "" ), - globals__io_lookup_bool_option(profile_memory, ProfileMemory, !IO), + globals.io_lookup_bool_option(profile_memory, ProfileMemory, !IO), ( ProfileMemory = yes, ProfileMemoryOpt = "-DMR_MPROF_PROFILE_MEMORY " @@ -493,7 +493,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ProfileMemory = no, ProfileMemoryOpt = "" ), - globals__io_lookup_bool_option(profile_deep, ProfileDeep, !IO), + globals.io_lookup_bool_option(profile_deep, ProfileDeep, !IO), ( ProfileDeep = yes, ProfileDeepOpt = "-DMR_DEEP_PROFILING " @@ -501,9 +501,9 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ProfileDeep = no, ProfileDeepOpt = "" ), - globals__io_lookup_bool_option(record_term_sizes_as_words, + globals.io_lookup_bool_option(record_term_sizes_as_words, RecordTermSizesAsWords, !IO), - globals__io_lookup_bool_option(record_term_sizes_as_cells, + globals.io_lookup_bool_option(record_term_sizes_as_cells, RecordTermSizesAsCells, !IO), ( RecordTermSizesAsWords = yes, @@ -527,7 +527,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ), ( PIC = pic, - globals__io_lookup_string_option(cflags_for_pic, CFLAGS_FOR_PIC, !IO), + globals.io_lookup_string_option(cflags_for_pic, CFLAGS_FOR_PIC, !IO), PIC_Reg = yes ; PIC = link_with_pic, @@ -536,7 +536,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ; PIC = non_pic, CFLAGS_FOR_PIC = "", - globals__io_lookup_bool_option(pic_reg, PIC_Reg, !IO) + globals.io_lookup_bool_option(pic_reg, PIC_Reg, !IO) ), ( PIC_Reg = yes, @@ -548,17 +548,17 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- PIC_Reg_Opt = "" ), - globals__io_get_tags_method(Tags_Method, !IO), + globals.io_get_tags_method(Tags_Method, !IO), ( Tags_Method = high -> TagsOpt = "-DMR_HIGHTAGS " ; TagsOpt = "" ), - globals__io_lookup_int_option(num_tag_bits, NumTagBits, !IO), - string__int_to_string(NumTagBits, NumTagBitsString), - string__append_list(["-DMR_TAGBITS=", NumTagBitsString, " "], + globals.io_lookup_int_option(num_tag_bits, NumTagBits, !IO), + string.int_to_string(NumTagBits, NumTagBitsString), + string.append_list(["-DMR_TAGBITS=", NumTagBitsString, " "], NumTagBitsOpt), - globals__io_lookup_bool_option(decl_debug, DeclDebug, !IO), + globals.io_lookup_bool_option(decl_debug, DeclDebug, !IO), ( DeclDebug = yes, DeclDebugOpt = "-DMR_DECL_DEBUG " @@ -566,7 +566,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- DeclDebug = no, DeclDebugOpt = "" ), - globals__io_lookup_bool_option(exec_trace, ExecTrace, !IO), + globals.io_lookup_bool_option(exec_trace, ExecTrace, !IO), ( ExecTrace = yes, ExecTraceOpt = "-DMR_EXEC_TRACE " @@ -574,7 +574,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ExecTrace = no, ExecTraceOpt = "" ), - globals__io_lookup_bool_option(extend_stacks_when_needed, Extend, !IO), + globals.io_lookup_bool_option(extend_stacks_when_needed, Extend, !IO), ( Extend = yes, ExtendOpt = "-DMR_EXTEND_STACKS_WHEN_NEEDED " @@ -582,17 +582,17 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- Extend = no, ExtendOpt = "" ), - globals__io_lookup_bool_option(target_debug, Target_Debug, !IO), + globals.io_lookup_bool_option(target_debug, Target_Debug, !IO), ( Target_Debug = yes, - globals__io_lookup_string_option(cflags_for_debug, Target_DebugOpt0, + globals.io_lookup_string_option(cflags_for_debug, Target_DebugOpt0, !IO), - string__append(Target_DebugOpt0, " ", Target_DebugOpt) + string.append(Target_DebugOpt0, " ", Target_DebugOpt) ; Target_Debug = no, Target_DebugOpt = "" ), - globals__io_lookup_bool_option(low_level_debug, LL_Debug, !IO), + globals.io_lookup_bool_option(low_level_debug, LL_Debug, !IO), ( LL_Debug = yes, LL_DebugOpt = "-DMR_LOW_LEVEL_DEBUG " @@ -600,7 +600,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- LL_Debug = no, LL_DebugOpt = "" ), - globals__io_lookup_bool_option(use_trail, UseTrail, !IO), + globals.io_lookup_bool_option(use_trail, UseTrail, !IO), ( UseTrail = yes, UseTrailOpt = "-DMR_USE_TRAIL " @@ -608,7 +608,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- UseTrail = no, UseTrailOpt = "" ), - globals__io_lookup_bool_option(reserve_tag, ReserveTag, !IO), + globals.io_lookup_bool_option(reserve_tag, ReserveTag, !IO), ( ReserveTag = yes, ReserveTagOpt = "-DMR_RESERVE_TAG " @@ -616,9 +616,9 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- ReserveTag = no, ReserveTagOpt = "" ), - globals__io_lookup_bool_option(use_minimal_model_stack_copy, + globals.io_lookup_bool_option(use_minimal_model_stack_copy, MinimalModelStackCopy, !IO), - globals__io_lookup_bool_option(use_minimal_model_own_stacks, + globals.io_lookup_bool_option(use_minimal_model_own_stacks, MinimalModelOwnStacks, !IO), ( MinimalModelStackCopy = yes, @@ -639,7 +639,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- MinimalModelOwnStacks = no, MinimalModelBaseOpt = "" ), - globals__io_lookup_bool_option(minimal_model_debug, MinimalModelDebug, + globals.io_lookup_bool_option(minimal_model_debug, MinimalModelDebug, !IO), ( MinimalModelDebug = yes, @@ -653,7 +653,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- MinimalModelDebug = no, MinimalModelOpt = MinimalModelBaseOpt ), - globals__io_lookup_bool_option(type_layout, TypeLayoutOption, !IO), + globals.io_lookup_bool_option(type_layout, TypeLayoutOption, !IO), ( TypeLayoutOption = no, TypeLayoutOpt = "-DMR_NO_TYPE_LAYOUT " @@ -661,24 +661,24 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- TypeLayoutOption = yes, TypeLayoutOpt = "" ), - globals__io_lookup_bool_option(c_optimize, C_optimize, !IO), + globals.io_lookup_bool_option(c_optimize, C_optimize, !IO), ( C_optimize = yes, - globals__io_lookup_string_option(cflags_for_optimization, OptimizeOpt, + globals.io_lookup_string_option(cflags_for_optimization, OptimizeOpt, !IO) ; C_optimize = no, OptimizeOpt = "" ), - globals__io_lookup_bool_option(ansi_c, Ansi, !IO), + globals.io_lookup_bool_option(ansi_c, Ansi, !IO), ( Ansi = yes, - globals__io_lookup_string_option(cflags_for_ansi, AnsiOpt, !IO) + globals.io_lookup_string_option(cflags_for_ansi, AnsiOpt, !IO) ; Ansi = no, AnsiOpt = "" ), - globals__io_lookup_bool_option(inline_alloc, InlineAlloc, !IO), + globals.io_lookup_bool_option(inline_alloc, InlineAlloc, !IO), ( InlineAlloc = yes, InlineAllocOpt = "-DMR_INLINE_ALLOC -DSILENT " @@ -686,10 +686,10 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- InlineAlloc = no, InlineAllocOpt = "" ), - globals__io_lookup_bool_option(warn_target_code, Warn, !IO), + globals.io_lookup_bool_option(warn_target_code, Warn, !IO), ( Warn = yes, - globals__io_lookup_string_option(cflags_for_warnings, + globals.io_lookup_string_option(cflags_for_warnings, WarningOpt, !IO) ; Warn = no, @@ -701,7 +701,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- % See the hard_coded/ppc_bug test case for an example % program which fails with this optimization. - globals__io_lookup_string_option(fullarch, FullArch, !IO), + globals.io_lookup_string_option(fullarch, FullArch, !IO), ( HighLevelCode = no, GCC_Regs = yes, @@ -716,7 +716,7 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- % e.g. CFLAGS_FOR_REGS must come after OptimizeOpt so that % it can override -fomit-frame-pointer with -fno-omit-frame-pointer. % Also be careful that each option is separated by spaces. - string__append_list([ + string.append_list([ CC, " ", SubDirInclOpt, InclOpt, OptimizeOpt, " ", @@ -751,15 +751,15 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- %-----------------------------------------------------------------------------% compile_java_file(ErrorStream, JavaFile, Succeeded, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Compiling `", !IO), maybe_write_string(Verbose, JavaFile, !IO), maybe_write_string(Verbose, "':\n", !IO), - globals__io_lookup_string_option(java_compiler, JavaCompiler, !IO), - globals__io_lookup_accumulating_option(java_flags, JavaFlagsList, !IO), + globals.io_lookup_string_option(java_compiler, JavaCompiler, !IO), + globals.io_lookup_accumulating_option(java_flags, JavaFlagsList, !IO), join_string_list(JavaFlagsList, "", "", " ", JAVAFLAGS), - globals__io_lookup_accumulating_option(java_classpath, Java_Incl_Dirs, + globals.io_lookup_accumulating_option(java_classpath, Java_Incl_Dirs, !IO), % XXX PathSeparator should be ";" on Windows PathSeparator = ":", @@ -771,11 +771,11 @@ compile_java_file(ErrorStream, JavaFile, Succeeded, !IO) :- ( ClassPath = "" -> InclOpt = "" ; - InclOpt = string__append_list([ + InclOpt = string.append_list([ "-classpath ", quote_arg(ClassPath), " "]) ), - globals__io_lookup_bool_option(target_debug, Target_Debug, !IO), + globals.io_lookup_bool_option(target_debug, Target_Debug, !IO), ( Target_Debug = yes, Target_DebugOpt = "-g " @@ -784,10 +784,10 @@ compile_java_file(ErrorStream, JavaFile, Succeeded, !IO) :- Target_DebugOpt = "" ), - globals__io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), - globals__io_lookup_string_option(fullarch, FullArch, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), + globals.io_lookup_string_option(fullarch, FullArch, !IO), + globals.io_get_globals(Globals, !IO), ( UseSubdirs = yes, ( @@ -800,7 +800,7 @@ compile_java_file(ErrorStream, JavaFile, Succeeded, !IO) :- ), % Javac won't create the destination directory for class files, % so we need to do it. - dir__make_directory(DirName, _, !IO), + dir.make_directory(DirName, _, !IO), % Set destination directory for class files. DestDir = "-d " ++ DirName ++ " " ; @@ -810,7 +810,7 @@ compile_java_file(ErrorStream, JavaFile, Succeeded, !IO) :- % Be careful with the order here! Some options may override others. % Also be careful that each option is separated by spaces. - string__append_list([JavaCompiler, " ", InclOpt, DestDir, + string.append_list([JavaCompiler, " ", InclOpt, DestDir, Target_DebugOpt, JAVAFLAGS, " ", JavaFile], Command), invoke_system_command(ErrorStream, verbose_commands, Command, Succeeded, !IO). @@ -838,20 +838,20 @@ assemble(ErrorStream, PIC, ModuleName, Succeeded, !IO) :- maybe_pic_object_file_extension(PIC, ObjExt, !IO), module_name_to_file_name(ModuleName, ObjExt, yes, ObjFile, !IO), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Assembling `", !IO), maybe_write_string(Verbose, AsmFile, !IO), maybe_write_string(Verbose, "':\n", !IO), % XXX should we use new asm_* options rather than % reusing cc, cflags, c_flag_to_name_object_file? - globals__io_lookup_string_option(cc, CC, !IO), - globals__io_lookup_string_option(c_flag_to_name_object_file, + globals.io_lookup_string_option(cc, CC, !IO), + globals.io_lookup_string_option(c_flag_to_name_object_file, NameObjectFile, !IO), - globals__io_lookup_accumulating_option(cflags, C_Flags_List, !IO), + globals.io_lookup_accumulating_option(cflags, C_Flags_List, !IO), join_string_list(C_Flags_List, "", "", " ", CFLAGS), % Be careful with the order here. % Also be careful that each option is separated by spaces. - string__append_list([CC, " ", CFLAGS, " ", GCCFLAGS_FOR_PIC, + string.append_list([CC, " ", CFLAGS, " ", GCCFLAGS_FOR_PIC, GCCFLAGS_FOR_ASM, "-c ", AsmFile, " ", NameObjectFile, ObjFile], Command), invoke_system_command(ErrorStream, verbose_commands, Command, Succeeded, @@ -862,11 +862,11 @@ assemble(ErrorStream, PIC, ModuleName, Succeeded, !IO) :- make_init_file(ErrorStream, MainModuleName, AllModules, Succeeded, !IO) :- module_name_to_file_name(MainModuleName, ".init.tmp", yes, TmpInitFileName, !IO), - io__open_output(TmpInitFileName, InitFileRes, !IO), + io.open_output(TmpInitFileName, InitFileRes, !IO), ( InitFileRes = ok(InitFileStream), - list__foldl(make_init_file(InitFileStream), AllModules, !IO), - globals__io_lookup_maybe_string_option(extra_init_command, + list.foldl(make_init_file(InitFileStream), AllModules, !IO), + globals.io_lookup_maybe_string_option(extra_init_command, MaybeInitFileCommand, !IO), ( MaybeInitFileCommand = yes(InitFileCommand), @@ -879,21 +879,21 @@ make_init_file(ErrorStream, MainModuleName, AllModules, Succeeded, !IO) :- Succeeded0 = yes ), - io__close_output(InitFileStream, !IO), + io.close_output(InitFileStream, !IO), module_name_to_file_name(MainModuleName, ".init", yes, InitFileName, !IO), update_interface_return_succeeded(InitFileName, Succeeded1, !IO), Succeeded = Succeeded0 `and` Succeeded1 ; InitFileRes = error(Error), - io__progname_base("mercury_compile", ProgName, !IO), - io__write_string(ErrorStream, ProgName, !IO), - io__write_string(ErrorStream, ": can't open `", !IO), - io__write_string(ErrorStream, TmpInitFileName, !IO), - io__write_string(ErrorStream, "' for output:\n", !IO), - io__nl(ErrorStream, !IO), - io__write_string(ErrorStream, io__error_message(Error), !IO), - io__nl(ErrorStream, !IO), + io.progname_base("mercury_compile", ProgName, !IO), + io.write_string(ErrorStream, ProgName, !IO), + io.write_string(ErrorStream, ": can't open `", !IO), + io.write_string(ErrorStream, TmpInitFileName, !IO), + io.write_string(ErrorStream, "' for output:\n", !IO), + io.nl(ErrorStream, !IO), + io.write_string(ErrorStream, io.error_message(Error), !IO), + io.nl(ErrorStream, !IO), Succeeded = no ). @@ -903,14 +903,14 @@ make_init_file(ErrorStream, MainModuleName, AllModules, Succeeded, !IO) :- make_init_file(InitFileStream, ModuleName, !IO) :- InitFuncName0 = make_init_name(ModuleName), InitFuncName = InitFuncName0 ++ "init", - io__write_string(InitFileStream, "INIT ", !IO), - io__write_string(InitFileStream, InitFuncName, !IO), - io__nl(InitFileStream, !IO). + io.write_string(InitFileStream, "INIT ", !IO), + io.write_string(InitFileStream, InitFuncName, !IO), + io.nl(InitFileStream, !IO). %-----------------------------------------------------------------------------% link_module_list(Modules, FactTableObjFiles, Succeeded, !IO) :- - globals__io_lookup_string_option(output_file_name, OutputFileName0, !IO), + globals.io_lookup_string_option(output_file_name, OutputFileName0, !IO), ( OutputFileName0 = "" -> ( Modules = [Module | _], @@ -925,14 +925,14 @@ link_module_list(Modules, FactTableObjFiles, Succeeded, !IO) :- file_name_to_module_name(OutputFileName, MainModuleName), - globals__io_lookup_bool_option(compile_to_shared_lib, CompileToSharedLib, + globals.io_lookup_bool_option(compile_to_shared_lib, CompileToSharedLib, !IO), TargetType = (CompileToSharedLib = yes -> shared_library ; executable), get_object_code_type(TargetType, PIC, !IO), maybe_pic_object_file_extension(PIC, Obj, !IO), - globals__io_get_target(Target, !IO), - io__output_stream(OutputStream, !IO), + globals.io_get_target(Target, !IO), + io.output_stream(OutputStream, !IO), ( Target = asm -> % For --target asm, we generate everything into a single object file. ( @@ -946,9 +946,9 @@ link_module_list(Modules, FactTableObjFiles, Succeeded, !IO) :- join_module_list(Modules, Obj, ObjectsList, !IO) ), ( TargetType = executable -> - list__map( + list.map( (pred(ModuleStr::in, ModuleName::out) is det :- - file_name_to_module_name(dir__basename_det(ModuleStr), + file_name_to_module_name(dir.basename_det(ModuleStr), ModuleName) ), Modules, ModuleNames), MustCompile = yes, @@ -959,7 +959,7 @@ link_module_list(Modules, FactTableObjFiles, Succeeded, !IO) :- ), ( InitObjResult = yes(InitObjFileName), - globals__io_lookup_accumulating_option(link_objects, + globals.io_lookup_accumulating_option(link_objects, ExtraLinkObjectsList, !IO), AllObjects0 = ObjectsList ++ ExtraLinkObjectsList ++ FactTableObjFiles, @@ -977,24 +977,24 @@ link_module_list(Modules, FactTableObjFiles, Succeeded, !IO) :- ). make_init_obj_file(ErrorStream, ModuleName, ModuleNames, Result, !IO) :- - globals__io_lookup_bool_option(rebuild, MustCompile, !IO), + globals.io_lookup_bool_option(rebuild, MustCompile, !IO), make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result, !IO). % WARNING: The code here duplicates the functionality of scripts/c2init.in. % Any changes there may also require changes here, and vice versa. -:- pred make_init_obj_file(io__output_stream::in, bool::in, +:- pred make_init_obj_file(io.output_stream::in, bool::in, module_name::in, list(module_name)::in, maybe(file_name)::out, io::di, io::uo) is det. make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Creating initialization file...\n", !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), compute_grade(Globals, Grade), get_object_code_type(executable, PIC, !IO), @@ -1004,21 +1004,21 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result, module_name_to_file_name(ModuleName, "_init.c", yes, InitCFileName, !IO), module_name_to_file_name(ModuleName, InitObj, yes, InitObjFileName, !IO), - list__map_foldl( + list.map_foldl( (pred(ThisModule::in, CFileName::out, IO0::di, IO::uo) is det :- module_name_to_file_name(ThisModule, ".c", no, CFileName, IO0, IO) ), ModuleNames, CFileNameList, !IO), join_quoted_string_list(CFileNameList, "", "", " ", CFileNames), - globals__io_lookup_accumulating_option(init_file_directories, + globals.io_lookup_accumulating_option(init_file_directories, InitFileDirsList, !IO), join_quoted_string_list(InitFileDirsList, "-I ", "", " ", InitFileDirs), - globals__io_lookup_accumulating_option(init_files, InitFileNamesList0, + globals.io_lookup_accumulating_option(init_files, InitFileNamesList0, !IO), - globals__io_lookup_accumulating_option(trace_init_files, + globals.io_lookup_accumulating_option(trace_init_files, TraceInitFileNamesList0, !IO), - globals__io_lookup_maybe_string_option( + globals.io_lookup_maybe_string_option( mercury_standard_library_directory, MaybeStdLibDir, !IO), ( MaybeStdLibDir = yes(StdLibDir), @@ -1035,7 +1035,7 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result, TraceInitFileNamesList = TraceInitFileNamesList0 ), - globals__io_get_trace_level(TraceLevel, !IO), + globals.io_get_trace_level(TraceLevel, !IO), ( given_trace_level_is_none(TraceLevel) = no -> TraceOpt = "-t", InitFileNamesList = InitFileNamesList1 ++ TraceInitFileNamesList @@ -1045,18 +1045,18 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result, ), join_quoted_string_list(InitFileNamesList, "", "", " ", InitFileNames), - globals__io_lookup_accumulating_option(runtime_flags, RuntimeFlagsList, + globals.io_lookup_accumulating_option(runtime_flags, RuntimeFlagsList, !IO), join_quoted_string_list(RuntimeFlagsList, "-r ", "", " ", RuntimeFlags), - globals__io_lookup_bool_option(extra_initialization_functions, ExtraInits, + globals.io_lookup_bool_option(extra_initialization_functions, ExtraInits, !IO), ExtraInitsOpt = ( ExtraInits = yes -> "-x" ; "" ), - globals__io_lookup_bool_option(main, Main, !IO), + globals.io_lookup_bool_option(main, Main, !IO), NoMainOpt = ( Main = no -> "-l" ; "" ), - globals__io_lookup_string_option(experimental_complexity, + globals.io_lookup_string_option(experimental_complexity, ExperimentalComplexity, !IO), ( ExperimentalComplexity = "" -> ExperimentalComplexityOpt = "" @@ -1064,9 +1064,9 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result, ExperimentalComplexityOpt = "-X " ++ ExperimentalComplexity ), - globals__io_lookup_string_option(mkinit_command, Mkinit, !IO), + globals.io_lookup_string_option(mkinit_command, Mkinit, !IO), TmpInitCFileName = InitCFileName ++ ".tmp", - MkInitCmd = string__append_list( + MkInitCmd = string.append_list( [ Mkinit, " -g ", Grade, " ", TraceOpt, @@ -1091,9 +1091,9 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result, Compile = yes ; MustCompile = no, - io__file_modification_time(InitCFileName, + io.file_modification_time(InitCFileName, InitCModTimeResult, !IO), - io__file_modification_time(InitObjFileName, + io.file_modification_time(InitObjFileName, InitObjModTimeResult, !IO), ( InitObjModTimeResult = ok(InitObjModTime), @@ -1140,8 +1140,8 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result, % Any changes there may also require changes here, and vice versa. link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Linking...\n", !IO), link_output_filename(LinkTargetType, ModuleName, _Ext, OutputFileName, !IO), @@ -1161,14 +1161,14 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- ThreadFlagsOpt = shlib_linker_thread_flags, DebugFlagsOpt = shlib_linker_debug_flags, TraceFlagsOpt = shlib_linker_trace_flags, - globals__io_lookup_bool_option(allow_undefined, AllowUndef, !IO), + globals.io_lookup_bool_option(allow_undefined, AllowUndef, !IO), ( AllowUndef = yes, - globals__io_lookup_string_option( + globals.io_lookup_string_option( linker_allow_undefined_flag, UndefOpt, !IO) ; AllowUndef = no, - globals__io_lookup_string_option( + globals.io_lookup_string_option( linker_error_undefined_flag, UndefOpt, !IO) ) ; @@ -1183,39 +1183,39 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- UndefOpt = "" ; LinkTargetType = static_library, - unexpected(this_file, "compile_target_code__link") + unexpected(this_file, "compile_target_code.link") ; LinkTargetType = java_archive, - unexpected(this_file, "compile_target_code__link") + unexpected(this_file, "compile_target_code.link") ), % Should the executable be stripped? - globals__io_lookup_bool_option(strip, Strip, !IO), + globals.io_lookup_bool_option(strip, Strip, !IO), ( LinkTargetType = executable, Strip = yes -> - globals__io_lookup_string_option(linker_strip_flag, StripOpt, !IO) + globals.io_lookup_string_option(linker_strip_flag, StripOpt, !IO) ; StripOpt = "" ), - globals__io_lookup_bool_option(target_debug, TargetDebug, !IO), + globals.io_lookup_bool_option(target_debug, TargetDebug, !IO), ( TargetDebug = yes, - globals__io_lookup_string_option(DebugFlagsOpt, DebugOpts, !IO) + globals.io_lookup_string_option(DebugFlagsOpt, DebugOpts, !IO) ; TargetDebug = no, DebugOpts = "" ), % Should the executable be statically linked? - globals__io_lookup_string_option(linkage, Linkage, !IO), + globals.io_lookup_string_option(linkage, Linkage, !IO), ( LinkTargetType = executable, Linkage = "static" -> - globals__io_lookup_string_option(linker_static_flags, StaticOpts, + globals.io_lookup_string_option(linker_static_flags, StaticOpts, !IO) ; StaticOpts = "" @@ -1225,14 +1225,14 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- use_thread_libs(UseThreadLibs, !IO), ( UseThreadLibs = yes, - globals__io_lookup_string_option(ThreadFlagsOpt, ThreadOpts, !IO) + globals.io_lookup_string_option(ThreadFlagsOpt, ThreadOpts, !IO) ; UseThreadLibs = no, ThreadOpts = "" ), % Find the Mercury standard libraries. - globals__io_lookup_maybe_string_option( + globals.io_lookup_maybe_string_option( mercury_standard_library_directory, MaybeStdLibDir, !IO), ( MaybeStdLibDir = yes(StdLibDir), @@ -1247,17 +1247,17 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- get_system_libs(LinkTargetType, SystemLibs, !IO), join_quoted_string_list(ObjectsList, "", "", " ", Objects), - globals__io_lookup_accumulating_option(LDFlagsOpt, LDFlagsList, !IO), + globals.io_lookup_accumulating_option(LDFlagsOpt, LDFlagsList, !IO), join_string_list(LDFlagsList, "", "", " ", LDFlags), - globals__io_lookup_accumulating_option(link_library_directories, + globals.io_lookup_accumulating_option(link_library_directories, LinkLibraryDirectoriesList, !IO), - globals__io_lookup_string_option(linker_path_flag, LinkerPathFlag, + globals.io_lookup_string_option(linker_path_flag, LinkerPathFlag, !IO), join_quoted_string_list(LinkLibraryDirectoriesList, LinkerPathFlag, "", " ", LinkLibraryDirectories), % Set up the runtime library path. - globals__io_lookup_bool_option(shlib_linker_use_install_name, + globals.io_lookup_bool_option(shlib_linker_use_install_name, UseInstallName, !IO), shared_libraries_supported(SharedLibsSupported, !IO), ( @@ -1267,16 +1267,16 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- ; LinkTargetType = shared_library ) -> - globals__io_lookup_accumulating_option( + globals.io_lookup_accumulating_option( runtime_link_library_directories, RpathDirs, !IO), ( RpathDirs = [], RpathOpts = "" ; RpathDirs = [_|_], - globals__io_lookup_string_option(RpathSepOpt, RpathSep, !IO), - globals__io_lookup_string_option(RpathFlagOpt, RpathFlag, !IO), - RpathOpts0 = string__join_list(RpathSep, RpathDirs), + globals.io_lookup_string_option(RpathSepOpt, RpathSep, !IO), + globals.io_lookup_string_option(RpathFlagOpt, RpathFlag, !IO), + RpathOpts0 = string.join_list(RpathSep, RpathDirs), RpathOpts = RpathFlag ++ RpathOpts0 ) ; @@ -1294,7 +1294,7 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- % be installed, *not* where it is going to be built. % sym_name_to_string(ModuleName, BaseFileName), - globals__io_lookup_string_option(shared_library_extension, + globals.io_lookup_string_option(shared_library_extension, SharedLibExt, !IO), ShLibFileName = "lib" ++ BaseFileName ++ SharedLibExt, get_install_name_option(ShLibFileName, InstallNameOpt, !IO) @@ -1302,31 +1302,31 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- InstallNameOpt = "" ), - globals__io_get_trace_level(TraceLevel, !IO), + globals.io_get_trace_level(TraceLevel, !IO), ( given_trace_level_is_none(TraceLevel) = yes -> TraceOpts = "" ; - globals__io_lookup_string_option(TraceFlagsOpt, TraceOpts, !IO) + globals.io_lookup_string_option(TraceFlagsOpt, TraceOpts, !IO) ), % Pass either `-llib' or `PREFIX/lib/GRADE/liblib.a', % depending on whether we are linking with static or shared % Mercury libraries. - globals__io_lookup_accumulating_option( + globals.io_lookup_accumulating_option( mercury_library_directories, MercuryLibDirs0, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), grade_directory_component(Globals, GradeDir), - MercuryLibDirs = list__map( + MercuryLibDirs = list.map( (func(LibDir) = LibDir/"lib"/GradeDir), MercuryLibDirs0), - globals__io_lookup_accumulating_option(link_libraries, + globals.io_lookup_accumulating_option(link_libraries, LinkLibrariesList0, !IO), - list__map_foldl2(process_link_library(MercuryLibDirs), + list.map_foldl2(process_link_library(MercuryLibDirs), LinkLibrariesList0, LinkLibrariesList, yes, LibrariesSucceeded, !IO), - globals__io_lookup_string_option(linker_opt_separator, + globals.io_lookup_string_option(linker_opt_separator, LinkOptSep, !IO), ( LibrariesSucceeded = yes, @@ -1335,8 +1335,8 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- % Note that LDFlags may contain `-l' options so it should come % after Objects. - globals__io_lookup_string_option(CommandOpt, Command, !IO), - string__append_list( + globals.io_lookup_string_option(CommandOpt, Command, !IO), + string.append_list( [Command, " ", StaticOpts, " ", StripOpt, " ", UndefOpt, " ", ThreadOpts, " ", TraceOpts, " ", @@ -1347,10 +1347,10 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- MercuryStdLibs, " ", SystemLibs], LinkCmd), - globals__io_lookup_bool_option(demangle, Demangle, !IO), + globals.io_lookup_bool_option(demangle, Demangle, !IO), ( Demangle = yes, - globals__io_lookup_string_option(demangle_command, + globals.io_lookup_string_option(demangle_command, DemamngleCmd, !IO), MaybeDemangleCmd = yes(DemamngleCmd) ; @@ -1381,12 +1381,12 @@ link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :- link_output_filename(LinkTargetType, ModuleName, Ext, OutputFileName, !IO) :- ( LinkTargetType = static_library, - globals__io_lookup_string_option(library_extension, Ext, !IO), + globals.io_lookup_string_option(library_extension, Ext, !IO), module_name_to_lib_file_name("lib", ModuleName, Ext, yes, OutputFileName, !IO) ; LinkTargetType = shared_library, - globals__io_lookup_string_option(shared_library_extension, Ext, !IO), + globals.io_lookup_string_option(shared_library_extension, Ext, !IO), module_name_to_lib_file_name("lib", ModuleName, Ext, yes, OutputFileName, !IO) ; @@ -1395,7 +1395,7 @@ link_output_filename(LinkTargetType, ModuleName, Ext, OutputFileName, !IO) :- module_name_to_file_name(ModuleName, Ext, yes, OutputFileName, !IO) ; LinkTargetType = executable, - globals__io_lookup_string_option(executable_file_extension, Ext, !IO), + globals.io_lookup_string_option(executable_file_extension, Ext, !IO), module_name_to_file_name(ModuleName, Ext, yes, OutputFileName, !IO) ). @@ -1406,9 +1406,9 @@ link_output_filename(LinkTargetType, ModuleName, Ext, OutputFileName, !IO) :- io::di, io::uo) is det. get_mercury_std_libs(TargetType, StdLibDir, StdLibs, !IO) :- - globals__io_get_gc_method(GCMethod, !IO), - globals__io_lookup_string_option(library_extension, LibExt, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_gc_method(GCMethod, !IO), + globals.io_lookup_string_option(library_extension, LibExt, !IO), + globals.io_get_globals(Globals, !IO), grade_directory_component(Globals, GradeDir), % GC libraries. @@ -1422,8 +1422,8 @@ get_mercury_std_libs(TargetType, StdLibDir, StdLibs, !IO) :- SharedGCLibs = "" ; GCMethod = boehm, - globals__io_lookup_bool_option(profile_time, ProfTime, !IO), - globals__io_lookup_bool_option(profile_deep, ProfDeep, !IO), + globals.io_lookup_bool_option(profile_time, ProfTime, !IO), + globals.io_lookup_bool_option(profile_deep, ProfDeep, !IO), ( ( ProfTime = yes ; ProfDeep = yes @@ -1433,7 +1433,7 @@ get_mercury_std_libs(TargetType, StdLibDir, StdLibs, !IO) :- ; GCGrade0 = "gc" ), - globals__io_lookup_bool_option(parallel, Parallel, !IO), + globals.io_lookup_bool_option(parallel, Parallel, !IO), ( Parallel = yes, GCGrade = "par_" ++ GCGrade0 @@ -1456,7 +1456,7 @@ get_mercury_std_libs(TargetType, StdLibDir, StdLibs, !IO) :- ), % Trace libraries. - globals__io_get_trace_level(TraceLevel, !IO), + globals.io_get_trace_level(TraceLevel, !IO), ( given_trace_level_is_none(TraceLevel) = yes -> StaticTraceLibs = "", SharedTraceLibs = "" @@ -1473,13 +1473,13 @@ get_mercury_std_libs(TargetType, StdLibDir, StdLibs, !IO) :- make_link_lib(TargetType, "mer_trace", TraceLib, !IO), make_link_lib(TargetType, "mer_browser", BrowserLib, !IO), make_link_lib(TargetType, "mer_mdbcomp", MdbCompLib, !IO), - SharedTraceLibs = string__join_list(" ", + SharedTraceLibs = string.join_list(" ", [TraceLib, BrowserLib, MdbCompLib]) ), - globals__io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO), + globals.io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO), ( MercuryLinkage = "static" -> - StdLibs = string__join_list(" ", + StdLibs = string.join_list(" ", [StaticTraceLibs, quote_arg(StdLibDir/"lib"/GradeDir/ ("libmer_std" ++ LibExt)), @@ -1489,7 +1489,7 @@ get_mercury_std_libs(TargetType, StdLibDir, StdLibs, !IO) :- ; MercuryLinkage = "shared" -> make_link_lib(TargetType, "mer_std", StdLib, !IO), make_link_lib(TargetType, "mer_rt", RuntimeLib, !IO), - StdLibs = string__join_list(" ", + StdLibs = string.join_list(" ", [SharedTraceLibs, StdLib, RuntimeLib, SharedGCLibs]) ; unexpected(this_file, "unknown linkage " ++ MercuryLinkage) @@ -1514,8 +1514,8 @@ make_link_lib(TargetType, LibName, LinkOpt, !IO) :- TargetType = static_library, unexpected(this_file, "make_link_lib: static_library") ), - globals__io_lookup_string_option(LinkLibFlag, LinkLibOpt, !IO), - globals__io_lookup_string_option(LinkLibSuffix, Suffix, !IO), + globals.io_lookup_string_option(LinkLibFlag, LinkLibOpt, !IO), + globals.io_lookup_string_option(LinkLibSuffix, Suffix, !IO), LinkOpt = quote_arg(LinkLibOpt ++ LibName ++ Suffix). :- pred get_system_libs(linked_target_type::in, string::out, io::di, io::uo) @@ -1523,15 +1523,15 @@ make_link_lib(TargetType, LibName, LinkOpt, !IO) :- get_system_libs(TargetType, SystemLibs, !IO) :- % System libraries used when tracing. - globals__io_get_trace_level(TraceLevel, !IO), + globals.io_get_trace_level(TraceLevel, !IO), ( given_trace_level_is_none(TraceLevel) = yes -> SystemTraceLibs = "" ; - globals__io_lookup_string_option(trace_libs, SystemTraceLibs0, !IO), - globals__io_lookup_bool_option(use_readline, UseReadline, !IO), + globals.io_lookup_string_option(trace_libs, SystemTraceLibs0, !IO), + globals.io_lookup_bool_option(use_readline, UseReadline, !IO), ( UseReadline = yes, - globals__io_lookup_string_option(readline_libs, ReadlineLibs, !IO), + globals.io_lookup_string_option(readline_libs, ReadlineLibs, !IO), SystemTraceLibs = SystemTraceLibs0 ++ " " ++ ReadlineLibs ; UseReadline = no, @@ -1543,7 +1543,7 @@ get_system_libs(TargetType, SystemLibs, !IO) :- use_thread_libs(UseThreadLibs, !IO), ( UseThreadLibs = yes, - globals__io_lookup_string_option(thread_libs, ThreadLibs, !IO) + globals.io_lookup_string_option(thread_libs, ThreadLibs, !IO) ; UseThreadLibs = no, ThreadLibs = "" @@ -1552,7 +1552,7 @@ get_system_libs(TargetType, SystemLibs, !IO) :- % Other system libraries. ( TargetType = shared_library, - globals__io_lookup_string_option(shared_libs, OtherSystemLibs, !IO) + globals.io_lookup_string_option(shared_libs, OtherSystemLibs, !IO) ; TargetType = static_library, unexpected(this_file, "get_std_libs: static library") @@ -1561,44 +1561,44 @@ get_system_libs(TargetType, SystemLibs, !IO) :- unexpected(this_file, "get_std_libs: java archive") ; TargetType = executable, - globals__io_lookup_string_option(math_lib, OtherSystemLibs, !IO) + globals.io_lookup_string_option(math_lib, OtherSystemLibs, !IO) ), - SystemLibs = string__join_list(" ", + SystemLibs = string.join_list(" ", [SystemTraceLibs, OtherSystemLibs, ThreadLibs]). :- pred use_thread_libs(bool::out, io::di, io::uo) is det. use_thread_libs(UseThreadLibs, !IO) :- - globals__io_lookup_bool_option(parallel, Parallel, !IO), - globals__io_get_gc_method(GCMethod, !IO), + globals.io_lookup_bool_option(parallel, Parallel, !IO), + globals.io_get_gc_method(GCMethod, !IO), UseThreadLibs = ( ( Parallel = yes ; GCMethod = mps ) -> yes ; no ). post_link_make_symlink_or_copy(ErrorStream, LinkTargetType, ModuleName, Succeeded, !IO) :- - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), ( UseGradeSubdirs = yes, link_output_filename(LinkTargetType, ModuleName, Ext, OutputFileName, !IO), % Link/copy the executable into the user's directory. - globals__io_set_option(use_subdirs, bool(no), !IO), - globals__io_set_option(use_grade_subdirs, bool(no), !IO), + globals.io_set_option(use_subdirs, bool(no), !IO), + globals.io_set_option(use_grade_subdirs, bool(no), !IO), ( LinkTargetType = executable -> module_name_to_file_name(ModuleName, Ext, no, UserDirFileName, !IO) ; module_name_to_lib_file_name("lib", ModuleName, Ext, no, UserDirFileName, !IO) ), - globals__io_set_option(use_subdirs, bool(yes), !IO), - globals__io_set_option(use_grade_subdirs, bool(yes), !IO), + globals.io_set_option(use_subdirs, bool(yes), !IO), + globals.io_set_option(use_grade_subdirs, bool(yes), !IO), - io__set_output_stream(ErrorStream, OutputStream, !IO), + io.set_output_stream(ErrorStream, OutputStream, !IO), % Remove the target of the symlink/copy in case it already exists. - io__remove_file(UserDirFileName, _, !IO), - make_symlink_or_copy_file(OutputFileName, UserDirFileName, - Succeeded, !IO), - io__set_output_stream(OutputStream, _, !IO) + io.remove_file(UserDirFileName, _, !IO), + make_symlink_or_copy_file(OutputFileName, UserDirFileName, Succeeded, + !IO), + io.set_output_stream(OutputStream, _, !IO) ; UseGradeSubdirs = no, Succeeded = yes @@ -1607,8 +1607,8 @@ post_link_make_symlink_or_copy(ErrorStream, LinkTargetType, ModuleName, shared_libraries_supported(Supported, !IO) :- % XXX This seems to be the standard way to check whether shared libraries % are supported but it's not very nice. - globals__io_lookup_string_option(library_extension, LibExt, !IO), - globals__io_lookup_string_option(shared_library_extension, SharedLibExt, + globals.io_lookup_string_option(library_extension, LibExt, !IO), + globals.io_lookup_string_option(shared_library_extension, SharedLibExt, !IO), Supported = (if LibExt \= SharedLibExt then yes else no). @@ -1618,34 +1618,33 @@ shared_libraries_supported(Supported, !IO) :- bool::in, bool::out, io::di, io::uo) is det. process_link_library(MercuryLibDirs, LibName, LinkerOpt, !Succeeded, !IO) :- - globals__io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO), - globals__io_lookup_accumulating_option(mercury_libraries, MercuryLibs, + globals.io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO), + globals.io_lookup_accumulating_option(mercury_libraries, MercuryLibs, !IO), ( MercuryLinkage = "static", - list__member(LibName, MercuryLibs) + list.member(LibName, MercuryLibs) -> % If we are linking statically with Mercury libraries, pass the % absolute pathname of the `.a' file for the library. - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, - !IO), + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), file_name_to_module_name(LibName, LibModuleName), - globals__io_lookup_string_option(library_extension, LibExt, !IO), + globals.io_lookup_string_option(library_extension, LibExt, !IO), - globals__io_set_option(use_grade_subdirs, bool(no), !IO), + globals.io_set_option(use_grade_subdirs, bool(no), !IO), module_name_to_lib_file_name("lib", LibModuleName, LibExt, no, LibFileName, !IO), - globals__io_set_option(use_grade_subdirs, bool(UseGradeSubdirs), !IO), + globals.io_set_option(use_grade_subdirs, bool(UseGradeSubdirs), !IO), - io__input_stream(InputStream, !IO), + io.input_stream(InputStream, !IO), search_for_file_returning_dir(MercuryLibDirs, LibFileName, SearchResult, !IO), ( SearchResult = ok(DirName), LinkerOpt = DirName/LibFileName, - io__set_input_stream(InputStream, LibInputStream, !IO), - io__close_input(LibInputStream, !IO) + io.set_input_stream(InputStream, LibInputStream, !IO), + io.close_input(LibInputStream, !IO) ; SearchResult = error(Error), LinkerOpt = "", @@ -1656,17 +1655,17 @@ process_link_library(MercuryLibDirs, LibName, LinkerOpt, !Succeeded, !IO) :- LinkerOpt = "-l" ++ LibName ). -:- pred create_archive(io__output_stream::in, file_name::in, bool::in, +:- pred create_archive(io.output_stream::in, file_name::in, bool::in, list(file_name)::in, bool::out, io::di, io::uo) is det. create_archive(ErrorStream, LibFileName, Quote, ObjectList, Succeeded, !IO) :- - globals__io_lookup_string_option(create_archive_command, ArCmd, !IO), - globals__io_lookup_accumulating_option(create_archive_command_flags, + globals.io_lookup_string_option(create_archive_command, ArCmd, !IO), + globals.io_lookup_accumulating_option(create_archive_command_flags, ArFlagsList, !IO), join_string_list(ArFlagsList, "", "", " ", ArFlags), - globals__io_lookup_string_option(create_archive_command_output_flag, + globals.io_lookup_string_option(create_archive_command_output_flag, ArOutputFlag, !IO), - globals__io_lookup_string_option(ranlib_command, RanLib, !IO), + globals.io_lookup_string_option(ranlib_command, RanLib, !IO), ( Quote = yes, join_quoted_string_list(ObjectList, "", "", " ", Objects) @@ -1677,7 +1676,7 @@ create_archive(ErrorStream, LibFileName, Quote, ObjectList, Succeeded, !IO) :- % Quoting would prevent that. join_string_list(ObjectList, "", "", " ", Objects) ), - MakeLibCmd = string__append_list([ + MakeLibCmd = string.append_list([ ArCmd, " ", ArFlags, " ", ArOutputFlag, " ", LibFileName, " ", Objects]), invoke_system_command(ErrorStream, verbose_commands, @@ -1689,12 +1688,12 @@ create_archive(ErrorStream, LibFileName, Quote, ObjectList, Succeeded, !IO) :- -> Succeeded = MakeLibCmdSucceeded ; - RanLibCmd = string__append_list([RanLib, " ", LibFileName]), + RanLibCmd = string.append_list([RanLib, " ", LibFileName]), invoke_system_command(ErrorStream, verbose_commands, RanLibCmd, Succeeded, !IO) ). -:- pred create_java_archive(io__output_stream::in, module_name::in, +:- pred create_java_archive(io.output_stream::in, module_name::in, file_name::in, list(file_name)::in, bool::out, io::di, io::uo) is det. create_java_archive(ErrorStream, ModuleName, JarFileName, ObjectList, @@ -1705,28 +1704,27 @@ create_java_archive(ErrorStream, ModuleName, JarFileName, ObjectList, join_quoted_string_list(ObjectList, "", "", " ", Objects), list_class_files_for_jar(ModuleName, Objects, ListClassFiles, !IO), - Cmd = string__append_list([ + Cmd = string.append_list([ Jar, " ", JarCreateFlags, " ", JarFileName, " ", ListClassFiles ]), invoke_system_command(ErrorStream, verbose_commands, Cmd, Succeeded, !IO). get_object_code_type(FileType, ObjectCodeType, !IO) :- - globals__io_lookup_string_option(pic_object_file_extension, PicObjExt, - !IO), - globals__io_lookup_string_option(link_with_pic_object_file_extension, + globals.io_lookup_string_option(pic_object_file_extension, PicObjExt, !IO), + globals.io_lookup_string_option(link_with_pic_object_file_extension, LinkWithPicObjExt, !IO), - globals__io_lookup_string_option(object_file_extension, ObjExt, !IO), - globals__io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO), - globals__io_lookup_bool_option(gcc_global_registers, GCCGlobals, !IO), - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), - globals__io_lookup_bool_option(pic, PIC, !IO), - globals__io_get_target(Target, !IO), + globals.io_lookup_string_option(object_file_extension, ObjExt, !IO), + globals.io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO), + globals.io_lookup_bool_option(gcc_global_registers, GCCGlobals, !IO), + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), + globals.io_lookup_bool_option(pic, PIC, !IO), + globals.io_get_target(Target, !IO), ( PIC = yes, % We've been explicitly told to use position independent code. ObjectCodeType = ( if PicObjExt = ObjExt then non_pic else pic ) ; - PIC = no, + PIC = no, ( FileType = static_library, ObjectCodeType = non_pic @@ -1771,9 +1769,9 @@ get_object_code_type(FileType, ObjectCodeType, !IO) :- :- pred standard_library_directory_option(string::out, io::di, io::uo) is det. standard_library_directory_option(Opt, !IO) :- - globals__io_lookup_maybe_string_option(mercury_standard_library_directory, + globals.io_lookup_maybe_string_option(mercury_standard_library_directory, MaybeStdLibDir, !IO), - globals__io_lookup_maybe_string_option(mercury_configuration_directory, + globals.io_lookup_maybe_string_option(mercury_configuration_directory, MaybeConfDir, !IO), ( MaybeStdLibDir = yes(StdLibDir), @@ -1807,11 +1805,11 @@ join_string_list([], _Prefix, _Suffix, _Separator, ""). join_string_list([String | Strings], Prefix, Suffix, Separator, Result) :- ( Strings = [], - string__append_list([Prefix, String, Suffix], Result) + string.append_list([Prefix, String, Suffix], Result) ; Strings = [_ | _], join_string_list(Strings, Prefix, Suffix, Separator, Result0), - string__append_list([Prefix, String, Suffix, Separator, Result0], + string.append_list([Prefix, String, Suffix, Separator, Result0], Result) ). @@ -1838,7 +1836,7 @@ join_quoted_string_list(Strings, Prefix, Suffix, Separator, Result) :- join_module_list([], _Extension, [], !IO). join_module_list([Module | Modules], Extension, [FileName | Rest], !IO) :- - file_name_to_module_name(dir__basename_det(Module), ModuleName), + file_name_to_module_name(dir.basename_det(Module), ModuleName), module_name_to_file_name(ModuleName, Extension, no, FileName, !IO), join_module_list(Modules, Extension, Rest, !IO). @@ -1846,14 +1844,14 @@ join_module_list([Module | Modules], Extension, [FileName | Rest], !IO) :- make_all_module_command(Command0, MainModule, AllModules, Command, !IO) :- % Pass the main module first. - list__map_foldl( + list.map_foldl( (pred(Module::in, FileName::out, IO0::di, IO::uo) is det :- module_name_to_file_name(Module, ".m", no, FileName, IO0, IO) ), - [MainModule | list__delete_all(AllModules, MainModule)], + [MainModule | list.delete_all(AllModules, MainModule)], ModuleNameStrings, !IO), - Command = string__join_list(" ", - list__map(quote_arg, [Command0 | ModuleNameStrings])). + Command = string.join_list(" ", + list.map(quote_arg, [Command0 | ModuleNameStrings])). %-----------------------------------------------------------------------------% @@ -1862,15 +1860,13 @@ make_all_module_command(Command0, MainModule, AllModules, Command, !IO) :- maybe_pic_object_file_extension(Globals::in, PIC::in, Ext::out) :- ( PIC = non_pic, - globals__lookup_string_option(Globals, - object_file_extension, Ext) + globals.lookup_string_option(Globals, object_file_extension, Ext) ; PIC = pic, - globals__lookup_string_option(Globals, - pic_object_file_extension, Ext) + globals.lookup_string_option(Globals, pic_object_file_extension, Ext) ; PIC = link_with_pic, - globals__lookup_string_option(Globals, + globals.lookup_string_option(Globals, link_with_pic_object_file_extension, Ext) ). maybe_pic_object_file_extension(Globals::in, PIC::out, Ext::in) :- @@ -1878,17 +1874,15 @@ maybe_pic_object_file_extension(Globals::in, PIC::out, Ext::in) :- % This test must come first -- if the architecture doesn't % need special treatment for PIC, we should always return % `non_pic'. `mmc --make' depends on this. - globals__lookup_string_option(Globals, - object_file_extension, Ext) + globals.lookup_string_option(Globals, object_file_extension, Ext) -> PIC = non_pic ; - globals__lookup_string_option(Globals, - pic_object_file_extension, Ext) + globals.lookup_string_option(Globals, pic_object_file_extension, Ext) -> PIC = pic ; - globals__lookup_string_option(Globals, + globals.lookup_string_option(Globals, link_with_pic_object_file_extension, Ext) -> PIC = link_with_pic @@ -1897,7 +1891,7 @@ maybe_pic_object_file_extension(Globals::in, PIC::out, Ext::in) :- ). maybe_pic_object_file_extension(PIC, ObjExt, !IO) :- - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), maybe_pic_object_file_extension(Globals, PIC, ObjExt). %-----------------------------------------------------------------------------% diff --git a/compiler/complexity.m b/compiler/complexity.m index 8a910b952..85d1e0127 100644 --- a/compiler/complexity.m +++ b/compiler/complexity.m @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__complexity. +:- module transform_hlds.complexity. :- interface. :- import_module hlds.hlds_module. @@ -90,14 +90,14 @@ %-----------------------------------------------------------------------------% read_spec_file(FileName, MaybeNumLinesProcMap, !IO) :- - io__open_input(FileName, ResStream, !IO), + io.open_input(FileName, ResStream, !IO), ( ResStream = error(Error), - MaybeNumLinesProcMap = error(io__error_message(Error)) + MaybeNumLinesProcMap = error(io.error_message(Error)) ; ResStream = ok(Stream), read_spec_file_lines(Stream, 0, NumLines, MaybeError, - map__init, ProcMap, !IO), + map.init, ProcMap, !IO), ( MaybeError = yes(Msg), MaybeNumLinesProcMap = error(Msg) @@ -107,13 +107,13 @@ read_spec_file(FileName, MaybeNumLinesProcMap, !IO) :- ) ). -:- pred read_spec_file_lines(io__input_stream::in, int::in, int::out, +:- pred read_spec_file_lines(io.input_stream::in, int::in, int::out, maybe(string)::out, map(string, int)::in, map(string, int)::out, io::di, io::uo) is det. read_spec_file_lines(Stream, CurLineNum, NumLines, MaybeError, !ProcMap, !IO) :- - io__read_line(Stream, ResLine, !IO), + io.read_line(Stream, ResLine, !IO), ( ResLine = eof, NumLines = CurLineNum, @@ -121,12 +121,12 @@ read_spec_file_lines(Stream, CurLineNum, NumLines, MaybeError, !ProcMap, ; ResLine = error(Error), NumLines = CurLineNum, - MaybeError = yes(io__error_message(Error)) + MaybeError = yes(io.error_message(Error)) ; ResLine = ok(Chars0), - list__filter(unify('\n'), Chars0, _, Chars), - string__from_char_list(Chars, ProcName), - ( map__insert(!.ProcMap, ProcName, CurLineNum, !:ProcMap) -> + list.filter(unify('\n'), Chars0, _, Chars), + string.from_char_list(Chars, ProcName), + ( map.insert(!.ProcMap, ProcName, CurLineNum, !:ProcMap) -> read_spec_file_lines(Stream, CurLineNum + 1, NumLines, MaybeError, !ProcMap, !IO) ; @@ -149,7 +149,7 @@ complexity_proc_name(ModuleInfo, PredId, ProcId) = FullName :- is_in_complexity_proc_map(ProcMap, ModuleInfo, PredId, ProcId) = IsInMap :- FullName = complexity_proc_name(ModuleInfo, PredId, ProcId), - ( map__search(ProcMap, FullName, ProcNum) -> + ( map.search(ProcMap, FullName, ProcNum) -> IsInMap = yes(ProcNum) ; IsInMap = no @@ -164,7 +164,7 @@ process_proc_msg(NumProcs, ProcMap, PredId, ProcId, !ProcInfo, !ModuleInfo, ( IsInMap = yes(ProcNum), FullName = complexity_proc_name(!.ModuleInfo, PredId, ProcId), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), ( Verbose = yes, pred_id_to_int(PredId, PredIdInt), @@ -265,7 +265,7 @@ process_proc(NumProcs, ProcNum, FullName, PredId, !ProcInfo, !ModuleInfo) :- % generated by the transformation does, so we need to compute the % nonlocals from the headvars rather than getting it from the % nonlocals field in the original goal. - set__list_to_set(HeadVars, OrigNonLocals), + set.list_to_set(HeadVars, OrigNonLocals), OrigGoal = _ - OrigGoalInfo, goal_info_get_instmap_delta(OrigGoalInfo, OrigInstMapDelta), add_goal_info_purity_feature(purity_impure, @@ -277,7 +277,7 @@ process_proc(NumProcs, ProcNum, FullName, PredId, !ProcInfo, !ModuleInfo) :- classify_args(HeadVars, ArgModes, !.ModuleInfo, VarSet, VarTypes, VarInfos), allocate_slot_numbers_cl(VarInfos, 0, NumberedProfiledVars), - list__length(NumberedProfiledVars, NumProfiledVars), + list.length(NumberedProfiledVars, NumProfiledVars), generate_slot_goals(ProcNum, NumberedProfiledVars, NumProfiledVars, Context, PredId, !ProcInfo, !ModuleInfo, SlotVar, SlotVarName, SlotGoals), @@ -370,7 +370,7 @@ process_proc(NumProcs, ProcNum, FullName, PredId, !ProcInfo, !ModuleInfo) :- proc_info_set_goal(Goal, !ProcInfo), - assoc_list__values(VarInfos, Infos), + assoc_list.values(VarInfos, Infos), ComplexityInfo = complexity_proc_info(ProcNum, FullName, Infos), module_info_get_complexity_proc_infos(!.ModuleInfo, ComplexityInfos0), ComplexityInfos = [ComplexityInfo | ComplexityInfos0], @@ -392,7 +392,7 @@ process_proc(NumProcs, ProcNum, FullName, PredId, !ProcInfo, !ModuleInfo) :- % to compute the sizes. % :- pred generate_slot_goals(int::in, assoc_list(prog_var, int)::in, - int::in, term__context::in, pred_id::in, + int::in, term.context::in, pred_id::in, proc_info::in, proc_info::out, module_info::in, module_info::out, prog_var::out, string::out, list(hlds_goal)::out) is det. @@ -415,10 +415,10 @@ generate_slot_goals(ProcNum, NumberedVars, NumProfiledVars, Context, PredId, complexity_generate_foreign_proc(PredName, det, [SlotVarArg], ForeignArgs, DeclCodeStr, PredCodeStr, ProcStr ++ FillCodeStr, [SlotVar], !.ModuleInfo, Context, CallGoal), - list__append(PrefixGoals, [CallGoal], Goals). + list.append(PrefixGoals, [CallGoal], Goals). :- pred generate_size_goals(assoc_list(prog_var, int)::in, - term__context::in, int::in, string::in, string::in, pred_id::in, + term.context::in, int::in, string::in, string::in, pred_id::in, proc_info::in, proc_info::out, module_info::in, module_info::out, list(hlds_goal)::out, list(foreign_arg)::out, string::out) is det. @@ -434,7 +434,7 @@ generate_size_goals([Var - VarSeqNum | NumberedVars], Context, NumProfiledVars, ProcVarName, SlotVarName, PredId, !ProcInfo, !ModuleInfo, RestGoals, RestForeignArgs, RestCodeStr). -:- pred generate_size_goal(prog_var::in, int::in, term__context::in, +:- pred generate_size_goal(prog_var::in, int::in, term.context::in, int::in, string::in, string::in, pred_id::in, proc_info::in, proc_info::out, module_info::in, module_info::out, list(hlds_goal)::out, list(foreign_arg)::out, string::out) is det. @@ -443,13 +443,13 @@ generate_size_goal(ArgVar, VarSeqNum, Context, NumProfiledVars, ProcVarName, SlotVarName, PredId, !ProcInfo, !ModuleInfo, Goals, ForeignArgs, CodeStr) :- proc_info_vartypes(!.ProcInfo, VarTypes1), - map__lookup(VarTypes1, ArgVar, VarType), + map.lookup(VarTypes1, ArgVar, VarType), MacroName = "MR_complexity_fill_size_slot", make_type_info_var(VarType, Context, PredId, !ProcInfo, !ModuleInfo, TypeInfoVar, Goals), % Since we just created TypeInfoVar, it isn't in VarTypes1. proc_info_vartypes(!.ProcInfo, VarTypes2), - map__lookup(VarTypes2, TypeInfoVar, TypeInfoType), + map.lookup(VarTypes2, TypeInfoVar, TypeInfoType), ArgName = "arg" ++ int_to_string(VarSeqNum), TypeInfoArgName = "input_typeinfo" ++ int_to_string(VarSeqNum), ForeignArg = foreign_arg(ArgVar, @@ -473,14 +473,14 @@ generate_size_goal(ArgVar, VarSeqNum, Context, NumProfiledVars, ProcVarName, generate_new_var(Name, Type, !ProcInfo, Var) :- proc_info_varset(!.ProcInfo, VarSet0), proc_info_vartypes(!.ProcInfo, VarTypes0), - varset__new_named_var(VarSet0, Name, Var, VarSet), - map__set(VarTypes0, Var, Type, VarTypes), + varset.new_named_var(VarSet0, Name, Var, VarSet), + map.set(VarTypes0, Var, Type, VarTypes), proc_info_set_varset(VarSet, !ProcInfo), proc_info_set_vartypes(VarTypes, !ProcInfo). :- pred complexity_generate_foreign_proc(string::in, determinism::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, string::in, - string::in, list(prog_var)::in, module_info::in, term__context::in, + string::in, list(prog_var)::in, module_info::in, term.context::in, hlds_goal::out) is det. complexity_generate_foreign_proc(PredName, Detism, Args, ExtraArgs, @@ -488,7 +488,7 @@ complexity_generate_foreign_proc(PredName, Detism, Args, ExtraArgs, mercury_term_size_prof_builtin_module(BuiltinModule), Attrs0 = default_attributes(c), set_may_call_mercury(will_not_call_mercury, Attrs0, Attrs), - goal_util__generate_foreign_proc(BuiltinModule, PredName, predicate, + goal_util.generate_foreign_proc(BuiltinModule, PredName, predicate, only_mode, Detism, Attrs, Args, ExtraArgs, PrefixCode, Code, SuffixCode, [impure_goal], ground_vars(BoundVars), ModuleInfo, Context, Goal). @@ -507,13 +507,13 @@ classify_args([], [_ | _], _, _, _, _) :- classify_args([Var | Vars], [Mode | Modes], ModuleInfo, VarSet, VarTypes, [Var - complexity_arg_info(MaybeName, Kind) | VarInfos]) :- classify_args(Vars, Modes, ModuleInfo, VarSet, VarTypes, VarInfos), - ( varset__search_name(VarSet, Var, Name) -> + ( varset.search_name(VarSet, Var, Name) -> MaybeName = yes(Name) ; MaybeName = no ), ( mode_is_fully_input(ModuleInfo, Mode) -> - map__lookup(VarTypes, Var, VarType), + map.lookup(VarTypes, Var, VarType), ( zero_size_type(VarType, ModuleInfo) -> Kind = complexity_input_fixed_size ; @@ -543,7 +543,7 @@ allocate_slot_numbers_cl([Var - Info | VarInfos], Offset, :- func ground_vars(list(prog_var)) = assoc_list(prog_var, mer_inst). ground_vars(Vars) = VarsAndGround :- - VarsAndGround = list__map(pair_with_ground, Vars). + VarsAndGround = list.map(pair_with_ground, Vars). :- func pair_with_ground(prog_var) = pair(prog_var, mer_inst). @@ -559,7 +559,7 @@ is_active_type = Type :- %-----------------------------------------------------------------------------% -:- pred make_type_info_var(mer_type::in, term__context::in, pred_id::in, +:- pred make_type_info_var(mer_type::in, term.context::in, pred_id::in, proc_info::in, proc_info::out, module_info::in, module_info::out, prog_var::out, list(hlds_goal)::out) is det. @@ -567,7 +567,7 @@ make_type_info_var(Type, Context, PredId, !ProcInfo, !ModuleInfo, TypeInfoVar, TypeInfoGoals) :- module_info_pred_info(!.ModuleInfo, PredId, PredInfo0), create_poly_info(!.ModuleInfo, PredInfo0, !.ProcInfo, PolyInfo0), - polymorphism__make_type_info_var(Type, Context, TypeInfoVar, + polymorphism.make_type_info_var(Type, Context, TypeInfoVar, TypeInfoGoals, PolyInfo0, PolyInfo), poly_info_extract(PolyInfo, PredInfo0, PredInfo, !ProcInfo, !:ModuleInfo), diff --git a/compiler/const_prop.m b/compiler/const_prop.m index 58599b6fb..2bd83321c 100644 --- a/compiler/const_prop.m +++ b/compiler/const_prop.m @@ -20,7 +20,7 @@ % %---------------------------------------------------------------------------% -:- module transform_hlds__const_prop. +:- module transform_hlds.const_prop. :- interface. :- import_module hlds.hlds_goal. @@ -93,10 +93,10 @@ evaluate_call(PredId, ProcId, Args, VarTypes, InstMap, ModuleInfo, Goal, predicate_name(ModuleInfo, PredId, PredName), proc_id_to_int(ProcId, ProcInt), LookupArgs = (func(Var) = arg_hlds_info(Var, Type, Inst) :- - instmap__lookup_var(InstMap, Var, Inst), + instmap.lookup_var(InstMap, Var, Inst), Type = VarTypes ^ det_elem(Var) ), - ArgHldsInfos = list__map(LookupArgs, Args), + ArgHldsInfos = list.map(LookupArgs, Args), evaluate_call_2(ModuleName, PredName, ProcInt, ArgHldsInfos, Goal, GoalInfo0, GoalInfo). @@ -331,9 +331,9 @@ evaluate_det_call("string", Name, _, [X, Y, Z], Z, string_const(ZVal)) :- X ^ arg_inst = bound(_XUniq, [functor(string_const(XVal), [])]), Y ^ arg_inst = bound(_YUniq, [functor(string_const(YVal), [])]), - % We can only do the append if Z is free (this allows - % us to ignore the mode number and pick up both the - % predicate and function versions of append) + % We can only do the append if Z is free (this allows us to ignore + % the mode number and pick up both the predicate and function versions + % of append). Z ^ arg_inst = free, ZVal = XVal ++ YVal. @@ -345,15 +345,14 @@ evaluate_det_call("string", Name, _, [X, Y, Z], Z, string_const(ZVal)) :- % ModuleName.ProcName(ArgList) % whose mode is specified by ModeNum. % - % If the call is a semidet call with no outputs that can be - % statically evaluated, evaluate_test succeeds with - % Result being "yes" if the call will succeed and "no" if the - % call will fail. - % Otherwise (i.e. if the call is not semidet, has any outputs, - % or cannot be statically evaluated), evaluate_test fails. + % If the call is a semidet call with no outputs that can be statically + % evaluated, evaluate_test succeeds with Result being "yes" if the call + % will succeed and "no" if the call will fail. Otherwise (i.e. if the call + % is not semidet, has any outputs, or cannot be statically evaluated), + % evaluate_test fails. % -:- pred evaluate_test(string::in, string::in, int::in, - list(arg_hlds_info)::in, bool::out) is semidet. +:- pred evaluate_test(string::in, string::in, int::in, list(arg_hlds_info)::in, + bool::out) is semidet. % Integer comparisons @@ -447,18 +446,16 @@ evaluate_test("private_builtin", "typed_unify", Mode, Args, Result) :- eval_unify(X, Y, Result) ). - % evaluate_semidet_call(ModuleName, ProcName, ModeNum, - % Args, Result): + % evaluate_semidet_call(ModuleName, ProcName, ModeNum, Args, Result): % % This attempts to evaluate a call to % ModuleName.ProcName(Args) % whose mode is specified by ModeNum. % - % If the call is a semidet call with one output that can be - % statically evaluated, evaluate_semidet_call succeeds with - % Result being "no" if the call will fail, or - % yes(OutputArg - OutputArgValue) if it will succeed, with - % OutputArg being whichever of the arguments is output, + % If the call is a semidet call with one output that can be statically + % evaluated, evaluate_semidet_call succeeds with Result being "no" + % if the call will fail, or yes(OutputArg - OutputArgValue) if it will + % succeed, with OutputArg being whichever of the arguments is output, % and with OutputArgVal being the computed value of OutputArg. % % Otherwise (i.e. if the call is not semidet, or has no outputs @@ -474,8 +471,7 @@ evaluate_test("private_builtin", "typed_unify", Mode, Args, Result) :- is semidet. evaluate_semidet_call("std_util", "dynamic_cast", 0, Args, Result) :- - evaluate_semidet_call("private_builtin", "typed_unify", 1, - Args, Result). + evaluate_semidet_call("private_builtin", "typed_unify", 1, Args, Result). evaluate_semidet_call("private_builtin", "typed_unify", Mode, Args, Result) :- % mode 0 is the (in, in) mode @@ -497,12 +493,11 @@ evaluate_semidet_call("private_builtin", "typed_unify", Mode, Args, Result) :- % This attempts to evaluate a call to % builtin.unify(FirstArg, SecondArg) % with mode (in, in). - % If the unification can be statically evaluated, - % evaluate_builtin_test succeeds with Result being "yes" - % if the unification will succeed and "no" if the - % unification will fail. Otherwise (i.e. if the unification + % If the unification can be statically evaluated, evaluate_builtin_test + % succeeds with Result being "yes" if the unification will succeed + % and "no" if the unification will fail. Otherwise (i.e. if the unification % cannot be statically evaluated), evaluate_unify fails. - + % :- pred eval_unify(arg_hlds_info::in, arg_hlds_info::in, bool::out) is semidet. eval_unify(X, Y, Result) :- @@ -537,8 +532,7 @@ eval_unify(X, Y, Result) :- make_assignment_goal(OutputArg, InputArg, Goal, !GoalInfo) :- make_assignment(OutputArg, InputArg, Goal), goal_info_get_instmap_delta(!.GoalInfo, Delta0), - instmap_delta_set(OutputArg ^ arg_var, InputArg ^ arg_inst, - Delta0, Delta), + instmap_delta_set(OutputArg ^ arg_var, InputArg ^ arg_inst, Delta0, Delta), goal_info_set_instmap_delta(Delta, !GoalInfo), goal_info_set_determinism(det, !GoalInfo). @@ -568,6 +562,7 @@ make_assignment(OutputArg, InputArg, Goal) :- % recompute_instmap_delta is run by simplify.m if anything changes, % so the insts are not important here. + % :- pred make_construction(arg_hlds_info::in, cons_id::in, hlds_goal_expr::out) is det. diff --git a/compiler/constraint.m b/compiler/constraint.m index 124692d15..afd9b5e37 100644 --- a/compiler/constraint.m +++ b/compiler/constraint.m @@ -88,9 +88,8 @@ propagate_constraints_in_goal(Goal0, Goal, !Info, !IO) :- io::di, io::uo) is det. propagate_goal(Goal0, Constraints, Goal, !Info, !IO) :- - % We need to treat all single goals as conjunctions so that - % propagate_conj can move the constraints to the left of the goal - % if that is allowed. + % We need to treat all single goals as conjunctions so that propagate_conj + % can move the constraints to the left of the goal if that is allowed. Goal0 = _ - GoalInfo0, goal_info_get_features(GoalInfo0, Features0), goal_info_get_context(GoalInfo0, Context), @@ -173,14 +172,13 @@ propagate_conj_sub_goal_2(scope(Reason, Goal0) - GoalInfo, Constraints, propagate_conj_sub_goal_2(not(NegGoal0) - GoalInfo, Constraints0, [not(NegGoal) - GoalInfo | Constraints], !Info, !IO) :- % We can't safely propagate constraints into a negation, - % because that would change the answers computed by the - % procedure. + % because that would change the answers computed by the procedure. propagate_goal(NegGoal0, [], NegGoal, !Info, !IO), flatten_constraints(Constraints0, Constraints). propagate_conj_sub_goal_2(Goal, Constraints0, [Goal | Constraints], !Info, !IO) :- - % propagate_conj will move the constraints to the left of the call + % Propagate_conj will move the constraints to the left of the call % if that is possible, so nothing needs to be done here. Goal = call(_, _, _, _, _, _) - _, flatten_constraints(Constraints0, Constraints). @@ -211,12 +209,12 @@ propagate_conj_sub_goal_2(Goal, _, _, !Info, !IO) :- :- pred flatten_constraints(list(constraint)::in, hlds_goals::out) is det. flatten_constraints(Constraints0, Goals) :- - list__map((pred(Constraint::in, Lists::out) is det :- + list.map((pred(Constraint::in, Lists::out) is det :- Constraint = constraint(Goal, _, _, Constructs), Lists = [Constructs, [Goal]] ), Constraints0, GoalLists0), - list__condense(GoalLists0, GoalLists), - list__condense(GoalLists, Goals). + list.condense(GoalLists0, GoalLists), + list.condense(GoalLists, Goals). %-----------------------------------------------------------------------------% @@ -250,10 +248,9 @@ propagate_cases(Var, Constraints, [case(ConsId, Goal0) | Cases0], %-----------------------------------------------------------------------------% % propagate_conj detects the constraints in a conjunction and - % moves them to as early as possible in the list. Some effort is - % made to keep the constraints in the same order as they are - % encountered to increase the likelihood of folding recursive - % calls. + % moves them to as early as possible in the list. Some effort is made + % to keep the constraints in the same order as they are encountered + % to increase the likelihood of folding recursive calls. % :- pred propagate_conj(hlds_goals::in, list(constraint)::in, hlds_goals::out, constraint_info::in, constraint_info::out, @@ -288,11 +285,11 @@ annotate_conj_output_vars([Goal | Goals], ModuleInfo, VarTypes, InstMap0, Goal = _ - GoalInfo, goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap), instmap_changed_vars(InstMap0, InstMap, VarTypes, ModuleInfo, ChangedVars0), - instmap__vars_list(InstMap, InstMapVars), + instmap.vars_list(InstMap, InstMapVars), % % Restrict the set of changed variables down to the set for % which the new inst is not an acceptable substitute for the @@ -302,32 +299,32 @@ annotate_conj_output_vars([Goal | Goals], ModuleInfo, VarTypes, InstMap0, % `bound(shared, ...)'. % InCompatible = (pred(Var::in) is semidet :- - instmap__lookup_var(InstMap0, Var, InstBefore), + instmap.lookup_var(InstMap0, Var, InstBefore), instmap_delta_search_var(InstMapDelta, Var, InstAfter), \+ inst_matches_initial(InstAfter, InstBefore, - map__lookup(VarTypes, Var), ModuleInfo) + map.lookup(VarTypes, Var), ModuleInfo) ), - IncompatibleInstVars = set__list_to_set( - list__filter(InCompatible, InstMapVars)), + IncompatibleInstVars = set.list_to_set( + list.filter(InCompatible, InstMapVars)), % % This will consider variables with inst `any' to be bound by % the goal, so goals which have non-locals with inst `any' will % not be considered to be constraints. XXX This is too conservative. % Bound = (pred(Var::in) is semidet :- - instmap__lookup_var(InstMap0, Var, InstBefore), + instmap.lookup_var(InstMap0, Var, InstBefore), instmap_delta_search_var(InstMapDelta, Var, InstAfter), \+ inst_matches_binding(InstAfter, InstBefore, - map__lookup(VarTypes, Var), ModuleInfo) + map.lookup(VarTypes, Var), ModuleInfo) ), - BoundVars = set__list_to_set(list__filter(Bound, InstMapVars)), + BoundVars = set.list_to_set(list.filter(Bound, InstMapVars)), % % Make sure that variables with inst `any' are placed in % the changed vars set. XXX This is too conservative, but % avoids unexpected reorderings. % - set__union(ChangedVars0, BoundVars, ChangedVars), + set.union(ChangedVars0, BoundVars, ChangedVars), AnnotatedConjunct = annotated_conjunct(Goal, ChangedVars, BoundVars, IncompatibleInstVars), @@ -342,49 +339,48 @@ annotate_conj_output_vars([Goal | Goals], ModuleInfo, VarTypes, InstMap0, :- type annotated_conj == list(annotated_conjunct). :- type annotated_conjunct - ---> annotated_conjunct( - hlds_goal, + ---> annotated_conjunct( + hlds_goal, - % All variables returned by instmap_changed_vars. - set(prog_var), + % All variables returned by instmap_changed_vars. + set(prog_var), - % All variables returned by instmap_changed_vars for - % which inst_matches_binding(NewInst, OldInst) fails. - set(prog_var), - - % Variables returned by instmap_changed_vars - % for which the new inst cannot be substituted - % for the old as an input to a goal - % (inst_matches_initial(NewInst, OldInst) fails). - set(prog_var) - ). + % All variables returned by instmap_changed_vars for + % which inst_matches_binding(NewInst, OldInst) fails. + set(prog_var), + % Variables returned by instmap_changed_vars + % for which the new inst cannot be substituted + % for the old as an input to a goal + % (inst_matches_initial(NewInst, OldInst) fails). + set(prog_var) + ). % A constraint is a goal that may fail, has no outputs, % always terminates and will not throw an exception. % :- type constraint - ---> constraint( - % The constraint itself. - hlds_goal, + ---> constraint( + % The constraint itself. + hlds_goal, - % All variables returned by instmap_changed_vars. - set(prog_var), + % All variables returned by instmap_changed_vars. + set(prog_var), - % Variables returned by instmap_changed_vars - % for which the new inst cannot be substituted - % for the old as an input to a goal - % (inst_matches_initial(NewInst, OldInst) fails). - set(prog_var), + % Variables returned by instmap_changed_vars + % for which the new inst cannot be substituted + % for the old as an input to a goal + % (inst_matches_initial(NewInst, OldInst) fails). + set(prog_var), - % Goals to construct constants used by the constraint. - % (as in X = 2, Y < X). These need to be propagated - % with the constraint. - list(hlds_goal) - ). + % Goals to construct constants used by the constraint. + % (as in X = 2, Y < X). These need to be propagated + % with the constraint. + list(hlds_goal) + ). % Conjunction annotated with constraining goals. - % + % :- type constrained_conj == assoc_list(hlds_goal, list(constraint)). % Pass backwards over the conjunction, annotating each conjunct @@ -396,10 +392,10 @@ annotate_conj_output_vars([Goal | Goals], ModuleInfo, VarTypes, InstMap0, annotate_conj_constraints(_, [], Constraints0, Goals0, Goals, !Info, !IO) :- flatten_constraints(Constraints0, Constraints1), - list__map((pred(Goal::in, CnstrGoal::out) is det :- + list.map((pred(Goal::in, CnstrGoal::out) is det :- CnstrGoal = Goal - [] ), Constraints1, Constraints), - list__append(Constraints, Goals0, Goals). + list.append(Constraints, Goals0, Goals). annotate_conj_constraints(ModuleInfo, [Conjunct | RevConjuncts0], Constraints0, Goals0, Goals, !Info, !IO) :- @@ -407,27 +403,23 @@ annotate_conj_constraints(ModuleInfo, IncompatibleInstVars), Goal = GoalExpr - GoalInfo, goal_info_get_nonlocals(GoalInfo, NonLocals), - CI_ModuleInfo0 = !.Info ^ module_info, + CI_ModuleInfo0 = !.Info ^ module_info, goal_can_loop_or_throw(Goal, GoalCanLoopOrThrow, CI_ModuleInfo0, CI_ModuleInfo, !IO), !:Info = !.Info ^ module_info := CI_ModuleInfo, ( - % Propagate goals that can fail and have no output - % variables. Propagating cc_nondet goals would be - % tricky, because we would need to be careful about - % reordering the constraints (the cc_nondet goal can't - % be moved before any goals which can fail). - % + % Propagate goals that can fail and have no output variables. + % Propagating cc_nondet goals would be tricky, because we would + % need to be careful about reordering the constraints (the cc_nondet + % goal can't be moved before any goals which can fail). goal_info_get_determinism(GoalInfo, Detism), ( Detism = semidet ; Detism = failure ), - % - % XXX This is probably a bit too conservative. For - % example, `any->any' moded non-locals are considered - % to be outputs. - % - set__empty(OutputVars), + + % XXX This is probably a bit too conservative. For example, + % `any->any' moded non-locals are considered to be outputs. + set.empty(OutputVars), % Don't propagate impure goals. goal_info_is_pure(GoalInfo), @@ -442,18 +434,15 @@ annotate_conj_constraints(ModuleInfo, IncompatibleInstVars, []), Constraints1 = [Constraint | Constraints0] ; - % - % Look for a simple goal which some constraint depends - % on which can be propagated backwards. This handles - % cases like X = 2, Y < X. This should only be done for - % goals which result in no execution at runtime, such as - % construction of static constants. Currently we only - % allow constructions of zero arity constants. - % - % Make a renamed copy of the goal, renaming within the - % constraint as well, so that a copy of the constant - % doesn't need to be kept on the stack. - % + % Look for a simple goal which some constraint depends on + % which can be propagated backwards. This handles cases like + % X = 2, Y < X. This should only be done for goals which result in + % no execution at runtime, such as construction of static constants. + % Currently we only allow constructions of zero arity constants. + + % Make a renamed copy of the goal, renaming within the constraint + % as well, so that a copy of the constant doesn't need to be kept + % on the stack. Goal = unify(_, _, _, Unify, _) - _, Unify = construct(ConstructVar, _, [], _, _, _, _) -> @@ -461,13 +450,12 @@ annotate_conj_constraints(ModuleInfo, add_constant_construction(ConstructVar, Goal, Constraints0, Constraints1, !Info), - % If the constraint was the only use of the constant, - % the old goal can be removed. We need to rerun - % quantification to work that out. + % If the constraint was the only use of the constant, the old goal + % can be removed. We need to rerun quantification to work that out. !:Info = !.Info ^ changed := yes ; - % Prune away the constraints after a goal that cannot - % succeed -- they can never be executed. + % Prune away the constraints after a goal that cannot succeed + % -- they can never be executed. goal_info_get_determinism(GoalInfo, Detism), determinism_components(Detism, _, at_most_zero) -> @@ -482,37 +470,33 @@ annotate_conj_constraints(ModuleInfo, Constraints1 = [], flatten_constraints(Constraints0, ConstraintGoals), - list__map(add_empty_constraints, [Goal | ConstraintGoals], + list.map(add_empty_constraints, [Goal | ConstraintGoals], GoalsAndConstraints), - list__append(GoalsAndConstraints, Goals0, Goals1) + list.append(GoalsAndConstraints, Goals0, Goals1) ; - % Don't move goals which can fail before a goal which - % can loop or throw an exception if `--fully-strict' is set. - % + % Don't move goals which can fail before a goal which can loop + % or throw an exception if `--fully-strict' is set. \+ goal_cannot_loop_or_throw(ModuleInfo, Goal), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, fully_strict, yes) + globals.lookup_bool_option(Globals, fully_strict, yes) -> - filter_dependent_constraints(NonLocals, - ChangedVars, Constraints0, DependentConstraints, - IndependentConstraints), + filter_dependent_constraints(NonLocals, ChangedVars, + Constraints0, DependentConstraints, IndependentConstraints), flatten_constraints(IndependentConstraints, IndependentConstraintGoals), - list__map(add_empty_constraints, IndependentConstraintGoals, + list.map(add_empty_constraints, IndependentConstraintGoals, GoalsAndConstraints), Goals1 = [attach_constraints(Goal, DependentConstraints) - | GoalsAndConstraints] ++ Goals0, + | GoalsAndConstraints] ++ Goals0, Constraints1 = [] ; - filter_dependent_constraints(NonLocals, - OutputVars, Constraints0, DependentConstraints, - IndependentConstraints), + filter_dependent_constraints(NonLocals, OutputVars, + Constraints0, DependentConstraints, IndependentConstraints), Constraints1 = IndependentConstraints, - Goals1 = [attach_constraints(Goal, DependentConstraints) - | Goals0] + Goals1 = [attach_constraints(Goal, DependentConstraints) | Goals0] ), - annotate_conj_constraints(ModuleInfo, RevConjuncts0, - Constraints1, Goals1, Goals, !Info, !IO). + annotate_conj_constraints(ModuleInfo, RevConjuncts0, Constraints1, + Goals1, Goals, !Info, !IO). :- pred add_empty_constraints(hlds_goal::in, pair(hlds_goal, list(constraint))::out) is det. @@ -524,11 +508,11 @@ add_empty_constraints(Goal, Goal - []). attach_constraints(Goal, Constraints0) = Goal - Constraints :- ( Goal = call(_, _, _, _, _, _) - _ -> - Constraints = list__map( - (func(constraint(Goal0, B, C, Constructs0)) = - constraint(add_constraint_feature(Goal0), B, C, - list__map(add_constraint_feature, Constructs0)) - ), Constraints0) + Constraints = list.map( + (func(constraint(Goal0, B, C, Constructs0)) = + constraint(add_constraint_feature(Goal0), B, C, + list.map(add_constraint_feature, Constructs0)) + ), Constraints0) ; Constraints = Constraints0 ). @@ -546,24 +530,22 @@ add_constraint_feature(Goal - GoalInfo0) = Goal - GoalInfo :- add_constant_construction(_, _, [], [], !Info). add_constant_construction(ConstructVar, Construct0, - [Constraint0 | Constraints0], - [Constraint | Constraints], !Info) :- + [Constraint0 | Constraints0], [Constraint | Constraints], !Info) :- Constraint0 = constraint(ConstraintGoal0, ChangedVars, IncompatibleInstVars, Constructs0), ( ConstraintGoal0 = _ - ConstraintInfo, - goal_info_get_nonlocals(ConstraintInfo, - ConstraintNonLocals), - set__member(ConstructVar, ConstraintNonLocals) + goal_info_get_nonlocals(ConstraintInfo, ConstraintNonLocals), + set.member(ConstructVar, ConstraintNonLocals) -> VarSet0 = !.Info ^ varset, VarTypes0 = !.Info ^ vartypes, - varset__new_var(VarSet0, NewVar, VarSet), - map__lookup(VarTypes0, ConstructVar, VarType), - map__det_insert(VarTypes0, NewVar, VarType, VarTypes), + varset.new_var(VarSet0, NewVar, VarSet), + map.lookup(VarTypes0, ConstructVar, VarType), + map.det_insert(VarTypes0, NewVar, VarType, VarTypes), !:Info = !.Info ^ varset := VarSet, !:Info = !.Info ^ vartypes := VarTypes, - map__from_assoc_list([ConstructVar - NewVar], Subn), + map.from_assoc_list([ConstructVar - NewVar], Subn), rename_vars_in_goal(Subn, Construct0, Construct), Constructs = [Construct | Constructs0], rename_vars_in_goal(Subn, ConstraintGoal0, ConstraintGoal), @@ -577,9 +559,9 @@ add_constant_construction(ConstructVar, Construct0, %-----------------------------------------------------------------------------% - % constraints__filter_dependent_constraints(GoalNonLocals, + % constraints.filter_dependent_constraints(GoalNonLocals, % GoalOutputVars, Constraints, DependentConstraints, - % IndependentConstraints) + % IndependentConstraints): % % Find all constraints which depend on the output variables of % the current goal in the conjunction being processed. The @@ -589,15 +571,14 @@ add_constant_construction(ConstructVar, Construct0, % current goal allow that. % :- pred filter_dependent_constraints(set(prog_var)::in, set(prog_var)::in, - list(constraint)::in, list(constraint)::out, list(constraint)::out) - is det. + list(constraint)::in, list(constraint)::out, list(constraint)::out) is det. filter_dependent_constraints(NonLocals, GoalOutputVars, Constraints, Dependent, Independent) :- filter_dependent_constraints(NonLocals, GoalOutputVars, Constraints, [], RevDependent, [], RevIndependent), - list__reverse(RevDependent, Dependent), - list__reverse(RevIndependent, Independent). + list.reverse(RevDependent, Dependent), + list.reverse(RevIndependent, Independent). :- pred filter_dependent_constraints(set(prog_var)::in, set(prog_var)::in, list(constraint)::in, @@ -614,36 +595,27 @@ filter_dependent_constraints(NonLocals, GoalOutputVars, ( ( - % - % A constraint is not independent of a goal - % if it uses any of the output variables - % of that goal. - % - set__intersect(ConstraintNonLocals, GoalOutputVars, + % A constraint is not independent of a goal if it uses + % any of the output variables of that goal. + set.intersect(ConstraintNonLocals, GoalOutputVars, OutputVarsUsedByConstraint), - \+ set__empty(OutputVarsUsedByConstraint) + \+ set.empty(OutputVarsUsedByConstraint) ; - % - % A constraint is not independent of a goal - % if it changes the inst of a non-local of the goal - % in such a way that the new inst is incompatible - % with the old inst (e.g. by losing uniqueness), - % - set__intersect(NonLocals, IncompatibleInstVars, + % A constraint is not independent of a goal if it changes + % the inst of a non-local of the goal in such a way that + % the new inst is incompatible with the old inst (e.g. by + % losing uniqueness). + set.intersect(NonLocals, IncompatibleInstVars, IncompatibleInstVarsUsedByGoal), - \+ set__empty(IncompatibleInstVarsUsedByGoal) + \+ set.empty(IncompatibleInstVarsUsedByGoal) ; - % - % A constraint is not independent of a goal if - % it uses any variables whose instantiatedness is - % changed by any the of the constraints already - % attached to the goal (the dependent constraints - % will be attached to the goal to be pushed into - % it by propagate_conj_sub_goal). - % - list__member(EarlierConstraint, !.RevDependent), - \+ can_reorder_constraints(EarlierConstraint, - Constraint) + % A constraint is not independent of a goal if it uses + % any variables whose instantiatedness is changed + % by any of the constraints already attached to the goal + % (the dependent constraints will be attached to the goal + % to be pushed into it by propagate_conj_sub_goal). + list.member(EarlierConstraint, !.RevDependent), + \+ can_reorder_constraints(EarlierConstraint, Constraint) ) -> !:RevDependent = [Constraint | !.RevDependent] @@ -662,9 +634,9 @@ can_reorder_constraints(EarlierConstraint, Constraint) :- Constraint = constraint(ConstraintGoal, _, _, _), ConstraintGoal = _ - ConstraintGoalInfo, goal_info_get_nonlocals(ConstraintGoalInfo, ConstraintNonLocals), - set__intersect(EarlierChangedVars, ConstraintNonLocals, + set.intersect(EarlierChangedVars, ConstraintNonLocals, EarlierConstraintIntersection), - set__empty(EarlierConstraintIntersection). + set.empty(EarlierConstraintIntersection). %-----------------------------------------------------------------------------% @@ -672,20 +644,19 @@ can_reorder_constraints(EarlierConstraint, Constraint) :- % :- pred propagate_conj_constraints(constrained_conj::in, list(hlds_goal)::in, list(hlds_goal)::out, - constraint_info::in, constraint_info::out, - io::di, io::uo) is det. + constraint_info::in, constraint_info::out, io::di, io::uo) is det. propagate_conj_constraints([], RevGoals, Goals, !Info, !IO) :- - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). propagate_conj_constraints([Goal0 - Constraints0 | Goals0], RevGoals0, RevGoals, !Info, !IO) :- filter_complex_constraints(Constraints0, SimpleConstraints, ComplexConstraints0), propagate_conj_sub_goal(Goal0, SimpleConstraints, GoalList1, !Info, !IO), flatten_constraints(ComplexConstraints0, ComplexConstraints), - list__reverse(ComplexConstraints, RevComplexConstraints), - list__reverse(GoalList1, RevGoalList1), - list__condense([RevComplexConstraints, RevGoalList1, RevGoals0], + list.reverse(ComplexConstraints, RevComplexConstraints), + list.reverse(GoalList1, RevGoalList1), + list.condense([RevComplexConstraints, RevGoalList1, RevGoals0], RevGoals1), constraint_info_update_goal(Goal0, !Info), propagate_conj_constraints(Goals0, RevGoals1, RevGoals, !Info, !IO). @@ -697,8 +668,8 @@ filter_complex_constraints(Constraints, SimpleConstraints, ComplexConstraints) :- filter_complex_constraints(Constraints, [], RevSimpleConstraints, [], RevComplexConstraints), - SimpleConstraints = list__reverse(RevSimpleConstraints), - ComplexConstraints = list__reverse(RevComplexConstraints). + SimpleConstraints = list.reverse(RevSimpleConstraints), + ComplexConstraints = list.reverse(RevComplexConstraints). % Don't attempt to push branched goals into other goals. % @@ -718,17 +689,13 @@ filter_complex_constraints([Constraint | Constraints], % with the complex constraints we've already found. % \+ ( - list__member(ComplexConstraint, - !.RevComplexConstraints), - \+ can_reorder_constraints(ComplexConstraint, - Constraint) + list.member(ComplexConstraint, !.RevComplexConstraints), + \+ can_reorder_constraints(ComplexConstraint, Constraint) ) -> - !:RevSimpleConstraints = - [Constraint | !.RevSimpleConstraints] + !:RevSimpleConstraints = [Constraint | !.RevSimpleConstraints] ; - !:RevComplexConstraints = - [Constraint | !.RevComplexConstraints] + !:RevComplexConstraints = [Constraint | !.RevComplexConstraints] ), filter_complex_constraints(Constraints, !RevSimpleConstraints, !RevComplexConstraints). @@ -749,13 +716,13 @@ goal_is_simple(Goal) :- %-----------------------------------------------------------------------------% :- type constraint_info - ---> constraint_info( - module_info :: module_info, - vartypes :: vartypes, - varset :: prog_varset, - instmap :: instmap, - changed :: bool % has anything changed. - ). + ---> constraint_info( + module_info :: module_info, + vartypes :: vartypes, + varset :: prog_varset, + instmap :: instmap, + changed :: bool % has anything changed. + ). constraint_info_init(ModuleInfo, VarTypes, VarSet, InstMap, ConstraintInfo) :- ConstraintInfo = constraint_info(ModuleInfo, VarTypes, VarSet, @@ -763,8 +730,7 @@ constraint_info_init(ModuleInfo, VarTypes, VarSet, InstMap, ConstraintInfo) :- constraint_info_deconstruct(ConstraintInfo, ModuleInfo, VarTypes, VarSet, Changed) :- - ConstraintInfo = constraint_info(ModuleInfo, VarTypes, VarSet, - _, Changed). + ConstraintInfo = constraint_info(ModuleInfo, VarTypes, VarSet, _, Changed). :- pred constraint_info_update_goal(hlds_goal::in, constraint_info::in, constraint_info::out) is det. @@ -772,7 +738,7 @@ constraint_info_deconstruct(ConstraintInfo, ModuleInfo, constraint_info_update_goal(_ - GoalInfo, !Info) :- InstMap0 = !.Info ^ instmap, goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap), !:Info = !.Info ^ instmap := InstMap. :- pred constraint_info_bind_var_to_functor(prog_var::in, cons_id::in, @@ -782,8 +748,8 @@ constraint_info_bind_var_to_functor(Var, ConsId, !Info) :- InstMap0 = !.Info ^ instmap, ModuleInfo0 = !.Info ^ module_info, VarTypes = !.Info ^ vartypes, - map__lookup(VarTypes, Var, Type), - instmap__bind_var_to_functor(Var, Type, ConsId, InstMap0, InstMap, + map.lookup(VarTypes, Var, Type), + instmap.bind_var_to_functor(Var, Type, ConsId, InstMap0, InstMap, ModuleInfo0, ModuleInfo), !:Info = !.Info ^ instmap := InstMap, !:Info = !.Info ^ module_info := ModuleInfo. @@ -796,9 +762,10 @@ constraint_info_bind_var_to_functor(Var, ConsId, !Info) :- constraint_info::in, constraint_info::out) is det. constraint_info_update_changed(Constraints, !Info) :- - ( Constraints = [] -> - true + ( + Constraints = [] ; + Constraints = [_ | _], !:Info = !.Info ^ changed := yes ). @@ -822,13 +789,13 @@ strip_constraint_markers(Goal - GoalInfo0) = strip_constraint_markers_expr(conj(ConjType, Goals)) = conj(ConjType, list.map(strip_constraint_markers, Goals)). strip_constraint_markers_expr(disj(Goals)) = - disj(list__map(strip_constraint_markers, Goals)). + disj(list.map(strip_constraint_markers, Goals)). strip_constraint_markers_expr(switch(Var, CanFail, Cases0)) = switch(Var, CanFail, Cases) :- - Cases = list__map( - (func(case(ConsId, Goal)) = - case(ConsId, strip_constraint_markers(Goal)) - ), Cases0). + Cases = list.map( + (func(case(ConsId, Goal)) = + case(ConsId, strip_constraint_markers(Goal)) + ), Cases0). strip_constraint_markers_expr(not(Goal)) = not(strip_constraint_markers(Goal)). strip_constraint_markers_expr(scope(Reason, Goal)) = diff --git a/compiler/continuation_info.m b/compiler/continuation_info.m index 94321db0e..7f36b98b7 100644 --- a/compiler/continuation_info.m +++ b/compiler/continuation_info.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1997-2000,2002-2005 The University of Melbourne. +% Copyright (C) 1997-2000,2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -49,7 +49,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__continuation_info. +:- module ll_backend.continuation_info. :- interface. :- import_module hlds.hlds_goal. @@ -392,7 +392,7 @@ maybe_process_proc_llds(Instructions, PredProcId, ModuleInfo, !ContInfo) :- basic_stack_layout_for_proc(PredInfo, Globals, Layout, _), ( Layout = yes, - globals__want_return_var_layouts(Globals, WantReturnLayout), + globals.want_return_var_layouts(Globals, WantReturnLayout), process_proc_llds(PredProcId, Instructions, WantReturnLayout, !ContInfo) ; @@ -404,7 +404,7 @@ maybe_process_proc_llds(Instructions, PredProcId, ModuleInfo, !ContInfo) :- label, % The return label. code_addr, % The target of the call. list(liveinfo), % What is live on return. - term__context, % The position of the call in source. + term.context, % The position of the call in source. goal_path % The position of the call in the body; % meaningful only if tracing is enabled. ). @@ -424,10 +424,10 @@ process_proc_llds(PredProcId, Instructions, WantReturnInfo, !GlobalData) :- GoalPath, _) - _Comment, Call = call_info(ReturnLabel, Target, LiveInfo, Context, GoalPath) ), - list__filter_map(GetCallInfo, Instructions, Calls), + list.filter_map(GetCallInfo, Instructions, Calls), % Process the continuation label info. - list__foldl(process_continuation(WantReturnInfo), Calls, + list.foldl(process_continuation(WantReturnInfo), Calls, Internals0, Internals), ProcLayoutInfo = ProcLayoutInfo0^internal_map := Internals, @@ -453,7 +453,7 @@ process_continuation(WantReturnInfo, CallInfo, !Internals) :- ReturnLabel = entry(_, _), unexpected(this_file, "process_continuation: bad return") ), - ( map__search(!.Internals, ReturnLabelNum, Internal0) -> + ( map.search(!.Internals, ReturnLabelNum, Internal0) -> Internal0 = internal_layout_info(Port0, Resume0, Return0) ; Port0 = no, @@ -476,8 +476,8 @@ process_continuation(WantReturnInfo, CallInfo, !Internals) :- Return0 = yes(ReturnInfo0), ReturnInfo0 = return_layout_info(TargetsContexts0, Layout0), Layout0 = layout_label_info(LV0, TV0), - set__intersect(LV0, VarInfoSet, LV), - map__intersect(set__intersect, TV0, TypeInfoMap, TV), + set.intersect(LV0, VarInfoSet, LV), + map.intersect(set.intersect, TV0, TypeInfoMap, TV), Layout = layout_label_info(LV, TV), TargetContexts = [Target - (Context - MaybeGoalPath) | TargetsContexts0], @@ -489,7 +489,7 @@ process_continuation(WantReturnInfo, CallInfo, !Internals) :- Return = Return0 ), Internal = internal_layout_info(Port0, Resume0, Return), - map__set(!.Internals, ReturnLabelNum, Internal, !:Internals). + map.set(!.Internals, ReturnLabelNum, Internal, !:Internals). :- pred convert_return_data(list(liveinfo)::in, set(layout_var_info)::out, map(tvar, set(layout_locn))::out) is det. @@ -499,16 +499,16 @@ convert_return_data(LiveInfos, VarInfoSet, TypeInfoMap) :- LiveLval = live_lvalue(Lval, LiveValueType, _), VarInfo = layout_var_info(Lval, LiveValueType, "convert_return_data") ), - list__map(GetVarInfo, LiveInfos, VarInfoList), + list.map(GetVarInfo, LiveInfos, VarInfoList), GetTypeInfo = (pred(LiveLval::in, LiveTypeInfoMap::out) is det :- LiveLval = live_lvalue(_, _, LiveTypeInfoMap) ), - list__map(GetTypeInfo, LiveInfos, TypeInfoMapList), - map__init(Empty), - list__foldl((pred(TIM1::in, TIM2::in, TIM::out) is det :- - map__union(set__intersect, TIM1, TIM2, TIM) + list.map(GetTypeInfo, LiveInfos, TypeInfoMapList), + map.init(Empty), + list.foldl((pred(TIM1::in, TIM2::in, TIM::out) is det :- + map.union(set.intersect, TIM1, TIM2, TIM) ), TypeInfoMapList, Empty, TypeInfoMap), - set__list_to_set(VarInfoList, VarInfoSet). + set.list_to_set(VarInfoList, VarInfoSet). :- pred filter_named_vars(list(liveinfo)::in, list(liveinfo)::out) is det. @@ -530,13 +530,13 @@ filter_named_vars([LiveInfo | LiveInfos], Filtered) :- basic_stack_layout_for_proc(PredInfo, Globals, BasicLayout, ForceProcIdLayout) :- ( - globals__lookup_bool_option(Globals, stack_trace_higher_order, yes), + globals.lookup_bool_option(Globals, stack_trace_higher_order, yes), some_arg_is_higher_order(PredInfo) -> BasicLayout = yes, ForceProcIdLayout = yes ; - globals__lookup_bool_option(Globals, basic_stack_layout, yes) + globals.lookup_bool_option(Globals, basic_stack_layout, yes) -> BasicLayout = yes, ForceProcIdLayout = no @@ -550,7 +550,7 @@ basic_stack_layout_for_proc(PredInfo, Globals, BasicLayout, some_arg_is_higher_order(PredInfo) :- pred_info_arg_types(PredInfo, ArgTypes), some [Type] ( - list__member(Type, ArgTypes), + list.member(Type, ArgTypes), type_is_higher_order(Type, _, _, _, _) ). @@ -558,14 +558,14 @@ some_arg_is_higher_order(PredInfo) :- generate_return_live_lvalues(OutputArgLocs, ReturnInstMap, Vars, VarLocs, Temps, ProcInfo, ModuleInfo, Globals, OkToDeleteAny, LiveLvalues) :- - globals__want_return_var_layouts(Globals, WantReturnVarLayout), + globals.want_return_var_layouts(Globals, WantReturnVarLayout), proc_info_stack_slots(ProcInfo, StackSlots), find_return_var_lvals(Vars, StackSlots, OkToDeleteAny, OutputArgLocs, VarLvals), generate_var_live_lvalues(VarLvals, ReturnInstMap, VarLocs, ProcInfo, ModuleInfo, WantReturnVarLayout, VarLiveLvalues), generate_temp_live_lvalues(Temps, TempLiveLvalues), - list__append(VarLiveLvalues, TempLiveLvalues, LiveLvalues). + list.append(VarLiveLvalues, TempLiveLvalues, LiveLvalues). :- pred find_return_var_lvals(list(prog_var)::in, stack_slots::in, bool::in, assoc_list(prog_var, arg_loc)::in, @@ -576,11 +576,11 @@ find_return_var_lvals([Var | Vars], StackSlots, OkToDeleteAny, OutputArgLocs, VarLvals) :- find_return_var_lvals(Vars, StackSlots, OkToDeleteAny, OutputArgLocs, TailVarLvals), - ( assoc_list__search(OutputArgLocs, Var, ArgLoc) -> + ( assoc_list.search(OutputArgLocs, Var, ArgLoc) -> % On return, output arguments are in their registers. - code_util__arg_loc_to_register(ArgLoc, Lval), + code_util.arg_loc_to_register(ArgLoc, Lval), VarLvals = [Var - Lval | TailVarLvals] - ; map__search(StackSlots, Var, Slot) -> + ; map.search(StackSlots, Var, Slot) -> % On return, other live variables are in their stack slots. VarLvals = [Var - stack_slot_to_lval(Slot) | TailVarLvals] ; OkToDeleteAny = yes -> @@ -596,7 +596,7 @@ generate_temp_live_lvalues([], []). generate_temp_live_lvalues([Temp | Temps], [Live | Lives]) :- Temp = Slot - Contents, live_value_type(Contents, LiveLvalueType), - map__init(Empty), + map.init(Empty), Live = live_lvalue(direct(Slot), LiveLvalueType, Empty), generate_temp_live_lvalues(Temps, Lives). @@ -615,7 +615,7 @@ generate_var_live_lvalues([Var - Lval | VarLvals], InstMap, VarLocs, ProcInfo, Live = live_lvalue(direct(Lval), LiveValueType, TypeParams) ; WantReturnVarLayout = no, - map__init(Empty), + map.init(Empty), Live = live_lvalue(direct(Lval), unwanted, Empty) ), generate_var_live_lvalues(VarLvals, InstMap, VarLocs, ProcInfo, @@ -625,17 +625,17 @@ generate_var_live_lvalues([Var - Lval | VarLvals], InstMap, VarLocs, ProcInfo, generate_resume_layout(ResumeMap, Temps, InstMap, ProcInfo, ModuleInfo, Layout) :- - map__to_assoc_list(ResumeMap, ResumeList), - set__init(TVars0), + map.to_assoc_list(ResumeMap, ResumeList), + set.init(TVars0), proc_info_vartypes(ProcInfo, VarTypes), generate_resume_layout_for_vars(ResumeList, InstMap, VarTypes, ProcInfo, ModuleInfo, [], VarInfos, TVars0, TVars), - set__list_to_set(VarInfos, VarInfoSet), - set__to_sorted_list(TVars, TVarList), + set.list_to_set(VarInfos, VarInfoSet), + set.to_sorted_list(TVars, TVarList), find_typeinfos_for_tvars(TVarList, ResumeMap, ProcInfo, TVarInfoMap), generate_temp_var_infos(Temps, TempInfos), - set__list_to_set(TempInfos, TempInfoSet), - set__union(VarInfoSet, TempInfoSet, AllInfoSet), + set.list_to_set(TempInfos, TempInfoSet), + set.union(VarInfoSet, TempInfoSet, AllInfoSet), Layout = layout_label_info(AllInfoSet, TVarInfoMap). :- pred generate_resume_layout_for_vars(assoc_list(prog_var, set(lval))::in, @@ -647,14 +647,14 @@ generate_resume_layout_for_vars([], _, _, _, _, !VarInfos, !TVars). generate_resume_layout_for_vars([Var - LvalSet | VarLvals], InstMap, VarTypes, ProcInfo, ModuleInfo, !VarInfos, !TVars) :- ( - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), is_dummy_argument_type(ModuleInfo, Type) -> true ; generate_resume_layout_for_var(Var, LvalSet, InstMap, ProcInfo, ModuleInfo, VarInfo, TypeVars), - set__insert_list(!.TVars, TypeVars, !:TVars), + set.insert_list(!.TVars, TypeVars, !:TVars), !:VarInfos = [VarInfo | !.VarInfos] ), generate_resume_layout_for_vars(VarLvals, InstMap, VarTypes, ProcInfo, @@ -666,7 +666,7 @@ generate_resume_layout_for_vars([Var - LvalSet | VarLvals], InstMap, generate_resume_layout_for_var(Var, LvalSet, InstMap, ProcInfo, ModuleInfo, VarInfo, TypeVars) :- - set__to_sorted_list(LvalSet, LvalList), + set.to_sorted_list(LvalSet, LvalList), ( LvalList = [LvalPrime] -> Lval = LvalPrime ; @@ -706,20 +706,20 @@ generate_layout_for_var(Var, InstMap, ProcInfo, ModuleInfo, LiveValueType, TypeVars) :- proc_info_varset(ProcInfo, VarSet), proc_info_vartypes(ProcInfo, VarTypes), - ( varset__search_name(VarSet, Var, GivenName) -> + ( varset.search_name(VarSet, Var, GivenName) -> Name = GivenName ; Name = "" ), - instmap__lookup_var(InstMap, Var, Inst), - map__lookup(VarTypes, Var, Type), - ( inst_match__inst_is_ground(ModuleInfo, Inst) -> + instmap.lookup_var(InstMap, Var, Inst), + map.lookup(VarTypes, Var, Type), + ( inst_match.inst_is_ground(ModuleInfo, Inst) -> LldsInst = ground ; LldsInst = partial(Inst) ), LiveValueType = var(Var, Name, Type, LldsInst), - prog_type__vars(Type, TypeVars). + prog_type.vars(Type, TypeVars). %---------------------------------------------------------------------------% @@ -729,13 +729,13 @@ generate_closure_layout(ModuleInfo, PredId, ProcId, ClosureLayout) :- proc_info_arg_info(ProcInfo, ArgInfos), pred_info_arg_types(PredInfo, ArgTypes), proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap), - map__init(VarLocs0), - set__init(TypeVars0), + map.init(VarLocs0), + set.init(TypeVars0), ( build_closure_info(HeadVars, ArgTypes, ArgInfos, ArgLayouts, InstMap, VarLocs0, VarLocs, TypeVars0, TypeVars) -> - set__to_sorted_list(TypeVars, TypeVarsList), + set.to_sorted_list(TypeVars, TypeVarsList), find_typeinfos_for_tvars(TypeVarsList, VarLocs, ProcInfo, TypeInfoDataMap), ClosureLayout = closure_layout_info(ArgLayouts, TypeInfoDataMap) @@ -754,12 +754,12 @@ build_closure_info([Var | Vars], [Type | Types], [ArgInfo | ArgInfos], [Layout | Layouts], InstMap, !VarLocs, !TypeVars) :- ArgInfo = arg_info(ArgLoc, _ArgMode), - instmap__lookup_var(InstMap, Var, Inst), + instmap.lookup_var(InstMap, Var, Inst), Layout = closure_arg_info(Type, Inst), - set__singleton_set(Locations, reg(r, ArgLoc)), - svmap__det_insert(Var, Locations, !VarLocs), - prog_type__vars(Type, VarTypeVars), - svset__insert_list(VarTypeVars, !TypeVars), + set.singleton_set(Locations, reg(r, ArgLoc)), + svmap.det_insert(Var, Locations, !VarLocs), + prog_type.vars(Type, VarTypeVars), + svset.insert_list(VarTypeVars, !TypeVars), build_closure_info(Vars, Types, ArgInfos, Layouts, InstMap, !VarLocs, !TypeVars). @@ -768,13 +768,13 @@ build_closure_info([Var | Vars], [Type | Types], find_typeinfos_for_tvars(TypeVars, VarLocs, ProcInfo, TypeInfoDataMap) :- proc_info_varset(ProcInfo, VarSet), proc_info_rtti_varmaps(ProcInfo, RttiVarMaps), - list__map(rtti_lookup_type_info_locn(RttiVarMaps), TypeVars, + list.map(rtti_lookup_type_info_locn(RttiVarMaps), TypeVars, TypeInfoLocns), FindLocn = (pred(TypeInfoLocn::in, Locns::out) is det :- type_info_locn_var(TypeInfoLocn, TypeInfoVar), - ( map__search(VarLocs, TypeInfoVar, TypeInfoLvalSet) -> + ( map.search(VarLocs, TypeInfoVar, TypeInfoLvalSet) -> ConvertLval = (pred(Locn::out) is nondet :- - set__member(Lval, TypeInfoLvalSet), + set.member(Lval, TypeInfoLvalSet), ( TypeInfoLocn = typeclass_info(_, FieldNum), Locn = indirect(Lval, FieldNum) @@ -785,25 +785,25 @@ find_typeinfos_for_tvars(TypeVars, VarLocs, ProcInfo, TypeInfoDataMap) :- ), solutions_set(ConvertLval, Locns) ; - varset__lookup_name(VarSet, TypeInfoVar, VarString), - string__format("%s: %s %s", + varset.lookup_name(VarSet, TypeInfoVar, VarString), + string.format("%s: %s %s", [s("find_typeinfos_for_tvars"), s("can't find rval for type_info var"), s(VarString)], ErrStr), unexpected(this_file, ErrStr) ) ), - list__map(FindLocn, TypeInfoLocns, TypeInfoVarLocns), - map__from_corresponding_lists(TypeVars, TypeInfoVarLocns, TypeInfoDataMap). + list.map(FindLocn, TypeInfoLocns, TypeInfoVarLocns), + map.from_corresponding_lists(TypeVars, TypeInfoVarLocns, TypeInfoDataMap). %---------------------------------------------------------------------------% generate_table_arg_type_info(ProcInfo, NumberedVars, TableArgInfos) :- proc_info_vartypes(ProcInfo, VarTypes), - set__init(TypeVars0), + set.init(TypeVars0), build_table_arg_info(VarTypes, NumberedVars, ArgLayouts, TypeVars0, TypeVars), - set__to_sorted_list(TypeVars, TypeVarsList), + set.to_sorted_list(TypeVars, TypeVarsList), find_typeinfos_for_tvars_table(TypeVarsList, NumberedVars, ProcInfo, TypeInfoDataMap), TableArgInfos = table_arg_infos(ArgLayouts, TypeInfoDataMap). @@ -815,10 +815,10 @@ generate_table_arg_type_info(ProcInfo, NumberedVars, TableArgInfos) :- build_table_arg_info(_, [], [], !TypeVars). build_table_arg_info(VarTypes, [Var - SlotNum | NumberedVars], [ArgLayout | ArgLayouts], !TypeVars) :- - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ArgLayout = table_arg_info(Var, SlotNum, Type), - prog_type__vars(Type, VarTypeVars), - svset__insert_list(VarTypeVars, !TypeVars), + prog_type.vars(Type, VarTypeVars), + svset.insert_list(VarTypeVars, !TypeVars), build_table_arg_info(VarTypes, NumberedVars, ArgLayouts, !TypeVars). %---------------------------------------------------------------------------% @@ -831,32 +831,32 @@ find_typeinfos_for_tvars_table(TypeVars, NumberedVars, ProcInfo, TypeInfoDataMap) :- proc_info_varset(ProcInfo, VarSet), proc_info_rtti_varmaps(ProcInfo, RttiVarMaps), - list__map(rtti_lookup_type_info_locn(RttiVarMaps), TypeVars, + list.map(rtti_lookup_type_info_locn(RttiVarMaps), TypeVars, TypeInfoLocns), FindLocn = (pred(TypeInfoLocn::in, Locn::out) is det :- ( ( TypeInfoLocn = typeclass_info(TypeInfoVar, FieldNum), - assoc_list__search(NumberedVars, TypeInfoVar, Slot), + assoc_list.search(NumberedVars, TypeInfoVar, Slot), LocnPrime = indirect(Slot, FieldNum) ; TypeInfoLocn = type_info(TypeInfoVar), - assoc_list__search(NumberedVars, TypeInfoVar, Slot), + assoc_list.search(NumberedVars, TypeInfoVar, Slot), LocnPrime = direct(Slot) ) -> Locn = LocnPrime ; type_info_locn_var(TypeInfoLocn, TypeInfoVar), - varset__lookup_name(VarSet, TypeInfoVar, VarString), - string__format("%s: %s %s", + varset.lookup_name(VarSet, TypeInfoVar, VarString), + string.format("%s: %s %s", [s("find_typeinfos_for_tvars_table"), s("can't find slot for type_info var"), s(VarString)], ErrStr), unexpected(this_file, ErrStr) ) ), - list__map(FindLocn, TypeInfoLocns, TypeInfoVarLocns), - map__from_corresponding_lists(TypeVars, TypeInfoVarLocns, TypeInfoDataMap). + list.map(FindLocn, TypeInfoLocns, TypeInfoVarLocns), + map.from_corresponding_lists(TypeVars, TypeInfoVarLocns, TypeInfoDataMap). %-----------------------------------------------------------------------------% diff --git a/compiler/cse_detection.m b/compiler/cse_detection.m index 6f2b80f00..cdc49ba12 100644 --- a/compiler/cse_detection.m +++ b/compiler/cse_detection.m @@ -17,7 +17,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__cse_detection. +:- module check_hlds.cse_detection. :- interface. :- import_module hlds.hlds_module. @@ -83,7 +83,7 @@ detect_cse(!ModuleInfo, !IO) :- detect_cse_in_preds([], !ModuleInfo, !IO). detect_cse_in_preds([PredId | PredIds], !ModuleInfo, !IO) :- module_info_preds(!.ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), detect_cse_in_pred(PredId, PredInfo, !ModuleInfo, !IO), detect_cse_in_preds(PredIds, !ModuleInfo, !IO). @@ -104,18 +104,18 @@ detect_cse_in_procs([ProcId | ProcIds], PredId, !ModuleInfo, !IO) :- detect_cse_in_proc(ProcId, PredId, !ModuleInfo, !IO) :- detect_cse_in_proc_2(ProcId, PredId, Redo, !ModuleInfo), - globals__io_lookup_bool_option(detailed_statistics, Statistics, !IO), + globals.io_lookup_bool_option(detailed_statistics, Statistics, !IO), maybe_report_stats(Statistics, !IO), ( Redo = no ; Redo = yes, - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string("% Repeating mode check for ", !IO), - hlds_out__write_pred_id(!.ModuleInfo, PredId, !IO), - io__write_string("\n", !IO) + io.write_string("% Repeating mode check for ", !IO), + hlds_out.write_pred_id(!.ModuleInfo, PredId, !IO), + io.write_string("\n", !IO) ; VeryVerbose = no ), @@ -128,9 +128,9 @@ detect_cse_in_proc(ProcId, PredId, !ModuleInfo, !IO) :- ), ( VeryVerbose = yes, - io__write_string("% Repeating switch detection for ", !IO), - hlds_out__write_pred_id(!.ModuleInfo, PredId, !IO), - io__write_string("\n", !IO) + io.write_string("% Repeating switch detection for ", !IO), + hlds_out.write_pred_id(!.ModuleInfo, PredId, !IO), + io.write_string("\n", !IO) ; VeryVerbose = no ), @@ -138,10 +138,10 @@ detect_cse_in_proc(ProcId, PredId, !ModuleInfo, !IO) :- maybe_report_stats(Statistics, !IO), ( VeryVerbose = yes, - io__write_string("% Repeating common " ++ + io.write_string("% Repeating common " ++ "deconstruction detection for ", !IO), - hlds_out__write_pred_id(!.ModuleInfo, PredId, !IO), - io__write_string("\n", !IO) + hlds_out.write_pred_id(!.ModuleInfo, PredId, !IO), + io.write_string("\n", !IO) ; VeryVerbose = no ), @@ -161,9 +161,9 @@ detect_cse_in_proc(ProcId, PredId, !ModuleInfo, !IO) :- detect_cse_in_proc_2(ProcId, PredId, Redo, ModuleInfo0, ModuleInfo) :- module_info_preds(ModuleInfo0, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), % To process each ProcInfo, we get the goal, initialize the instmap % based on the modes of the head vars, and pass these to @@ -195,9 +195,9 @@ detect_cse_in_proc_2(ProcId, PredId, Redo, ModuleInfo0, ModuleInfo) :- proc_info_set_vartypes(VarTypes, ProcInfo2, ProcInfo3), proc_info_set_rtti_varmaps(RttiVarMaps, ProcInfo3, ProcInfo), - map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable), + map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, ModuleInfo0, ModuleInfo) ). @@ -226,7 +226,7 @@ detect_cse_in_goal_1(Goal0 - GoalInfo, InstMap0, !CseInfo, Redo, Goal - GoalInfo, InstMap) :- detect_cse_in_goal_2(Goal0, GoalInfo, InstMap0, !CseInfo, Redo, Goal), goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap). + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap). % Here we process each of the different sorts of goals. % @@ -246,7 +246,7 @@ detect_cse_in_goal_2(unify(LHS, RHS0, Mode, Unify, UnifyContext), _, InstMap0, Vars, Modes, Det, Goal0) -> ModuleInfo = !.CseInfo ^ module_info, - instmap__pre_lambda_update(ModuleInfo, Vars, Modes, InstMap0, InstMap), + instmap.pre_lambda_update(ModuleInfo, Vars, Modes, InstMap0, InstMap), detect_cse_in_goal(Goal0, InstMap, !CseInfo, Redo, Goal), RHS = lambda_goal(Purity, PredOrFunc, EvalMethod, NonLocalVars, Vars, Modes, Det, Goal) @@ -269,20 +269,20 @@ detect_cse_in_goal_2(disj(Goals0), GoalInfo, InstMap, !CseInfo, Redo, Goal) :- Goal = disj([]) ; goal_info_get_nonlocals(GoalInfo, NonLocals), - set__to_sorted_list(NonLocals, NonLocalsList), + set.to_sorted_list(NonLocals, NonLocalsList), detect_cse_in_disj(NonLocalsList, Goals0, GoalInfo, InstMap, !CseInfo, Redo, Goal) ). detect_cse_in_goal_2(switch(Var, CanFail, Cases0), GoalInfo, InstMap, !CseInfo, Redo, Goal) :- goal_info_get_nonlocals(GoalInfo, NonLocals), - set__to_sorted_list(NonLocals, NonLocalsList), + set.to_sorted_list(NonLocals, NonLocalsList), detect_cse_in_cases(NonLocalsList, Var, CanFail, Cases0, GoalInfo, InstMap, !CseInfo, Redo, Goal). detect_cse_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0), GoalInfo, InstMap, !CseInfo, Redo, Goal) :- goal_info_get_nonlocals(GoalInfo, NonLocals), - set__to_sorted_list(NonLocals, NonLocalsList), + set.to_sorted_list(NonLocals, NonLocalsList), detect_cse_in_ite(NonLocalsList, Vars, Cond0, Then0, Else0, GoalInfo, InstMap, !CseInfo, Redo, Goal). @@ -326,7 +326,7 @@ detect_cse_in_disj([], Goals0, _, InstMap, !CseInfo, Redo, disj(Goals)) :- detect_cse_in_disj([Var | Vars], Goals0, GoalInfo0, InstMap, !CseInfo, Redo, Goal) :- ( - instmap__lookup_var(InstMap, Var, VarInst0), + instmap.lookup_var(InstMap, Var, VarInst0), ModuleInfo = !.CseInfo ^ module_info, % XXX we only need inst_is_bound, but leave this as it is % until mode analysis can handle aliasing between free @@ -352,7 +352,7 @@ detect_cse_in_disj_2([Goal0 | Goals0], InstMap0, !CseInfo, Redo, [Goal | Goals]) :- detect_cse_in_goal(Goal0, InstMap0, !CseInfo, Redo1, Goal), detect_cse_in_disj_2(Goals0, InstMap0, !CseInfo, Redo2, Goals), - bool__or(Redo1, Redo2, Redo). + bool.or(Redo1, Redo2, Redo). :- pred detect_cse_in_cases(list(prog_var)::in, prog_var::in, can_fail::in, list(case)::in, hlds_goal_info::in, instmap::in, @@ -365,7 +365,7 @@ detect_cse_in_cases([Var | Vars], SwitchVar, CanFail, Cases0, GoalInfo, InstMap, !CseInfo, Redo, Goal) :- ( Var \= SwitchVar, - instmap__lookup_var(InstMap, Var, VarInst0), + instmap.lookup_var(InstMap, Var, VarInst0), ModuleInfo = !.CseInfo ^ module_info, % XXX We only need inst_is_bound, but leave this as it is until % mode analysis can handle aliasing between free variables. @@ -393,7 +393,7 @@ detect_cse_in_cases_2([Case0 | Cases0], InstMap, !CseInfo, Redo, detect_cse_in_goal(Goal0, InstMap, !CseInfo, Redo1, Goal), Case = case(Functor, Goal), detect_cse_in_cases_2(Cases0, InstMap, !CseInfo, Redo2, Cases), - bool__or(Redo1, Redo2, Redo). + bool.or(Redo1, Redo2, Redo). :- pred detect_cse_in_ite(list(prog_var)::in, list(prog_var)::in, hlds_goal::in, hlds_goal::in, hlds_goal::in, hlds_goal_info::in, @@ -408,7 +408,7 @@ detect_cse_in_ite([Var | Vars], IfVars, Cond0, Then0, Else0, GoalInfo, InstMap, !CseInfo, Redo, Goal) :- ( ModuleInfo = !.CseInfo ^ module_info, - instmap__lookup_var(InstMap, Var, VarInst0), + instmap.lookup_var(InstMap, Var, VarInst0), % XXX We only need inst_is_bound, but leave this as it is until % mode analysis can handle aliasing between free variables. inst_is_ground_or_any(ModuleInfo, VarInst0), @@ -435,8 +435,8 @@ detect_cse_in_ite_2(Cond0, Then0, Else0, InstMap0, !CseInfo, Redo, detect_cse_in_goal_1(Cond0, InstMap0, !CseInfo, Redo1, Cond, InstMap1), detect_cse_in_goal(Then0, InstMap1, !CseInfo, Redo2, Then), detect_cse_in_goal(Else0, InstMap0, !CseInfo, Redo3, Else), - bool__or(Redo1, Redo2, Redo12), - bool__or(Redo12, Redo3, Redo). + bool.or(Redo1, Redo2, Redo12), + bool.or(Redo12, Redo3, Redo). %-----------------------------------------------------------------------------% @@ -582,8 +582,8 @@ construct_common_unify(Var, GoalExpr0 - GoalInfo, !CseInfo, OldNewVars, goal_info_get_context(GoalInfo, Context), create_parallel_subterms(Args, Context, Ucontext, !CseInfo, OldNewVars, Replacements), - map__from_assoc_list(OldNewVars, Sub), - goal_util__rename_vars_in_goal(Sub, + map.from_assoc_list(OldNewVars, Sub), + goal_util.rename_vars_in_goal(Sub, GoalExpr1 - GoalInfo, HoistedGoal) ; unexpected(this_file, "non-unify goal in construct_common_unify") @@ -611,9 +611,9 @@ create_parallel_subterm(OFV, Context, UnifyContext, !CseInfo, !OldNewVar, Goal) :- VarSet0 = !.CseInfo ^ varset, VarTypes0 = !.CseInfo ^ vartypes, - varset__new_var(VarSet0, NFV, VarSet), - map__lookup(VarTypes0, OFV, Type), - map__det_insert(VarTypes0, NFV, Type, VarTypes), + varset.new_var(VarSet0, NFV, VarSet), + map.lookup(VarTypes0, OFV, Type), + map.det_insert(VarTypes0, NFV, Type, VarTypes), !:OldNewVar = [OFV - NFV | !.OldNewVar], UnifyContext = unify_context(MainCtxt, SubCtxt), % It is ok to create complicated unifications here, because we rerun @@ -641,10 +641,10 @@ find_similar_deconstruct(HoistedUnifyGoal, OldUnifyGoal, Context, OldUnifyInfo = deconstruct(_, OldFunctor, OldVars, _, _, _) -> HoistedFunctor = OldFunctor, - list__length(HoistedVars, HoistedVarsCount), - list__length(OldVars, OldVarsCount), + list.length(HoistedVars, HoistedVarsCount), + list.length(OldVars, OldVarsCount), HoistedVarsCount = OldVarsCount, - assoc_list__from_corresponding_lists(OldVars, HoistedVars, + assoc_list.from_corresponding_lists(OldVars, HoistedVars, OldHoistedVars), pair_subterms(OldHoistedVars, Context, OC, Replacements) ; @@ -690,16 +690,16 @@ pair_subterms([OldVar - HoistedVar | OldHoistedVars], Context, UnifyContext, % As an example, consider a disjunction such as % % ( -% HeadVar__2_2 = x:u(TypeClassInfo_for_v_8, V_4), +% HeadVar.g2_2 = x:u(TypeClassInfo_for_v_8, V_4), % ... % ; -% HeadVar__2_2 = x:u(TypeClassInfo_for_v_14, V_6) +% HeadVar.g2_2 = x:u(TypeClassInfo_for_v_14, V_6) % ... % ) % % The main part of cse_detection will replace this with % -% HeadVar__2_2 = x:u(V_17, V_16) +% HeadVar.g2_2 = x:u(V_17, V_16) % ( % TypeClassInfo_for_v_8 = V_17, % V_4 = V_16, @@ -747,8 +747,8 @@ maybe_update_existential_data_structures(Unify, FirstOldNew, LaterOldNew, UnifyInfo = deconstruct(Var, ConsId, _, _, _, _), ModuleInfo = !.CseInfo ^ module_info, VarTypes = !.CseInfo ^ vartypes, - map__lookup(VarTypes, Var, Type), - type_util__is_existq_cons(ModuleInfo, Type, ConsId) + map.lookup(VarTypes, Var, Type), + type_util.is_existq_cons(ModuleInfo, Type, ConsId) -> update_existential_data_structures(FirstOldNew, LaterOldNew, !CseInfo) ; @@ -760,9 +760,9 @@ maybe_update_existential_data_structures(Unify, FirstOldNew, LaterOldNew, cse_info::in, cse_info::out) is det. update_existential_data_structures(FirstOldNew, LaterOldNews, !CseInfo) :- - list__condense(LaterOldNews, LaterOldNew), - map__from_assoc_list(FirstOldNew, FirstOldNewMap), - map__from_assoc_list(LaterOldNew, LaterOldNewMap), + list.condense(LaterOldNews, LaterOldNew), + map.from_assoc_list(FirstOldNew, FirstOldNewMap), + map.from_assoc_list(LaterOldNew, LaterOldNewMap), RttiVarMaps0 = !.CseInfo ^ rtti_varmaps, VarTypes0 = !.CseInfo ^ vartypes, @@ -773,25 +773,25 @@ update_existential_data_structures(FirstOldNew, LaterOldNews, !CseInfo) :- % that have had their locations moved. % rtti_varmaps_tvars(RttiVarMaps0, TvarsList), - list__foldl(find_type_info_locn_tvar_map(RttiVarMaps0, FirstOldNewMap), - TvarsList, map__init, NewTvarMap), + list.foldl(find_type_info_locn_tvar_map(RttiVarMaps0, FirstOldNewMap), + TvarsList, map.init, NewTvarMap), % Traverse TVarsList again, this time looking for locations in later % branches that merge with locations in the first branch. When we find one, % add a type substitution which represents the type variables that were % merged. % - list__foldl(find_merged_tvars(RttiVarMaps0, LaterOldNewMap, NewTvarMap), - TvarsList, map__init, Renaming), + list.foldl(find_merged_tvars(RttiVarMaps0, LaterOldNewMap, NewTvarMap), + TvarsList, map.init, Renaming), % Apply the full old->new map and the type substitution to the % rtti_varmaps, and apply the type substitution to the vartypes. % - list__append(FirstOldNew, LaterOldNew, OldNew), - map__from_assoc_list(OldNew, OldNewMap), - apply_substitutions_to_rtti_varmaps(Renaming, map__init, OldNewMap, + list.append(FirstOldNew, LaterOldNew, OldNew), + map.from_assoc_list(OldNew, OldNewMap), + apply_substitutions_to_rtti_varmaps(Renaming, map.init, OldNewMap, RttiVarMaps0, RttiVarMaps), - map__map_values(apply_tvar_rename(Renaming), VarTypes0, VarTypes), + map.map_values(apply_tvar_rename(Renaming), VarTypes0, VarTypes), !:CseInfo = !.CseInfo ^ rtti_varmaps := RttiVarMaps, !:CseInfo = !.CseInfo ^ vartypes := VarTypes. @@ -809,9 +809,9 @@ apply_tvar_rename(Renaming, _Var, Type0, Type) :- find_type_info_locn_tvar_map(RttiVarMaps, FirstOldNewMap, Tvar, !NewTvarMap) :- rtti_lookup_type_info_locn(RttiVarMaps, Tvar, TypeInfoLocn0), type_info_locn_var(TypeInfoLocn0, Old), - ( map__search(FirstOldNewMap, Old, New) -> + ( map.search(FirstOldNewMap, Old, New) -> type_info_locn_set_var(New, TypeInfoLocn0, TypeInfoLocn), - svmap__det_insert(TypeInfoLocn, Tvar, !NewTvarMap) + svmap.det_insert(TypeInfoLocn, Tvar, !NewTvarMap) ; true ). @@ -823,13 +823,13 @@ find_type_info_locn_tvar_map(RttiVarMaps, FirstOldNewMap, Tvar, !NewTvarMap) :- find_merged_tvars(RttiVarMaps, LaterOldNewMap, NewTvarMap, Tvar, !Renaming) :- rtti_lookup_type_info_locn(RttiVarMaps, Tvar, TypeInfoLocn0), type_info_locn_var(TypeInfoLocn0, Old), - ( map__search(LaterOldNewMap, Old, New) -> + ( map.search(LaterOldNewMap, Old, New) -> type_info_locn_set_var(New, TypeInfoLocn0, TypeInfoLocn), - map__lookup(NewTvarMap, TypeInfoLocn, NewTvar), + map.lookup(NewTvarMap, TypeInfoLocn, NewTvar), ( NewTvar = Tvar -> true ; - svmap__det_insert(Tvar, NewTvar, !Renaming) + svmap.det_insert(Tvar, NewTvar, !Renaming) ) ; true diff --git a/compiler/dead_proc_elim.m b/compiler/dead_proc_elim.m index 2fe0d3290..c40c7acac 100644 --- a/compiler/dead_proc_elim.m +++ b/compiler/dead_proc_elim.m @@ -19,7 +19,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__dead_proc_elim. +:- module transform_hlds.dead_proc_elim. :- interface. :- import_module hlds.hlds_module. @@ -124,7 +124,7 @@ dead_proc_elim(Pass, !ModuleInfo, !IO) :- %-----------------------------------------------------------------------------% analyze(ModuleInfo0, !:Needed) :- - set__init(Examined0), + set.init(Examined0), initialize(ModuleInfo0, Queue0, !:Needed), examine(Queue0, Examined0, ModuleInfo0, !Needed). @@ -136,8 +136,8 @@ analyze(ModuleInfo0, !:Needed) :- entity_queue::out, needed_map::out) is det. initialize(ModuleInfo, !:Queue, !:Needed) :- - !:Queue = queue__init, - !:Needed = map__init, + !:Queue = queue.init, + !:Needed = map.init, module_info_predids(ModuleInfo, PredIds), module_info_preds(ModuleInfo, PredTable), initialize_preds(PredIds, PredTable, !Queue, !Needed), @@ -159,7 +159,7 @@ initialize(ModuleInfo, !:Queue, !:Needed) :- initialize_preds([], _PredTable, !Queue, !Needed). initialize_preds([PredId | PredIds], PredTable, !Queue, !Needed) :- - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), ProcIds = pred_info_exported_procids(PredInfo), initialize_procs(PredId, ProcIds, !Queue, !Needed), initialize_preds(PredIds, PredTable, !Queue, !Needed). @@ -173,8 +173,8 @@ initialize_preds([PredId | PredIds], PredTable, initialize_procs(_PredId, [], !Queue, !Needed). initialize_procs(PredId, [ProcId | ProcIds], !Queue, !Needed) :- - svqueue__put(proc(PredId, ProcId), !Queue), - svmap__set(proc(PredId, ProcId), no, !Needed), + svqueue.put(proc(PredId, ProcId), !Queue), + svmap.set(proc(PredId, ProcId), no, !Needed), initialize_procs(PredId, ProcIds, !Queue, !Needed). % Add procedures exported to C by a pragma(export, ...) declaration @@ -187,8 +187,8 @@ initialize_procs(PredId, [ProcId | ProcIds], initialize_pragma_exports([], !Queue, !Needed). initialize_pragma_exports([PragmaProc | PragmaProcs], !Queue, !Needed) :- PragmaProc = pragma_exported_proc(PredId, ProcId, _CFunction, _Ctxt), - svqueue__put(proc(PredId, ProcId), !Queue), - svmap__set(proc(PredId, ProcId), no, !Needed), + svqueue.put(proc(PredId, ProcId), !Queue), + svmap.set(proc(PredId, ProcId), no, !Needed), initialize_pragma_exports(PragmaProcs, !Queue, !Needed). :- pred initialize_base_gen_infos(list(type_ctor_gen_info)::in, @@ -218,8 +218,8 @@ initialize_base_gen_infos([TypeCtorGenInfo | TypeCtorGenInfos], semidet_succeed -> Entity = base_gen_info(ModuleName, TypeName, Arity), - svqueue__put(Entity, !Queue), - svmap__set(Entity, no, !Needed) + svqueue.put(Entity, !Queue), + svmap.set(Entity, no, !Needed) ; true ), @@ -231,11 +231,11 @@ initialize_base_gen_infos([TypeCtorGenInfo | TypeCtorGenInfos], initialize_class_methods(Classes, Instances, !Queue, !Needed) :- - map__values(Instances, InstanceDefnsLists), - list__condense(InstanceDefnsLists, InstanceDefns), - list__foldl2(get_instance_pred_procs, InstanceDefns, !Queue, !Needed), - map__values(Classes, ClassDefns), - list__foldl2(get_class_pred_procs, ClassDefns, !Queue, !Needed). + map.values(Instances, InstanceDefnsLists), + list.condense(InstanceDefnsLists, InstanceDefns), + list.foldl2(get_instance_pred_procs, InstanceDefns, !Queue, !Needed), + map.values(Classes, ClassDefns), + list.foldl2(get_class_pred_procs, ClassDefns, !Queue, !Needed). :- pred get_instance_pred_procs(hlds_instance_defn::in, entity_queue::in, entity_queue::out, needed_map::in, needed_map::out) @@ -250,7 +250,7 @@ get_instance_pred_procs(Instance, !Queue, !Needed) :- PredProcIds = no ; PredProcIds = yes(Ids), - list__foldl2(get_class_interface_pred_proc, Ids, !Queue, !Needed) + list.foldl2(get_class_interface_pred_proc, Ids, !Queue, !Needed) ). :- pred get_class_pred_procs(hlds_class_defn::in, @@ -259,7 +259,7 @@ get_instance_pred_procs(Instance, !Queue, !Needed) :- get_class_pred_procs(Class, !Queue, !Needed) :- Methods = Class ^ class_hlds_interface, - list__foldl2(get_class_interface_pred_proc, Methods, !Queue, !Needed). + list.foldl2(get_class_interface_pred_proc, Methods, !Queue, !Needed). :- pred get_class_interface_pred_proc(hlds_class_proc::in, entity_queue::in, entity_queue::out, needed_map::in, needed_map::out) @@ -267,8 +267,8 @@ get_class_pred_procs(Class, !Queue, !Needed) :- get_class_interface_pred_proc(ClassProc, !Queue, !Needed) :- ClassProc = hlds_class_proc(PredId, ProcId), - svqueue__put(proc(PredId, ProcId), !Queue), - svmap__set(proc(PredId, ProcId), no, !Needed). + svqueue.put(proc(PredId, ProcId), !Queue), + svmap.set(proc(PredId, ProcId), no, !Needed). %-----------------------------------------------------------------------------% @@ -277,12 +277,12 @@ get_class_interface_pred_proc(ClassProc, !Queue, !Needed) :- examine(!.Queue, !.Examined, ModuleInfo, !Needed) :- % see if the queue is empty - ( svqueue__get(Entity, !Queue) -> + ( svqueue.get(Entity, !Queue) -> % see if the next element has been examined before - ( set__member(Entity, !.Examined) -> + ( set.member(Entity, !.Examined) -> examine(!.Queue, !.Examined, ModuleInfo, !Needed) ; - svset__insert(Entity, !Examined), + svset.insert(Entity, !Examined), ( Entity = proc(PredId, ProcId), PredProcId = proc(PredId, ProcId), @@ -346,8 +346,8 @@ examine_refs([], !Queue, !Needed). examine_refs([Ref | Refs], !Queue, !Needed) :- Ref = proc(PredId, ProcId), Entity = proc(PredId, ProcId), - svqueue__put(Entity, !Queue), - svmap__set(Entity, no, !Needed), + svqueue.put(Entity, !Queue), + svmap.set(Entity, no, !Needed), examine_refs(Refs, !Queue, !Needed). %-----------------------------------------------------------------------------% @@ -360,11 +360,11 @@ examine_proc(proc(PredId, ProcId), ModuleInfo, !Queue, !Needed) :- ( module_info_preds(ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), ProcIds = pred_info_non_imported_procids(PredInfo), - list__member(ProcId, ProcIds), + list.member(ProcId, ProcIds), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, ProcInfo) + map.lookup(ProcTable, ProcId, ProcInfo) -> proc_info_goal(ProcInfo, Goal), examine_goal(Goal, proc(PredId, ProcId), !Queue, !Needed) @@ -412,21 +412,19 @@ examine_expr(scope(_, Goal), CurrProc, !Queue, !Needed) :- examine_goal(Goal, CurrProc, !Queue, !Needed). examine_expr(switch(_, _, Cases), CurrProc, !Queue, !Needed) :- examine_cases(Cases, CurrProc, !Queue, !Needed). -examine_expr(if_then_else(_, Cond, Then, Else), CurrProc, - !Queue, !Needed) :- +examine_expr(if_then_else(_, Cond, Then, Else), CurrProc, !Queue, !Needed) :- examine_goal(Cond, CurrProc, !Queue, !Needed), examine_goal(Then, CurrProc, !Queue, !Needed), examine_goal(Else, CurrProc, !Queue, !Needed). examine_expr(generic_call(_,_,_,_), _, !Queue, !Needed). -examine_expr(call(PredId, ProcId, _,_,_,_), - CurrProc, !Queue, !Needed) :- - queue__put(!.Queue, proc(PredId, ProcId), !:Queue), +examine_expr(call(PredId, ProcId, _,_,_,_), CurrProc, !Queue, !Needed) :- + queue.put(!.Queue, proc(PredId, ProcId), !:Queue), ( proc(PredId, ProcId) = CurrProc -> % if it's reachable and recursive, then we can't % eliminate or inline it NewNotation = no, - svmap__set(proc(PredId, ProcId), NewNotation, !Needed) - ; map__search(!.Needed, proc(PredId, ProcId), OldNotation) -> + svmap.set(proc(PredId, ProcId), NewNotation, !Needed) + ; map.search(!.Needed, proc(PredId, ProcId), OldNotation) -> ( OldNotation = no, NewNotation = no @@ -434,17 +432,16 @@ examine_expr(call(PredId, ProcId, _,_,_,_), OldNotation = yes(Count), NewNotation = yes(Count + 1) ), - svmap__det_update(proc(PredId, ProcId), NewNotation, !Needed) + svmap.det_update(proc(PredId, ProcId), NewNotation, !Needed) ; NewNotation = yes(1), - svmap__set(proc(PredId, ProcId), NewNotation, !Needed) + svmap.set(proc(PredId, ProcId), NewNotation, !Needed) ). -examine_expr(foreign_proc(_, PredId, ProcId, _, _, _), - _CurrProc, !Queue, !Needed) :- - svqueue__put(proc(PredId, ProcId), !Queue), - svmap__set(proc(PredId, ProcId), no, !Needed). -examine_expr(unify(_,_,_, Uni, _), _CurrProc, +examine_expr(foreign_proc(_, PredId, ProcId, _, _, _), _CurrProc, !Queue, !Needed) :- + svqueue.put(proc(PredId, ProcId), !Queue), + svmap.set(proc(PredId, ProcId), no, !Needed). +examine_expr(unify(_,_,_, Uni, _), _CurrProc, !Queue, !Needed) :- ( Uni = construct(_, ConsId, _, _, _, _, _), ( @@ -456,8 +453,8 @@ examine_expr(unify(_,_,_, Uni, _), _CurrProc, Entity = base_gen_info(Module, TypeName, Arity) ) -> - svqueue__put(Entity, !Queue), - svmap__set(Entity, no, !Needed) + svqueue.put(Entity, !Queue), + svmap.set(Entity, no, !Needed) ; true ). @@ -491,7 +488,7 @@ eliminate(Pass, !.Needed, !ModuleInfo, !IO) :- Changed0 = no, ElimInfo0 = elimination_info(!.Needed, !.ModuleInfo, PredTable0, Changed0), - list__foldl2(eliminate_pred(Pass), PredIds, ElimInfo0, ElimInfo, !IO), + list.foldl2(eliminate_pred(Pass), PredIds, ElimInfo0, ElimInfo, !IO), ElimInfo = elimination_info(!:Needed, !:ModuleInfo, PredTable, Changed), module_info_set_preds(PredTable, !ModuleInfo), @@ -515,12 +512,13 @@ eliminate(Pass, !.Needed, !ModuleInfo, !IO) :- eliminate_pred(Pass, PredId, !ElimInfo, !IO) :- !.ElimInfo = elimination_info(Needed, ModuleInfo, PredTable0, Changed0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_import_status(PredInfo0, Status), ( % Find out if the predicate is defined in this module. % If yes, find out also whether any of its procedures must be kept. - ( Status = local, + ( + Status = local, Keep = no, ( % Don't warn for unify or comparison preds, @@ -536,30 +534,32 @@ eliminate_pred(Pass, PredId, !ElimInfo, !IO) :- % procedure if appropriate. Likewise, don't warn for procedures % introduced for type specialization. PredName = pred_info_name(PredInfo0), - ( string__prefix(PredName, "IntroducedFrom__") - ; string__prefix(PredName, "TypeSpecOf__") + ( string.prefix(PredName, "IntroducedFrom__") + ; string.prefix(PredName, "TypeSpecOf__") ) -> WarnForThisProc = no ; WarnForThisProc = yes ) - ; Status = pseudo_imported, + ; + Status = pseudo_imported, Keep = no, WarnForThisProc = no - ; Status = pseudo_exported, - hlds_pred__in_in_unification_proc_id(InitProcId), + ; + Status = pseudo_exported, + hlds_pred.in_in_unification_proc_id(InitProcId), Keep = yes(InitProcId), WarnForThisProc = no ) -> ProcIds = pred_info_procids(PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - list__foldl3(eliminate_proc(Pass, PredId, + list.foldl3(eliminate_proc(Pass, PredId, Keep, WarnForThisProc, !.ElimInfo), ProcIds, ProcTable0, ProcTable, Changed0, Changed, !IO), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable) + map.det_update(PredTable0, PredId, PredInfo, PredTable) ; % Don't generate code in the current module for unoptimized % opt_imported preds (that is, for opt_imported preds which we have not @@ -576,18 +576,18 @@ eliminate_pred(Pass, PredId, !ElimInfo, !IO) :- % XXX this looks fishy to me - zs DestroyGoal = (pred(Id::in, PTable0::in, PTable::out) is det :- - map__lookup(ProcTable0, Id, ProcInfo0), + map.lookup(ProcTable0, Id, ProcInfo0), goal_info_init(GoalInfo), Goal = true_goal_expr - GoalInfo, proc_info_set_goal(Goal, ProcInfo0, ProcInfo), - map__det_update(PTable0, Id, ProcInfo, PTable) + map.det_update(PTable0, Id, ProcInfo, PTable) ), - list__foldl(DestroyGoal, ProcIds, ProcTable0, ProcTable), + list.foldl(DestroyGoal, ProcIds, ProcTable0, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo1), pred_info_set_import_status(imported(interface), PredInfo1, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable), - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + map.det_update(PredTable0, PredId, PredInfo, PredTable), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, write_pred_progress_message("% Eliminated opt_imported predicate ", @@ -615,14 +615,14 @@ eliminate_proc(Pass, PredId, Keep, WarnForThisProc, ElimInfo, ( % Keep the procedure if it is in the needed map % or if it is to be kept because it is exported. - ( map__search(Needed, proc(PredId, ProcId), _) + ( map.search(Needed, proc(PredId, ProcId), _) ; Keep = yes(ProcId) ) -> true ; !:Changed = yes, - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, write_proc_progress_message("% Eliminated the dead procedure ", @@ -642,7 +642,7 @@ eliminate_proc(Pass, PredId, Keep, WarnForThisProc, ElimInfo, ; true ), - svmap__delete(ProcId, !ProcTable) + svmap.delete(ProcId, !ProcTable) ). :- pred warn_dead_proc(pred_id::in, proc_id::in, prog_context::in, @@ -653,7 +653,7 @@ warn_dead_proc(PredId, ProcId, Context, ModuleInfo, !IO) :- should_not_module_qualify, proc(PredId, ProcId)), Components = [words("Warning:")] ++ ProcPieces ++ [words("is never called.")], - error_util__report_warning(Context, 0, Components, !IO). + error_util.report_warning(Context, 0, Components, !IO). :- pred eliminate_base_gen_infos(list(type_ctor_gen_info)::in, needed_map::in, list(type_ctor_gen_info)::out) is det. @@ -667,7 +667,7 @@ eliminate_base_gen_infos([TypeCtorGenInfo0 | TypeCtorGenInfos0], TypeName, Arity, _Status, _HldsDefn, _Unify, _Compare), ( Entity = base_gen_info(ModuleName, TypeName, Arity), - map__search(Needed, Entity, _) + map.search(Needed, Entity, _) -> TypeCtorGenInfos = [TypeCtorGenInfo0 | TypeCtorGenInfos1] ; @@ -687,8 +687,8 @@ eliminate_base_gen_infos([TypeCtorGenInfo0 | TypeCtorGenInfos0], ). dead_pred_elim(!ModuleInfo) :- - queue__init(Queue0), - map__init(Needed0), + queue.init(Queue0), + map.init(Needed0), module_info_get_pragma_exported_procs(!.ModuleInfo, PragmaExports), initialize_pragma_exports(PragmaExports, Queue0, _, Needed0, Needed1), % @@ -699,19 +699,19 @@ dead_pred_elim(!ModuleInfo) :- module_info_get_instance_table(!.ModuleInfo, Instances), module_info_get_class_table(!.ModuleInfo, Classes), initialize_class_methods(Classes, Instances, Queue0, _, Needed1, Needed), - map__keys(Needed, Entities), - queue__init(Queue1), - set__init(NeededPreds0), - list__foldl2(dead_pred_elim_add_entity, Entities, Queue1, Queue, + map.keys(Needed, Entities), + queue.init(Queue1), + set.init(NeededPreds0), + list.foldl2(dead_pred_elim_add_entity, Entities, Queue1, Queue, NeededPreds0, NeededPreds1), - set__init(Preds0), - set__init(Names0), + set.init(Preds0), + set.init(Names0), DeadInfo0 = dead_pred_info(!.ModuleInfo, Queue, Preds0, NeededPreds1, Names0), module_info_predids(!.ModuleInfo, PredIds), - list__foldl(dead_pred_elim_initialize, PredIds, DeadInfo0, DeadInfo1), + list.foldl(dead_pred_elim_initialize, PredIds, DeadInfo0, DeadInfo1), dead_pred_elim_analyze(DeadInfo1, DeadInfo), DeadInfo = dead_pred_info(!:ModuleInfo, _, _, NeededPreds2, _), @@ -723,16 +723,15 @@ dead_pred_elim(!ModuleInfo) :- module_info_get_type_spec_info(!.ModuleInfo, type_spec_info(TypeSpecProcs0, TypeSpecForcePreds0, SpecMap0, PragmaMap0)), - set__to_sorted_list(NeededPreds2, NeededPredList2), - list__foldl((pred(NeededPred::in, AllPreds0::in, AllPreds::out) - is det :- - ( map__search(SpecMap0, NeededPred, NewNeededPreds) -> - set__insert_list(AllPreds0, NewNeededPreds, AllPreds) + set.to_sorted_list(NeededPreds2, NeededPredList2), + list.foldl((pred(NeededPred::in, AllPreds0::in, AllPreds::out) is det :- + ( map.search(SpecMap0, NeededPred, NewNeededPreds) -> + set.insert_list(AllPreds0, NewNeededPreds, AllPreds) ; AllPreds = AllPreds0 ) ), NeededPredList2, NeededPreds2, NeededPreds), - set__intersect(TypeSpecForcePreds0, NeededPreds, TypeSpecForcePreds), + set.intersect(TypeSpecForcePreds0, NeededPreds, TypeSpecForcePreds), module_info_set_type_spec_info( type_spec_info(TypeSpecProcs0, TypeSpecForcePreds, @@ -742,7 +741,7 @@ dead_pred_elim(!ModuleInfo) :- module_info_get_predicate_table(!.ModuleInfo, PredTable0), module_info_get_partial_qualifier_info(!.ModuleInfo, PartialQualInfo), predicate_table_restrict(PartialQualInfo, - set__to_sorted_list(NeededPreds), PredTable0, PredTable), + set.to_sorted_list(NeededPreds), PredTable0, PredTable), module_info_set_predicate_table(PredTable, !ModuleInfo). :- pred dead_pred_elim_add_entity(entity::in, queue(pred_id)::in, @@ -750,8 +749,8 @@ dead_pred_elim(!ModuleInfo) :- dead_pred_elim_add_entity(base_gen_info(_, _, _), !Queue, !Preds). dead_pred_elim_add_entity(proc(PredId, _), !Queue, !Preds) :- - svqueue__put(PredId, !Queue), - svset__insert(PredId, !Preds). + svqueue.put(PredId, !Queue), + svset.insert(PredId, !Preds). :- pred dead_pred_elim_initialize(pred_id::in, dead_pred_info::in, dead_pred_info::out) is det. @@ -789,15 +788,15 @@ dead_pred_elim_initialize(PredId, DeadInfo0, DeadInfo) :- % Don't eliminate _init_any/1 predicates; modes.m may % insert calls to them to initialize variables from inst `free' % to inst `any'. - string__remove_suffix(PredName, "_init_any", _), + string.remove_suffix(PredName, "_init_any", _), PredArity = 1 ; % Don't eliminate the clauses for promises. pred_info_get_goal_type(PredInfo, promise(_)) ) -> - svset__insert(qualified(PredModule, PredName), !NeededNames), - svqueue__put(PredId, !Queue) + svset.insert(qualified(PredModule, PredName), !NeededNames), + svqueue.put(PredId, !Queue) ; true ), @@ -811,20 +810,20 @@ dead_pred_elim_analyze(!DeadInfo) :- some [!Queue, !Ex, !Needed] ( !.DeadInfo = dead_pred_info(ModuleInfo, !:Queue, !:Ex, !:Needed, NeededNames), - ( svqueue__get(PredId, !Queue) -> - ( set__member(PredId, !.Ex) -> + ( svqueue.get(PredId, !Queue) -> + ( set.member(PredId, !.Ex) -> !:DeadInfo = dead_pred_info(ModuleInfo, !.Queue, !.Ex, !.Needed, NeededNames) ; - svset__insert(PredId, !Needed), - svset__insert(PredId, !Ex), + svset.insert(PredId, !Needed), + svset.insert(PredId, !Ex), !:DeadInfo = dead_pred_info(ModuleInfo, !.Queue, !.Ex, !.Needed, NeededNames), module_info_pred_info(ModuleInfo, PredId, PredInfo), pred_info_clauses_info(PredInfo, ClausesInfo), clauses_info_clauses_rep(ClausesInfo, ClausesRep), get_clause_list_any_order(ClausesRep, Clauses), - list__foldl(dead_pred_elim_process_clause, Clauses, !DeadInfo) + list.foldl(dead_pred_elim_process_clause, Clauses, !DeadInfo) ), dead_pred_elim_analyze(!DeadInfo) ; @@ -842,17 +841,17 @@ dead_pred_elim_process_clause(clause(_, Goal, _, _), !DeadInfo) :- dead_pred_info::in, dead_pred_info::out) is det. pre_modecheck_examine_goal(conj(_ConjType, Goals) - _, !DeadInfo) :- - list__foldl(pre_modecheck_examine_goal, Goals, !DeadInfo). + list.foldl(pre_modecheck_examine_goal, Goals, !DeadInfo). pre_modecheck_examine_goal(disj(Goals) - _, !DeadInfo) :- - list__foldl(pre_modecheck_examine_goal, Goals, !DeadInfo). + list.foldl(pre_modecheck_examine_goal, Goals, !DeadInfo). pre_modecheck_examine_goal(if_then_else(_, If, Then, Else) - _, !DeadInfo) :- - list__foldl(pre_modecheck_examine_goal, [If, Then, Else], !DeadInfo). + list.foldl(pre_modecheck_examine_goal, [If, Then, Else], !DeadInfo). pre_modecheck_examine_goal(switch(_, _, Cases) - _, !DeadInfo) :- ExamineCase = (pred(Case::in, Info0::in, Info::out) is det :- Case = case(_, Goal), pre_modecheck_examine_goal(Goal, Info0, Info) ), - list__foldl(ExamineCase, Cases, !DeadInfo). + list.foldl(ExamineCase, Cases, !DeadInfo). pre_modecheck_examine_goal(generic_call(_,_,_,_) - _, !DeadInfo). pre_modecheck_examine_goal(not(Goal) - _, !DeadInfo) :- pre_modecheck_examine_goal(Goal, !DeadInfo). @@ -888,16 +887,16 @@ dead_pred_info_add_pred_name(Name, !DeadInfo) :- some [!Queue, !NeededNames] ( !.DeadInfo = dead_pred_info(ModuleInfo, !:Queue, Ex, Needed, !:NeededNames), - ( set__member(Name, !.NeededNames) -> + ( set.member(Name, !.NeededNames) -> true ; module_info_get_predicate_table(ModuleInfo, PredicateTable), - svset__insert(Name, !NeededNames), + svset.insert(Name, !NeededNames), ( predicate_table_search_sym(PredicateTable, may_be_partially_qualified, Name, PredIds) -> - svqueue__put_list(PredIds, !Queue) + svqueue.put_list(PredIds, !Queue) ; true ), diff --git a/compiler/deep_profiling.m b/compiler/deep_profiling.m index 22975f856..4d4abd6aa 100644 --- a/compiler/deep_profiling.m +++ b/compiler/deep_profiling.m @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__deep_profiling. +:- module ll_backend.deep_profiling. :- interface. :- import_module hlds.hlds_module. @@ -69,7 +69,7 @@ apply_deep_profiling_transformation(!ModuleInfo) :- module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, deep_profile_tail_recursion, + globals.lookup_bool_option(Globals, deep_profile_tail_recursion, TailRecursion), ( TailRecursion = yes, @@ -93,14 +93,14 @@ apply_tail_recursion_transformation(!ModuleInfo) :- module_info_ensure_dependency_info(!ModuleInfo), module_info_dependency_info(!.ModuleInfo, DepInfo), hlds_dependency_info_get_dependency_ordering(DepInfo, SCCs), - list__foldl(apply_tail_recursion_to_scc, SCCs, !ModuleInfo). + list.foldl(apply_tail_recursion_to_scc, SCCs, !ModuleInfo). :- pred apply_tail_recursion_to_scc(list(pred_proc_id)::in, module_info::in, module_info::out) is det. apply_tail_recursion_to_scc(SCC, !ModuleInfo) :- % For the time being, we only look for self-tail-recursive calls. - list__foldl(apply_tail_recursion_to_proc, SCC, !ModuleInfo). + list.foldl(apply_tail_recursion_to_proc, SCC, !ModuleInfo). :- pred apply_tail_recursion_to_proc(pred_proc_id::in, module_info::in, module_info::out) is det. @@ -108,10 +108,10 @@ apply_tail_recursion_to_scc(SCC, !ModuleInfo) :- apply_tail_recursion_to_proc(PredProcId, !ModuleInfo) :- PredProcId = proc(PredId, ProcId), module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_arg_types(PredInfo0, Types), pred_info_procedures(PredInfo0, ProcTable0), - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), proc_info_goal(ProcInfo0, Goal0), proc_info_interface_determinism(ProcInfo0, Detism), ( @@ -142,10 +142,10 @@ apply_tail_recursion_to_proc(PredProcId, !ModuleInfo) :- ProcInfo1, ProcInfo), proc_info_set_maybe_deep_profile_info( yes(CloneDeepProfileInfo), ProcInfo1, CloneProcInfo), - map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable1), - map__det_insert(ProcTable1, CloneProcId, CloneProcInfo, ProcTable), + map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable1), + map.det_insert(ProcTable1, CloneProcId, CloneProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo) ; true @@ -200,7 +200,7 @@ apply_tail_recursion_to_goal(Goal0, ApplyInfo, Goal, !FoundTailCall, GoalExpr0 = call(PredId, ProcId, Args, Builtin, UnifyContext, SymName), ( PredProcId = proc(PredId, ProcId), - assoc_list__search(ApplyInfo ^ scc_ppids, PredProcId, + assoc_list.search(ApplyInfo ^ scc_ppids, PredProcId, ClonePredProcId), module_info_pred_proc_info(ApplyInfo ^ moduleinfo, PredId, ProcId, PredInfo, ProcInfo), @@ -361,7 +361,7 @@ figure_out_rec_call_numbers(Goal, !N, !TailCallSites) :- ; GoalExpr = call(_, _, _, BuiltinState, _, _), goal_info_get_features(GoalInfo, Features), - ( set__member(tailcall, Features) -> + ( set.member(tailcall, Features) -> !:TailCallSites = [!.N | !.TailCallSites] ; true @@ -424,19 +424,19 @@ figure_out_rec_call_numbers_in_case_list([Case|Cases], !N, !TailCallSites) :- pred_table::in, pred_table::out) is det. transform_predicate(ModuleInfo, PredId, PredMap0, PredMap) :- - map__lookup(PredMap0, PredId, PredInfo0), + map.lookup(PredMap0, PredId, PredInfo0), ProcIds = pred_info_non_imported_procids(PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - list__foldl(maybe_transform_procedure(ModuleInfo, PredId), + list.foldl(maybe_transform_procedure(ModuleInfo, PredId), ProcIds, ProcTable0, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredMap0, PredId, PredInfo, PredMap). + map.det_update(PredMap0, PredId, PredInfo, PredMap). :- pred maybe_transform_procedure(module_info::in, pred_id::in, proc_id::in, proc_table::in, proc_table::out) is det. maybe_transform_procedure(ModuleInfo, PredId, ProcId, !ProcTable) :- - map__lookup(!.ProcTable, ProcId, ProcInfo0), + map.lookup(!.ProcTable, ProcId, ProcInfo0), proc_info_goal(ProcInfo0, Goal0), predicate_module(ModuleInfo, PredId, PredModuleName), ( @@ -456,7 +456,7 @@ maybe_transform_procedure(ModuleInfo, PredId, ProcId, !ProcTable) :- ; transform_procedure2(ModuleInfo, proc(PredId, ProcId), ProcInfo0, ProcInfo), - map__det_update(!.ProcTable, ProcId, ProcInfo, !:ProcTable) + map.det_update(!.ProcTable, ProcId, ProcInfo, !:ProcTable) ). :- pred transform_procedure2(module_info::in, pred_proc_id::in, @@ -519,19 +519,19 @@ transform_det_proc(ModuleInfo, PredProcId, !ProcInfo) :- proc_info_varset(!.ProcInfo, !:VarSet), proc_info_vartypes(!.ProcInfo, !:VarTypes), CPointerType = c_pointer_type, - svvarset__new_named_var("TopCSD", TopCSD, !VarSet), - svvarset__new_named_var("MiddleCSD", MiddleCSD, !VarSet), - svvarset__new_named_var("ProcStaticLayout", ProcStaticVar, !VarSet), - svmap__set(TopCSD, CPointerType, !VarTypes), - svmap__set(MiddleCSD, CPointerType, !VarTypes), - svmap__set(ProcStaticVar, CPointerType, !VarTypes), + svvarset.new_named_var("TopCSD", TopCSD, !VarSet), + svvarset.new_named_var("MiddleCSD", MiddleCSD, !VarSet), + svvarset.new_named_var("ProcStaticLayout", ProcStaticVar, !VarSet), + svmap.set(TopCSD, CPointerType, !VarTypes), + svmap.set(MiddleCSD, CPointerType, !VarTypes), + svmap.set(ProcStaticVar, CPointerType, !VarTypes), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, use_activation_counts, + globals.lookup_bool_option(Globals, use_activation_counts, UseActivationCounts), ( UseActivationCounts = no, - svvarset__new_named_var("ActivationPtr", ActivationPtr0, !VarSet), - svmap__set(ActivationPtr0, CPointerType, !VarTypes), + svvarset.new_named_var("ActivationPtr", ActivationPtr0, !VarSet), + svmap.set(ActivationPtr0, CPointerType, !VarTypes), MaybeActivationPtr = yes(ActivationPtr0) ; UseActivationCounts = yes, @@ -539,13 +539,13 @@ transform_det_proc(ModuleInfo, PredProcId, !ProcInfo) :- ), ExcpVars = hlds_deep_excp_vars(TopCSD, MiddleCSD, MaybeActivationPtr), proc_info_context(!.ProcInfo, Context), - FileName = term__context_file(Context), - LineNumber = term__context_line(Context), + FileName = term.context_file(Context), + LineNumber = term.context_line(Context), proc_info_get_maybe_deep_profile_info(!.ProcInfo, MaybeDeepProfInfo), extract_deep_rec_info(MaybeDeepProfInfo, MaybeRecInfo), DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD, - counter__init(0), [], !.VarSet, !.VarTypes, + counter.init(0), [], !.VarSet, !.VarTypes, FileName, MaybeRecInfo) ), @@ -611,19 +611,19 @@ transform_semi_proc(ModuleInfo, PredProcId, !ProcInfo) :- proc_info_varset(!.ProcInfo, !:VarSet), proc_info_vartypes(!.ProcInfo, !:VarTypes), CPointerType = c_pointer_type, - svvarset__new_named_var("TopCSD", TopCSD, !VarSet), - svvarset__new_named_var("MiddleCSD", MiddleCSD, !VarSet), - svvarset__new_named_var("ProcStaticLayout", ProcStaticVar, !VarSet), - svmap__set(TopCSD, CPointerType, !VarTypes), - svmap__set(MiddleCSD, CPointerType, !VarTypes), - svmap__set(ProcStaticVar, CPointerType, !VarTypes), + svvarset.new_named_var("TopCSD", TopCSD, !VarSet), + svvarset.new_named_var("MiddleCSD", MiddleCSD, !VarSet), + svvarset.new_named_var("ProcStaticLayout", ProcStaticVar, !VarSet), + svmap.set(TopCSD, CPointerType, !VarTypes), + svmap.set(MiddleCSD, CPointerType, !VarTypes), + svmap.set(ProcStaticVar, CPointerType, !VarTypes), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, use_activation_counts, + globals.lookup_bool_option(Globals, use_activation_counts, UseActivationCounts), ( UseActivationCounts = no, - svvarset__new_named_var("ActivationPtr", ActivationPtr0, !VarSet), - svmap__set(ActivationPtr0, CPointerType, !VarTypes), + svvarset.new_named_var("ActivationPtr", ActivationPtr0, !VarSet), + svmap.set(ActivationPtr0, CPointerType, !VarTypes), MaybeActivationPtr = yes(ActivationPtr0) ; UseActivationCounts = yes, @@ -631,13 +631,13 @@ transform_semi_proc(ModuleInfo, PredProcId, !ProcInfo) :- ), ExcpVars = hlds_deep_excp_vars(TopCSD, MiddleCSD, MaybeActivationPtr), proc_info_context(!.ProcInfo, Context), - FileName = term__context_file(Context), - LineNumber = term__context_line(Context), + FileName = term.context_file(Context), + LineNumber = term.context_line(Context), proc_info_get_maybe_deep_profile_info(!.ProcInfo, MaybeDeepProfInfo), extract_deep_rec_info(MaybeDeepProfInfo, MaybeRecInfo), DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD, - counter__init(0), [], !.VarSet, !.VarTypes, + counter.init(0), [], !.VarSet, !.VarTypes, FileName, MaybeRecInfo) ), @@ -720,20 +720,20 @@ transform_non_proc(ModuleInfo, PredProcId, !ProcInfo) :- proc_info_varset(!.ProcInfo, !:VarSet), proc_info_vartypes(!.ProcInfo, !:VarTypes), CPointerType = c_pointer_type, - svvarset__new_named_var("TopCSD", TopCSD, !VarSet), - svvarset__new_named_var("MiddleCSD", MiddleCSD, !VarSet), - svvarset__new_named_var("ProcStaticLayout", ProcStaticVar, !VarSet), - svmap__set(TopCSD, CPointerType, !VarTypes), - svmap__set(MiddleCSD, CPointerType, !VarTypes), - svmap__set(ProcStaticVar, CPointerType, !VarTypes), + svvarset.new_named_var("TopCSD", TopCSD, !VarSet), + svvarset.new_named_var("MiddleCSD", MiddleCSD, !VarSet), + svvarset.new_named_var("ProcStaticLayout", ProcStaticVar, !VarSet), + svmap.set(TopCSD, CPointerType, !VarTypes), + svmap.set(MiddleCSD, CPointerType, !VarTypes), + svmap.set(ProcStaticVar, CPointerType, !VarTypes), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, use_activation_counts, + globals.lookup_bool_option(Globals, use_activation_counts, UseActivationCounts), ( UseActivationCounts = no, - svvarset__new_named_var("OldOutermost", OldOutermostProcDyn0, + svvarset.new_named_var("OldOutermost", OldOutermostProcDyn0, !VarSet), - svmap__set(OldOutermostProcDyn0, CPointerType, !VarTypes), + svmap.set(OldOutermostProcDyn0, CPointerType, !VarTypes), MaybeOldActivationPtr = yes(OldOutermostProcDyn0) ; UseActivationCounts = yes, @@ -741,16 +741,16 @@ transform_non_proc(ModuleInfo, PredProcId, !ProcInfo) :- ), ExcpVars = hlds_deep_excp_vars(TopCSD, MiddleCSD, MaybeOldActivationPtr), - svvarset__new_named_var("NewOutermost", NewOutermostProcDyn, !VarSet), - svmap__set(NewOutermostProcDyn, CPointerType, !VarTypes), + svvarset.new_named_var("NewOutermost", NewOutermostProcDyn, !VarSet), + svmap.set(NewOutermostProcDyn, CPointerType, !VarTypes), proc_info_context(!.ProcInfo, Context), - FileName = term__context_file(Context), - LineNumber = term__context_line(Context), + FileName = term.context_file(Context), + LineNumber = term.context_line(Context), proc_info_get_maybe_deep_profile_info(!.ProcInfo, MaybeDeepProfInfo), extract_deep_rec_info(MaybeDeepProfInfo, MaybeRecInfo), DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD, - counter__init(0), [], !.VarSet, !.VarTypes, FileName, MaybeRecInfo) + counter.init(0), [], !.VarSet, !.VarTypes, FileName, MaybeRecInfo) ), transform_goal([], Goal0, TransformedGoal, _, DeepInfo0, DeepInfo), @@ -818,7 +818,7 @@ transform_non_proc(ModuleInfo, PredProcId, !ProcInfo) :- determinism_components(Detism, CanFail, at_most_many), goal_info_set_determinism(Detism, GoalInfo0, GoalInfo1), - ExitRedoNonLocals = set__union(NewNonlocals, + ExitRedoNonLocals = set.union(NewNonlocals, list_to_set([NewOutermostProcDyn])), ExitRedoGoalInfo = impure_reachable_init_goal_info(ExitRedoNonLocals, multidet), @@ -856,16 +856,16 @@ transform_inner_proc(ModuleInfo, PredProcId, !ProcInfo) :- proc_info_vartypes(!.ProcInfo, VarTypes0), CPointerType = c_pointer_type, % MiddleCSD should be unused - varset__new_named_var(VarSet0, "MiddleCSD", MiddleCSD, VarSet1), - map__set(VarTypes0, MiddleCSD, CPointerType, VarTypes1), + varset.new_named_var(VarSet0, "MiddleCSD", MiddleCSD, VarSet1), + map.set(VarTypes0, MiddleCSD, CPointerType, VarTypes1), goal_info_get_context(GoalInfo0, Context), - FileName = term__context_file(Context), + FileName = term.context_file(Context), proc_info_get_maybe_deep_profile_info(!.ProcInfo, MaybeDeepProfInfo), extract_deep_rec_info(MaybeDeepProfInfo, MaybeRecInfo), DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD, - counter__init(0), [], VarSet1, VarTypes1, + counter.init(0), [], VarSet1, VarTypes1, FileName, MaybeRecInfo), transform_goal([], Goal0, TransformedGoal, _, DeepInfo0, DeepInfo), @@ -905,7 +905,7 @@ transform_goal(Path, conj(ConjType, Goals0) - GoalInfo0, transform_goal(Path, switch(Var, CF, Cases0) - GoalInfo0, switch(Var, CF, Cases) - GoalInfo, AddedImpurity, !DeepInfo) :- - transform_switch(list__length(Cases0), 0, Path, Cases0, Cases, + transform_switch(list.length(Cases0), 0, Path, Cases0, Cases, AddedImpurity, !DeepInfo), add_impurity_if_needed(AddedImpurity, GoalInfo0, GoalInfo). @@ -1029,7 +1029,7 @@ transform_conj(N, Path, [Goal0 | Goals0], [Goal | Goals], AddedImpurity, transform_goal([conj(N1) | Path], Goal0, Goal, AddedImpurityFirst, !DeepInfo), transform_conj(N1, Path, Goals0, Goals, AddedImpurityLater, !DeepInfo), - bool__or(AddedImpurityFirst, AddedImpurityLater, AddedImpurity). + bool.or(AddedImpurityFirst, AddedImpurityLater, AddedImpurity). :- pred transform_disj(int::in, goal_path::in, list(hlds_goal)::in, list(hlds_goal)::out, bool::out, @@ -1042,7 +1042,7 @@ transform_disj(N, Path, [Goal0 | Goals0], [Goal | Goals], AddedImpurity, transform_goal([disj(N1) | Path], Goal0, Goal, AddedImpurityFirst, !DeepInfo), transform_disj(N1, Path, Goals0, Goals, AddedImpurityLater, !DeepInfo), - bool__or(AddedImpurityFirst, AddedImpurityLater, AddedImpurity). + bool.or(AddedImpurityFirst, AddedImpurityLater, AddedImpurity). :- pred transform_switch(int::in, int::in, goal_path::in, list(case)::in, list(case)::out, bool::out, @@ -1056,7 +1056,7 @@ transform_switch(NumCases, N, Path, [case(Id, Goal0) | Goals0], AddedImpurityFirst, !DeepInfo), transform_switch(NumCases, N1, Path, Goals0, Goals, AddedImpurityLater, !DeepInfo), - bool__or(AddedImpurityFirst, AddedImpurityLater, AddedImpurity). + bool.or(AddedImpurityFirst, AddedImpurityLater, AddedImpurity). :- pred wrap_call(goal_path::in, hlds_goal::in, hlds_goal::out, deep_info::in, deep_info::out) is det. @@ -1079,23 +1079,23 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :- Goal1 = GoalExpr - GoalInfo, SiteNumCounter0 = !.DeepInfo ^ site_num_counter, - counter__allocate(SiteNum, SiteNumCounter0, SiteNumCounter), - varset__new_named_var(!.DeepInfo ^ vars, "SiteNum", SiteNumVar, VarSet1), + counter.allocate(SiteNum, SiteNumCounter0, SiteNumCounter), + varset.new_named_var(!.DeepInfo ^ vars, "SiteNum", SiteNumVar, VarSet1), IntType = int_type, - map__set(!.DeepInfo ^ var_types, SiteNumVar, IntType, VarTypes1), + map.set(!.DeepInfo ^ var_types, SiteNumVar, IntType, VarTypes1), generate_unify(int_const(SiteNum), SiteNumVar, SiteNumVarGoal), !:DeepInfo = (((!.DeepInfo ^ vars := VarSet1) ^ var_types := VarTypes1) ^ site_num_counter := SiteNumCounter), goal_info_get_context(GoalInfo0, Context), - FileName0 = term__context_file(Context), - LineNumber = term__context_line(Context), + FileName0 = term.context_file(Context), + LineNumber = term.context_line(Context), compress_filename(!.DeepInfo, FileName0, FileName), classify_call(ModuleInfo, GoalExpr, CallKind), ( CallKind = normal(PredProcId), - ( set__member(tailcall, GoalFeatures) -> + ( set.member(tailcall, GoalFeatures) -> generate_call(ModuleInfo, "prepare_for_tail_call", 1, [SiteNumVar], [], PrepareGoal) ; @@ -1111,7 +1111,7 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :- PredProcId = !.DeepInfo ^ pred_proc_id -> OuterPredProcId = proc(OuterPredId, OuterProcId), - RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, + RttiProcLabel = rtti.make_rtti_proc_label(ModuleInfo, OuterPredId, OuterProcId) ; MaybeRecInfo = yes(RecInfo2), @@ -1120,10 +1120,10 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :- -> OuterPredProcId = !.DeepInfo ^ pred_proc_id, OuterPredProcId = proc(OuterPredId, OuterProcId), - RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, + RttiProcLabel = rtti.make_rtti_proc_label(ModuleInfo, OuterPredId, OuterProcId) ; - RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, + RttiProcLabel = rtti.make_rtti_proc_label(ModuleInfo, PredId, ProcId) ), CallSite = normal_call(RttiProcLabel, TypeSubst, @@ -1144,9 +1144,9 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :- CallSite = higher_order_call(FileName, LineNumber, GoalPath) ; Generic = class_method(TypeClassInfoVar, MethodNum, _, _), - varset__new_named_var(!.DeepInfo ^ vars, "MethodNum", + varset.new_named_var(!.DeepInfo ^ vars, "MethodNum", MethodNumVar, VarSet2), - map__set(!.DeepInfo ^ var_types, MethodNumVar, IntType, VarTypes2), + map.set(!.DeepInfo ^ var_types, MethodNumVar, IntType, VarTypes2), generate_unify(int_const(MethodNum), MethodNumVar, MethodNumVarGoal), !:DeepInfo = ((!.DeepInfo ^ vars := VarSet2) @@ -1162,11 +1162,11 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :- CallSite = method_call(FileName, LineNumber, GoalPath) ; Generic = cast(_), - unexpected(this_file, "deep_profiling__wrap_call: cast") + unexpected(this_file, "deep_profiling.wrap_call: cast") ), goal_info_get_code_model(GoalInfo0, GoalCodeModel), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, use_zeroing_for_ho_cycles, UseZeroing), ( UseZeroing = yes, @@ -1181,7 +1181,7 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :- !:DeepInfo = !.DeepInfo ^ call_sites := (!.DeepInfo ^ call_sites ++ [CallSite]), ( - set__member(tailcall, GoalFeatures), + set.member(tailcall, GoalFeatures), !.DeepInfo ^ maybe_rec_info = yes(RecInfo), RecInfo ^ role = outer_proc(_) -> @@ -1207,7 +1207,7 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :- goal_info_get_code_model(GoalInfo0, CodeModel), ( CodeModel = model_det -> - list__condense([ + list.condense([ CallGoals, [SiteNumVarGoal, PrepareGoal, Goal2], ExitGoals @@ -1225,9 +1225,9 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :- FailGoalInfo = fail_goal_info, FailGoal = disj([]) - FailGoalInfo, - list__append(FailGoals, [FailGoal], FailGoalsAndFail), + list.append(FailGoals, [FailGoal], FailGoalsAndFail), - list__condense([ + list.condense([ CallGoals, [disj([ conj(plain_conj, [ @@ -1254,21 +1254,21 @@ transform_higher_order_call(Globals, CodeModel, Goal0, Goal, !DeepInfo) :- VarTypes0 = !.DeepInfo ^ var_types, CPointerType = c_pointer_type, - varset__new_named_var(VarSet0, "SavedPtr", SavedPtrVar, VarSet1), - map__set(VarTypes0, SavedPtrVar, CPointerType, VarTypes1), + varset.new_named_var(VarSet0, "SavedPtr", SavedPtrVar, VarSet1), + map.set(VarTypes0, SavedPtrVar, CPointerType, VarTypes1), - globals__lookup_bool_option(Globals, use_activation_counts, + globals.lookup_bool_option(Globals, use_activation_counts, UseActivationCounts), ( UseActivationCounts = yes, IntType = int_type, - varset__new_named_var(VarSet1, "SavedCounter", SavedCountVar, VarSet), - map__set(VarTypes1, SavedCountVar, IntType, VarTypes), + varset.new_named_var(VarSet1, "SavedCounter", SavedCountVar, VarSet), + map.set(VarTypes1, SavedCountVar, IntType, VarTypes), !:DeepInfo = !.DeepInfo ^ vars := VarSet, !:DeepInfo = !.DeepInfo ^ var_types := VarTypes, - ExtraNonLocals = set__list_to_set([SavedCountVar, SavedPtrVar]), + ExtraNonLocals = set.list_to_set([SavedCountVar, SavedPtrVar]), generate_call(!.DeepInfo ^ module_info, "save_and_zero_activation_info_ac", 2, @@ -1285,7 +1285,7 @@ transform_higher_order_call(Globals, CodeModel, Goal0, Goal, !DeepInfo) :- !:DeepInfo = !.DeepInfo ^ vars := VarSet1, !:DeepInfo = !.DeepInfo ^ var_types := VarTypes1, - ExtraNonLocals = set__list_to_set([SavedPtrVar]), + ExtraNonLocals = set.list_to_set([SavedPtrVar]), generate_call(!.DeepInfo ^ module_info, "save_and_zero_activation_info_sr", 1, @@ -1312,7 +1312,7 @@ transform_higher_order_call(Globals, CodeModel, Goal0, Goal, !DeepInfo) :- RestoreFailGoalInfo = impure_unreachable_init_goal_info(ExtraNonLocals, failure), - RezeroFailGoalInfo = impure_unreachable_init_goal_info(set__init, + RezeroFailGoalInfo = impure_unreachable_init_goal_info(set.init, failure), make_impure(GoalInfo0, GoalInfo), @@ -1369,17 +1369,17 @@ wrap_foreign_code(GoalPath, Goal0, Goal, !DeepInfo) :- ModuleInfo = !.DeepInfo ^ module_info, SiteNumCounter0 = !.DeepInfo ^ site_num_counter, - counter__allocate(SiteNum, SiteNumCounter0, SiteNumCounter), - varset__new_named_var(!.DeepInfo ^ vars, "SiteNum", SiteNumVar, VarSet), - map__set(!.DeepInfo ^ var_types, SiteNumVar, int_type, VarTypes), + counter.allocate(SiteNum, SiteNumCounter0, SiteNumCounter), + varset.new_named_var(!.DeepInfo ^ vars, "SiteNum", SiteNumVar, VarSet), + map.set(!.DeepInfo ^ var_types, SiteNumVar, int_type, VarTypes), generate_unify(int_const(SiteNum), SiteNumVar, SiteNumVarGoal), generate_call(ModuleInfo, "prepare_for_callback", 1, [SiteNumVar], [], PrepareGoal), goal_info_get_context(GoalInfo0, Context), - LineNumber = term__context_line(Context), - FileName0 = term__context_file(Context), + LineNumber = term.context_line(Context), + FileName0 = term.context_file(Context), compress_filename(!.DeepInfo, FileName0, FileName), CallSite = callback(FileName, LineNumber, GoalPath), @@ -1467,7 +1467,7 @@ max_save_restore_vector_size = 9. generate_recursion_counter_saves_and_restores(CSNs, CSDVar, CallGoals, ExitGoals, FailGoals, ExtraVars, !DeepInfo) :- - list__chunk(CSNs, max_save_restore_vector_size, CSNChunks), + list.chunk(CSNs, max_save_restore_vector_size, CSNChunks), generate_recursion_counter_saves_and_restores_2(CSNChunks, CSDVar, CallGoals, ExitGoals, FailGoals, ExtraVars, !DeepInfo). @@ -1481,24 +1481,24 @@ generate_recursion_counter_saves_and_restores_2([], _, [], [], [], [], generate_recursion_counter_saves_and_restores_2([Chunk | Chunks], CSDVar, CallGoals, ExitGoals, FailGoals, ExtraVars, !DeepInfo) :- - list__map_foldl(generate_depth_var, Chunk, DepthVars, !DeepInfo), + list.map_foldl(generate_depth_var, Chunk, DepthVars, !DeepInfo), % We generate three separate variables to hold the constant CSN vector. % If we used only one, the code generator would have to save its value % on the stack when we enter the disjunction that wraps the goal. - list__length(Chunk, Length), + list.length(Chunk, Length), generate_csn_vector(Length, Chunk, CallVars1, CallGoals1, CallCellVar, !DeepInfo), generate_csn_vector(Length, Chunk, ExitVars1, ExitGoals1, ExitCellVar, !DeepInfo), generate_csn_vector(Length, Chunk, FailVars1, FailGoals1, FailCellVar, !DeepInfo), - list__condense([CallVars1, ExitVars1, FailVars1], ExtraVars1), + list.condense([CallVars1, ExitVars1, FailVars1], ExtraVars1), - CallPredName = string__format("save_recursion_depth_%d", [i(Length)]), - ExitPredName = string__format("restore_recursion_depth_exit_%d", + CallPredName = string.format("save_recursion_depth_%d", [i(Length)]), + ExitPredName = string.format("restore_recursion_depth_exit_%d", [i(Length)]), - FailPredName = string__format("restore_recursion_depth_fail_%d", + FailPredName = string.format("restore_recursion_depth_fail_%d", [i(Length)]), ModuleInfo = !.DeepInfo ^ module_info, generate_call(ModuleInfo, CallPredName, Length + 2, @@ -1511,10 +1511,10 @@ generate_recursion_counter_saves_and_restores_2([Chunk | Chunks], CSDVar, generate_recursion_counter_saves_and_restores_2(Chunks, CSDVar, CallGoals2, ExitGoals2, FailGoals2, ExtraVars2, !DeepInfo), - list__append(CallGoals1, [CallCellGoal | CallGoals2], CallGoals), - list__append(ExitGoals1, [ExitCellGoal | ExitGoals2], ExitGoals), - list__append(FailGoals1, [FailCellGoal | FailGoals2], FailGoals), - list__append(ExtraVars1, ExtraVars2, ExtraVars). + list.append(CallGoals1, [CallCellGoal | CallGoals2], CallGoals), + list.append(ExitGoals1, [ExitCellGoal | ExitGoals2], ExitGoals), + list.append(FailGoals1, [FailCellGoal | FailGoals2], FailGoals), + list.append(ExtraVars1, ExtraVars2, ExtraVars). :- pred generate_depth_var(int::in, prog_var::out, deep_info::in, deep_info::out) is det. @@ -1523,9 +1523,9 @@ generate_depth_var(CSN, DepthVar, !DeepInfo) :- VarSet0 = !.DeepInfo ^ vars, VarTypes0 = !.DeepInfo ^ var_types, IntType = int_type, - VarName = string__format("Depth%d", [i(CSN)]), - varset__new_named_var(VarSet0, VarName, DepthVar, VarSet), - map__set(VarTypes0, DepthVar, IntType, VarTypes), + VarName = string.format("Depth%d", [i(CSN)]), + varset.new_named_var(VarSet0, VarName, DepthVar, VarSet), + map.set(VarTypes0, DepthVar, IntType, VarTypes), !:DeepInfo = !.DeepInfo ^ vars := VarSet, !:DeepInfo = !.DeepInfo ^ var_types := VarTypes. @@ -1542,14 +1542,14 @@ generate_csn_vector(Length, CSNs, CSNVars, UnifyGoals, CellVar, !DeepInfo) :- ; expect(Length =< max_save_restore_vector_size, this_file, "generate_csn_vector_unifies: too long"), - list__map_foldl(generate_single_csn_unify, CSNs, CSNVarsGoals, + list.map_foldl(generate_single_csn_unify, CSNs, CSNVarsGoals, !DeepInfo), - InnerVars = assoc_list__keys(CSNVarsGoals), - InnerGoals = assoc_list__values(CSNVarsGoals), + InnerVars = assoc_list.keys(CSNVarsGoals), + InnerGoals = assoc_list.values(CSNVarsGoals), generate_csn_vector_cell(Length, InnerVars, CellVar, CellGoal, !DeepInfo), CSNVars = [CellVar | InnerVars], - UnifyGoals = list__append(InnerGoals, [CellGoal]) + UnifyGoals = list.append(InnerGoals, [CellGoal]) ). :- pred generate_csn_vector_cell(int::in, list(prog_var)::in, @@ -1558,12 +1558,12 @@ generate_csn_vector(Length, CSNs, CSNVars, UnifyGoals, CellVar, !DeepInfo) :- generate_csn_vector_cell(Length, CSNVars, CellVar, CellGoal, !DeepInfo) :- VarSet0 = !.DeepInfo ^ vars, VarTypes0 = !.DeepInfo ^ var_types, - varset__new_named_var(VarSet0, "CSNCell", CellVar, VarSet), + varset.new_named_var(VarSet0, "CSNCell", CellVar, VarSet), mercury_profiling_builtin_module(ProfilingBuiltin), - CellTypeName = string__format("call_site_nums_%d", [i(Length)]), + CellTypeName = string.format("call_site_nums_%d", [i(Length)]), CellTypeId = qualified(ProfilingBuiltin, CellTypeName) - Length, construct_type(CellTypeId, [], CellType), - map__set(VarTypes0, CellVar, CellType, VarTypes), + map.set(VarTypes0, CellVar, CellType, VarTypes), !:DeepInfo = !.DeepInfo ^ vars := VarSet, !:DeepInfo = !.DeepInfo ^ var_types := VarTypes, ConsId = cons(qualified(ProfilingBuiltin, CellTypeName), Length), @@ -1575,9 +1575,9 @@ generate_csn_vector_cell(Length, CSNVars, CellVar, CellGoal, !DeepInfo) :- generate_single_csn_unify(CSN, CSNVar - UnifyGoal, !DeepInfo) :- VarSet0 = !.DeepInfo ^ vars, VarTypes0 = !.DeepInfo ^ var_types, - VarName = string__format("CSN%d", [i(CSN)]), - varset__new_named_var(VarSet0, VarName, CSNVar, VarSet), - map__set(VarTypes0, CSNVar, int_type, VarTypes), + VarName = string.format("CSN%d", [i(CSN)]), + varset.new_named_var(VarSet0, VarName, CSNVar, VarSet), + map.set(VarTypes0, CSNVar, int_type, VarTypes), !:DeepInfo = !.DeepInfo ^ vars := VarSet, !:DeepInfo = !.DeepInfo ^ var_types := VarTypes, generate_unify(int_const(CSN), CSNVar, UnifyGoal). @@ -1615,7 +1615,7 @@ generate_call(ModuleInfo, Name, Arity, ArgVars, MaybeOutputVars, Detism, generate_unify(ConsId, Var, Goal) :- Ground = ground(shared, none), - NonLocals = set__make_singleton_set(Var), + NonLocals = set.make_singleton_set(Var), instmap_delta_from_assoc_list([Var - ground(shared, none)], InstMapDelta), Determinism = det, goal_info_init(NonLocals, InstMapDelta, Determinism, purity_pure, @@ -1631,13 +1631,13 @@ generate_unify(ConsId, Var, Goal) :- generate_cell_unify(Length, ConsId, Args, Var, Goal) :- Ground = ground(shared, none), - NonLocals = set__list_to_set([Var | Args]), + NonLocals = set.list_to_set([Var | Args]), instmap_delta_from_assoc_list([Var - Ground], InstMapDelta), Determinism = det, goal_info_init(NonLocals, InstMapDelta, Determinism, purity_pure, GoalInfo), ArgMode = ((free - Ground) -> (Ground - Ground)), - list__duplicate(Length, ArgMode, ArgModes), + list.duplicate(Length, ArgMode, ArgModes), Goal = unify(Var, functor(ConsId, no, Args), (free -> Ground) - (Ground -> Ground), construct(Var, ConsId, Args, ArgModes, @@ -1719,7 +1719,7 @@ impure_unreachable_init_goal_info(NonLocals, Determinism) = GoalInfo :- goal_info_add_nonlocals_make_impure(!.GoalInfo, NewNonLocals) = !:GoalInfo :- goal_info_get_nonlocals(!.GoalInfo, NonLocals0), - NonLocals = set__union(NonLocals0, NewNonLocals), + NonLocals = set.union(NonLocals0, NewNonLocals), goal_info_set_nonlocals(NonLocals, !GoalInfo), make_impure(!GoalInfo). @@ -1727,7 +1727,7 @@ goal_info_add_nonlocals_make_impure(!.GoalInfo, NewNonLocals) = !:GoalInfo :- fail_goal_info = GoalInfo :- instmap_delta_init_unreachable(InstMapDelta), - goal_info_init(set__init, InstMapDelta, failure, purity_pure, GoalInfo). + goal_info_init(set.init, InstMapDelta, failure, purity_pure, GoalInfo). :- pred make_impure(hlds_goal_info::in, hlds_goal_info::out) is det. diff --git a/compiler/deforest.m b/compiler/deforest.m index 8ddd63816..dfc8d12e8 100644 --- a/compiler/deforest.m +++ b/compiler/deforest.m @@ -31,7 +31,7 @@ % %-----------------------------------------------------------------------------% -:- module transform_hlds__deforest. +:- module transform_hlds.deforest. :- interface. :- import_module hlds.hlds_module. @@ -116,17 +116,17 @@ deforestation(!ModuleInfo, !IO) :- module_info_ensure_dependency_info(!ModuleInfo), module_info_dependency_info(!.ModuleInfo, DepInfo), hlds_dependency_info_get_dependency_ordering(DepInfo, DepOrdering), - list__condense(DepOrdering, DepList), + list.condense(DepOrdering, DepList), pd_info_init(!.ModuleInfo, ProcArgInfo, PDInfo0), - list__foldl2(deforest_proc, DepList, PDInfo0, PDInfo, !IO), + list.foldl2(deforest_proc, DepList, PDInfo0, PDInfo, !IO), pd_info_get_module_info(PDInfo, !:ModuleInfo), module_info_clobber_dependency_info(!ModuleInfo), pd_info_get_versions(PDInfo, VersionIndex), - map__keys(VersionIndex, Versions), + map.keys(VersionIndex, Versions), - globals__io_lookup_bool_option(constraint_propagation, + globals.io_lookup_bool_option(constraint_propagation, Constraints, !IO), ( Constraints = yes, @@ -135,7 +135,7 @@ deforestation(!ModuleInfo, !IO) :- % We can sometimes improve efficiency by rerunning determinism % inference on the specialized versions after constraint propagation, % because some nondet predicates will have become semidet. - list__foldl(reset_inferred_proc_determinism, Versions, !ModuleInfo), + list.foldl(reset_inferred_proc_determinism, Versions, !ModuleInfo), module_info_get_num_errors(!.ModuleInfo, Errors5), disable_det_warnings(OptionsToRestore, !IO), @@ -169,7 +169,7 @@ reset_inferred_proc_determinism(PredProcId, !ModuleInfo) :- :- pred proc_arg_info_init(map(pred_proc_id, pd_proc_arg_info)::out) is det. proc_arg_info_init(ProcArgInfo0) :- - map__init(ProcArgInfo0). + map.init(ProcArgInfo0). :- pred get_branch_vars_proc(pred_id::in, proc_id::in, proc_info::in, proc_info::out, univ::in, univ::out, @@ -178,7 +178,7 @@ proc_arg_info_init(ProcArgInfo0) :- get_branch_vars_proc(PredId, ProcId, ProcInfo, ProcInfo, UnivProcArgInfo0, UnivProcArgInfo, !ModuleInfo) :- ( univ_to_type(UnivProcArgInfo0, ProcArgInfo0) -> - pd_util__get_branch_vars_proc(proc(PredId, ProcId), ProcInfo, + pd_util.get_branch_vars_proc(proc(PredId, ProcId), ProcInfo, ProcArgInfo0, ProcArgInfo, !ModuleInfo), type_to_univ(ProcArgInfo, UnivProcArgInfo) ; @@ -206,13 +206,13 @@ deforest_proc_2(proc(PredId, ProcId), CostDelta, SizeDelta, !PDInfo, !IO) :- proc_info_goal(!.ProcInfo, !:Goal), % Inlining may have created some opportunities for simplification. - globals__io_get_globals(Globals, !IO), - simplify__find_simplifications(no, Globals, Simplifications), - pd_util__simplify_goal(Simplifications, !Goal, !PDInfo, !IO), + globals.io_get_globals(Globals, !IO), + simplify.find_simplifications(no, Globals, Simplifications), + pd_util.simplify_goal(Simplifications, !Goal, !PDInfo, !IO), - pd_util__propagate_constraints(!Goal, !PDInfo, !IO), + pd_util.propagate_constraints(!Goal, !PDInfo, !IO), - pd_debug__output_goal(!.PDInfo, "after constraints\n", !.Goal, !IO), + pd_debug_output_goal(!.PDInfo, "after constraints\n", !.Goal, !IO), deforest_goal(!Goal, !PDInfo, !IO), pd_info_get_proc_info(!.PDInfo, !:ProcInfo), @@ -251,7 +251,7 @@ deforest_proc_2(proc(PredId, ProcId), CostDelta, SizeDelta, !PDInfo, !IO) :- % Recompute the branch_info for the procedure. pd_info_get_proc_arg_info(!.PDInfo, ProcArgInfo0), - pd_util__get_branch_vars_proc(proc(PredId, ProcId), !.ProcInfo, + pd_util.get_branch_vars_proc(proc(PredId, ProcId), !.ProcInfo, ProcArgInfo0, ProcArgInfo, !ModuleInfo), pd_info_set_proc_arg_info(ProcArgInfo, !PDInfo), pd_info_set_module_info(!.ModuleInfo, !PDInfo) @@ -283,7 +283,7 @@ deforest_goal(conj(ConjType, !.Goals) - Info, conj(ConjType, !:Goals) - Info, partially_evaluate_conj_goals(!.Goals, [], !:Goals, !PDInfo, !IO), pd_info_set_instmap(InstMap0, !PDInfo), goal_info_get_nonlocals(Info, NonLocals), - globals__io_lookup_bool_option(deforestation, Deforestation, !IO), + globals.io_lookup_bool_option(deforestation, Deforestation, !IO), ( Deforestation = yes, compute_goal_infos(!Goals, !PDInfo), @@ -292,7 +292,7 @@ deforest_goal(conj(ConjType, !.Goals) - Info, conj(ConjType, !:Goals) - Info, ; Deforestation = no ), - globals__io_lookup_bool_option(constraint_propagation, Constraints, + globals.io_lookup_bool_option(constraint_propagation, Constraints, !IO), pd_info_set_instmap(InstMap0, !PDInfo), ( @@ -386,14 +386,14 @@ deforest_cases(Var, [case(ConsId, Goal0) | Cases0], pd_info::in, pd_info::out, io::di, io::uo) is det. partially_evaluate_conj_goals([], RevGoals, Goals, !PDInfo, !IO) :- - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). partially_evaluate_conj_goals([Goal0 | Goals0], RevGoals0, Goals, !PDInfo, !IO) :- deforest_goal(Goal0, Goal1, !PDInfo, !IO), pd_info_update_goal(Goal1, !PDInfo), ( Goal1 = conj(plain_conj, Goals1) - _ -> - list__reverse(Goals1, RevGoals1), - list__append(RevGoals1, RevGoals0, RevGoals2) + list.reverse(Goals1, RevGoals1), + list.append(RevGoals1, RevGoals0, RevGoals2) ; RevGoals2 = [Goal1 | RevGoals0] ), @@ -418,14 +418,14 @@ compute_goal_infos([Goal | Goals0], [Goal - MaybeBranchInfo | Goals], deforest_get_branch_vars_goal(Goal, MaybeBranchInfo, !PDInfo) :- Goal = GoalExpr - _, - ( goal_util__goal_is_branched(GoalExpr) -> - pd_util__get_branch_vars_goal(Goal, MaybeBranchInfo, !PDInfo) + ( goal_util.goal_is_branched(GoalExpr) -> + pd_util.get_branch_vars_goal(Goal, MaybeBranchInfo, !PDInfo) ; GoalExpr = call(PredId, ProcId, Args, _, _, _) -> pd_info_get_proc_arg_info(!.PDInfo, ProcBranchInfos), - ( map__search(ProcBranchInfos, proc(PredId, ProcId), BranchInfo0) -> + ( map.search(ProcBranchInfos, proc(PredId, ProcId), BranchInfo0) -> % Rename the branch_info for the called procedure % onto the argument variables. - pd_util__convert_branch_info(BranchInfo0, Args, BranchInfo), + pd_util.convert_branch_info(BranchInfo0, Args, BranchInfo), MaybeBranchInfo = yes(BranchInfo) ; MaybeBranchInfo = no @@ -441,7 +441,7 @@ deforest_get_branch_vars_goal(Goal, MaybeBranchInfo, !PDInfo) :- pd_info::in, pd_info::out, io::di, io::uo) is det. propagate_conj_constraints([], _, RevGoals, Goals, !PDInfo, !IO) :- - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). propagate_conj_constraints([Goal0 | Goals0], NonLocals, RevGoals0, Goals, !PDInfo, !IO) :- pd_info_get_module_info(!.PDInfo, ModuleInfo), @@ -451,14 +451,14 @@ propagate_conj_constraints([Goal0 | Goals0], Goal0 = call(PredId, _ProcId, _Args, _, _, SymName) - _, module_info_pred_info(ModuleInfo, PredId, PredInfo), \+ pred_info_is_imported(PredInfo), - list__takewhile((pred(CnstrGoal::in) is semidet :- + list.takewhile((pred(CnstrGoal::in) is semidet :- CnstrGoal = _ - CnstrGoalInfo, goal_info_has_feature(CnstrGoalInfo, constraint) ), Goals0, Constraints, Goals1), Constraints \= [] -> - mdbcomp__prim_data__sym_name_to_string(SymName, SymNameString), - pd_debug__message("propagating constraints into call to %s\n", + mdbcomp.prim_data.sym_name_to_string(SymName, SymNameString), + pd_debug_message("propagating constraints into call to %s\n", [s(SymNameString)], !IO), get_sub_conj_nonlocals(NonLocals, RevGoals0, [], @@ -493,7 +493,7 @@ propagate_conj_constraints([Goal0 | Goals0], pd_info::in, pd_info::out, io::di, io::uo) is det. deforest_conj([], _, RevGoals, Goals, !PDInfo, !IO) :- - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). deforest_conj([Goal0 - MaybeBranchInfo | Goals0], NonLocals, RevGoals0, RevGoals, !PDInfo, !IO) :- ( @@ -559,8 +559,8 @@ search_for_deforest_goal(EarlierGoal, EarlierBranchInfo, RevBetweenGoals0, potential_deforestation(EarlierBranchInfo, LaterBranchInfo, DeforestBranches) -> - list__reverse(RevBetweenGoals0, BetweenGoals1), - assoc_list__keys(BetweenGoals1, BetweenGoals), + list.reverse(RevBetweenGoals0, BetweenGoals1), + assoc_list.keys(BetweenGoals1, BetweenGoals), Goals = Goals0, DeforestInfo = deforest_info(EarlierGoal, EarlierBranchInfo, BetweenGoals, LaterGoal, LaterBranchInfo, DeforestBranches) @@ -580,19 +580,19 @@ potential_deforestation(Info1, Info2, DeforestBranches) :- Info1 = pd_branch_info(VarMap1, _, _), Info2 = pd_branch_info(_, LeftVars2, _), - map__select(VarMap1, LeftVars2, VarMap), - map__to_assoc_list(VarMap, VarAssoc), - \+ map__is_empty(VarMap), + map.select(VarMap1, LeftVars2, VarMap), + map.to_assoc_list(VarMap, VarAssoc), + \+ map.is_empty(VarMap), % Work out which branches of the first goal should contain % unfolded versions of the second goal. GetBranches = (pred(VarInfo::in, Branches0::in, Branches::out) is det :- VarInfo = _ - Branches1, - set__union(Branches0, Branches1, Branches) + set.union(Branches0, Branches1, Branches) ), - set__init(DeforestBranches0), - list__foldl(GetBranches, VarAssoc, + set.init(DeforestBranches0), + list.foldl(GetBranches, VarAssoc, DeforestBranches0, DeforestBranches). %-----------------------------------------------------------------------------% @@ -612,7 +612,7 @@ handle_deforestation(NonLocals, DeforestInfo0, !RevBeforeGoals, !AfterGoals, pd_info_get_created_versions(!.PDInfo, CreatedVersions0), pd_info_get_depth(!.PDInfo, Depth0), - pd_debug__message("checking for deforestation at depth %i\n", [i(Depth0)], + pd_debug_message("checking for deforestation at depth %i\n", [i(Depth0)], !IO), reorder_conj(DeforestInfo0, DeforestInfo, @@ -622,7 +622,7 @@ handle_deforestation(NonLocals, DeforestInfo0, !RevBeforeGoals, !AfterGoals, BeforeIrrelevant, AfterIrrelevant, !.AfterGoals, ConjNonLocals), % Update the instmap. - list__foldl(pd_info_update_goal, BeforeIrrelevant, !PDInfo), + list.foldl(pd_info_update_goal, BeforeIrrelevant, !PDInfo), pd_info_get_pred_proc_id(!.PDInfo, CurrPredProcId), pd_info_get_parents(!.PDInfo, Parents0), @@ -648,7 +648,7 @@ handle_deforestation(NonLocals, DeforestInfo0, !RevBeforeGoals, !AfterGoals, pd_info_get_module_info(!.PDInfo, ModuleInfo0), predicate_name(ModuleInfo0, PredId1, PredName1), predicate_name(ModuleInfo0, PredId2, PredName2), - pd_debug__message("deforesting calls to %s and %s\n", + pd_debug_message("deforesting calls to %s and %s\n", [s(PredName1), s(PredName2)], !IO), call_call(ConjNonLocals, EarlierGoal, BetweenGoals, yes(LaterGoal), MaybeGoal, !PDInfo, !IO), @@ -667,16 +667,16 @@ handle_deforestation(NonLocals, DeforestInfo0, !RevBeforeGoals, !AfterGoals, % call or a call to a predicate we have already pushed into a switch, % since it is difficult to stop the process. EarlierGoal = EarlierGoalExpr - _, - goal_util__goal_is_branched(EarlierGoalExpr), + goal_util.goal_is_branched(EarlierGoalExpr), LaterGoal = call(PredId, ProcId, _, _, _, _) - _, PredProcId = proc(PredId, ProcId), PredProcId \= CurrPredProcId, - \+ set__member(PredProcId, Parents0) + \+ set.member(PredProcId, Parents0) -> predicate_name(ModuleInfo, PredId, CurrPredName), - pd_debug__message("Pushing call to %s into goal\n", + pd_debug_message("Pushing call to %s into goal\n", [s(CurrPredName)], !IO), - set__insert(Parents0, proc(PredId, ProcId), Parents), + set.insert(Parents0, proc(PredId, ProcId), Parents), pd_info_set_parents(Parents, !PDInfo), push_goal_into_goal(ConjNonLocals, DeforestBranches, EarlierGoal, BetweenGoals, LaterGoal, Goal, !PDInfo, !IO), @@ -687,10 +687,10 @@ handle_deforestation(NonLocals, DeforestInfo0, !RevBeforeGoals, !AfterGoals, % of the first. EarlierGoal = EarlierGoalExpr - _, LaterGoal = LaterGoalExpr - _, - goal_util__goal_is_branched(EarlierGoalExpr), - goal_util__goal_is_branched(LaterGoalExpr) + goal_util.goal_is_branched(EarlierGoalExpr), + goal_util.goal_is_branched(LaterGoalExpr) -> - pd_debug__message("Pushing goal into goal\n", [], !IO), + pd_debug_message("Pushing goal into goal\n", [], !IO), push_goal_into_goal(ConjNonLocals, DeforestBranches, EarlierGoal, BetweenGoals, LaterGoal, Goal, !PDInfo, !IO), Goals = [Goal], @@ -701,7 +701,7 @@ handle_deforestation(NonLocals, DeforestInfo0, !RevBeforeGoals, !AfterGoals, pd_info_incr_size_delta(SizeDiff, !PDInfo), Optimized0 = yes ; - pd_debug__message("not optimizing\n", [], !IO), + pd_debug_message("not optimizing\n", [], !IO), Goals = [], Optimized0 = no ), @@ -725,24 +725,24 @@ handle_deforestation(NonLocals, DeforestInfo0, !RevBeforeGoals, !AfterGoals, % Remove any versions which were created. pd_info_get_created_versions(!.PDInfo, CreatedVersions), - set__difference(CreatedVersions, CreatedVersions0, NewVersions0), - set__to_sorted_list(NewVersions0, NewVersions), - list__foldl(pd_info__remove_version, NewVersions, !PDInfo) + set.difference(CreatedVersions, CreatedVersions0, NewVersions0), + set.to_sorted_list(NewVersions0, NewVersions), + list.foldl(pd_info.remove_version, NewVersions, !PDInfo) % AfterGoals will be restored properly in conj. ; Optimized = yes, % We want to reprocess the deforested goal to see if it can be % deforested with other goals later in the conjunction. - list__condense([BeforeIrrelevant, Goals, AfterIrrelevant], + list.condense([BeforeIrrelevant, Goals, AfterIrrelevant], GoalsToProcess), compute_goal_infos(GoalsToProcess, GoalsAndInfo, !PDInfo), - list__append(GoalsAndInfo, !AfterGoals), + list.append(GoalsAndInfo, !AfterGoals), pd_info_set_instmap(InstMap0, !PDInfo), pd_info_set_changed(yes, !PDInfo), pd_info_set_rerun_det(yes, !PDInfo) ), - pd_debug__message("finished deforestation at depth %i\n", [i(Depth0)], + pd_debug_message("finished deforestation at depth %i\n", [i(Depth0)], !IO), pd_info_set_parents(Parents0, !PDInfo). @@ -758,25 +758,25 @@ should_try_deforestation(DeforestInfo, ShouldTry, !PDInfo, !IO) :- ( EarlierGoal = call(PredId1, ProcId1, _, _, _, _) - _, LaterGoal = call(PredId2, ProcId2, _, _, _, _) - _, - set__member(proc(PredId1, ProcId1) - proc(PredId2, ProcId2), + set.member(proc(PredId1, ProcId1) - proc(PredId2, ProcId2), UselessVersions) -> - pd_debug__message("version tried before, not worthwhile\n", [], !IO), + pd_debug_message("version tried before, not worthwhile\n", [], !IO), ShouldTry = no ; - % If some later goal depends on a variable such as an io__state + % If some later goal depends on a variable such as an io.state % for which the construction cannot be reversed, recursive % folding will be impossible, so give up on the optimization. EarlierBranchInfo = pd_branch_info(_, _, OpaqueVars), - ( list__member(OpaqueGoal, BetweenGoals) + ( list.member(OpaqueGoal, BetweenGoals) ; OpaqueGoal = LaterGoal ), OpaqueGoal = _ - OpaqueGoalInfo, goal_info_get_nonlocals(OpaqueGoalInfo, OpaqueNonLocals), - set__intersect(OpaqueNonLocals, OpaqueVars, UsedOpaqueVars), - \+ set__empty(UsedOpaqueVars) + set.intersect(OpaqueNonLocals, OpaqueVars, UsedOpaqueVars), + \+ set.empty(UsedOpaqueVars) -> - pd_debug__message("later goals depend on opaque vars\n", [], !IO), + pd_debug_message("later goals depend on opaque vars\n", [], !IO), ShouldTry = no ; ShouldTry = yes @@ -789,14 +789,14 @@ should_try_deforestation(DeforestInfo, ShouldTry, !PDInfo, !IO) :- can_optimize_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, ShouldTry, !PDInfo, !IO) :- pd_info_get_pred_info(!.PDInfo, PredInfo), - globals__io_lookup_option(deforestation_depth_limit, DepthLimitOpt, !IO), + globals.io_lookup_option(deforestation_depth_limit, DepthLimitOpt, !IO), pd_info_get_depth(!.PDInfo, Depth0), Depth = Depth0 + 1, pd_info_set_depth(Depth, !PDInfo), - globals__io_lookup_int_option(deforestation_size_threshold, SizeLimit, + globals.io_lookup_int_option(deforestation_size_threshold, SizeLimit, !IO), pd_info_get_module_info(!.PDInfo, ModuleInfo), - globals__io_lookup_option(fully_strict, FullyStrictOp, !IO), + globals.io_lookup_option(fully_strict, FullyStrictOp, !IO), ( DepthLimitOpt = int(MaxDepth), MaxDepth \= -1, % no depth limit set @@ -804,7 +804,7 @@ can_optimize_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, ShouldTry, -> % The depth limit was exceeded. This should not occur too often in % practice - the depth limit is just a safety net. - pd_debug__message("\n\n*****Depth limit exceeded*****\n\n", [], !IO), + pd_debug_message("\n\n*****Depth limit exceeded*****\n\n", [], !IO), ShouldTry = no ; % Check whether either of the goals to be deforested is too large. @@ -823,7 +823,7 @@ can_optimize_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, ShouldTry, SizeLimit \= -1, CalledGoalSize > SizeLimit -> - pd_debug__message("goal too large\n", [], !IO), + pd_debug_message("goal too large\n", [], !IO), ShouldTry = no ; % Check whether either of the goals to be deforested can't be inlined. @@ -837,10 +837,10 @@ can_optimize_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, ShouldTry, % XXX We should probably allow deforestation of semipure goals. InlinePromisedPure = no, pred_info_get_markers(PredInfo, CallerMarkers), - \+ inlining__can_inline_proc(PredId, ProcId, BuiltinState, + \+ inlining.can_inline_proc(PredId, ProcId, BuiltinState, InlinePromisedPure, CallerMarkers, ModuleInfo) -> - pd_debug__message("non-inlineable calls\n", [], !IO), + pd_debug_message("non-inlineable calls\n", [], !IO), ShouldTry = no ; % @@ -849,19 +849,19 @@ can_optimize_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, ShouldTry, % \+ is_simple_goal_list(BetweenGoals) -> - pd_debug__message("between goals not simple enough\n", [], !IO), + pd_debug_message("between goals not simple enough\n", [], !IO), ShouldTry = no ; % Give up if there are any impure goals involved. % XXX We should probably allow deforestation of semipure goals. - ( list__member(ImpureGoal, BetweenGoals) + ( list.member(ImpureGoal, BetweenGoals) ; ImpureGoal = EarlierGoal ; MaybeLaterGoal = yes(ImpureGoal) ), ImpureGoal = _ - ImpureGoalInfo, \+ goal_info_is_pure(ImpureGoalInfo) -> - pd_debug__message("goal list contains impure goal(s)\n", [], !IO), + pd_debug_message("goal list contains impure goal(s)\n", [], !IO), ShouldTry = no ; % Check whether interleaving the execution of the goals could alter @@ -869,13 +869,13 @@ can_optimize_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, ShouldTry, % semantics options. % FullyStrictOp = bool(FullyStrict), - ( list__member(OtherGoal, BetweenGoals) + ( list.member(OtherGoal, BetweenGoals) ; MaybeLaterGoal = yes(LaterGoal), OtherGoal = LaterGoal ), - \+ goal_util__reordering_maintains_termination(ModuleInfo, + \+ goal_util.reordering_maintains_termination(ModuleInfo, FullyStrict, EarlierGoal, OtherGoal) -> - pd_debug__message("interleaving execution could change " ++ + pd_debug_message("interleaving execution could change " ++ "termination behaviour\n", [], !IO), ShouldTry = no ; @@ -896,18 +896,18 @@ check_improvement(Optimized0, CostDelta0, SizeDelta0, Optimized, PDInfo, pd_info_get_size_delta(PDInfo, SizeDelta), Improvement = CostDelta - CostDelta0, SizeDifference = SizeDelta - SizeDelta0, - globals__io_lookup_int_option(deforestation_cost_factor, Factor, !IO), + globals.io_lookup_int_option(deforestation_cost_factor, Factor, !IO), ( Optimized0 = yes, check_deforestation_improvement(Factor, Improvement, SizeDifference) -> Optimized = yes, - pd_debug__message("Enough improvement: cost(%i) size(%i)\n", + pd_debug_message("Enough improvement: cost(%i) size(%i)\n", [i(Improvement), i(SizeDifference)], !IO) ; Optimized = no, - pd_debug__message( + pd_debug_message( "Not enough improvement: cost(%i) size(%i)\n", [i(Improvement), i(SizeDifference)], !IO) ). @@ -944,7 +944,7 @@ call_call_2(ConjNonLocals, EarlierGoal, BetweenGoals, create_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, ConjNonLocals, FoldGoal), - pd_info__search_version(!.PDInfo, FoldGoal, MaybeVersion, !IO), + pd_info.search_version(!.PDInfo, FoldGoal, MaybeVersion, !IO), pd_info_get_parent_versions(!.PDInfo, Parents), ( MaybeVersion = version(_, VersionPredProcId, @@ -954,11 +954,11 @@ call_call_2(ConjNonLocals, EarlierGoal, BetweenGoals, VersionPredProcId = proc(VersionPredId, _), pd_info_get_module_info(!.PDInfo, ModuleInfo0), predicate_name(ModuleInfo0, VersionPredId, FoldPredName), - pd_debug__message("Folded with %s\n", [s(FoldPredName)], !IO), - ( set__member(VersionPredProcId, Parents) -> - pd_cost__recursive_fold(FoldCostDelta) + pd_debug_message("Folded with %s\n", [s(FoldPredName)], !IO), + ( set.member(VersionPredProcId, Parents) -> + FoldCostDelta = cost_of_recursive_fold ; - pd_cost__fold(FoldCostDelta) + FoldCostDelta = cost_of_fold ), pd_info_incr_cost_delta(FoldCostDelta, !PDInfo), goals_size([EarlierGoal | BetweenGoals], NegSizeDelta), @@ -971,19 +971,19 @@ call_call_2(ConjNonLocals, EarlierGoal, BetweenGoals, pd_info_get_global_term_info(!.PDInfo, TermInfo0), pd_info_get_parent_versions(!.PDInfo, ParentVersions0), - pd_debug__do_io(io__write_string("Parents: "), !IO), - pd_debug__write(ParentVersions0, !IO), - pd_debug__do_io(io__nl, !IO), + pd_debug_do_io(io.write_string("Parents: "), !IO), + pd_debug_write(ParentVersions0, !IO), + pd_debug_do_io(io.nl, !IO), pd_info_get_module_info(!.PDInfo, ModuleInfo), pd_info_get_versions(!.PDInfo, Versions), pd_info_get_instmap(!.PDInfo, InstMap), - pd_term__global_check(ModuleInfo, EarlierGoal, BetweenGoals, + pd_term.global_check(ModuleInfo, EarlierGoal, BetweenGoals, MaybeLaterGoal, InstMap, Versions, TermInfo0, TermInfo, CheckResult), ( CheckResult = ok(ProcPair, Size), - pd_debug__message("global termination check succeeded - " ++ + pd_debug_message("global termination check succeeded - " ++ "creating new version\n", [], !IO), pd_info_set_global_term_info(TermInfo, !PDInfo), RunModes = no, @@ -1003,7 +1003,7 @@ call_call_2(ConjNonLocals, EarlierGoal, BetweenGoals, CoveringPredProcId, MaybeGoal, !PDInfo, !IO) ; CheckResult = loop, - pd_debug__message("global termination check failed\n", [], !IO), + pd_debug_message("global termination check failed\n", [], !IO), MaybeGoal = no ), pd_info_set_global_term_info(TermInfo0, !PDInfo) @@ -1024,7 +1024,7 @@ create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, FoldGoal0, NonLocals, RunModes, ProcPair, Size, MaybeGeneralised, MaybeCallGoal, !PDInfo, !IO) :- pd_info_get_module_info(!.PDInfo, ModuleInfo0), - globals__io_lookup_int_option(deforestation_vars_threshold, VarsOpt, !IO), + globals.io_lookup_int_option(deforestation_vars_threshold, VarsOpt, !IO), ( EarlierGoal = call(PredId1, ProcId1, Args1, _, _, _) - _, ( @@ -1041,14 +1041,14 @@ create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, module_info_pred_proc_info(ModuleInfo0, PredId1, ProcId1, _, CalledProcInfo1), proc_info_goal(CalledProcInfo1, CalledGoal1), - goal_util__goal_vars(CalledGoal1, GoalVars1), - set__to_sorted_list(GoalVars1, GoalVarsList1), - set__init(GoalVars2), - goal_util__goals_goal_vars(BetweenGoals, GoalVars2, GoalVars3), - set__to_sorted_list(GoalVars3, GoalVarsList3), + goal_util.goal_vars(CalledGoal1, GoalVars1), + set.to_sorted_list(GoalVars1, GoalVarsList1), + set.init(GoalVars2), + goal_util.goals_goal_vars(BetweenGoals, GoalVars2, GoalVars3), + set.to_sorted_list(GoalVars3, GoalVarsList3), - list__length(GoalVarsList1, NumVars1), - list__length(GoalVarsList3, NumVars3), + list.length(GoalVarsList1, NumVars1), + list.length(GoalVarsList3, NumVars3), NumVars = NumVars1 + NumVars3, NumVars < VarsOpt ) @@ -1058,13 +1058,13 @@ create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, pd_info_get_instmap(!.PDInfo, InstMap0), pd_info_get_proc_info(!.PDInfo, ProcInfo0), - pd_debug__message("unfolding first call\n", [], !IO), + pd_debug_message("unfolding first call\n", [], !IO), unfold_call(no, no, PredId1, ProcId1, Args1, EarlierGoal, UnfoldedCall, DidUnfold, !PDInfo, !IO), create_conj(UnfoldedCall, BetweenGoals, MaybeLaterGoal, NonLocals, DeforestGoal0), - set__to_sorted_list(NonLocals, NonLocalsList), + set.to_sorted_list(NonLocals, NonLocalsList), ( DidUnfold = yes, @@ -1078,12 +1078,12 @@ create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, % to a particular functor but the extra information was % generalised away. - pd_debug__message("running modes on deforest goal\n", [], !IO), - pd_util__unique_modecheck_goal(DeforestGoal0, + pd_debug_message("running modes on deforest goal\n", [], !IO), + pd_util.unique_modecheck_goal(DeforestGoal0, DeforestGoal, Errors1, !PDInfo, !IO), - pd_util__unique_modecheck_goal(FoldGoal0, FoldGoal, + pd_util.unique_modecheck_goal(FoldGoal0, FoldGoal, Errors2, !PDInfo, !IO), - list__append(Errors1, Errors2, Errors) + list.append(Errors1, Errors2, Errors) ; DeforestGoal = DeforestGoal0, FoldGoal = FoldGoal0, @@ -1099,14 +1099,14 @@ create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, -> % Create the new version. - pd_info__define_new_pred(created(deforestation), + pd_info.define_new_pred(created(deforestation), DeforestGoal, PredProcId, CallGoal, !PDInfo), PredProcId = proc(PredId, _), pd_info_get_module_info(!.PDInfo, ModuleInfo), predicate_name(ModuleInfo, PredId, PredName), - pd_debug__message("\nCreated predicate %s\n", [s(PredName)], !IO), + pd_debug_message("\nCreated predicate %s\n", [s(PredName)], !IO), ( MaybeLaterGoal = yes(call(PredId2, ProcId2, _, _, _, _) - _) -> CalledPreds = [proc(PredId1, ProcId1), proc(PredId2, ProcId2)] ; @@ -1116,16 +1116,16 @@ create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, pd_info_get_proc_info(!.PDInfo, ProcInfo1), proc_info_vartypes(ProcInfo1, VarTypes), - map__apply_to_list(NonLocalsList, VarTypes, ArgTypes), + map.apply_to_list(NonLocalsList, VarTypes, ArgTypes), VersionInfo = version_info(FoldGoal, CalledPreds, NonLocalsList, ArgTypes, InstMap0, 0, 0, Parents0, MaybeGeneralised), pd_info_get_global_term_info(!.PDInfo, TermInfo0), - pd_term__update_global_term_info(ProcPair, PredProcId, + pd_term.update_global_term_info(ProcPair, PredProcId, Size, TermInfo0, TermInfo), pd_info_set_global_term_info(TermInfo, !PDInfo), - set__insert_list(Parents0, [PredProcId | CalledPreds], Parents), + set.insert_list(Parents0, [PredProcId | CalledPreds], Parents), pd_info_set_parent_versions(Parents, !PDInfo), - pd_info__register_version(PredProcId, VersionInfo, !PDInfo, !IO), + pd_info.register_version(PredProcId, VersionInfo, !PDInfo, !IO), % Run deforestation on the new predicate to do the folding. pd_info_get_unfold_info(!.PDInfo, UnfoldInfo), @@ -1139,7 +1139,7 @@ create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, CurrPredId, CurrProcId, ModuleInfo, !IO), MaybeCallGoal = yes(CallGoal) ; - pd_debug__message("Generalisation produced mode errors\n", [], + pd_debug_message("Generalisation produced mode errors\n", [], !IO), MaybeCallGoal = no ), @@ -1150,7 +1150,7 @@ create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, pd_info_set_proc_info(ProcInfo0, !PDInfo), pd_info_set_instmap(InstMap0, !PDInfo) ; - pd_debug__message("vars threshold exceeded\n", [], !IO), + pd_debug_message("vars threshold exceeded\n", [], !IO), MaybeCallGoal = no ). @@ -1195,7 +1195,7 @@ create_call_goal(proc(PredId, ProcId), VersionInfo, proc_info_argmodes(CalledProcInfo, ArgModes), instmap_delta_from_mode_list(Args, ArgModes, ModuleInfo, InstMapDelta), proc_info_interface_determinism(ProcInfo, Detism), - set__list_to_set(Args, NonLocals), + set.list_to_set(Args, NonLocals), pred_info_get_purity(CalledPredInfo, Purity), goal_info_init(NonLocals, InstMapDelta, Detism, Purity, GoalInfo), @@ -1216,13 +1216,13 @@ create_deforest_call_args([_|_], [], _, _, _, !VarSet, !VarTypes) :- unexpected(this_file, "create_deforest_call_args: length mismatch"). create_deforest_call_args([OldArg | OldArgs], [ArgType | ArgTypes], Renaming, TypeSubn, [Arg | Args], !VarSet, !VarTypes) :- - ( map__search(Renaming, OldArg, Arg0) -> + ( map.search(Renaming, OldArg, Arg0) -> Arg = Arg0 ; % The variable is local to the call. Create a fresh variable. - varset__new_var(!.VarSet, Arg, !:VarSet), + varset.new_var(!.VarSet, Arg, !:VarSet), apply_subst_to_type(TypeSubn, ArgType, SubnArgType), - map__det_insert(!.VarTypes, Arg, SubnArgType, !:VarTypes) + map.det_insert(!.VarTypes, Arg, SubnArgType, !:VarTypes) ), create_deforest_call_args(OldArgs, ArgTypes, Renaming, TypeSubn, Args, !VarSet, !VarTypes). @@ -1238,7 +1238,7 @@ create_deforest_call_args([OldArg | OldArgs], [ArgType | ArgTypes], create_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, NonLocals, FoldGoal) :- ( MaybeLaterGoal = yes(LaterGoal), - list__append([EarlierGoal | BetweenGoals], [LaterGoal], DeforestConj) + list.append([EarlierGoal | BetweenGoals], [LaterGoal], DeforestConj) ; MaybeLaterGoal = no, DeforestConj = [EarlierGoal | BetweenGoals] @@ -1270,9 +1270,9 @@ create_conj(EarlierGoal, BetweenGoals, MaybeLaterGoal, NonLocals, FoldGoal) :- try_generalisation(EarlierGoal, BetweenGoals, MaybeLaterGoal, FoldGoal, ConjNonLocals, ProcPair, Size, CoveringPredProcId, MaybeGoal, !PDInfo, !IO) :- - pd_debug__message("trying generalisation\n", [], !IO), + pd_debug_message("trying generalisation\n", [], !IO), pd_info_get_versions(!.PDInfo, VersionIndex), - map__lookup(VersionIndex, CoveringPredProcId, Version), + map.lookup(VersionIndex, CoveringPredProcId, Version), pd_info_get_module_info(!.PDInfo, ModuleInfo), Version = version_info(VersionGoal, _, VersionArgs, VersionArgTypes, VersionInstMap, _, _, _, _), @@ -1280,7 +1280,7 @@ try_generalisation(EarlierGoal, BetweenGoals, MaybeLaterGoal, pd_info_get_proc_info(!.PDInfo, ProcInfo), proc_info_vartypes(ProcInfo, VarTypes), ( - pd_util__goals_match(ModuleInfo, VersionGoal, VersionArgs, + pd_util.goals_match(ModuleInfo, VersionGoal, VersionArgs, VersionArgTypes, FoldGoal, VarTypes, Renaming, _) -> do_generalisation(VersionArgs, Renaming, VersionInstMap, @@ -1297,12 +1297,12 @@ try_generalisation(EarlierGoal, BetweenGoals, MaybeLaterGoal, MaybeLaterGoal, ConjNonLocals, VarSet, VarTypes, Versions, Renaming) -> - pd_debug__message("matched with generalised version\n", [], !IO), + pd_debug_message("matched with generalised version\n", [], !IO), do_generalisation(VersionArgs, Renaming, VersionInstMap, EarlierGoal, BetweenGoals, MaybeLaterGoal, FoldGoal, ConjNonLocals, ProcPair, Size, CoveringPredProcId, MaybeGoal, !PDInfo, !IO) ; - pd_debug__message("goals don't match\n", [], !IO), + pd_debug_message("goals don't match\n", [], !IO), MaybeGoal = no ). @@ -1316,28 +1316,28 @@ try_generalisation(EarlierGoal, BetweenGoals, MaybeLaterGoal, do_generalisation(VersionArgs, Renaming, VersionInstMap, EarlierGoal, BetweenGoals, MaybeLaterGoal, FoldGoal, ConjNonLocals, ProcPair, Size, Generalised, MaybeGoal, !PDInfo, !IO) :- - pd_debug__message("goals match, trying MSG\n", [], !IO), + pd_debug_message("goals match, trying MSG\n", [], !IO), pd_info_get_module_info(!.PDInfo, ModuleInfo), pd_info_get_instmap(!.PDInfo, InstMap0), - instmap__lookup_vars(VersionArgs, VersionInstMap, VersionInsts), - pd_util__inst_list_size(ModuleInfo, VersionInsts, VersionInstSizes), - set__to_sorted_list(ConjNonLocals, ConjNonLocalsList), + instmap.lookup_vars(VersionArgs, VersionInstMap, VersionInsts), + pd_util.inst_list_size(ModuleInfo, VersionInsts, VersionInstSizes), + set.to_sorted_list(ConjNonLocals, ConjNonLocalsList), ( % Check whether we can do a most specific generalisation of insts % of the non-locals. try_MSG(ModuleInfo, VersionInstMap, VersionArgs, Renaming, InstMap0, InstMap), - instmap__lookup_vars(ConjNonLocalsList, InstMap, ArgInsts), - pd_util__inst_list_size(ModuleInfo, ArgInsts, NewInstSizes), + instmap.lookup_vars(ConjNonLocalsList, InstMap, ArgInsts), + pd_util.inst_list_size(ModuleInfo, ArgInsts, NewInstSizes), NewInstSizes < VersionInstSizes -> - pd_debug__message("MSG succeeded", [], !IO), + pd_debug_message("MSG succeeded", [], !IO), pd_info_set_instmap(InstMap, !PDInfo), create_deforest_goal(EarlierGoal, BetweenGoals, MaybeLaterGoal, FoldGoal, ConjNonLocals, yes, ProcPair, Size, yes(Generalised), MaybeGoal, !PDInfo, !IO) ; - pd_debug__message("MSG failed\n", [], !IO), + pd_debug_message("MSG failed\n", [], !IO), MaybeGoal = no ), pd_info_set_instmap(InstMap0, !PDInfo). @@ -1348,13 +1348,13 @@ do_generalisation(VersionArgs, Renaming, VersionInstMap, EarlierGoal, try_MSG(_, _, [], _, !InstMap). try_MSG(ModuleInfo, VersionInstMap, [VersionArg | VersionArgs], Renaming, !InstMap) :- - instmap__lookup_var(VersionInstMap, VersionArg, VersionInst), + instmap.lookup_var(VersionInstMap, VersionArg, VersionInst), ( - map__search(Renaming, VersionArg, Arg), - instmap__lookup_var(!.InstMap, Arg, VarInst), + map.search(Renaming, VersionArg, Arg), + instmap.lookup_var(!.InstMap, Arg, VarInst), inst_MSG(VersionInst, VarInst, ModuleInfo, Inst) -> - instmap__set(Arg, Inst, !InstMap) + instmap.set(Arg, Inst, !InstMap) ; true ), @@ -1388,24 +1388,24 @@ match_generalised_version(ModuleInfo, VersionGoal, VersionArgs, FirstGoal = call(FirstPredId, FirstProcId, FirstArgs, _, _, _) - _, % Look up the version which the first goal calls. - map__search(Versions, proc(FirstPredId, FirstProcId), FirstVersionInfo), + map.search(Versions, proc(FirstPredId, FirstProcId), FirstVersionInfo), FirstVersionInfo = version_info(FirstVersionGoal, _, FirstVersionArgs, _, _, _, _, _, MaybeNonGeneralisedVersion), MaybeNonGeneralisedVersion = yes(NonGeneralisedPredProcId), - map__from_corresponding_lists(FirstVersionArgs, FirstArgs, FirstRenaming0), + map.from_corresponding_lists(FirstVersionArgs, FirstArgs, FirstRenaming0), - goal_util__goal_vars(FirstVersionGoal, FirstVersionVars0), - set__to_sorted_list(FirstVersionVars0, FirstVersionVars), + goal_util.goal_vars(FirstVersionGoal, FirstVersionVars0), + set.to_sorted_list(FirstVersionVars0, FirstVersionVars), module_info_pred_proc_info(ModuleInfo, FirstPredId, FirstProcId, _, FirstProcInfo), proc_info_varset(FirstProcInfo, FirstVersionVarSet), proc_info_vartypes(FirstProcInfo, FirstVersionVarTypes), - goal_util__create_variables(FirstVersionVars, + goal_util.create_variables(FirstVersionVars, FirstVersionVarSet, FirstVersionVarTypes, !VarSet, !VarTypes, FirstRenaming0, FirstRenaming), - goal_util__must_rename_vars_in_goal(FirstRenaming, + goal_util.must_rename_vars_in_goal(FirstRenaming, FirstVersionGoal, RenamedFirstVersionGoal), % Look up the version which was generalised to create the version @@ -1418,11 +1418,11 @@ match_generalised_version(ModuleInfo, VersionGoal, VersionArgs, % Find a renaming from the argument variables of the generalised % version to the version which was generalised. - map__search(Versions, NonGeneralisedPredProcId, + map.search(Versions, NonGeneralisedPredProcId, NonGeneralisedVersion), NonGeneralisedVersion = version_info(NonGeneralisedGoal, _, NonGeneralisedArgs, NonGeneralisedArgTypes,_,_,_,_,_), - pd_util__goals_match(ModuleInfo, NonGeneralisedGoal, + pd_util.goals_match(ModuleInfo, NonGeneralisedGoal, NonGeneralisedArgs, NonGeneralisedArgTypes, RenamedFirstVersionGoal, !.VarTypes, GeneralRenaming, TypeRenaming), @@ -1433,7 +1433,7 @@ match_generalised_version(ModuleInfo, VersionGoal, VersionArgs, NonGeneralisedArgTypes, GeneralRenaming, TypeRenaming, NewArgs, !.VarSet, _, !.VarTypes, _), - % Only fill in as much as pd_util__goals_match actually looks at. + % Only fill in as much as pd_util.goals_match actually looks at. goal_info_init(GoalInfo), NonGeneralFirstGoal = call(NonGeneralisedPredId, NonGeneralisedProcId, NewArgs, not_builtin, no, unqualified("")) - GoalInfo, @@ -1441,7 +1441,7 @@ match_generalised_version(ModuleInfo, VersionGoal, VersionArgs, ConjNonLocals, GoalToMatch), % Check whether the entire conjunction matches. - pd_util__goals_match(ModuleInfo, VersionGoal, VersionArgs, + pd_util.goals_match(ModuleInfo, VersionGoal, VersionArgs, VersionArgTypes, GoalToMatch, !.VarTypes, Renaming, _). %-----------------------------------------------------------------------------% @@ -1460,7 +1460,7 @@ get_sub_conj_nonlocals(NonLocals0, DeforestInfo, AfterGoals0, SubConjNonLocals) :- DeforestInfo = deforest_info(EarlierGoal, _, BetweenGoals, LaterGoal, _, _), - assoc_list__keys(AfterGoals0, AfterGoals), + assoc_list.keys(AfterGoals0, AfterGoals), get_sub_conj_nonlocals(NonLocals0, RevBeforeGoals, BeforeIrrelevant, EarlierGoal, BetweenGoals, yes(LaterGoal), AfterIrrelevant, AfterGoals, SubConjNonLocals). @@ -1476,21 +1476,21 @@ get_sub_conj_nonlocals(!.NonLocals, RevBeforeGoals, BeforeIrrelevant, AddGoalNonLocals = (pred(Goal::in, Vars0::in, Vars::out) is det :- Goal = _ - GoalInfo, goal_info_get_nonlocals(GoalInfo, GoalNonLocals), - set__union(Vars0, GoalNonLocals, Vars) + set.union(Vars0, GoalNonLocals, Vars) ), - list__foldl(AddGoalNonLocals, RevBeforeGoals, !NonLocals), - list__foldl(AddGoalNonLocals, BeforeIrrelevant, !NonLocals), - list__foldl(AddGoalNonLocals, AfterIrrelevant, !NonLocals), - list__foldl(AddGoalNonLocals, AfterGoals, !NonLocals), + list.foldl(AddGoalNonLocals, RevBeforeGoals, !NonLocals), + list.foldl(AddGoalNonLocals, BeforeIrrelevant, !NonLocals), + list.foldl(AddGoalNonLocals, AfterIrrelevant, !NonLocals), + list.foldl(AddGoalNonLocals, AfterGoals, !NonLocals), - list__foldl(AddGoalNonLocals, [EarlierGoal | BetweenGoals], - set__init, !:SubConjNonLocals), + list.foldl(AddGoalNonLocals, [EarlierGoal | BetweenGoals], + set.init, !:SubConjNonLocals), ( MaybeLaterGoal = yes(LaterGoal) -> call(AddGoalNonLocals, LaterGoal, !SubConjNonLocals) ; true ), - set__intersect(!.NonLocals, !SubConjNonLocals). + set.intersect(!.NonLocals, !SubConjNonLocals). %-----------------------------------------------------------------------------% @@ -1505,21 +1505,21 @@ get_sub_conj_nonlocals(!.NonLocals, RevBeforeGoals, BeforeIrrelevant, reorder_conj(DeforestInfo0, DeforestInfo, BeforeIrrelevant, AfterIrrelevant, PDInfo, !IO) :- - pd_debug__message("Reordering conjunction\n", [], !IO), + pd_debug_message("Reordering conjunction\n", [], !IO), DeforestInfo0 = deforest_info(EarlierGoal, EarlierBranchInfo, BetweenGoals0, LaterGoal, LaterBranchInfo, DeforestBranches), pd_info_get_module_info(PDInfo, ModuleInfo), - globals__io_lookup_bool_option(fully_strict, FullyStrict, !IO), + globals.io_lookup_bool_option(fully_strict, FullyStrict, !IO), - move_goals(deforest__can_move_goal_backward, ModuleInfo, + move_goals(deforest.can_move_goal_backward, ModuleInfo, FullyStrict, BetweenGoals0, [], RevBetweenGoals1, EarlierGoal, [], RevBeforeIrrelevant), - move_goals(deforest__can_move_goal_forward, + move_goals(deforest.can_move_goal_forward, ModuleInfo, FullyStrict, RevBetweenGoals1, [], BetweenGoals, LaterGoal, [], AfterIrrelevant), - list__reverse(RevBeforeIrrelevant, BeforeIrrelevant), + list.reverse(RevBeforeIrrelevant, BeforeIrrelevant), DeforestInfo = deforest_info(EarlierGoal, EarlierBranchInfo, BetweenGoals, LaterGoal, LaterBranchInfo, DeforestBranches). @@ -1554,8 +1554,8 @@ move_goals(CanMove, ModuleInfo, FullyStrict, [BetweenGoal | RevBetweenGoals0], can_move_goal_forward(ModuleInfo, FullyStrict, ThisGoal, Goals) :- \+ ( - list__member(LaterGoal, Goals), - \+ pd_util__can_reorder_goals(ModuleInfo, FullyStrict, + list.member(LaterGoal, Goals), + \+ pd_util.can_reorder_goals(ModuleInfo, FullyStrict, ThisGoal, LaterGoal) ). @@ -1567,8 +1567,8 @@ can_move_goal_forward(ModuleInfo, FullyStrict, ThisGoal, Goals) :- can_move_goal_backward(ModuleInfo, FullyStrict, ThisGoal, Goals) :- \+ ( - list__member(EarlierGoal, Goals), - \+ pd_util__can_reorder_goals(ModuleInfo, FullyStrict, + list.member(EarlierGoal, Goals), + \+ pd_util.can_reorder_goals(ModuleInfo, FullyStrict, EarlierGoal, ThisGoal) ). @@ -1587,7 +1587,7 @@ push_goal_into_goal(NonLocals, DeforestInfo, EarlierGoal, pd_info_get_instmap(!.PDInfo, InstMap0), EarlierGoal = EarlierGoalExpr - _, ( EarlierGoalExpr = switch(Var1, CanFail1, Cases1) -> - set__insert(NonLocals, Var1, CaseNonLocals), + set.insert(NonLocals, Var1, CaseNonLocals), append_goal_to_cases(Var1, BetweenGoals, LaterGoal, CaseNonLocals, 1, DeforestInfo, Cases1, Cases, !PDInfo, !IO), GoalExpr = switch(Var1, CanFail1, Cases) @@ -1595,7 +1595,7 @@ push_goal_into_goal(NonLocals, DeforestInfo, EarlierGoal, pd_info_update_goal(Cond, !PDInfo), Cond = _ - CondInfo, goal_info_get_nonlocals(CondInfo, CondNonLocals), - set__union(CondNonLocals, NonLocals, ThenNonLocals), + set.union(CondNonLocals, NonLocals, ThenNonLocals), append_goal(Then0, BetweenGoals, LaterGoal, ThenNonLocals, 1, DeforestInfo, Then, !PDInfo, !IO), pd_info_set_instmap(InstMap0, !PDInfo), @@ -1626,12 +1626,12 @@ push_goal_into_goal(NonLocals, DeforestInfo, EarlierGoal, pd_info_get_module_info(!.PDInfo, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - simplify__find_simplifications(no, Globals, Simplifications0), + simplify.find_simplifications(no, Globals, Simplifications0), % Be a bit more aggressive with common structure elimination. % This helps achieve folding in some cases. Simplifications = [extra_common_struct | Simplifications0], - pd_util__simplify_goal(Simplifications, Goal2, Goal3, !PDInfo, !IO), + pd_util.simplify_goal(Simplifications, Goal2, Goal3, !PDInfo, !IO), pd_info_set_instmap(InstMap0, !PDInfo), % Perform any folding which may now be possible. @@ -1639,9 +1639,8 @@ push_goal_into_goal(NonLocals, DeforestInfo, EarlierGoal, pd_info_set_instmap(InstMap0, !PDInfo). :- pred append_goal_to_disjuncts(hlds_goals::in, hlds_goal::in, - set(prog_var)::in, int::in, set(int)::in, - hlds_goals::in, hlds_goals::out, pd_info::in, pd_info::out, - io::di, io::uo) is det. + set(prog_var)::in, int::in, set(int)::in, hlds_goals::in, hlds_goals::out, + pd_info::in, pd_info::out, io::di, io::uo) is det. append_goal_to_disjuncts(_, _, _, _, _, [], [], !PDInfo, !IO). append_goal_to_disjuncts(BetweenGoals, GoalToAppend, NonLocals, @@ -1679,11 +1678,10 @@ append_goal_to_cases(Var, BetweenGoals, GoalToAppend, NonLocals, append_goal(Goal0, BetweenGoals, GoalToAppend0, NonLocals0, CurrBranch, Branches, Goal, !PDInfo, !IO) :- - ( set__member(CurrBranch, Branches) -> + ( set.member(CurrBranch, Branches) -> % Unfold the call. pd_info_get_instmap(!.PDInfo, InstMap0), - list__foldl(pd_info_update_goal, [Goal0 | BetweenGoals], - !PDInfo), + list.foldl(pd_info_update_goal, [Goal0 | BetweenGoals], !PDInfo), deforest_goal(GoalToAppend0, GoalToAppend, !PDInfo, !IO), pd_info_set_instmap(InstMap0, !PDInfo) ; @@ -1691,10 +1689,10 @@ append_goal(Goal0, BetweenGoals, GoalToAppend0, ), goal_to_conj_list(Goal0, GoalList0), goal_to_conj_list(GoalToAppend, GoalListToAppend), - list__condense([GoalList0, BetweenGoals, GoalListToAppend], Goals), + list.condense([GoalList0, BetweenGoals, GoalListToAppend], Goals), goal_list_nonlocals(Goals, SubNonLocals), - set__intersect(NonLocals0, SubNonLocals, NonLocals), + set.intersect(NonLocals0, SubNonLocals, NonLocals), goal_list_instmap_delta(Goals, Delta0), instmap_delta_restrict(NonLocals, Delta0, Delta), goal_list_determinism(Goals, Detism), @@ -1715,23 +1713,23 @@ deforest_call(PredId, ProcId, Args, SymName, BuiltinState, Goal0, Goal, pd_info_get_module_info(!.PDInfo, ModuleInfo), pd_info_get_instmap(!.PDInfo, InstMap), unqualify_name(SymName, Name), - list__length(Args, Arity), + list.length(Args, Arity), Goal0 = GoalExpr0 - GoalInfo0, goal_info_get_context(GoalInfo0, Context), pd_info_get_local_term_info(!.PDInfo, LocalTermInfo0), pd_info_get_pred_info(!.PDInfo, PredInfo), - globals__io_lookup_int_option(deforestation_size_threshold, + globals.io_lookup_int_option(deforestation_size_threshold, SizeThreshold, !IO), pred_info_get_markers(PredInfo, CallerMarkers), ( % Check for extra information to the call. - map__search(ProcArgInfos, proc(PredId, ProcId), ProcArgInfo), + map.search(ProcArgInfos, proc(PredId, ProcId), ProcArgInfo), ProcArgInfo = pd_branch_info(_, LeftArgs, _), - set__member(LeftArg, LeftArgs), - list__index1_det(Args, LeftArg, Arg), - instmap__lookup_var(InstMap, Arg, ArgInst), + set.member(LeftArg, LeftArgs), + list.index1_det(Args, LeftArg, Arg), + instmap.lookup_var(InstMap, Arg, ArgInst), inst_is_bound_to_functors(ModuleInfo, ArgInst, [_]), % We don't attempt to deforest predicates which are @@ -1741,7 +1739,7 @@ deforest_call(PredId, ProcId, Args, SymName, BuiltinState, Goal0, Goal, % XXX We should probably allow deforestation of % semipure goals. InlinePromisedPure = no, - inlining__can_inline_proc(PredId, ProcId, BuiltinState, + inlining.can_inline_proc(PredId, ProcId, BuiltinState, InlinePromisedPure, CallerMarkers, ModuleInfo), % Check the goal size. @@ -1753,14 +1751,14 @@ deforest_call(PredId, ProcId, Args, SymName, BuiltinState, Goal0, Goal, ; CalledGoalSize < SizeThreshold ) -> - pd_debug__message(Context, + pd_debug_message(Context, "Found extra information for call to %s/%i\n", [s(Name), i(Arity)], !IO), ( - pd_term__local_check(ModuleInfo, Goal0, InstMap, + pd_term.local_check(ModuleInfo, Goal0, InstMap, LocalTermInfo0, LocalTermInfo) -> - pd_debug__message("Local termination check succeeded\n", [], !IO), + pd_debug_message("Local termination check succeeded\n", [], !IO), pd_info_set_local_term_info(LocalTermInfo, !PDInfo), unfold_call(yes, yes, PredId, ProcId, Args, Goal0, Goal1, Optimized, !PDInfo, !IO), @@ -1773,11 +1771,11 @@ deforest_call(PredId, ProcId, Args, SymName, BuiltinState, Goal0, Goal, ), pd_info_set_local_term_info(LocalTermInfo0, !PDInfo) ; - pd_debug__message("Local termination check failed\n", [], !IO), + pd_debug_message("Local termination check failed\n", [], !IO), Goal = GoalExpr0 - GoalInfo0 ) ; - pd_debug__message(Context, "No extra information for call to %s/%i\n", + pd_debug_message(Context, "No extra information for call to %s/%i\n", [s(Name), i(Arity)], !IO), Goal = Goal0 ). @@ -1788,11 +1786,11 @@ deforest_call(PredId, ProcId, Args, SymName, BuiltinState, Goal0, Goal, unfold_call(CheckImprovement, CheckVars, PredId, ProcId, Args, Goal0, Goal, Optimized, !PDInfo, !IO) :- - globals__io_lookup_int_option(deforestation_vars_threshold, VarsOpt, !IO), + globals.io_lookup_int_option(deforestation_vars_threshold, VarsOpt, !IO), pd_info_get_proc_info(!.PDInfo, ProcInfo0), proc_info_varset(ProcInfo0, VarSet0), - varset__vars(VarSet0, Vars), - list__length(Vars, NumVars), + varset.vars(VarSet0, Vars), + list.length(Vars, NumVars), ( % Check that we haven't already got too many variables. ( @@ -1812,7 +1810,7 @@ unfold_call(CheckImprovement, CheckVars, PredId, ProcId, Args, pred_info_get_univ_quant_tvars(PredInfo0, UnivQVars), proc_info_vartypes(ProcInfo0, VarTypes0), proc_info_rtti_varmaps(ProcInfo0, RttiVarMaps0), - inlining__do_inline_call(UnivQVars, Args, CalledPredInfo, + inlining.do_inline_call(UnivQVars, Args, CalledPredInfo, CalledProcInfo, VarSet0, VarSet, VarTypes0, VarTypes, TypeVarSet0, TypeVarSet, RttiVarMaps0, RttiVarMaps, Goal1), pred_info_set_typevarset(TypeVarSet, PredInfo0, PredInfo), @@ -1822,7 +1820,7 @@ unfold_call(CheckImprovement, CheckVars, PredId, ProcId, Args, pd_info_set_pred_info(PredInfo, !PDInfo), pd_info_set_proc_info(ProcInfo, !PDInfo), - pd_cost__goal(Goal1, OriginalCost), + goal_cost(Goal1, OriginalCost), pd_info_get_cost_delta(!.PDInfo, CostDelta0), pd_info_get_size_delta(!.PDInfo, SizeDelta0), pd_info_get_changed(!.PDInfo, Changed0), @@ -1830,20 +1828,20 @@ unfold_call(CheckImprovement, CheckVars, PredId, ProcId, Args, % Update the quantification if not all the output arguments are used. Goal1 = _ - GoalInfo1, goal_info_get_nonlocals(GoalInfo1, NonLocals1), - set__list_to_set(Args, NonLocals), - ( \+ set__equal(NonLocals1, NonLocals) -> - pd_util__requantify_goal(NonLocals, Goal1, Goal2, !PDInfo) + set.list_to_set(Args, NonLocals), + ( \+ set.equal(NonLocals1, NonLocals) -> + pd_util.requantify_goal(NonLocals, Goal1, Goal2, !PDInfo) ; Goal2 = Goal1 ), % Push the extra information from the call through the goal. - pd_debug__message("Running unique modes\n", [], !IO), + pd_debug_message("Running unique modes\n", [], !IO), proc_info_arglives(CalledProcInfo, ModuleInfo0, ArgLives), get_live_vars(Args, ArgLives, LiveVars0), - set__list_to_set(LiveVars0, LiveVars1), - set__intersect(NonLocals, LiveVars1, LiveVars), - pd_util__unique_modecheck_goal(LiveVars, Goal2, Goal3, Errors, + set.list_to_set(LiveVars0, LiveVars1), + set.intersect(NonLocals, LiveVars1, LiveVars), + pd_util.unique_modecheck_goal(LiveVars, Goal2, Goal3, Errors, !PDInfo, !IO), ( @@ -1856,18 +1854,17 @@ unfold_call(CheckImprovement, CheckVars, PredId, ProcId, Args, Optimized0 = no ), - pd_debug__message("Running simplify\n", [], !IO), + pd_debug_message("Running simplify\n", [], !IO), pd_info_get_module_info(!.PDInfo, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - simplify__find_simplifications(no, Globals, Simplifications), - pd_util__simplify_goal(Simplifications, Goal3, Goal4, !PDInfo, !IO), + simplify.find_simplifications(no, Globals, Simplifications), + pd_util.simplify_goal(Simplifications, Goal3, Goal4, !PDInfo, !IO), pd_info_get_cost_delta(!.PDInfo, CostDelta1), CostDelta = CostDelta1 - CostDelta0, goal_size(Goal4, GoalSize), - pd_cost__call(CallCost), - SizeDelta = GoalSize - CallCost, - globals__io_lookup_int_option(deforestation_cost_factor, Factor, !IO), + SizeDelta = GoalSize - cost_of_call, + globals.io_lookup_int_option(deforestation_cost_factor, Factor, !IO), ( Optimized0 = yes, ( @@ -1884,7 +1881,7 @@ unfold_call(CheckImprovement, CheckVars, PredId, ProcId, Args, ) -> Goal = Goal4, - pd_debug__message("inlined: cost(%i) size(%i)\n", + pd_debug_message("inlined: cost(%i) size(%i)\n", [i(CostDelta), i(SizeDelta)], !IO), pd_info_incr_size_delta(SizeDelta, !PDInfo), pd_info_set_changed(yes, !PDInfo), @@ -1904,7 +1901,7 @@ unfold_call(CheckImprovement, CheckVars, PredId, ProcId, Args, Optimized = yes ; - pd_debug__message("not enough improvement - " ++ + pd_debug_message("not enough improvement - " ++ "not inlining: cost(%i) size(%i)\n", [i(CostDelta), i(SizeDelta)], !IO), pd_info_set_pred_info(PredInfo0, !PDInfo), @@ -1916,7 +1913,7 @@ unfold_call(CheckImprovement, CheckVars, PredId, ProcId, Args, Optimized = no ) ; - pd_debug__message("too many variables - not inlining\n", [], !IO), + pd_debug_message("too many variables - not inlining\n", [], !IO), Goal = Goal0, Optimized = no ). @@ -1947,8 +1944,7 @@ is_simple_goal(Goal - _) :- % Very rough heuristics for checking improvement. This should lean % towards allowing optimizations. % -:- pred check_improvement(int::in, int::in, int::in, int::in) - is semidet. +:- pred check_improvement(int::in, int::in, int::in, int::in) is semidet. check_improvement(_Factor, Size, OriginalCost, CostDelta) :- ( Size =< 5 -> @@ -1970,8 +1966,7 @@ check_deforestation_improvement(Factor, CostDelta, SizeChange) :- % Accept the optimization if we save the equivalent of a heap increment % per 3 extra atomic goals. Note that folding is heavily rewarded by % pd_cost.m, so this isn't very restrictive if a fold occurs. - pd_cost__heap_incr(HeapCost), - ExpectedCostDelta = 1000 * HeapCost * SizeChange // 3, + ExpectedCostDelta = 1000 * cost_of_heap_incr * SizeChange // 3, FudgedCostDelta = CostDelta * Factor, FudgedCostDelta >= ExpectedCostDelta ). diff --git a/compiler/delay_construct.m b/compiler/delay_construct.m index 2abbddf9d..eb8a79c73 100644 --- a/compiler/delay_construct.m +++ b/compiler/delay_construct.m @@ -24,7 +24,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__delay_construct. +:- module transform_hlds.delay_construct. :- interface. :- import_module hlds.hlds_module. @@ -61,7 +61,7 @@ delay_construct_proc(PredId, ProcId, ModuleInfo, !ProcInfo, !IO) :- write_proc_progress_message("% Delaying construction unifications in ", PredId, ProcId, ModuleInfo, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), module_info_pred_info(ModuleInfo, PredId, PredInfo), delay_construct_proc_no_io(PredInfo, ModuleInfo, Globals, !ProcInfo). @@ -117,7 +117,7 @@ delay_construct_in_goal(GoalExpr0 - GoalInfo0, InstMap0, DelayInfo, Goal) :- CanFail = can_fail, MaxSoln \= at_most_zero -> - delay_construct_in_conj(Goals0, InstMap0, DelayInfo, set__init, + delay_construct_in_conj(Goals0, InstMap0, DelayInfo, set.init, [], Goals1) ; Goals1 = Goals0 @@ -144,7 +144,7 @@ delay_construct_in_goal(GoalExpr0 - GoalInfo0, InstMap0, DelayInfo, Goal) :- GoalExpr0 = if_then_else(Vars, Cond0, Then0, Else0), Cond0 = _ - CondInfo0, goal_info_get_instmap_delta(CondInfo0, CondInstMapDelta), - instmap__apply_instmap_delta(InstMap0, CondInstMapDelta, InstMapThen), + instmap.apply_instmap_delta(InstMap0, CondInstMapDelta, InstMapThen), delay_construct_in_goal(Cond0, InstMap0, DelayInfo, Cond), delay_construct_in_goal(Then0, InstMapThen, DelayInfo, Then), delay_construct_in_goal(Else0, InstMap0, DelayInfo, Else), @@ -203,22 +203,22 @@ delay_construct_in_goal(GoalExpr0 - GoalInfo0, InstMap0, DelayInfo, Goal) :- list(hlds_goal)::out) is det. delay_construct_in_conj([], _, _, _, RevDelayedGoals, DelayedGoals) :- - list__reverse(RevDelayedGoals, DelayedGoals). + list.reverse(RevDelayedGoals, DelayedGoals). delay_construct_in_conj([Goal0 | Goals0], InstMap0, DelayInfo, ConstructedVars0, RevDelayedGoals0, Goals) :- Goal0 = GoalExpr0 - GoalInfo0, goal_info_get_instmap_delta(GoalInfo0, InstMapDelta0), - instmap__apply_instmap_delta(InstMap0, InstMapDelta0, InstMap1), + instmap.apply_instmap_delta(InstMap0, InstMapDelta0, InstMap1), ( GoalExpr0 = unify(_, _, _, Unif, _), Unif = construct(Var, _, Args, _, _, _, _), Args = [_ | _], % We are constructing a cell, not a constant - instmap__lookup_var(InstMap0, Var, Inst0), + instmap.lookup_var(InstMap0, Var, Inst0), inst_is_free(DelayInfo ^ module_info, Inst0), - instmap__lookup_var(InstMap1, Var, Inst1), + instmap.lookup_var(InstMap1, Var, Inst1), inst_is_ground(DelayInfo ^ module_info, Inst1) -> - set__insert(ConstructedVars0, Var, ConstructedVars1), + set.insert(ConstructedVars0, Var, ConstructedVars1), RevDelayedGoals1 = [Goal0 | RevDelayedGoals0], delay_construct_in_conj(Goals0, InstMap1, DelayInfo, ConstructedVars1, RevDelayedGoals1, Goals) @@ -230,9 +230,9 @@ delay_construct_in_conj([Goal0 | Goals0], InstMap0, DelayInfo, DelayInfo ^ body_typeinfo_liveness, DelayInfo ^ vartypes, DelayInfo ^ rtti_varmaps, CompletedNonLocals), - set__intersect(CompletedNonLocals, ConstructedVars0, + set.intersect(CompletedNonLocals, ConstructedVars0, Intersection), - set__empty(Intersection), + set.empty(Intersection), \+ goal_info_has_feature(GoalInfo0, impure_goal), \+ goal_info_has_feature(GoalInfo0, semipure_goal) -> @@ -240,10 +240,10 @@ delay_construct_in_conj([Goal0 | Goals0], InstMap0, DelayInfo, ConstructedVars0, RevDelayedGoals0, Goals1), Goals = [Goal0 | Goals1] ; - list__reverse(RevDelayedGoals0, DelayedGoals), + list.reverse(RevDelayedGoals0, DelayedGoals), delay_construct_in_conj(Goals0, InstMap1, DelayInfo, - set__init, [], Goals1), - list__append(DelayedGoals, [Goal0 | Goals1], Goals) + set.init, [], Goals1), + list.append(DelayedGoals, [Goal0 | Goals1], Goals) ). :- pred delay_construct_skippable(hlds_goal_expr::in, hlds_goal_info::in) diff --git a/compiler/delay_info.m b/compiler/delay_info.m index 98ec6dee0..7e570c274 100644 --- a/compiler/delay_info.m +++ b/compiler/delay_info.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-1998, 2003-2005 The University of Melbourne. +% Copyright (C) 1994-1998, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -17,7 +17,7 @@ %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- module check_hlds__delay_info. +:- module check_hlds.delay_info. :- interface. :- import_module check_hlds.mode_errors. @@ -34,53 +34,53 @@ % Sanity-check the delay_info structure. % -:- pred delay_info__check_invariant(delay_info::in) is det. +:- pred delay_info_check_invariant(delay_info::in) is det. % Initialize the delay_info structure. % -:- pred delay_info__init(delay_info::out) is det. +:- pred delay_info_init(delay_info::out) is det. % Tell the delay_info structure that we've entered a new conjunction. % -:- pred delay_info__enter_conj(delay_info::in, delay_info::out) is det. +:- pred delay_info_enter_conj(delay_info::in, delay_info::out) is det. % Tell the delay_info structure that we've left a conjunction. % This predicate returns a list of the delayed goals from that % conjunction, i.e. goals which could not be scheduled. % -:- pred delay_info__leave_conj(delay_info::in, list(delayed_goal)::out, +:- pred delay_info_leave_conj(delay_info::in, list(delayed_goal)::out, delay_info::out) is det. % Insert a new delayed goal into the delay_info structure. % -:- pred delay_info__delay_goal(delay_info::in, mode_error_info::in, +:- pred delay_info_delay_goal(delay_info::in, mode_error_info::in, hlds_goal::in, delay_info::out) is det. % Mark a list of variables as having been bound. % This may allow a previously delayed goal to change status % from "delayed" to "pending". - % (This predicate just calls delay_info__bind_var in a loop.) + % (This predicate just calls delay_info_bind_var in a loop.) % -:- pred delay_info__bind_var_list(list(prog_var)::in, +:- pred delay_info_bind_var_list(list(prog_var)::in, delay_info::in, delay_info::out) is det. % Mark a variable as having been bound. % This may allow a previously delayed goal to change status % from "delayed" to "pending". % -:- pred delay_info__bind_var(prog_var::in, delay_info::in, delay_info::out) +:- pred delay_info_bind_var(prog_var::in, delay_info::in, delay_info::out) is det. % Mark all variables as having been bound. % This will allow all previously delayed goals to change status % from "delayed" to "pending". % -:- pred delay_info__bind_all_vars(delay_info::in, delay_info::out) is det. +:- pred delay_info_bind_all_vars(delay_info::in, delay_info::out) is det. % Check if there are any "pending" goals, and if so, % remove them from the delay_info and return them. % -:- pred delay_info__wakeup_goals(list(hlds_goal)::out, +:- pred delay_info_wakeup_goals(list(hlds_goal)::out, delay_info::in, delay_info::out) is det. %-----------------------------------------------------------------------------% @@ -155,20 +155,20 @@ %-----------------------------------------------------------------------------% -delay_info__check_invariant(_). +delay_info_check_invariant(_). % for debugging purposes -%%% delay_info__check_invariant(DelayInfo) :- -%%% delay_info__check_invariant_x(DelayInfo). +%%% delay_info_check_invariant(DelayInfo) :- +%%% delay_info_check_invariant_x(DelayInfo). -:- pred delay_info__check_invariant_x(delay_info::in) is det. +:- pred delay_info_check_invariant_x(delay_info::in) is det. -delay_info__check_invariant_x(DelayInfo) :- +delay_info_check_invariant_x(DelayInfo) :- DelayInfo = delay_info(CurrentDepth, DelayedGoalStack, WaitingGoalsTable, _PendingGoals, NextSeqNums), ( - stack__depth(DelayedGoalStack, CurrentDepth), - stack__depth(NextSeqNums, CurrentDepth), - map__keys(WaitingGoalsTable, WaitingVars), + stack.depth(DelayedGoalStack, CurrentDepth), + stack.depth(NextSeqNums, CurrentDepth), + map.keys(WaitingGoalsTable, WaitingVars), waiting_goals_check_invariant(WaitingVars, WaitingGoalsTable) -> true @@ -184,8 +184,8 @@ delay_info__check_invariant_x(DelayInfo) :- waiting_goals_check_invariant([], _). waiting_goals_check_invariant([Var | Vars], WaitingGoalsTable) :- - map__lookup(WaitingGoalsTable, Var, WaitingGoals), - map__keys(WaitingGoals, GoalNums), + map.lookup(WaitingGoalsTable, Var, WaitingGoals), + map.keys(WaitingGoals, GoalNums), waiting_goal_check_invariant(GoalNums, WaitingGoals, WaitingGoalsTable), waiting_goals_check_invariant(Vars, WaitingGoalsTable). @@ -197,8 +197,8 @@ waiting_goals_check_invariant([Var | Vars], WaitingGoalsTable) :- waiting_goal_check_invariant([], _, _). waiting_goal_check_invariant([GoalNum | GoalNums], WaitingGoals, WaitingGoalsTable) :- - map__lookup(WaitingGoals, GoalNum, Vars), - set__list_to_set(Vars, VarsSet), + map.lookup(WaitingGoals, GoalNum, Vars), + set.list_to_set(Vars, VarsSet), waiting_goal_vars_check_invariant(Vars, GoalNum, VarsSet, WaitingGoalsTable), waiting_goal_check_invariant(GoalNums, WaitingGoals, WaitingGoalsTable). @@ -213,10 +213,10 @@ waiting_goal_check_invariant([GoalNum | GoalNums], WaitingGoals, waiting_goal_vars_check_invariant([], _, _, _). waiting_goal_vars_check_invariant([Var | Vars], GoalNum, GivenVars, WaitingGoalsTable) :- - map__search(WaitingGoalsTable, Var, WaitingGoals), - map__search(WaitingGoals, GoalNum, VarsList), - set__list_to_set(VarsList, VarsSet), - set__equal(GivenVars, VarsSet), + map.search(WaitingGoalsTable, Var, WaitingGoals), + map.search(WaitingGoals, GoalNum, VarsList), + set.list_to_set(VarsList, VarsSet), + set.equal(GivenVars, VarsSet), waiting_goal_vars_check_invariant(Vars, GoalNum, GivenVars, WaitingGoalsTable). @@ -225,46 +225,46 @@ waiting_goal_vars_check_invariant([Var | Vars], GoalNum, GivenVars, % Initialize the delay info structure in preparation for mode analysis of % a goal. % -delay_info__init(DelayInfo) :- +delay_info_init(DelayInfo) :- CurrentDepth = 0, - stack__init(DelayedGoalStack), - map__init(WaitingGoalsTable), - map__init(PendingGoals), - stack__init(NextSeqNums), + stack.init(DelayedGoalStack), + map.init(WaitingGoalsTable), + map.init(PendingGoals), + stack.init(NextSeqNums), DelayInfo = delay_info(CurrentDepth, DelayedGoalStack, WaitingGoalsTable, PendingGoals, NextSeqNums), - delay_info__check_invariant(DelayInfo). + delay_info_check_invariant(DelayInfo). %-----------------------------------------------------------------------------% -delay_info__enter_conj(DelayInfo0, DelayInfo) :- - delay_info__check_invariant(DelayInfo0), +delay_info_enter_conj(DelayInfo0, DelayInfo) :- + delay_info_check_invariant(DelayInfo0), DelayInfo0 = delay_info(CurrentDepth0, DelayedGoalStack0, WaitingGoalsTable, PendingGoals, NextSeqNums0), - map__init(DelayedGoals), - stack__push(DelayedGoalStack0, DelayedGoals, DelayedGoalStack), - stack__push(NextSeqNums0, 0, NextSeqNums), + map.init(DelayedGoals), + stack.push(DelayedGoalStack0, DelayedGoals, DelayedGoalStack), + stack.push(NextSeqNums0, 0, NextSeqNums), CurrentDepth = CurrentDepth0 + 1, DelayInfo = delay_info(CurrentDepth, DelayedGoalStack, WaitingGoalsTable, PendingGoals, NextSeqNums), - delay_info__check_invariant(DelayInfo). + delay_info_check_invariant(DelayInfo). %-----------------------------------------------------------------------------% -delay_info__leave_conj(DelayInfo0, DelayedGoalsList, DelayInfo) :- - delay_info__check_invariant(DelayInfo0), +delay_info_leave_conj(DelayInfo0, DelayedGoalsList, DelayInfo) :- + delay_info_check_invariant(DelayInfo0), DelayInfo0 = delay_info(CurrentDepth0, DelayedGoalStack0, WaitingGoalsTable0, PendingGoals, NextSeqNums0), - stack__pop_det(DelayedGoalStack0, DelayedGoals, DelayedGoalStack), - map__keys(DelayedGoals, SeqNums), + stack.pop_det(DelayedGoalStack0, DelayedGoals, DelayedGoalStack), + map.keys(DelayedGoals, SeqNums), remove_delayed_goals(SeqNums, DelayedGoals, CurrentDepth0, WaitingGoalsTable0, WaitingGoalsTable), - stack__pop_det(NextSeqNums0, _, NextSeqNums), + stack.pop_det(NextSeqNums0, _, NextSeqNums), CurrentDepth = CurrentDepth0 - 1, - map__values(DelayedGoals, DelayedGoalsList), + map.values(DelayedGoals, DelayedGoalsList), DelayInfo = delay_info(CurrentDepth, DelayedGoalStack, WaitingGoalsTable, PendingGoals, NextSeqNums), - delay_info__check_invariant(DelayInfo). + delay_info_check_invariant(DelayInfo). %-----------------------------------------------------------------------------% @@ -277,10 +277,10 @@ delay_info__leave_conj(DelayInfo0, DelayedGoalsList, DelayInfo) :- remove_delayed_goals([], _, _, !WaitingGoalsTable). remove_delayed_goals([SeqNum | SeqNums], DelayedGoalsTable, Depth, !WaitingGoalsTable) :- - map__lookup(DelayedGoalsTable, SeqNum, DelayedGoal), + map.lookup(DelayedGoalsTable, SeqNum, DelayedGoal), DelayedGoal = delayed_goal(Vars, _Error, _Goal), GoalNum = Depth - SeqNum, - set__to_sorted_list(Vars, VarList), + set.to_sorted_list(Vars, VarList), delete_waiting_vars(VarList, GoalNum, !WaitingGoalsTable), remove_delayed_goals(SeqNums, DelayedGoalsTable, Depth, !WaitingGoalsTable). @@ -290,32 +290,32 @@ remove_delayed_goals([SeqNum | SeqNums], DelayedGoalsTable, Depth, % We are going to delay a goal. % Update the delay info structure to record the delayed goal. % -delay_info__delay_goal(DelayInfo0, Error, Goal, DelayInfo) :- - delay_info__check_invariant(DelayInfo0), +delay_info_delay_goal(DelayInfo0, Error, Goal, DelayInfo) :- + delay_info_check_invariant(DelayInfo0), Error = mode_error_info(Vars, _, _, _), DelayInfo0 = delay_info(CurrentDepth, DelayedGoalStack0, WaitingGoalsTable0, PendingGoals, NextSeqNums0), % Get the next sequence number - stack__pop_det(NextSeqNums0, SeqNum, NextSeqNums1), + stack.pop_det(NextSeqNums0, SeqNum, NextSeqNums1), NextSeq = SeqNum + 1, - stack__push(NextSeqNums1, NextSeq, NextSeqNums), + stack.push(NextSeqNums1, NextSeq, NextSeqNums), % Store the goal in the delayed goal stack - stack__pop_det(DelayedGoalStack0, DelayedGoals0, DelayedGoalStack1), - svmap__set(SeqNum, delayed_goal(Vars, Error, Goal), + stack.pop_det(DelayedGoalStack0, DelayedGoals0, DelayedGoalStack1), + svmap.set(SeqNum, delayed_goal(Vars, Error, Goal), DelayedGoals0, DelayedGoals), - stack__push(DelayedGoalStack1, DelayedGoals, DelayedGoalStack), + stack.push(DelayedGoalStack1, DelayedGoals, DelayedGoalStack), % Store indexes to the goal in the waiting goals table GoalNum = CurrentDepth - SeqNum, - set__to_sorted_list(Vars, VarList), + set.to_sorted_list(Vars, VarList), add_waiting_vars(VarList, GoalNum, VarList, WaitingGoalsTable0, WaitingGoalsTable), DelayInfo = delay_info(CurrentDepth, DelayedGoalStack, WaitingGoalsTable, PendingGoals, NextSeqNums), - delay_info__check_invariant(DelayInfo). + delay_info_check_invariant(DelayInfo). % add_waiting_vars(Vars, Goal, AllVars, WGT0, WGT): % @@ -328,13 +328,13 @@ delay_info__delay_goal(DelayInfo0, Error, Goal, DelayInfo) :- add_waiting_vars([], _, _, !WaitingGoalsTable). add_waiting_vars([Var | Vars], Goal, AllVars, !WaitingGoalsTable) :- - ( map__search(!.WaitingGoalsTable, Var, WaitingGoals0) -> + ( map.search(!.WaitingGoalsTable, Var, WaitingGoals0) -> WaitingGoals1 = WaitingGoals0 ; - map__init(WaitingGoals1) + map.init(WaitingGoals1) ), - map__set(WaitingGoals1, Goal, AllVars, WaitingGoals), - svmap__set(Var, WaitingGoals, !WaitingGoalsTable), + map.set(WaitingGoals1, Goal, AllVars, WaitingGoals), + svmap.set(Var, WaitingGoals, !WaitingGoalsTable), add_waiting_vars(Vars, Goal, AllVars, !WaitingGoalsTable). %-----------------------------------------------------------------------------% @@ -345,32 +345,32 @@ add_waiting_vars([Var | Vars], Goal, AllVars, !WaitingGoalsTable) :- % to the pending goals table. They will be woken up next time we get back % to their conjunction. % -delay_info__bind_all_vars(!DelayInfo) :- - map__keys(!.DelayInfo ^ delay_waiting, WaitingVars), - delay_info__bind_var_list(WaitingVars, !DelayInfo). +delay_info_bind_all_vars(!DelayInfo) :- + map.keys(!.DelayInfo ^ delay_waiting, WaitingVars), + delay_info_bind_var_list(WaitingVars, !DelayInfo). -delay_info__bind_var_list([], !DelayInfo). -delay_info__bind_var_list([Var|Vars], !DelayInfo) :- - delay_info__bind_var(Var, !DelayInfo), - delay_info__bind_var_list(Vars, !DelayInfo). +delay_info_bind_var_list([], !DelayInfo). +delay_info_bind_var_list([Var|Vars], !DelayInfo) :- + delay_info_bind_var(Var, !DelayInfo), + delay_info_bind_var_list(Vars, !DelayInfo). % Whenever we bind a variable, we also check to see whether we need to wake % up some goals. If so, we remove those goals from the waiting goals table % and add them to the pending goals table. They will be woken up next time % we get back to their conjunction. % -delay_info__bind_var(Var, !DelayInfo) :- - delay_info__check_invariant(!.DelayInfo), +delay_info_bind_var(Var, !DelayInfo) :- + delay_info_check_invariant(!.DelayInfo), !.DelayInfo = delay_info(CurrentDepth, DelayedGoalStack, WaitingGoalsTable0, PendingGoals0, NextSeqNums), - ( map__search(WaitingGoalsTable0, Var, GoalsWaitingOnVar) -> - map__keys(GoalsWaitingOnVar, NewlyPendingGoals), + ( map.search(WaitingGoalsTable0, Var, GoalsWaitingOnVar) -> + map.keys(GoalsWaitingOnVar, NewlyPendingGoals), add_pending_goals(NewlyPendingGoals, GoalsWaitingOnVar, PendingGoals0, PendingGoals, WaitingGoalsTable0, WaitingGoalsTable), !:DelayInfo = delay_info(CurrentDepth, DelayedGoalStack, WaitingGoalsTable, PendingGoals, NextSeqNums), - delay_info__check_invariant(!.DelayInfo) + delay_info_check_invariant(!.DelayInfo) ; true ). @@ -389,17 +389,17 @@ add_pending_goals([Depth - SeqNum | Rest], WaitingVarsTable, !PendingGoals, !WaitingGoals) :- % Remove any other indexes to the goal from the waiting goals table. GoalNum = Depth - SeqNum, - map__lookup(WaitingVarsTable, GoalNum, WaitingVars), + map.lookup(WaitingVarsTable, GoalNum, WaitingVars), delete_waiting_vars(WaitingVars, GoalNum, !WaitingGoals), % Add the goal to the pending goals table. - ( map__search(!.PendingGoals, Depth, PendingSeqNums0) -> + ( map.search(!.PendingGoals, Depth, PendingSeqNums0) -> % XXX Should use a queue. - list__append(PendingSeqNums0, [SeqNum], PendingSeqNums) + list.append(PendingSeqNums0, [SeqNum], PendingSeqNums) ; PendingSeqNums = [SeqNum] ), - svmap__set(Depth, PendingSeqNums, !PendingGoals), + svmap.set(Depth, PendingSeqNums, !PendingGoals), % Do the same for the rest of the pending goals. add_pending_goals(Rest, WaitingVarsTable, !PendingGoals, !WaitingGoals). @@ -413,28 +413,28 @@ add_pending_goals([Depth - SeqNum | Rest], WaitingVarsTable, delete_waiting_vars([], _, !WaitingGoalTables). delete_waiting_vars([Var | Vars], GoalNum, !WaitingGoalsTable) :- - map__lookup(!.WaitingGoalsTable, Var, WaitingGoals0), - map__delete(WaitingGoals0, GoalNum, WaitingGoals), - ( map__is_empty(WaitingGoals) -> - svmap__delete(Var, !WaitingGoalsTable) + map.lookup(!.WaitingGoalsTable, Var, WaitingGoals0), + map.delete(WaitingGoals0, GoalNum, WaitingGoals), + ( map.is_empty(WaitingGoals) -> + svmap.delete(Var, !WaitingGoalsTable) ; - svmap__set(Var, WaitingGoals, !WaitingGoalsTable) + svmap.set(Var, WaitingGoals, !WaitingGoalsTable) ), delete_waiting_vars(Vars, GoalNum, !WaitingGoalsTable). %-----------------------------------------------------------------------------% - % delay_info__wakeup_goals(Goals, !DelayInfo): + % delay_info_wakeup_goals(Goals, !DelayInfo): % % Goals is the list of pending goal in the order that they should be % woken up, and DelayInfo is the new delay_info, updated to reflect % the fact that the Goals have been woken up and is hence are longer % pending. % -delay_info__wakeup_goals(Goals, !DelayInfo) :- - ( delay_info__wakeup_goal(Goal, !DelayInfo) -> +delay_info_wakeup_goals(Goals, !DelayInfo) :- + ( delay_info_wakeup_goal(Goal, !DelayInfo) -> Goals = [Goal | Goals1], - delay_info__wakeup_goals(Goals1, !DelayInfo) + delay_info_wakeup_goals(Goals1, !DelayInfo) ; Goals = [] ). @@ -443,36 +443,36 @@ delay_info__wakeup_goals(Goals, !DelayInfo) :- % remove it from the delay_info, and return it. If there are no pending % goals, this predicate will fail. % -:- pred delay_info__wakeup_goal(hlds_goal::out, +:- pred delay_info_wakeup_goal(hlds_goal::out, delay_info::in, delay_info::out) is semidet. - % delay_info__wakeup_goal(DelayInfo0, Goal, DelayInfo) is true iff + % delay_info_wakeup_goal(DelayInfo0, Goal, DelayInfo) is true iff % DelayInfo0 specifies that there is at least one goal which is pending, % Goal is the pending goal which should be reawakened first, and DelayInfo % is the new delay_info, updated to reflect the fact that Goal has been % woken up and is hence no longer pending. % -delay_info__wakeup_goal(Goal, !DelayInfo) :- - delay_info__check_invariant(!.DelayInfo), +delay_info_wakeup_goal(Goal, !DelayInfo) :- + delay_info_check_invariant(!.DelayInfo), !.DelayInfo = delay_info(CurrentDepth, DelayedGoalStack0, WaitingGoals, PendingGoalsTable0, NextSeqNums), % Is there a goal in the current conjunction which is pending? - map__search(PendingGoalsTable0, CurrentDepth, PendingGoals0), + map.search(PendingGoalsTable0, CurrentDepth, PendingGoals0), % If so, remove it from the pending goals table, remove it from the % delayed goals stack, and return it. PendingGoals0 = [SeqNum | PendingGoals], - map__set(PendingGoalsTable0, CurrentDepth, PendingGoals, + map.set(PendingGoalsTable0, CurrentDepth, PendingGoals, PendingGoalsTable), - stack__pop_det(DelayedGoalStack0, DelayedGoals0, DelayedGoalStack1), - map__lookup(DelayedGoals0, SeqNum, DelayedGoal), + stack.pop_det(DelayedGoalStack0, DelayedGoals0, DelayedGoalStack1), + map.lookup(DelayedGoals0, SeqNum, DelayedGoal), DelayedGoal = delayed_goal(_Vars, _ErrorReason, Goal), - map__delete(DelayedGoals0, SeqNum, DelayedGoals), - stack__push(DelayedGoalStack1, DelayedGoals, DelayedGoalStack), + map.delete(DelayedGoals0, SeqNum, DelayedGoals), + stack.push(DelayedGoalStack1, DelayedGoals, DelayedGoalStack), !:DelayInfo = delay_info(CurrentDepth, DelayedGoalStack, WaitingGoals, PendingGoalsTable, NextSeqNums), - delay_info__check_invariant(!.DelayInfo). + delay_info_check_invariant(!.DelayInfo). %-----------------------------------------------------------------------------% diff --git a/compiler/delay_slot.m b/compiler/delay_slot.m index e362e16d9..9fa4aff81 100644 --- a/compiler/delay_slot.m +++ b/compiler/delay_slot.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1997-1998, 2003-2005 The University of Melbourne. +% Copyright (C) 1997-1998, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -47,7 +47,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__delay_slot. +:- module ll_backend.delay_slot. :- interface. :- import_module ll_backend.llds. @@ -79,7 +79,7 @@ fill_branch_delay_slot([Instr0 | Instrs0], Instrs) :- Instr3 = assign(stackvar(Size), lval(succip)) - C2 -> fill_branch_delay_slot(Tail0, Tail1), - string__append(C2, " (early save in delay slot)", NewC2), + string.append(C2, " (early save in delay slot)", NewC2), EarlySave = assign(stackvar(0), lval(succip)) - NewC2, Instrs = [Instr0, EarlySave, Instr1, Instr2 | Tail1] ; diff --git a/compiler/dense_switch.m b/compiler/dense_switch.m index c3cb1e4f0..46f81a1d2 100644 --- a/compiler/dense_switch.m +++ b/compiler/dense_switch.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__dense_switch. +:- module ll_backend.dense_switch. :- interface. :- import_module backend_libs.switch_util. @@ -76,27 +76,27 @@ is_dense_switch(CI, CaseVar, TaggedCases, CanFail0, ReqDensity, FirstVal, LastVal, CanFail) :- - list__length(TaggedCases, NumCases), + list.length(TaggedCases, NumCases), NumCases > 2, TaggedCases = [FirstCase | _], FirstCase = case(_, int_constant(FirstCaseVal), _, _), - list__index1_det(TaggedCases, NumCases, LastCase), + list.index1_det(TaggedCases, NumCases, LastCase), LastCase = case(_, int_constant(LastCaseVal), _, _), Span = LastCaseVal - FirstCaseVal, Range = Span + 1, - dense_switch__calc_density(NumCases, Range, Density), + dense_switch.calc_density(NumCases, Range, Density), Density > ReqDensity, ( CanFail0 = can_fail -> % For semidet switches, we normally need to check that the variable % is in range before we index into the jump table. However, if the % range of the type is sufficiently small, we can make the jump table % large enough to hold all of the values for the type. - Type = code_info__variable_type(CI, CaseVar), - code_info__get_module_info(CI, ModuleInfo), + Type = code_info.variable_type(CI, CaseVar), + code_info.get_module_info(CI, ModuleInfo), classify_type(ModuleInfo, Type) = TypeCategory, ( - dense_switch__type_range(CI, TypeCategory, Type, TypeRange), - dense_switch__calc_density(NumCases, TypeRange, DetDensity), + dense_switch.type_range(CI, TypeCategory, Type, TypeRange), + dense_switch.calc_density(NumCases, TypeRange, DetDensity), DetDensity > ReqDensity -> CanFail = cannot_fail, @@ -128,8 +128,8 @@ calc_density(NumCases, Range, Density) :- % (e.g. int). % type_range(CI, TypeCategory, Type, Range) :- - code_info__get_module_info(CI, ModuleInfo), - switch_util__type_range(TypeCategory, Type, ModuleInfo, Min, Max), + code_info.get_module_info(CI, ModuleInfo), + switch_util.type_range(TypeCategory, Type, ModuleInfo, Min, Max), Range = Max - Min + 1. %---------------------------------------------------------------------------% @@ -137,7 +137,7 @@ type_range(CI, TypeCategory, Type, Range) :- generate_dense_switch(Cases, StartVal, EndVal, Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, MaybeEnd0, MaybeEnd, Code, !CI) :- % Evaluate the variable which we are going to be switching on. - code_info__produce_variable(Var, VarCode, Rval, !CI), + code_info.produce_variable(Var, VarCode, Rval, !CI), % If the case values start at some number other than 0, % then subtract that number to give us a zero-based index. ( StartVal = 0 -> @@ -150,7 +150,7 @@ generate_dense_switch(Cases, StartVal, EndVal, Var, CodeModel, CanFail, ( CanFail = can_fail, Difference = EndVal - StartVal, - code_info__fail_if_rval_is_false( + code_info.fail_if_rval_is_false( binop(unsigned_le, Index, const(int_const(Difference))), RangeCheck, !CI) ; @@ -183,7 +183,7 @@ generate_cases(Cases0, NextVal, EndVal, CodeModel, SwitchGoalInfo, EndLabel, label(EndLabel) - "End of dense switch" ]) ; - code_info__get_next_label(ThisLabel, !CI), + code_info.get_next_label(ThisLabel, !CI), generate_case(Cases0, Cases1, NextVal, CodeModel, SwitchGoalInfo, !MaybeEnd, ThisCode, Comment, !CI), LabelCode = node([ @@ -215,19 +215,19 @@ generate_case(!Cases, NextVal, CodeModel, SwitchGoalInfo, !MaybeEnd, Code, Comment = "case of dense switch", % We need to save the expression cache, etc., % and restore them when we've finished. - code_info__remember_position(!.CI, BranchStart), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + code_info.remember_position(!.CI, BranchStart), + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), goal_info_get_store_map(SwitchGoalInfo, StoreMap), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), Code = tree_list([TraceCode, GoalCode, SaveCode]), - code_info__reset_to_position(BranchStart, !CI) + code_info.reset_to_position(BranchStart, !CI) ; % This case didn't occur in the original case list % - just generate a `fail' for it. Comment = "compiler-introduced `fail' case of dense switch", - code_info__generate_failure(Code, !CI) + code_info.generate_failure(Code, !CI) ). %----------------------------------------------------------------------------% diff --git a/compiler/dependency_graph.m b/compiler/dependency_graph.m index 68b7ebc06..3db72e6a5 100644 --- a/compiler/dependency_graph.m +++ b/compiler/dependency_graph.m @@ -21,7 +21,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__dependency_graph. +:- module transform_hlds.dependency_graph. :- interface. :- import_module hlds.hlds_module. @@ -54,12 +54,12 @@ % Build the dependency graph of procedures. % -:- pred dependency_graph__build_pred_dependency_graph(module_info::in, +:- pred dependency_graph.build_pred_dependency_graph(module_info::in, include_imported::in, dependency_info(pred_id)::out) is det. % Build the dependency graph of predicates. % -:- pred dependency_graph__build_proc_dependency_graph(module_info::in, +:- pred dependency_graph.build_proc_dependency_graph(module_info::in, include_imported::in, dependency_info(pred_proc_id)::out) is det. % Output a form of the static call graph to a file, in a format suitable @@ -68,7 +68,7 @@ % % CallerModeDecl \t CalleeModeDecl % -:- pred dependency_graph__write_dependency_graph(module_info::in, +:- pred dependency_graph.write_dependency_graph(module_info::in, module_info::out, io::di, io::uo) is det. % Output a form of the static call graph to a file for use by the profiler. @@ -76,7 +76,7 @@ % % CallerLabel \t CalleeLabel % -:- pred dependency_graph__write_prof_dependency_graph(module_info::in, +:- pred dependency_graph.write_prof_dependency_graph(module_info::in, module_info::out, io::di, io::uo) is det. % Given the list of predicates in a strongly connected component @@ -84,7 +84,7 @@ % and a module_info, find out which members of the SCC can be % called from outside the SCC. % -:- pred dependency_graph__get_scc_entry_points(list(pred_proc_id)::in, +:- pred dependency_graph.get_scc_entry_points(list(pred_proc_id)::in, dependency_ordering::in, module_info::in, list(pred_proc_id)::out) is det. % write_graph(Graph, WriteNode, WriteEdge) @@ -92,7 +92,7 @@ % Write out the dependency graph using WriteNode to decide what to output % for a node in the dependency graph and WriteEdge for an edge. % -:- pred dependency_graph__write_graph(dependency_info::in, +:- pred dependency_graph.write_graph(dependency_info::in, pred(pred_proc_id, io, io)::pred(in, di, uo) is det, pred(pred_proc_id, pred_proc_id, io, io)::pred(in, in, di, uo) is det, io::di, io::uo) is det. @@ -102,7 +102,7 @@ % Write out each of the Nodes in the Graph using WriteNode and % any edges originating in Nodes, using WriteEdge. % -:- pred dependency_graph__write_graph_nodes(list(pred_proc_id)::in, +:- pred dependency_graph.write_graph_nodes(list(pred_proc_id)::in, dependency_graph::in, pred(pred_proc_id, io, io)::pred(in, di, uo) is det, pred(pred_proc_id, pred_proc_id, io, io)::pred(in, in, di, uo) is det, io::di, io::uo) is det. @@ -148,59 +148,59 @@ module_info_ensure_dependency_info(!ModuleInfo) :- MaybeDepInfo = yes(_) ; MaybeDepInfo = no, - dependency_graph__build_dependency_graph(!.ModuleInfo, + dependency_graph.build_dependency_graph(!.ModuleInfo, do_not_include_imported, DepInfo), module_info_set_dependency_info(DepInfo, !ModuleInfo) ). module_info_rebuild_dependency_info(!ModuleInfo, DepInfo) :- - dependency_graph__build_dependency_graph(!.ModuleInfo, + dependency_graph.build_dependency_graph(!.ModuleInfo, do_not_include_imported, DepInfo), module_info_set_dependency_info(DepInfo, !ModuleInfo). -dependency_graph__build_proc_dependency_graph(ModuleInfo, Imported, DepInfo) :- - dependency_graph__build_dependency_graph(ModuleInfo, Imported, DepInfo). +dependency_graph.build_proc_dependency_graph(ModuleInfo, Imported, DepInfo) :- + dependency_graph.build_dependency_graph(ModuleInfo, Imported, DepInfo). -dependency_graph__build_pred_dependency_graph(ModuleInfo, Imported, DepInfo) :- - dependency_graph__build_dependency_graph(ModuleInfo, Imported, DepInfo). +dependency_graph.build_pred_dependency_graph(ModuleInfo, Imported, DepInfo) :- + dependency_graph.build_dependency_graph(ModuleInfo, Imported, DepInfo). - % Traverse the module structure, calling `dependency_graph__add_arcs' + % Traverse the module structure, calling `dependency_graph.add_arcs' % for each procedure body. % -:- pred dependency_graph__build_dependency_graph(module_info::in, +:- pred dependency_graph.build_dependency_graph(module_info::in, include_imported::in, dependency_info(T)::out) is det <= dependency_node(T). -dependency_graph__build_dependency_graph(ModuleInfo, Imported, !:DepInfo) :- +dependency_graph.build_dependency_graph(ModuleInfo, Imported, !:DepInfo) :- module_info_predids(ModuleInfo, PredIds), - relation__init(DepGraph0), - dependency_graph__add_nodes(PredIds, ModuleInfo, Imported, + relation.init(DepGraph0), + dependency_graph.add_nodes(PredIds, ModuleInfo, Imported, DepGraph0, DepGraph1), - dependency_graph__add_arcs(PredIds, ModuleInfo, Imported, + dependency_graph.add_arcs(PredIds, ModuleInfo, Imported, DepGraph1, DepGraph), hlds_dependency_info_init(!:DepInfo), hlds_dependency_info_set_dependency_graph(DepGraph, !DepInfo), - relation__atsort(DepGraph, DepOrd0), - dependency_graph__sets_to_lists(DepOrd0, [], DepOrd), + relation.atsort(DepGraph, DepOrd0), + dependency_graph.sets_to_lists(DepOrd0, [], DepOrd), hlds_dependency_info_set_dependency_ordering(DepOrd, !DepInfo). -:- pred dependency_graph__sets_to_lists(list(set(T))::in, list(list(T))::in, +:- pred dependency_graph.sets_to_lists(list(set(T))::in, list(list(T))::in, list(list(T))::out) is det. -dependency_graph__sets_to_lists([], Xs, Xs). -dependency_graph__sets_to_lists([X | Xs], Ys, Zs) :- - set__to_sorted_list(X, Y), - dependency_graph__sets_to_lists(Xs, [Y | Ys], Zs). +dependency_graph.sets_to_lists([], Xs, Xs). +dependency_graph.sets_to_lists([X | Xs], Ys, Zs) :- + set.to_sorted_list(X, Y), + dependency_graph.sets_to_lists(Xs, [Y | Ys], Zs). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% :- typeclass dependency_node(T) where [ - pred dependency_graph__add_nodes(list(pred_id)::in, module_info::in, + pred dependency_graph.add_nodes(list(pred_id)::in, module_info::in, include_imported::in, dependency_graph(T)::in, dependency_graph(T)::out) is det, - pred dependency_graph__add_arcs(list(pred_id)::in, module_info::in, + pred dependency_graph.add_arcs(list(pred_id)::in, module_info::in, include_imported::in, dependency_graph(T)::in, dependency_graph(T)::out) is det, @@ -208,33 +208,33 @@ dependency_graph__sets_to_lists([X | Xs], Ys, Zs) :- ]. :- instance dependency_node(pred_proc_id) where [ - pred(dependency_graph__add_nodes/5) is - dependency_graph__add_pred_proc_nodes, - pred(dependency_graph__add_arcs/5) is - dependency_graph__add_pred_proc_arcs, + pred(dependency_graph.add_nodes/5) is + dependency_graph.add_pred_proc_nodes, + pred(dependency_graph.add_arcs/5) is + dependency_graph.add_pred_proc_arcs, func(dependency_node/1) is id ]. :- instance dependency_node(pred_id) where [ - pred(dependency_graph__add_nodes/5) is - dependency_graph__add_pred_nodes, - pred(dependency_graph__add_arcs/5) is - dependency_graph__add_pred_arcs, + pred(dependency_graph.add_nodes/5) is + dependency_graph.add_pred_nodes, + pred(dependency_graph.add_arcs/5) is + dependency_graph.add_pred_arcs, func(dependency_node/1) is pred_proc_id_get_pred_id ]. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_pred_proc_nodes(list(pred_id)::in, +:- pred dependency_graph.add_pred_proc_nodes(list(pred_id)::in, module_info::in, include_imported::in, dependency_graph::in, dependency_graph::out) is det. -dependency_graph__add_pred_proc_nodes([], _ModuleInfo, _, !DepGraph). -dependency_graph__add_pred_proc_nodes([PredId | PredIds], ModuleInfo, Imported, +dependency_graph.add_pred_proc_nodes([], _ModuleInfo, _, !DepGraph). +dependency_graph.add_pred_proc_nodes([PredId | PredIds], ModuleInfo, Imported, !DepGraph) :- module_info_preds(ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), ( % Don't bother adding nodes (or arcs) for procedures which are imported % (i.e. which we don't have any `clauses' for). @@ -244,30 +244,30 @@ dependency_graph__add_pred_proc_nodes([PredId | PredIds], ModuleInfo, Imported, Imported = include_imported, ProcIds = pred_info_procids(PredInfo) ), - dependency_graph__add_proc_nodes(ProcIds, PredId, ModuleInfo, !DepGraph), - dependency_graph__add_pred_proc_nodes(PredIds, ModuleInfo, Imported, + dependency_graph.add_proc_nodes(ProcIds, PredId, ModuleInfo, !DepGraph), + dependency_graph.add_pred_proc_nodes(PredIds, ModuleInfo, Imported, !DepGraph). -:- pred dependency_graph__add_proc_nodes(list(proc_id)::in, pred_id::in, +:- pred dependency_graph.add_proc_nodes(list(proc_id)::in, pred_id::in, module_info::in, dependency_graph::in, dependency_graph::out) is det. -dependency_graph__add_proc_nodes([], _PredId, _ModuleInfo, !DepGraph). -dependency_graph__add_proc_nodes([ProcId | ProcIds], PredId, ModuleInfo, +dependency_graph.add_proc_nodes([], _PredId, _ModuleInfo, !DepGraph). +dependency_graph.add_proc_nodes([ProcId | ProcIds], PredId, ModuleInfo, !DepGraph) :- - relation__add_element(!.DepGraph, proc(PredId, ProcId), _, !:DepGraph), - dependency_graph__add_proc_nodes(ProcIds, PredId, ModuleInfo, !DepGraph). + relation.add_element(!.DepGraph, proc(PredId, ProcId), _, !:DepGraph), + dependency_graph.add_proc_nodes(ProcIds, PredId, ModuleInfo, !DepGraph). %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_pred_nodes(list(pred_id)::in, module_info::in, +:- pred dependency_graph.add_pred_nodes(list(pred_id)::in, module_info::in, include_imported::in, dependency_graph(pred_id)::in, dependency_graph(pred_id)::out) is det. -dependency_graph__add_pred_nodes([], _ModuleInfo, _, DepGraph, DepGraph). -dependency_graph__add_pred_nodes([PredId | PredIds], ModuleInfo, +dependency_graph.add_pred_nodes([], _ModuleInfo, _, DepGraph, DepGraph). +dependency_graph.add_pred_nodes([PredId | PredIds], ModuleInfo, IncludeImported, !DepGraph) :- module_info_preds(ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), % Don't bother adding nodes (or arcs) for predicates % which are imported (i.e. which we don't have any `clauses' for). ( @@ -276,23 +276,23 @@ dependency_graph__add_pred_nodes([PredId | PredIds], ModuleInfo, -> true ; - relation__add_element(!.DepGraph, PredId, _, !:DepGraph) + relation.add_element(!.DepGraph, PredId, _, !:DepGraph) ), - dependency_graph__add_pred_nodes(PredIds, ModuleInfo, IncludeImported, + dependency_graph.add_pred_nodes(PredIds, ModuleInfo, IncludeImported, !DepGraph). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_pred_proc_arcs(list(pred_id)::in, +:- pred dependency_graph.add_pred_proc_arcs(list(pred_id)::in, module_info::in, include_imported::in, dependency_graph::in, dependency_graph::out) is det. -dependency_graph__add_pred_proc_arcs([], _ModuleInfo, _, !DepGraph). -dependency_graph__add_pred_proc_arcs([PredId | PredIds], ModuleInfo, Imported, +dependency_graph.add_pred_proc_arcs([], _ModuleInfo, _, !DepGraph). +dependency_graph.add_pred_proc_arcs([PredId | PredIds], ModuleInfo, Imported, !DepGraph) :- module_info_preds(ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), ( % Don't bother adding nodes (or arcs) for procedures which are imported % (i.e. which we don't have any `clauses' for). @@ -302,28 +302,28 @@ dependency_graph__add_pred_proc_arcs([PredId | PredIds], ModuleInfo, Imported, Imported = include_imported, ProcIds = pred_info_procids(PredInfo) ), - dependency_graph__add_proc_arcs(ProcIds, PredId, ModuleInfo, Imported, + dependency_graph.add_proc_arcs(ProcIds, PredId, ModuleInfo, Imported, !DepGraph), - dependency_graph__add_pred_proc_arcs(PredIds, ModuleInfo, Imported, + dependency_graph.add_pred_proc_arcs(PredIds, ModuleInfo, Imported, !DepGraph). -:- pred dependency_graph__add_proc_arcs(list(proc_id)::in, pred_id::in, +:- pred dependency_graph.add_proc_arcs(list(proc_id)::in, pred_id::in, module_info::in, include_imported::in, dependency_graph::in, dependency_graph::out) is det. -dependency_graph__add_proc_arcs([], _PredId, _ModuleInfo, _, !DepGraph). -dependency_graph__add_proc_arcs([ProcId | ProcIds], PredId, ModuleInfo, +dependency_graph.add_proc_arcs([], _PredId, _ModuleInfo, _, !DepGraph). +dependency_graph.add_proc_arcs([ProcId | ProcIds], PredId, ModuleInfo, IncludeImported, !DepGraph) :- module_info_preds(ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), ( IncludeImported = do_not_include_imported, proc_info_goal(ProcInfo0, Goal), - relation__lookup_element(!.DepGraph, proc(PredId, ProcId), Caller), - dependency_graph__add_arcs_in_goal(Goal, Caller, !DepGraph) + relation.lookup_element(!.DepGraph, proc(PredId, ProcId), Caller), + dependency_graph.add_arcs_in_goal(Goal, Caller, !DepGraph) ; IncludeImported = include_imported, pred_info_import_status(PredInfo0, ImportStatus), @@ -333,24 +333,24 @@ dependency_graph__add_proc_arcs([ProcId | ProcIds], PredId, ModuleInfo, ; Imported = no, proc_info_goal(ProcInfo0, Goal), - relation__lookup_element(!.DepGraph, proc(PredId, ProcId), Caller), - dependency_graph__add_arcs_in_goal(Goal, Caller, !DepGraph) + relation.lookup_element(!.DepGraph, proc(PredId, ProcId), Caller), + dependency_graph.add_arcs_in_goal(Goal, Caller, !DepGraph) ) ), - dependency_graph__add_proc_arcs(ProcIds, PredId, ModuleInfo, + dependency_graph.add_proc_arcs(ProcIds, PredId, ModuleInfo, IncludeImported, !DepGraph). %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_pred_arcs(list(pred_id)::in, module_info::in, +:- pred dependency_graph.add_pred_arcs(list(pred_id)::in, module_info::in, include_imported::in, dependency_graph(pred_id)::in, dependency_graph(pred_id)::out) is det. -dependency_graph__add_pred_arcs([], _ModuleInfo, _, !DepGraph). -dependency_graph__add_pred_arcs([PredId | PredIds], ModuleInfo, +dependency_graph.add_pred_arcs([], _ModuleInfo, _, !DepGraph). +dependency_graph.add_pred_arcs([PredId | PredIds], ModuleInfo, IncludeImported, !DepGraph) :- module_info_preds(ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), ( IncludeImported = do_not_include_imported, pred_info_is_imported(PredInfo) @@ -360,11 +360,11 @@ dependency_graph__add_pred_arcs([PredId | PredIds], ModuleInfo, pred_info_clauses_info(PredInfo, ClausesInfo), clauses_info_clauses_rep(ClausesInfo, ClausesRep), get_clause_list_any_order(ClausesRep, Clauses), - Goals = list__map(func(clause(_, Goal, _, _)) = Goal, Clauses), - relation__lookup_element(!.DepGraph, PredId, Caller), - dependency_graph__add_arcs_in_list(Goals, Caller, !DepGraph) + Goals = list.map(func(clause(_, Goal, _, _)) = Goal, Clauses), + relation.lookup_element(!.DepGraph, PredId, Caller), + dependency_graph.add_arcs_in_list(Goals, Caller, !DepGraph) ), - dependency_graph__add_pred_arcs(PredIds, ModuleInfo, IncludeImported, + dependency_graph.add_pred_arcs(PredIds, ModuleInfo, IncludeImported, !DepGraph). %-----------------------------------------------------------------------------% @@ -377,44 +377,44 @@ pred_proc_id_get_pred_id(proc(PredId, _)) = PredId. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_arcs_in_goal(hlds_goal::in, relation_key::in, +:- pred dependency_graph.add_arcs_in_goal(hlds_goal::in, relation_key::in, dependency_graph(T)::in, dependency_graph(T)::out) is det <= dependency_node(T). -dependency_graph__add_arcs_in_goal(Goal - _GoalInfo, PPId, !DepGraph) :- - dependency_graph__add_arcs_in_goal_2(Goal, PPId, !DepGraph). +dependency_graph.add_arcs_in_goal(Goal - _GoalInfo, PPId, !DepGraph) :- + dependency_graph.add_arcs_in_goal_2(Goal, PPId, !DepGraph). %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_arcs_in_goal_2(hlds_goal_expr::in, +:- pred dependency_graph.add_arcs_in_goal_2(hlds_goal_expr::in, relation_key::in, dependency_graph(T)::in, dependency_graph(T)::out) is det <= dependency_node(T). -dependency_graph__add_arcs_in_goal_2(conj(_, Goals), Caller, !DepGraph) :- - dependency_graph__add_arcs_in_list(Goals, Caller, !DepGraph). +dependency_graph.add_arcs_in_goal_2(conj(_, Goals), Caller, !DepGraph) :- + dependency_graph.add_arcs_in_list(Goals, Caller, !DepGraph). -dependency_graph__add_arcs_in_goal_2(disj(Goals), Caller, !DepGraph) :- - dependency_graph__add_arcs_in_list(Goals, Caller, !DepGraph). +dependency_graph.add_arcs_in_goal_2(disj(Goals), Caller, !DepGraph) :- + dependency_graph.add_arcs_in_list(Goals, Caller, !DepGraph). -dependency_graph__add_arcs_in_goal_2(switch(_Var, _Det, Cases), Caller, +dependency_graph.add_arcs_in_goal_2(switch(_Var, _Det, Cases), Caller, !DepGraph) :- - dependency_graph__add_arcs_in_cases(Cases, Caller, !DepGraph). + dependency_graph.add_arcs_in_cases(Cases, Caller, !DepGraph). -dependency_graph__add_arcs_in_goal_2(if_then_else(_Vars, Cond, Then, Else), +dependency_graph.add_arcs_in_goal_2(if_then_else(_Vars, Cond, Then, Else), Caller, !DepGraph) :- - dependency_graph__add_arcs_in_goal(Cond, Caller, !DepGraph), - dependency_graph__add_arcs_in_goal(Then, Caller, !DepGraph), - dependency_graph__add_arcs_in_goal(Else, Caller, !DepGraph). + dependency_graph.add_arcs_in_goal(Cond, Caller, !DepGraph), + dependency_graph.add_arcs_in_goal(Then, Caller, !DepGraph), + dependency_graph.add_arcs_in_goal(Else, Caller, !DepGraph). -dependency_graph__add_arcs_in_goal_2(not(Goal), Caller, !DepGraph) :- - dependency_graph__add_arcs_in_goal(Goal, Caller, !DepGraph). +dependency_graph.add_arcs_in_goal_2(not(Goal), Caller, !DepGraph) :- + dependency_graph.add_arcs_in_goal(Goal, Caller, !DepGraph). -dependency_graph__add_arcs_in_goal_2(scope(_, Goal), Caller, !DepGraph) :- - dependency_graph__add_arcs_in_goal(Goal, Caller, !DepGraph). +dependency_graph.add_arcs_in_goal_2(scope(_, Goal), Caller, !DepGraph) :- + dependency_graph.add_arcs_in_goal(Goal, Caller, !DepGraph). -dependency_graph__add_arcs_in_goal_2(generic_call(_, _, _, _), _, !DepGraph). +dependency_graph.add_arcs_in_goal_2(generic_call(_, _, _, _), _, !DepGraph). -dependency_graph__add_arcs_in_goal_2(call(PredId, ProcId, _, Builtin, _, _), +dependency_graph.add_arcs_in_goal_2(call(PredId, ProcId, _, Builtin, _, _), Caller, !DepGraph) :- ( Builtin = inline_builtin -> true @@ -422,16 +422,16 @@ dependency_graph__add_arcs_in_goal_2(call(PredId, ProcId, _, Builtin, _, _), ( % If the node isn't in the relation, then we didn't insert it % because is was imported, and we don't consider it. - relation__search_element(!.DepGraph, + relation.search_element(!.DepGraph, dependency_node(proc(PredId, ProcId)), Callee) -> - relation__add(!.DepGraph, Caller, Callee, !:DepGraph) + relation.add(!.DepGraph, Caller, Callee, !:DepGraph) ; true ) ). -dependency_graph__add_arcs_in_goal_2(unify(_,_,_,Unify,_), Caller, +dependency_graph.add_arcs_in_goal_2(unify(_,_,_,Unify,_), Caller, !DepGraph) :- ( Unify = assign(_, _) @@ -439,115 +439,115 @@ dependency_graph__add_arcs_in_goal_2(unify(_,_,_,Unify,_), Caller, Unify = simple_test(_, _) ; Unify = construct(_, Cons, _, _, _, _, _), - dependency_graph__add_arcs_in_cons(Cons, Caller, !DepGraph) + dependency_graph.add_arcs_in_cons(Cons, Caller, !DepGraph) ; Unify = deconstruct(_, Cons, _, _, _, _), - dependency_graph__add_arcs_in_cons(Cons, Caller, !DepGraph) + dependency_graph.add_arcs_in_cons(Cons, Caller, !DepGraph) ; Unify = complicated_unify(_, _, _) ). % There can be no dependencies within a foreign_proc -dependency_graph__add_arcs_in_goal_2( +dependency_graph.add_arcs_in_goal_2( foreign_proc(_, _, _, _, _, _), _, !DepGraph). -dependency_graph__add_arcs_in_goal_2(shorthand(ShorthandGoal), Caller, +dependency_graph.add_arcs_in_goal_2(shorthand(ShorthandGoal), Caller, !DepGraph) :- - dependency_graph__add_arcs_in_goal_2_shorthand(ShorthandGoal, Caller, + dependency_graph.add_arcs_in_goal_2_shorthand(ShorthandGoal, Caller, !DepGraph). -:- pred dependency_graph__add_arcs_in_goal_2_shorthand(shorthand_goal_expr::in, +:- pred dependency_graph.add_arcs_in_goal_2_shorthand(shorthand_goal_expr::in, relation_key::in, dependency_graph(T)::in, dependency_graph(T)::out) is det <= dependency_node(T). -dependency_graph__add_arcs_in_goal_2_shorthand(bi_implication(LHS, RHS), +dependency_graph.add_arcs_in_goal_2_shorthand(bi_implication(LHS, RHS), Caller, !DepGraph) :- - dependency_graph__add_arcs_in_list([LHS, RHS], Caller, !DepGraph). + dependency_graph.add_arcs_in_list([LHS, RHS], Caller, !DepGraph). %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_arcs_in_list(list(hlds_goal)::in, +:- pred dependency_graph.add_arcs_in_list(list(hlds_goal)::in, relation_key::in, dependency_graph(T)::in, dependency_graph(T)::out) is det <= dependency_node(T). -dependency_graph__add_arcs_in_list([], _Caller, !DepGraph). -dependency_graph__add_arcs_in_list([Goal|Goals], Caller, !DepGraph) :- - dependency_graph__add_arcs_in_goal(Goal, Caller, !DepGraph), - dependency_graph__add_arcs_in_list(Goals, Caller, !DepGraph). +dependency_graph.add_arcs_in_list([], _Caller, !DepGraph). +dependency_graph.add_arcs_in_list([Goal|Goals], Caller, !DepGraph) :- + dependency_graph.add_arcs_in_goal(Goal, Caller, !DepGraph), + dependency_graph.add_arcs_in_list(Goals, Caller, !DepGraph). %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_arcs_in_cases(list(case)::in, relation_key::in, +:- pred dependency_graph.add_arcs_in_cases(list(case)::in, relation_key::in, dependency_graph(T)::in, dependency_graph(T)::out) is det <= dependency_node(T). -dependency_graph__add_arcs_in_cases([], _Caller, !DepGraph). -dependency_graph__add_arcs_in_cases([case(Cons, Goal) | Goals], Caller, +dependency_graph.add_arcs_in_cases([], _Caller, !DepGraph). +dependency_graph.add_arcs_in_cases([case(Cons, Goal) | Goals], Caller, !DepGraph) :- - dependency_graph__add_arcs_in_cons(Cons, Caller, !DepGraph), - dependency_graph__add_arcs_in_goal(Goal, Caller, !DepGraph), - dependency_graph__add_arcs_in_cases(Goals, Caller, !DepGraph). + dependency_graph.add_arcs_in_cons(Cons, Caller, !DepGraph), + dependency_graph.add_arcs_in_goal(Goal, Caller, !DepGraph), + dependency_graph.add_arcs_in_cases(Goals, Caller, !DepGraph). %-----------------------------------------------------------------------------% -:- pred dependency_graph__add_arcs_in_cons(cons_id::in, relation_key::in, +:- pred dependency_graph.add_arcs_in_cons(cons_id::in, relation_key::in, dependency_graph(T)::in, dependency_graph(T)::out) is det <= dependency_node(T). -dependency_graph__add_arcs_in_cons(cons(_, _), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(int_const(_), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(string_const(_), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(float_const(_), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(pred_const(ShroudedPredProcId, _), Caller, +dependency_graph.add_arcs_in_cons(cons(_, _), _Caller, !DepGraph). +dependency_graph.add_arcs_in_cons(int_const(_), _Caller, !DepGraph). +dependency_graph.add_arcs_in_cons(string_const(_), _Caller, !DepGraph). +dependency_graph.add_arcs_in_cons(float_const(_), _Caller, !DepGraph). +dependency_graph.add_arcs_in_cons(pred_const(ShroudedPredProcId, _), Caller, !DepGraph) :- PredProcId = unshroud_pred_proc_id(ShroudedPredProcId), ( % If the node isn't in the relation, then we didn't insert it % because it was imported, and we don't consider it. - relation__search_element(!.DepGraph, dependency_node(PredProcId), + relation.search_element(!.DepGraph, dependency_node(PredProcId), Callee) -> - relation__add(!.DepGraph, Caller, Callee, !:DepGraph) + relation.add(!.DepGraph, Caller, Callee, !:DepGraph) ; true ). -dependency_graph__add_arcs_in_cons(type_ctor_info_const(_, _, _), +dependency_graph.add_arcs_in_cons(type_ctor_info_const(_, _, _), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(base_typeclass_info_const(_, _, _, _), +dependency_graph.add_arcs_in_cons(base_typeclass_info_const(_, _, _, _), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(type_info_cell_constructor(_), +dependency_graph.add_arcs_in_cons(type_info_cell_constructor(_), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(typeclass_info_cell_constructor, +dependency_graph.add_arcs_in_cons(typeclass_info_cell_constructor, _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(tabling_pointer_const(_), +dependency_graph.add_arcs_in_cons(tabling_pointer_const(_), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(deep_profiling_proc_layout(_), +dependency_graph.add_arcs_in_cons(deep_profiling_proc_layout(_), _Caller, !DepGraph). -dependency_graph__add_arcs_in_cons(table_io_decl(_), +dependency_graph.add_arcs_in_cons(table_io_decl(_), _Caller, !DepGraph). %-----------------------------------------------------------------------------% -:- pred dependency_graph__write_dependency_ordering( +:- pred dependency_graph.write_dependency_ordering( list(list(pred_proc_id))::in, module_info::in, int::in, io::di, io::uo) is det. -dependency_graph__write_dependency_ordering([], _ModuleInfo, _N, !IO) :- - io__write_string("\n", !IO). -dependency_graph__write_dependency_ordering([Clique | Rest], ModuleInfo, N, +dependency_graph.write_dependency_ordering([], _ModuleInfo, _N, !IO) :- + io.write_string("\n", !IO). +dependency_graph.write_dependency_ordering([Clique | Rest], ModuleInfo, N, !IO) :- - io__write_string("% Clique ", !IO), - io__write_int(N, !IO), - io__write_string("\n", !IO), - dependency_graph__write_clique(Clique, ModuleInfo, !IO), + io.write_string("% Clique ", !IO), + io.write_int(N, !IO), + io.write_string("\n", !IO), + dependency_graph.write_clique(Clique, ModuleInfo, !IO), N1 = N + 1, - dependency_graph__write_dependency_ordering(Rest, ModuleInfo, N1, !IO). + dependency_graph.write_dependency_ordering(Rest, ModuleInfo, N1, !IO). -:- pred dependency_graph__write_clique(list(pred_proc_id)::in, module_info::in, +:- pred dependency_graph.write_clique(list(pred_proc_id)::in, module_info::in, io::di, io::uo) is det. -dependency_graph__write_clique([], _ModuleInfo, !IO). -dependency_graph__write_clique([proc(PredId, ProcId) | Rest], ModuleInfo, +dependency_graph.write_clique([], _ModuleInfo, !IO). +dependency_graph.write_clique([proc(PredId, ProcId) | Rest], ModuleInfo, !IO) :- module_info_pred_proc_info(ModuleInfo, PredId, ProcId, PredInfo, ProcInfo), @@ -555,27 +555,27 @@ dependency_graph__write_clique([proc(PredId, ProcId) | Rest], ModuleInfo, proc_info_declared_determinism(ProcInfo, Det), proc_info_argmodes(ProcInfo, Modes), proc_info_context(ProcInfo, Context), - varset__init(ModeVarSet), + varset.init(ModeVarSet), - io__write_string("% ", !IO), + io.write_string("% ", !IO), mercury_output_pred_mode_subdecl(ModeVarSet, unqualified(Name), Modes, Det, Context, !IO), - io__write_string("\n", !IO), - dependency_graph__write_clique(Rest, ModuleInfo, !IO). + io.write_string("\n", !IO), + dependency_graph.write_clique(Rest, ModuleInfo, !IO). %-----------------------------------------------------------------------------% -dependency_graph__write_prof_dependency_graph(!ModuleInfo, !IO) :- +dependency_graph.write_prof_dependency_graph(!ModuleInfo, !IO) :- module_info_ensure_dependency_info(!ModuleInfo), module_info_dependency_info(!.ModuleInfo, DepInfo), write_graph(DepInfo, write_empty_node, write_prof_dep_graph_link(!.ModuleInfo), !IO). -dependency_graph__write_dependency_graph(!ModuleInfo, !IO) :- +dependency_graph.write_dependency_graph(!ModuleInfo, !IO) :- module_info_ensure_dependency_info(!ModuleInfo), module_info_dependency_info(!.ModuleInfo, DepInfo), - io__write_string("% Dependency graph\n", !IO), - io__write_string("\n\n% Dependency ordering\n", !IO), + io.write_string("% Dependency graph\n", !IO), + io.write_string("\n\n% Dependency ordering\n", !IO), write_graph(DepInfo, write_empty_node, write_dep_graph_link(!.ModuleInfo), !IO). @@ -589,10 +589,10 @@ write_empty_node(_, !IO). write_prof_dep_graph_link(ModuleInfo, Parent, Child, !IO) :- Parent = proc(PPredId, PProcId), % Caller Child = proc(CPredId, CProcId), % Callee - dependency_graph__output_label(ModuleInfo, PPredId, PProcId, !IO), - io__write_string("\t", !IO), - dependency_graph__output_label(ModuleInfo, CPredId, CProcId, !IO), - io__write_string("\n", !IO). + dependency_graph.output_label(ModuleInfo, PPredId, PProcId, !IO), + io.write_string("\t", !IO), + dependency_graph.output_label(ModuleInfo, CPredId, CProcId, !IO), + io.write_string("\n", !IO). :- pred write_dep_graph_link(module_info::in, pred_proc_id::in, pred_proc_id::in, io::di, io::uo) is det. @@ -612,28 +612,28 @@ write_dep_graph_link(ModuleInfo, Parent, Child, !IO) :- proc_info_declared_determinism(CProcInfo, CDet), proc_info_argmodes(CProcInfo, CModes), proc_info_context(CProcInfo, CContext), - varset__init(ModeVarSet), + varset.init(ModeVarSet), mercury_output_pred_mode_subdecl(ModeVarSet, unqualified(PName), PModes, PDet, PContext, !IO), - io__write_string(" -> ", !IO), + io.write_string(" -> ", !IO), mercury_output_pred_mode_subdecl(ModeVarSet, unqualified(CName), CModes, CDet, CContext, !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). %-----------------------------------------------------------------------------% write_graph(DepInfo, WriteNode, WriteLink, !IO) :- hlds_dependency_info_get_dependency_graph(DepInfo, DepGraph), - relation__domain(DepGraph, DomSet), - set__to_sorted_list(DomSet, DomList), + relation.domain(DepGraph, DomSet), + set.to_sorted_list(DomSet, DomList), write_graph_nodes(DomList, DepGraph, WriteNode, WriteLink, !IO). write_graph_nodes([], _Graph, _WriteNode, _WriteLink, !IO). write_graph_nodes([Node | Nodes], Graph, WriteNode, WriteLink, !IO) :- WriteNode(Node, !IO), - relation__lookup_element(Graph, Node, NodeKey), - relation__lookup_from(Graph, NodeKey, ChildrenSet), - set__to_sorted_list(ChildrenSet, Children), + relation.lookup_element(Graph, Node, NodeKey), + relation.lookup_from(Graph, NodeKey, ChildrenSet), + set.to_sorted_list(ChildrenSet, Children), write_graph_children(Children, Node, Graph, WriteLink, !IO), write_graph_nodes(Nodes, Graph, WriteNode, WriteLink, !IO). @@ -644,7 +644,7 @@ write_graph_nodes([Node | Nodes], Graph, WriteNode, WriteLink, !IO) :- write_graph_children([], _Parent, _Graph, _WriteLink, !IO). write_graph_children([ChildKey | Children], Parent, Graph, WriteLink, !IO) :- - relation__lookup_key(Graph, ChildKey, Child), + relation.lookup_key(Graph, ChildKey, Child), WriteLink(Parent, Child, !IO), write_graph_children(Children, Parent, Graph, WriteLink, !IO). @@ -652,24 +652,24 @@ write_graph_children([ChildKey | Children], Parent, Graph, WriteLink, !IO) :- % Print out the label corresponding to the given pred_id and proc_id. % -:- pred dependency_graph__output_label(module_info::in, +:- pred dependency_graph.output_label(module_info::in, pred_id::in, proc_id::in, io::di, io::uo) is det. -dependency_graph__output_label(ModuleInfo, PredId, ProcId, !IO) :- +dependency_graph.output_label(ModuleInfo, PredId, ProcId, !IO) :- ProcLabel = make_proc_label(ModuleInfo, PredId, ProcId), output_proc_label(ProcLabel, !IO). %-----------------------------------------------------------------------------% -dependency_graph__get_scc_entry_points(SCC, HigherSCCs, +dependency_graph.get_scc_entry_points(SCC, HigherSCCs, ModuleInfo, EntryPoints) :- - list__filter(dependency_graph__is_entry_point(HigherSCCs, ModuleInfo), + list.filter(dependency_graph.is_entry_point(HigherSCCs, ModuleInfo), SCC, EntryPoints). -:- pred dependency_graph__is_entry_point(list(list(pred_proc_id))::in, +:- pred dependency_graph.is_entry_point(list(list(pred_proc_id))::in, module_info::in, pred_proc_id::in) is semidet. -dependency_graph__is_entry_point(HigherSCCs, ModuleInfo, PredProcId) :- +dependency_graph.is_entry_point(HigherSCCs, ModuleInfo, PredProcId) :- ( % Is the predicate exported? PredProcId = proc(PredId, _ProcId), @@ -680,27 +680,27 @@ dependency_graph__is_entry_point(HigherSCCs, ModuleInfo, PredProcId) :- module_info_dependency_info(ModuleInfo, DepInfo), hlds_dependency_info_get_dependency_graph(DepInfo, DepGraph), - relation__lookup_element(DepGraph, PredProcId, PredProcIdKey), - relation__lookup_to(DepGraph, PredProcIdKey, CallingKeys), - set__member(CallingKey, CallingKeys), - relation__lookup_key(DepGraph, CallingKey, CallingPred), - list__member(HigherSCC, HigherSCCs), - list__member(CallingPred, HigherSCC) + relation.lookup_element(DepGraph, PredProcId, PredProcIdKey), + relation.lookup_to(DepGraph, PredProcIdKey, CallingKeys), + set.member(CallingKey, CallingKeys), + relation.lookup_key(DepGraph, CallingKey, CallingPred), + list.member(HigherSCC, HigherSCCs), + list.member(CallingPred, HigherSCC) ). %-----------------------------------------------------------------------------% % Find the SCCs called from a given SCC. % -:- pred dependency_graph__get_called_scc_ids(scc_id::in, relation(scc_id)::in, +:- pred dependency_graph.get_called_scc_ids(scc_id::in, relation(scc_id)::in, set(scc_id)::out) is det. -dependency_graph__get_called_scc_ids(SCCid, SCCRel, CalledSCCSet) :- - relation__lookup_element(SCCRel, SCCid, SCCidKey), - relation__lookup_from(SCCRel, SCCidKey, CalledSCCKeys), - set__to_sorted_list(CalledSCCKeys, CalledSCCKeyList), - list__map(relation__lookup_key(SCCRel), CalledSCCKeyList, CalledSCCs), - set__list_to_set(CalledSCCs, CalledSCCSet). +dependency_graph.get_called_scc_ids(SCCid, SCCRel, CalledSCCSet) :- + relation.lookup_element(SCCRel, SCCid, SCCidKey), + relation.lookup_from(SCCRel, SCCidKey, CalledSCCKeys), + set.to_sorted_list(CalledSCCKeys, CalledSCCKeyList), + list.map(relation.lookup_key(SCCRel), CalledSCCKeyList, CalledSCCs), + set.list_to_set(CalledSCCs, CalledSCCSet). %-----------------------------------------------------------------------------% @@ -723,8 +723,8 @@ dependency_graph__get_called_scc_ids(SCCid, SCCRel, CalledSCCSet) :- handle_higher_order_args([], _, _, _, _, !SCCRel, !NoMerge). handle_higher_order_args([Arg | Args], IsAgg, SCCid, Map, PredSCC, !SCCRel, !NoMerge) :- - ( multi_map__search(Map, Arg, PredProcIds) -> - list__foldl2(handle_higher_order_arg(PredSCC, IsAgg, SCCid), + ( multi_map.search(Map, Arg, PredProcIds) -> + list.foldl2(handle_higher_order_arg(PredSCC, IsAgg, SCCid), PredProcIds, !SCCRel, !NoMerge) ; true @@ -739,19 +739,19 @@ handle_higher_order_args([Arg | Args], IsAgg, SCCid, Map, PredSCC, handle_higher_order_arg(PredSCC, IsAgg, SCCid, PredProcId, !SCCRel, !NoMerge) :- - ( map__search(PredSCC, PredProcId, CalledSCCid) -> + ( map.search(PredSCC, PredProcId, CalledSCCid) -> % Make sure anything called through an aggregate % is not merged into the current sub-module. ( IsAgg = yes, - set__insert(!.NoMerge, CalledSCCid, !:NoMerge) + set.insert(!.NoMerge, CalledSCCid, !:NoMerge) ; IsAgg = no ), ( CalledSCCid = SCCid -> true ; - relation__add_values(!.SCCRel, SCCid, CalledSCCid, !:SCCRel) + relation.add_values(!.SCCRel, SCCid, CalledSCCid, !:SCCRel) ) ; true diff --git a/compiler/det_util.m b/compiler/det_util.m index 1f45fcfb5..8dbf7998c 100644 --- a/compiler/det_util.m +++ b/compiler/det_util.m @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__det_util. +:- module check_hlds.det_util. :- interface. :- import_module hlds.hlds_data. @@ -115,11 +115,11 @@ delete_unreachable_cases([Case | Cases0], [ConsId | ConsIds], Cases) :- ). interpret_unify(X, var(Y), !Subst) :- - term__unify(term__variable(X), term__variable(Y), !Subst). + term.unify(variable(X), variable(Y), !Subst). interpret_unify(X, functor(ConsId, _, ArgVars), !Subst) :- - term__var_list_to_term_list(ArgVars, ArgTerms), + term.var_list_to_term_list(ArgVars, ArgTerms), cons_id_and_args_to_term(ConsId, ArgTerms, RhsTerm), - term__unify(term__variable(X), RhsTerm, !Subst). + term.unify(variable(X), RhsTerm, !Subst). interpret_unify(_X, lambda_goal(_, _, _, _, _, _, _, _), !Subst). % For ease of implementation we just ignore unifications with lambda terms. % This is a safe approximation, it just prevents us from optimizing them @@ -128,9 +128,9 @@ interpret_unify(_X, lambda_goal(_, _, _, _, _, _, _, _), !Subst). det_lookup_detism(DetInfo, PredId, ModeId, Detism) :- det_info_get_module_info(DetInfo, ModuleInfo), module_info_preds(ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ModeId, ProcInfo), + map.lookup(ProcTable, ModeId, ProcInfo), proc_info_interface_determinism(ProcInfo, Detism). det_get_proc_info(DetInfo, ProcInfo) :- @@ -138,23 +138,23 @@ det_get_proc_info(DetInfo, ProcInfo) :- det_info_get_pred_id(DetInfo, PredId), det_info_get_proc_id(DetInfo, ProcId), module_info_preds(ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, ProcInfo). + map.lookup(ProcTable, ProcId, ProcInfo). det_lookup_var_type(ModuleInfo, ProcInfo, Var, TypeDefn) :- proc_info_vartypes(ProcInfo, VarTypes), - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ( type_to_ctor_and_args(Type, TypeCtor, _) -> module_info_get_type_table(ModuleInfo, TypeTable), - map__search(TypeTable, TypeCtor, TypeDefn) + map.search(TypeTable, TypeCtor, TypeDefn) ; unexpected(this_file, "det_lookup_var_type") ). det_no_output_vars(Vars, InstMap, InstMapDelta, DetInfo) :- det_info_get_module_info(DetInfo, ModuleInfo), - instmap__no_output_vars(InstMap, InstMapDelta, Vars, + instmap.no_output_vars(InstMap, InstMapDelta, Vars, DetInfo ^ vartypes, ModuleInfo). %-----------------------------------------------------------------------------% @@ -171,9 +171,9 @@ det_no_output_vars(Vars, InstMap, InstMapDelta, DetInfo) :- ). det_info_init(ModuleInfo, VarTypes, PredId, ProcId, Globals, DetInfo) :- - globals__lookup_bool_option(Globals, reorder_conj, ReorderConj), - globals__lookup_bool_option(Globals, reorder_disj, ReorderDisj), - globals__lookup_bool_option(Globals, fully_strict, FullyStrict), + globals.lookup_bool_option(Globals, reorder_conj, ReorderConj), + globals.lookup_bool_option(Globals, reorder_disj, ReorderDisj), + globals.lookup_bool_option(Globals, fully_strict, FullyStrict), DetInfo = det_info(ModuleInfo, VarTypes, PredId, ProcId, ReorderConj, ReorderDisj, FullyStrict). diff --git a/compiler/disj_gen.m b/compiler/disj_gen.m index e1b8c11f0..06f86eac9 100644 --- a/compiler/disj_gen.m +++ b/compiler/disj_gen.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2000,2002-2005 The University of Melbourne. +% Copyright (C) 1994-2000,2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__disj_gen. +:- module ll_backend.disj_gen. :- interface. :- import_module hlds.code_model. @@ -57,7 +57,7 @@ generate_disj(AddTrailOps, CodeModel, Goals, DisjGoalInfo, Code, !CI) :- ( Goals = [], ( CodeModel = model_semi -> - code_info__generate_failure(Code, !CI) + code_info.generate_failure(Code, !CI) ; unexpected(this_file, "generate_disj: empty disjunction.") ) @@ -68,7 +68,7 @@ generate_disj(AddTrailOps, CodeModel, Goals, DisjGoalInfo, Code, !CI) :- ( Resume = resume_point(ResumeVarsPrime, _) -> ResumeVars = ResumeVarsPrime ; - set__init(ResumeVars) + set.init(ResumeVars) ), generate_real_disj(AddTrailOps, CodeModel, ResumeVars, Goals, DisjGoalInfo, Code, !CI) @@ -76,7 +76,7 @@ generate_disj(AddTrailOps, CodeModel, Goals, DisjGoalInfo, Code, !CI) :- %---------------------------------------------------------------------------% -:- pred disj_gen__generate_real_disj(bool::in, code_model::in, +:- pred disj_gen.generate_real_disj(bool::in, code_model::in, set(prog_var)::in, list(hlds_goal)::in, hlds_goal_info::in, code_tree::out, code_info::in, code_info::out) is det. @@ -87,15 +87,15 @@ generate_real_disj(AddTrailOps, CodeModel, ResumeVars, Goals, DisjGoalInfo, % on backtracking to any disjunct are materialized into % registers or stack slots. Their locations are recorded % in ResumeMap. - code_info__produce_vars(ResumeVars, ResumeMap, FlushCode, !CI), + code_info.produce_vars(ResumeVars, ResumeMap, FlushCode, !CI), % If we are using a trail, save the current trail state % before the first disjunct. % XXX We should use a scheme such as the one we use for heap % recovery for semi and det disjunctions, and delay saving % the ticket until necessary. - code_info__get_globals(!.CI, Globals), - code_info__maybe_save_ticket(AddTrailOps, SaveTicketCode, MaybeTicketSlot, + code_info.get_globals(!.CI, Globals), + code_info.maybe_save_ticket(AddTrailOps, SaveTicketCode, MaybeTicketSlot, !CI), % If we are using a grade in which we can recover memory @@ -106,9 +106,9 @@ generate_real_disj(AddTrailOps, CodeModel, ResumeVars, Goals, DisjGoalInfo, % across all disjuncts, even disjuncts that cannot % themselves allocate memory, since we can backtrack % to disjunct N after control leaves disjunct N-1. - globals__lookup_bool_option(Globals, reclaim_heap_on_nondet_failure, + globals.lookup_bool_option(Globals, reclaim_heap_on_nondet_failure, ReclaimHeap), - code_info__maybe_save_hp(ReclaimHeap, SaveHpCode, MaybeHpSlot, !CI) + code_info.maybe_save_hp(ReclaimHeap, SaveHpCode, MaybeHpSlot, !CI) ; % With other disjunctions, we can backtrack to % disjunct N only from disjunct N-1, so if disjunct @@ -117,7 +117,7 @@ generate_real_disj(AddTrailOps, CodeModel, ResumeVars, Goals, DisjGoalInfo, % for no disjunct to allocate memory, we delay saving % the heap pointer and allocating a stack slot for % the saved hp as long as possible. - globals__lookup_bool_option(Globals, reclaim_heap_on_semidet_failure, + globals.lookup_bool_option(Globals, reclaim_heap_on_semidet_failure, ReclaimHeap), SaveHpCode = empty, MaybeHpSlot = no @@ -126,12 +126,12 @@ generate_real_disj(AddTrailOps, CodeModel, ResumeVars, Goals, DisjGoalInfo, % Save the values of any stack slots we may hijack, % and if necessary, set the redofr slot of the top frame % to point to this frame. - code_info__prepare_for_disj_hijack(CodeModel, HijackInfo, + code_info.prepare_for_disj_hijack(CodeModel, HijackInfo, PrepareHijackCode, !CI), - code_info__get_next_label(EndLabel, !CI), + code_info.get_next_label(EndLabel, !CI), - code_info__remember_position(!.CI, BranchStart), + code_info.remember_position(!.CI, BranchStart), PrevBranchModifiesTrail = no, generate_disjuncts(Goals, CodeModel, ResumeMap, no, HijackInfo, DisjGoalInfo, EndLabel, ReclaimHeap, PrevBranchModifiesTrail, @@ -139,9 +139,9 @@ generate_real_disj(AddTrailOps, CodeModel, ResumeVars, Goals, DisjGoalInfo, !CI), goal_info_get_store_map(DisjGoalInfo, StoreMap), - code_info__after_all_branches(StoreMap, MaybeEnd, !CI), + code_info.after_all_branches(StoreMap, MaybeEnd, !CI), ( CodeModel = model_non -> - code_info__set_resume_point_to_unknown(!CI) + code_info.set_resume_point_to_unknown(!CI) ; true ), @@ -164,14 +164,14 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, PrevBranchModifiesTrail, MaybeHpSlot0, MaybeTicketSlot, BranchStart0, MaybeEnd0, MaybeEnd, Code, !CI) :- - code_info__reset_to_position(BranchStart0, !CI), + code_info.reset_to_position(BranchStart0, !CI), % % If this is not the first disjunct, generate the resume point by which % we arrive at this disjunct. % ( MaybeEntryResumePoint = yes(EntryResumePoint), - code_info__generate_resume_point(EntryResumePoint, + code_info.generate_resume_point(EntryResumePoint, EntryResumePointCode, !CI) ; MaybeEntryResumePoint = no, @@ -188,12 +188,12 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, MaybeEntryResumePoint = yes(_), % Reset the heap pointer to recover memory allocated by the % previous disjunct(s), if necessary. - code_info__maybe_restore_hp(MaybeHpSlot0, RestoreHpCode), + code_info.maybe_restore_hp(MaybeHpSlot0, RestoreHpCode), % Reset the solver state if necessary. ( PrevBranchModifiesTrail = yes, - code_info__maybe_reset_ticket(MaybeTicketSlot, undo, + code_info.maybe_reset_ticket(MaybeTicketSlot, undo, RestoreTicketCode) ; % Don't bother if the previous branch is known not to modify @@ -220,7 +220,7 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, goal_may_allocate_heap(Goal), MaybeHpSlot0 = no -> - code_info__save_hp(SaveHpCode, HpSlot, !CI), + code_info.save_hp(SaveHpCode, HpSlot, !CI), MaybeHpSlot = yes(HpSlot), % % This method of updating BranchStart0 is ugly. The best @@ -230,10 +230,10 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, % entry into this disjunction, which overwrites part of the % location-dependent state originally in BranchStart0. % - code_info__save_hp_in_branch(BranchSaveHpCode, BranchHpSlot, + code_info.save_hp_in_branch(BranchSaveHpCode, BranchHpSlot, BranchStart0, BranchStart), - tree__flatten(SaveHpCode, HpCodeList), - tree__flatten(BranchSaveHpCode, BranchHpCodeList), + tree.flatten(SaveHpCode, HpCodeList), + tree.flatten(BranchSaveHpCode, BranchHpCodeList), expect(unify(HpCodeList, BranchHpCodeList), this_file, "cannot use same code for saving hp"), expect(unify(HpSlot, BranchHpSlot), this_file, @@ -244,21 +244,21 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, BranchStart = BranchStart0 ), - code_info__make_resume_point(ResumeVars, ResumeLocs, FullResumeMap, + code_info.make_resume_point(ResumeVars, ResumeLocs, FullResumeMap, NextResumePoint, !CI), - code_info__effect_resume_point(NextResumePoint, CodeModel, ModContCode, + code_info.effect_resume_point(NextResumePoint, CodeModel, ModContCode, !CI), - trace__maybe_generate_internal_event_code(Goal, DisjGoalInfo, + trace.maybe_generate_internal_event_code(Goal, DisjGoalInfo, TraceCode, !CI), goal_info_get_code_model(GoalInfo, GoalCodeModel), - code_gen__generate_goal(GoalCodeModel, Goal, GoalCode, !CI), + code_gen.generate_goal(GoalCodeModel, Goal, GoalCode, !CI), ( CodeModel = model_non -> % We can backtrack to the next disjunct from outside, % so we make sure every variable in the resume set % is in its stack slot. - code_info__flush_resume_vars_to_stack(ResumeVarsCode, !CI), + code_info.flush_resume_vars_to_stack(ResumeVarsCode, !CI), % We hang onto any temporary slots holding saved % heap pointers and/or tickets, thus ensuring that @@ -267,12 +267,12 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, ; ResumeVarsCode = empty, - code_info__maybe_release_hp(MaybeHpSlot, !CI), + code_info.maybe_release_hp(MaybeHpSlot, !CI), % We're committing to this disjunct if it succeeds. - code_info__maybe_reset_prune_and_release_ticket(MaybeTicketSlot, + code_info.maybe_reset_prune_and_release_ticket(MaybeTicketSlot, commit, PruneTicketCode, !CI), - code_info__reset_resume_known(BranchStart, !CI) + code_info.reset_resume_known(BranchStart, !CI) ), % Forget the variables that are needed only at the resumption point at @@ -280,16 +280,16 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, % when their storage is clobbered by the movement of the live % variables to the places indicated in the store map. % - code_info__pop_resume_point(!CI), - code_info__pickup_zombies(Zombies, !CI), - code_info__make_vars_forward_dead(Zombies, !CI), + code_info.pop_resume_point(!CI), + code_info.pickup_zombies(Zombies, !CI), + code_info.make_vars_forward_dead(Zombies, !CI), % Put every variable whose value is needed after the disjunction to % the place indicated by StoreMap, and accumulate information about % the code_info state at the ends of the branches so far. % goal_info_get_store_map(DisjGoalInfo, StoreMap), - code_info__generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd1, + code_info.generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd1, SaveCode, !CI), BranchCode = node([ @@ -301,7 +301,7 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, % ThisBranchModifiesTrail = pred_to_bool(goal_may_modify_trail(Goal)), - disj_gen__generate_disjuncts(Goals, CodeModel, FullResumeMap, + disj_gen.generate_disjuncts(Goals, CodeModel, FullResumeMap, yes(NextResumePoint), HijackInfo, DisjGoalInfo, EndLabel, ReclaimHeap, ThisBranchModifiesTrail, MaybeHpSlot, MaybeTicketSlot, BranchStart, MaybeEnd1, MaybeEnd, RestCode, !CI), @@ -315,25 +315,25 @@ generate_disjuncts([Goal0 | Goals], CodeModel, FullResumeMap, % Restore the heap pointer and solver state if necessary. % - code_info__maybe_restore_and_release_hp(MaybeHpSlot0, RestoreHpCode, + code_info.maybe_restore_and_release_hp(MaybeHpSlot0, RestoreHpCode, !CI), ( PrevBranchModifiesTrail = yes, - code_info__maybe_reset_discard_and_release_ticket(MaybeTicketSlot, + code_info.maybe_reset_discard_and_release_ticket(MaybeTicketSlot, undo, RestoreTicketCode, !CI) ; PrevBranchModifiesTrail = no, - code_info__maybe_discard_and_release_ticket(MaybeTicketSlot, + code_info.maybe_discard_and_release_ticket(MaybeTicketSlot, RestoreTicketCode, !CI) ), - code_info__undo_disj_hijack(HijackInfo, UndoCode, !CI), + code_info.undo_disj_hijack(HijackInfo, UndoCode, !CI), - trace__maybe_generate_internal_event_code(Goal0, DisjGoalInfo, + trace.maybe_generate_internal_event_code(Goal0, DisjGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal0, GoalCode, !CI), + code_gen.generate_goal(CodeModel, Goal0, GoalCode, !CI), goal_info_get_store_map(DisjGoalInfo, StoreMap), - code_info__generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, SaveCode, + code_info.generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, SaveCode, !CI), EndCode = node([ diff --git a/compiler/dupelim.m b/compiler/dupelim.m index 297a04405..7a1c59a6d 100644 --- a/compiler/dupelim.m +++ b/compiler/dupelim.m @@ -1,16 +1,16 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1995-2005 The University of Melbourne. +% Copyright (C) 1995-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% - +% % File: dupelim.m. % Author: zs. - +% % This module eliminate some duplicate code sequences. - +% % Our algorithm has the following stages. % % 1. Divide the code of the procedure into basic blocks. @@ -42,7 +42,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__dupelim. +:- module ll_backend.dupelim. :- interface. :- import_module ll_backend.llds. @@ -84,15 +84,16 @@ % generalization of the blocks started by Exemplar and OtherLabels. % OtherLabels must be nonempty. % -:- type cluster ---> cluster(label, list(label)). +:- type cluster + ---> cluster(label, list(label)). dupelim_main(ProcLabel, !C, Instrs0, Instrs) :- create_basic_blocks(Instrs0, Comments, ProcLabel, !C, _NewLabels, LabelSeq0, BlockMap0), - map__init(StdMap0), - set__init(Fixed0), - dupelim__build_maps(LabelSeq0, BlockMap0, StdMap0, StdMap, Fixed0, Fixed), - map__values(StdMap, StdList), + map.init(StdMap0), + set.init(Fixed0), + dupelim_build_maps(LabelSeq0, BlockMap0, StdMap0, StdMap, Fixed0, Fixed), + map.values(StdMap, StdList), find_clusters(StdList, Fixed, [], Clusters), ( Clusters = [], @@ -101,43 +102,42 @@ dupelim_main(ProcLabel, !C, Instrs0, Instrs) :- Instrs = Instrs0 ; Clusters = [_ | _], - map__init(ReplMap0), + map.init(ReplMap0), process_clusters(Clusters, LabelSeq0, LabelSeq, BlockMap0, BlockMap, ReplMap0, ReplMap), flatten_basic_blocks(LabelSeq, BlockMap, Instrs1), - opt_util__replace_labels_instruction_list(Instrs1, + opt_util.replace_labels_instruction_list(Instrs1, ReplMap, yes, Instrs2), - list__append(Comments, Instrs2, Instrs) + list.append(Comments, Instrs2, Instrs) ). %-----------------------------------------------------------------------------% - % dupelim__build_maps builds up a map mapping standardized instruction + % dupelim_build_maps builds up a map mapping standardized instruction % sequences to the label(s) that start basic blocks with that standardized % form, and a set showing which labels are fallen into. % -:- pred dupelim__build_maps(list(label)::in, block_map::in, +:- pred dupelim_build_maps(list(label)::in, block_map::in, std_map::in, std_map::out, set(label)::in, set(label)::out) is det. -dupelim__build_maps([], _, !StdMap, !Fixed). -dupelim__build_maps([Label | Labels], BlockMap, !StdMap, !Fixed) :- - map__lookup(BlockMap, Label, BlockInfo), +dupelim_build_maps([], _, !StdMap, !Fixed). +dupelim_build_maps([Label | Labels], BlockMap, !StdMap, !Fixed) :- + map.lookup(BlockMap, Label, BlockInfo), BlockInfo = block_info(_, _, Instrs, _, _, MaybeFallThrough), standardize_instr_block(Instrs, MaybeFallThrough, StdInstrs), - ( map__search(!.StdMap, StdInstrs, Cluster) -> - svmap__det_update(StdInstrs, [Label | Cluster], !StdMap) + ( map.search(!.StdMap, StdInstrs, Cluster) -> + svmap.det_update(StdInstrs, [Label | Cluster], !StdMap) ; - svmap__det_insert(StdInstrs, [Label], !StdMap) + svmap.det_insert(StdInstrs, [Label], !StdMap) ), ( MaybeFallThrough = yes(FallIntoLabel), - svset__insert(FallIntoLabel, !Fixed) + svset.insert(FallIntoLabel, !Fixed) ; MaybeFallThrough = no ), - list__foldl(add_pragma_pref_labels, Instrs, !Fixed), - dupelim__build_maps(Labels, BlockMap, !StdMap, !Fixed). - + list.foldl(add_pragma_pref_labels, Instrs, !Fixed), + dupelim_build_maps(Labels, BlockMap, !StdMap, !Fixed). :- pred add_pragma_pref_labels(instruction::in, set(label)::in, set(label)::out) is det. @@ -149,19 +149,19 @@ add_pragma_pref_labels(Instr, !FoldFixed) :- -> ( MaybeFixedLabel = yes(FixedLabel), - svset__insert(FixedLabel, !FoldFixed) + svset.insert(FixedLabel, !FoldFixed) ; MaybeFixedLabel = no ), ( MaybeLayoutLabel = yes(LayoutLabel), - svset__insert(LayoutLabel, !FoldFixed) + svset.insert(LayoutLabel, !FoldFixed) ; MaybeLayoutLabel = no ), ( MaybeOnlyLayoutLabel = yes(OnlyLayoutLabel), - svset__insert(OnlyLayoutLabel, !FoldFixed) + svset.insert(OnlyLayoutLabel, !FoldFixed) ; MaybeOnlyLayoutLabel = no ) @@ -193,9 +193,9 @@ find_clusters([Labels | LabelsList], Fixed, !Clusters) :- % if there aren't at least two labels whose blocks have the same % standardized form. IsFallenInto = (pred(Label::in) is semidet :- - set__member(Label, Fixed) + set.member(Label, Fixed) ), - list__filter(IsFallenInto, Labels, FixedLabels, NonFixedLabels), + list.filter(IsFallenInto, Labels, FixedLabels, NonFixedLabels), NonFixedLabels = [FirstNonFixed | OtherNonFixed] -> ( @@ -226,7 +226,7 @@ find_clusters([Labels | LabelsList], Fixed, !Clusters) :- process_clusters([], !LabelSeq, !BlockMap, !ReplMap). process_clusters([Cluster | Clusters], !LabelSeq, !BlockMap, !ReplMap) :- Cluster = cluster(Exemplar, ElimLabels), - map__lookup(!.BlockMap, Exemplar, ExemplarInfo0), + map.lookup(!.BlockMap, Exemplar, ExemplarInfo0), ExemplarInfo0 = block_info(ExLabel, ExLabelInstr, ExInstrs0, ExFallInto, ExSideLabels, ExMaybeFallThrough), expect(unify(Exemplar, ExLabel), this_file, "exemplar label mismatch"), @@ -235,7 +235,7 @@ process_clusters([Cluster | Clusters], !LabelSeq, !BlockMap, !ReplMap) :- ExMaybeFallThrough, UnifiedMaybeFallThrough), ExemplarInfo = block_info(ExLabel, ExLabelInstr, UnifiedInstrs, ExFallInto, ExSideLabels, UnifiedMaybeFallThrough), - svmap__det_update(Exemplar, ExemplarInfo, !BlockMap), + svmap.det_update(Exemplar, ExemplarInfo, !BlockMap), process_clusters(Clusters, !LabelSeq, !BlockMap, !ReplMap). % Given the current form of a basic block (instructions and fallthrough), @@ -257,7 +257,7 @@ process_elim_labels([], Instrs, !LabelSeq, _, _, !ReplMap, Instrs, !MaybeFallThrough). process_elim_labels([ElimLabel | ElimLabels], Instrs0, !LabelSeq, BlockMap, Exemplar, !ReplMap, Instrs, !MaybeFallThrough) :- - map__lookup(BlockMap, ElimLabel, ElimLabelInfo), + map.lookup(BlockMap, ElimLabel, ElimLabelInfo), ElimLabelInfo = block_info(ElimLabel2, _, ElimInstrs, _, _, ElimMaybeFallThrough), expect(unify(ElimLabel, ElimLabel2), this_file, "elim label mismatch"), @@ -265,8 +265,8 @@ process_elim_labels([ElimLabel | ElimLabels], Instrs0, !LabelSeq, BlockMap, most_specific_block(Instrs0, !.MaybeFallThrough, ElimInstrs, ElimMaybeFallThrough, Instrs1, !:MaybeFallThrough) -> - list__delete_all(!.LabelSeq, ElimLabel, !:LabelSeq), - map__det_insert(!.ReplMap, ElimLabel, Exemplar, !:ReplMap), + list.delete_all(!.LabelSeq, ElimLabel, !:LabelSeq), + map.det_insert(!.ReplMap, ElimLabel, Exemplar, !:ReplMap), process_elim_labels(ElimLabels, Instrs1, !LabelSeq, BlockMap, Exemplar, !ReplMap, Instrs, !MaybeFallThrough) ; @@ -293,7 +293,7 @@ standardize_instr_block(Instrs0, MaybeFallThrough, Uinstrs) :- ( MaybeFallThrough = yes(Label), Goto = goto(label(Label)), - list__append(Uinstrs1, [Goto], Uinstrs) + list.append(Uinstrs1, [Goto], Uinstrs) ; MaybeFallThrough = no, Uinstrs = Uinstrs1 @@ -538,13 +538,13 @@ standardize_block(Instrs, MaybeFallThrough, StdInstrs) :- ( MaybeFallThrough = yes(Label), ( - list__last(Instrs, LastInstr), + list.last(Instrs, LastInstr), LastInstr = goto(label(Label)) - _ -> StdInstrs = Instrs ; Goto = goto(label(Label)) - "", - list__append(Instrs, [Goto], StdInstrs) + list.append(Instrs, [Goto], StdInstrs) ) ; MaybeFallThrough = no, @@ -565,7 +565,7 @@ most_specific_block(Instrs1, MaybeFallThrough1, % had no executable instructions. While most_specific_instrs % can delete comments from its input instruction sequences, % it cannot delete executable instructions. - list__last_det(Instrs, LastInstr), + list.last_det(Instrs, LastInstr), ( LastInstr = goto(label(Label)) - _ -> MaybeFallThrough = yes(Label) ; diff --git a/compiler/dupproc.m b/compiler/dupproc.m index eaa98ac66..c2d1d2268 100644 --- a/compiler/dupproc.m +++ b/compiler/dupproc.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2005 The University of Melbourne. +% Copyright (C) 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -16,10 +16,9 @@ % %-----------------------------------------------------------------------------% -:- module ll_backend__dupproc. +:- module ll_backend.dupproc. :- interface. -% :- import_module hlds__hlds_pred. :- import_module ll_backend.llds. :- import_module mdbcomp.prim_data. @@ -59,7 +58,7 @@ eliminate_duplicate_procs(IdProcs, Procs, !DupProcMap) :- standardize_proc(Proc1, StdProc1, !.DupProcMap), eliminate_dup_procs([Id1 - StdProc1], IdProcsTail, FinalIdProcsTail, !DupProcMap), - assoc_list__values(FinalIdProcsTail, FinalProcsTail), + assoc_list.values(FinalIdProcsTail, FinalProcsTail), Procs = [Proc1 | FinalProcsTail] ). @@ -79,14 +78,14 @@ eliminate_dup_procs(ModelStdProcs0, [Id - Proc0 | IdProcs0], MaybeProc = yes(ProcPrime) -> Proc = ProcPrime, - map__det_insert(!.DupProcMap, Id, MatchingId, !:DupProcMap), + map.det_insert(!.DupProcMap, Id, MatchingId, !:DupProcMap), ModelStdProcs = ModelStdProcs0 ; Proc = Proc0, standardize_proc(Proc0, StdProc0, !.DupProcMap), % Since the number of procedures per predicate is tiny, % the quadratic behavior here is not a problem. - list__append(ModelStdProcs0, [Id - StdProc0], ModelStdProcs) + list.append(ModelStdProcs0, [Id - StdProc0], ModelStdProcs) ), eliminate_dup_procs(ModelStdProcs, IdProcs0, IdProcs, !DupProcMap). @@ -96,7 +95,7 @@ eliminate_dup_procs(ModelStdProcs0, [Id - Proc0 | IdProcs0], find_matching_model_proc([ModelId - ModelStdProc | ModelIdProcs], Id, Proc, DupProcMap, MatchingId) :- - map__det_insert(DupProcMap, Id, ModelId, AugDupProcMap), + map.det_insert(DupProcMap, Id, ModelId, AugDupProcMap), standardize_proc(Proc, StdProc, AugDupProcMap), StdInstrs = StdProc ^ cproc_code, ModelStdInstrs = ModelStdProc ^ cproc_code, @@ -123,8 +122,8 @@ maybe_redirect_proc(Proc0, Target, MaybeProc) :- get_prologue(Instrs0, LabelInstr, _Comments, LaterInstrs), Redirect = goto(label(entry(local, Target))) - "Redirect to procedure with identical body", - list__filter(disallowed_instr, LaterInstrs, DisallowedInstrs), - list__length(LaterInstrs, NumLaterInstrs), + list.filter(disallowed_instr, LaterInstrs, DisallowedInstrs), + list.length(LaterInstrs, NumLaterInstrs), ( DisallowedInstrs = [], % The threshold here is a guess. I don't think the precise value @@ -293,7 +292,7 @@ standardize_instr(Instr, StdInstr, DupProcMap) :- map(proc_label, proc_label)::in) is det. standardize_proc_label(ProcLabel, StdProcLabel, DupProcMap) :- - ( map__search(DupProcMap, ProcLabel, FoundProcLabel) -> + ( map.search(DupProcMap, ProcLabel, FoundProcLabel) -> StdProcLabel = FoundProcLabel ; StdProcLabel = ProcLabel diff --git a/compiler/equiv_type.m b/compiler/equiv_type.m index d07dfe18e..ee8aea1c3 100644 --- a/compiler/equiv_type.m +++ b/compiler/equiv_type.m @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module parse_tree__equiv_type. +:- module parse_tree.equiv_type. :- interface. :- import_module mdbcomp.prim_data. @@ -130,20 +130,20 @@ % definitions. Then we go through the item list and replace them. % expand_eqv_types(ModuleName, Items0, Items, Error, EqvMap, !Info, !IO) :- - map__init(EqvMap0), - map__init(EqvInstMap0), + map.init(EqvMap0), + map.init(EqvInstMap0), build_eqv_map(Items0, EqvMap0, EqvMap, EqvInstMap0, EqvInstMap), replace_in_item_list(ModuleName, Items0, EqvMap, EqvInstMap, [], RevItems, [], ErrorList, !Info), - list__reverse(RevItems, Items), + list.reverse(RevItems, Items), ( ErrorList = [], Error = no ; ErrorList = [_ | _], - list__foldl(report_error, list__reverse(ErrorList), !IO), + list.foldl(report_error, list.reverse(ErrorList), !IO), Error = yes, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). % We need to expand equivalence insts in @@ -178,13 +178,12 @@ build_eqv_map([Item - _Context | Items0], !EqvMap, !EqvInstMap) :- skip_abstract_imported_items(Items0, Items) ; Item = type_defn(VarSet, Name, Args, eqv_type(Body), _Cond) -> Items = Items0, - list__length(Args, Arity), - svmap__set(Name - Arity, eqv_type_body(VarSet, Args, Body), !EqvMap) + list.length(Args, Arity), + svmap.set(Name - Arity, eqv_type_body(VarSet, Args, Body), !EqvMap) ; Item = inst_defn(VarSet, Name, Args, eqv_inst(Body), _) -> Items = Items0, - list__length(Args, Arity), - svmap__set(Name - Arity, eqv_inst_body(VarSet, Args, Body), - !EqvInstMap) + list.length(Args, Arity), + svmap.set(Name - Arity, eqv_inst_body(VarSet, Args, Body), !EqvInstMap) ; Items = Items0 ), @@ -270,7 +269,7 @@ replace_in_item(ModuleName, Context, EqvMap, _EqvInstMap, type_defn(VarSet, Name, TArgs, TypeDefn, Cond), Error, !Info) :- - list__length(TArgs, Arity), + list.length(TArgs, Arity), maybe_record_expanded_items(ModuleName, Name, !.Info, UsedTypeCtors0), replace_in_type_defn(EqvMap, Name - Arity, TypeDefn0, @@ -305,7 +304,7 @@ replace_in_item(ModuleName, Det0, Det, ExpandedItems0, ExpandedItems, Errors), ItemType = pred_or_func_to_item_type(PredOrFunc), - list__length(TypesAndModes, Arity), + list.length(TypesAndModes, Arity), adjust_func_arity(PredOrFunc, OrigArity, Arity), finish_recording_expanded_items( item_id(ItemType, PredName - OrigArity), ExpandedItems, !Info). @@ -335,7 +334,7 @@ replace_in_item(ModuleName, ( MaybePredOrFunc = yes(PredOrFunc), ItemType = pred_or_func_to_item_type(PredOrFunc), - list__length(Modes, Arity), + list.length(Modes, Arity), adjust_func_arity(PredOrFunc, OrigArity, Arity), finish_recording_expanded_items( item_id(ItemType, PredName - OrigArity), ExpandedItems, !Info) @@ -350,7 +349,7 @@ replace_in_item(ModuleName, typeclass(Constraints, FunDeps, ClassName, Vars, ClassInterface, VarSet), Errors, !Info) :- - list__length(Vars, Arity), + list.length(Vars, Arity), maybe_record_expanded_items(ModuleName, ClassName, !.Info, ExpandedItems0), replace_in_prog_constraint_list(EqvMap, @@ -382,14 +381,14 @@ replace_in_item(ModuleName, -> UsedTypeCtors0 = no ; - UsedTypeCtors0 = yes(ModuleName - set__init) + UsedTypeCtors0 = yes(ModuleName - set.init) ), replace_in_prog_constraint_list(EqvMap, Constraints0, Constraints, VarSet0, VarSet1, UsedTypeCtors0, UsedTypeCtors1), replace_in_type_list(EqvMap, Ts0, Ts, _, _, VarSet1, VarSet, UsedTypeCtors1, UsedTypeCtors), - list__length(Ts0, Arity), + list.length(Ts0, Arity), finish_recording_expanded_items( item_id(typeclass_item, ClassName - Arity), UsedTypeCtors, !Info). @@ -425,7 +424,7 @@ replace_in_item(ModuleName, [], !Info) :- QualName = qualified(ModuleName, MutName), maybe_record_expanded_items(ModuleName, QualName, !.Info, ExpandedItems0), - TVarSet0 = varset__init, + TVarSet0 = varset.init, replace_in_type(EqvMap, Type0, Type, _TypeChanged, TVarSet0, _TVarSet, ExpandedItems0, ExpandedItems1), replace_in_inst(Inst0, EqvInstMap, Inst, @@ -473,7 +472,7 @@ replace_in_prog_constraints(EqvMap, Cs0, Cs, !VarSet, !Info) :- is det. replace_in_prog_constraint_list(EqvMap, !Cs, !VarSet, !Info) :- - list__map_foldl2(replace_in_prog_constraint(EqvMap), !Cs, !VarSet, !Info). + list.map_foldl2(replace_in_prog_constraint(EqvMap), !Cs, !VarSet, !Info). replace_in_prog_constraint(EqvMap, Constraint0, Constraint, !VarSet, !Info) :- Constraint0 = constraint(ClassName, Ts0), @@ -489,7 +488,7 @@ replace_in_prog_constraint(EqvMap, Constraint0, Constraint, !VarSet, !Info) :- replace_in_class_interface(ClassInterface0, EqvMap, EqvInstMap, ClassInterface, !Errors, !Info) :- - list__map_foldl2(replace_in_class_method(EqvMap, EqvInstMap), + list.map_foldl2(replace_in_class_method(EqvMap, EqvInstMap), ClassInterface0, ClassInterface, !Errors, !Info). :- pred replace_in_class_method(eqv_map::in, eqv_inst_map::in, @@ -545,7 +544,7 @@ replace_in_subst(EqvMap, [Var - Type0 | Subst0], %-----------------------------------------------------------------------------% replace_in_ctors(EqvMap, !Ctors, !VarSet, !Info) :- - list__map_foldl2(replace_in_ctor(EqvMap), !Ctors, !VarSet, !Info). + list.map_foldl2(replace_in_ctor(EqvMap), !Ctors, !VarSet, !Info). :- pred replace_in_ctor(eqv_map::in, constructor::in, constructor::out, tvarset::in, tvarset::out, @@ -647,7 +646,7 @@ replace_in_type_2(EqvMap, TypeCtorsAlreadyExpanded, Type0, Type, Type0 = defined(SymName, TArgs0, Kind), replace_in_type_list_2(EqvMap, TypeCtorsAlreadyExpanded, TArgs0, TArgs, ArgsChanged, no, Circ0, !VarSet, !Info), - Arity = list__length(TArgs), + Arity = list.length(TArgs), TypeCtor = SymName - Arity, replace_type_ctor(EqvMap, TypeCtorsAlreadyExpanded, Type0, TypeCtor, TArgs, Kind, Type, ArgsChanged, Changed, @@ -666,8 +665,8 @@ replace_in_type_2(EqvMap, TypeCtorsAlreadyExpanded, Type0, Type, replace_in_type_2(EqvMap, TypeCtorsAlreadyExpanded, Ret0, Ret, RetChanged, RetCirc, !VarSet, !Info), MaybeRet = yes(Ret), - Changed = bool__or(ArgsChanged, RetChanged), - Circ = bool__or(ArgsCirc, RetCirc) + Changed = bool.or(ArgsChanged, RetChanged), + Circ = bool.or(ArgsCirc, RetCirc) ; MaybeRet0 = no, MaybeRet = no, @@ -723,21 +722,21 @@ replace_in_type_2(EqvMap, TypeCtorsAlreadyExpanded, Type0, Type, replace_type_ctor(EqvMap, TypeCtorsAlreadyExpanded, Type0, TypeCtor, TArgs, Kind, Type, !Changed, !Circ, !VarSet, !Info) :- - ( list__member(TypeCtor, TypeCtorsAlreadyExpanded) -> + ( list.member(TypeCtor, TypeCtorsAlreadyExpanded) -> AlreadyExpanded = yes ; AlreadyExpanded = no ), ( - map__search(EqvMap, TypeCtor, eqv_type_body(EqvVarSet, Args0, Body0)), + map.search(EqvMap, TypeCtor, eqv_type_body(EqvVarSet, Args0, Body0)), - % Don't merge in the variable names from the type declaration to - % avoid creating multiple variables with the same name so that - % `varset__create_name_var_map' can be used on the resulting - % tvarset. make_hlds uses `varset__create_name_var_map' to match - % up type variables in `:- pragma type_spec' declarations and - % explicit type qualifications with the type variables in the - % predicate's declaration. + % Don't merge in the variable names from the type declaration to avoid + % creating multiple variables with the same name so that + % `varset.create_name_var_map' can be used on the resulting tvarset. + % make_hlds uses `varset.create_name_var_map' to match up type + % variables in `:- pragma type_spec' declarations and explicit type + % qualifications with the type variables in the predicate's + % declaration. tvarset_merge_renaming_without_names(!.VarSet, EqvVarSet, !:VarSet, Renaming), @@ -745,10 +744,10 @@ replace_type_ctor(EqvMap, TypeCtorsAlreadyExpanded, Type0, AlreadyExpanded = no -> !:Changed = yes, - map__apply_to_list(Args0, Renaming, Args), + map.apply_to_list(Args0, Renaming, Args), apply_variable_renaming_to_type(Renaming, Body0, Body1), record_expanded_item(item_id(type_item, TypeCtor), !Info), - map__from_corresponding_lists(Args, TArgs, Subst), + map.from_corresponding_lists(Args, TArgs, Subst), apply_subst_to_type(Subst, Body1, Body), replace_in_type_2(EqvMap, [TypeCtor | TypeCtorsAlreadyExpanded], Body, Type, _, !:Circ, !VarSet, !Info) @@ -761,14 +760,14 @@ replace_type_ctor(EqvMap, TypeCtorsAlreadyExpanded, Type0, !.Changed = no, Type = Type0 ), - bool__or(AlreadyExpanded, !Circ) + bool.or(AlreadyExpanded, !Circ) ). :- pred replace_in_inst(mer_inst::in, eqv_inst_map::in, mer_inst::out, equiv_type_info::in, equiv_type_info::out) is det. replace_in_inst(Inst0, EqvInstMap, Inst, !Info) :- - replace_in_inst(Inst0, EqvInstMap, set__init, Inst, !Info). + replace_in_inst(Inst0, EqvInstMap, set.init, Inst, !Info). :- pred replace_in_inst(mer_inst::in, eqv_inst_map::in, set(inst_id)::in, mer_inst::out, @@ -778,17 +777,17 @@ replace_in_inst(Inst0, EqvInstMap, ExpandedInstIds, Inst, !Info) :- ( Inst0 = defined_inst(user_inst(SymName, ArgInsts)) -> InstId = SymName - length(ArgInsts), ( - set__member(InstId, ExpandedInstIds) + set.member(InstId, ExpandedInstIds) -> Inst = Inst0 ; - map__search(EqvInstMap, InstId, + map.search(EqvInstMap, InstId, eqv_inst_body(_, EqvInstParams, EqvInst)) -> inst_substitute_arg_list(EqvInstParams, ArgInsts, EqvInst, Inst1), record_expanded_item(item_id(inst_item, InstId), !Info), replace_in_inst(Inst1, EqvInstMap, - set__insert(ExpandedInstIds, InstId), Inst, !Info) + set.insert(ExpandedInstIds, InstId), Inst, !Info) ; Inst = Inst0 ) @@ -844,13 +843,13 @@ replace_in_pred_type(PredName, PredOrFunc, Context, EqvMap, EqvInstMap, ExtraTypesAndModes = [] ; ExtraModes = [] -> Errors = Errors1, - ExtraTypesAndModes = list__map((func(Type) = type_only(Type)), + ExtraTypesAndModes = list.map((func(Type) = type_only(Type)), ExtraTypes) ; length(ExtraTypes) `with_type` int = length(ExtraModes) -> Errors = Errors1, - assoc_list__from_corresponding_lists(ExtraTypes, ExtraModes, + assoc_list.from_corresponding_lists(ExtraTypes, ExtraModes, ExtraTypesModes), - ExtraTypesAndModes = list__map( + ExtraTypesAndModes = list.map( (func(Type - Mode) = type_and_mode(Type, Mode)), ExtraTypesModes) ; @@ -877,7 +876,7 @@ replace_in_pred_type(PredName, PredOrFunc, Context, EqvMap, EqvInstMap, ; ExtraTypesAndModes = [_ | _], OrigItemId = item_id(pred_or_func_to_item_type(PredOrFunc), - PredName - list__length(TypesAndModes0)), + PredName - list.length(TypesAndModes0)), record_expanded_item(OrigItemId, !Info), TypesAndModes = TypesAndModes1 ++ ExtraTypesAndModes ). @@ -941,7 +940,7 @@ replace_in_pred_mode(PredName, OrigArity, Context, DeclType, is det. replace_in_tms(EqvMap, !TMs, !VarSet, !Info) :- - list__map_foldl2(replace_in_tm(EqvMap), !TMs, !VarSet, !Info). + list.map_foldl2(replace_in_tm(EqvMap), !TMs, !VarSet, !Info). :- pred replace_in_tm(eqv_map::in, type_and_mode::in, type_and_mode::out, tvarset::in, tvarset::out, @@ -965,7 +964,7 @@ maybe_record_expanded_items(ModuleName, SymName, yes(_), ( SymName = qualified(ModuleName, _) -> MaybeInfo = no ; - MaybeInfo = yes(ModuleName - set__init) + MaybeInfo = yes(ModuleName - set.init) ). :- pred record_expanded_item(item_id::in, @@ -985,7 +984,7 @@ record_expanded_item_2(ItemId, ModuleName - Items0, % We don't need to record local types. Items = Items0 ; - Items = set__insert(Items0, ItemId) + Items = set.insert(Items0, ItemId) ). finish_recording_expanded_items(_, no, no, no). @@ -994,7 +993,7 @@ finish_recording_expanded_items(_, yes(_), no, _) :- unexpected(this_file, "finish_recording_expanded_items"). finish_recording_expanded_items(Item, yes(_ - ExpandedItems), yes(Info0), yes(Info)) :- - recompilation__record_expanded_items(Item, ExpandedItems, Info0, Info). + recompilation.record_expanded_items(Item, ExpandedItems, Info0, Info). %-----------------------------------------------------------------------------% @@ -1014,11 +1013,11 @@ report_error(circular_equivalence(Item) - Context, !IO) :- ). report_error(invalid_with_type(SymName, PredOrFunc) - Context, !IO) :- Pieces = [words("In type declaration for"), - words(error_util__pred_or_func_to_string(PredOrFunc)), - fixed(error_util__describe_sym_name(SymName)), + words(error_util.pred_or_func_to_string(PredOrFunc)), + fixed(error_util.describe_sym_name(SymName)), suffix(":"), nl, words("error: expected higher order"), - words(error_util__pred_or_func_to_string(PredOrFunc)), + words(error_util.pred_or_func_to_string(PredOrFunc)), words("type after `with_type`.")], write_error_pieces(Context, 0, Pieces, !IO). report_error(invalid_with_inst(DeclType, SymName, MaybePredOrFunc) - Context, @@ -1030,18 +1029,18 @@ report_error(invalid_with_inst(DeclType, SymName, MaybePredOrFunc) - Context, MaybePredOrFunc = no, PredOrFuncStr = "" ; MaybePredOrFunc = yes(PredOrFunc), - PredOrFuncStr = error_util__pred_or_func_to_string(PredOrFunc) + PredOrFuncStr = error_util.pred_or_func_to_string(PredOrFunc) ), Pieces = [words("In"), words(DeclStr), words("for"), words(PredOrFuncStr), - fixed(error_util__describe_sym_name(SymName)), suffix(":"), nl, + fixed(error_util.describe_sym_name(SymName)), suffix(":"), nl, words("error: expected higher order "), words(PredOrFuncStr), words("inst after `with_inst`.")], write_error_pieces(Context, 0, Pieces, !IO). report_error(non_matching_with_type_with_inst(SymName, PredOrFunc) - Context, !IO) :- Pieces = [words("In type declaration for"), - words(error_util__pred_or_func_to_string(PredOrFunc)), - fixed(error_util__describe_sym_name(SymName)), + words(error_util.pred_or_func_to_string(PredOrFunc)), + fixed(error_util.describe_sym_name(SymName)), suffix(":"), nl, words("error: the `with_type` and `with_inst`"), words("annotations are incompatible.")], diff --git a/compiler/equiv_type_hlds.m b/compiler/equiv_type_hlds.m index 0c0d5cf8a..29b042808 100644 --- a/compiler/equiv_type_hlds.m +++ b/compiler/equiv_type_hlds.m @@ -17,7 +17,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__equiv_type_hlds. +:- module transform_hlds.equiv_type_hlds. :- interface. :- import_module hlds.hlds_module. @@ -62,37 +62,37 @@ replace_in_hlds(!ModuleInfo) :- module_info_get_type_table(!.ModuleInfo, Types0), - map__foldl2(add_type_to_eqv_map, Types0, map__init, EqvMap, - set__init, EqvExportTypes), - set__fold(mark_eqv_exported_types, EqvExportTypes, Types0, Types1), + map.foldl2(add_type_to_eqv_map, Types0, map.init, EqvMap, + set.init, EqvExportTypes), + set.fold(mark_eqv_exported_types, EqvExportTypes, Types0, Types1), module_info_get_maybe_recompilation_info(!.ModuleInfo, MaybeRecompInfo0), module_info_get_name(!.ModuleInfo, ModuleName), - map__map_foldl(replace_in_type_defn(ModuleName, EqvMap), Types1, Types, + map.map_foldl(replace_in_type_defn(ModuleName, EqvMap), Types1, Types, MaybeRecompInfo0, MaybeRecompInfo), module_info_set_type_table(Types, !ModuleInfo), module_info_set_maybe_recompilation_info(MaybeRecompInfo, !ModuleInfo), - InstCache0 = map__init, + InstCache0 = map.init, module_info_get_inst_table(!.ModuleInfo, Insts0), replace_in_inst_table(EqvMap, Insts0, Insts, InstCache0, InstCache1), module_info_set_inst_table(Insts, !ModuleInfo), module_info_predids(!.ModuleInfo, PredIds), - list__foldl2(replace_in_pred(EqvMap), PredIds, !ModuleInfo, InstCache1, _). + list.foldl2(replace_in_pred(EqvMap), PredIds, !ModuleInfo, InstCache1, _). :- pred add_type_to_eqv_map(type_ctor::in, hlds_type_defn::in, eqv_map::in, eqv_map::out, set(type_ctor)::in, set(type_ctor)::out) is det. add_type_to_eqv_map(TypeCtor, Defn, !EqvMap, !EqvExportTypes) :- - hlds_data__get_type_defn_body(Defn, Body), + hlds_data.get_type_defn_body(Defn, Body), ( Body = eqv_type(EqvType) -> - hlds_data__get_type_defn_tvarset(Defn, TVarSet), - hlds_data__get_type_defn_tparams(Defn, Params), - hlds_data__get_type_defn_status(Defn, Status), - svmap__det_insert(TypeCtor, eqv_type_body(TVarSet, Params, EqvType), + hlds_data.get_type_defn_tvarset(Defn, TVarSet), + hlds_data.get_type_defn_tparams(Defn, Params), + hlds_data.get_type_defn_status(Defn, Status), + svmap.det_insert(TypeCtor, eqv_type_body(TVarSet, Params, EqvType), !EqvMap), ( status_is_exported(Status, yes) -> add_type_ctors_to_set(EqvType, !EqvExportTypes) @@ -108,8 +108,8 @@ add_type_to_eqv_map(TypeCtor, Defn, !EqvMap, !EqvExportTypes) :- add_type_ctors_to_set(Type, !Set) :- ( type_to_ctor_and_args(Type, TypeCtor, Args) -> - svset__insert(TypeCtor, !Set), - list__foldl(add_type_ctors_to_set, Args, !Set) + svset.insert(TypeCtor, !Set), + list.foldl(add_type_ctors_to_set, Args, !Set) ; true ). @@ -118,9 +118,9 @@ add_type_ctors_to_set(Type, !Set) :- is det. mark_eqv_exported_types(TypeCtor, !TypeTable) :- - ( map__search(!.TypeTable, TypeCtor, Defn0) -> + ( map.search(!.TypeTable, TypeCtor, Defn0) -> set_type_defn_in_exported_eqv(yes, Defn0, Defn), - svmap__det_update(TypeCtor, Defn, !TypeTable) + svmap.det_update(TypeCtor, Defn, !TypeTable) ; % We can get here for builtin `types' such as func. Since their unify % and compare preds are in the runtime system, not generated by the @@ -133,18 +133,18 @@ mark_eqv_exported_types(TypeCtor, !TypeTable) :- maybe(recompilation_info)::in, maybe(recompilation_info)::out) is det. replace_in_type_defn(ModuleName, EqvMap, TypeCtor, !Defn, !MaybeRecompInfo) :- - hlds_data__get_type_defn_tvarset(!.Defn, TVarSet0), - hlds_data__get_type_defn_body(!.Defn, Body0), - equiv_type__maybe_record_expanded_items(ModuleName, fst(TypeCtor), + hlds_data.get_type_defn_tvarset(!.Defn, TVarSet0), + hlds_data.get_type_defn_body(!.Defn, Body0), + equiv_type.maybe_record_expanded_items(ModuleName, fst(TypeCtor), !.MaybeRecompInfo, EquivTypeInfo0), ( Body0 = du_type(Ctors0, _, _, _, _, _), - equiv_type__replace_in_ctors(EqvMap, Ctors0, Ctors, + equiv_type.replace_in_ctors(EqvMap, Ctors0, Ctors, TVarSet0, TVarSet, EquivTypeInfo0, EquivTypeInfo), Body = Body0 ^ du_type_ctors := Ctors ; Body0 = eqv_type(Type0), - equiv_type__replace_in_type(EqvMap, Type0, Type, _, + equiv_type.replace_in_type(EqvMap, Type0, Type, _, TVarSet0, TVarSet, EquivTypeInfo0, EquivTypeInfo), Body = eqv_type(Type) ; @@ -156,7 +156,7 @@ replace_in_type_defn(ModuleName, EqvMap, TypeCtor, !Defn, !MaybeRecompInfo) :- Body0 = solver_type(SolverTypeDetails0, UserEq), SolverTypeDetails0 = solver_type_details(RepnType0, InitPred, GroundInst, AnyInst, MutableItems), - equiv_type__replace_in_type(EqvMap, RepnType0, RepnType, _, + equiv_type.replace_in_type(EqvMap, RepnType0, RepnType, _, TVarSet0, TVarSet, EquivTypeInfo0, EquivTypeInfo), SolverTypeDetails = solver_type_details(RepnType, InitPred, GroundInst, AnyInst, MutableItems), @@ -167,10 +167,10 @@ replace_in_type_defn(ModuleName, EqvMap, TypeCtor, !Defn, !MaybeRecompInfo) :- Body = Body0, TVarSet = TVarSet0 ), - equiv_type__finish_recording_expanded_items( + equiv_type.finish_recording_expanded_items( item_id(type_body_item, TypeCtor), EquivTypeInfo, !MaybeRecompInfo), - hlds_data__set_type_defn_body(Body, !Defn), - hlds_data__set_type_defn_tvarset(TVarSet, !Defn). + hlds_data.set_type_defn_body(Body, !Defn), + hlds_data.set_type_defn_tvarset(TVarSet, !Defn). :- pred replace_in_inst_table(eqv_map::in, inst_table::in, inst_table::out, @@ -182,7 +182,7 @@ replace_in_inst_table(EqvMap, !InstTable, !Cache) :- % % so this is unnecessary. % % % inst_table_get_user_insts(!.InstTable, UserInsts0), -% map__map_values( +% map.map_values( % (pred(_::in, Defn0::in, Defn::out) is det :- % Body0 = Defn0 ^ inst_body, % ( @@ -191,7 +191,7 @@ replace_in_inst_table(EqvMap, !InstTable, !Cache) :- % ; % Body0 = eqv_inst(Inst0), % % XXX We don't have a valid tvarset here. -% TVarSet0 = varset__init. +% TVarSet0 = varset.init. % replace_in_inst(EqvMap, Inst0, Inst, % TVarSet0, _) % ) @@ -228,36 +228,36 @@ replace_in_inst_table(EqvMap, !InstTable, !Cache) :- inst_cache::in, inst_cache::out) is det. replace_in_inst_table(P, EqvMap, Map0, Map, !Cache) :- - map__to_assoc_list(Map0, AL0), - list__map_foldl( + map.to_assoc_list(Map0, AL0), + list.map_foldl( (pred((Name0 - T0)::in, (Name - T)::out, !.Cache::in, !:Cache::out) is det :- % XXX We don't have a valid tvarset here. - varset__init(TVarSet), + varset.init(TVarSet), replace_in_inst_name(EqvMap, Name0, Name, _, TVarSet, _, !Cache), P(T0, T, !Cache) ), AL0, AL, !Cache), - map__from_assoc_list(AL, Map). + map.from_assoc_list(AL, Map). :- pred replace_in_merge_inst_table(eqv_map::in, merge_inst_table::in, merge_inst_table::out, inst_cache::in, inst_cache::out) is det. replace_in_merge_inst_table(EqvMap, Map0, Map, !Cache) :- - map__to_assoc_list(Map0, AL0), - list__map_foldl( + map.to_assoc_list(Map0, AL0), + list.map_foldl( (pred(((InstA0 - InstB0) - MaybeInst0)::in, ((InstA - InstB) - MaybeInst)::out, !.Cache::in, !:Cache::out) is det :- some [!TVarSet] ( % XXX We don't have a valid tvarset here. - !:TVarSet = varset__init, + !:TVarSet = varset.init, replace_in_inst(EqvMap, InstA0, InstA, _, !TVarSet, !Cache), replace_in_inst(EqvMap, InstB0, InstB, _, !.TVarSet, _, !Cache), replace_in_maybe_inst(EqvMap, MaybeInst0, MaybeInst, !Cache) ) ), AL0, AL, !Cache), - map__from_assoc_list(AL, Map). + map.from_assoc_list(AL, Map). :- pred replace_in_maybe_inst(eqv_map::in, maybe_inst::in, maybe_inst::out, inst_cache::in, inst_cache::out) is det. @@ -265,7 +265,7 @@ replace_in_merge_inst_table(EqvMap, Map0, Map, !Cache) :- replace_in_maybe_inst(_, unknown, unknown, !Cache). replace_in_maybe_inst(EqvMap, known(Inst0), known(Inst), !Cache) :- % XXX We don't have a valid tvarset here. - varset__init(TVarSet), + varset.init(TVarSet), replace_in_inst(EqvMap, Inst0, Inst, _, TVarSet, _, !Cache). :- pred replace_in_maybe_inst_det(eqv_map::in, @@ -276,7 +276,7 @@ replace_in_maybe_inst_det(_, unknown, unknown, !Cache). replace_in_maybe_inst_det(EqvMap, known(Inst0, Det), known(Inst, Det), !Cache) :- % XXX We don't have a valid tvarset here. - varset__init(TVarSet), + varset.init(TVarSet), replace_in_inst(EqvMap, Inst0, Inst, _, TVarSet, _, !Cache). :- pred replace_in_pred(eqv_map::in, pred_id::in, @@ -290,17 +290,17 @@ replace_in_pred(EqvMap, PredId, !ModuleInfo, !Cache) :- module_info_get_maybe_recompilation_info(!.ModuleInfo, MaybeRecompInfo0), PredName = pred_info_name(!.PredInfo), - equiv_type__maybe_record_expanded_items(ModuleName, + equiv_type.maybe_record_expanded_items(ModuleName, qualified(ModuleName, PredName), MaybeRecompInfo0, !:EquivTypeInfo), pred_info_arg_types(!.PredInfo, ArgTVarSet0, ExistQVars, ArgTypes0), - equiv_type__replace_in_type_list(EqvMap, ArgTypes0, ArgTypes, + equiv_type.replace_in_type_list(EqvMap, ArgTypes0, ArgTypes, _, ArgTVarSet0, ArgTVarSet1, !EquivTypeInfo), % The constraint_proofs aren't used after polymorphism, % so they don't need to be processed. pred_info_get_class_context(!.PredInfo, ClassContext0), - equiv_type__replace_in_prog_constraints(EqvMap, ClassContext0, + equiv_type.replace_in_prog_constraints(EqvMap, ClassContext0, ClassContext, ArgTVarSet1, ArgTVarSet, !EquivTypeInfo), pred_info_set_class_context(ClassContext, !PredInfo), pred_info_set_arg_types(ArgTVarSet, ExistQVars, ArgTypes, !PredInfo), @@ -309,12 +309,12 @@ replace_in_pred(EqvMap, PredId, !ModuleInfo, !Cache) :- pred_info_is_pred_or_func(!.PredInfo)), qualified(pred_info_module(!.PredInfo), PredName) - pred_info_orig_arity(!.PredInfo)), - equiv_type__finish_recording_expanded_items(ItemId, + equiv_type.finish_recording_expanded_items(ItemId, !.EquivTypeInfo, MaybeRecompInfo0, MaybeRecompInfo), module_info_set_maybe_recompilation_info(MaybeRecompInfo, !ModuleInfo), pred_info_procedures(!.PredInfo, Procs0), - map__map_foldl( + map.map_foldl( replace_in_proc(EqvMap), Procs0, Procs, {!.ModuleInfo, !.PredInfo, !.Cache}, {!:ModuleInfo, !:PredInfo, !:Cache}), @@ -347,10 +347,10 @@ replace_in_proc(EqvMap, _, !ProcInfo, {!.ModuleInfo, !.PredInfo, !.Cache}, ), proc_info_vartypes(!.ProcInfo, VarTypes0), - map__map_foldl( + map.map_foldl( (pred(_::in, VarType0::in, VarType::out, !.TVarSet::in, !:TVarSet::out) is det :- - equiv_type__replace_in_type(EqvMap, + equiv_type.replace_in_type(EqvMap, VarType0, VarType, _, !TVarSet, no, _) ), VarTypes0, VarTypes, !TVarSet), @@ -358,16 +358,16 @@ replace_in_proc(EqvMap, _, !ProcInfo, {!.ModuleInfo, !.PredInfo, !.Cache}, proc_info_rtti_varmaps(!.ProcInfo, RttiVarMaps0), rtti_varmaps_types(RttiVarMaps0, AllTypes), - list__foldl2( + list.foldl2( (pred(OldType::in, !.TMap::in, !:TMap::out, !.TVarSet::in, !:TVarSet::out) is det :- - equiv_type__replace_in_type(EqvMap, OldType, NewType, _, + equiv_type.replace_in_type(EqvMap, OldType, NewType, _, !TVarSet, no, _), - svmap__set(OldType, NewType, !TMap) - ), AllTypes, map__init, TypeMap, !TVarSet), + svmap.set(OldType, NewType, !TMap) + ), AllTypes, map.init, TypeMap, !TVarSet), rtti_varmaps_transform_types( (pred(!.VarMapType::in, !:VarMapType::out) is det :- - map__lookup(TypeMap, !VarMapType) + map.lookup(TypeMap, !VarMapType) ), RttiVarMaps0, RttiVarMaps), proc_info_set_rtti_varmaps(RttiVarMaps, !ProcInfo), @@ -454,7 +454,7 @@ replace_in_inst_2(_, any(_) @ Inst, Inst, no, !TVarSet, !Cache). replace_in_inst_2(_, free @ Inst, Inst, no, !TVarSet, !Cache). replace_in_inst_2(EqvMap, Inst0 @ free(Type0), Inst, Changed, !TVarSet, !Cache) :- - equiv_type__replace_in_type(EqvMap, Type0, Type, Changed, !TVarSet, no, _), + equiv_type.replace_in_type(EqvMap, Type0, Type, Changed, !TVarSet, no, _), ( Changed = yes, Inst = free(Type) ; Changed = no, Inst = Inst0 ). @@ -604,11 +604,11 @@ replace_in_insts(EqvMap, List0 @ [Inst0 | Insts0], List, Changed, inst_cache::in, inst_cache::out) is det. hash_cons_inst(Inst0, Inst, !Cache) :- - ( map__search(!.Cache, Inst0, Inst1) -> + ( map.search(!.Cache, Inst0, Inst1) -> Inst = Inst1 ; Inst = Inst0, - !:Cache = map__det_insert(!.Cache, Inst, Inst) + !:Cache = map.det_insert(!.Cache, Inst, Inst) ). %-----------------------------------------------------------------------------% @@ -740,7 +740,7 @@ replace_in_goal_expr(EqvMap, Goal0 @ unify(Var, _, _, _, _), Goal, module_info_get_type_table(!.Info ^ module_info, Types), proc_info_vartypes(!.Info ^ proc_info, VarTypes), proc_info_rtti_varmaps(!.Info ^ proc_info, RttiVarMaps), - map__lookup(VarTypes, Var, VarType), + map.lookup(VarTypes, Var, VarType), classify_type(!.Info ^ module_info, VarType) = TypeCat, ( % If this goal constructs a type_info for an equivalence type, @@ -750,8 +750,8 @@ replace_in_goal_expr(EqvMap, Goal0 @ unify(Var, _, _, _, _), Goal, Goal0 ^ unify_kind = construct(_, ConsId, _, _, _, _, _), ConsId = type_info_cell_constructor(TypeCtor), TypeCat = type_cat_type_info, - map__search(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, Body), + map.search(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, Body), Body = eqv_type(_) -> Changed = yes, @@ -765,8 +765,8 @@ replace_in_goal_expr(EqvMap, Goal0 @ unify(Var, _, _, _, _), Goal, ; unexpected(this_file, "replace_in_goal_expr: info not found") ), - polymorphism__make_type_info_var(TypeInfoType, - term__context_init, TypeInfoVar, Goals0, PolyInfo0, PolyInfo), + polymorphism.make_type_info_var(TypeInfoType, + term.context_init, TypeInfoVar, Goals0, PolyInfo0, PolyInfo), poly_info_extract(PolyInfo, PredInfo0, PredInfo, !.Info ^ proc_info, ProcInfo, ModuleInfo), pred_info_typevarset(PredInfo, TVarSet), @@ -775,8 +775,8 @@ replace_in_goal_expr(EqvMap, Goal0 @ unify(Var, _, _, _, _), Goal, !:Info = !.Info ^ module_info := ModuleInfo, !:Info = !.Info ^ tvarset := TVarSet, - goal_util__rename_vars_in_goals(no, - map__from_assoc_list([TypeInfoVar - Var]), Goals0, Goals), + goal_util.rename_vars_in_goals(no, + map.from_assoc_list([TypeInfoVar - Var]), Goals0, Goals), ( Goals = [Goal1 - _] -> Goal = Goal1 ; @@ -791,8 +791,8 @@ replace_in_goal_expr(EqvMap, Goal0 @ unify(Var, _, _, _, _), Goal, Goal0 ^ unify_kind = construct(_, ConsId, _, _, _, _, _), ConsId = type_info_cell_constructor(TypeCtor), TypeCat = type_cat_type_ctor_info, - map__search(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, Body), + map.search(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, Body), Body = eqv_type(_) -> Changed = yes, @@ -926,5 +926,5 @@ replace_in_foreign_arg_list(EqvMap, List0 @ [A0 | As0], List, this_file = "equiv_type_hlds.m". %-----------------------------------------------------------------------------% -:- end_module transform_hlds__equiv_type_hlds. +:- end_module transform_hlds.equiv_type_hlds. %-----------------------------------------------------------------------------% diff --git a/compiler/error_util.m b/compiler/error_util.m index e33734ada..ec940d260 100644 --- a/compiler/error_util.m +++ b/compiler/error_util.m @@ -33,7 +33,7 @@ %-----------------------------------------------------------------------------% -:- module parse_tree__error_util. +:- module parse_tree.error_util. :- interface. :- import_module mdbcomp.prim_data. @@ -380,11 +380,11 @@ write_error_pieces_maybe_with_context(IsFirst, MaybeContext, % indent ( MaybeContext = yes(Context), - term__context_file(Context, FileName), - term__context_line(Context, LineNumber), - string__length(FileName, FileNameLength), - string__int_to_string(LineNumber, LineNumberStr), - string__length(LineNumberStr, LineNumberStrLength0), + term.context_file(Context, FileName), + term.context_line(Context, LineNumber), + string.length(FileName, FileNameLength), + string.int_to_string(LineNumber, LineNumberStr), + string.length(LineNumberStr, LineNumberStrLength0), ( LineNumberStrLength0 < 3 -> LineNumberStrLength = 3 ; @@ -413,14 +413,14 @@ write_lines([], _, _, !IO). write_lines([Line | Lines], MaybeContext, FixedIndent, !IO) :- ( MaybeContext = yes(Context), - prog_out__write_context(Context, !IO) + prog_out.write_context(Context, !IO) ; MaybeContext = no ), Line = line(LineIndent, LineWords), Indent = FixedIndent + LineIndent * indent_increment, - string__pad_left("", ' ', Indent, IndentStr), - io__write_string(IndentStr, !IO), + string.pad_left("", ' ', Indent, IndentStr), + io.write_string(IndentStr, !IO), write_line(LineWords, !IO), write_lines(Lines, MaybeContext, FixedIndent, !IO). @@ -428,16 +428,16 @@ write_lines([Line | Lines], MaybeContext, FixedIndent, !IO) :- write_line([], !IO). write_line([Word | Words], !IO) :- - io__write_string(Word, !IO), + io.write_string(Word, !IO), write_line_rest(Words, !IO), - io__write_char('\n', !IO). + io.write_char('\n', !IO). :- pred write_line_rest(list(string)::in, io::di, io::uo) is det. write_line_rest([], !IO). write_line_rest([Word | Words], !IO) :- - io__write_char(' ', !IO), - io__write_string(Word, !IO), + io.write_char(' ', !IO), + io.write_string(Word, !IO), write_line_rest(Words, !IO). error_pieces_to_string([]) = "". @@ -520,7 +520,7 @@ convert_components_to_paragraphs(Components, Paras) :- convert_components_to_paragraphs_acc([], RevWords0, !Paras) :- Strings = rev_words_to_strings(RevWords0), - list__reverse([paragraph(Strings, 0) | !.Paras], !:Paras). + list.reverse([paragraph(Strings, 0) | !.Paras], !:Paras). convert_components_to_paragraphs_acc([Component | Components], RevWords0, !Paras) :- ( @@ -573,7 +573,7 @@ convert_components_to_paragraphs_acc([Component | Components], RevWords0, :- func rev_words_to_strings(list(word)) = list(string). rev_words_to_strings(RevWords) = Strings :- - PorPs = list__reverse(rev_words_to_rev_plain_or_prefix(RevWords)), + PorPs = list.reverse(rev_words_to_rev_plain_or_prefix(RevWords)), Strings = join_prefixes(PorPs). :- func rev_words_to_rev_plain_or_prefix(list(word)) = list(plain_or_prefix). @@ -652,7 +652,7 @@ break_into_words_from(String, Cur, Words0, Words) :- ( find_word_start(String, Cur, Start) -> find_word_end(String, Start, End), Length = End - Start + 1, - string__substring(String, Start, Length, WordStr), + string.substring(String, Start, Length, WordStr), Next = End + 1, break_into_words_from(String, Next, [word(WordStr) | Words0], Words) ; @@ -662,8 +662,8 @@ break_into_words_from(String, Cur, Words0, Words) :- :- pred find_word_start(string::in, int::in, int::out) is semidet. find_word_start(String, Cur, WordStart) :- - string__index(String, Cur, Char), - ( char__is_whitespace(Char) -> + string.index(String, Cur, Char), + ( char.is_whitespace(Char) -> Next = Cur + 1, find_word_start(String, Next, WordStart) ; @@ -674,8 +674,8 @@ find_word_start(String, Cur, WordStart) :- find_word_end(String, Cur, WordEnd) :- Next = Cur + 1, - ( string__index(String, Next, Char) -> - ( char__is_whitespace(Char) -> + ( string.index(String, Next, Char) -> + ( char.is_whitespace(Char) -> WordEnd = Cur ; find_word_end(String, Next, WordEnd) @@ -754,7 +754,7 @@ group_nonfirst_line_words(Words, Indent, Max, Lines) :- list(string)::out, list(string)::out) is det. get_line_of_words(FirstWord, LaterWords, Indent, Max, Line, RestWords) :- - string__length(FirstWord, FirstWordLen), + string.length(FirstWord, FirstWordLen), Avail = Max - Indent * indent_increment, get_later_words(LaterWords, FirstWordLen, Avail, [FirstWord], Line, RestWords). @@ -764,10 +764,10 @@ get_line_of_words(FirstWord, LaterWords, Indent, Max, Line, RestWords) :- get_later_words([], _, _, Line, Line, []). get_later_words([Word | Words], OldLen, Avail, Line0, Line, RestWords) :- - string__length(Word, WordLen), + string.length(Word, WordLen), NewLen = OldLen + 1 + WordLen, ( NewLen =< Avail -> - list__append(Line0, [Word], Line1), + list.append(Line0, [Word], Line1), get_later_words(Words, NewLen, Avail, Line1, Line, RestWords) ; Line = Line0, @@ -777,11 +777,11 @@ get_later_words([Word | Words], OldLen, Avail, Line0, Line, RestWords) :- %-----------------------------------------------------------------------------% describe_sym_name_and_arity(SymName / Arity) = - string__append_list(["`", SymNameString, "/", - string__int_to_string(Arity), "'"]) :- + string.append_list(["`", SymNameString, "/", + string.int_to_string(Arity), "'"]) :- sym_name_to_string(SymName, SymNameString). -describe_sym_name(SymName) = string__append_list(["`", SymNameString, "'"]) :- +describe_sym_name(SymName) = string.append_list(["`", SymNameString, "'"]) :- sym_name_to_string(SymName, SymNameString). pred_or_func_to_string(predicate) = "predicate". @@ -808,7 +808,7 @@ report_error_num_args(MaybePredOrFunc, Arity0, Arities0, !IO) :- % Adjust arities for functions. ( MaybePredOrFunc = yes(function) -> adjust_func_arity(function, Arity, Arity0), - list__map( + list.map( (pred(OtherArity0::in, OtherArity::out) is det :- adjust_func_arity(function, OtherArity, OtherArity0) ), @@ -817,26 +817,26 @@ report_error_num_args(MaybePredOrFunc, Arity0, Arities0, !IO) :- Arity = Arity0, Arities = Arities0 ), - io__write_string("wrong number of arguments (", !IO), - io__write_int(Arity, !IO), - io__write_string("; should be ", !IO), + io.write_string("wrong number of arguments (", !IO), + io.write_int(Arity, !IO), + io.write_string("; should be ", !IO), report_error_right_num_args(Arities, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). :- pred report_error_right_num_args(list(int)::in, io::di, io::uo) is det. report_error_right_num_args([], !IO). report_error_right_num_args([Arity | Arities], !IO) :- - io__write_int(Arity, !IO), + io.write_int(Arity, !IO), ( Arities = [], true ; Arities = [_], - io__write_string(" or ", !IO) + io.write_string(" or ", !IO) ; Arities = [_, _ | _], - io__write_string(", ", !IO) + io.write_string(", ", !IO) ), report_error_right_num_args(Arities, !IO). diff --git a/compiler/export.m b/compiler/export.m index f1e2d99dd..c43137a0a 100644 --- a/compiler/export.m +++ b/compiler/export.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1996-2005 The University of Melbourne. +% Copyright (C) 1996-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -17,7 +17,7 @@ %-----------------------------------------------------------------------------% -:- module backend_libs__export. +:- module backend_libs.export. :- interface. :- import_module hlds.hlds_module. @@ -111,7 +111,7 @@ get_foreign_export_decls(HLDS, ForeignExportDecls) :- predicate_table_get_preds(PredicateTable, Preds), module_info_get_foreign_decl(HLDS, RevForeignDecls), - ForeignDecls = list__reverse(RevForeignDecls), + ForeignDecls = list.reverse(RevForeignDecls), module_info_get_pragma_exported_procs(HLDS, ExportedProcs), module_info_get_globals(HLDS, Globals), @@ -269,7 +269,7 @@ to_c(Preds, [E | ExportedProcs], ModuleInfo, ExportedProcsCode) :- ProcLabel = make_proc_label(ModuleInfo, PredId, ProcId), ProcLabelString = proc_label_to_c_string(ProcLabel, yes), - string__append_list([ + string.append_list([ "\n", DeclareString, "(", ProcLabelString, ");\n", "\n", @@ -342,7 +342,7 @@ to_c(Preds, [E | ExportedProcs], ModuleInfo, ExportedProcsCode) :- get_export_info(Preds, PredId, ProcId, _Globals, ModuleInfo, HowToDeclareLabel, C_RetType, MaybeDeclareRetval, MaybeFail, MaybeSucceed, ArgInfoTypes) :- - map__lookup(Preds, PredId, PredInfo), + map.lookup(Preds, PredId, PredInfo), pred_info_import_status(PredInfo, Status), ( ( @@ -357,7 +357,7 @@ get_export_info(Preds, PredId, ProcId, _Globals, ModuleInfo, HowToDeclareLabel, ), PredOrFunc = pred_info_is_pred_or_func(PredInfo), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, ProcInfo), + map.lookup(ProcTable, ProcId, ProcInfo), proc_info_maybe_arg_info(ProcInfo, MaybeArgInfos), pred_info_arg_types(PredInfo, ArgTypes), ( @@ -369,7 +369,7 @@ get_export_info(Preds, PredId, ProcId, _Globals, ModuleInfo, HowToDeclareLabel, proc_info_arg_info(NewProcInfo, ArgInfos) ), proc_info_interface_code_model(ProcInfo, CodeModel), - assoc_list__from_corresponding_lists(ArgInfos, ArgTypes, ArgInfoTypes0), + assoc_list.from_corresponding_lists(ArgInfos, ArgTypes, ArgInfoTypes0), % Figure out what the C return type should be, and build the `return' % instructions (if any). @@ -382,14 +382,14 @@ get_export_info(Preds, PredId, ProcId, _Globals, ModuleInfo, HowToDeclareLabel, RetArgMode = top_out, \+ is_dummy_argument_type(ModuleInfo, RetType) -> - Export_RetType = foreign__to_exported_type(ModuleInfo, RetType), - C_RetType = foreign__to_type_string(c, Export_RetType), + Export_RetType = foreign.to_exported_type(ModuleInfo, RetType), + C_RetType = foreign.to_type_string(c, Export_RetType), argloc_to_string(RetArgLoc, RetArgString0), convert_type_from_mercury(RetArgString0, RetType, RetArgString), MaybeDeclareRetval = "\t" ++ C_RetType ++ " return_value;\n", % We need to unbox non-word-sized foreign types % before returning them to C code - ( foreign__is_foreign_type(Export_RetType) = yes(_) -> + ( foreign.is_foreign_type(Export_RetType) = yes(_) -> SetReturnValue = "\tMR_MAYBE_UNBOX_FOREIGN_TYPE(" ++ C_RetType ++ ", " ++ RetArgString ++ ", return_value);\n" @@ -414,7 +414,7 @@ get_export_info(Preds, PredId, ProcId, _Globals, ModuleInfo, HowToDeclareLabel, % to indicate success or failure. C_RetType = "MR_bool", MaybeDeclareRetval = "", - string__append_list([ + string.append_list([ "\tif (!MR_r1) {\n", "\t\tMR_restore_regs_from_mem(c_regs);\n", "\treturn MR_FALSE;\n", @@ -425,7 +425,7 @@ get_export_info(Preds, PredId, ProcId, _Globals, ModuleInfo, HowToDeclareLabel, CodeModel = model_non, unexpected(this_file, "Attempt to export model_non procedure.") ), - list__filter(include_arg(ModuleInfo), ArgInfoTypes2, ArgInfoTypes). + list.filter(include_arg(ModuleInfo), ArgInfoTypes2, ArgInfoTypes). % include_arg(ArgInfoType): % @@ -476,13 +476,13 @@ get_argument_declaration(ArgInfo, Type, Num, NameThem, ModuleInfo, ArgInfo = arg_info(_Loc, Mode), ( NameThem = yes, - string__int_to_string(Num, NumString), - string__append(" Mercury__argument", NumString, ArgName) + string.int_to_string(Num, NumString), + string.append(" Mercury__argument", NumString, ArgName) ; NameThem = no, ArgName = "" ), - TypeString0 = foreign__to_type_string(c, ModuleInfo, Type), + TypeString0 = foreign.to_type_string(c, ModuleInfo, Type), ( Mode = top_out -> % output variables are passed as pointers TypeString = TypeString0 ++ " *" @@ -500,16 +500,16 @@ get_input_args([AT | ATs], Num0, ModuleInfo, Result) :- Num = Num0 + 1, ( Mode = top_in, - string__int_to_string(Num, NumString), + string.int_to_string(Num, NumString), ArgName0 = "Mercury__argument" ++ NumString, convert_type_to_mercury(ArgName0, Type, ArgName), argloc_to_string(ArgLoc, ArgLocString), - Export_Type = foreign__to_exported_type(ModuleInfo, Type), + Export_Type = foreign.to_exported_type(ModuleInfo, Type), % We need to box non-word-sized foreign types % before passing them to Mercury code - ( foreign__is_foreign_type(Export_Type) = yes(_) -> - C_Type = foreign__to_type_string(c, Export_Type), - string__append_list(["\tMR_MAYBE_BOX_FOREIGN_TYPE(", + ( foreign.is_foreign_type(Export_Type) = yes(_) -> + C_Type = foreign.to_type_string(c, Export_Type), + string.append_list(["\tMR_MAYBE_BOX_FOREIGN_TYPE(", C_Type, ", ", ArgName, ", ", ArgLocString, ");\n"], InputArg) ; InputArg = "\t" ++ ArgLocString ++ " = " ++ ArgName ++ ";\n" @@ -537,16 +537,16 @@ copy_output_args([AT | ATs], Num0, ModuleInfo, Result) :- OutputArg = "" ; Mode = top_out, - string__int_to_string(Num, NumString), - string__append("Mercury__argument", NumString, ArgName), + string.int_to_string(Num, NumString), + string.append("Mercury__argument", NumString, ArgName), argloc_to_string(ArgLoc, ArgLocString0), convert_type_from_mercury(ArgLocString0, Type, ArgLocString), - Export_Type = foreign__to_exported_type(ModuleInfo, Type), + Export_Type = foreign.to_exported_type(ModuleInfo, Type), % We need to unbox non-word-sized foreign types % before returning them to C code - ( foreign__is_foreign_type(Export_Type) = yes(_) -> - C_Type = foreign__to_type_string(c, Export_Type), - string__append_list(["\tMR_MAYBE_UNBOX_FOREIGN_TYPE(", C_Type, + ( foreign.is_foreign_type(Export_Type) = yes(_) -> + C_Type = foreign.to_type_string(c, Export_Type), + string.append_list(["\tMR_MAYBE_UNBOX_FOREIGN_TYPE(", C_Type, ", ", ArgLocString, ", * ", ArgName, ");\n"], OutputArg) ; OutputArg = "\t*" ++ ArgName ++ " = " ++ ArgLocString ++ ";\n" @@ -556,7 +556,7 @@ copy_output_args([AT | ATs], Num0, ModuleInfo, Result) :- OutputArg = "" ), copy_output_args(ATs, Num, ModuleInfo, TheRest), - string__append(OutputArg, TheRest, Result). + string.append(OutputArg, TheRest, Result). % convert an argument location (currently just a register number) % to a string representing a C code fragment that names it. @@ -613,14 +613,14 @@ produce_header_file(ForeignExportDecls, ModuleName, !IO) :- ForeignExportDecls = foreign_export_decls(ForeignDecls, C_ExportDecls), HeaderExt = ".mh", module_name_to_file_name(ModuleName, HeaderExt, yes, FileName, !IO), - io__open_output(FileName ++ ".tmp", Result, !IO), + io.open_output(FileName ++ ".tmp", Result, !IO), ( Result = ok(FileStream) -> - io__set_output_stream(FileStream, OutputStream, !IO), + io.set_output_stream(FileStream, OutputStream, !IO), module_name_to_file_name(ModuleName, ".m", no, SourceFileName, !IO), - library__version(Version), - io__write_strings([ + library.version(Version), + io.write_strings([ "/*\n", "** Automatically generated from `", SourceFileName, "'\n", "** by the Mercury compiler,\n", @@ -628,9 +628,9 @@ produce_header_file(ForeignExportDecls, ModuleName, !IO) :- "** Do not edit.\n", "*/\n"], !IO), MangledModuleName = sym_name_mangle(ModuleName), - string__to_upper(MangledModuleName, UppercaseModuleName), - string__append(UppercaseModuleName, "_MH", GuardMacroName), - io__write_strings([ + string.to_upper(MangledModuleName, UppercaseModuleName), + string.append(UppercaseModuleName, "_MH", GuardMacroName), + io.write_strings([ "#ifndef ", GuardMacroName, "\n", "#define ", GuardMacroName, "\n", "\n", @@ -650,33 +650,33 @@ produce_header_file(ForeignExportDecls, ModuleName, !IO) :- "#endif\n", "\n"], !IO), - io__write_strings([ + io.write_strings([ "#ifndef ", decl_guard(ModuleName), "\n", "#define ", decl_guard(ModuleName), "\n"], !IO), - list__foldl(output_foreign_decl(yes(foreign_decl_is_exported)), + list.foldl(output_foreign_decl(yes(foreign_decl_is_exported)), ForeignDecls, !IO), - io__write_string("\n#endif\n", !IO), + io.write_string("\n#endif\n", !IO), produce_header_file_2(C_ExportDecls, !IO), - io__write_strings([ + io.write_strings([ "\n", "#ifdef __cplusplus\n", "}\n", "#endif\n", "\n", "#endif /* ", GuardMacroName, " */\n"], !IO), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO), + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO), % rename ".mh.tmp" to ".mh". update_interface(FileName, !IO) ; - io__progname_base("export.m", ProgName, !IO), - io__write_string("\n", !IO), - io__write_string(ProgName, !IO), - io__write_string(": can't open `", !IO), - io__write_string(FileName ++ ".tmp", !IO), - io__write_string("' for output\n", !IO), - io__set_exit_status(1, !IO) + io.progname_base("export.m", ProgName, !IO), + io.write_string("\n", !IO), + io.write_string(ProgName, !IO), + io.write_string(": can't open `", !IO), + io.write_string(FileName ++ ".tmp", !IO), + io.write_string("' for output\n", !IO), + io.set_exit_status(1, !IO) ). :- pred produce_header_file_2(list(foreign_export_decl)::in, io::di, io::uo) @@ -687,12 +687,12 @@ produce_header_file_2([E | ExportedProcs], !IO) :- E = foreign_export_decl(Lang, C_RetType, C_Function, ArgDecls), ( Lang = c -> % Output the function header. - io__write_string(C_RetType, !IO), - io__write_string(" ", !IO), - io__write_string(C_Function, !IO), - io__write_string("(", !IO), - io__write_string(ArgDecls, !IO), - io__write_string(");\n", !IO) + io.write_string(C_RetType, !IO), + io.write_string(" ", !IO), + io.write_string(C_Function, !IO), + io.write_string("(", !IO), + io.write_string(ArgDecls, !IO), + io.write_string(");\n", !IO) ; sorry(this_file, "foreign languages other than C unimplemented") ), @@ -712,12 +712,12 @@ output_foreign_decl(MaybeDesiredIsLocal, DeclCode, !IO) :- DesiredIsLocal = IsLocal ) -> - term__context_file(Context, File), - term__context_line(Context, Line), - c_util__set_line_num(File, Line, !IO), - io__write_string(Code, !IO), - io__nl(!IO), - c_util__reset_line_num(!IO) + term.context_file(Context, File), + term.context_line(Context, Line), + c_util.set_line_num(File, Line, !IO), + io.write_string(Code, !IO), + io.nl(!IO), + c_util.reset_line_num(!IO) ; true ). diff --git a/compiler/exprn_aux.m b/compiler/exprn_aux.m index 5e8243669..500e24bec 100644 --- a/compiler/exprn_aux.m +++ b/compiler/exprn_aux.m @@ -10,7 +10,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__exprn_aux. +:- module ll_backend.exprn_aux. :- interface. :- import_module libs.options. @@ -117,10 +117,10 @@ %-----------------------------------------------------------------------------% init_exprn_opts(Options, ExprnOpts) :- - getopt_io__lookup_bool_option(Options, gcc_non_local_gotos, NLG), - getopt_io__lookup_bool_option(Options, asm_labels, ASM), - getopt_io__lookup_bool_option(Options, static_ground_terms, SGT), - getopt_io__lookup_bool_option(Options, unboxed_float, UBF), + getopt_io.lookup_bool_option(Options, gcc_non_local_gotos, NLG), + getopt_io.lookup_bool_option(Options, asm_labels, ASM), + getopt_io.lookup_bool_option(Options, static_ground_terms, SGT), + getopt_io.lookup_bool_option(Options, unboxed_float, UBF), ExprnOpts = nlg_asm_sgt_ubf(NLG, ASM, SGT, UBF). % Determine whether a const (well, what _we_ consider to be a const) @@ -159,7 +159,7 @@ addr_is_constant(label(Label), ExprnOpts, IsConst) :- label_is_constant(Label, NonLocalGotos, AsmLabels, IsConst). addr_is_constant(imported(_), ExprnOpts, IsConst) :- ExprnOpts = nlg_asm_sgt_ubf(NonLocalGotos, AsmLabels, _SGT, _UBF), - globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst). + globals.imported_is_constant(NonLocalGotos, AsmLabels, IsConst). addr_is_constant(succip, _, no). addr_is_constant(do_succeed(_), _, no). addr_is_constant(do_redo, _, no). @@ -173,9 +173,9 @@ addr_is_constant(do_not_reached, _, no). :- pred label_is_constant(label::in, bool::in, bool::in, bool::out) is det. label_is_constant(entry(exported, _), NonLocalGotos, AsmLabels, IsConst) :- - globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst). + globals.imported_is_constant(NonLocalGotos, AsmLabels, IsConst). label_is_constant(entry(local, _), NonLocalGotos, AsmLabels, IsConst) :- - globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst). + globals.imported_is_constant(NonLocalGotos, AsmLabels, IsConst). label_is_constant(entry(c_local, _), _NonLocalGotos, _AsmLabels, yes). label_is_constant(internal(_, _), _NonLocalGotos, _AsmLabels, yes). @@ -268,7 +268,7 @@ vars_in_rval(unop(_Unop, Rval), Vars) :- vars_in_rval(binop(_Binop, Rval0, Rval1), Vars) :- vars_in_rval(Rval0, Vars0), vars_in_rval(Rval1, Vars1), - list__append(Vars0, Vars1, Vars). + list.append(Vars0, Vars1, Vars). vars_in_rval(mem_addr(MemRef), Vars) :- vars_in_mem_ref(MemRef, Vars). @@ -294,7 +294,7 @@ vars_in_lval(prevfr(Rval), Vars) :- vars_in_lval(field(_MaybeTag, Rval0, Rval1), Vars) :- vars_in_rval(Rval0, Vars0), vars_in_rval(Rval1, Vars1), - list__append(Vars0, Vars1, Vars). + list.append(Vars0, Vars1, Vars). vars_in_lval(mem_ref(Rval), Vars) :- vars_in_rval(Rval, Vars). vars_in_lval(lvar(Var), [Var]). @@ -330,14 +330,14 @@ substitute_lval_in_uinstr(OldLval, NewLval, Uinstr0, Uinstr, !N) :- Uinstr = Uinstr0 ; Uinstr0 = livevals(LvalSet0), - set__to_sorted_list(LvalSet0, Lvals0), - list__map_foldl(substitute_lval_in_lval_count(OldLval, NewLval), + set.to_sorted_list(LvalSet0, Lvals0), + list.map_foldl(substitute_lval_in_lval_count(OldLval, NewLval), Lvals0, Lvals, !N), - set__list_to_set(Lvals, LvalSet), + set.list_to_set(Lvals, LvalSet), Uinstr = livevals(LvalSet) ; Uinstr0 = block(TempR, TempF, Instrs0), - list__map_foldl(substitute_lval_in_instr(OldLval, NewLval), + list.map_foldl(substitute_lval_in_instr(OldLval, NewLval), Instrs0, Instrs, !N), Uinstr = block(TempR, TempF, Instrs) ; @@ -435,7 +435,7 @@ substitute_lval_in_uinstr(OldLval, NewLval, Uinstr0, Uinstr, !N) :- Uinstr0 = pragma_c(Decls, Components0, MayCallMercury, MaybeLabel1, MaybeLabel2, MaybeLabel3, MaybeLabel4, ReferStackSlot, MayDupl), - list__map_foldl(substitute_lval_in_component(OldLval, NewLval), + list.map_foldl(substitute_lval_in_component(OldLval, NewLval), Components0, Components, !N), Uinstr = pragma_c(Decls, Components, MayCallMercury, MaybeLabel1, MaybeLabel2, MaybeLabel3, MaybeLabel4, @@ -464,12 +464,12 @@ substitute_lval_in_component(OldLval, NewLval, Component0, Component, !N) :- ( Component0 = pragma_c_inputs(Inputs0), - list__map_foldl(substitute_lval_in_pragma_c_input(OldLval, NewLval), + list.map_foldl(substitute_lval_in_pragma_c_input(OldLval, NewLval), Inputs0, Inputs, !N), Component = pragma_c_inputs(Inputs) ; Component0 = pragma_c_outputs(Outputs0), - list__map_foldl(substitute_lval_in_pragma_c_output(OldLval, NewLval), + list.map_foldl(substitute_lval_in_pragma_c_output(OldLval, NewLval), Outputs0, Outputs, !N), Component = pragma_c_outputs(Outputs) ; @@ -495,10 +495,10 @@ substitute_lval_in_live_lval_info(_OldLval, _NewLval, no_live_lvals_info, no_live_lvals_info, !N). substitute_lval_in_live_lval_info(OldLval, NewLval, live_lvals_info(LvalSet0), live_lvals_info(LvalSet), !N) :- - Lvals0 = set__to_sorted_list(LvalSet0), - list__map_foldl(substitute_lval_in_lval_count(OldLval, NewLval), + Lvals0 = set.to_sorted_list(LvalSet0), + list.map_foldl(substitute_lval_in_lval_count(OldLval, NewLval), Lvals0, Lvals, !N), - set__list_to_set(Lvals, LvalSet). + set.list_to_set(Lvals, LvalSet). :- pred substitute_lval_in_pragma_c_input(lval::in, lval::in, pragma_c_input::in, pragma_c_input::out, int::in, int::out) is det. @@ -917,8 +917,8 @@ rval_addrs(unop(_Unop, Rval), CodeAddrs, DataAddrs) :- rval_addrs(binop(_Binop, Rval1, Rval2), CodeAddrs, DataAddrs) :- rval_addrs(Rval1, CodeAddrs1, DataAddrs1), rval_addrs(Rval2, CodeAddrs2, DataAddrs2), - list__append(CodeAddrs1, CodeAddrs2, CodeAddrs), - list__append(DataAddrs1, DataAddrs2, DataAddrs). + list.append(CodeAddrs1, CodeAddrs2, CodeAddrs), + list.append(DataAddrs1, DataAddrs2, DataAddrs). rval_addrs(mem_addr(Rval), CodeAddrs, DataAddrs) :- mem_ref_addrs(Rval, CodeAddrs, DataAddrs). @@ -943,8 +943,8 @@ lval_addrs(sp, [], []). lval_addrs(field(_Tag, Rval1, Rval2), CodeAddrs, DataAddrs) :- rval_addrs(Rval1, CodeAddrs1, DataAddrs1), rval_addrs(Rval2, CodeAddrs2, DataAddrs2), - list__append(CodeAddrs1, CodeAddrs2, CodeAddrs), - list__append(DataAddrs1, DataAddrs2, DataAddrs). + list.append(CodeAddrs1, CodeAddrs2, CodeAddrs), + list.append(DataAddrs1, DataAddrs2, DataAddrs). lval_addrs(lvar(_Var), [], []). lval_addrs(temp(_Type, _TmpNum), [], []). lval_addrs(mem_ref(Rval), CodeAddrs, DataAddrs) :- @@ -954,15 +954,15 @@ rval_list_addrs([], [], []). rval_list_addrs([Rval | Rvals], CodeAddrs, DataAddrs) :- rval_addrs(Rval, CodeAddrs0, DataAddrs0), rval_list_addrs(Rvals, CodeAddrs1, DataAddrs1), - list__append(CodeAddrs0, CodeAddrs1, CodeAddrs), - list__append(DataAddrs0, DataAddrs1, DataAddrs). + list.append(CodeAddrs0, CodeAddrs1, CodeAddrs), + list.append(DataAddrs0, DataAddrs1, DataAddrs). lval_list_addrs([], [], []). lval_list_addrs([Lval | Lvals], CodeAddrs, DataAddrs) :- lval_addrs(Lval, CodeAddrs0, DataAddrs0), lval_list_addrs(Lvals, CodeAddrs1, DataAddrs1), - list__append(CodeAddrs0, CodeAddrs1, CodeAddrs), - list__append(DataAddrs0, DataAddrs1, DataAddrs). + list.append(CodeAddrs0, CodeAddrs1, CodeAddrs), + list.append(DataAddrs0, DataAddrs1, DataAddrs). :- pred mem_ref_addrs(mem_ref::in, list(code_addr)::out, list(data_addr)::out) is det. @@ -984,8 +984,8 @@ maybe_rval_list_addrs([MaybeRval | MaybeRvals], CodeAddrs, DataAddrs) :- MaybeRval = yes(Rval), rval_addrs(Rval, CodeAddrs0, DataAddrs0), maybe_rval_list_addrs(MaybeRvals, CodeAddrs1, DataAddrs1), - list__append(CodeAddrs0, CodeAddrs1, CodeAddrs), - list__append(DataAddrs0, DataAddrs1, DataAddrs) + list.append(CodeAddrs0, CodeAddrs1, CodeAddrs), + list.append(DataAddrs0, DataAddrs1, DataAddrs) ; MaybeRval = no, maybe_rval_list_addrs(MaybeRvals, CodeAddrs, DataAddrs) diff --git a/compiler/fact_table.m b/compiler/fact_table.m index 572aed8cb..cabf68329 100644 --- a/compiler/fact_table.m +++ b/compiler/fact_table.m @@ -48,7 +48,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__fact_table. +:- module ll_backend.fact_table. :- interface. :- import_module hlds.hlds_module. @@ -145,7 +145,7 @@ :- type proc_stream ---> proc_stream( proc_id, % ID of procedure. - io__output_stream % Sort file stream. + io.output_stream % Sort file stream. ). :- type hash_entry @@ -208,7 +208,7 @@ :- pred fact_table_size(int::out, io::di, io::uo) is det. fact_table_size(FactTableSize, !IO) :- - globals__io_lookup_int_option(fact_table_max_array_size, FactTableSize, + globals.io_lookup_int_option(fact_table_max_array_size, FactTableSize, !IO). %---------------------------------------------------------------------------% @@ -241,7 +241,7 @@ fact_table_compile_facts(PredName, Arity, FileName, !PredInfo, Context, :- pred fact_table_compile_facts_2(sym_name::in, arity::in, string::in, pred_info::in, pred_info::out, prog_context::in, module_info::in, - string::out, proc_id::out, string::in, io__output_stream::in, + string::out, proc_id::out, string::in, io.output_stream::in, io::di, io::uo) is det. fact_table_compile_facts_2(PredName, Arity, FileName, !PredInfo, Context, @@ -256,8 +256,8 @@ fact_table_compile_facts_2(PredName, Arity, FileName, !PredInfo, Context, C_HeaderCode0, StructName, Pass1Errors, Pass1HeaderErrors), ( Pass1HeaderErrors = [], - io__write_string(OutputStream, fact_table_file_header(FileName), !IO), - io__write_string(OutputStream, C_HeaderCode0, !IO), + io.write_string(OutputStream, fact_table_file_header(FileName), !IO), + io.write_string(OutputStream, C_HeaderCode0, !IO), open_sort_files(CheckProcs, ProcStreams, [], OpenErrors, !IO), ( WriteDataTable = yes, @@ -279,7 +279,7 @@ fact_table_compile_facts_2(PredName, Arity, FileName, !PredInfo, Context, ), compile_facts(PredName, Arity, !.PredInfo, ModuleInfo, FactArgInfos, ProcStreams, MaybeOutput, 0, NumFacts, [], CompileErrors, !IO), - io__seen(!IO), + io.seen(!IO), ( MaybeOutput = yes(_), % Outputs closing brace for last fact array. @@ -292,21 +292,21 @@ fact_table_compile_facts_2(PredName, Arity, FileName, !PredInfo, Context, ), close_sort_files(ProcStreams, ProcFiles, !IO), - list__append(OpenErrors, CompileErrors, OpenCompileErrors), + list.append(OpenErrors, CompileErrors, OpenCompileErrors), ( OpenCompileErrors = [], pred_info_procedures(!.PredInfo, ProcTable0), infer_determinism_pass_2(ProcFiles, ExistsAllInMode, ProcTable0, ProcTable, !IO), pred_info_set_procedures(ProcTable, !PredInfo), - io__make_temp(DataFileName, !IO), + io.make_temp(DataFileName, !IO), write_fact_table_arrays(ProcFiles, DataFileName, StructName, ProcTable, ModuleInfo, NumFacts, FactArgInfos, WriteHashTables, WriteDataAfterSorting, OutputStream, C_HeaderCode1, PrimaryProcID, !IO), write_fact_table_numfacts(PredName, NumFacts, OutputStream, C_HeaderCode3, !IO), - string__append_list([C_HeaderCode0, C_HeaderCode1, + string.append_list([C_HeaderCode0, C_HeaderCode1, C_HeaderCode2, C_HeaderCode3], C_HeaderCode) ; OpenCompileErrors = [_ | _], @@ -327,7 +327,7 @@ fact_table_compile_facts_2(PredName, Arity, FileName, !PredInfo, Context, WriteDataAfterSorting = no, DataFileName = "" ), - io__close_output(OutputStream, !IO), + io.close_output(OutputStream, !IO), maybe_append_data_table(WriteDataAfterSorting, OutputFileName, DataFileName, !IO). @@ -337,27 +337,27 @@ fact_table_compile_facts_2(PredName, Arity, FileName, !PredInfo, Context, % :- pred compile_facts(sym_name::in, arity::in, pred_info::in, module_info::in, list(fact_arg_info)::in, list(proc_stream)::in, - maybe(pair(io__output_stream, string))::in, int::in, int::out, + maybe(pair(io.output_stream, string))::in, int::in, int::out, error_reports::in, error_reports::out, io::di, io::uo) is det. compile_facts(PredName, Arity, PredInfo, ModuleInfo, FactArgInfos, ProcStreams, MaybeOutput, !NumFacts, !Errors, !IO) :- - parser__read_term(Result0, !IO), + parser.read_term(Result0, !IO), ( Result0 = eof ; Result0 = error(Message, LineNum), - io__input_stream_name(FileName, !IO), - term__context_init(FileName, LineNum, Context), + io.input_stream_name(FileName, !IO), + term.context_init(FileName, LineNum, Context), add_error_report(Context, [words(Message)], !Errors) ; Result0 = term(_VarSet, Term), fact_table_size(FactTableSize, !IO), ( 0 = !.NumFacts mod FactTableSize -> - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__format("%% Read fact %d\n", [i(!.NumFacts)], !IO) + io.format("%% Read fact %d\n", [i(!.NumFacts)], !IO) ; VeryVerbose = no ) @@ -382,23 +382,23 @@ compile_facts(PredName, Arity, PredInfo, ModuleInfo, FactArgInfos, ProcStreams, % :- pred check_fact_term(sym_name::in, arity::in, pred_info::in, module_info::in, prog_term::in, list(fact_arg_info)::in, - list(proc_stream)::in, maybe(pair(io__output_stream, string))::in, + list(proc_stream)::in, maybe(pair(io.output_stream, string))::in, int::in, fact_result::out, error_reports::in, error_reports::out, io::di, io::uo) is det. -check_fact_term(_, _, _, _, term__variable(_V), _, _, _, _, error, +check_fact_term(_, _, _, _, term.variable(_V), _, _, _, _, error, !Errors, !IO) :- - io__get_line_number(LineNum, !IO), - io__input_stream_name(FileName, !IO), - Context = term__context(FileName, LineNum), + io.get_line_number(LineNum, !IO), + io.input_stream_name(FileName, !IO), + Context = term.context(FileName, LineNum), Msg = "Error: term is not a fact.", add_error_report(Context, [words(Msg)], !Errors). check_fact_term(PredName, Arity0, PredInfo, ModuleInfo, - term__functor(Const, Terms0, Context), FactArgInfos, + term.functor(Const, Terms0, Context), FactArgInfos, ProcStreams, MaybeOutput, FactNum, Result, !Errors, !IO) :- PredOrFunc = pred_info_is_pred_or_func(PredInfo), unqualify_name(PredName, PredString), - ( Const = term__atom(TopLevel) -> + ( Const = term.atom(TopLevel) -> ( ( PredOrFunc = predicate, @@ -409,9 +409,8 @@ check_fact_term(PredName, Arity0, PredInfo, ModuleInfo, PredOrFunc = function, TopLevel = "=", Terms0 = [FuncHeadTerm, FuncResultTerm], - FuncHeadTerm = term__functor( - term__atom(PredString), Terms1, _), - list__append(Terms1, [FuncResultTerm], Terms), + FuncHeadTerm = term.functor(term.atom(PredString), Terms1, _), + list.append(Terms1, [FuncResultTerm], Terms), Arity = Arity0 + 1 ) -> @@ -420,7 +419,7 @@ check_fact_term(PredName, Arity0, PredInfo, ModuleInfo, Result, !Errors, !IO) ; PFStr = pred_or_func_to_full_str(PredOrFunc), - string__format("Error: invalid clause for %s `%s/%d'.", + string.format("Error: invalid clause for %s `%s/%d'.", [s(PFStr), s(PredString), i(Arity0)], Msg), add_error_report(Context, [words(Msg)], !Errors), Result = error @@ -433,7 +432,7 @@ check_fact_term(PredName, Arity0, PredInfo, ModuleInfo, :- pred check_fact_term_2(pred_or_func::in, arity::in, pred_info::in, module_info::in, list(prog_term)::in, context::in, list(fact_arg_info)::in, - list(proc_stream)::in, maybe(pair(io__output_stream, string))::in, + list(proc_stream)::in, maybe(pair(io.output_stream, string))::in, int::in, fact_result::out, error_reports::in, error_reports::out, io::di, io::uo) is det. @@ -441,13 +440,13 @@ check_fact_term_2(PredOrFunc, Arity, PredInfo, ModuleInfo, Terms, Context, FactArgInfos, ProcStreams, MaybeOutput, FactNum, Result, !Errors, !IO) :- % Check that arity of the fact is correct. - list__length(Terms, Len), + list.length(Terms, Len), ( Len = Arity -> pred_info_arg_types(PredInfo, Types), check_fact_type_and_mode(Types, Terms, 0, PredOrFunc, Context, Result, !Errors), pred_info_procedures(PredInfo, ProcTable), - string__int_to_string(FactNum, FactNumStr), + string.int_to_string(FactNum, FactNumStr), write_sort_file_lines(ProcStreams, ProcTable, Terms, ModuleInfo, FactNumStr, FactArgInfos, yes, !IO), @@ -458,19 +457,19 @@ check_fact_term_2(PredOrFunc, Arity, PredInfo, ModuleInfo, Terms, Context, MaybeOutput = yes(OutputStream - StructName), TermToArg = (pred(Term::in, FactArg::out) is semidet :- - Term = term__functor(FactArg, _, _) + Term = term.functor(FactArg, _, _) ), - list__map(TermToArg, Terms, FactArgs) + list.map(TermToArg, Terms, FactArgs) -> write_fact_data(FactNum, FactArgs, StructName, OutputStream, !IO) ; - % If list__map above fails, don't do anything here. The error will + % If list.map above fails, don't do anything here. The error will % have already been reported in check_fact_type_and_mode. true ) ; Msg1 = "Error: fact has wrong number of arguments.", - string__format("Expecting %d arguments, but fact has %d arguments.", + string.format("Expecting %d arguments, but fact has %d arguments.", [i(Arity), i(Len)], Msg2), add_error_report(Context, [words(Msg1), words(Msg2)], !Errors), Result = error @@ -489,26 +488,26 @@ check_fact_type_and_mode(Types0, [Term | Terms], ArgNum0, PredOrFunc, Context0, Result, !Errors) :- ArgNum = ArgNum0 + 1, ( - Term = term__variable(_), + Term = term.variable(_), Msg = "Error: non-ground term in fact.", add_error_report(Context0, [words(Msg)], !Errors), Result = error ; - Term = term__functor(Functor, Items, Context), + Term = term.functor(Functor, Items, Context), % We know that string, integer and float constants are % ground, but we still need to check that they are % the right type for this argument. ( - Functor = term__string(_), + Functor = term.string(_), RequiredType = yes(string) ; - Functor = term__integer(_), + Functor = term.integer(_), RequiredType = yes(int) ; - Functor = term__float(_), + Functor = term.float(_), RequiredType = yes(float) ; - Functor = term__atom(_), + Functor = term.atom(_), RequiredType = no ), ( @@ -549,7 +548,7 @@ report_type_error(Context, ArgNum, RemainingTerms, PredOrFunc, !Errors) :- -> Msg = "Type error in return value of function." ; - string__format("Type error in argument %d.", [i(ArgNum)], Msg) + string.format("Type error in argument %d.", [i(ArgNum)], Msg) ), add_error_report(Context, [words(Msg)], !Errors). @@ -558,8 +557,8 @@ report_type_error(Context, ArgNum, RemainingTerms, PredOrFunc, !Errors) :- :- func fact_table_file_header(string) = string. fact_table_file_header(FileName) = FileHeader :- - library__version(Version), - string__append_list( + library.version(Version), + string.append_list( ["/*\n", "** Automatically generated from `", FileName, "'\n", "** by the Mercury compiler, version ", Version, "\n", @@ -590,7 +589,7 @@ create_fact_table_header(PredName, PredInfo, FactArgInfos, ++ StructContents ++ "};\n\n" ), HashDef = hash_def, - string__append(StructDef, HashDef, C_HeaderCode). + string.append(StructDef, HashDef, C_HeaderCode). % Define a struct for a hash table entry. % @@ -702,8 +701,8 @@ create_fact_table_struct([Info | Infos], I, Context, StructContents, -> ( IsOutput = yes, - string__format("\t%s V_%d;\n", [s(TypeStr), i(I)], StructField), - string__append(StructField, StructContentsTail, StructContents) + string.format("\t%s V_%d;\n", [s(TypeStr), i(I)], StructField), + string.append(StructField, StructContentsTail, StructContents) ; IsOutput = no, StructContents = StructContentsTail @@ -784,7 +783,7 @@ infer_determinism_pass_1(!PredInfo, Context, ModuleInfo, CheckProcs, % There are no declared modes so report an error. PredString = pred_info_name(!.PredInfo), Arity = pred_info_orig_arity(!.PredInfo), - string__format( + string.format( "Error: no modes declared for fact table `%s/%d'.\n", [s(PredString), i(Arity)], Msg), add_error_report(Context, [words(Msg)], !Errors), @@ -812,7 +811,7 @@ infer_determinism_pass_1(!PredInfo, Context, ModuleInfo, CheckProcs, % We need to get the order right for CheckProcs because the first % procedure in list is used to derive the primary lookup key. - list__reverse(CheckProcs1, CheckProcs), + list.reverse(CheckProcs1, CheckProcs), pred_info_set_procedures(ProcTable, !PredInfo) ). @@ -827,7 +826,7 @@ infer_proc_determinism_pass_1([], _, !ProcTable, !CheckProcs, !FactArgInfos, infer_proc_determinism_pass_1([ProcID | ProcIDs], ModuleInfo, !ProcTable, !CheckProcs, !FactArgInfos, MaybeAllInProc, WriteHashTables, WriteDataTable, !Errors) :- - map__lookup(!.ProcTable, ProcID, ProcInfo0), + map.lookup(!.ProcTable, ProcID, ProcInfo0), proc_info_argmodes(ProcInfo0, ArgModes), fill_in_fact_arg_infos(ArgModes, ModuleInfo, !FactArgInfos), fact_table_mode_type(ArgModes, ModuleInfo, ModeType), @@ -888,7 +887,7 @@ infer_proc_determinism_pass_1([ProcID | ProcIDs], ModuleInfo, !ProcTable, ( InferredDetism = inferred(Determinism) -> proc_info_set_inferred_determinism(Determinism, ProcInfo0, ProcInfo), - map__det_update(!.ProcTable, ProcID, ProcInfo, !:ProcTable) + map.det_update(!.ProcTable, ProcID, ProcInfo, !:ProcTable) ; true ), @@ -902,8 +901,8 @@ infer_proc_determinism_pass_1([ProcID | ProcIDs], ModuleInfo, !ProcTable, MaybeAllInProc0 = no, MaybeAllInProc = MaybeAllInProc1 ), - bool__or(WriteHashTables0, WriteHashTables1, WriteHashTables), - bool__or(WriteDataTable0, WriteDataTable1, WriteDataTable). + bool.or(WriteHashTables0, WriteHashTables1, WriteHashTables), + bool.or(WriteDataTable0, WriteDataTable1, WriteDataTable). % Return the fact_table_mode_type for a procedure. % @@ -946,8 +945,8 @@ fact_table_mode_type([Mode | Modes], ModuleInfo, ModeType) :- open_sort_files([], [], !Errors, !IO). open_sort_files([ProcID | ProcIDs], ProcStreams, !Errors, !IO) :- - io__make_temp(SortFileName, !IO), - io__open_output(SortFileName, Result, !IO), + io.make_temp(SortFileName, !IO), + io.open_output(SortFileName, Result, !IO), ( Result = ok(Stream), open_sort_files(ProcIDs, ProcStreams0, !Errors, !IO), @@ -955,8 +954,8 @@ open_sort_files([ProcID | ProcIDs], ProcStreams, !Errors, !IO) :- ; Result = error(ErrorCode), ProcStreams = [], - io__error_message(ErrorCode, Message), - string__format("Error opening file `%s' for output: %s.", + io.error_message(ErrorCode, Message), + string.format("Error opening file `%s' for output: %s.", [s(SortFileName), s(Message)], Msg), add_error_report([words(Msg)], !Errors) ). @@ -971,8 +970,8 @@ open_sort_files([ProcID | ProcIDs], ProcStreams, !Errors, !IO) :- close_sort_files([], [], !IO). close_sort_files([proc_stream(ProcID, Stream) | ProcStreams], [ProcID - FileName | ProcFiles], !IO) :- - io__output_stream_name(Stream, FileName, !IO), - io__close_output(Stream, !IO), + io.output_stream_name(Stream, FileName, !IO), + io.close_output(Stream, !IO), close_sort_files(ProcStreams, ProcFiles, !IO). % write_sort_file_lines(ProcStreams, ProcTable, Terms): @@ -992,19 +991,19 @@ close_sort_files([proc_stream(ProcID, Stream) | ProcStreams], write_sort_file_lines([], _, _, _, _, _, _, !IO). write_sort_file_lines([proc_stream(ProcID, Stream) | ProcStreams], ProcTable, Terms, ModuleInfo, FactNumStr, FactArgInfos, IsPrimary, !IO) :- - map__lookup(ProcTable, ProcID, ProcInfo), + map.lookup(ProcTable, ProcID, ProcInfo), proc_info_argmodes(ProcInfo, ArgModes), - assoc_list__from_corresponding_lists(ArgModes, Terms, ModeTerms), + assoc_list.from_corresponding_lists(ArgModes, Terms, ModeTerms), make_sort_file_key(ModeTerms, ModuleInfo, Key), ( IsPrimary = yes, - assoc_list__from_corresponding_lists(FactArgInfos, Terms, InfoTerms), + assoc_list.from_corresponding_lists(FactArgInfos, Terms, InfoTerms), DataString = make_fact_data_string(InfoTerms) ; IsPrimary = no, DataString = "" ), - io__write_strings(Stream, + io.write_strings(Stream, [Key, "~", FactNumStr, "~", DataString, "\n"], !IO), write_sort_file_lines(ProcStreams, ProcTable, Terms, ModuleInfo, FactNumStr, [], no, !IO). @@ -1027,12 +1026,12 @@ make_sort_file_key([], _, ""). make_sort_file_key([(Mode - Term) | ModeTerms], ModuleInfo, Key) :- ( mode_is_fully_input(ModuleInfo, Mode), - Term = term__functor(Const, [], _Context) + Term = term.functor(Const, [], _Context) -> KeyPart = make_key_part(Const), make_sort_file_key(ModeTerms, ModuleInfo, Key0), - string__append(":", Key0, Key1), % field separator - string__append(KeyPart, Key1, Key) + string.append(":", Key0, Key1), % field separator + string.append(KeyPart, Key1, Key) ; make_sort_file_key(ModeTerms, ModuleInfo, Key) ). @@ -1046,29 +1045,29 @@ make_fact_data_string([fact_arg_info(_, _, IsOutput) - Term | InfoTerms]) = String :- ( IsOutput = yes, - Term = term__functor(Const, [], _) + Term = term.functor(Const, [], _) -> KeyPart = make_key_part(Const), String0 = make_fact_data_string(InfoTerms), - string__append_list([KeyPart, ":", String0], String) + string.append_list([KeyPart, ":", String0], String) ; String = make_fact_data_string(InfoTerms) ). :- func make_key_part(const) = string. -make_key_part(term__atom(_)) = _ :- +make_key_part(term.atom(_)) = _ :- unexpected(this_file, "make_key_part: enumerated types are not supported yet."). -make_key_part(term__integer(I)) = +make_key_part(term.integer(I)) = % convert int to base 36 to reduce the size of the I/O. - string__int_to_base_string(I, 36). -make_key_part(term__float(F)) = - string__float_to_string(F). -make_key_part(term__string(S)) = K :- - string__to_char_list(S, Cs0), + string.int_to_base_string(I, 36). +make_key_part(term.float(F)) = + string.float_to_string(F). +make_key_part(term.string(S)) = K :- + string.to_char_list(S, Cs0), Cs = key_from_chars(Cs0), - string__from_char_list(Cs, K). + string.from_char_list(Cs, K). % Escape all backslashes with a backslash and replace all % newlines with "\n", colons with "\c" and tildes with "\t". @@ -1077,7 +1076,7 @@ make_key_part(term__string(S)) = K :- key_from_chars(Cs) = ECs :- key_from_chars_2(Cs, [], ECs0), - list__reverse(ECs0, ECs). + list.reverse(ECs0, ECs). :- pred key_from_chars_2(list(char)::in, list(char)::in, list(char)::out) is det. @@ -1111,16 +1110,16 @@ key_from_chars_2([C | Cs], ECs0, ECs) :- infer_determinism_pass_2([], _, !ProcTable, !IO). infer_determinism_pass_2([ProcID - FileName | ProcFiles], ExistsAllInMode, !ProcTable, !IO) :- - map__lookup(!.ProcTable, ProcID, ProcInfo0), - make_command_string(string__format( + map.lookup(!.ProcTable, ProcID, ProcInfo0), + make_command_string(string.format( "LC_ALL=C sort -o %s %s && " ++ "cut -d'~' -f1 %s | LC_ALL=C sort -cu >/dev/null 2>&1", [s(FileName), s(FileName), s(FileName)]), double, Command), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Invoking system command `", !IO), maybe_write_string(Verbose, Command, !IO), maybe_write_string(Verbose, "'...", !IO), - io__call_system(Command, Result, !IO), + io.call_system(Command, Result, !IO), maybe_write_string(Verbose, "done.\n", !IO), ( Result = ok(ExitStatus), @@ -1155,13 +1154,13 @@ infer_determinism_pass_2([ProcID - FileName | ProcFiles], ExistsAllInMode, Determinism = nondet ) ; - io__progname_base("mercury_compile", ProgName, !IO), - string__format( + io.progname_base("mercury_compile", ProgName, !IO), + string.format( "%s: an error occurred in the `sort' program " ++ "during fact table determinism inference.", [s(ProgName)], Msg), write_error_pieces_plain([words(Msg)], !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), Determinism = erroneous ) ; @@ -1170,7 +1169,7 @@ infer_determinism_pass_2([ProcID - FileName | ProcFiles], ExistsAllInMode, Determinism = erroneous ), proc_info_set_inferred_determinism(Determinism, ProcInfo0, ProcInfo), - map__det_update(!.ProcTable, ProcID, ProcInfo, !:ProcTable), + map.det_update(!.ProcTable, ProcID, ProcInfo, !:ProcTable), infer_determinism_pass_2(ProcFiles, ExistsAllInMode, !ProcTable, !IO). %---------------------------------------------------------------------------% @@ -1179,7 +1178,7 @@ infer_determinism_pass_2([ProcID - FileName | ProcFiles], ExistsAllInMode, % :- pred write_fact_table_arrays(assoc_list(proc_id, string)::in, string::in, string::in, proc_table::in, module_info::in, int::in, - list(fact_arg_info)::in, bool::in, bool::in, io__output_stream::in, + list(fact_arg_info)::in, bool::in, bool::in, io.output_stream::in, string::out, proc_id::out, io::di, io::uo) is det. write_fact_table_arrays(ProcFiles0, DataFileName, StructName, ProcTable, @@ -1191,7 +1190,7 @@ write_fact_table_arrays(ProcFiles0, DataFileName, StructName, ProcTable, ProcFiles0 = [], C_HeaderCode = "", % This won't get used anyway. - PrimaryProcID = hlds_pred__initial_proc_id + PrimaryProcID = hlds_pred.initial_proc_id ; ProcFiles0 = [PrimaryProcID - FileName | ProcFiles1], ( @@ -1229,7 +1228,7 @@ write_fact_table_arrays(ProcFiles0, DataFileName, StructName, ProcTable, % Write out the data for the fact table. % :- pred write_fact_table_data(int::in, list(list(fact_arg))::in, string::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. write_fact_table_data(_, [], _, _, !IO). write_fact_table_data(FactNum, [Args | ArgsList], StructName, OutputStream, @@ -1243,7 +1242,7 @@ write_fact_table_data(FactNum, [Args | ArgsList], StructName, OutputStream, % for the first array or the closing brace of the last array. % :- pred write_fact_data(int::in, list(fact_arg)::in, string::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. write_fact_data(FactNum, Args, StructName, OutputStream, !IO) :- fact_table_size(FactTableSize, !IO), @@ -1254,58 +1253,58 @@ write_fact_data(FactNum, Args, StructName, OutputStream, !IO) :- write_closing_brace(OutputStream, !IO), write_new_data_array(OutputStream, StructName, FactNum, !IO) ), - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__format("%% Writing fact %d\n", [i(FactNum)], !IO) + io.format("%% Writing fact %d\n", [i(FactNum)], !IO) ; VeryVerbose = no ) ; true ), - io__write_string(OutputStream, "\t{", !IO), + io.write_string(OutputStream, "\t{", !IO), write_fact_args(Args, OutputStream, !IO), - io__write_string(OutputStream, " },\n", !IO). + io.write_string(OutputStream, " },\n", !IO). % Write out the declaration of a new data array followed by " = {\n". % -:- pred write_new_data_array(io__output_stream::in, string::in, int::in, +:- pred write_new_data_array(io.output_stream::in, string::in, int::in, io::di, io::uo) is det. write_new_data_array(OutputStream, StructName, FactNum, !IO) :- - io__format(OutputStream, "const struct %s_struct %s%d[] = {\n", + io.format(OutputStream, "const struct %s_struct %s%d[] = {\n", [s(StructName), s(StructName), i(FactNum)], !IO). % Write out the closing brace of an array. % -:- pred write_closing_brace(io__output_stream::in, io::di, io::uo) is det. +:- pred write_closing_brace(io.output_stream::in, io::di, io::uo) is det. write_closing_brace(OutputStream, !IO) :- - io__write_string(OutputStream, "};\n\n", !IO). + io.write_string(OutputStream, "};\n\n", !IO). -:- pred write_fact_args(list(fact_arg)::in, io__output_stream::in, +:- pred write_fact_args(list(fact_arg)::in, io.output_stream::in, io::di, io::uo) is det. write_fact_args([], _, !IO). write_fact_args([Arg | Args], OutputStream, !IO) :- ( - Arg = term__string(String), - io__set_output_stream(OutputStream, OldStream, !IO), - io__write_string("""", !IO), - c_util__output_quoted_string(String, !IO), - io__write_string(""", ", !IO), - io__set_output_stream(OldStream, _, !IO) + Arg = term.string(String), + io.set_output_stream(OutputStream, OldStream, !IO), + io.write_string("""", !IO), + c_util.output_quoted_string(String, !IO), + io.write_string(""", ", !IO), + io.set_output_stream(OldStream, _, !IO) ; - Arg = term__integer(Int), - io__write_int(OutputStream, Int, !IO), - io__write_string(OutputStream, ", ", !IO) + Arg = term.integer(Int), + io.write_int(OutputStream, Int, !IO), + io.write_string(OutputStream, ", ", !IO) ; - Arg = term__float(Float), - io__write_float(OutputStream, Float, !IO), - io__write_string(OutputStream, ", ", !IO) + Arg = term.float(Float), + io.write_float(OutputStream, Float, !IO), + io.write_string(OutputStream, ", ", !IO) ; - Arg = term__atom(_), + Arg = term.atom(_), unexpected(this_file, "write_fact_terms: unsupported type") ), write_fact_args(Args, OutputStream, !IO). @@ -1318,13 +1317,13 @@ write_fact_args([Arg | Args], OutputStream, !IO) :- maybe_append_data_table(no, _, _, !IO). maybe_append_data_table(yes, OutputFileName, DataFileName, !IO) :- - make_command_string(string__format("cat %s >>%s", + make_command_string(string.format("cat %s >>%s", [s(DataFileName), s(OutputFileName)]), forward, Command), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Invoking system command `", !IO), maybe_write_string(Verbose, Command, !IO), maybe_write_string(Verbose, ", ...", !IO), - io__call_system(Command, Result, !IO), + io.call_system(Command, Result, !IO), maybe_write_string(Verbose, "done.\n", !IO), ( Result = ok(ExitStatus), @@ -1334,7 +1333,7 @@ maybe_append_data_table(yes, OutputFileName, DataFileName, !IO) :- Msg = "An error occurred while concatenating" ++ "fact table output files.", write_error_pieces_plain([words(Msg)], !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ) ; Result = error(ErrorCode), @@ -1347,14 +1346,14 @@ maybe_append_data_table(yes, OutputFileName, DataFileName, !IO) :- % Write out the data table if required. % :- pred write_primary_hash_table(proc_id::in, string::in, string::in, - string::in, proc_table::in, module_info::in, io__output_stream::in, + string::in, proc_table::in, module_info::in, io.output_stream::in, list(fact_arg_info)::in, bool::in, int::in, bool::in, fact_result::out, map(int, int)::out, string::out, io::di, io::uo) is det. write_primary_hash_table(ProcID, FileName, DataFileName, StructName, ProcTable, ModuleInfo, OutputStream, FactArgInfos, WriteDataTable, NumFacts, CreateFactMap, Result, FactMap, C_HeaderCode, !IO) :- - map__init(FactMap0), + map.init(FactMap0), see_input_handle_error(no, FileName, Result0, !IO), ( Result0 = ok, @@ -1380,14 +1379,14 @@ write_primary_hash_table(ProcID, FileName, DataFileName, StructName, ProcTable, ( Result2 = ok, proc_id_to_int(ProcID, ProcInt), - string__format("%s_hash_table_%d_", + string.format("%s_hash_table_%d_", [s(StructName), i(ProcInt)], HashTableName), - string__format("extern struct MR_fact_table_hash_table_i %s0;\n", + string.format("extern struct MR_fact_table_hash_table_i %s0;\n", [s(HashTableName)], C_HeaderCode0), % Note: the type declared here is not necessarily correct. % The type is declared just to stop the C compiler emitting % warnings. - map__lookup(ProcTable, ProcID, ProcInfo), + map.lookup(ProcTable, ProcID, ProcInfo), proc_info_argmodes(ProcInfo, ArgModes), read_sort_file_line(FactArgInfos, ArgModes, ModuleInfo, MaybeFirstFact, !IO), @@ -1414,13 +1413,13 @@ write_primary_hash_table(ProcID, FileName, DataFileName, StructName, ProcTable, write_closing_brace(DataStream1, !IO), write_fact_table_pointer_array(NumFacts, StructName, DataStream1, C_HeaderCode1, !IO), - io__close_output(DataStream1, !IO), + io.close_output(DataStream1, !IO), C_HeaderCode = C_HeaderCode0 ++ C_HeaderCode1 ; MaybeDataStream = no, C_HeaderCode = C_HeaderCode0 ), - io__seen(!IO), + io.seen(!IO), delete_temporary_file(FileName, !IO) ; Result0 = error(_), @@ -1432,7 +1431,7 @@ write_primary_hash_table(ProcID, FileName, DataFileName, StructName, ProcTable, % Build hash tables for non-primary input procs. % :- pred write_secondary_hash_tables(assoc_list(proc_id, string)::in, - string::in, proc_table::in, module_info::in, io__output_stream::in, + string::in, proc_table::in, module_info::in, io.output_stream::in, map(int, int)::in, list(fact_arg_info)::in, string::in, string::out, io::di, io::uo) is det. @@ -1444,16 +1443,16 @@ write_secondary_hash_tables([ProcID - FileName | ProcFiles], StructName, ( SeeResult = ok, proc_id_to_int(ProcID, ProcInt), - string__format("%s_hash_table_%d_", + string.format("%s_hash_table_%d_", [s(StructName), i(ProcInt)], HashTableName), - string__format( + string.format( "extern struct MR_fact_table_hash_table_i %s0;\n", [s(HashTableName)], New_C_HeaderCode), % Note: the type declared here is not necessarily correct. % The type is declared just to stop the C compiler emitting % warnings. - string__append(New_C_HeaderCode, !C_HeaderCode), - map__lookup(ProcTable, ProcID, ProcInfo), + string.append(New_C_HeaderCode, !C_HeaderCode), + map.lookup(ProcTable, ProcID, ProcInfo), proc_info_argmodes(ProcInfo, ArgModes), read_sort_file_line(FactArgInfos, ArgModes, ModuleInfo, MaybeFirstFact, !IO), @@ -1462,14 +1461,14 @@ write_secondary_hash_tables([ProcID - FileName | ProcFiles], StructName, build_hash_table(0, 0, HashTableName, StructName, 0, ArgModes, ModuleInfo, FactArgInfos, no, OutputStream, FirstFact, no, no, FactMap, _, !IO), - io__seen(!IO), + io.seen(!IO), delete_temporary_file(FileName, !IO), write_secondary_hash_tables(ProcFiles, StructName, ProcTable, ModuleInfo, OutputStream, FactMap, FactArgInfos, !C_HeaderCode, !IO) ; MaybeFirstFact = no, - io__seen(!IO) + io.seen(!IO) ) ; SeeResult = error(_) @@ -1480,10 +1479,10 @@ write_secondary_hash_tables([ProcID - FileName | ProcFiles], StructName, read_sort_file_line(FactArgInfos, ArgModes, ModuleInfo, MaybeSortFileLine, !IO) :- - io__read_line(Result, !IO), + io.read_line(Result, !IO), ( Result = ok(LineChars), - string__from_char_list(LineChars, LineString), + string.from_char_list(LineChars, LineString), split_sort_file_line(FactArgInfos, ArgModes, ModuleInfo, LineString, SortFileLine), MaybeSortFileLine = yes(SortFileLine) @@ -1492,11 +1491,11 @@ read_sort_file_line(FactArgInfos, ArgModes, ModuleInfo, MaybeSortFileLine, MaybeSortFileLine = no ; Result = error(ErrorCode), - io__error_message(ErrorCode, ErrorMessage), - io__input_stream_name(FileName, !IO), - string__format("Error reading file `%s':", [s(FileName)], Msg), + io.error_message(ErrorCode, ErrorMessage), + io.input_stream_name(FileName, !IO), + string.format("Error reading file `%s':", [s(FileName)], Msg), write_error_pieces_plain([words(Msg), nl, words(ErrorMessage)], !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), MaybeSortFileLine = no ). @@ -1505,8 +1504,8 @@ read_sort_file_line(FactArgInfos, ArgModes, ModuleInfo, MaybeSortFileLine, % :- pred build_hash_table(int::in, int::in, string::in, string::in, int::in, list(mer_mode)::in, module_info::in, list(fact_arg_info)::in, bool::in, - io__output_stream::in, sort_file_line::in, - maybe(io__output_stream)::in, bool::in, + io.output_stream::in, sort_file_line::in, + maybe(io.output_stream)::in, bool::in, map(int, int)::in, map(int, int)::out, io::di, io::uo) is det. build_hash_table(FactNum, InputArgNum, HashTableName, StructName, TableNum, @@ -1516,8 +1515,8 @@ build_hash_table(FactNum, InputArgNum, HashTableName, StructName, TableNum, TableNum, ArgModes, ModuleInfo, Infos, IsPrimaryTable, OutputStream, yes(FirstFact), MaybeDataStream, CreateFactMap, !FactMap, [], HashList, !IO), - list__length(HashList, Len), - globals__io_get_globals(Globals, !IO), + list.length(HashList, Len), + globals.io_get_globals(Globals, !IO), calculate_hash_table_size(Globals, Len, HashSize), hash_table_init(HashSize, HashTable0), hash_table_from_list(HashList, HashSize, HashTable0, HashTable), @@ -1525,8 +1524,8 @@ build_hash_table(FactNum, InputArgNum, HashTableName, StructName, TableNum, :- pred build_hash_table_2(int::in, int::in, string::in, string::in, int::in, list(mer_mode)::in, module_info::in, list(fact_arg_info)::in, bool::in, - io__output_stream::in, - maybe(sort_file_line)::in, maybe(io__output_stream)::in, + io.output_stream::in, + maybe(sort_file_line)::in, maybe(io.output_stream)::in, bool::in, map(int, int)::in, map(int, int)::out, list(hash_entry)::in, list(hash_entry)::out, io::di, io::uo) is det. @@ -1546,7 +1545,7 @@ build_hash_table_2(FactNum, InputArgNum, HashTableName, StructName, !.TableNum, ), ( MaybeDataStream = yes(DataStream), - list__map((pred(X::in, Y::out) is det :- + list.map((pred(X::in, Y::out) is det :- X = sort_file_line(_, _, Y) ), MatchingFacts, OutputData), write_fact_table_data(FactNum, OutputData, StructName, DataStream, !IO) @@ -1556,7 +1555,7 @@ build_hash_table_2(FactNum, InputArgNum, HashTableName, StructName, !.TableNum, do_build_hash_table(FactNum, InputArgNum, HashTableName, !TableNum, IsPrimaryTable, OutputStream, MatchingFacts, !.FactMap, !HashList, !IO), - list__length(MatchingFacts, Len), + list.length(MatchingFacts, Len), NextFactNum = FactNum + Len, build_hash_table_2(NextFactNum, InputArgNum, HashTableName, StructName, !.TableNum, ArgModes, ModuleInfo, Infos, IsPrimaryTable, OutputStream, @@ -1568,7 +1567,7 @@ build_hash_table_2(FactNum, InputArgNum, HashTableName, StructName, !.TableNum, % from the actual sort file. % :- pred build_hash_table_lower_levels(int::in, int::in, string::in, - int::in, int::out, bool::in, io__output_stream::in, + int::in, int::out, bool::in, io.output_stream::in, list(sort_file_line)::in, map(int, int)::in, io::di, io::uo) is det. build_hash_table_lower_levels(FactNum, InputArgNum, HashTableName, @@ -1577,15 +1576,15 @@ build_hash_table_lower_levels(FactNum, InputArgNum, HashTableName, build_hash_table_lower_levels_2(FactNum, InputArgNum, HashTableName, TableNum0, TableNum, IsPrimaryTable, OutputStream, Facts, FactMap, [], HashList, !IO), - list__length(HashList, Len), - globals__io_get_globals(Globals, !IO), + list.length(HashList, Len), + globals.io_get_globals(Globals, !IO), calculate_hash_table_size(Globals, Len, HashSize), hash_table_init(HashSize, HashTable0), hash_table_from_list(HashList, HashSize, HashTable0, HashTable), write_hash_table(HashTableName, TableNum0, HashTable, OutputStream, !IO). :- pred build_hash_table_lower_levels_2(int::in, int::in, string::in, - int::in, int::out, bool::in, io__output_stream::in, + int::in, int::out, bool::in, io.output_stream::in, list(sort_file_line)::in, map(int, int)::in, list(hash_entry)::in, list(hash_entry)::out, io::di, io::uo) is det. @@ -1598,7 +1597,7 @@ build_hash_table_lower_levels_2(FactNum, InputArgNum, HashTableName, Facts1, InputArgNum), do_build_hash_table(FactNum, InputArgNum, HashTableName, !TableNum, IsPrimaryTable, OutputStream, MatchingFacts, FactMap, !HashList, !IO), - list__length(MatchingFacts, Len), + list.length(MatchingFacts, Len), NextFactNum = FactNum + Len, build_hash_table_lower_levels_2(NextFactNum, InputArgNum, HashTableName, !TableNum, IsPrimaryTable, OutputStream, Facts1, FactMap, !HashList, @@ -1608,7 +1607,7 @@ build_hash_table_lower_levels_2(FactNum, InputArgNum, HashTableName, % hash table. % :- pred do_build_hash_table(int::in, int::in, string::in, int::in, int::out, - bool::in, io__output_stream::in, list(sort_file_line)::in, + bool::in, io.output_stream::in, list(sort_file_line)::in, map(int, int)::in, list(hash_entry)::in, list(hash_entry)::out, io::di, io::uo) is det. @@ -1625,7 +1624,7 @@ do_build_hash_table(FactNum, InputArgNum, HashTableName, !TableNum, HashIndex = FactNum ; IsPrimaryTable = no, - map__lookup(FactMap, Index, HashIndex) + map.lookup(FactMap, Index, HashIndex) ), ( Facts1 = [] @@ -1638,7 +1637,7 @@ do_build_hash_table(FactNum, InputArgNum, HashTableName, !TableNum, NextInputArgNum = InputArgNum + 1, Fact = sort_file_line(InputArgs, _, _), N = NextInputArgNum + 1, - list__drop(N, InputArgs, _) + list.drop(N, InputArgs, _) -> !:TableNum = !.TableNum + 1, ThisTableNum = !.TableNum, @@ -1673,7 +1672,7 @@ top_level_collect_matching_facts(Fact, MatchingFacts, MaybeNextFact, Infos, ArgModes, ModuleInfo, !IO) :- top_level_collect_matching_facts_2(Fact, [], MatchingFacts0, MaybeNextFact, Infos, ArgModes, ModuleInfo, !IO), - list__reverse(MatchingFacts0, MatchingFacts1), + list.reverse(MatchingFacts0, MatchingFacts1), MatchingFacts = [Fact | MatchingFacts1]. :- pred top_level_collect_matching_facts_2(sort_file_line::in, @@ -1716,7 +1715,7 @@ lower_level_collect_matching_facts(Fact, Facts0, Matching, Remaining, InputArgNum) :- lower_level_collect_matching_facts_2(Fact, Facts0, [], Matching0, Remaining, InputArgNum), - list__reverse(Matching0, Matching1), + list.reverse(Matching0, Matching1), Matching = [Fact | Matching1]. :- pred lower_level_collect_matching_facts_2(sort_file_line::in, @@ -1729,8 +1728,8 @@ lower_level_collect_matching_facts_2(Fact, [Fact0 | Facts0], Matching0, Fact0 = sort_file_line(InputArgs0, _, _), Fact = sort_file_line(InputArgs, _, _), ( - list__drop(InputArgNum, InputArgs0, [Arg0 | _]), - list__drop(InputArgNum, InputArgs, [Arg | _]) + list.drop(InputArgNum, InputArgs0, [Arg0 | _]), + list.drop(InputArgNum, InputArgs, [Arg | _]) -> ( Arg = Arg0 -> lower_level_collect_matching_facts_2(Fact, Facts0, @@ -1750,7 +1749,7 @@ lower_level_collect_matching_facts_2(Fact, [Fact0 | Facts0], Matching0, update_fact_map(_, [], !FactMap). update_fact_map(FactNum, [Fact | Facts], !FactMap) :- Fact = sort_file_line(_, Index, _), - map__set(!.FactMap, Index, FactNum, !:FactMap), + map.set(!.FactMap, Index, FactNum, !:FactMap), update_fact_map(FactNum + 1, Facts, !FactMap). %---------------------------------------------------------------------------% @@ -1763,14 +1762,14 @@ update_fact_map(FactNum, [Fact | Facts], !FactMap) :- split_sort_file_line(FactArgInfos, ArgModes, ModuleInfo, Line0, SortFileLine) :- ( - string__sub_string_search(Line0, "~", Pos0), - string__split(Line0, Pos0, InputArgsString, Line1), - string__first_char(Line1, _, Line2), - string__sub_string_search(Line2, "~", Pos1), - string__split(Line2, Pos1, IndexString, Line3), - string__first_char(Line3, _, Line4), - string__remove_suffix(Line4, "\n", OutputArgsString), - string__to_int(IndexString, Index0) + string.sub_string_search(Line0, "~", Pos0), + string.split(Line0, Pos0, InputArgsString, Line1), + string.first_char(Line1, _, Line2), + string.sub_string_search(Line2, "~", Pos1), + string.split(Line2, Pos1, IndexString, Line3), + string.first_char(Line3, _, Line4), + string.remove_suffix(Line4, "\n", OutputArgsString), + string.to_int(IndexString, Index0) -> split_key_to_arg_strings(InputArgsString, InputArgStrings), get_input_args_list(FactArgInfos, ArgModes, ModuleInfo, @@ -1801,9 +1800,9 @@ split_key_to_arg_strings(Key0, ArgStrings) :- ArgStrings = [] ; ( - string__sub_string_search(Key0, ":", Pos), - string__split(Key0, Pos, ArgString, Key1), - string__first_char(Key1, _, Key2) + string.sub_string_search(Key0, ":", Pos), + string.split(Key0, Pos, ArgString, Key1), + string.first_char(Key1, _, Key2) -> split_key_to_arg_strings(Key2, ArgStrings0), ArgStrings = [ArgString | ArgStrings0] @@ -1866,21 +1865,21 @@ get_output_args_list([Info | Infos], ArgStrings0, Args) :- convert_key_string_to_arg(ArgString, Type, Arg) :- ( Type = builtin(int) -> - ( string__base_string_to_int(36, ArgString, I) -> - Arg = term__integer(I) + ( string.base_string_to_int(36, ArgString, I) -> + Arg = term.integer(I) ; unexpected(this_file, "convert_key_string_to_arg: could not convert string to int") ) ; Type = builtin(string) -> - string__to_char_list(ArgString, Cs0), + string.to_char_list(ArgString, Cs0), remove_sort_file_escapes(Cs0, [], Cs1), - list__reverse(Cs1, Cs), - string__from_char_list(Cs, S), - Arg = term__string(S) + list.reverse(Cs1, Cs), + string.from_char_list(Cs, S), + Arg = term.string(S) ; Type = builtin(float) -> - ( string__to_float(ArgString, F) -> - Arg = term__float(F) + ( string.to_float(ArgString, F) -> + Arg = term.float(F) ; unexpected(this_file, "convert_key_string_to_arg: could not convert string to float") @@ -1926,7 +1925,7 @@ remove_sort_file_escapes([C0 | Cs0], In, Out) :- fact_get_arg_and_index(Fact, InputArgNum, Arg, Index) :- Fact = sort_file_line(InputArgs, Index, _), - ( list__drop(InputArgNum, InputArgs, [Arg0 | _]) -> + ( list.drop(InputArgNum, InputArgs, [Arg0 | _]) -> Arg = Arg0 ; unexpected(this_file, "fact_get_arg_and_index: not enough input args") @@ -1941,7 +1940,7 @@ fact_get_arg_and_index(Fact, InputArgNum, Arg, Index) :- :- pred calculate_hash_table_size(globals::in, int::in, int::out) is det. calculate_hash_table_size(Globals, NumEntries, HashTableSize) :- - globals__lookup_int_option(Globals, fact_table_hash_percent_full, + globals.lookup_int_option(Globals, fact_table_hash_percent_full, PercentFull), Primes = [2, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 16411, 32771, 65537, 131101, 262147, 524309, 1048627, 2097257, 4194493, @@ -2027,19 +2026,19 @@ get_free_hash_slot_2(HashTable, Start, Max, Free) :- :- pred fact_table_hash(int::in, fact_arg::in, int::out) is det. fact_table_hash(HashSize, Key, HashVal) :- - ( Key = term__string(String) -> + ( Key = term.string(String) -> % XXX This method of hashing strings may not work if cross-compiling % between systems that have different character representations. - string__to_char_list(String, Cs), - list__map((pred(C::in, I::out) is det :- char__to_int(C, I)), Cs, Ns) - ; Key = term__integer(Int) -> - int__abs(Int, N), + string.to_char_list(String, Cs), + list.map((pred(C::in, I::out) is det :- char.to_int(C, I)), Cs, Ns) + ; Key = term.integer(Int) -> + int.abs(Int, N), Ns = [N] - ; Key = term__float(Float) -> + ; Key = term.float(Float) -> % XXX This method of hashing floats may not work cross-compiling % between architectures that have different floating-point % representations. - int__abs(float__hash(Float), N), + int.abs(float.hash(Float), N), Ns = [N] ; unexpected(this_file, "fact_table_hash: unsupported type in key") @@ -2066,7 +2065,7 @@ hash_list_insert_many([Fact | Facts], IsPrimaryTable, FactMap, HashIndex = FactNum ; IsPrimaryTable = no, - map__lookup(FactMap, Index, HashIndex) + map.lookup(FactMap, Index, HashIndex) ), !:HashList = [hash_entry(Arg, fact(HashIndex), -1) | !.HashList], hash_list_insert_many(Facts, IsPrimaryTable, FactMap, FactNum, @@ -2075,7 +2074,7 @@ hash_list_insert_many([Fact | Facts], IsPrimaryTable, FactMap, :- pred hash_table_init(int::in, hash_table::out) is det. hash_table_init(Size, HashTable) :- - map__init(Map), + map.init(Map), HashTable = hash_table(Size, Map). :- pred hash_table_from_list(list(hash_entry)::in, int::in, hash_table::in, @@ -2090,33 +2089,33 @@ hash_table_from_list([Entry | Entrys], HashSize, !HashTable) :- hash_table_search(HashTable, Index, Value) :- HashTable = hash_table(_, Map), - map__search(Map, Index, Value). + map.search(Map, Index, Value). :- pred hash_table_set(int::in, hash_entry::in, hash_table::in, hash_table::out) is det. hash_table_set(Index, Value, HashTable0, HashTable) :- HashTable0 = hash_table(Size, Map0), - map__set(Map0, Index, Value, Map), + map.set(Map0, Index, Value, Map), HashTable = hash_table(Size, Map). %--------------------------------------------------------------------------% % Write out the C code for a hash table. :- pred write_hash_table(string::in, int::in, hash_table::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. write_hash_table(BaseName, TableNum, HashTable, OutputStream, !IO) :- get_hash_table_type(HashTable, TableType), - string__format("struct MR_fact_table_hash_entry_%c %s%d_data[]", + string.format("struct MR_fact_table_hash_entry_%c %s%d_data[]", [c(TableType), s(BaseName), i(TableNum)], HashTableDataName), - io__set_output_stream(OutputStream, OldOutputStream, !IO), - io__write_strings([HashTableDataName, " = {\n"], !IO), + io.set_output_stream(OutputStream, OldOutputStream, !IO), + io.write_strings([HashTableDataName, " = {\n"], !IO), HashTable = hash_table(Size, _), MaxIndex = Size - 1, write_hash_table_2(HashTable, 0, MaxIndex, !IO), - io__write_string("};\n\n", !IO), - io__format(" + io.write_string("};\n\n", !IO), + io.format(" struct MR_fact_table_hash_table_%c %s%d = { %d, @@ -2125,7 +2124,7 @@ struct MR_fact_table_hash_table_%c %s%d = { ", [c(TableType), s(BaseName), i(TableNum), i(Size), s(BaseName), i(TableNum)], !IO), - io__set_output_stream(OldOutputStream, _, !IO). + io.set_output_stream(OldOutputStream, _, !IO). :- pred write_hash_table_2(hash_table::in, int::in, int::in, io::di, io::uo) is det. @@ -2134,37 +2133,37 @@ write_hash_table_2(HashTable, CurrIndex, MaxIndex, !IO) :- ( CurrIndex > MaxIndex -> true ; - io__write_string("\t{ ", !IO), + io.write_string("\t{ ", !IO), ( hash_table_search(HashTable, CurrIndex, hash_entry(Key, Index, Next)) -> - ( Key = term__string(String) -> - io__write_string("""", !IO), - c_util__output_quoted_string(String, !IO), - io__write_string("""", !IO) - ; Key = term__integer(Int) -> - io__write_int(Int, !IO) - ; Key = term__float(Float) -> - io__write_float(Float, !IO) + ( Key = term.string(String) -> + io.write_string("""", !IO), + c_util.output_quoted_string(String, !IO), + io.write_string("""", !IO) + ; Key = term.integer(Int) -> + io.write_int(Int, !IO) + ; Key = term.float(Float) -> + io.write_float(Float, !IO) ; unexpected(this_file, "write_hash_table: unsupported type") ), ( Index = fact(I), - io__format(", MR_FACT_TABLE_MAKE_TAGGED_INDEX(%d, 1), ", + io.format(", MR_FACT_TABLE_MAKE_TAGGED_INDEX(%d, 1), ", [i(I)], !IO) ; Index = hash_table(I, H), - io__format(", MR_FACT_TABLE_MAKE_TAGGED_POINTER(&%s%d, 2), ", + io.format(", MR_FACT_TABLE_MAKE_TAGGED_POINTER(&%s%d, 2), ", [s(H), i(I)], !IO) ), - io__write_int(Next, !IO) + io.write_int(Next, !IO) ; - io__write_string( + io.write_string( "0, MR_FACT_TABLE_MAKE_TAGGED_POINTER(NULL, 0), -1 ", !IO) ), - io__write_string("},\n", !IO), + io.write_string("},\n", !IO), write_hash_table_2(HashTable, CurrIndex + 1, MaxIndex, !IO) ). @@ -2175,7 +2174,7 @@ write_hash_table_2(HashTable, CurrIndex, MaxIndex, !IO) :- get_hash_table_type(HashTable, TableType) :- HashTable = hash_table(_Size, Map), - ( map__is_empty(Map) -> + ( map.is_empty(Map) -> unexpected(this_file, "get_has_table_type: empty hash table") ; get_hash_table_type_2(Map, 0, TableType) @@ -2185,15 +2184,15 @@ get_hash_table_type(HashTable, TableType) :- is det. get_hash_table_type_2(Map, Index, TableType) :- - ( map__search(Map, Index, Entry) -> + ( map.search(Map, Index, Entry) -> Entry = hash_entry(Key, _, _), - ( Key = term__string(_) -> + ( Key = term.string(_) -> TableType = 's' - ; Key = term__integer(_) -> + ; Key = term.integer(_) -> TableType = 'i' - ; Key = term__float(_) -> + ; Key = term.float(_) -> TableType = 'f' - ; Key = term__atom(_) -> + ; Key = term.atom(_) -> TableType = 'a' ; unexpected(this_file, "get_hash_table_type: invalid term") @@ -2207,27 +2206,27 @@ get_hash_table_type_2(Map, Index, TableType) :- % Write out the array of pointers to the fact table arrays. % :- pred write_fact_table_pointer_array(int::in, string::in, - io__output_stream::in, string::out, io::di, io::uo) is det. + io.output_stream::in, string::out, io::di, io::uo) is det. write_fact_table_pointer_array(NumFacts, StructName, OutputStream, C_HeaderCode, !IO) :- PointerArrayName = "const struct " ++ StructName ++ "_struct *" ++ StructName ++ "[]", C_HeaderCode = "extern " ++ PointerArrayName ++ ";\n", - io__write_strings(OutputStream, [PointerArrayName, " = {\n"], !IO), + io.write_strings(OutputStream, [PointerArrayName, " = {\n"], !IO), write_fact_table_pointer_array_2(0, NumFacts, StructName, OutputStream, !IO), - io__write_string(OutputStream, "};\n", !IO). + io.write_string(OutputStream, "};\n", !IO). :- pred write_fact_table_pointer_array_2(int::in, int::in, string::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. write_fact_table_pointer_array_2(CurrFact, NumFacts, StructName, OutputStream, !IO) :- ( CurrFact >= NumFacts -> true ; - io__format(OutputStream, "\t%s%d,\n", + io.format(OutputStream, "\t%s%d,\n", [s(StructName), i(CurrFact)], !IO), fact_table_size(FactTableSize, !IO), NextFact = CurrFact + FactTableSize, @@ -2235,21 +2234,21 @@ write_fact_table_pointer_array_2(CurrFact, NumFacts, StructName, OutputStream, OutputStream, !IO) ). -:- pred write_fact_table_numfacts(sym_name::in, int::in, io__output_stream::in, +:- pred write_fact_table_numfacts(sym_name::in, int::in, io.output_stream::in, string::out, io::di, io::uo) is det. write_fact_table_numfacts(PredName, NumFacts, OutputStream, C_HeaderCode, !IO) :- - io__set_output_stream(OutputStream, OldOutputStream, !IO), + io.set_output_stream(OutputStream, OldOutputStream, !IO), % Write out the size of the fact table. make_fact_table_identifier(PredName, Identifier), - io__write_strings(["const MR_Integer mercury__", Identifier, + io.write_strings(["const MR_Integer mercury__", Identifier, "_fact_table_num_facts = "], !IO), - io__write_int(NumFacts, !IO), - io__write_string(";\n\n", !IO), + io.write_int(NumFacts, !IO), + io.write_string(";\n\n", !IO), C_HeaderCode = "extern const MR_Integer mercury__" ++ Identifier ++ "_fact_table_num_facts;\n", - io__set_output_stream(OldOutputStream, _, !IO). + io.set_output_stream(OldOutputStream, _, !IO). %---------------------------------------------------------------------------% @@ -2319,7 +2318,7 @@ fact_table_generate_c_code(PredName, PragmaVars, ProcID, PrimaryProcID, % List the variables in the C code to stop the compiler giving % a warning about them not being there. pragma_vars_to_names_string(PragmaVars, NamesString), - string__format("/* %s */", [s(NamesString)], ProcCode), + string.format("/* %s */", [s(NamesString)], ProcCode), ExtraCode = "" ). @@ -2374,13 +2373,13 @@ void mercury_sys_init_%s_module(void) { ", NumFactsVar = "mercury__" ++ PredName ++ "_fact_table_num_facts", - list__length(PragmaVars, Arity), + list.length(PragmaVars, Arity), generate_argument_vars_code(PragmaVars, ArgTypes, ModuleInfo, ArgDeclCode, _InputCode, OutputCode, _, _, _), generate_fact_lookup_code(PredName, PragmaVars, ArgTypes, ModuleInfo, 1, FactTableSize, FactLookupCode), - string__format(ExtraCodeTemplate, [ + string.format(ExtraCodeTemplate, [ s(ExtraCodeLabel), s(ExtraCodeLabel), s(ExtraCodeLabel), @@ -2425,12 +2424,12 @@ generate_nondet_proc_code(PragmaVars, PredName, ProcID, ExtraCodeLabel, } ", - list__length(PragmaVars, Arity), + list.length(PragmaVars, Arity), proc_id_to_int(ProcID, ProcInt), - string__format("mercury__%s_%d_%d_xx", + string.format("mercury__%s_%d_%d_xx", [s(PredName), i(Arity), i(ProcInt)], ExtraCodeLabel), pragma_vars_to_names_string(PragmaVars, NamesString), - string__format(ProcCodeTemplate, [s(NamesString), s(ExtraCodeLabel), + string.format(ProcCodeTemplate, [s(NamesString), s(ExtraCodeLabel), s(ExtraCodeLabel)], ProcCode). % pragma_vars_to_names_string(PragmaVars, NamesString): @@ -2444,7 +2443,7 @@ pragma_vars_to_names_string([], ""). pragma_vars_to_names_string([pragma_var(_, Name, _, _) | PVars], NamesString) :- pragma_vars_to_names_string(PVars, NamesString0), - string__append_list([Name, ", ", NamesString0], NamesString). + string.append_list([Name, ", ", NamesString0], NamesString). %---------------------------------------------------------------------------% @@ -2454,7 +2453,7 @@ pragma_vars_to_names_string([pragma_var(_, Name, _, _) | PVars], is det. generate_cc_multi_code(PredName, PragmaVars, ProcCode) :- - string__append_list(["mercury__", PredName, "_fact_table"], StructName), + string.append_list(["mercury__", PredName, "_fact_table"], StructName), generate_cc_multi_code_2(PragmaVars, StructName, 1, "", ProcCode). :- pred generate_cc_multi_code_2(list(pragma_var)::in, string::in, int::in, @@ -2463,9 +2462,9 @@ generate_cc_multi_code(PredName, PragmaVars, ProcCode) :- generate_cc_multi_code_2([], _, _, !ProcCode). generate_cc_multi_code_2([pragma_var(_, VarName, _, _) | PragmaVars], StructName, ArgNum, !ProcCode) :- - string__format("\t\t%s = %s[0][0].V_%d;\n", [s(VarName), s(StructName), + string.format("\t\t%s = %s[0][0].V_%d;\n", [s(VarName), s(StructName), i(ArgNum)], NewProcCode), - string__append(NewProcCode, !ProcCode), + string.append(NewProcCode, !ProcCode), generate_cc_multi_code_2(PragmaVars, StructName, ArgNum + 1, !ProcCode). %---------------------------------------------------------------------------% @@ -2480,7 +2479,7 @@ generate_all_in_code(PredName, PragmaVars, ProcID, ArgTypes, ModuleInfo, generate_decl_code(PredName, ProcID, DeclCode), proc_id_to_int(ProcID, ProcInt), - string__format("%s_%d", [s(PredName), i(ProcInt)], LabelName), + string.format("%s_%d", [s(PredName), i(ProcInt)], LabelName), generate_hash_code(PragmaVars, ArgTypes, ModuleInfo, LabelName, 0, PredName, 1, FactTableSize, HashCode), @@ -2493,7 +2492,7 @@ generate_all_in_code(PredName, PragmaVars, ProcID, ArgTypes, ModuleInfo, skip_%s: ; ", - string__format(SuccessCodeTemplate, [s(LabelName), s(LabelName), + string.format(SuccessCodeTemplate, [s(LabelName), s(LabelName), s(LabelName), s(LabelName)], SuccessCode), ProcCode = "\t{\n" ++ DeclCode ++ HashCode ++ SuccessCode ++ "\t}\n". @@ -2512,7 +2511,7 @@ generate_semidet_in_out_code(PredName, PragmaVars, ProcID, ArgTypes, generate_decl_code(PredName, ProcID, DeclCode), proc_id_to_int(ProcID, ProcInt), - string__format("%s_%d", [s(PredName), i(ProcInt)], LabelName), + string.format("%s_%d", [s(PredName), i(ProcInt)], LabelName), generate_hash_code(PragmaVars, ArgTypes, ModuleInfo, LabelName, 0, PredName, 1, FactTableSize, HashCode), @@ -2520,7 +2519,7 @@ generate_semidet_in_out_code(PredName, PragmaVars, ProcID, ArgTypes, success_code_%s: SUCCESS_INDICATOR = MR_TRUE; ", - string__format(SuccessCodeTemplate, [s(LabelName)], SuccessCode), + string.format(SuccessCodeTemplate, [s(LabelName)], SuccessCode), generate_fact_lookup_code(PredName, PragmaVars, ArgTypes, ModuleInfo, 1, FactTableSize, FactLookupCode), @@ -2532,7 +2531,7 @@ generate_semidet_in_out_code(PredName, PragmaVars, ProcID, ArgTypes, skip_%s: ; ", - string__format(FailCodeTemplate, [s(LabelName), s(LabelName), + string.format(FailCodeTemplate, [s(LabelName), s(LabelName), s(LabelName)], FailCode), ProcCode = "\t{\n" ++ DeclCode ++ HashCode ++ SuccessCode @@ -2561,7 +2560,7 @@ generate_decl_code(Name, ProcID, DeclCode) :- ", proc_id_to_int(ProcID, ProcInt), - string__format(DeclCodeTemplate, [s(Name), i(ProcInt)], DeclCode). + string.format(DeclCodeTemplate, [s(Name), i(ProcInt)], DeclCode). % Generate code to calculate hash values and lookup the hash tables. % @@ -2597,7 +2596,7 @@ generate_hash_code([pragma_var(_, Name, Mode, _) | PragmaVars], [Type | Types], generate_hash_code(PragmaVars, Types, ModuleInfo, LabelName, LabelNum + 1, PredName, NextArgNum, FactTableSize, C_Code1), - string__append(C_Code0, C_Code1, C_Code) + string.append(C_Code0, C_Code1, C_Code) ; % skip non-input arguments generate_hash_code(PragmaVars, Types, ModuleInfo, LabelName, @@ -2628,7 +2627,7 @@ generate_hash_int_code(Name, LabelName, LabelNum, PredName, PragmaVars, %s ", - string__format(C_Code_Template, [s(Name), s(Name), s(Name), s(Name), + string.format(C_Code_Template, [s(Name), s(Name), s(Name), s(Name), s(HashLookupCode)], C_Code). :- pred generate_hash_float_code(string::in, string::in, int::in, string::in, @@ -2656,7 +2655,7 @@ generate_hash_float_code(Name, LabelName, LabelNum, PredName, PragmaVars, %s ", - string__format(C_Code_Template, [s(Name), s(Name), s(HashLookupCode)], + string.format(C_Code_Template, [s(Name), s(Name), s(HashLookupCode)], C_Code). :- pred generate_hash_string_code(string::in, string::in, int::in, string::in, @@ -2687,7 +2686,7 @@ generate_hash_string_code(Name, LabelName, LabelNum, PredName, PragmaVars, %s ", - string__format(C_Code_Template, [s(Name), s(Name), s(HashLookupCode)], + string.format(C_Code_Template, [s(Name), s(Name), s(HashLookupCode)], C_Code). % Generate code to lookup the key in the hash table. @@ -2703,10 +2702,10 @@ generate_hash_string_code(Name, LabelName, LabelNum, PredName, PragmaVars, generate_hash_lookup_code(VarName, LabelName, LabelNum, CompareTemplate, KeyType, CheckKeys, PredName, PragmaVars, Types, ModuleInfo, ArgNum, FactTableSize, HashLookupCode) :- - string__format("((struct MR_fact_table_hash_table_%c *) current_table)" + string.format("((struct MR_fact_table_hash_table_%c *) current_table)" ++ "->table[hashval]", [c(KeyType)], HashTableEntry), - string__append(HashTableEntry, ".key", HashTableKey), - string__format(CompareTemplate, [s(HashTableKey), s(VarName)], + string.append(HashTableEntry, ".key", HashTableKey), + string.format(CompareTemplate, [s(HashTableKey), s(VarName)], CompareString), HashLookupCodeTemplate = " @@ -2744,7 +2743,7 @@ generate_hash_lookup_code(VarName, LabelName, LabelNum, CompareTemplate, ModuleInfo, ArgNum, yes, FactTableSize, CondCode), ( CondCode \= "" -> TestCodeTemplate = "if (%s\t\t\t) goto failure_code_%s;\n", - string__format(TestCodeTemplate, [s(CondCode), s(LabelName)], + string.format(TestCodeTemplate, [s(CondCode), s(LabelName)], TestCode) ; TestCode = "" @@ -2754,7 +2753,7 @@ generate_hash_lookup_code(VarName, LabelName, LabelNum, CompareTemplate, TestCode = "" ), - string__format(HashLookupCodeTemplate, [s(HashTableEntry), + string.format(HashLookupCodeTemplate, [s(HashTableEntry), s(CompareString), s(HashTableEntry), s(LabelName), i(LabelNum), s(HashTableEntry), s(LabelName), s(LabelName), i(LabelNum), s(HashTableEntry), s(TestCode), c(KeyType), @@ -2777,7 +2776,7 @@ generate_fact_lookup_code(PredName, NextArgNum = ArgNum + 1, ( mode_is_fully_output(ModuleInfo, Mode) -> TableEntryTemplate = "mercury__%s_fact_table[ind/%d][ind%%%d].V_%d", - string__format(TableEntryTemplate, + string.format(TableEntryTemplate, [s(PredName), i(FactTableSize), i(FactTableSize), i(ArgNum)], TableEntry), ( Type = builtin(string) -> @@ -2787,7 +2786,7 @@ generate_fact_lookup_code(PredName, % warning "assignment discards `const'". Template = "\t\tMR_make_aligned_string(%s, " ++ "(MR_String) (MR_Word) %s);\n", - string__format(Template, [s(VarName), s(TableEntry)], C_Code0) + string.format(Template, [s(VarName), s(TableEntry)], C_Code0) ; % Unique modes need to allow destructive % update so we need to make a copy of the @@ -2799,17 +2798,17 @@ generate_fact_lookup_code(PredName, %s = (MR_String) tmp; strcpy(%s, %s); ", - string__format(Template, + string.format(Template, [s(TableEntry), s(VarName), s(VarName), s(TableEntry)], C_Code0) ) ; Template = "\t\t%s = %s;\n", - string__format(Template, [s(VarName), s(TableEntry)], C_Code0) + string.format(Template, [s(VarName), s(TableEntry)], C_Code0) ), generate_fact_lookup_code(PredName, PragmaVars, Types, ModuleInfo, NextArgNum, FactTableSize, C_Code1), - string__append(C_Code0, C_Code1, C_Code) + string.append(C_Code0, C_Code1, C_Code) ; % Skip non-output arguments. generate_fact_lookup_code(PredName, PragmaVars, Types, @@ -2901,7 +2900,7 @@ void mercury_sys_init_%s_module(void) { GetRegsCode, NumFrameVars), generate_decl_code(PredName, ProcID, DeclCode), proc_id_to_int(ProcID, ProcInt), - string__format("%s_%d", [s(PredName), i(ProcInt)], LabelName), + string.format("%s_%d", [s(PredName), i(ProcInt)], LabelName), generate_hash_code(PragmaVars, ArgTypes, ModuleInfo, LabelName, 0, PredName, 1, FactTableSize, HashCode), generate_fact_lookup_code(PredName, PragmaVars, ArgTypes, ModuleInfo, 1, @@ -2909,11 +2908,11 @@ void mercury_sys_init_%s_module(void) { generate_fact_test_code(PredName, PragmaVars, ArgTypes, ModuleInfo, FactTableSize, FactTestCode), - string__append_list(["mercury__", PredName, "_fact_table_num_facts"], + string.append_list(["mercury__", PredName, "_fact_table_num_facts"], NumFactsVar), - list__length(PragmaVars, Arity), + list.length(PragmaVars, Arity), - string__format(ExtraCodeTemplate, [ + string.format(ExtraCodeTemplate, [ s(ExtraCodeLabel), s(ExtraCodeLabel), s(ExtraCodeLabel), @@ -2957,7 +2956,7 @@ void mercury_sys_init_%s_module(void) { generate_argument_vars_code(PragmaVars, Types, ModuleInfo, DeclCode, InputCode, OutputCode, SaveRegsCode, GetRegsCode, NumInputArgs) :- - list__map((pred(X::in, Y::out) is det :- X = pragma_var(_, _, Y, _)), + list.map((pred(X::in, Y::out) is det :- X = pragma_var(_, _, Y, _)), PragmaVars, Modes), make_arg_infos(Types, Modes, model_non, ModuleInfo, ArgInfos), generate_argument_vars_code_2(PragmaVars, ArgInfos, Types, ModuleInfo, @@ -3017,7 +3016,7 @@ generate_argument_vars_code_2(PragmaVars0, ArgInfos0, Types0, Module, DeclCode, generate_arg_decl_code(Name, Type, Module, DeclCode) :- C_Type = to_type_string(c, Module, Type), - string__format("\t\t%s %s;\n", [s(C_Type), s(Name)], DeclCode). + string.format("\t\t%s %s;\n", [s(C_Type), s(Name)], DeclCode). :- pred generate_arg_input_code(string::in, mer_type::in, int::in, int::in, string::out, string::out, string::out) is det. @@ -3027,10 +3026,10 @@ generate_arg_input_code(Name, Type, RegNum, FrameVarNum, InputCode, get_reg_name(RegNum, RegName), convert_type_from_mercury(RegName, Type, Converted), Template = "\t\t%s = %s;\n", - string__format(Template, [s(Name), s(Converted)], InputCode), - string__format("\t\tMR_framevar(%d) = %s;\n", + string.format(Template, [s(Name), s(Converted)], InputCode), + string.format("\t\tMR_framevar(%d) = %s;\n", [i(FrameVarNum), s(RegName)], SaveRegCode), - string__format("\t\t%s = MR_framevar(%d);\n", + string.format("\t\t%s = MR_framevar(%d);\n", [s(RegName), i(FrameVarNum)], GetRegCode). :- pred generate_arg_output_code(string::in, mer_type::in, int::in, @@ -3040,14 +3039,14 @@ generate_arg_output_code(Name, Type, RegNum, OutputCode) :- get_reg_name(RegNum, RegName), convert_type_to_mercury(Name, Type, Converted), Template = "\t\t%s = %s;\n", - string__format(Template, [s(RegName), s(Converted)], OutputCode). + string.format(Template, [s(RegName), s(Converted)], OutputCode). :- pred get_reg_name(int::in, string::out) is det. get_reg_name(RegNum, RegName) :- - code_util__arg_loc_to_register(RegNum, Lval), + code_util.arg_loc_to_register(RegNum, Lval), ( Lval = reg(RegType, N) -> - RegName = llds_out__reg_to_string(RegType, N) + RegName = llds_out.reg_to_string(RegType, N) ; unexpected(this_file, "get_reg_name: lval is not a register") ). @@ -3086,7 +3085,7 @@ generate_test_condition_code(FactTableName, [PragmaVar | PragmaVars], ; Template = "%s[ind/%d][ind%%%d].V_%d != %s\n" ), - string__format(Template, [s(FactTableName), i(FactTableSize), + string.format(Template, [s(FactTableName), i(FactTableSize), i(FactTableSize), i(ArgNum), s(Name)], CondCode0), ( !.IsFirstInputArg = no, @@ -3201,8 +3200,8 @@ void mercury_sys_init_%s_module(void) { InputCode, OutputCode, _SaveRegsCode, _GetRegsCode, _NumFrameVars), generate_decl_code(PredName, ProcID, DeclCode), proc_id_to_int(ProcID, ProcInt), - string__format("%s_%d", [s(PredName), i(ProcInt)], LabelName), - string__append(LabelName, "_2", LabelName2), + string.format("%s_%d", [s(PredName), i(ProcInt)], LabelName), + string.append(LabelName, "_2", LabelName2), generate_hash_code(PragmaVars, ArgTypes, ModuleInfo, LabelName, 0, PredName, 1, FactTableSize, HashCode), @@ -3216,9 +3215,9 @@ void mercury_sys_init_%s_module(void) { 0, 0, FloatHashLookupCode), generate_fact_lookup_code(PredName, PragmaVars, ArgTypes, ModuleInfo, 1, FactTableSize, FactLookupCode), - list__length(PragmaVars, Arity), + list.length(PragmaVars, Arity), - string__format(ExtraCodeTemplate, [ + string.format(ExtraCodeTemplate, [ s(ExtraCodeLabel), s(ExtraCodeLabel), s(ExtraCodeLabel), @@ -3260,65 +3259,65 @@ void mercury_sys_init_%s_module(void) { :- pred delete_temporary_file(string::in, io::di, io::uo) is det. delete_temporary_file(FileName, !IO) :- - io__remove_file(FileName, Result, !IO), + io.remove_file(FileName, Result, !IO), ( Result = ok ; Result = error(ErrorCode), - io__error_message(ErrorCode, ErrorMsg), - io__progname_base("mercury_compile", ProgName, !IO), - string__format("%s: error deleting file `%s:", + io.error_message(ErrorCode, ErrorMsg), + io.progname_base("mercury_compile", ProgName, !IO), + string.format("%s: error deleting file `%s:", [s(ProgName), s(FileName)], Msg), write_error_pieces_plain([words(Msg), nl, words(ErrorMsg)], !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). :- pred open_output_handle_error(maybe(context)::in, string::in, - io__res(io__output_stream)::out, io::di, io::uo) is det. + io.res(io.output_stream)::out, io::di, io::uo) is det. open_output_handle_error(MaybeContext, FileName, Result, !IO) :- - io__open_output(FileName, Result, !IO), + io.open_output(FileName, Result, !IO), ( Result = ok(_) ; Result = error(ErrorCode), - io__error_message(ErrorCode, ErrorMsg), - string__format("Error opening file `%s' for output:", + io.error_message(ErrorCode, ErrorMsg), + string.format("Error opening file `%s' for output:", [s(FileName)], Msg), write_error_msg(MaybeContext, Msg, ErrorMsg, !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). :- pred open_input_handle_error(maybe(context)::in, string::in, - io__res(io__input_stream)::out, io::di, io::uo) is det. + io.res(io.input_stream)::out, io::di, io::uo) is det. open_input_handle_error(MaybeContext, FileName, Result, !IO) :- - io__open_input(FileName, Result, !IO), + io.open_input(FileName, Result, !IO), ( Result = ok(_) ; Result = error(ErrorCode), - io__error_message(ErrorCode, ErrorMsg), - string__format("Error opening file `%s' for input:", + io.error_message(ErrorCode, ErrorMsg), + string.format("Error opening file `%s' for input:", [s(FileName)], Msg), write_error_msg(MaybeContext, Msg, ErrorMsg, !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). :- pred see_input_handle_error(maybe(context)::in, string::in, - io__res::out, io::di, io::uo) is det. + io.res::out, io::di, io::uo) is det. see_input_handle_error(MaybeContext, FileName, Result, !IO) :- - io__see(FileName, Result, !IO), + io.see(FileName, Result, !IO), ( Result = ok ; Result = error(ErrorCode), - io__error_message(ErrorCode, ErrorMsg), - string__format("Error opening file `%s' for input:", + io.error_message(ErrorCode, ErrorMsg), + string.format("Error opening file `%s' for input:", [s(FileName)], Msg), write_error_msg(MaybeContext, Msg, ErrorMsg, !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). :- pred write_error_msg(maybe(context)::in, string::in, string::in, @@ -3333,16 +3332,16 @@ write_error_msg(MaybeContext, Msg, ErrorMsg, !IO) :- write_error_pieces_plain([words(Msg), nl, words(ErrorMsg)], !IO) ). -:- pred write_call_system_error_msg(string::in, io__error::in, io::di, io::uo) +:- pred write_call_system_error_msg(string::in, io.error::in, io::di, io::uo) is det. write_call_system_error_msg(Cmd, ErrorCode, !IO) :- - io__error_message(ErrorCode, ErrorMsg), - io__progname_base("mercury_compile", ProgName, !IO), - string__format("%s: error executing system command `%s:", + io.error_message(ErrorCode, ErrorMsg), + io.progname_base("mercury_compile", ProgName, !IO), + string.format("%s: error executing system command `%s:", [s(ProgName), s(Cmd)], Msg), write_error_pieces_plain([words(Msg), nl, words(ErrorMsg)], !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% @@ -3368,8 +3367,8 @@ add_error_report(Components, !Errors) :- :- pred print_error_reports(error_reports::in, io::di, io::uo) is det. print_error_reports(RevErrors, !IO) :- - list__reverse(RevErrors, Errors), - list__foldl(print_error_report, Errors, !IO). + list.reverse(RevErrors, Errors), + list.foldl(print_error_report, Errors, !IO). :- pred print_error_report(error_report::in, io::di, io::uo) is det. @@ -3381,7 +3380,7 @@ print_error_report(MaybeContext - Components, !IO) :- MaybeContext = no, write_error_pieces_plain(Components, !IO) ), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/field_access.m b/compiler/field_access.m index b77242d0f..a1214f439 100644 --- a/compiler/field_access.m +++ b/compiler/field_access.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1993-2005 The University of Melbourne. +% Copyright (C) 1993-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -12,7 +12,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__field_access. +:- module hlds.make_hlds.field_access. :- interface. :- import_module hlds.hlds_goal. @@ -136,10 +136,9 @@ expand_set_field_function_call_2(Context, MainContext, SubContext0, make_fresh_arg_vars(FieldArgs, FieldArgVars, !VarSet, !SInfo, !IO), ( FieldNames = [_ | _], - varset__new_var(!.VarSet, SubTermInputVar, !:VarSet), - varset__new_var(!.VarSet, SubTermOutputVar, !:VarSet), - SetArgs = list__append(FieldArgVars, - [TermInputVar, SubTermOutputVar]), + varset.new_var(!.VarSet, SubTermInputVar, !:VarSet), + varset.new_var(!.VarSet, SubTermOutputVar, !:VarSet), + SetArgs = FieldArgVars ++ [TermInputVar, SubTermOutputVar], construct_field_access_function_call(set, Context, MainContext, SubContext0, FieldName, TermOutputVar, SetArgs, purity_pure, Functor, UpdateGoal, !QualInfo), @@ -147,11 +146,11 @@ expand_set_field_function_call_2(Context, MainContext, SubContext0, % Extract the field containing the field to update. construct_field_access_function_call(get, Context, MainContext, SubContext0, FieldName, SubTermInputVar, - list__append(FieldArgVars, [TermInputVar]), purity_pure, _, + list.append(FieldArgVars, [TermInputVar]), purity_pure, _, GetSubFieldGoal, !QualInfo), % Recursively update the field. - SubTermInputArgNumber = 2 + list__length(FieldArgs), + SubTermInputArgNumber = 2 + list.length(FieldArgs), TermInputContext = Functor - SubTermInputArgNumber, SubContext = [TermInputContext | SubContext0], expand_set_field_function_call_2(Context, MainContext, @@ -159,10 +158,10 @@ expand_set_field_function_call_2(Context, MainContext, SubContext0, SubTermOutputVar, !VarSet, _, FieldSubContext, Goals0, !ModuleInfo, !QualInfo, !SInfo, !IO), - list__append([GetSubFieldGoal | Goals0], [UpdateGoal], Goals1) + Goals1 = [GetSubFieldGoal | Goals0] ++ [UpdateGoal] ; FieldNames = [], - SetArgs = list__append(FieldArgVars, [TermInputVar, FieldValueVar]), + SetArgs = FieldArgVars ++ [TermInputVar, FieldValueVar], construct_field_access_function_call(set, Context, MainContext, SubContext0, FieldName, TermOutputVar, SetArgs, purity_pure, Functor, Goal, !QualInfo), @@ -217,16 +216,16 @@ expand_get_field_function_call_2(Context, MainContext, SubContext0, TermInputVar, Purity, !VarSet, Functor, FieldSubContext, Goals, !ModuleInfo, !QualInfo, !SInfo, !IO) :- make_fresh_arg_vars(FieldArgs, FieldArgVars, !VarSet, !SInfo, !IO), - GetArgVars = list__append(FieldArgVars, [TermInputVar]), + GetArgVars = FieldArgVars ++ [TermInputVar], ( FieldNames = [_ | _], - varset__new_var(!.VarSet, SubTermInputVar, !:VarSet), + varset.new_var(!.VarSet, SubTermInputVar, !:VarSet), construct_field_access_function_call(get, Context, MainContext, SubContext0, FieldName, SubTermInputVar, GetArgVars, Purity, Functor, Goal, !QualInfo), % recursively extract until we run out of field names - TermInputArgNumber = 1 + list__length(FieldArgVars), + TermInputArgNumber = 1 + list.length(FieldArgVars), TermInputContext = Functor - TermInputArgNumber, SubContext = [TermInputContext | SubContext0], expand_get_field_function_call_2(Context, MainContext, @@ -258,14 +257,14 @@ construct_field_access_function_call(AccessType, Context, MainContext, SubContext, FieldName, RetArg, Args, Purity, Functor, Goal, !QualInfo) :- field_access_function_name(AccessType, FieldName, FuncName), - list__length(Args, Arity), + list.length(Args, Arity), Functor = cons(FuncName, Arity), make_atomic_unification(RetArg, functor(Functor, no, Args), Context, MainContext, SubContext, Purity, Goal, !QualInfo). parse_field_list(Term, MaybeFieldNames) :- ( - Term = term__functor(term__atom("^"), + Term = term.functor(term.atom("^"), [FieldNameTerm, OtherFieldNamesTerm], _) -> ( @@ -284,8 +283,7 @@ parse_field_list(Term, MaybeFieldNames) :- ok([FieldName - Args | FieldNames1]) ) ; - MaybeFieldNames = error("expected field name", - FieldNameTerm) + MaybeFieldNames = error("expected field name", FieldNameTerm) ) ; ( diff --git a/compiler/follow_code.m b/compiler/follow_code.m index c5062da17..8332f466b 100644 --- a/compiler/follow_code.m +++ b/compiler/follow_code.m @@ -28,7 +28,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__follow_code. +:- module ll_backend.follow_code. :- interface. :- import_module hlds.hlds_goal. @@ -73,8 +73,8 @@ move_follow_code_in_proc(_PredId, _ProcId, _PredInfo, !ProcInfo, !ModuleInfo) :- module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, follow_code, FollowCode), - globals__lookup_bool_option(Globals, prev_code, PrevCode), + globals.lookup_bool_option(Globals, follow_code, FollowCode), + globals.lookup_bool_option(Globals, prev_code, PrevCode), Flags = FollowCode - PrevCode, proc_info_goal(!.ProcInfo, Goal0), proc_info_varset(!.ProcInfo, Varset0), @@ -183,7 +183,7 @@ move_follow_code_in_cases([case(Cons, Goal0) | Goals0], move_follow_code_in_conj(Goals0, Goals, Flags, !R) :- move_follow_code_in_conj_2(Goals0, [], RevGoals, Flags, !R), - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). :- pred move_follow_code_in_conj_2(list(hlds_goal)::in, list(hlds_goal)::in, list(hlds_goal)::out, pair(bool)::in, bool::in, bool::out) is det. @@ -194,7 +194,7 @@ move_follow_code_in_conj_2([Goal0 | Goals0], !RevPrevGoals, Flags, !R) :- ( PushFollowCode = yes, Goal0 = GoalExpr0 - _, - goal_util__goal_is_branched(GoalExpr0), + goal_util.goal_is_branched(GoalExpr0), move_follow_code_select(Goals0, FollowGoals, RestGoalsPrime), FollowGoals = [_ | _], move_follow_code_move_goals(Goal0, FollowGoals, Goal1Prime) @@ -283,7 +283,7 @@ follow_code_conjoin_goal_and_goal_list(Goal0, FollowGoals, Goal) :- ; check_follow_code_detism(FollowGoals, Detism0), ( GoalExpr0 = conj(plain_conj, GoalList0) -> - list__append(GoalList0, FollowGoals, GoalList), + list.append(GoalList0, FollowGoals, GoalList), GoalExpr = conj(plain_conj, GoalList) ; GoalExpr = conj(plain_conj, [Goal0 | FollowGoals]) diff --git a/compiler/follow_vars.m b/compiler/follow_vars.m index 76a1b80a6..65264755f 100644 --- a/compiler/follow_vars.m +++ b/compiler/follow_vars.m @@ -27,7 +27,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__follow_vars. +:- module ll_backend.follow_vars. :- interface. :- import_module hlds.hlds_goal. @@ -77,8 +77,8 @@ find_final_follow_vars(ProcInfo, FollowVarsMap, NextNonReserved) :- proc_info_arg_info(ProcInfo, ArgInfo), proc_info_headvars(ProcInfo, HeadVars), - assoc_list__from_corresponding_lists(ArgInfo, HeadVars, ArgInfoHeadVars), - map__init(FollowVarsMap0), + assoc_list.from_corresponding_lists(ArgInfo, HeadVars, ArgInfoHeadVars), + map.init(FollowVarsMap0), find_final_follow_vars_2(ArgInfoHeadVars, FollowVarsMap0, FollowVarsMap, 1, NextNonReserved). @@ -91,8 +91,8 @@ find_final_follow_vars_2([arg_info(RegNum, Mode) - Var | ArgInfoVars], !FollowVarsMap, !NextNonReserved) :- ( Mode = top_out -> Locn = abs_reg(RegNum), - svmap__det_insert(Var, Locn, !FollowVarsMap), - int__max(RegNum + 1, !NextNonReserved) + svmap.det_insert(Var, Locn, !FollowVarsMap), + int.max(RegNum + 1, !NextNonReserved) ; true ), @@ -209,9 +209,9 @@ find_follow_vars_in_goal_expr(Goal @ unify(_, _, _, Unify, _), Goal, !FollowVarsMap, !NextNonReserved) :- ( Unify = assign(LVar, RVar), - map__search(!.FollowVarsMap, LVar, DesiredLoc) + map.search(!.FollowVarsMap, LVar, DesiredLoc) -> - svmap__set(RVar, DesiredLoc, !FollowVarsMap) + svmap.set(RVar, DesiredLoc, !FollowVarsMap) ; true ). @@ -232,16 +232,16 @@ find_follow_vars_in_goal_expr( true ; determinism_to_code_model(Det, CodeModel), - map__apply_to_list(Args, VarTypes, Types), + map.apply_to_list(Args, VarTypes, Types), make_arg_infos(Types, Modes, CodeModel, ModuleInfo, ArgInfos), - assoc_list__from_corresponding_lists(Args, ArgInfos, ArgsInfos), - arg_info__partition_args(ArgsInfos, InVarInfos, _), - assoc_list__keys(InVarInfos, InVars), + assoc_list.from_corresponding_lists(Args, ArgInfos, ArgsInfos), + arg_info.partition_args(ArgsInfos, InVarInfos, _), + assoc_list.keys(InVarInfos, InVars), module_info_get_globals(ModuleInfo, Globals), - call_gen__generic_call_info(Globals, GenericCall, + call_gen.generic_call_info(Globals, GenericCall, length(InVars), _, SpecifierArgInfos, FirstInput, _), find_follow_vars_from_arginfo(SpecifierArgInfos, - map__init, !:FollowVarsMap, 1, _), + map.init, !:FollowVarsMap, 1, _), find_follow_vars_from_sequence(InVars, FirstInput, !FollowVarsMap, !:NextNonReserved) ). @@ -265,8 +265,8 @@ find_follow_vars_in_call(PredId, ProcId, Args, ModuleInfo, FollowVarsMap, NextNonReserved) :- module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo), proc_info_arg_info(ProcInfo, ArgInfo), - assoc_list__from_corresponding_lists(Args, ArgInfo, ArgsInfos), - find_follow_vars_from_arginfo(ArgsInfos, map__init, FollowVarsMap, + assoc_list.from_corresponding_lists(Args, ArgInfo, ArgsInfos), + find_follow_vars_from_arginfo(ArgsInfos, map.init, FollowVarsMap, 1, NextNonReserved). :- pred find_follow_vars_from_arginfo(assoc_list(prog_var, arg_info)::in, @@ -278,7 +278,7 @@ find_follow_vars_from_arginfo([ArgVar - arg_info(RegNum, Mode) | ArgsInfos], !FollowVarsMap, !NextNonReserved) :- ( Mode = top_in -> Locn = abs_reg(RegNum), - ( svmap__insert(ArgVar, Locn, !FollowVarsMap) -> + ( svmap.insert(ArgVar, Locn, !FollowVarsMap) -> true % FollowVarsMap is updated ; % The call is not in superhomogeneous form: this @@ -288,7 +288,7 @@ find_follow_vars_from_arginfo([ArgVar - arg_info(RegNum, Mode) | ArgsInfos], % we would give to this appearance of the variable. true % FollowVarsMap is not updated ), - int__max(RegNum + 1, !NextNonReserved) + int.max(RegNum + 1, !NextNonReserved) ; true ), @@ -304,7 +304,7 @@ find_follow_vars_from_sequence([], NextRegNum, !FollowVarsMap, NextRegNum). find_follow_vars_from_sequence([InVar | InVars], NextRegNum, !FollowVarsMap, NextNonReserved) :- Locn = abs_reg(NextRegNum), - ( map__insert(!.FollowVarsMap, InVar, Locn, !:FollowVarsMap) -> + ( map.insert(!.FollowVarsMap, InVar, Locn, !:FollowVarsMap) -> true % FollowVarsMap is updated ; % The call is not in superhomogeneous form: this argument has diff --git a/compiler/foreign.m b/compiler/foreign.m index 880476490..8221cc3b0 100644 --- a/compiler/foreign.m +++ b/compiler/foreign.m @@ -18,7 +18,7 @@ %-----------------------------------------------------------------------------% -:- module backend_libs__foreign. +:- module backend_libs.foreign. :- interface. :- import_module hlds.hlds_data. @@ -181,17 +181,17 @@ filter_decls(WantedLang, Decls0, LangDecls, NotLangDecls) :- IsWanted = (pred(foreign_decl_code(Lang, _, _, _)::in) is semidet :- WantedLang = Lang), - list__filter(IsWanted, Decls0, LangDecls, NotLangDecls). + list.filter(IsWanted, Decls0, LangDecls, NotLangDecls). filter_imports(WantedLang, Imports0, LangImports, NotLangImports) :- IsWanted = (pred(foreign_import_module(Lang, _, _)::in) is semidet :- WantedLang = Lang), - list__filter(IsWanted, Imports0, LangImports, NotLangImports). + list.filter(IsWanted, Imports0, LangImports, NotLangImports). filter_bodys(WantedLang, Bodys0, LangBodys, NotLangBodys) :- IsWanted = (pred(foreign_body_code(Lang, _, _)::in) is semidet :- WantedLang = Lang), - list__filter(IsWanted, Bodys0, LangBodys, NotLangBodys). + list.filter(IsWanted, Bodys0, LangBodys, NotLangBodys). extrude_pragma_implementation([], _PragmaVars, _PredName, _PredOrFunc, _Context, !ModuleInfo, !NewAttributes, !Impl) :- @@ -205,7 +205,7 @@ extrude_pragma_implementation([TargetLang | TargetLangs], _PragmaVars, % If the foreign language is available as a target language, % we don't need to do anything. - ( list__member(ForeignLanguage, [TargetLang | TargetLangs]) -> + ( list.member(ForeignLanguage, [TargetLang | TargetLangs]) -> true ; set_foreign_language(TargetLang, !Attributes), @@ -348,11 +348,11 @@ make_pragma_import(PredInfo, ProcInfo, C_Function, Context, PragmaImpl, VarSet, % Build a list of argument variables, together with their names, modes, % and types. - varset__init(VarSet0), - list__length(Modes, Arity), - varset__new_vars(VarSet0, Arity, Vars, VarSet), + varset.init(VarSet0), + list.length(Modes, Arity), + varset.new_vars(VarSet0, Arity, Vars, VarSet), create_pragma_vars(Vars, Modes, 0, PragmaVars), - assoc_list__from_corresponding_lists(PragmaVars, ArgTypes, + assoc_list.from_corresponding_lists(PragmaVars, ArgTypes, PragmaVarsAndTypes), % Construct parts of the C_code string for calling a C_function. This C @@ -367,7 +367,7 @@ make_pragma_import(PredInfo, ProcInfo, C_Function, Context, PragmaImpl, VarSet, proc_info_declared_determinism(ProcInfo, MaybeDeclaredDetism), handle_return_value(Context, MaybeDeclaredDetism, CodeModel, PredOrFunc, PragmaVarsAndTypes, ArgPragmaVarsAndTypes, Return, !ModuleInfo, !IO), - assoc_list__keys(ArgPragmaVarsAndTypes, ArgPragmaVars), + assoc_list.keys(ArgPragmaVarsAndTypes, ArgPragmaVars), create_pragma_import_c_code(ArgPragmaVars, !.ModuleInfo, "", Variables), % Make an import implementation. @@ -404,7 +404,7 @@ handle_return_value(Context, MaybeDeclaredDetism, CodeModel, PredOrFunc, RetArg = pragma_var(_, RetArgName, RetMode, _) - RetType, mode_to_arg_mode(!.ModuleInfo, RetMode, RetType, RetArgMode), RetArgMode = top_out, - \+ type_util__is_dummy_argument_type(!.ModuleInfo, RetType) + \+ type_util.is_dummy_argument_type(!.ModuleInfo, RetType) -> C_Code0 = RetArgName ++ " = " ; @@ -438,12 +438,12 @@ handle_return_value(Context, MaybeDeclaredDetism, CodeModel, PredOrFunc, % be used. C_Code0 = "\n#error ""cannot import nondet procedure""\n" ), - list__filter(include_import_arg(!.ModuleInfo), !Args). + list.filter(include_import_arg(!.ModuleInfo), !Args). % include_import_arg(M, Arg): % % Succeeds iff Arg should be included in the arguments of the C function. - % Fails if `Arg' has a type such as `io__state' that is just a dummy + % Fails if `Arg' has a type such as `io.state' that is just a dummy % argument that should not be passed to C. % :- pred include_import_arg(module_info::in, pair(pragma_var, mer_type)::in) @@ -452,7 +452,7 @@ handle_return_value(Context, MaybeDeclaredDetism, CodeModel, PredOrFunc, include_import_arg(ModuleInfo, pragma_var(_Var, _Name, Mode, _Box) - Type) :- mode_to_arg_mode(ModuleInfo, Mode, Type, ArgMode), ArgMode \= top_unused, - \+ type_util__is_dummy_argument_type(ModuleInfo, Type). + \+ type_util.is_dummy_argument_type(ModuleInfo, Type). % create_pragma_vars(Vars, Modes, ArgNum0, PragmaVars): % @@ -468,8 +468,8 @@ create_pragma_vars([Var | Vars], [Mode | Modes], ArgNum0, [PragmaVar | PragmaVars]) :- % Figure out a name for the C variable which will hold this argument. ArgNum = ArgNum0 + 1, - string__int_to_string(ArgNum, ArgNumString), - string__append("Arg", ArgNumString, ArgName), + string.int_to_string(ArgNum, ArgNumString), + string.append("Arg", ArgNumString, ArgName), PragmaVar = pragma_var(Var, ArgName, Mode, native_if_possible), create_pragma_vars(Vars, Modes, ArgNum, PragmaVars). create_pragma_vars([_ | _], [], _, _) :- @@ -533,9 +533,9 @@ to_exported_type(ModuleInfo, Type) = ExportType :- module_info_get_type_table(ModuleInfo, Types), ( type_to_ctor_and_args(Type, TypeCtor, _), - map__search(Types, TypeCtor, TypeDefn) + map.search(Types, TypeCtor, TypeDefn) -> - hlds_data__get_type_defn_body(TypeDefn, Body), + hlds_data.get_type_defn_body(TypeDefn, Body), ( Body = foreign_type(ForeignTypeBody) -> foreign_type_body_to_exported_type(ModuleInfo, ForeignTypeBody, ForeignTypeName, _, Assertions), @@ -557,7 +557,7 @@ foreign_type_body_to_exported_type(ModuleInfo, ForeignTypeBody, Name, MaybeUserEqComp, Assertions) :- ForeignTypeBody = foreign_type_body(MaybeIL, MaybeC, MaybeJava), module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( Target = c, ( @@ -676,7 +676,7 @@ to_type_string(java, mercury(Type)) = Result :- decl_guard(ModuleName) = UppercaseModuleName ++ "_DECL_GUARD" :- MangledModuleName = sym_name_mangle(ModuleName), - string__to_upper(MangledModuleName, UppercaseModuleName). + string.to_upper(MangledModuleName, UppercaseModuleName). %-----------------------------------------------------------------------------% diff --git a/compiler/frameopt.m b/compiler/frameopt.m index 4ff45fa94..d8a4c4b40 100644 --- a/compiler/frameopt.m +++ b/compiler/frameopt.m @@ -1,14 +1,14 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2001,2003-2005 The University of Melbourne. +% Copyright (C) 1994-2001,2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% - +% % File: frameopt.m. % Main author: zs. - +% % This module performs two kinds of transformation to optimize code that % manipulates detstack frames. % @@ -90,7 +90,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__frameopt. +:- module ll_backend.frameopt. :- interface. :- import_module libs.globals. @@ -174,14 +174,14 @@ %-----------------------------------------------------------------------------% frameopt_main(ProcLabel, !C, Instrs0, Instrs, Globals, Mod) :- - opt_util__get_prologue(Instrs0, LabelInstr, Comments0, Instrs1), - ( frameopt__detstack_setup(Instrs1, FrameSize, Msg, _, _, _) -> + opt_util.get_prologue(Instrs0, LabelInstr, Comments0, Instrs1), + ( frameopt.detstack_setup(Instrs1, FrameSize, Msg, _, _, _) -> some [!BlockMap] ( - map__init(!:BlockMap), + map.init(!:BlockMap), divide_into_basic_blocks([LabelInstr | Instrs1], ProcLabel, BasicInstrs, !C), build_frame_block_map(BasicInstrs, FrameSize, LabelSeq0, no, no, - ProcLabel, !BlockMap, map__init, PredMap, !C), + ProcLabel, !BlockMap, map.init, PredMap, !C), analyze_block_map(LabelSeq0, !BlockMap, KeepFrame), ( KeepFrame = yes(FirstLabel - SecondLabel), @@ -190,9 +190,9 @@ frameopt_main(ProcLabel, !C, Instrs0, Instrs, Globals, Mod) :- CanClobberSuccip, !BlockMap), LabelSeq = LabelSeq0, NewComment = comment("keeping stack frame") - "", - list__append(Comments0, [NewComment], Comments), + list.append(Comments0, [NewComment], Comments), flatten_block_seq(LabelSeq, !.BlockMap, BodyInstrs), - list__append(Comments, BodyInstrs, Instrs), + list.append(Comments, BodyInstrs, Instrs), Mod = yes ; KeepFrame = no, @@ -205,7 +205,7 @@ frameopt_main(ProcLabel, !C, Instrs0, Instrs, Globals, Mod) :- -> Comments = Comments0 ++ NewComments, flatten_block_seq(LabelSeq, !.BlockMap, BodyInstrs), - list__append(Comments, BodyInstrs, Instrs), + list.append(Comments, BodyInstrs, Instrs), Mod = yes ; Instrs = Instrs0, @@ -224,10 +224,10 @@ frameopt_main(ProcLabel, !C, Instrs0, Instrs, Globals, Mod) :- flatten_block_seq([], _, []). flatten_block_seq([Label | Labels], BlockMap, Instrs) :- flatten_block_seq(Labels, BlockMap, RestInstrs), - map__lookup(BlockMap, Label, BlockInfo), + map.lookup(BlockMap, Label, BlockInfo), BlockInstrs = BlockInfo ^ fb_instrs, ( - list__split_last(BlockInstrs, MostInstrs, LastInstr), + list.split_last(BlockInstrs, MostInstrs, LastInstr), Labels = [NextLabel | _], LastInstr = goto(label(NextLabel)) - _ -> @@ -244,19 +244,19 @@ flatten_block_seq([Label | Labels], BlockMap, Instrs) :- frameopt_nondet(ProcLabel, LayoutLabels, MayAlterRtti, !C, Instrs0, Instrs, Mod) :- - opt_util__get_prologue(Instrs0, LabelInstr, Comments0, Instrs1), + opt_util.get_prologue(Instrs0, LabelInstr, Comments0, Instrs1), ( MayAlterRtti = may_alter_rtti, - frameopt__nondetstack_setup(Instrs1, FrameInfo, Redoip, + frameopt.nondetstack_setup(Instrs1, FrameInfo, Redoip, MkframeInstr, Remain), MkframeInstr = MkframeUinstr - MkframeComment, - find_succeed_labels(Instrs1, map__init, SuccMap), - counter__allocate(KeepFrameLabelNum, !C), + find_succeed_labels(Instrs1, map.init, SuccMap), + counter.allocate(KeepFrameLabelNum, !C), KeepFrameLabel = internal(KeepFrameLabelNum, ProcLabel), keep_nondet_frame(Remain, Instrs2, ProcLabel, KeepFrameLabel, MkframeUinstr, SuccMap, LayoutLabels, no, yes) -> - list__condense([[LabelInstr], Comments0, + list.condense([[LabelInstr], Comments0, [mkframe(FrameInfo, no) - MkframeComment, label(KeepFrameLabel) - "tail recursion target", assign(redoip(lval(curfr)), const(code_addr_const(Redoip))) - ""], @@ -267,11 +267,11 @@ frameopt_nondet(ProcLabel, LayoutLabels, MayAlterRtti, !C, Instrs0, Instrs, Mod = no ). -:- pred frameopt__nondetstack_setup(list(instruction)::in, +:- pred frameopt.nondetstack_setup(list(instruction)::in, nondet_frame_info::out, code_addr::out, instruction::out, list(instruction)::out) is semidet. -frameopt__nondetstack_setup(Instrs0, FrameInfo, Redoip, MkframeInstr, +frameopt.nondetstack_setup(Instrs0, FrameInfo, Redoip, MkframeInstr, Remain) :- Instrs0 = [MkframeInstr | Remain], MkframeInstr = mkframe(FrameInfo, yes(Redoip)) - _, @@ -285,10 +285,10 @@ find_succeed_labels([Instr | Instrs], !SuccMap) :- Instr = Uinstr - _, ( Uinstr = label(Label), - opt_util__skip_comments(Instrs, TailInstrs), - opt_util__is_succeed_next(TailInstrs, Between) + opt_util.skip_comments(Instrs, TailInstrs), + opt_util.is_succeed_next(TailInstrs, Between) -> - svmap__det_insert(Label, Between, !SuccMap) + svmap.det_insert(Label, Between, !SuccMap) ; true ), @@ -308,10 +308,10 @@ keep_nondet_frame([Instr0 | Instrs0], Instrs, ProcLabel, KeepFrameLabel, Uinstr0 = call(label(entry(_, ProcLabel)), label(RetLabel), _, _, _, CallModel), CallModel = nondet(unchecked_tail_call), - map__search(SuccMap, RetLabel, BetweenIncl), + map.search(SuccMap, RetLabel, BetweenIncl), BetweenIncl = [livevals(_) - _, goto(_) - _], PrevInstr = livevals(Livevals), - not set__member(RetLabel, LayoutLabels) + not set.member(RetLabel, LayoutLabels) -> keep_nondet_frame(Instrs0, Instrs1, ProcLabel, KeepFrameLabel, Uinstr0, SuccMap, LayoutLabels, !.Changed, _), @@ -394,14 +394,14 @@ divide_into_basic_blocks([], _, [], !C). % This is the only situation in which the base case can be reached. divide_into_basic_blocks([Instr0 | Instrs0], ProcLabel, Instrs, !C) :- Instr0 = Uinstr0 - _Comment, - ( opt_util__can_instr_branch_away(Uinstr0, yes) -> + ( opt_util.can_instr_branch_away(Uinstr0, yes) -> ( Instrs0 = [Instr1 | _], ( Instr1 = label(_) - _ -> divide_into_basic_blocks(Instrs0, ProcLabel, Instrs1, !C), Instrs = [Instr0 | Instrs1] ; - counter__allocate(N, !C), + counter.allocate(N, !C), NewLabel = internal(N, ProcLabel), NewInstr = label(NewLabel) - "", divide_into_basic_blocks(Instrs0, ProcLabel, Instrs1, !C), @@ -449,35 +449,35 @@ build_frame_block_map([Instr0 | Instrs0], FrameSize, LabelSeq, ( Instr0 = label(Label) - _ -> ( MaybePrevLabel = yes(PrevLabel), - svmap__det_insert(Label, PrevLabel, !PredMap) + svmap.det_insert(Label, PrevLabel, !PredMap) ; MaybePrevLabel = no ), ( - frameopt__detstack_setup(Instrs0, _, _, Setup, Others, Remain) + frameopt.detstack_setup(Instrs0, _, _, Setup, Others, Remain) -> % Create a block with just the Setup instructions in it. BlockInfo = frame_block_info(Label, [Instr0 | Setup], FallInto, [], no, setup), - list__append(Others, Remain, Instrs1), + list.append(Others, Remain, Instrs1), ( Instrs1 = [Instr1 | _], Instr1 = label(_) - _ -> Instrs2 = Instrs1 ; - counter__allocate(N, !C), + counter.allocate(N, !C), NewLabel = internal(N, ProcLabel), NewInstr = label(NewLabel) - "", Instrs2 = [NewInstr | Instrs1] ), build_frame_block_map(Instrs2, FrameSize, LabelSeq0, yes(Label), yes(Label), ProcLabel, !BlockMap, !PredMap, !C), - svmap__det_insert(Label, BlockInfo, !BlockMap), + svmap.det_insert(Label, BlockInfo, !BlockMap), LabelSeq = [Label | LabelSeq0] ; - frameopt__detstack_teardown(Instrs0, FrameSize, Extra, + frameopt.detstack_teardown(Instrs0, FrameSize, Extra, SuccipRestore, Decrsp, Livevals, Goto, Remain) -> Teardown = SuccipRestore ++ Decrsp ++ Livevals ++ [Goto], @@ -495,7 +495,7 @@ build_frame_block_map([Instr0 | Instrs0], FrameSize, LabelSeq, ExtraInfo = frame_block_info(Label, [Instr0 | Extra], FallInto, [], no, ordinary(NeedsFrame)), MaybeExtraInfo = yes(ExtraInfo - Label), - counter__allocate(N, !C), + counter.allocate(N, !C), NewLabel = internal(N, ProcLabel), NewInstr = label(NewLabel) - "", LabelledBlock = [NewInstr | Teardown], @@ -503,30 +503,30 @@ build_frame_block_map([Instr0 | Instrs0], FrameSize, LabelSeq, TeardownInfo = frame_block_info(TeardownLabel, LabelledBlock, yes(Label), [], no, teardown(SuccipRestore, Livevals, Goto)), - svmap__det_insert(NewLabel, Label, !PredMap), + svmap.det_insert(NewLabel, Label, !PredMap), NextPrevLabel = TeardownLabel ), build_frame_block_map(Remain, FrameSize, LabelSeq0, yes(NextPrevLabel), no, ProcLabel, !BlockMap, !PredMap, !C), ( MaybeExtraInfo = no, - svmap__det_insert(TeardownLabel, TeardownInfo, !BlockMap), + svmap.det_insert(TeardownLabel, TeardownInfo, !BlockMap), LabelSeq = [TeardownLabel | LabelSeq0] ; MaybeExtraInfo = yes(ExtraInfo2 - ExtraLabel2), - svmap__det_insert(TeardownLabel, TeardownInfo, !BlockMap), - svmap__det_insert(ExtraLabel2, ExtraInfo2, !BlockMap), + svmap.det_insert(TeardownLabel, TeardownInfo, !BlockMap), + svmap.det_insert(ExtraLabel2, ExtraInfo2, !BlockMap), LabelSeq = [ExtraLabel2, TeardownLabel | LabelSeq0] ) ; - opt_util__skip_to_next_label(Instrs0, Block, Instrs1), + opt_util.skip_to_next_label(Instrs0, Block, Instrs1), block_needs_frame(Block, NeedsFrame), BlockInstrs = [Instr0 | Block], BlockInfo = frame_block_info(Label, BlockInstrs, FallInto, [], no, ordinary(NeedsFrame)), - ( list__last(BlockInstrs, LastBlockInstr) -> + ( list.last(BlockInstrs, LastBlockInstr) -> LastBlockInstr = LastBlockUinstr - _, - opt_util__can_instr_fall_through(LastBlockUinstr, + opt_util.can_instr_fall_through(LastBlockUinstr, NextFallIntoBool), ( NextFallIntoBool = yes, @@ -540,7 +540,7 @@ build_frame_block_map([Instr0 | Instrs0], FrameSize, LabelSeq, ), build_frame_block_map(Instrs1, FrameSize, LabelSeq0, yes(Label), NextFallInto, ProcLabel, !BlockMap, !PredMap, !C), - svmap__det_insert(Label, BlockInfo, !BlockMap), + svmap.det_insert(Label, BlockInfo, !BlockMap), LabelSeq = [Label | LabelSeq0] ) ; @@ -558,23 +558,23 @@ build_frame_block_map([Instr0 | Instrs0], FrameSize, LabelSeq, % but can be moved after Setup, and Remain is all remaining % instructions. % -:- pred frameopt__detstack_setup(list(instruction)::in, int::out, string::out, +:- pred frameopt.detstack_setup(list(instruction)::in, int::out, string::out, list(instruction)::out, list(instruction)::out, list(instruction)::out) is semidet. -frameopt__detstack_setup(Instrs0, FrameSize, Msg, Setup, Others, Remain) :- - opt_util__gather_comments(Instrs0, Others0, Instrs1), +frameopt.detstack_setup(Instrs0, FrameSize, Msg, Setup, Others, Remain) :- + opt_util.gather_comments(Instrs0, Others0, Instrs1), Instrs1 = [SetupInstr1 | Instrs2], SetupInstr1 = incr_sp(FrameSize, Msg) - _, - frameopt__detstack_setup_2(Instrs2, FrameSize, SetupInstr2, + frameopt.detstack_setup_2(Instrs2, FrameSize, SetupInstr2, Others0, Others, Remain), Setup = [SetupInstr1, SetupInstr2]. -:- pred frameopt__detstack_setup_2(list(instruction)::in, int::in, +:- pred frameopt.detstack_setup_2(list(instruction)::in, int::in, instruction::out, list(instruction)::in, list(instruction)::out, list(instruction)::out) is semidet. -frameopt__detstack_setup_2([Instr0 | Instrs0], FrameSize, Setup, !Others, +frameopt.detstack_setup_2([Instr0 | Instrs0], FrameSize, Setup, !Others, Remain) :- ( Instr0 = assign(Lval, Rval) - _ -> ( @@ -588,14 +588,14 @@ frameopt__detstack_setup_2([Instr0 | Instrs0], FrameSize, Setup, !Others, Lval \= stackvar(FrameSize) -> !:Others = !.Others ++ [Instr0], - frameopt__detstack_setup_2(Instrs0, FrameSize, Setup, !Others, + frameopt.detstack_setup_2(Instrs0, FrameSize, Setup, !Others, Remain) ; fail ) ; Instr0 = comment(_) - _ -> !:Others = !.Others ++ [Instr0], - frameopt__detstack_setup_2(Instrs0, FrameSize, Setup, !Others, Remain) + frameopt.detstack_setup_2(Instrs0, FrameSize, Setup, !Others, Remain) ; fail ). @@ -616,19 +616,19 @@ frameopt__detstack_setup_2([Instr0 | Instrs0], FrameSize, Setup, !Others, % any such instructions are returned as Extra. Remain is all the % instructions after the teardown. % -:- pred frameopt__detstack_teardown(list(instruction)::in, int::in, +:- pred frameopt.detstack_teardown(list(instruction)::in, int::in, list(instruction)::out, list(instruction)::out, list(instruction)::out, list(instruction)::out, instruction::out, list(instruction)::out) is semidet. -frameopt__detstack_teardown([Instr0 | Instrs0], FrameSize, +frameopt.detstack_teardown([Instr0 | Instrs0], FrameSize, Extra, Succip, Decrsp, Livevals, Goto, Remain) :- ( Instr0 = label(_) - _ -> fail ; - frameopt__detstack_teardown_2([Instr0 | Instrs0], FrameSize, + frameopt.detstack_teardown_2([Instr0 | Instrs0], FrameSize, [], ExtraPrime, [], SuccipPrime, [], DecrspPrime, [], LivevalsPrime, GotoPrime, RemainPrime) -> @@ -639,21 +639,21 @@ frameopt__detstack_teardown([Instr0 | Instrs0], FrameSize, Goto = GotoPrime, Remain = RemainPrime ; - frameopt__detstack_teardown(Instrs0, FrameSize, Extra1, Succip, + frameopt.detstack_teardown(Instrs0, FrameSize, Extra1, Succip, Decrsp, Livevals, Goto, Remain), Extra = [Instr0 | Extra1] ). -:- pred frameopt__detstack_teardown_2(list(instruction)::in, int::in, +:- pred frameopt.detstack_teardown_2(list(instruction)::in, int::in, list(instruction)::in, list(instruction)::out, list(instruction)::in, list(instruction)::out, list(instruction)::in, list(instruction)::out, list(instruction)::in, list(instruction)::out, instruction::out, list(instruction)::out) is semidet. -frameopt__detstack_teardown_2(Instrs0, FrameSize, +frameopt.detstack_teardown_2(Instrs0, FrameSize, !Extra, !Succip, !Decrsp, !Livevals, Goto, Remain) :- - opt_util__skip_comments(Instrs0, Instrs1), + opt_util.skip_comments(Instrs0, Instrs1), Instrs1 = [Instr1 | Instrs2], Instr1 = Uinstr1 - _, ( @@ -665,26 +665,26 @@ frameopt__detstack_teardown_2(Instrs0, FrameSize, !.Succip = [], !.Decrsp = [], !:Succip = [Instr1], - frameopt__detstack_teardown_2(Instrs2, FrameSize, !Extra, !Succip, + frameopt.detstack_teardown_2(Instrs2, FrameSize, !Extra, !Succip, !Decrsp, !Livevals, Goto, Remain) ; - opt_util__lval_refers_stackvars(Lval, no), - opt_util__rval_refers_stackvars(Rval, no), - list__append(!.Extra, [Instr1], !:Extra), - frameopt__detstack_teardown_2(Instrs2, FrameSize, !Extra, !Succip, + opt_util.lval_refers_stackvars(Lval, no), + opt_util.rval_refers_stackvars(Rval, no), + list.append(!.Extra, [Instr1], !:Extra), + frameopt.detstack_teardown_2(Instrs2, FrameSize, !Extra, !Succip, !Decrsp, !Livevals, Goto, Remain) ) ; Uinstr1 = decr_sp(FrameSize), !.Decrsp = [], !:Decrsp = [Instr1], - frameopt__detstack_teardown_2(Instrs2, FrameSize, !Extra, !Succip, + frameopt.detstack_teardown_2(Instrs2, FrameSize, !Extra, !Succip, !Decrsp, !Livevals, Goto, Remain) ; Uinstr1 = livevals(_), !.Livevals = [], !:Livevals = [Instr1], - frameopt__detstack_teardown_2(Instrs2, FrameSize, !Extra, !Succip, + frameopt.detstack_teardown_2(Instrs2, FrameSize, !Extra, !Succip, !Decrsp, !Livevals, Goto, Remain) ; Uinstr1 = goto(_), @@ -700,14 +700,14 @@ frameopt__detstack_teardown_2(Instrs0, FrameSize, :- pred block_needs_frame(list(instruction)::in, block_needs_frame::out) is det. block_needs_frame(Instrs, NeedsFrame) :- - opt_util__block_refers_stackvars(Instrs, ReferStackVars), + opt_util.block_refers_stackvars(Instrs, ReferStackVars), ( ReferStackVars = yes, NeedsFrame = block_needs_frame ; ReferStackVars = no, ( - list__member(Instr, Instrs), + list.member(Instr, Instrs), Instr = Uinstr - _, ( Uinstr = call(_, _, _, _, _, _) @@ -760,7 +760,7 @@ block_needs_frame(Instrs, NeedsFrame) :- analyze_block_map(LabelSeq, !BlockMap, KeepFrameData) :- ( LabelSeq = [FirstLabel, SecondLabel | _], - map__search(!.BlockMap, FirstLabel, FirstBlockInfo), + map.search(!.BlockMap, FirstLabel, FirstBlockInfo), FirstBlockInfo = frame_block_info(FirstLabel, _, _, _, _, setup) -> analyze_block_map_2(LabelSeq, FirstLabel, !BlockMap, @@ -787,7 +787,7 @@ analyze_block_map(LabelSeq, !BlockMap, KeepFrameData) :- analyze_block_map_2([], _, !BlockMap, !AnyBlockNeedsFrame, !KeepFrame). analyze_block_map_2([Label | Labels], FirstLabel, !BlockMap, !AnyBlockNeedsFrame, !JumpToStart) :- - map__lookup(!.BlockMap, Label, BlockInfo0), + map.lookup(!.BlockMap, Label, BlockInfo0), BlockInfo0 = frame_block_info(BlockLabel, BlockInstrs, FallInto, _, _, Type), ( Type = ordinary(block_needs_frame) -> @@ -797,12 +797,12 @@ analyze_block_map_2([Label | Labels], FirstLabel, !BlockMap, ), ( Label = BlockLabel, % sanity check - list__last(BlockInstrs, LastInstr) + list.last(BlockInstrs, LastInstr) -> LastInstr = LastUinstr - _, possible_targets(LastUinstr, SideLabels, _SideCodeAddrs), ( - opt_util__can_instr_fall_through(LastUinstr, yes), + opt_util.can_instr_fall_through(LastUinstr, yes), Labels = [NextLabel | _] -> MaybeFallThrough = yes(NextLabel) @@ -822,7 +822,7 @@ analyze_block_map_2([Label | Labels], FirstLabel, !BlockMap, ), BlockInfo = frame_block_info(BlockLabel, BlockInstrs, FallInto, SideLabels, MaybeFallThrough, Type), - svmap__det_update(Label, BlockInfo, !BlockMap), + svmap.det_update(Label, BlockInfo, !BlockMap), analyze_block_map_2(Labels, FirstLabel, !BlockMap, !AnyBlockNeedsFrame, !JumpToStart). @@ -859,10 +859,10 @@ matching_entry_type(c_local, c_local). can_clobber_succip([], _BlockMap) = no. can_clobber_succip([Label | Labels], BlockMap) = CanClobberSuccip :- - map__lookup(BlockMap, Label, BlockInfo), + map.lookup(BlockMap, Label, BlockInfo), Instrs = BlockInfo ^ fb_instrs, ( - list__member(Instr, Instrs), + list.member(Instr, Instrs), Instr = Uinstr - _, ( Uinstr = call(_, _, _, _, _, _) @@ -892,7 +892,7 @@ can_clobber_succip([Label | Labels], BlockMap) = CanClobberSuccip :- keep_frame_transform([], _, _, _, !BlockMap). keep_frame_transform([Label | Labels], FirstLabel, SecondLabel, CanClobberSuccip, !BlockMap) :- - map__lookup(!.BlockMap, Label, BlockInfo0), + map.lookup(!.BlockMap, Label, BlockInfo0), ( BlockInfo0 = frame_block_info(Label, OrigInstrs, FallInto, [_], no, teardown(Succip, Livevals, Goto)), @@ -908,12 +908,12 @@ keep_frame_transform([Label | Labels], FirstLabel, SecondLabel, unexpected(this_file, "keep_frame_transform: block does not begin with label") ), - string__append(Comment, " (keeping frame)", NewComment), + string.append(Comment, " (keeping frame)", NewComment), NewGoto = goto(label(SecondLabel)) - NewComment, - list__append(Livevals, [NewGoto], LivevalsGoto), + list.append(Livevals, [NewGoto], LivevalsGoto), ( CanClobberSuccip = yes, - list__append(Succip, LivevalsGoto, BackInstrs) + list.append(Succip, LivevalsGoto, BackInstrs) ; CanClobberSuccip = no, BackInstrs = LivevalsGoto @@ -921,14 +921,14 @@ keep_frame_transform([Label | Labels], FirstLabel, SecondLabel, Instrs = [OrigLabelInstr | BackInstrs], BlockInfo = frame_block_info(Label, Instrs, FallInto, [SecondLabel], no, ordinary(block_needs_frame)), - map__det_update(!.BlockMap, Label, BlockInfo, !:BlockMap) + map.det_update(!.BlockMap, Label, BlockInfo, !:BlockMap) ; true ), keep_frame_transform(Labels, FirstLabel, SecondLabel, CanClobberSuccip, !BlockMap). -% list__split_last_det +% list.split_last_det :- pred pick_last(list(T)::in, list(T)::out, T::out) is det. pick_last([], _, _) :- @@ -954,7 +954,7 @@ pick_last([First | Rest], NonLast, Last) :- can_delay_frame([], _). can_delay_frame([Label | _Labels], BlockMap) :- - map__lookup(BlockMap, Label, BlockInfo), + map.lookup(BlockMap, Label, BlockInfo), BlockInfo ^ fb_type = setup. %-----------------------------------------------------------------------------% @@ -962,19 +962,19 @@ can_delay_frame([Label | _Labels], BlockMap) :- % The data structures used in the delaying optimizations. - % map__search(RevMap, Label, SideLabels) should be true if the block + % map.search(RevMap, Label, SideLabels) should be true if the block % started by Label can be reached via jump or fallthrough from the labels % in SideLabels. % :- type rev_map == map(label, list(label)). - % Given the label L starting a block, map__search(PredMap, L, PrevL) + % Given the label L starting a block, map.search(PredMap, L, PrevL) % is true if PrevL starts the block immediately before L. % If L is the first block in the sequence (which should be a setup block), - % map__search(PredMap, L, _) fails. + % map.search(PredMap, L, _) fails. :- type pred_map == map(label, label). - % map__search(SetupParMap, L, SetupL) should be true if L starts + % map.search(SetupParMap, L, SetupL) should be true if L starts % an ordinary block that needs a stack frame that can be jumped to by % blocks that do not have a stack frame. In this case, SetupL will be the % label starting a new block that sets up the stack frame before handing @@ -986,7 +986,7 @@ can_delay_frame([Label | _Labels], BlockMap) :- % :- type setup_par_map ---> setup_par_map(map(label, label)). - % map__search(TeardownParMap, L, ParallelL should be true if L starts + % map.search(TeardownParMap, L, ParallelL should be true if L starts % a teardown block and ParallelL starts a copy of L's block from which % the instructions to tear down the stack frame have been deleted. % If the block immediately before L does not have a stack frame, @@ -1072,16 +1072,16 @@ can_delay_frame([Label | _Labels], BlockMap) :- delay_frame_transform(!LabelSeq, FrameSize, Msg, ProcLabel, PredMap, !C, !BlockMap, Globals, NewComments, CanTransform) :- some [!OrdNeedsFrame, !CanTransform, !PropagationStepsLeft] ( - !:OrdNeedsFrame = map__init, + !:OrdNeedsFrame = map.init, !:CanTransform = can_transform, !:PropagationStepsLeft = max_propagation_steps, - delay_frame_init(!.LabelSeq, !.BlockMap, map__init, RevMap, - queue__init, SuccQueue, !OrdNeedsFrame), + delay_frame_init(!.LabelSeq, !.BlockMap, map.init, RevMap, + queue.init, SuccQueue, !OrdNeedsFrame), propagate_frame_requirement_to_successors(SuccQueue, !.BlockMap, - !OrdNeedsFrame, set__init, !PropagationStepsLeft, !CanTransform), - map__to_assoc_list(!.OrdNeedsFrame, OrdNeedsFrameList), - list__filter_map(key_block_needs_frame, OrdNeedsFrameList, Frontier), - queue__list_to_queue(Frontier, PredQueue), + !OrdNeedsFrame, set.init, !PropagationStepsLeft, !CanTransform), + map.to_assoc_list(!.OrdNeedsFrame, OrdNeedsFrameList), + list.filter_map(key_block_needs_frame, OrdNeedsFrameList, Frontier), + queue.list_to_queue(Frontier, PredQueue), propagate_frame_requirement_to_predecessors(PredQueue, !.BlockMap, RevMap, !OrdNeedsFrame, !.PropagationStepsLeft, _, !CanTransform), ( @@ -1091,7 +1091,7 @@ delay_frame_transform(!LabelSeq, FrameSize, Msg, ProcLabel, PredMap, !C, NewComments = [] ; !.CanTransform = can_transform, - globals__lookup_bool_option(Globals, frameopt_comments, + globals.lookup_bool_option(Globals, frameopt_comments, FrameoptComments), ( FrameoptComments = no, @@ -1099,13 +1099,13 @@ delay_frame_transform(!LabelSeq, FrameSize, Msg, ProcLabel, PredMap, !C, ; FrameoptComments = yes, FirstComment = comment("delaying stack frame") - "", - list__map(describe_block(!.BlockMap, !.OrdNeedsFrame, + list.map(describe_block(!.BlockMap, !.OrdNeedsFrame, PredMap, ProcLabel), !.LabelSeq, BlockComments), NewComments = [FirstComment | BlockComments] ), process_frame_delay(!.LabelSeq, !.OrdNeedsFrame, ProcLabel, !C, - !BlockMap, setup_par_map(map__init), SetupParMap, - teardown_par_map(map__init), TeardownParMap), + !BlockMap, setup_par_map(map.init), SetupParMap, + teardown_par_map(map.init), TeardownParMap), create_parallels(!LabelSeq, FrameSize, Msg, ProcLabel, !C, !.OrdNeedsFrame, SetupParMap, TeardownParMap, PredMap, !BlockMap) @@ -1150,18 +1150,18 @@ key_block_needs_frame(Label - block_needs_frame, Label). delay_frame_init([], _, !RevMap, !Queue, !OrdNeedsFrame). delay_frame_init([Label | Labels], BlockMap, !RevMap, !Queue, !OrdNeedsFrame) :- - map__lookup(BlockMap, Label, BlockInfo), + map.lookup(BlockMap, Label, BlockInfo), BlockType = BlockInfo ^ fb_type, ( BlockType = setup ; BlockType = ordinary(NeedsFrame), - svmap__det_insert(Label, NeedsFrame, !OrdNeedsFrame), + svmap.det_insert(Label, NeedsFrame, !OrdNeedsFrame), ( NeedsFrame = block_doesnt_need_frame ; NeedsFrame = block_needs_frame, - svqueue__put(Label, !Queue) + svqueue.put(Label, !Queue) ) ; BlockType = teardown(_, _, _) @@ -1174,12 +1174,12 @@ delay_frame_init([Label | Labels], BlockMap, !RevMap, !Queue, rev_map_side_labels([], _Label, !RevMap). rev_map_side_labels([Label | Labels], SourceLabel, !RevMap) :- - ( map__search(!.RevMap, Label, OtherSources0) -> + ( map.search(!.RevMap, Label, OtherSources0) -> OtherSources = [SourceLabel | OtherSources0], - svmap__det_update(Label, OtherSources, !RevMap) + svmap.det_update(Label, OtherSources, !RevMap) ; OtherSources = [SourceLabel], - svmap__det_insert(Label, OtherSources, !RevMap) + svmap.det_insert(Label, OtherSources, !RevMap) ), rev_map_side_labels(Labels, SourceLabel, !RevMap). @@ -1203,14 +1203,14 @@ propagate_frame_requirement_to_successors(!.Queue, BlockMap, !OrdNeedsFrame, true ; !.PropagationStepsLeft < 0 -> !:CanTransform = cannot_transform - ; svqueue__get(Label, !Queue) -> + ; svqueue.get(Label, !Queue) -> !:PropagationStepsLeft = !.PropagationStepsLeft - 1, - svset__insert(Label, !AlreadyProcessed), - map__lookup(BlockMap, Label, BlockInfo), + svset.insert(Label, !AlreadyProcessed), + map.lookup(BlockMap, Label, BlockInfo), BlockType = BlockInfo ^ fb_type, ( BlockType = ordinary(_), - svmap__det_update(Label, block_needs_frame, !OrdNeedsFrame), + svmap.det_update(Label, block_needs_frame, !OrdNeedsFrame), % Putting an already processed label into the queue could % lead to an infinite loop. However, we cannot decide whether % a label has been processed by checking whether !.OrdNeedsFrame @@ -1219,9 +1219,9 @@ propagate_frame_requirement_to_successors(!.Queue, BlockMap, !OrdNeedsFrame, % is a setup frame. We cannot assume that successors not in % !.OrdNeedsFrame should set !:CanTransform to no either, since % we don't want to do that for teardown frames. - list__filter(set__contains(!.AlreadyProcessed), + list.filter(set.contains(!.AlreadyProcessed), successors(BlockInfo), _, UnprocessedSuccessors), - svqueue__put_list(UnprocessedSuccessors, !Queue) + svqueue.put_list(UnprocessedSuccessors, !Queue) ; BlockType = setup, !:CanTransform = cannot_transform @@ -1250,9 +1250,9 @@ propagate_frame_requirement_to_predecessors(!.Queue, BlockMap, RevMap, true ; !.PropagationStepsLeft < 0 -> !:CanTransform = cannot_transform - ; svqueue__get(Label, !Queue) -> + ; svqueue.get(Label, !Queue) -> !:PropagationStepsLeft = !.PropagationStepsLeft - 1, - ( map__search(RevMap, Label, PredecessorsPrime) -> + ( map.search(RevMap, Label, PredecessorsPrime) -> Predecessors = PredecessorsPrime ; % We get here if Label cannot be reached by a fallthrough or an @@ -1260,13 +1260,13 @@ propagate_frame_requirement_to_predecessors(!.Queue, BlockMap, RevMap, % that sets up the resumption point saves the address of Label on % the stack, and thus is already known to need a stack frame. Predecessors = [], - svmap__det_update(Label, block_needs_frame, !OrdNeedsFrame) + svmap.det_update(Label, block_needs_frame, !OrdNeedsFrame) ), - list__filter(all_successors_need_frame(BlockMap, !.OrdNeedsFrame), + list.filter(all_successors_need_frame(BlockMap, !.OrdNeedsFrame), Predecessors, NowNeedFrameLabels), - list__foldl2(record_frame_need(BlockMap), NowNeedFrameLabels, + list.foldl2(record_frame_need(BlockMap), NowNeedFrameLabels, !OrdNeedsFrame, !CanTransform), - svqueue__put_list(NowNeedFrameLabels, !Queue), + svqueue.put_list(NowNeedFrameLabels, !Queue), propagate_frame_requirement_to_predecessors(!.Queue, BlockMap, RevMap, !OrdNeedsFrame, !PropagationStepsLeft, !CanTransform) ; @@ -1278,14 +1278,14 @@ propagate_frame_requirement_to_predecessors(!.Queue, BlockMap, RevMap, can_transform::in, can_transform::out) is det. record_frame_need(BlockMap, Label, !OrdNeedsFrame, !CanTransform) :- - map__lookup(BlockMap, Label, BlockInfo), + map.lookup(BlockMap, Label, BlockInfo), BlockType = BlockInfo ^ fb_type, ( BlockType = setup, !:CanTransform = cannot_transform ; BlockType = ordinary(_), - svmap__det_update(Label, block_needs_frame, !OrdNeedsFrame) + svmap.det_update(Label, block_needs_frame, !OrdNeedsFrame) ; BlockType = teardown(_, _, _), unexpected(this_file, "record_frame_need: teardown") @@ -1295,19 +1295,19 @@ record_frame_need(BlockMap, Label, !OrdNeedsFrame, !CanTransform) :- label::in) is semidet. all_successors_need_frame(BlockMap, OrdNeedsFrame, Label) :- - map__lookup(BlockMap, Label, BlockInfo), + map.lookup(BlockMap, Label, BlockInfo), Successors = successors(BlockInfo), - list__filter(label_needs_frame(OrdNeedsFrame), Successors, + list.filter(label_needs_frame(OrdNeedsFrame), Successors, _NeedFrameSuccessors, NoNeedFrameSuccessors), NoNeedFrameSuccessors = []. :- pred label_needs_frame(ord_needs_frame::in, label::in) is semidet. label_needs_frame(OrdNeedsFrame, Label) :- - ( map__search(OrdNeedsFrame, Label, NeedsFrame) -> + ( map.search(OrdNeedsFrame, Label, NeedsFrame) -> NeedsFrame = block_needs_frame ; - % If the map__search fails, Label is not an ordinary frame. + % If the map.search fails, Label is not an ordinary frame. % Setup blocks and teardown blocks don't need frames. fail ). @@ -1344,7 +1344,7 @@ process_frame_delay([], _, _, !C, !BlockMap, !SetupParMap, !TeardownParMap). process_frame_delay([Label0 | Labels0], OrdNeedsFrame, ProcLabel, !C, !BlockMap, !SetupParMap, !TeardownParMap) :- - map__lookup(!.BlockMap, Label0, BlockInfo0), + map.lookup(!.BlockMap, Label0, BlockInfo0), BlockInfo0 = frame_block_info(Label0Copy, Instrs0, FallInto, SideLabels0, MaybeFallThrough0, Type), expect(unify(Label0, Label0Copy), this_file, @@ -1376,12 +1376,12 @@ process_frame_delay([Label0 | Labels0], OrdNeedsFrame, ProcLabel, !C, ), BlockInfo = frame_block_info(Label0, [LabelInstr], FallInto, SideLabels0, MaybeFallThrough0, ordinary(block_doesnt_need_frame)), - svmap__det_update(Label0, BlockInfo, !BlockMap), + svmap.det_update(Label0, BlockInfo, !BlockMap), process_frame_delay(Labels0, OrdNeedsFrame, ProcLabel, !C, !BlockMap, !SetupParMap, !TeardownParMap) ; Type = ordinary(_), - map__lookup(OrdNeedsFrame, Label0, NeedsFrame), + map.lookup(OrdNeedsFrame, Label0, NeedsFrame), ( NeedsFrame = block_needs_frame, % Every block reachable from this block, whether via jump or @@ -1413,13 +1413,13 @@ process_frame_delay([Label0 | Labels0], OrdNeedsFrame, ProcLabel, !C, % - If it is an ordinary block B that does need a stack frame, we need to % insert the frame setup code at the transfer between the two blocks. % The label S of the block that contains the setup code and then goes - % to block B will be given by map__lookup(!.SetupParMap, B, S). + % to block B will be given by map.lookup(!.SetupParMap, B, S). % Here, we just allocate the label S; the block will be created later. % % - If it is teardown block B, then we need to jump to a variant of B % that does no teardown, since there is no stack frame to tear down. % The label S of the variant block will be given by - % map__lookup(!.TeardownParMap, B, S). Here, we just allocate + % map.lookup(!.TeardownParMap, B, S). Here, we just allocate % the label S; the block will be created later. % :- pred transform_nostack_ordinary_block(label::in, list(label)::in, @@ -1461,12 +1461,12 @@ transform_nostack_ordinary_block(Label0, Labels0, BlockInfo0, OrdNeedsFrame, RedirectFallThrough = [] ), pick_last(Instrs0, PrevInstrs, LastInstr0), - map__from_assoc_list(AssocLabelMap, LabelMap), - opt_util__replace_labels_instruction(LastInstr0, LabelMap, no, LastInstr), + map.from_assoc_list(AssocLabelMap, LabelMap), + opt_util.replace_labels_instruction(LastInstr0, LabelMap, no, LastInstr), Instrs = PrevInstrs ++ [LastInstr | RedirectFallThrough], BlockInfo = frame_block_info(Label0, Instrs, FallInto, SideLabels, MaybeFallThrough, Type), - map__set(!.BlockMap, Label0, BlockInfo, !:BlockMap), + map.set(!.BlockMap, Label0, BlockInfo, !:BlockMap), process_frame_delay(Labels0, OrdNeedsFrame, ProcLabel, !C, !BlockMap, !SetupParMap, !TeardownParMap). @@ -1518,7 +1518,7 @@ mark_parallels_for_nostack_successors([Label0 | Labels0], [Label | Labels], mark_parallel_for_nostack_successor(Label0, Label, OrdNeedsFrame, BlockMap, ProcLabel, !C, !SetupParMap, !TeardownParMap) :- - map__lookup(BlockMap, Label0, BlockInfo), + map.lookup(BlockMap, Label0, BlockInfo), Type = BlockInfo ^ fb_type, ( Type = setup, @@ -1526,7 +1526,7 @@ mark_parallel_for_nostack_successor(Label0, Label, OrdNeedsFrame, BlockMap, "reached setup via jump from ordinary block") ; Type = ordinary(_), - map__lookup(OrdNeedsFrame, Label0, NeedsFrame), + map.lookup(OrdNeedsFrame, Label0, NeedsFrame), ( NeedsFrame = block_needs_frame, ensure_setup_parallel(Label0, Label, ProcLabel, !C, !SetupParMap) @@ -1559,7 +1559,7 @@ create_parallels([Label0 | Labels0], Labels, FrameSize, Msg, ProcLabel, !C, OrdNeedsFrame, SetupParMap, TeardownParMap, PredMap, !BlockMap) :- create_parallels(Labels0, Labels1, FrameSize, Msg, ProcLabel, !C, OrdNeedsFrame, SetupParMap, TeardownParMap, PredMap, !BlockMap), - map__lookup(!.BlockMap, Label0, BlockInfo0), + map.lookup(!.BlockMap, Label0, BlockInfo0), BlockInfo0 = frame_block_info(Label0Copy, _, FallInto, SideLabels, MaybeFallThrough, Type), expect(unify(Label0, Label0Copy), this_file, @@ -1585,7 +1585,7 @@ create_parallels([Label0 | Labels0], Labels, FrameSize, Msg, ProcLabel, !C, PrevNeedsFrame = block_doesnt_need_frame, Labels = [ParallelLabel, Label0 | Labels1], BlockInfo = BlockInfo0 ^ fb_fallen_into := no, - svmap__det_update(Label0, BlockInfo, !BlockMap), + svmap.det_update(Label0, BlockInfo, !BlockMap), ParallelBlockFallInto = FallInto ; PrevNeedsFrame = block_needs_frame, @@ -1595,7 +1595,7 @@ create_parallels([Label0 | Labels0], Labels, FrameSize, Msg, ProcLabel, !C, ParallelBlockInfo = frame_block_info(ParallelLabel, ReplacementCode, ParallelBlockFallInto, SideLabels, no, ordinary(block_doesnt_need_frame)), - svmap__det_insert(ParallelLabel, ParallelBlockInfo, !BlockMap) + svmap.det_insert(ParallelLabel, ParallelBlockInfo, !BlockMap) ; unexpected(this_file, "block in teardown_par_map is not teardown") @@ -1606,7 +1606,7 @@ create_parallels([Label0 | Labels0], Labels, FrameSize, Msg, ProcLabel, !C, PrevNeedsFrame = prev_block_needs_frame(OrdNeedsFrame, BlockInfo0), ( PrevNeedsFrame = block_needs_frame, - counter__allocate(N, !C), + counter.allocate(N, !C), JumpAroundLabel = internal(N, ProcLabel), % By not including a label instruction at the start of % JumpAroundCode, we are breaking an invariant of frame_block_maps. @@ -1620,10 +1620,10 @@ create_parallels([Label0 | Labels0], Labels, FrameSize, Msg, ProcLabel, !C, JumpAroundBlockInfo = frame_block_info(JumpAroundLabel, JumpAroundCode, no, [Label0], FallInto, ordinary(block_needs_frame)), - svmap__det_insert(JumpAroundLabel, JumpAroundBlockInfo, !BlockMap), + svmap.det_insert(JumpAroundLabel, JumpAroundBlockInfo, !BlockMap), SetupFallInto = yes(JumpAroundLabel), BlockInfo = BlockInfo0 ^ fb_fallen_into := yes(SetupLabel), - svmap__det_update(Label0, BlockInfo, !BlockMap) + svmap.det_update(Label0, BlockInfo, !BlockMap) ; PrevNeedsFrame = block_doesnt_need_frame, Labels = [SetupLabel, Label0 | Labels1], @@ -1636,7 +1636,7 @@ create_parallels([Label0 | Labels0], Labels, FrameSize, Msg, ProcLabel, !C, ], SetupBlockInfo = frame_block_info(SetupLabel, SetupCode, SetupFallInto, [], yes(Label0), setup), - svmap__det_insert(SetupLabel, SetupBlockInfo, !BlockMap) + svmap.det_insert(SetupLabel, SetupBlockInfo, !BlockMap) ; Labels = [Label0 | Labels1] ). @@ -1648,7 +1648,7 @@ prev_block_needs_frame(OrdNeedsFrame, BlockInfo) = PrevNeedsFrame :- MaybeFallIntoFrom = BlockInfo ^ fb_fallen_into, ( MaybeFallIntoFrom = yes(FallIntoFrom), - ( map__search(OrdNeedsFrame, FallIntoFrom, NeedsFrame) -> + ( map.search(OrdNeedsFrame, FallIntoFrom, NeedsFrame) -> % FallIntoFrom is an ordinary block that can fall through % to this block. PrevNeedsFrame = NeedsFrame @@ -1678,13 +1678,13 @@ is_ordinary(ordinary(_)). ensure_setup_parallel(Label, ParallelLabel, ProcLabel, !C, !SetupParMap) :- !.SetupParMap = setup_par_map(ParMap0), - ( map__search(ParMap0, Label, OldParallel) -> + ( map.search(ParMap0, Label, OldParallel) -> ParallelLabel = OldParallel ; - counter__allocate(N, !C), + counter.allocate(N, !C), NewParallel = internal(N, ProcLabel), ParallelLabel = NewParallel, - map__det_insert(ParMap0, Label, NewParallel, ParMap), + map.det_insert(ParMap0, Label, NewParallel, ParMap), !:SetupParMap = setup_par_map(ParMap) ). @@ -1698,13 +1698,13 @@ ensure_setup_parallel(Label, ParallelLabel, ProcLabel, !C, !SetupParMap) :- ensure_teardown_parallel(Label, ParallelLabel, ProcLabel, !C, !TeardownParMap) :- !.TeardownParMap = teardown_par_map(ParMap0), - ( map__search(ParMap0, Label, OldParallel) -> + ( map.search(ParMap0, Label, OldParallel) -> ParallelLabel = OldParallel ; - counter__allocate(N, !C), + counter.allocate(N, !C), NewParallel = internal(N, ProcLabel), ParallelLabel = NewParallel, - map__det_insert(ParMap0, Label, NewParallel, ParMap), + map.det_insert(ParMap0, Label, NewParallel, ParMap), !:TeardownParMap = teardown_par_map(ParMap) ). @@ -1718,7 +1718,7 @@ ensure_teardown_parallel(Label, ParallelLabel, ProcLabel, !C, proc_label::in, label::in, instruction::out) is det. describe_block(BlockMap, OrdNeedsFrame, PredMap, ProcLabel, Label, Instr) :- - map__lookup(BlockMap, Label, BlockInfo), + map.lookup(BlockMap, Label, BlockInfo), BlockInfo = frame_block_info(BlockLabel, BlockInstrs, FallInto, SideLabels, MaybeFallThrough, Type), expect(unify(Label, BlockLabel), this_file, @@ -1726,7 +1726,7 @@ describe_block(BlockMap, OrdNeedsFrame, PredMap, ProcLabel, Label, Instr) :- LabelStr = dump_label(ProcLabel, Label), BlockInstrsStr = dump_fullinstrs(ProcLabel, yes, BlockInstrs), Heading = "\nBLOCK " ++ LabelStr ++ "\n\n", - ( map__search(PredMap, Label, PredLabel) -> + ( map.search(PredMap, Label, PredLabel) -> PredStr = "previous label " ++ dump_label(ProcLabel, PredLabel) ++ "\n" ; PredStr = "no previous label\n" @@ -1771,7 +1771,7 @@ describe_block(BlockMap, OrdNeedsFrame, PredMap, ProcLabel, Label, Instr) :- UsesFrame = block_doesnt_need_frame, TypeStr = "ordinary; does not use frame, " ), - map__lookup(OrdNeedsFrame, Label, NeedsFrame), + map.lookup(OrdNeedsFrame, Label, NeedsFrame), ( NeedsFrame = block_doesnt_need_frame, expect(unify(UsesFrame, block_doesnt_need_frame), this_file, @@ -1810,13 +1810,13 @@ is_yes(yes(_)). is semidet. search_setup_par_map(setup_par_map(ParMap), Label, ParallelLabel) :- - map__search(ParMap, Label, ParallelLabel). + map.search(ParMap, Label, ParallelLabel). :- pred search_teardown_par_map(teardown_par_map::in, label::in, label::out) is semidet. search_teardown_par_map(teardown_par_map(ParMap), Label, ParallelLabel) :- - map__search(ParMap, Label, ParallelLabel). + map.search(ParMap, Label, ParallelLabel). %-----------------------------------------------------------------------------% diff --git a/compiler/global_data.m b/compiler/global_data.m index 0e31aa607..c500c220c 100644 --- a/compiler/global_data.m +++ b/compiler/global_data.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2003-2005 The University of Melbourne. +% Copyright (C) 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -13,7 +13,7 @@ % %-----------------------------------------------------------------------------% -:- module ll_backend__global_data. +:- module ll_backend.global_data. :- interface. :- import_module hlds.hlds_pred. @@ -142,45 +142,45 @@ wrap_layout_data(LayoutData) = layout_data(LayoutData). global_data_init(StaticCellInfo, GlobalData) :- - map__init(EmptyDataMap), - map__init(EmptyLayoutMap), + map.init(EmptyDataMap), + map.init(EmptyLayoutMap), GlobalData = global_data(EmptyDataMap, EmptyLayoutMap, [], StaticCellInfo). global_data_add_new_proc_var(PredProcId, ProcVar, !GlobalData) :- ProcVarMap0 = !.GlobalData ^ proc_var_map, - map__det_insert(ProcVarMap0, PredProcId, ProcVar, ProcVarMap), + map.det_insert(ProcVarMap0, PredProcId, ProcVar, ProcVarMap), !:GlobalData = !.GlobalData ^ proc_var_map := ProcVarMap. global_data_add_new_proc_layout(PredProcId, ProcLayout, !GlobalData) :- ProcLayoutMap0 = !.GlobalData ^ proc_layout_map, - map__det_insert(ProcLayoutMap0, PredProcId, ProcLayout, ProcLayoutMap), + map.det_insert(ProcLayoutMap0, PredProcId, ProcLayout, ProcLayoutMap), !:GlobalData = !.GlobalData ^ proc_layout_map := ProcLayoutMap. global_data_update_proc_layout(PredProcId, ProcLayout, !GlobalData) :- ProcLayoutMap0 = !.GlobalData ^ proc_layout_map, - map__det_update(ProcLayoutMap0, PredProcId, ProcLayout, ProcLayoutMap), + map.det_update(ProcLayoutMap0, PredProcId, ProcLayout, ProcLayoutMap), !:GlobalData = !.GlobalData ^ proc_layout_map := ProcLayoutMap. global_data_add_new_closure_layouts(NewClosureLayouts, !GlobalData) :- ClosureLayouts0 = !.GlobalData ^ closure_layouts, - list__append(NewClosureLayouts, ClosureLayouts0, ClosureLayouts), + list.append(NewClosureLayouts, ClosureLayouts0, ClosureLayouts), !:GlobalData = !.GlobalData ^ closure_layouts := ClosureLayouts. global_data_maybe_get_proc_layout(GlobalData, PredProcId, ProcLayout) :- ProcLayoutMap = GlobalData ^ proc_layout_map, - map__search(ProcLayoutMap, PredProcId, ProcLayout). + map.search(ProcLayoutMap, PredProcId, ProcLayout). global_data_get_proc_layout(GlobalData, PredProcId, ProcLayout) :- ProcLayoutMap = GlobalData ^ proc_layout_map, - map__lookup(ProcLayoutMap, PredProcId, ProcLayout). + map.lookup(ProcLayoutMap, PredProcId, ProcLayout). global_data_get_all_proc_vars(GlobalData, ProcVars) :- ProcVarMap = GlobalData ^ proc_var_map, - map__values(ProcVarMap, ProcVars). + map.values(ProcVarMap, ProcVars). global_data_get_all_proc_layouts(GlobalData, ProcLayouts) :- ProcLayoutMap = GlobalData ^ proc_layout_map, - map__values(ProcLayoutMap, ProcLayouts). + map.values(ProcLayoutMap, ProcLayouts). global_data_get_all_closure_layouts(GlobalData, ClosureLayouts) :- ClosureLayouts = GlobalData ^ closure_layouts. @@ -226,13 +226,13 @@ global_data_set_static_cell_info(StaticCellInfo, !GlobalData) :- ). init_static_cell_info(BaseName, UnboxFloat, CommonData) = Info0 :- - map__init(Cells0), - map__init(CellMap0), + map.init(Cells0), + map.init(CellMap0), Info0 = static_cell_info(BaseName, UnboxFloat, CommonData, - counter__init(0), counter__init(0), Cells0, CellMap0). + counter.init(0), counter.init(0), Cells0, CellMap0). add_static_cell_natural_types(Args, DataAddr, !Info) :- - list__map(associate_natural_type(!.Info ^ unbox_float), Args, ArgsTypes), + list.map(associate_natural_type(!.Info ^ unbox_float), Args, ArgsTypes), add_static_cell(ArgsTypes, DataAddr, !Info). add_static_cell(ArgsTypes0, DataAddr, !Info) :- @@ -253,31 +253,31 @@ add_static_cell(ArgsTypes0, DataAddr, !Info) :- static_cell_info::in, static_cell_info::out) is det. do_add_static_cell(ArgsTypes, CellType, CellArgs, DataAddr, !Info) :- - assoc_list__keys(ArgsTypes, Args), + assoc_list.keys(ArgsTypes, Args), CellGroupMap0 = !.Info ^ cell_group_map, - ( map__search(CellGroupMap0, CellType, CellGroup0) -> + ( map.search(CellGroupMap0, CellType, CellGroup0) -> TypeNum = CellGroup0 ^ cell_type_number, CellGroup1 = CellGroup0 ; TypeNumCounter0 = !.Info ^ type_counter, - counter__allocate(TypeNum, TypeNumCounter0, TypeNumCounter), + counter.allocate(TypeNum, TypeNumCounter0, TypeNumCounter), !:Info = !.Info ^ type_counter := TypeNumCounter, - CellGroup1 = cell_type_group(TypeNum, map__init) + CellGroup1 = cell_type_group(TypeNum, map.init) ), MembersMap0 = CellGroup1 ^ cell_group_members, ModuleName = !.Info ^ module_name, - ( map__search(MembersMap0, Args, DataNamePrime) -> + ( map.search(MembersMap0, Args, DataNamePrime) -> DataName = DataNamePrime ; CellNumCounter0 = !.Info ^ cell_counter, - counter__allocate(CellNum, CellNumCounter0, CellNumCounter), + counter.allocate(CellNum, CellNumCounter0, CellNumCounter), !:Info = !.Info ^ cell_counter := CellNumCounter, DataName = common(CellNum, TypeNum), ( !.Info ^ common_data = yes, - map__set(MembersMap0, Args, DataName, MembersMap), + map.set(MembersMap0, Args, DataName, MembersMap), CellGroup = CellGroup1 ^ cell_group_members := MembersMap, - map__set(CellGroupMap0, CellType, CellGroup, CellGroupMap), + map.set(CellGroupMap0, CellType, CellGroup, CellGroupMap), !:Info = !.Info ^ cell_group_map := CellGroupMap ; !.Info ^ common_data = no @@ -294,7 +294,7 @@ do_add_static_cell(ArgsTypes, CellType, CellArgs, DataAddr, !Info) :- CellTypeAndValue = grouped_type_and_value(TypeNum, GroupedArgs) ), Cell = common_data(ModuleName, CellNum, CellTypeAndValue), - map__det_insert(Cells0, CellNum, Cell, Cells), + map.det_insert(Cells0, CellNum, Cell, Cells), !:Info = !.Info ^ cells := Cells ), DataAddr = data_addr(ModuleName, DataName). @@ -307,14 +307,14 @@ compute_cell_type(ArgsTypes, CellType, CellTypeAndValue) :- ArgsTypes = [FirstArg - FirstArgType | LaterArgsTypes], threshold_group_types(FirstArgType, [FirstArg], LaterArgsTypes, TypeGroups, TypeAndArgGroups), - OldLength = list__length(ArgsTypes), - NewLength = list__length(TypeAndArgGroups), + OldLength = list.length(ArgsTypes), + NewLength = list.length(TypeAndArgGroups), OldLength >= NewLength * 2 -> CellType = grouped_type(TypeGroups), CellTypeAndValue = grouped_args(TypeAndArgGroups) ; - CellType = plain_type(assoc_list__values(ArgsTypes)), + CellType = plain_type(assoc_list.values(ArgsTypes)), CellTypeAndValue = plain_args(ArgsTypes) ). @@ -351,8 +351,8 @@ make_arg_groups(Type, RevArgs, TypeGroup, TypeAndArgGroup) :- TypeGroup = Type - 1, TypeAndArgGroup = common_cell_ungrouped_arg(Type, Arg) ; - list__length(RevArgs, NumArgs), - list__reverse(RevArgs, Args), + list.length(RevArgs, NumArgs), + list.reverse(RevArgs, Args), TypeGroup = Type - NumArgs, TypeAndArgGroup = common_cell_grouped_args(Type, NumArgs, Args) ). @@ -360,11 +360,11 @@ make_arg_groups(Type, RevArgs, TypeGroup, TypeAndArgGroup) :- search_static_cell_offset(Info, DataAddr, Offset, Rval) :- DataAddr = data_addr(Info ^ module_name, DataName), DataName = common(CellNum, _), - map__search(Info ^ cells, CellNum, CommonData), + map.search(Info ^ cells, CellNum, CommonData), CommonData = common_data(_, _, TypeAndValue), ( TypeAndValue = plain_type_and_value(_, ArgsTypes), - list__index0_det(ArgsTypes, Offset, Rval - _) + list.index0_det(ArgsTypes, Offset, Rval - _) ; TypeAndValue = grouped_type_and_value(_, ArgGroups), offset_into_group(ArgGroups, Offset, Rval) @@ -379,7 +379,7 @@ offset_into_group([Group | Groups], Offset, Rval) :- ( Group = common_cell_grouped_args(_, NumRvalsInGroup, Rvals), ( Offset < NumRvalsInGroup -> - list__index0_det(Rvals, Offset, Rval) + list.index0_det(Rvals, Offset, Rval) ; offset_into_group(Groups, Offset - NumRvalsInGroup, Rval) ) @@ -393,7 +393,7 @@ offset_into_group([Group | Groups], Offset, Rval) :- ). get_static_cells(Info) = - list__map(wrap_common_data, map__values(Info ^ cells)). + list.map(wrap_common_data, map.values(Info ^ cells)). :- func wrap_common_data(common_data) = comp_gen_c_data. @@ -405,7 +405,7 @@ rval_type_as_arg(Rval, ExprnOpts, Type) :- :- pred natural_type(bool::in, rval::in, llds_type::out) is det. natural_type(UnboxFloat, Rval, Type) :- - llds__rval_type(Rval, Type0), + llds.rval_type(Rval, Type0), ( Type0 = float, UnboxFloat = no diff --git a/compiler/globals.m b/compiler/globals.m index 4e8329690..3b8055dac 100644 --- a/compiler/globals.m +++ b/compiler/globals.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -12,11 +12,11 @@ % This module exports the `globals' type and associated access predicates. % The globals type is used to collect together all the various data % that would be global variables in an imperative language. -% This global data is stored in the io__state. +% This global data is stored in the io.state. %-----------------------------------------------------------------------------% -:- module libs__globals. +:- module libs.globals. :- interface. :- import_module libs.options. @@ -130,58 +130,58 @@ % Access predicates for the `globals' structure % -:- pred globals__init(option_table::di, compilation_target::di, gc_method::di, +:- pred globals_init(option_table::di, compilation_target::di, gc_method::di, tags_method::di, termination_norm::di, termination_norm::di, - trace_level::di, trace_suppress_items::di, + trace_level::di, trace_suppress_items::di, maybe_thread_safe::di, globals::uo) is det. -:- pred globals__get_options(globals::in, option_table::out) is det. -:- pred globals__get_target(globals::in, compilation_target::out) is det. -:- pred globals__get_backend_foreign_languages(globals::in, +:- pred get_options(globals::in, option_table::out) is det. +:- pred get_target(globals::in, compilation_target::out) is det. +:- pred get_backend_foreign_languages(globals::in, list(foreign_language)::out) is det. -:- pred globals__get_gc_method(globals::in, gc_method::out) is det. -:- pred globals__get_tags_method(globals::in, tags_method::out) is det. -:- pred globals__get_termination_norm(globals::in, termination_norm::out) +:- pred get_gc_method(globals::in, gc_method::out) is det. +:- pred get_tags_method(globals::in, tags_method::out) is det. +:- pred get_termination_norm(globals::in, termination_norm::out) is det. -:- pred globals__get_termination2_norm(globals::in, termination_norm::out) +:- pred get_termination2_norm(globals::in, termination_norm::out) is det. -:- pred globals__get_trace_level(globals::in, trace_level::out) is det. -:- pred globals__get_trace_suppress(globals::in, trace_suppress_items::out) +:- pred get_trace_level(globals::in, trace_level::out) is det. +:- pred get_trace_suppress(globals::in, trace_suppress_items::out) is det. -:- pred globals__get_source_file_map(globals::in, maybe(source_file_map)::out) +:- pred get_source_file_map(globals::in, maybe(source_file_map)::out) is det. -:- pred globals__get_maybe_thread_safe(globals::in, maybe_thread_safe::out) +:- pred get_maybe_thread_safe(globals::in, maybe_thread_safe::out) is det. -:- pred globals__get_extra_error_info(globals::in, bool::out) is det. +:- pred get_extra_error_info(globals::in, bool::out) is det. -:- pred globals__set_option(option::in, option_data::in, +:- pred set_option(option::in, option_data::in, globals::in, globals::out) is det. -:- pred globals__set_options(option_table::in, globals::in, globals::out) +:- pred set_options(option_table::in, globals::in, globals::out) is det. -:- pred globals__set_gc_method(gc_method::in, globals::in, globals::out) +:- pred set_gc_method(gc_method::in, globals::in, globals::out) is det. -:- pred globals__set_tags_method(tags_method::in, globals::in, globals::out) +:- pred set_tags_method(tags_method::in, globals::in, globals::out) is det. -:- pred globals__set_trace_level(trace_level::in, globals::in, globals::out) +:- pred set_trace_level(trace_level::in, globals::in, globals::out) is det. -:- pred globals__set_trace_level_none(globals::in, globals::out) is det. -:- pred globals__set_source_file_map(maybe(source_file_map)::in, +:- pred set_trace_level_none(globals::in, globals::out) is det. +:- pred set_source_file_map(maybe(source_file_map)::in, globals::in, globals::out) is det. -:- pred globals__set_extra_error_info(bool::in, globals::in, globals::out) +:- pred set_extra_error_info(bool::in, globals::in, globals::out) is det. -:- pred globals__lookup_option(globals::in, option::in, option_data::out) +:- pred lookup_option(globals::in, option::in, option_data::out) is det. -:- pred globals__lookup_bool_option(globals, option, bool). -:- mode globals__lookup_bool_option(in, in, out) is det. -:- mode globals__lookup_bool_option(in, in, in) is semidet. % implied -:- pred globals__lookup_int_option(globals::in, option::in, int::out) is det. -:- pred globals__lookup_string_option(globals::in, option::in, string::out) +:- pred lookup_bool_option(globals, option, bool). +:- mode lookup_bool_option(in, in, out) is det. +:- mode lookup_bool_option(in, in, in) is semidet. % implied +:- pred lookup_int_option(globals::in, option::in, int::out) is det. +:- pred lookup_string_option(globals::in, option::in, string::out) is det. -:- pred globals__lookup_maybe_string_option(globals::in, option::in, +:- pred lookup_maybe_string_option(globals::in, option::in, maybe(string)::out) is det. -:- pred globals__lookup_accumulating_option(globals::in, option::in, +:- pred lookup_accumulating_option(globals::in, option::in, list(string)::out) is det. %-----------------------------------------------------------------------------% @@ -192,18 +192,18 @@ % Check if static code addresses are available in the % current grade of compilation. % -:- pred globals__have_static_code_addresses(globals::in, bool::out) is det. +:- pred have_static_code_addresses(globals::in, bool::out) is det. % Check if we should include variable information in the layout % structures of call return sites. % -:- pred globals__want_return_var_layouts(globals::in, bool::out) is det. +:- pred want_return_var_layouts(globals::in, bool::out) is det. - % globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst) + % imported_is_constant(NonLocalGotos, AsmLabels, IsConst) % figures out whether an imported label address is a constant. % This depends on how we treat labels. % -:- pred globals__imported_is_constant(bool::in, bool::in, bool::out) is det. +:- pred imported_is_constant(bool::in, bool::in, bool::out) is det. %-----------------------------------------------------------------------------% % @@ -211,67 +211,67 @@ % using io.set_globals and io.get_globals. % -:- pred globals__io_init(option_table::di, compilation_target::in, +:- pred globals_io_init(option_table::di, compilation_target::in, gc_method::in, tags_method::in, termination_norm::in, termination_norm::in, trace_level::in, trace_suppress_items::in, maybe_thread_safe::in, io::di, io::uo) is det. -:- pred globals__io_get_target(compilation_target::out, io::di, io::uo) is det. -:- pred globals__io_get_backend_foreign_languages(list(foreign_language)::out, +:- pred io_get_target(compilation_target::out, io::di, io::uo) is det. +:- pred io_get_backend_foreign_languages(list(foreign_language)::out, io::di, io::uo) is det. -:- pred globals__io_lookup_foreign_language_option(option::in, +:- pred io_lookup_foreign_language_option(option::in, foreign_language::out, io::di, io::uo) is det. -:- pred globals__io_get_gc_method(gc_method::out, io::di, io::uo) is det. -:- pred globals__io_get_tags_method(tags_method::out, io::di, io::uo) is det. -:- pred globals__io_get_termination_norm(termination_norm::out, +:- pred io_get_gc_method(gc_method::out, io::di, io::uo) is det. +:- pred io_get_tags_method(tags_method::out, io::di, io::uo) is det. +:- pred io_get_termination_norm(termination_norm::out, io::di, io::uo) is det. -:- pred globals__io_get_termination2_norm(termination_norm::out, +:- pred io_get_termination2_norm(termination_norm::out, io::di, io::uo) is det. -:- pred globals__io_get_trace_level(trace_level::out, io::di, io::uo) is det. +:- pred io_get_trace_level(trace_level::out, io::di, io::uo) is det. -:- pred globals__io_get_trace_suppress(trace_suppress_items::out, +:- pred io_get_trace_suppress(trace_suppress_items::out, io::di, io::uo) is det. -:- pred globals__io_get_maybe_thread_safe(maybe_thread_safe::out, +:- pred io_get_maybe_thread_safe(maybe_thread_safe::out, io::di, io::uo) is det. -:- pred globals__io_get_extra_error_info(bool::out, io::di, io::uo) is det. +:- pred io_get_extra_error_info(bool::out, io::di, io::uo) is det. -:- pred globals__io_get_globals(globals::out, io::di, io::uo) is det. +:- pred io_get_globals(globals::out, io::di, io::uo) is det. -:- pred globals__io_set_globals(globals::di, io::di, io::uo) is det. +:- pred io_set_globals(globals::di, io::di, io::uo) is det. -:- pred globals__io_set_option(option::in, option_data::in, +:- pred io_set_option(option::in, option_data::in, io::di, io::uo) is det. -:- pred globals__io_set_gc_method(gc_method::in, io::di, io::uo) is det. -:- pred globals__io_set_tags_method(tags_method::in, io::di, io::uo) is det. -:- pred globals__io_set_trace_level(trace_level::in, io::di, io::uo) is det. -:- pred globals__io_set_trace_level_none(io::di, io::uo) is det. -:- pred globals__io_set_extra_error_info(bool::in, io::di, io::uo) is det. +:- pred io_set_gc_method(gc_method::in, io::di, io::uo) is det. +:- pred io_set_tags_method(tags_method::in, io::di, io::uo) is det. +:- pred io_set_trace_level(trace_level::in, io::di, io::uo) is det. +:- pred io_set_trace_level_none(io::di, io::uo) is det. +:- pred io_set_extra_error_info(bool::in, io::di, io::uo) is det. -:- pred globals__io_lookup_option(option::in, option_data::out, +:- pred io_lookup_option(option::in, option_data::out, io::di, io::uo) is det. -:- pred globals__io_lookup_bool_option(option::in, bool::out, +:- pred io_lookup_bool_option(option::in, bool::out, io::di, io::uo) is det. -:- pred globals__io_lookup_int_option(option::in, int::out, +:- pred io_lookup_int_option(option::in, int::out, io::di, io::uo) is det. -:- pred globals__io_lookup_string_option(option::in, string::out, +:- pred io_lookup_string_option(option::in, string::out, io::di, io::uo) is det. -:- pred globals__io_lookup_maybe_string_option(option::in, maybe(string)::out, +:- pred io_lookup_maybe_string_option(option::in, maybe(string)::out, io::di, io::uo) is det. -:- pred globals__io_lookup_accumulating_option(option::in, list(string)::out, +:- pred io_lookup_accumulating_option(option::in, list(string)::out, io::di, io::uo) is det. -:- pred globals__io_printing_usage(bool::out, io::di, io::uo) is det. +:- pred io_printing_usage(bool::out, io::di, io::uo) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -287,7 +287,7 @@ %-----------------------------------------------------------------------------% convert_target(String, Target) :- - convert_target_2(string__to_lower(String), Target). + convert_target_2(string.to_lower(String), Target). :- pred convert_target_2(string::in, compilation_target::out) is semidet. @@ -297,7 +297,7 @@ convert_target_2("il", il). convert_target_2("c", c). convert_foreign_language(String, ForeignLanguage) :- - convert_foreign_language_2(string__to_lower(String), ForeignLanguage). + convert_foreign_language_2(string.to_lower(String), ForeignLanguage). :- pred convert_foreign_language_2(string::in, foreign_language::out) is semidet. @@ -376,29 +376,29 @@ gc_is_conservative(automatic) = no. % were enabled. ). -globals__init(Options, Target, GC_Method, TagsMethod, +globals_init(Options, Target, GC_Method, TagsMethod, TerminationNorm, Termination2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, globals(Options, Target, GC_Method, TagsMethod, - TerminationNorm, Termination2Norm, TraceLevel, TraceSuppress, + TerminationNorm, Termination2Norm, TraceLevel, TraceSuppress, no, no, MaybeThreadSafe, no)). -globals__get_options(Globals, Globals ^ options). -globals__get_target(Globals, Globals ^ target). -globals__get_gc_method(Globals, Globals ^ gc_method). -globals__get_tags_method(Globals, Globals ^ tags_method). -globals__get_termination_norm(Globals, Globals ^ termination_norm). -globals__get_termination2_norm(Globals, Globals ^ termination2_norm). -globals__get_trace_level(Globals, Globals ^ trace_level). -globals__get_trace_suppress(Globals, Globals ^ trace_suppress_items). -globals__get_source_file_map(Globals, Globals ^ source_file_map). -globals__get_maybe_thread_safe(Globals, Globals ^ maybe_thread_safe). -globals__get_extra_error_info(Globals, Globals ^ extra_error_info). +get_options(Globals, Globals ^ options). +get_target(Globals, Globals ^ target). +get_gc_method(Globals, Globals ^ gc_method). +get_tags_method(Globals, Globals ^ tags_method). +get_termination_norm(Globals, Globals ^ termination_norm). +get_termination2_norm(Globals, Globals ^ termination2_norm). +get_trace_level(Globals, Globals ^ trace_level). +get_trace_suppress(Globals, Globals ^ trace_suppress_items). +get_source_file_map(Globals, Globals ^ source_file_map). +get_maybe_thread_safe(Globals, Globals ^ maybe_thread_safe). +get_extra_error_info(Globals, Globals ^ extra_error_info). -globals__get_backend_foreign_languages(Globals, ForeignLangs) :- - globals__lookup_accumulating_option(Globals, backend_foreign_languages, +get_backend_foreign_languages(Globals, ForeignLangs) :- + lookup_accumulating_option(Globals, backend_foreign_languages, LangStrs), - ForeignLangs = list__map(func(String) = ForeignLang :- + ForeignLangs = list.map(func(String) = ForeignLang :- ( convert_foreign_language(String, ForeignLang0) -> ForeignLang = ForeignLang0 ; @@ -406,61 +406,61 @@ globals__get_backend_foreign_languages(Globals, ForeignLangs) :- "invalid foreign_language string") ), LangStrs). -globals__set_options(Options, Globals, Globals ^ options := Options). +set_options(Options, Globals, Globals ^ options := Options). -globals__set_option(Option, OptionData, !Globals) :- - globals__get_options(!.Globals, OptionTable0), - map__set(OptionTable0, Option, OptionData, OptionTable), - globals__set_options(OptionTable, !Globals). +set_option(Option, OptionData, !Globals) :- + get_options(!.Globals, OptionTable0), + map.set(OptionTable0, Option, OptionData, OptionTable), + set_options(OptionTable, !Globals). -globals__set_gc_method(GC_Method, Globals, Globals ^ gc_method := GC_Method). +set_gc_method(GC_Method, Globals, Globals ^ gc_method := GC_Method). -globals__set_tags_method(Tags_Method, Globals, +set_tags_method(Tags_Method, Globals, Globals ^ tags_method := Tags_Method). -globals__set_trace_level(TraceLevel, Globals, +set_trace_level(TraceLevel, Globals, Globals ^ trace_level := TraceLevel). -globals__set_trace_level_none(Globals, +set_trace_level_none(Globals, Globals ^ trace_level := trace_level_none). -globals__set_source_file_map(SourceFileMap, Globals, +set_source_file_map(SourceFileMap, Globals, Globals ^ source_file_map := SourceFileMap). -globals__lookup_option(Globals, Option, OptionData) :- - globals__get_options(Globals, OptionTable), - map__lookup(OptionTable, Option, OptionData). +lookup_option(Globals, Option, OptionData) :- + get_options(Globals, OptionTable), + map.lookup(OptionTable, Option, OptionData). -globals__set_extra_error_info(ExtraErrorInfo, Globals, +set_extra_error_info(ExtraErrorInfo, Globals, Globals ^ extra_error_info := ExtraErrorInfo). %-----------------------------------------------------------------------------% -globals__lookup_bool_option(Globals, Option, Value) :- - globals__lookup_option(Globals, Option, OptionData), +lookup_bool_option(Globals, Option, Value) :- + lookup_option(Globals, Option, OptionData), ( OptionData = bool(Bool) -> Value = Bool ; unexpected(this_file, "lookup_bool_option: invalid bool option") ). -globals__lookup_string_option(Globals, Option, Value) :- - globals__lookup_option(Globals, Option, OptionData), +lookup_string_option(Globals, Option, Value) :- + lookup_option(Globals, Option, OptionData), ( OptionData = string(String) -> Value = String ; unexpected(this_file, "lookup_string_option: invalid string option") ). -globals__lookup_int_option(Globals, Option, Value) :- - globals__lookup_option(Globals, Option, OptionData), +lookup_int_option(Globals, Option, Value) :- + lookup_option(Globals, Option, OptionData), ( OptionData = int(Int) -> Value = Int ; unexpected(this_file, "lookup_int_option: invalid int option") ). -globals__lookup_maybe_string_option(Globals, Option, Value) :- - globals__lookup_option(Globals, Option, OptionData), +lookup_maybe_string_option(Globals, Option, Value) :- + lookup_option(Globals, Option, OptionData), ( OptionData = maybe_string(MaybeString) -> Value = MaybeString ; @@ -468,8 +468,8 @@ globals__lookup_maybe_string_option(Globals, Option, Value) :- "lookup_string_option: invalid maybe_string option") ). -globals__lookup_accumulating_option(Globals, Option, Value) :- - globals__lookup_option(Globals, Option, OptionData), +lookup_accumulating_option(Globals, Option, Value) :- + lookup_option(Globals, Option, OptionData), ( OptionData = accumulating(Accumulating) -> Value = Accumulating ; @@ -479,29 +479,29 @@ globals__lookup_accumulating_option(Globals, Option, Value) :- %-----------------------------------------------------------------------------% -globals__have_static_code_addresses(Globals, IsConst) :- - globals__get_options(Globals, OptionTable), - globals__have_static_code_addresses_2(OptionTable, IsConst). +have_static_code_addresses(Globals, IsConst) :- + get_options(Globals, OptionTable), + have_static_code_addresses_2(OptionTable, IsConst). -:- pred globals__have_static_code_addresses_2(option_table::in, +:- pred have_static_code_addresses_2(option_table::in, bool::out) is det. -globals__have_static_code_addresses_2(OptionTable, IsConst) :- - getopt_io__lookup_bool_option(OptionTable, gcc_non_local_gotos, +have_static_code_addresses_2(OptionTable, IsConst) :- + getopt_io.lookup_bool_option(OptionTable, gcc_non_local_gotos, NonLocalGotos), - getopt_io__lookup_bool_option(OptionTable, asm_labels, AsmLabels), - globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst). + getopt_io.lookup_bool_option(OptionTable, asm_labels, AsmLabels), + imported_is_constant(NonLocalGotos, AsmLabels, IsConst). -globals__want_return_var_layouts(Globals, WantReturnLayouts) :- +want_return_var_layouts(Globals, WantReturnLayouts) :- % We need to generate layout info for call return labels % if we are using accurate gc or if the user wants uplevel printing. ( ( - globals__get_gc_method(Globals, GC_Method), + get_gc_method(Globals, GC_Method), GC_Method = accurate ; - globals__get_trace_level(Globals, TraceLevel), - globals__get_trace_suppress(Globals, TraceSuppress), + get_trace_level(Globals, TraceLevel), + get_trace_suppress(Globals, TraceSuppress), trace_needs_return_info(TraceLevel, TraceSuppress) = yes ) -> @@ -513,7 +513,7 @@ globals__want_return_var_layouts(Globals, WantReturnLayouts) :- % The logic of this function and how it is used to select the default % type_info method must agree with the code in runtime/typeinfo.h. -globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst) :- +imported_is_constant(NonLocalGotos, AsmLabels, IsConst) :- ( NonLocalGotos = yes, AsmLabels = no @@ -533,7 +533,7 @@ globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst) :- %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -globals__io_init(Options, Target, GC_Method, TagsMethod, TerminationNorm, +globals_io_init(Options, Target, GC_Method, TagsMethod, TerminationNorm, Termination2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, !IO) :- copy(Target, Target1), copy(GC_Method, GC_Method1), @@ -543,119 +543,119 @@ globals__io_init(Options, Target, GC_Method, TagsMethod, TerminationNorm, copy(TraceLevel, TraceLevel1), copy(TraceSuppress, TraceSuppress1), copy(MaybeThreadSafe, MaybeThreadSafe1), - globals__init(Options, Target1, GC_Method1, TagsMethod1, + globals_init(Options, Target1, GC_Method1, TagsMethod1, TerminationNorm1, Termination2Norm1, TraceLevel1, TraceSuppress1, MaybeThreadSafe1, Globals), - globals__io_set_globals(Globals, !IO). + io_set_globals(Globals, !IO). -globals__io_get_target(Target, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_target(Globals, Target). +io_get_target(Target, !IO) :- + io_get_globals(Globals, !IO), + get_target(Globals, Target). -globals__io_get_gc_method(GC_Method, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_gc_method(Globals, GC_Method). +io_get_gc_method(GC_Method, !IO) :- + io_get_globals(Globals, !IO), + get_gc_method(Globals, GC_Method). -globals__io_get_tags_method(Tags_Method, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_tags_method(Globals, Tags_Method). +io_get_tags_method(Tags_Method, !IO) :- + io_get_globals(Globals, !IO), + get_tags_method(Globals, Tags_Method). -globals__io_get_termination_norm(TerminationNorm, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_termination_norm(Globals, TerminationNorm). +io_get_termination_norm(TerminationNorm, !IO) :- + io_get_globals(Globals, !IO), + get_termination_norm(Globals, TerminationNorm). -globals__io_get_termination2_norm(Termination2Norm, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_termination2_norm(Globals, Termination2Norm). +io_get_termination2_norm(Termination2Norm, !IO) :- + io_get_globals(Globals, !IO), + get_termination2_norm(Globals, Termination2Norm). -globals__io_get_trace_level(TraceLevel, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_trace_level(Globals, TraceLevel). +io_get_trace_level(TraceLevel, !IO) :- + io_get_globals(Globals, !IO), + get_trace_level(Globals, TraceLevel). -globals__io_get_trace_suppress(TraceSuppress, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_trace_suppress(Globals, TraceSuppress). +io_get_trace_suppress(TraceSuppress, !IO) :- + io_get_globals(Globals, !IO), + get_trace_suppress(Globals, TraceSuppress). -globals__io_get_maybe_thread_safe(MaybeThreadSafe, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_maybe_thread_safe(Globals, MaybeThreadSafe). +io_get_maybe_thread_safe(MaybeThreadSafe, !IO) :- + io_get_globals(Globals, !IO), + get_maybe_thread_safe(Globals, MaybeThreadSafe). -globals__io_get_extra_error_info(ExtraErrorInfo, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_extra_error_info(Globals, ExtraErrorInfo). +io_get_extra_error_info(ExtraErrorInfo, !IO) :- + io_get_globals(Globals, !IO), + get_extra_error_info(Globals, ExtraErrorInfo). -globals__io_get_globals(Globals, !IO) :- - io__get_globals(UnivGlobals, !IO), +io_get_globals(Globals, !IO) :- + io.get_globals(UnivGlobals, !IO), ( univ_to_type(UnivGlobals, Globals0) -> Globals = Globals0 ; unexpected(this_file, "io_get_globals: univ_to_type failed") ). -globals__io_set_globals(Globals, !IO) :- +io_set_globals(Globals, !IO) :- type_to_univ(Globals, UnivGlobals), - io__set_globals(UnivGlobals, !IO). + io.set_globals(UnivGlobals, !IO). %-----------------------------------------------------------------------------% -globals__io_lookup_option(Option, OptionData, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_options(Globals, OptionTable), - map__lookup(OptionTable, Option, OptionData). +io_lookup_option(Option, OptionData, !IO) :- + io_get_globals(Globals, !IO), + get_options(Globals, OptionTable), + map.lookup(OptionTable, Option, OptionData). -globals__io_set_option(Option, OptionData, !IO) :- - globals__io_get_globals(Globals0, !IO), - globals__get_options(Globals0, OptionTable0), - map__set(OptionTable0, Option, OptionData, OptionTable), - globals__set_options(OptionTable, Globals0, Globals1), +io_set_option(Option, OptionData, !IO) :- + io_get_globals(Globals0, !IO), + get_options(Globals0, OptionTable0), + map.set(OptionTable0, Option, OptionData, OptionTable), + set_options(OptionTable, Globals0, Globals1), % XXX there is a bit of a design flaw with regard to - % uniqueness and io__set_globals + % uniqueness and io.set_globals unsafe_promise_unique(Globals1, Globals), - globals__io_set_globals(Globals, !IO). + io_set_globals(Globals, !IO). -globals__io_set_gc_method(GC_Method, !IO) :- - globals__io_get_globals(Globals0, !IO), - globals__set_gc_method(GC_Method, Globals0, Globals1), +io_set_gc_method(GC_Method, !IO) :- + io_get_globals(Globals0, !IO), + set_gc_method(GC_Method, Globals0, Globals1), unsafe_promise_unique(Globals1, Globals), % XXX there is a bit of a design flaw with regard to - % uniqueness and io__set_globals - globals__io_set_globals(Globals, !IO). + % uniqueness and io.set_globals + io_set_globals(Globals, !IO). -globals__io_set_tags_method(Tags_Method, !IO) :- - globals__io_get_globals(Globals0, !IO), - globals__set_tags_method(Tags_Method, Globals0, Globals1), +io_set_tags_method(Tags_Method, !IO) :- + io_get_globals(Globals0, !IO), + set_tags_method(Tags_Method, Globals0, Globals1), unsafe_promise_unique(Globals1, Globals), % XXX there is a bit of a design flaw with regard to - % uniqueness and io__set_globals - globals__io_set_globals(Globals, !IO). + % uniqueness and io.set_globals + io_set_globals(Globals, !IO). -globals__io_set_trace_level(TraceLevel, !IO) :- - globals__io_get_globals(Globals0, !IO), - globals__set_trace_level(TraceLevel, Globals0, Globals1), +io_set_trace_level(TraceLevel, !IO) :- + io_get_globals(Globals0, !IO), + set_trace_level(TraceLevel, Globals0, Globals1), unsafe_promise_unique(Globals1, Globals), % XXX there is a bit of a design flaw with regard to - % uniqueness and io__set_globals - globals__io_set_globals(Globals, !IO). + % uniqueness and io.set_globals + io_set_globals(Globals, !IO). -globals__io_set_extra_error_info(ExtraErrorInfo, !IO) :- +io_set_extra_error_info(ExtraErrorInfo, !IO) :- some [!Globals] ( - globals__io_get_globals(!:Globals, !IO), - globals__set_extra_error_info(ExtraErrorInfo, !Globals), + io_get_globals(!:Globals, !IO), + set_extra_error_info(ExtraErrorInfo, !Globals), unsafe_promise_unique(!Globals), % XXX there is a bit of a design flaw with regard to - % uniqueness and io__set_globals - globals__io_set_globals(!.Globals, !IO) + % uniqueness and io.set_globals + io_set_globals(!.Globals, !IO) ). % This predicate is needed because mercury_compile.m doesn't know % anything about type trace_level. -globals__io_set_trace_level_none(!IO) :- - globals__io_set_trace_level(trace_level_none, !IO). +io_set_trace_level_none(!IO) :- + io_set_trace_level(trace_level_none, !IO). %-----------------------------------------------------------------------------% -globals__io_lookup_foreign_language_option(Option, ForeignLang, !IO) :- - globals__io_lookup_string_option(Option, String, !IO), +io_lookup_foreign_language_option(Option, ForeignLang, !IO) :- + io_lookup_string_option(Option, String, !IO), ( convert_foreign_language(String, ForeignLang0) -> ForeignLang = ForeignLang0 ; @@ -663,44 +663,43 @@ globals__io_lookup_foreign_language_option(Option, ForeignLang, !IO) :- ++ "invalid foreign_language option") ). -globals__io_get_backend_foreign_languages(ForeignLangs, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__get_backend_foreign_languages(Globals, ForeignLangs). +io_get_backend_foreign_languages(ForeignLangs, !IO) :- + io_get_globals(Globals, !IO), + get_backend_foreign_languages(Globals, ForeignLangs). -globals__io_lookup_bool_option(Option, Value, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, Option, Value). +io_lookup_bool_option(Option, Value, !IO) :- + io_get_globals(Globals, !IO), + lookup_bool_option(Globals, Option, Value). -globals__io_lookup_int_option(Option, Value, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_int_option(Globals, Option, Value). +io_lookup_int_option(Option, Value, !IO) :- + io_get_globals(Globals, !IO), + lookup_int_option(Globals, Option, Value). -globals__io_lookup_string_option(Option, Value, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_string_option(Globals, Option, Value). +io_lookup_string_option(Option, Value, !IO) :- + io_get_globals(Globals, !IO), + lookup_string_option(Globals, Option, Value). -globals__io_lookup_maybe_string_option(Option, Value, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_maybe_string_option(Globals, Option, Value). +io_lookup_maybe_string_option(Option, Value, !IO) :- + io_get_globals(Globals, !IO), + lookup_maybe_string_option(Globals, Option, Value). -globals__io_lookup_accumulating_option(Option, Value, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_accumulating_option(Globals, Option, Value). +io_lookup_accumulating_option(Option, Value, !IO) :- + io_get_globals(Globals, !IO), + lookup_accumulating_option(Globals, Option, Value). %-----------------------------------------------------------------------------% -globals__io_printing_usage(AlreadyPrinted, !IO) :- - globals__io_get_globals(Globals0, !IO), +io_printing_usage(AlreadyPrinted, !IO) :- + io_get_globals(Globals0, !IO), AlreadyPrinted = Globals0 ^ have_printed_usage, Globals1 = Globals0 ^ have_printed_usage := yes, unsafe_promise_unique(Globals1, Globals), % XXX there is a bit of a design flaw with regard to - % uniqueness and io__set_globals - globals__io_set_globals(Globals, !IO). + % uniqueness and io.set_globals + io_set_globals(Globals, !IO). %-----------------------------------------------------------------------------% - :- func this_file = string. this_file = "globals.m". diff --git a/compiler/goal_form.m b/compiler/goal_form.m index 47ae8bbab..8406de7e3 100644 --- a/compiler/goal_form.m +++ b/compiler/goal_form.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__goal_form. +:- module hlds.goal_form. :- interface. :- import_module hlds.hlds_goal. @@ -345,13 +345,13 @@ goal_cannot_loop_aux(MaybeModuleInfo, Goal) :- is semidet. goal_cannot_loop_expr(MaybeModuleInfo, conj(plain_conj, Goals)) :- - list__member(Goal, Goals) => + list.member(Goal, Goals) => goal_cannot_loop_aux(MaybeModuleInfo, Goal). goal_cannot_loop_expr(MaybeModuleInfo, disj(Goals)) :- - list__member(Goal, Goals) => + list.member(Goal, Goals) => goal_cannot_loop_aux(MaybeModuleInfo, Goal). goal_cannot_loop_expr(MaybeModuleInfo, switch(_Var, _Category, Cases)) :- - list__member(Case, Cases) => + list.member(Case, Cases) => ( Case = case(_, Goal), goal_cannot_loop_aux(MaybeModuleInfo, Goal) @@ -700,8 +700,8 @@ count_recursive_calls_2(if_then_else(_, Cond, Then, Else), PredId, ProcId, count_recursive_calls(Else, PredId, ProcId, EMin, EMax), CTMin = CMin + TMin, CTMax = CMax + TMax, - int__min(CTMin, EMin, Min), - int__max(CTMax, EMax, Max). + int.min(CTMin, EMin, Min), + int.max(CTMax, EMax, Max). count_recursive_calls_2(shorthand(_), _, _, _, _) :- % these should have been expanded out by now unexpected(this_file, "count_recursive_calls_2: unexpected shorthand"). @@ -730,8 +730,8 @@ count_recursive_calls_disj([Goal | Goals], PredId, ProcId, Min, Max) :- Goals = [_ | _], count_recursive_calls(Goal, PredId, ProcId, Min0, Max0), count_recursive_calls_disj(Goals, PredId, ProcId, Min1, Max1), - int__min(Min0, Min1, Min), - int__max(Max0, Max1, Max) + int.min(Min0, Min1, Min), + int.max(Max0, Max1, Max) ). :- pred count_recursive_calls_cases(list(case)::in, pred_id::in, proc_id::in, @@ -748,8 +748,8 @@ count_recursive_calls_cases([case(_, Goal) | Cases], PredId, ProcId, Cases = [_ | _], count_recursive_calls(Goal, PredId, ProcId, Min0, Max0), count_recursive_calls_cases(Cases, PredId, ProcId, Min1, Max1), - int__min(Min0, Min1, Min), - int__max(Max0, Max1, Max) + int.min(Min0, Min1, Min), + int.max(Max0, Max1, Max) ). %-----------------------------------------------------------------------------% % diff --git a/compiler/goal_path.m b/compiler/goal_path.m index 5c072b138..f9e4e2177 100644 --- a/compiler/goal_path.m +++ b/compiler/goal_path.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__goal_path. +:- module check_hlds.goal_path. :- interface. :- import_module hlds.hlds_goal. @@ -32,7 +32,7 @@ % be recalculated anywhere between these two passes. See the XXX % comment near the declaration of constraint_id. % -:- pred goal_path__fill_slots(module_info::in, proc_info::in, proc_info::out) +:- pred fill_goal_path_slots(module_info::in, proc_info::in, proc_info::out) is det. % Fill in the goal_paths for goals in the clauses_info of the predicate. @@ -44,10 +44,10 @@ % path is always equivalent to its instantiatedness at the parent goal % path. % -:- pred goal_path__fill_slots_in_clauses(module_info::in, bool::in, +:- pred fill_goal_path_slots_in_clauses(module_info::in, bool::in, pred_info::in, pred_info::out) is det. -:- pred goal_path__fill_slots_in_goal(hlds_goal::in, vartypes::in, +:- pred fill_goal_path_slots_in_goal(hlds_goal::in, vartypes::in, module_info::in, hlds_goal::out) is det. %-----------------------------------------------------------------------------% @@ -76,18 +76,18 @@ omit_mode_equiv_prefix :: bool ). -goal_path__fill_slots(ModuleInfo, !Proc) :- +fill_goal_path_slots(ModuleInfo, !Proc) :- proc_info_goal(!.Proc, Goal0), proc_info_vartypes(!.Proc, VarTypes), - goal_path__fill_slots_in_goal(Goal0, VarTypes, ModuleInfo, Goal), + fill_goal_path_slots_in_goal(Goal0, VarTypes, ModuleInfo, Goal), proc_info_set_goal(Goal, !Proc). -goal_path__fill_slots_in_clauses(ModuleInfo, OmitModeEquivPrefix, !PredInfo) :- +fill_goal_path_slots_in_clauses(ModuleInfo, OmitModeEquivPrefix, !PredInfo) :- pred_info_clauses_info(!.PredInfo, ClausesInfo0), clauses_info_clauses_only(ClausesInfo0, Clauses0), clauses_info_vartypes(ClausesInfo0, VarTypes), SlotInfo = slot_info(VarTypes, ModuleInfo, OmitModeEquivPrefix), - list__map_foldl(fill_slots_in_clause(SlotInfo), Clauses0, Clauses, 1, _), + list.map_foldl(fill_slots_in_clause(SlotInfo), Clauses0, Clauses, 1, _), clauses_info_set_clauses(Clauses, ClausesInfo0, ClausesInfo), pred_info_set_clauses_info(ClausesInfo, !PredInfo). @@ -99,7 +99,7 @@ fill_slots_in_clause(SlotInfo, Clause0, Clause, ClauseNum, ClauseNum + 1) :- fill_goal_slots([disj(ClauseNum)], SlotInfo, Goal0, Goal), Clause = clause(ProcIds, Goal, Lang, Context). -goal_path__fill_slots_in_goal(Goal0, VarTypes, ModuleInfo, Goal) :- +fill_goal_path_slots_in_goal(Goal0, VarTypes, ModuleInfo, Goal) :- SlotInfo = slot_info(VarTypes, ModuleInfo, no), fill_goal_slots([], SlotInfo, Goal0, Goal). @@ -110,7 +110,7 @@ fill_goal_slots(Path0, SlotInfo, Expr0 - Info0, Expr - Info) :- OmitModeEquivPrefix = SlotInfo ^ omit_mode_equiv_prefix, ( OmitModeEquivPrefix = yes, - list__takewhile(mode_equiv_step, Path0, _, Path) + list.takewhile(mode_equiv_step, Path0, _, Path) ; OmitModeEquivPrefix = no, Path = Path0 @@ -143,7 +143,7 @@ fill_expr_slots(GoalInfo, Path0, SlotInfo, Goal0, Goal) :- Goal0 = switch(Var, CanFail, Cases0), VarTypes = SlotInfo ^ vartypes, ModuleInfo = SlotInfo ^ module_info, - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ( switch_type_num_functors(ModuleInfo, Type, NumFunctors) -> NumCases = NumFunctors ; diff --git a/compiler/goal_store.m b/compiler/goal_store.m index e5e3a8de8..c854ac8c0 100644 --- a/compiler/goal_store.m +++ b/compiler/goal_store.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2000, 2003, 2005 The University of Melbourne. +% Copyright (C) 2000, 2003, 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -10,12 +10,12 @@ % Main author: petdr. % % Define a type goal_store(Key) which allows a hlds_goal to be stored in a -% dictionary like structure. However there some operations on this dictionary -% which are specific to hlds_goals. +% dictionary like structure. However, there some operations on this dictionary +% that are specific to hlds_goals. % %-----------------------------------------------------------------------------% -:- module transform_hlds__goal_store. +:- module transform_hlds.goal_store. :- interface. :- import_module hlds.hlds_goal. @@ -32,18 +32,18 @@ :- type stored_goal == pair(hlds_goal, instmap). :- type goal_store(T). -:- pred goal_store__init(goal_store(T)::out) is det. -:- func goal_store__init = goal_store(T). +:- pred goal_store_init(goal_store(T)::out) is det. +:- func goal_store_init = goal_store(T). -:- pred goal_store__det_insert(T::in, stored_goal::in, +:- pred goal_store_det_insert(T::in, stored_goal::in, goal_store(T)::in, goal_store(T)::out) is det. -:- pred goal_store__lookup(goal_store(T)::in, T::in, stored_goal::out) is det. +:- pred goal_store_lookup(goal_store(T)::in, T::in, stored_goal::out) is det. -:- pred goal_store__member(goal_store(T)::in, T::out, stored_goal::out) +:- pred goal_store_member(goal_store(T)::in, T::out, stored_goal::out) is nondet. -:- pred goal_store__all_ancestors(goal_store(T)::in, T::in, vartypes::in, +:- pred goal_store_all_ancestors(goal_store(T)::in, T::in, vartypes::in, module_info::in, bool::in, set(T)::out) is det. %-----------------------------------------------------------------------------% @@ -59,48 +59,46 @@ %-----------------------------------------------------------------------------% -:- type goal_store(T) == map__map(T, stored_goal). +:- type goal_store(T) == map.map(T, stored_goal). %-----------------------------------------------------------------------------% -goal_store__init(GS) :- - map__init(GS). +goal_store_init(GS) :- + map.init(GS). -goal_store__init = GS :- - goal_store__init(GS). +goal_store_init = GS :- + goal_store_init(GS). -goal_store__det_insert(Id, Goal, GS0, GS) :- - map__det_insert(GS0, Id, Goal, GS). +goal_store_det_insert(Id, Goal, GS0, GS) :- + map.det_insert(GS0, Id, Goal, GS). -goal_store__lookup(GS, Id, Goal) :- - map__lookup(GS, Id, Goal). +goal_store_lookup(GS, Id, Goal) :- + map.lookup(GS, Id, Goal). -goal_store__member(GoalStore, Key, Goal) :- - map__member(GoalStore, Key, Goal). +goal_store_member(GoalStore, Key, Goal) :- + map.member(GoalStore, Key, Goal). -all_ancestors(GoalStore, StartId, VarTypes, ModuleInfo, FullyStrict, +goal_store_all_ancestors(GoalStore, StartId, VarTypes, ModuleInfo, FullyStrict, AncestorIds) :- - AncestorIds = ancestors_2(GoalStore, [StartId], set__init, + AncestorIds = ancestors_2(GoalStore, [StartId], set.init, VarTypes, ModuleInfo, FullyStrict). :- func ancestors_2(goal_store(T), list(T), set(T), vartypes, module_info, bool) = set(T). ancestors_2(_GoalStore, [], _VisitedIds, _VarTypes, _ModuleInfo, _FullyStrict) - = set__init. + = set.init. ancestors_2(GoalStore, [Id|Ids], VisitedIds, VarTypes, ModuleInfo, FullyStrict) = AncestorIds :- - ( - set__member(Id, VisitedIds) - -> + ( set.member(Id, VisitedIds) -> AncestorIds = ancestors_2(GoalStore, Ids, VisitedIds, VarTypes, ModuleInfo, FullyStrict) ; Ancestors = direct_ancestors(GoalStore, Id, VarTypes, ModuleInfo, FullyStrict), - AncestorIds = set__list_to_set(Ancestors) `union` + AncestorIds = set.list_to_set(Ancestors) `union` ancestors_2(GoalStore, Ancestors `append` Ids, - set__insert(VisitedIds, Id), VarTypes, ModuleInfo, FullyStrict) + set.insert(VisitedIds, Id), VarTypes, ModuleInfo, FullyStrict) ). :- func direct_ancestors(goal_store(T), T, vartypes, module_info, bool) @@ -116,10 +114,10 @@ direct_ancestors(GoalStore, StartId, VarTypes, ModuleInfo, FullyStrict) direct_ancestor(GoalStore, StartId, VarTypes, ModuleInfo, FullyStrict, EarlierId) :- - goal_store__lookup(GoalStore, StartId, LaterGoal - LaterInstMap), - goal_store__member(GoalStore, EarlierId, EarlierGoal - EarlierInstMap), + goal_store_lookup(GoalStore, StartId, LaterGoal - LaterInstMap), + goal_store_member(GoalStore, EarlierId, EarlierGoal - EarlierInstMap), compare((<), EarlierId, StartId), - not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, + not goal_util.can_reorder_goals(ModuleInfo, VarTypes, FullyStrict, EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal). %-----------------------------------------------------------------------------% diff --git a/compiler/goal_util.m b/compiler/goal_util.m index 95600e88a..bfbd3e934 100644 --- a/compiler/goal_util.m +++ b/compiler/goal_util.m @@ -308,7 +308,7 @@ :- pred generate_simple_call(module_name::in, string::in, pred_or_func::in, mode_no::in, determinism::in, prog_vars::in, list(goal_feature)::in, assoc_list(prog_var, mer_inst)::in, - module_info::in, term__context::in, hlds_goal::out) is det. + module_info::in, term.context::in, hlds_goal::out) is det. % generate_foreign_proc(ModuleName, ProcName, PredOrFunc, % ModeNo, Detism, Attributes, Args, ExtraArgs, PrefixCode, Code, @@ -329,7 +329,7 @@ pragma_foreign_proc_attributes::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, string::in, string::in, list(goal_feature)::in, assoc_list(prog_var, mer_inst)::in, - module_info::in, term__context::in, hlds_goal::out) is det. + module_info::in, term.context::in, hlds_goal::out) is det. % Generate a cast goal. The input and output insts are just ground. % @@ -377,16 +377,16 @@ update_instmap(_Goal0 - GoalInfo0, !InstMap) :- goal_info_get_instmap_delta(GoalInfo0, DeltaInstMap), - instmap__apply_instmap_delta(!.InstMap, DeltaInstMap, !:InstMap). + instmap.apply_instmap_delta(!.InstMap, DeltaInstMap, !:InstMap). %-----------------------------------------------------------------------------% create_renaming(OrigVars, InstMapDelta, !VarTypes, !VarSet, Unifies, NewVars, Renaming) :- create_renaming_2(OrigVars, InstMapDelta, !VarTypes, !VarSet, - [], RevUnifies, [], RevNewVars, map__init, Renaming), - list__reverse(RevNewVars, NewVars), - list__reverse(RevUnifies, Unifies). + [], RevUnifies, [], RevNewVars, map.init, Renaming), + list.reverse(RevNewVars, NewVars), + list.reverse(RevUnifies, Unifies). :- pred create_renaming_2(prog_vars::in, instmap_delta::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, @@ -397,9 +397,9 @@ create_renaming_2([], _, !VarTypes, !VarSet, !RevUnifies, !RevNewVars, !Renaming). create_renaming_2([OrigVar | OrigVars], InstMapDelta, !VarTypes, !VarSet, !RevUnifies, !RevNewVars, !Renaming) :- - svvarset__new_var(NewVar, !VarSet), - map__lookup(!.VarTypes, OrigVar, Type), - svmap__det_insert(NewVar, Type, !VarTypes), + svvarset.new_var(NewVar, !VarSet), + map.lookup(!.VarTypes, OrigVar, Type), + svmap.det_insert(NewVar, Type, !VarTypes), ( instmap_delta_search_var(InstMapDelta, OrigVar, DeltaInst) -> NewInst = DeltaInst ; @@ -409,13 +409,13 @@ create_renaming_2([OrigVar | OrigVars], InstMapDelta, !VarTypes, !VarSet, UnifyInfo = assign(OrigVar, NewVar), UnifyContext = unify_context(explicit, []), GoalExpr = unify(OrigVar, var(NewVar), Mode, UnifyInfo, UnifyContext), - set__list_to_set([OrigVar, NewVar], NonLocals), + set.list_to_set([OrigVar, NewVar], NonLocals), instmap_delta_from_assoc_list([OrigVar - NewInst], UnifyInstMapDelta), goal_info_init(NonLocals, UnifyInstMapDelta, det, purity_pure, - term__context_init, GoalInfo), + term.context_init, GoalInfo), Goal = GoalExpr - GoalInfo, !:RevUnifies = [Goal | !.RevUnifies], - svmap__det_insert(OrigVar, NewVar, !Renaming), + svmap.det_insert(OrigVar, NewVar, !Renaming), !:RevNewVars = [NewVar | !.RevNewVars], create_renaming_2(OrigVars, InstMapDelta, !VarTypes, !VarSet, !RevUnifies, !RevNewVars, !Renaming). @@ -425,18 +425,18 @@ create_renaming_2([OrigVar | OrigVars], InstMapDelta, !VarTypes, !VarSet, create_variables([], _OldVarNames, _OldVarTypes, !Varset, !VarTypes, !Subn). create_variables([V | Vs], OldVarNames, OldVarTypes, !Varset, !VarTypes, !Subn) :- - ( map__contains(!.Subn, V) -> + ( map.contains(!.Subn, V) -> true ; - svvarset__new_var(NV, !Varset), - ( varset__search_name(OldVarNames, V, Name) -> - svvarset__name_var(NV, Name, !Varset) + svvarset.new_var(NV, !Varset), + ( varset.search_name(OldVarNames, V, Name) -> + svvarset.name_var(NV, Name, !Varset) ; true ), - svmap__det_insert(V, NV, !Subn), - ( map__search(OldVarTypes, V, VT) -> - svmap__set(NV, VT, !VarTypes) + svmap.det_insert(V, NV, !Subn), + ( map.search(OldVarTypes, V, VT) -> + svmap.set(NV, VT, !VarTypes) ; true ) @@ -450,7 +450,7 @@ create_variables([V | Vs], OldVarNames, OldVarTypes, !Varset, !VarTypes, init_subn([], !Subn). init_subn([A - H | Vs], !Subn) :- - svmap__set(H, A, !Subn), + svmap.set(H, A, !Subn), init_subn(Vs, !Subn). %-----------------------------------------------------------------------------% @@ -469,7 +469,7 @@ rename_var_list(Must, Subn, [V | Vs], [N | Ns]) :- rename_var_list(Must, Subn, Vs, Ns). rename_var(Must, Subn, V, N) :- - ( map__search(Subn, V, N0) -> + ( map.search(Subn, V, N0) -> N = N0 ; ( @@ -477,8 +477,8 @@ rename_var(Must, Subn, V, N) :- N = V ; Must = yes, - term__var_to_int(V, VInt), - string__format("rename_var: no substitute for var %i", [i(VInt)], + term.var_to_int(V, VInt), + string.format("rename_var: no substitute for var %i", [i(VInt)], Msg), unexpected(this_file, Msg) ) @@ -720,9 +720,9 @@ rename_generic_call(_, _, cast(CastType), cast(CastType)). map(prog_var, T)::in, map(prog_var, T)::out) is det. rename_var_maps(Must, Subn, Map0, Map) :- - map__to_assoc_list(Map0, AssocList0), + map.to_assoc_list(Map0, AssocList0), rename_var_maps_2(Must, Subn, AssocList0, AssocList), - map__from_assoc_list(AssocList, Map). + map.from_assoc_list(AssocList, Map). :- pred rename_var_maps_2(bool::in, map(var(V), var(V))::in, assoc_list(var(V), T)::in, assoc_list(var(V), T)::out) is det. @@ -750,9 +750,9 @@ rename_vars_in_goal_info(Must, Subn, !GoalInfo) :- %-----------------------------------------------------------------------------% rename_vars_in_var_set(Must, Subn, Vars0, Vars) :- - set__to_sorted_list(Vars0, VarsList0), + set.to_sorted_list(Vars0, VarsList0), rename_var_list(Must, Subn, VarsList0, VarsList), - set__list_to_set(VarsList, Vars). + set.list_to_set(VarsList, Vars). :- pred rename_vars_in_code_gen_info(bool::in, prog_var_renaming::in, @@ -772,16 +772,16 @@ rename_vars_in_code_gen_info(Must, Subn, %-----------------------------------------------------------------------------% goal_vars(Goal - _GoalInfo, Set) :- - goal_vars_2(Goal, set__init, Set). + goal_vars_2(Goal, set.init, Set). :- pred goal_vars_2(hlds_goal_expr::in, set(prog_var)::in, set(prog_var)::out) is det. goal_vars_2(unify(Var, RHS, _, Unif, _), !Set) :- - svset__insert(Var, !Set), + svset.insert(Var, !Set), ( Unif = construct(_, _, _, _, CellToReuse, _, _) -> ( CellToReuse = reuse_cell(cell_to_reuse(Var, _, _)) -> - svset__insert(Var, !Set) + svset.insert(Var, !Set) ; true ) @@ -792,11 +792,11 @@ goal_vars_2(unify(Var, RHS, _, Unif, _), !Set) :- goal_vars_2(generic_call(GenericCall, ArgVars, _, _), !Set) :- generic_call_vars(GenericCall, Vars0), - svset__insert_list(Vars0, !Set), - svset__insert_list(ArgVars, !Set). + svset.insert_list(Vars0, !Set), + svset.insert_list(ArgVars, !Set). goal_vars_2(call(_, _, ArgVars, _, _, _), !Set) :- - svset__insert_list(ArgVars, !Set). + svset.insert_list(ArgVars, !Set). goal_vars_2(conj(_, Goals), !Set) :- goals_goal_vars(Goals, !Set). @@ -805,25 +805,25 @@ goal_vars_2(disj(Goals), !Set) :- goals_goal_vars(Goals, !Set). goal_vars_2(switch(Var, _Det, Cases), !Set) :- - svset__insert(Var, !Set), + svset.insert(Var, !Set), cases_goal_vars(Cases, !Set). goal_vars_2(scope(Reason, Goal - _), !Set) :- ( Reason = exist_quant(Vars), - svset__insert_list(Vars, !Set) + svset.insert_list(Vars, !Set) ; Reason = promise_purity(_, _) ; Reason = promise_solutions(Vars, _), - svset__insert_list(Vars, !Set) + svset.insert_list(Vars, !Set) ; Reason = barrier(_) ; Reason = commit(_) ; Reason = from_ground_term(Var), - set__insert(!.Set, Var, !:Set) + set.insert(!.Set, Var, !:Set) ), goal_vars_2(Goal, !Set). @@ -831,15 +831,15 @@ goal_vars_2(not(Goal - _GoalInfo), !Set) :- goal_vars_2(Goal, !Set). goal_vars_2(if_then_else(Vars, A - _, B - _, C - _), !Set) :- - set__insert_list(!.Set, Vars, !:Set), + set.insert_list(!.Set, Vars, !:Set), goal_vars_2(A, !Set), goal_vars_2(B, !Set), goal_vars_2(C, !Set). goal_vars_2(foreign_proc(_, _, _, Args, ExtraArgs, _), !Set) :- - ArgVars = list__map(foreign_arg_var, Args), - ExtraVars = list__map(foreign_arg_var, ExtraArgs), - svset__insert_list(list__append(ArgVars, ExtraVars), !Set). + ArgVars = list.map(foreign_arg_var, Args), + ExtraVars = list.map(foreign_arg_var, ExtraArgs), + svset.insert_list(list.append(ArgVars, ExtraVars), !Set). goal_vars_2(shorthand(ShorthandGoal), !Set) :- goal_vars_2_shorthand(ShorthandGoal, !Set). @@ -869,14 +869,14 @@ cases_goal_vars([case(_, Goal - _) | Cases], !Set) :- rhs_goal_vars(RHS, !Set) :- RHS = var(X), - svset__insert(X, !Set). + svset.insert(X, !Set). rhs_goal_vars(RHS, !Set) :- RHS = functor(_Functor, _, ArgVars), - svset__insert_list(ArgVars, !Set). + svset.insert_list(ArgVars, !Set). rhs_goal_vars(RHS, !Set) :- RHS = lambda_goal(_, _, _, NonLocals, LambdaVars, _, _, Goal - _), - svset__insert_list(NonLocals, !Set), - svset__insert_list(LambdaVars, !Set), + svset.insert_list(NonLocals, !Set), + svset.insert_list(LambdaVars, !Set), goal_vars_2(Goal, !Set). generic_call_vars(higher_order(Var, _, _, _), [Var]). @@ -888,7 +888,7 @@ generic_call_vars(cast(_), []). attach_features_to_all_goals(Features, Goal0, Goal) :- Goal0 = GoalExpr0 - GoalInfo0, attach_features_goal_expr(Features, GoalExpr0, GoalExpr), - list__foldl(goal_info_add_feature, Features, GoalInfo0, GoalInfo), + list.foldl(goal_info_add_feature, Features, GoalInfo0, GoalInfo), Goal = GoalExpr - GoalInfo. :- pred attach_features_to_case(list(goal_feature)::in, @@ -903,15 +903,15 @@ attach_features_to_case(Features, case(ConsId, Goal0), case(ConsId, Goal)) :- attach_features_goal_expr(Features, GoalExpr0, GoalExpr) :- ( GoalExpr0 = conj(ConjType, Goals0), - list__map(attach_features_to_all_goals(Features), Goals0, Goals), + list.map(attach_features_to_all_goals(Features), Goals0, Goals), GoalExpr = conj(ConjType, Goals) ; GoalExpr0 = disj(Goals0), - list__map(attach_features_to_all_goals(Features), Goals0, Goals), + list.map(attach_features_to_all_goals(Features), Goals0, Goals), GoalExpr = disj(Goals) ; GoalExpr0 = switch(Var, CanFail, Cases0), - list__map(attach_features_to_case(Features), Cases0, Cases), + list.map(attach_features_to_case(Features), Cases0, Cases), GoalExpr = switch(Var, CanFail, Cases) ; GoalExpr0 = if_then_else(Vars, Cond0, Then0, Else0), @@ -953,11 +953,11 @@ extra_nonlocal_typeinfos(RttiVarMaps, VarTypes, ExistQVars, % existentially quantified or type vars that appear in the % type of a non-local prog_var. % - set__to_sorted_list(NonLocals, NonLocalsList), - map__apply_to_list(NonLocalsList, VarTypes, NonLocalsTypes), - prog_type__vars_list(NonLocalsTypes, NonLocalTypeVarsList0), - list__append(ExistQVars, NonLocalTypeVarsList0, NonLocalTypeVarsList), - set__list_to_set(NonLocalTypeVarsList, NonLocalTypeVars), + set.to_sorted_list(NonLocals, NonLocalsList), + map.apply_to_list(NonLocalsList, VarTypes, NonLocalsTypes), + prog_type.vars_list(NonLocalsTypes, NonLocalTypeVarsList0), + list.append(ExistQVars, NonLocalTypeVarsList0, NonLocalTypeVarsList), + set.list_to_set(NonLocalTypeVarsList, NonLocalTypeVars), % Find all the type_infos that are non-local, that is, % type_infos for type vars that are non-local in the above @@ -967,7 +967,7 @@ extra_nonlocal_typeinfos(RttiVarMaps, VarTypes, ExistQVars, rtti_lookup_type_info_locn(RttiVarMaps, TypeVar, Locn), type_info_locn_var(Locn, ProgVar) ), - NonLocalTypeInfoVars = set__map(TypeVarToProgVar, NonLocalTypeVars), + NonLocalTypeInfoVars = set.map(TypeVarToProgVar, NonLocalTypeVars), % Find all the typeclass_infos that are non-local. These % include all typeclass_infos that constrain a type variable @@ -978,16 +978,16 @@ extra_nonlocal_typeinfos(RttiVarMaps, VarTypes, ExistQVars, % Search through all arguments of all constraints % that the goal could have used. rtti_varmaps_reusable_constraints(RttiVarMaps, Constraints), - list__member(Constraint, Constraints), + list.member(Constraint, Constraints), Constraint = constraint(_Name, ArgTypes), type_list_contains_var(ArgTypes, TypeVar), - set__member(TypeVar, NonLocalTypeVars), + set.member(TypeVar, NonLocalTypeVars), % We found a constraint that is non-local. Include the variable % holding its typeclass_info. rtti_lookup_typeclass_info_var(RttiVarMaps, Constraint, Var) ), NonLocalTypeClassInfoVars), - NonLocalTypeInfos = set__union(NonLocalTypeInfoVars, + NonLocalTypeInfos = set.union(NonLocalTypeInfoVars, NonLocalTypeClassInfoVars). %-----------------------------------------------------------------------------% @@ -1008,7 +1008,7 @@ goals_size([Goal | Goals], Size) :- Size = Size1 + Size2. clause_list_size(Clauses, GoalSize) :- - list__foldl(clause_size_increment, Clauses, 0, GoalSize0), + list.foldl(clause_size_increment, Clauses, 0, GoalSize0), ( Clauses = [_] -> GoalSize = GoalSize0 ; @@ -1203,7 +1203,7 @@ goal_expr_contains_reconstruction(conj(_ConjType, Goals)) :- goal_expr_contains_reconstruction(disj(Goals)) :- goals_contain_reconstruction(Goals). goal_expr_contains_reconstruction(switch(_, _, Cases)) :- - list__member(Case, Cases), + list.member(Case, Cases), Case = case(_, Goal), goal_contains_reconstruction(Goal). goal_expr_contains_reconstruction(if_then_else(_, Cond, Then, Else)) :- @@ -1219,7 +1219,7 @@ goal_expr_contains_reconstruction(unify(_, _, _, Unify, _)) :- :- pred goals_contain_reconstruction(hlds_goals::in) is semidet. goals_contain_reconstruction(Goals) :- - list__member(Goal, Goals), + list.member(Goal, Goals), goal_contains_reconstruction(Goal). %-----------------------------------------------------------------------------% @@ -1237,11 +1237,11 @@ direct_subgoal(if_then_else(_, If, Then, Else), Goal) :- ; Goal = Else ). direct_subgoal(conj(_ConjType, ConjList), Goal) :- - list__member(Goal, ConjList). + list.member(Goal, ConjList). direct_subgoal(disj(DisjList), Goal) :- - list__member(Goal, DisjList). + list.member(Goal, DisjList). direct_subgoal(switch(_, _, CaseList), Goal) :- - list__member(Case, CaseList), + list.member(Case, CaseList), Case = case(_, Goal). %-----------------------------------------------------------------------------% @@ -1257,11 +1257,11 @@ switch_to_disjunction(Var, [case(ConsId, Goal0) | Cases], InstMap, case_to_disjunct(Var, ConsId, CaseGoal, InstMap, Disjunct, !VarSet, !VarTypes, !ModuleInfo) :- ConsArity = cons_id_arity(ConsId), - svvarset__new_vars(ConsArity, ArgVars, !VarSet), - map__lookup(!.VarTypes, Var, VarType), - type_util__get_cons_id_arg_types(!.ModuleInfo, VarType, ConsId, ArgTypes), - svmap__det_insert_from_corresponding_lists(ArgVars, ArgTypes, !VarTypes), - instmap__lookup_var(InstMap, Var, Inst0), + svvarset.new_vars(ConsArity, ArgVars, !VarSet), + map.lookup(!.VarTypes, Var, VarType), + type_util.get_cons_id_arg_types(!.ModuleInfo, VarType, ConsId, ArgTypes), + svmap.det_insert_from_corresponding_lists(ArgVars, ArgTypes, !VarTypes), + instmap.lookup_var(InstMap, Var, Inst0), ( inst_expand(!.ModuleInfo, Inst0, Inst1), get_arg_insts(Inst1, ConsId, ConsArity, ArgInsts1) @@ -1273,14 +1273,14 @@ case_to_disjunct(Var, ConsId, CaseGoal, InstMap, Disjunct, !VarSet, !VarTypes, InstToUniMode = (pred(ArgInst::in, ArgUniMode::out) is det :- ArgUniMode = ((ArgInst - free) -> (ArgInst - ArgInst)) ), - list__map(InstToUniMode, ArgInsts, UniModes), + list.map(InstToUniMode, ArgInsts, UniModes), UniMode = (Inst0 -> Inst0) - (Inst0 -> Inst0), UnifyContext = unify_context(explicit, []), Unification = deconstruct(Var, ConsId, ArgVars, UniModes, can_fail, cannot_cgc), ExtraGoal = unify(Var, functor(ConsId, no, ArgVars), UniMode, Unification, UnifyContext), - set__singleton_set(NonLocals, Var), + set.singleton_set(NonLocals, Var), instmap_delta_init_reachable(ExtraInstMapDelta0), instmap_delta_bind_var_to_functor(Var, VarType, ConsId, InstMap, ExtraInstMapDelta0, ExtraInstMapDelta, !ModuleInfo), @@ -1295,7 +1295,7 @@ case_to_disjunct(Var, ConsId, CaseGoal, InstMap, Disjunct, !VarSet, !VarTypes, % of the entire conjunction. CaseGoal = _ - CaseGoalInfo, goal_info_get_nonlocals(CaseGoalInfo, CaseNonLocals0), - set__insert(CaseNonLocals0, Var, CaseNonLocals), + set.insert(CaseNonLocals0, Var, CaseNonLocals), goal_info_get_instmap_delta(CaseGoalInfo, CaseInstMapDelta), instmap_delta_apply_instmap_delta(ExtraInstMapDelta, CaseInstMapDelta, test_size, InstMapDelta), @@ -1368,8 +1368,8 @@ compute_disjunct_goal_info(Goal1, Goal2, GoalInfo, CombinedInfo) :- goal_info_get_nonlocals(GoalInfo1, NonLocals1), goal_info_get_nonlocals(GoalInfo2, NonLocals2), goal_info_get_nonlocals(GoalInfo, OuterNonLocals), - set__union(NonLocals1, NonLocals2, CombinedNonLocals0), - set__intersect(CombinedNonLocals0, OuterNonLocals, CombinedNonLocals), + set.union(NonLocals1, NonLocals2, CombinedNonLocals0), + set.intersect(CombinedNonLocals0, OuterNonLocals, CombinedNonLocals), goal_info_get_instmap_delta(GoalInfo1, Delta1), goal_info_get_instmap_delta(GoalInfo2, Delta2), @@ -1542,21 +1542,21 @@ reordering_maintains_termination(FullyStrict, EarlierGoal, LaterGoal, goal_depends_on_earlier_goal(_ - LaterGoalInfo, _ - EarlierGoalInfo, InstMapBeforeEarlierGoal, VarTypes, ModuleInfo) :- goal_info_get_instmap_delta(EarlierGoalInfo, EarlierInstMapDelta), - instmap__apply_instmap_delta(InstMapBeforeEarlierGoal, + instmap.apply_instmap_delta(InstMapBeforeEarlierGoal, EarlierInstMapDelta, InstMapAfterEarlierGoal), instmap_changed_vars(InstMapBeforeEarlierGoal, InstMapAfterEarlierGoal, VarTypes, ModuleInfo, EarlierChangedVars), goal_info_get_nonlocals(LaterGoalInfo, LaterGoalNonLocals), - set__intersect(EarlierChangedVars, LaterGoalNonLocals, Intersection), - not set__empty(Intersection). + set.intersect(EarlierChangedVars, LaterGoalNonLocals, Intersection), + not set.empty(Intersection). %-----------------------------------------------------------------------------% generate_simple_call(ModuleName, ProcName, PredOrFunc, ModeNo, Detism, Args, Features, InstMap, ModuleInfo, Context, Goal) :- - list__length(Args, Arity), + list.length(Args, Arity), lookup_builtin_pred_proc_id(ModuleInfo, ModuleName, ProcName, PredOrFunc, Arity, ModeNo, PredId, ProcId), @@ -1568,8 +1568,8 @@ generate_simple_call(ModuleName, ProcName, PredOrFunc, ModeNo, Detism, Args, GoalExpr = call(PredId, ProcId, Args, BuiltinState, no, qualified(ModuleName, ProcName)), - set__init(NonLocals0), - set__insert_list(NonLocals0, Args, NonLocals), + set.init(NonLocals0), + set.insert_list(NonLocals0, Args, NonLocals), determinism_components(Detism, _CanFail, NumSolns), ( NumSolns = at_most_zero -> instmap_delta_init_unreachable(InstMapDelta) @@ -1580,23 +1580,23 @@ generate_simple_call(ModuleName, ProcName, PredOrFunc, ModeNo, Detism, Args, pred_info_get_purity(PredInfo, Purity), goal_info_init(NonLocals, InstMapDelta, Detism, Purity, Context, GoalInfo0), - list__foldl(goal_info_add_feature, Features, GoalInfo0, GoalInfo), + list.foldl(goal_info_add_feature, Features, GoalInfo0, GoalInfo), Goal = GoalExpr - GoalInfo. generate_foreign_proc(ModuleName, ProcName, PredOrFunc, ModeNo, Detism, Attributes, Args, ExtraArgs, PrefixCode, Code, SuffixCode, Features, InstMap, ModuleInfo, Context, Goal) :- - list__length(Args, Arity), + list.length(Args, Arity), lookup_builtin_pred_proc_id(ModuleInfo, ModuleName, ProcName, PredOrFunc, Arity, ModeNo, PredId, ProcId), AllCode = PrefixCode ++ Code ++ SuffixCode, GoalExpr = foreign_proc(Attributes, PredId, ProcId, Args, ExtraArgs, ordinary(AllCode, no)), - ArgVars = list__map(foreign_arg_var, Args), - ExtraArgVars = list__map(foreign_arg_var, ExtraArgs), + ArgVars = list.map(foreign_arg_var, Args), + ExtraArgVars = list.map(foreign_arg_var, ExtraArgs), Vars = ArgVars ++ ExtraArgVars, - set__list_to_set(Vars, NonLocals), + set.list_to_set(Vars, NonLocals), determinism_components(Detism, _CanFail, NumSolns), ( NumSolns = at_most_zero -> instmap_delta_init_unreachable(InstMapDelta) @@ -1607,7 +1607,7 @@ generate_foreign_proc(ModuleName, ProcName, PredOrFunc, ModeNo, Detism, pred_info_get_purity(PredInfo, Purity), goal_info_init(NonLocals, InstMapDelta, Detism, Purity, Context, GoalInfo0), - list__foldl(goal_info_add_feature, Features, GoalInfo0, GoalInfo), + list.foldl(goal_info_add_feature, Features, GoalInfo0, GoalInfo), Goal = GoalExpr - GoalInfo. generate_cast(CastType, InArg, OutArg, Context, Goal) :- @@ -1615,7 +1615,7 @@ generate_cast(CastType, InArg, OutArg, Context, Goal) :- generate_cast(CastType, InArg, OutArg, Ground, Ground, Context, Goal). generate_cast(CastType, InArg, OutArg, InInst, OutInst, Context, Goal) :- - set__list_to_set([InArg, OutArg], NonLocals), + set.list_to_set([InArg, OutArg], NonLocals), instmap_delta_from_assoc_list([OutArg - OutInst], InstMapDelta), goal_info_init(NonLocals, InstMapDelta, det, purity_pure, Context, GoalInfo), @@ -1650,13 +1650,13 @@ pred_proc_ids_from_goal(Goal, PredProcIds) :- foreign_code_uses_variable(Impl, VarName) :- ( Impl = ordinary(ForeignBody, _), - string__sub_string_search(ForeignBody, VarName, _) + string.sub_string_search(ForeignBody, VarName, _) ; Impl = nondet(FB1, _, FB2, _, FB3, _, _, FB4, _), - ( string__sub_string_search(FB1, VarName, _) - ; string__sub_string_search(FB2, VarName, _) - ; string__sub_string_search(FB3, VarName, _) - ; string__sub_string_search(FB4, VarName, _) + ( string.sub_string_search(FB1, VarName, _) + ; string.sub_string_search(FB2, VarName, _) + ; string.sub_string_search(FB3, VarName, _) + ; string.sub_string_search(FB4, VarName, _) ) ). diff --git a/compiler/graph_colour.m b/compiler/graph_colour.m index 44828c4cb..de6032004 100644 --- a/compiler/graph_colour.m +++ b/compiler/graph_colour.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1995-1996, 2004-2005 The University of Melbourne. +% Copyright (C) 1995-1996, 2004-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -19,7 +19,7 @@ %-----------------------------------------------------------------------------% -:- module libs__graph_colour. +:- module libs.graph_colour. :- interface. :- import_module set. @@ -40,17 +40,17 @@ %-----------------------------------------------------------------------------% group_elements(Constraints, Colours) :- - set__power_union(Constraints, AllVars), - set__init(EmptySet), - set__delete(Constraints, EmptySet, Constraints1), - set__to_sorted_list(Constraints1, ConstraintList), + set.power_union(Constraints, AllVars), + set.init(EmptySet), + set.delete(Constraints, EmptySet, Constraints1), + set.to_sorted_list(Constraints1, ConstraintList), find_all_colours(ConstraintList, AllVars, ColourList), - set__list_to_set(ColourList, Colours). + set.list_to_set(ColourList, Colours). % % performance reducing sanity check.... % ( -% set__power_union(Colours, AllColours), -% (set__member(Var, AllVars) => set__member(Var, AllColours)) +% set.power_union(Colours, AllColours), +% (set.member(Var, AllVars) => set.member(Var, AllColours)) % -> % error("group_elements: sanity check failed") % ; @@ -72,7 +72,7 @@ find_all_colours(ConstraintList, Vars, ColourList) :- ; ConstraintList = [_ | _], next_colour(Vars, ConstraintList, RemainingConstraints, Colour), - set__difference(Vars, Colour, RestVars), + set.difference(Vars, Colour, RestVars), find_all_colours(RemainingConstraints, RestVars, ColourList0), ColourList = [Colour | ColourList0] ). @@ -98,10 +98,10 @@ next_colour(Vars0, ConstraintList, Remainder, SameColour) :- % See if there are sets that can share a colour with the % selected var. NotContaining = [_ | _], - ( set__empty(RestVars) -> + ( set.empty(RestVars) -> % There were no variables left that could share a colour, % so create a singleton set containing this variable. - set__singleton_set(SameColour, Var), + set.singleton_set(SameColour, Var), ResidueSets = NotContaining ; % If there is at least one variable that can share a colour @@ -111,7 +111,7 @@ next_colour(Vars0, ConstraintList, Remainder, SameColour) :- next_colour(RestVars, NotContaining, ResidueSets, SameColour0), % Add this variable to the variables of the current colour. - set__insert(SameColour0, Var, SameColour) + set.insert(SameColour0, Var, SameColour) ) ; NotContaining = [], @@ -119,19 +119,19 @@ next_colour(Vars0, ConstraintList, Remainder, SameColour) :- % by assigning any variable a colour the same as the current % variable, so create a signleton set with the current var, % and assign the residue to the empty set. - set__singleton_set(SameColour, Var), + set.singleton_set(SameColour, Var), ResidueSets = [] ), % The remaining constraints are the residue sets that could not be % satisfied by assigning any variable to the current colour, and the % constraints that were already satisfied by the assignment of the % current variable to this colour. - list__append(ResidueSets, WereContaining, Remainder) + list.append(ResidueSets, WereContaining, Remainder) ; % If there were no constraints, then no colours were needed. ConstraintList = [], Remainder = [], - set__init(SameColour) + set.init(SameColour) ). %-----------------------------------------------------------------------------% @@ -150,15 +150,15 @@ next_colour(Vars0, ConstraintList, Remainder, SameColour) :- divide_constraints(_Var, [], [], [], !Vars). divide_constraints(Var, [S | Ss], C, NC, !Vars) :- divide_constraints(Var, Ss, C0, NC0, !Vars), - ( set__member(Var, S) -> - set__delete(S, Var, T), - ( set__empty(T) -> + ( set.member(Var, S) -> + set.delete(S, Var, T), + ( set.empty(T) -> C = C0 ; C = [T | C0] ), NC = NC0, - set__difference(!.Vars, T, !:Vars) + set.difference(!.Vars, T, !:Vars) ; C = C0, NC = [S | NC0] @@ -172,7 +172,7 @@ divide_constraints(Var, [S | Ss], C, NC, !Vars) :- :- pred choose_var(set(T)::in, T::out, set(T)::out) is det. choose_var(Vars0, Var, Vars) :- - ( set__remove_least(Vars0, VarPrime, VarsPrime) -> + ( set.remove_least(Vars0, VarPrime, VarsPrime) -> Var = VarPrime, Vars = VarsPrime ; diff --git a/compiler/handle_options.m b/compiler/handle_options.m index d09416b16..e94a18337 100644 --- a/compiler/handle_options.m +++ b/compiler/handle_options.m @@ -16,7 +16,7 @@ %-----------------------------------------------------------------------------% -:- module libs__handle_options. +:- module libs.handle_options. :- interface. :- import_module libs.globals. @@ -97,10 +97,10 @@ %-----------------------------------------------------------------------------% handle_options(Args0, Errors, OptionArgs, Args, Link, !IO) :- - % io__write_string("original arguments\n", !IO), + % io.write_string("original arguments\n", !IO), % dump_arguments(Args0, !IO), process_options(Args0, OptionArgs, Args, Result, !IO), - % io__write_string("final arguments\n", !IO), + % io.write_string("final arguments\n", !IO), % dump_arguments(Args, !IO), postprocess_options(Result, Errors, !IO), ( @@ -108,48 +108,48 @@ handle_options(Args0, Errors, OptionArgs, Args, Link, !IO) :- Link = no ; Errors = [], - globals__io_lookup_bool_option(generate_dependencies, + globals.io_lookup_bool_option(generate_dependencies, GenerateDependencies, !IO), - globals__io_lookup_bool_option(generate_dependency_file, + globals.io_lookup_bool_option(generate_dependency_file, GenerateDependencyFile, !IO), - globals__io_lookup_bool_option(make_interface, MakeInterface, !IO), - globals__io_lookup_bool_option(make_private_interface, + globals.io_lookup_bool_option(make_interface, MakeInterface, !IO), + globals.io_lookup_bool_option(make_private_interface, MakePrivateInterface, !IO), - globals__io_lookup_bool_option(make_short_interface, + globals.io_lookup_bool_option(make_short_interface, MakeShortInterface, !IO), - globals__io_lookup_bool_option(make_optimization_interface, + globals.io_lookup_bool_option(make_optimization_interface, MakeOptimizationInt, !IO), - globals__io_lookup_bool_option(make_transitive_opt_interface, + globals.io_lookup_bool_option(make_transitive_opt_interface, MakeTransOptInt, !IO), - globals__io_lookup_bool_option(make_analysis_registry, + globals.io_lookup_bool_option(make_analysis_registry, MakeAnalysisRegistry, !IO), - globals__io_lookup_bool_option(convert_to_mercury, + globals.io_lookup_bool_option(convert_to_mercury, ConvertToMercury, !IO), - globals__io_lookup_bool_option(typecheck_only, TypecheckOnly, !IO), - globals__io_lookup_bool_option(errorcheck_only, ErrorcheckOnly, !IO), - globals__io_lookup_bool_option(target_code_only, + globals.io_lookup_bool_option(typecheck_only, TypecheckOnly, !IO), + globals.io_lookup_bool_option(errorcheck_only, ErrorcheckOnly, !IO), + globals.io_lookup_bool_option(target_code_only, TargetCodeOnly, !IO), - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), GenerateIL = (if Target = il then yes else no), - globals__io_lookup_bool_option(compile_only, CompileOnly, !IO), - bool__or_list([GenerateDependencies, GenerateDependencyFile, + globals.io_lookup_bool_option(compile_only, CompileOnly, !IO), + bool.or_list([GenerateDependencies, GenerateDependencyFile, MakeInterface, MakePrivateInterface, MakeShortInterface, MakeOptimizationInt, MakeTransOptInt, MakeAnalysisRegistry, ConvertToMercury, TypecheckOnly, ErrorcheckOnly, TargetCodeOnly, GenerateIL, CompileOnly], NotLink), - bool__not(NotLink, Link), - globals__io_lookup_bool_option(smart_recompilation, Smart, !IO), + bool.not(NotLink, Link), + globals.io_lookup_bool_option(smart_recompilation, Smart, !IO), ( Smart = yes, Link = yes -> % XXX Currently smart recompilation doesn't check that all the % files needed to link are present and up-to-date, so disable it. - globals__io_get_globals(Globals0, !IO), + globals.io_get_globals(Globals0, !IO), disable_smart_recompilation("linking", Globals0, Globals1, !IO), unsafe_promise_unique(Globals1, Globals), - globals__io_set_globals(Globals, !IO) + globals.io_set_globals(Globals, !IO) ; true ) @@ -158,16 +158,16 @@ handle_options(Args0, Errors, OptionArgs, Args, Link, !IO) :- process_options(Args0, OptionArgs, Args, Result, !IO) :- OptionOps = option_ops(short_option, long_option, option_defaults, special_handler), - getopt_io__process_options(OptionOps, Args0, OptionArgs, Args, Result, + getopt_io.process_options(OptionOps, Args0, OptionArgs, Args, Result, !IO). :- pred dump_arguments(list(string)::in, io::di, io::uo) is det. dump_arguments([], !IO). dump_arguments([Arg | Args], !IO) :- - io__write_string("<", !IO), - io__write_string(Arg, !IO), - io__write_string(">\n", !IO), + io.write_string("<", !IO), + io.write_string(Arg, !IO), + io.write_string(">\n", !IO), dump_arguments(Args, !IO). %-----------------------------------------------------------------------------% @@ -203,7 +203,7 @@ postprocess_options(ok(OptionTable0), Errors, !IO) :- check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, !Errors) :- - map__lookup(OptionTable0, target, Target0), + map.lookup(OptionTable0, target, Target0), ( Target0 = string(TargetStr), convert_target(TargetStr, TargetPrime) @@ -214,7 +214,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, add_error("Invalid target option " ++ "(must be `c', `asm', `il', or `java')", !Errors) ), - map__lookup(OptionTable0, gc, GC_Method0), + map.lookup(OptionTable0, gc, GC_Method0), ( GC_Method0 = string(GC_MethodStr), convert_gc_method(GC_MethodStr, GC_MethodPrime) @@ -226,7 +226,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, "`conservative', `boehm', `mps', `accurate', or `automatic')", !Errors) ), - map__lookup(OptionTable0, tags, TagsMethod0), + map.lookup(OptionTable0, tags, TagsMethod0), ( TagsMethod0 = string(TagsMethodStr), convert_tags_method(TagsMethodStr, TagsMethodPrime) @@ -237,7 +237,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, add_error("Invalid tags option " ++ "(must be `none', `low' or `high')", !Errors) ), - map__lookup(OptionTable0, fact_table_hash_percent_full, PercentFull), + map.lookup(OptionTable0, fact_table_hash_percent_full, PercentFull), ( PercentFull = int(Percent), Percent >= 1, @@ -249,7 +249,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, "`--fact-table-hash-percent-full'\n\t" ++ "(must be an integer between 1 and 100)", !Errors) ), - map__lookup(OptionTable0, termination_norm, TermNorm0), + map.lookup(OptionTable0, termination_norm, TermNorm0), ( TermNorm0 = string(TermNormStr), convert_termination_norm(TermNormStr, TermNormPrime) @@ -261,7 +261,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, "`--termination-norm'\n\t(must be " ++ "`simple', `total' or `num-data-elems').", !Errors) ), - map__lookup(OptionTable0, termination2_norm, Term2Norm0), + map.lookup(OptionTable0, termination2_norm, Term2Norm0), ( Term2Norm0 = string(Term2NormStr), convert_termination_norm(Term2NormStr, Term2NormPrime) @@ -273,13 +273,13 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, "`--termination2-norm'\n\t(must be" ++ "`simple', `total' or `num-data-elems').", !Errors) ), - map__lookup(OptionTable0, force_disable_tracing, ForceDisableTracing), + map.lookup(OptionTable0, force_disable_tracing, ForceDisableTracing), ( ForceDisableTracing = bool(yes) -> TraceLevel = trace_level_none ; - map__lookup(OptionTable0, trace, Trace), - map__lookup(OptionTable0, exec_trace, ExecTraceOpt), - map__lookup(OptionTable0, decl_debug, DeclDebugOpt), + map.lookup(OptionTable0, trace, Trace), + map.lookup(OptionTable0, exec_trace, ExecTraceOpt), + map.lookup(OptionTable0, decl_debug, DeclDebugOpt), ( Trace = string(TraceStr), ExecTraceOpt = bool(ExecTrace), @@ -302,7 +302,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, "`decl', `rep' or `default').", !Errors) ) ), - map__lookup(OptionTable0, suppress_trace, Suppress), + map.lookup(OptionTable0, suppress_trace, Suppress), ( Suppress = string(SuppressStr), convert_trace_suppress(SuppressStr, TraceSuppressPrime) @@ -312,7 +312,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, TraceSuppress = default_trace_suppress, % dummy add_error("Invalid argument to option `--suppress-trace'.", !Errors) ), - map__lookup(OptionTable0, maybe_thread_safe, MaybeThreadSafeOption), + map.lookup(OptionTable0, maybe_thread_safe, MaybeThreadSafeOption), ( MaybeThreadSafeOption = string(MaybeThreadSafeString), convert_maybe_thread_safe(MaybeThreadSafeString, MaybeThreadSafe0) @@ -322,7 +322,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, MaybeThreadSafe = no, % dummy add_error("Invalid argument to option `--maybe-thread-safe'.", !Errors) ), - map__lookup(OptionTable0, dump_hlds_alias, DumpAliasOption), + map.lookup(OptionTable0, dump_hlds_alias, DumpAliasOption), ( DumpAliasOption = string(DumpAlias), DumpAlias = "" @@ -332,7 +332,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, DumpAliasOption = string(DumpAlias), convert_dump_alias(DumpAlias, DumpOptions) -> - map__set(OptionTable0, dump_hlds_options, string(DumpOptions), + map.set(OptionTable0, dump_hlds_options, string(DumpOptions), OptionTable) ; OptionTable = OptionTable0, % dummy @@ -344,7 +344,7 @@ check_option_values(OptionTable0, OptionTable, Target, GC_Method, TagsMethod, add_error(Error, Errors0, Errors) :- % We won't be appending enough errors for the quadratic complexity % of repeated appends to be a problem. - list__append(Errors0, [Error], Errors). + list.append(Errors0, [Error], Errors). % NOTE: each termination analyser has its own norm setting. % @@ -358,17 +358,17 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, !Errors, !IO) :- unsafe_promise_unique(OptionTable0, OptionTable1), % XXX - globals__io_init(OptionTable1, Target, GC_Method, TagsMethod0, + globals_io_init(OptionTable1, Target, GC_Method, TagsMethod0, TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, !IO), some [!Globals] ( - globals__io_get_globals(!:Globals, !IO), + globals.io_get_globals(!:Globals, !IO), % Conservative GC implies --no-reclaim-heap-* ( gc_is_conservative(GC_Method) = yes -> - globals__set_option(reclaim_heap_on_semidet_failure, bool(no), + globals.set_option(reclaim_heap_on_semidet_failure, bool(no), !Globals), - globals__set_option(reclaim_heap_on_nondet_failure, bool(no), + globals.set_option(reclaim_heap_on_nondet_failure, bool(no), !Globals) ; true @@ -378,7 +378,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, ( TagsMethod0 = none -> NumTagBits0 = 0 ; - globals__lookup_int_option(!.Globals, num_tag_bits, NumTagBits0) + globals.lookup_int_option(!.Globals, num_tag_bits, NumTagBits0) ), % if --tags low but --num-tag-bits not specified, @@ -389,7 +389,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, TagsMethod0 = low, NumTagBits0 = -1 -> - globals__lookup_int_option(!.Globals, conf_low_tag_bits, + globals.lookup_int_option(!.Globals, conf_low_tag_bits, NumTagBits1) ; NumTagBits1 = NumTagBits0 @@ -398,27 +398,27 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % if --num-tag-bits negative or unspecified, issue a warning % and assume --num-tag-bits 0 ( NumTagBits1 < 0 -> - io__progname_base("mercury_compile", ProgName, !IO), + io.progname_base("mercury_compile", ProgName, !IO), report_warning(ProgName, !IO), report_warning( ": warning: --num-tag-bits invalid or unspecified\n", !IO), - io__write_string(ProgName, !IO), + io.write_string(ProgName, !IO), report_warning(": using --num-tag-bits 0 (tags disabled)\n", !IO), NumTagBits = 0 ; NumTagBits = NumTagBits1 ), - globals__set_option(num_tag_bits, int(NumTagBits), !Globals), + globals.set_option(num_tag_bits, int(NumTagBits), !Globals), ( NumTagBits = 0 -> TagsMethod = none, - globals__set_tags_method(TagsMethod, !Globals) + globals.set_tags_method(TagsMethod, !Globals) ; TagsMethod = TagsMethod0 ), - globals__lookup_bool_option(!.Globals, highlevel_data, HighLevelData), - globals__lookup_bool_option(!.Globals, + globals.lookup_bool_option(!.Globals, highlevel_data, HighLevelData), + globals.lookup_bool_option(!.Globals, automatic_intermodule_optimization, AutoIntermodOptimization), % Generating IL implies: @@ -470,29 +470,29 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % needed, so ensure that this dead code is removed. ( Target = il -> - globals__set_gc_method(automatic, !Globals), - globals__set_option(gc, string("automatic"), !Globals), - globals__set_option(reclaim_heap_on_nondet_failure, bool(no), + globals.set_gc_method(automatic, !Globals), + globals.set_option(gc, string("automatic"), !Globals), + globals.set_option(reclaim_heap_on_nondet_failure, bool(no), !Globals), - globals__set_option(reclaim_heap_on_semidet_failure, bool(no), + globals.set_option(reclaim_heap_on_semidet_failure, bool(no), !Globals), - globals__set_option(highlevel_code, bool(yes), !Globals), - globals__set_option(highlevel_data, bool(yes), !Globals), - globals__set_option(gcc_nested_functions, bool(no), !Globals), - globals__set_option(nondet_copy_out, bool(yes), !Globals), - globals__set_option(num_tag_bits, int(0), !Globals), - globals__set_option(unboxed_enums, bool(no), !Globals), - globals__set_option(unboxed_no_tag_types, bool(no), !Globals), - % globals__set_option(num_reserved_addresses, int(1), !Globals) - globals__set_option(static_ground_terms, bool(no), !Globals), + globals.set_option(highlevel_code, bool(yes), !Globals), + globals.set_option(highlevel_data, bool(yes), !Globals), + globals.set_option(gcc_nested_functions, bool(no), !Globals), + globals.set_option(nondet_copy_out, bool(yes), !Globals), + globals.set_option(num_tag_bits, int(0), !Globals), + globals.set_option(unboxed_enums, bool(no), !Globals), + globals.set_option(unboxed_no_tag_types, bool(no), !Globals), + % globals.set_option(num_reserved_addresses, int(1), !Globals) + globals.set_option(static_ground_terms, bool(no), !Globals), ( HighLevelData = yes, AutoIntermodOptimization = yes -> - globals__set_option(intermodule_optimization, bool(yes), + globals.set_option(intermodule_optimization, bool(yes), !Globals), - globals__set_option(optimize_dead_procs, bool(yes), !Globals) + globals.set_option(optimize_dead_procs, bool(yes), !Globals) ; true ), @@ -500,7 +500,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % On the .NET backend we will be using a language independent % debugger not mdb. Thus --debug has to imply --target-debug. ( given_trace_level_is_none(TraceLevel) = no -> - globals__set_option(target_debug, bool(yes), !Globals) + globals.set_option(target_debug, bool(yes), !Globals) ; true ) @@ -511,9 +511,9 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % Set --put-nondet-env-on-heap if --verifiable-code is specified, % unless both --il-funcptr-types and --il-refany-fields % are specified. - globals__lookup_bool_option(!.Globals, il_funcptr_types, + globals.lookup_bool_option(!.Globals, il_funcptr_types, ILFuncPtrTypes), - globals__lookup_bool_option(!.Globals, il_refany_fields, + globals.lookup_bool_option(!.Globals, il_refany_fields, ILRefAnyFields), ( ILFuncPtrTypes = yes, @@ -564,27 +564,27 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % needed, so ensure that this dead code is removed. ( Target = java -> - globals__set_gc_method(automatic, !Globals), - globals__set_option(gc, string("automatic"), !Globals), - globals__set_option(reclaim_heap_on_nondet_failure, bool(no), + globals.set_gc_method(automatic, !Globals), + globals.set_option(gc, string("automatic"), !Globals), + globals.set_option(reclaim_heap_on_nondet_failure, bool(no), !Globals), - globals__set_option(reclaim_heap_on_semidet_failure, bool(no), + globals.set_option(reclaim_heap_on_semidet_failure, bool(no), !Globals), - globals__set_option(highlevel_code, bool(yes), !Globals), - globals__set_option(highlevel_data, bool(yes), !Globals), - globals__set_option(gcc_nested_functions, bool(no), !Globals), - globals__set_option(nondet_copy_out, bool(yes), !Globals), - globals__set_option(det_copy_out, bool(yes), !Globals), - globals__set_option(num_tag_bits, int(0), !Globals), - globals__set_option(unboxed_no_tag_types, bool(no), !Globals), - globals__set_option(static_ground_terms, bool(no), !Globals), - globals__set_option(put_nondet_env_on_heap, bool(yes), !Globals), + globals.set_option(highlevel_code, bool(yes), !Globals), + globals.set_option(highlevel_data, bool(yes), !Globals), + globals.set_option(gcc_nested_functions, bool(no), !Globals), + globals.set_option(nondet_copy_out, bool(yes), !Globals), + globals.set_option(det_copy_out, bool(yes), !Globals), + globals.set_option(num_tag_bits, int(0), !Globals), + globals.set_option(unboxed_no_tag_types, bool(no), !Globals), + globals.set_option(static_ground_terms, bool(no), !Globals), + globals.set_option(put_nondet_env_on_heap, bool(yes), !Globals), ( AutoIntermodOptimization = yes, - globals__set_option(intermodule_optimization, bool(yes), + globals.set_option(intermodule_optimization, bool(yes), !Globals), - globals__set_option(optimize_dead_procs, bool(yes), !Globals) + globals.set_option(optimize_dead_procs, bool(yes), !Globals) ; AutoIntermodOptimization = no ) @@ -594,7 +594,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % Generating assembler via the gcc back-end requires % using high-level code. ( Target = asm -> - globals__set_option(highlevel_code, bool(yes), !Globals) + globals.set_option(highlevel_code, bool(yes), !Globals) ; true ), @@ -647,11 +647,11 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % If no --lib-linkage option has been specified, default to the % set of all possible linkages. - globals__lookup_accumulating_option(!.Globals, lib_linkages, + globals.lookup_accumulating_option(!.Globals, lib_linkages, LibLinkages0), ( LibLinkages0 = [], - globals__set_option(lib_linkages, + globals.set_option(lib_linkages, accumulating(["static", "shared"]), !Globals) ; LibLinkages0 = [_ | _] @@ -711,10 +711,10 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, true ), - ( io__have_symlinks -> + ( io.have_symlinks -> true ; - globals__set_option(use_symlinks, bool(no), !Globals) + globals.set_option(use_symlinks, bool(no), !Globals) ), option_implies(verbose_check_termination, check_termination,bool(yes), @@ -746,7 +746,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % without the extra information from the `.opt' files % is done when making the `.opt' file. With `--use-opt-files', % that doesn't happen. - globals__set_option(use_opt_files, bool(no), !Globals), + globals.set_option(use_opt_files, bool(no), !Globals), option_implies(smart_recompilation, generate_item_version_numbers, bool(yes), !Globals), @@ -808,7 +808,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % in interface files for users of a library compiled with % inter-module optimization but not using inter-module % optimization themselves. - globals__lookup_bool_option(!.Globals, smart_recompilation, Smart), + globals.lookup_bool_option(!.Globals, smart_recompilation, Smart), maybe_disable_smart_recompilation(Smart, intermodule_optimization, yes, "`--intermodule-optimization'", !Globals, !IO), maybe_disable_smart_recompilation(Smart, use_opt_files, yes, @@ -827,13 +827,13 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, option_implies(very_verbose, verbose, bool(yes), !Globals), option_implies(verbose, verbose_commands, bool(yes), !Globals), - globals__lookup_bool_option(!.Globals, very_verbose, VeryVerbose), - globals__lookup_bool_option(!.Globals, statistics, Statistics), + globals.lookup_bool_option(!.Globals, very_verbose, VeryVerbose), + globals.lookup_bool_option(!.Globals, statistics, Statistics), ( VeryVerbose = yes, Statistics = yes -> - globals__set_option(detailed_statistics, bool(yes), !Globals) + globals.set_option(detailed_statistics, bool(yes), !Globals) ; true ), @@ -843,7 +843,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, option_implies(debug_modes_statistics, debug_modes, bool(yes), !Globals), - globals__lookup_int_option(!.Globals, debug_liveness, DebugLiveness), + globals.lookup_int_option(!.Globals, debug_liveness, DebugLiveness), ( DebugLiveness >= 0, convert_dump_alias("all", AllDumpOptions) @@ -852,45 +852,45 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % interested in the goal annotations put on goals by % the various phases of the liveness pass. The default % dump options do not print these annotations. - globals__lookup_string_option(!.Globals, dump_hlds_options, + globals.lookup_string_option(!.Globals, dump_hlds_options, DumpOptions0), - string__append(DumpOptions0, AllDumpOptions, DumpOptions1), - globals__set_option(dump_hlds_options, string(DumpOptions1), + string.append(DumpOptions0, AllDumpOptions, DumpOptions1), + globals.set_option(dump_hlds_options, string(DumpOptions1), !Globals) ; true ), option_implies(debug_modes_verbose, debug_modes, bool(yes), !Globals), - globals__lookup_int_option(!.Globals, debug_modes_pred_id, + globals.lookup_int_option(!.Globals, debug_modes_pred_id, DebugModesPredId), ( DebugModesPredId > 0 -> - globals__set_option(debug_modes, bool(yes), !Globals) + globals.set_option(debug_modes, bool(yes), !Globals) ; true ), - globals__lookup_int_option(!.Globals, debug_opt_pred_id, + globals.lookup_int_option(!.Globals, debug_opt_pred_id, DebugOptPredId), ( DebugOptPredId > 0 -> - globals__set_option(debug_opt, bool(yes), !Globals) + globals.set_option(debug_opt, bool(yes), !Globals) ; true ), - globals__lookup_bool_option(!.Globals, debug_intermodule_analysis, + globals.lookup_bool_option(!.Globals, debug_intermodule_analysis, DebugIntermoduleAnalysis), - analysis__enable_debug_messages(DebugIntermoduleAnalysis, !IO), + analysis.enable_debug_messages(DebugIntermoduleAnalysis, !IO), - globals__lookup_int_option(!.Globals, dump_hlds_pred_id, + globals.lookup_int_option(!.Globals, dump_hlds_pred_id, DumpHLDSPredId), ( DumpHLDSPredId >= 0 -> - globals__lookup_string_option(!.Globals, dump_hlds_options, + globals.lookup_string_option(!.Globals, dump_hlds_options, DumpOptions2), % Prevent the dumping of the mode and type tables. - string__replace_all(DumpOptions2, "M", "", DumpOptions3), - string__replace_all(DumpOptions3, "T", "", DumpOptions), - globals__set_option(dump_hlds_options, string(DumpOptions), + string.replace_all(DumpOptions2, "M", "", DumpOptions3), + string.replace_all(DumpOptions3, "T", "", DumpOptions), + globals.set_option(dump_hlds_options, string(DumpOptions), !Globals) ; true @@ -902,13 +902,13 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % Minimal model tabling is not compatible with high level code % or with trailing; see the comments in runtime/mercury_grade.h. - globals__lookup_bool_option(!.Globals, use_trail, UseTrail), - globals__lookup_bool_option(!.Globals, highlevel_code, HighLevel), - globals__lookup_bool_option(!.Globals, use_minimal_model_stack_copy, + globals.lookup_bool_option(!.Globals, use_trail, UseTrail), + globals.lookup_bool_option(!.Globals, highlevel_code, HighLevel), + globals.lookup_bool_option(!.Globals, use_minimal_model_stack_copy, UseMinimalModelStackCopy), - globals__lookup_bool_option(!.Globals, use_minimal_model_own_stacks, + globals.lookup_bool_option(!.Globals, use_minimal_model_own_stacks, UseMinimalModelOwnStacks), - bool__or(UseMinimalModelStackCopy, UseMinimalModelOwnStacks, + bool.or(UseMinimalModelStackCopy, UseMinimalModelOwnStacks, UseMinimalModel), ( UseMinimalModelStackCopy = yes, @@ -942,12 +942,12 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % information about the inlined calls. option_implies(profile_deep, allow_inlining, bool(no), !Globals), - globals__lookup_string_option(!.Globals, experimental_complexity, + globals.lookup_string_option(!.Globals, experimental_complexity, ExpComp), ( ExpComp = "" -> true ; - globals__set_option(allow_inlining, bool(no), !Globals) + globals.set_option(allow_inlining, bool(no), !Globals) ), % --decl-debug is an extension of --debug @@ -975,14 +975,14 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % space overhead of trailing (mostly for extra code) as well unless the % user has explicitly requested it. - globals__lookup_bool_option(!.Globals, exec_trace, ExecTrace), - globals__lookup_bool_option(!.Globals, decl_debug, DeclDebug), + globals.lookup_bool_option(!.Globals, exec_trace, ExecTrace), + globals.lookup_bool_option(!.Globals, decl_debug, DeclDebug), ( ExecTrace = yes, DeclDebug = no, UseMinimalModel = no -> - globals__set_option(use_trail, bool(yes), !Globals) + globals.set_option(use_trail, bool(yes), !Globals) ; true ), @@ -1006,7 +1006,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % paths across optimization levels % - enabling stack layouts % - enabling typeinfo liveness - globals__lookup_bool_option(!.Globals, trace_optimized, + globals.lookup_bool_option(!.Globals, trace_optimized, TraceOptimized), ( given_trace_level_is_none(TraceLevel) = no -> ( @@ -1015,32 +1015,32 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % of the program, which makes it difficult to % relate the trace to the source code (although % it can be easily related to the transformed HLDS). - globals__set_option(allow_inlining, bool(no), !Globals), - globals__set_option(optimize_unused_args, bool(no), !Globals), - globals__set_option(optimize_higher_order, bool(no), !Globals), - globals__set_option(type_specialization, bool(no), !Globals), - globals__set_option(user_guided_type_specialization, + globals.set_option(allow_inlining, bool(no), !Globals), + globals.set_option(optimize_unused_args, bool(no), !Globals), + globals.set_option(optimize_higher_order, bool(no), !Globals), + globals.set_option(type_specialization, bool(no), !Globals), + globals.set_option(user_guided_type_specialization, bool(no), !Globals), - globals__set_option(deforestation, bool(no), !Globals), - globals__set_option(constraint_propagation, + globals.set_option(deforestation, bool(no), !Globals), + globals.set_option(constraint_propagation, bool(no), !Globals), - globals__set_option(local_constraint_propagation, + globals.set_option(local_constraint_propagation, bool(no), !Globals), - globals__set_option(optimize_duplicate_calls, + globals.set_option(optimize_duplicate_calls, bool(no), !Globals), - globals__set_option(optimize_constructor_last_call, + globals.set_option(optimize_constructor_last_call, bool(no), !Globals), - globals__set_option(optimize_saved_vars_cell, + globals.set_option(optimize_saved_vars_cell, bool(no), !Globals), - globals__set_option(loop_invariants, bool(no), !Globals), - globals__set_option(untuple, bool(no), !Globals), - globals__set_option(tuple, bool(no), !Globals), + globals.set_option(loop_invariants, bool(no), !Globals), + globals.set_option(untuple, bool(no), !Globals), + globals.set_option(tuple, bool(no), !Globals), % For the IL backend we turn off optimize_peep % so that we don't optimize away references to the % local variables of a procedure. ( Target = il -> - globals__set_option(optimize_peep, bool(no), !Globals) + globals.set_option(optimize_peep, bool(no), !Globals) ; true ) @@ -1071,33 +1071,33 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % hijacks, it would be slower as well, except in % procedures that would have many nested hijacks, % and such code is extremely rare. - globals__set_option(allow_hijacks, bool(no), !Globals), + globals.set_option(allow_hijacks, bool(no), !Globals), % The following option prevents useless variables % from cluttering the trace. Its explicit setting % removes a source of variability in the goal paths % reported by tracing. - globals__set_option(excess_assign, bool(yes), !Globals), + globals.set_option(excess_assign, bool(yes), !Globals), % The explicit setting of the following option % removes a source of variability in the goal paths % reported by tracing. - globals__set_option(follow_code, bool(yes), !Globals), + globals.set_option(follow_code, bool(yes), !Globals), % The following option selects a special-case % code generator that cannot (yet) implement tracing. - globals__set_option(middle_rec, bool(no), !Globals), + globals.set_option(middle_rec, bool(no), !Globals), % The following options cause the info required % by tracing to be generated. - globals__set_option(trace_stack_layout, bool(yes), !Globals), - globals__set_option(body_typeinfo_liveness, bool(yes), !Globals), + globals.set_option(trace_stack_layout, bool(yes), !Globals), + globals.set_option(body_typeinfo_liveness, bool(yes), !Globals), % To support up-level printing, we need to save % variables across a call even if the call cannot % succeed. - globals__set_option(opt_no_return_calls, bool(no), !Globals) + globals.set_option(opt_no_return_calls, bool(no), !Globals) ; true ), option_implies(profile_deep, procid_stack_layout, bool(yes), !Globals), - globals__lookup_bool_option(!.Globals, profile_deep, ProfileDeep), + globals.lookup_bool_option(!.Globals, profile_deep, ProfileDeep), ( ProfileDeep = yes, ( @@ -1109,15 +1109,15 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, add_error("deep profiling is incompatible " ++ "with high level code", !Errors) ), - globals__set_option(optimize_constructor_last_call, + globals.set_option(optimize_constructor_last_call, bool(no), !Globals), - globals__lookup_bool_option(!.Globals, + globals.lookup_bool_option(!.Globals, use_lots_of_ho_specialization, LotsOfHOSpec), ( LotsOfHOSpec = yes, True = bool(yes), - globals__set_option(optimize_higher_order, True, !Globals), - globals__set_option(higher_order_size_limit, int(999999), + globals.set_option(optimize_higher_order, True, !Globals), + globals.set_option(higher_order_size_limit, int(999999), !Globals) ; LotsOfHOSpec = no @@ -1126,9 +1126,9 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, ProfileDeep = no ), - globals__lookup_bool_option(!.Globals, record_term_sizes_as_words, + globals.lookup_bool_option(!.Globals, record_term_sizes_as_words, RecordTermSizesAsWords), - globals__lookup_bool_option(!.Globals, record_term_sizes_as_cells, + globals.lookup_bool_option(!.Globals, record_term_sizes_as_cells, RecordTermSizesAsCells), ( RecordTermSizesAsWords = yes, @@ -1141,7 +1141,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, ; RecordTermSizesAsCells = yes ) -> - globals__set_option(optimize_constructor_last_call, bool(no), + globals.set_option(optimize_constructor_last_call, bool(no), !Globals), ( HighLevel = yes, @@ -1245,22 +1245,22 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % which the current RTTI system can't handle. % ( GC_Method = accurate -> - globals__set_option(agc_stack_layout, bool(yes), !Globals), - globals__set_option(body_typeinfo_liveness, bool(yes), !Globals), - globals__set_option(allow_hijacks, bool(no), !Globals), - globals__set_option(optimize_frames, bool(no), !Globals), - globals__set_option(opt_no_return_calls, bool(no), !Globals), - globals__set_option(middle_rec, bool(no), !Globals), - globals__set_option( + globals.set_option(agc_stack_layout, bool(yes), !Globals), + globals.set_option(body_typeinfo_liveness, bool(yes), !Globals), + globals.set_option(allow_hijacks, bool(no), !Globals), + globals.set_option(optimize_frames, bool(no), !Globals), + globals.set_option(opt_no_return_calls, bool(no), !Globals), + globals.set_option(middle_rec, bool(no), !Globals), + globals.set_option( reclaim_heap_on_semidet_failure, bool(no), !Globals), - globals__set_option( + globals.set_option( reclaim_heap_on_nondet_failure, bool(no), !Globals), option_implies(highlevel_code, optimize_higher_order, bool(no), !Globals), - globals__set_option(type_specialization, bool(no), !Globals), - globals__set_option(user_guided_type_specialization, + globals.set_option(type_specialization, bool(no), !Globals), + globals.set_option(user_guided_type_specialization, bool(no), !Globals) ; true @@ -1270,7 +1270,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % both assume (for accurate GC) that continuation environments % are always allocated on the stack, which means that things won't % if --gc accurate and --put-nondet-env-on-heap are both enabled. - globals__lookup_bool_option(!.Globals, put_nondet_env_on_heap, + globals.lookup_bool_option(!.Globals, put_nondet_env_on_heap, PutNondetEnvOnHeap), ( HighLevel = yes, @@ -1330,16 +1330,16 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % these extra pieces of code to be disabled. The disabled program will % work only if the program doesn't actually use minimal model tabling, % which makes it useful only for performance testing. - globals__lookup_bool_option(!.Globals, + globals.lookup_bool_option(!.Globals, disable_minimal_model_stack_copy_pneg, DisablePneg), - globals__lookup_bool_option(!.Globals, + globals.lookup_bool_option(!.Globals, disable_minimal_model_stack_copy_cut, DisableCut), ( UseMinimalModelStackCopy = yes, DisablePneg = no -> - globals__set_option(use_minimal_model_stack_copy_pneg, + globals.set_option(use_minimal_model_stack_copy_pneg, bool(yes), !Globals) ; true @@ -1348,20 +1348,20 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, UseMinimalModelStackCopy = yes, DisableCut = no -> - globals__set_option(use_minimal_model_stack_copy_cut, + globals.set_option(use_minimal_model_stack_copy_cut, bool(yes), !Globals) ; true ), % --dump-hlds and --statistics require compilation by phases - globals__lookup_accumulating_option(!.Globals, dump_hlds, DumpStages), + globals.lookup_accumulating_option(!.Globals, dump_hlds, DumpStages), ( ( DumpStages = [_ | _] ; Statistics = yes ) -> - globals__set_option(trad_passes, bool(no), !Globals) + globals.set_option(trad_passes, bool(no), !Globals) ; true ), @@ -1412,32 +1412,32 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, option_implies(generate_source_file_mapping, warn_wrong_module_name, bool(no), !Globals), - globals__lookup_string_option(!.Globals, fullarch, FullArch), + globals.lookup_string_option(!.Globals, fullarch, FullArch), % % Add the standard library directory. % - globals__lookup_maybe_string_option(!.Globals, + globals.lookup_maybe_string_option(!.Globals, mercury_standard_library_directory, MaybeStdLibDir), ( MaybeStdLibDir = yes(StdLibDir), - globals__get_options(!.Globals, OptionTable2), - globals__set_options(option_table_add_mercury_library_directory( + globals.get_options(!.Globals, OptionTable2), + globals.set_options(option_table_add_mercury_library_directory( OptionTable2, StdLibDir), !Globals), % % Add `-L' and `-R' options for the location % of the GC libraries. % - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, link_library_directories, LinkLibDirs0), - globals__set_option(link_library_directories, + globals.set_option(link_library_directories, accumulating([StdLibDir/"lib" | LinkLibDirs0]), !Globals), - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, runtime_link_library_directories, Rpath0), - globals__set_option(runtime_link_library_directories, + globals.set_option(runtime_link_library_directories, accumulating([StdLibDir/"lib" | Rpath0]), !Globals) ; @@ -1447,13 +1447,13 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % % Add the path to mercury_conf.h. % - globals__lookup_maybe_string_option(!.Globals, + globals.lookup_maybe_string_option(!.Globals, mercury_configuration_directory, MaybeConfDir), ( MaybeConfDir = yes(ConfDir), - globals__lookup_accumulating_option(!.Globals, c_include_directory, + globals.lookup_accumulating_option(!.Globals, c_include_directory, CIncludeDirs0), - globals__set_option(c_include_directory, + globals.set_option(c_include_directory, accumulating([ConfDir/"conf" | CIncludeDirs0]), !Globals) ; MaybeConfDir = no @@ -1462,17 +1462,17 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % % Find the configuration file. % - globals__lookup_maybe_string_option(!.Globals, config_file, + globals.lookup_maybe_string_option(!.Globals, config_file, ConfigFile), % yes("") means `--config-file' was not passed on the command line. ( ConfigFile = yes("") -> ( MaybeConfDir = yes(ConfDir1), - globals__set_option(config_file, maybe_string(yes( + globals.set_option(config_file, maybe_string(yes( ConfDir1/"conf"/"Mercury.config")), !Globals) ; MaybeConfDir = no, - globals__set_option(config_file, maybe_string(no), !Globals) + globals.set_option(config_file, maybe_string(no), !Globals) ) ; true @@ -1483,43 +1483,43 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % These couldn't be handled by options.m because they are grade % dependent. % - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, mercury_library_directories, MercuryLibDirs), grade_directory_component(!.Globals, GradeString), ( MercuryLibDirs = [_ | _], - ExtraLinkLibDirs = list__map( + ExtraLinkLibDirs = list.map( (func(MercuryLibDir) = MercuryLibDir/"lib"/GradeString ), MercuryLibDirs), - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, link_library_directories, LinkLibDirs), - globals__set_option(link_library_directories, + globals.set_option(link_library_directories, accumulating(LinkLibDirs ++ ExtraLinkLibDirs), !Globals), - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, runtime_link_library_directories, Rpath), - globals__set_option(runtime_link_library_directories, + globals.set_option(runtime_link_library_directories, accumulating(Rpath ++ ExtraLinkLibDirs), !Globals), - ExtraCIncludeDirs = list__map( + ExtraCIncludeDirs = list.map( (func(MercuryLibDir) = MercuryLibDir/"lib"/GradeString/"inc" ), MercuryLibDirs), - globals__lookup_accumulating_option(!.Globals, c_include_directory, + globals.lookup_accumulating_option(!.Globals, c_include_directory, CIncludeDirs), - globals__set_option(c_include_directory, + globals.set_option(c_include_directory, accumulating(ExtraCIncludeDirs ++ CIncludeDirs), !Globals), - ExtraIntermodDirs = list__map( + ExtraIntermodDirs = list.map( (func(MercuryLibDir) = - dir__make_path_name(MercuryLibDir, - dir__make_path_name("ints", GradeString)) + dir.make_path_name(MercuryLibDir, + dir.make_path_name("ints", GradeString)) ), MercuryLibDirs), - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, intermod_directories, IntermodDirs0), - globals__set_option(intermod_directories, + globals.set_option(intermod_directories, accumulating(ExtraIntermodDirs ++ IntermodDirs0), !Globals) ; MercuryLibDirs = [] @@ -1528,21 +1528,21 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % If --use-search-directories-for-intermod is true, append the % search directories to the list of directories to search for % .opt files. - globals__lookup_bool_option(!.Globals, + globals.lookup_bool_option(!.Globals, use_search_directories_for_intermod, UseSearchDirs), ( UseSearchDirs = yes, - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, intermod_directories, IntermodDirs1), - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, search_directories, SearchDirs), - globals__set_option(intermod_directories, + globals.set_option(intermod_directories, accumulating(IntermodDirs1 ++ SearchDirs), !Globals) ; UseSearchDirs = no ), - globals__lookup_bool_option(!.Globals, use_grade_subdirs, + globals.lookup_bool_option(!.Globals, use_grade_subdirs, UseGradeSubdirs), ( UseGradeSubdirs = yes, @@ -1556,12 +1556,12 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % `--intermod-directory Mercury//' % to find the `.opt' files in the current directory. % - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, intermod_directories, IntermodDirs2), GradeSubdirIntermodDirs = ["Mercury"/GradeString/FullArch | - list__filter(isnt(unify(dir__this_directory)), IntermodDirs2)], - globals__set_option(intermod_directories, + list.filter(isnt(unify(dir.this_directory)), IntermodDirs2)], + globals.set_option(intermod_directories, accumulating(GradeSubdirIntermodDirs), !Globals) ; UseGradeSubdirs = no @@ -1573,7 +1573,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % name, so we need to add the full path to the % header files in the current directory. % - globals__lookup_bool_option(!.Globals, use_subdirs, UseSubdirs), + globals.lookup_bool_option(!.Globals, use_subdirs, UseSubdirs), ( ( UseGradeSubdirs = yes -> MihsSubdir = "Mercury"/GradeString/FullArch/"Mercury"/"mihs" @@ -1583,11 +1583,11 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, fail ) -> - globals__lookup_accumulating_option(!.Globals, c_include_directory, + globals.lookup_accumulating_option(!.Globals, c_include_directory, CIncludeDirs1), SubdirCIncludeDirs = - [dir__this_directory, MihsSubdir | CIncludeDirs1], - globals__set_option(c_include_directory, + [dir.this_directory, MihsSubdir | CIncludeDirs1], + globals.set_option(c_include_directory, accumulating(SubdirCIncludeDirs), !Globals) ; true @@ -1631,17 +1631,17 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, ), % only set the backend foreign languages if they are unset - globals__lookup_accumulating_option(!.Globals, + globals.lookup_accumulating_option(!.Globals, backend_foreign_languages, CurrentBackendForeignLanguage), ( CurrentBackendForeignLanguage = [], - globals__set_option(backend_foreign_languages, + globals.set_option(backend_foreign_languages, accumulating(BackendForeignLanguages), !Globals) ; CurrentBackendForeignLanguage = [_ | _] ), - globals__lookup_int_option(!.Globals, compare_specialization, + globals.lookup_int_option(!.Globals, compare_specialization, CompareSpec), ( CompareSpec < 0 -> % This indicates that the option was not set by the user; @@ -1650,10 +1650,10 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, % different performance tradeoffs. ( HighLevel = no, - globals__set_option(compare_specialization, int(13), !Globals) + globals.set_option(compare_specialization, int(13), !Globals) ; HighLevel = yes, - globals__set_option(compare_specialization, int(14), !Globals) + globals.set_option(compare_specialization, int(14), !Globals) ) ; true @@ -1674,10 +1674,10 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, ), NumTagBits >= 2 -> - globals__set_option(can_compare_constants_as_ints, bool(yes), + globals.set_option(can_compare_constants_as_ints, bool(yes), !Globals) ; - globals__set_option(can_compare_constants_as_ints, bool(no), + globals.set_option(can_compare_constants_as_ints, bool(no), !Globals) ), @@ -1689,7 +1689,7 @@ postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0, ), unsafe_promise_unique(!Globals), - globals__io_set_globals(!.Globals, !IO) + globals.io_set_globals(!.Globals, !IO) ). % These option implications only affect the low-level (LLDS) code @@ -1735,7 +1735,7 @@ postprocess_options_lowlevel(!Globals) :- % the jump and label optimization having been done. They are turned % on above, but they still won't be executed unless optimize_repeat % is at least one. - globals__set_option(optimize_repeat, int(1), !Globals) + globals.set_option(optimize_repeat, int(1), !Globals) ; true ). @@ -1748,10 +1748,10 @@ postprocess_options_lowlevel(!Globals) :- globals::in, globals::out) is det. option_implies(SourceOption, ImpliedOption, ImpliedOptionValue, !Globals) :- - globals__lookup_bool_option(!.Globals, SourceOption, SourceOptionValue), + globals.lookup_bool_option(!.Globals, SourceOption, SourceOptionValue), ( SourceOptionValue = yes, - globals__set_option(ImpliedOption, ImpliedOptionValue, !Globals) + globals.set_option(ImpliedOption, ImpliedOptionValue, !Globals) ; SourceOptionValue = no ). @@ -1765,12 +1765,12 @@ option_implies(SourceOption, ImpliedOption, ImpliedOptionValue, !Globals) :- option_neg_implies(SourceOption, ImpliedOption, ImpliedOptionValue, !Globals) :- - globals__lookup_bool_option(!.Globals, SourceOption, SourceOptionValue), + globals.lookup_bool_option(!.Globals, SourceOption, SourceOptionValue), ( SourceOptionValue = yes ; SourceOptionValue = no, - globals__set_option(ImpliedOption, ImpliedOptionValue, !Globals) + globals.set_option(ImpliedOption, ImpliedOptionValue, !Globals) ). % option_requires(SourceBoolOption, RequiredOption, RequiredOptionValue, @@ -1783,8 +1783,8 @@ option_neg_implies(SourceOption, ImpliedOption, ImpliedOptionValue, option_requires(SourceOption, RequiredOption, RequiredOptionValue, ErrorMessage, Globals, !Errors) :- - globals__lookup_bool_option(Globals, SourceOption, SourceOptionValue), - globals__lookup_option(Globals, RequiredOption, OptionValue), + globals.lookup_bool_option(Globals, SourceOption, SourceOptionValue), + globals.lookup_option(Globals, RequiredOption, OptionValue), ( SourceOptionValue = yes, OptionValue \= RequiredOptionValue @@ -1803,7 +1803,7 @@ option_requires(SourceOption, RequiredOption, RequiredOptionValue, maybe_disable_smart_recompilation(Smart, ConflictingOption, ValueToDisableSmart, OptionDescr, !Globals, !IO) :- - globals__lookup_bool_option(!.Globals, ConflictingOption, Value), + globals.lookup_bool_option(!.Globals, ConflictingOption, Value), ( Smart = yes, Value = ValueToDisableSmart @@ -1817,19 +1817,19 @@ maybe_disable_smart_recompilation(Smart, ConflictingOption, io::di, io::uo) is det. disable_smart_recompilation(OptionDescr, !Globals, !IO) :- - globals__set_option(smart_recompilation, bool(no), !Globals), - globals__lookup_bool_option(!.Globals, warn_smart_recompilation, + globals.set_option(smart_recompilation, bool(no), !Globals), + globals.lookup_bool_option(!.Globals, warn_smart_recompilation, WarnSmart), ( WarnSmart = yes, - io__write_string("Warning: smart recompilation " ++ + io.write_string("Warning: smart recompilation " ++ "does not yet work with ", !IO), - io__write_string(OptionDescr, !IO), - io__write_string(".\n", !IO), - globals__lookup_bool_option(!.Globals, halt_at_warn, Halt), + io.write_string(OptionDescr, !IO), + io.write_string(".\n", !IO), + globals.lookup_bool_option(!.Globals, halt_at_warn, Halt), ( Halt = yes, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; Halt = no ) @@ -1838,14 +1838,14 @@ disable_smart_recompilation(OptionDescr, !Globals, !IO) :- ). usage_errors(Errors, !IO) :- - io__progname_base("mercury_compile", ProgName, !IO), - list__foldl(write_error_plain_with_progname(ProgName), Errors, !IO), - io__set_exit_status(1, !IO), + io.progname_base("mercury_compile", ProgName, !IO), + list.foldl(write_error_plain_with_progname(ProgName), Errors, !IO), + io.set_exit_status(1, !IO), usage(!IO). display_compiler_version(!IO) :- - library__version(Version), - io__write_strings([ + library.version(Version), + io.write_strings([ "Mercury Compiler, version ", Version, "\n", "Copyright (C) 1993-2006 The University of Melbourne\n" ], !IO). @@ -1853,11 +1853,11 @@ display_compiler_version(!IO) :- usage(!IO) :- % usage is called from many places; ensure that we don't print the % duplicate copies of the message. - globals__io_printing_usage(AlreadyPrinted, !IO), + globals.io_printing_usage(AlreadyPrinted, !IO), ( AlreadyPrinted = no, display_compiler_version(!IO), - io__write_strings([ + io.write_strings([ "Usage: mmc [] \n", "Use `mmc --help' for more information.\n" ], !IO) @@ -1869,17 +1869,17 @@ long_usage(!IO) :- % long_usage is called from only one place, so can't print duplicate % copies of the long usage message. We can print both a short and along % usage message, but there is no simple way to avoid that. - library__version(Version), - io__write_strings(["Mercury Compiler, version ", Version, "\n"], !IO), - io__write_string("Copyright (C) 1993-2006 " ++ + library.version(Version), + io.write_strings(["Mercury Compiler, version ", Version, "\n"], !IO), + io.write_string("Copyright (C) 1993-2006 " ++ "The University of Melbourne\n", !IO), - io__write_string("Usage: mmc [] \n", !IO), - io__write_string("Arguments:\n", !IO), - io__write_string("\tArguments ending in `.m' " ++ + io.write_string("Usage: mmc [] \n", !IO), + io.write_string("Arguments:\n", !IO), + io.write_string("\tArguments ending in `.m' " ++ "are assumed to be source file names.\n", !IO), - io__write_string("\tArguments that do not end in `.m' " ++ + io.write_string("\tArguments that do not end in `.m' " ++ "are assumed to be module names.\n", !IO), - io__write_string("Options:\n", !IO), + io.write_string("Options:\n", !IO), options_help(!IO). %-----------------------------------------------------------------------------% @@ -1924,15 +1924,15 @@ long_usage(!IO) :- convert_grade_option(GradeString, Options0, Options) :- reset_grade_options(Options0, Options1), split_grade_string(GradeString, Components), - set__init(NoComps), - list__foldl2((pred(CompStr::in, Opts0::in, Opts::out, + set.init(NoComps), + list.foldl2((pred(CompStr::in, Opts0::in, Opts::out, CompSet0::in, CompSet::out) is semidet :- grade_component_table(CompStr, Comp, CompOpts, MaybeTargets, _), % Check that the component isn't mentioned % more than once. - \+ set__member(Comp, CompSet0), - set__insert(CompSet0, Comp, CompSet), + \+ set.member(Comp, CompSet0), + set.insert(CompSet0, Comp, CompSet), add_option_list(CompOpts, Opts0, Opts1), % XXX Here the behaviour matches what used to happen @@ -1949,9 +1949,9 @@ convert_grade_option(GradeString, Options0, Options) :- option_table::out) is det. add_option_list(CompOpts, Opts0, Opts) :- - list__foldl((pred(Opt::in, Opts1::in, Opts2::out) is det :- + list.foldl((pred(Opt::in, Opts1::in, Opts2::out) is det :- Opt = Option - Data, - map__set(Opts1, Option, Data, Opts2) + map.set(Opts1, Option, Data, Opts2) ), CompOpts, Opts0, Opts). grade_directory_component(Globals, Grade) :- @@ -1960,9 +1960,9 @@ grade_directory_component(Globals, Grade) :- % implied by the file names (.pic_o vs .o, `.a' vs `.so'). % ( - string__sub_string_search(Grade0, ".picreg", PicRegIndex), - string__split(Grade0, PicRegIndex, LeftPart, RightPart0), - string__append(".picreg", RightPart, RightPart0) + string.sub_string_search(Grade0, ".picreg", PicRegIndex), + string.split(Grade0, PicRegIndex, LeftPart, RightPart0), + string.append(".picreg", RightPart, RightPart0) -> Grade = LeftPart ++ RightPart ; @@ -1970,7 +1970,7 @@ grade_directory_component(Globals, Grade) :- ). compute_grade(Globals, Grade) :- - globals__get_options(Globals, Options), + globals.get_options(Globals, Options), compute_grade_components(Options, Components), ( Components = [], @@ -1988,7 +1988,7 @@ construct_string([_ - Bit|Bits], Grade) :- ( Bits = [_|_], construct_string(Bits, Grade0), - string__append_list([Bit, ".", Grade0], Grade) + string.append_list([Bit, ".", Grade0], Grade) ; Bits = [], Grade = Bit @@ -2007,11 +2007,11 @@ compute_grade_components(Options, GradeComponents) :- % ie % all [Opt, Value] ( % member(Opt - Value, CompOpts) => - % map__search(Options, Opt, Value) + % map.search(Options, Opt, Value) % ) \+ ( - list__member(Opt - Value, CompOpts), - \+ map__search(Options, Opt, Value) + list.member(Opt - Value, CompOpts), + \+ map.search(Options, Opt, Value) ), % Don't include `.mm' or `.dmm' in grade strings % because they are just synonyms for `.mmsc' and @@ -2025,8 +2025,8 @@ compute_grade_components(Options, GradeComponents) :- % possible targets. ( MaybeTargets = yes(Targets), - list__member(Target, Targets), - map__search(Options, target, Target) + list.member(Target, Targets), + map.search(Options, target, Target) ; MaybeTargets = no ), @@ -2248,7 +2248,7 @@ reset_grade_options(Options0, Options) :- aggregate(grade_start_values, (pred(Pair::in, Opts0::in, Opts::out) is det :- Pair = Option - Value, - map__set(Opts0, Option, Value, Opts) + map.set(Opts0, Option, Value, Opts) ), Options0, Options). :- pred grade_start_values(pair(option, option_data)::out) is multi. @@ -2278,7 +2278,7 @@ grade_start_values(extend_stacks_when_needed - bool(no)). :- pred split_grade_string(string::in, list(string)::out) is semidet. split_grade_string(GradeStr, Components) :- - string__to_char_list(GradeStr, Chars), + string.to_char_list(GradeStr, Chars), split_grade_string_2(Chars, Components). :- pred split_grade_string_2(list(char)::in, list(string)::out) is semidet. @@ -2286,8 +2286,8 @@ split_grade_string(GradeStr, Components) :- split_grade_string_2([], []). split_grade_string_2(Chars, Components) :- Chars = [_|_], - list__takewhile(char_is_not('.'), Chars, ThisChars, RestChars0), - string__from_char_list(ThisChars, ThisComponent), + list.takewhile(char_is_not('.'), Chars, ThisChars, RestChars0), + string.from_char_list(ThisChars, ThisComponent), Components = [ThisComponent|RestComponents], ( RestChars0 = [_|RestChars], % discard the `.' diff --git a/compiler/hhf.m b/compiler/hhf.m index edbf08faa..4567ce642 100644 --- a/compiler/hhf.m +++ b/compiler/hhf.m @@ -17,7 +17,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__hhf. +:- module hlds.hhf. :- interface. :- import_module hlds.hlds_pred. @@ -69,7 +69,7 @@ process_pred(Simple, PredId, !ModuleInfo, !IO) :- clauses_info_varset(ClausesInfo, VarSet), some [!IG] ( !:IG = PredInfo0 ^ inst_graph_info, - inst_graph__init(HeadVars, InstGraph), + inst_graph.init(HeadVars, InstGraph), !:IG = !.IG ^ implementation_inst_graph := InstGraph, !:IG = !.IG ^ interface_inst_graph := InstGraph, !:IG = !.IG ^ interface_vars := HeadVars, @@ -94,8 +94,8 @@ process_pred(Simple, PredId, !ModuleInfo, !IO) :- !:IG = !.IG ^ interface_inst_graph := ImplementationInstGraph, solutions( (pred(V::out) is nondet :- - list__member(V0, HeadVars), - inst_graph__reachable(ImplementationInstGraph, + list.member(V0, HeadVars), + inst_graph.reachable(ImplementationInstGraph, V0, V) ), InterfaceVars), !:IG = !.IG ^ interface_vars := InterfaceVars, @@ -114,17 +114,17 @@ process_pred(Simple, PredId, !ModuleInfo, !IO) :- % pred_info_clauses_info(PredInfo2, ClausesInfo2), % clauses_info_headvars(ClausesInfo2, HeadVars), % clauses_info_varset(ClausesInfo2, VarSet), -% inst_graph__init(HeadVars, InterfaceInstGraph), +% inst_graph.init(HeadVars, InterfaceInstGraph), % InstGraphInfo0 = ( (PredInfo2 ^ inst_graph_info) % ^ interface_inst_graph := InterfaceInstGraph ) % ^ interface_varset := VarSet, -% map__foldl(process_proc(ModuleInfo0, HeadVars), +% map.foldl(process_proc(ModuleInfo0, HeadVars), % Procedures, InstGraphInfo0, InstGraphInfo1), % % % Calculate interface vars. % solutions((pred(V::out) is nondet :- -% list__member(V0, HeadVars), -% inst_graph__reachable(InstGraph, V0, V) +% list.member(V0, HeadVars), +% inst_graph.reachable(InstGraph, V0, V) % ), InterfaceVars), % InstGraphInfo = InstGraphInfo1 ^ interface_vars := % InterfaceVars, @@ -138,7 +138,7 @@ process_pred(Simple, PredId, !ModuleInfo, !IO) :- process_clauses_info(Simple, ModuleInfo, !ClausesInfo, InstGraph) :- clauses_info_varset(!.ClausesInfo, VarSet0), clauses_info_vartypes(!.ClausesInfo, VarTypes0), - inst_graph__init(VarTypes0 ^ keys, InstGraph0), + inst_graph.init(VarTypes0 ^ keys, InstGraph0), Info0 = hhf_info(InstGraph0, VarSet0, VarTypes0), clauses_info_headvars(!.ClausesInfo, HeadVars), @@ -152,7 +152,7 @@ process_clauses_info(Simple, ModuleInfo, !ClausesInfo, InstGraph) :- % Info1 = Info0 %; % Simple = no, - list__map_foldl(process_clause(HeadVars), + list.map_foldl(process_clause(HeadVars), Clauses0, Clauses, Info0, Info1) ), @@ -165,7 +165,7 @@ process_clauses_info(Simple, ModuleInfo, !ClausesInfo, InstGraph) :- Info = hhf_info(InstGraph1, VarSet, VarTypes), ( Simple = yes, - inst_graph__init(VarTypes ^ keys, InstGraph) + inst_graph.init(VarTypes ^ keys, InstGraph) ; Simple = no, InstGraph = InstGraph1 @@ -173,8 +173,8 @@ process_clauses_info(Simple, ModuleInfo, !ClausesInfo, InstGraph) :- % XXX do we need this (it slows things down a lot (i.e. uses 50% % of the runtime). - % varset__vars(VarSet1, Vars1), - % varset__ensure_unique_names(Vars1, "_", VarSet1, VarSet), + % varset.vars(VarSet1, Vars1), + % varset.ensure_unique_names(Vars1, "_", VarSet1, VarSet), clauses_info_set_varset(VarSet, !ClausesInfo), clauses_info_set_vartypes(VarTypes, !ClausesInfo). @@ -237,7 +237,7 @@ process_goal_expr(NonLocals, GoalInfo, GoalExpr0, GoalExpr, !HI) :- GoalExpr = GoalExpr0 ; GoalExpr0 = conj(ConjType, Goals0), - list__map_foldl(process_goal(NonLocals), Goals0, Goals1, !HI), + list.map_foldl(process_goal(NonLocals), Goals0, Goals1, !HI), ( ConjType = plain_conj, flatten_conj(Goals1, Goals) @@ -248,7 +248,7 @@ process_goal_expr(NonLocals, GoalInfo, GoalExpr0, GoalExpr, !HI) :- GoalExpr = conj(ConjType, Goals) ; GoalExpr0 = disj(Goals0), - list__map_foldl(goal_use_own_nonlocals, Goals0, Goals, !HI), + list.map_foldl(goal_use_own_nonlocals, Goals0, Goals, !HI), GoalExpr = disj(Goals) ; GoalExpr0 = switch(_, _, _), @@ -294,8 +294,8 @@ process_unify(functor(ConsId0, IsExistConstruct, ArgsA), NonLocals, GoalInfo0, TypeOfX = !.HI ^ vartypes ^ det_elem(X), qualify_cons_id(TypeOfX, ArgsA, ConsId0, _, ConsId), InstGraph0 = !.HI ^ inst_graph, - map__lookup(InstGraph0, X, node(Functors0, MaybeParent)), - ( map__search(Functors0, ConsId, ArgsB) -> + map.lookup(InstGraph0, X, node(Functors0, MaybeParent)), + ( map.search(Functors0, ConsId, ArgsB) -> make_unifications(ArgsA, ArgsB, GoalInfo0, Mode, Unif, Context, Unifications), Args = ArgsB @@ -303,14 +303,14 @@ process_unify(functor(ConsId0, IsExistConstruct, ArgsA), NonLocals, GoalInfo0, add_unifications(ArgsA, NonLocals, GoalInfo0, Mode, Unif, Context, Args, Unifications, !HI), InstGraph1 = !.HI ^ inst_graph, - map__det_insert(Functors0, ConsId, Args, Functors), - map__det_update(InstGraph1, X, node(Functors, MaybeParent), + map.det_insert(Functors0, ConsId, Args, Functors), + map.det_update(InstGraph1, X, node(Functors, MaybeParent), InstGraph2), - list__foldl(inst_graph__set_parent(X), Args, InstGraph2, InstGraph), + list.foldl(inst_graph.set_parent(X), Args, InstGraph2, InstGraph), !:HI = !.HI ^ inst_graph := InstGraph ), goal_info_get_nonlocals(GoalInfo0, GINonlocals0), - GINonlocals = GINonlocals0 `set__union` list_to_set(Args), + GINonlocals = GINonlocals0 `set.union` list_to_set(Args), goal_info_set_nonlocals(GINonlocals, GoalInfo0, GoalInfo), UnifyGoal = unify(X, functor(ConsId, IsExistConstruct, Args), Mode, Unif, Context) - GoalInfo, @@ -328,7 +328,7 @@ make_unifications([], [_ | _], _, _, _, _, _) :- make_unifications([A | As], [B | Bs], GI0, M, U, C, [unify(A, var(B), M, U, C) - GI | Us]) :- goal_info_get_nonlocals(GI0, GINonlocals0), - GINonlocals = GINonlocals0 `set__insert` A `set__insert` B, + GINonlocals = GINonlocals0 `set.insert` A `set.insert` B, goal_info_set_nonlocals(GINonlocals, GI0, GI), make_unifications(As, Bs, GI0, M, U, C, Us). @@ -342,24 +342,24 @@ add_unifications([A | As], NonLocals, GI0, M, U, C, [V | Vs], Goals, !HI) :- InstGraph0 = !.HI ^ inst_graph, ( ( - map__lookup(InstGraph0, A, Node), + map.lookup(InstGraph0, A, Node), Node = node(_, parent(_)) ; - A `set__member` NonLocals + A `set.member` NonLocals ) -> VarSet0 = !.HI ^ varset, VarTypes0 = !.HI ^ vartypes, - varset__new_var(VarSet0, V, VarSet), - map__lookup(VarTypes0, A, Type), - map__det_insert(VarTypes0, V, Type, VarTypes), - map__init(Empty), - map__det_insert(InstGraph0, V, node(Empty, top_level), InstGraph), + varset.new_var(VarSet0, V, VarSet), + map.lookup(VarTypes0, A, Type), + map.det_insert(VarTypes0, V, Type, VarTypes), + map.init(Empty), + map.det_insert(InstGraph0, V, node(Empty, top_level), InstGraph), !:HI = !.HI ^ varset := VarSet, !:HI = !.HI ^ vartypes := VarTypes, !:HI = !.HI ^ inst_graph := InstGraph, goal_info_get_nonlocals(GI0, GINonlocals0), - GINonlocals = GINonlocals0 `set__insert` V, + GINonlocals = GINonlocals0 `set.insert` V, goal_info_set_nonlocals(GINonlocals, GI0, GI), Goals = [unify(A, var(V), M, U, C) - GI | Goals0] ; @@ -373,7 +373,7 @@ flatten_conj([], []). flatten_conj([Goal | Goals0], Goals) :- flatten_conj(Goals0, Goals1), ( Goal = conj(plain_conj, SubGoals) - _ -> - list__append(SubGoals, Goals1, Goals) + list.append(SubGoals, Goals1, Goals) ; Goals = [Goal | Goals1] ). @@ -383,8 +383,8 @@ flatten_conj([Goal | Goals0], Goals) :- complete_inst_graph(ModuleInfo, !HI) :- InstGraph0 = !.HI ^ inst_graph, - map__keys(InstGraph0, Vars), - list__foldl(complete_inst_graph_node(ModuleInfo, Vars), Vars, !HI). + map.keys(InstGraph0, Vars), + list.foldl(complete_inst_graph_node(ModuleInfo, Vars), Vars, !HI). :- pred complete_inst_graph_node(module_info::in, list(prog_var)::in, prog_var::in, hhf_info::in, hhf_info::out) is det. @@ -392,11 +392,11 @@ complete_inst_graph(ModuleInfo, !HI) :- complete_inst_graph_node(ModuleInfo, BaseVars, Var, !HI) :- VarTypes0 = !.HI ^ vartypes, ( - map__search(VarTypes0, Var, Type), + map.search(VarTypes0, Var, Type), type_constructors(Type, ModuleInfo, Constructors), type_to_ctor_and_args(Type, TypeId, _) -> - list__foldl(maybe_add_cons_id(Var, ModuleInfo, BaseVars, TypeId), + list.foldl(maybe_add_cons_id(Var, ModuleInfo, BaseVars, TypeId), Constructors, !HI) ; true @@ -408,15 +408,15 @@ complete_inst_graph_node(ModuleInfo, BaseVars, Var, !HI) :- maybe_add_cons_id(Var, ModuleInfo, BaseVars, TypeId, Ctor, !HI) :- Ctor = ctor(_, _, Name, Args), ConsId = make_cons_id(Name, Args, TypeId), - map__lookup(!.HI ^ inst_graph, Var, node(Functors0, MaybeParent)), - ( map__contains(Functors0, ConsId) -> + map.lookup(!.HI ^ inst_graph, Var, node(Functors0, MaybeParent)), + ( map.contains(Functors0, ConsId) -> true ; - list__map_foldl(add_cons_id(Var, ModuleInfo, BaseVars), - Args, NewVars, !HI), - map__det_insert(Functors0, ConsId, NewVars, Functors), + list.map_foldl(add_cons_id(Var, ModuleInfo, BaseVars), Args, NewVars, + !HI), + map.det_insert(Functors0, ConsId, NewVars, Functors), !:HI = !.HI ^ inst_graph := - map__det_update(!.HI ^ inst_graph, Var, + map.det_update(!.HI ^ inst_graph, Var, node(Functors, MaybeParent)) ). @@ -433,10 +433,10 @@ add_cons_id(Var, ModuleInfo, BaseVars, Arg, NewVar, !HI) :- -> NewVar = NewVar0 ; - varset__new_var(VarSet0, NewVar, VarSet), - map__det_insert(VarTypes0, NewVar, ArgType, VarTypes), - map__init(Empty), - map__det_insert(InstGraph0, NewVar, node(Empty, parent(Var)), + varset.new_var(VarSet0, NewVar, VarSet), + map.det_insert(VarTypes0, NewVar, ArgType, VarTypes), + map.init(Empty), + map.det_insert(InstGraph0, NewVar, node(Empty, parent(Var)), InstGraph), !:HI = hhf_info(InstGraph, VarSet, VarTypes), complete_inst_graph_node(ModuleInfo, BaseVars, NewVar, !HI) @@ -447,13 +447,13 @@ add_cons_id(Var, ModuleInfo, BaseVars, Arg, NewVar, !HI) :- find_var_with_type(Var0, Type, InstGraph, VarTypes, BaseVars, Var) :- ( - map__search(VarTypes, Var0, Type0), + map.search(VarTypes, Var0, Type0), same_type(Type0, Type) -> Var = Var0 ; - map__lookup(InstGraph, Var0, node(_, parent(Var1))), - \+ Var1 `list__member` BaseVars, + map.lookup(InstGraph, Var0, node(_, parent(Var1))), + \+ Var1 `list.member` BaseVars, find_var_with_type(Var1, Type, InstGraph, VarTypes, BaseVars, Var) ). @@ -500,18 +500,18 @@ same_type_list([A | As], [B | Bs]) :- % proc_info_argmodes(ProcInfo, ArgModes), % % mode_list_get_initial_insts(ArgModes, ModuleInfo, InstsI), -% assoc_list__from_corresponding_lists(HeadVars, InstsI, VarInstsI), -% list__foldl(process_arg(ModuleInfo), VarInstsI, Info0, Info), +% assoc_list.from_corresponding_lists(HeadVars, InstsI, VarInstsI), +% list.foldl(process_arg(ModuleInfo), VarInstsI, Info0, Info), % % mode_list_get_final_insts(ArgModes, ModuleInfo, InstsF), -% assoc_list__from_corresponding_lists(HeadVars, InstsF, VarInstsF), -% list__foldl(process_arg(ModuleInfo), VarInstsF, Info0, Info). +% assoc_list.from_corresponding_lists(HeadVars, InstsF, VarInstsF), +% list.foldl(process_arg(ModuleInfo), VarInstsF, Info0, Info). % % :- pred process_arg(module_info::in, pair(prog_var, inst)::in, % inst_graph_info::in, inst_graph_info::out) is det. % % process_arg(ModuleInfo, Var - Inst, Info0, Info) :- -% map__init(Seen0), +% map.init(Seen0), % process_arg_inst(ModuleInfo, Var, Seen0, Inst, Info0, Info). % % :- pred process_arg_inst(module_info::in, prog_var::in, @@ -520,11 +520,11 @@ same_type_list([A | As], [B | Bs]) :- % % process_arg_inst(ModuleInfo, Var, Seen0, Inst0, Info0, Info) :- % ( Inst0 = defined_inst(InstName) -> -% map__det_insert(Seen0, InstName, Var, Seen), +% map.det_insert(Seen0, InstName, Var, Seen), % inst_lookup(ModuleInfo, InstName, Inst), % process_arg_inst(Inst, ModuleInfo, Var, Seen, Info0, Info) % ; Inst0 = bound(_, BoundInsts) -> -% list__foldl(process_bound_inst(ModuleInfo, Var, Seen0), +% list.foldl(process_bound_inst(ModuleInfo, Var, Seen0), % BoundInts, Info0, Info) % ; % Info = Info0 diff --git a/compiler/higher_order.m b/compiler/higher_order.m index f649f6475..9e41658e6 100644 --- a/compiler/higher_order.m +++ b/compiler/higher_order.m @@ -969,7 +969,7 @@ instance_matches(ClassTypes, Instance, Constraints, UnconstrainedTVarTypes, % XXX kind inference: % we assume all tvars have kind `star'. - map__init(KindMap), + map.init(KindMap), apply_rec_subst_to_tvar_list(KindMap, Subst, UnconstrainedTVars0, UnconstrainedTVarTypes). @@ -1734,7 +1734,7 @@ version_matches(Params, ModuleInfo, Request, Version, Match) :- % XXX kind inference: % we assume all tvars have kind `star' - map__init(KindMap), + map.init(KindMap), apply_variable_renaming_to_tvar_kind_map(TVarRenaming, KindMap, RenamedKindMap), apply_variable_renaming_to_tvar_list(TVarRenaming, @@ -2624,7 +2624,7 @@ output_higher_order_args(ModuleInfo, NumToDrop, Indent, [HOArg | HOArgs], CurriedHOArgs, IsConst), io.write_string("% ", !IO), list.duplicate(Indent + 1, " ", Spaces), - list.foldl(io__write_string, Spaces, !IO), + list.foldl(io.write_string, Spaces, !IO), ( IsConst = yes, io.write_string("const ", !IO) @@ -2788,7 +2788,7 @@ create_new_proc(NewPred, !.NewProcInfo, !NewPredInfo, !Info) :- ), % Add in the extra typeinfo vars. - list.map(polymorphism__build_type_info_type, + list.map(polymorphism.build_type_info_type, ExtraTypeInfoTVarTypes, ExtraTypeInfoTypes), proc_info_create_vars_from_types(ExtraTypeInfoTypes, ExtraTypeInfoVars, !NewProcInfo), @@ -3183,7 +3183,7 @@ substitute_rtti_var_info(_, non_rtti_var, non_rtti_var). :- func higher_order_args_size(list(higher_order_arg)) = int. higher_order_args_size(Args) = - list.foldl(int__max, list__map(higher_order_arg_size, Args), 0). + list.foldl(int.max, list.map(higher_order_arg_size, Args), 0). :- func higher_order_arg_size(higher_order_arg) = int. @@ -3193,7 +3193,7 @@ higher_order_arg_size(HOArg) = :- func higher_order_args_depth(list(higher_order_arg)) = int. higher_order_args_depth(Args) = - list.foldl(int__max, list__map(higher_order_arg_depth, Args), 0). + list.foldl(int.max, list.map(higher_order_arg_depth, Args), 0). :- func higher_order_arg_depth(higher_order_arg) = int. diff --git a/compiler/il_peephole.m b/compiler/il_peephole.m index aff38bac7..71a33695a 100644 --- a/compiler/il_peephole.m +++ b/compiler/il_peephole.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2000-2001, 2003-2005 The University of Melbourne. +% Copyright (C) 2000-2001, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -33,7 +33,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__il_peephole. +:- module ml_backend.il_peephole. :- interface. :- import_module ml_backend.ilasm. @@ -43,12 +43,12 @@ %-----------------------------------------------------------------------------% - % il_peephole__optimize(VerifyOnly, !IL): + % il_peephole_optimize(VerifyOnly, !IL): % % Peephole optimize a list of instructions, possibly only doing % those optimizations which are necessary for verifiable code. % -:- pred il_peephole__optimize(bool::in, +:- pred il_peephole_optimize(bool::in, list(ilasm__decl)::in, list(ilasm__decl)::out) is det. %-----------------------------------------------------------------------------% @@ -69,13 +69,13 @@ :- type instrs == list(instr). -optimize(VerifyOnly, Decls0, Decls) :- +il_peephole_optimize(VerifyOnly, Decls0, Decls) :- % We zip down to the end of the instruction list, and start attempting % to optimize instruction sequences. As long as we can continue % optimizing the instruction sequence, we keep doing so; % when we find a sequence we can't optimize, we back up and try % to optimize the sequence starting with the previous instruction. - list__map_foldl(optimize_decl(VerifyOnly), Decls0, Decls, no, _Mod). + list.map_foldl(optimize_decl(VerifyOnly), Decls0, Decls, no, _Mod). % Mod is a bool that says whether the code was modified as a % result of the optimization (that is, whether Decl \= Decl0). @@ -86,15 +86,15 @@ optimize(VerifyOnly, Decls0, Decls) :- optimize_decl(VerifyOnly, Decl0, Decl, !Mod) :- ( Decl0 = class(A, B, C, D, ClassMembers0) -> - list__map_foldl(optimize_class_member(VerifyOnly), + list.map_foldl(optimize_class_member(VerifyOnly), ClassMembers0, ClassMembers, !Mod), Decl = class(A, B, C, D, ClassMembers) ; Decl0 = method(A, MethodDecls0) -> - list__map_foldl(optimize_method_decl(VerifyOnly), MethodDecls0, + list.map_foldl(optimize_method_decl(VerifyOnly), MethodDecls0, MethodDecls, !Mod), Decl = method(A, MethodDecls) ; Decl0 = namespace(A, NamespaceDecls0) -> - list__map_foldl(optimize_decl(VerifyOnly), NamespaceDecls0, + list.map_foldl(optimize_decl(VerifyOnly), NamespaceDecls0, NamespaceDecls, !Mod), Decl = namespace(A, NamespaceDecls) ; @@ -106,21 +106,21 @@ optimize_decl(VerifyOnly, Decl0, Decl, !Mod) :- optimize_class_member(VerifyOnly, Decl0, Decl, !Mod) :- ( Decl0 = method(A, MethodDecls0) -> - list__map_foldl(optimize_method_decl(VerifyOnly), MethodDecls0, + list.map_foldl(optimize_method_decl(VerifyOnly), MethodDecls0, MethodDecls1, !Mod), ( !.Mod = yes, % Find the new maxstack. - MaxStacks = list__map((func(X) = + MaxStacks = list.map((func(X) = ( if X = instrs(I) then calculate_max_stack(I) else 0 )), MethodDecls1), - NewMaxStack = list__foldl((func(X, Y0) = X + Y0), + NewMaxStack = list.foldl((func(X, Y0) = X + Y0), MaxStacks, 0 ), % set the maxstack - MethodDecls = list__map((func(X) = + MethodDecls = list.map((func(X) = ( if X = maxstack(_) then maxstack(int32(NewMaxStack)) else X @@ -142,7 +142,7 @@ optimize_class_member(VerifyOnly, Decl0, Decl, !Mod) :- optimize_method_decl(VerifyOnly, Decl0, Decl, !Mod) :- ( Decl0 = instrs(Instrs0) -> optimize_instrs(VerifyOnly, Instrs0, Instrs, InstrsMod), - bool__or(InstrsMod, !Mod), + bool.or(InstrsMod, !Mod), Decl = instrs(Instrs) ; Decl0 = Decl @@ -159,7 +159,7 @@ optimize_2(_, [], [], no). optimize_2(VerifyOnly, [Instr0 | Instrs0], Instrs, Mod) :- optimize_2(VerifyOnly, Instrs0, Instrs1, Mod0), opt_instr(VerifyOnly, Instr0, Instrs1, Instrs, Mod1), - bool__or(Mod0, Mod1, Mod). + bool.or(Mod0, Mod1, Mod). % Try to optimize the beginning of the given instruction sequence. % If successful, try it again. @@ -200,12 +200,12 @@ opt_instr(VerifyOnly, Instr0, Instrs0, Instrs, Mod) :- % (but don't eliminate them because they may be useful). match(ret, _, Instrs0, Replacement) :- - list__takewhile((pred(X::in) is semidet :- + list.takewhile((pred(X::in) is semidet :- X \= label(_) ), Instrs0, PreLabel, NextInstrs0), PreLabel = [_ | _], - list__filter((pred(X::in) is semidet :- equivalent_to_nop(X) = yes), + list.filter((pred(X::in) is semidet :- equivalent_to_nop(X) = yes), PreLabel, KeepInstrs), Replacement = KeepInstrs ++ [comment("peephole -- eliminated instrs after ret"), ret] ++ @@ -217,7 +217,7 @@ match(ret, _, Instrs0, Replacement) :- match(br(label_target(Label)), VerifyOnly, Instrs0, Instrs) :- VerifyOnly = no, - list__takewhile((pred(X::in) is semidet :- + list.takewhile((pred(X::in) is semidet :- X \= label(Label) ), Instrs0, _, [label(Label) | NextInstrs0]), skip_nops(NextInstrs0, NextInstrs, _), @@ -242,8 +242,8 @@ match(stloc(Var), VerifyOnly, Instrs0, Instrs) :- Instrs1 = [ldloc(Var) | Rest], % Comment and replacement. Comment = "peephole: stloc(X), ldloc(X) --> dup, stloc(X)", - Replacement = list__append([dup | Nops], [stloc(Var)]), - Instrs = [comment(Comment) | list__append(Replacement, Rest)]. + Replacement = list.append([dup | Nops], [stloc(Var)]), + Instrs = [comment(Comment) | list.append(Replacement, Rest)]. % ldc(C) % stloc(X) @@ -260,7 +260,7 @@ match(stloc(Var), VerifyOnly, Instrs0, Instrs) :- match(ldc(Type, Const), VerifyOnly, [stloc(Var)| Instrs0], Instrs) :- VerifyOnly = no, % The pattern. - list__takewhile((pred(X::in) is semidet :- + list.takewhile((pred(X::in) is semidet :- X \= ldloc(Var), X \= label(_), X \= stloc(Var), @@ -273,7 +273,7 @@ match(ldc(Type, Const), VerifyOnly, [stloc(Var)| Instrs0], Instrs) :- Comment = comment( "peephole: ldc(X), stloc(X), ldloc(X) --> ldc(X), dup, stloc(X)"), Replacement = PreLdInstrs ++ [Comment, ldc(Type, Const), dup, stloc(Var)], - Instrs = list__append(Replacement, Rest). + Instrs = list.append(Replacement, Rest). % Two patterns begin with start_scope. @@ -302,11 +302,11 @@ match_start_scope_1(start_block(scope(Locals), Id), Instrs0, Instrs) :- IsUnusedLocal = (pred(V::in) is semidet :- % Var is in the locals V = name(VN), - assoc_list__search(Locals, VN, _), + assoc_list.search(Locals, VN, _), % No ldloc(Var) or ldloca(Var) anywhere in the scope % (should only really look until the end of this scope) - list__takewhile((pred(X::in) is semidet :- + list.takewhile((pred(X::in) is semidet :- X \= ldloc(V), X \= ldloca(V) ), Instrs0, _, []) @@ -319,7 +319,7 @@ match_start_scope_1(start_block(scope(Locals), Id), Instrs0, Instrs) :- % instructions (we reverse and flatten it later). FindDup = (pred(InstrIn::in, NextInput::out, R0::in, R::out) is semidet :- R0 = Pre0 - _NextInput0, - list__takewhile((pred(X::in) is semidet :- X \= dup), + list.takewhile((pred(X::in) is semidet :- X \= dup), InstrIn, Pre, Post0), Post0 = [dup | NextInput], ( @@ -339,7 +339,7 @@ match_start_scope_1(start_block(scope(Locals), Id), Instrs0, Instrs) :- FindStloc = (pred(R0::in, R::out) is semidet :- R0 = Pre0 - Post0, Post0 = InstrIn0, - list__takewhile((pred(X::in) is semidet :- equivalent_to_nop(X) = yes), + list.takewhile((pred(X::in) is semidet :- equivalent_to_nop(X) = yes), InstrIn0, Pre, MaybePost), MaybePost = [stloc(V) | Post], IsUnusedLocal(V), @@ -355,10 +355,10 @@ match_start_scope_1(start_block(scope(Locals), Id), Instrs0, Instrs) :- PreStlocInstrs = condense(reverse(PreStlocInstrsList)), % Comment and replacement. - Comment = string__format( + Comment = string.format( "peephole: dup, stloc(%s) --> nothing (%s unused in scope)", [s(VarName), s(VarName)]), - Instrs = list__condense([[start_block(scope(Locals), Id)], + Instrs = list.condense([[start_block(scope(Locals), Id)], PreStlocInstrs, Nops, [comment(Comment)], @@ -374,11 +374,11 @@ match_start_scope_2(start_block(scope(Locals), Id), Instrs0, Instrs) :- no_handwritten_code(Instrs0, Id), % The pattern. - list__filter((pred(VarName - _Type::in) is semidet :- + list.filter((pred(VarName - _Type::in) is semidet :- Var = name(VarName), % No stloc(Var) or ldloc(Var) or ldloca(Var) anywhere in the scope % (should only really look until the end of this scope) - list__takewhile((pred(X::in) is semidet :- + list.takewhile((pred(X::in) is semidet :- X \= ldloc(Var), X \= ldloca(Var), X \= stloc(Var) @@ -387,14 +387,14 @@ match_start_scope_2(start_block(scope(Locals), Id), Instrs0, Instrs) :- UnusedLocals = [_ | _], % Comment and replacement. - list__map((pred(VarName - _Type::in, Comment::out) is det :- - string__format("peephole: unused local var %s eliminated", + list.map((pred(VarName - _Type::in, Comment::out) is det :- + string.format("peephole: unused local var %s eliminated", [s(VarName)], CommentStr), Comment = comment(CommentStr) ), UnusedLocals, Comments), Replacement = [start_block(scope(UsedLocals), Id)], - Instrs = list__condense([Comments, Replacement, Instrs0]). + Instrs = list.condense([Comments, Replacement, Instrs0]). % Any scope without local variables may be eliminated. % XXX We don't do this yet because it would requirer finding the matching @@ -406,7 +406,7 @@ match_start_scope_2(start_block(scope(Locals), Id), Instrs0, Instrs) :- match4(start_block(scope([]), _), Instrs0, Instrs) :- Replacement = [], Rest = Instrs0, - Instrs = list__append(Replacement, Rest). + Instrs = list.append(Replacement, Rest). %-----------------------------------------------------------------------------% @@ -446,7 +446,7 @@ skip_over_block([Instr | Instrs], Id) = :- pred skip_comments(instrs::in, instrs::out, instrs::out) is det. skip_comments(Instrs0, Instrs, Comments) :- - list__takewhile(pred(ilds__comment(_)::in) is semidet, + list.takewhile(pred(ilds__comment(_)::in) is semidet, Instrs0, Comments, Instrs). % Skip over all the nop equivalents. @@ -454,7 +454,7 @@ skip_comments(Instrs0, Instrs, Comments) :- :- pred skip_nops(instrs::in, instrs::out, instrs::out) is det. skip_nops(Instrs0, Instrs, Nops) :- - list__takewhile((pred(X::in) is semidet :- equivalent_to_nop(X) = yes), + list.takewhile((pred(X::in) is semidet :- equivalent_to_nop(X) = yes), Instrs0, Nops, Instrs). % keep_looking(Producer, Condition, Input, IntermediateResult0, diff --git a/compiler/ilasm.m b/compiler/ilasm.m index b49251022..16c9cfeac 100644 --- a/compiler/ilasm.m +++ b/compiler/ilasm.m @@ -104,13 +104,13 @@ % .custom % A custom attribute. ; custom(custom_decl) - + % % Comments % - + ; comment_term(term) - + % Print almost anything using pprint.to_doc % (see library/pprint.m for limitations). ; some [T] comment_thing(T) @@ -168,14 +168,14 @@ ) ; custom(custom_decl) % custom attribute - + % % Comments % - + ; comment_term(term) ; comment(string) - + % print almost anything using pprint.to_doc % (see library/pprint.m for limitations). ; some [T] comment_thing(T). @@ -210,17 +210,17 @@ % Declarations that can form the body of a method. % :- type method_body_decl - ---> emitbyte(int32) + ---> emitbyte(int32) % raw byte output (danger! danger!) % "emits an int32 to the code section of the method" according % to the IL Assembly Language Programmers' Reference. % This probably means it can output IL bytecodes. - - ; maxstack(int32) + + ; maxstack(int32) % "Defines the maximum size of the stack, specified by the int32" % But does it measure in bits, nibbles, bytes, words or % something else? - + ; entrypoint % Is this "main"? ; zeroinit % Initialize locals to zero. ; custom(custom_decl) % Custom attribute. @@ -376,7 +376,7 @@ % It's a good idea to do this anyway, as there is apparently a % performance hit if you use assembly references to a symbol that is % in the local assembly. - + :- type ilasm_info ---> ilasm_info( current_assembly :: ilds.id @@ -462,18 +462,18 @@ output_decl(method(MethodHead, MethodDecls), !Info, !IO) :- io.write_string("}\n", !IO). output_decl(data(TLS, MaybeId, Body), !Info, !IO) :- io.write_string(".data ", !IO), - ( + ( TLS = yes, io.write_string("tls ", !IO) ; - TLS = no + TLS = no ), - ( + ( MaybeId = yes(Id), output_id(Id, !IO), io.write_string(" = ", !IO) ; - MaybeId = no + MaybeId = no ), output_data_body(Body, !IO). output_decl(comment_term(CommentTerm), !Info, !IO) :- @@ -495,7 +495,7 @@ output_decl(comment_thing(Thing), !Info, !IO) :- write(70, Doc, !IO), io.nl(!IO) ; - PrintComments = no + PrintComments = no ). output_decl(comment(CommentStr), !Info, !IO) :- globals.io_lookup_bool_option(auto_comments, PrintComments, !IO), diff --git a/compiler/inlining.m b/compiler/inlining.m index 6cb41fcd7..3cec2c34f 100644 --- a/compiler/inlining.m +++ b/compiler/inlining.m @@ -77,7 +77,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__inlining. +:- module transform_hlds.inlining. :- interface. :- import_module hlds.hlds_goal. @@ -205,18 +205,18 @@ inlining(!ModuleInfo, !IO) :- % this threshold then we don't inline it. % - whether we're in an MLDS grade % - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, inline_simple, Simple), - globals__lookup_bool_option(Globals, inline_single_use, SingleUse), - globals__lookup_int_option(Globals, inline_call_cost, CallCost), - globals__lookup_int_option(Globals, inline_compound_threshold, + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, inline_simple, Simple), + globals.lookup_bool_option(Globals, inline_single_use, SingleUse), + globals.lookup_int_option(Globals, inline_call_cost, CallCost), + globals.lookup_int_option(Globals, inline_compound_threshold, CompoundThreshold), - globals__lookup_int_option(Globals, inline_simple_threshold, + globals.lookup_int_option(Globals, inline_simple_threshold, SimpleThreshold), - globals__lookup_int_option(Globals, inline_vars_threshold, VarThreshold), - globals__lookup_bool_option(Globals, highlevel_code, HighLevelCode), - globals__io_get_trace_level(TraceLevel, !IO), - AnyTracing = bool__not(given_trace_level_is_none(TraceLevel)), + globals.lookup_int_option(Globals, inline_vars_threshold, VarThreshold), + globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode), + globals.io_get_trace_level(TraceLevel, !IO), + AnyTracing = bool.not(given_trace_level_is_none(TraceLevel)), Params = params(Simple, SingleUse, CallCost, CompoundThreshold, SimpleThreshold, VarThreshold, HighLevelCode, AnyTracing), @@ -230,9 +230,9 @@ inlining(!ModuleInfo, !IO) :- ; CompoundThreshold > 0 ) -> - dead_proc_elim__analyze(!.ModuleInfo, NeededMap) + dead_proc_elim.analyze(!.ModuleInfo, NeededMap) ; - map__init(NeededMap) + map.init(NeededMap) ), % % Build the call graph and extract the topological sort. @@ -248,8 +248,8 @@ inlining(!ModuleInfo, !IO) :- module_info_ensure_dependency_info(!ModuleInfo), module_info_dependency_info(!.ModuleInfo, DepInfo), hlds_dependency_info_get_dependency_ordering(DepInfo, SCCs), - list__condense(SCCs, PredProcs), - set__init(InlinedProcs0), + list.condense(SCCs, PredProcs), + set.init(InlinedProcs0), do_inlining(PredProcs, NeededMap, Params, InlinedProcs0, !ModuleInfo, !IO), % The dependency graph is now out of date and needs to be rebuilt. @@ -282,7 +282,7 @@ mark_predproc(PredProcId, NeededMap, Params, ModuleInfo, !InlinedProcs, !IO) :- PredProcId = proc(PredId, ProcId), module_info_pred_info(ModuleInfo, PredId, PredInfo), pred_info_procedures(PredInfo, Procs), - map__lookup(Procs, ProcId, ProcInfo), + map.lookup(Procs, ProcId, ProcInfo), proc_info_goal(ProcInfo, CalledGoal), Entity = proc(PredId, ProcId), @@ -292,7 +292,7 @@ mark_predproc(PredProcId, NeededMap, Params, ModuleInfo, !InlinedProcs, !IO) :- is_simple_goal(CalledGoal, SimpleThreshold) ; CompoundThreshold > 0, - map__search(NeededMap, Entity, Needed), + map.search(NeededMap, Entity, Needed), Needed = yes(NumUses), goal_size(CalledGoal, Size), % The size increase due to inlining at a call site is not Size, @@ -302,7 +302,7 @@ mark_predproc(PredProcId, NeededMap, Params, ModuleInfo, !InlinedProcs, !IO) :- (Size - CallCost) * NumUses =< CompoundThreshold ; SingleUse = yes, - map__search(NeededMap, Entity, Needed), + map.search(NeededMap, Entity, Needed), Needed = yes(NumUses), NumUses = 1 ), @@ -369,7 +369,7 @@ is_flat_simple_goal_list([Goal | Goals]) :- mark_proc_as_inlined(proc(PredId, ProcId), ModuleInfo, !InlinedProcs, !IO) :- - set__insert(!.InlinedProcs, proc(PredId, ProcId), !:InlinedProcs), + set.insert(!.InlinedProcs, proc(PredId, ProcId), !:InlinedProcs), module_info_pred_info(ModuleInfo, PredId, PredInfo), ( pred_info_requested_inlining(PredInfo) -> true @@ -449,9 +449,9 @@ in_predproc(PredProcId, InlinedProcs, Params, !ModuleInfo, !IO) :- some [!PredInfo, !ProcInfo] ( module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, !:PredInfo), + map.lookup(PredTable0, PredId, !:PredInfo), pred_info_procedures(!.PredInfo, ProcTable0), - map__lookup(ProcTable0, ProcId, !:ProcInfo), + map.lookup(ProcTable0, ProcId, !:ProcInfo), pred_info_get_univ_quant_tvars(!.PredInfo, UnivQTVars), pred_info_typevarset(!.PredInfo, TypeVarSet0), @@ -499,7 +499,7 @@ in_predproc(PredProcId, InlinedProcs, Params, !ModuleInfo, !IO) :- DidInlining = no ), - map__det_update(ProcTable0, ProcId, !.ProcInfo, ProcTable), + map.det_update(ProcTable0, ProcId, !.ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, !PredInfo), ( @@ -509,14 +509,14 @@ in_predproc(PredProcId, InlinedProcs, Params, !ModuleInfo, !IO) :- PurityChanged = no ), - map__det_update(PredTable0, PredId, !.PredInfo, PredTable), + map.det_update(PredTable0, PredId, !.PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo) ), % If the determinism of some sub-goals has changed, then we re-run % determinism analysis, because propagating the determinism information % through the procedure may lead to more efficient code. - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), ( DetChanged = yes, det_infer_proc(PredId, ProcId, !ModuleInfo, Globals, _, _, _) @@ -613,13 +613,13 @@ inlining_in_call(PredId, ProcId, ArgVars, Builtin, ; UserReq = no, % Okay, but will we exceed the number-of-variables threshold? - varset__vars(VarSet0, ListOfVars), - list__length(ListOfVars, ThisMany), + varset.vars(VarSet0, ListOfVars), + list.length(ListOfVars, ThisMany), % We need to find out how many variables the Callee has. proc_info_varset(ProcInfo, CalleeVarSet), - varset__vars(CalleeVarSet, CalleeListOfVars), - list__length(CalleeListOfVars, CalleeThisMany), + varset.vars(CalleeVarSet, CalleeListOfVars), + list.length(CalleeListOfVars, CalleeThisMany), TotalVars = ThisMany + CalleeThisMany, TotalVars =< VarThresh ) @@ -631,7 +631,7 @@ inlining_in_call(PredId, ProcId, ArgVars, Builtin, % If some of the output variables are not used in the calling % procedure, requantify the procedure. goal_info_get_nonlocals(GoalInfo0, NonLocals), - ( set__list_to_set(ArgVars) = NonLocals -> + ( set.list_to_set(ArgVars) = NonLocals -> Requantify = Requantify0 ; Requantify = yes @@ -712,8 +712,8 @@ do_inline_call(HeadTypeParams, ArgVars, PredInfo, ProcInfo, % for type variables which have been substituted away, % because those entries simply won't be used. - map__apply_to_list(HeadVars, CalleeVarTypes1, HeadTypes), - map__apply_to_list(ArgVars, VarTypes0, ArgTypes), + map.apply_to_list(HeadVars, CalleeVarTypes1, HeadTypes), + map.apply_to_list(ArgVars, VarTypes0, ArgTypes), pred_info_get_exist_quant_tvars(PredInfo, CalleeExistQVars), get_type_substitution(HeadTypes, ArgTypes, HeadTypeParams, @@ -735,9 +735,8 @@ do_inline_call(HeadTypeParams, ArgVars, PredInfo, ProcInfo, ), % Now rename apart the variables in the called goal. - rename_goal(HeadVars, ArgVars, VarSet0, CalleeVarSet, - VarSet, VarTypes1, CalleeVarTypes, VarTypes, Subn, - CalledGoal, Goal), + rename_goal(HeadVars, ArgVars, VarSet0, CalleeVarSet, VarSet, VarTypes1, + CalleeVarTypes, VarTypes, Subn, CalledGoal, Goal), apply_substitutions_to_rtti_varmaps(TypeRenaming, TypeSubn, Subn, CalleeRttiVarMaps0, CalleeRttiVarMaps1), @@ -751,7 +750,8 @@ do_inline_call(HeadTypeParams, ArgVars, PredInfo, ProcInfo, get_type_substitution(HeadTypes, ArgTypes, HeadTypeParams, CalleeExistQVars, TypeSubn) :- - ( CalleeExistQVars = [] -> + ( + CalleeExistQVars = [], ( type_list_subsumes(HeadTypes, ArgTypes, TypeSubn0) -> TypeSubn = TypeSubn0 ; @@ -764,13 +764,14 @@ get_type_substitution(HeadTypes, ArgTypes, % In those cases, we don't need to worry about the type % substitution. (Perhaps it would be better if polymorphism % introduced calls to unsafe_type_cast/2 for such cases.) - map__init(TypeSubn) + map.init(TypeSubn) ) ; + CalleeExistQVars = [_ | _], % For calls to existentially type preds, we may need to bind % type variables in the caller, not just those in the callee. ( - map__init(TypeSubn0), + map.init(TypeSubn0), type_unify_list(HeadTypes, ArgTypes, HeadTypeParams, TypeSubn0, TypeSubn1) -> @@ -781,15 +782,14 @@ get_type_substitution(HeadTypes, ArgTypes, ) ). -rename_goal(HeadVars, ArgVars, VarSet0, CalleeVarSet, - VarSet, VarTypes1, CalleeVarTypes, VarTypes, Subn, - CalledGoal, Goal) :- - map__from_corresponding_lists(HeadVars, ArgVars, Subn0), - varset__vars(CalleeVarSet, CalleeListOfVars), - goal_util__create_variables(CalleeListOfVars, +rename_goal(HeadVars, ArgVars, VarSet0, CalleeVarSet, VarSet, VarTypes1, + CalleeVarTypes, VarTypes, Subn, CalledGoal, Goal) :- + map.from_corresponding_lists(HeadVars, ArgVars, Subn0), + varset.vars(CalleeVarSet, CalleeListOfVars), + goal_util.create_variables(CalleeListOfVars, CalleeVarSet, CalleeVarTypes, VarSet0, VarSet, VarTypes1, VarTypes, Subn0, Subn), - goal_util__must_rename_vars_in_goal(Subn, CalledGoal, Goal). + goal_util.must_rename_vars_in_goal(Subn, CalledGoal, Goal). %-----------------------------------------------------------------------------% @@ -827,7 +827,7 @@ inlining_in_conj([Goal0 | Goals0], Goals, !Info) :- inlining_in_goal(Goal0, Goal1, !Info), goal_to_conj_list(Goal1, Goal1List), inlining_in_conj(Goals0, Goals1, !Info), - list__append(Goal1List, Goals1, Goals). + list.append(Goal1List, Goals1, Goals). %-----------------------------------------------------------------------------% @@ -856,7 +856,7 @@ should_inline_proc(PredId, ProcId, BuiltinState, HighLevelCode, UserReq = yes ; ( check_marker(Markers, heuristic_inline) - ; set__member(proc(PredId, ProcId), InlinedProcs) + ; set.member(proc(PredId, ProcId), InlinedProcs) ) -> UserReq = no @@ -867,7 +867,7 @@ should_inline_proc(PredId, ProcId, BuiltinState, HighLevelCode, can_inline_proc(PredId, ProcId, BuiltinState, InlinePromisedPure, CallingPredMarkers, ModuleInfo) :- module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, highlevel_code, HighLevelCode), + globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode), can_inline_proc_2(PredId, ProcId, BuiltinState, HighLevelCode, InlinePromisedPure, CallingPredMarkers, ModuleInfo). @@ -889,7 +889,7 @@ can_inline_proc_2(PredId, ProcId, BuiltinState, HighLevelCode, % for imported types. \+ ( pred_info_is_pseudo_imported(PredInfo), - hlds_pred__in_in_unification_proc_id(ProcId) + hlds_pred.in_in_unification_proc_id(ProcId) ), % Only try to inline procedures which are evaluated using normal @@ -929,7 +929,7 @@ can_inline_proc_2(PredId, ProcId, BuiltinState, HighLevelCode, % Only inline foreign_code if it is appropriate for % the target language. module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( ( CalledGoal = foreign_proc(ForeignAttributes, diff --git a/compiler/inst_graph.m b/compiler/inst_graph.m index f72930c26..8f482e4db 100644 --- a/compiler/inst_graph.m +++ b/compiler/inst_graph.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2001-2005 The University of Melbourne. +% Copyright (C) 2001-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__inst_graph. +:- module hlds.inst_graph. :- interface. :- import_module parse_tree.prog_data. @@ -198,25 +198,25 @@ %-----------------------------------------------------------------------------% init(Vars, InstGraph) :- - map__init(InstGraph0), - list__foldl(init_var, Vars, InstGraph0, InstGraph). + map.init(InstGraph0), + list.foldl(init_var, Vars, InstGraph0, InstGraph). :- pred init_var(prog_var::in, inst_graph::in, inst_graph::out) is det. init_var(Var, InstGraph0, InstGraph) :- - map__det_insert(InstGraph0, Var, node(map__init, top_level), InstGraph). + map.det_insert(InstGraph0, Var, node(map.init, top_level), InstGraph). set_parent(Parent, Child, InstGraph0, InstGraph) :- - map__lookup(InstGraph0, Child, node(Functors, MaybeParent0)), + map.lookup(InstGraph0, Child, node(Functors, MaybeParent0)), ( MaybeParent0 = top_level -> - map__det_update(InstGraph0, Child, node(Functors, parent(Parent)), + map.det_update(InstGraph0, Child, node(Functors, parent(Parent)), InstGraph) ; unexpected(this_file, "set_parent: node already has parent") ). top_level_node(InstGraph, Var, TopLevel) :- - map__lookup(InstGraph, Var, node(_, MaybeParent)), + map.lookup(InstGraph, Var, node(_, MaybeParent)), ( MaybeParent = parent(Parent), top_level_node(InstGraph, Parent, TopLevel) @@ -226,23 +226,23 @@ top_level_node(InstGraph, Var, TopLevel) :- ). descendant(InstGraph, Var, Descendant) :- - set__init(Seen), + set.init(Seen), descendant_2(InstGraph, Seen, Var, Descendant). :- pred descendant_2(inst_graph::in, set(prog_var)::in, prog_var::in, prog_var::out) is nondet. descendant_2(InstGraph, Seen, Var, Descendant) :- - map__lookup(InstGraph, Var, node(Functors, _)), - map__member(Functors, _ConsId, Args), - list__member(Arg, Args), + map.lookup(InstGraph, Var, node(Functors, _)), + map.member(Functors, _ConsId, Args), + list.member(Arg, Args), ( Descendant = Arg ; - ( Arg `set__member` Seen -> + ( Arg `set.member` Seen -> fail ; - descendant_2(InstGraph, Seen `set__insert` Arg, Arg, Descendant) + descendant_2(InstGraph, Seen `set.insert` Arg, Arg, Descendant) ) ). @@ -251,38 +251,38 @@ reachable(InstGraph, Var, Reachable) :- descendant(InstGraph, Var, Reachable). reachable_from_list(InstGraph, Vars, Reachable) :- - list__member(Var, Vars), + list.member(Var, Vars), reachable(InstGraph, Var, Reachable). foldl_reachable(P, InstGraph, Var, !Acc) :- % A possible alternate implementation: % aggregate(reachable(InstGraph, Var), P, !Acc). - foldl_reachable_aux(P, InstGraph, Var, set__init, !Acc). + foldl_reachable_aux(P, InstGraph, Var, set.init, !Acc). :- pred foldl_reachable_aux(pred(prog_var, T, T)::pred(in, in, out) is det, inst_graph::in, prog_var::in, set(prog_var)::in, T::in, T::out) is det. foldl_reachable_aux(P, InstGraph, Var, Seen, !Acc) :- P(Var, !Acc), - map__lookup(InstGraph, Var, node(Functors, _)), - map__foldl((pred(_ConsId::in, Args::in, MAcc0::in, MAcc::out) is det :- - list__foldl((pred(Arg::in, LAcc0::in, LAcc::out) is det :- - ( Arg `set__member` Seen -> + map.lookup(InstGraph, Var, node(Functors, _)), + map.foldl((pred(_ConsId::in, Args::in, MAcc0::in, MAcc::out) is det :- + list.foldl((pred(Arg::in, LAcc0::in, LAcc::out) is det :- + ( Arg `set.member` Seen -> LAcc = LAcc0 ; - foldl_reachable_aux(P, InstGraph, Arg, Seen `set__insert` Arg, + foldl_reachable_aux(P, InstGraph, Arg, Seen `set.insert` Arg, LAcc0, LAcc) ) ), Args, MAcc0, MAcc) ), Functors, !Acc). foldl_reachable_from_list(P, InstGraph, Vars) --> - list__foldl(foldl_reachable(P, InstGraph), Vars). + list.foldl(foldl_reachable(P, InstGraph), Vars). foldl_reachable2(P, InstGraph, Var, !Acc1, !Acc2) :- % A possible alternate implementation: % aggregate2(reachable(InstGraph, Var), P, !Acc1, !Acc2). - foldl_reachable_aux2(P, InstGraph, Var, set__init, !Acc1, !Acc2). + foldl_reachable_aux2(P, InstGraph, Var, set.init, !Acc1, !Acc2). :- pred foldl_reachable_aux2( pred(prog_var, T, T, U, U)::pred(in, in, out, in, out) is det, @@ -291,23 +291,23 @@ foldl_reachable2(P, InstGraph, Var, !Acc1, !Acc2) :- foldl_reachable_aux2(P, InstGraph, Var, Seen, !Acc1, !Acc2) :- P(Var, !Acc1, !Acc2), - map__lookup(InstGraph, Var, node(Functors, _)) , - map__foldl2((pred(_ConsId::in, Args::in, MAcc10::in, MAcc1::out, + map.lookup(InstGraph, Var, node(Functors, _)) , + map.foldl2((pred(_ConsId::in, Args::in, MAcc10::in, MAcc1::out, MAcc20::in, MAcc2::out) is det :- - list__foldl2((pred(Arg::in, LAccA0::in, LAccA::out, + list.foldl2((pred(Arg::in, LAccA0::in, LAccA::out, LAccB0::in, LAccB::out) is det :- - ( Arg `set__member` Seen -> + ( Arg `set.member` Seen -> LAccA = LAccA0, LAccB = LAccB0 ; - foldl_reachable_aux2(P, InstGraph, Arg, Seen `set__insert` Arg, + foldl_reachable_aux2(P, InstGraph, Arg, Seen `set.insert` Arg, LAccA0, LAccA, LAccB0, LAccB) ) ), Args, MAcc10, MAcc1, MAcc20, MAcc2) ), Functors, !Acc1, !Acc2). foldl_reachable_from_list2(P, InstGraph, Vars, !Acc1, !Acc2) :- - list__foldl2(foldl_reachable2(P, InstGraph), Vars, + list.foldl2(foldl_reachable2(P, InstGraph), Vars, !Acc1, !Acc2). corresponding_nodes(InstGraph, A, B, V, W) :- @@ -315,7 +315,7 @@ corresponding_nodes(InstGraph, A, B, V, W) :- corresponding_nodes(InstGraphA, InstGraphB, A, B, V, W) :- corresponding_nodes_2(InstGraphA, InstGraphB, - set__init, set__init, A, B, V, W). + set.init, set.init, A, B, V, W). :- pred corresponding_nodes_2(inst_graph::in, inst_graph::in, set(prog_var)::in, set(prog_var)::in, prog_var::in, prog_var::in, @@ -324,30 +324,30 @@ corresponding_nodes(InstGraphA, InstGraphB, A, B, V, W) :- corresponding_nodes_2(_, _, _, _, A, B, A, B). corresponding_nodes_2(InstGraphA, InstGraphB, SeenA0, SeenB0, A, B, V, W) :- not ( - A `set__member` SeenA0, - B `set__member` SeenB0 + A `set.member` SeenA0, + B `set.member` SeenB0 ), - map__lookup(InstGraphA, A, node(FunctorsA, _)), - map__lookup(InstGraphB, B, node(FunctorsB, _)), + map.lookup(InstGraphA, A, node(FunctorsA, _)), + map.lookup(InstGraphB, B, node(FunctorsB, _)), - SeenA = SeenA0 `set__insert` A, - SeenB = SeenB0 `set__insert` B, + SeenA = SeenA0 `set.insert` A, + SeenB = SeenB0 `set.insert` B, - ( map__member(FunctorsA, ConsId, ArgsA) -> - ( map__is_empty(FunctorsB) -> - list__member(V0, ArgsA), + ( map.member(FunctorsA, ConsId, ArgsA) -> + ( map.is_empty(FunctorsB) -> + list.member(V0, ArgsA), corresponding_nodes_2(InstGraphA, InstGraphB, SeenA, SeenB, V0, B, V, W) ; - map__search(FunctorsB, ConsId, ArgsB), + map.search(FunctorsB, ConsId, ArgsB), corresponding_members(ArgsA, ArgsB, V0, W0), corresponding_nodes_2(InstGraphA, InstGraphB, SeenA, SeenB, V0, W0, V, W) ) ; - map__member(FunctorsB, _ConsId, ArgsB), - list__member(W0, ArgsB), + map.member(FunctorsB, _ConsId, ArgsB), + list.member(W0, ArgsB), corresponding_nodes_2(InstGraphA, InstGraphB, SeenA, SeenB, A, W0, V, W) ). @@ -361,24 +361,24 @@ corresponding_members([_ | As], [_ | Bs], A, B) :- corresponding_members(As, Bs, A, B). merge(InstGraph0, VarSet0, NewInstGraph, NewVarSet, InstGraph, VarSet, Sub) :- - varset__merge_subst_without_names(VarSet0, NewVarSet, VarSet, Sub0), + varset.merge_subst_without_names(VarSet0, NewVarSet, VarSet, Sub0), ( - map__map_values(pred(_::in, term__variable(V)::in, V::out) is semidet, + map.map_values(pred(_::in, term.variable(V)::in, V::out) is semidet, Sub0, Sub1) -> Sub = Sub1 ; unexpected(this_file, "merge: non-variable terms in substitution") ), - map__foldl((pred(Var0::in, Node0::in, IG0::in, IG::out) is det :- + map.foldl((pred(Var0::in, Node0::in, IG0::in, IG::out) is det :- Node0 = node(Functors0, MaybeParent), - map__map_values( + map.map_values( (pred(_::in, Args0::in, Args::out) is det :- - map__apply_to_list(Args0, Sub, Args)), + map.apply_to_list(Args0, Sub, Args)), Functors0, Functors), Node = node(Functors, MaybeParent), - map__lookup(Sub, Var0, Var), - map__det_insert(IG0, Var, Node, IG) + map.lookup(Sub, Var0, Var), + map.det_insert(IG0, Var, Node, IG) ), NewInstGraph, InstGraph0, InstGraph). %-----------------------------------------------------------------------------% @@ -386,9 +386,9 @@ merge(InstGraph0, VarSet0, NewInstGraph, NewVarSet, InstGraph, VarSet, Sub) :- % join(InstGraphA, VarSetA, InstGraphB, VarSetB, % InstGraph, VarSet) :- % solutions((pred(V::out) is nondet :- -% map__member(InstGraphB, V, node(_, top_level)) +% map.member(InstGraphB, V, node(_, top_level)) % ), VarsB), -% list__foldl2(join_nodes(InstGraphB, VarSetB), VarsB, InstGraphA, +% list.foldl2(join_nodes(InstGraphB, VarSetB), VarsB, InstGraphA, % InstGraph, VarSetA, VarSet). % % :- pred join_nodes(inst_graph, prog_varset, prog_var, inst_graph, inst_graph, @@ -400,45 +400,45 @@ merge(InstGraph0, VarSet0, NewInstGraph, NewVarSet, InstGraph, VarSet, Sub) :- %-----------------------------------------------------------------------------% dump(InstGraph, VarSet, !IO) :- - map__foldl(dump_node(VarSet), InstGraph, !IO). + map.foldl(dump_node(VarSet), InstGraph, !IO). :- pred dump_node(prog_varset::in, prog_var::in, node::in, io::di, io::uo) is det. dump_node(VarSet, Var, Node, !IO) :- Node = node(Functors, MaybeParent), - io__write_string("%% ", !IO), - term_io__write_variable(Var, VarSet, !IO), - io__write_string(": ", !IO), + io.write_string("%% ", !IO), + term_io.write_variable(Var, VarSet, !IO), + io.write_string(": ", !IO), ( MaybeParent = parent(Parent), - term_io__write_variable(Parent, VarSet, !IO) + term_io.write_variable(Parent, VarSet, !IO) ; MaybeParent = top_level ), - io__nl(!IO), - map__foldl(dump_functor(VarSet), Functors, !IO). + io.nl(!IO), + map.foldl(dump_functor(VarSet), Functors, !IO). :- pred dump_functor(prog_varset::in, cons_id::in, list(prog_var)::in, io::di, io::uo) is det. dump_functor(VarSet, ConsId, Args, !IO) :- - io__write_string("%%\t", !IO), - hlds_out__write_cons_id(ConsId, !IO), + io.write_string("%%\t", !IO), + hlds_out.write_cons_id(ConsId, !IO), ( Args = [_ | _], - io__write_char('(', !IO), - io__write_list(Args, ", ", dump_var(VarSet), !IO), - io__write_char(')', !IO) + io.write_char('(', !IO), + io.write_list(Args, ", ", dump_var(VarSet), !IO), + io.write_char(')', !IO) ; Args = [] ), - io__nl(!IO). + io.nl(!IO). :- pred dump_var(prog_varset::in, prog_var::in, io::di, io::uo) is det. dump_var(VarSet, Var, !IO) :- - term_io__write_variable(Var, VarSet, !IO). + term_io.write_variable(Var, VarSet, !IO). %-----------------------------------------------------------------------------% @@ -464,8 +464,8 @@ dump_var(VarSet, Var, !IO) :- ). inst_graph_info_init = inst_graph_info(InstGraph, [], VarSet, InstGraph) :- - varset__init(VarSet), - map__init(InstGraph). + varset.init(VarSet), + map.init(InstGraph). %-----------------------------------------------------------------------------% diff --git a/compiler/inst_match.m b/compiler/inst_match.m index ec34e0edf..3e29e3e54 100644 --- a/compiler/inst_match.m +++ b/compiler/inst_match.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1995-1998, 2000-2005 The University of Melbourne. +% Copyright (C) 1995-1998, 2000-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -37,7 +37,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__inst_match. +:- module check_hlds.inst_match. :- interface. :- import_module hlds.hlds_module. @@ -417,7 +417,7 @@ sub(Info) = Sub :- :- func init_inst_match_info(module_info) = inst_match_info. init_inst_match_info(ModuleInfo) = - inst_match_info(ModuleInfo, set__init, no, none, match, yes). + inst_match_info(ModuleInfo, set.init, no, none, match, yes). :- pred swap_sub( pred(inst_match_info, inst_match_info)::in(pred(in, out) is semidet), @@ -446,12 +446,12 @@ swap_calculate_sub(none) = none. inst_matches_initial_2(InstA, InstB, MaybeType, !Info) :- ThisExpansion = inst_match_inputs(InstA, InstB, MaybeType), - ( set__member(ThisExpansion, !.Info ^ expansions) -> + ( set.member(ThisExpansion, !.Info ^ expansions) -> true ; inst_expand(!.Info ^ module_info, InstA, InstA2), inst_expand(!.Info ^ module_info, InstB, InstB2), - set__insert(!.Info ^ expansions, ThisExpansion, Expansions1), + set.insert(!.Info ^ expansions, ThisExpansion, Expansions1), handle_inst_var_subs(inst_matches_initial_2, inst_matches_initial_4, InstA2, InstB2, MaybeType, !.Info ^ expansions := Expansions1, !:Info) @@ -565,7 +565,7 @@ inst_matches_initial_4(ground(UniqA, _GII_A), bound(UniqB, ListB), MaybeType, MaybeType = yes(Type), % We can only check this case properly if the type is known. compare_uniqueness(!.Info ^ uniqueness_comparison, UniqA, UniqB), - bound_inst_list_is_complete_for_type(set__init, !.Info ^ module_info, + bound_inst_list_is_complete_for_type(set.init, !.Info ^ module_info, ListB, Type), ground_matches_initial_bound_inst_list(UniqA, ListB, yes(Type), !Info). @@ -582,7 +582,7 @@ inst_matches_initial_4(abstract_inst(_,_), any(shared), _, !Info). inst_matches_initial_4(abstract_inst(_,_), free, _, !Info). inst_matches_initial_4(abstract_inst(Name, ArgsA), abstract_inst(Name, ArgsB), _Type, !Info) :- - list__duplicate(length(ArgsA), no, MaybeTypes), + list.duplicate(length(ArgsA), no, MaybeTypes), % XXX how do we get the argument types for an abstract inst? inst_list_matches_initial(ArgsA, ArgsB, MaybeTypes, !Info). inst_matches_initial_4(not_reached, _, _, !Info). @@ -600,7 +600,7 @@ ground_matches_initial_bound_inst_list(_, [], _, !Info). ground_matches_initial_bound_inst_list(Uniq, [functor(ConsId, Args) | List], MaybeType, !Info) :- maybe_get_cons_id_arg_types(!.Info ^ module_info, MaybeType, ConsId, - list__length(Args), MaybeTypes), + list.length(Args), MaybeTypes), ground_matches_initial_inst_list(Uniq, Args, MaybeTypes, !Info), ground_matches_initial_bound_inst_list(Uniq, List, MaybeType, !Info). @@ -625,19 +625,19 @@ ground_matches_initial_inst_list(Uniq, [Inst | Insts], [Type | Types], bound_inst_list_is_complete_for_type(Expansions, ModuleInfo, BoundInsts, Type) :- % Is this a type for which cons_ids are recorded in the type_table? - type_util__cons_id_arg_types(ModuleInfo, Type, _, _), + type_util.cons_id_arg_types(ModuleInfo, Type, _, _), % Is there a bound_inst for each cons_id in the type_table? all [ConsId, ArgTypes] ( - type_util__cons_id_arg_types(ModuleInfo, Type, ConsId, ArgTypes) + type_util.cons_id_arg_types(ModuleInfo, Type, ConsId, ArgTypes) => ( - list__member(functor(ConsId0, ArgInsts), BoundInsts), - % Cons_ids returned from type_util__cons_id_arg_types + list.member(functor(ConsId0, ArgInsts), BoundInsts), + % Cons_ids returned from type_util.cons_id_arg_types % are not module-qualified so we need to call % equivalent_cons_ids instead of just using `=/2'. equivalent_cons_ids(ConsId0, ConsId), - list__map(inst_is_complete_for_type(Expansions, ModuleInfo), + list.map(inst_is_complete_for_type(Expansions, ModuleInfo), ArgInsts, ArgTypes) ) ). @@ -647,11 +647,11 @@ bound_inst_list_is_complete_for_type(Expansions, ModuleInfo, BoundInsts, inst_is_complete_for_type(Expansions, ModuleInfo, Inst, Type) :- ( Inst = defined_inst(Name) -> - ( set__member(Name, Expansions) -> + ( set.member(Name, Expansions) -> true ; inst_lookup(ModuleInfo, Name, ExpandedInst), - inst_is_complete_for_type(Expansions `set__insert` Name, + inst_is_complete_for_type(Expansions `set.insert` Name, ModuleInfo, ExpandedInst, Type) ) ; Inst = bound(_, List) -> @@ -725,7 +725,7 @@ greater_than_disregard_module_qual(ConsIdA, ConsIdB) :- update_inst_var_sub(InstVars, InstA, MaybeType, !Info) :- ( !.Info ^ maybe_sub = yes(_), - set__fold(update_inst_var_sub_2(InstA, MaybeType), + set.fold(update_inst_var_sub_2(InstA, MaybeType), InstVars, !Info) ; !.Info ^ maybe_sub = no @@ -762,7 +762,7 @@ ground_inst_info_matches_initial(GroundInstInfoA, none, _, _, !Info) :- ground_inst_info_matches_initial(none, higher_order(PredInstB), _, Type, !Info) :- PredInstB = pred_inst_info(function, ArgModes, _Det), - Arity = list__length(ArgModes), + Arity = list.length(ArgModes), PredInstA = pred_inst_info_standard_func_mode(Arity), pred_inst_matches_2(PredInstA, PredInstB, Type, !Info). ground_inst_info_matches_initial(higher_order(PredInstA), @@ -905,7 +905,7 @@ bound_inst_list_matches_initial([X | Xs], [Y | Ys], MaybeType, !Info) :- Y = functor(ConsIdY, ArgsY), ( equivalent_cons_ids(ConsIdX, ConsIdY) -> maybe_get_cons_id_arg_types(!.Info ^ module_info, MaybeType, - ConsIdX, list__length(ArgsX), MaybeTypes), + ConsIdX, list.length(ArgsX), MaybeTypes), inst_list_matches_initial(ArgsX, ArgsY, MaybeTypes, !Info), bound_inst_list_matches_initial(Xs, Ys, MaybeType, !Info) ; @@ -962,14 +962,14 @@ inst_matches_final(InstA, InstB, Type, ModuleInfo) :- inst_matches_final_2(InstA, InstB, MaybeType, !Info) :- ThisExpansion = inst_match_inputs(InstA, InstB, MaybeType), - ( set__member(ThisExpansion, !.Info ^ expansions) -> + ( set.member(ThisExpansion, !.Info ^ expansions) -> true ; InstA = InstB -> true ; inst_expand(!.Info ^ module_info, InstA, InstA2), inst_expand(!.Info ^ module_info, InstB, InstB2), - set__insert(!.Info ^ expansions, ThisExpansion, Expansions1), + set.insert(!.Info ^ expansions, ThisExpansion, Expansions1), handle_inst_var_subs(inst_matches_final_2, inst_matches_final_3, InstA2, InstB2, MaybeType, !.Info ^ expansions := Expansions1, !:Info) @@ -1024,7 +1024,7 @@ inst_matches_final_3(ground(UniqA, GroundInstInfoA), bound(UniqB, ListB), ( MaybeType = yes(Type), % We can only do this check if the type is known. - bound_inst_list_is_complete_for_type(set__init, + bound_inst_list_is_complete_for_type(set.init, !.Info ^ module_info, ListB, Type) ; true @@ -1041,7 +1041,7 @@ inst_matches_final_3(ground(UniqA, GroundInstInfoA), inst_matches_final_3(abstract_inst(_, _), any(shared), _, !Info). inst_matches_final_3(abstract_inst(Name, ArgsA), abstract_inst(Name, ArgsB), _MaybeType, !Info) :- - list__duplicate(length(ArgsA), no, MaybeTypes), + list.duplicate(length(ArgsA), no, MaybeTypes), % XXX how do we get the argument types for an abstract inst? inst_list_matches_final(ArgsA, ArgsB, MaybeTypes, !Info). inst_matches_final_3(not_reached, _, _, !Info). @@ -1050,7 +1050,7 @@ inst_matches_final_3(constrained_inst_vars(InstVarsA, InstA), InstB, MaybeType, ( InstB = constrained_inst_vars(InstVarsB, InstB1) -> % Constrained_inst_vars match_final only if InstVarsA contains % all the variables in InstVarsB - InstVarsB `set__subset` InstVarsA, + InstVarsB `set.subset` InstVarsA, inst_matches_final_2(InstA, InstB1, MaybeType, !Info) ; inst_matches_final_2(InstA, InstB, MaybeType, !Info) @@ -1065,7 +1065,7 @@ ground_inst_info_matches_final(GroundInstInfoA, none, _, !Info) :- GroundInstInfoA). ground_inst_info_matches_final(none, higher_order(PredInstB), Type, !Info) :- PredInstB = pred_inst_info(function, ArgModes, _Det), - Arity = list__length(ArgModes), + Arity = list.length(ArgModes), PredInstA = pred_inst_info_standard_func_mode(Arity), pred_inst_matches_2(PredInstA, PredInstB, Type, !Info). ground_inst_info_matches_final(higher_order(PredInstA), @@ -1101,7 +1101,7 @@ bound_inst_list_matches_final([X | Xs], [Y | Ys], MaybeType, !Info) :- Y = functor(ConsIdY, ArgsY), ( equivalent_cons_ids(ConsIdX, ConsIdY) -> maybe_get_cons_id_arg_types(!.Info ^ module_info, MaybeType, - ConsIdX, list__length(ArgsX), MaybeTypes), + ConsIdX, list.length(ArgsX), MaybeTypes), inst_list_matches_final(ArgsX, ArgsY, MaybeTypes, !Info), bound_inst_list_matches_final(Xs, Ys, MaybeType, !Info) ; @@ -1133,14 +1133,14 @@ inst_matches_binding_allow_any_any(InstA, InstB, Type, ModuleInfo) :- inst_matches_binding_2(InstA, InstB, MaybeType, !Info) :- ThisExpansion = inst_match_inputs(InstA, InstB, MaybeType), - ( set__member(ThisExpansion, !.Info ^ expansions) -> + ( set.member(ThisExpansion, !.Info ^ expansions) -> true ; inst_expand_and_remove_constrained_inst_vars( !.Info ^ module_info, InstA, InstA2), inst_expand_and_remove_constrained_inst_vars( !.Info ^ module_info, InstB, InstB2), - set__insert(!.Info ^ expansions, ThisExpansion, Expansions1), + set.insert(!.Info ^ expansions, ThisExpansion, Expansions1), inst_matches_binding_3(InstA2, InstB2, MaybeType, !.Info ^ expansions := Expansions1, !:Info) ). @@ -1184,7 +1184,7 @@ inst_matches_binding_3(ground(_UniqA, _), bound(_UniqB, ListB), MaybeType, ( MaybeType = yes(Type), % We can only do this check if the type is known. - bound_inst_list_is_complete_for_type(set__init, + bound_inst_list_is_complete_for_type(set.init, !.Info ^ module_info, ListB, Type) ; true @@ -1199,7 +1199,7 @@ inst_matches_binding_3(ground(_UniqA, GroundInstInfoA), MaybeType, !.Info ^ module_info). inst_matches_binding_3(abstract_inst(Name, ArgsA), abstract_inst(Name, ArgsB), _MaybeType, !Info) :- - list__duplicate(length(ArgsA), no, MaybeTypes), + list.duplicate(length(ArgsA), no, MaybeTypes), % XXX how do we get the argument types for an abstract inst? inst_list_matches_binding(ArgsA, ArgsB, MaybeTypes, !Info). inst_matches_binding_3(not_reached, _, _, !Info). @@ -1211,7 +1211,7 @@ ground_inst_info_matches_binding(_, none, _, _). ground_inst_info_matches_binding(none, higher_order(PredInstB), MaybeType, ModuleInfo) :- PredInstB = pred_inst_info(function, ArgModes, _Det), - Arity = list__length(ArgModes), + Arity = list.length(ArgModes), PredInstA = pred_inst_info_standard_func_mode(Arity), pred_inst_matches_1(PredInstA, PredInstB, MaybeType, ModuleInfo). ground_inst_info_matches_binding(higher_order(PredInstA), @@ -1247,7 +1247,7 @@ bound_inst_list_matches_binding([X | Xs], [Y | Ys], MaybeType, !Info) :- Y = functor(ConsIdY, ArgsY), ( equivalent_cons_ids(ConsIdX, ConsIdY) -> maybe_get_cons_id_arg_types(!.Info ^ module_info, MaybeType, - ConsIdX, list__length(ArgsX), MaybeTypes), + ConsIdX, list.length(ArgsX), MaybeTypes), inst_list_matches_binding(ArgsX, ArgsY, MaybeTypes, !Info), bound_inst_list_matches_binding(Xs, Ys, MaybeType, !Info) ; @@ -1347,9 +1347,8 @@ inst_is_ground(ModuleInfo, Inst) :- is semidet. inst_is_ground(ModuleInfo, MaybeType, Inst) :- - set__init(Expansions0), - inst_is_ground_1(ModuleInfo, MaybeType, Inst, - Expansions0, _Expansions). + set.init(Expansions0), + inst_is_ground_1(ModuleInfo, MaybeType, Inst, Expansions0, _Expansions). % The third arg is the set of insts which have already been expanded - we % use this to avoid going into an infinite loop. @@ -1358,16 +1357,15 @@ inst_is_ground(ModuleInfo, MaybeType, Inst) :- set(mer_inst)::in, set(mer_inst)::out) is semidet. inst_is_ground_1(ModuleInfo, MaybeType, Inst, !Expansions) :- - ( set__member(Inst, !.Expansions) -> + ( set.member(Inst, !.Expansions) -> true ; ( Inst \= any(_) -> - svset__insert(Inst, !Expansions) + svset.insert(Inst, !Expansions) ; true ), - inst_is_ground_2(ModuleInfo, MaybeType, Inst, - !Expansions) + inst_is_ground_2(ModuleInfo, MaybeType, Inst, !Expansions) ). :- pred inst_is_ground_2(module_info::in, maybe(mer_type)::in, mer_inst::in, @@ -1394,7 +1392,7 @@ inst_is_ground_2(ModuleInfo, MaybeType, any(Uniq), !Expansions) :- % `any', or the equivalent. Fails for abstract insts. % inst_is_ground_or_any(ModuleInfo, Inst) :- - set__init(Expansions0), + set.init(Expansions0), inst_is_ground_or_any_2(ModuleInfo, Inst, Expansions0, _Expansions). % The third arg is the set of insts which have already been expanded - we @@ -1416,10 +1414,10 @@ inst_is_ground_or_any_2(ModuleInfo, Inst, !Expansions) :- inst_is_ground_or_any_2(ModuleInfo, Inst2, !Expansions). inst_is_ground_or_any_2(ModuleInfo, Inst, !Expansions) :- Inst = defined_inst(InstName), - ( set__member(Inst, !.Expansions) -> + ( set.member(Inst, !.Expansions) -> true ; - svset__insert(Inst, !Expansions), + svset.insert(Inst, !Expansions), inst_lookup(ModuleInfo, InstName, Inst2), inst_is_ground_or_any_2(ModuleInfo, Inst2, !Expansions) ). @@ -1428,7 +1426,7 @@ inst_is_ground_or_any_2(ModuleInfo, Inst, !Expansions) :- % insts are not considered unique. % inst_is_unique(ModuleInfo, Inst) :- - set__init(Expansions0), + set.init(Expansions0), inst_is_unique_2(ModuleInfo, Inst, Expansions0, _Expansions). % The third arg is the set of insts which have already been expanded - we @@ -1450,10 +1448,10 @@ inst_is_unique_2(ModuleInfo, Inst, !Expansions) :- inst_is_unique_2(ModuleInfo, Inst2, !Expansions). inst_is_unique_2(ModuleInfo, Inst, !Expansions) :- Inst = defined_inst(InstName), - ( set__member(Inst, !.Expansions) -> + ( set.member(Inst, !.Expansions) -> true ; - svset__insert(Inst, !Expansions), + svset.insert(Inst, !Expansions), inst_lookup(ModuleInfo, InstName, Inst2), inst_is_unique_2(ModuleInfo, Inst2, !Expansions) ). @@ -1462,7 +1460,7 @@ inst_is_unique_2(ModuleInfo, Inst, !Expansions) :- % mostly_unique, or free. Abstract insts are not considered unique. % inst_is_mostly_unique(ModuleInfo, Inst) :- - set__init(Expansions0), + set.init(Expansions0), inst_is_mostly_unique_2(ModuleInfo, Inst, Expansions0, _Expansions). % The third arg is the set of insts which have already been expanded - we @@ -1488,10 +1486,10 @@ inst_is_mostly_unique_2(ModuleInfo, Inst, !Expansions) :- inst_is_mostly_unique_2(ModuleInfo, Inst2, !Expansions). inst_is_mostly_unique_2(ModuleInfo, Inst, !Expansions) :- Inst = defined_inst(InstName), - ( set__member(Inst, !.Expansions) -> + ( set.member(Inst, !.Expansions) -> true ; - svset__insert(Inst, !Expansions), + svset.insert(Inst, !Expansions), inst_lookup(ModuleInfo, InstName, Inst2), inst_is_mostly_unique_2(ModuleInfo, Inst2, !Expansions) ). @@ -1501,9 +1499,8 @@ inst_is_mostly_unique_2(ModuleInfo, Inst, !Expansions) :- % or free. It fails for abstract insts. % inst_is_not_partly_unique(ModuleInfo, Inst) :- - set__init(Expansions0), - inst_is_not_partly_unique_2(ModuleInfo, Inst, - Expansions0, _Expansions). + set.init(Expansions0), + inst_is_not_partly_unique_2(ModuleInfo, Inst, Expansions0, _Expansions). % The third arg is the set of insts which have already % been expanded - we use this to avoid going into an @@ -1525,10 +1522,10 @@ inst_is_not_partly_unique_2(ModuleInfo, Inst, !Expansions) :- inst_is_not_partly_unique_2(ModuleInfo, Inst2, !Expansions). inst_is_not_partly_unique_2(ModuleInfo, Inst, !Expansions) :- Inst = defined_inst(InstName), - ( set__member(Inst, !.Expansions) -> + ( set.member(Inst, !.Expansions) -> true ; - svset__insert(Inst, !Expansions), + svset.insert(Inst, !Expansions), inst_lookup(ModuleInfo, InstName, Inst2), inst_is_not_partly_unique_2(ModuleInfo, Inst2, !Expansions) ). @@ -1538,9 +1535,8 @@ inst_is_not_partly_unique_2(ModuleInfo, Inst, !Expansions) :- % insts. % inst_is_not_fully_unique(ModuleInfo, Inst) :- - set__init(Expansions0), - inst_is_not_fully_unique_2(ModuleInfo, Inst, - Expansions0, _Expansions). + set.init(Expansions0), + inst_is_not_fully_unique_2(ModuleInfo, Inst, Expansions0, _Expansions). % The third arg is the set of insts which have already been expanded - we % use this to avoid going into an infinite loop. @@ -1569,10 +1565,10 @@ inst_is_not_fully_unique_2(ModuleInfo, Inst, !Expansions) :- inst_is_not_fully_unique_2(ModuleInfo, Inst2, !Expansions). inst_is_not_fully_unique_2(ModuleInfo, Inst, !Expansions) :- Inst = defined_inst(InstName), - ( set__member(Inst, !.Expansions) -> + ( set.member(Inst, !.Expansions) -> true ; - svset__insert(Inst, !Expansions), + svset.insert(Inst, !Expansions), inst_lookup(ModuleInfo, InstName, Inst2), inst_is_not_fully_unique_2(ModuleInfo, Inst2, !Expansions) ). @@ -1589,7 +1585,7 @@ bound_inst_list_is_ground([], _, _). bound_inst_list_is_ground([functor(Name, Args) | BoundInsts], MaybeType, ModuleInfo) :- maybe_get_cons_id_arg_types(ModuleInfo, MaybeType, Name, - list__length(Args), MaybeTypes), + list.length(Args), MaybeTypes), inst_list_is_ground(Args, MaybeTypes, ModuleInfo), bound_inst_list_is_ground(BoundInsts, MaybeType, ModuleInfo). @@ -1631,7 +1627,7 @@ bound_inst_list_is_ground_2([], _, _, !Expansions). bound_inst_list_is_ground_2([functor(Name, Args) | BoundInsts], MaybeType, ModuleInfo, !Expansions) :- maybe_get_cons_id_arg_types(ModuleInfo, MaybeType, Name, - list__length(Args), MaybeTypes), + list.length(Args), MaybeTypes), inst_list_is_ground_2(Args, MaybeTypes, ModuleInfo, !Expansions), bound_inst_list_is_ground_2(BoundInsts, MaybeType, ModuleInfo, !Expansions). @@ -1688,7 +1684,7 @@ bound_inst_list_is_not_fully_unique_2([functor(_Name, Args) | BoundInsts], %-----------------------------------------------------------------------------% inst_list_is_ground(Insts, ModuleInfo) :- - MaybeTypes = list__duplicate(list__length(Insts), no), + MaybeTypes = list.duplicate(list.length(Insts), no), inst_list_is_ground(Insts, MaybeTypes, ModuleInfo). :- pred inst_list_is_ground(list(mer_inst)::in, list(maybe(mer_type))::in, @@ -1815,7 +1811,7 @@ inst_list_is_ground_or_any_or_dead([Inst | Insts], [Live | Lives], %-----------------------------------------------------------------------------% inst_contains_instname(Inst, ModuleInfo, InstName) :- - set__init(Expansions0), + set.init(Expansions0), inst_contains_instname_2(Inst, ModuleInfo, InstName, yes, Expansions0, _Expansions). @@ -1840,13 +1836,13 @@ inst_contains_instname_2(defined_inst(InstName1), ModuleInfo, InstName, ( InstName = InstName1 -> Result = yes ; - ( set__member(InstName1, !.Expansions) -> + ( set.member(InstName1, !.Expansions) -> Result = no ; inst_lookup(ModuleInfo, InstName1, Inst1), - svset__insert(InstName1, !Expansions), - inst_contains_instname_2(Inst1, ModuleInfo, - InstName, Result, !Expansions) + svset.insert(InstName1, !Expansions), + inst_contains_instname_2(Inst1, ModuleInfo, InstName, Result, + !Expansions) ) ). inst_contains_instname_2(bound(_Uniq, ArgInsts), ModuleInfo, @@ -1973,7 +1969,7 @@ mode_contains_inst_var(Mode, InstVar) :- ( Inst = Initial ; Inst = Final ) ; Mode = user_defined_mode(_Name, Insts), - list__member(Inst, Insts) + list.member(Inst, Insts) ), inst_contains_inst_var(Inst, InstVar). @@ -1988,13 +1984,13 @@ mode_contains_inst_var(Mode, InstVar) :- uniqueness::in, mer_inst::out) is semidet. maybe_any_to_bound(yes(Type), ModuleInfo, Uniq, Inst) :- - \+ type_util__is_solver_type(ModuleInfo, Type), + \+ type_util.is_solver_type(ModuleInfo, Type), ( type_constructors(Type, ModuleInfo, Constructors) -> constructors_to_bound_any_insts(ModuleInfo, Uniq, Constructors, BoundInsts0), - list__sort_and_remove_dups(BoundInsts0, BoundInsts), + list.sort_and_remove_dups(BoundInsts0, BoundInsts), Inst = bound(Uniq, BoundInsts) ; type_may_contain_solver_type(Type, ModuleInfo) diff --git a/compiler/inst_util.m b/compiler/inst_util.m index 36b11b4cc..c1ad8479c 100644 --- a/compiler/inst_util.m +++ b/compiler/inst_util.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1997-2005 The University of Melbourne. +% Copyright (C) 1997-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -37,7 +37,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__inst_util. +:- module check_hlds.inst_util. :- interface. :- import_module hlds.hlds_module. @@ -138,7 +138,6 @@ % Return true if the given inst may restrict the set of function symbols % that may be successfully unified with the variable that has this inst. - % % :- func inst_may_restrict_cons_ids(module_info, mer_inst) = bool. @@ -172,7 +171,7 @@ abstractly_unify_inst(Live, InstA, InstB, UnifyIsReal, Inst, Det, ThisInstPair = unify_inst(Live, InstA, InstB, UnifyIsReal), module_info_get_inst_table(!.ModuleInfo, InstTable0), inst_table_get_unify_insts(InstTable0, UnifyInsts0), - ( map__search(UnifyInsts0, ThisInstPair, Result) -> + ( map.search(UnifyInsts0, ThisInstPair, Result) -> ( Result = known(UnifyInst, UnifyDet) -> Inst0 = UnifyInst, Det = UnifyDet @@ -187,7 +186,7 @@ abstractly_unify_inst(Live, InstA, InstB, UnifyIsReal, Inst, Det, Inst1 = Inst0 ; % Insert ThisInstPair into the table with value `unknown'. - svmap__det_insert(ThisInstPair, unknown, UnifyInsts0, UnifyInsts1), + svmap.det_insert(ThisInstPair, unknown, UnifyInsts0, UnifyInsts1), inst_table_set_unify_insts(UnifyInsts1, InstTable0, InstTable1), module_info_set_inst_table(InstTable1, !ModuleInfo), % Unify the insts. @@ -207,7 +206,7 @@ abstractly_unify_inst(Live, InstA, InstB, UnifyIsReal, Inst, Det, % Now update the value associated with ThisInstPair. module_info_get_inst_table(!.ModuleInfo, InstTable2), inst_table_get_unify_insts(InstTable2, UnifyInsts2), - map__det_update(UnifyInsts2, ThisInstPair, known(Inst1, Det), + map.det_update(UnifyInsts2, ThisInstPair, known(Inst1, Det), UnifyInsts), inst_table_set_unify_insts(UnifyInsts, InstTable2, InstTable), module_info_set_inst_table(InstTable, !ModuleInfo) @@ -537,7 +536,7 @@ abstractly_unify_inst_functor_2(live, any(Uniq), ConsId, ArgInsts, ArgLives, Real, Type, Inst, Det, !ModuleInfo) :- % We only allow `any' to unify with a functor if we know that % the type is not a solver type. - \+ type_util__is_solver_type(!.ModuleInfo, Type), + \+ type_util.is_solver_type(!.ModuleInfo, Type), make_any_inst_list_lives(ArgInsts, live, ArgLives, Uniq, Real, AnyArgInsts, Det, !ModuleInfo), Inst = bound(Uniq, [functor(ConsId, AnyArgInsts)]). @@ -566,7 +565,7 @@ abstractly_unify_inst_functor_2(dead, free, ConsId, Args, _ArgLives, _Real, _, abstractly_unify_inst_functor_2(dead, any(Uniq), ConsId, ArgInsts, _ArgLives, Real, Type, Inst, Det, !ModuleInfo) :- - \+ type_util__is_solver_type(!.ModuleInfo, Type), + \+ type_util.is_solver_type(!.ModuleInfo, Type), make_any_inst_list(ArgInsts, dead, Uniq, Real, AnyArgInsts, Det, !ModuleInfo), Inst = bound(Uniq, [functor(ConsId, AnyArgInsts)]). @@ -732,8 +731,7 @@ abstractly_unify_constrained_inst_vars(IsLive, InstVars, InstConstraint, InstB, Inst0 = constrained_inst_vars(InstVars0, Inst1) -> % Avoid nested constrained_inst_vars. - Inst = constrained_inst_vars(set__union(InstVars0, InstVars), - Inst1) + Inst = constrained_inst_vars(set.union(InstVars0, InstVars), Inst1) ; % We can keep the constrained_inst_vars. Inst = constrained_inst_vars(InstVars, Inst0) @@ -911,7 +909,7 @@ make_ground_inst(defined_inst(InstName), IsLive, Uniq, Real, Inst, Det, inst_table_get_ground_insts(InstTable0, GroundInsts0), GroundInstKey = ground_inst(InstName, IsLive, Uniq, Real), ( - map__search(GroundInsts0, GroundInstKey, Result) + map.search(GroundInsts0, GroundInstKey, Result) -> ( Result = known(GroundInst0, Det0) -> GroundInst = GroundInst0, @@ -926,10 +924,8 @@ make_ground_inst(defined_inst(InstName), IsLive, Uniq, Real, Inst, Det, ; % Insert the inst name in the ground_inst table, with value `unknown' % for the moment. - svmap__det_insert(GroundInstKey, unknown, - GroundInsts0, GroundInsts1), - inst_table_set_ground_insts(GroundInsts1, - InstTable0, InstTable1), + svmap.det_insert(GroundInstKey, unknown, GroundInsts0, GroundInsts1), + inst_table_set_ground_insts(GroundInsts1, InstTable0, InstTable1), module_info_set_inst_table(InstTable1, !ModuleInfo), % Expand the inst name, and invoke ourself recursively on its @@ -943,7 +939,7 @@ make_ground_inst(defined_inst(InstName), IsLive, Uniq, Real, Inst, Det, % value `known(GroundInst, Det)' in the ground_inst table. module_info_get_inst_table(!.ModuleInfo, InstTable2), inst_table_get_ground_insts(InstTable2, GroundInsts2), - svmap__det_update(GroundInstKey, known(GroundInst, Det), + svmap.det_update(GroundInstKey, known(GroundInst, Det), GroundInsts2, GroundInsts), inst_table_set_ground_insts(GroundInsts, InstTable2, InstTable), module_info_set_inst_table(InstTable, !ModuleInfo) @@ -1019,9 +1015,7 @@ make_any_inst(defined_inst(InstName), IsLive, Uniq, Real, Inst, Det, module_info_get_inst_table(!.ModuleInfo, InstTable0), inst_table_get_any_insts(InstTable0, AnyInsts0), AnyInstKey = any_inst(InstName, IsLive, Uniq, Real), - ( - map__search(AnyInsts0, AnyInstKey, Result) - -> + ( map.search(AnyInsts0, AnyInstKey, Result) -> ( Result = known(AnyInst0, Det0) -> AnyInst = AnyInst0, Det = Det0 @@ -1035,7 +1029,7 @@ make_any_inst(defined_inst(InstName), IsLive, Uniq, Real, Inst, Det, ; % Insert the inst name in the any_inst table, with value `unknown' % for the moment. - svmap__det_insert(AnyInstKey, unknown, AnyInsts0, AnyInsts1), + svmap.det_insert(AnyInstKey, unknown, AnyInsts0, AnyInsts1), inst_table_set_any_insts(AnyInsts1, InstTable0, InstTable1), module_info_set_inst_table(InstTable1, !ModuleInfo), @@ -1050,8 +1044,7 @@ make_any_inst(defined_inst(InstName), IsLive, Uniq, Real, Inst, Det, % value `known(AnyInst, Det)' in the any_inst table. module_info_get_inst_table(!.ModuleInfo, InstTable2), inst_table_get_any_insts(InstTable2, AnyInsts2), - svmap__det_update(AnyInstKey, known(AnyInst, Det), - AnyInsts2, AnyInsts), + svmap.det_update(AnyInstKey, known(AnyInst, Det), AnyInsts2, AnyInsts), inst_table_set_any_insts(AnyInsts, InstTable2, InstTable), module_info_set_inst_table(InstTable, !ModuleInfo) ), @@ -1170,7 +1163,7 @@ make_shared_inst(defined_inst(InstName), Inst, !ModuleInfo) :- % Check whether the inst name is already in the shared_inst table. module_info_get_inst_table(!.ModuleInfo, InstTable0), inst_table_get_shared_insts(InstTable0, SharedInsts0), - ( map__search(SharedInsts0, InstName, Result) -> + ( map.search(SharedInsts0, InstName, Result) -> ( Result = known(SharedInst0) -> SharedInst = SharedInst0 ; @@ -1179,7 +1172,7 @@ make_shared_inst(defined_inst(InstName), Inst, !ModuleInfo) :- ; % Insert the inst name in the shared_inst table, with value `unknown' % for the moment. - svmap__det_insert(InstName, unknown, SharedInsts0, SharedInsts1), + svmap.det_insert(InstName, unknown, SharedInsts0, SharedInsts1), inst_table_set_shared_insts(SharedInsts1, InstTable0, InstTable1), module_info_set_inst_table(InstTable1, !ModuleInfo), @@ -1193,7 +1186,7 @@ make_shared_inst(defined_inst(InstName), Inst, !ModuleInfo) :- % value `known(SharedInst)' in the shared_inst table. module_info_get_inst_table(!.ModuleInfo, InstTable2), inst_table_get_shared_insts(InstTable2, SharedInsts2), - svmap__det_update(InstName, known(SharedInst), + svmap.det_update(InstName, known(SharedInst), SharedInsts2, SharedInsts), inst_table_set_shared_insts(SharedInsts, InstTable2, InstTable), @@ -1260,7 +1253,7 @@ make_mostly_uniq_inst(defined_inst(InstName), Inst, !ModuleInfo) :- % Check whether the inst name is already in the mostly_uniq_inst table. module_info_get_inst_table(!.ModuleInfo, InstTable0), inst_table_get_mostly_uniq_insts(InstTable0, NondetLiveInsts0), - ( map__search(NondetLiveInsts0, InstName, Result) -> + ( map.search(NondetLiveInsts0, InstName, Result) -> ( Result = known(NondetLiveInst0) -> NondetLiveInst = NondetLiveInst0 ; @@ -1269,7 +1262,7 @@ make_mostly_uniq_inst(defined_inst(InstName), Inst, !ModuleInfo) :- ; % Insert the inst name in the mostly_uniq_inst table, with value % `unknown' for the moment. - map__det_insert(NondetLiveInsts0, InstName, unknown, NondetLiveInsts1), + map.det_insert(NondetLiveInsts0, InstName, unknown, NondetLiveInsts1), inst_table_set_mostly_uniq_insts(NondetLiveInsts1, InstTable0, InstTable1), module_info_set_inst_table(InstTable1, !ModuleInfo), @@ -1284,7 +1277,7 @@ make_mostly_uniq_inst(defined_inst(InstName), Inst, !ModuleInfo) :- % value `known(NondetLiveInst)' in the mostly_uniq_inst table. module_info_get_inst_table(!.ModuleInfo, InstTable2), inst_table_get_mostly_uniq_insts(InstTable2, NondetLiveInsts2), - svmap__det_update(InstName, known(NondetLiveInst), + svmap.det_update(InstName, known(NondetLiveInst), NondetLiveInsts2, NondetLiveInsts), inst_table_set_mostly_uniq_insts(NondetLiveInsts, InstTable2, InstTable), @@ -1342,7 +1335,7 @@ inst_merge(InstA, InstB, MaybeType, Inst, !ModuleInfo) :- module_info_get_inst_table(!.ModuleInfo, InstTable0), inst_table_get_merge_insts(InstTable0, MergeInstTable0), ThisInstPair = InstA - InstB, - ( map__search(MergeInstTable0, ThisInstPair, Result) -> + ( map.search(MergeInstTable0, ThisInstPair, Result) -> ( Result = known(MergedInst) -> Inst0 = MergedInst ; @@ -1350,7 +1343,7 @@ inst_merge(InstA, InstB, MaybeType, Inst, !ModuleInfo) :- ) ; % Insert ThisInstPair into the table with value `unknown'. - map__det_insert(MergeInstTable0, ThisInstPair, unknown, + map.det_insert(MergeInstTable0, ThisInstPair, unknown, MergeInstTable1), inst_table_set_merge_insts(MergeInstTable1, InstTable0, InstTable1), module_info_set_inst_table(InstTable1, !ModuleInfo), @@ -1361,7 +1354,7 @@ inst_merge(InstA, InstB, MaybeType, Inst, !ModuleInfo) :- % Now update the value associated with ThisInstPair. module_info_get_inst_table(!.ModuleInfo, InstTable2), inst_table_get_merge_insts(InstTable2, MergeInstTable2), - map__det_update(MergeInstTable2, ThisInstPair, known(Inst0), + map.det_update(MergeInstTable2, ThisInstPair, known(Inst0), MergeInstTable3), inst_table_set_merge_insts(MergeInstTable3, InstTable2, InstTable3), module_info_set_inst_table(InstTable3, !ModuleInfo) @@ -1396,8 +1389,8 @@ inst_merge_3(InstA, InstB, MaybeType, Inst, !ModuleInfo) :- ( InstA = constrained_inst_vars(InstVarsA, InstA1) -> ( InstB = constrained_inst_vars(InstVarsB, InstB1) -> inst_merge(InstA1, InstB1, MaybeType, Inst0, !ModuleInfo), - InstVars = InstVarsA `set__intersect` InstVarsB, - ( set__non_empty(InstVars) -> + InstVars = InstVarsA `set.intersect` InstVarsB, + ( set.non_empty(InstVars) -> Inst = constrained_inst_vars(InstVars, Inst0) % We can keep the constrained_inst_vars here since % Inst0 = InstA1 `lub` InstB1 and the original constraint @@ -1508,7 +1501,7 @@ inst_merge_4(ground(UniqA, GroundInstInfoA), ground(UniqB, GroundInstInfoB), inst_merge_4(abstract_inst(Name, ArgsA), abstract_inst(Name, ArgsB), _, abstract_inst(Name, Args), !ModuleInfo) :- % We don't know the arguments types of an abstract inst. - MaybeTypes = list__duplicate(list__length(ArgsA), no), + MaybeTypes = list.duplicate(list.length(ArgsA), no), inst_list_merge(ArgsA, ArgsB, MaybeTypes, Args, !ModuleInfo). inst_merge_4(not_reached, Inst, _, Inst, !ModuleInfo). @@ -1532,7 +1525,7 @@ merge_uniq(UniqA, UniqB, Merged) :- merge_uniq_bound(UniqA, UniqB, ListB, ModuleInfo, Uniq) :- merge_uniq(UniqA, UniqB, Uniq0), - set__init(Expansions0), + set.init(Expansions0), merge_bound_inst_list_uniq(ListB, Uniq0, ModuleInfo, Expansions0, _Expansions, Uniq). @@ -1574,10 +1567,10 @@ merge_inst_uniq(abstract_inst(_,_), UniqB, _, !Expansions, Uniq) :- merge_uniq(shared, UniqB, Uniq). merge_inst_uniq(defined_inst(InstName), UniqB, ModuleInfo, !Expansions, Uniq) :- - ( set__member(InstName, !.Expansions) -> + ( set.member(InstName, !.Expansions) -> Uniq = UniqB ; - svset__insert(InstName, !Expansions), + svset.insert(InstName, !Expansions), inst_lookup(ModuleInfo, InstName, Inst), merge_inst_uniq(Inst, UniqB, ModuleInfo, !Expansions, Uniq) ). @@ -1607,7 +1600,7 @@ inst_merge_bound_ground(UniqA, ListA, UniqB, MaybeType, Result, !ModuleInfo) :- type_constructors(Type, !.ModuleInfo, Constructors), constructors_to_bound_insts(!.ModuleInfo, UniqB, Constructors, ListB0), - list__sort_and_remove_dups(ListB0, ListB), + list.sort_and_remove_dups(ListB0, ListB), inst_merge_4(bound(UniqA, ListA), bound(UniqB, ListB), MaybeType, Result, !ModuleInfo) ; @@ -1652,7 +1645,7 @@ bound_inst_list_merge(Xs, Ys, MaybeType, Zs, !ModuleInfo) :- Y = functor(ConsIdY, ArgsY), ( cons_ids_match(ConsIdX, ConsIdY) -> maybe_get_cons_id_arg_types(!.ModuleInfo, MaybeType, - ConsIdX, list__length(ArgsX), MaybeTypes), + ConsIdX, list.length(ArgsX), MaybeTypes), inst_list_merge(ArgsX, ArgsY, MaybeTypes, Args, !ModuleInfo), Z = functor(ConsIdX, Args), Zs = [Z | Zs1], @@ -1670,7 +1663,7 @@ bound_inst_list_merge(Xs, Ys, MaybeType, Zs, !ModuleInfo) :- %-----------------------------------------------------------------------------% inst_contains_nonstandard_func_mode(ModuleInfo, Inst) :- - set__init(Expansions0), + set.init(Expansions0), inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst, Expansions0). :- pred inst_contains_nonstandard_func_mode_2(module_info::in, mer_inst::in, @@ -1681,55 +1674,54 @@ inst_contains_nonstandard_func_mode_2(ModuleInfo, ground(_, GroundInstInfo), ground_inst_info_is_nonstandard_func_mode(ModuleInfo, GroundInstInfo). inst_contains_nonstandard_func_mode_2(ModuleInfo, bound(_, BoundInsts), Expansions) :- - list__member(functor(_, Insts), BoundInsts), - list__member(Inst, Insts), + list.member(functor(_, Insts), BoundInsts), + list.member(Inst, Insts), inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst, Expansions). inst_contains_nonstandard_func_mode_2(_, inst_var(_), _) :- unexpected(this_file, "internal error: uninstantiated inst parameter"). inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst, Expansions0) :- Inst = defined_inst(InstName), - \+ set__member(Inst, Expansions0), - set__insert(Expansions0, Inst, Expansions1), + \+ set.member(Inst, Expansions0), + set.insert(Expansions0, Inst, Expansions1), inst_lookup(ModuleInfo, InstName, Inst2), inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst2, Expansions1). %-----------------------------------------------------------------------------% inst_contains_any(ModuleInfo, Inst) :- - set__init(Expansions), + set.init(Expansions), inst_contains_any_2(ModuleInfo, Inst, Expansions). - :- pred inst_contains_any_2(module_info::in, (mer_inst)::in, - set(inst_name)::in) is semidet. + set(inst_name)::in) is semidet. inst_contains_any_2(_ModuleInfo, any(_), _Expansions). inst_contains_any_2(ModuleInfo, bound(_, BoundInsts), Expansions) :- - list__member(functor(_, Insts), BoundInsts), - list__member(Inst, Insts), + list.member(functor(_, Insts), BoundInsts), + list.member(Inst, Insts), inst_contains_any_2(ModuleInfo, Inst, Expansions). inst_contains_any_2(_ModuleInfo, inst_var(_), _Expansions) :- unexpected(this_file, "internal error: uninstantiated inst parameter"). inst_contains_any_2(ModuleInfo, defined_inst(InstName), Expansions0) :- - \+ set__member(InstName, Expansions0), - Expansions = set__insert(Expansions0, InstName), + \+ set.member(InstName, Expansions0), + Expansions = set.insert(Expansions0, InstName), inst_lookup(ModuleInfo, InstName, Inst), inst_contains_any_2(ModuleInfo, Inst, Expansions). %-----------------------------------------------------------------------------% var_inst_contains_any(ModuleInfo, Instmap, Var) :- - instmap__lookup_var(Instmap, Var, Inst), + instmap.lookup_var(Instmap, Var, Inst), inst_contains_any(ModuleInfo, Inst). %-----------------------------------------------------------------------------% pred_inst_info_is_nonstandard_func_mode(ModuleInfo, PredInstInfo) :- PredInstInfo = pred_inst_info(function, ArgModes, _), - Arity = list__length(ArgModes), + Arity = list.length(ArgModes), \+ pred_inst_matches(PredInstInfo, pred_inst_info_standard_func_mode(Arity), ModuleInfo). @@ -1741,7 +1733,7 @@ pred_inst_info_standard_func_mode(Arity) = pred_inst_info(function, ArgModes, det) :- in_mode(InMode), out_mode(OutMode), - ArgModes = list__duplicate(Arity - 1, InMode) ++ [OutMode]. + ArgModes = list.duplicate(Arity - 1, InMode) ++ [OutMode]. %-----------------------------------------------------------------------------% @@ -1811,7 +1803,6 @@ inst_may_restrict_cons_ids(ModuleInfo, Inst) = MayRestrict :- %-----------------------------------------------------------------------------% - :- func this_file = string. this_file = "inst_util". diff --git a/compiler/instmap.m b/compiler/instmap.m index 3aa736097..bac6c4144 100644 --- a/compiler/instmap.m +++ b/compiler/instmap.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1996-2001, 2003-2005 The University of Melbourne. +% Copyright (C) 1996-2001, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -18,7 +18,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__instmap. +:- module hlds.instmap. :- interface. :- import_module check_hlds.mode_errors. @@ -38,11 +38,11 @@ % Initialize an empty instmap. % -:- pred instmap__init_reachable(instmap::out) is det. +:- pred init_reachable(instmap::out) is det. % Initialize an empty unreachable instmap. % -:- pred instmap__init_unreachable(instmap::out) is det. +:- pred init_unreachable(instmap::out) is det. % Initialize an empty reachable instmap_delta. % @@ -53,16 +53,16 @@ :- pred instmap_delta_init_unreachable(instmap_delta::out) is det. % For any instmap InstMap, exactly one of - % instmap__is_reachable(InstMap) and - % instmap__is_unreachable(InstMap) holds. + % is_reachable(InstMap) and + % is_unreachable(InstMap) holds. % Is the instmap reachable? % -:- pred instmap__is_reachable(instmap::in) is semidet. +:- pred is_reachable(instmap::in) is semidet. % Is the instmap unreachable? % -:- pred instmap__is_unreachable(instmap::in) is semidet. +:- pred is_unreachable(instmap::in) is semidet. % For any instmap InstMapDelta, exactly one of % instmap_delta_is_reachable(InstMapDelta) and @@ -76,7 +76,7 @@ % :- pred instmap_delta_is_unreachable(instmap_delta::in) is semidet. -:- pred instmap__from_assoc_list(assoc_list(prog_var, mer_inst)::in, +:- pred from_assoc_list(assoc_list(prog_var, mer_inst)::in, instmap::out) is det. :- pred instmap_delta_from_assoc_list(assoc_list(prog_var, mer_inst)::in, @@ -89,11 +89,11 @@ % Return the set of variables in an instmap. % -:- pred instmap__vars(instmap::in, set(prog_var)::out) is det. +:- pred vars(instmap::in, set(prog_var)::out) is det. % Return the list of variables in an instmap. % -:- pred instmap__vars_list(instmap::in, list(prog_var)::out) is det. +:- pred vars_list(instmap::in, list(prog_var)::out) is det. % Return the set of variables whose instantiations have % changed (or our knowledge about them has changed) across @@ -123,7 +123,7 @@ % Given an instmap and a variable, determine the inst of that variable. % -:- pred instmap__lookup_var(instmap::in, prog_var::in, mer_inst::out) is det. +:- pred lookup_var(instmap::in, prog_var::in, mer_inst::out) is det. % Given an instmap_delta and a variable, determine the new inst % of that variable (if any). @@ -134,7 +134,7 @@ % Given an instmap and a list of variables, return a list % containing the insts of those variable. % -:- pred instmap__lookup_vars(list(prog_var)::in, instmap::in, +:- pred lookup_vars(list(prog_var)::in, instmap::in, list(mer_inst)::out) is det. % Insert an entry into an instmap_delta. Note that you cannot call @@ -145,12 +145,12 @@ % Set an entry in an instmap. % -:- pred instmap__set(prog_var::in, mer_inst::in, instmap::in, instmap::out) +:- pred set(prog_var::in, mer_inst::in, instmap::in, instmap::out) is det. % Set multiple entries in an instmap. % -:- pred instmap__set_vars(list(prog_var)::in, list(mer_inst)::in, +:- pred set_vars(list(prog_var)::in, list(mer_inst)::in, instmap::in, instmap::out) is det. :- pred instmap_delta_set(prog_var::in, mer_inst::in, @@ -163,13 +163,13 @@ cons_id::in, instmap::in, instmap_delta::in, instmap_delta::out, module_info::in, module_info::out) is det. -:- pred instmap__bind_var_to_functor(prog_var::in, mer_type::in, cons_id::in, +:- pred bind_var_to_functor(prog_var::in, mer_type::in, cons_id::in, instmap::in, instmap::out, module_info::in, module_info::out) is det. % Update the given instmap to include the initial insts of the % lambda variables. % -:- pred instmap__pre_lambda_update(module_info::in, list(prog_var)::in, +:- pred pre_lambda_update(module_info::in, list(prog_var)::in, list(mer_mode)::in, instmap::in, instmap::out) is det. %-----------------------------------------------------------------------------% @@ -188,7 +188,7 @@ % Given an instmap and an instmap_delta, overlay the entries in the % instmap_delta on top of those in the instmap to produce a new instmap. % -:- pred instmap__apply_instmap_delta(instmap::in, instmap_delta::in, +:- pred apply_instmap_delta(instmap::in, instmap_delta::in, instmap::out) is det. % Given two instmap_deltas, overlay the entries in the second instmap_delta @@ -203,10 +203,10 @@ % or if-then-else, and update the instantiatedness of all the nonlocal % variables, checking that it is the same for every branch. % -:- pred instmap__merge(set(prog_var)::in, list(instmap)::in, merge_context::in, +:- pred merge(set(prog_var)::in, list(instmap)::in, merge_context::in, mode_info::in, mode_info::out) is det. - % instmap__unify(NonLocalVars, InstMapNonlocalvarPairss): + % unify(NonLocalVars, InstMapNonlocalvarPairss): % % Unify the `InstMaps' in the list of pairs resulting from different % branches of a parallel conjunction and update the instantiatedness @@ -214,13 +214,13 @@ % when modechecking the individual conjuncts ensures that variables % have at most one producer. % -:- pred instmap__unify(set(prog_var)::in, list(pair(instmap, +:- pred unify(set(prog_var)::in, list(pair(instmap, set(prog_var)))::in, mode_info::in, mode_info::out) is det. - % instmap__restrict takes an instmap and a set of vars and returns + % restrict takes an instmap and a set of vars and returns % an instmap with its domain restricted to those vars. % -:- pred instmap__restrict(set(prog_var)::in, instmap::in, instmap::out) +:- pred restrict(set(prog_var)::in, instmap::in, instmap::out) is det. % instmap_delta_restrict takes an instmap and a set of vars and returns @@ -235,11 +235,11 @@ :- pred instmap_delta_delete_vars(list(prog_var)::in, instmap_delta::in, instmap_delta::out) is det. - % `instmap__no_output_vars(Instmap, InstmapDelta, Vars, ModuleInfo)' + % `no_output_vars(Instmap, InstmapDelta, Vars, ModuleInfo)' % is true if none of the vars in the set Vars could have become more % instantiated when InstmapDelta is applied to Instmap. % -:- pred instmap__no_output_vars(instmap::in, instmap_delta::in, +:- pred no_output_vars(instmap::in, instmap_delta::in, set(prog_var)::in, vartypes::in, module_info::in) is semidet. % merge_instmap_delta(InitialInstMap, NonLocals, @@ -284,12 +284,12 @@ :- pred instmap_delta_apply_sub(bool::in, map(prog_var, prog_var)::in, instmap_delta::in, instmap_delta::out) is det. -:- pred instmap__apply_sub(bool::in, map(prog_var, prog_var)::in, +:- pred apply_sub(bool::in, map(prog_var, prog_var)::in, instmap::in, instmap::out) is det. %-----------------------------------------------------------------------------% -:- pred instmap__to_assoc_list(instmap::in, +:- pred to_assoc_list(instmap::in, assoc_list(prog_var, mer_inst)::out) is det. :- pred instmap_delta_to_assoc_list(instmap_delta::in, @@ -339,21 +339,21 @@ % Initialize an empty instmap and instmap_delta. -instmap__init_reachable(reachable(InstMapping)) :- - map__init(InstMapping). +init_reachable(reachable(InstMapping)) :- + map.init(InstMapping). -instmap__init_unreachable(unreachable). +init_unreachable(unreachable). instmap_delta_init_reachable(reachable(InstMapping)) :- - map__init(InstMapping). + map.init(InstMapping). instmap_delta_init_unreachable(unreachable). %-----------------------------------------------------------------------------% -instmap__is_reachable(reachable(_)). +is_reachable(reachable(_)). -instmap__is_unreachable(unreachable). +is_unreachable(unreachable). instmap_delta_is_reachable(reachable(_)). @@ -361,16 +361,16 @@ instmap_delta_is_unreachable(unreachable). %-----------------------------------------------------------------------------% -instmap__from_assoc_list(AL, reachable(Instmapping)) :- - map__from_assoc_list(AL, Instmapping). +from_assoc_list(AL, reachable(Instmapping)) :- + map.from_assoc_list(AL, Instmapping). instmap_delta_from_assoc_list(AL, reachable(Instmapping)) :- - map__from_assoc_list(AL, Instmapping). + map.from_assoc_list(AL, Instmapping). instmap_delta_map_foldl(_, unreachable, unreachable, !T). instmap_delta_map_foldl(P, reachable(Instmapping0), reachable(Instmapping), !T) :- - map__map_foldl(P, Instmapping0, Instmapping, !T). + map.map_foldl(P, Instmapping0, Instmapping, !T). %-----------------------------------------------------------------------------% @@ -399,24 +399,24 @@ instmap_delta_from_mode_list_2([Var | Vars], [Mode | Modes], ModuleInfo, %-----------------------------------------------------------------------------% -instmap__vars(Instmap, Vars) :- - instmap__vars_list(Instmap, VarsList), - set__list_to_set(VarsList, Vars). +vars(Instmap, Vars) :- + vars_list(Instmap, VarsList), + set.list_to_set(VarsList, Vars). -instmap__vars_list(unreachable, []). -instmap__vars_list(reachable(InstMapping), VarsList) :- - map__keys(InstMapping, VarsList). +vars_list(unreachable, []). +vars_list(reachable(InstMapping), VarsList) :- + map.keys(InstMapping, VarsList). instmap_delta_changed_vars(unreachable, EmptySet) :- - set__init(EmptySet). + set.init(EmptySet). instmap_delta_changed_vars(reachable(InstMapping), ChangedVars) :- - map__keys(InstMapping, ChangedVarsList), - set__sorted_list_to_set(ChangedVarsList, ChangedVars). + map.keys(InstMapping, ChangedVarsList), + set.sorted_list_to_set(ChangedVarsList, ChangedVars). %-----------------------------------------------------------------------------% instmap_changed_vars(InstMapA, InstMapB, VarTypes, ModuleInfo, ChangedVars) :- - instmap__vars_list(InstMapB, VarsB), + vars_list(InstMapB, VarsB), changed_vars_2(VarsB, InstMapA, InstMapB, VarTypes, ModuleInfo, ChangedVars). @@ -424,33 +424,33 @@ instmap_changed_vars(InstMapA, InstMapB, VarTypes, ModuleInfo, ChangedVars) :- module_info::in, set(prog_var)::out) is det. changed_vars_2([], _InstMapA, _InstMapB, _Types, _ModuleInfo, ChangedVars) :- - set__init(ChangedVars). + set.init(ChangedVars). changed_vars_2([VarB | VarBs], InstMapA, InstMapB, VarTypes, ModuleInfo, ChangedVars) :- changed_vars_2(VarBs, InstMapA, InstMapB, VarTypes, ModuleInfo, ChangedVars0), - instmap__lookup_var(InstMapA, VarB, InitialInst), - instmap__lookup_var(InstMapB, VarB, FinalInst), - map__lookup(VarTypes, VarB, Type), + lookup_var(InstMapA, VarB, InitialInst), + lookup_var(InstMapB, VarB, FinalInst), + map.lookup(VarTypes, VarB, Type), ( inst_matches_final(InitialInst, FinalInst, Type, ModuleInfo) -> ChangedVars = ChangedVars0 ; - set__insert(ChangedVars0, VarB, ChangedVars) + set.insert(ChangedVars0, VarB, ChangedVars) ). %-----------------------------------------------------------------------------% -instmap__lookup_var(unreachable, _Var, not_reached). -instmap__lookup_var(reachable(InstMap), Var, Inst) :- +lookup_var(unreachable, _Var, not_reached). +lookup_var(reachable(InstMap), Var, Inst) :- instmapping_lookup_var(InstMap, Var, Inst). :- pred instmapping_lookup_var(instmapping::in, prog_var::in, mer_inst::out) is det. instmapping_lookup_var(InstMap, Var, Inst) :- - ( map__search(InstMap, Var, VarInst) -> + ( map.search(InstMap, Var, VarInst) -> Inst = VarInst ; Inst = free @@ -458,32 +458,32 @@ instmapping_lookup_var(InstMap, Var, Inst) :- instmap_delta_search_var(unreachable, _, not_reached). instmap_delta_search_var(reachable(InstMap), Var, Inst) :- - map__search(InstMap, Var, Inst). + map.search(InstMap, Var, Inst). -instmap__lookup_vars([], _InstMap, []). -instmap__lookup_vars([Arg|Args], InstMap, [Inst|Insts]) :- - instmap__lookup_var(InstMap, Arg, Inst), - instmap__lookup_vars(Args, InstMap, Insts). +lookup_vars([], _InstMap, []). +lookup_vars([Arg|Args], InstMap, [Inst|Insts]) :- + lookup_var(InstMap, Arg, Inst), + lookup_vars(Args, InstMap, Insts). -instmap__set(_Var, _Inst, unreachable, unreachable). -instmap__set(Var, Inst, reachable(InstMapping0), reachable(InstMapping)) :- - map__set(InstMapping0, Var, Inst, InstMapping). +set(_Var, _Inst, unreachable, unreachable). +set(Var, Inst, reachable(InstMapping0), reachable(InstMapping)) :- + map.set(InstMapping0, Var, Inst, InstMapping). -instmap__set_vars([], [], !InstMap). -instmap__set_vars([V | Vs], [I | Is], !InstMap) :- - instmap__set(V, I, !InstMap), - instmap__set_vars(Vs, Is, !InstMap). -instmap__set_vars([_ | _], [], !InstMap) :- - unexpected(this_file, "instmap__set_vars: length mismatch (1)"). -instmap__set_vars([], [_ | _], !InstMap) :- - unexpected(this_file, "instmap__set_vars: length mismatch (2)"). +set_vars([], [], !InstMap). +set_vars([V | Vs], [I | Is], !InstMap) :- + set(V, I, !InstMap), + set_vars(Vs, Is, !InstMap). +set_vars([_ | _], [], !InstMap) :- + unexpected(this_file, "set_vars: length mismatch (1)"). +set_vars([], [_ | _], !InstMap) :- + unexpected(this_file, "set_vars: length mismatch (2)"). instmap_delta_set(_Var, _Inst, unreachable, unreachable). instmap_delta_set(Var, Inst, reachable(InstMapping0), Instmap) :- ( Inst = not_reached -> Instmap = unreachable ; - map__set(InstMapping0, Var, Inst, InstMapping), + map.set(InstMapping0, Var, Inst, InstMapping), Instmap = reachable(InstMapping) ). @@ -492,7 +492,7 @@ instmap_delta_insert(Var, Inst, reachable(InstMapping0), Instmap) :- ( Inst = not_reached -> Instmap = unreachable ; - map__det_insert(InstMapping0, Var, Inst, InstMapping), + map.det_insert(InstMapping0, Var, Inst, InstMapping), Instmap = reachable(InstMapping) ). @@ -506,11 +506,11 @@ instmap_delta_bind_var_to_functor(Var, Type, ConsId, InstMap, !InstmapDelta, !.InstmapDelta = reachable(InstmappingDelta0), % Get the initial inst from the InstMap - instmap__lookup_var(InstMap, Var, OldInst), + lookup_var(InstMap, Var, OldInst), % Compute the new inst by taking the old inst, applying the instmap % delta to it, and then unifying with bound(ConsId, ...). - ( map__search(InstmappingDelta0, Var, NewInst0) -> + ( map.search(InstmappingDelta0, Var, NewInst0) -> NewInst1 = NewInst0 ; NewInst1 = OldInst @@ -525,18 +525,18 @@ instmap_delta_bind_var_to_functor(Var, Type, ConsId, InstMap, !InstmapDelta, ) ). -instmap__bind_var_to_functor(Var, Type, ConsId, !InstMap, !ModuleInfo) :- - instmap__lookup_var(!.InstMap, Var, Inst0), +bind_var_to_functor(Var, Type, ConsId, !InstMap, !ModuleInfo) :- + lookup_var(!.InstMap, Var, Inst0), bind_inst_to_functor(Type, ConsId, Inst0, Inst, !ModuleInfo), - instmap__set(Var, Inst, !InstMap). + set(Var, Inst, !InstMap). :- pred bind_inst_to_functor(mer_type::in, cons_id::in, mer_inst::in, mer_inst::out, module_info::in, module_info::out) is det. bind_inst_to_functor(Type, ConsId, !Inst, !ModuleInfo) :- Arity = cons_id_adjusted_arity(!.ModuleInfo, Type, ConsId), - list__duplicate(Arity, dead, ArgLives), - list__duplicate(Arity, free, ArgInsts), + list.duplicate(Arity, dead, ArgLives), + list.duplicate(Arity, free, ArgInsts), ( abstractly_unify_inst_functor(dead, !.Inst, ConsId, ArgInsts, ArgLives, real_unify, Type, !:Inst, _Det, !ModuleInfo) @@ -548,19 +548,19 @@ bind_inst_to_functor(Type, ConsId, !Inst, !ModuleInfo) :- %-----------------------------------------------------------------------------% -instmap__pre_lambda_update(ModuleInfo, Vars, Modes, InstMap0, InstMap) :- +pre_lambda_update(ModuleInfo, Vars, Modes, InstMap0, InstMap) :- mode_list_get_initial_insts(ModuleInfo, Modes, Insts), - assoc_list__from_corresponding_lists(Vars, Insts, VarInsts), + assoc_list.from_corresponding_lists(Vars, Insts, VarInsts), instmap_delta_from_assoc_list(VarInsts, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap). + apply_instmap_delta(InstMap0, InstMapDelta, InstMap). %-----------------------------------------------------------------------------% -instmap__apply_instmap_delta(unreachable, _, unreachable). -instmap__apply_instmap_delta(reachable(_), unreachable, unreachable). -instmap__apply_instmap_delta(reachable(InstMapping0), +apply_instmap_delta(unreachable, _, unreachable). +apply_instmap_delta(reachable(_), unreachable, unreachable). +apply_instmap_delta(reachable(InstMapping0), reachable(InstMappingDelta), reachable(InstMapping)) :- - map__overlay(InstMapping0, InstMappingDelta, InstMapping). + map.overlay(InstMapping0, InstMappingDelta, InstMapping). instmap_delta_apply_instmap_delta(InstMap1, InstMap2, How, InstMap) :- ( @@ -575,23 +575,23 @@ instmap_delta_apply_instmap_delta(InstMap1, InstMap2, How, InstMap) :- InstMap2 = reachable(InstMappingDelta2), ( How = large_base, - map__overlay(InstMappingDelta1, InstMappingDelta2, + map.overlay(InstMappingDelta1, InstMappingDelta2, InstMappingDelta) ; How = large_overlay, - map__overlay_large_map(InstMappingDelta1, + map.overlay_large_map(InstMappingDelta1, InstMappingDelta2, InstMappingDelta) ; How = test_size, ( - map__count(InstMappingDelta1, Count1), - map__count(InstMappingDelta2, Count2), + map.count(InstMappingDelta1, Count1), + map.count(InstMappingDelta2, Count2), Count1 >= Count2 -> - map__overlay(InstMappingDelta1, + map.overlay(InstMappingDelta1, InstMappingDelta2, InstMappingDelta) ; - map__overlay_large_map(InstMappingDelta1, + map.overlay_large_map(InstMappingDelta1, InstMappingDelta2, InstMappingDelta) ) ), @@ -600,30 +600,30 @@ instmap_delta_apply_instmap_delta(InstMap1, InstMap2, How, InstMap) :- %-----------------------------------------------------------------------------% -instmap__restrict(_, unreachable, unreachable). -instmap__restrict(Vars, reachable(InstMapping0), reachable(InstMapping)) :- - map__select(InstMapping0, Vars, InstMapping). +restrict(_, unreachable, unreachable). +restrict(Vars, reachable(InstMapping0), reachable(InstMapping)) :- + map.select(InstMapping0, Vars, InstMapping). instmap_delta_restrict(_, unreachable, unreachable). instmap_delta_restrict(Vars, reachable(InstMapping0), reachable(InstMapping)) :- - map__select(InstMapping0, Vars, InstMapping). + map.select(InstMapping0, Vars, InstMapping). instmap_delta_delete_vars(_, unreachable, unreachable). instmap_delta_delete_vars(Vars, reachable(InstMapping0), reachable(InstMapping)) :- - map__delete_list(InstMapping0, Vars, InstMapping). + map.delete_list(InstMapping0, Vars, InstMapping). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% - % instmap__merge(NonLocals, InstMapList, MergeContext, !ModeInfo): + % merge(NonLocals, InstMapList, MergeContext, !ModeInfo): % % Merge the `InstMapList' resulting from different branches of a % disjunction or if-then-else, and update the instantiatedness of all % the nonlocal variables, checking that it is the same for every branch. % -instmap__merge(NonLocals, InstMapList, MergeContext, !ModeInfo) :- +merge(NonLocals, InstMapList, MergeContext, !ModeInfo) :- mode_info_get_instmap(!.ModeInfo, InstMap0), mode_info_get_module_info(!.ModeInfo, ModuleInfo0), get_reachable_instmaps(InstMapList, InstMappingList), @@ -633,15 +633,15 @@ instmap__merge(NonLocals, InstMapList, MergeContext, !ModeInfo) :- InstMap0 = reachable(InstMapping0), InstMappingList = [_ | _] -> - set__to_sorted_list(NonLocals, NonLocalsList), + set.to_sorted_list(NonLocals, NonLocalsList), mode_info_get_var_types(!.ModeInfo, VarTypes), - instmap__merge_2(NonLocalsList, InstMapList, VarTypes, + merge_2(NonLocalsList, InstMapList, VarTypes, InstMapping0, InstMapping, ModuleInfo0, ModuleInfo, ErrorList), mode_info_set_module_info(ModuleInfo, !ModeInfo), ( ErrorList = [FirstError | _], FirstError = Var - _, - set__singleton_set(WaitingVars, Var), + set.singleton_set(WaitingVars, Var), mode_info_error(WaitingVars, mode_error_disj(MergeContext, ErrorList), !ModeInfo) ; @@ -669,7 +669,7 @@ get_reachable_instmaps([InstMap | InstMaps], Reachables) :- %-----------------------------------------------------------------------------% - % instmap__merge_2(Vars, InstMapList, VarTypes, !InstMapping, !ModuleInfo, + % merge_2(Vars, InstMapList, VarTypes, !InstMapping, !ModuleInfo, % Errors): % % Given Vars, a list of variables, and InstMapList, a list of instmaps @@ -686,33 +686,33 @@ get_reachable_instmaps([InstMap | InstMaps], Reachables) :- % If some variables in Vars have incompatible insts in two or more instmaps % in InstMapList, return them in `Errors'. % -:- pred instmap__merge_2(list(prog_var)::in, list(instmap)::in, vartypes::in, +:- pred merge_2(list(prog_var)::in, list(instmap)::in, vartypes::in, instmapping::in, instmapping::out, module_info::in, module_info::out, merge_errors::out) is det. -instmap__merge_2([], _, _, !InstMap, !ModuleInfo, []). -instmap__merge_2([Var | Vars], InstMapList, VarTypes, !InstMapping, +merge_2([], _, _, !InstMap, !ModuleInfo, []). +merge_2([Var | Vars], InstMapList, VarTypes, !InstMapping, !ModuleInfo, !:ErrorList) :- - instmap__merge_2(Vars, InstMapList, VarTypes, !InstMapping, !ModuleInfo, + merge_2(Vars, InstMapList, VarTypes, !InstMapping, !ModuleInfo, !:ErrorList), - map__lookup(VarTypes, Var, VarType), - list__map(lookup_var_in_instmap(Var), InstMapList, InstList), - instmap__merge_var(InstList, Var, VarType, !ModuleInfo, MaybeInst), + map.lookup(VarTypes, Var, VarType), + list.map(lookup_var_in_instmap(Var), InstMapList, InstList), + merge_var(InstList, Var, VarType, !ModuleInfo, MaybeInst), ( MaybeInst = no, !:ErrorList = [Var - InstList | !.ErrorList], - svmap__set(Var, not_reached, !InstMapping) + svmap.set(Var, not_reached, !InstMapping) ; MaybeInst = yes(Inst), - svmap__set(Var, Inst, !InstMapping) + svmap.set(Var, Inst, !InstMapping) ). :- pred lookup_var_in_instmap(prog_var::in, instmap::in, mer_inst::out) is det. lookup_var_in_instmap(Var, InstMap, Inst) :- - instmap__lookup_var(InstMap, Var, Inst). + lookup_var(InstMap, Var, Inst). - % instmap__merge_var(Insts, Var, Type, Inst, !ModuleInfo, !Error): + % merge_var(Insts, Var, Type, Inst, !ModuleInfo, !Error): % % Given a list of insts of the given variable that reflect the inst of that % variable at the ends of a branched control structure such as a @@ -738,11 +738,11 @@ lookup_var_in_instmap(Var, InstMap, Inst) :- % number of insts in half by merging adjacent pairs of insts. The overall % complexity is thus N log N, not N^2. % -:- pred instmap__merge_var(list(mer_inst)::in, prog_var::in, mer_type::in, +:- pred merge_var(list(mer_inst)::in, prog_var::in, mer_type::in, module_info::in, module_info::out, maybe(mer_inst)::out) is det. -instmap__merge_var(Insts, Var, Type, !ModuleInfo, MaybeMergedInst) :- - instmap__merge_var_2(Insts, Var, Type, [], MergedInsts, !ModuleInfo, +merge_var(Insts, Var, Type, !ModuleInfo, MaybeMergedInst) :- + merge_var_2(Insts, Var, Type, [], MergedInsts, !ModuleInfo, no, Error), ( Error = yes, @@ -757,23 +757,23 @@ instmap__merge_var(Insts, Var, Type, !ModuleInfo, MaybeMergedInst) :- MaybeMergedInst = yes(MergedInst) ; MergedInsts = [_, _ | _], - instmap__merge_var(MergedInsts, Var, Type, !ModuleInfo, + merge_var(MergedInsts, Var, Type, !ModuleInfo, MaybeMergedInst) ) ). -:- pred instmap__merge_var_2(list(mer_inst)::in, prog_var::in, mer_type::in, +:- pred merge_var_2(list(mer_inst)::in, prog_var::in, mer_type::in, list(mer_inst)::in, list(mer_inst)::out, module_info::in, module_info::out, bool::in, bool::out) is det. -instmap__merge_var_2([], _, _, !MergedInsts, !ModuleInfo, !Error). -instmap__merge_var_2([Inst], _Var, _Type, !MergedInsts, !ModuleInfo, !Error) :- - !:MergedInsts = [Inst | !.MergedInsts]. -instmap__merge_var_2([Inst1, Inst2 | Insts], Var, Type, !MergedInsts, +merge_var_2([], _, _, !MergedInsts, !ModuleInfo, !Error). +merge_var_2([Inst], _Var, _Type, !MergedInsts, !ModuleInfo, !Error) :- + !:MergedInsts = [Inst | !.MergedInsts]. +merge_var_2([Inst1, Inst2 | Insts], Var, Type, !MergedInsts, !ModuleInfo, !Error) :- ( inst_merge(Inst1, Inst2, yes(Type), MergedInst, !ModuleInfo) -> !:MergedInsts = [MergedInst | !.MergedInsts], - instmap__merge_var_2(Insts, Var, Type, !MergedInsts, !ModuleInfo, + merge_var_2(Insts, Var, Type, !MergedInsts, !ModuleInfo, !Error) ; !:Error = yes @@ -818,11 +818,11 @@ merge_instmap_deltas_2(InstMap, NonLocals, VarTypes, [Delta1, Delta2 | Deltas], %-----------------------------------------------------------------------------% -instmap__unify(NonLocals, InstMapList, !ModeInfo) :- +unify(NonLocals, InstMapList, !ModeInfo) :- ( % If any of the instmaps is unreachable, then the final instmap % is unreachable. - list__member(unreachable - _, InstMapList) + list.member(unreachable - _, InstMapList) -> mode_info_set_instmap(unreachable, !ModeInfo) ; @@ -835,11 +835,11 @@ instmap__unify(NonLocals, InstMapList, !ModeInfo) :- InstMap0 = reachable(InstMapping0) -> % Having got the first instmapping, to use as an accumulator, - % all instmap__unify_2 which unifies each of the nonlocals from + % all unify_2 which unifies each of the nonlocals from % each instmap with the corresponding inst in the accumulator. mode_info_get_module_info(!.ModeInfo, ModuleInfo0), - set__to_sorted_list(NonLocals, NonLocalsList), - instmap__unify_2(NonLocalsList, InstMap0, InstMapList1, + set.to_sorted_list(NonLocals, NonLocalsList), + unify_2(NonLocalsList, InstMap0, InstMapList1, ModuleInfo0, ModuleInfo, InstMapping0, InstMapping, ErrorList), mode_info_set_module_info(ModuleInfo, !ModeInfo), @@ -848,7 +848,7 @@ instmap__unify(NonLocals, InstMapList, !ModeInfo) :- ( ErrorList = [FirstError | _], FirstError = Var - _, - set__singleton_set(WaitingVars, Var), + set.singleton_set(WaitingVars, Var), mode_info_error(WaitingVars, mode_error_par_conj(ErrorList), !ModeInfo) ; @@ -861,25 +861,25 @@ instmap__unify(NonLocals, InstMapList, !ModeInfo) :- %-----------------------------------------------------------------------------% - % instmap__unify_2(Vars, InitialInstMap, InstMaps, !ModuleInfo, + % unify_2(Vars, InitialInstMap, InstMaps, !ModuleInfo, % !Instmap, ErrorList): % % Let `ErrorList' be the list of variables in `Vars' for which there are % two instmaps in `InstMaps' for which the insts of the variable is % incompatible. % -:- pred instmap__unify_2(list(prog_var)::in, instmap::in, +:- pred unify_2(list(prog_var)::in, instmap::in, list(pair(instmap, set(prog_var)))::in, module_info::in, module_info::out, map(prog_var, mer_inst)::in, map(prog_var, mer_inst)::out, merge_errors::out) is det. -instmap__unify_2([], _, _, !ModuleInfo, !InstMap, []). -instmap__unify_2([Var|Vars], InitialInstMap, InstMapList, +unify_2([], _, _, !ModuleInfo, !InstMap, []). +unify_2([Var|Vars], InitialInstMap, InstMapList, !ModuleInfo, !InstMap, ErrorList) :- - instmap__unify_2(Vars, InitialInstMap, InstMapList, !ModuleInfo, !InstMap, + unify_2(Vars, InitialInstMap, InstMapList, !ModuleInfo, !InstMap, ErrorListTail), - instmap__lookup_var(InitialInstMap, Var, InitialVarInst), - instmap__unify_var(InstMapList, Var, [], Insts, InitialVarInst, Inst, + lookup_var(InitialInstMap, Var, InitialVarInst), + unify_var(InstMapList, Var, [], Insts, InitialVarInst, Inst, !ModuleInfo, no, Error), ( Error = yes, @@ -888,25 +888,25 @@ instmap__unify_2([Var|Vars], InitialInstMap, InstMapList, Error = no, ErrorList = ErrorListTail ), - map__set(!.InstMap, Var, Inst, !:InstMap). + map.set(!.InstMap, Var, Inst, !:InstMap). - % instmap__unify_var(InstMaps, Var, InitialInstMap, ModuleInfo, + % unify_var(InstMaps, Var, InitialInstMap, ModuleInfo, % Insts, Error): % % Let `Insts' be the list of the inst of `Var' in each of the % corresponding `InstMaps'. Let `Error' be yes iff there are two % instmaps for which the inst of `Var' is incompatible. % -:- pred instmap__unify_var(list(pair(instmap, set(prog_var)))::in, +:- pred unify_var(list(pair(instmap, set(prog_var)))::in, prog_var::in, list(mer_inst)::in, list(mer_inst)::out, mer_inst::in, mer_inst::out, module_info::in, module_info::out, bool::in, bool::out) is det. -instmap__unify_var([], _, !Insts, !Inst, !ModuleInfo, !Error). -instmap__unify_var([InstMap - Nonlocals| Rest], Var, !InstList, !Inst, +unify_var([], _, !Insts, !Inst, !ModuleInfo, !Error). +unify_var([InstMap - Nonlocals| Rest], Var, !InstList, !Inst, !ModuleInfo, !Error) :- - ( set__member(Var, Nonlocals) -> - instmap__lookup_var(InstMap, Var, VarInst), + ( set.member(Var, Nonlocals) -> + lookup_var(InstMap, Var, VarInst), ( % We can ignore the determinism of the unification: % if it isn't det, then there will be a mode error @@ -923,7 +923,7 @@ instmap__unify_var([InstMap - Nonlocals| Rest], Var, !InstList, !Inst, VarInst = free ), !:InstList = [VarInst | !.InstList], - instmap__unify_var(Rest, Var, !InstList, !Inst, !ModuleInfo, !Error). + unify_var(Rest, Var, !InstList, !Inst, !ModuleInfo, !Error). %-----------------------------------------------------------------------------% @@ -931,9 +931,9 @@ compute_instmap_delta(unreachable, _, _, unreachable). compute_instmap_delta(reachable(_), unreachable, _, unreachable). compute_instmap_delta(reachable(InstMapA), reachable(InstMapB), NonLocals, reachable(DeltaInstMap)) :- - set__to_sorted_list(NonLocals, NonLocalsList), + set.to_sorted_list(NonLocals, NonLocalsList), compute_instmap_delta_2(NonLocalsList, InstMapA, InstMapB, AssocList), - map__from_sorted_assoc_list(AssocList, DeltaInstMap). + map.from_sorted_assoc_list(AssocList, DeltaInstMap). :- pred compute_instmap_delta_2(list(prog_var)::in, instmapping::in, instmapping::in, assoc_list(prog_var, mer_inst)::out) is det. @@ -952,16 +952,16 @@ compute_instmap_delta_2([Var | Vars], InstMapA, InstMapB, AssocList) :- %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -instmap__no_output_vars(_, unreachable, _, _, _). -instmap__no_output_vars(InstMap0, reachable(InstMapDelta), Vars, VT, M) :- - set__to_sorted_list(Vars, VarList), - instmap__no_output_vars_2(VarList, InstMap0, InstMapDelta, VT, M). +no_output_vars(_, unreachable, _, _, _). +no_output_vars(InstMap0, reachable(InstMapDelta), Vars, VT, M) :- + set.to_sorted_list(Vars, VarList), + no_output_vars_2(VarList, InstMap0, InstMapDelta, VT, M). -:- pred instmap__no_output_vars_2(list(prog_var)::in, instmap::in, +:- pred no_output_vars_2(list(prog_var)::in, instmap::in, instmapping::in, vartypes::in, module_info::in) is semidet. -instmap__no_output_vars_2([], _, _, _, _). -instmap__no_output_vars_2([Var | Vars], InstMap0, InstMapDelta, VarTypes, +no_output_vars_2([], _, _, _, _). +no_output_vars_2([Var | Vars], InstMap0, InstMapDelta, VarTypes, ModuleInfo) :- % We use `inst_matches_binding' to check that the new inst has only % added information or lost uniqueness, not bound anything. @@ -970,16 +970,15 @@ instmap__no_output_vars_2([Var | Vars], InstMap0, InstMapDelta, VarTypes, % rather than an increase in instantiatedness. If the instmap delta % doesn't contain the variable, it may still have been (partially) output, % if its inst is (or contains) `any'. - instmap__lookup_var(InstMap0, Var, Inst0), - ( map__search(InstMapDelta, Var, Inst1) -> + lookup_var(InstMap0, Var, Inst0), + ( map.search(InstMapDelta, Var, Inst1) -> Inst = Inst1 ; Inst = Inst0 ), - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), inst_matches_binding(Inst, Inst0, Type, ModuleInfo), - instmap__no_output_vars_2(Vars, InstMap0, InstMapDelta, VarTypes, - ModuleInfo). + no_output_vars_2(Vars, InstMap0, InstMapDelta, VarTypes, ModuleInfo). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -999,14 +998,14 @@ merge_instmap_delta(InstMap, NonLocals, VarTypes, reachable(InstMappingA), merge_instmapping_delta(InstMap, NonLocals, VarTypes, InstMappingA, InstMappingB, InstMapping, !ModuleInfo) :- - map__keys(InstMappingA, VarsInA), - map__keys(InstMappingB, VarsInB), - set__sorted_list_to_set(VarsInA, SetofVarsInA), - set__insert_list(SetofVarsInA, VarsInB, SetofVars0), - set__intersect(SetofVars0, NonLocals, SetofVars), - set__to_sorted_list(SetofVars, ListofVars), + map.keys(InstMappingA, VarsInA), + map.keys(InstMappingB, VarsInB), + set.sorted_list_to_set(VarsInA, SetofVarsInA), + set.insert_list(SetofVarsInA, VarsInB, SetofVars0), + set.intersect(SetofVars0, NonLocals, SetofVars), + set.to_sorted_list(SetofVars, ListofVars), merge_instmapping_delta_2(ListofVars, InstMap, VarTypes, - InstMappingA, InstMappingB, map__init, InstMapping, !ModuleInfo). + InstMappingA, InstMappingB, map.init, InstMapping, !ModuleInfo). :- pred merge_instmapping_delta_2(list(prog_var)::in, instmap::in, vartypes::in, instmapping::in, instmapping::in, @@ -1016,21 +1015,21 @@ merge_instmapping_delta(InstMap, NonLocals, VarTypes, merge_instmapping_delta_2([], _, _, _, _, !InstMapping, !ModuleInfo). merge_instmapping_delta_2([Var | Vars], InstMap, VarTypes, InstMappingA, InstMappingB, !InstMapping, !ModuleInfo) :- - ( map__search(InstMappingA, Var, InstInA) -> + ( map.search(InstMappingA, Var, InstInA) -> InstA = InstInA ; - instmap__lookup_var(InstMap, Var, InstA) + lookup_var(InstMap, Var, InstA) ), - ( map__search(InstMappingB, Var, InstInB) -> + ( map.search(InstMappingB, Var, InstInB) -> InstB = InstInB ; - instmap__lookup_var(InstMap, Var, InstB) + lookup_var(InstMap, Var, InstB) ), ( inst_merge(InstA, InstB, yes(VarTypes ^ det_elem(Var)), Inst1, !ModuleInfo) -> - % XXX Given instmap__lookup_var(InstMap, Var, OldInst), + % XXX Given lookup_var(InstMap, Var, OldInst), % we should probably set Inst not directly from Inst1, but % from a conjunction of OldInst and Inst1. If OldInst says that % Var is bound to f, and Inst1 says that it is bound to g, @@ -1047,10 +1046,10 @@ merge_instmapping_delta_2([Var | Vars], InstMap, VarTypes, % tests/hard_coded. -zs Inst = Inst1, - svmap__det_insert(Var, Inst, !InstMapping) + svmap.det_insert(Var, Inst, !InstMapping) ; - term__var_to_int(Var, VarInt), - string__format("merge_instmapping_delta_2: error merging var %i", + term.var_to_int(Var, VarInt), + string.format("merge_instmapping_delta_2: error merging var %i", [i(VarInt)], Msg), unexpected(this_file, Msg) ), @@ -1077,14 +1076,14 @@ unify_instmap_delta(InstMap, NonLocals, reachable(InstMappingA), unify_instmapping_delta(InstMap, NonLocals, InstMappingA, InstMappingB, InstMapping, !ModuleInfo) :- - map__keys(InstMappingA, VarsInA), - map__keys(InstMappingB, VarsInB), - set__sorted_list_to_set(VarsInA, SetofVarsInA), - set__insert_list(SetofVarsInA, VarsInB, SetofVars0), - set__intersect(SetofVars0, NonLocals, SetofVars), - set__to_sorted_list(SetofVars, ListofVars), + map.keys(InstMappingA, VarsInA), + map.keys(InstMappingB, VarsInB), + set.sorted_list_to_set(VarsInA, SetofVarsInA), + set.insert_list(SetofVarsInA, VarsInB, SetofVars0), + set.intersect(SetofVars0, NonLocals, SetofVars), + set.to_sorted_list(SetofVars, ListofVars), unify_instmapping_delta_2(ListofVars, InstMap, InstMappingA, InstMappingB, - map__init, InstMapping, !ModuleInfo). + map.init, InstMapping, !ModuleInfo). :- pred unify_instmapping_delta_2(list(prog_var)::in, instmap::in, instmapping::in, instmapping::in, instmapping::in, instmapping::out, @@ -1093,8 +1092,8 @@ unify_instmapping_delta(InstMap, NonLocals, InstMappingA, InstMappingB, unify_instmapping_delta_2([], _, _, _, !InstMapping, !ModuleInfo). unify_instmapping_delta_2([Var | Vars], InstMap, InstMappingA, InstMappingB, !InstMapping, !ModuleInfo) :- - ( map__search(InstMappingA, Var, InstA) -> - ( map__search(InstMappingB, Var, InstB) -> + ( map.search(InstMappingA, Var, InstA) -> + ( map.search(InstMappingB, Var, InstB) -> ( % We can ignore the determinism of the unification: if it % isn't det, then there will be a mode error or a determinism @@ -1103,17 +1102,17 @@ unify_instmapping_delta_2([Var | Vars], InstMap, InstMappingA, InstMappingB, abstractly_unify_inst(live, InstA, InstB, fake_unify, Inst, _Det, !ModuleInfo) -> - svmap__det_insert(Var, Inst, !InstMapping) + svmap.det_insert(Var, Inst, !InstMapping) ; unexpected(this_file, "unify_instmapping_delta_2: unexpected error") ) ; - svmap__det_insert(Var, InstA, !InstMapping) + svmap.det_insert(Var, InstA, !InstMapping) ) ; - ( map__search(InstMappingB, Var, InstB) -> - svmap__det_insert(Var, InstB, !InstMapping) + ( map.search(InstMappingB, Var, InstB) -> + svmap.det_insert(Var, InstB, !InstMapping) ; true ) @@ -1127,11 +1126,11 @@ unify_instmapping_delta_2([Var | Vars], InstMap, InstMappingA, InstMappingB, instmap_delta_apply_sub(_Must, _Sub, unreachable, unreachable). instmap_delta_apply_sub(Must, Sub, reachable(OldInstMapping), reachable(InstMapping)) :- - map__to_assoc_list(OldInstMapping, InstMappingAL), + map.to_assoc_list(OldInstMapping, InstMappingAL), instmap_delta_apply_sub_2(InstMappingAL, Must, Sub, - map__init, InstMapping). + map.init, InstMapping). -instmap__apply_sub(Must, Sub, InstMap0, InstMap) :- +apply_sub(Must, Sub, InstMap0, InstMap) :- instmap_delta_apply_sub(Must, Sub, InstMap0, InstMap). :- pred instmap_delta_apply_sub_2(assoc_list(prog_var, mer_inst)::in, bool::in, @@ -1139,7 +1138,7 @@ instmap__apply_sub(Must, Sub, InstMap0, InstMap) :- instmap_delta_apply_sub_2([], _Must, _Sub, IM, IM). instmap_delta_apply_sub_2([V - I | AL], Must, Sub, IM0, IM) :- - ( map__search(Sub, V, N0) -> + ( map.search(Sub, V, N0) -> N = N0 ; ( @@ -1151,27 +1150,26 @@ instmap_delta_apply_sub_2([V - I | AL], Must, Sub, IM0, IM) :- ) ), % XXX temporary hack alert XXX - % this should be a call to to map__det_insert, - % rather than a call to map__set. However, if we - % do that, then the compiler breaks, due to a problem - % with excess.m not preserving super-homogenous form. - map__set(IM0, N, I, IM1), + % This should be a call to to map.det_insert, rather than a call + % to map.set. However, if we do that, then the compiler breaks, + % due to a problem with excess.m not preserving super-homogenous form. + map.set(IM0, N, I, IM1), instmap_delta_apply_sub_2(AL, Must, Sub, IM1, IM). %-----------------------------------------------------------------------------% -instmap__to_assoc_list(unreachable, []). -instmap__to_assoc_list(reachable(InstMapping), AL) :- - map__to_assoc_list(InstMapping, AL). +to_assoc_list(unreachable, []). +to_assoc_list(reachable(InstMapping), AL) :- + map.to_assoc_list(InstMapping, AL). instmap_delta_to_assoc_list(unreachable, []). instmap_delta_to_assoc_list(reachable(InstMapping), AL) :- - map__to_assoc_list(InstMapping, AL). + map.to_assoc_list(InstMapping, AL). %-----------------------------------------------------------------------------% var_is_ground_in_instmap(ModuleInfo, InstMap, Var) :- - instmap__lookup_var(InstMap, Var, Inst), + lookup_var(InstMap, Var, Inst), inst_is_ground(ModuleInfo, Inst). %-----------------------------------------------------------------------------% diff --git a/compiler/intermod.m b/compiler/intermod.m index 12c45b2b0..e0f3b01af 100644 --- a/compiler/intermod.m +++ b/compiler/intermod.m @@ -35,7 +35,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__intermod. +:- module transform_hlds.intermod. :- interface. :- import_module hlds.hlds_module. @@ -137,30 +137,30 @@ write_optfile(!ModuleInfo, !IO) :- % We don't want to output line numbers in the .opt files, % since that causes spurious changes to the .opt files % when you make trivial changes (e.g. add comments) to the source files. - globals__io_lookup_bool_option(line_numbers, LineNumbers, !IO), - globals__io_set_option(line_numbers, bool(no), !IO), + globals.io_lookup_bool_option(line_numbers, LineNumbers, !IO), + globals.io_set_option(line_numbers, bool(no), !IO), module_info_get_name(!.ModuleInfo, ModuleName), module_name_to_file_name(ModuleName, ".opt.tmp", yes, TmpName, !IO), - io__open_output(TmpName, Result2, !IO), + io.open_output(TmpName, Result2, !IO), ( Result2 = error(Err2), - io__error_message(Err2, Msg2), - io__write_string(Msg2, !IO), - io__set_exit_status(1, !IO) + io.error_message(Err2, Msg2), + io.write_string(Msg2, !IO), + io.set_exit_status(1, !IO) ; Result2 = ok(FileStream), - io__set_output_stream(FileStream, OutputStream, !IO), + io.set_output_stream(FileStream, OutputStream, !IO), module_info_predids(!.ModuleInfo, RealPredIds), module_info_get_assertion_table(!.ModuleInfo, AssertionTable), assertion_table_pred_ids(AssertionTable, AssertPredIds), - list__append(AssertPredIds, RealPredIds, PredIds), - globals__io_lookup_int_option(intermod_inline_simple_threshold, + list.append(AssertPredIds, RealPredIds, PredIds), + globals.io_lookup_int_option(intermod_inline_simple_threshold, Threshold, !IO), - globals__io_lookup_bool_option(deforestation, Deforestation, !IO), - globals__io_lookup_int_option(higher_order_size_limit, + globals.io_lookup_bool_option(deforestation, Deforestation, !IO), + globals.io_lookup_int_option(higher_order_size_limit, HigherOrderSizeLimit, !IO), - globals__io_lookup_bool_option(intermod_unused_args, UnusedArgs, !IO), + globals.io_lookup_bool_option(intermod_unused_args, UnusedArgs, !IO), some [!IntermodInfo] ( init_intermod_info(!.ModuleInfo, !:IntermodInfo), gather_preds(PredIds, yes, Threshold, HigherOrderSizeLimit, @@ -169,8 +169,8 @@ write_optfile(!ModuleInfo, !IO) :- gather_types(!IntermodInfo), write_intermod_info(!.IntermodInfo, !IO), intermod_info_get_module_info(!.IntermodInfo, !:ModuleInfo), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO), + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO), ( UnusedArgs = yes, do_adjust_pred_import_status(!.IntermodInfo, !ModuleInfo) @@ -180,7 +180,7 @@ write_optfile(!ModuleInfo, !IO) :- ) ), % restore the option setting that we overrode above - globals__io_set_option(line_numbers, bool(LineNumbers), !IO). + globals.io_set_option(line_numbers, bool(LineNumbers), !IO). %-----------------------------------------------------------------------------% % @@ -198,7 +198,7 @@ gather_preds(AllPredIds, CollectTypes, InlineThreshold, HigherOrderSizeLimit, InlineThreshold, HigherOrderSizeLimit, Deforestation, !Info), % Then gather preds used by exported preds (recursively). - set__init(ExtraExportedPreds0), + set.init(ExtraExportedPreds0), gather_preds_2(ExtraExportedPreds0, CollectTypes, InlineThreshold, HigherOrderSizeLimit, Deforestation, !Info). @@ -208,8 +208,8 @@ gather_preds(AllPredIds, CollectTypes, InlineThreshold, HigherOrderSizeLimit, gather_preds_2(ExtraExportedPreds0, CollectTypes, InlineThreshold, HigherOrderSizeLimit, Deforestation, !Info) :- intermod_info_get_pred_decls(!.Info, ExtraExportedPreds), - NewlyExportedPreds = set__to_sorted_list( - ExtraExportedPreds `set__difference` ExtraExportedPreds0), + NewlyExportedPreds = set.to_sorted_list( + ExtraExportedPreds `set.difference` ExtraExportedPreds0), ( NewlyExportedPreds = [] ; @@ -229,13 +229,13 @@ gather_pred_list([PredId | PredIds], ProcessLocalPreds, CollectTypes, InlineThreshold, HigherOrderSizeLimit, Deforestation, !Info) :- intermod_info_get_module_info(!.Info, ModuleInfo0), module_info_preds(ModuleInfo0, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), module_info_get_type_spec_info(ModuleInfo0, TypeSpecInfo), TypeSpecInfo = type_spec_info(_, TypeSpecForcePreds, _, _), pred_info_clauses_info(PredInfo0, ClausesInfo0), ( clauses_info_explicit_vartypes(ClausesInfo0, ExplicitVarTypes), - map__is_empty(ExplicitVarTypes), + map.is_empty(ExplicitVarTypes), should_be_processed(ProcessLocalPreds, PredId, PredInfo0, TypeSpecForcePreds, InlineThreshold, HigherOrderSizeLimit, Deforestation, ModuleInfo0) @@ -264,7 +264,7 @@ gather_pred_list([PredId | PredIds], ProcessLocalPreds, CollectTypes, clauses_info_set_clauses_rep(ClausesRep, ClausesInfo0, ClausesInfo), pred_info_set_clauses_info(ClausesInfo, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, ModuleInfo0, ModuleInfo), intermod_info_get_preds(!.Info, Preds0), ( pred_info_pragma_goal_type(PredInfo) -> @@ -274,7 +274,7 @@ gather_pred_list([PredId | PredIds], ProcessLocalPreds, CollectTypes, ; true ), - set__insert(Preds0, PredId, Preds), + set.insert(Preds0, PredId, Preds), intermod_info_set_preds(Preds, !Info), intermod_info_set_module_info(ModuleInfo, !Info) ; @@ -309,7 +309,7 @@ should_be_processed(ProcessLocalPreds, PredId, PredInfo, TypeSpecForcePreds, [ProcId | _ProcIds] = pred_info_procids(PredInfo), pred_info_procedures(PredInfo, Procs), - map__lookup(Procs, ProcId, ProcInfo), + map.lookup(Procs, ProcId, ProcInfo), % At this point, the goal size includes some dummy unifications % HeadVar1 = X, HeadVar2 = Y, etc. which will be optimized away @@ -332,18 +332,18 @@ should_be_processed(ProcessLocalPreds, PredId, PredInfo, TypeSpecForcePreds, \+ pred_info_is_builtin(PredInfo), % These will be recreated in the importing module. - \+ set__member(PredId, TypeSpecForcePreds), + \+ set.member(PredId, TypeSpecForcePreds), % No point exporting code which isn't very inlinable. module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), \+ clauses_contain_noninlinable_foreign_code(Target, Clauses), % Don't export tabled predicates since they are not inlinable. proc_info_eval_method(ProcInfo, eval_normal), ( - inlining__is_simple_clause_list(Clauses, InlineThreshold + Arity), + inlining.is_simple_clause_list(Clauses, InlineThreshold + Arity), pred_info_get_markers(PredInfo, Markers), \+ check_marker(Markers, user_marked_no_inline) ; @@ -359,7 +359,7 @@ should_be_processed(ProcessLocalPreds, PredId, PredInfo, TypeSpecForcePreds, % in each disjunct. The disjunction adds one to the goal size, % hence the `+1'. DeforestThreshold = InlineThreshold * 2 + 1, - inlining__is_simple_clause_list(Clauses, + inlining.is_simple_clause_list(Clauses, DeforestThreshold + Arity), clause_list_is_deforestable(PredId, Clauses) ) @@ -416,7 +416,7 @@ check_for_ho_input_args(ModuleInfo, VarTypes, [HeadVar | HeadVars], [ArgMode | ArgModes]) :- ( mode_is_input(ModuleInfo, ArgMode), - map__lookup(VarTypes, HeadVar, Type), + map.lookup(VarTypes, HeadVar, Type), classify_type(ModuleInfo, Type) = type_cat_higher_order ; check_for_ho_input_args(ModuleInfo, VarTypes, HeadVars, ArgModes) @@ -429,7 +429,7 @@ check_for_ho_input_args(ModuleInfo, VarTypes, clause_list_is_deforestable(PredId, Clauses) :- some [Clause1] ( - list__member(Clause1, Clauses), + list.member(Clause1, Clauses), Clause1 = clause(_, Goal1, _, _), goal_calls_pred_id(Goal1, PredId) ), @@ -502,7 +502,7 @@ traverse_goal(if_then_else(Vars, Cond0, Then0, Else0) - Info, traverse_goal(Cond0, Cond, DoWrite1, !Info), traverse_goal(Then0, Then, DoWrite2, !Info), traverse_goal(Else0, Else, DoWrite3, !Info), - bool__and_list([DoWrite1, DoWrite2, DoWrite3], DoWrite). + bool.and_list([DoWrite1, DoWrite2, DoWrite3], DoWrite). % Inlineable exported pragma_foreign_code goals can't use any % non-exported types, so we just write out the clauses. traverse_goal(Goal @ foreign_proc(_, _, _, _, _, _) - Info, @@ -597,8 +597,8 @@ add_proc_2(PredId, DoWrite, !Info) :- check_marker(Markers, infer_modes) ; pred_info_procedures(PredInfo, Procs), - list__member(ProcId, ProcIds), - map__lookup(Procs, ProcId, ProcInfo), + list.member(ProcId, ProcIds), + map.lookup(Procs, ProcId, ProcInfo), proc_info_declared_determinism(ProcInfo, no) ) -> @@ -659,7 +659,7 @@ add_proc_2(PredId, DoWrite, !Info) :- -> DoWrite = yes, intermod_info_get_pred_decls(!.Info, PredDecls0), - set__insert(PredDecls0, PredId, PredDecls), + set.insert(PredDecls0, PredId, PredDecls), intermod_info_set_pred_decls(PredDecls, !Info) ; ( Status = imported(_) @@ -672,7 +672,7 @@ add_proc_2(PredId, DoWrite, !Info) :- DoWrite = yes, PredModule = pred_info_module(PredInfo), intermod_info_get_modules(!.Info, Modules0), - set__insert(Modules0, PredModule, Modules), + set.insert(Modules0, PredModule, Modules), intermod_info_set_modules(Modules, !Info) ; unexpected(this_file, "add_proc: unexpected status") @@ -724,14 +724,14 @@ module_qualify_unify_rhs(_LHS, RHS @ functor(Functor, _Exist, _Vars), gather_instances(!Info) :- intermod_info_get_module_info(!.Info, ModuleInfo), module_info_get_instance_table(ModuleInfo, Instances), - map__foldl(gather_instances_2(ModuleInfo), Instances, !Info). + map.foldl(gather_instances_2(ModuleInfo), Instances, !Info). :- pred gather_instances_2(module_info::in, class_id::in, list(hlds_instance_defn)::in, intermod_info::in, intermod_info::out) is det. gather_instances_2(ModuleInfo, ClassId, InstanceDefns, !Info) :- - list__foldl(gather_instances_3(ModuleInfo, ClassId), InstanceDefns, !Info). + list.foldl(gather_instances_3(ModuleInfo, ClassId), InstanceDefns, !Info). :- pred gather_instances_3(module_info::in, class_id::in, hlds_instance_defn::in, intermod_info::in, intermod_info::out) is det. @@ -756,21 +756,21 @@ gather_instances_3(ModuleInfo, ClassId, InstanceDefn, !Info) :- (pred(Proc::in, PredId::out) is det :- Proc = hlds_class_proc(PredId, _) ), - list__map(GetPredId, ClassProcs, ClassPreds0), + list.map(GetPredId, ClassProcs, ClassPreds0), % The interface is sorted on pred_id. - list__remove_adjacent_dups(ClassPreds0, ClassPreds), - assoc_list__from_corresponding_lists(ClassPreds, Methods0, + list.remove_adjacent_dups(ClassPreds0, ClassPreds), + assoc_list.from_corresponding_lists(ClassPreds, Methods0, MethodAL) ; MaybePredProcIds = no, unexpected(this_file, "gather_instances_3: method pred_proc_ids not filled in") ), - list__map_foldl(qualify_instance_method(ModuleInfo), + list.map_foldl(qualify_instance_method(ModuleInfo), MethodAL, Methods, [], PredIds), - list__map_foldl(add_proc, PredIds, DoWriteMethodsList, !Info), - bool__and_list(DoWriteMethodsList, DoWriteMethods), + list.map_foldl(add_proc, PredIds, DoWriteMethodsList, !Info), + bool.and_list(DoWriteMethodsList, DoWriteMethods), ( DoWriteMethods = yes, Interface = concrete(Methods) @@ -896,9 +896,9 @@ find_func_matching_instance_method(ModuleInfo, InstanceMethodName0, ( is_field_access_function_name(ModuleInfo, InstanceMethodName0, MethodArity, _, FieldName), - map__search(CtorFieldTable, FieldName, FieldDefns) + map.search(CtorFieldTable, FieldName, FieldDefns) -> - TypeCtors0 = list__map( + TypeCtors0 = list.map( (func(FieldDefn) = TypeCtor :- FieldDefn = hlds_ctor_field_defn(_, _, TypeCtor, _, _) ), FieldDefns) @@ -907,17 +907,17 @@ find_func_matching_instance_method(ModuleInfo, InstanceMethodName0, ), module_info_get_cons_table(ModuleInfo, Ctors), ( - map__search(Ctors, cons(InstanceMethodName0, MethodArity), + map.search(Ctors, cons(InstanceMethodName0, MethodArity), MatchingConstructors) -> - TypeCtors1 = list__map( + TypeCtors1 = list.map( (func(ConsDefn) = TypeCtor :- ConsDefn = hlds_cons_defn(_, _, _, TypeCtor, _) ), MatchingConstructors) ; TypeCtors1 = [] ), - TypeCtors = list__append(TypeCtors0, TypeCtors1), + TypeCtors = list.append(TypeCtors0, TypeCtors1), module_info_get_predicate_table(ModuleInfo, PredicateTable), ( @@ -949,7 +949,7 @@ find_func_matching_instance_method(ModuleInfo, InstanceMethodName0, gather_types(!Info) :- intermod_info_get_module_info(!.Info, ModuleInfo), module_info_get_type_table(ModuleInfo, Types), - map__foldl(gather_types_2, Types, !Info). + map.foldl(gather_types_2, Types, !Info). :- pred gather_types_2(type_ctor::in, hlds_type_defn::in, intermod_info::in, intermod_info::out) is det. @@ -958,13 +958,13 @@ gather_types_2(TypeCtor, TypeDefn0, !Info) :- intermod_info_get_module_info(!.Info, ModuleInfo), module_info_get_name(ModuleInfo, ModuleName), ( should_write_type(ModuleName, TypeCtor, TypeDefn0) -> - hlds_data__get_type_defn_body(TypeDefn0, TypeBody0), + hlds_data.get_type_defn_body(TypeDefn0, TypeBody0), ( TypeBody0 = du_type(Ctors, Tags, Enum, MaybeUserEqComp0, ReservedTag, MaybeForeign0) -> module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), % % Note that we don't resolve overloading for the definitions @@ -993,7 +993,7 @@ gather_types_2(TypeCtor, TypeDefn0, !Info) :- ), TypeBody = du_type(Ctors, Tags, Enum, MaybeUserEqComp, ReservedTag, MaybeForeign), - hlds_data__set_type_defn_body(TypeBody, TypeDefn0, TypeDefn) + hlds_data.set_type_defn_body(TypeBody, TypeDefn0, TypeDefn) ; TypeBody0 = foreign_type(ForeignTypeBody0) -> @@ -1003,7 +1003,7 @@ gather_types_2(TypeCtor, TypeDefn0, !Info) :- resolve_foreign_type_body_overloading(ModuleInfo, TypeCtor, ForeignTypeBody0, ForeignTypeBody, !Info), TypeBody = foreign_type(ForeignTypeBody), - hlds_data__set_type_defn_body(TypeBody, TypeDefn0, TypeDefn) + hlds_data.set_type_defn_body(TypeBody, TypeDefn0, TypeDefn) ; TypeDefn = TypeDefn0 ), @@ -1021,7 +1021,7 @@ resolve_foreign_type_body_overloading(ModuleInfo, TypeCtor, foreign_type_body(MaybeIL0, MaybeC0, MaybeJava0), foreign_type_body(MaybeIL, MaybeC, MaybeJava), !Info) :- module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), % % Note that we don't resolve overloading for the foreign definitions @@ -1087,7 +1087,7 @@ resolve_user_special_pred_overloading(_, _, _, no, no, !Info). resolve_user_special_pred_overloading(ModuleInfo, SpecialId, TypeCtor, yes(Pred0), yes(Pred), !Info) :- module_info_get_special_pred_map(ModuleInfo, SpecialPreds), - map__lookup(SpecialPreds, SpecialId - TypeCtor, UnifyPredId), + map.lookup(SpecialPreds, SpecialId - TypeCtor, UnifyPredId), module_info_pred_info(ModuleInfo, UnifyPredId, UnifyPredInfo), pred_info_arg_types(UnifyPredInfo, TVarSet, _, ArgTypes), init_markers(Markers0), @@ -1100,7 +1100,7 @@ resolve_user_special_pred_overloading(ModuleInfo, SpecialId, is semidet. should_write_type(ModuleName, TypeCtor, TypeDefn) :- - hlds_data__get_type_defn_status(TypeDefn, ImportStatus), + hlds_data.get_type_defn_status(TypeDefn, ImportStatus), TypeCtor = Name - _Arity, Name = qualified(ModuleName, _), import_status_to_write(ImportStatus). @@ -1114,9 +1114,9 @@ should_write_type(ModuleName, TypeCtor, TypeDefn) :- write_intermod_info(IntermodInfo, !IO) :- intermod_info_get_module_info(IntermodInfo, ModuleInfo), module_info_get_name(ModuleInfo, ModuleName), - io__write_string(":- module ", !IO), + io.write_string(":- module ", !IO), mercury_output_bracketed_sym_name(ModuleName, !IO), - io__write_string(".\n", !IO), + io.write_string(".\n", !IO), intermod_info_get_preds(IntermodInfo, Preds), intermod_info_get_pred_decls(IntermodInfo, PredDecls), @@ -1126,13 +1126,13 @@ write_intermod_info(IntermodInfo, !IO) :- % If none of these item types need writing, nothing % else needs to be written. % - set__empty(Preds), - set__empty(PredDecls), + set.empty(Preds), + set.empty(PredDecls), Instances = [], module_info_get_type_table(ModuleInfo, Types), \+ ( - map__member(Types, _, TypeDefn), - hlds_data__get_type_defn_status(TypeDefn, Status), + map.member(Types, _, TypeDefn), + hlds_data.get_type_defn_status(TypeDefn, Status), ( Status = abstract_exported ; Status = exported_to_submodules ) @@ -1148,16 +1148,16 @@ write_intermod_info(IntermodInfo, !IO) :- write_intermod_info_2(IntermodInfo, !IO) :- IntermodInfo = info(_, Preds0, PredDecls0, Instances, Types, ModuleInfo, WriteHeader, _, _), - set__to_sorted_list(Preds0, Preds), - set__to_sorted_list(PredDecls0, PredDecls), + set.to_sorted_list(Preds0, Preds), + set.to_sorted_list(PredDecls0, PredDecls), module_info_get_imported_module_specifiers(ModuleInfo, Modules0), - set__to_sorted_list(Modules0, Modules), + set.to_sorted_list(Modules0, Modules), ( Modules = [_ | _], % XXX this could be reduced to the set that is actually needed % by the items being written. - io__write_string(":- use_module ", !IO), + io.write_string(":- use_module ", !IO), write_modules(Modules, !IO) ; Modules = [] @@ -1170,14 +1170,14 @@ write_intermod_info_2(IntermodInfo, !IO) :- write_instances(Instances, !IO), % Disable verbose dumping of clauses. - globals__io_lookup_string_option(dump_hlds_options, VerboseDump, !IO), - globals__io_set_option(dump_hlds_options, string(""), !IO), + globals.io_lookup_string_option(dump_hlds_options, VerboseDump, !IO), + globals.io_set_option(dump_hlds_options, string(""), !IO), ( WriteHeader = yes, module_info_get_foreign_import_module(ModuleInfo, RevForeignImports), - ForeignImports = list__reverse(RevForeignImports), + ForeignImports = list.reverse(RevForeignImports), - list__foldl( + list.foldl( (pred(ForeignImport::in, IO0::di, IO::uo) is det :- ForeignImport = foreign_import_module(Lang, Import, _), mercury_output_pragma_foreign_import_module(Lang, Import, @@ -1188,7 +1188,7 @@ write_intermod_info_2(IntermodInfo, !IO) :- ), write_pred_decls(ModuleInfo, PredDecls, !IO), write_preds(ModuleInfo, Preds, !IO), - globals__io_set_option(dump_hlds_options, string(VerboseDump), !IO). + globals.io_set_option(dump_hlds_options, string(VerboseDump), !IO). :- pred write_modules(list(module_name)::in, io::di, io::uo) is det. @@ -1197,10 +1197,10 @@ write_modules([Module | Rest], !IO) :- mercury_output_bracketed_sym_name(Module, !IO), ( Rest = [], - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ; Rest = [_ | _], - io__write_string(", ", !IO), + io.write_string(", ", !IO), write_modules(Rest, !IO) ). @@ -1208,16 +1208,16 @@ write_modules([Module | Rest], !IO) :- is det. write_types(Types, !IO) :- - list__foldl(write_type, Types, !IO). + list.foldl(write_type, Types, !IO). :- pred write_type(pair(type_ctor, hlds_type_defn)::in, io::di, io::uo) is det. write_type(TypeCtor - TypeDefn, !IO) :- - hlds_data__get_type_defn_tvarset(TypeDefn, VarSet), - hlds_data__get_type_defn_tparams(TypeDefn, Args), - hlds_data__get_type_defn_body(TypeDefn, Body), - hlds_data__get_type_defn_context(TypeDefn, Context), + hlds_data.get_type_defn_tvarset(TypeDefn, VarSet), + hlds_data.get_type_defn_tparams(TypeDefn, Args), + hlds_data.get_type_defn_body(TypeDefn, Body), + hlds_data.get_type_defn_context(TypeDefn, Context), TypeCtor = Name - Arity, ( Ctors = Body ^ du_type_ctors, @@ -1303,7 +1303,7 @@ write_modes(ModuleInfo, !IO) :- module_info_get_name(ModuleInfo, ModuleName), module_info_get_mode_table(ModuleInfo, Modes), mode_table_get_mode_defns(Modes, ModeDefns), - map__foldl(write_mode(ModuleName), ModeDefns, !IO). + map.foldl(write_mode(ModuleName), ModeDefns, !IO). :- pred write_mode(module_name::in, mode_id::in, hlds_mode_defn::in, io::di, io::uo) is det. @@ -1330,7 +1330,7 @@ write_insts(ModuleInfo, !IO) :- module_info_get_inst_table(ModuleInfo, Insts), inst_table_get_user_insts(Insts, UserInsts), user_inst_table_get_inst_defns(UserInsts, InstDefns), - map__foldl(write_inst(ModuleName), InstDefns, !IO). + map.foldl(write_inst(ModuleName), InstDefns, !IO). :- pred write_inst(module_name::in, inst_id::in, hlds_inst_defn::in, io::di, io::uo) is det. @@ -1360,7 +1360,7 @@ write_inst(ModuleName, InstId, InstDefn, !IO) :- write_classes(ModuleInfo, !IO) :- module_info_get_name(ModuleInfo, ModuleName), module_info_get_class_table(ModuleInfo, Classes), - map__foldl(write_class(ModuleName), Classes, !IO). + map.foldl(write_class(ModuleName), Classes, !IO). :- pred write_class(module_name::in, class_id::in, hlds_class_defn::in, io::di, io::uo) is det. @@ -1402,7 +1402,7 @@ unmake_hlds_class_fundep_2(TVars, Set) = solutions(P) :- io::di, io::uo) is det. write_instances(Instances, !IO) :- - list__foldl(write_instance, Instances, !IO). + list.foldl(write_instance, Instances, !IO). :- pred write_instance(pair(class_id, hlds_instance_defn)::in, io::di, io::uo) is det. @@ -1475,7 +1475,7 @@ write_pred_decls(ModuleInfo, [PredId | PredIds], !IO) :- proc_id_to_int(ProcId2, ProcInt2), compare(Result, ProcInt1, ProcInt2) ), - list__sort(CompareProcId, ProcIds, SortedProcIds), + list.sort(CompareProcId, ProcIds, SortedProcIds), write_pred_modes(Procs, qualified(Module, Name), PredOrFunc, SortedProcIds, !IO), write_pragmas(PredInfo, !IO), @@ -1487,7 +1487,7 @@ write_pred_decls(ModuleInfo, [PredId | PredIds], !IO) :- write_pred_modes(_, _, _, [], !IO). write_pred_modes(Procs, SymName, PredOrFunc, [ProcId | ProcIds], !IO) :- - map__lookup(Procs, ProcId, ProcInfo), + map.lookup(Procs, ProcId, ProcInfo), proc_info_maybe_declared_argmodes(ProcInfo, MaybeArgModes), proc_info_declared_determinism(ProcInfo, MaybeDetism), ( @@ -1501,7 +1501,7 @@ write_pred_modes(Procs, SymName, PredOrFunc, [ProcId | ProcIds], !IO) :- "write_pred_modes: attempt to write undeclared mode") ), proc_info_context(ProcInfo, Context), - varset__init(Varset), + varset.init(Varset), ( PredOrFunc = function, pred_args_to_func_args(ArgModes, FuncArgModes, FuncRetMode), @@ -1536,7 +1536,7 @@ write_preds(ModuleInfo, [PredId | PredIds], !IO) :- ( pred_info_get_goal_type(PredInfo, promise(PromiseType)) -> ( Clauses = [Clause] -> - hlds_out__write_promise(PromiseType, 0, ModuleInfo, + hlds_out.write_promise(PromiseType, 0, ModuleInfo, PredId, VarSet, no, HeadVars, PredOrFunc, Clause, no, !IO) ; unexpected(this_file, @@ -1545,7 +1545,7 @@ write_preds(ModuleInfo, [PredId | PredIds], !IO) :- ; pred_info_typevarset(PredInfo, TypeVarset), MaybeVarTypes = yes(TypeVarset, VarTypes), - list__foldl(write_clause(ModuleInfo, PredId, VarSet, + list.foldl(write_clause(ModuleInfo, PredId, VarSet, HeadVars, PredOrFunc, SymName, MaybeVarTypes), Clauses, !IO) ), write_preds(ModuleInfo, PredIds, !IO). @@ -1563,7 +1563,7 @@ write_clause(ModuleInfo, PredId, VarSet, HeadVars, PredOrFunc, _SymName, % are named the same as variables in the enclosing clause. AppendVarNums = yes, UseDeclaredModes = yes, - hlds_out__write_clause(1, ModuleInfo, PredId, VarSet, AppendVarNums, + hlds_out.write_clause(1, ModuleInfo, PredId, VarSet, AppendVarNums, ClauseHeadVars, PredOrFunc, Clause, UseDeclaredModes, MaybeVarTypes, !IO). @@ -1576,7 +1576,7 @@ write_clause(ModuleInfo, PredId, VarSet, _HeadVars, PredOrFunc, SymName, ( % Pull the foreign code out of the goal. Goal = conj(plain_conj, Goals) - _, - list__filter((pred(X::in) is semidet :- + list.filter((pred(X::in) is semidet :- X = foreign_proc(_, _, _, _, _, _) - _ ), Goals, [ForeignCodeGoal]), ForeignCodeGoal = foreign_proc(Attributes, @@ -1585,7 +1585,7 @@ write_clause(ModuleInfo, PredId, VarSet, _HeadVars, PredOrFunc, SymName, Goal = foreign_proc(Attributes, _, _, Args, _, PragmaCode) - _ ) -> - list__foldl(write_foreign_clause(Procs, PredOrFunc, + list.foldl(write_foreign_clause(Procs, PredOrFunc, PragmaCode, Attributes, Args, VarSet, SymName), ProcIds, !IO) ; unexpected(this_file, "foreign_proc expected within this goal") @@ -1598,7 +1598,7 @@ write_clause(ModuleInfo, PredId, VarSet, _HeadVars, PredOrFunc, SymName, write_foreign_clause(Procs, PredOrFunc, PragmaImpl, Attributes, Args, ProgVarset0, SymName, ProcId, !IO) :- - map__lookup(Procs, ProcId, ProcInfo), + map.lookup(Procs, ProcId, ProcInfo), proc_info_maybe_declared_argmodes(ProcInfo, MaybeArgModes), ( MaybeArgModes = yes(ArgModes), @@ -1613,7 +1613,7 @@ write_foreign_clause(Procs, PredOrFunc, PragmaImpl, unexpected(this_file, "write_clause: no mode declaration") ). - % Strip the `Headvar__n = Term' unifications from each clause, + % Strip the `Headvar.n = Term' unifications from each clause, % except if the `Term' is a lambda expression. % % At least two problems occur if this is not done: @@ -1635,22 +1635,22 @@ strip_headvar_unifications(HeadVars, clause(ProcIds, Goal0, Lang, Context), HeadTerms, clause(ProcIds, Goal, Lang, Context)) :- Goal0 = _ - GoalInfo0, goal_to_conj_list(Goal0, Goals0), - map__init(HeadVarMap0), + map.init(HeadVarMap0), ( strip_headvar_unifications_from_goal_list(Goals0, HeadVars, [], Goals, HeadVarMap0, HeadVarMap) -> - list__map( + list.map( (pred(HeadVar0::in, HeadTerm::out) is det :- - ( map__search(HeadVarMap, HeadVar0, HeadTerm0) -> + ( map.search(HeadVarMap, HeadVar0, HeadTerm0) -> HeadTerm = HeadTerm0 ; - HeadTerm = term__variable(HeadVar0) + HeadTerm = term.variable(HeadVar0) ) ), HeadVars, HeadTerms), conj_list_to_goal(Goals, GoalInfo0, Goal) ; - term__var_list_to_term_list(HeadVars, HeadTerms), + term.var_list_to_term_list(HeadVars, HeadTerms), Goal = Goal0 ). @@ -1661,37 +1661,37 @@ strip_headvar_unifications(HeadVars, clause(ProcIds, Goal0, Lang, Context), strip_headvar_unifications_from_goal_list([], _, RevGoals, Goals, !HeadVarMap) :- - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). strip_headvar_unifications_from_goal_list([Goal | Goals0], HeadVars, RevGoals0, Goals, !HeadVarMap) :- ( Goal = unify(LHSVar, RHS, _, _, _) - _, - list__member(LHSVar, HeadVars), + list.member(LHSVar, HeadVars), ( RHS = var(RHSVar), - RHSTerm = term__variable(RHSVar) + RHSTerm = term.variable(RHSVar) ; RHS = functor(ConsId, _, Args), - term__context_init(Context), + term.context_init(Context), ( ConsId = int_const(Int), - RHSTerm = term__functor(term__integer(Int), [], Context) + RHSTerm = term.functor(term.integer(Int), [], Context) ; ConsId = float_const(Float), - RHSTerm = term__functor(term__float(Float), [], Context) + RHSTerm = term.functor(term.float(Float), [], Context) ; ConsId = string_const(String), - RHSTerm = term__functor(term__string(String), [], Context) + RHSTerm = term.functor(term.string(String), [], Context) ; ConsId = cons(SymName, _), - term__var_list_to_term_list(Args, ArgTerms), + term.var_list_to_term_list(Args, ArgTerms), construct_qualified_term(SymName, ArgTerms, RHSTerm) ) ) -> % Don't strip the headvar unifications if one of the % headvars appears twice. This should probably never happen. - map__insert(!.HeadVarMap, LHSVar, RHSTerm, !:HeadVarMap), + map.insert(!.HeadVarMap, LHSVar, RHSTerm, !:HeadVarMap), RevGoals1 = RevGoals0 ; RevGoals1 = [Goal | RevGoals0] @@ -1719,7 +1719,7 @@ write_pragmas(SymName, Arity, [Marker | Markers], PredOrFunc, !IO) :- should_output_marker(Marker, ShouldOutput), ( ShouldOutput = yes, - hlds_out__marker_name(Marker, Name), + hlds_out.marker_name(Marker, Name), mercury_output_pragma_decl(SymName, Arity, PredOrFunc, Name, no, !IO) ; ShouldOutput = no @@ -1732,8 +1732,8 @@ write_pragmas(SymName, Arity, [Marker | Markers], PredOrFunc, !IO) :- write_type_spec_pragmas(ModuleInfo, PredId, !IO) :- module_info_get_type_spec_info(ModuleInfo, TypeSpecInfo), PragmaMap = TypeSpecInfo ^ pragma_map, - ( multi_map__search(PragmaMap, PredId, TypeSpecPragmas) -> - list__foldl(write_type_spec_pragma, TypeSpecPragmas, !IO) + ( multi_map.search(PragmaMap, PredId, TypeSpecPragmas) -> + list.foldl(write_type_spec_pragma, TypeSpecPragmas, !IO) ; true ). @@ -1796,7 +1796,7 @@ get_pragma_foreign_code_vars(Args, Modes, !VarSet, PragmaVars) :- MaybeNameAndMode = yes(Name - _Mode2) ), PragmaVar = pragma_var(Var, Name, Mode, native_if_possible), - varset__name_var(!.VarSet, Var, Name, !:VarSet), + varset.name_var(!.VarSet, Var, Name, !:VarSet), get_pragma_foreign_code_vars(ArgsTail, ModesTail, !VarSet, PragmaVarsTail), PragmaVars = [PragmaVar | PragmaVarsTail] @@ -1853,11 +1853,11 @@ get_pragma_foreign_code_vars(Args, Modes, !VarSet, PragmaVars) :- :- pred init_intermod_info(module_info::in, intermod_info::out) is det. init_intermod_info(ModuleInfo, IntermodInfo) :- - set__init(Modules), - set__init(Procs), - set__init(ProcDecls), - map__init(VarTypes), - varset__init(TVarSet), + set.init(Modules), + set.init(Procs), + set.init(ProcDecls), + map.init(VarTypes), + varset.init(TVarSet), Instances = [], Types = [], IntermodInfo = info(Modules, Procs, ProcDecls, Instances, Types, @@ -1930,16 +1930,16 @@ intermod_info_set_tvarset(TVarSet, Info, Info ^ im_tvarset := TVarSet). % on those preds. % adjust_pred_import_status(!Module, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), maybe_write_string(VeryVerbose, "% Adjusting import status of predicates in the `.opt' file...", !IO), module_info_predids(!.Module, PredIds), module_info_get_globals(!.Module, Globals), - globals__lookup_int_option(Globals, intermod_inline_simple_threshold, + globals.lookup_int_option(Globals, intermod_inline_simple_threshold, Threshold), - globals__lookup_bool_option(Globals, deforestation, Deforestation), - globals__lookup_int_option(Globals, higher_order_size_limit, + globals.lookup_bool_option(Globals, deforestation, Deforestation), + globals.lookup_int_option(Globals, higher_order_size_limit, HigherOrderSizeLimit), some [!Info] ( init_intermod_info(!.Module, !:Info), @@ -1956,7 +1956,7 @@ adjust_pred_import_status(!Module, !IO) :- do_adjust_pred_import_status(Info, !ModuleInfo) :- intermod_info_get_pred_decls(Info, PredDecls0), - set__to_sorted_list(PredDecls0, PredDecls), + set.to_sorted_list(PredDecls0, PredDecls), set_list_of_preds_exported(PredDecls, !ModuleInfo), adjust_type_status(!ModuleInfo), adjust_class_status(!ModuleInfo), @@ -1966,9 +1966,9 @@ do_adjust_pred_import_status(Info, !ModuleInfo) :- adjust_type_status(!ModuleInfo) :- module_info_get_type_table(!.ModuleInfo, Types0), - map__to_assoc_list(Types0, TypesAL0), - list__map_foldl(adjust_type_status_2, TypesAL0, TypesAL, !ModuleInfo), - map__from_assoc_list(TypesAL, Types), + map.to_assoc_list(Types0, TypesAL0), + list.map_foldl(adjust_type_status_2, TypesAL0, TypesAL, !ModuleInfo), + map.from_assoc_list(TypesAL, Types), module_info_set_type_table(Types, !ModuleInfo). :- pred adjust_type_status_2(pair(type_ctor, hlds_type_defn)::in, @@ -1978,7 +1978,7 @@ adjust_type_status(!ModuleInfo) :- adjust_type_status_2(TypeCtor - TypeDefn0, TypeCtor - TypeDefn, !ModuleInfo) :- module_info_get_name(!.ModuleInfo, ModuleName), ( should_write_type(ModuleName, TypeCtor, TypeDefn0) -> - hlds_data__set_type_defn_status(exported, TypeDefn0, TypeDefn), + hlds_data.set_type_defn_status(exported, TypeDefn0, TypeDefn), fixup_special_preds(TypeCtor, !ModuleInfo) ; TypeDefn = TypeDefn0 @@ -1990,8 +1990,8 @@ adjust_type_status_2(TypeCtor - TypeDefn0, TypeCtor - TypeDefn, !ModuleInfo) :- fixup_special_preds(TypeCtor, ModuleInfo0, ModuleInfo) :- special_pred_list(SpecialPredList), module_info_get_special_pred_map(ModuleInfo0, SpecPredMap), - list__filter_map((pred(SpecPredId::in, PredId::out) is semidet :- - map__search(SpecPredMap, SpecPredId - TypeCtor, PredId) + list.filter_map((pred(SpecPredId::in, PredId::out) is semidet :- + map.search(SpecPredMap, SpecPredId - TypeCtor, PredId) ), SpecialPredList, PredIds), set_list_of_preds_exported(PredIds, ModuleInfo0, ModuleInfo). @@ -1999,9 +1999,9 @@ fixup_special_preds(TypeCtor, ModuleInfo0, ModuleInfo) :- adjust_class_status(!ModuleInfo) :- module_info_get_class_table(!.ModuleInfo, Classes0), - map__to_assoc_list(Classes0, ClassAL0), - list__map_foldl(adjust_class_status_2, ClassAL0, ClassAL, !ModuleInfo), - map__from_assoc_list(ClassAL, Classes), + map.to_assoc_list(Classes0, ClassAL0), + list.map_foldl(adjust_class_status_2, ClassAL0, ClassAL, !ModuleInfo), + map.from_assoc_list(ClassAL, Classes), module_info_set_class_table(Classes, !ModuleInfo). :- pred adjust_class_status_2(pair(class_id, hlds_class_defn)::in, @@ -2022,21 +2022,21 @@ adjust_class_status_2(ClassId - ClassDefn0, ClassId - ClassDefn, is det. class_procs_to_pred_ids(ClassProcs, PredIds) :- - list__map( + list.map( (pred(ClassProc::in, PredId::out) is det :- ClassProc = hlds_class_proc(PredId, _) ), ClassProcs, PredIds0), - list__sort_and_remove_dups(PredIds0, PredIds). + list.sort_and_remove_dups(PredIds0, PredIds). :- pred adjust_instance_status(module_info::in, module_info::out) is det. adjust_instance_status(!ModuleInfo) :- module_info_get_instance_table(!.ModuleInfo, Instances0), - map__to_assoc_list(Instances0, InstanceAL0), - list__map_foldl(adjust_instance_status_2, InstanceAL0, InstanceAL, + map.to_assoc_list(Instances0, InstanceAL0), + list.map_foldl(adjust_instance_status_2, InstanceAL0, InstanceAL, !ModuleInfo), - map__from_assoc_list(InstanceAL, Instances), + map.from_assoc_list(InstanceAL, Instances), module_info_set_instance_table(Instances, !ModuleInfo). :- pred adjust_instance_status_2(pair(class_id, list(hlds_instance_defn))::in, @@ -2045,7 +2045,7 @@ adjust_instance_status(!ModuleInfo) :- adjust_instance_status_2(ClassId - InstanceList0, ClassId - InstanceList, !ModuleInfo) :- - list__map_foldl(adjust_instance_status_3, InstanceList0, InstanceList, + list.map_foldl(adjust_instance_status_3, InstanceList0, InstanceList, !ModuleInfo). :- pred adjust_instance_status_3(hlds_instance_defn::in, @@ -2085,7 +2085,7 @@ set_list_of_preds_exported(PredIds, !ModuleInfo) :- set_list_of_preds_exported_2([], !Preds). set_list_of_preds_exported_2([PredId | PredIds], !Preds) :- - map__lookup(!.Preds, PredId, PredInfo0), + map.lookup(!.Preds, PredId, PredInfo0), ( pred_info_import_status(PredInfo0, Status), import_status_to_write(Status) @@ -2103,7 +2103,7 @@ set_list_of_preds_exported_2([PredId | PredIds], !Preds) :- NewStatus = opt_exported ), pred_info_set_import_status(NewStatus, PredInfo0, PredInfo), - map__det_update(!.Preds, PredId, PredInfo, !:Preds) + map.det_update(!.Preds, PredId, PredInfo, !:Preds) ; true ), @@ -2145,11 +2145,11 @@ grab_optfiles(!Module, FoundError, !IO) :- Ancestors0 = !.Module ^ parent_deps, InterfaceDeps0 = !.Module ^ int_deps, ImplementationDeps0 = !.Module ^ impl_deps, - OptFiles = list__sort_and_remove_dups(list__condense( + OptFiles = list.sort_and_remove_dups(list.condense( [Ancestors0, InterfaceDeps0, ImplementationDeps0])), - globals__io_lookup_bool_option(read_opt_files_transitively, Transitive, + globals.io_lookup_bool_option(read_opt_files_transitively, Transitive, !IO), - ModulesProcessed = set__insert(set__sorted_list_to_set(OptFiles), + ModulesProcessed = set.insert(set.sorted_list_to_set(OptFiles), ModuleName), read_optimization_interfaces(Transitive, ModuleName, OptFiles, ModulesProcessed, [], OptItems, no, OptError, !IO), @@ -2165,19 +2165,19 @@ grab_optfiles(!Module, FoundError, !IO) :- % the .opt file for the current module. These are needed because we can % probably remove more arguments with intermod_unused_args, but the % interface for other modules must remain the same. - globals__io_lookup_bool_option(intermod_unused_args, UnusedArgs, !IO), + globals.io_lookup_bool_option(intermod_unused_args, UnusedArgs, !IO), ( UnusedArgs = yes, read_optimization_interfaces(no, ModuleName, [ModuleName], - set__init, [], LocalItems, no, UAError, !IO), + set.init, [], LocalItems, no, UAError, !IO), IsPragmaUnusedArgs = (pred(Item::in) is semidet :- Item = pragma(_, PragmaType) - _, PragmaType = unused_args(_,_,_,_,_) ), - list__filter(IsPragmaUnusedArgs, LocalItems, PragmaItems), + list.filter(IsPragmaUnusedArgs, LocalItems, PragmaItems), module_imports_get_items(!.Module, Items2), - list__append(Items2, PragmaItems, Items), + list.append(Items2, PragmaItems, Items), module_imports_set_items(Items, !Module) ; UnusedArgs = no, @@ -2185,8 +2185,8 @@ grab_optfiles(!Module, FoundError, !IO) :- ), % Read .int0 files required by the `.opt' files. - Int0Files = list__delete_all( - list__condense(list__map(get_ancestors, OptFiles)), ModuleName), + Int0Files = list.delete_all( + list.condense(list.map(get_ancestors, OptFiles)), ModuleName), process_module_private_interfaces(ReadModules, Int0Files, make_pseudo_decl(opt_imported), make_pseudo_decl(opt_imported), @@ -2197,16 +2197,16 @@ grab_optfiles(!Module, FoundError, !IO) :- % Figure out which .int files are needed by the .opt files % get_dependencies(OptItems, NewImportDeps0, NewUseDeps0), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), get_implicit_dependencies(OptItems, Globals, NewImplicitImportDeps0, NewImplicitUseDeps0), - NewDeps = list__sort_and_remove_dups(list__condense( + NewDeps = list.sort_and_remove_dups(list.condense( [NewImportDeps0, NewUseDeps0, NewImplicitImportDeps0, NewImplicitUseDeps0, AncestorImports1, AncestorImports2])), % Read in the .int, and .int2 files needed by the .opt files. - map__init(ReadModules), + map.init(ReadModules), process_module_long_interfaces(ReadModules, must_be_qualified, NewDeps, ".int", make_pseudo_decl(opt_imported), make_pseudo_decl(opt_imported), [], NewIndirectDeps, [], NewImplIndirectDeps, !Module, !IO), @@ -2237,33 +2237,33 @@ read_optimization_interfaces(_, _, [], _, !Items, !Error, !IO). read_optimization_interfaces(Transitive, ModuleName, [ModuleToRead | ModulesToRead], ModulesProcessed0, !Items, !Error, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), maybe_write_string(VeryVerbose, "% Reading optimization interface for module", !IO), maybe_write_string(VeryVerbose, " `", !IO), - mdbcomp__prim_data__sym_name_to_string(ModuleToRead, ModuleToReadString), + mdbcomp.prim_data.sym_name_to_string(ModuleToRead, ModuleToReadString), maybe_write_string(VeryVerbose, ModuleToReadString, !IO), maybe_write_string(VeryVerbose, "'...\n", !IO), maybe_flush_output(VeryVerbose, !IO), module_name_to_search_file_name(ModuleToRead, ".opt", FileName, !IO), - prog_io__read_opt_file(FileName, ModuleToRead, + prog_io.read_opt_file(FileName, ModuleToRead, ModuleError, Messages, OptItems, !IO), update_error_status(opt, FileName, ModuleError, Messages, !Error, !IO), !:Items = !.Items ++ OptItems, maybe_write_string(VeryVerbose, "% done.\n", !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), ( Transitive = yes -> get_dependencies(OptItems, NewImportDeps0, NewUseDeps0), get_implicit_dependencies(OptItems, Globals, NewImplicitImportDeps0, NewImplicitUseDeps0), - NewDeps0 = list__condense([NewImportDeps0, NewUseDeps0, + NewDeps0 = list.condense([NewImportDeps0, NewUseDeps0, NewImplicitImportDeps0, NewImplicitUseDeps0]), - set__list_to_set(NewDeps0, NewDepsSet0), - set__difference(NewDepsSet0, ModulesProcessed0, NewDepsSet), - set__union(ModulesProcessed0, NewDepsSet, ModulesProcessed), - set__to_sorted_list(NewDepsSet, NewDeps) + set.list_to_set(NewDeps0, NewDepsSet0), + set.difference(NewDepsSet0, ModulesProcessed0, NewDepsSet), + set.union(ModulesProcessed0, NewDepsSet, ModulesProcessed), + set.to_sorted_list(NewDepsSet, NewDeps) ; ModulesProcessed = ModulesProcessed0, NewDeps = [] @@ -2277,7 +2277,7 @@ update_error_status(FileType, FileName, ModuleError, Messages, ModuleError = no_module_errors ; ModuleError = some_module_errors, - prog_out__write_messages(Messages, !IO), + prog_out.write_messages(Messages, !IO), !:Error = yes ; ModuleError = fatal_module_errors, @@ -2288,13 +2288,13 @@ update_error_status(FileType, FileName, ModuleError, Messages, FileType = trans_opt, WarningOption = warn_missing_trans_opt_files ), - globals__io_lookup_bool_option(WarningOption, DoWarn, !IO), + globals.io_lookup_bool_option(WarningOption, DoWarn, !IO), ( DoWarn = yes, - io__write_string("Warning: cannot open `", !IO), - io__write_string(FileName, !IO), - io__write_string("'.\n", !IO), - globals__io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO), + io.write_string("Warning: cannot open `", !IO), + io.write_string(FileName, !IO), + io.write_string("'.\n", !IO), + globals.io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO), ( HaltAtWarn = yes, !:Error = yes diff --git a/compiler/interval.m b/compiler/interval.m index 77c4b9928..9ab747339 100644 --- a/compiler/interval.m +++ b/compiler/interval.m @@ -29,7 +29,7 @@ %-----------------------------------------------------------------------------% -:- module backend_libs__interval. +:- module backend_libs.interval. :- interface. :- import_module hlds.hlds_goal. @@ -238,7 +238,7 @@ build_interval_info_in_goal(switch(Var, _Det, Cases) - GoalInfo, !IntervalInfo, !Acc), build_interval_info_in_cases(Cases, StartAnchor, EndAnchor, BeforeId, AfterId, OpenIntervalsList, !IntervalInfo, !Acc), - OpenIntervals = set__union_list(OpenIntervalsList), + OpenIntervals = set.union_list(OpenIntervalsList), leave_branch_start(switch, StartAnchor, BeforeId, MaybeResumeVars, OpenIntervals, !IntervalInfo), require_in_regs([Var], !IntervalInfo), @@ -281,9 +281,9 @@ build_interval_info_in_goal(Goal - GoalInfo, !IntervalInfo, !Acc) :- goal_info_get_maybe_need_across_call(GoalInfo, MaybeNeedAcrossCall), IntParams = !.IntervalInfo ^ interval_params, VarTypes = IntParams ^ var_types, - list__map(map__lookup(VarTypes), ArgVars, ArgTypes), + list.map(map.lookup(VarTypes), ArgVars, ArgTypes), ModuleInfo = IntParams ^ module_info, - arg_info__compute_in_and_out_vars(ModuleInfo, ArgVars, ArgModes, ArgTypes, + arg_info.compute_in_and_out_vars(ModuleInfo, ArgVars, ArgModes, ArgTypes, InputArgs, _OutputArgs), % Casts are generated inline. @@ -292,10 +292,10 @@ build_interval_info_in_goal(Goal - GoalInfo, !IntervalInfo, !Acc) :- require_access(InputArgs, !IntervalInfo) ; module_info_get_globals(ModuleInfo, Globals), - call_gen__generic_call_info(Globals, GenericCall, + call_gen.generic_call_info(Globals, GenericCall, length(InputArgs), _, GenericVarsArgInfos, _, _), - assoc_list__keys(GenericVarsArgInfos, GenericVars), - list__append(GenericVars, InputArgs, Inputs), + assoc_list.keys(GenericVarsArgInfos, GenericVars), + list.append(GenericVars, InputArgs, Inputs), build_interval_info_at_call(Inputs, MaybeNeedAcrossCall, GoalInfo, !IntervalInfo, !Acc) ). @@ -307,9 +307,9 @@ build_interval_info_in_goal(Goal - GoalInfo, !IntervalInfo, !Acc) :- module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _PredInfo, ProcInfo), VarTypes = IntParams ^ var_types, - arg_info__partition_proc_call_args(ProcInfo, VarTypes, + arg_info.partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, ArgVars, InputArgs, _, _), - set__to_sorted_list(InputArgs, Inputs), + set.to_sorted_list(InputArgs, Inputs), ( Builtin = inline_builtin -> require_in_regs(Inputs, !IntervalInfo), require_access(Inputs, !IntervalInfo) @@ -327,12 +327,12 @@ build_interval_info_in_goal(Goal - GoalInfo, !IntervalInfo, !Acc) :- module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _PredInfo, ProcInfo), VarTypes = IntParams ^ var_types, - ArgVars = list__map(foreign_arg_var, Args), - ExtraVars = list__map(foreign_arg_var, ExtraArgs), - arg_info__partition_proc_call_args(ProcInfo, VarTypes, + ArgVars = list.map(foreign_arg_var, Args), + ExtraVars = list.map(foreign_arg_var, ExtraArgs), + arg_info.partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, ArgVars, InputArgVarSet, _, _), - set__to_sorted_list(InputArgVarSet, InputArgVars), - list__append(InputArgVars, ExtraVars, InputVars), + set.to_sorted_list(InputArgVarSet, InputArgVars), + list.append(InputArgVars, ExtraVars, InputVars), ( goal_info_maybe_get_maybe_need_across_call(GoalInfo, MaybeNeedAcrossCall), @@ -415,7 +415,7 @@ build_interval_info_at_call(Inputs, MaybeNeedAcrossCall, GoalInfo, MaybeNeedAcrossCall = yes(NeedAcrossCall), NeedAcrossCall = need_across_call(ForwardVars, ResumeVars, NondetLiveVars), - VarsOnStack0 = set__union_list([ForwardVars, ResumeVars, + VarsOnStack0 = set.union_list([ForwardVars, ResumeVars, NondetLiveVars]), goal_info_get_goal_path(GoalInfo, GoalPath), CallAnchor = call_site(GoalPath), @@ -436,7 +436,7 @@ build_interval_info_at_call(Inputs, MaybeNeedAcrossCall, GoalInfo, % If the call cannot succeed, then execution cannot % get from BeforeCallId to AfterCallId. record_interval_no_succ(BeforeCallId, !IntervalInfo), - VarsOnStack = set__init + VarsOnStack = set.init ), set_cur_interval(BeforeCallId, !IntervalInfo), assign_open_intervals_to_anchor(CallAnchor, !IntervalInfo), @@ -476,7 +476,7 @@ build_interval_info_in_conj([Goal | Goals], ConjType, !IntervalInfo, !Acc) :- set(interval_id)::out, interval_info::in, interval_info::out, T::in, T::out) is det <= build_interval_info_acc(T). -build_interval_info_in_disj([], _, _, _, _, _, set__init, !IntervalInfo, !Acc). +build_interval_info_in_disj([], _, _, _, _, _, set.init, !IntervalInfo, !Acc). build_interval_info_in_disj([Goal | Goals], MaybeNeedsFlush, StartAnchor, EndAnchor, BeforeId, AfterId, OpenIntervals, !IntervalInfo, !Acc) :- @@ -531,8 +531,8 @@ reached_branch_end(GoalInfo, MaybeResumeGoal, Construct, ), record_branch_resume(GoalPath, HasResumeSave, !IntervalInfo), ( goal_info_maybe_get_store_map(GoalInfo, StoreMap) -> - map__sorted_keys(StoreMap, StoreMapVarList), - set__sorted_list_to_set(StoreMapVarList, StoreMapVars), + map.sorted_keys(StoreMap, StoreMapVarList), + set.sorted_list_to_set(StoreMapVarList, StoreMapVars), require_flushed(StoreMapVars, !IntervalInfo) ; unexpected(this_file, "reached_branch_end: no store map") @@ -592,7 +592,7 @@ reached_cond_then(GoalInfo, !IntervalInfo) :- record_interval_succ(CondTailId, ThenStartId, !IntervalInfo), set_cur_interval(CondTailId, !IntervalInfo), get_open_intervals(!.IntervalInfo, OpenIntervals0), - svset__insert(CondTailId, OpenIntervals0, OpenIntervals), + svset.insert(CondTailId, OpenIntervals0, OpenIntervals), set_open_intervals(OpenIntervals, !IntervalInfo). :- pred leave_branch_start(branch_construct::in, anchor::in, interval_id::in, @@ -625,14 +625,14 @@ set_open_intervals(OpenIntervals, !IntervalInfo) :- :- pred no_open_intervals(interval_info::in, interval_info::out) is det. no_open_intervals(!IntervalInfo) :- - !:IntervalInfo = !.IntervalInfo ^ open_intervals := set__init. + !:IntervalInfo = !.IntervalInfo ^ open_intervals := set.init. :- pred one_open_interval(interval_id::in, interval_info::in, interval_info::out) is det. one_open_interval(IntervalId, !IntervalInfo) :- !:IntervalInfo = !.IntervalInfo ^ open_intervals := - set__make_singleton_set(IntervalId). + set.make_singleton_set(IntervalId). :- pred assign_open_intervals_to_anchor(anchor::in, interval_info::in, interval_info::out) is det. @@ -641,18 +641,18 @@ assign_open_intervals_to_anchor(Anchor, !IntervalInfo) :- AnchorFollowMap0 = !.IntervalInfo ^ anchor_follow_map, IntervalVarMap = !.IntervalInfo ^ interval_vars, CurOpenIntervals = !.IntervalInfo ^ open_intervals, - set__fold(gather_interval_vars(IntervalVarMap), CurOpenIntervals, - set__init, CurOpenIntervalVars), - ( map__search(AnchorFollowMap0, Anchor, AnchorFollowInfo0) -> + set.fold(gather_interval_vars(IntervalVarMap), CurOpenIntervals, + set.init, CurOpenIntervalVars), + ( map.search(AnchorFollowMap0, Anchor, AnchorFollowInfo0) -> AnchorFollowInfo0 = OpenIntervalVars0 - OpenIntervals0, - OpenIntervalVars = set__union(OpenIntervalVars0, CurOpenIntervalVars), - OpenIntervals = set__union(OpenIntervals0, CurOpenIntervals), + OpenIntervalVars = set.union(OpenIntervalVars0, CurOpenIntervalVars), + OpenIntervals = set.union(OpenIntervals0, CurOpenIntervals), AnchorFollowInfo = OpenIntervalVars - OpenIntervals, - svmap__det_update(Anchor, AnchorFollowInfo, + svmap.det_update(Anchor, AnchorFollowInfo, AnchorFollowMap0, AnchorFollowMap) ; AnchorFollowInfo = CurOpenIntervalVars - CurOpenIntervals, - svmap__det_insert(Anchor, AnchorFollowInfo, + svmap.det_insert(Anchor, AnchorFollowInfo, AnchorFollowMap0, AnchorFollowMap) ), !:IntervalInfo = !.IntervalInfo ^ anchor_follow_map := AnchorFollowMap. @@ -661,8 +661,8 @@ assign_open_intervals_to_anchor(Anchor, !IntervalInfo) :- interval_id::in, set(prog_var)::in, set(prog_var)::out) is det. gather_interval_vars(IntervalVarMap, IntervalId, !OpenIntervalVars) :- - map__lookup(IntervalVarMap, IntervalId, IntervalVars), - !:OpenIntervalVars = set__union(!.OpenIntervalVars, IntervalVars). + map.lookup(IntervalVarMap, IntervalId, IntervalVars), + !:OpenIntervalVars = set.union(!.OpenIntervalVars, IntervalVars). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -683,9 +683,9 @@ set_cur_interval(CurInterval, IntervalInfo, new_interval_id(Id, !IntervalInfo) :- Counter0 = !.IntervalInfo ^ interval_counter, IntervalVars0 = !.IntervalInfo ^ interval_vars, - counter__allocate(Num, Counter0, Counter), + counter.allocate(Num, Counter0, Counter), Id = interval_id(Num), - svmap__det_insert(Id, set__init, IntervalVars0, IntervalVars), + svmap.det_insert(Id, set.init, IntervalVars0, IntervalVars), !:IntervalInfo = !.IntervalInfo ^ interval_counter := Counter, !:IntervalInfo = !.IntervalInfo ^ interval_vars := IntervalVars. @@ -698,7 +698,7 @@ record_branch_end_info(GoalPath, !IntervalInfo) :- CurInterval = !.IntervalInfo ^ cur_interval, BranchEndMap0 = !.IntervalInfo ^ branch_end_map, BranchEndInfo = branch_end_info(FlushedLater, AccessedLater, CurInterval), - svmap__det_insert(GoalPath, BranchEndInfo, BranchEndMap0, BranchEndMap), + svmap.det_insert(GoalPath, BranchEndInfo, BranchEndMap0, BranchEndMap), !:IntervalInfo = !.IntervalInfo ^ branch_end_map := BranchEndMap. :- pred record_cond_end(goal_path::in, interval_info::in, interval_info::out) @@ -707,7 +707,7 @@ record_branch_end_info(GoalPath, !IntervalInfo) :- record_cond_end(GoalPath, !IntervalInfo) :- CurInterval = !.IntervalInfo ^ cur_interval, CondEndMap0 = !.IntervalInfo ^ cond_end_map, - svmap__det_insert(GoalPath, CurInterval, CondEndMap0, CondEndMap), + svmap.det_insert(GoalPath, CurInterval, CondEndMap0, CondEndMap), !:IntervalInfo = !.IntervalInfo ^ cond_end_map := CondEndMap. :- pred record_interval_end(interval_id::in, anchor::in, @@ -715,7 +715,7 @@ record_cond_end(GoalPath, !IntervalInfo) :- record_interval_end(Id, End, !IntervalInfo) :- EndMap0 = !.IntervalInfo ^ interval_end, - svmap__det_insert(Id, End, EndMap0, EndMap), + svmap.det_insert(Id, End, EndMap0, EndMap), !:IntervalInfo = !.IntervalInfo ^ interval_end := EndMap. :- pred record_interval_start(interval_id::in, anchor::in, @@ -723,7 +723,7 @@ record_interval_end(Id, End, !IntervalInfo) :- record_interval_start(Id, Start, !IntervalInfo) :- StartMap0 = !.IntervalInfo ^ interval_start, - svmap__det_insert(Id, Start, StartMap0, StartMap), + svmap.det_insert(Id, Start, StartMap0, StartMap), !:IntervalInfo = !.IntervalInfo ^ interval_start := StartMap. :- pred record_interval_succ(interval_id::in, interval_id::in, @@ -731,10 +731,10 @@ record_interval_start(Id, Start, !IntervalInfo) :- record_interval_succ(Id, Succ, !IntervalInfo) :- SuccMap0 = !.IntervalInfo ^ interval_succ, - ( map__search(SuccMap0, Id, Succ0) -> - svmap__det_update(Id, [Succ | Succ0], SuccMap0, SuccMap) + ( map.search(SuccMap0, Id, Succ0) -> + svmap.det_update(Id, [Succ | Succ0], SuccMap0, SuccMap) ; - svmap__det_insert(Id, [Succ], SuccMap0, SuccMap) + svmap.det_insert(Id, [Succ], SuccMap0, SuccMap) ), !:IntervalInfo = !.IntervalInfo ^ interval_succ := SuccMap. @@ -743,41 +743,41 @@ record_interval_succ(Id, Succ, !IntervalInfo) :- record_interval_no_succ(Id, !IntervalInfo) :- SuccMap0 = !.IntervalInfo ^ interval_succ, - ( map__search(SuccMap0, Id, _Succ0) -> + ( map.search(SuccMap0, Id, _Succ0) -> unexpected(this_file, "record_interval_no_succ: already in succ map") ; - svmap__det_insert(Id, [], SuccMap0, SuccMap) + svmap.det_insert(Id, [], SuccMap0, SuccMap) ), !:IntervalInfo = !.IntervalInfo ^ interval_succ := SuccMap. record_interval_vars(Id, NewVars, !IntervalInfo) :- VarsMap0 = !.IntervalInfo ^ interval_vars, - ( map__search(VarsMap0, Id, Vars0) -> - svset__insert_list(NewVars, Vars0, Vars), - svmap__det_update(Id, Vars, VarsMap0, VarsMap) + ( map.search(VarsMap0, Id, Vars0) -> + svset.insert_list(NewVars, Vars0, Vars), + svmap.det_update(Id, Vars, VarsMap0, VarsMap) ; - set__list_to_set(NewVars, Vars), - svmap__det_insert(Id, Vars, VarsMap0, VarsMap) + set.list_to_set(NewVars, Vars), + svmap.det_insert(Id, Vars, VarsMap0, VarsMap) ), !:IntervalInfo = !.IntervalInfo ^ interval_vars := VarsMap. delete_interval_vars(Id, ToDeleteVars, DeletedVars, !IntervalInfo) :- VarsMap0 = !.IntervalInfo ^ interval_vars, - map__lookup(VarsMap0, Id, Vars0), - DeletedVars = set__intersect(Vars0, ToDeleteVars), - Vars = set__difference(Vars0, DeletedVars), - svmap__det_update(Id, Vars, VarsMap0, VarsMap), + map.lookup(VarsMap0, Id, Vars0), + DeletedVars = set.intersect(Vars0, ToDeleteVars), + Vars = set.difference(Vars0, DeletedVars), + svmap.det_update(Id, Vars, VarsMap0, VarsMap), !:IntervalInfo = !.IntervalInfo ^ interval_vars := VarsMap, % The deletions are recorded only for debugging. The algorithm itself % does not need this information to be recorded. DeleteMap0 = !.IntervalInfo ^ interval_delvars, - ( map__search(DeleteMap0, Id, Deletions0) -> + ( map.search(DeleteMap0, Id, Deletions0) -> Deletions = [DeletedVars | Deletions0], - svmap__det_update(Id, Deletions, DeleteMap0, DeleteMap) + svmap.det_update(Id, Deletions, DeleteMap0, DeleteMap) ; Deletions = [DeletedVars], - svmap__det_insert(Id, Deletions, DeleteMap0, DeleteMap) + svmap.det_insert(Id, Deletions, DeleteMap0, DeleteMap) ), !:IntervalInfo = !.IntervalInfo ^ interval_delvars := DeleteMap. @@ -793,7 +793,7 @@ require_in_regs(Vars, !IntervalInfo) :- require_flushed(Vars, !IntervalInfo) :- FlushedLater0 = !.IntervalInfo ^ flushed_later, - FlushedLater = set__union(FlushedLater0, Vars), + FlushedLater = set.union(FlushedLater0, Vars), !:IntervalInfo = !.IntervalInfo ^ flushed_later := FlushedLater. :- pred require_access(list(prog_var)::in, @@ -801,7 +801,7 @@ require_flushed(Vars, !IntervalInfo) :- require_access(Vars, !IntervalInfo) :- AccessedLater0 = !.IntervalInfo ^ accessed_later, - svset__insert_list(Vars, AccessedLater0, AccessedLater), + svset.insert_list(Vars, AccessedLater0, AccessedLater), !:IntervalInfo = !.IntervalInfo ^ accessed_later := AccessedLater. :- pred record_branch_resume(goal_path::in, resume_save_status::in, @@ -809,7 +809,7 @@ require_access(Vars, !IntervalInfo) :- record_branch_resume(GoalPath, ResumeSaveStatus, !IntervalInfo) :- BranchResumeMap0 = !.IntervalInfo ^ branch_resume_map, - svmap__det_insert(GoalPath, ResumeSaveStatus, + svmap.det_insert(GoalPath, ResumeSaveStatus, BranchResumeMap0, BranchResumeMap), !:IntervalInfo = !.IntervalInfo ^ branch_resume_map := BranchResumeMap. @@ -818,7 +818,7 @@ record_branch_resume(GoalPath, ResumeSaveStatus, !IntervalInfo) :- record_model_non_anchor(Anchor, !IntervalInfo) :- ModelNonAnchors0 = !.IntervalInfo ^ model_non_anchors, - svset__insert(Anchor, ModelNonAnchors0, ModelNonAnchors), + svset.insert(Anchor, ModelNonAnchors0, ModelNonAnchors), !:IntervalInfo = !.IntervalInfo ^ model_non_anchors := ModelNonAnchors. %-----------------------------------------------------------------------------% @@ -899,12 +899,12 @@ record_decisions_in_goal(Goal0, Goal, !VarInfo, !VarRename, InsertMap, record_decisions_in_goal(Then0, Then, !VarInfo, !.VarRename, _, InsertMap, MaybeFeature), lookup_inserts(InsertMap, StartAnchor, StartInserts), - make_inserted_goals(!VarInfo, map__init, VarRenameElse, + make_inserted_goals(!VarInfo, map.init, VarRenameElse, StartInserts, MaybeFeature, StartInsertGoals), record_decisions_in_goal(Else0, Else1, !VarInfo, VarRenameElse, _, InsertMap, MaybeFeature), Else0 = _ - ElseGoalInfo0, - conj_list_to_goal(list__append(StartInsertGoals, [Else1]), + conj_list_to_goal(list.append(StartInsertGoals, [Else1]), ElseGoalInfo0, Else), Goal1 = if_then_else(Vars, Cond, Then, Else) - GoalInfo0, lookup_inserts(InsertMap, EndAnchor, EndInserts), @@ -982,7 +982,7 @@ record_decisions_in_goal(shorthand(_) - _, _, !VarInfo, !VarRename, _, _) :- is det. lookup_inserts(InsertMap, Anchor, Inserts) :- - ( map__search(InsertMap, Anchor, InsertsPrime) -> + ( map.search(InsertMap, Anchor, InsertsPrime) -> Inserts = InsertsPrime ; Inserts = [] @@ -994,7 +994,7 @@ lookup_inserts(InsertMap, Anchor, Inserts) :- insert_goals_after(BranchesGoal, Goal, !VarInfo, VarRename, Inserts, MaybeFeature) :- - make_inserted_goals(!VarInfo, map__init, VarRename, Inserts, MaybeFeature, + make_inserted_goals(!VarInfo, map.init, VarRename, Inserts, MaybeFeature, InsertGoals), BranchesGoal = _ - BranchesGoalInfo, conj_list_to_goal([BranchesGoal | InsertGoals], BranchesGoalInfo, Goal). @@ -1033,9 +1033,9 @@ make_inserted_goal(!VarInfo, !VarRename, Spec, MaybeFeature, Goal) :- Goal2 = GoalExpr1 - GoalInfo2, !.VarInfo = var_info(VarSet0, VarTypes0), create_shadow_vars(ArgVars, VarsToExtract, VarSet0, VarSet, - VarTypes0, VarTypes, map__init, NewRename, map__init, VoidRename), + VarTypes0, VarTypes, map.init, NewRename, map.init, VoidRename), !:VarInfo = var_info(VarSet, VarTypes), - map__merge(!.VarRename, NewRename, !:VarRename), + map.merge(!.VarRename, NewRename, !:VarRename), % We rename the original goal rename_vars_in_goal(!.VarRename, Goal2, Goal3), rename_vars_in_goal(VoidRename, Goal3, Goal) @@ -1068,14 +1068,14 @@ create_shadow_vars([Arg | Args], VarsToExtract, !VarSet, !VarTypes, create_shadow_var(Arg, VarsToExtract, !VarSet, !VarTypes, !VarRename, !VoidRename) :- - varset__lookup_name(!.VarSet, Arg, Name), - svvarset__new_named_var(Name, Shadow, !VarSet), - map__lookup(!.VarTypes, Arg, Type), - svmap__det_insert(Shadow, Type, !VarTypes), - ( set__member(Arg, VarsToExtract) -> - svmap__det_insert(Arg, Shadow, !VarRename) + varset.lookup_name(!.VarSet, Arg, Name), + svvarset.new_named_var(Name, Shadow, !VarSet), + map.lookup(!.VarTypes, Arg, Type), + svmap.det_insert(Shadow, Type, !VarTypes), + ( set.member(Arg, VarsToExtract) -> + svmap.det_insert(Arg, Shadow, !VarRename) ; - svmap__det_insert(Arg, Shadow, !VoidRename) + svmap.det_insert(Arg, Shadow, !VoidRename) ). %-----------------------------------------------------------------------------% @@ -1137,12 +1137,12 @@ record_decisions_in_conj([Goal0 | Goals0], Goals, !VarInfo, !VarRename, record_decisions_in_disj([], [], !VarInfo, _, _, _, _). record_decisions_in_disj([Goal0 | Goals0], [Goal | Goals], !VarInfo, VarRename0, Inserts, InsertMap, MaybeFeature) :- - make_inserted_goals(!VarInfo, map__init, VarRename1, + make_inserted_goals(!VarInfo, map.init, VarRename1, Inserts, MaybeFeature, InsertGoals), Goal0 = _ - GoalInfo0, record_decisions_in_goal(Goal0, Goal1, !VarInfo, VarRename1, _, InsertMap, MaybeFeature), - conj_list_to_goal(list__append(InsertGoals, [Goal1]), GoalInfo0, Goal), + conj_list_to_goal(list.append(InsertGoals, [Goal1]), GoalInfo0, Goal), record_decisions_in_disj(Goals0, Goals, !VarInfo, VarRename0, Inserts, InsertMap, MaybeFeature). @@ -1162,12 +1162,12 @@ record_decisions_in_cases([case(Var, Goal0) | Cases0], %-----------------------------------------------------------------------------% apply_headvar_correction(HeadVarSet, RenameMap, Goal0, Goal) :- - set__to_sorted_list(HeadVarSet, HeadVars), - build_headvar_subst(HeadVars, RenameMap, map__init, Subst), - ( map__is_empty(Subst) -> + set.to_sorted_list(HeadVarSet, HeadVars), + build_headvar_subst(HeadVars, RenameMap, map.init, Subst), + ( map.is_empty(Subst) -> Goal = Goal0 ; - goal_util__rename_vars_in_goal(Subst, Goal0, Goal) + goal_util.rename_vars_in_goal(Subst, Goal0, Goal) ). :- pred build_headvar_subst(list(prog_var)::in, rename_map::in, @@ -1175,9 +1175,9 @@ apply_headvar_correction(HeadVarSet, RenameMap, Goal0, Goal) :- build_headvar_subst([], _RenameMap, !Subst). build_headvar_subst([HeadVar | HeadVars], RenameMap, !Subst) :- - ( map__search(RenameMap, HeadVar, Replacement) -> - svmap__det_insert(Replacement, HeadVar, !Subst), - svmap__det_insert(HeadVar, Replacement, !Subst) + ( map.search(RenameMap, HeadVar, Replacement) -> + svmap.det_insert(Replacement, HeadVar, !Subst), + svmap.det_insert(HeadVar, Replacement, !Subst) ; true ), @@ -1199,62 +1199,60 @@ construct_anchors(Construct, Goal, StartAnchor, EndAnchor) :- % For debugging purposes. dump_interval_info(IntervalInfo, !IO) :- - map__keys(IntervalInfo ^ interval_start, StartIds), - map__keys(IntervalInfo ^ interval_end, EndIds), - map__keys(IntervalInfo ^ interval_vars, VarsIds), - map__keys(IntervalInfo ^ interval_succ, SuccIds), - list__condense([StartIds, EndIds, VarsIds, SuccIds], IntervalIds0), - list__sort_and_remove_dups(IntervalIds0, IntervalIds), - io__write_string("INTERVALS:\n", !IO), - list__foldl(dump_interval_info(IntervalInfo), IntervalIds, !IO), + map.keys(IntervalInfo ^ interval_start, StartIds), + map.keys(IntervalInfo ^ interval_end, EndIds), + map.keys(IntervalInfo ^ interval_vars, VarsIds), + map.keys(IntervalInfo ^ interval_succ, SuccIds), + list.condense([StartIds, EndIds, VarsIds, SuccIds], IntervalIds0), + list.sort_and_remove_dups(IntervalIds0, IntervalIds), + io.write_string("INTERVALS:\n", !IO), + list.foldl(dump_interval_info(IntervalInfo), IntervalIds, !IO), - map__to_assoc_list(IntervalInfo ^ anchor_follow_map, AnchorFollows), - io__write_string("\nANCHOR FOLLOW:\n", !IO), - list__foldl(dump_anchor_follow, AnchorFollows, !IO). + map.to_assoc_list(IntervalInfo ^ anchor_follow_map, AnchorFollows), + io.write_string("\nANCHOR FOLLOW:\n", !IO), + list.foldl(dump_anchor_follow, AnchorFollows, !IO). :- pred dump_interval_info(interval_info::in, interval_id::in, io::di, io::uo) is det. dump_interval_info(IntervalInfo, IntervalId, !IO) :- - io__write_string("\ninterval ", !IO), - io__write_int(interval_id_to_int(IntervalId), !IO), - io__write_string(": ", !IO), - ( map__search(IntervalInfo ^ interval_succ, IntervalId, SuccIds) -> - SuccNums = list__map(interval_id_to_int, SuccIds), - io__write_string("succ [", !IO), + io.write_string("\ninterval ", !IO), + io.write_int(interval_id_to_int(IntervalId), !IO), + io.write_string(": ", !IO), + ( map.search(IntervalInfo ^ interval_succ, IntervalId, SuccIds) -> + SuccNums = list.map(interval_id_to_int, SuccIds), + io.write_string("succ [", !IO), write_int_list(SuccNums, !IO), - io__write_string("]\n", !IO) + io.write_string("]\n", !IO) ; - io__write_string("no succ\n", !IO) + io.write_string("no succ\n", !IO) ), - ( map__search(IntervalInfo ^ interval_start, IntervalId, Start) -> - io__write_string("start ", !IO), - io__write(Start, !IO), - io__write_string("\n", !IO) + ( map.search(IntervalInfo ^ interval_start, IntervalId, Start) -> + io.write_string("start ", !IO), + io.write(Start, !IO), + io.write_string("\n", !IO) ; - io__write_string("no start\n", !IO) + io.write_string("no start\n", !IO) ), - ( map__search(IntervalInfo ^ interval_end, IntervalId, End) -> - io__write_string("end ", !IO), - io__write(End, !IO), - io__write_string("\n", !IO) + ( map.search(IntervalInfo ^ interval_end, IntervalId, End) -> + io.write_string("end ", !IO), + io.write(End, !IO), + io.write_string("\n", !IO) ; - io__write_string("no end\n", !IO) + io.write_string("no end\n", !IO) ), - ( map__search(IntervalInfo ^ interval_vars, IntervalId, Vars) -> - list__map(term__var_to_int, set__to_sorted_list(Vars), - VarNums), - io__write_string("vars [", !IO), + ( map.search(IntervalInfo ^ interval_vars, IntervalId, Vars) -> + list.map(term.var_to_int, set.to_sorted_list(Vars), VarNums), + io.write_string("vars [", !IO), write_int_list(VarNums, !IO), - io__write_string("]\n", !IO) + io.write_string("]\n", !IO) ; - io__write_string("no vars\n", !IO) + io.write_string("no vars\n", !IO) ), - ( map__search(IntervalInfo ^ interval_delvars, IntervalId, Deletions) - -> - io__write_string("deletions", !IO), - list__foldl(dump_deletion, Deletions, !IO), - io__write_string("\n", !IO) + ( map.search(IntervalInfo ^ interval_delvars, IntervalId, Deletions) -> + io.write_string("deletions", !IO), + list.foldl(dump_deletion, Deletions, !IO), + io.write_string("\n", !IO) ; true ). @@ -1262,29 +1260,29 @@ dump_interval_info(IntervalInfo, IntervalId, !IO) :- :- pred dump_deletion(set(prog_var)::in, io::di, io::uo) is det. dump_deletion(Vars, !IO) :- - list__map(term__var_to_int, set__to_sorted_list(Vars), VarNums), - io__write_string(" [", !IO), + list.map(term.var_to_int, set.to_sorted_list(Vars), VarNums), + io.write_string(" [", !IO), write_int_list(VarNums, !IO), - io__write_string("]", !IO). + io.write_string("]", !IO). :- pred dump_anchor_follow(pair(anchor, anchor_follow_info)::in, io::di, io::uo) is det. dump_anchor_follow(Anchor - AnchorFollowInfo, !IO) :- AnchorFollowInfo = Vars - Intervals, - io__write_string("\n", !IO), - io__write(Anchor, !IO), - io__write_string(" =>\n", !IO), - list__map(term__var_to_int, set__to_sorted_list(Vars), VarNums), - io__write_string("vars [", !IO), + io.write_string("\n", !IO), + io.write(Anchor, !IO), + io.write_string(" =>\n", !IO), + list.map(term.var_to_int, set.to_sorted_list(Vars), VarNums), + io.write_string("vars [", !IO), write_int_list(VarNums, !IO), - io__write_string("]\nintervals: ", !IO), - set__to_sorted_list(Intervals, IntervalList), - write_int_list(list__map(interval_id_to_int, IntervalList), !IO), - io__write_string("\n", !IO). + io.write_string("]\nintervals: ", !IO), + set.to_sorted_list(Intervals, IntervalList), + write_int_list(list.map(interval_id_to_int, IntervalList), !IO), + io.write_string("\n", !IO). write_int_list(List, !IO) :- - io__write_list(List, ", ", io__write_int, !IO). + io.write_list(List, ", ", io.write_int, !IO). interval_id_to_int(interval_id(Num)) = Num. diff --git a/compiler/ite_gen.m b/compiler/ite_gen.m index 22994d2af..adc745d0b 100644 --- a/compiler/ite_gen.m +++ b/compiler/ite_gen.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -15,7 +15,7 @@ % %---------------------------------------------------------------------------% -:- module ll_backend__ite_gen. +:- module ll_backend.ite_gen. :- interface. :- import_module hlds.code_model. @@ -25,11 +25,11 @@ %---------------------------------------------------------------------------% -:- pred ite_gen__generate_ite(add_trail_ops::in, code_model::in, +:- pred ite_gen.generate_ite(add_trail_ops::in, code_model::in, hlds_goal::in, hlds_goal::in, hlds_goal::in, hlds_goal_info::in, code_tree::out, code_info::in, code_info::out) is det. -:- pred ite_gen__generate_negation(add_trail_ops::in, code_model::in, +:- pred ite_gen.generate_negation(add_trail_ops::in, code_model::in, hlds_goal::in, hlds_goal_info::in, code_tree::out, code_info::in, code_info::out) is det. @@ -93,14 +93,14 @@ generate_ite(AddTrailOps, CodeModel, CondGoal0, ThenGoal, ElseGoal, % Make sure that the variables whose values will be needed on backtracking % to the else part are materialized into registers or stack slots. % Their locations are recorded in ResumeMap. - code_info__produce_vars(ResumeVars, ResumeMap, FlushCode, !CI), + code_info.produce_vars(ResumeVars, ResumeMap, FlushCode, !CI), % Maybe save the heap state current before the condition. - % This is after code_info__produce_vars since code that + % This is after code_info.produce_vars since code that % flushes the cache may allocate memory we must not "recover". - code_info__get_globals(!.CI, Globals), + code_info.get_globals(!.CI, Globals), ( - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, reclaim_heap_on_semidet_failure, yes), goal_may_allocate_heap(CondGoal) -> @@ -108,32 +108,32 @@ generate_ite(AddTrailOps, CodeModel, CondGoal0, ThenGoal, ElseGoal, ; ReclaimHeap = no ), - code_info__maybe_save_hp(ReclaimHeap, SaveHpCode, MaybeHpSlot, !CI), + code_info.maybe_save_hp(ReclaimHeap, SaveHpCode, MaybeHpSlot, !CI), % Maybe save the current trail state before the condition. - code_info__maybe_save_ticket(AddTrailOps, SaveTicketCode, MaybeTicketSlot, + code_info.maybe_save_ticket(AddTrailOps, SaveTicketCode, MaybeTicketSlot, !CI), - code_info__remember_position(!.CI, BranchStart), + code_info.remember_position(!.CI, BranchStart), - code_info__prepare_for_ite_hijack(EffCodeModel, HijackInfo, + code_info.prepare_for_ite_hijack(EffCodeModel, HijackInfo, PrepareHijackCode, !CI), - code_info__make_resume_point(ResumeVars, ResumeLocs, ResumeMap, + code_info.make_resume_point(ResumeVars, ResumeLocs, ResumeMap, ResumePoint, !CI), - code_info__effect_resume_point(ResumePoint, EffCodeModel, EffectResumeCode, + code_info.effect_resume_point(ResumePoint, EffCodeModel, EffectResumeCode, !CI), % Generate the condition. - trace__maybe_generate_internal_event_code(CondGoal, IteGoalInfo, + trace.maybe_generate_internal_event_code(CondGoal, IteGoalInfo, CondTraceCode, !CI), - code_gen__generate_goal(CondCodeModel, CondGoal, CondCode, !CI), + code_gen.generate_goal(CondCodeModel, CondGoal, CondCode, !CI), - code_info__ite_enter_then(HijackInfo, ThenNeckCode, ElseNeckCode, !CI), + code_info.ite_enter_then(HijackInfo, ThenNeckCode, ElseNeckCode, !CI), % Kill again any variables that have become zombies. - code_info__pickup_zombies(Zombies, !CI), - code_info__make_vars_forward_dead(Zombies, !CI), + code_info.pickup_zombies(Zombies, !CI), + code_info.make_vars_forward_dead(Zombies, !CI), % Discard hp and prune trail ticket if the condition succeeded. ( CondCodeModel = model_non -> @@ -142,49 +142,49 @@ generate_ite(AddTrailOps, CodeModel, CondGoal0, ThenGoal, ElseGoal, % into. Nor can we prune the trail ticket that we allocated, % since the condition may have allocated other trail tickets % since then which have not yet been pruned. - code_info__maybe_reset_ticket(MaybeTicketSlot, solve, ResetTicketCode) + code_info.maybe_reset_ticket(MaybeTicketSlot, solve, ResetTicketCode) ; - code_info__maybe_release_hp(MaybeHpSlot, !CI), - code_info__maybe_reset_prune_and_release_ticket( + code_info.maybe_release_hp(MaybeHpSlot, !CI), + code_info.maybe_reset_prune_and_release_ticket( MaybeTicketSlot, commit, ResetTicketCode, !CI) ), goal_info_get_store_map(IteGoalInfo, StoreMap), - code_info__get_instmap(!.CI, EndCondInstMap), - ( instmap__is_unreachable(EndCondInstMap) -> + code_info.get_instmap(!.CI, EndCondInstMap), + ( instmap.is_unreachable(EndCondInstMap) -> % If the instmap indicates we cannot reach the then part, % do not attempt to generate it (may cause aborts). ThenTraceCode = empty, ThenCode = empty, - map__init(EmptyStoreMap), - code_info__generate_branch_end(EmptyStoreMap, no, + map.init(EmptyStoreMap), + code_info.generate_branch_end(EmptyStoreMap, no, MaybeEnd0, ThenSaveCode, !CI) ; % Generate the then branch. - trace__maybe_generate_internal_event_code(ThenGoal, + trace.maybe_generate_internal_event_code(ThenGoal, IteGoalInfo, ThenTraceCode, !CI), - code_gen__generate_goal(CodeModel, ThenGoal, ThenCode, !CI), - code_info__generate_branch_end(StoreMap, no, + code_gen.generate_goal(CodeModel, ThenGoal, ThenCode, !CI), + code_info.generate_branch_end(StoreMap, no, MaybeEnd0, ThenSaveCode, !CI) ), % Generate the entry to the else branch. - code_info__reset_to_position(BranchStart, !CI), - code_info__generate_resume_point(ResumePoint, ResumeCode, !CI), + code_info.reset_to_position(BranchStart, !CI), + code_info.generate_resume_point(ResumePoint, ResumeCode, !CI), % Restore the heap pointer and solver state if necessary. - code_info__maybe_restore_and_release_hp(MaybeHpSlot, RestoreHpCode, !CI), - code_info__maybe_reset_discard_and_release_ticket(MaybeTicketSlot, undo, + code_info.maybe_restore_and_release_hp(MaybeHpSlot, RestoreHpCode, !CI), + code_info.maybe_reset_discard_and_release_ticket(MaybeTicketSlot, undo, RestoreTicketCode, !CI), % Generate the else branch. - trace__maybe_generate_internal_event_code(ElseGoal, IteGoalInfo, + trace.maybe_generate_internal_event_code(ElseGoal, IteGoalInfo, ElseTraceCode, !CI), - code_gen__generate_goal(CodeModel, ElseGoal, ElseCode, !CI), - code_info__generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, + code_gen.generate_goal(CodeModel, ElseGoal, ElseCode, !CI), + code_info.generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, ElseSaveCode, !CI), - code_info__get_next_label(EndLabel, !CI), + code_info.get_next_label(EndLabel, !CI), JumpToEndCode = node([ goto(label(EndLabel)) - "Jump to the end of if-then-else" ]), @@ -218,7 +218,7 @@ generate_ite(AddTrailOps, CodeModel, CondGoal0, ThenGoal, ElseGoal, ElseCode, ElseSaveCode, EndLabelCode]), - code_info__after_all_branches(StoreMap, MaybeEnd, !CI). + code_info.after_all_branches(StoreMap, MaybeEnd, !CI). %-----------------------------------------------------------------------------% @@ -248,18 +248,18 @@ generate_negation(AddTrailOps, CodeModel, Goal0, NotGoalInfo, Code, ( CodeModel = model_semi, GoalExpr = unify(_, _, _, simple_test(L, R), _), - code_info__failure_is_direct_branch(!.CI, CodeAddr), - code_info__get_globals(!.CI, Globals), - globals__lookup_bool_option(Globals, simple_neg, yes) + code_info.failure_is_direct_branch(!.CI, CodeAddr), + code_info.get_globals(!.CI, Globals), + globals.lookup_bool_option(Globals, simple_neg, yes) -> % Because we are generating the negated goal ourselves, we need to % apply the pre- and post-goal updates that would normally be applied - % by code_gen__generate_goal. + % by code_gen.generate_goal. - code_info__enter_simple_neg(ResumeVars, GoalInfo, SimpleNeg, !CI), - code_info__produce_variable(L, CodeL, ValL, !CI), - code_info__produce_variable(R, CodeR, ValR, !CI), - Type = code_info__variable_type(!.CI, L), + code_info.enter_simple_neg(ResumeVars, GoalInfo, SimpleNeg, !CI), + code_info.produce_variable(L, CodeL, ValL, !CI), + code_info.produce_variable(R, CodeR, ValR, !CI), + Type = code_info.variable_type(!.CI, L), ( Type = builtin(string) -> Op = str_eq ; Type = builtin(float) -> @@ -270,7 +270,7 @@ generate_negation(AddTrailOps, CodeModel, Goal0, NotGoalInfo, Code, TestCode = node([ if_val(binop(Op, ValL, ValR), CodeAddr) - "test inequality" ]), - code_info__leave_simple_neg(GoalInfo, SimpleNeg, !CI), + code_info.leave_simple_neg(GoalInfo, SimpleNeg, !CI), Code = tree(tree(CodeL, CodeR), TestCode) ; generate_negation_general(AddTrailOps, CodeModel, Goal, NotGoalInfo, @@ -287,15 +287,15 @@ generate_negation(AddTrailOps, CodeModel, Goal0, NotGoalInfo, Code, generate_negation_general(AddTrailOps, CodeModel, Goal, NotGoalInfo, ResumeVars, ResumeLocs, Code, !CI) :- - code_info__produce_vars(ResumeVars, ResumeMap, FlushCode, !CI), + code_info.produce_vars(ResumeVars, ResumeMap, FlushCode, !CI), % % Maybe save the heap state current before the condition; this ought to be % after we make the failure continuation because that causes the cache to % get flushed. % - code_info__get_globals(!.CI, Globals), + code_info.get_globals(!.CI, Globals), ( - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, reclaim_heap_on_semidet_failure, yes), goal_may_allocate_heap(Goal) -> @@ -303,32 +303,32 @@ generate_negation_general(AddTrailOps, CodeModel, Goal, NotGoalInfo, ; ReclaimHeap = no ), - code_info__maybe_save_hp(ReclaimHeap, SaveHpCode, MaybeHpSlot, !CI), + code_info.maybe_save_hp(ReclaimHeap, SaveHpCode, MaybeHpSlot, !CI), - code_info__maybe_save_ticket(AddTrailOps, SaveTicketCode, + code_info.maybe_save_ticket(AddTrailOps, SaveTicketCode, MaybeTicketSlot, !CI), - code_info__prepare_for_ite_hijack(CodeModel, HijackInfo, + code_info.prepare_for_ite_hijack(CodeModel, HijackInfo, PrepareHijackCode, !CI), - code_info__make_resume_point(ResumeVars, ResumeLocs, ResumeMap, + code_info.make_resume_point(ResumeVars, ResumeLocs, ResumeMap, ResumePoint, !CI), - code_info__effect_resume_point(ResumePoint, CodeModel, + code_info.effect_resume_point(ResumePoint, CodeModel, EffectResumeCode, !CI), % Generate the negated goal as a semi-deterministic goal; it cannot be % nondet, since mode correctness requires it to have no output vars. - trace__maybe_generate_internal_event_code(Goal, NotGoalInfo, + trace.maybe_generate_internal_event_code(Goal, NotGoalInfo, EnterTraceCode, !CI), - code_gen__generate_goal(model_semi, Goal, GoalCode, !CI), + code_gen.generate_goal(model_semi, Goal, GoalCode, !CI), - code_info__ite_enter_then(HijackInfo, ThenNeckCode, ElseNeckCode, !CI), + code_info.ite_enter_then(HijackInfo, ThenNeckCode, ElseNeckCode, !CI), % Kill again any variables that have become zombies. - code_info__pickup_zombies(Zombies, !CI), - code_info__make_vars_forward_dead(Zombies, !CI), + code_info.pickup_zombies(Zombies, !CI), + code_info.make_vars_forward_dead(Zombies, !CI), - code_info__get_forward_live_vars(!.CI, LiveVars), + code_info.get_forward_live_vars(!.CI, LiveVars), ( CodeModel = model_det -> % The then branch will never be reached. @@ -336,31 +336,31 @@ generate_negation_general(AddTrailOps, CodeModel, Goal, NotGoalInfo, FailTraceCode = empty, FailCode = empty ; - code_info__remember_position(!.CI, AfterNegatedGoal), + code_info.remember_position(!.CI, AfterNegatedGoal), % The call to reset_ticket(..., commit) here is necessary % in order to properly detect floundering. - code_info__maybe_release_hp(MaybeHpSlot, !CI), - code_info__maybe_reset_prune_and_release_ticket(MaybeTicketSlot, + code_info.maybe_release_hp(MaybeHpSlot, !CI), + code_info.maybe_reset_prune_and_release_ticket(MaybeTicketSlot, commit, PruneTicketCode, !CI), - trace__maybe_generate_negated_event_code(Goal, NotGoalInfo, + trace.maybe_generate_negated_event_code(Goal, NotGoalInfo, neg_failure, FailTraceCode, !CI), - code_info__generate_failure(FailCode, !CI), + code_info.generate_failure(FailCode, !CI), % We want liveness after not(G) to be the same as after G. % Information about what variables are where will be set - % by code_info__generate_resume_point. - code_info__reset_to_position(AfterNegatedGoal, !CI) + % by code_info.generate_resume_point. + code_info.reset_to_position(AfterNegatedGoal, !CI) ), % Generate the entry to the else branch. - code_info__generate_resume_point(ResumePoint, ResumeCode, !CI), + code_info.generate_resume_point(ResumePoint, ResumeCode, !CI), - code_info__set_forward_live_vars(LiveVars, !CI), + code_info.set_forward_live_vars(LiveVars, !CI), % Restore the heap pointer and solver state if necessary. - code_info__maybe_restore_and_release_hp(MaybeHpSlot, RestoreHpCode, !CI), - code_info__maybe_reset_discard_and_release_ticket(MaybeTicketSlot, undo, + code_info.maybe_restore_and_release_hp(MaybeHpSlot, RestoreHpCode, !CI), + code_info.maybe_reset_discard_and_release_ticket(MaybeTicketSlot, undo, RestoreTicketCode, !CI), - trace__maybe_generate_negated_event_code(Goal, NotGoalInfo, + trace.maybe_generate_negated_event_code(Goal, NotGoalInfo, neg_success, SuccessTraceCode, !CI), make_pneg_context_wrappers(Globals, NotGoalInfo, PNegCondCode, @@ -405,13 +405,13 @@ generate_negation_general(AddTrailOps, CodeModel, Goal, NotGoalInfo, make_pneg_context_wrappers(Globals, GoalInfo, PNegCondCode, PNegThenCode, PNegElseCode) :- - globals__lookup_bool_option(Globals, use_minimal_model_stack_copy_pneg, + globals.lookup_bool_option(Globals, use_minimal_model_stack_copy_pneg, UseMinimalModelStackCopyPNeg), ( UseMinimalModelStackCopyPNeg = yes, goal_info_get_context(GoalInfo, Context), - term__context_file(Context, File), - term__context_line(Context, Line), + term.context_file(Context, File), + term.context_line(Context, Line), ( File \= "", Line > 0 @@ -424,17 +424,17 @@ make_pneg_context_wrappers(Globals, GoalInfo, PNegCondCode, PNegThenCode, PNegCondComponents = [ pragma_c_raw_code( wrap_transient("\t\tMR_pneg_enter_cond();\n"), - cannot_branch_away, live_lvals_info(set__init)) + cannot_branch_away, live_lvals_info(set.init)) ], PNegThenComponents = [ pragma_c_raw_code( wrap_transient("\t\tMR_pneg_enter_then();\n"), - cannot_branch_away, live_lvals_info(set__init)) + cannot_branch_away, live_lvals_info(set.init)) ], PNegElseComponents = [ pragma_c_raw_code( wrap_transient("\t\tMR_pneg_enter_else(" ++ CtxtStr ++ ");\n"), - cannot_branch_away, live_lvals_info(set__init)) + cannot_branch_away, live_lvals_info(set.init)) ], PNegCondCode = node([ pragma_c([], PNegCondComponents, will_not_call_mercury, @@ -458,7 +458,7 @@ make_pneg_context_wrappers(Globals, GoalInfo, PNegCondCode, PNegThenCode, :- func wrap_transient(string) = string. wrap_transient(Code) = - string__append_list([ + string.append_list([ "\t\tMR_save_transient_registers();\n", Code, "\t\tMR_restore_transient_registers();\n"]). diff --git a/compiler/java_util.m b/compiler/java_util.m index f28c7102c..2981b13be 100644 --- a/compiler/java_util.m +++ b/compiler/java_util.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2002-2005 The University of Melbourne. +% Copyright (C) 2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -15,7 +15,7 @@ % %-----------------------------------------------------------------------------% -:- module ml_backend__java_util. +:- module ml_backend.java_util. :- interface. :- import_module backend_libs.builtin_ops. @@ -26,7 +26,7 @@ % Succeeds iff the given string matches a reserved word in Java. % -:- pred java_util__is_keyword(string::in) is semidet. +:- pred java_is_keyword(string::in) is semidet. %-----------------------------------------------------------------------------% % @@ -38,28 +38,28 @@ % The operator returned will be either a prefix operator or function name. % The operand needs to be placed in parentheses after the operator name. % -:- pred java_util__unary_prefix_op(unary_op::in, string::out) is det. +:- pred java_unary_prefix_op(unary_op::in, string::out) is det. % The operator returned will be <, >, etc.; it can be used in the form: % `.CompareTo(, ) 0'. % -:- pred java_util__string_compare_op(binary_op::in, string::out) is semidet. +:- pred java_string_compare_op(binary_op::in, string::out) is semidet. % The operator returned will be +, *, etc.; % the arguments should be floats and the result will be a float. % -:- pred java_util__float_op(binary_op::in, string::out) is semidet. +:- pred java_float_op(binary_op::in, string::out) is semidet. % The operator returned will be <, >, etc.; % the arguments should be floats and the result will be a boolean. % -:- pred java_util__float_compare_op(binary_op::in, string::out) is semidet. +:- pred java_float_compare_op(binary_op::in, string::out) is semidet. % The operator returned will be an infix operator. % The arguments should be integer or booleans % and the result will be an integer or a boolean. % -:- pred java_util__binary_infix_op(binary_op::in, string::out) is semidet. +:- pred java_binary_infix_op(binary_op::in, string::out) is semidet. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -76,108 +76,108 @@ % operators except for `tag' return no-ops. The `tag' case is handled % seperately in mlds_to_java__output_std_unop. % -java_util__unary_prefix_op(mktag, "/* mktag */ "). -java_util__unary_prefix_op(unmktag, "/* unmktag */ "). -java_util__unary_prefix_op(strip_tag, "/* strip_tag */ "). -java_util__unary_prefix_op(mkbody, "/* mkbody */ "). -java_util__unary_prefix_op(unmkbody, "/* unmkbody */ "). -java_util__unary_prefix_op(hash_string, "mercury.String.hash_1_f_0"). -java_util__unary_prefix_op(bitwise_complement, "~"). -java_util__unary_prefix_op(logical_not, "!"). -java_util__unary_prefix_op(tag, ""). % This case is never used. +java_unary_prefix_op(mktag, "/* mktag */ "). +java_unary_prefix_op(unmktag, "/* unmktag */ "). +java_unary_prefix_op(strip_tag, "/* strip_tag */ "). +java_unary_prefix_op(mkbody, "/* mkbody */ "). +java_unary_prefix_op(unmkbody, "/* unmkbody */ "). +java_unary_prefix_op(hash_string, "mercury.String.hash_1_f_0"). +java_unary_prefix_op(bitwise_complement, "~"). +java_unary_prefix_op(logical_not, "!"). +java_unary_prefix_op(tag, ""). % This case is never used. -java_util__string_compare_op(str_eq, "=="). -java_util__string_compare_op(str_ne, "!="). -java_util__string_compare_op(str_le, "<="). -java_util__string_compare_op(str_ge, ">="). -java_util__string_compare_op(str_lt, "<"). -java_util__string_compare_op(str_gt, ">"). +java_string_compare_op(str_eq, "=="). +java_string_compare_op(str_ne, "!="). +java_string_compare_op(str_le, "<="). +java_string_compare_op(str_ge, ">="). +java_string_compare_op(str_lt, "<"). +java_string_compare_op(str_gt, ">"). -java_util__float_compare_op(float_eq, "=="). -java_util__float_compare_op(float_ne, "!="). -java_util__float_compare_op(float_le, "<="). -java_util__float_compare_op(float_ge, ">="). -java_util__float_compare_op(float_lt, "<"). -java_util__float_compare_op(float_gt, ">"). +java_float_compare_op(float_eq, "=="). +java_float_compare_op(float_ne, "!="). +java_float_compare_op(float_le, "<="). +java_float_compare_op(float_ge, ">="). +java_float_compare_op(float_lt, "<"). +java_float_compare_op(float_gt, ">"). -java_util__float_op(float_plus, "+"). -java_util__float_op(float_minus, "-"). -java_util__float_op(float_times, "*"). -java_util__float_op(float_divide, "/"). +java_float_op(float_plus, "+"). +java_float_op(float_minus, "-"). +java_float_op(float_times, "*"). +java_float_op(float_divide, "/"). -java_util__binary_infix_op(int_add, "+"). -java_util__binary_infix_op(int_sub, "-"). -java_util__binary_infix_op(int_mul, "*"). -java_util__binary_infix_op(int_div, "/"). -java_util__binary_infix_op(int_mod, "%"). -java_util__binary_infix_op(unchecked_left_shift, "<<"). -java_util__binary_infix_op(unchecked_right_shift, ">>"). -java_util__binary_infix_op(bitwise_and, "&"). -java_util__binary_infix_op(bitwise_or, "|"). -java_util__binary_infix_op(bitwise_xor, "^"). -java_util__binary_infix_op(logical_and, "&&"). -java_util__binary_infix_op(logical_or, "||"). -java_util__binary_infix_op(eq, "=="). -java_util__binary_infix_op(ne, "!="). -java_util__binary_infix_op(int_lt, "<"). -java_util__binary_infix_op(int_gt, ">"). -java_util__binary_infix_op(int_le, "<="). -java_util__binary_infix_op(int_ge, ">="). +java_binary_infix_op(int_add, "+"). +java_binary_infix_op(int_sub, "-"). +java_binary_infix_op(int_mul, "*"). +java_binary_infix_op(int_div, "/"). +java_binary_infix_op(int_mod, "%"). +java_binary_infix_op(unchecked_left_shift, "<<"). +java_binary_infix_op(unchecked_right_shift, ">>"). +java_binary_infix_op(bitwise_and, "&"). +java_binary_infix_op(bitwise_or, "|"). +java_binary_infix_op(bitwise_xor, "^"). +java_binary_infix_op(logical_and, "&&"). +java_binary_infix_op(logical_or, "||"). +java_binary_infix_op(eq, "=="). +java_binary_infix_op(ne, "!="). +java_binary_infix_op(int_lt, "<"). +java_binary_infix_op(int_gt, ">"). +java_binary_infix_op(int_le, "<="). +java_binary_infix_op(int_ge, ">="). %-----------------------------------------------------------------------------% -java_util__is_keyword("abstract"). -java_util__is_keyword("boolean"). -java_util__is_keyword("break"). -java_util__is_keyword("byte"). -java_util__is_keyword("case"). -java_util__is_keyword("catch"). -java_util__is_keyword("char"). -java_util__is_keyword("class"). -java_util__is_keyword("const"). -java_util__is_keyword("continue"). -java_util__is_keyword("default"). -java_util__is_keyword("do"). -java_util__is_keyword("double"). -java_util__is_keyword("else"). -java_util__is_keyword("enum"). -java_util__is_keyword("extends"). -java_util__is_keyword("false"). -java_util__is_keyword("final"). -java_util__is_keyword("finally"). -java_util__is_keyword("float"). -java_util__is_keyword("for"). -java_util__is_keyword("goto"). -java_util__is_keyword("if"). -java_util__is_keyword("implements"). -java_util__is_keyword("import"). -java_util__is_keyword("instanceof"). -java_util__is_keyword("int"). -java_util__is_keyword("interface"). -java_util__is_keyword("long"). -java_util__is_keyword("native"). -java_util__is_keyword("new"). -java_util__is_keyword("null"). -java_util__is_keyword("package"). -java_util__is_keyword("private"). -java_util__is_keyword("protected"). -java_util__is_keyword("public"). -java_util__is_keyword("return"). -java_util__is_keyword("short"). -java_util__is_keyword("static"). -java_util__is_keyword("strictfp"). -java_util__is_keyword("super"). -java_util__is_keyword("switch"). -java_util__is_keyword("synchronized"). -java_util__is_keyword("this"). -java_util__is_keyword("throw"). -java_util__is_keyword("throws"). -java_util__is_keyword("transient"). -java_util__is_keyword("true"). -java_util__is_keyword("try"). -java_util__is_keyword("void"). -java_util__is_keyword("volatile"). -java_util__is_keyword("while"). +java_is_keyword("abstract"). +java_is_keyword("boolean"). +java_is_keyword("break"). +java_is_keyword("byte"). +java_is_keyword("case"). +java_is_keyword("catch"). +java_is_keyword("char"). +java_is_keyword("class"). +java_is_keyword("const"). +java_is_keyword("continue"). +java_is_keyword("default"). +java_is_keyword("do"). +java_is_keyword("double"). +java_is_keyword("else"). +java_is_keyword("enum"). +java_is_keyword("extends"). +java_is_keyword("false"). +java_is_keyword("final"). +java_is_keyword("finally"). +java_is_keyword("float"). +java_is_keyword("for"). +java_is_keyword("goto"). +java_is_keyword("if"). +java_is_keyword("implements"). +java_is_keyword("import"). +java_is_keyword("instanceof"). +java_is_keyword("int"). +java_is_keyword("interface"). +java_is_keyword("long"). +java_is_keyword("native"). +java_is_keyword("new"). +java_is_keyword("null"). +java_is_keyword("package"). +java_is_keyword("private"). +java_is_keyword("protected"). +java_is_keyword("public"). +java_is_keyword("return"). +java_is_keyword("short"). +java_is_keyword("static"). +java_is_keyword("strictfp"). +java_is_keyword("super"). +java_is_keyword("switch"). +java_is_keyword("synchronized"). +java_is_keyword("this"). +java_is_keyword("throw"). +java_is_keyword("throws"). +java_is_keyword("transient"). +java_is_keyword("true"). +java_is_keyword("try"). +java_is_keyword("void"). +java_is_keyword("volatile"). +java_is_keyword("while"). %-----------------------------------------------------------------------------% diff --git a/compiler/jumpopt.m b/compiler/jumpopt.m index 1a8ed3e85..b1487f6be 100644 --- a/compiler/jumpopt.m +++ b/compiler/jumpopt.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__jumpopt. +:- module ll_backend.jumpopt. :- interface. :- import_module ll_backend.llds. @@ -109,9 +109,9 @@ jumpopt_main(LayoutLabels, MayAlterRtti, ProcLabel, Fulljumpopt, Recjump, map.init(!:Procmap), map.init(!:Sdprocmap), map.init(!:Succmap), - jumpopt__build_maps(!.Instrs, Recjump, !Instrmap, !Blockmap, !Lvalmap, + jumpopt.build_maps(!.Instrs, Recjump, !Instrmap, !Blockmap, !Lvalmap, !Procmap, !Sdprocmap, !Succmap), - jumpopt__build_forkmap(!.Instrs, !.Sdprocmap, map.init, !:Forkmap), + jumpopt.build_forkmap(!.Instrs, !.Sdprocmap, map.init, !:Forkmap), ( PessimizeTailCalls = no ; @@ -124,7 +124,7 @@ jumpopt_main(LayoutLabels, MayAlterRtti, ProcLabel, Fulljumpopt, Recjump, ( CheckedNondetTailCall = yes, CheckedNondetTailCallInfo0 = yes(ProcLabel - !.C), - jumpopt__instr_list(!.Instrs, comment(""), !.Instrmap, !.Blockmap, + jumpopt.instr_list(!.Instrs, comment(""), !.Instrmap, !.Blockmap, !.Lvalmap, !.Procmap, !.Sdprocmap, !.Forkmap, !.Succmap, LayoutLabels, Fulljumpopt, MayAlterRtti, CheckedNondetTailCallInfo0, CheckedNondetTailCallInfo, @@ -139,13 +139,13 @@ jumpopt_main(LayoutLabels, MayAlterRtti, ProcLabel, Fulljumpopt, Recjump, ; CheckedNondetTailCall = no, CheckedNondetTailCallInfo0 = no, - jumpopt__instr_list(!.Instrs, comment(""), !.Instrmap, !.Blockmap, + jumpopt.instr_list(!.Instrs, comment(""), !.Instrmap, !.Blockmap, !.Lvalmap, !.Procmap, !.Sdprocmap, !.Forkmap, !.Succmap, LayoutLabels, Fulljumpopt, MayAlterRtti, CheckedNondetTailCallInfo0, _, [], RevInstrs) ), - list__reverse(RevInstrs, !:Instrs), - opt_util__filter_out_bad_livevals(!Instrs), + list.reverse(RevInstrs, !:Instrs), + opt_util.filter_out_bad_livevals(!Instrs), ( !.Instrs = Instrs0 -> Mod = no ; @@ -155,41 +155,41 @@ jumpopt_main(LayoutLabels, MayAlterRtti, ProcLabel, Fulljumpopt, Recjump, %-----------------------------------------------------------------------------% -:- pred jumpopt__build_maps(list(instruction)::in, bool::in, +:- pred jumpopt.build_maps(list(instruction)::in, bool::in, instrmap::in, instrmap::out, tailmap::in, tailmap::out, lvalmap::in, lvalmap::out, tailmap::in, tailmap::out, tailmap::in, tailmap::out, tailmap::in, tailmap::out) is det. -jumpopt__build_maps([], _, !Instrmap, !Blockmap, +jumpopt.build_maps([], _, !Instrmap, !Blockmap, !Lvalmap, !Procmap, !Sdprocmap, !Succmap). -jumpopt__build_maps([Instr0 | Instrs0], Recjump, !Instrmap, !Blockmap, +jumpopt.build_maps([Instr0 | Instrs0], Recjump, !Instrmap, !Blockmap, !Lvalmap, !Procmap, !Sdprocmap, !Succmap) :- Instr0 = Uinstr0 - _, ( Uinstr0 = label(Label) -> - opt_util__skip_comments(Instrs0, Instrs1), + opt_util.skip_comments(Instrs0, Instrs1), ( Instrs1 = [Instr1 | _], Instr1 = livevals(_) - _ -> - map__det_insert(!.Lvalmap, Label, yes(Instr1), !:Lvalmap) + map.det_insert(!.Lvalmap, Label, yes(Instr1), !:Lvalmap) ; - map__det_insert(!.Lvalmap, Label, no, !:Lvalmap) + map.det_insert(!.Lvalmap, Label, no, !:Lvalmap) ), - opt_util__skip_comments_livevals(Instrs1, Instrs2), + opt_util.skip_comments_livevals(Instrs1, Instrs2), ( Instrs2 = [Instr2 | _] -> - map__det_insert(!.Instrmap, Label, Instr2, !:Instrmap) + map.det_insert(!.Instrmap, Label, Instr2, !:Instrmap) ; true ), - ( opt_util__is_proceed_next(Instrs1, Between1) -> - map__det_insert(!.Procmap, Label, Between1, !:Procmap) + ( opt_util.is_proceed_next(Instrs1, Between1) -> + map.det_insert(!.Procmap, Label, Between1, !:Procmap) ; true ), - ( opt_util__is_sdproceed_next(Instrs1, Between2) -> - map__det_insert(!.Sdprocmap, Label, Between2, !:Sdprocmap) + ( opt_util.is_sdproceed_next(Instrs1, Between2) -> + map.det_insert(!.Sdprocmap, Label, Between2, !:Sdprocmap) ; true ), - ( opt_util__is_succeed_next(Instrs1, Between3) -> - map__det_insert(!.Succmap, Label, Between3, !:Succmap) + ( opt_util.is_succeed_next(Instrs1, Between3) -> + map.det_insert(!.Succmap, Label, Between3, !:Succmap) ; true ), @@ -200,34 +200,34 @@ jumpopt__build_maps([Instr0 | Instrs0], Recjump, !Instrmap, !Blockmap, ; Recjump = yes ) -> - opt_util__find_no_fallthrough(Instrs1, Block), - map__det_insert(!.Blockmap, Label, Block, !:Blockmap) + opt_util.find_no_fallthrough(Instrs1, Block), + map.det_insert(!.Blockmap, Label, Block, !:Blockmap) ; true ) ; true ), - jumpopt__build_maps(Instrs0, Recjump, !Instrmap, !Blockmap, !Lvalmap, + jumpopt.build_maps(Instrs0, Recjump, !Instrmap, !Blockmap, !Lvalmap, !Procmap, !Sdprocmap, !Succmap). % Find labels followed by a test of r1 where both paths set r1 to % its original value and proceed. % -:- pred jumpopt__build_forkmap(list(instruction)::in, tailmap::in, +:- pred jumpopt.build_forkmap(list(instruction)::in, tailmap::in, tailmap::in, tailmap::out) is det. -jumpopt__build_forkmap([], _Sdprocmap, !Forkmap). -jumpopt__build_forkmap([Instr - _Comment|Instrs], Sdprocmap, !Forkmap) :- +jumpopt.build_forkmap([], _Sdprocmap, !Forkmap). +jumpopt.build_forkmap([Instr - _Comment|Instrs], Sdprocmap, !Forkmap) :- ( Instr = label(Label), - opt_util__is_forkproceed_next(Instrs, Sdprocmap, Between) + opt_util.is_forkproceed_next(Instrs, Sdprocmap, Between) -> - map__det_insert(!.Forkmap, Label, Between, !:Forkmap) + map.det_insert(!.Forkmap, Label, Between, !:Forkmap) ; true ), - jumpopt__build_forkmap(Instrs, Sdprocmap, !Forkmap). + jumpopt.build_forkmap(Instrs, Sdprocmap, !Forkmap). %-----------------------------------------------------------------------------% @@ -266,17 +266,17 @@ jumpopt__build_forkmap([Instr - _Comment|Instrs], Sdprocmap, !Forkmap) :- % building it in right order would make instr_list not tail recursive, % and thus unable to handle very long instruction lists. % -:- pred jumpopt__instr_list(list(instruction)::in, instr::in, instrmap::in, +:- pred jumpopt.instr_list(list(instruction)::in, instr::in, instrmap::in, tailmap::in, lvalmap::in, tailmap::in, tailmap::in, tailmap::in, tailmap::in, set(label)::in, bool::in, may_alter_rtti::in, maybe(pair(proc_label, counter))::in, maybe(pair(proc_label, counter))::out, list(instruction)::in, list(instruction)::out) is det. -jumpopt__instr_list([], _PrevInstr, _Instrmap, _Blockmap, _Lvalmap, +jumpopt.instr_list([], _PrevInstr, _Instrmap, _Blockmap, _Lvalmap, _Procmap, _Sdprocmap, _Forkmap, _Succmap, _LayoutLabels, _Fulljumpopt, _MayAlterRtti, !CheckedNondetTailCallInfo, !RevInstrs). -jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, +jumpopt.instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, Lvalmap, Procmap, Sdprocmap, Forkmap, Succmap, LayoutLabels, Fulljumpopt, MayAlterRtti, !CheckedNondetTailCallInfo, !RevInstrs) :- Instr0 = Uinstr0 - Comment0, @@ -295,22 +295,22 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % the call is semidet, because one of the optimizations below % turns a pair of semidet epilogs into a det epilog. ( CallModel = det ; CallModel = semidet ), - map__search(Procmap, RetLabel, Between0), + map.search(Procmap, RetLabel, Between0), PrevInstr = livevals(Livevals), MayAlterRtti = may_alter_rtti, - not set__member(RetLabel, LayoutLabels) + not set.member(RetLabel, LayoutLabels) -> - opt_util__filter_out_livevals(Between0, Between1), + opt_util.filter_out_livevals(Between0, Between1), NewInstrs = Between1 ++ [livevals(Livevals) - "", goto(Proc) - redirect_comment(Comment0)], NewRemain = specified(NewInstrs, Instrs0) ; % Look for semidet style tailcalls. CallModel = semidet, - map__search(Forkmap, RetLabel, Between), + map.search(Forkmap, RetLabel, Between), PrevInstr = livevals(Livevals), MayAlterRtti = may_alter_rtti, - not set__member(RetLabel, LayoutLabels) + not set.member(RetLabel, LayoutLabels) -> NewInstrs = Between ++ [livevals(Livevals) - "", goto(Proc) - redirect_comment(Comment0)], @@ -319,11 +319,11 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % Look for nondet style tailcalls which do not need % a runtime check. CallModel = nondet(unchecked_tail_call), - map__search(Succmap, RetLabel, BetweenIncl), + map.search(Succmap, RetLabel, BetweenIncl), BetweenIncl = [livevals(_) - _, goto(_) - _], PrevInstr = livevals(Livevals), MayAlterRtti = may_alter_rtti, - not set__member(RetLabel, LayoutLabels) + not set.member(RetLabel, LayoutLabels) -> NewInstrs = [ assign(maxfr, lval(prevfr(lval(curfr)))) @@ -341,13 +341,13 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % a runtime check. CallModel = nondet(checked_tail_call), !.CheckedNondetTailCallInfo = yes(ProcLabel - Counter0), - map__search(Succmap, RetLabel, BetweenIncl), + map.search(Succmap, RetLabel, BetweenIncl), BetweenIncl = [livevals(_) - _, goto(_) - _], PrevInstr = livevals(Livevals), MayAlterRtti = may_alter_rtti, - not set__member(RetLabel, LayoutLabels) + not set.member(RetLabel, LayoutLabels) -> - counter__allocate(LabelNum, Counter0, Counter1), + counter.allocate(LabelNum, Counter0, Counter1), NewLabel = internal(LabelNum, ProcLabel), NewInstrs = [ if_val(binop(ne, lval(curfr), lval(maxfr)), @@ -368,11 +368,11 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, !:CheckedNondetTailCallInfo = yes(ProcLabel - Counter1) ; % Short circuit the return label if possible. - map__search(Instrmap, RetLabel, RetInstr), + map.search(Instrmap, RetLabel, RetInstr), MayAlterRtti = may_alter_rtti, - not set__member(RetLabel, LayoutLabels) + not set.member(RetLabel, LayoutLabels) -> - jumpopt__final_dest(Instrmap, RetLabel, DestLabel, + jumpopt.final_dest(Instrmap, RetLabel, DestLabel, RetInstr, _DestInstr), ( RetLabel = DestLabel -> NewInstrs = [Instr0] @@ -393,13 +393,13 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, ( TargetAddr = label(TargetLabel) -> ( % Eliminate the goto if possible. - opt_util__is_this_label_next(TargetLabel, Instrs0, _) + opt_util.is_this_label_next(TargetLabel, Instrs0, _) -> NewInstrs = [], NewRemain = specified(NewInstrs, Instrs0) ; PrevInstr = if_val(_, label(IfTargetLabel)), - opt_util__is_this_label_next(IfTargetLabel, Instrs0, _) + opt_util.is_this_label_next(IfTargetLabel, Instrs0, _) -> % Eliminating the goto (by the local peephole pass) % is better than shortcircuiting it here, @@ -411,23 +411,23 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, NewRemain = specified(NewInstrs, Instrs0) ; % Replace a jump to a det epilog with the epilog. - map__search(Procmap, TargetLabel, Between0) + map.search(Procmap, TargetLabel, Between0) -> - jumpopt__adjust_livevals(PrevInstr, Between0, Between), + jumpopt.adjust_livevals(PrevInstr, Between0, Between), NewInstrs = Between ++ [goto(succip) - "shortcircuit"], NewRemain = specified(NewInstrs, Instrs0) ; % Replace a jump to a semidet epilog with the epilog. - map__search(Sdprocmap, TargetLabel, Between0) + map.search(Sdprocmap, TargetLabel, Between0) -> - jumpopt__adjust_livevals(PrevInstr, Between0, Between), + jumpopt.adjust_livevals(PrevInstr, Between0, Between), NewInstrs = Between ++ [goto(succip) - "shortcircuit"], NewRemain = specified(NewInstrs, Instrs0) ; % Replace a jump to a nondet epilog with the epilog. - map__search(Succmap, TargetLabel, BetweenIncl0) + map.search(Succmap, TargetLabel, BetweenIncl0) -> - jumpopt__adjust_livevals(PrevInstr, BetweenIncl0, NewInstrs), + jumpopt.adjust_livevals(PrevInstr, BetweenIncl0, NewInstrs), NewRemain = specified(NewInstrs, Instrs0) ; % Replace a jump to a non-epilog block with the @@ -445,34 +445,34 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % which is correct only if jumps to those labels % are short-circuited everywhere. Fulljumpopt = yes, - map__search(Instrmap, TargetLabel, TargetInstr), - jumpopt__final_dest(Instrmap, TargetLabel, DestLabel, + map.search(Instrmap, TargetLabel, TargetInstr), + jumpopt.final_dest(Instrmap, TargetLabel, DestLabel, TargetInstr, _DestInstr), - map__search(Blockmap, DestLabel, Block), + map.search(Blockmap, DestLabel, Block), block_may_be_duplicated(Block) = yes -> - opt_util__filter_out_labels(Block, FilteredBlock), - jumpopt__adjust_livevals(PrevInstr, FilteredBlock, + opt_util.filter_out_labels(Block, FilteredBlock), + jumpopt.adjust_livevals(PrevInstr, FilteredBlock, AdjustedBlock), % Block may end with a goto to DestLabel. We avoid % infinite expansion in such cases by removing % DestLabel from Blockmap, though only while % processing AdjustedBlock. - map__delete(Blockmap, DestLabel, CrippledBlockmap), - jumpopt__instr_list(AdjustedBlock, comment(""), Instrmap, + map.delete(Blockmap, DestLabel, CrippledBlockmap), + jumpopt.instr_list(AdjustedBlock, comment(""), Instrmap, CrippledBlockmap, Lvalmap, Procmap, Sdprocmap, Forkmap, Succmap, LayoutLabels, Fulljumpopt, MayAlterRtti, !CheckedNondetTailCallInfo, [], RevNewInstrs), - NewRemain = specified(list__reverse(RevNewInstrs), Instrs0) + NewRemain = specified(list.reverse(RevNewInstrs), Instrs0) ; % Short-circuit the goto. - map__search(Instrmap, TargetLabel, TargetInstr) + map.search(Instrmap, TargetLabel, TargetInstr) -> - jumpopt__final_dest(Instrmap, TargetLabel, DestLabel, + jumpopt.final_dest(Instrmap, TargetLabel, DestLabel, TargetInstr, DestInstr), DestInstr = UdestInstr - _Destcomment, Shorted = "shortcircuited jump: " ++ Comment0, - opt_util__can_instr_fall_through(UdestInstr, Canfallthrough), + opt_util.can_instr_fall_through(UdestInstr, Canfallthrough), ( Canfallthrough = no, NewInstrs0 = [UdestInstr - Shorted] @@ -484,8 +484,8 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, NewInstrs0 = [goto(label(DestLabel)) - Shorted] ) ), - ( map__search(Lvalmap, DestLabel, yes(Lvalinstr)) -> - jumpopt__adjust_livevals(PrevInstr, + ( map.search(Lvalmap, DestLabel, yes(Lvalinstr)) -> + jumpopt.adjust_livevals(PrevInstr, [Lvalinstr | NewInstrs0], NewInstrs) ; NewInstrs = NewInstrs0 @@ -500,7 +500,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, ; Uinstr0 = computed_goto(Index, LabelList0), % Short-circuit all the destination labels. - jumpopt__short_labels(Instrmap, LabelList0, LabelList), + jumpopt.short_labels(Instrmap, LabelList0, LabelList), ( LabelList = LabelList0 -> NewRemain = usual_case ; @@ -530,11 +530,11 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % directly to L3). This may not be possible if L3 is % a non-label code address; e.g. we cannot jump to % non-label code addresses from computed gotos. - opt_util__skip_comments(Instrs0, Instrs1), + opt_util.skip_comments(Instrs0, Instrs1), Instrs1 = [Instr1 | Instrs2], ( Instr1 = label(ElimLabel) - _ -> - not set__member(ElimLabel, LayoutLabels), - opt_util__skip_comments(Instrs2, Instrs3), + not set.member(ElimLabel, LayoutLabels), + opt_util.skip_comments(Instrs2, Instrs3), Instrs3 = [GotoInstr | AfterGoto], HaveLabel = yes ; @@ -544,11 +544,11 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, ), GotoInstr = goto(GotoTarget) - GotoComment, ( HaveLabel = no ; GotoTarget = label(_) ), - opt_util__skip_comments(AfterGoto, AfterGotoComments), + opt_util.skip_comments(AfterGoto, AfterGotoComments), AfterGotoComments = [LabelInstr | _], LabelInstr = label(TargetLabel) - _ -> - code_util__neg_rval(Cond, NotCond), + code_util.neg_rval(Cond, NotCond), NewInstr = if_val(NotCond, GotoTarget) - GotoComment, NewInstrs = [], % The transformed code may fit the pattern again, @@ -580,16 +580,16 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % if_val, to get the recursive call to replace the goto % to L1 with the code at L1. Fulljumpopt = yes, - map__search(Blockmap, TargetLabel, _TargetBlock), - opt_util__skip_comments(Instrs0, Instrs1), + map.search(Blockmap, TargetLabel, _TargetBlock), + opt_util.skip_comments(Instrs0, Instrs1), Instrs1 = [GotoInstr | AfterGoto], GotoInstr = goto(GotoAddr) - GotoComment, \+ ( GotoAddr = label(GotoLabel), - map__search(Blockmap, GotoLabel, _) + map.search(Blockmap, GotoLabel, _) ) -> - code_util__neg_rval(Cond, NotCond), + code_util.neg_rval(Cond, NotCond), NewIfInstr = if_val(NotCond, GotoAddr) - GotoComment, NewInstrs = [NewIfInstr], NewGotoComment = Comment0 ++ " (switched)", @@ -597,9 +597,9 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, RemainInstrs = [NewGotoInstr | AfterGoto], NewRemain = specified(NewInstrs, RemainInstrs) ; - map__search(Instrmap, TargetLabel, TargetInstr) + map.search(Instrmap, TargetLabel, TargetInstr) -> - jumpopt__final_dest(Instrmap, TargetLabel, DestLabel, + jumpopt.final_dest(Instrmap, TargetLabel, DestLabel, TargetInstr, _DestInstr), ( % Attempt to transform code such as @@ -617,17 +617,17 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % r1 = Cond % % - opt_util__is_sdproceed_next(Instrs0, BetweenFT), - map__search(Blockmap, DestLabel, Block), - opt_util__is_sdproceed_next(Block, BetweenBR), - opt_util__filter_out_r1(BetweenFT, yes(SuccessFT), + opt_util.is_sdproceed_next(Instrs0, BetweenFT), + map.search(Blockmap, DestLabel, Block), + opt_util.is_sdproceed_next(Block, BetweenBR), + opt_util.filter_out_r1(BetweenFT, yes(SuccessFT), Between), - opt_util__filter_out_r1(BetweenBR, yes(SuccessBR), + opt_util.filter_out_r1(BetweenBR, yes(SuccessBR), Between), ( SuccessFT = true, SuccessBR = false, - code_util__neg_rval(Cond, NewCond) + code_util.neg_rval(Cond, NewCond) ; SuccessFT = false, SuccessBR = true, @@ -663,7 +663,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, ; Uinstr0 = assign(Lval, Rval0), % Any labels mentioned in Rval0 should be short-circuited. - jumpopt__short_labels_rval(Instrmap, Rval0, Rval), + jumpopt.short_labels_rval(Instrmap, Rval0, Rval), ( Rval = Rval0 -> NewRemain = usual_case ; @@ -674,7 +674,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, ; Uinstr0 = mkframe(FrameInfo, Redoip), ( Redoip = yes(label(Label0)) -> - jumpopt__short_label(Instrmap, Label0, Label), + jumpopt.short_label(Instrmap, Label0, Label), ( Label = Label0 -> NewRemain = usual_case ; @@ -690,7 +690,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, MaybeFixNoLayout, MaybeFixLayout, MaybeFixOnlyLayout, MaybeNoFix0, StackSlotRef, MaybeDup), some [!Redirect] ( - list__map_foldl(short_pragma_component(Instrmap), + list.map_foldl(short_pragma_component(Instrmap), Components0, Components, no, !:Redirect), ( MaybeNoFix0 = yes(NoFix), @@ -711,7 +711,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % short_label(Instrmap, FixNoLayout, FixNoLayoutDest), % FixNoLayoutDest \= FixNoLayout % -> -% error("jumpopt__instr_list: pragma_c fix_no_layout") +% error("jumpopt.instr_list: pragma_c fix_no_layout") % ; % true % ), @@ -720,7 +720,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % short_label(Instrmap, FixLayout, FixLayoutDest), % FixLayoutDest \= FixLayout % -> -% error("jumpopt__instr_list: pragma_c fix_layout") +% error("jumpopt.instr_list: pragma_c fix_layout") % ; % true % ), @@ -729,7 +729,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % short_label(Instrmap, FixOnlyLayout, FixOnlyLayoutDest), % FixOnlyLayoutDest \= FixOnlyLayout % -> -% error("jumpopt__instr_list: pragma_c fix_only_layout") +% error("jumpopt.instr_list: pragma_c fix_only_layout") % ; % true % ), @@ -851,7 +851,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, % ReplacementInstrs are in the right order, but they will be reversed % by our caller. We therefore reverse them here, which allows that % final reverse to put them in the right order. - !:RevInstrs = list__reverse(ReplacementInstrs) ++ !.RevInstrs, + !:RevInstrs = list.reverse(ReplacementInstrs) ++ !.RevInstrs, ( ReplacementInstrs = [], ReplacementInstrsEmpty = yes @@ -869,7 +869,7 @@ jumpopt__instr_list([Instr0 | Instrs0], PrevInstr, Instrmap, Blockmap, ; NewPrevInstr = Uinstr0 ), - jumpopt__instr_list(RecurseInstrs, NewPrevInstr, Instrmap, Blockmap, + jumpopt.instr_list(RecurseInstrs, NewPrevInstr, Instrmap, Blockmap, Lvalmap, Procmap, Sdprocmap, Forkmap, Succmap, LayoutLabels, Fulljumpopt, MayAlterRtti, !CheckedNondetTailCallInfo, !RevInstrs). @@ -904,7 +904,7 @@ instr_may_be_duplicated(Instr) = InstrMayBeDuplicated :- :- func redirect_comment(string) = string. -redirect_comment(Comment0) = string__append(Comment0, " (redirected return)"). +redirect_comment(Comment0) = string.append(Comment0, " (redirected return)"). % We avoid generating statements that redefine the value of a location % by comparing its old contents for non-equality with zero. @@ -942,13 +942,13 @@ needs_workaround(Lval, Cond) :- ) ). -:- pred jumpopt__adjust_livevals(instr::in, list(instruction)::in, +:- pred jumpopt.adjust_livevals(instr::in, list(instruction)::in, list(instruction)::out) is det. -jumpopt__adjust_livevals(PrevInstr, Instrs0, Instrs) :- +jumpopt.adjust_livevals(PrevInstr, Instrs0, Instrs) :- ( PrevInstr = livevals(PrevLivevals), - opt_util__skip_comments(Instrs0, Instrs1), + opt_util.skip_comments(Instrs0, Instrs1), Instrs1 = [livevals(BetweenLivevals) - _ | Instrs2] -> ( BetweenLivevals = PrevLivevals -> @@ -966,39 +966,39 @@ jumpopt__adjust_livevals(PrevInstr, Instrs0, Instrs) :- % Short-circuit the given label by following any gotos at the % labelled instruction or by falling through consecutive labels. % -:- pred jumpopt__short_label(instrmap::in, label::in, label::out) is det. +:- pred jumpopt.short_label(instrmap::in, label::in, label::out) is det. -jumpopt__short_label(Instrmap, Label0, Label) :- - ( map__search(Instrmap, Label0, Instr0) -> - jumpopt__final_dest(Instrmap, Label0, Label, Instr0, _Instr) +jumpopt.short_label(Instrmap, Label0, Label) :- + ( map.search(Instrmap, Label0, Instr0) -> + jumpopt.final_dest(Instrmap, Label0, Label, Instr0, _Instr) ; Label = Label0 ). -:- pred jumpopt__short_labels(instrmap::in, list(label)::in, list(label)::out) +:- pred jumpopt.short_labels(instrmap::in, list(label)::in, list(label)::out) is det. -jumpopt__short_labels(_Instrmap, [], []). -jumpopt__short_labels(Instrmap, [Label0 | Labels0], [Label | Labels]) :- - jumpopt__short_label(Instrmap, Label0, Label), - jumpopt__short_labels(Instrmap, Labels0, Labels). +jumpopt.short_labels(_Instrmap, [], []). +jumpopt.short_labels(Instrmap, [Label0 | Labels0], [Label | Labels]) :- + jumpopt.short_label(Instrmap, Label0, Label), + jumpopt.short_labels(Instrmap, Labels0, Labels). %-----------------------------------------------------------------------------% % Find the final destination of a given instruction at a given label. % We follow gotos as well as consecutive labels. % -:- pred jumpopt__final_dest(instrmap::in, label::in, label::out, +:- pred jumpopt.final_dest(instrmap::in, label::in, label::out, instruction::in, instruction::out) is det. -jumpopt__final_dest(Instrmap, SrcLabel, DestLabel, SrcInstr, DestInstr) :- - jumpopt__final_dest_2(Instrmap, [], SrcLabel, DestLabel, +jumpopt.final_dest(Instrmap, SrcLabel, DestLabel, SrcInstr, DestInstr) :- + jumpopt.final_dest_2(Instrmap, [], SrcLabel, DestLabel, SrcInstr, DestInstr). -:- pred jumpopt__final_dest_2(instrmap::in, list(label)::in, +:- pred jumpopt.final_dest_2(instrmap::in, list(label)::in, label::in, label::out, instruction::in, instruction::out) is det. -jumpopt__final_dest_2(Instrmap, LabelsSofar, SrcLabel, DestLabel, +jumpopt.final_dest_2(Instrmap, LabelsSofar, SrcLabel, DestLabel, SrcInstr, DestInstr) :- ( SrcInstr = SrcUinstr - _Comment, @@ -1007,10 +1007,10 @@ jumpopt__final_dest_2(Instrmap, LabelsSofar, SrcLabel, DestLabel, ; SrcUinstr = label(TargetLabel) ), - map__search(Instrmap, TargetLabel, TargetInstr), - \+ list__member(SrcLabel, LabelsSofar) + map.search(Instrmap, TargetLabel, TargetInstr), + \+ list.member(SrcLabel, LabelsSofar) -> - jumpopt__final_dest_2(Instrmap, [SrcLabel | LabelsSofar], + jumpopt.final_dest_2(Instrmap, [SrcLabel | LabelsSofar], TargetLabel, DestLabel, TargetInstr, DestInstr) ; DestLabel = SrcLabel, @@ -1019,94 +1019,94 @@ jumpopt__final_dest_2(Instrmap, LabelsSofar, SrcLabel, DestLabel, %-----------------------------------------------------------------------------% -:- pred jumpopt__short_labels_rval(instrmap::in, rval::in, rval::out) is det. +:- pred jumpopt.short_labels_rval(instrmap::in, rval::in, rval::out) is det. -jumpopt__short_labels_rval(Instrmap, lval(Lval0), lval(Lval)) :- - jumpopt__short_labels_lval(Instrmap, Lval0, Lval). -jumpopt__short_labels_rval(_, var(_), _) :- +jumpopt.short_labels_rval(Instrmap, lval(Lval0), lval(Lval)) :- + jumpopt.short_labels_lval(Instrmap, Lval0, Lval). +jumpopt.short_labels_rval(_, var(_), _) :- unexpected(this_file, "var rval in short_labels_rval"). -jumpopt__short_labels_rval(Instrmap, mkword(Tag, Rval0), mkword(Tag, Rval)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval). -jumpopt__short_labels_rval(Instrmap, const(Const0), const(Const)) :- - jumpopt__short_labels_const(Instrmap, Const0, Const). -jumpopt__short_labels_rval(Instrmap, unop(Op, Rval0), unop(Op, Rval)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval). -jumpopt__short_labels_rval(Instrmap, binop(Op, LRval0, RRval0), +jumpopt.short_labels_rval(Instrmap, mkword(Tag, Rval0), mkword(Tag, Rval)) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval). +jumpopt.short_labels_rval(Instrmap, const(Const0), const(Const)) :- + jumpopt.short_labels_const(Instrmap, Const0, Const). +jumpopt.short_labels_rval(Instrmap, unop(Op, Rval0), unop(Op, Rval)) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval). +jumpopt.short_labels_rval(Instrmap, binop(Op, LRval0, RRval0), binop(Op, LRval, RRval)) :- - jumpopt__short_labels_rval(Instrmap, LRval0, LRval), - jumpopt__short_labels_rval(Instrmap, RRval0, RRval). -jumpopt__short_labels_rval(_, mem_addr(MemRef), mem_addr(MemRef)). + jumpopt.short_labels_rval(Instrmap, LRval0, LRval), + jumpopt.short_labels_rval(Instrmap, RRval0, RRval). +jumpopt.short_labels_rval(_, mem_addr(MemRef), mem_addr(MemRef)). -:- pred jumpopt__short_labels_const(instrmap::in, +:- pred jumpopt.short_labels_const(instrmap::in, rval_const::in, rval_const::out) is det. -jumpopt__short_labels_const(_, true, true). -jumpopt__short_labels_const(_, false, false). -jumpopt__short_labels_const(_, int_const(I), int_const(I)). -jumpopt__short_labels_const(_, float_const(F), float_const(F)). -jumpopt__short_labels_const(_, string_const(S), string_const(S)). -jumpopt__short_labels_const(_, multi_string_const(L, S), +jumpopt.short_labels_const(_, true, true). +jumpopt.short_labels_const(_, false, false). +jumpopt.short_labels_const(_, int_const(I), int_const(I)). +jumpopt.short_labels_const(_, float_const(F), float_const(F)). +jumpopt.short_labels_const(_, string_const(S), string_const(S)). +jumpopt.short_labels_const(_, multi_string_const(L, S), multi_string_const(L, S)). -jumpopt__short_labels_const(Instrmap, code_addr_const(CodeAddr0), +jumpopt.short_labels_const(Instrmap, code_addr_const(CodeAddr0), code_addr_const(CodeAddr)) :- ( CodeAddr0 = label(Label0) -> - jumpopt__short_label(Instrmap, Label0, Label), + jumpopt.short_label(Instrmap, Label0, Label), CodeAddr = label(Label) ; CodeAddr = CodeAddr0 ). -jumpopt__short_labels_const(_, data_addr_const(D, O), data_addr_const(D, O)). +jumpopt.short_labels_const(_, data_addr_const(D, O), data_addr_const(D, O)). -:- pred jumpopt__short_labels_maybe_rvals(instrmap::in, list(maybe(rval))::in, +:- pred jumpopt.short_labels_maybe_rvals(instrmap::in, list(maybe(rval))::in, list(maybe(rval))::out) is det. -jumpopt__short_labels_maybe_rvals(_, [], []). -jumpopt__short_labels_maybe_rvals(Instrmap, [MaybeRval0 | MaybeRvals0], +jumpopt.short_labels_maybe_rvals(_, [], []). +jumpopt.short_labels_maybe_rvals(Instrmap, [MaybeRval0 | MaybeRvals0], [MaybeRval | MaybeRvals]) :- - jumpopt__short_labels_maybe_rval(Instrmap, MaybeRval0, MaybeRval), - jumpopt__short_labels_maybe_rvals(Instrmap, MaybeRvals0, MaybeRvals). + jumpopt.short_labels_maybe_rval(Instrmap, MaybeRval0, MaybeRval), + jumpopt.short_labels_maybe_rvals(Instrmap, MaybeRvals0, MaybeRvals). -:- pred jumpopt__short_labels_maybe_rval(instrmap::in, +:- pred jumpopt.short_labels_maybe_rval(instrmap::in, maybe(rval)::in, maybe(rval)::out) is det. -jumpopt__short_labels_maybe_rval(Instrmap, MaybeRval0, MaybeRval) :- +jumpopt.short_labels_maybe_rval(Instrmap, MaybeRval0, MaybeRval) :- ( MaybeRval0 = no, MaybeRval = no ; MaybeRval0 = yes(Rval0), - jumpopt__short_labels_rval(Instrmap, Rval0, Rval), + jumpopt.short_labels_rval(Instrmap, Rval0, Rval), MaybeRval = yes(Rval) ). -:- pred jumpopt__short_labels_lval(instrmap::in, lval::in, lval::out) is det. +:- pred jumpopt.short_labels_lval(instrmap::in, lval::in, lval::out) is det. -jumpopt__short_labels_lval(_, reg(T, N), reg(T, N)). -jumpopt__short_labels_lval(_, succip, succip). -jumpopt__short_labels_lval(_, maxfr, maxfr). -jumpopt__short_labels_lval(_, curfr, curfr). -jumpopt__short_labels_lval(_, hp, hp). -jumpopt__short_labels_lval(_, sp, sp). -jumpopt__short_labels_lval(_, temp(T, N), temp(T, N)). -jumpopt__short_labels_lval(_, stackvar(N), stackvar(N)). -jumpopt__short_labels_lval(_, framevar(N), framevar(N)). -jumpopt__short_labels_lval(Instrmap, succip(Rval0), succip(Rval)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval). -jumpopt__short_labels_lval(Instrmap, redoip(Rval0), redoip(Rval)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval). -jumpopt__short_labels_lval(Instrmap, redofr(Rval0), redofr(Rval)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval). -jumpopt__short_labels_lval(Instrmap, succfr(Rval0), succfr(Rval)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval). -jumpopt__short_labels_lval(Instrmap, prevfr(Rval0), prevfr(Rval)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval). -jumpopt__short_labels_lval(Instrmap, field(Tag, Rval0, Field0), +jumpopt.short_labels_lval(_, reg(T, N), reg(T, N)). +jumpopt.short_labels_lval(_, succip, succip). +jumpopt.short_labels_lval(_, maxfr, maxfr). +jumpopt.short_labels_lval(_, curfr, curfr). +jumpopt.short_labels_lval(_, hp, hp). +jumpopt.short_labels_lval(_, sp, sp). +jumpopt.short_labels_lval(_, temp(T, N), temp(T, N)). +jumpopt.short_labels_lval(_, stackvar(N), stackvar(N)). +jumpopt.short_labels_lval(_, framevar(N), framevar(N)). +jumpopt.short_labels_lval(Instrmap, succip(Rval0), succip(Rval)) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval). +jumpopt.short_labels_lval(Instrmap, redoip(Rval0), redoip(Rval)) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval). +jumpopt.short_labels_lval(Instrmap, redofr(Rval0), redofr(Rval)) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval). +jumpopt.short_labels_lval(Instrmap, succfr(Rval0), succfr(Rval)) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval). +jumpopt.short_labels_lval(Instrmap, prevfr(Rval0), prevfr(Rval)) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval). +jumpopt.short_labels_lval(Instrmap, field(Tag, Rval0, Field0), field(Tag, Rval, Field)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval), - jumpopt__short_labels_rval(Instrmap, Field0, Field). -jumpopt__short_labels_lval(Instrmap, mem_ref(Rval0), mem_ref(Rval)) :- - jumpopt__short_labels_rval(Instrmap, Rval0, Rval). -jumpopt__short_labels_lval(_, lvar(_), _) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval), + jumpopt.short_labels_rval(Instrmap, Field0, Field). +jumpopt.short_labels_lval(Instrmap, mem_ref(Rval0), mem_ref(Rval)) :- + jumpopt.short_labels_rval(Instrmap, Rval0, Rval). +jumpopt.short_labels_lval(_, lvar(_), _) :- unexpected(this_file, "lvar lval in short_labels_lval"). :- pred short_pragma_component(instrmap::in, diff --git a/compiler/labelopt.m b/compiler/labelopt.m index 14a7f865e..7a60e047a 100644 --- a/compiler/labelopt.m +++ b/compiler/labelopt.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-1999, 2003-2005 The University of Melbourne. +% Copyright (C) 1994-1999, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__labelopt. +:- module ll_backend.labelopt. :- interface. :- import_module ll_backend.llds. @@ -68,8 +68,8 @@ labelopt_main(Final, LayoutLabelSet, Instrs0, Instrs, Mod) :- build_useset([], !Useset). build_useset([Instr | Instructions], !Useset) :- Instr = Uinstr - _Comment, - opt_util__instr_labels(Uinstr, Labels, _CodeAddresses), - svset__insert_list(Labels, !Useset), + opt_util.instr_labels(Uinstr, Labels, _CodeAddresses), + svset.insert_list(Labels, !Useset), build_useset(Instructions, !Useset). %-----------------------------------------------------------------------------% @@ -91,7 +91,7 @@ build_useset([Instr | Instructions], !Useset) :- instr_list(Instrs0, Instrs, Useset, Mod) :- Fallthrough = yes, instr_list_2(Instrs0, [], RevInstrs, no, Mod, Fallthrough, Useset), - list__reverse(RevInstrs, Instrs). + list.reverse(RevInstrs, Instrs). :- pred instr_list_2(list(instruction)::in, list(instruction)::in, list(instruction)::out, @@ -108,7 +108,7 @@ instr_list_2([Instr0 | Instrs0], !RevInstrs, !Mod, !.Fallthrough, Useset) :- ; EntryType = local ) ; - set__member(Label, Useset) + set.member(Label, Useset) ) -> !:RevInstrs = [Instr0 | !.RevInstrs], @@ -124,7 +124,7 @@ instr_list_2([Instr0 | Instrs0], !RevInstrs, !Mod, !.Fallthrough, Useset) :- !.Fallthrough = no, eliminate(Instr0, no, !RevInstrs, !Mod) ), - opt_util__can_instr_fall_through(Uinstr0, Canfallthrough), + opt_util.can_instr_fall_through(Uinstr0, Canfallthrough), ( Canfallthrough = yes ; diff --git a/compiler/lambda.m b/compiler/lambda.m index db43c1f1c..e3d1d0e1d 100644 --- a/compiler/lambda.m +++ b/compiler/lambda.m @@ -63,11 +63,10 @@ % be different for each call. % Currently we don't support second-order polymorphism, so we % don't support existentially typed lambda expressions either. -% %-----------------------------------------------------------------------------% -:- module transform_hlds__lambda. +:- module transform_hlds.lambda. :- interface. :- import_module hlds.hlds_module. @@ -135,31 +134,31 @@ process_module(!ModuleInfo) :- module_info_predids(!.ModuleInfo, PredIds), - list__foldl(process_pred, PredIds, !ModuleInfo), + list.foldl(process_pred, PredIds, !ModuleInfo), % Need update the dependency graph to include the lambda predicates. module_info_clobber_dependency_info(!ModuleInfo). process_pred(PredId, !ModuleInfo) :- module_info_pred_info(!.ModuleInfo, PredId, PredInfo), ProcIds = pred_info_procids(PredInfo), - list__foldl(process_proc(PredId), ProcIds, !ModuleInfo). + list.foldl(process_proc(PredId), ProcIds, !ModuleInfo). :- pred process_proc(pred_id::in, proc_id::in, module_info::in, module_info::out) is det. process_proc(PredId, ProcId, !ModuleInfo) :- module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), process_proc_2(ProcInfo0, ProcInfo, PredInfo0, PredInfo1, !ModuleInfo), pred_info_procedures(PredInfo1, ProcTable1), - map__det_update(ProcTable1, ProcId, ProcInfo, ProcTable), + map.det_update(ProcTable1, ProcId, ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo1, PredInfo), module_info_preds(!.ModuleInfo, PredTable1), - map__det_update(PredTable1, PredId, PredInfo, PredTable), + map.det_update(PredTable1, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo). :- pred process_proc_2(proc_info::in, proc_info::out, @@ -315,10 +314,10 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, % Note currently we only allow lambda expressions to have universally % quantified constraints. rtti_varmaps_reusable_constraints(RttiVarMaps, AllConstraints), - map__apply_to_list(Vars, VarTypes, LambdaVarTypes), - list__map(prog_type__vars, LambdaVarTypes, LambdaTypeVarsList), - list__condense(LambdaTypeVarsList, LambdaTypeVars), - list__filter(constraint_contains_vars(LambdaTypeVars), + map.apply_to_list(Vars, VarTypes, LambdaVarTypes), + list.map(prog_type.vars, LambdaVarTypes, LambdaTypeVarsList), + list.condense(LambdaTypeVarsList, LambdaTypeVars), + list.filter(constraint_contains_vars(LambdaTypeVars), AllConstraints, UnivConstraints), Constraints = constraints(UnivConstraints, []), @@ -327,8 +326,8 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, ExistQVars = [], LambdaGoal = _ - LambdaGoalInfo, goal_info_get_nonlocals(LambdaGoalInfo, LambdaGoalNonLocals), - set__insert_list(LambdaGoalNonLocals, Vars, LambdaNonLocals), - goal_util__extra_nonlocal_typeinfos(RttiVarMaps, VarTypes, ExistQVars, + set.insert_list(LambdaGoalNonLocals, Vars, LambdaNonLocals), + goal_util.extra_nonlocal_typeinfos(RttiVarMaps, VarTypes, ExistQVars, LambdaNonLocals, ExtraTypeInfos), OrigVars = OrigNonLocals0, @@ -339,22 +338,22 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, unexpected(this_file, "transform_lambda: weird unification") ), - set__delete_list(LambdaGoalNonLocals, Vars, NonLocals1), + set.delete_list(LambdaGoalNonLocals, Vars, NonLocals1), % We need all the typeinfos, including the ones that are not used, % for the layout structure describing the closure. - NewTypeInfos = ExtraTypeInfos `set__difference` NonLocals1, - NonLocals = NonLocals1 `set__union` NewTypeInfos, + NewTypeInfos = ExtraTypeInfos `set.difference` NonLocals1, + NonLocals = NonLocals1 `set.union` NewTypeInfos, % If we added variables to the nonlocals of the lambda goal, then % we need to recompute the nonlocals for the procedure that contains it. - ( \+ set__empty(NewTypeInfos) -> + ( \+ set.empty(NewTypeInfos) -> MustRecomputeNonLocals = yes ; MustRecomputeNonLocals = MustRecomputeNonLocals0 ), - set__to_sorted_list(NonLocals, ArgVars1), + set.to_sorted_list(NonLocals, ArgVars1), ( % Optimize a special case: replace @@ -371,13 +370,13 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, LambdaGoal = call(PredId0, ProcId0, CallVars, _, _, _) - _, module_info_pred_proc_info(ModuleInfo0, PredId0, ProcId0, Call_PredInfo, Call_ProcInfo), - list__remove_suffix(CallVars, Vars, InitialVars), + list.remove_suffix(CallVars, Vars, InitialVars), % check that none of the variables that we're trying to % use as curried arguments are lambda-bound variables \+ ( - list__member(InitialVar, InitialVars), - list__member(InitialVar, Vars) + list.member(InitialVar, InitialVars), + list.member(InitialVar, Vars) ), % Check that the code models are compatible. Note that det is not @@ -389,7 +388,7 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, proc_info_interface_code_model(Call_ProcInfo, Call_CodeModel), determinism_to_code_model(Detism, CodeModel), module_info_get_globals(ModuleInfo0, Globals), - globals__lookup_bool_option(Globals, highlevel_code, HighLevelCode), + globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode), ( HighLevelCode = no, ( @@ -407,10 +406,10 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, % Check that the curried arguments are all input. proc_info_argmodes(Call_ProcInfo, Call_ArgModes), - list__length(InitialVars, NumInitialVars), - list__take(NumInitialVars, Call_ArgModes, CurriedArgModes), + list.length(InitialVars, NumInitialVars), + list.take(NumInitialVars, Call_ArgModes, CurriedArgModes), ( - list__member(Mode, CurriedArgModes) + list.member(Mode, CurriedArgModes) => mode_is_input(ModuleInfo0, Mode) ) @@ -418,7 +417,7 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, ArgVars = InitialVars, PredId = PredId0, ProcId = ProcId0, - mode_util__modes_to_uni_modes(ModuleInfo0, + mode_util.modes_to_uni_modes(ModuleInfo0, CurriedArgModes, CurriedArgModes, UniModes), % We must mark the procedure as having had its address taken. proc_info_set_address_taken(address_is_taken, @@ -432,12 +431,12 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, % arg types, determinism, context, status, etc. for the new predicate. ArgVars = put_typeinfo_vars_first(ArgVars1, VarTypes), - list__append(ArgVars, Vars, AllArgVars), + list.append(ArgVars, Vars, AllArgVars), module_info_get_name(ModuleInfo0, ModuleName), goal_info_get_context(LambdaGoalInfo, OrigContext), - term__context_file(OrigContext, OrigFile), - term__context_line(OrigContext, OrigLine), + term.context_file(OrigContext, OrigFile), + term.context_line(OrigContext, OrigLine), module_info_next_lambda_count(OrigContext, LambdaCount, ModuleInfo0, ModuleInfo1), make_pred_name_with_context(ModuleName, "IntroducedFrom", @@ -456,21 +455,21 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, % For the lambda var arguments at the end, we use the mode in the % lambda expression. - list__length(ArgVars, NumArgVars), + list.length(ArgVars, NumArgVars), in_mode(In), - list__duplicate(NumArgVars, In, InModes), - map__from_corresponding_lists(ArgVars, InModes, ArgModesMap), + list.duplicate(NumArgVars, In, InModes), + map.from_corresponding_lists(ArgVars, InModes, ArgModesMap), - map__from_corresponding_lists(OrigVars, OrigArgModes, OrigArgModesMap), - map__overlay(ArgModesMap, OrigArgModesMap, ArgModesMap1), - map__apply_to_list(ArgVars, ArgModesMap1, ArgModes1), + map.from_corresponding_lists(OrigVars, OrigArgModes, OrigArgModesMap), + map.overlay(ArgModesMap, OrigArgModesMap, ArgModesMap1), + map.apply_to_list(ArgVars, ArgModesMap1, ArgModes1), % Recompute the uni_modes. - mode_util__modes_to_uni_modes(ModuleInfo1, ArgModes1, ArgModes1, + mode_util.modes_to_uni_modes(ModuleInfo1, ArgModes1, ArgModes1, UniModes), - list__append(ArgModes1, Modes, AllArgModes), - map__apply_to_list(AllArgVars, VarTypes, ArgTypes), + list.append(ArgModes1, Modes, AllArgModes), + map.apply_to_list(AllArgVars, VarTypes, ArgTypes), purity_to_markers(Purity, LambdaMarkers), @@ -493,7 +492,7 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, MustRecomputeNonLocals0 = no, ProcInfo = ProcInfo1 ), - set__init(Assertions), + set.init(Assertions), pred_info_create(ModuleName, PredName, PredOrFunc, LambdaContext, lambda(OrigFile, OrigLine, LambdaCount), local, LambdaMarkers, ArgTypes, TVarSet, ExistQVars, Constraints, Assertions, @@ -521,13 +520,13 @@ process_lambda(Purity, PredOrFunc, EvalMethod, Vars, Modes, Detism, constraint_contains_vars(LambdaVars, ClassConstraint) :- ClassConstraint = constraint(_, ConstraintTypes), - list__map(prog_type__vars, ConstraintTypes, ConstraintVarsList), - list__condense(ConstraintVarsList, ConstraintVars), + list.map(prog_type.vars, ConstraintTypes, ConstraintVarsList), + list.condense(ConstraintVarsList, ConstraintVars), % Probably not the most efficient way of doing it, but I wouldn't think % that it matters. - set__list_to_set(LambdaVars, LambdaVarsSet), - set__list_to_set(ConstraintVars, ConstraintVarsSet), - set__subset(ConstraintVarsSet, LambdaVarsSet). + set.list_to_set(LambdaVars, LambdaVarsSet), + set.list_to_set(ConstraintVars, ConstraintVarsSet), + set.subset(ConstraintVarsSet, LambdaVarsSet). % This predicate works out the modes of the original non-local variables % of a lambda expression based on the list of uni_mode in the unify_info diff --git a/compiler/layout.m b/compiler/layout.m index 2dc57f238..3d1f4c715 100644 --- a/compiler/layout.m +++ b/compiler/layout.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2001-2005 The University of Melbourne. +% Copyright (C) 2001-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -31,7 +31,7 @@ % %-----------------------------------------------------------------------------% -:- module ll_backend__layout. +:- module ll_backend.layout. :- interface. :- import_module hlds.hlds_pred. diff --git a/compiler/layout_out.m b/compiler/layout_out.m index 08a9e0489..290df4826 100644 --- a/compiler/layout_out.m +++ b/compiler/layout_out.m @@ -20,7 +20,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__layout_out. +:- module ll_backend.layout_out. :- interface. :- import_module ll_backend.layout. @@ -153,7 +153,7 @@ output_layout_data_defn(table_gen_data(RttiProcLabel, NumInputs, NumOutputs, output_layout_name_decl(LayoutName, !IO) :- output_layout_name_storage_type_name(LayoutName, no, !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). output_maybe_layout_name_decl(LayoutName, !DeclSet, !IO) :- ( decl_set_is_member(data_addr(layout_addr(LayoutName)), !.DeclSet) -> @@ -201,7 +201,7 @@ output_layout_decl(LayoutName, !DeclSet, !IO) :- true ; output_layout_name_storage_type_name(LayoutName, no, !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet) ). @@ -212,7 +212,7 @@ make_label_layout_name(Label) = Name :- % to make the MR_init_label_sl macro delete that prefix from the % label's name to get the name of its layout structure. LabelName = label_to_c_string(Label, yes), - string__append_list([ + string.append_list([ mercury_data_prefix, "_label_layout__", LabelName @@ -220,123 +220,123 @@ make_label_layout_name(Label) = Name :- output_layout_name(label_layout(ProcLabel, LabelNum, _), !IO) :- % This code should be kept in sync with make_label_layout_name/1 above. - io__write_string(mercury_data_prefix, !IO), - io__write_string("_label_layout__", !IO), - io__write_string(label_to_c_string(internal(LabelNum, ProcLabel), yes), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_label_layout__", !IO), + io.write_string(label_to_c_string(internal(LabelNum, ProcLabel), yes), !IO). output_layout_name(proc_layout(RttiProcLabel, _), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_proc_layout__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_proc_layout__", !IO), % We can't omit the mercury_ prefix on ProcLabel, even though the % mercury_data_prefix duplicates it, because there is no simply way % to make the MR_init_entryl_sl macro delete that prefix from the % entry label's name to get the name of its layout structure. output_proc_label(make_proc_label_from_rtti(RttiProcLabel), yes, !IO). output_layout_name(proc_layout_exec_trace(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_proc_layout_exec_trace__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_proc_layout_exec_trace__", !IO), output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO). output_layout_name(proc_layout_head_var_nums(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_head_var_nums__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_head_var_nums__", !IO), output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO). output_layout_name(proc_layout_var_names(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_var_names__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_var_names__", !IO), output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO). output_layout_name(proc_layout_body_bytecode(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_body_bytecode__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_body_bytecode__", !IO), output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO). output_layout_name(closure_proc_id(CallerProcLabel, SeqNo, _), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_closure_layout__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_closure_layout__", !IO), output_proc_label(CallerProcLabel, no, !IO), - io__write_string("_", !IO), - io__write_int(SeqNo, !IO). + io.write_string("_", !IO), + io.write_int(SeqNo, !IO). output_layout_name(file_layout(ModuleName, FileNum), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_file_layout__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_file_layout__", !IO), ModuleNameStr = sym_name_mangle(ModuleName), - io__write_string(ModuleNameStr, !IO), - io__write_string("_", !IO), - io__write_int(FileNum, !IO). + io.write_string(ModuleNameStr, !IO), + io.write_string("_", !IO), + io.write_int(FileNum, !IO). output_layout_name(file_layout_line_number_vector(ModuleName, FileNum), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_file_lines__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_file_lines__", !IO), ModuleNameStr = sym_name_mangle(ModuleName), - io__write_string(ModuleNameStr, !IO), - io__write_string("_", !IO), - io__write_int(FileNum, !IO). + io.write_string(ModuleNameStr, !IO), + io.write_string("_", !IO), + io.write_int(FileNum, !IO). output_layout_name(file_layout_label_layout_vector(ModuleName, FileNum), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_file_label_layouts__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_file_label_layouts__", !IO), ModuleNameStr = sym_name_mangle(ModuleName), - io__write_string(ModuleNameStr, !IO), - io__write_string("_", !IO), - io__write_int(FileNum, !IO). + io.write_string(ModuleNameStr, !IO), + io.write_string("_", !IO), + io.write_int(FileNum, !IO). output_layout_name(module_layout_string_table(ModuleName), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_module_strings__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_module_strings__", !IO), ModuleNameStr = sym_name_mangle(ModuleName), - io__write_string(ModuleNameStr, !IO). + io.write_string(ModuleNameStr, !IO). output_layout_name(module_layout_file_vector(ModuleName), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_module_files__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_module_files__", !IO), ModuleNameStr = sym_name_mangle(ModuleName), - io__write_string(ModuleNameStr, !IO). + io.write_string(ModuleNameStr, !IO). output_layout_name(module_layout_proc_vector(ModuleName), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_module_procs__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_module_procs__", !IO), ModuleNameStr = sym_name_mangle(ModuleName), - io__write_string(ModuleNameStr, !IO). + io.write_string(ModuleNameStr, !IO). output_layout_name(module_layout_label_exec_count(ModuleName, _), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_module_label_exec_counts__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_module_label_exec_counts__", !IO), ModuleNameStr = sym_name_mangle(ModuleName), - io__write_string(ModuleNameStr, !IO). + io.write_string(ModuleNameStr, !IO). output_layout_name(module_layout(ModuleName), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_module_layout__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_module_layout__", !IO), ModuleNameStr = sym_name_mangle(ModuleName), - io__write_string(ModuleNameStr, !IO). + io.write_string(ModuleNameStr, !IO). output_layout_name(proc_static(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_proc_static__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_proc_static__", !IO), ProcLabel = make_proc_label_from_rtti(RttiProcLabel), output_proc_label(ProcLabel, no, !IO). output_layout_name(proc_static_call_sites(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_proc_static_call_sites__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_proc_static_call_sites__", !IO), ProcLabel = make_proc_label_from_rtti(RttiProcLabel), output_proc_label(ProcLabel, no, !IO). output_layout_name(table_io_decl(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_table_io_decl__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_table_io_decl__", !IO), ProcLabel = make_proc_label_from_rtti(RttiProcLabel), output_proc_label(ProcLabel, no, !IO). output_layout_name(table_gen_info(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_table_gen__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_table_gen__", !IO), ProcLabel = make_proc_label_from_rtti(RttiProcLabel), output_proc_label(ProcLabel, no, !IO). output_layout_name(table_gen_enum_params(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_table_enum_params__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_table_enum_params__", !IO), ProcLabel = make_proc_label_from_rtti(RttiProcLabel), output_proc_label(ProcLabel, no, !IO). output_layout_name(table_gen_steps(RttiProcLabel), !IO) :- - io__write_string(mercury_data_prefix, !IO), - io__write_string("_table_steps__", !IO), + io.write_string(mercury_data_prefix, !IO), + io.write_string("_table_steps__", !IO), ProcLabel = make_proc_label_from_rtti(RttiProcLabel), output_proc_label(ProcLabel, no, !IO). output_layout_name_storage_type_name( label_layout(ProcLabel, LabelNum, LabelVars), _BeingDefined, !IO) :- - io__write_string("static const ", !IO), - io__write_string(label_vars_to_type(LabelVars), !IO), - io__write_string(" ", !IO), + io.write_string("static const ", !IO), + io.write_string(label_vars_to_type(LabelVars), !IO), + io.write_string(" ", !IO), output_layout_name(label_layout(ProcLabel, LabelNum, LabelVars), !IO). output_layout_name_storage_type_name(proc_layout(ProcLabel, Kind), BeingDefined, !IO) :- @@ -346,123 +346,123 @@ output_layout_name_storage_type_name(proc_layout(ProcLabel, Kind), ProcIsImported = no, ProcIsExported = no -> - io__write_string("static ", !IO) + io.write_string("static ", !IO) ; ( BeingDefined = yes ; BeingDefined = no, - io__write_string("extern ", !IO) + io.write_string("extern ", !IO) ) ), - io__write_string("const ", !IO), - io__write_string(proc_layout_kind_to_type(Kind), !IO), - io__write_string(" ", !IO), + io.write_string("const ", !IO), + io.write_string(proc_layout_kind_to_type(Kind), !IO), + io.write_string(" ", !IO), output_layout_name(proc_layout(ProcLabel, Kind), !IO). output_layout_name_storage_type_name(proc_layout_exec_trace(ProcLabel), _BeingDefined, !IO) :- - io__write_string("static MR_STATIC_CODE_CONST MR_Exec_Trace\n\t", !IO), + io.write_string("static MR_STATIC_CODE_CONST MR_Exec_Trace\n\t", !IO), output_layout_name(proc_layout_exec_trace(ProcLabel), !IO). output_layout_name_storage_type_name(proc_layout_head_var_nums(ProcLabel), _BeingDefined, !IO) :- - io__write_string("static const ", !IO), - io__write_string("MR_uint_least16_t ", !IO), + io.write_string("static const ", !IO), + io.write_string("MR_uint_least16_t ", !IO), output_layout_name(proc_layout_head_var_nums(ProcLabel), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(proc_layout_var_names(ProcLabel), _BeingDefined, !IO) :- - io__write_string("static const ", !IO), - io__write_string("MR_uint_least32_t ", !IO), + io.write_string("static const ", !IO), + io.write_string("MR_uint_least32_t ", !IO), output_layout_name(proc_layout_var_names(ProcLabel), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(proc_layout_body_bytecode(ProcLabel), _BeingDefined, !IO) :- - io__write_string("static const ", !IO), - io__write_string("MR_uint_least8_t ", !IO), + io.write_string("static const ", !IO), + io.write_string("MR_uint_least8_t ", !IO), output_layout_name(proc_layout_body_bytecode(ProcLabel), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel), _BeingDefined, !IO) :- - io__write_string("static const ", !IO), + io.write_string("static const ", !IO), ( ClosureProcLabel = proc(_, _, _, _, _, _), - io__write_string("MR_User_Closure_Id\n", !IO) + io.write_string("MR_User_Closure_Id\n", !IO) ; ClosureProcLabel = special_proc(_, _, _, _, _, _), - io__write_string("MR_UCI_Closure_Id\n", !IO) + io.write_string("MR_UCI_Closure_Id\n", !IO) ), output_layout_name(closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel), !IO). output_layout_name_storage_type_name(file_layout(ModuleName, FileNum), _BeingDefined, !IO) :- - io__write_string("static const MR_Module_File_Layout ", !IO), + io.write_string("static const MR_Module_File_Layout ", !IO), output_layout_name(file_layout(ModuleName, FileNum), !IO). output_layout_name_storage_type_name(file_layout_line_number_vector( ModuleName, FileNum), _BeingDefined, !IO) :- - io__write_string("static const MR_int_least16_t ", !IO), + io.write_string("static const MR_int_least16_t ", !IO), output_layout_name( file_layout_line_number_vector(ModuleName, FileNum), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(file_layout_label_layout_vector( ModuleName, FileNum), _BeingDefined, !IO) :- - io__write_string("static const MR_Label_Layout *", !IO), + io.write_string("static const MR_Label_Layout *", !IO), output_layout_name( file_layout_label_layout_vector(ModuleName, FileNum), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(module_layout_string_table(ModuleName), _BeingDefined, !IO) :- - io__write_string("static const char ", !IO), + io.write_string("static const char ", !IO), output_layout_name(module_layout_string_table(ModuleName), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(module_layout_file_vector(ModuleName), _BeingDefined, !IO) :- - io__write_string("static const MR_Module_File_Layout *", !IO), + io.write_string("static const MR_Module_File_Layout *", !IO), output_layout_name(module_layout_file_vector(ModuleName), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(module_layout_label_exec_count( ModuleName, NumElements), _BeingDefined, !IO) :- - io__write_string("static MR_Unsigned ", !IO), + io.write_string("static MR_Unsigned ", !IO), output_layout_name( module_layout_label_exec_count(ModuleName, NumElements), !IO), - io__write_string("[", !IO), - io__write_int(NumElements, !IO), - io__write_string("]", !IO). + io.write_string("[", !IO), + io.write_int(NumElements, !IO), + io.write_string("]", !IO). output_layout_name_storage_type_name(module_layout_proc_vector(ModuleName), _BeingDefined, !IO) :- - io__write_string("static const MR_Proc_Layout *", !IO), + io.write_string("static const MR_Proc_Layout *", !IO), output_layout_name(module_layout_proc_vector(ModuleName), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(module_layout(ModuleName), _BeingDefined, !IO) :- - io__write_string("static const MR_Module_Layout ", !IO), + io.write_string("static const MR_Module_Layout ", !IO), output_layout_name(module_layout(ModuleName), !IO). output_layout_name_storage_type_name(proc_static(RttiProcLabel), _BeingDefined, !IO) :- - io__write_string("static MR_ProcStatic ", !IO), + io.write_string("static MR_ProcStatic ", !IO), output_layout_name(proc_static(RttiProcLabel), !IO). output_layout_name_storage_type_name(proc_static_call_sites(RttiProcLabel), _BeingDefined, !IO) :- - io__write_string("static const MR_CallSiteStatic ", !IO), + io.write_string("static const MR_CallSiteStatic ", !IO), output_layout_name(proc_static_call_sites(RttiProcLabel), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(table_io_decl(RttiProcLabel), _BeingDefined, !IO) :- - io__write_string("static const MR_Table_Io_Decl ", !IO), + io.write_string("static const MR_Table_Io_Decl ", !IO), output_layout_name(table_io_decl(RttiProcLabel), !IO). output_layout_name_storage_type_name(table_gen_info(RttiProcLabel), _BeingDefined, !IO) :- - io__write_string("static const MR_Table_Gen ", !IO), + io.write_string("static const MR_Table_Gen ", !IO), output_layout_name(table_gen_info(RttiProcLabel), !IO). output_layout_name_storage_type_name(table_gen_enum_params(RttiProcLabel), _BeingDefined, !IO) :- - io__write_string("static const MR_Integer ", !IO), + io.write_string("static const MR_Integer ", !IO), output_layout_name(table_gen_enum_params(RttiProcLabel), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). output_layout_name_storage_type_name(table_gen_steps(RttiProcLabel), _BeingDefined, !IO) :- - io__write_string("static const MR_Table_Trie_Step ", !IO), + io.write_string("static const MR_Table_Trie_Step ", !IO), output_layout_name(table_gen_steps(RttiProcLabel), !IO), - io__write_string("[]", !IO). + io.write_string("[]", !IO). layout_name_would_include_code_addr(label_layout(_, _, _)) = no. layout_name_would_include_code_addr(proc_layout(_, _)) = no. @@ -512,11 +512,11 @@ proc_layout_kind_to_type(proc_layout_proc_id(uci)) = io::di, io::uo) is det. output_rval_or_num_or_none(rval(Rval), !IO) :- - io__write_string(", ", !IO), + io.write_string(", ", !IO), output_rval_as_addr(Rval, !IO). output_rval_or_num_or_none(num(Num), !IO) :- - io__write_string(", ", !IO), - io__write_int(Num, !IO). + io.write_string(", ", !IO), + io.write_int(Num, !IO). output_rval_or_num_or_none(none, !IO). :- pred output_label_layout_data_defn(proc_label::in, int::in, layout_name::in, @@ -590,42 +590,42 @@ output_label_layout_data_defn(ProcLabel, LabelNum, ProcLayoutAddr, MaybePort, MaybeVarInfoTuple = no ), LayoutName = label_layout(ProcLabel, LabelNum, LabelVars), - io__write_string("\n", !IO), - io__write_string(Macro, !IO), - io__write_string("(", !IO), + io.write_string("\n", !IO), + io.write_string(Macro, !IO), + io.write_string("(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(",\n", !IO), - io__write_int(LabelNum, !IO), - io__write_string(", ", !IO), + io.write_string(",\n", !IO), + io.write_int(LabelNum, !IO), + io.write_string(", ", !IO), ( MaybePort = yes(Port), - io__write_string(trace_port_to_string(Port), !IO) + io.write_string(trace_port_to_string(Port), !IO) ; MaybePort = no, - io__write_string("NONE", !IO) + io.write_string("NONE", !IO) ), - io__write_string(", ", !IO), - io__write_int(LabelNumberInModule, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), + io.write_int(LabelNumberInModule, !IO), + io.write_string(", ", !IO), ( MaybeGoalPath = yes(GoalPath), - io__write_int(GoalPath, !IO) + io.write_int(GoalPath, !IO) ; MaybeGoalPath = no, - io__write_string("0", !IO) + io.write_string("0", !IO) ), ( MaybeVarInfoTuple = yes({EncodedVarCount, LocnsTypes, VarNums, TypeParams}), - io__write_string(", ", !IO), - io__write_int(EncodedVarCount, !IO), + io.write_string(", ", !IO), + io.write_int(EncodedVarCount, !IO), output_rval_or_num_or_none(LocnsTypes, !IO), output_rval_or_num_or_none(VarNums, !IO), output_rval_or_num_or_none(TypeParams, !IO) ; MaybeVarInfoTuple = no ), - io__write_string(");\n", !IO), + io.write_string(");\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). % Output the rval in a context in which it is immediately cast to an @@ -635,12 +635,12 @@ output_label_layout_data_defn(ProcLabel, LabelNum, ProcLayoutAddr, MaybePort, output_rval_as_addr(Rval, !IO) :- ( Rval = const(int_const(0)) -> - io__write_string(" 0", !IO) + io.write_string(" 0", !IO) ; Rval = const(data_addr_const(DataAddr, no)) -> - io__write_string(" &", !IO), + io.write_string(" &", !IO), output_data_addr(DataAddr, !IO) ; - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_rval(Rval, !IO) ). @@ -710,21 +710,21 @@ output_proc_layout_data_defn(RttiProcLabel, Traversal, MaybeRest, output_layout_proc_id_group(ProcLabel, Origin, !IO), ( MaybeExecTrace = no, - io__write_string("NULL,\n", !IO) + io.write_string("NULL,\n", !IO) ; MaybeExecTrace = yes(_), - io__write_string("&", !IO), + io.write_string("&", !IO), output_layout_name(proc_layout_exec_trace(RttiProcLabel), !IO), - io__write_string(",\n", !IO) + io.write_string(",\n", !IO) ), ( MaybeProcStatic = no, - io__write_string("NULL\n", !IO) + io.write_string("NULL\n", !IO) ; MaybeProcStatic = yes(_), - io__write_string("&", !IO), + io.write_string("&", !IO), output_layout_name(proc_static(RttiProcLabel), !IO), - io__write_string("\n", !IO) + io.write_string("\n", !IO) ), output_proc_layout_data_defn_end(!IO) ), @@ -751,16 +751,16 @@ proc_label_user_or_uci(special_proc(_, _, _, _, _, _)) = uci. io::di, io::uo) is det. output_proc_layout_data_defn_start(RttiProcLabel, Kind, Traversal, !IO) :- - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(proc_layout(RttiProcLabel, Kind), yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_layout_traversal_group(Traversal, !IO). :- pred output_proc_layout_data_defn_end(io::di, io::uo) is det. output_proc_layout_data_defn_end(!IO) :- - io__write_string("};\n", !IO). + io.write_string("};\n", !IO). :- pred output_layout_traversal_decls(proc_layout_stack_traversal::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -781,7 +781,7 @@ output_layout_traversal_decls(Traversal, !DeclSet, !IO) :- output_layout_traversal_group(Traversal, !IO) :- Traversal = proc_layout_stack_traversal(MaybeEntryLabel, MaybeSuccipSlot, StackSlotCount, Detism), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), ( MaybeEntryLabel = yes(EntryLabel), output_code_addr(label(EntryLabel), !IO) @@ -789,21 +789,21 @@ output_layout_traversal_group(Traversal, !IO) :- MaybeEntryLabel = no, % The actual code address will be put into the structure % by module initialization code. - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), ( MaybeSuccipSlot = yes(SuccipSlot), - io__write_int(SuccipSlot, !IO) + io.write_int(SuccipSlot, !IO) ; MaybeSuccipSlot = no, - io__write_int(-1, !IO) + io.write_int(-1, !IO) ), - io__write_string(",\n", !IO), - io__write_int(StackSlotCount, !IO), - io__write_string(",\n", !IO), - io__write_string(detism_to_c_detism(Detism), !IO), - io__write_string("\n},\n", !IO). + io.write_string(",\n", !IO), + io.write_int(StackSlotCount, !IO), + io.write_string(",\n", !IO), + io.write_string(detism_to_c_detism(Detism), !IO), + io.write_string("\n},\n", !IO). :- func detism_to_c_detism(determinism) = string. @@ -820,14 +820,14 @@ detism_to_c_detism(cc_multidet) = "MR_DETISM_CCMULTI". io::di, io::uo) is det. output_layout_proc_id_group(ProcLabel, Origin, !IO) :- - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), output_proc_id(ProcLabel, Origin, !IO), - io__write_string("},\n", !IO). + io.write_string("},\n", !IO). :- pred output_layout_no_proc_id_group(io::di, io::uo) is det. output_layout_no_proc_id_group(!IO) :- - io__write_string("-1\n", !IO). + io.write_string("-1\n", !IO). :- pred output_layout_exec_trace_decls(rtti_proc_label::in, proc_layout_exec_trace::in, decl_set::in, decl_set::out, @@ -875,11 +875,11 @@ output_bytecodes(Bytes, BytesLeft, !.Seq, MaxSeq, !IO) :- ; Bytes = [Head | Tail], ( !.Seq < MaxSeq -> - io__write_int(Head, !IO), - io__write_char(',', !IO), + io.write_int(Head, !IO), + io.write_char(',', !IO), !:Seq = !.Seq + 1, ( unchecked_rem(!.Seq, 16) = 0 -> - io__write_char('\n', !IO) + io.write_char('\n', !IO) ; true ), @@ -902,86 +902,86 @@ output_layout_exec_trace(RttiProcLabel, ExecTrace, !DeclSet, !IO) :- ProcBodyBytes = [] ; ProcBodyBytes = [_ | _], - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name( proc_layout_body_bytecode(RttiProcLabel), yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_bytecodes_driver(ProcBodyBytes, !IO), - io__write_string("};\n", !IO) + io.write_string("};\n", !IO) ), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name( proc_layout_exec_trace(RttiProcLabel), yes, !IO), - io__write_string(" = {\nMR_LABEL_LAYOUT_REF(", !IO), + io.write_string(" = {\nMR_LABEL_LAYOUT_REF(", !IO), ( CallLabelLayout = label_layout(CallProcLabel, CallLabelNum, _) -> output_label(internal(CallLabelNum, CallProcLabel), no, !IO) ; unexpected(this_file, "output_layout_exec_trace: bad call layout") ), - io__write_string("),\n(const MR_Module_Layout *) &", !IO), + io.write_string("),\n(const MR_Module_Layout *) &", !IO), ProcLabel = make_proc_label_from_rtti(RttiProcLabel), ModuleName = get_defining_module_name(ProcLabel), output_layout_name(module_layout(ModuleName), !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), ( ProcBodyBytes = [], - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ; ProcBodyBytes = [_ | _], output_layout_name(proc_layout_body_bytecode(RttiProcLabel), !IO) ), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), ( MaybeCallTableSlot = yes(_), - io__write_string("&", !IO), + io.write_string("&", !IO), output_tabling_pointer_var_name(ProcLabel, !IO) ; MaybeCallTableSlot = no, - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ), - io__write_string(",\n{ ", !IO), + io.write_string(",\n{ ", !IO), ( MaybeTableInfo = yes(TableInfo), - io__write_string("(const void *) &", !IO), + io.write_string("(const void *) &", !IO), output_layout_name(TableInfo, !IO) ; MaybeTableInfo = no, - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ), - io__write_string(" },\n", !IO), + io.write_string(" },\n", !IO), output_layout_name(proc_layout_head_var_nums(RttiProcLabel), !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_layout_name(proc_layout_var_names(RttiProcLabel), !IO), - io__write_string(",\n", !IO), - io__write_int(list__length(HeadVarNums), !IO), - io__write_string(",\n", !IO), - io__write_int(MaxVarNum, !IO), - io__write_string(",\n", !IO), - io__write_int(MaxRegNum, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + io.write_int(list.length(HeadVarNums), !IO), + io.write_string(",\n", !IO), + io.write_int(MaxVarNum, !IO), + io.write_string(",\n", !IO), + io.write_int(MaxRegNum, !IO), + io.write_string(",\n", !IO), write_maybe_slot_num(MaybeFromFullSlot, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), write_maybe_slot_num(MaybeIoSeqSlot, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), write_maybe_slot_num(MaybeTrailSlot, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), write_maybe_slot_num(MaybeMaxfrSlot, !IO), - io__write_string(",\n", !IO), - io__write_string(eval_method_to_c_string(EvalMethod), !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + io.write_string(eval_method_to_c_string(EvalMethod), !IO), + io.write_string(",\n", !IO), write_maybe_slot_num(MaybeCallTableSlot, !IO), - io__write_string(",\n", !IO), - io__write_string(trace_level_rep(EffTraceLevel), !IO), - io__write_string(",\n", !IO), - io__write_int(Flags, !IO), - io__write_string("\n};\n", !IO). + io.write_string(",\n", !IO), + io.write_string(trace_level_rep(EffTraceLevel), !IO), + io.write_string(",\n", !IO), + io.write_int(Flags, !IO), + io.write_string("\n};\n", !IO). :- pred write_maybe_slot_num(maybe(int)::in, io::di, io::uo) is det. write_maybe_slot_num(yes(SlotNum), !IO) :- - io__write_int(SlotNum, !IO). + io.write_int(SlotNum, !IO). write_maybe_slot_num(no, !IO) :- - io__write_int(-1, !IO). + io.write_int(-1, !IO). :- func eval_method_to_c_string(eval_method) = string. @@ -1029,20 +1029,20 @@ eval_method_to_c_string(eval_table_io(Decl, Unitize)) = Str :- decl_set::in, decl_set::out, io::di, io::uo) is det. output_proc_layout_head_var_nums(ProcLabel, HeadVarNums, !DeclSet, !IO) :- - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(proc_layout_head_var_nums(ProcLabel), yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), ( HeadVarNums = [], % ANSI/ISO C doesn't allow empty arrays, so place a dummy value % in the array. - io__write_string("0\n", !IO) + io.write_string("0\n", !IO) ; HeadVarNums = [_ | _], - list__foldl(output_number_in_vector, HeadVarNums, !IO) + list.foldl(output_number_in_vector, HeadVarNums, !IO) ), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr( layout_addr(proc_layout_head_var_nums(ProcLabel))), !DeclSet). @@ -1050,23 +1050,23 @@ output_proc_layout_head_var_nums(ProcLabel, HeadVarNums, !DeclSet, !IO) :- int::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_proc_layout_var_names(ProcLabel, VarNames, MaxVarNum, !DeclSet, !IO) :- - list__length(VarNames, VarNameCount), + list.length(VarNames, VarNameCount), expect(unify(VarNameCount, MaxVarNum), this_file, "output_proc_layout_var_names: VarNameCount != MaxVarNum"), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(proc_layout_var_names(ProcLabel), yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), ( VarNames = [], % ANSI/ISO C doesn't allow empty arrays, so place a dummy value % in the array. - io__write_string("0\n", !IO) + io.write_string("0\n", !IO) ; VarNames = [_ | _], - list__foldl(output_number_in_vector, VarNames, !IO) + list.foldl(output_number_in_vector, VarNames, !IO) ), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(proc_layout_var_names(ProcLabel))), !DeclSet). @@ -1079,21 +1079,21 @@ output_proc_layout_var_names(ProcLabel, VarNames, MaxVarNum, !DeclSet, !IO) :- output_closure_proc_id_data_defn(CallerProcLabel, SeqNo, ClosureProcLabel, ModuleName, FileName, LineNumber, PredOrigin, GoalPath, !DeclSet, !IO) :- - io__write_string("\n", !IO), + io.write_string("\n", !IO), LayoutName = closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n{\n", !IO), + io.write_string(" = {\n{\n", !IO), output_proc_id(ClosureProcLabel, PredOrigin, !IO), - io__write_string("},\n", !IO), - mdbcomp__prim_data__sym_name_to_string(ModuleName, ModuleNameStr), + io.write_string("},\n", !IO), + sym_name_to_string(ModuleName, ModuleNameStr), quote_and_write_string(ModuleNameStr, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), quote_and_write_string(FileName, !IO), - io__write_string(",\n", !IO), - io__write_int(LineNumber, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + io.write_int(LineNumber, !IO), + io.write_string(",\n", !IO), quote_and_write_string(GoalPath, !IO), - io__write_string("\n};\n", !IO), + io.write_string("\n};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred output_proc_id(proc_label::in, pred_origin::in, io::di, io::uo) is det. @@ -1106,17 +1106,17 @@ output_proc_id(ProcLabel, Origin, !IO) :- sym_name_to_string(DefiningModule, DefiningModuleStr), sym_name_to_string(DeclaringModule, DeclaringModuleStr), output_pred_or_func(PredOrFunc, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), quote_and_write_string(DeclaringModuleStr, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), quote_and_write_string(DefiningModuleStr, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), quote_and_write_string(PredName, !IO), - io__write_string(",\n", !IO), - io__write_int(Arity, !IO), - io__write_string(",\n", !IO), - io__write_int(Mode, !IO), - io__write_string("\n", !IO) + io.write_string(",\n", !IO), + io.write_int(Arity, !IO), + io.write_string(",\n", !IO), + io.write_int(Mode, !IO), + io.write_string("\n", !IO) ; ProcLabel = special_proc(DefiningModule, SpecialPredId, TypeModule, TypeName, TypeArity, Mode), @@ -1126,17 +1126,17 @@ output_proc_id(ProcLabel, Origin, !IO) :- sym_name_to_string(DefiningModule, DefiningModuleStr), sym_name_to_string(TypeModule, TypeModuleStr), quote_and_write_string(TypeName, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), quote_and_write_string(TypeModuleStr, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), quote_and_write_string(DefiningModuleStr, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), quote_and_write_string(PredName, !IO), - io__write_string(",\n", !IO), - io__write_int(TypeArity, !IO), - io__write_string(",\n", !IO), - io__write_int(Mode, !IO), - io__write_string("\n", !IO) + io.write_string(",\n", !IO), + io.write_int(TypeArity, !IO), + io.write_string(",\n", !IO), + io.write_int(Mode, !IO), + io.write_string("\n", !IO) ). :- func origin_name(pred_origin, string) = string. @@ -1144,13 +1144,13 @@ output_proc_id(ProcLabel, Origin, !IO) :- origin_name(Origin, Name0) = Name :- ( Origin = lambda(FileName0, LineNum, SeqNo), - ( string__append("IntroducedFrom", _, Name0) -> - string__replace_all(FileName0, ".", "_", FileName), + ( string.append("IntroducedFrom", _, Name0) -> + string.replace_all(FileName0, ".", "_", FileName), ( SeqNo > 1 -> - string__format("lambda%d_%s_%d", + string.format("lambda%d_%s_%d", [i(SeqNo), s(FileName), i(LineNum)], Name) ; - string__format("lambda_%s_%d", [s(FileName), i(LineNum)], Name) + string.format("lambda_%s_%d", [s(FileName), i(LineNum)], Name) ) ; % If the lambda pred has a meaningful name, use it. @@ -1179,7 +1179,7 @@ origin_name(Origin, Name0) = Name :- % ), % TypeCtor = TypeSymName - TypeArity, % TypeName = sym_name_to_string(TypeSymName), -% string__format("%s_for_%s_%d", +% string.format("%s_for_%s_%d", % [s(SpecialName), s(TypeName), i(TypeArity)], Name) ; Origin = transformed(Transform, OldOrigin, _), @@ -1210,11 +1210,11 @@ pred_transform_name(higher_order_specialization(Seq)) = pred_transform_name(higher_order_type_specialization(Proc)) = "hoproc" ++ int_to_string(Proc). pred_transform_name(type_specialization(Substs)) = - string__join_list("_", list__map(subst_to_name, Substs)). + string.join_list("_", list.map(subst_to_name, Substs)). pred_transform_name(unused_argument_elimination(Posns)) = "ua_" ++ - string__join_list("_", list__map(int_to_string, Posns)). + string.join_list("_", list.map(int_to_string, Posns)). pred_transform_name(accumulator(Posns)) = "acc_" ++ - string__join_list("_", list__map(int_to_string, Posns)). + string.join_list("_", list.map(int_to_string, Posns)). pred_transform_name(loop_invariant(Proc)) = "inv_" ++ int_to_string(Proc). pred_transform_name(tuple(Proc)) = "tup_" ++ int_to_string(Proc). pred_transform_name(untuple(Proc)) = "untup_" ++ int_to_string(Proc). @@ -1232,8 +1232,8 @@ ints_to_string([N | Ns]) = "_" ++ int_to_string(N) ++ ints_to_string(Ns). :- func subst_to_name(pair(int, mer_type)) = string. subst_to_name(TVar - Type) = - string__format("%d/%s", - [i(TVar), s(mercury_type_to_string(varset__init, no, Type))]). + string.format("%d/%s", + [i(TVar), s(mercury_type_to_string(varset.init, no, Type))]). %-----------------------------------------------------------------------------% @@ -1254,43 +1254,43 @@ output_module_layout_data_defn(ModuleName, StringTableSize, StringTable, output_file_layout_vector_data_defn(ModuleName, FileLayoutNames, FileVectorName, !DeclSet, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), LabelExecCountName = module_layout_label_exec_count(ModuleName, NumLabels), output_layout_name_storage_type_name(LabelExecCountName, yes, !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), decl_set_insert(data_addr(layout_addr(LabelExecCountName)), !DeclSet), ModuleLayoutName = module_layout(ModuleName), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(ModuleLayoutName, yes, !IO), - io__write_string(" = {\n", !IO), - mdbcomp__prim_data__sym_name_to_string(ModuleName, ModuleNameStr), + io.write_string(" = {\n", !IO), + sym_name_to_string(ModuleName, ModuleNameStr), quote_and_write_string(ModuleNameStr, !IO), - io__write_string(",\n", !IO), - io__write_int(StringTableSize, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + io.write_int(StringTableSize, !IO), + io.write_string(",\n", !IO), ModuleStringTableName = module_layout_string_table(ModuleName), output_layout_name(ModuleStringTableName, !IO), - io__write_string(",\n", !IO), - list__length(ProcLayoutNames, ProcLayoutVectorLength), - io__write_int(ProcLayoutVectorLength, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + list.length(ProcLayoutNames, ProcLayoutVectorLength), + io.write_int(ProcLayoutVectorLength, !IO), + io.write_string(",\n", !IO), output_layout_name(ProcVectorName, !IO), - io__write_string(",\n", !IO), - list__length(FileLayouts, FileLayoutVectorLength), - io__write_int(FileLayoutVectorLength, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + list.length(FileLayouts, FileLayoutVectorLength), + io.write_int(FileLayoutVectorLength, !IO), + io.write_string(",\n", !IO), output_layout_name(FileVectorName, !IO), - io__write_string(",\n", !IO), - io__write_string(trace_level_rep(TraceLevel), !IO), - io__write_string(",\n", !IO), - io__write_int(SuppressedEvents, !IO), - io__write_string(",\n", !IO), - io__write_int(NumLabels, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + io.write_string(trace_level_rep(TraceLevel), !IO), + io.write_string(",\n", !IO), + io.write_int(SuppressedEvents, !IO), + io.write_string(",\n", !IO), + io.write_int(NumLabels, !IO), + io.write_string(",\n", !IO), output_layout_name(LabelExecCountName, !IO), - io__write_string("\n};\n", !IO), + io.write_string("\n};\n", !IO), decl_set_insert(data_addr(layout_addr(ModuleLayoutName)), !DeclSet). :- pred output_module_layout_proc_vector_defn(module_name::in, @@ -1299,21 +1299,21 @@ output_module_layout_data_defn(ModuleName, StringTableSize, StringTable, output_module_layout_proc_vector_defn(ModuleName, ProcLayoutNames, VectorName, !DeclSet, !IO) :- - list__foldl2(output_layout_decl, ProcLayoutNames, !DeclSet, !IO), + list.foldl2(output_layout_decl, ProcLayoutNames, !DeclSet, !IO), VectorName = module_layout_proc_vector(ModuleName), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(VectorName, yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), ( ProcLayoutNames = [], % ANSI/ISO C doesn't allow empty arrays, so place a dummy value % in the array. - io__write_string("NULL\n", !IO) + io.write_string("NULL\n", !IO) ; ProcLayoutNames = [_ | _], - list__foldl(output_proc_layout_name_in_vector, ProcLayoutNames, !IO) + list.foldl(output_proc_layout_name_in_vector, ProcLayoutNames, !IO) ), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(VectorName)), !DeclSet). :- pred output_proc_layout_name_in_vector(layout_name::in, io::di, io::uo) @@ -1322,9 +1322,9 @@ output_module_layout_proc_vector_defn(ModuleName, ProcLayoutNames, output_proc_layout_name_in_vector(LayoutName, !IO) :- ( LayoutName = proc_layout(RttiProcLabel, _) -> ProcLabel = make_proc_label_from_rtti(RttiProcLabel), - io__write_string("MR_PROC_LAYOUT1(", !IO), + io.write_string("MR_PROC_LAYOUT1(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(")\n", !IO) + io.write_string(")\n", !IO) ; unexpected(this_file, "output_proc_layout_name_in_vector: not proc layout") @@ -1342,12 +1342,12 @@ output_proc_layout_name_in_vector(LayoutName, !IO) :- output_module_string_table(ModuleName, StringTableSize, StringTable, !DeclSet, !IO) :- TableName = module_layout_string_table(ModuleName), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(TableName, yes, !IO), - io__write_string(" = {", !IO), + io.write_string(" = {", !IO), output_module_string_table_chars_driver(0, StringTableSize - 1, StringTable, !IO), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(TableName)), !DeclSet). % The job of this predicate is to minimize stack space consumption in @@ -1362,7 +1362,7 @@ output_module_string_table(ModuleName, StringTableSize, StringTable, output_module_string_table_chars_driver(CurIndex, MaxIndex, StringWithNulls, !IO) :- ( CurIndex < MaxIndex -> - SubMaxIndex = int__min(MaxIndex, CurIndex + 255), + SubMaxIndex = int.min(MaxIndex, CurIndex + 255), output_module_string_table_chars(CurIndex, SubMaxIndex, StringWithNulls, !IO), output_module_string_table_chars_driver(SubMaxIndex + 1, MaxIndex, @@ -1376,16 +1376,16 @@ output_module_string_table_chars_driver(CurIndex, MaxIndex, StringWithNulls, output_module_string_table_chars(CurIndex, MaxIndex, StringWithNulls, !IO) :- ( CurIndex mod 10 = 0 -> - io__write_string("\n", !IO) + io.write_string("\n", !IO) ; true ), StringWithNulls = string_with_0s(String), - string__unsafe_index(String, CurIndex, Char), - io__write_char('''', !IO), - c_util__output_quoted_char(Char, !IO), - io__write_char('''', !IO), - io__write_string(", ", !IO), + string.unsafe_index(String, CurIndex, Char), + io.write_char('''', !IO), + c_util.output_quoted_char(Char, !IO), + io.write_char('''', !IO), + io.write_string(", ", !IO), ( CurIndex < MaxIndex -> output_module_string_table_chars(CurIndex + 1, MaxIndex, StringWithNulls, !IO) @@ -1401,21 +1401,21 @@ output_module_string_table_chars(CurIndex, MaxIndex, StringWithNulls, !IO) :- output_file_layout_vector_data_defn(ModuleName, FileLayoutNames, VectorName, !DeclSet, !IO) :- - list__foldl2(output_layout_decl, FileLayoutNames, !DeclSet, !IO), + list.foldl2(output_layout_decl, FileLayoutNames, !DeclSet, !IO), VectorName = module_layout_file_vector(ModuleName), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(VectorName, yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), ( FileLayoutNames = [], % ANSI/ISO C doesn't allow empty arrays, so place a dummy value % in the array. - io__write_string("NULL\n", !IO) + io.write_string("NULL\n", !IO) ; FileLayoutNames = [_ | _], - list__foldl(output_layout_name_in_vector("&"), FileLayoutNames, !IO) + list.foldl(output_layout_name_in_vector("&"), FileLayoutNames, !IO) ), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(VectorName)), !DeclSet). :- pred output_file_layout_data_defns(module_name::in, int::in, @@ -1437,28 +1437,28 @@ output_file_layout_data_defns(ModuleName, FileNum, [FileLayout | FileLayouts], output_file_layout_data_defn(ModuleName, FileNum, FileLayout, FileLayoutName, !DeclSet, !IO) :- FileLayout = file_layout_data(FileName, LineNoLabelList), - list__map2(line_no_label_to_label_layout_addr, LineNoLabelList, + list.map2(line_no_label_to_label_layout_addr, LineNoLabelList, LineNos, LabelLayoutAddrs), - list__foldl2(output_data_addr_decls, LabelLayoutAddrs, !DeclSet, !IO), + list.foldl2(output_data_addr_decls, LabelLayoutAddrs, !DeclSet, !IO), - list__length(LineNoLabelList, VectorLengths), + list.length(LineNoLabelList, VectorLengths), output_file_layout_line_number_vector_defn(ModuleName, FileNum, LineNos, LineNumberVectorName, !DeclSet, !IO), output_file_layout_label_layout_vector_defn(ModuleName, FileNum, LabelLayoutAddrs, LabelVectorName, !DeclSet, !IO), FileLayoutName = file_layout(ModuleName, FileNum), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(FileLayoutName, yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), quote_and_write_string(FileName, !IO), - io__write_string(",\n", !IO), - io__write_int(VectorLengths, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + io.write_int(VectorLengths, !IO), + io.write_string(",\n", !IO), output_layout_name(LineNumberVectorName, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_layout_name(LabelVectorName, !IO), - io__write_string("\n};\n", !IO), + io.write_string("\n};\n", !IO), decl_set_insert(data_addr(layout_addr(FileLayoutName)), !DeclSet). :- pred output_file_layout_line_number_vector_defn(module_name::in, int::in, @@ -1468,19 +1468,19 @@ output_file_layout_data_defn(ModuleName, FileNum, FileLayout, FileLayoutName, output_file_layout_line_number_vector_defn(ModuleName, FileNum, LineNumbers, LayoutName, !DeclSet, !IO) :- LayoutName = file_layout_line_number_vector(ModuleName, FileNum), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), ( LineNumbers = [], % ANSI/ISO C doesn't allow empty arrays, so place a dummy value % in the array. - io__write_string("0\n", !IO) + io.write_string("0\n", !IO) ; LineNumbers = [_ | _], - list__foldl(output_number_in_vector, LineNumbers, !IO) + list.foldl(output_number_in_vector, LineNumbers, !IO) ), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred output_file_layout_label_layout_vector_defn(module_name::in, int::in, @@ -1490,20 +1490,20 @@ output_file_layout_line_number_vector_defn(ModuleName, FileNum, LineNumbers, output_file_layout_label_layout_vector_defn(ModuleName, FileNum, LabelAddrs, LayoutName, !DeclSet, !IO) :- LayoutName = file_layout_label_layout_vector(ModuleName, FileNum), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), ( LabelAddrs = [], % ANSI/ISO C doesn't allow empty arrays, so place a dummy value % in the array. - io__write_string("NULL\n", !IO) + io.write_string("NULL\n", !IO) ; LabelAddrs = [_ | _], - list__map(project_label_layout, LabelAddrs, Labels), + list.map(project_label_layout, LabelAddrs, Labels), output_label_layout_addrs_in_vector(Labels, !IO) ), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred project_label_layout(data_addr::in, label::out) is det. @@ -1529,19 +1529,19 @@ output_label_layout_addrs_in_vector([Label | Labels], !IO) :- Labels, RemainingLabels), N > 1 -> - list__reverse(RevLabelNums, LabelNums), - io__write_string("MR_LABEL_LAYOUT", !IO), - io__write_int(list__length(LabelNums), !IO), - io__write_string("(", !IO), + list.reverse(RevLabelNums, LabelNums), + io.write_string("MR_LABEL_LAYOUT", !IO), + io.write_int(list.length(LabelNums), !IO), + io.write_string("(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(",", !IO), - io__write_list(LabelNums, ",", io__write_int, !IO), - io__write_string(")\n", !IO), + io.write_string(",", !IO), + io.write_list(LabelNums, ",", io.write_int, !IO), + io.write_string(")\n", !IO), output_label_layout_addrs_in_vector(RemainingLabels, !IO) ; - io__write_string("MR_LABEL_LAYOUT(", !IO), + io.write_string("MR_LABEL_LAYOUT(", !IO), output_label(Label, !IO), - io__write_string("),\n", !IO), + io.write_string("),\n", !IO), output_label_layout_addrs_in_vector(Labels, !IO) ). @@ -1576,31 +1576,31 @@ line_no_label_to_label_layout_addr(LineNo - LabelLayout, LineNo, DataAddr) :- :- pred quote_and_write_string(string::in, io::di, io::uo) is det. quote_and_write_string(String, !IO) :- - io__write_string("""", !IO), - c_util__output_quoted_string(String, !IO), - io__write_string("""", !IO). + io.write_string("""", !IO), + c_util.output_quoted_string(String, !IO), + io.write_string("""", !IO). :- pred output_number_in_vector(int::in, io::di, io::uo) is det. output_number_in_vector(Num, !IO) :- - io__write_int(Num, !IO), - io__write_string(",\n", !IO). + io.write_int(Num, !IO), + io.write_string(",\n", !IO). :- pred output_layout_name_in_vector(string::in, layout_name::in, io::di, io::uo) is det. output_layout_name_in_vector(Prefix, Name, !IO) :- - io__write_string(Prefix, !IO), + io.write_string(Prefix, !IO), output_layout_name(Name, !IO), - io__write_string(",\n", !IO). + io.write_string(",\n", !IO). :- pred output_data_addr_in_vector(string::in, data_addr::in, io::di, io::uo) is det. output_data_addr_in_vector(Prefix, DataAddr, !IO) :- - io__write_string(Prefix, !IO), + io.write_string(Prefix, !IO), output_data_addr(DataAddr, !IO), - io__write_string(",\n", !IO). + io.write_string(",\n", !IO). %-----------------------------------------------------------------------------% @@ -1614,40 +1614,40 @@ output_proc_static_data_defn(RttiProcLabel, ProcLayoutProcStatic, DeepExcpVars), HLDSProcStatic = hlds_proc_static(FileName, LineNumber, IsInInterface, CallSites), - list__foldl2(output_call_site_static_decl, CallSites, !DeclSet, !IO), + list.foldl2(output_call_site_static_decl, CallSites, !DeclSet, !IO), output_call_site_static_array(RttiProcLabel, CallSites, !DeclSet, !IO), LayoutName = proc_static(RttiProcLabel), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), quote_and_write_string(FileName, !IO), - io__write_string(",\n", !IO), - io__write_int(LineNumber, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + io.write_int(LineNumber, !IO), + io.write_string(",\n", !IO), ( IsInInterface = yes, - io__write_string("MR_TRUE", !IO) + io.write_string("MR_TRUE", !IO) ; IsInInterface = no, - io__write_string("MR_FALSE", !IO) + io.write_string("MR_FALSE", !IO) ), - io__write_string(",\n", !IO), - io__write_int(list__length(CallSites), !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), + io.write_int(list.length(CallSites), !IO), + io.write_string(",\n", !IO), CallSitesLayoutName = proc_static_call_sites(RttiProcLabel), output_layout_name(CallSitesLayoutName, !IO), - io__write_string(",\n#ifdef MR_USE_ACTIVATION_COUNTS\n", !IO), - io__write_string("0,\n", !IO), - io__write_string("#endif\n", !IO), - io__write_string("NULL,\n", !IO), + io.write_string(",\n#ifdef MR_USE_ACTIVATION_COUNTS\n", !IO), + io.write_string("0,\n", !IO), + io.write_string("#endif\n", !IO), + io.write_string("NULL,\n", !IO), DeepExcpVars = deep_excp_slots(TopCSDSlot, MiddleCSDSlot, OldOutermostSlot), - io__write_int(TopCSDSlot, !IO), - io__write_string(",\n\t", !IO), - io__write_int(MiddleCSDSlot, !IO), - io__write_string(",\n\t", !IO), - io__write_int(OldOutermostSlot, !IO), - io__write_string("\n};\n", !IO), + io.write_int(TopCSDSlot, !IO), + io.write_string(",\n\t", !IO), + io.write_int(MiddleCSDSlot, !IO), + io.write_string(",\n\t", !IO), + io.write_int(OldOutermostSlot, !IO), + io.write_string("\n};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred output_call_site_static_array(rtti_proc_label::in, @@ -1656,56 +1656,56 @@ output_proc_static_data_defn(RttiProcLabel, ProcLayoutProcStatic, output_call_site_static_array(RttiProcLabel, CallSites, !DeclSet, !IO) :- LayoutName = proc_static_call_sites(RttiProcLabel), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n", !IO), - list__foldl2(output_call_site_static, CallSites, 0, _, !IO), - io__write_string("};\n", !IO), + io.write_string(" = {\n", !IO), + list.foldl2(output_call_site_static, CallSites, 0, _, !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred output_call_site_static(call_site_static_data::in, int::in, int::out, io::di, io::uo) is det. output_call_site_static(CallSiteStatic, Index, Index + 1, !IO) :- - io__write_string("{ /* ", !IO), - io__write_int(Index, !IO), - io__write_string(" */ ", !IO), + io.write_string("{ /* ", !IO), + io.write_int(Index, !IO), + io.write_string(" */ ", !IO), ( CallSiteStatic = normal_call(Callee, TypeSubst, FileName, LineNumber, GoalPath), - io__write_string("MR_normal_call, (MR_Proc_Layout *)\n&", !IO), + io.write_string("MR_normal_call, (MR_Proc_Layout *)\n&", !IO), CalleeProcLabel = make_proc_label_from_rtti(Callee), CalleeUserOrUci = proc_label_user_or_uci(CalleeProcLabel), output_layout_name(proc_layout(Callee, proc_layout_proc_id(CalleeUserOrUci)), !IO), ( TypeSubst = "" -> - io__write_string(", NULL, ", !IO) + io.write_string(", NULL, ", !IO) ; - io__write_string(",\n""", !IO), - io__write_string(TypeSubst, !IO), - io__write_string(""", ", !IO) + io.write_string(",\n""", !IO), + io.write_string(TypeSubst, !IO), + io.write_string(""", ", !IO) ) ; CallSiteStatic = special_call(FileName, LineNumber, GoalPath), - io__write_string("MR_special_call, NULL, NULL, ", !IO) + io.write_string("MR_special_call, NULL, NULL, ", !IO) ; CallSiteStatic = higher_order_call(FileName, LineNumber, GoalPath), - io__write_string("MR_higher_order_call, NULL, NULL, ", !IO) + io.write_string("MR_higher_order_call, NULL, NULL, ", !IO) ; CallSiteStatic = method_call(FileName, LineNumber, GoalPath), - io__write_string("MR_method_call, NULL, NULL, ", !IO) + io.write_string("MR_method_call, NULL, NULL, ", !IO) ; CallSiteStatic = callback(FileName, LineNumber, GoalPath), - io__write_string("MR_callback, NULL, NULL, ", !IO) + io.write_string("MR_callback, NULL, NULL, ", !IO) ), - io__write_string("""", !IO), - io__write_string(FileName, !IO), - io__write_string(""", ", !IO), - io__write_int(LineNumber, !IO), - io__write_string(", """, !IO), + io.write_string("""", !IO), + io.write_string(FileName, !IO), + io.write_string(""", ", !IO), + io.write_int(LineNumber, !IO), + io.write_string(", """, !IO), goal_path_to_string(GoalPath, GoalPathStr), - io__write_string(GoalPathStr, !IO), - io__write_string(""" },\n", !IO). + io.write_string(GoalPathStr, !IO), + io.write_string(""" },\n", !IO). :- pred output_call_site_static_decl(call_site_static_data::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -1740,17 +1740,17 @@ output_table_io_decl(RttiProcLabel, ProcLayoutKind, NumPTIs, ProcLayoutName = proc_layout(RttiProcLabel, ProcLayoutKind), output_layout_decl(ProcLayoutName, !DeclSet, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n(const MR_Proc_Layout *) &", !IO), + io.write_string(" = {\n(const MR_Proc_Layout *) &", !IO), output_layout_name(ProcLayoutName, !IO), - io__write_string(",\n", !IO), - io__write_int(NumPTIs, !IO), - io__write_string(",\n(const MR_PseudoTypeInfo *) ", !IO), + io.write_string(",\n", !IO), + io.write_int(NumPTIs, !IO), + io.write_string(",\n(const MR_PseudoTypeInfo *) ", !IO), output_rval(PTIVectorRval, !IO), - io__write_string(",\n(const MR_Type_Param_Locns *) ", !IO), + io.write_string(",\n(const MR_Type_Param_Locns *) ", !IO), output_rval(TypeParamsRval, !IO), - io__write_string("\n};\n", !IO), + io.write_string("\n};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred output_table_gen(rtti_proc_label::in, int::in, int::in, @@ -1765,21 +1765,21 @@ output_table_gen(RttiProcLabel, NumInputs, NumOutputs, Steps, !DeclSet, !IO), output_rval_decls(PTIVectorRval, !DeclSet, !IO), LayoutName = table_gen_info(RttiProcLabel), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n", !IO), - io__write_int(NumInputs, !IO), - io__write_string(",\n", !IO), - io__write_int(NumOutputs, !IO), - io__write_string(",\n", !IO), + io.write_string(" = {\n", !IO), + io.write_int(NumInputs, !IO), + io.write_string(",\n", !IO), + io.write_int(NumOutputs, !IO), + io.write_string(",\n", !IO), output_layout_name(table_gen_steps(RttiProcLabel), !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_layout_name(table_gen_enum_params(RttiProcLabel), !IO), - io__write_string(",\n(const MR_PseudoTypeInfo *)\n", !IO), + io.write_string(",\n(const MR_PseudoTypeInfo *)\n", !IO), output_rval(PTIVectorRval, !IO), - io__write_string(",\n(const MR_Type_Param_Locns *)\n", !IO), + io.write_string(",\n(const MR_Type_Param_Locns *)\n", !IO), output_rval(TypeParamsRval, !IO), - io__write_string("\n};\n", !IO), + io.write_string("\n};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred output_table_gen_steps_table(rtti_proc_label::in, @@ -1789,11 +1789,11 @@ output_table_gen(RttiProcLabel, NumInputs, NumOutputs, Steps, output_table_gen_steps_table(RttiProcLabel, Steps, MaybeEnumParams, !DeclSet, !IO) :- LayoutName = table_gen_steps(RttiProcLabel), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_table_gen_steps(Steps, MaybeEnumParams, !IO), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred output_table_gen_steps(list(table_trie_step)::in, @@ -1855,8 +1855,8 @@ output_table_gen_steps([Step | Steps], [MaybeEnumParam | MaybeEnumParams], StepType = "MR_TABLE_STEP_PROMISE_IMPLIED", MaybeEnumParam = no ), - io__write_string(StepType, !IO), - io__write_string(",\n", !IO), + io.write_string(StepType, !IO), + io.write_string(",\n", !IO), output_table_gen_steps(Steps, MaybeEnumParams, !IO). :- pred output_table_gen_enum_params_table(rtti_proc_label::in, @@ -1866,11 +1866,11 @@ output_table_gen_steps([Step | Steps], [MaybeEnumParam | MaybeEnumParams], output_table_gen_enum_params_table(RttiProcLabel, MaybeEnumParams, !DeclSet, !IO) :- LayoutName = table_gen_enum_params(RttiProcLabel), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_layout_name_storage_type_name(LayoutName, yes, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_table_gen_enum_params(MaybeEnumParams, !IO), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), decl_set_insert(data_addr(layout_addr(LayoutName)), !DeclSet). :- pred output_table_gen_enum_params(list(maybe(int))::in, @@ -1880,12 +1880,12 @@ output_table_gen_enum_params([], !IO). output_table_gen_enum_params([MaybeEnumParam | MaybeEnumParams], !IO) :- ( MaybeEnumParam = no, - io__write_int(-1, !IO) + io.write_int(-1, !IO) ; MaybeEnumParam = yes(EnumRange), - io__write_int(EnumRange, !IO) + io.write_int(EnumRange, !IO) ), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_table_gen_enum_params(MaybeEnumParams, !IO). %-----------------------------------------------------------------------------% @@ -1893,10 +1893,10 @@ output_table_gen_enum_params([MaybeEnumParam | MaybeEnumParams], !IO) :- output_pred_or_func(PredOrFunc, !IO) :- ( PredOrFunc = predicate, - io__write_string("MR_PREDICATE", !IO) + io.write_string("MR_PREDICATE", !IO) ; PredOrFunc = function, - io__write_string("MR_FUNCTION", !IO) + io.write_string("MR_FUNCTION", !IO) ). %-----------------------------------------------------------------------------% diff --git a/compiler/lco.m b/compiler/lco.m index 2974a5825..fee56c9ff 100644 --- a/compiler/lco.m +++ b/compiler/lco.m @@ -102,7 +102,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__lco. +:- module transform_hlds.lco. :- interface. :- import_module hlds.hlds_module. @@ -192,24 +192,24 @@ lco_modulo_constructors(!ModuleInfo) :- module_info_rebuild_dependency_info(!ModuleInfo, DepInfo), hlds_dependency_info_get_dependency_ordering(DepInfo, SCCs), - list__foldl2(lco_scc, SCCs, map__init, _, !ModuleInfo). + list.foldl2(lco_scc, SCCs, map.init, _, !ModuleInfo). :- pred lco_scc(list(pred_proc_id)::in, variant_map::in, variant_map::out, module_info::in, module_info::out) is det. lco_scc(SCC, !VariantMap, !ModuleInfo) :- ModuleInfo0 = !.ModuleInfo, - list__foldl4(lco_proc(!.VariantMap, SCC), SCC, !ModuleInfo, - map__init, CurSCCVariantMap, map__init, CurSCCUpdateMap, + list.foldl4(lco_proc(!.VariantMap, SCC), SCC, !ModuleInfo, + map.init, CurSCCVariantMap, map.init, CurSCCUpdateMap, permitted, Permitted), - map__to_assoc_list(CurSCCVariantMap, CurSCCVariants), - map__to_assoc_list(CurSCCUpdateMap, CurSCCUpdates), + map.to_assoc_list(CurSCCVariantMap, CurSCCVariants), + map.to_assoc_list(CurSCCUpdateMap, CurSCCUpdates), ( Permitted = permitted, CurSCCUpdates = [_ | _] -> - list__foldl(process_proc_update, CurSCCUpdates, !ModuleInfo), - list__foldl(process_proc_variant, CurSCCVariants, !ModuleInfo) + list.foldl(process_proc_update, CurSCCUpdates, !ModuleInfo), + list.foldl(process_proc_variant, CurSCCVariants, !ModuleInfo) ; !:ModuleInfo = ModuleInfo0 ). @@ -223,11 +223,11 @@ process_proc_update(PredProcId - NewProcInfo, !ModuleInfo) :- PredProcId = proc(PredId, ProcId), module_info_preds(!.ModuleInfo, Preds0), - map__lookup(Preds0, PredId, PredInfo0), + map.lookup(Preds0, PredId, PredInfo0), pred_info_procedures(PredInfo0, Procs0), - map__det_update(Procs0, ProcId, NewProcInfo, Procs), + map.det_update(Procs0, ProcId, NewProcInfo, Procs), pred_info_set_procedures(Procs, PredInfo0, PredInfo), - map__det_update(Preds0, PredId, PredInfo, Preds), + map.det_update(Preds0, PredId, PredInfo, Preds), module_info_set_preds(Preds, !ModuleInfo). :- pred process_proc_variant(pair(pred_proc_id, variant_id)::in, @@ -245,7 +245,7 @@ process_proc_variant(PredProcId - VariantId, !ModuleInfo) :- some [!VariantPredInfo] ( module_info_preds(!.ModuleInfo, Preds0), - map__lookup(Preds0, VariantPredId, !:VariantPredInfo), + map.lookup(Preds0, VariantPredId, !:VariantPredInfo), Name0 = pred_info_name(!.VariantPredInfo), pred_info_get_origin(!.VariantPredInfo, Origin0), create_variant_name(AddrOutArgPosns, Name0, Name), @@ -256,10 +256,10 @@ process_proc_variant(PredProcId - VariantId, !ModuleInfo) :- % We throw away any other procs in the variant predicate, because % we create a separate predicate for each variant. - map__det_insert(map__init, VariantProcId, VariantProcInfo, + map.det_insert(map.init, VariantProcId, VariantProcInfo, VariantProcs), pred_info_set_procedures(VariantProcs, !VariantPredInfo), - map__det_update(Preds0, VariantPredId, !.VariantPredInfo, Preds), + map.det_update(Preds0, VariantPredId, !.VariantPredInfo, Preds), module_info_set_preds(Preds, !ModuleInfo) ). @@ -302,8 +302,8 @@ lco_proc(LowerSCCVariants, SCC, CurProc, !ModuleInfo, !CurSCCVariants, proc_info_vartypes(ProcInfo0, VarTypes0), proc_info_headvars(ProcInfo0, HeadVars), proc_info_argmodes(ProcInfo0, ArgModes), - list__map(map__lookup(VarTypes0), HeadVars, ArgTypes), - arg_info__compute_in_and_out_vars(!.ModuleInfo, HeadVars, + list.map(map.lookup(VarTypes0), HeadVars, ArgTypes), + arg_info.compute_in_and_out_vars(!.ModuleInfo, HeadVars, ArgModes, ArgTypes, _InputHeadVars, OutputHeadVars), proc_info_inferred_determinism(ProcInfo0, CurProcDetism), ConstInfo = lco_const_info(LowerSCCVariants, list_to_set(SCC), @@ -324,7 +324,7 @@ lco_proc(LowerSCCVariants, SCC, CurProc, !ModuleInfo, !CurSCCVariants, proc_info_set_vartypes(VarTypes, !ProcInfo), proc_info_set_goal(Goal, !ProcInfo), requantify_proc(!ProcInfo), - svmap__det_insert(CurProc, !.ProcInfo, !CurSCCUpdates) + svmap.det_insert(CurProc, !.ProcInfo, !CurSCCUpdates) ) ; true @@ -354,7 +354,7 @@ lco_in_goal(Goal0 - GoalInfo, Goal - GoalInfo, !Info, ConstInfo) :- Goal0 = conj(ConjType, Goals0), ( ConjType = plain_conj, - lco_in_conj(list__reverse(Goals0), [], bag__init, MaybeGoals, + lco_in_conj(list.reverse(Goals0), [], bag.init, MaybeGoals, !Info, ConstInfo), ( MaybeGoals = yes(Goals), @@ -365,7 +365,7 @@ lco_in_goal(Goal0 - GoalInfo, Goal - GoalInfo, !Info, ConstInfo) :- % unifications we can move before a recursive call, % maybe it ends with a switch or if-then-else, some of whose % arms fit that pattern. - ( list__split_last(Goals0, AllButLast, Last0) -> + ( list.split_last(Goals0, AllButLast, Last0) -> lco_in_goal(Last0, Last, !Info, ConstInfo), Goal = conj(plain_conj, AllButLast ++ [Last]) ; @@ -381,7 +381,7 @@ lco_in_goal(Goal0 - GoalInfo, Goal - GoalInfo, !Info, ConstInfo) :- Goal0 = disj(Goals0), % There is no point in looking for tail calls in the non-last % disjuncts. - ( list__split_last(Goals0, AllButLast, Last0) -> + ( list.split_last(Goals0, AllButLast, Last0) -> lco_in_goal(Last0, Last, !Info, ConstInfo), Goal = disj(AllButLast ++ [Last]) ; @@ -480,7 +480,7 @@ lco_in_conj([RevGoal | RevGoals], !.Unifies, !.UnifyInputVars, MaybeGoals, SubInfo = construct_sub_info(no, _) ), all_true(acceptable_construct_mode(ModuleInfo), ArgUniModes), - map__lookup(VarTypes, ConstructedVar, ConstructedType), + map.lookup(VarTypes, ConstructedVar, ConstructedType), ConsTag = cons_id_to_tag(ConsId, ConstructedType, ModuleInfo), % The code generator can't handle the other tags. For example, it % doesn't make sense to the address of the field of a function symbol @@ -491,15 +491,15 @@ lco_in_conj([RevGoal | RevGoals], !.Unifies, !.UnifyInputVars, MaybeGoals, ConsTag = shared_remote_tag(_, _) ) -> - svbag__delete(ConstructedVar, !UnifyInputVars), - svbag__insert_list(ConstructArgs, !UnifyInputVars), + svbag.delete(ConstructedVar, !UnifyInputVars), + svbag.insert_list(ConstructArgs, !UnifyInputVars), !:Unifies = [RevGoal | !.Unifies], lco_in_conj(RevGoals, !.Unifies, !.UnifyInputVars, MaybeGoals, !Info, ConstInfo) ; RevGoalExpr = call(PredId, ProcId, Args, Builtin, UnifyContext, SymName), - set__member(proc(PredId, ProcId), ConstInfo ^ cur_scc), + set.member(proc(PredId, ProcId), ConstInfo ^ cur_scc), goal_info_get_determinism(RevGoalInfo, RevGoalDetism), RevGoalDetism = ConstInfo ^ cur_proc_detism, @@ -509,26 +509,26 @@ lco_in_conj([RevGoal | RevGoals], !.Unifies, !.UnifyInputVars, MaybeGoals, classify_proc_call_args(ModuleInfo, VarTypes, Args, CalleeArgModes, _InArgs, OutArgs, UnusedArgs), UnusedArgs = [], - list__length(OutArgs, NumOutArgs), + list.length(OutArgs, NumOutArgs), CurrProcOutArgs = ConstInfo ^ cur_proc_outputs, - list__length(CurrProcOutArgs, NumCurrProcOutArgs), + list.length(CurrProcOutArgs, NumCurrProcOutArgs), NumOutArgs = NumCurrProcOutArgs, - assoc_list__from_corresponding_lists(OutArgs, CurrProcOutArgs, + assoc_list.from_corresponding_lists(OutArgs, CurrProcOutArgs, CallHeadPairs), find_args_to_pass_by_addr(CallHeadPairs, 1, Mismatches, - UpdatedCallOutArgs, map__init, Subst, !Info), + UpdatedCallOutArgs, map.init, Subst, !Info), % If there are no mismatches, we would create an identical "variant". % Such cases should be optimized using other means. Mismatches = [_ | _], - assoc_list__values(Mismatches, MismatchedCallArgs), + assoc_list.values(Mismatches, MismatchedCallArgs), % The variants we create return each output in only one place in % memory. all_true(occurs_once(!.UnifyInputVars), MismatchedCallArgs), - ensure_variant_exists(PredId, ProcId, assoc_list__keys(Mismatches), + ensure_variant_exists(PredId, ProcId, assoc_list.keys(Mismatches), VariantPredProcId, !Info) -> - list__map(update_construct(Subst), !.Unifies, UpdatedUnifies), + list.map(update_construct(Subst), !.Unifies, UpdatedUnifies), proc_info_argmodes(CalleeProcInfo, CalleeModes), update_call_args(ModuleInfo, VarTypes, CalleeModes, Args, UpdatedCallOutArgs, UpdatedArgs), @@ -537,7 +537,7 @@ lco_in_conj([RevGoal | RevGoals], !.Unifies, !.UnifyInputVars, MaybeGoals, Builtin, UnifyContext, SymName), UpdatedGoalInfo = RevGoalInfo, UpdatedGoal = UpdatedGoalExpr - UpdatedGoalInfo, - Goals = list__reverse(RevGoals) ++ UpdatedUnifies ++ [UpdatedGoal], + Goals = list.reverse(RevGoals) ++ UpdatedUnifies ++ [UpdatedGoal], MaybeGoals = yes(Goals), !:Info = !.Info ^ changed := changed ; @@ -558,7 +558,7 @@ update_call_args(_ModuleInfo, _VarTypes, [_ | _], [], _, _) :- unexpected(this_file, "update_call_args: mismatches lists"). update_call_args(ModuleInfo, VarTypes, [CalleeMode | CalleeModes], [Arg | Args], !.UpdatedCallOutArgs, !:UpdatedArgs) :- - map__lookup(VarTypes, Arg, CalleeType), + map.lookup(VarTypes, Arg, CalleeType), mode_to_arg_mode(ModuleInfo, CalleeMode, CalleeType, ArgMode), ( ArgMode = top_in, @@ -596,7 +596,7 @@ classify_proc_call_args(ModuleInfo, VarTypes, [Arg | Args], [CalleeMode | CalleeModes], !:InArgs, !:OutArgs, !:UnusedArgs) :- classify_proc_call_args(ModuleInfo, VarTypes, Args, CalleeModes, !:InArgs, !:OutArgs, !:UnusedArgs), - map__lookup(VarTypes, Arg, CalleeType), + map.lookup(VarTypes, Arg, CalleeType), mode_to_arg_mode(ModuleInfo, CalleeMode, CalleeType, ArgMode), ( ArgMode = top_in, @@ -627,7 +627,7 @@ find_args_to_pass_by_addr([CallArg - HeadArg | CallHeadArgs], ArgNum, ; make_address_var(CallArg, UpdatedCallArg, !Info), Mismatches = [ArgNum - CallArg | MismatchesTail], - svmap__det_insert(CallArg, UpdatedCallArg, !Subst) + svmap.det_insert(CallArg, UpdatedCallArg, !Subst) ). :- pred make_address_var(prog_var::in, prog_var::out, @@ -636,11 +636,11 @@ find_args_to_pass_by_addr([CallArg - HeadArg | CallHeadArgs], ArgNum, make_address_var(Var, AddrVar, !Info) :- VarSet0 = !.Info ^ var_set, VarTypes0 = !.Info ^ var_types, - varset__lookup_name(VarSet0, Var, "SCCcallarg", Name), + varset.lookup_name(VarSet0, Var, "SCCcallarg", Name), AddrName = "Addr" ++ Name, - varset__new_named_var(VarSet0, AddrName, AddrVar, VarSet), - map__lookup(VarTypes0, Var, FieldType), - map__det_insert(VarTypes0, AddrVar, make_ref_type(FieldType), VarTypes), + varset.new_named_var(VarSet0, AddrName, AddrVar, VarSet), + map.lookup(VarTypes0, Var, FieldType), + map.det_insert(VarTypes0, AddrVar, make_ref_type(FieldType), VarTypes), !:Info = !.Info ^ var_set := VarSet, !:Info = !.Info ^ var_types := VarTypes. @@ -658,7 +658,7 @@ make_ref_type(FieldType) = PtrType :- ensure_variant_exists(PredId, ProcId, AddrArgNums, VariantPredProcId, !Info) :- CurSCCVariants0 = !.Info ^ cur_scc_variants, - ( map__search(CurSCCVariants0, proc(PredId, ProcId), ExistingVariant) -> + ( map.search(CurSCCVariants0, proc(PredId, ProcId), ExistingVariant) -> ExistingVariant = variant_id(ExistingAddrArgNums, VariantPredProcId), AddrArgNums = ExistingAddrArgNums ; @@ -667,7 +667,7 @@ ensure_variant_exists(PredId, ProcId, AddrArgNums, VariantPredProcId, !Info) :- VariantPredProcId = proc(ClonePredId, ProcId), !:Info = !.Info ^ module_info := ModuleInfo, NewVariant = variant_id(AddrArgNums, VariantPredProcId), - map__det_insert(CurSCCVariants0, proc(PredId, ProcId), NewVariant, + map.det_insert(CurSCCVariants0, proc(PredId, ProcId), NewVariant, CurSCCVariants), !:Info = !.Info ^ cur_scc_variants := CurSCCVariants ). @@ -743,7 +743,7 @@ update_construct_args(Subst, ArgNum, [OrigVar | OrigVars], [UpdatedVar | UpdatedVars], AddrArgs, !InstMapDelta) :- update_construct_args(Subst, ArgNum + 1, OrigVars, UpdatedVars, AddrArgsTail, !InstMapDelta), - ( map__search(Subst, OrigVar, AddrVar) -> + ( map.search(Subst, OrigVar, AddrVar) -> UpdatedVar = AddrVar, instmap_delta_set(AddrVar, ground(shared, none), !InstMapDelta), AddrArgs = [ArgNum | AddrArgsTail] @@ -766,7 +766,7 @@ acceptable_construct_mode(ModuleInfo, UniMode) :- :- pred occurs_once(bag(prog_var)::in, prog_var::in) is semidet. occurs_once(Bag, Var) :- - bag__count_value(Bag, Var, 1). + bag.count_value(Bag, Var, 1). %-----------------------------------------------------------------------------% @@ -811,7 +811,7 @@ make_addr_vars([_ | _], [], _, _, _, _, _, _, !VarSet, !VarTypes) :- make_addr_vars([HeadVar0 | HeadVars0], [Mode0 | Modes0], [HeadVar | HeadVars], [Mode | Modes], !.AddrOutArgPosns, NextOutArgNum, ModuleInfo, VarToAddr, !VarSet, !VarTypes) :- - map__lookup(!.VarTypes, HeadVar0, HeadVarType), + map.lookup(!.VarTypes, HeadVar0, HeadVarType), mode_to_arg_mode(ModuleInfo, Mode0, HeadVarType, ArgMode), ( ArgMode = top_in, @@ -822,11 +822,11 @@ make_addr_vars([HeadVar0 | HeadVars0], [Mode0 | Modes0], ; ArgMode = top_out, ( !.AddrOutArgPosns = [NextOutArgNum | !:AddrOutArgPosns] -> - varset__lookup_name(!.VarSet, HeadVar0, Name), + varset.lookup_name(!.VarSet, HeadVar0, Name), AddrName = "AddrOf" ++ Name, - svvarset__new_named_var(AddrName, AddrVar, !VarSet), - map__lookup(!.VarTypes, HeadVar0, OldType), - svmap__det_insert(AddrVar, make_ref_type(OldType), !VarTypes), + svvarset.new_named_var(AddrName, AddrVar, !VarSet), + map.lookup(!.VarTypes, HeadVar0, OldType), + svmap.det_insert(AddrVar, make_ref_type(OldType), !VarTypes), HeadVar = AddrVar, Mode = in_mode, make_addr_vars(HeadVars0, Modes0, HeadVars, Modes, @@ -861,12 +861,12 @@ transform_variant_goal(ModuleInfo, VarToAddr, InstMap0, ) ; GoalExpr0 = disj(Goals0), - list__map(transform_variant_goal(ModuleInfo, VarToAddr, InstMap0), + list.map(transform_variant_goal(ModuleInfo, VarToAddr, InstMap0), Goals0, Goals), GoalExpr = disj(Goals) ; GoalExpr0 = switch(Var, CanFail, Cases0), - list__map(transform_variant_case(ModuleInfo, VarToAddr, InstMap0), + list.map(transform_variant_case(ModuleInfo, VarToAddr, InstMap0), Cases0, Cases), GoalExpr = switch(Var, CanFail, Cases) ; @@ -934,14 +934,14 @@ transform_variant_case(ModuleInfo, VarToAddr, InstMap0, case(ConsId, Goal0), transform_variant_atomic_goal(ModuleInfo, VarToAddr, InstMap0, GoalInfo, GoalExpr0, GoalExpr) :- update_instmap(GoalExpr0 - GoalInfo, InstMap0, InstMap1), - list__filter(is_grounding(ModuleInfo, InstMap0, InstMap1), VarToAddr, + list.filter(is_grounding(ModuleInfo, InstMap0, InstMap1), VarToAddr, GroundingVarToAddr), ( GroundingVarToAddr = [], GoalExpr = GoalExpr0 ; GroundingVarToAddr = [_ | _], - list__map(make_store_goal(ModuleInfo), GroundingVarToAddr, StoreGoals), + list.map(make_store_goal(ModuleInfo), GroundingVarToAddr, StoreGoals), GoalExpr = conj(plain_conj, [GoalExpr0 - GoalInfo | StoreGoals]) ). @@ -949,9 +949,9 @@ transform_variant_atomic_goal(ModuleInfo, VarToAddr, InstMap0, GoalInfo, pair(prog_var)::in) is semidet. is_grounding(ModuleInfo, InstMap0, InstMap, Var - _AddrVar) :- - instmap__lookup_var(InstMap0, Var, Inst0), + instmap.lookup_var(InstMap0, Var, Inst0), not inst_is_ground(ModuleInfo, Inst0), - instmap__lookup_var(InstMap, Var, Inst), + instmap.lookup_var(InstMap, Var, Inst), inst_is_ground(ModuleInfo, Inst). :- pred make_store_goal(module_info::in, pair(prog_var)::in, @@ -960,7 +960,7 @@ is_grounding(ModuleInfo, InstMap0, InstMap, Var - _AddrVar) :- make_store_goal(ModuleInfo, Var - AddrVar, Goal) :- generate_simple_call(mercury_private_builtin_module, "store_at_ref", predicate, only_mode, det, [AddrVar, Var], [impure_goal], [], - ModuleInfo, term__context_init, Goal). + ModuleInfo, term.context_init, Goal). %-----------------------------------------------------------------------------% diff --git a/compiler/live_vars.m b/compiler/live_vars.m index 586385304..950e1c079 100644 --- a/compiler/live_vars.m +++ b/compiler/live_vars.m @@ -19,7 +19,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__live_vars. +:- module ll_backend.live_vars. :- interface. % Parse tree modules @@ -93,14 +93,14 @@ build_live_sets_in_goal(Goal0 - GoalInfo0, Goal - GoalInfo, ResumeVars0, goal_info_get_post_births(GoalInfo0, PostBirths), % note: we must be careful to apply deaths before births - set__difference(!.Liveness, PreDeaths, !:Liveness), - set__union(!.Liveness, PreBirths, !:Liveness), + set.difference(!.Liveness, PreDeaths, !:Liveness), + set.union(!.Liveness, PreBirths, !:Liveness), % If the goal is atomic, we want to apply the postdeaths before processing % the goal, but if the goal is a compound goal, then we want to apply them % after processing it. ( goal_is_atomic(Goal0) -> - set__difference(!.Liveness, PostDeaths, !:Liveness) + set.difference(!.Liveness, PostDeaths, !:Liveness) ; true ), @@ -113,7 +113,7 @@ build_live_sets_in_goal(Goal0 - GoalInfo0, Goal - GoalInfo, ResumeVars0, ; ResumePoint = resume_point(ResumePointVars, Locs), ( resume_locs_include_stack(Locs, yes) -> - set__union(ResumeVars0, ResumePointVars, ResumeVars1), + set.union(ResumeVars0, ResumePointVars, ResumeVars1), ResumeOnStack = yes ; ResumeVars1 = ResumeVars0, @@ -130,10 +130,10 @@ build_live_sets_in_goal(Goal0 - GoalInfo0, Goal - GoalInfo, ResumeVars0, ( goal_is_atomic(Goal0) -> true ; - set__difference(!.Liveness, PostDeaths, !:Liveness) + set.difference(!.Liveness, PostDeaths, !:Liveness) ), - set__union(!.Liveness, PostBirths, !:Liveness). + set.union(!.Liveness, PostBirths, !:Liveness). :- pred resume_locs_include_stack(resume_locs::in, bool::out) is det. @@ -169,7 +169,7 @@ build_live_sets_in_goal_2(conj(ConjType, Goals0), conj(ConjType, Goals), ; ConjType = parallel_conj, goal_info_get_code_gen_nonlocals(GoalInfo0, NonLocals), - set__union(NonLocals, !.Liveness, LiveSet), + set.union(NonLocals, !.Liveness, LiveSet), % Since each parallel conjunct may be run on a different Mercury engine % to the current engine, we must save all the variables that are live % or nonlocal to the parallel conjunction. Nonlocal variables that are @@ -204,7 +204,7 @@ build_live_sets_in_goal_2(disj(Goals0), disj(Goals), GoalInfo, GoalInfo, ( goal_info_get_code_model(GoalInfo, model_non), some [Disjunct] ( - list__member(Disjunct, Goals), + list.member(Disjunct, Goals), Disjunct = _ - DisjunctGoalInfo, goal_info_get_resume_point(DisjunctGoalInfo, DisjunctResumePoint), @@ -212,7 +212,7 @@ build_live_sets_in_goal_2(disj(Goals0), disj(Goals), GoalInfo, GoalInfo, resume_locs_include_stack(Locs, yes) ) -> - set__union(!.NondetLiveness, ResumeVars, !:NondetLiveness) + set.union(!.NondetLiveness, ResumeVars, !:NondetLiveness) ; true ) @@ -244,7 +244,7 @@ build_live_sets_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0), LivenessCond, _LivenessThen, NondetLivenessCond, NondetLivenessThen), build_live_sets_in_goal(Else0, Else, ResumeVars0, AllocData, !StackAlloc, Liveness0, Liveness, NondetLiveness0, NondetLivenessElse), - set__union(NondetLivenessThen, NondetLivenessElse, NondetLiveness). + set.union(NondetLivenessThen, NondetLivenessElse, NondetLiveness). build_live_sets_in_goal_2(not(Goal0), not(Goal), GoalInfo, GoalInfo, ResumeVars0, AllocData, !StackAlloc, !Liveness, !NondetLiveness) :- @@ -278,9 +278,9 @@ build_live_sets_in_goal_2(Goal, Goal, GoalInfo0, GoalInfo, ResumeVars0, ; ProcInfo = AllocData ^ proc_info, proc_info_vartypes(ProcInfo, VarTypes), - map__apply_to_list(ArgVars, VarTypes, Types), + map.apply_to_list(ArgVars, VarTypes, Types), ModuleInfo = AllocData ^ module_info, - arg_info__partition_generic_call_args(ModuleInfo, ArgVars, + arg_info.partition_generic_call_args(ModuleInfo, ArgVars, Types, Modes, _InVars, OutVars, _UnusedVars), build_live_sets_in_call(OutVars, GoalInfo0, GoalInfo, ResumeVars0, AllocData, !StackAlloc, !.Liveness, !NondetLiveness) @@ -293,7 +293,7 @@ build_live_sets_in_goal_2(Goal, Goal, GoalInfo0, GoalInfo, ResumeVars0, CallerProcInfo = AllocData ^ proc_info, proc_info_vartypes(CallerProcInfo, VarTypes), module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo), - arg_info__partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, + arg_info.partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, ArgVars, _InVars, OutVars, _UnusedVars), ( Builtin = inline_builtin -> GoalInfo = GoalInfo0 @@ -318,8 +318,8 @@ build_live_sets_in_goal_2(Goal, Goal, GoalInfo0, GoalInfo, ResumeVars0, CallerProcInfo = AllocData ^ proc_info, proc_info_vartypes(CallerProcInfo, VarTypes), module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo), - ArgVars = list__map(foreign_arg_var, Args), - arg_info__partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, + ArgVars = list.map(foreign_arg_var, Args), + arg_info.partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, ArgVars, _InVars, OutVars, _UnusedVars), goal_info_get_code_model(GoalInfo0, CodeModel), ( @@ -362,7 +362,7 @@ build_live_sets_in_goal_2(shorthand(_), _,_,_,_,_,_,_,_,_,_,_) :- build_live_sets_in_call(OutVars, GoalInfo0, GoalInfo, ResumeVars0, AllocData, !StackAlloc, Liveness, !NondetLiveness) :- - set__difference(Liveness, OutVars, ForwardVars0), + set.difference(Liveness, OutVars, ForwardVars0), % Might need to add more live variables with typeinfo liveness % calculation. @@ -375,7 +375,7 @@ build_live_sets_in_call(OutVars, GoalInfo0, GoalInfo, ResumeVars0, AllocData, Detism = erroneous, AllocData ^ opt_no_return_calls = yes -> - NeedAcrossCall = need_across_call(set__init, set__init, set__init) + NeedAcrossCall = need_across_call(set.init, set.init, set.init) ; NeedAcrossCall = need_across_call(ForwardVars, ResumeVars0, !.NondetLiveness) @@ -388,7 +388,7 @@ build_live_sets_in_call(OutVars, GoalInfo0, GoalInfo, ResumeVars0, AllocData, goal_info_get_code_model(GoalInfo, CodeModel), ( CodeModel = model_non -> - set__union(!.NondetLiveness, ForwardVars, !:NondetLiveness) + set.union(!.NondetLiveness, ForwardVars, !:NondetLiveness) ; true ). @@ -458,13 +458,13 @@ build_live_sets_in_disj([Goal0 | Goals0], [Goal | Goals], % NondetLiveness should be a set of prog_var sets. Instead of taking % the union of the NondetLive sets at the ends of disjuncts, we should % just keep them in this set of sets. - set__union(NondetLiveness1, NondetLiveness2, NondetLiveness3), + set.union(NondetLiveness1, NondetLiveness2, NondetLiveness3), goal_info_get_resume_point(GoalInfo, Resume), ( Resume = resume_point(ResumePointVars, Locs), resume_locs_include_stack(Locs, yes) -> - set__union(NondetLiveness3, ResumePointVars, NondetLiveness) + set.union(NondetLiveness3, ResumePointVars, NondetLiveness) ; NondetLiveness = NondetLiveness3 ) @@ -488,7 +488,7 @@ build_live_sets_in_cases([case(Cons, Goal0) | Cases0], !StackAlloc, Liveness0, Liveness, NondetLiveness0, NondetLiveness1), build_live_sets_in_cases(Cases0, Cases, ResumeVars0, AllocData, !StackAlloc, Liveness0, _Liveness2, NondetLiveness0, NondetLiveness2), - set__union(NondetLiveness1, NondetLiveness2, NondetLiveness). + set.union(NondetLiveness1, NondetLiveness2, NondetLiveness). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -524,8 +524,8 @@ maybe_add_typeinfo_liveness(ProcInfo, TypeInfoLiveness, OutVars, TypeInfoVarsLive), proc_info_get_typeinfo_vars(OutVars, VarTypes, RttiVarMaps, TypeInfoVarsOut), - set__union(!.LiveVars, TypeInfoVarsOut, !:LiveVars), - set__union(!.LiveVars, TypeInfoVarsLive, !:LiveVars) + set.union(!.LiveVars, TypeInfoVarsOut, !:LiveVars), + set.union(!.LiveVars, TypeInfoVarsLive, !:LiveVars) ; TypeInfoLiveness = no ). diff --git a/compiler/livemap.m b/compiler/livemap.m index 85a403e38..c722d1f6c 100644 --- a/compiler/livemap.m +++ b/compiler/livemap.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__livemap. +:- module ll_backend.livemap. :- interface. :- import_module ll_backend.llds. @@ -31,7 +31,7 @@ % % We can compute this set only if the procedure contains no C code. % -:- pred livemap__build(list(instruction)::in, maybe(livemap)::out) is det. +:- pred livemap.build(list(instruction)::in, maybe(livemap)::out) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -59,24 +59,24 @@ % scan, this time with more knowledge about more labels, until we % get to a fixpoint. -livemap__build(Instrs, MaybeLivemap) :- - map__init(Livemap0), - list__reverse(Instrs, BackInstrs), - livemap__build_2(BackInstrs, Livemap0, MaybeLivemap). +livemap.build(Instrs, MaybeLivemap) :- + map.init(Livemap0), + list.reverse(Instrs, BackInstrs), + livemap.build_2(BackInstrs, Livemap0, MaybeLivemap). -:- pred livemap__build_2(list(instruction)::in, livemap::in, +:- pred livemap.build_2(list(instruction)::in, livemap::in, maybe(livemap)::out) is det. -livemap__build_2(Backinstrs, Livemap0, MaybeLivemap) :- - set__init(Livevals0), - livemap__build_livemap(Backinstrs, Livevals0, no, ContainsUserCode, +livemap.build_2(Backinstrs, Livemap0, MaybeLivemap) :- + set.init(Livevals0), + livemap.build_livemap(Backinstrs, Livevals0, no, ContainsUserCode, Livemap0, Livemap1), ( ContainsUserCode = yes -> MaybeLivemap = no - ; livemap__equal_livemaps(Livemap0, Livemap1) -> + ; livemap.equal_livemaps(Livemap0, Livemap1) -> MaybeLivemap = yes(Livemap1) ; - livemap__build_2(Backinstrs, Livemap1, MaybeLivemap) + livemap.build_2(Backinstrs, Livemap1, MaybeLivemap) ). % Check whether the two livemaps agree on the set of live lvals @@ -86,22 +86,22 @@ livemap__build_2(Backinstrs, Livemap0, MaybeLivemap) :- % The domain of Livemap2 should always be every label in the procedure. % as should the domain of Livemap1 in every call after the first. % -:- pred livemap__equal_livemaps(livemap::in, livemap::in) is semidet. +:- pred livemap.equal_livemaps(livemap::in, livemap::in) is semidet. -livemap__equal_livemaps(Livemap1, Livemap2) :- - map__keys(Livemap1, Labels), - map__keys(Livemap2, Labels), - livemap__equal_livemaps_keys(Labels, Livemap1, Livemap2). +livemap.equal_livemaps(Livemap1, Livemap2) :- + map.keys(Livemap1, Labels), + map.keys(Livemap2, Labels), + livemap.equal_livemaps_keys(Labels, Livemap1, Livemap2). -:- pred livemap__equal_livemaps_keys(list(label)::in, livemap::in, livemap::in) +:- pred livemap.equal_livemaps_keys(list(label)::in, livemap::in, livemap::in) is semidet. -livemap__equal_livemaps_keys([], _Livemap1, _Livemap2). -livemap__equal_livemaps_keys([Label | Labels], Livemap1, Livemap2) :- - map__lookup(Livemap1, Label, Liveset1), - map__lookup(Livemap2, Label, Liveset2), - set__equal(Liveset1, Liveset2), - livemap__equal_livemaps_keys(Labels, Livemap1, Livemap2). +livemap.equal_livemaps_keys([], _Livemap1, _Livemap2). +livemap.equal_livemaps_keys([Label | Labels], Livemap1, Livemap2) :- + map.lookup(Livemap1, Label, Liveset1), + map.lookup(Livemap2, Label, Liveset2), + set.equal(Liveset1, Liveset2), + livemap.equal_livemaps_keys(Labels, Livemap1, Livemap2). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -109,21 +109,21 @@ livemap__equal_livemaps_keys([Label | Labels], Livemap1, Livemap2) :- % Build up a map of what lvals are live at each label. % The input instruction sequence is reversed. % -:- pred livemap__build_livemap(list(instruction)::in, lvalset::in, +:- pred livemap.build_livemap(list(instruction)::in, lvalset::in, bool::in, bool::out, livemap::in, livemap::out) is det. -livemap__build_livemap([], _, !ContainsUserCode, !Livemap). -livemap__build_livemap([Instr0 | Instrs0], Livevals0, +livemap.build_livemap([], _, !ContainsUserCode, !Livemap). +livemap.build_livemap([Instr0 | Instrs0], Livevals0, !ContainsUserCode, !Livemap) :- - livemap__build_livemap_instr(Instr0, Instrs0, Instrs1, + livemap.build_livemap_instr(Instr0, Instrs0, Instrs1, Livevals0, Livevals1, !ContainsUserCode, !Livemap), - livemap__build_livemap(Instrs1, Livevals1, !ContainsUserCode, !Livemap). + livemap.build_livemap(Instrs1, Livevals1, !ContainsUserCode, !Livemap). -:- pred livemap__build_livemap_instr(instruction::in, list(instruction)::in, +:- pred livemap.build_livemap_instr(instruction::in, list(instruction)::in, list(instruction)::out, lvalset::in, lvalset::out, bool::in, bool::out, livemap::in, livemap::out) is det. -livemap__build_livemap_instr(Instr0, !Instrs, !Livevals, !ContainsUserCode, +livemap.build_livemap_instr(Instr0, !Instrs, !Livevals, !ContainsUserCode, !Livemap) :- Instr0 = Uinstr0 - _, ( @@ -145,27 +145,27 @@ livemap__build_livemap_instr(Instr0, !Instrs, !Livevals, !ContainsUserCode, % appears on the right hand side as well as the left, then we % want make_live to put it back into the liveval set. - set__delete(!.Livevals, Lval, !:Livevals), - opt_util__lval_access_rvals(Lval, Rvals), - livemap__make_live_in_rvals([Rval | Rvals], !Livevals) + set.delete(!.Livevals, Lval, !:Livevals), + opt_util.lval_access_rvals(Lval, Rvals), + livemap.make_live_in_rvals([Rval | Rvals], !Livevals) ; Uinstr0 = call(_, _, _, _, _, _), - livemap__look_for_livevals(!Instrs, !Livevals, "call", yes, _) + livemap.look_for_livevals(!Instrs, !Livevals, "call", yes, _) ; Uinstr0 = mkframe(_, _) ; Uinstr0 = label(Label), - map__set(!.Livemap, Label, !.Livevals, !:Livemap) + map.set(!.Livemap, Label, !.Livevals, !:Livemap) ; Uinstr0 = goto(CodeAddr), - opt_util__livevals_addr(CodeAddr, LivevalsNeeded), - livemap__look_for_livevals(!Instrs, !Livevals, "goto", + opt_util.livevals_addr(CodeAddr, LivevalsNeeded), + livemap.look_for_livevals(!Instrs, !Livevals, "goto", LivevalsNeeded, Found), ( Found = yes -> true ; CodeAddr = label(Label) -> - livemap__insert_label_livevals(!.Livemap, Label, - set__init, !:Livevals) + livemap.insert_label_livevals(!.Livemap, Label, + set.init, !:Livevals) ; ( CodeAddr = do_redo ; CodeAddr = do_fail @@ -176,22 +176,22 @@ livemap__build_livemap_instr(Instr0, !Instrs, !Livevals, !ContainsUserCode, ; unexpected(this_file, "unknown label type in build_livemap") ), - livemap__special_code_addr(CodeAddr, MaybeSpecial), + livemap.special_code_addr(CodeAddr, MaybeSpecial), ( MaybeSpecial = yes(Special), - set__insert(!.Livevals, Special, !:Livevals) + set.insert(!.Livevals, Special, !:Livevals) ; MaybeSpecial = no ) ; Uinstr0 = computed_goto(Rval, Labels), - livemap__make_live_in_rvals([Rval], set__init, !:Livevals), - list__foldl(livemap__insert_label_livevals(!.Livemap), Labels, + livemap.make_live_in_rvals([Rval], set.init, !:Livevals), + list.foldl(livemap.insert_label_livevals(!.Livemap), Labels, !Livevals) ; Uinstr0 = if_val(Rval, CodeAddr), Livevals0 = !.Livevals, - livemap__look_for_livevals(!Instrs, !Livevals, "if_val", no, Found), + livemap.look_for_livevals(!Instrs, !Livevals, "if_val", no, Found), ( Found = yes, % This if_val was put here by middle_rec. @@ -200,31 +200,31 @@ livemap__build_livemap_instr(Instr0, !Instrs, !Livevals, !ContainsUserCode, % since they will be needed at CodeAddr. % The locations in Livevals0 may be needed % in the fall-through continuation. - set__union(Livevals0, !Livevals) + set.union(Livevals0, !Livevals) ; Found = no, - livemap__make_live_in_rvals([Rval], !Livevals), + livemap.make_live_in_rvals([Rval], !Livevals), ( CodeAddr = label(Label) -> - livemap__insert_label_livevals(!.Livemap, Label, !Livevals) + livemap.insert_label_livevals(!.Livemap, Label, !Livevals) ; true ) ), - livemap__special_code_addr(CodeAddr, MaybeSpecial), + livemap.special_code_addr(CodeAddr, MaybeSpecial), ( MaybeSpecial = yes(Special), - set__insert(!.Livevals, Special, !:Livevals) + set.insert(!.Livevals, Special, !:Livevals) ; MaybeSpecial = no ) ; Uinstr0 = save_maxfr(Lval), - set__delete(!.Livevals, Lval, !:Livevals), - opt_util__lval_access_rvals(Lval, Rvals), - livemap__make_live_in_rvals(Rvals, !Livevals) + set.delete(!.Livevals, Lval, !:Livevals), + opt_util.lval_access_rvals(Lval, Rvals), + livemap.make_live_in_rvals(Rvals, !Livevals) ; Uinstr0 = restore_maxfr(Lval), - livemap__make_live_in_rval(lval(Lval), !Livevals) + livemap.make_live_in_rval(lval(Lval), !Livevals) ; Uinstr0 = incr_hp(Lval, _, _, Rval, _), @@ -235,40 +235,40 @@ livemap__build_livemap_instr(Instr0, !Instrs, !Livevals, !ContainsUserCode, % to lval, but the two should never have any variables in % common. This is why doing the deletion first works. - set__delete(!.Livevals, Lval, !:Livevals), - opt_util__lval_access_rvals(Lval, Rvals), - livemap__make_live_in_rvals([Rval | Rvals], !Livevals) + set.delete(!.Livevals, Lval, !:Livevals), + opt_util.lval_access_rvals(Lval, Rvals), + livemap.make_live_in_rvals([Rval | Rvals], !Livevals) ; Uinstr0 = mark_hp(Lval), - set__delete(!.Livevals, Lval, !:Livevals), - opt_util__lval_access_rvals(Lval, Rvals), - livemap__make_live_in_rvals(Rvals, !Livevals) + set.delete(!.Livevals, Lval, !:Livevals), + opt_util.lval_access_rvals(Lval, Rvals), + livemap.make_live_in_rvals(Rvals, !Livevals) ; Uinstr0 = restore_hp(Rval), - livemap__make_live_in_rvals([Rval], !Livevals) + livemap.make_live_in_rvals([Rval], !Livevals) ; Uinstr0 = free_heap(Rval), - livemap__make_live_in_rvals([Rval], !Livevals) + livemap.make_live_in_rvals([Rval], !Livevals) ; Uinstr0 = store_ticket(Lval), - set__delete(!.Livevals, Lval, !:Livevals), - opt_util__lval_access_rvals(Lval, Rvals), - livemap__make_live_in_rvals(Rvals, !Livevals) + set.delete(!.Livevals, Lval, !:Livevals), + opt_util.lval_access_rvals(Lval, Rvals), + livemap.make_live_in_rvals(Rvals, !Livevals) ; Uinstr0 = reset_ticket(Rval, _Reason), - livemap__make_live_in_rval(Rval, !Livevals) + livemap.make_live_in_rval(Rval, !Livevals) ; Uinstr0 = discard_ticket ; Uinstr0 = prune_ticket ; Uinstr0 = mark_ticket_stack(Lval), - set__delete(!.Livevals, Lval, !:Livevals), - opt_util__lval_access_rvals(Lval, Rvals), - livemap__make_live_in_rvals(Rvals, !Livevals) + set.delete(!.Livevals, Lval, !:Livevals), + opt_util.lval_access_rvals(Lval, Rvals), + livemap.make_live_in_rvals(Rvals, !Livevals) ; Uinstr0 = prune_tickets_to(Rval), - livemap__make_live_in_rval(Rval, !Livevals) + livemap.make_live_in_rval(Rval, !Livevals) ; Uinstr0 = incr_sp(_, _) ; @@ -288,23 +288,23 @@ livemap__build_livemap_instr(Instr0, !Instrs, !Livevals, !ContainsUserCode, Uinstr0 = join_and_continue(_, _) ; Uinstr0 = c_code(_, LiveLvalInfo), - livemap__build_live_lval_info(LiveLvalInfo, + livemap.build_live_lval_info(LiveLvalInfo, !Livevals, !ContainsUserCode) ; Uinstr0 = pragma_c(_, Components, _, _, _, _, _, _, _), - livemap__build_livemap_pragma_components(Components, + livemap.build_livemap_pragma_components(Components, !Livevals, !ContainsUserCode) ). -:- pred livemap__build_livemap_pragma_components(list(pragma_c_component)::in, +:- pred livemap.build_livemap_pragma_components(list(pragma_c_component)::in, lvalset::in, lvalset::out, bool::in, bool::out) is det. -livemap__build_livemap_pragma_components([], !Livevals, !ContainsUserCode). -livemap__build_livemap_pragma_components([Component | Components], +livemap.build_livemap_pragma_components([], !Livevals, !ContainsUserCode). +livemap.build_livemap_pragma_components([Component | Components], !Livevals, !ContainsUserCode) :- ( Component = pragma_c_inputs(Inputs), - livemap__build_livemap_pragma_inputs(Inputs, + livemap.build_livemap_pragma_inputs(Inputs, !Livevals) ; Component = pragma_c_outputs(_) @@ -313,47 +313,47 @@ livemap__build_livemap_pragma_components([Component | Components], !:ContainsUserCode = yes ; Component = pragma_c_raw_code(_, _, LiveLvalInfo), - livemap__build_live_lval_info(LiveLvalInfo, + livemap.build_live_lval_info(LiveLvalInfo, !Livevals, !ContainsUserCode) ; Component = pragma_c_fail_to(_) ; Component = pragma_c_noop ), - livemap__build_livemap_pragma_components(Components, + livemap.build_livemap_pragma_components(Components, !Livevals, !ContainsUserCode). -:- pred livemap__build_live_lval_info(c_code_live_lvals::in, +:- pred livemap.build_live_lval_info(c_code_live_lvals::in, lvalset::in, lvalset::out, bool::in, bool::out) is det. -livemap__build_live_lval_info(no_live_lvals_info, !Livevals, _, yes). -livemap__build_live_lval_info(live_lvals_info(LiveLvalSet), !Livevals, +livemap.build_live_lval_info(no_live_lvals_info, !Livevals, _, yes). +livemap.build_live_lval_info(live_lvals_info(LiveLvalSet), !Livevals, !DontValueNumber) :- - set__to_sorted_list(LiveLvalSet, LiveLvals), - livemap__insert_proper_livevals(LiveLvals, !Livevals). + set.to_sorted_list(LiveLvalSet, LiveLvals), + livemap.insert_proper_livevals(LiveLvals, !Livevals). -:- pred livemap__build_livemap_pragma_inputs(list(pragma_c_input)::in, +:- pred livemap.build_livemap_pragma_inputs(list(pragma_c_input)::in, lvalset::in, lvalset::out) is det. -livemap__build_livemap_pragma_inputs([], !Livevals). -livemap__build_livemap_pragma_inputs([Input | Inputs], !Livevals) :- +livemap.build_livemap_pragma_inputs([], !Livevals). +livemap.build_livemap_pragma_inputs([Input | Inputs], !Livevals) :- Input = pragma_c_input(_, _, _, _, Rval, _, _), ( Rval = lval(Lval) -> - livemap__insert_proper_liveval(Lval, !Livevals) + livemap.insert_proper_liveval(Lval, !Livevals) ; true ), - livemap__build_livemap_pragma_inputs(Inputs, !Livevals). + livemap.build_livemap_pragma_inputs(Inputs, !Livevals). -:- pred livemap__look_for_livevals(list(instruction)::in, +:- pred livemap.look_for_livevals(list(instruction)::in, list(instruction)::out, lvalset::in, lvalset::out, string::in, bool::in, bool::out) is det. -livemap__look_for_livevals(Instrs0, Instrs, !Livevals, +livemap.look_for_livevals(Instrs0, Instrs, !Livevals, Site, Compulsory, Found) :- - opt_util__skip_comments(Instrs0, Instrs1), + opt_util.skip_comments(Instrs0, Instrs1), ( Instrs1 = [livevals(Livevals1) - _ | Instrs2] -> - livemap__filter_livevals(Livevals1, !:Livevals), + livemap.filter_livevals(Livevals1, !:Livevals), Instrs = Instrs2, Found = yes ; Compulsory = yes -> @@ -365,106 +365,106 @@ livemap__look_for_livevals(Instrs0, Instrs, !Livevals, % What lval (if any) is consulted when we branch to a code address? % -:- pred livemap__special_code_addr(code_addr::in, maybe(lval)::out) is det. +:- pred livemap.special_code_addr(code_addr::in, maybe(lval)::out) is det. -livemap__special_code_addr(label(_), no). -livemap__special_code_addr(imported(_), no). -livemap__special_code_addr(succip, yes(succip)). -livemap__special_code_addr(do_succeed(_), yes(succip(lval(curfr)))). -livemap__special_code_addr(do_redo, yes(redoip(lval(maxfr)))). -livemap__special_code_addr(do_trace_redo_fail_shallow, no). -livemap__special_code_addr(do_trace_redo_fail_deep, no). -livemap__special_code_addr(do_fail, no). -livemap__special_code_addr(do_call_closure(_), no). -livemap__special_code_addr(do_call_class_method(_), no). -livemap__special_code_addr(do_not_reached, no). +livemap.special_code_addr(label(_), no). +livemap.special_code_addr(imported(_), no). +livemap.special_code_addr(succip, yes(succip)). +livemap.special_code_addr(do_succeed(_), yes(succip(lval(curfr)))). +livemap.special_code_addr(do_redo, yes(redoip(lval(maxfr)))). +livemap.special_code_addr(do_trace_redo_fail_shallow, no). +livemap.special_code_addr(do_trace_redo_fail_deep, no). +livemap.special_code_addr(do_fail, no). +livemap.special_code_addr(do_call_closure(_), no). +livemap.special_code_addr(do_call_class_method(_), no). +livemap.special_code_addr(do_not_reached, no). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- pred livemap__make_live_in_rvals(list(rval)::in, lvalset::in, lvalset::out) +:- pred livemap.make_live_in_rvals(list(rval)::in, lvalset::in, lvalset::out) is det. -livemap__make_live_in_rvals([], !Live). -livemap__make_live_in_rvals([Rval | Rvals], !Live) :- - livemap__make_live_in_rval(Rval, !Live), - livemap__make_live_in_rvals(Rvals, !Live). +livemap.make_live_in_rvals([], !Live). +livemap.make_live_in_rvals([Rval | Rvals], !Live) :- + livemap.make_live_in_rval(Rval, !Live), + livemap.make_live_in_rvals(Rvals, !Live). % Set all lvals found in this rval to live, with the exception of fields, % since they are treated specially (the later stages consider them % to be live even if they are not explicitly in the live set). % -:- pred livemap__make_live_in_rval(rval::in, lvalset::in, lvalset::out) is det. +:- pred livemap.make_live_in_rval(rval::in, lvalset::in, lvalset::out) is det. -livemap__make_live_in_rval(lval(Lval), !Live) :- +livemap.make_live_in_rval(lval(Lval), !Live) :- % XXX maybe we should treat mem_refs the same way as field refs ( Lval = field(_, _, _) -> true ; - set__insert(!.Live, Lval, !:Live) + set.insert(!.Live, Lval, !:Live) ), - opt_util__lval_access_rvals(Lval, AccessRvals), - livemap__make_live_in_rvals(AccessRvals, !Live). -livemap__make_live_in_rval(mkword(_, Rval), !Live) :- - livemap__make_live_in_rval(Rval, !Live). -livemap__make_live_in_rval(const(_), !Live). -livemap__make_live_in_rval(unop(_, Rval), !Live) :- - livemap__make_live_in_rval(Rval, !Live). -livemap__make_live_in_rval(binop(_, Rval1, Rval2), !Live) :- - livemap__make_live_in_rval(Rval1, !Live), - livemap__make_live_in_rval(Rval2, !Live). -livemap__make_live_in_rval(var(_), _, _) :- + opt_util.lval_access_rvals(Lval, AccessRvals), + livemap.make_live_in_rvals(AccessRvals, !Live). +livemap.make_live_in_rval(mkword(_, Rval), !Live) :- + livemap.make_live_in_rval(Rval, !Live). +livemap.make_live_in_rval(const(_), !Live). +livemap.make_live_in_rval(unop(_, Rval), !Live) :- + livemap.make_live_in_rval(Rval, !Live). +livemap.make_live_in_rval(binop(_, Rval1, Rval2), !Live) :- + livemap.make_live_in_rval(Rval1, !Live), + livemap.make_live_in_rval(Rval2, !Live). +livemap.make_live_in_rval(var(_), _, _) :- unexpected(this_file, "var rval should not propagate to the optimizer"). -livemap__make_live_in_rval(mem_addr(MemRef), !Live) :- - livemap__make_live_in_mem_ref(MemRef, !Live). +livemap.make_live_in_rval(mem_addr(MemRef), !Live) :- + livemap.make_live_in_mem_ref(MemRef, !Live). -:- pred livemap__make_live_in_mem_ref(mem_ref::in, lvalset::in, lvalset::out) +:- pred livemap.make_live_in_mem_ref(mem_ref::in, lvalset::in, lvalset::out) is det. -livemap__make_live_in_mem_ref(stackvar_ref(_), !Live). -livemap__make_live_in_mem_ref(framevar_ref(_), !Live). -livemap__make_live_in_mem_ref(heap_ref(Rval, _, _), !Live) :- - livemap__make_live_in_rval(Rval, !Live). +livemap.make_live_in_mem_ref(stackvar_ref(_), !Live). +livemap.make_live_in_mem_ref(framevar_ref(_), !Live). +livemap.make_live_in_mem_ref(heap_ref(Rval, _, _), !Live) :- + livemap.make_live_in_rval(Rval, !Live). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- pred livemap__filter_livevals(lvalset::in, lvalset::out) is det. +:- pred livemap.filter_livevals(lvalset::in, lvalset::out) is det. -livemap__filter_livevals(Livevals0, Livevals) :- - set__to_sorted_list(Livevals0, Livelist), - set__init(Livevals1), - livemap__insert_proper_livevals(Livelist, Livevals1, Livevals). +livemap.filter_livevals(Livevals0, Livevals) :- + set.to_sorted_list(Livevals0, Livelist), + set.init(Livevals1), + livemap.insert_proper_livevals(Livelist, Livevals1, Livevals). -:- pred livemap__insert_label_livevals(livemap::in, label::in, +:- pred livemap.insert_label_livevals(livemap::in, label::in, lvalset::in, lvalset::out) is det. -livemap__insert_label_livevals(Livemap, Label, !Livevals) :- - ( map__search(Livemap, Label, LabelLivevals) -> - set__to_sorted_list(LabelLivevals, Livelist), - livemap__insert_proper_livevals(Livelist, !Livevals) +livemap.insert_label_livevals(Livemap, Label, !Livevals) :- + ( map.search(Livemap, Label, LabelLivevals) -> + set.to_sorted_list(LabelLivevals, Livelist), + livemap.insert_proper_livevals(Livelist, !Livevals) ; true ). -:- pred livemap__insert_proper_livevals(list(lval)::in, lvalset::in, +:- pred livemap.insert_proper_livevals(list(lval)::in, lvalset::in, lvalset::out) is det. -livemap__insert_proper_livevals([], !Livevals). -livemap__insert_proper_livevals([Live | Livelist], !Livevals) :- - livemap__insert_proper_liveval(Live, !Livevals), - livemap__insert_proper_livevals(Livelist, !Livevals). +livemap.insert_proper_livevals([], !Livevals). +livemap.insert_proper_livevals([Live | Livelist], !Livevals) :- + livemap.insert_proper_liveval(Live, !Livevals), + livemap.insert_proper_livevals(Livelist, !Livevals). % Don't insert references to locations on the heap. % -:- pred livemap__insert_proper_liveval(lval::in, lvalset::in, lvalset::out) +:- pred livemap.insert_proper_liveval(lval::in, lvalset::in, lvalset::out) is det. -livemap__insert_proper_liveval(Live, !Livevals) :- +livemap.insert_proper_liveval(Live, !Livevals) :- ( Live = field(_, _, _) -> true ; - set__insert(!.Livevals, Live, !:Livevals) + set.insert(!.Livevals, Live, !:Livevals) ). %-----------------------------------------------------------------------------% diff --git a/compiler/liveness.m b/compiler/liveness.m index b5f0333aa..99b63b888 100644 --- a/compiler/liveness.m +++ b/compiler/liveness.m @@ -148,7 +148,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__liveness. +:- module ll_backend.liveness. :- interface. :- import_module hlds.hlds_module. @@ -221,7 +221,7 @@ detect_liveness_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :- live_info_init(ModuleInfo, TypeInfoLiveness, VarTypes, RttiVarMaps, VarSet, LiveInfo), - globals__lookup_int_option(Globals, debug_liveness, DebugLiveness), + globals.lookup_int_option(Globals, debug_liveness, DebugLiveness), pred_id_to_int(PredId, PredIdInt), maybe_write_progress_message("\nbefore liveness", DebugLiveness, PredIdInt, Goal0, VarSet, ModuleInfo, !IO), @@ -238,10 +238,10 @@ detect_liveness_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :- DebugLiveness, PredIdInt, Goal2, VarSet, ModuleInfo, !IO), ( - globals__get_trace_level(Globals, TraceLevel), + globals.get_trace_level(Globals, TraceLevel), AllowDelayDeath = trace_level_allows_delay_death(TraceLevel), AllowDelayDeath = yes, - globals__lookup_bool_option(Globals, delay_death, DelayDeath), + globals.lookup_bool_option(Globals, delay_death, DelayDeath), DelayDeath = yes -> delay_death_proc_body(Goal2, Goal3, VarSet, Liveness0), @@ -251,11 +251,11 @@ detect_liveness_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :- Goal3 = Goal2 ), - globals__get_trace_level(Globals, TraceLevel), + globals.get_trace_level(Globals, TraceLevel), ( eff_trace_level_is_none(PredInfo, !.ProcInfo, TraceLevel) = no -> - trace__fail_vars(ModuleInfo, !.ProcInfo, ResumeVars0) + trace.fail_vars(ModuleInfo, !.ProcInfo, ResumeVars0) ; - set__init(ResumeVars0) + set.init(ResumeVars0) ), detect_resume_points_in_goal(Goal3, Goal, Liveness0, _, LiveInfo, ResumeVars0), @@ -271,9 +271,9 @@ detect_liveness_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :- maybe_write_progress_message(Message, DebugLiveness, PredIdInt, Goal, VarSet, ModuleInfo, !IO) :- ( DebugLiveness = PredIdInt -> - io__write_string(Message, !IO), - io__write_string(":\n", !IO), - hlds_out__write_goal(Goal, ModuleInfo, VarSet, yes, 0, "\n", !IO) + io.write_string(Message, !IO), + io.write_string(":\n", !IO), + hlds_out.write_goal(Goal, ModuleInfo, VarSet, yes, 0, "\n", !IO) ; true ). @@ -288,21 +288,21 @@ detect_liveness_in_goal(Goal0 - GoalInfo0, Goal - GoalInfo, Liveness0, Liveness, LiveInfo) :- % work out which variables get born in this goal - liveness__get_nonlocals_and_typeinfos(LiveInfo, GoalInfo0, + liveness.get_nonlocals_and_typeinfos(LiveInfo, GoalInfo0, BaseNonLocals, CompletedNonLocals), - set__difference(CompletedNonLocals, Liveness0, NewVarsSet), - set__to_sorted_list(NewVarsSet, NewVarsList), + set.difference(CompletedNonLocals, Liveness0, NewVarsSet), + set.to_sorted_list(NewVarsSet, NewVarsList), goal_info_get_instmap_delta(GoalInfo0, InstMapDelta), - set__init(Empty), + set.init(Empty), ( instmap_delta_is_unreachable(InstMapDelta) -> Births = Empty ; - set__init(Births0), + set.init(Births0), find_value_giving_occurrences(NewVarsList, LiveInfo, InstMapDelta, Births0, Births1), - set__difference(CompletedNonLocals, BaseNonLocals, TypeInfos), - set__difference(TypeInfos, Liveness0, NewTypeInfos), - set__union(Births1, NewTypeInfos, Births) + set.difference(CompletedNonLocals, BaseNonLocals, TypeInfos), + set.difference(TypeInfos, Liveness0, NewTypeInfos), + set.union(Births1, NewTypeInfos, Births) ), ( goal_is_atomic(Goal0) -> PreDeaths = Empty, @@ -315,12 +315,12 @@ detect_liveness_in_goal(Goal0 - GoalInfo0, Goal - GoalInfo, PreBirths = Empty, detect_liveness_in_goal_2(Goal0, Goal, Liveness0, ActualLiveness, CompletedNonLocals, LiveInfo), - set__intersect(CompletedNonLocals, ActualLiveness, NonLocalLiveness), - set__union(NonLocalLiveness, Liveness0, FinalLiveness), - set__difference(FinalLiveness, Liveness, PostDeaths), - set__difference(Liveness, FinalLiveness, PostBirths) + set.intersect(CompletedNonLocals, ActualLiveness, NonLocalLiveness), + set.union(NonLocalLiveness, Liveness0, FinalLiveness), + set.difference(FinalLiveness, Liveness, PostDeaths), + set.difference(Liveness, FinalLiveness, PostBirths) ), - set__union(Liveness0, Births, Liveness), + set.union(Liveness0, Births, Liveness), % We initialize all the fields in order to obliterate any % annotations left by a previous invocation of this module. goal_info_initialize_liveness_info(PreBirths, PostBirths, @@ -341,18 +341,18 @@ detect_liveness_in_goal_2(conj(ConjType, Goals0), conj(ConjType, Goals), detect_liveness_in_conj(Goals0, Goals, !Liveness, LiveInfo) ; ConjType = parallel_conj, - set__init(Union0), + set.init(Union0), detect_liveness_in_par_conj(Goals0, Goals, !.Liveness, NonLocals, LiveInfo, Union0, Union), - set__union(Union, !Liveness) + set.union(Union, !Liveness) ). detect_liveness_in_goal_2(disj(Goals0), disj(Goals), !Liveness, NonLocals, LiveInfo) :- - set__init(Union0), + set.init(Union0), detect_liveness_in_disj(Goals0, Goals, !.Liveness, NonLocals, LiveInfo, Union0, Union), - set__union(Union, !Liveness). + set.union(Union, !Liveness). detect_liveness_in_goal_2(switch(Var, Det, Cases0), switch(Var, Det, Cases), !Liveness, NonLocals, LiveInfo) :- @@ -382,11 +382,11 @@ detect_liveness_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0), detect_liveness_in_goal(Else0, Else1, Liveness0, LivenessElse, LiveInfo), - set__union(LivenessThen, LivenessElse, Liveness), - set__intersect(Liveness, NonLocals, NonLocalLiveness), + set.union(LivenessThen, LivenessElse, Liveness), + set.intersect(Liveness, NonLocals, NonLocalLiveness), - set__difference(NonLocalLiveness, LivenessThen, ResidueThen), - set__difference(NonLocalLiveness, LivenessElse, ResidueElse), + set.difference(NonLocalLiveness, LivenessThen, ResidueThen), + set.difference(NonLocalLiveness, LivenessElse, ResidueElse), add_liveness_after_goal(Then1, ResidueThen, Then), add_liveness_after_goal(Else1, ResidueElse, Else). @@ -445,11 +445,11 @@ detect_liveness_in_disj([], [], _Liveness, _NonLocals, _LiveInfo, !Union). detect_liveness_in_disj([Goal0 | Goals0], [Goal | Goals], Liveness0, NonLocals, LiveInfo, !Union) :- detect_liveness_in_goal(Goal0, Goal1, Liveness0, Liveness1, LiveInfo), - set__union(Liveness1, !Union), + set.union(Liveness1, !Union), detect_liveness_in_disj(Goals0, Goals, Liveness0, NonLocals, LiveInfo, !Union), - set__intersect(!.Union, NonLocals, NonLocalUnion), - set__difference(NonLocalUnion, Liveness1, Residue), + set.intersect(!.Union, NonLocals, NonLocalUnion), + set.difference(NonLocalUnion, Liveness1, Residue), add_liveness_after_goal(Goal1, Residue, Goal). %-----------------------------------------------------------------------------% @@ -462,11 +462,11 @@ detect_liveness_in_cases([], [], _Liveness, _NonLocals, _LiveInfo, !Union). detect_liveness_in_cases([case(Cons, Goal0) | Goals0], [case(Cons, Goal) | Goals], Liveness0, NonLocals, LiveInfo, !Union) :- detect_liveness_in_goal(Goal0, Goal1, Liveness0, Liveness1, LiveInfo), - set__union(Liveness1, !Union), + set.union(Liveness1, !Union), detect_liveness_in_cases(Goals0, Goals, Liveness0, NonLocals, LiveInfo, !Union), - set__intersect(!.Union, NonLocals, NonLocalUnion), - set__difference(NonLocalUnion, Liveness1, Residue), + set.intersect(!.Union, NonLocals, NonLocalUnion), + set.difference(NonLocalUnion, Liveness1, Residue), add_liveness_after_goal(Goal1, Residue, Goal). %-----------------------------------------------------------------------------% @@ -479,11 +479,11 @@ detect_liveness_in_par_conj([], [], _Liveness, _NonLocals, _LiveInfo, !Union). detect_liveness_in_par_conj([Goal0 | Goals0], [Goal | Goals], Liveness0, NonLocals, LiveInfo, !Union) :- detect_liveness_in_goal(Goal0, Goal1, Liveness0, Liveness1, LiveInfo), - set__union(Liveness1, !Union), + set.union(Liveness1, !Union), detect_liveness_in_par_conj(Goals0, Goals, Liveness0, NonLocals, LiveInfo, !Union), - set__intersect(!.Union, NonLocals, NonLocalUnion), - set__difference(NonLocalUnion, Liveness1, Residue), + set.intersect(!.Union, NonLocals, NonLocalUnion), + set.difference(NonLocalUnion, Liveness1, Residue), add_liveness_after_goal(Goal1, Residue, Goal). %-----------------------------------------------------------------------------% @@ -500,30 +500,30 @@ detect_deadness_in_goal(Goal0 - GoalInfo0, Goal - GoalInfo, !Deadness, goal_info_get_post_deaths(GoalInfo0, PostDeaths0), goal_info_get_post_births(GoalInfo0, PostBirths0), - set__difference(!.Deadness, PostBirths0, !:Deadness), - set__union(PostDeaths0, !Deadness), + set.difference(!.Deadness, PostBirths0, !:Deadness), + set.union(PostDeaths0, !Deadness), - set__difference(!.Liveness, PreDeaths0, !:Liveness), - set__union(PreBirths0, !Liveness), + set.difference(!.Liveness, PreDeaths0, !:Liveness), + set.union(PreBirths0, !Liveness), - set__init(Empty), + set.init(Empty), ( goal_is_atomic(Goal0) -> - liveness__get_nonlocals_and_typeinfos(LiveInfo, GoalInfo0, + liveness.get_nonlocals_and_typeinfos(LiveInfo, GoalInfo0, _BaseNonLocals, CompletedNonLocals), - set__intersect(!.Liveness, CompletedNonLocals, LiveNonLocals), - set__difference(LiveNonLocals, !.Deadness, NewPostDeaths), - set__union(NewPostDeaths, !Deadness), + set.intersect(!.Liveness, CompletedNonLocals, LiveNonLocals), + set.difference(LiveNonLocals, !.Deadness, NewPostDeaths), + set.union(NewPostDeaths, !Deadness), Goal = Goal0 ; NewPostDeaths = Empty, detect_deadness_in_goal_2(Goal0, Goal, GoalInfo0, !Deadness, !.Liveness, LiveInfo) ), - set__union(PostDeaths0, NewPostDeaths, PostDeaths), + set.union(PostDeaths0, NewPostDeaths, PostDeaths), goal_info_set_post_deaths(PostDeaths, GoalInfo0, GoalInfo), - set__difference(!.Deadness, PreBirths0, !:Deadness), - set__union(PreDeaths0, !Deadness). + set.difference(!.Deadness, PreBirths0, !:Deadness), + set.union(PreDeaths0, !Deadness). % Here we process each of the different sorts of goals. % @@ -538,18 +538,18 @@ detect_deadness_in_goal_2(conj(ConjType, Goals0), conj(ConjType, Goals), detect_deadness_in_conj(Goals0, Goals, !Deadness, Liveness0, LiveInfo) ; ConjType = parallel_conj, - liveness__get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, + liveness.get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, _, CompletedNonLocals), - set__init(Union0), + set.init(Union0), detect_deadness_in_par_conj(Goals0, Goals, !.Deadness, Liveness0, CompletedNonLocals, LiveInfo, Union0, Union), - set__union(Union, !Deadness) + set.union(Union, !Deadness) ). detect_deadness_in_goal_2(disj(Goals0), disj(Goals), GoalInfo, !Deadness, Liveness0, LiveInfo) :- - set__init(Union0), - liveness__get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, + set.init(Union0), + liveness.get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, _, CompletedNonLocals), detect_deadness_in_disj(Goals0, Goals, !.Deadness, Liveness0, CompletedNonLocals, LiveInfo, Union0, Union, _), @@ -557,8 +557,8 @@ detect_deadness_in_goal_2(disj(Goals0), disj(Goals), GoalInfo, !Deadness, detect_deadness_in_goal_2(switch(Var, Det, Cases0), switch(Var, Det, Cases), GoalInfo, !Deadness, Liveness0, LiveInfo) :- - set__init(Union0), - liveness__get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, + set.init(Union0), + liveness.get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, _, CompletedNonLocals), detect_deadness_in_cases(Var, Cases0, Cases, !.Deadness, Liveness0, CompletedNonLocals, LiveInfo, Union0, Union, _), @@ -580,7 +580,7 @@ detect_deadness_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0), detect_deadness_in_goal(Cond0, Cond1, DeadnessThen, DeadnessCond, Liveness0, LiveInfo), - liveness__get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, + liveness.get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, _, CompletedNonLocals), goal_info_get_instmap_delta(GoalInfo, InstmapDelta), ( instmap_delta_is_reachable(InstmapDelta) -> @@ -605,21 +605,21 @@ detect_deadness_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0), ; ElseInstmapReachable = no ), - set__init(Union0), + set.init(Union0), union_branch_deadness(DeadnessCond, Deadness0, CondThenInstmapReachable, Union0, Union1), union_branch_deadness(DeadnessElse, Deadness0, ElseInstmapReachable, Union1, Union), Deadness = Union, - set__intersect(Deadness, CompletedNonLocals, + set.intersect(Deadness, CompletedNonLocals, CompletedNonLocalDeadness), add_branch_pre_deaths(DeadnessCond, Deadness0, CompletedNonLocalDeadness, CondThenInstmapReachable, Cond1, Cond), add_branch_pre_deaths(DeadnessElse, Deadness0, CompletedNonLocalDeadness, ElseInstmapReachable, Else1, Else) ; - set__union(DeadnessCond, DeadnessElse, Deadness), - set__intersect(Deadness, CompletedNonLocals, + set.union(DeadnessCond, DeadnessElse, Deadness), + set.intersect(Deadness, CompletedNonLocals, CompletedNonLocalDeadness), add_branch_pre_deaths(DeadnessCond, Deadness0, CompletedNonLocalDeadness, yes, Cond1, Cond), @@ -677,7 +677,7 @@ detect_deadness_in_conj([Goal0 | Goals0], [Goal | Goals], !Deadness, detect_deadness_in_disj([], [], _Deadness0, _Liveness0, CompletedNonLocals, _LiveInfo, !Union, CompletedNonLocalUnion) :- - set__intersect(!.Union, CompletedNonLocals, CompletedNonLocalUnion). + set.intersect(!.Union, CompletedNonLocals, CompletedNonLocalUnion). detect_deadness_in_disj([Goal0 | Goals0], [Goal | Goals], Deadness0, Liveness0, CompletedNonLocals, LiveInfo, !Union, CompletedNonLocalUnion) :- detect_deadness_in_goal(Goal0, Goal1, Deadness0, DeadnessGoal, @@ -705,8 +705,8 @@ detect_deadness_in_cases(SwitchVar, [], [], _Deadness0, _Liveness, CompletedNonLocals, _LiveInfo, !Union, CompletedNonLocalUnion) :- % If the switch variable does not become dead in a case, % it must be put in the pre-death set of that case. - set__insert(!.Union, SwitchVar, !:Union), - set__intersect(!.Union, CompletedNonLocals, CompletedNonLocalUnion). + set.insert(!.Union, SwitchVar, !:Union), + set.intersect(!.Union, CompletedNonLocals, CompletedNonLocalUnion). detect_deadness_in_cases(SwitchVar, [case(Cons, Goal0) | Goals0], [case(Cons, Goal) | Goals], Deadness0, Liveness0, CompletedNonLocals, LiveInfo, !Union, CompletedNonLocalUnion) :- @@ -738,11 +738,11 @@ detect_deadness_in_par_conj([Goal0 | Goals0], [Goal | Goals], Deadness0, Liveness0, NonLocals, LiveInfo, !Union) :- detect_deadness_in_goal(Goal0, Goal1, Deadness0, Deadness1, Liveness0, LiveInfo), - set__union(Deadness1, !Union), + set.union(Deadness1, !Union), detect_deadness_in_par_conj(Goals0, Goals, Deadness0, Liveness0, NonLocals, LiveInfo, !Union), - set__intersect(!.Union, NonLocals, NonLocalUnion), - set__difference(NonLocalUnion, Deadness1, Residue), + set.intersect(!.Union, NonLocals, NonLocalUnion), + set.difference(NonLocalUnion, Deadness1, Residue), add_deadness_before_goal(Residue, Goal1, Goal). %-----------------------------------------------------------------------------% @@ -783,11 +783,11 @@ detect_deadness_in_par_conj([Goal0 | Goals0], [Goal | Goals], Deadness0, union_branch_deadness(DeadnessGoal, Deadness0, InstmapReachable, !Union) :- ( InstmapReachable = yes, - set__union(!.Union, DeadnessGoal, !:Union) + set.union(!.Union, DeadnessGoal, !:Union) ; InstmapReachable = no, - set__difference(DeadnessGoal, Deadness0, FilteredDeadnessGoal), - set__union(!.Union, FilteredDeadnessGoal, !:Union) + set.difference(DeadnessGoal, Deadness0, FilteredDeadnessGoal), + set.union(!.Union, FilteredDeadnessGoal, !:Union) ). :- pred add_branch_pre_deaths(set(prog_var)::in, set(prog_var)::in, @@ -795,13 +795,13 @@ union_branch_deadness(DeadnessGoal, Deadness0, InstmapReachable, !Union) :- add_branch_pre_deaths(DeadnessGoal, Deadness0, CompletedNonLocalUnion, InstmapReachable, !Goal) :- - set__difference(CompletedNonLocalUnion, DeadnessGoal, PreDeaths), + set.difference(CompletedNonLocalUnion, DeadnessGoal, PreDeaths), ( InstmapReachable = yes, add_deadness_before_goal(PreDeaths, !Goal) ; InstmapReachable = no, - set__difference(PreDeaths, Deadness0, FilteredPreDeaths), + set.difference(PreDeaths, Deadness0, FilteredPreDeaths), add_deadness_before_goal(FilteredPreDeaths, !Goal) ). @@ -817,17 +817,17 @@ update_liveness_goal(GoalExpr - GoalInfo, LiveInfo, !Liveness) :- goal_info_get_post_births(GoalInfo, PostBirths), Liveness0 = !.Liveness, - set__difference(!.Liveness, PreDeaths, !:Liveness), - set__union(PreBirths, !Liveness), + set.difference(!.Liveness, PreDeaths, !:Liveness), + set.union(PreBirths, !Liveness), update_liveness_expr(GoalExpr, GoalInfo, LiveInfo, !Liveness), - set__difference(!.Liveness, PostDeaths, !:Liveness), - set__union(PostBirths, !Liveness), + set.difference(!.Liveness, PostDeaths, !:Liveness), + set.union(PostBirths, !Liveness), - set__divide_by_set(Liveness0, !.Liveness, OldLiveness, NewLiveness0), - liveness__get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, + set.divide_by_set(Liveness0, !.Liveness, OldLiveness, NewLiveness0), + liveness.get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, _, CompletedNonLocals), - set__intersect(NewLiveness0, CompletedNonLocals, NewLiveness), - set__union(OldLiveness, NewLiveness, !:Liveness). + set.intersect(NewLiveness0, CompletedNonLocals, NewLiveness), + set.union(OldLiveness, NewLiveness, !:Liveness). :- pred update_liveness_expr(hlds_goal_expr::in, hlds_goal_info::in, live_info::in, set(prog_var)::in, set(prog_var)::out) is det. @@ -934,11 +934,11 @@ find_reachable_case([case(_, Goal) | Cases], ReachableGoal) :- set(prog_var)::in) is det. delay_death_proc_body(Goal0, Goal, VarSet, BornVars0) :- - delay_death_goal(Goal0, Goal1, BornVars0, _, set__init, DelayedDead, + delay_death_goal(Goal0, Goal1, BornVars0, _, set.init, DelayedDead, VarSet), Goal1 = GoalExpr - GoalInfo1, goal_info_get_post_deaths(GoalInfo1, PostDeaths1), - set__union(PostDeaths1, DelayedDead, PostDeaths), + set.union(PostDeaths1, DelayedDead, PostDeaths), goal_info_set_post_deaths(PostDeaths, GoalInfo1, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -952,10 +952,10 @@ delay_death_goal(GoalExpr0 - GoalInfo0, GoalExpr - GoalInfo, goal_info_get_pre_deaths(GoalInfo0, PreDeaths0), BornVars0 = !.BornVars, - set__union(PreBirths, !BornVars), - set__divide(var_is_named(VarSet), PreDeaths0, + set.union(PreBirths, !BornVars), + set.divide(var_is_named(VarSet), PreDeaths0, PreDelayedDead, UnnamedPreDeaths), - set__union(PreDelayedDead, !DelayedDead), + set.union(PreDelayedDead, !DelayedDead), goal_info_set_pre_deaths(UnnamedPreDeaths, GoalInfo0, GoalInfo1), delay_death_goal_expr(GoalExpr0, GoalExpr, GoalInfo1, GoalInfo2, @@ -964,18 +964,18 @@ delay_death_goal(GoalExpr0 - GoalInfo0, GoalExpr - GoalInfo, goal_info_get_post_births(GoalInfo2, PostBirths), goal_info_get_post_deaths(GoalInfo2, PostDeaths2), - set__union(PostBirths, !BornVars), - set__divide(var_is_named(VarSet), PostDeaths2, + set.union(PostBirths, !BornVars), + set.divide(var_is_named(VarSet), PostDeaths2, PostDelayedDead, UnnamedPostDeaths), - set__union(PostDelayedDead, !DelayedDead), - set__divide_by_set(BornVars0, !.DelayedDead, !:DelayedDead, ToBeKilled), - set__union(UnnamedPostDeaths, ToBeKilled, PostDeaths), + set.union(PostDelayedDead, !DelayedDead), + set.divide_by_set(BornVars0, !.DelayedDead, !:DelayedDead, ToBeKilled), + set.union(UnnamedPostDeaths, ToBeKilled, PostDeaths), goal_info_set_post_deaths(PostDeaths, GoalInfo2, GoalInfo). :- pred var_is_named(prog_varset::in, prog_var::in) is semidet. var_is_named(VarSet, Var) :- - varset__search_name(VarSet, Var, _). + varset.search_name(VarSet, Var, _). :- pred delay_death_goal_expr(hlds_goal_expr::in, hlds_goal_expr::out, hlds_goal_info::in, hlds_goal_info::out, @@ -1008,7 +1008,7 @@ delay_death_goal_expr(!GoalExpr, !GoalInfo, !BornVars, !DelayedDead, VarSet) :- VarSet, MaybeBornVarsDelayedDead), ( MaybeBornVarsDelayedDead = yes(!:BornVars - !:DelayedDead), - Goals = list__map(kill_excess_delayed_dead_goal(!.DelayedDead), + Goals = list.map(kill_excess_delayed_dead_goal(!.DelayedDead), GoalDeaths), !:GoalExpr = disj(Goals) ; @@ -1022,7 +1022,7 @@ delay_death_goal_expr(!GoalExpr, !GoalInfo, !BornVars, !DelayedDead, VarSet) :- VarSet, MaybeBornVarsDelayedDead), ( MaybeBornVarsDelayedDead = yes(!:BornVars - !:DelayedDead), - Cases = list__map(kill_excess_delayed_dead_case(!.DelayedDead), + Cases = list.map(kill_excess_delayed_dead_case(!.DelayedDead), CaseDeaths), !:GoalExpr = switch(Var, CanFail, Cases) ; @@ -1043,8 +1043,8 @@ delay_death_goal_expr(!GoalExpr, !GoalInfo, !BornVars, !DelayedDead, VarSet) :- DelayedDeadCond, DelayedDeadThen, VarSet), delay_death_goal(Else0, Else1, BornVars0, BornVarsElse, DelayedDead0, DelayedDeadElse, VarSet), - set__intersect(BornVarsThen, BornVarsElse, BornVars), - set__intersect(DelayedDeadThen, DelayedDeadElse, DelayedDead), + set.intersect(BornVarsThen, BornVarsElse, BornVars), + set.intersect(DelayedDeadThen, DelayedDeadElse, DelayedDead), Then = kill_excess_delayed_dead_goal(DelayedDead, Then1 - DelayedDeadThen), !:BornVars = BornVars, @@ -1082,8 +1082,8 @@ delay_death_par_conj([Goal0 | Goals0], [Goal | Goals], DelayedDead0, DelayedDeadGoal, VarSet), delay_death_par_conj(Goals0, Goals, BornVars0, BornVarsGoals, DelayedDead0, DelayedDeadGoals, VarSet), - set__union(BornVarsGoal, BornVarsGoals, BornVars), - set__union(DelayedDeadGoal, DelayedDeadGoals, DelayedDead). + set.union(BornVarsGoal, BornVarsGoals, BornVars), + set.union(DelayedDeadGoal, DelayedDeadGoals, DelayedDead). :- pred delay_death_disj(list(hlds_goal)::in, assoc_list(hlds_goal, set(prog_var))::out, @@ -1099,8 +1099,8 @@ delay_death_disj([Goal0 | Goals0], [Goal - DelayedDeadGoal | Goals], MaybeBornVarsDelayedDead), ( MaybeBornVarsDelayedDead = yes(BornVarsGoals - DelayedDeadGoals), - set__intersect(BornVarsGoal, BornVarsGoals, BornVars), - set__intersect(DelayedDeadGoal, DelayedDeadGoals, DelayedDead) + set.intersect(BornVarsGoal, BornVarsGoals, BornVars), + set.intersect(DelayedDeadGoal, DelayedDeadGoals, DelayedDead) ; MaybeBornVarsDelayedDead = no, BornVars = BornVarsGoal, @@ -1121,8 +1121,8 @@ delay_death_cases([case(ConsId, Goal0) | Cases0], MaybeBornVarsDelayedDead), ( MaybeBornVarsDelayedDead = yes(BornVarsCases - DelayedDeadCases), - set__intersect(BornVarsGoal, BornVarsCases, BornVars), - set__intersect(DelayedDeadGoal, DelayedDeadCases, DelayedDead) + set.intersect(BornVarsGoal, BornVarsCases, BornVars), + set.intersect(DelayedDeadGoal, DelayedDeadCases, DelayedDead) ; MaybeBornVarsDelayedDead = no, BornVars = BornVarsGoal, @@ -1137,10 +1137,10 @@ delay_death_cases([case(ConsId, Goal0) | Cases0], pair(hlds_goal, set(prog_var))) = hlds_goal. kill_excess_delayed_dead_goal(FinalDelayedDead, Goal0 - DelayedDead0) = Goal :- - set__difference(DelayedDead0, FinalDelayedDead, ToBeKilled), + set.difference(DelayedDead0, FinalDelayedDead, ToBeKilled), Goal0 = GoalExpr - GoalInfo0, goal_info_get_post_deaths(GoalInfo0, PostDeath0), - set__union(PostDeath0, ToBeKilled, PostDeath), + set.union(PostDeath0, ToBeKilled, PostDeath), goal_info_set_post_deaths(PostDeath, GoalInfo0, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -1149,10 +1149,10 @@ kill_excess_delayed_dead_goal(FinalDelayedDead, Goal0 - DelayedDead0) = Goal :- kill_excess_delayed_dead_case(FinalDelayedDead, case(ConsId, Goal0) - DelayedDead0) = case(ConsId, Goal) :- - set__difference(DelayedDead0, FinalDelayedDead, ToBeKilled), + set.difference(DelayedDead0, FinalDelayedDead, ToBeKilled), Goal0 = GoalExpr - GoalInfo0, goal_info_get_post_deaths(GoalInfo0, PostDeath0), - set__union(PostDeath0, ToBeKilled, PostDeath), + set.union(PostDeath0, ToBeKilled, PostDeath), goal_info_set_post_deaths(PostDeath, GoalInfo0, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -1170,14 +1170,14 @@ detect_resume_points_in_goal(Goal0 - GoalInfo0, Goal - GoalInfo0, goal_info_get_post_deaths(GoalInfo0, PostDeaths0), goal_info_get_post_births(GoalInfo0, PostBirths0), - set__difference(!.Liveness, PreDeaths0, !:Liveness), - set__union(PreBirths0, !Liveness), + set.difference(!.Liveness, PreDeaths0, !:Liveness), + set.union(PreBirths0, !Liveness), detect_resume_points_in_goal_2(Goal0, Goal, !Liveness, GoalInfo0, LiveInfo, ResumeVars0), - set__difference(!.Liveness, PostDeaths0, !:Liveness), - set__union(PostBirths0, !Liveness). + set.difference(!.Liveness, PostDeaths0, !:Liveness), + set.union(PostBirths0, !Liveness). :- pred detect_resume_points_in_goal_2(hlds_goal_expr::in, hlds_goal_expr::out, set(prog_var)::in, set(prog_var)::out, hlds_goal_info::in, @@ -1219,11 +1219,11 @@ detect_resume_points_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0), % of the else part and attach this set to the condition. Else0 = _ElseExpr0 - ElseInfo0, goal_info_get_pre_deaths(ElseInfo0, ElsePreDeath0), - set__difference(Liveness0, ElsePreDeath0, CondResumeVars0), - liveness__maybe_complete_with_typeinfos(LiveInfo, CondResumeVars0, + set.difference(Liveness0, ElsePreDeath0, CondResumeVars0), + liveness.maybe_complete_with_typeinfos(LiveInfo, CondResumeVars0, CondResumeVars1), % ResumeVars0 should already have been completed. - set__union(CondResumeVars1, ResumeVars0, CondResumeVars), + set.union(CondResumeVars1, ResumeVars0, CondResumeVars), detect_resume_points_in_goal(Cond0, Cond1, Liveness0, LivenessCond, LiveInfo, CondResumeVars), @@ -1242,7 +1242,7 @@ detect_resume_points_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0), -> CondResumeLocs = orig_only ; - set__empty(CondResumeVars) + set.empty(CondResumeVars) -> % There is no difference between orig_only and stack_only when % there are no resume variables, but some parts of code_info @@ -1273,10 +1273,10 @@ detect_resume_points_in_goal_2(not(Goal0), not(Goal), Liveness0, Liveness, _, LiveInfo, ResumeVars0) :- detect_resume_points_in_goal(Goal0, _, Liveness0, Liveness, LiveInfo, ResumeVars0), - liveness__maybe_complete_with_typeinfos(LiveInfo, Liveness, + liveness.maybe_complete_with_typeinfos(LiveInfo, Liveness, CompletedLiveness), % ResumeVars0 should already have been completed. - set__union(CompletedLiveness, ResumeVars0, ResumeVars1), + set.union(CompletedLiveness, ResumeVars0, ResumeVars1), detect_resume_points_in_goal(Goal0, Goal1, Liveness0, _Liveness, LiveInfo, ResumeVars1), @@ -1369,7 +1369,7 @@ detect_resume_points_in_non_disj([Goal0 | Goals0], [Goal | Goals], live_info::in, set(prog_var)::in, set(prog_var)::out) is det. detect_resume_points_in_pruned_disj([], [], !Liveness, _, _, Needed) :- - set__init(Needed). + set.init(Needed). detect_resume_points_in_pruned_disj([Goal0 | Goals0], [Goal | Goals], Liveness0, Liveness, LiveInfo, ResumeVars0, Needed) :- Goal0 = _ - GoalInfo0, @@ -1405,7 +1405,7 @@ detect_resume_points_in_non_last_disjunct(Goal0, Goal, MayUseOrigOnly, Liveness, NeededRest, Needed) :- % We must save a variable across this disjunct if it is needed % in a later disjunct or in an enclosing resume point - set__union(NeededRest, ResumeVars0, ResumeVars1), + set.union(NeededRest, ResumeVars0, ResumeVars1), detect_resume_points_in_goal(Goal0, Goal1, Liveness0, Liveness, LiveInfo, ResumeVars1), @@ -1432,11 +1432,11 @@ detect_resume_points_in_non_last_disjunct(Goal0, Goal, MayUseOrigOnly, Goal = _ - GoalInfo, goal_info_get_pre_deaths(GoalInfo, PreDeaths), - set__difference(Liveness0, PreDeaths, NeededFirst), - liveness__maybe_complete_with_typeinfos(LiveInfo, NeededFirst, + set.difference(Liveness0, PreDeaths, NeededFirst), + liveness.maybe_complete_with_typeinfos(LiveInfo, NeededFirst, CompletedNeededFirst), % NeededRest has already been completed. - set__union(CompletedNeededFirst, NeededRest, Needed), + set.union(CompletedNeededFirst, NeededRest, Needed), require_equal(Liveness, LivenessRest, "disjunction", LiveInfo). @@ -1450,8 +1450,8 @@ detect_resume_points_in_last_disjunct(Goal0, Goal, Liveness0, Liveness, LiveInfo, ResumeVars0), Goal = _ - GoalInfo, goal_info_get_pre_deaths(GoalInfo, PreDeaths), - set__difference(Liveness0, PreDeaths, Needed), - liveness__maybe_complete_with_typeinfos(LiveInfo, Needed, CompletedNeeded). + set.difference(Liveness0, PreDeaths, Needed), + liveness.maybe_complete_with_typeinfos(LiveInfo, Needed, CompletedNeeded). :- pred detect_resume_points_in_cases(list(case)::in, list(case)::out, set(prog_var)::in, set(prog_var)::out, @@ -1489,19 +1489,19 @@ detect_resume_points_in_par_conj([Goal0 | Goals0], [Goal | Goals], live_info::in) is det. require_equal(LivenessFirst, LivenessRest, GoalType, LiveInfo) :- - ( set__equal(LivenessFirst, LivenessRest) -> + ( set.equal(LivenessFirst, LivenessRest) -> true ; VarSet = LiveInfo ^ varset, - set__to_sorted_list(LivenessFirst, FirstVarsList), - set__to_sorted_list(LivenessRest, RestVarsList), - list__map(varset__lookup_name(VarSet), FirstVarsList, FirstVarNames), - list__map(varset__lookup_name(VarSet), RestVarsList, RestVarNames), - Pad = (pred(S0::in, S::out) is det :- string__append(S0, " ", S)), - list__map(Pad, FirstVarNames, PaddedFirstNames), - list__map(Pad, RestVarNames, PaddedRestNames), - string__append_list(PaddedFirstNames, FirstNames), - string__append_list(PaddedRestNames, RestNames), + set.to_sorted_list(LivenessFirst, FirstVarsList), + set.to_sorted_list(LivenessRest, RestVarsList), + list.map(varset.lookup_name(VarSet), FirstVarsList, FirstVarNames), + list.map(varset.lookup_name(VarSet), RestVarsList, RestVarNames), + Pad = (pred(S0::in, S::out) is det :- string.append(S0, " ", S)), + list.map(Pad, FirstVarNames, PaddedFirstNames), + list.map(Pad, RestVarNames, PaddedRestNames), + string.append_list(PaddedFirstNames, FirstNames), + string.append_list(PaddedRestNames, RestNames), Msg = "branches of " ++ GoalType ++ " disagree on liveness\n" ++ "First: " ++ FirstNames ++ "\n" ++ "Rest: " ++ RestNames ++ "\n", unexpected(this_file, Msg) @@ -1514,8 +1514,8 @@ initial_liveness(ProcInfo, PredId, ModuleInfo, !:Liveness) :- proc_info_headvars(ProcInfo, Vars), proc_info_argmodes(ProcInfo, Modes), proc_info_vartypes(ProcInfo, VarTypes), - map__apply_to_list(Vars, VarTypes, Types), - set__init(!:Liveness), + map.apply_to_list(Vars, VarTypes, Types), + set.init(!:Liveness), ( initial_liveness_2(Vars, Modes, Types, ModuleInfo, !Liveness) -> true ; @@ -1536,7 +1536,7 @@ initial_liveness(ProcInfo, PredId, ModuleInfo, !:Liveness) :- body_should_use_typeinfo_liveness(PredInfo, Globals, TypeinfoLiveness), proc_info_maybe_complete_with_typeinfo_vars(NonLocals0, TypeinfoLiveness, VarTypes, RttiVarMaps, NonLocals), - set__intersect(!.Liveness, NonLocals, !:Liveness). + set.intersect(!.Liveness, NonLocals, !:Liveness). :- pred initial_liveness_2(list(prog_var)::in, list(mer_mode)::in, list(mer_type)::in, module_info::in, @@ -1545,7 +1545,7 @@ initial_liveness(ProcInfo, PredId, ModuleInfo, !:Liveness) :- initial_liveness_2([], [], [], _ModuleInfo, !Liveness). initial_liveness_2([V | Vs], [M | Ms], [T | Ts], ModuleInfo, !Liveness) :- ( mode_to_arg_mode(ModuleInfo, M, T, top_in) -> - svset__insert(V, !Liveness) + svset.insert(V, !Liveness) ; true ), @@ -1561,7 +1561,7 @@ initial_liveness_2([V | Vs], [M | Ms], [T | Ts], ModuleInfo, !Liveness) :- initial_deadness(ProcInfo, LiveInfo, ModuleInfo, Deadness) :- % The output arguments are all in the initial deadness. - arg_info__partition_proc_args(ProcInfo, ModuleInfo, _, Deadness0, _), + arg_info.partition_proc_args(ProcInfo, ModuleInfo, _, Deadness0, _), % If doing typeinfo liveness, the corresponding typeinfos need to be added % to these. @@ -1578,7 +1578,7 @@ initial_deadness(ProcInfo, LiveInfo, ModuleInfo, Deadness) :- add_liveness_after_goal(Goal - GoalInfo0, Residue, Goal - GoalInfo) :- goal_info_get_post_births(GoalInfo0, PostBirths0), - set__union(PostBirths0, Residue, PostBirths), + set.union(PostBirths0, Residue, PostBirths), goal_info_set_post_births(PostBirths, GoalInfo0, GoalInfo). :- pred add_deadness_before_goal(set(prog_var)::in, @@ -1586,7 +1586,7 @@ add_liveness_after_goal(Goal - GoalInfo0, Residue, Goal - GoalInfo) :- add_deadness_before_goal(Residue, Goal - GoalInfo0, Goal - GoalInfo) :- goal_info_get_pre_deaths(GoalInfo0, PreDeaths0), - set__union(PreDeaths0, Residue, PreDeaths), + set.union(PreDeaths0, Residue, PreDeaths), goal_info_set_pre_deaths(PreDeaths, GoalInfo0, GoalInfo). :- pred add_deadness_after_goal(set(prog_var)::in, @@ -1594,7 +1594,7 @@ add_deadness_before_goal(Residue, Goal - GoalInfo0, Goal - GoalInfo) :- add_deadness_after_goal(Residue, Goal - GoalInfo0, Goal - GoalInfo) :- goal_info_get_post_deaths(GoalInfo0, PostDeaths0), - set__union(PostDeaths0, Residue, PostDeaths), + set.union(PostDeaths0, Residue, PostDeaths), goal_info_set_post_deaths(PostDeaths, GoalInfo0, GoalInfo). %-----------------------------------------------------------------------------% @@ -1615,13 +1615,13 @@ find_value_giving_occurrences([], _, _, !ValueVars). find_value_giving_occurrences([Var | Vars], LiveInfo, InstMapDelta, !ValueVars) :- VarTypes = LiveInfo ^ vartypes, - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ( instmap_delta_search_var(InstMapDelta, Var, Inst), ModuleInfo = LiveInfo ^ module_info, mode_to_arg_mode(ModuleInfo, (free -> Inst), Type, top_out) -> - svset__insert(Var, !ValueVars) + svset.insert(Var, !ValueVars) ; true ), @@ -1633,19 +1633,19 @@ find_value_giving_occurrences([Var | Vars], LiveInfo, InstMapDelta, % Get the nonlocals, and, if doing typeinfo liveness, add the % typeinfo vars for the nonlocals. -:- pred liveness__get_nonlocals_and_typeinfos(live_info::in, +:- pred liveness.get_nonlocals_and_typeinfos(live_info::in, hlds_goal_info::in, set(prog_var)::out, set(prog_var)::out) is det. -liveness__get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, +liveness.get_nonlocals_and_typeinfos(LiveInfo, GoalInfo, NonLocals, CompletedNonLocals) :- goal_info_get_code_gen_nonlocals(GoalInfo, NonLocals), - liveness__maybe_complete_with_typeinfos(LiveInfo, + liveness.maybe_complete_with_typeinfos(LiveInfo, NonLocals, CompletedNonLocals). -:- pred liveness__maybe_complete_with_typeinfos(live_info::in, +:- pred liveness.maybe_complete_with_typeinfos(live_info::in, set(prog_var)::in, set(prog_var)::out) is det. -liveness__maybe_complete_with_typeinfos(LiveInfo, Vars0, Vars) :- +liveness.maybe_complete_with_typeinfos(LiveInfo, Vars0, Vars) :- proc_info_maybe_complete_with_typeinfo_vars(Vars0, LiveInfo ^ typeinfo_liveness, LiveInfo ^ vartypes, LiveInfo ^ rtti_varmaps, Vars). diff --git a/compiler/ll_pseudo_type_info.m b/compiler/ll_pseudo_type_info.m index 360cfa03b..7cb9d0e73 100644 --- a/compiler/ll_pseudo_type_info.m +++ b/compiler/ll_pseudo_type_info.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 2000,2002-2003, 2005 The University of Melbourne. +% Copyright (C) 2000,2002-2003, 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -21,7 +21,7 @@ %---------------------------------------------------------------------------% -:- module ll_backend__ll_pseudo_type_info. +:- module ll_backend.ll_pseudo_type_info. :- interface. :- import_module ll_backend.global_data. @@ -77,7 +77,7 @@ construct_llds_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, construct_typed_llds_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, !StaticCellInfo, PseudoRval, LldsType) :- - pseudo_type_info__construct_pseudo_type_info(Type, NumUnivQTvars, + pseudo_type_info.construct_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, Pseudo), convert_pseudo_type_info(Pseudo, !StaticCellInfo, PseudoRval, LldsType). @@ -102,7 +102,7 @@ convert_pseudo_type_info(Pseudo, !StaticCellInfo, Rval, LldsType) :- !StaticCellInfo, Rval, LldsType) ; Pseudo = var_arity_pseudo_type_info(VarArityId, Args), - list__length(Args, Arity), + list.length(Args, Arity), ArityArg = const(int_const(Arity)), RttiTypeCtor = var_arity_id_to_rtti_type_ctor(VarArityId), convert_compound_pseudo_type_info(RttiTypeCtor, [ArityArg], @@ -125,7 +125,7 @@ convert_plain_type_info(TypeInfo, !StaticCellInfo, Rval, LldsType) :- !StaticCellInfo, Rval, LldsType) ; TypeInfo = var_arity_type_info(VarArityId, Args), - list__length(Args, Arity), + list.length(Args, Arity), ArityArg = const(int_const(Arity)), RttiTypeCtor = var_arity_id_to_rtti_type_ctor(VarArityId), convert_compound_type_info(RttiTypeCtor, [ArityArg], Args, @@ -143,7 +143,7 @@ convert_compound_pseudo_type_info(RttiTypeCtor, ArgRvals0, Args, ctor_rtti_id(RttiTypeCtor, type_ctor_info)), TypeCtorInfoRval = const(data_addr_const(TypeCtorInfoDataAddr, no)), LldsType = data_ptr, - list__map_foldl((pred(A::in, AR::out, SCI0::in, SCI::out) is det :- + list.map_foldl((pred(A::in, AR::out, SCI0::in, SCI::out) is det :- ( A = pseudo(PTI), convert_pseudo_type_info(PTI, SCI0, SCI, AR, _LldsType) @@ -152,7 +152,7 @@ convert_compound_pseudo_type_info(RttiTypeCtor, ArgRvals0, Args, convert_plain_type_info(TI, SCI0, SCI, AR, _LldsType) ) ), Args, ArgRvals1, !StaticCellInfo), - list__append(ArgRvals0, ArgRvals1, ArgRvals), + list.append(ArgRvals0, ArgRvals1, ArgRvals), add_static_cell_natural_types([TypeCtorInfoRval | ArgRvals], DataAddr, !StaticCellInfo), Rval = const(data_addr_const(DataAddr, no)). @@ -168,10 +168,10 @@ convert_compound_type_info(RttiTypeCtor, ArgRvals0, Args, !StaticCellInfo, ctor_rtti_id(RttiTypeCtor, TypeCtorInfoData)), TypeCtorInfoRval = const(data_addr_const(TypeCtorInfoDataAddr, no)), LldsType = data_ptr, - list__map_foldl((pred(A::in, AR::out, SCI0::in, SCI::out) is det :- + list.map_foldl((pred(A::in, AR::out, SCI0::in, SCI::out) is det :- convert_plain_type_info(A, SCI0, SCI, AR, _LldsType) ), Args, ArgRvals1, !StaticCellInfo), - list__append(ArgRvals0, ArgRvals1, ArgRvals), + list.append(ArgRvals0, ArgRvals1, ArgRvals), add_static_cell_natural_types([TypeCtorInfoRval | ArgRvals], DataAddr, !StaticCellInfo), Rval = const(data_addr_const(DataAddr, no)). diff --git a/compiler/llds.m b/compiler/llds.m index aca0e801c..feeefa182 100644 --- a/compiler/llds.m +++ b/compiler/llds.m @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__llds. +:- module ll_backend.llds. :- interface. :- import_module backend_libs.builtin_ops. @@ -227,7 +227,7 @@ % Assign the value specified by rval to the location % specified by lval. - ; call(code_addr, code_addr, list(liveinfo), term__context, + ; call(code_addr, code_addr, list(liveinfo), term.context, goal_path, call_model) % call(Target, Continuation, _, _, _) is the same as % succip = Continuation; goto(Target). @@ -653,7 +653,7 @@ ). % For an explanation of this type, see the comment on - % stack_layout__represent_locn. + % stack_layout.represent_locn. % :- type layout_locn ---> direct(lval) @@ -1008,35 +1008,35 @@ :- pred break_up_local_label(label::in, proc_label::out, int::out) is det. -:- pred llds__wrap_rtti_data(rtti_data::in, comp_gen_c_data::out) is det. +:- pred wrap_rtti_data(rtti_data::in, comp_gen_c_data::out) is det. % Given a non-var rval, figure out its type. % -:- pred llds__rval_type(rval::in, llds_type::out) is det. +:- pred rval_type(rval::in, llds_type::out) is det. % Given a non-var lval, figure out its type. % -:- pred llds__lval_type(lval::in, llds_type::out) is det. +:- pred lval_type(lval::in, llds_type::out) is det. % Given a constant, figure out its type. % -:- pred llds__const_type(rval_const::in, llds_type::out) is det. +:- pred const_type(rval_const::in, llds_type::out) is det. % Given a unary operator, figure out its return type. % -:- pred llds__unop_return_type(unary_op::in, llds_type::out) is det. +:- pred unop_return_type(unary_op::in, llds_type::out) is det. % Given a unary operator, figure out the type of its argument. % -:- pred llds__unop_arg_type(unary_op::in, llds_type::out) is det. +:- pred unop_arg_type(unary_op::in, llds_type::out) is det. % Given a binary operator, figure out its return type. % -:- pred llds__binop_return_type(binary_op::in, llds_type::out) is det. +:- pred binop_return_type(binary_op::in, llds_type::out) is det. % Given a register, figure out its type. % -:- pred llds__register_type(reg_type::in, llds_type::out) is det. +:- pred register_type(reg_type::in, llds_type::out) is det. :- func get_proc_label(label) = proc_label. @@ -1086,33 +1086,33 @@ break_up_local_label(Label, ProcLabel, LabelNum) :- unexpected(this_file, "break_up_local_label: entry label") ). -llds__wrap_rtti_data(RttiData, rtti_data(RttiData)). +wrap_rtti_data(RttiData, rtti_data(RttiData)). -llds__lval_type(reg(RegType, _), Type) :- - llds__register_type(RegType, Type). -llds__lval_type(succip, code_ptr). -llds__lval_type(maxfr, data_ptr). -llds__lval_type(curfr, data_ptr). -llds__lval_type(hp, data_ptr). -llds__lval_type(sp, data_ptr). -llds__lval_type(temp(RegType, _), Type) :- - llds__register_type(RegType, Type). -llds__lval_type(stackvar(_), word). -llds__lval_type(framevar(_), word). -llds__lval_type(succip(_), code_ptr). -llds__lval_type(redoip(_), code_ptr). -llds__lval_type(redofr(_), data_ptr). -llds__lval_type(succfr(_), data_ptr). -llds__lval_type(prevfr(_), data_ptr). -llds__lval_type(field(_, _, _), word). -llds__lval_type(lvar(_), _) :- - unexpected(this_file, "lvar unexpected in llds__lval_type"). -llds__lval_type(mem_ref(_), word). +lval_type(reg(RegType, _), Type) :- + register_type(RegType, Type). +lval_type(succip, code_ptr). +lval_type(maxfr, data_ptr). +lval_type(curfr, data_ptr). +lval_type(hp, data_ptr). +lval_type(sp, data_ptr). +lval_type(temp(RegType, _), Type) :- + register_type(RegType, Type). +lval_type(stackvar(_), word). +lval_type(framevar(_), word). +lval_type(succip(_), code_ptr). +lval_type(redoip(_), code_ptr). +lval_type(redofr(_), data_ptr). +lval_type(succfr(_), data_ptr). +lval_type(prevfr(_), data_ptr). +lval_type(field(_, _, _), word). +lval_type(lvar(_), _) :- + unexpected(this_file, "lvar unexpected in llds.lval_type"). +lval_type(mem_ref(_), word). -llds__rval_type(lval(Lval), Type) :- - llds__lval_type(Lval, Type). -llds__rval_type(var(_), _) :- - unexpected(this_file, "var unexpected in llds__rval_type"). +rval_type(lval(Lval), Type) :- + lval_type(Lval, Type). +rval_type(var(_), _) :- + unexpected(this_file, "var unexpected in llds.rval_type"). % % Note that mkword and data_addr consts must be of type data_ptr, % not of type word, to ensure that static consts containing @@ -1125,84 +1125,84 @@ llds__rval_type(var(_), _) :- % to a pointer, but casts from integer to pointer are OK, it's % only the reverse direction we need to avoid. % -llds__rval_type(mkword(_, _), data_ptr). -llds__rval_type(const(Const), Type) :- - llds__const_type(Const, Type). -llds__rval_type(unop(UnOp, _), Type) :- - llds__unop_return_type(UnOp, Type). -llds__rval_type(binop(BinOp, _, _), Type) :- - llds__binop_return_type(BinOp, Type). -llds__rval_type(mem_addr(_), data_ptr). +rval_type(mkword(_, _), data_ptr). +rval_type(const(Const), Type) :- + const_type(Const, Type). +rval_type(unop(UnOp, _), Type) :- + unop_return_type(UnOp, Type). +rval_type(binop(BinOp, _, _), Type) :- + binop_return_type(BinOp, Type). +rval_type(mem_addr(_), data_ptr). -llds__const_type(true, bool). -llds__const_type(false, bool). -llds__const_type(int_const(_), integer). -llds__const_type(float_const(_), float). -llds__const_type(string_const(_), string). -llds__const_type(multi_string_const(_, _), string). -llds__const_type(code_addr_const(_), code_ptr). -llds__const_type(data_addr_const(_, _), data_ptr). +const_type(true, bool). +const_type(false, bool). +const_type(int_const(_), integer). +const_type(float_const(_), float). +const_type(string_const(_), string). +const_type(multi_string_const(_, _), string). +const_type(code_addr_const(_), code_ptr). +const_type(data_addr_const(_, _), data_ptr). -llds__unop_return_type(mktag, word). -llds__unop_return_type(tag, word). -llds__unop_return_type(unmktag, word). -llds__unop_return_type(strip_tag, word). -llds__unop_return_type(mkbody, word). -llds__unop_return_type(unmkbody, word). -llds__unop_return_type(hash_string, integer). -llds__unop_return_type(bitwise_complement, integer). -llds__unop_return_type(logical_not, bool). +unop_return_type(mktag, word). +unop_return_type(tag, word). +unop_return_type(unmktag, word). +unop_return_type(strip_tag, word). +unop_return_type(mkbody, word). +unop_return_type(unmkbody, word). +unop_return_type(hash_string, integer). +unop_return_type(bitwise_complement, integer). +unop_return_type(logical_not, bool). -llds__unop_arg_type(mktag, word). -llds__unop_arg_type(tag, word). -llds__unop_arg_type(unmktag, word). -llds__unop_arg_type(strip_tag, word). -llds__unop_arg_type(mkbody, word). -llds__unop_arg_type(unmkbody, word). -llds__unop_arg_type(hash_string, string). -llds__unop_arg_type(bitwise_complement, integer). -llds__unop_arg_type(logical_not, bool). +unop_arg_type(mktag, word). +unop_arg_type(tag, word). +unop_arg_type(unmktag, word). +unop_arg_type(strip_tag, word). +unop_arg_type(mkbody, word). +unop_arg_type(unmkbody, word). +unop_arg_type(hash_string, string). +unop_arg_type(bitwise_complement, integer). +unop_arg_type(logical_not, bool). -llds__binop_return_type(int_add, integer). -llds__binop_return_type(int_sub, integer). -llds__binop_return_type(int_mul, integer). -llds__binop_return_type(int_div, integer). -llds__binop_return_type(int_mod, integer). -llds__binop_return_type(unchecked_left_shift, integer). -llds__binop_return_type(unchecked_right_shift, integer). -llds__binop_return_type(bitwise_and, integer). -llds__binop_return_type(bitwise_or, integer). -llds__binop_return_type(bitwise_xor, integer). -llds__binop_return_type(logical_and, bool). -llds__binop_return_type(logical_or, bool). -llds__binop_return_type(eq, bool). -llds__binop_return_type(ne, bool). -llds__binop_return_type(array_index(_Type), word). -llds__binop_return_type(str_eq, bool). -llds__binop_return_type(str_ne, bool). -llds__binop_return_type(str_lt, bool). -llds__binop_return_type(str_gt, bool). -llds__binop_return_type(str_le, bool). -llds__binop_return_type(str_ge, bool). -llds__binop_return_type(int_lt, bool). -llds__binop_return_type(int_gt, bool). -llds__binop_return_type(int_le, bool). -llds__binop_return_type(int_ge, bool). -llds__binop_return_type(unsigned_le, bool). -llds__binop_return_type(float_plus, float). -llds__binop_return_type(float_minus, float). -llds__binop_return_type(float_times, float). -llds__binop_return_type(float_divide, float). -llds__binop_return_type(float_eq, bool). -llds__binop_return_type(float_ne, bool). -llds__binop_return_type(float_lt, bool). -llds__binop_return_type(float_gt, bool). -llds__binop_return_type(float_le, bool). -llds__binop_return_type(float_ge, bool). -llds__binop_return_type(body, word). +binop_return_type(int_add, integer). +binop_return_type(int_sub, integer). +binop_return_type(int_mul, integer). +binop_return_type(int_div, integer). +binop_return_type(int_mod, integer). +binop_return_type(unchecked_left_shift, integer). +binop_return_type(unchecked_right_shift, integer). +binop_return_type(bitwise_and, integer). +binop_return_type(bitwise_or, integer). +binop_return_type(bitwise_xor, integer). +binop_return_type(logical_and, bool). +binop_return_type(logical_or, bool). +binop_return_type(eq, bool). +binop_return_type(ne, bool). +binop_return_type(array_index(_Type), word). +binop_return_type(str_eq, bool). +binop_return_type(str_ne, bool). +binop_return_type(str_lt, bool). +binop_return_type(str_gt, bool). +binop_return_type(str_le, bool). +binop_return_type(str_ge, bool). +binop_return_type(int_lt, bool). +binop_return_type(int_gt, bool). +binop_return_type(int_le, bool). +binop_return_type(int_ge, bool). +binop_return_type(unsigned_le, bool). +binop_return_type(float_plus, float). +binop_return_type(float_minus, float). +binop_return_type(float_times, float). +binop_return_type(float_divide, float). +binop_return_type(float_eq, bool). +binop_return_type(float_ne, bool). +binop_return_type(float_lt, bool). +binop_return_type(float_gt, bool). +binop_return_type(float_le, bool). +binop_return_type(float_ge, bool). +binop_return_type(body, word). -llds__register_type(r, word). -llds__register_type(f, float). +register_type(r, word). +register_type(f, float). get_proc_label(entry(_, ProcLabel)) = ProcLabel. get_proc_label(internal(_, ProcLabel)) = ProcLabel. diff --git a/compiler/llds_out.m b/compiler/llds_out.m index 1d6286081..c12bf89a0 100644 --- a/compiler/llds_out.m +++ b/compiler/llds_out.m @@ -16,7 +16,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__llds_out. +:- module ll_backend.llds_out. :- interface. :- import_module backend_libs.builtin_ops. @@ -223,74 +223,74 @@ :- type decl_set == set_tree234(decl_id). decl_set_init(DeclSet) :- - DeclSet = set_tree234__init. + DeclSet = set_tree234.init. decl_set_insert(DeclId, DeclSet0, DeclSet) :- - set_tree234__insert(DeclId, DeclSet0, DeclSet). + set_tree234.insert(DeclId, DeclSet0, DeclSet). decl_set_is_member(DeclId, DeclSet) :- - set_tree234__contains(DeclSet, DeclId). + set_tree234.contains(DeclSet, DeclId). %-----------------------------------------------------------------------------% output_llds(CFile, ComplexityProcs, StackLayoutLabels, !IO) :- CFile = c_file(ModuleName, _, _, _, _, _, _, _, _), module_name_to_file_name(ModuleName, ".c", yes, FileName, !IO), - io__open_output(FileName, Result, !IO), + io.open_output(FileName, Result, !IO), ( Result = ok(FileStream), decl_set_init(DeclSet0), output_single_c_file(CFile, ComplexityProcs, StackLayoutLabels, FileStream, DeclSet0, _, !IO), - io__close_output(FileStream, !IO) + io.close_output(FileStream, !IO) ; Result = error(Error), - io__progname_base("llds.m", ProgName, !IO), - io__write_string("\n", !IO), - io__write_string(ProgName, !IO), - io__write_string(": can't open `", !IO), - io__write_string(FileName, !IO), - io__write_string("' for output:\n", !IO), - io__write_string(io__error_message(Error), !IO), - io__write_string("\n", !IO), - io__set_exit_status(1, !IO) + io.progname_base("llds.m", ProgName, !IO), + io.write_string("\n", !IO), + io.write_string(ProgName, !IO), + io.write_string(": can't open `", !IO), + io.write_string(FileName, !IO), + io.write_string("' for output:\n", !IO), + io.write_string(io.error_message(Error), !IO), + io.write_string("\n", !IO), + io.set_exit_status(1, !IO) ). :- pred output_c_file_mercury_headers(io::di, io::uo) is det. output_c_file_mercury_headers(!IO) :- - globals__io_get_trace_level(TraceLevel, !IO), + globals.io_get_trace_level(TraceLevel, !IO), ( given_trace_level_is_none(TraceLevel) = no -> - io__write_string("#include ""mercury_imp.h""\n", !IO), - io__write_string("#include ""mercury_trace_base.h""\n", !IO) + io.write_string("#include ""mercury_imp.h""\n", !IO), + io.write_string("#include ""mercury_trace_base.h""\n", !IO) ; - io__write_string("#include ""mercury_imp.h""\n", !IO) + io.write_string("#include ""mercury_imp.h""\n", !IO) ), - globals__io_lookup_bool_option(profile_deep, DeepProfile, !IO), + globals.io_lookup_bool_option(profile_deep, DeepProfile, !IO), ( DeepProfile = yes, - io__write_string("#include ""mercury_deep_profiling.h""\n", !IO) + io.write_string("#include ""mercury_deep_profiling.h""\n", !IO) ; DeepProfile = no ), - globals__io_lookup_bool_option(generate_bytecode, GenBytecode, !IO), + globals.io_lookup_bool_option(generate_bytecode, GenBytecode, !IO), ( GenBytecode = yes, - io__write_string("#include ""mb_interface_stub.h""\n", !IO) + io.write_string("#include ""mb_interface_stub.h""\n", !IO) ; GenBytecode = no ). :- pred output_single_c_file(c_file::in, list(complexity_proc_info)::in, - map(label, data_addr)::in, io__output_stream::in, + map(label, data_addr)::in, io.output_stream::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_single_c_file(CFile, ComplexityProcs, StackLayoutLabels, FileStream, !DeclSet, !IO) :- CFile = c_file(ModuleName, C_HeaderLines, UserForeignCode, Exports, Vars, Datas, Modules, UserInitPredCNames, UserFinalPredCNames), - library__version(Version), - io__set_output_stream(FileStream, OutputStream, !IO), + library.version(Version), + io.set_output_stream(FileStream, OutputStream, !IO), module_name_to_file_name(ModuleName, ".m", no, SourceFileName, !IO), output_c_file_intro_and_grade(SourceFileName, Version, !IO), output_init_comment(ModuleName, UserInitPredCNames, @@ -298,30 +298,30 @@ output_single_c_file(CFile, ComplexityProcs, StackLayoutLabels, output_c_file_mercury_headers(!IO), output_foreign_header_include_lines(C_HeaderLines, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), gather_c_file_labels(Modules, Labels), - classify_comp_gen_c_data(Datas, multi_map__init, CommonMap, + classify_comp_gen_c_data(Datas, multi_map.init, CommonMap, [], CommonDatas0, [], RttiDatas, [], LayoutDatas), - multi_map__to_assoc_list(CommonMap, CommonAssocList), - list__foldl2(output_common_decl_group, CommonAssocList, !DeclSet, !IO), + multi_map.to_assoc_list(CommonMap, CommonAssocList), + list.foldl2(output_common_decl_group, CommonAssocList, !DeclSet, !IO), output_rtti_data_decl_list(RttiDatas, !DeclSet, !IO), output_c_label_decls(StackLayoutLabels, Labels, !DeclSet, !IO), - list__foldl2(output_comp_gen_c_var, Vars, !DeclSet, !IO), - list__reverse(CommonDatas0, CommonDatas), - list__foldl2(output_common_data_defn, CommonDatas, !DeclSet, !IO), - list__foldl2(output_rtti_data_defn, RttiDatas, !DeclSet, !IO), + list.foldl2(output_comp_gen_c_var, Vars, !DeclSet, !IO), + list.reverse(CommonDatas0, CommonDatas), + list.foldl2(output_common_data_defn, CommonDatas, !DeclSet, !IO), + list.foldl2(output_rtti_data_defn, RttiDatas, !DeclSet, !IO), order_layout_datas(LayoutDatas, OrderedLayoutDatas), - list__foldl2(output_layout_data_defn, OrderedLayoutDatas, !DeclSet, !IO), + list.foldl2(output_layout_data_defn, OrderedLayoutDatas, !DeclSet, !IO), - list__foldl2(output_comp_gen_c_module(StackLayoutLabels), Modules, + list.foldl2(output_comp_gen_c_module(StackLayoutLabels), Modules, !DeclSet, !IO), - list__foldl(output_user_foreign_code, UserForeignCode, !IO), - list__foldl(io__write_string, Exports, !IO), - io__write_string("\n", !IO), + list.foldl(output_user_foreign_code, UserForeignCode, !IO), + list.foldl(io.write_string, Exports, !IO), + io.write_string("\n", !IO), output_c_module_init_list(ModuleName, Modules, Datas, Vars, ComplexityProcs, StackLayoutLabels, !DeclSet, !IO), - io__set_output_stream(OutputStream, _, !IO). + io.set_output_stream(OutputStream, _, !IO). :- pred order_layout_datas(list(layout_data)::in, list(layout_data)::out) is det. @@ -329,10 +329,10 @@ output_single_c_file(CFile, ComplexityProcs, StackLayoutLabels, order_layout_datas(LayoutDatas0, LayoutDatas) :- order_layout_datas_2(LayoutDatas0, [], ProcLayouts, [], LabelLayouts, [], OtherLayouts), - % list__reverse(RevProcLayouts, ProcLayouts), - % list__reverse(RevLabelLayouts, LabelLayouts), - % list__reverse(RevOtherLayouts, OtherLayouts), - list__condense([ProcLayouts, LabelLayouts, OtherLayouts], LayoutDatas). + % list.reverse(RevProcLayouts, ProcLayouts), + % list.reverse(RevLabelLayouts, LabelLayouts), + % list.reverse(RevOtherLayouts, OtherLayouts), + list.condense([ProcLayouts, LabelLayouts, OtherLayouts], LayoutDatas). :- pred order_layout_datas_2(list(layout_data)::in, list(layout_data)::in, list(layout_data)::out, @@ -361,9 +361,9 @@ output_c_module_init_list(ModuleName, Modules, Datas, Vars, ComplexityProcs, MustInit = (pred(Module::in) is semidet :- module_defines_label_with_layout(Module, StackLayoutLabels) ), - list__filter(MustInit, Modules, AlwaysInitModules, MaybeInitModules), - list__chunk(AlwaysInitModules, 40, AlwaysInitModuleBunches), - list__chunk(MaybeInitModules, 40, MaybeInitModuleBunches), + list.filter(MustInit, Modules, AlwaysInitModules, MaybeInitModules), + list.chunk(AlwaysInitModules, 40, AlwaysInitModuleBunches), + list.chunk(MaybeInitModules, 40, MaybeInitModuleBunches), output_init_bunch_defs(AlwaysInitModuleBunches, ModuleName, "always", 0, !IO), @@ -376,51 +376,51 @@ output_c_module_init_list(ModuleName, Modules, Datas, Vars, ComplexityProcs, "maybe", 0, !IO) ), - io__write_string("/* suppress gcc -Wmissing-decls warnings */\n", !IO), - io__write_string("void ", !IO), + io.write_string("/* suppress gcc -Wmissing-decls warnings */\n", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init(void);\n", !IO), + io.write_string("init(void);\n", !IO), - io__write_string("void ", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init_type_tables(void);\n", !IO), - io__write_string("void ", !IO), + io.write_string("init_type_tables(void);\n", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init_debugger(void);\n", !IO), + io.write_string("init_debugger(void);\n", !IO), - io__write_string("#ifdef MR_DEEP_PROFILING\n", !IO), - io__write_string("void ", !IO), + io.write_string("#ifdef MR_DEEP_PROFILING\n", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("write_out_proc_statics(FILE *fp);\n", !IO), - io__write_string("#endif\n", !IO), + io.write_string("write_out_proc_statics(FILE *fp);\n", !IO), + io.write_string("#endif\n", !IO), - io__write_string("#ifdef MR_RECORD_TERM_SIZES\n", !IO), - io__write_string("void ", !IO), + io.write_string("#ifdef MR_RECORD_TERM_SIZES\n", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init_complexity_procs(void);\n", !IO), - io__write_string("#endif\n", !IO), + io.write_string("init_complexity_procs(void);\n", !IO), + io.write_string("#endif\n", !IO), - globals__io_lookup_bool_option(allow_table_reset, TableReset, !IO), + globals.io_lookup_bool_option(allow_table_reset, TableReset, !IO), ( TableReset = yes, - io__write_string("void ", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("reset_tables(void);\n", !IO) + io.write_string("reset_tables(void);\n", !IO) ; TableReset = no ), - io__write_string("\n", !IO), + io.write_string("\n", !IO), - io__write_string("void ", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init(void)\n", !IO), - io__write_string("{\n", !IO), - io__write_string("\tstatic MR_bool done = MR_FALSE;\n", !IO), - io__write_string("\tif (done) {\n", !IO), - io__write_string("\t\treturn;\n", !IO), - io__write_string("\t}\n", !IO), - io__write_string("\tdone = MR_TRUE;\n", !IO), + io.write_string("init(void)\n", !IO), + io.write_string("{\n", !IO), + io.write_string("\tstatic MR_bool done = MR_FALSE;\n", !IO), + io.write_string("\tif (done) {\n", !IO), + io.write_string("\t\treturn;\n", !IO), + io.write_string("\t}\n", !IO), + io.write_string("\tdone = MR_TRUE;\n", !IO), output_init_bunch_calls(AlwaysInitModuleBunches, ModuleName, "always", 0, !IO), @@ -438,73 +438,73 @@ output_c_module_init_list(ModuleName, Modules, Datas, Vars, ComplexityProcs, % once the debugger has been modified to call do_init_modules_debugger() % and all debuggable object files created before this change have been % overwritten, it can be deleted. - io__write_string("\t", !IO), + io.write_string("\t", !IO), output_init_name(ModuleName, !IO), - io__write_string("init_debugger();\n", !IO), - io__write_string("}\n\n", !IO), + io.write_string("init_debugger();\n", !IO), + io.write_string("}\n\n", !IO), - io__write_string("void ", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init_type_tables(void)\n", !IO), - io__write_string("{\n", !IO), - io__write_string("\tstatic MR_bool done = MR_FALSE;\n", !IO), - io__write_string("\tif (done) {\n", !IO), - io__write_string("\t\treturn;\n", !IO), - io__write_string("\t}\n", !IO), - io__write_string("\tdone = MR_TRUE;\n", !IO), + io.write_string("init_type_tables(void)\n", !IO), + io.write_string("{\n", !IO), + io.write_string("\tstatic MR_bool done = MR_FALSE;\n", !IO), + io.write_string("\tif (done) {\n", !IO), + io.write_string("\t\treturn;\n", !IO), + io.write_string("\t}\n", !IO), + io.write_string("\tdone = MR_TRUE;\n", !IO), output_type_tables_init_list(Datas, !IO), - io__write_string("}\n\n", !IO), + io.write_string("}\n\n", !IO), output_debugger_init_list_decls(Datas, !DeclSet, !IO), - io__write_string("\n", !IO), - io__write_string("void ", !IO), + io.write_string("\n", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init_debugger(void)\n", !IO), - io__write_string("{\n", !IO), - io__write_string("\tstatic MR_bool done = MR_FALSE;\n", !IO), - io__write_string("\tif (done) {\n", !IO), - io__write_string("\t\treturn;\n", !IO), - io__write_string("\t}\n", !IO), - io__write_string("\tdone = MR_TRUE;\n", !IO), + io.write_string("init_debugger(void)\n", !IO), + io.write_string("{\n", !IO), + io.write_string("\tstatic MR_bool done = MR_FALSE;\n", !IO), + io.write_string("\tif (done) {\n", !IO), + io.write_string("\t\treturn;\n", !IO), + io.write_string("\t}\n", !IO), + io.write_string("\tdone = MR_TRUE;\n", !IO), output_debugger_init_list(Datas, !IO), - io__write_string("}\n\n", !IO), + io.write_string("}\n\n", !IO), - io__write_string("#ifdef MR_DEEP_PROFILING\n", !IO), + io.write_string("#ifdef MR_DEEP_PROFILING\n", !IO), output_write_proc_static_list_decls(Datas, !DeclSet, !IO), - io__write_string("\nvoid ", !IO), + io.write_string("\nvoid ", !IO), output_init_name(ModuleName, !IO), - io__write_string("write_out_proc_statics(FILE *fp)\n", !IO), - io__write_string("{\n", !IO), + io.write_string("write_out_proc_statics(FILE *fp)\n", !IO), + io.write_string("{\n", !IO), output_write_proc_static_list(Datas, !IO), - io__write_string("}\n", !IO), - io__write_string("\n#endif\n\n", !IO), + io.write_string("}\n", !IO), + io.write_string("\n#endif\n\n", !IO), - io__write_string("#ifdef MR_RECORD_TERM_SIZES\n", !IO), + io.write_string("#ifdef MR_RECORD_TERM_SIZES\n", !IO), output_complexity_arg_info_arrays(ComplexityProcs, !IO), - io__write_string("\nvoid ", !IO), + io.write_string("\nvoid ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init_complexity_procs(void)\n", !IO), - io__write_string("{\n", !IO), + io.write_string("init_complexity_procs(void)\n", !IO), + io.write_string("{\n", !IO), output_init_complexity_proc_list(ComplexityProcs, !IO), - io__write_string("}\n", !IO), - io__write_string("\n#endif\n\n", !IO), + io.write_string("}\n", !IO), + io.write_string("\n#endif\n\n", !IO), ( TableReset = yes, - io__write_string("void ", !IO), + io.write_string("void ", !IO), output_init_name(ModuleName, !IO), - io__write_string("reset_tables(void)\n", !IO), - io__write_string("{\n", !IO), - list__foldl(output_init_reset_table, Vars, !IO), - io__write_string("}\n\n", !IO) + io.write_string("reset_tables(void)\n", !IO), + io.write_string("{\n", !IO), + list.foldl(output_init_reset_table, Vars, !IO), + io.write_string("}\n\n", !IO) ; TableReset = no ), - io__write_string( + io.write_string( "/* ensure everything is compiled with the same grade */\n", !IO), - io__write_string( + io.write_string( "static const void *const MR_grade = &MR_GRADE_VAR;\n", !IO). :- pred module_defines_label_with_layout(comp_gen_c_module::in, @@ -513,23 +513,23 @@ output_c_module_init_list(ModuleName, Modules, Datas, Vars, ComplexityProcs, module_defines_label_with_layout(Module, StackLayoutLabels) :- % Checking whether the set is empty or not % allows us to avoid calling gather_c_module_labels. - \+ map__is_empty(StackLayoutLabels), + \+ map.is_empty(StackLayoutLabels), Module = comp_gen_c_module(_, Procedures), gather_c_module_labels(Procedures, Labels), - list__member(Label, Labels), - map__search(StackLayoutLabels, Label, _). + list.member(Label, Labels), + map.search(StackLayoutLabels, Label, _). :- pred output_init_bunch_defs(list(list(comp_gen_c_module))::in, module_name::in, string::in, int::in, io::di, io::uo) is det. output_init_bunch_defs([], _, _, _, !IO). output_init_bunch_defs([Bunch | Bunches], ModuleName, InitStatus, Seq, !IO) :- - io__write_string("static void ", !IO), + io.write_string("static void ", !IO), output_bunch_name(ModuleName, InitStatus, Seq, !IO), - io__write_string("(void)\n", !IO), - io__write_string("{\n", !IO), + io.write_string("(void)\n", !IO), + io.write_string("{\n", !IO), output_init_bunch_def(Bunch, ModuleName, !IO), - io__write_string("}\n\n", !IO), + io.write_string("}\n\n", !IO), NextSeq = Seq + 1, output_init_bunch_defs(Bunches, ModuleName, InitStatus, NextSeq, !IO). @@ -539,9 +539,9 @@ output_init_bunch_defs([Bunch | Bunches], ModuleName, InitStatus, Seq, !IO) :- output_init_bunch_def([], _, !IO). output_init_bunch_def([Module | Modules], ModuleName, !IO) :- Module = comp_gen_c_module(C_ModuleName, _), - io__write_string("\t", !IO), - io__write_string(C_ModuleName, !IO), - io__write_string("();\n", !IO), + io.write_string("\t", !IO), + io.write_string(C_ModuleName, !IO), + io.write_string("();\n", !IO), output_init_bunch_def(Modules, ModuleName, !IO). :- pred output_init_bunch_calls(list(list(comp_gen_c_module))::in, @@ -549,9 +549,9 @@ output_init_bunch_def([Module | Modules], ModuleName, !IO) :- output_init_bunch_calls([], _, _, _, !IO). output_init_bunch_calls([_ | Bunches], ModuleName, InitStatus, Seq, !IO) :- - io__write_string("\t", !IO), + io.write_string("\t", !IO), output_bunch_name(ModuleName, InitStatus, Seq, !IO), - io__write_string("();\n", !IO), + io.write_string("();\n", !IO), NextSeq = Seq + 1, output_init_bunch_calls(Bunches, ModuleName, InitStatus, NextSeq, !IO). @@ -564,7 +564,7 @@ output_init_bunch_calls([_ | Bunches], ModuleName, InitStatus, Seq, !IO) :- output_c_data_init_list([], !IO). output_c_data_init_list([Data | Datas], !IO) :- ( Data = rtti_data(RttiData) -> - rtti_out__init_rtti_data_if_nec(RttiData, !IO) + rtti_out.init_rtti_data_if_nec(RttiData, !IO) ; true ), @@ -578,7 +578,7 @@ output_c_data_init_list([Data | Datas], !IO) :- output_type_tables_init_list([], !IO). output_type_tables_init_list([Data | Datas], !IO) :- ( Data = rtti_data(RttiData) -> - rtti_out__register_rtti_data_if_nec(RttiData, !IO) + rtti_out.register_rtti_data_if_nec(RttiData, !IO) ; true ), @@ -616,11 +616,11 @@ output_debugger_init_list([Data | Datas], !IO) :- Data = layout_data(LayoutData), LayoutData = module_layout_data(ModuleName, _,_,_,_,_,_,_) -> - io__write_string("\tif (MR_register_module_layout != NULL) {\n", !IO), - io__write_string("\t\t(*MR_register_module_layout)(", !IO), - io__write_string("\n\t\t\t&", !IO), + io.write_string("\tif (MR_register_module_layout != NULL) {\n", !IO), + io.write_string("\t\t(*MR_register_module_layout)(", !IO), + io.write_string("\n\t\t\t&", !IO), output_layout_name(module_layout(ModuleName), !IO), - io__write_string(");\n\t}\n", !IO) + io.write_string(");\n\t}\n", !IO) ; true ), @@ -657,13 +657,13 @@ output_write_proc_static_list([Data | Datas], !IO) :- Kind = proc_layout_proc_id(UserOrUCI), ( UserOrUCI = user, - io__write_string("\tMR_write_out_user_proc_static(fp,\n\t\t&", !IO) + io.write_string("\tMR_write_out_user_proc_static(fp,\n\t\t&", !IO) ; UserOrUCI = uci, - io__write_string("\tMR_write_out_uci_proc_static(fp,\n\t\t&", !IO) + io.write_string("\tMR_write_out_uci_proc_static(fp,\n\t\t&", !IO) ), output_layout_name(proc_layout(RttiProcLabel, Kind), !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; true ), @@ -680,13 +680,13 @@ complexity_arg_info_array_name(ProcNum) = output_complexity_arg_info_arrays([], !IO). output_complexity_arg_info_arrays([Info | Infos], !IO) :- Info = complexity_proc_info(ProcNum, _, Args), - io__write_string("\nMR_ComplexityArgInfo ", !IO), - io__write_string(complexity_arg_info_array_name(ProcNum), !IO), - io__write_string("[", !IO), - io__write_int(list__length(Args), !IO), - io__write_string("] = {\n", !IO), + io.write_string("\nMR_ComplexityArgInfo ", !IO), + io.write_string(complexity_arg_info_array_name(ProcNum), !IO), + io.write_string("[", !IO), + io.write_int(list.length(Args), !IO), + io.write_string("] = {\n", !IO), output_complexity_arg_info_array(Args, !IO), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), output_complexity_arg_info_arrays(Infos, !IO). :- pred output_complexity_arg_info_array(list(complexity_arg_info)::in, @@ -695,27 +695,27 @@ output_complexity_arg_info_arrays([Info | Infos], !IO) :- output_complexity_arg_info_array([], !IO). output_complexity_arg_info_array([Arg | Args], !IO) :- Arg = complexity_arg_info(MaybeName, Kind), - io__write_string("{ ", !IO), + io.write_string("{ ", !IO), ( MaybeName = yes(Name), - io__write_string("""", !IO), - io__write_string(Name, !IO), - io__write_string(""", ", !IO) + io.write_string("""", !IO), + io.write_string(Name, !IO), + io.write_string(""", ", !IO) ; MaybeName = no, - io__write_string("NULL, ", !IO) + io.write_string("NULL, ", !IO) ), ( Kind = complexity_input_variable_size, - io__write_string("MR_COMPLEXITY_INPUT_VAR_SIZE", !IO) + io.write_string("MR_COMPLEXITY_INPUT_VAR_SIZE", !IO) ; Kind = complexity_input_fixed_size, - io__write_string("MR_COMPLEXITY_INPUT_FIX_SIZE", !IO) + io.write_string("MR_COMPLEXITY_INPUT_FIX_SIZE", !IO) ; Kind = complexity_output, - io__write_string("MR_COMPLEXITY_OUTPUT", !IO) + io.write_string("MR_COMPLEXITY_OUTPUT", !IO) ), - io__write_string(" },\n", !IO), + io.write_string(" },\n", !IO), output_complexity_arg_info_array(Args, !IO). :- pred output_init_complexity_proc_list(list(complexity_proc_info)::in, @@ -724,18 +724,18 @@ output_complexity_arg_info_array([Arg | Args], !IO) :- output_init_complexity_proc_list([], !IO). output_init_complexity_proc_list([Info | Infos], !IO) :- Info = complexity_proc_info(ProcNum, FullProcName, ArgInfos), - io__write_string("\tMR_init_complexity_proc(", !IO), - io__write_int(ProcNum, !IO), - io__write_string(", """, !IO), - c_util__output_quoted_string(FullProcName, !IO), - io__write_string(""", ", !IO), - list__filter(complexity_arg_is_profiled, ArgInfos, ProfiledArgInfos), - io__write_int(list__length(ProfiledArgInfos), !IO), - io__write_string(", ", !IO), - io__write_int(list__length(ArgInfos), !IO), - io__write_string(", ", !IO), - io__write_string(complexity_arg_info_array_name(ProcNum), !IO), - io__write_string(");\n", !IO), + io.write_string("\tMR_init_complexity_proc(", !IO), + io.write_int(ProcNum, !IO), + io.write_string(", """, !IO), + c_util.output_quoted_string(FullProcName, !IO), + io.write_string(""", ", !IO), + list.filter(complexity_arg_is_profiled, ArgInfos, ProfiledArgInfos), + io.write_int(list.length(ProfiledArgInfos), !IO), + io.write_string(", ", !IO), + io.write_int(list.length(ArgInfos), !IO), + io.write_string(", ", !IO), + io.write_string(complexity_arg_info_array_name(ProcNum), !IO), + io.write_string(");\n", !IO), output_init_complexity_proc_list(Infos, !IO). :- pred complexity_arg_is_profiled(complexity_arg_info::in) is semidet. @@ -747,9 +747,9 @@ complexity_arg_is_profiled(complexity_arg_info(_, Kind)) :- output_init_reset_table(Var, !IO) :- Var = tabling_pointer_var(_Module, ProcLabel), - io__write_string("\t", !IO), + io.write_string("\t", !IO), output_tabling_pointer_var_name(ProcLabel, !IO), - io__write_string(".MR_integer = 0;\n", !IO). + io.write_string(".MR_integer = 0;\n", !IO). % Output a comment to tell mkinit what functions to call from % _init.c. @@ -759,40 +759,40 @@ output_init_reset_table(Var, !IO) :- output_init_comment(ModuleName, UserInitPredCNames, UserFinalPredCNames, !IO) :- - io__write_string("/*\n", !IO), - io__write_string("INIT ", !IO), + io.write_string("/*\n", !IO), + io.write_string("INIT ", !IO), output_init_name(ModuleName, !IO), - io__write_string("init\n", !IO), - list__foldl(output_required_user_init_comment, UserInitPredCNames, !IO), - list__foldl(output_required_user_final_comment, UserFinalPredCNames, !IO), - io__write_string("ENDINIT\n", !IO), - io__write_string("*/\n\n", !IO). + io.write_string("init\n", !IO), + list.foldl(output_required_user_init_comment, UserInitPredCNames, !IO), + list.foldl(output_required_user_final_comment, UserFinalPredCNames, !IO), + io.write_string("ENDINIT\n", !IO), + io.write_string("*/\n\n", !IO). :- pred output_required_user_init_comment(string::in, io::di, io::uo) is det. output_required_user_init_comment(CName, !IO) :- - io__write_string("REQUIRED_INIT ", !IO), - io__write_string(CName, !IO), - io__nl(!IO). + io.write_string("REQUIRED_INIT ", !IO), + io.write_string(CName, !IO), + io.nl(!IO). :- pred output_required_user_final_comment(string::in, io::di, io::uo) is det. output_required_user_final_comment(CName, !IO) :- - io__write_string("REQUIRED_FINAL ", !IO), - io__write_string(CName, !IO), - io__nl(!IO). + io.write_string("REQUIRED_FINAL ", !IO), + io.write_string(CName, !IO), + io.nl(!IO). :- pred output_bunch_name(module_name::in, string::in, int::in, io::di, io::uo) is det. output_bunch_name(ModuleName, InitStatus, Number, !IO) :- - io__write_string("mercury__", !IO), + io.write_string("mercury__", !IO), MangledModuleName = sym_name_mangle(ModuleName), - io__write_string(MangledModuleName, !IO), - io__write_string("_", !IO), - io__write_string(InitStatus, !IO), - io__write_string("_bunch_", !IO), - io__write_int(Number, !IO). + io.write_string(MangledModuleName, !IO), + io.write_string("_", !IO), + io.write_string(InitStatus, !IO), + io.write_string("_bunch_", !IO), + io.write_int(Number, !IO). :- pred classify_comp_gen_c_data(list(comp_gen_c_data)::in, multi_map(int, common_data)::in, @@ -808,7 +808,7 @@ classify_comp_gen_c_data([Data | Datas], !CommonMap, !CommonList, Data = common_data(CommonData), CommonData = common_data(_ModuleName, _CellNum, TypeAndValue), TypeNum = common_cell_get_type_num(TypeAndValue), - multi_map__set(!.CommonMap, TypeNum, CommonData, !:CommonMap), + multi_map.set(!.CommonMap, TypeNum, CommonData, !:CommonMap), !:CommonList = [CommonData | !.CommonList] ; Data = rtti_data(Rtti), @@ -824,7 +824,7 @@ classify_comp_gen_c_data([Data | Datas], !CommonMap, !CommonList, decl_set::in, decl_set::out, io::di, io::uo) is det. output_common_decl_group(TypeNum - CommonDatas, !DeclSet, !IO) :- - io__write_string("\n", !IO), + io.write_string("\n", !IO), ( CommonDatas = [CommonData | _], CommonData = common_data(_, _, TypeAndValue) @@ -837,27 +837,27 @@ output_common_decl_group(TypeNum - CommonDatas, !DeclSet, !IO) :- true ; output_const_term_type(TypeAndValue, "", "", 0, _, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), decl_set_insert(TypeDeclId, !DeclSet) ), % There should be a macro MR_DEF_COMMON for every n up to % ChunkSize. ChunkSize = 10, - list__chunk(list__reverse(CommonDatas), ChunkSize, CommonDataChunks), - list__foldl2(output_common_decl_shorthand_chunk(TypeNum), + list.chunk(list.reverse(CommonDatas), ChunkSize, CommonDataChunks), + list.foldl2(output_common_decl_shorthand_chunk(TypeNum), CommonDataChunks, !DeclSet, !IO). :- pred output_common_decl_shorthand_chunk(int::in, list(common_data)::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_common_decl_shorthand_chunk(TypeNum, CommonDatas, !DeclSet, !IO) :- - io__write_string("MR_DEF_COMMON", !IO), - io__write_int(list__length(CommonDatas), !IO), - io__write_string("(", !IO), - io__write_int(TypeNum, !IO), - io__write_string(",", !IO), + io.write_string("MR_DEF_COMMON", !IO), + io.write_int(list.length(CommonDatas), !IO), + io.write_string("(", !IO), + io.write_int(TypeNum, !IO), + io.write_string(",", !IO), output_common_decl_shorthand_chunk_entries(CommonDatas, !DeclSet, !IO), - io__write_string(")\n", !IO). + io.write_string(")\n", !IO). :- pred output_common_decl_shorthand_chunk_entries(list(common_data)::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -872,10 +872,10 @@ output_common_decl_shorthand_chunk_entries([CommonData | CommonDatas], VarName = common(CellNum, TypeNum), VarDeclId = data_addr(data_addr(ModuleName, VarName)), decl_set_insert(VarDeclId, !DeclSet), - io__write_int(CellNum, !IO), + io.write_int(CellNum, !IO), ( CommonDatas = [_ | _], - io__write_string(",", !IO), + io.write_string(",", !IO), output_common_decl_shorthand_chunk_entries(CommonDatas, !DeclSet, !IO) ; CommonDatas = [] @@ -885,9 +885,9 @@ output_common_decl_shorthand_chunk_entries([CommonData | CommonDatas], decl_set::in, decl_set::out, io::di, io::uo) is det. output_common_decl_chunk(TypeNum, CommonDatas, !DeclSet, !IO) :- - io__write_string("const struct ", !IO), + io.write_string("const struct ", !IO), output_common_cell_type_name(TypeNum, !IO), - io__nl(!IO), + io.nl(!IO), output_common_decl_chunk_entries(CommonDatas, !DeclSet, !IO). :- pred output_common_decl_chunk_entries(list(common_data)::in, @@ -904,11 +904,11 @@ output_common_decl_chunk_entries([CommonData | CommonDatas], !DeclSet, !IO) :- decl_set_insert(VarDeclId, !DeclSet), ( CommonDatas = [_ | _], - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_common_decl_chunk_entries(CommonDatas, !DeclSet, !IO) ; CommonDatas = [], - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ). % output_c_data_type_def outputs the given the type definition. @@ -931,7 +931,7 @@ output_c_data_type_def(layout_data(LayoutData), !DeclSet, !IO) :- output_common_data_decl(common_data(ModuleName, CellNum, TypeAndValue), !DeclSet, !IO) :- - io__write_string("\n", !IO), + io.write_string("\n", !IO), % The code for data local to a Mercury module should normally be visible % only within the C file generated for that module. However, if we generate @@ -943,7 +943,7 @@ output_common_data_decl(common_data(ModuleName, CellNum, TypeAndValue), true ; output_const_term_type(TypeAndValue, "", "", 0, _, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), decl_set_insert(TypeDeclId, !DeclSet) ), VarName = common(CellNum, TypeNum), @@ -958,31 +958,30 @@ output_common_data_decl(common_data(ModuleName, CellNum, TypeAndValue), output_comp_gen_c_module(StackLayoutLabels, comp_gen_c_module(ModuleName, Procedures), !DeclSet, !IO) :- - io__write_string("\n", !IO), - list__foldl2(output_c_procedure_decls(StackLayoutLabels), + io.write_string("\n", !IO), + list.foldl2(output_c_procedure_decls(StackLayoutLabels), Procedures, !DeclSet, !IO), - io__write_string("\n", !IO), - io__write_string("MR_BEGIN_MODULE(", !IO), - io__write_string(ModuleName, !IO), - io__write_string(")\n", !IO), + io.write_string("\n", !IO), + io.write_string("MR_BEGIN_MODULE(", !IO), + io.write_string(ModuleName, !IO), + io.write_string(")\n", !IO), gather_c_module_labels(Procedures, Labels), output_c_label_inits(StackLayoutLabels, Labels, !IO), - io__write_string("MR_BEGIN_CODE\n", !IO), - io__write_string("\n", !IO), - globals__io_lookup_bool_option(auto_comments, PrintComments, !IO), - globals__io_lookup_bool_option(emit_c_loops, EmitCLoops, !IO), - list__foldl(output_c_procedure(PrintComments, EmitCLoops), Procedures, - !IO), - io__write_string("MR_END_MODULE\n", !IO). + io.write_string("MR_BEGIN_CODE\n", !IO), + io.write_string("\n", !IO), + globals.io_lookup_bool_option(auto_comments, PrintComments, !IO), + globals.io_lookup_bool_option(emit_c_loops, EmitCLoops, !IO), + list.foldl(output_c_procedure(PrintComments, EmitCLoops), Procedures, !IO), + io.write_string("MR_END_MODULE\n", !IO). :- pred output_comp_gen_c_var(comp_gen_c_var::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_comp_gen_c_var(tabling_pointer_var(ModuleName, ProcLabel), !DeclSet, !IO) :- - io__write_string("\nMR_TableNode ", !IO), + io.write_string("\nMR_TableNode ", !IO), output_tabling_pointer_var_name(ProcLabel, !IO), - io__write_string(" = { 0 };\n", !IO), + io.write_string(" = { 0 };\n", !IO), DataAddr = data_addr(ModuleName, tabling_pointer(ProcLabel)), decl_set_insert(data_addr(DataAddr), !DeclSet). @@ -1001,7 +1000,7 @@ output_comp_gen_c_data(layout_data(LayoutData), !DeclSet, !IO) :- output_common_data_defn(common_data(ModuleName, CellNum, TypeAndValue), !DeclSet, !IO) :- - io__write_string("\n", !IO), + io.write_string("\n", !IO), Args = common_cell_get_rvals(TypeAndValue), output_rvals_decls(Args, !DeclSet, !IO), @@ -1017,18 +1016,18 @@ output_common_data_defn(common_data(ModuleName, CellNum, TypeAndValue), output_user_foreign_code(user_foreign_code(Lang, Foreign_Code, Context), !IO) :- ( Lang = c -> - globals__io_lookup_bool_option(auto_comments, PrintComments, !IO), + globals.io_lookup_bool_option(auto_comments, PrintComments, !IO), ( PrintComments = yes, - io__write_string("/* ", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" pragma foreign_code */\n", !IO) + io.write_string("/* ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" pragma foreign_code */\n", !IO) ; PrintComments = no ), output_set_line_num(Context, !IO), - io__write_string(Foreign_Code, !IO), - io__write_string("\n", !IO), + io.write_string(Foreign_Code, !IO), + io.write_string("\n", !IO), output_reset_line_num(!IO) ; unexpected(this_file, "output_user_foreign_code: unimplemented: " ++ @@ -1039,7 +1038,7 @@ output_user_foreign_code(user_foreign_code(Lang, Foreign_Code, Context), io::di, io::uo) is det. output_foreign_header_include_lines(Decls, !IO) :- - list__foldl2(output_foreign_header_include_line, Decls, set__init, _, !IO). + list.foldl2(output_foreign_header_include_line, Decls, set.init, _, !IO). :- pred output_foreign_header_include_line(foreign_decl_code::in, set(string)::in, set(string)::out, io::di, io::uo) is det. @@ -1047,24 +1046,24 @@ output_foreign_header_include_lines(Decls, !IO) :- output_foreign_header_include_line(Decl, !AlreadyDone, !IO) :- Decl = foreign_decl_code(Lang, _IsLocal, Code, Context), ( Lang = c -> - ( set__member(Code, !.AlreadyDone) -> + ( set.member(Code, !.AlreadyDone) -> true ; - set__insert(!.AlreadyDone, Code, !:AlreadyDone), - globals__io_lookup_bool_option(auto_comments, PrintComments, !IO), + set.insert(!.AlreadyDone, Code, !:AlreadyDone), + globals.io_lookup_bool_option(auto_comments, PrintComments, !IO), ( PrintComments = yes, - io__write_string("/* ", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" pragma foreign_decl_code( ", !IO), - io__write(Lang, !IO), - io__write_string(" */\n", !IO) + io.write_string("/* ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" pragma foreign_decl_code( ", !IO), + io.write(Lang, !IO), + io.write_string(" */\n", !IO) ; PrintComments = no ), output_set_line_num(Context, !IO), - io__write_string(Code, !IO), - io__write_string("\n", !IO), + io.write_string(Code, !IO), + io.write_string("\n", !IO), output_reset_line_num(!IO) ) ; @@ -1077,16 +1076,16 @@ output_foreign_header_include_line(Decl, !AlreadyDone, !IO) :- output_c_label_decls(StackLayoutLabels, Labels, !DeclSet, !IO) :- group_c_labels_with_layouts(StackLayoutLabels, Labels, - multi_map__init, DeclLLMap, multi_map__init, LocalLabels, + multi_map.init, DeclLLMap, multi_map.init, LocalLabels, [], RevAddrsToDecl, [], RevOtherLabels), - multi_map__to_assoc_list(DeclLLMap, DeclLLList), - list__foldl2(output_label_layout_decls, DeclLLList, !DeclSet, !IO), - multi_map__to_assoc_list(LocalLabels, LocalLabelList), - list__foldl2(output_local_label_decls, LocalLabelList, !DeclSet, !IO), - list__reverse(RevAddrsToDecl, AddrsToDecl), - list__foldl2(output_stack_layout_decl, AddrsToDecl, !DeclSet, !IO), - list__reverse(RevOtherLabels, OtherLabels), - list__foldl2(output_c_label_decl(StackLayoutLabels), OtherLabels, + multi_map.to_assoc_list(DeclLLMap, DeclLLList), + list.foldl2(output_label_layout_decls, DeclLLList, !DeclSet, !IO), + multi_map.to_assoc_list(LocalLabels, LocalLabelList), + list.foldl2(output_local_label_decls, LocalLabelList, !DeclSet, !IO), + list.reverse(RevAddrsToDecl, AddrsToDecl), + list.foldl2(output_stack_layout_decl, AddrsToDecl, !DeclSet, !IO), + list.reverse(RevOtherLabels, OtherLabels), + list.foldl2(output_c_label_decl(StackLayoutLabels), OtherLabels, !DeclSet, !IO). :- pred group_c_labels_with_layouts(map(label, data_addr)::in, list(label)::in, @@ -1101,20 +1100,20 @@ group_c_labels_with_layouts(StackLayoutLabels, [Label | Labels], !DeclLLMap, !OtherLocalMap, !RevAddrsToDecl, !RevOthers) :- ( Label = internal(LabelNum, ProcLabel), - ( map__search(StackLayoutLabels, Label, DataAddr) -> + ( map.search(StackLayoutLabels, Label, DataAddr) -> ( DataAddr = layout_addr(LayoutName), LayoutName = label_layout(ProcLabel, LabelNum, LabelVars), LabelVars = label_has_var_info -> - svmulti_map__set(ProcLabel, LabelNum, !DeclLLMap) + svmulti_map.set(ProcLabel, LabelNum, !DeclLLMap) ; - svmulti_map__set(ProcLabel, LabelNum, !OtherLocalMap), + svmulti_map.set(ProcLabel, LabelNum, !OtherLocalMap), !:RevAddrsToDecl = [DataAddr | !.RevAddrsToDecl] ) ; - svmulti_map__set(ProcLabel, LabelNum, !OtherLocalMap) + svmulti_map.set(ProcLabel, LabelNum, !OtherLocalMap) ) ; Label = entry(_, _), @@ -1129,23 +1128,23 @@ group_c_labels_with_layouts(StackLayoutLabels, [Label | Labels], output_label_layout_decls(ProcLabel - LabelNums0, !DeclSet, !IO) :- % There must be a macro of the form MR_DECL_LL for every % up to MaxChunkSize. - list__reverse(LabelNums0, LabelNums), + list.reverse(LabelNums0, LabelNums), MaxChunkSize = 10, - list__chunk(LabelNums, MaxChunkSize, LabelNumChunks), - list__foldl2(output_label_layout_decl_group(ProcLabel), LabelNumChunks, + list.chunk(LabelNums, MaxChunkSize, LabelNumChunks), + list.foldl2(output_label_layout_decl_group(ProcLabel), LabelNumChunks, !DeclSet, !IO). :- pred output_label_layout_decl_group(proc_label::in, list(int)::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_label_layout_decl_group(ProcLabel, LabelNums, !DeclSet, !IO) :- - io__write_string("MR_DECL_LL", !IO), - io__write_int(list__length(LabelNums), !IO), - io__write_string("(", !IO), + io.write_string("MR_DECL_LL", !IO), + io.write_int(list.length(LabelNums), !IO), + io.write_string("(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(", ", !IO), - io__write_list(LabelNums, ",", io__write_int, !IO), - io__write_string(")\n", !IO). + io.write_string(", ", !IO), + io.write_list(LabelNums, ",", io.write_int, !IO), + io.write_string(")\n", !IO). :- pred output_local_label_decls(pair(proc_label, list(int))::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -1153,27 +1152,27 @@ output_label_layout_decl_group(ProcLabel, LabelNums, !DeclSet, !IO) :- output_local_label_decls(ProcLabel - LabelNums0, !DeclSet, !IO) :- % There must be a macro of the form MR_decl_label for every % up to MaxChunkSize. - list__reverse(LabelNums0, LabelNums), + list.reverse(LabelNums0, LabelNums), MaxChunkSize = 8, - list__chunk(LabelNums, MaxChunkSize, LabelNumChunks), - list__foldl2(output_local_label_decl_group(ProcLabel), LabelNumChunks, + list.chunk(LabelNums, MaxChunkSize, LabelNumChunks), + list.foldl2(output_local_label_decl_group(ProcLabel), LabelNumChunks, !DeclSet, !IO), - list__foldl(insert_var_info_label_layout_decl(ProcLabel), LabelNums, + list.foldl(insert_var_info_label_layout_decl(ProcLabel), LabelNums, !DeclSet), - list__foldl(insert_code_addr_decl(ProcLabel), LabelNums, !DeclSet). + list.foldl(insert_code_addr_decl(ProcLabel), LabelNums, !DeclSet). :- pred output_local_label_decl_group(proc_label::in, list(int)::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_local_label_decl_group(ProcLabel, LabelNums, !DeclSet, !IO) :- - io__write_string("MR_decl_label", !IO), - io__write_int(list__length(LabelNums), !IO), - io__write_string("(", !IO), + io.write_string("MR_decl_label", !IO), + io.write_int(list.length(LabelNums), !IO), + io.write_string("(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(", ", !IO), - io__write_list(LabelNums, ",", io__write_int, !IO), - io__write_string(")\n", !IO), - list__foldl(insert_code_addr_decl(ProcLabel), LabelNums, !DeclSet). + io.write_string(", ", !IO), + io.write_list(LabelNums, ",", io.write_int, !IO), + io.write_string(")\n", !IO), + list.foldl(insert_code_addr_decl(ProcLabel), LabelNums, !DeclSet). :- pred insert_var_info_label_layout_decl(proc_label::in, int::in, decl_set::in, decl_set::out) is det. @@ -1198,7 +1197,7 @@ output_c_label_decl(StackLayoutLabels, Label, !DeclSet, !IO) :- % % Declare the stack layout entry for this label, if needed. % - ( map__search(StackLayoutLabels, Label, DataAddr) -> + ( map.search(StackLayoutLabels, Label, DataAddr) -> ( Label = internal(LabelNum, ProcLabel), DataAddr = layout_addr(LayoutName), @@ -1211,13 +1210,13 @@ output_c_label_decl(StackLayoutLabels, Label, !DeclSet, !IO) :- LabelVars = label_has_no_var_info, Macro = "MR_DECL_LLNVI" ), - io__write_string(Macro, !IO), - io__write_string("(", !IO), + io.write_string(Macro, !IO), + io.write_string("(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(", ", !IO), - io__write_int(LabelNum, !IO), + io.write_string(", ", !IO), + io.write_int(LabelNum, !IO), % The final semicolon is in the macro definition. - io__write_string(")\n", !IO), + io.write_string(")\n", !IO), % The macro declares both the label layout structure % and the label. AlreadyDeclaredLabel = yes @@ -1246,10 +1245,10 @@ output_c_label_decl(StackLayoutLabels, Label, !DeclSet, !IO) :- Label = internal(_, _), DeclMacro = "MR_decl_label(" ), - io__write_string(DeclMacro, !IO), - io__write_string("", !IO), + io.write_string(DeclMacro, !IO), + io.write_string("", !IO), output_label(Label, no, !IO), - io__write_string(")\n", !IO) + io.write_string(")\n", !IO) ; AlreadyDeclaredLabel = yes ), @@ -1265,14 +1264,14 @@ output_stack_layout_decl(DataAddr, !DeclSet, !IO) :- io::di, io::uo) is det. output_c_label_inits(StackLayoutLabels, Labels, !IO) :- - group_c_labels(StackLayoutLabels, Labels, multi_map__init, NoLayoutMap, - multi_map__init, LayoutMap, [], RevOtherLabels), - list__reverse(RevOtherLabels, OtherLabels), - list__foldl(output_c_label_init(StackLayoutLabels), OtherLabels, !IO), - multi_map__to_assoc_list(NoLayoutMap, NoLayoutList), - multi_map__to_assoc_list(LayoutMap, LayoutList), - list__foldl(output_c_label_init_group(""), NoLayoutList, !IO), - list__foldl(output_c_label_init_group("_sl"), LayoutList, !IO). + group_c_labels(StackLayoutLabels, Labels, multi_map.init, NoLayoutMap, + multi_map.init, LayoutMap, [], RevOtherLabels), + list.reverse(RevOtherLabels, OtherLabels), + list.foldl(output_c_label_init(StackLayoutLabels), OtherLabels, !IO), + multi_map.to_assoc_list(NoLayoutMap, NoLayoutList), + multi_map.to_assoc_list(LayoutMap, LayoutList), + list.foldl(output_c_label_init_group(""), NoLayoutList, !IO), + list.foldl(output_c_label_init_group("_sl"), LayoutList, !IO). :- pred group_c_labels(map(label, data_addr)::in, list(label)::in, multi_map(proc_label, int)::in, multi_map(proc_label, int)::out, @@ -1284,10 +1283,10 @@ group_c_labels(StackLayoutLabels, [Label | Labels], !NoLayoutMap, !LayoutMap, !RevOthers) :- ( Label = internal(LabelNum, ProcLabel), - ( map__search(StackLayoutLabels, Label, _DataAddr) -> - svmulti_map__set(ProcLabel, LabelNum, !LayoutMap) + ( map.search(StackLayoutLabels, Label, _DataAddr) -> + svmulti_map.set(ProcLabel, LabelNum, !LayoutMap) ; - svmulti_map__set(ProcLabel, LabelNum, !NoLayoutMap) + svmulti_map.set(ProcLabel, LabelNum, !NoLayoutMap) ) ; Label = entry(_, _), @@ -1300,32 +1299,32 @@ group_c_labels(StackLayoutLabels, [Label | Labels], !NoLayoutMap, !LayoutMap, pair(proc_label, list(int))::in, io::di, io::uo) is det. output_c_label_init_group(Suffix, ProcLabel - RevLabelNums, !IO) :- - list__reverse(RevLabelNums, LabelNums), + list.reverse(RevLabelNums, LabelNums), % There must be macros of the form MR_init_label and % MR_init_label_sl for every up to MaxChunkSize. MaxChunkSize = 8, - list__chunk(LabelNums, MaxChunkSize, LabelNumChunks), - list__foldl(output_c_label_init_chunk(Suffix, ProcLabel), + list.chunk(LabelNums, MaxChunkSize, LabelNumChunks), + list.foldl(output_c_label_init_chunk(Suffix, ProcLabel), LabelNumChunks, !IO). :- pred output_c_label_init_chunk(string::in, proc_label::in, list(int)::in, io::di, io::uo) is det. output_c_label_init_chunk(Suffix, ProcLabel, LabelNums, !IO) :- - io__write_string("\tMR_init_label", !IO), - io__write_string(Suffix, !IO), - io__write_int(list__length(LabelNums), !IO), - io__write_string("(", !IO), + io.write_string("\tMR_init_label", !IO), + io.write_string(Suffix, !IO), + io.write_int(list.length(LabelNums), !IO), + io.write_string("(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(",", !IO), - io__write_list(LabelNums, ",", io__write_int, !IO), - io__write_string(")\n", !IO). + io.write_string(",", !IO), + io.write_list(LabelNums, ",", io.write_int, !IO), + io.write_string(")\n", !IO). :- pred output_c_label_init(map(label, data_addr)::in, label::in, io::di, io::uo) is det. output_c_label_init(StackLayoutLabels, Label, !IO) :- - ( map__search(StackLayoutLabels, Label, DataAddr) -> + ( map.search(StackLayoutLabels, Label, DataAddr) -> SuffixOpen = "_sl(", ( DataAddr = layout_addr(proc_layout(_, _)) -> % Labels whose stack layouts are proc layouts may need @@ -1356,15 +1355,15 @@ output_c_label_init(StackLayoutLabels, Label, !IO) :- % These should have been separated out by group_c_labels. unexpected(this_file, "output_c_label_init: internal/2") ), - io__write_string(TabInitMacro, !IO), - io__write_string(SuffixOpen, !IO), + io.write_string(TabInitMacro, !IO), + io.write_string(SuffixOpen, !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(");\n", !IO), + io.write_string(");\n", !IO), ( InitProcLayout = yes, - io__write_string("\tMR_INIT_PROC_LAYOUT_ADDR(", !IO), + io.write_string("\tMR_INIT_PROC_LAYOUT_ADDR(", !IO), output_label(Label, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; InitProcLayout = no ). @@ -1379,7 +1378,7 @@ label_is_proc_entry(entry(_, _), yes). output_c_procedure_decls(StackLayoutLabels, Proc, !DeclSet, !IO) :- Proc = c_procedure(_Name, _Arity, _PredProcId, Instrs, _, _, _), - list__foldl2(output_instruction_decls(StackLayoutLabels), Instrs, + list.foldl2(output_instruction_decls(StackLayoutLabels), Instrs, !DeclSet, !IO). :- pred output_c_procedure(bool::in, bool::in, c_procedure::in, @@ -1390,34 +1389,34 @@ output_c_procedure(PrintComments, EmitCLoops, Proc, !IO) :- proc_id_to_int(ProcId, ModeNum), ( PrintComments = yes, - io__write_string("\n/*-------------------------------------", !IO), - io__write_string("------------------------------------*/\n", !IO) + io.write_string("\n/*-------------------------------------", !IO), + io.write_string("------------------------------------*/\n", !IO) ; PrintComments = no ), ( PrintComments = yes, - io__write_string("/* code for predicate '", !IO), + io.write_string("/* code for predicate '", !IO), % Now that we have unused_args.m mangling predicate % names, we should probably demangle them here. - io__write_string(Name, !IO), - io__write_string("'/", !IO), - io__write_int(Arity, !IO), - io__write_string(" in mode ", !IO), - io__write_int(ModeNum, !IO), - io__write_string(" */\n", !IO) + io.write_string(Name, !IO), + io.write_string("'/", !IO), + io.write_int(Arity, !IO), + io.write_string(" in mode ", !IO), + io.write_int(ModeNum, !IO), + io.write_string(" */\n", !IO) ; PrintComments = no ), find_caller_label(Instrs, CallerLabel), - find_cont_labels(Instrs, bintree_set__init, ContLabelSet), + find_cont_labels(Instrs, bintree_set.init, ContLabelSet), ( EmitCLoops = yes, - find_while_labels(Instrs, bintree_set__init, WhileSet) + find_while_labels(Instrs, bintree_set.init, WhileSet) ; EmitCLoops = no, - WhileSet = bintree_set__init + WhileSet = bintree_set.init ), output_instruction_list(Instrs, PrintComments, CallerLabel - ContLabelSet, WhileSet, !IO). @@ -1462,11 +1461,11 @@ find_cont_labels([Instr - _ | Instrs], !ContLabelSet) :- Const = code_addr_const(label(ContLabel)) ) -> - bintree_set__insert(!.ContLabelSet, ContLabel, !:ContLabelSet) + bintree_set.insert(!.ContLabelSet, ContLabel, !:ContLabelSet) ; Instr = fork(Label1, Label2, _) -> - bintree_set__insert_list(!.ContLabelSet, [Label1, Label2], + bintree_set.insert_list(!.ContLabelSet, [Label1, Label2], !:ContLabelSet) ; Instr = block(_, _, Block) @@ -1505,7 +1504,7 @@ find_while_labels([Instr0 - _ | Instrs0], !WhileSet) :- is_while_label(Label, Instrs0, Instrs1, 0, UseCount), UseCount > 0 -> - bintree_set__insert(!.WhileSet, Label, !:WhileSet), + bintree_set.insert(!.WhileSet, Label, !:WhileSet), find_while_labels(Instrs1, !WhileSet) ; find_while_labels(Instrs0, !WhileSet) @@ -1566,7 +1565,7 @@ output_instr_decls(_, comment(_), !DeclSet, !IO). output_instr_decls(_, livevals(_), !DeclSet, !IO). output_instr_decls( StackLayoutLabels, block(_TempR, _TempF, Instrs), !DeclSet, !IO) :- - list__foldl2(output_instruction_decls(StackLayoutLabels), Instrs, + list.foldl2(output_instruction_decls(StackLayoutLabels), Instrs, !DeclSet, !IO). output_instr_decls(_, assign(Lval, Rval), !DeclSet, !IO) :- output_lval_decls(Lval, !DeclSet, !IO), @@ -1588,19 +1587,19 @@ output_instr_decls(_, mkframe(FrameInfo, MaybeFailureContinuation), ; true ), - io__write_string("struct ", !IO), - io__write_string(StructName, !IO), - io__write_string(" {\n", !IO), + io.write_string("struct ", !IO), + io.write_string(StructName, !IO), + io.write_string(" {\n", !IO), ( MaybeStructFieldsContext = yes(StructFieldsContext), output_set_line_num(StructFieldsContext, !IO), - io__write_string(StructFields, !IO), + io.write_string(StructFields, !IO), output_reset_line_num(!IO) ; MaybeStructFieldsContext = no, - io__write_string(StructFields, !IO) + io.write_string(StructFields, !IO) ), - io__write_string("\n};\n", !IO), + io.write_string("\n};\n", !IO), decl_set_insert(pragma_c_struct(StructName), !DeclSet) ; true @@ -1649,19 +1648,19 @@ output_instr_decls(StackLayoutLabels, pragma_c(_, Comps, _, _, MaybeLayoutLabel, MaybeOnlyLayoutLabel, _, _, _), !DeclSet, !IO) :- ( MaybeLayoutLabel = yes(Label), - map__lookup(StackLayoutLabels, Label, DataAddr), + map.lookup(StackLayoutLabels, Label, DataAddr), output_stack_layout_decl(DataAddr, !DeclSet, !IO) ; MaybeLayoutLabel = no ), ( MaybeOnlyLayoutLabel = yes(OnlyLabel), - map__lookup(StackLayoutLabels, OnlyLabel, OnlyDataAddr), + map.lookup(StackLayoutLabels, OnlyLabel, OnlyDataAddr), output_stack_layout_decl(OnlyDataAddr, !DeclSet, !IO) ; MaybeOnlyLayoutLabel = no ), - list__foldl2(output_pragma_c_component_decls, Comps, !DeclSet, !IO). + list.foldl2(output_pragma_c_component_decls, Comps, !DeclSet, !IO). output_instr_decls(_, init_sync_term(Lval, _), !DeclSet, !IO) :- output_lval_decls(Lval, !DeclSet, !IO). output_instr_decls(_, fork(Child, Parent, _), !DeclSet, !IO) :- @@ -1698,9 +1697,9 @@ output_instruction_list([Instr0 - Comment0 | Instrs], PrintComments, ProfInfo, !IO), ( Instr0 = label(Label), - bintree_set__is_member(Label, WhileSet) + bintree_set.is_member(Label, WhileSet) -> - io__write_string("\twhile (1) {\n", !IO), + io.write_string("\twhile (1) {\n", !IO), output_instruction_list_while(Instrs, Label, PrintComments, ProfInfo, WhileSet, !IO) % The matching close brace is printed in output_instruction_list @@ -1716,27 +1715,27 @@ output_instruction_list([Instr0 - Comment0 | Instrs], PrintComments, ProfInfo, io::di, io::uo) is det. output_instruction_list_while([], _, _, _, _, !IO) :- - io__write_string("\tbreak; } /* end while */\n", !IO). + io.write_string("\tbreak; } /* end while */\n", !IO). output_instruction_list_while([Instr0 - Comment0 | Instrs], Label, PrintComments, ProfInfo, WhileSet, !IO) :- ( Instr0 = label(_) -> - io__write_string("\tbreak; } /* end while */\n", !IO), + io.write_string("\tbreak; } /* end while */\n", !IO), output_instruction_list([Instr0 - Comment0 | Instrs], PrintComments, ProfInfo, WhileSet, !IO) ; Instr0 = goto(label(Label)) -> - io__write_string("\t/* continue */ } /* end while */\n", !IO), + io.write_string("\t/* continue */ } /* end while */\n", !IO), output_instruction_list(Instrs, PrintComments, ProfInfo, WhileSet, !IO) ; Instr0 = if_val(Rval, label(Label)) -> - io__write_string("\tif (", !IO), + io.write_string("\tif (", !IO), output_test_rval(Rval, !IO), - io__write_string(")\n\t\tcontinue;\n", !IO), + io.write_string(")\n\t\tcontinue;\n", !IO), ( PrintComments = yes, Comment0 \= "" -> - io__write_string("\t\t/* ", !IO), - io__write_string(Comment0, !IO), - io__write_string(" */\n", !IO) + io.write_string("\t\t/* ", !IO), + io.write_string(Comment0, !IO), + io.write_string(" */\n", !IO) ; true ), @@ -1765,20 +1764,20 @@ output_instruction_list_while_block([Instr0 - Comment0 | Instrs], Label, ( Instr0 = label(_) -> unexpected(this_file, "label in block") ; Instr0 = goto(label(Label)) -> - io__write_string("\tcontinue;\n", !IO), + io.write_string("\tcontinue;\n", !IO), expect(unify(Instrs, []), this_file, "output_instruction_list_while_block: code after goto") ; Instr0 = if_val(Rval, label(Label)) -> - io__write_string("\tif (", !IO), + io.write_string("\tif (", !IO), output_test_rval(Rval, !IO), - io__write_string(")\n\t\tcontinue;\n", !IO), + io.write_string(")\n\t\tcontinue;\n", !IO), ( PrintComments = yes, Comment0 \= "" -> - io__write_string("\t\t/* ", !IO), - io__write_string(Comment0, !IO), - io__write_string(" */\n", !IO) + io.write_string("\t\t/* ", !IO), + io.write_string(Comment0, !IO), + io.write_string(" */\n", !IO) ; true ), @@ -1814,9 +1813,9 @@ output_instruction_and_comment(Instr, Comment, PrintComments, ProfInfo, !IO) :- ( Comment = "" -> true ; - io__write_string("\t\t/* ", !IO), - io__write_string(Comment, !IO), - io__write_string("*/\n", !IO) + io.write_string("\t\t/* ", !IO), + io.write_string(Comment, !IO), + io.write_string("*/\n", !IO) ) ). @@ -1824,10 +1823,10 @@ output_instruction_and_comment(Instr, Comment, PrintComments, ProfInfo, !IO) :- % Normally we use output_instruction_and_comment/6. % output_debug_instruction_and_comment(Instr, Comment, PrintComments, !IO) :- - bintree_set__init(ContLabelSet), + bintree_set.init(ContLabelSet), DummyModule = unqualified("DEBUG"), DummyPredName = "DEBUG", - proc_id_to_int(hlds_pred__initial_proc_id, InitialProcIdInt), + proc_id_to_int(hlds_pred.initial_proc_id, InitialProcIdInt), ProcLabel = proc(DummyModule, predicate, DummyModule, DummyPredName, 0, InitialProcIdInt), ProfInfo = entry(local, ProcLabel) - ContLabelSet, @@ -1838,10 +1837,10 @@ output_debug_instruction_and_comment(Instr, Comment, PrintComments, !IO) :- % Normally we use output_instruction/4. % output_debug_instruction(Instr, !IO) :- - bintree_set__init(ContLabelSet), + bintree_set.init(ContLabelSet), DummyModule = unqualified("DEBUG"), DummyPredName = "DEBUG", - proc_id_to_int(hlds_pred__initial_proc_id, InitialProcIdInt), + proc_id_to_int(hlds_pred.initial_proc_id, InitialProcIdInt), ProcLabel = proc(DummyModule, predicate, DummyModule, DummyPredName, 0, InitialProcIdInt), ProfInfo = entry(local, ProcLabel) - ContLabelSet, @@ -1850,18 +1849,18 @@ output_debug_instruction(Instr, !IO) :- :- pred output_block_start(int::in, int::in, io::di, io::uo) is det. output_block_start(TempR, TempF, !IO) :- - io__write_string("\t{\n", !IO), + io.write_string("\t{\n", !IO), ( TempR > 0 -> - io__write_string("\tMR_Word ", !IO), + io.write_string("\tMR_Word ", !IO), output_temp_decls(TempR, "r", !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ; true ), ( TempF > 0 -> - io__write_string("\tMR_Float ", !IO), + io.write_string("\tMR_Float ", !IO), output_temp_decls(TempF, "f", !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ; true ). @@ -1869,33 +1868,33 @@ output_block_start(TempR, TempF, !IO) :- :- pred output_block_end(io::di, io::uo) is det. output_block_end(!IO) :- - io__write_string("\t}\n", !IO). + io.write_string("\t}\n", !IO). :- pred output_instruction(instr::in, pair(label, bintree_set(label))::in, io::di, io::uo) is det. output_instruction(comment(Comment), _, !IO) :- - io__write_strings(["/*", Comment, "*/\n"], !IO). + io.write_strings(["/*", Comment, "*/\n"], !IO). output_instruction(livevals(LiveVals), _, !IO) :- - io__write_string("/*\n* Live lvalues:\n", !IO), - set__to_sorted_list(LiveVals, LiveValsList), + io.write_string("/*\n* Live lvalues:\n", !IO), + set.to_sorted_list(LiveVals, LiveValsList), output_livevals(LiveValsList, !IO), - io__write_string("*/\n", !IO). + io.write_string("*/\n", !IO). output_instruction(block(TempR, TempF, Instrs), ProfInfo, !IO) :- output_block_start(TempR, TempF, !IO), - globals__io_lookup_bool_option(auto_comments, PrintComments, !IO), + globals.io_lookup_bool_option(auto_comments, PrintComments, !IO), output_instruction_list(Instrs, PrintComments, ProfInfo, - bintree_set__init, !IO), + bintree_set.init, !IO), output_block_end(!IO). output_instruction(assign(Lval, Rval), _, !IO) :- - io__write_string("\t", !IO), + io.write_string("\t", !IO), output_lval_for_assign(Lval, Type, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), output_rval_as_type(Rval, Type, !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). output_instruction(call(Target, ContLabel, LiveVals, _, _, _), ProfInfo, !IO) :- @@ -1904,8 +1903,8 @@ output_instruction(call(Target, ContLabel, LiveVals, _, _, _), ProfInfo, output_gc_livevals(LiveVals, !IO). output_instruction(c_code(C_Code_String, _), _, !IO) :- - io__write_string("\t", !IO), - io__write_string(C_Code_String, !IO). + io.write_string("\t", !IO), + io.write_string(C_Code_String, !IO). output_instruction(mkframe(FrameInfo, MaybeFailCont), _, !IO) :- ( @@ -1914,51 +1913,51 @@ output_instruction(mkframe(FrameInfo, MaybeFailCont), _, !IO) :- MaybeStruct = yes(pragma_c_struct(StructName, _, _)), ( MaybeFailCont = yes(FailCont), - io__write_string("\tMR_mkpragmaframe(""", !IO), - c_util__output_quoted_string(Msg, !IO), - io__write_string(""", ", !IO), - io__write_int(Num, !IO), - io__write_string(", ", !IO), - io__write_string(StructName, !IO), - io__write_string(", ", !IO), + io.write_string("\tMR_mkpragmaframe(""", !IO), + c_util.output_quoted_string(Msg, !IO), + io.write_string(""", ", !IO), + io.write_int(Num, !IO), + io.write_string(", ", !IO), + io.write_string(StructName, !IO), + io.write_string(", ", !IO), output_code_addr(FailCont, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; MaybeFailCont = no, - io__write_string("\tMR_mkpragmaframe_no_redoip(""", !IO), - c_util__output_quoted_string(Msg, !IO), - io__write_string(""", ", !IO), - io__write_int(Num, !IO), - io__write_string(", ", !IO), - io__write_string(StructName, !IO), - io__write_string(");\n", !IO) + io.write_string("\tMR_mkpragmaframe_no_redoip(""", !IO), + c_util.output_quoted_string(Msg, !IO), + io.write_string(""", ", !IO), + io.write_int(Num, !IO), + io.write_string(", ", !IO), + io.write_string(StructName, !IO), + io.write_string(");\n", !IO) ) ; MaybeStruct = no, ( MaybeFailCont = yes(FailCont), - io__write_string("\tMR_mkframe(""", !IO), - c_util__output_quoted_string(Msg, !IO), - io__write_string(""", ", !IO), - io__write_int(Num, !IO), - io__write_string(", ", !IO), + io.write_string("\tMR_mkframe(""", !IO), + c_util.output_quoted_string(Msg, !IO), + io.write_string(""", ", !IO), + io.write_int(Num, !IO), + io.write_string(", ", !IO), output_code_addr(FailCont, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; MaybeFailCont = no, - io__write_string("\tMR_mkframe_no_redoip(""", + io.write_string("\tMR_mkframe_no_redoip(""", !IO), - c_util__output_quoted_string(Msg, !IO), - io__write_string(""", ", !IO), - io__write_int(Num, !IO), - io__write_string(");\n", !IO) + c_util.output_quoted_string(Msg, !IO), + io.write_string(""", ", !IO), + io.write_int(Num, !IO), + io.write_string(");\n", !IO) ) ) ; FrameInfo = temp_frame(Kind), ( Kind = det_stack_proc, - io__write_string("\tMR_mkdettempframe(", !IO), + io.write_string("\tMR_mkdettempframe(", !IO), ( MaybeFailCont = yes(FailCont), output_code_addr(FailCont, !IO) @@ -1966,10 +1965,10 @@ output_instruction(mkframe(FrameInfo, MaybeFailCont), _, !IO) :- MaybeFailCont = no, unexpected(this_file, "output_instruction: no failcont") ), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; Kind = nondet_stack_proc, - io__write_string("\tMR_mktempframe(", !IO), + io.write_string("\tMR_mktempframe(", !IO), ( MaybeFailCont = yes(FailCont), output_code_addr(FailCont, !IO) @@ -1977,7 +1976,7 @@ output_instruction(mkframe(FrameInfo, MaybeFailCont), _, !IO) :- MaybeFailCont = no, unexpected(this_file, "output_instruction: no failcont") ), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ) ). @@ -1987,204 +1986,204 @@ output_instruction(label(Label), ProfInfo, !IO) :- output_instruction(goto(CodeAddr), ProfInfo, !IO) :- ProfInfo = CallerLabel - _, - io__write_string("\t", !IO), + io.write_string("\t", !IO), output_goto(CodeAddr, CallerLabel, !IO). output_instruction(computed_goto(Rval, Labels), _, !IO) :- - io__write_string("\tMR_COMPUTED_GOTO(", !IO), + io.write_string("\tMR_COMPUTED_GOTO(", !IO), output_rval_as_type(Rval, unsigned, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_label_list(Labels, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(if_val(Rval, Target), ProfInfo, !IO) :- ProfInfo = CallerLabel - _, - io__write_string("\tif (", !IO), + io.write_string("\tif (", !IO), output_test_rval(Rval, !IO), - io__write_string(") {\n\t\t", !IO), + io.write_string(") {\n\t\t", !IO), output_goto(Target, CallerLabel, !IO), - io__write_string("\t}\n", !IO). + io.write_string("\t}\n", !IO). output_instruction(save_maxfr(Lval), _, !IO) :- - io__write_string("\tMR_save_maxfr(", !IO), + io.write_string("\tMR_save_maxfr(", !IO), output_lval(Lval, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(restore_maxfr(Lval), _, !IO) :- - io__write_string("\tMR_restore_maxfr(", !IO), + io.write_string("\tMR_restore_maxfr(", !IO), output_lval(Lval, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(incr_hp(Lval, MaybeTag, MaybeOffset, Rval, TypeMsg), ProfInfo, !IO) :- - globals__io_lookup_bool_option(profile_memory, ProfMem, !IO), + globals.io_lookup_bool_option(profile_memory, ProfMem, !IO), ( ProfMem = yes, ( MaybeTag = no, - io__write_string("\tMR_offset_incr_hp_msg(", !IO), + io.write_string("\tMR_offset_incr_hp_msg(", !IO), output_lval_as_word(Lval, !IO) ; MaybeTag = yes(Tag), - io__write_string("\tMR_tag_offset_incr_hp_msg(", !IO), + io.write_string("\tMR_tag_offset_incr_hp_msg(", !IO), output_lval_as_word(Lval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), output_tag(Tag, !IO) ), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ( MaybeOffset = no, - io__write_string("0, ", !IO) + io.write_string("0, ", !IO) ; MaybeOffset = yes(Offset), - io__write_int(Offset, !IO), - io__write_string(", ", !IO) + io.write_int(Offset, !IO), + io.write_string(", ", !IO) ), output_rval_as_type(Rval, word, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ProfInfo = CallerLabel - _, output_label(CallerLabel, !IO), - io__write_string(", """, !IO), - c_util__output_quoted_string(TypeMsg, !IO), - io__write_string(""");\n", !IO) + io.write_string(", """, !IO), + c_util.output_quoted_string(TypeMsg, !IO), + io.write_string(""");\n", !IO) ; ProfMem = no, ( MaybeTag = no, ( MaybeOffset = yes(_), - io__write_string("\tMR_offset_incr_hp(", !IO) + io.write_string("\tMR_offset_incr_hp(", !IO) ; MaybeOffset = no, - io__write_string("\tMR_alloc_heap(", !IO) + io.write_string("\tMR_alloc_heap(", !IO) ), output_lval_as_word(Lval, !IO) ; MaybeTag = yes(Tag), ( MaybeOffset = yes(_), - io__write_string("\tMR_tag_offset_incr_hp(", !IO), + io.write_string("\tMR_tag_offset_incr_hp(", !IO), output_lval_as_word(Lval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), output_tag(Tag, !IO) ; MaybeOffset = no, - io__write_string("\tMR_tag_alloc_heap(", !IO), + io.write_string("\tMR_tag_alloc_heap(", !IO), output_lval_as_word(Lval, !IO), - io__write_string(", ", !IO), - io__write_int(Tag, !IO) + io.write_string(", ", !IO), + io.write_int(Tag, !IO) ) ), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ( MaybeOffset = yes(Offset), - io__write_int(Offset, !IO), - io__write_string(", ", !IO) + io.write_int(Offset, !IO), + io.write_string(", ", !IO) ; MaybeOffset = no ), output_rval_as_type(Rval, word, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ). output_instruction(mark_hp(Lval), _, !IO) :- - io__write_string("\tMR_mark_hp(", !IO), + io.write_string("\tMR_mark_hp(", !IO), output_lval_as_word(Lval, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(restore_hp(Rval), _, !IO) :- - io__write_string("\tMR_restore_hp(", !IO), + io.write_string("\tMR_restore_hp(", !IO), output_rval_as_type(Rval, word, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(free_heap(Rval), _, !IO) :- - io__write_string("\tMR_free_heap(", !IO), + io.write_string("\tMR_free_heap(", !IO), output_rval_as_type(Rval, data_ptr, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(store_ticket(Lval), _, !IO) :- - io__write_string("\tMR_store_ticket(", !IO), + io.write_string("\tMR_store_ticket(", !IO), output_lval_as_word(Lval, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(reset_ticket(Rval, Reason), _, !IO) :- - io__write_string("\tMR_reset_ticket(", !IO), + io.write_string("\tMR_reset_ticket(", !IO), output_rval_as_type(Rval, word, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), output_reset_trail_reason(Reason, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(discard_ticket, _, !IO) :- - io__write_string("\tMR_discard_ticket();\n", !IO). + io.write_string("\tMR_discard_ticket();\n", !IO). output_instruction(prune_ticket, _, !IO) :- - io__write_string("\tMR_prune_ticket();\n", !IO). + io.write_string("\tMR_prune_ticket();\n", !IO). output_instruction(mark_ticket_stack(Lval), _, !IO) :- - io__write_string("\tMR_mark_ticket_stack(", !IO), + io.write_string("\tMR_mark_ticket_stack(", !IO), output_lval_as_word(Lval, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(prune_tickets_to(Rval), _, !IO) :- - io__write_string("\tMR_prune_tickets_to(", !IO), + io.write_string("\tMR_prune_tickets_to(", !IO), output_rval_as_type(Rval, word, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(incr_sp(N, _Msg), _, !IO) :- - io__write_string("\tMR_incr_sp(", !IO), - io__write_int(N, !IO), - io__write_string(");\n", !IO). + io.write_string("\tMR_incr_sp(", !IO), + io.write_int(N, !IO), + io.write_string(");\n", !IO). % Use the code below instead of the code above if you want to run % tools/framesize on the output of the compiler. - % io__write_string("\tMR_incr_sp_push_msg(", !IO), - % io__write_int(N, !IO), - % io__write_string(", """, !IO), - % c_util__output_quoted_string(Msg, !IO), - % io__write_string(""");\n", !IO). + % io.write_string("\tMR_incr_sp_push_msg(", !IO), + % io.write_int(N, !IO), + % io.write_string(", """, !IO), + % c_util.output_quoted_string(Msg, !IO), + % io.write_string(""");\n", !IO). output_instruction(decr_sp(N), _, !IO) :- - io__write_string("\tMR_decr_sp(", !IO), - io__write_int(N, !IO), - io__write_string(");\n", !IO). + io.write_string("\tMR_decr_sp(", !IO), + io.write_int(N, !IO), + io.write_string(");\n", !IO). output_instruction(decr_sp_and_return(N), _, !IO) :- - io__write_string("\tMR_decr_sp_and_return(", !IO), - io__write_int(N, !IO), - io__write_string(");\n", !IO). + io.write_string("\tMR_decr_sp_and_return(", !IO), + io.write_int(N, !IO), + io.write_string(");\n", !IO). output_instruction(pragma_c(Decls, Components, _, _, _, _, _, _, _), _, !IO) :- - io__write_string("\t{\n", !IO), + io.write_string("\t{\n", !IO), output_pragma_decls(Decls, !IO), - list__foldl(output_pragma_c_component, Components, !IO), - io__write_string("\t}\n", !IO). + list.foldl(output_pragma_c_component, Components, !IO), + io.write_string("\t}\n", !IO). output_instruction(init_sync_term(Lval, N), _, !IO) :- - io__write_string("\tMR_init_sync_term(", !IO), + io.write_string("\tMR_init_sync_term(", !IO), output_lval_as_word(Lval, !IO), - io__write_string(", ", !IO), - io__write_int(N, !IO), - io__write_string(");\n", !IO). + io.write_string(", ", !IO), + io.write_int(N, !IO), + io.write_string(");\n", !IO). output_instruction(fork(Child, Parent, Lval), _, !IO) :- - io__write_string("\tMR_fork_new_context(", !IO), + io.write_string("\tMR_fork_new_context(", !IO), output_label_as_code_addr(Child, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), output_label_as_code_addr(Parent, !IO), - io__write_string(", ", !IO), - io__write_int(Lval, !IO), - io__write_string(");\n", !IO). + io.write_string(", ", !IO), + io.write_int(Lval, !IO), + io.write_string(");\n", !IO). output_instruction(join_and_terminate(Lval), _, !IO) :- - io__write_string("\tMR_join_and_terminate(", !IO), + io.write_string("\tMR_join_and_terminate(", !IO), output_lval(Lval, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_instruction(join_and_continue(Lval, Label), _, !IO) :- - io__write_string("\tMR_join_and_continue(", !IO), + io.write_string("\tMR_join_and_continue(", !IO), output_lval(Lval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), output_label_as_code_addr(Label, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). :- pred output_pragma_c_component(pragma_c_component::in, io::di, io::uo) is det. @@ -2201,24 +2200,24 @@ output_pragma_c_component(pragma_c_user_code(MaybeContext, C_Code), !IO) :- % just in case it starts with a proprocessor directive. ( MaybeContext = yes(Context), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), output_set_line_num(Context, !IO), - io__write_string(C_Code, !IO), - io__write_string(";}\n", !IO), + io.write_string(C_Code, !IO), + io.write_string(";}\n", !IO), output_reset_line_num(!IO) ; MaybeContext = no, - io__write_string("{\n", !IO), - io__write_string(C_Code, !IO), - io__write_string(";}\n", !IO) + io.write_string("{\n", !IO), + io.write_string(C_Code, !IO), + io.write_string(";}\n", !IO) ) ). output_pragma_c_component(pragma_c_raw_code(C_Code, _, _), !IO) :- - io__write_string(C_Code, !IO). + io.write_string(C_Code, !IO). output_pragma_c_component(pragma_c_fail_to(Label), !IO) :- - io__write_string("if (!" ++ pragma_succ_ind_name ++ ") MR_GOTO_LAB(", !IO), + io.write_string("if (!" ++ pragma_succ_ind_name ++ ") MR_GOTO_LAB(", !IO), output_label(Label, no, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_pragma_c_component(pragma_c_noop, !IO). % Output the local variable declarations at the top of the @@ -2231,18 +2230,18 @@ output_pragma_decls([Decl | Decls], !IO) :- ( % Apart from special cases, the local variables are MR_Words Decl = pragma_c_arg_decl(_Type, TypeString, VarName), - io__write_string("\t", !IO), - io__write_string(TypeString, !IO), - io__write_string("\t", !IO), - io__write_string(VarName, !IO), - io__write_string(";\n", !IO) + io.write_string("\t", !IO), + io.write_string(TypeString, !IO), + io.write_string("\t", !IO), + io.write_string(VarName, !IO), + io.write_string(";\n", !IO) ; Decl = pragma_c_struct_ptr_decl(StructTag, VarName), - io__write_string("\tstruct ", !IO), - io__write_string(StructTag, !IO), - io__write_string("\t*", !IO), - io__write_string(VarName, !IO), - io__write_string(";\n", !IO) + io.write_string("\tstruct ", !IO), + io.write_string(StructTag, !IO), + io.write_string("\t*", !IO), + io.write_string(VarName, !IO), + io.write_string(";\n", !IO) ), output_pragma_decls(Decls, !IO). @@ -2283,11 +2282,11 @@ output_pragma_inputs([Input | Inputs], !IO) :- output_pragma_input(Input, !IO) :- Input = pragma_c_input(VarName, _VarType, _IsDummy, OrigType, Rval, MaybeForeignTypeInfo, BoxPolicy), - io__write_string("\t", !IO), + io.write_string("\t", !IO), ( BoxPolicy = always_boxed, - io__write_string(VarName, !IO), - io__write_string(" = ", !IO), + io.write_string(VarName, !IO), + io.write_string(" = ", !IO), output_rval_as_type(Rval, word, !IO) ; BoxPolicy = native_if_possible, @@ -2301,28 +2300,28 @@ output_pragma_input(Input, !IO) :- % invokes memcpy when given a word-sized type. ( ( c_type_is_word_sized_int_or_ptr(ForeignType) - ; list__member(can_pass_as_mercury_type, Assertions) + ; list.member(can_pass_as_mercury_type, Assertions) ) -> % Note that for this cast to be correct the foreign % type must be a word sized integer or pointer type. - io__write_string(VarName, !IO), - io__write_string(" = ", !IO), - io__write_string("(" ++ ForeignType ++ ") ", !IO), + io.write_string(VarName, !IO), + io.write_string(" = ", !IO), + io.write_string("(" ++ ForeignType ++ ") ", !IO), output_rval_as_type(Rval, word, !IO) ; - io__write_string("MR_MAYBE_UNBOX_FOREIGN_TYPE(", !IO), - io__write_string(ForeignType, !IO), - io__write_string(", ", !IO), + io.write_string("MR_MAYBE_UNBOX_FOREIGN_TYPE(", !IO), + io.write_string(ForeignType, !IO), + io.write_string(", ", !IO), output_rval_as_type(Rval, word, !IO), - io__write_string(", ", !IO), - io__write_string(VarName, !IO), - io__write_string(")", !IO) + io.write_string(", ", !IO), + io.write_string(VarName, !IO), + io.write_string(")", !IO) ) ; MaybeForeignTypeInfo = no, - io__write_string(VarName, !IO), - io__write_string(" = ", !IO), + io.write_string(VarName, !IO), + io.write_string(" = ", !IO), ( OrigType = builtin(string) -> output_llds_type_cast(string, !IO), output_rval_as_type(Rval, word, !IO) @@ -2333,7 +2332,7 @@ output_pragma_input(Input, !IO) :- ) ) ), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). % Output declarations for any lvals used for the outputs. % @@ -2372,88 +2371,88 @@ output_pragma_outputs([Output | Outputs], !IO) :- output_pragma_output(Output, !IO) :- Output = pragma_c_output(Lval, _VarType, _IsDummy, OrigType, VarName, MaybeForeignType, BoxPolicy), - io__write_string("\t", !IO), + io.write_string("\t", !IO), ( BoxPolicy = always_boxed, output_lval_as_word(Lval, !IO), - io__write_string(" = ", !IO), - io__write_string(VarName, !IO) + io.write_string(" = ", !IO), + io.write_string(VarName, !IO) ; BoxPolicy = native_if_possible, ( MaybeForeignType = yes(ForeignTypeInfo), ForeignTypeInfo = pragma_c_foreign_type(ForeignType, Assertions), - ( list__member(can_pass_as_mercury_type, Assertions) -> + ( list.member(can_pass_as_mercury_type, Assertions) -> output_lval_as_word(Lval, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), output_llds_type_cast(word, !IO), - io__write_string(VarName, !IO) + io.write_string(VarName, !IO) ; - io__write_string("MR_MAYBE_BOX_FOREIGN_TYPE(", !IO), - io__write_string(ForeignType, !IO), - io__write_string(", ", !IO), - io__write_string(VarName, !IO), - io__write_string(", ", !IO), + io.write_string("MR_MAYBE_BOX_FOREIGN_TYPE(", !IO), + io.write_string(ForeignType, !IO), + io.write_string(", ", !IO), + io.write_string(VarName, !IO), + io.write_string(", ", !IO), output_lval_as_word(Lval, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ) ; MaybeForeignType = no, output_lval_as_word(Lval, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), ( OrigType = builtin(string) -> output_llds_type_cast(word, !IO), - io__write_string(VarName, !IO) + io.write_string(VarName, !IO) ; OrigType = builtin(float) -> - io__write_string("MR_float_to_word(", !IO), - io__write_string(VarName, !IO), - io__write_string(")", !IO) + io.write_string("MR_float_to_word(", !IO), + io.write_string(VarName, !IO), + io.write_string(")", !IO) ; - io__write_string(VarName, !IO) + io.write_string(VarName, !IO) ) ) ), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). :- pred output_reset_trail_reason(reset_trail_reason::in, io::di, io::uo) is det. output_reset_trail_reason(undo, !IO) :- - io__write_string("MR_undo", !IO). + io.write_string("MR_undo", !IO). output_reset_trail_reason(commit, !IO) :- - io__write_string("MR_commit", !IO). + io.write_string("MR_commit", !IO). output_reset_trail_reason(solve, !IO) :- - io__write_string("MR_solve", !IO). + io.write_string("MR_solve", !IO). output_reset_trail_reason(exception, !IO) :- - io__write_string("MR_exception", !IO). + io.write_string("MR_exception", !IO). output_reset_trail_reason(retry, !IO) :- - io__write_string("MR_retry", !IO). + io.write_string("MR_retry", !IO). output_reset_trail_reason(gc, !IO) :- - io__write_string("MR_gc", !IO). + io.write_string("MR_gc", !IO). :- pred output_livevals(list(lval)::in, io::di, io::uo) is det. output_livevals([], !IO). output_livevals([Lval | Lvals], !IO) :- - io__write_string("*\t", !IO), + io.write_string("*\t", !IO), output_lval(Lval, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_livevals(Lvals, !IO). :- pred output_gc_livevals(list(liveinfo)::in, io::di, io::uo) is det. output_gc_livevals(LiveVals, !IO) :- - globals__io_lookup_bool_option(auto_comments, PrintAutoComments, !IO), + globals.io_lookup_bool_option(auto_comments, PrintAutoComments, !IO), ( PrintAutoComments = yes, - io__write_string("/*\n", !IO), - io__write_string("* Garbage collection livevals info\n", !IO), + io.write_string("/*\n", !IO), + io.write_string("* Garbage collection livevals info\n", !IO), output_gc_livevals_2(LiveVals, !IO), - io__write_string("*/\n", !IO) + io.write_string("*/\n", !IO) ; PrintAutoComments = no ). @@ -2463,14 +2462,14 @@ output_gc_livevals(LiveVals, !IO) :- output_gc_livevals_2([], !IO). output_gc_livevals_2([LiveInfo | LiveInfos], !IO) :- LiveInfo = live_lvalue(Locn, LiveValueType, TypeParams), - io__write_string("*\t", !IO), + io.write_string("*\t", !IO), output_layout_locn(Locn, !IO), - io__write_string("\t", !IO), + io.write_string("\t", !IO), output_live_value_type(LiveValueType, !IO), - io__write_string("\t", !IO), - map__to_assoc_list(TypeParams, TypeParamList), + io.write_string("\t", !IO), + map.to_assoc_list(TypeParams, TypeParamList), output_gc_livevals_params(TypeParamList, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_gc_livevals_2(LiveInfos, !IO). :- pred output_gc_livevals_params(assoc_list(tvar, set(layout_locn))::in, @@ -2478,12 +2477,12 @@ output_gc_livevals_2([LiveInfo | LiveInfos], !IO) :- output_gc_livevals_params([], !IO). output_gc_livevals_params([Var - LocnSet | Locns], !IO) :- - term__var_to_int(Var, VarInt), - io__write_int(VarInt, !IO), - io__write_string(" - ", !IO), - set__to_sorted_list(LocnSet, LocnList), + term.var_to_int(Var, VarInt), + io.write_int(VarInt, !IO), + io.write_string(" - ", !IO), + set.to_sorted_list(LocnSet, LocnList), output_layout_locns(LocnList, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), output_gc_livevals_params(Locns, !IO). :- pred output_layout_locns(list(layout_locn)::in, io::di, io::uo) is det. @@ -2495,7 +2494,7 @@ output_layout_locns([Locn | Locns], !IO) :- Locns = [] ; Locns = [_ | _], - io__write_string(" and ", !IO), + io.write_string(" and ", !IO), output_layout_locns(Locns, !IO) ). @@ -2507,53 +2506,53 @@ output_layout_locn(Locn, !IO) :- output_lval(Lval, !IO) ; Locn = indirect(Lval, Offset), - io__write_string("offset ", !IO), - io__write_int(Offset, !IO), - io__write_string(" from ", !IO), + io.write_string("offset ", !IO), + io.write_int(Offset, !IO), + io.write_string(" from ", !IO), output_lval(Lval, !IO) ). :- pred output_live_value_type(live_value_type::in, io::di, io::uo) is det. output_live_value_type(succip, !IO) :- - io__write_string("type succip", !IO). + io.write_string("type succip", !IO). output_live_value_type(curfr, !IO) :- - io__write_string("type curfr", !IO). + io.write_string("type curfr", !IO). output_live_value_type(maxfr, !IO) :- - io__write_string("type maxfr", !IO). + io.write_string("type maxfr", !IO). output_live_value_type(redofr, !IO) :- - io__write_string("type redofr", !IO). + io.write_string("type redofr", !IO). output_live_value_type(redoip, !IO) :- - io__write_string("type redoip", !IO). + io.write_string("type redoip", !IO). output_live_value_type(hp, !IO) :- - io__write_string("type hp", !IO). + io.write_string("type hp", !IO). output_live_value_type(trail_ptr, !IO) :- - io__write_string("type trail_ptr", !IO). + io.write_string("type trail_ptr", !IO). output_live_value_type(ticket, !IO) :- - io__write_string("type ticket", !IO). + io.write_string("type ticket", !IO). output_live_value_type(unwanted, !IO) :- - io__write_string("unwanted", !IO). + io.write_string("unwanted", !IO). output_live_value_type(var(Var, Name, Type, LldsInst), !IO) :- - io__write_string("var(", !IO), - term__var_to_int(Var, VarInt), - io__write_int(VarInt, !IO), - io__write_string(", ", !IO), - io__write_string(Name, !IO), - io__write_string(", ", !IO), + io.write_string("var(", !IO), + term.var_to_int(Var, VarInt), + io.write_int(VarInt, !IO), + io.write_string(", ", !IO), + io.write_string(Name, !IO), + io.write_string(", ", !IO), % XXX Fake type varset - varset__init(NewTVarset), + varset.init(NewTVarset), mercury_output_type(NewTVarset, no, Type, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ( LldsInst = ground, - io__write_string("ground", !IO) + io.write_string("ground", !IO) ; LldsInst = partial(Inst), % XXX Fake inst varset - varset__init(NewIVarset), + varset.init(NewIVarset), mercury_output_inst(Inst, NewIVarset, !IO) ), - io__write_string(")", !IO). + io.write_string(")", !IO). :- pred output_temp_decls(int::in, string::in, io::di, io::uo) is det. @@ -2566,13 +2565,13 @@ output_temp_decls(N, Type, !IO) :- output_temp_decls_2(Next, Max, Type, !IO) :- ( Next =< Max -> ( Next > 1 -> - io__write_string(", ", !IO) + io.write_string(", ", !IO) ; true ), - io__write_string("MR_temp", !IO), - io__write_string(Type, !IO), - io__write_int(Next, !IO), + io.write_string("MR_temp", !IO), + io.write_string(Type, !IO), + io.write_int(Next, !IO), output_temp_decls_2(Next + 1, Max, Type, !IO) ; true @@ -2615,8 +2614,8 @@ output_rval_decls(const(Const), FirstIndent, LaterIndent, !N, !DeclSet, !IO) :- % then for each float constant which we might want to box we declare % a static const variable holding that constant. % - globals__io_lookup_bool_option(unboxed_float, UnboxedFloat, !IO), - globals__io_lookup_bool_option(static_ground_terms, StaticGroundTerms, + globals.io_lookup_bool_option(unboxed_float, UnboxedFloat, !IO), + globals.io_lookup_bool_option(static_ground_terms, StaticGroundTerms, !IO), ( UnboxedFloat = no, @@ -2628,10 +2627,10 @@ output_rval_decls(const(Const), FirstIndent, LaterIndent, !N, !DeclSet, !IO) :- true ; decl_set_insert(FloatLabel, !DeclSet), - FloatString = c_util__make_float_literal( FloatVal), + FloatString = c_util.make_float_literal( FloatVal), output_indent(FirstIndent, LaterIndent, !.N, !IO), !:N = !.N + 1, - io__write_strings(["static const MR_Float ", + io.write_strings(["static const MR_Float ", "mercury_float_const_", FloatName, " = ", FloatString, ";\n" ], !IO) @@ -2654,9 +2653,9 @@ output_rval_decls(binop(Op, Rval1, Rval2), FirstIndent, LaterIndent, % then for each float constant which we might want to box we declare % a static const variable holding that constant. % - ( c_util__float_op(Op, OpStr) -> - globals__io_lookup_bool_option(unboxed_float, UnboxFloat, !IO), - globals__io_lookup_bool_option(static_ground_terms, StaticGroundTerms, + ( c_util.float_op(Op, OpStr) -> + globals.io_lookup_bool_option(unboxed_float, UnboxFloat, !IO), + globals.io_lookup_bool_option(static_ground_terms, StaticGroundTerms, !IO), ( UnboxFloat = no, @@ -2670,21 +2669,21 @@ output_rval_decls(binop(Op, Rval1, Rval2), FirstIndent, LaterIndent, decl_set_insert(FloatLabel, !DeclSet), output_indent(FirstIndent, LaterIndent, !.N, !IO), !:N = !.N + 1, - io__write_string("static const ", !IO), + io.write_string("static const ", !IO), output_llds_type(float, !IO), - io__write_string(" mercury_float_const_", !IO), - io__write_string(FloatName, !IO), - io__write_string(" = ", !IO), + io.write_string(" mercury_float_const_", !IO), + io.write_string(FloatName, !IO), + io.write_string(" = ", !IO), % Note that we just output the expression here, and let the C % compiler evaluate it, rather than evaluating it ourselves. % This avoids having to deal with some nasty issues regarding % floating point accuracy when doing cross-compilation. output_rval_as_type(Rval1, float, !IO), - io__write_string(" ", !IO), - io__write_string(OpStr, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), + io.write_string(OpStr, !IO), + io.write_string(" ", !IO), output_rval_as_type(Rval2, float, !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ) ; true @@ -2764,10 +2763,10 @@ float_const_binop_expr_name(Op, Arg1, Arg2, Name) :- float_literal_name(Float, FloatName) :- % The name of the variable is based on the value of the float const, with % "pt" instead of ".", "plus" instead of "+", and "neg" instead of "-". - FloatName0 = c_util__make_float_literal(Float), - string__replace_all(FloatName0, ".", "pt", FloatName1), - string__replace_all(FloatName1, "+", "plus", FloatName2), - string__replace_all(FloatName2, "-", "neg", FloatName). + FloatName0 = c_util.make_float_literal(Float), + string.replace_all(FloatName0, ".", "pt", FloatName1), + string.replace_all(FloatName1, "+", "plus", FloatName2), + string.replace_all(FloatName2, "-", "neg", FloatName). % Succeed iff the binary operator is an operator whose return % type is float; bind the output string to a name for that operator @@ -2796,11 +2795,11 @@ common_cell_get_type_num(TypeAndValue) = TypeNum :- common_cell_get_rvals(TypeAndValue) = Rvals :- ( TypeAndValue = plain_type_and_value(_, RvalsTypes), - assoc_list__keys(RvalsTypes, Rvals) + assoc_list.keys(RvalsTypes, Rvals) ; TypeAndValue = grouped_type_and_value(_, Groups), - RvalLists = list__map(common_group_get_rvals, Groups), - list__condense(RvalLists, Rvals) + RvalLists = list.map(common_group_get_rvals, Groups), + list.condense(RvalLists, Rvals) ). :- func common_group_get_rvals(common_cell_arg_group) = list(rval). @@ -2837,19 +2836,19 @@ common_group_get_rvals(common_cell_ungrouped_arg(_, Rval)) = [Rval]. output_const_term_type(TypeAndValue, FirstIndent, LaterIndent, !N, !IO) :- output_indent(FirstIndent, LaterIndent, !.N, !IO), !:N = !.N + 1, - io__write_string("struct ", !IO), + io.write_string("struct ", !IO), TypeNum = common_cell_get_type_num(TypeAndValue), output_common_cell_type_name(TypeNum, !IO), - io__write_string(" {\n", !IO), + io.write_string(" {\n", !IO), ( TypeAndValue = plain_type_and_value(_, ArgsTypes), - assoc_list__values(ArgsTypes, Types), + assoc_list.values(ArgsTypes, Types), output_cons_arg_types(Types, "\t", 1, !IO) ; TypeAndValue = grouped_type_and_value(_, ArgGroups), output_cons_arg_group_types(ArgGroups, "\t", 1, !IO) ), - io__write_string("};\n", !IO). + io.write_string("};\n", !IO). :- pred output_const_term_decl_or_defn(common_cell_type_and_value::in, module_name::in, int::in, bool::in, bool::in, @@ -2861,22 +2860,22 @@ output_const_term_decl_or_defn(TypeAndValue, ModuleName, CellNum, Exported, !:N = !.N + 1, ( Exported = yes, - io__write_string("const struct ", !IO) + io.write_string("const struct ", !IO) ; Exported = no, - io__write_string("static const struct ", !IO) + io.write_string("static const struct ", !IO) ), TypeNum = common_cell_get_type_num(TypeAndValue), output_common_cell_type_name(TypeNum, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), VarDeclId = data_addr(ModuleName, common(CellNum, TypeNum)), output_decl_id(data_addr(VarDeclId), !IO), ( IsDefn = no, - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ; IsDefn = yes, - io__write_string(" =\n{\n", !IO), + io.write_string(" =\n{\n", !IO), ( TypeAndValue = plain_type_and_value(_, ArgsTypes), output_cons_args(ArgsTypes, !IO) @@ -2884,8 +2883,8 @@ output_const_term_decl_or_defn(TypeAndValue, ModuleName, CellNum, Exported, TypeAndValue = grouped_type_and_value(_, ArgGroups), output_cons_arg_groups(ArgGroups, !IO) ), - io__write_string(LaterIndent, !IO), - io__write_string("};\n", !IO) + io.write_string(LaterIndent, !IO), + io.write_string("};\n", !IO) ). % Return true if a data structure of the given type will eventually @@ -2934,11 +2933,11 @@ output_decl_id(typeclass_constraint_struct(_Name), !IO) :- output_cons_arg_types([], _, _, !IO). output_cons_arg_types([Type | Types], Indent, ArgNum, !IO) :- - io__write_string(Indent, !IO), + io.write_string(Indent, !IO), output_llds_type(Type, !IO), - io__write_string(" f", !IO), - io__write_int(ArgNum, !IO), - io__write_string(";\n", !IO), + io.write_string(" f", !IO), + io.write_int(ArgNum, !IO), + io.write_string(";\n", !IO), output_cons_arg_types(Types, Indent, ArgNum + 1, !IO). :- pred output_cons_arg_group_types(list(common_cell_arg_group)::in, @@ -2946,21 +2945,21 @@ output_cons_arg_types([Type | Types], Indent, ArgNum, !IO) :- output_cons_arg_group_types([], _, _, !IO). output_cons_arg_group_types([Group | Groups], Indent, ArgNum, !IO) :- - io__write_string(Indent, !IO), + io.write_string(Indent, !IO), ( Group = common_cell_grouped_args(Type, ArraySize, _), output_llds_type(Type, !IO), - io__write_string(" f", !IO), - io__write_int(ArgNum, !IO), - io__write_string("[", !IO), - io__write_int(ArraySize, !IO), - io__write_string("];\n", !IO) + io.write_string(" f", !IO), + io.write_int(ArgNum, !IO), + io.write_string("[", !IO), + io.write_int(ArraySize, !IO), + io.write_string("];\n", !IO) ; Group = common_cell_ungrouped_arg(Type, _), output_llds_type(Type, !IO), - io__write_string(" f", !IO), - io__write_int(ArgNum, !IO), - io__write_string(";\n", !IO) + io.write_string(" f", !IO), + io.write_int(ArgNum, !IO), + io.write_string(";\n", !IO) ), output_cons_arg_group_types(Groups, Indent, ArgNum + 1, !IO). @@ -2972,8 +2971,8 @@ output_cons_arg_group_types([Group | Groups], Indent, ArgNum, !IO) :- :- pred rval_type_as_arg(rval::in, llds_type::out, io::di, io::uo) is det. rval_type_as_arg(Rval, ArgType, !IO) :- - llds__rval_type(Rval, Type), - globals__io_lookup_bool_option(unboxed_float, UnboxFloat, !IO), + llds.rval_type(Rval, Type), + globals.io_lookup_bool_option(unboxed_float, UnboxFloat, !IO), ( Type = float, UnboxFloat = no @@ -2988,40 +2987,40 @@ rval_type_as_arg(Rval, ArgType, !IO) :- :- pred output_llds_type_cast(llds_type::in, io::di, io::uo) is det. output_llds_type_cast(LLDSType, !IO) :- - io__write_string("(", !IO), + io.write_string("(", !IO), output_llds_type(LLDSType, !IO), - io__write_string(") ", !IO). + io.write_string(") ", !IO). :- pred output_llds_type(llds_type::in, io::di, io::uo) is det. output_llds_type(int_least8, !IO) :- - io__write_string("MR_int_least8_t", !IO). + io.write_string("MR_int_least8_t", !IO). output_llds_type(uint_least8, !IO) :- - io__write_string("MR_uint_least8_t", !IO). + io.write_string("MR_uint_least8_t", !IO). output_llds_type(int_least16, !IO) :- - io__write_string("MR_int_least16_t", !IO). + io.write_string("MR_int_least16_t", !IO). output_llds_type(uint_least16, !IO) :- - io__write_string("MR_uint_least16_t", !IO). + io.write_string("MR_uint_least16_t", !IO). output_llds_type(int_least32, !IO) :- - io__write_string("MR_int_least32_t", !IO). + io.write_string("MR_int_least32_t", !IO). output_llds_type(uint_least32, !IO) :- - io__write_string("MR_uint_least32_t", !IO). + io.write_string("MR_uint_least32_t", !IO). output_llds_type(bool, !IO) :- - io__write_string("MR_Integer", !IO). + io.write_string("MR_Integer", !IO). output_llds_type(integer, !IO) :- - io__write_string("MR_Integer", !IO). + io.write_string("MR_Integer", !IO). output_llds_type(unsigned, !IO) :- - io__write_string("MR_Unsigned", !IO). + io.write_string("MR_Unsigned", !IO). output_llds_type(float, !IO) :- - io__write_string("MR_Float", !IO). + io.write_string("MR_Float", !IO). output_llds_type(word, !IO) :- - io__write_string("MR_Word", !IO). + io.write_string("MR_Word", !IO). output_llds_type(string, !IO) :- - io__write_string("MR_String", !IO). + io.write_string("MR_String", !IO). output_llds_type(data_ptr, !IO) :- - io__write_string("MR_Word *", !IO). + io.write_string("MR_Word *", !IO). output_llds_type(code_ptr, !IO) :- - io__write_string("MR_Code *", !IO). + io.write_string("MR_Code *", !IO). % Output the arguments, each on its own line prefixing with Indent, % and with a cast appropriate to its type if necessary. @@ -3041,11 +3040,11 @@ output_cons_args([Rval - Type | RvalsTypes], !IO) :- ), ( RvalsTypes = [_ | _], - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_cons_args(RvalsTypes, !IO) ; RvalsTypes = [], - io__write_string("\n", !IO) + io.write_string("\n", !IO) ). :- pred output_cons_arg_groups(list(common_cell_arg_group)::in, io::di, io::uo) @@ -3055,10 +3054,10 @@ output_cons_arg_groups([], !IO). output_cons_arg_groups([Group | Groups], !IO) :- ( Group = common_cell_grouped_args(Type, _, Rvals), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), ( direct_field_int_constant(Type) = yes, - list__map(project_int_constant, Rvals, Ints) + list.map(project_int_constant, Rvals, Ints) -> Check = check_int_const_sizes, ( @@ -3071,7 +3070,7 @@ output_cons_arg_groups([Group | Groups], !IO) :- ; output_cons_arg_group_elements(Type, Rvals, !IO) ), - io__write_string("}", !IO) + io.write_string("}", !IO) ; Group = common_cell_ungrouped_arg(Type, Rval), ( @@ -3085,11 +3084,11 @@ output_cons_arg_groups([Group | Groups], !IO) :- ), ( Groups = [_ | _], - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_cons_arg_groups(Groups, !IO) ; Groups = [], - io__write_string("\n", !IO) + io.write_string("\n", !IO) ). :- pred output_cons_arg_group_elements(llds_type::in, list(rval)::in, @@ -3100,25 +3099,25 @@ output_cons_arg_group_elements(Type, [Rval | Rvals], !IO) :- output_rval_as_type(Rval, Type, !IO), ( Rvals = [_ | _], - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_cons_arg_group_elements(Type, Rvals, !IO) ; Rvals = [], - io__write_string("\n", !IO) + io.write_string("\n", !IO) ). :- pred output_cons_arg_group_ints(list(int)::in, io::di, io::uo) is det. output_cons_arg_group_ints([], !IO). output_cons_arg_group_ints([Int | Ints], !IO) :- - io__write_int(Int, !IO), + io.write_int(Int, !IO), ( Ints = [_ | _], - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_cons_arg_group_ints(Ints, !IO) ; Ints = [], - io__write_string("\n", !IO) + io.write_string("\n", !IO) ). :- pred output_cons_arg_group_ints_check(list(int)::in, llds_type::in, @@ -3129,11 +3128,11 @@ output_cons_arg_group_ints_check([Int | Ints], Type, !IO) :- output_int_const(Int, Type, !IO), ( Ints = [_ | _], - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_cons_arg_group_ints_check(Ints, Type, !IO) ; Ints = [], - io__write_string("\n", !IO) + io.write_string("\n", !IO) ). :- pred project_int_constant(rval::in, int::out) is semidet. @@ -3156,14 +3155,14 @@ output_int_const(N, Type, !IO) :- ( Check = yes, ( ok_int_const(N, Type) -> - io__write_int(N, !IO) + io.write_int(N, !IO) ; unexpected(this_file, "output_int_const: constant does not fit in type") ) ; Check = no, - io__write_int(N, !IO) + io.write_int(N, !IO) ). :- pred ok_int_const(int::in, llds_type::in) is semidet. @@ -3280,7 +3279,7 @@ need_code_addr_decls(imported(_), yes, !IO). need_code_addr_decls(succip, no, !IO). need_code_addr_decls(do_succeed(_), no, !IO). need_code_addr_decls(do_redo, NeedDecl, !IO) :- - globals__io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), + globals.io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), ( UseMacro = yes, NeedDecl = no @@ -3289,7 +3288,7 @@ need_code_addr_decls(do_redo, NeedDecl, !IO) :- NeedDecl = yes ). need_code_addr_decls(do_fail, NeedDecl, !IO) :- - globals__io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), + globals.io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), ( UseMacro = yes, NeedDecl = no @@ -3308,53 +3307,53 @@ need_code_addr_decls(do_not_reached, yes, !IO). output_code_addr_decls(label(Label), !IO) :- output_label_as_code_addr_decls(Label, !IO). output_code_addr_decls(imported(ProcLabel), !IO) :- - io__write_string("MR_decl_entry(", !IO), + io.write_string("MR_decl_entry(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_code_addr_decls(succip, !IO). output_code_addr_decls(do_succeed(_), !IO). output_code_addr_decls(do_redo, !IO) :- - globals__io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), + globals.io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), ( UseMacro = yes ; UseMacro = no, - io__write_string("MR_declare_entry(", !IO), - io__write_string("MR_do_redo", !IO), - io__write_string(");\n", !IO) + io.write_string("MR_declare_entry(", !IO), + io.write_string("MR_do_redo", !IO), + io.write_string(");\n", !IO) ). output_code_addr_decls(do_fail, !IO) :- - globals__io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), + globals.io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), ( UseMacro = yes ; UseMacro = no, - io__write_string("MR_declare_entry(", !IO), - io__write_string("MR_do_fail", !IO), - io__write_string(");\n", !IO) + io.write_string("MR_declare_entry(", !IO), + io.write_string("MR_do_fail", !IO), + io.write_string(");\n", !IO) ). output_code_addr_decls(do_trace_redo_fail_shallow, !IO) :- - io__write_string("MR_declare_entry(MR_do_trace_redo_fail_shallow);\n", + io.write_string("MR_declare_entry(MR_do_trace_redo_fail_shallow);\n", !IO). output_code_addr_decls(do_trace_redo_fail_deep, !IO) :- - io__write_string("MR_declare_entry(MR_do_trace_redo_fail_deep);\n", !IO). + io.write_string("MR_declare_entry(MR_do_trace_redo_fail_deep);\n", !IO). output_code_addr_decls(do_call_closure(Variant), !IO) :- - io__write_string("MR_declare_entry(mercury__do_call_closure_", !IO), - io__write_string(ho_call_variant_to_string(Variant), !IO), - io__write_string(");\n", !IO). + io.write_string("MR_declare_entry(mercury__do_call_closure_", !IO), + io.write_string(ho_call_variant_to_string(Variant), !IO), + io.write_string(");\n", !IO). output_code_addr_decls(do_call_class_method(Variant), !IO) :- - io__write_string("MR_declare_entry(mercury__do_call_class_method_", !IO), - io__write_string(ho_call_variant_to_string(Variant), !IO), - io__write_string(");\n", !IO). + io.write_string("MR_declare_entry(mercury__do_call_class_method_", !IO), + io.write_string(ho_call_variant_to_string(Variant), !IO), + io.write_string(");\n", !IO). output_code_addr_decls(do_not_reached, !IO) :- - io__write_string("MR_declare_entry(MR_do_not_reached);\n", !IO). + io.write_string("MR_declare_entry(MR_do_not_reached);\n", !IO). :- pred output_label_as_code_addr_decls(label::in, io::di, io::uo) is det. output_label_as_code_addr_decls(entry(exported, ProcLabel), !IO) :- - io__write_string("MR_decl_entry(", !IO), + io.write_string("MR_decl_entry(", !IO), output_label(entry(exported, ProcLabel), no, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_label_as_code_addr_decls(entry(local, _ProcLabel), !IO). output_label_as_code_addr_decls(entry(c_local, _), !IO). output_label_as_code_addr_decls(internal(_, _), !IO). @@ -3381,15 +3380,15 @@ output_data_addr_decls_2(DataAddr, FirstIndent, LaterIndent, !N, !IO) :- DataAddr = data_addr(ModuleName, DataVarName), output_data_addr_storage_type_name(ModuleName, DataVarName, no, LaterIndent, !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ; DataAddr = rtti_addr(RttiId), output_rtti_id_storage_type_name_no_decl(RttiId, no, !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ; DataAddr = layout_addr(LayoutName), output_layout_name_storage_type_name(LayoutName, no, !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ). output_data_addrs_decls([], _, _, !N, !DeclSet, !IO). @@ -3421,7 +3420,7 @@ c_data_linkage_string(DefaultLinkage, BeingDefined) = LinkageStr :- c_data_const_string(Globals, InclCodeAddr) = ( InclCodeAddr = yes, - globals__have_static_code_addresses(Globals, no) + globals.have_static_code_addresses(Globals, no) -> "" ; @@ -3440,17 +3439,17 @@ output_data_addr_storage_type_name(ModuleName, DataVarName, BeingDefined, LaterIndent, !IO) :- data_name_linkage(DataVarName, Linkage), LinkageStr = c_data_linkage_string(Linkage, BeingDefined), - io__write_string(LinkageStr, !IO), + io.write_string(LinkageStr, !IO), InclCodeAddr = data_name_may_include_non_static_code_address(DataVarName), - globals__io_get_globals(Globals, !IO), - io__write_string(c_data_const_string(Globals, InclCodeAddr), !IO), + globals.io_get_globals(Globals, !IO), + io.write_string(c_data_const_string(Globals, InclCodeAddr), !IO), - io__write_string("struct ", !IO), + io.write_string("struct ", !IO), output_data_addr(ModuleName, DataVarName, !IO), - io__write_string("_struct\n", !IO), - io__write_string(LaterIndent, !IO), - io__write_string("\t", !IO), + io.write_string("_struct\n", !IO), + io.write_string(LaterIndent, !IO), + io.write_string("\t", !IO), output_data_addr(ModuleName, DataVarName, !IO). :- pred data_name_linkage(data_name::in, linkage::out) is det. @@ -3464,9 +3463,9 @@ data_name_linkage(tabling_pointer(_), static). output_indent(FirstIndent, LaterIndent, N0, !IO) :- ( N0 > 0 -> - io__write_string(LaterIndent, !IO) + io.write_string(LaterIndent, !IO) ; - io__write_string(FirstIndent, !IO) + io.write_string(FirstIndent, !IO) ). %-----------------------------------------------------------------------------% @@ -3477,14 +3476,14 @@ output_indent(FirstIndent, LaterIndent, N0, !IO) :- maybe_output_update_prof_counter(Label, CallerLabel - ContLabelSet, !IO) :- % If ProfileTime is no, the definition of MR_update_prof_current_proc % is empty anyway. - globals__io_lookup_bool_option(profile_time, ProfileTime, !IO), + globals.io_lookup_bool_option(profile_time, ProfileTime, !IO), ( - bintree_set__is_member(Label, ContLabelSet), + bintree_set.is_member(Label, ContLabelSet), ProfileTime = yes -> - io__write_string("\tMR_update_prof_current_proc(MR_LABEL_AP(", !IO), + io.write_string("\tMR_update_prof_current_proc(MR_LABEL_AP(", !IO), output_label(CallerLabel, no, !IO), - io__write_string("));\n", !IO) + io.write_string("));\n", !IO) ; true ). @@ -3499,126 +3498,126 @@ maybe_output_update_prof_counter(Label, CallerLabel - ContLabelSet, !IO) :- output_goto(label(Label), CallerLabel, !IO) :- ( Label = entry(exported, _), - globals__io_lookup_bool_option(profile_calls, ProfileCalls, !IO), + globals.io_lookup_bool_option(profile_calls, ProfileCalls, !IO), ( ProfileCalls = yes, - io__write_string("MR_tailcall(", !IO), + io.write_string("MR_tailcall(", !IO), output_label_as_code_addr(Label, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_label_as_code_addr(CallerLabel, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; ProfileCalls = no, - io__write_string("MR_np_tailcall_ent(", !IO), + io.write_string("MR_np_tailcall_ent(", !IO), output_label(Label, no, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ) ; Label = entry(local, _), - globals__io_lookup_bool_option(profile_calls, ProfileCalls, !IO), + globals.io_lookup_bool_option(profile_calls, ProfileCalls, !IO), ( ProfileCalls = yes, - io__write_string("MR_tailcall(", !IO), + io.write_string("MR_tailcall(", !IO), output_label_as_code_addr(Label, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_label_as_code_addr(CallerLabel, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; ProfileCalls = no, - io__write_string("MR_np_tailcall_ent(", !IO), + io.write_string("MR_np_tailcall_ent(", !IO), output_label(Label, no, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ) ; Label = entry(c_local, _), - globals__io_lookup_bool_option(profile_calls, ProfileCalls, !IO), + globals.io_lookup_bool_option(profile_calls, ProfileCalls, !IO), ( ProfileCalls = yes, - io__write_string("MR_localtailcall(", !IO), + io.write_string("MR_localtailcall(", !IO), output_label(Label, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_label_as_code_addr(CallerLabel, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; ProfileCalls = no, - io__write_string("MR_np_localtailcall(", !IO), + io.write_string("MR_np_localtailcall(", !IO), output_label(Label, no, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ) ; Label = internal(_, _), - io__write_string("MR_GOTO_LAB(", !IO), + io.write_string("MR_GOTO_LAB(", !IO), output_label(Label, no, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ). output_goto(imported(ProcLabel), CallerLabel, !IO) :- - globals__io_lookup_bool_option(profile_calls, ProfileCalls, !IO), + globals.io_lookup_bool_option(profile_calls, ProfileCalls, !IO), ( ProfileCalls = yes, - io__write_string("MR_tailcall(MR_ENTRY(", !IO), + io.write_string("MR_tailcall(MR_ENTRY(", !IO), output_proc_label(ProcLabel, !IO), - io__write_string("),\n\t\t", !IO), + io.write_string("),\n\t\t", !IO), output_label_as_code_addr(CallerLabel, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; ProfileCalls = no, - io__write_string("MR_np_tailcall_ent(", !IO), + io.write_string("MR_np_tailcall_ent(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ). output_goto(succip, _, !IO) :- - io__write_string("MR_proceed();\n", !IO). + io.write_string("MR_proceed();\n", !IO). output_goto(do_succeed(Last), _, !IO) :- ( Last = no, - io__write_string("MR_succeed();\n", !IO) + io.write_string("MR_succeed();\n", !IO) ; Last = yes, - io__write_string("MR_succeed_discard();\n", !IO) + io.write_string("MR_succeed_discard();\n", !IO) ). output_goto(do_redo, _, !IO) :- - globals__io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), + globals.io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), ( UseMacro = yes, - io__write_string("MR_redo();\n", !IO) + io.write_string("MR_redo();\n", !IO) ; UseMacro = no, - io__write_string("MR_GOTO(MR_ENTRY(MR_do_redo));\n", !IO) + io.write_string("MR_GOTO(MR_ENTRY(MR_do_redo));\n", !IO) ). output_goto(do_fail, _, !IO) :- - globals__io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), + globals.io_lookup_bool_option(use_macro_for_redo_fail, UseMacro, !IO), ( UseMacro = yes, - io__write_string("MR_fail();\n", !IO) + io.write_string("MR_fail();\n", !IO) ; UseMacro = no, - io__write_string("MR_GOTO(MR_ENTRY(MR_do_fail));\n", !IO) + io.write_string("MR_GOTO(MR_ENTRY(MR_do_fail));\n", !IO) ). output_goto(do_trace_redo_fail_shallow, _, !IO) :- - io__write_string("MR_GOTO(MR_ENTRY(MR_do_trace_redo_fail_shallow));\n", + io.write_string("MR_GOTO(MR_ENTRY(MR_do_trace_redo_fail_shallow));\n", !IO). output_goto(do_trace_redo_fail_deep, _, !IO) :- - io__write_string("MR_GOTO(MR_ENTRY(MR_do_trace_redo_fail_deep));\n", !IO). + io.write_string("MR_GOTO(MR_ENTRY(MR_do_trace_redo_fail_deep));\n", !IO). output_goto(do_call_closure(Variant), CallerLabel, !IO) :- % see comment in output_call for why we use `noprof_' etc. here - io__write_string("MR_set_prof_ho_caller_proc(", !IO), + io.write_string("MR_set_prof_ho_caller_proc(", !IO), output_label_as_code_addr(CallerLabel, !IO), - io__write_string(");\n\t", !IO), - io__write_string("MR_np_tailcall_ent(do_call_closure_", !IO), - io__write_string(ho_call_variant_to_string(Variant), !IO), - io__write_string(");\n", !IO). + io.write_string(");\n\t", !IO), + io.write_string("MR_np_tailcall_ent(do_call_closure_", !IO), + io.write_string(ho_call_variant_to_string(Variant), !IO), + io.write_string(");\n", !IO). output_goto(do_call_class_method(Variant), CallerLabel, !IO) :- % see comment in output_call for why we use `noprof_' etc. here - io__write_string("MR_set_prof_ho_caller_proc(", !IO), + io.write_string("MR_set_prof_ho_caller_proc(", !IO), output_label_as_code_addr(CallerLabel, !IO), - io__write_string(");\n\t", !IO), - io__write_string("MR_np_tailcall_ent(do_call_class_method_", !IO), - io__write_string(ho_call_variant_to_string(Variant), !IO), - io__write_string(");\n", !IO). + io.write_string(");\n\t", !IO), + io.write_string("MR_np_tailcall_ent(do_call_class_method_", !IO), + io.write_string(ho_call_variant_to_string(Variant), !IO), + io.write_string(");\n", !IO). output_goto(do_not_reached, CallerLabel, !IO) :- - io__write_string("MR_tailcall(MR_ENTRY(MR_do_not_reached),\n\t\t", !IO), + io.write_string("MR_tailcall(MR_ENTRY(MR_do_not_reached),\n\t\t", !IO), output_label_as_code_addr(CallerLabel, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). % Note that we also do some optimization here by outputting `localcall' % rather than `call' for calls to local labels, or `call_localret' for @@ -3632,7 +3631,7 @@ output_goto(do_not_reached, CallerLabel, !IO) :- is det. output_call(Target, Continuation, CallerLabel, !IO) :- - io__write_string("\t", !IO), + io.write_string("\t", !IO), % For profiling, we ignore calls to do_call_closure and % do_call_class_method, because in general they lead to cycles in the call % graph that screw up the profile. By generating a `noprof_call' rather @@ -3647,11 +3646,11 @@ output_call(Target, Continuation, CallerLabel, !IO) :- ) -> ProfileCall = no, - io__write_string("MR_set_prof_ho_caller_proc(", !IO), + io.write_string("MR_set_prof_ho_caller_proc(", !IO), output_label_as_code_addr(CallerLabel, !IO), - io__write_string(");\n\t", !IO) + io.write_string(");\n\t", !IO) ; - globals__io_lookup_bool_option(profile_calls, ProfileCall, !IO) + globals.io_lookup_bool_option(profile_calls, ProfileCall, !IO) ), ( Target = label(Label), @@ -3660,9 +3659,9 @@ output_call(Target, Continuation, CallerLabel, !IO) :- -> ( ProfileCall = yes, - io__write_string("MR_localcall(", !IO), + io.write_string("MR_localcall(", !IO), output_label(Label, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_code_addr(Continuation, !IO) ; ProfileCall = no, @@ -3670,32 +3669,32 @@ output_call(Target, Continuation, CallerLabel, !IO) :- NeedsPrefix, Wrapper), ( NeedsPrefix = no, - io__write_string("MR_noprof_localcall(", !IO), + io.write_string("MR_noprof_localcall(", !IO), output_label(Label, no, !IO), - io__write_string(",\n\t\t", !IO), - io__write_string(BaseStr, !IO), + io.write_string(",\n\t\t", !IO), + io.write_string(BaseStr, !IO), output_code_addr_from_pieces(BaseStr, NeedsPrefix, Wrapper, !IO) ; NeedsPrefix = yes, Wrapper = entry, - io__write_string("MR_np_localcall_ent(", !IO), + io.write_string("MR_np_localcall_ent(", !IO), output_label(Label, no, !IO), - io__write_string(",\n\t\t", !IO), - io__write_string(BaseStr, !IO) + io.write_string(",\n\t\t", !IO), + io.write_string(BaseStr, !IO) ; NeedsPrefix = yes, Wrapper = label, - io__write_string("MR_np_localcall_lab(", !IO), + io.write_string("MR_np_localcall_lab(", !IO), output_label(Label, no, !IO), - io__write_string(",\n\t\t", !IO), - io__write_string(BaseStr, !IO) + io.write_string(",\n\t\t", !IO), + io.write_string(BaseStr, !IO) ; NeedsPrefix = yes, Wrapper = none, - io__write_string("MR_np_localcall(", !IO), + io.write_string("MR_np_localcall(", !IO), output_label(Label, no, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_code_addr_from_pieces(BaseStr, NeedsPrefix, Wrapper, !IO) ) @@ -3706,26 +3705,26 @@ output_call(Target, Continuation, CallerLabel, !IO) :- -> ( ProfileCall = yes, - io__write_string("MR_call_localret(", !IO), + io.write_string("MR_call_localret(", !IO), output_code_addr(Target, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_label(ContLabel, !IO) ; ProfileCall = no, code_addr_to_string_base(Target, BaseStr, NeedsPrefix, Wrapper), ( NeedsPrefix = no, - io__write_string("MR_noprof_call_localret(", !IO), + io.write_string("MR_noprof_call_localret(", !IO), output_code_addr_from_pieces(BaseStr, NeedsPrefix, Wrapper, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_label(ContLabel, !IO) ; NeedsPrefix = yes, Wrapper = entry, - io__write_string("MR_np_call_localret_ent(", !IO), - io__write_string(BaseStr, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string("MR_np_call_localret_ent(", !IO), + io.write_string(BaseStr, !IO), + io.write_string(",\n\t\t", !IO), output_label(ContLabel, no, !IO) ; NeedsPrefix = yes, @@ -3737,33 +3736,33 @@ output_call(Target, Continuation, CallerLabel, !IO) :- ; NeedsPrefix = yes, Wrapper = none, - io__write_string("MR_np_call_localret(", !IO), + io.write_string("MR_np_call_localret(", !IO), output_code_addr_from_pieces(BaseStr, NeedsPrefix, Wrapper, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_label(ContLabel, no, !IO) ) ) ; ( ProfileCall = yes, - io__write_string("MR_call(", !IO) + io.write_string("MR_call(", !IO) ; ProfileCall = no, - io__write_string("MR_noprof_call(", !IO) + io.write_string("MR_noprof_call(", !IO) ), output_code_addr(Target, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_code_addr(Continuation, !IO) ), ( ProfileCall = yes, - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), output_label_as_code_addr(CallerLabel, !IO) ; ProfileCall = no ), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_code_addr(CodeAddr, !IO) :- code_addr_to_string_base(CodeAddr, BaseStr, NeedsPrefix, Wrapper), @@ -3782,38 +3781,38 @@ output_code_addr_from_pieces(BaseStr, NeedsPrefix, Wrapper, !IO) :- Wrapper = none, ( NeedsPrefix = yes, - io__write_string(mercury_label_prefix, !IO) + io.write_string(mercury_label_prefix, !IO) ; NeedsPrefix = no ), - io__write_string(BaseStr, !IO) + io.write_string(BaseStr, !IO) ; Wrapper = entry, ( NeedsPrefix = yes, % The _AP version of the macro adds the prefix. - io__write_string("MR_ENTRY_AP(", !IO), - io__write_string(BaseStr, !IO), - io__write_string(")", !IO) + io.write_string("MR_ENTRY_AP(", !IO), + io.write_string(BaseStr, !IO), + io.write_string(")", !IO) ; NeedsPrefix = no, - io__write_string("MR_ENTRY(", !IO), - io__write_string(BaseStr, !IO), - io__write_string(")", !IO) + io.write_string("MR_ENTRY(", !IO), + io.write_string(BaseStr, !IO), + io.write_string(")", !IO) ) ; Wrapper = label, ( NeedsPrefix = yes, % The _AP version of the macro adds the prefix. - io__write_string("MR_LABEL_AP(", !IO), - io__write_string(BaseStr, !IO), - io__write_string(")", !IO) + io.write_string("MR_LABEL_AP(", !IO), + io.write_string(BaseStr, !IO), + io.write_string(")", !IO) ; NeedsPrefix = no, - io__write_string("MR_LABEL(", !IO), - io__write_string(BaseStr, !IO), - io__write_string(")", !IO) + io.write_string("MR_LABEL(", !IO), + io.write_string(BaseStr, !IO), + io.write_string(")", !IO) ) ). @@ -3875,7 +3874,7 @@ output_maybe_data_addr(MaybeDataAddr, !IO) :- output_data_addr(DataAddr, !IO) ; MaybeDataAddr = no, - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ). % Output a list of maybe data addresses, with a `no' meaning NULL. @@ -3885,10 +3884,10 @@ output_maybe_data_addr(MaybeDataAddr, !IO) :- output_maybe_data_addrs([], !IO). output_maybe_data_addrs([MaybeDataAddr | MaybeDataAddrs], !IO) :- - io__write_string("\t", !IO), - io__write_list([MaybeDataAddr | MaybeDataAddrs], ",\n\t", + io.write_string("\t", !IO), + io.write_list([MaybeDataAddr | MaybeDataAddrs], ",\n\t", output_maybe_data_addr, !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). % Output a list of data addresses. % @@ -3896,9 +3895,9 @@ output_maybe_data_addrs([MaybeDataAddr | MaybeDataAddrs], !IO) :- output_data_addrs([], !IO). output_data_addrs([DataAddr | DataAddrs], !IO) :- - io__write_string("\t", !IO), - io__write_list([DataAddr | DataAddrs], ",\n\t", output_data_addr, !IO), - io__write_string("\n", !IO). + io.write_string("\t", !IO), + io.write_list([DataAddr | DataAddrs], ",\n\t", output_data_addr, !IO), + io.write_string("\n", !IO). % Output a data address. % @@ -3916,7 +3915,7 @@ output_data_addr(_ModuleName, VarName, !IO) :- ( VarName = common(CellNum, _TypeNum), output_common_prefix(common_prefix_var, !IO), - io__write_int(CellNum, !IO) + io.write_int(CellNum, !IO) ; VarName = tabling_pointer(ProcLabel), output_tabling_pointer_var_name(ProcLabel, !IO) @@ -3926,7 +3925,7 @@ output_data_addr(_ModuleName, VarName, !IO) :- output_common_cell_type_name(TypeNum, !IO) :- output_common_prefix(common_prefix_type, !IO), - io__write_int(TypeNum, !IO). + io.write_int(TypeNum, !IO). :- type common_prefix ---> common_prefix_var @@ -3937,17 +3936,17 @@ output_common_cell_type_name(TypeNum, !IO) :- output_common_prefix(Prefix, !IO) :- ( Prefix = common_prefix_var, - io__write_string(mercury_common_prefix, !IO) + io.write_string(mercury_common_prefix, !IO) ; Prefix = common_prefix_type, - io__write_string(mercury_common_type_prefix, !IO) + io.write_string(mercury_common_type_prefix, !IO) ). :- pred output_label_as_code_addr(label::in, io::di, io::uo) is det. output_label_as_code_addr(Label, !IO) :- label_as_code_addr_to_string(Label, Str), - io__write_string(Str, !IO). + io.write_string(Str, !IO). :- func label_is_external_to_c_module(label) = bool. @@ -3973,41 +3972,41 @@ label_as_code_addr_to_string(Label, Str) :- output_label_list([], !IO). output_label_list([Label | Labels], !IO) :- - io__write_string("MR_LABEL_AP(", !IO), + io.write_string("MR_LABEL_AP(", !IO), output_label(Label, no, !IO), - io__write_string(")", !IO), + io.write_string(")", !IO), output_label_list_2(Labels, !IO). :- pred output_label_list_2(list(label)::in, io::di, io::uo) is det. output_label_list_2([], !IO). output_label_list_2([Label | Labels], !IO) :- - io__write_string(" MR_AND\n\t\t", !IO), - io__write_string("MR_LABEL_AP(", !IO), + io.write_string(" MR_AND\n\t\t", !IO), + io.write_string("MR_LABEL_AP(", !IO), output_label(Label, no, !IO), - io__write_string(")", !IO), + io.write_string(")", !IO), output_label_list_2(Labels, !IO). :- pred output_label_defn(label::in, io::di, io::uo) is det. output_label_defn(entry(exported, ProcLabel), !IO) :- - io__write_string("MR_define_entry(", !IO), + io.write_string("MR_define_entry(", !IO), output_label(entry(exported, ProcLabel), !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). output_label_defn(entry(local, ProcLabel), !IO) :- - io__write_string("MR_def_static(", !IO), + io.write_string("MR_def_static(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(")\n", !IO). + io.write_string(")\n", !IO). output_label_defn(entry(c_local, ProcLabel), !IO) :- - io__write_string("MR_def_local(", !IO), + io.write_string("MR_def_local(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(")\n", !IO). + io.write_string(")\n", !IO). output_label_defn(internal(Num, ProcLabel), !IO) :- - io__write_string("MR_def_label(", !IO), + io.write_string("MR_def_label(", !IO), output_proc_label(ProcLabel, no, !IO), - io__write_string(",", !IO), - io__write_int(Num, !IO), - io__write_string(")\n", !IO). + io.write_string(",", !IO), + io.write_int(Num, !IO), + io.write_string(")\n", !IO). % Entry labels should generate the same code, regardless of the entry label % type, because we may refer to an entry label via different entry label types @@ -4019,40 +4018,40 @@ output_label_defn(internal(Num, ProcLabel), !IO) :- output_label(Label, !IO) :- LabelStr = label_to_c_string(Label, yes), - io__write_string(LabelStr, !IO). + io.write_string(LabelStr, !IO). output_label(Label, AddPrefix, !IO) :- LabelStr = label_to_c_string(Label, AddPrefix), - io__write_string(LabelStr, !IO). + io.write_string(LabelStr, !IO). label_to_c_string(entry(_, ProcLabel), AddPrefix) = proc_label_to_c_string(ProcLabel, AddPrefix). label_to_c_string(internal(Num, ProcLabel), AddPrefix) = LabelStr :- ProcLabelStr = proc_label_to_c_string(ProcLabel, AddPrefix), - string__int_to_string(Num, NumStr), - string__append("_i", NumStr, NumSuffix), - string__append(ProcLabelStr, NumSuffix, LabelStr). + string.int_to_string(Num, NumStr), + string.append("_i", NumStr, NumSuffix), + string.append(ProcLabelStr, NumSuffix, LabelStr). :- pred output_reg(reg_type::in, int::in, io::di, io::uo) is det. output_reg(r, N, !IO) :- - io__write_string(reg_to_string(r, N), !IO). + io.write_string(reg_to_string(r, N), !IO). output_reg(f, _, !IO) :- sorry(this_file, "Floating point registers not implemented"). :- pred output_tag(tag::in, io::di, io::uo) is det. output_tag(Tag, !IO) :- - io__write_string("MR_mktag(", !IO), - io__write_int(Tag, !IO), - io__write_string(")", !IO). + io.write_string("MR_mktag(", !IO), + io.write_int(Tag, !IO), + io.write_string(")", !IO). % Output an rval, converted to the specified type % :- pred output_rval_as_type(rval::in, llds_type::in, io::di, io::uo) is det. output_rval_as_type(Rval, DesiredType, !IO) :- - llds__rval_type(Rval, ActualType), + llds.rval_type(Rval, ActualType), ( types_match(DesiredType, ActualType) -> % No casting needed. output_rval(Rval, !IO) @@ -4061,9 +4060,9 @@ output_rval_as_type(Rval, DesiredType, !IO) :- % Convertions to/from float must be treated specially; % for the others, we can just use a cast. ( DesiredType = float -> - io__write_string("MR_word_to_float(", !IO), + io.write_string("MR_word_to_float(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; ActualType = float -> ( DesiredType = word -> output_float_rval_as_word(Rval, !IO) @@ -4155,8 +4154,8 @@ output_float_rval(Rval, IsPtr, !IO) :- % For float constant expressions, if we're using boxed boxed floats % and --static-ground-terms is enabled, we just refer to the static const % which we declared earlier. - globals__io_lookup_bool_option(unboxed_float, UnboxFloat, !IO), - globals__io_lookup_bool_option(static_ground_terms, StaticGroundTerms, + globals.io_lookup_bool_option(unboxed_float, UnboxFloat, !IO), + globals.io_lookup_bool_option(static_ground_terms, StaticGroundTerms, !IO), ( UnboxFloat = no, @@ -4171,8 +4170,8 @@ output_float_rval(Rval, IsPtr, !IO) :- Cast = word ), output_llds_type_cast(Cast, !IO), - io__write_string("&mercury_float_const_", !IO), - io__write_string(FloatName, !IO) + io.write_string("&mercury_float_const_", !IO), + io.write_string(FloatName, !IO) ; ( IsPtr = yes, @@ -4180,9 +4179,9 @@ output_float_rval(Rval, IsPtr, !IO) :- ; IsPtr = no ), - io__write_string("MR_float_to_word(", !IO), + io.write_string("MR_float_to_word(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred output_test_rval(rval::in, io::di, io::uo) is det. @@ -4191,109 +4190,109 @@ output_test_rval(Test, !IO) :- ( is_int_cmp(Test, Left, RightConst, OpStr, _) -> - io__write_string(OpStr, !IO), - io__write_string("(", !IO), + io.write_string(OpStr, !IO), + io.write_string("(", !IO), output_rval(Left, !IO), - io__write_string(",", !IO), - io__write_int(RightConst, !IO), - io__write_string(")", !IO) + io.write_string(",", !IO), + io.write_int(RightConst, !IO), + io.write_string(")", !IO) ; Test = unop(logical_not, InnerTest), is_int_cmp(InnerTest, Left, RightConst, _, NegOpStr) -> - io__write_string(NegOpStr, !IO), - io__write_string("(", !IO), + io.write_string(NegOpStr, !IO), + io.write_string("(", !IO), output_rval(Left, !IO), - io__write_string(",", !IO), - io__write_int(RightConst, !IO), - io__write_string(")", !IO) + io.write_string(",", !IO), + io.write_int(RightConst, !IO), + io.write_string(")", !IO) ; is_ptag_test(Test, Rval, Ptag, Negated) -> ( Negated = no, - io__write_string("MR_PTAG_TEST(", !IO) + io.write_string("MR_PTAG_TEST(", !IO) ; Negated = yes, - io__write_string("MR_PTAG_TESTR(", !IO) + io.write_string("MR_PTAG_TESTR(", !IO) ), output_rval(Rval, !IO), - io__write_string(",", !IO), - io__write_int(Ptag, !IO), - io__write_string(")", !IO) + io.write_string(",", !IO), + io.write_int(Ptag, !IO), + io.write_string(")", !IO) ; Test = unop(logical_not, InnerTest), is_ptag_test(InnerTest, Rval, Ptag, Negated) -> ( Negated = no, - io__write_string("MR_PTAG_TESTR(", !IO) + io.write_string("MR_PTAG_TESTR(", !IO) ; Negated = yes, - io__write_string("MR_PTAG_TEST(", !IO) + io.write_string("MR_PTAG_TEST(", !IO) ), output_rval(Rval, !IO), - io__write_string(",", !IO), - io__write_int(Ptag, !IO), - io__write_string(")", !IO) + io.write_string(",", !IO), + io.write_int(Ptag, !IO), + io.write_string(")", !IO) ; Test = binop(logical_and, Left, Right), is_ptag_test(Left, Rval, Ptag, no), is_remote_stag_test(Right, Rval, Ptag, Stag) -> - io__write_string("MR_RTAGS_TEST(", !IO), + io.write_string("MR_RTAGS_TEST(", !IO), output_rval(Rval, !IO), - io__write_string(",", !IO), - io__write_int(Ptag, !IO), - io__write_string(",", !IO), - io__write_int(Stag, !IO), - io__write_string(")", !IO) + io.write_string(",", !IO), + io.write_int(Ptag, !IO), + io.write_string(",", !IO), + io.write_int(Stag, !IO), + io.write_string(")", !IO) ; Test = unop(logical_not, InnerTest), InnerTest = binop(logical_and, Left, Right), is_ptag_test(Left, Rval, Ptag, no), is_remote_stag_test(Right, Rval, Ptag, Stag) -> - io__write_string("MR_RTAGS_TESTR(", !IO), + io.write_string("MR_RTAGS_TESTR(", !IO), output_rval(Rval, !IO), - io__write_string(",", !IO), - io__write_int(Ptag, !IO), - io__write_string(",", !IO), - io__write_int(Stag, !IO), - io__write_string(")", !IO) + io.write_string(",", !IO), + io.write_int(Ptag, !IO), + io.write_string(",", !IO), + io.write_int(Stag, !IO), + io.write_string(")", !IO) ; is_local_stag_test(Test, Rval, Ptag, Stag, Negated) -> ( Negated = no, - io__write_string("MR_LTAGS_TEST(", !IO) + io.write_string("MR_LTAGS_TEST(", !IO) ; Negated = yes, - io__write_string("MR_LTAGS_TESTR(", !IO) + io.write_string("MR_LTAGS_TESTR(", !IO) ), output_rval(Rval, !IO), - io__write_string(",", !IO), - io__write_int(Ptag, !IO), - io__write_string(",", !IO), - io__write_int(Stag, !IO), - io__write_string(")", !IO) + io.write_string(",", !IO), + io.write_int(Ptag, !IO), + io.write_string(",", !IO), + io.write_int(Stag, !IO), + io.write_string(")", !IO) ; Test = unop(logical_not, InnerTest), is_local_stag_test(InnerTest, Rval, Ptag, Stag, Negated) -> ( Negated = no, - io__write_string("MR_LTAGS_TESTR(", !IO) + io.write_string("MR_LTAGS_TESTR(", !IO) ; Negated = yes, - io__write_string("MR_LTAGS_TEST(", !IO) + io.write_string("MR_LTAGS_TEST(", !IO) ), output_rval(Rval, !IO), - io__write_string(",", !IO), - io__write_int(Ptag, !IO), - io__write_string(",", !IO), - io__write_int(Stag, !IO), - io__write_string(")", !IO) + io.write_string(",", !IO), + io.write_int(Ptag, !IO), + io.write_string(",", !IO), + io.write_int(Stag, !IO), + io.write_string(")", !IO) ; output_rval_as_type(Test, bool, !IO) ). @@ -4370,47 +4369,47 @@ output_rval(const(Const), !IO) :- output_rval_const(Const, !IO). output_rval(unop(UnaryOp, Exprn), !IO) :- output_unary_op(UnaryOp, !IO), - io__write_string("(", !IO), - llds__unop_arg_type(UnaryOp, ArgType), + io.write_string("(", !IO), + llds.unop_arg_type(UnaryOp, ArgType), output_rval_as_type(Exprn, ArgType, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_rval(binop(Op, X, Y), !IO) :- ( Op = array_index(_Type) -> - io__write_string("(", !IO), + io.write_string("(", !IO), output_rval_as_type(X, data_ptr, !IO), - io__write_string(")[", !IO), + io.write_string(")[", !IO), output_rval_as_type(Y, integer, !IO), - io__write_string("]", !IO) + io.write_string("]", !IO) ; - c_util__string_compare_op(Op, OpStr) + c_util.string_compare_op(Op, OpStr) -> - io__write_string("(strcmp((char *)", !IO), + io.write_string("(strcmp((char *)", !IO), output_rval_as_type(X, word, !IO), - io__write_string(", (char *)", !IO), + io.write_string(", (char *)", !IO), output_rval_as_type(Y, word, !IO), - io__write_string(")", !IO), - io__write_string(" ", !IO), - io__write_string(OpStr, !IO), - io__write_string(" ", !IO), - io__write_string("0)", !IO) + io.write_string(")", !IO), + io.write_string(" ", !IO), + io.write_string(OpStr, !IO), + io.write_string(" ", !IO), + io.write_string("0)", !IO) ; - ( c_util__float_compare_op(Op, OpStr1) -> + ( c_util.float_compare_op(Op, OpStr1) -> OpStr = OpStr1 - ; c_util__float_op(Op, OpStr2) -> + ; c_util.float_op(Op, OpStr2) -> OpStr = OpStr2 ; fail ) -> - io__write_string("(", !IO), + io.write_string("(", !IO), output_rval_as_type(X, float, !IO), - io__write_string(" ", !IO), - io__write_string(OpStr, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), + io.write_string(OpStr, !IO), + io.write_string(" ", !IO), output_rval_as_type(Y, float, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; % XXX broken for C == minint % (since `NewC is 0 - C' overflows) @@ -4421,49 +4420,49 @@ output_rval(binop(Op, X, Y), !IO) :- % NewOp = (-), % NewC is 0 - C, % NewY = const(int_const(NewC)), -% io__write_string("("), +% io.write_string("("), % output_rval(X), -% io__write_string(" "), +% io.write_string(" "), % output_binary_op(NewOp), -% io__write_string(" "), +% io.write_string(" "), % output_rval(NewY), -% io__write_string(")") +% io.write_string(")") % ; % special-case equality ops to avoid some unnecessary % casts -- there's no difference between signed and % unsigned equality, so if both args are unsigned, we % don't need to cast them to (Integer) ( Op = eq ; Op = ne ), - ( llds__rval_type(X, XType) ), + ( llds.rval_type(X, XType) ), ( XType = word ; XType = unsigned ), - ( llds__rval_type(Y, YType) ), + ( llds.rval_type(Y, YType) ), ( YType = word ; YType = unsigned ) -> - io__write_string("(", !IO), + io.write_string("(", !IO), output_rval(X, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), output_binary_op(Op, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), output_rval(Y, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - c_util__unsigned_compare_op(Op, OpStr) + c_util.unsigned_compare_op(Op, OpStr) -> - io__write_string("(", !IO), + io.write_string("(", !IO), output_rval_as_type(X, unsigned, !IO), - io__write_string(" ", !IO), - io__write_string(OpStr, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), + io.write_string(OpStr, !IO), + io.write_string(" ", !IO), output_rval_as_type(Y, unsigned, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - io__write_string("(", !IO), + io.write_string("(", !IO), output_rval_as_type(X, integer, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), output_binary_op(Op, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), output_rval_as_type(Y, integer, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). output_rval(mkword(Tag, Exprn), !IO) :- ( @@ -4471,25 +4470,25 @@ output_rval(mkword(Tag, Exprn), !IO) :- DataAddr = data_addr(_, DataName), DataName = common(CellNum, _TypeNum) -> - io__write_string("MR_TAG_COMMON(", !IO), - io__write_int(Tag, !IO), - io__write_string(",", !IO), - io__write_int(CellNum, !IO), - io__write_string(")", !IO) + io.write_string("MR_TAG_COMMON(", !IO), + io.write_int(Tag, !IO), + io.write_string(",", !IO), + io.write_int(CellNum, !IO), + io.write_string(")", !IO) ; Exprn = unop(mkbody, const(int_const(Body))) -> - io__write_string("MR_tbmkword(", !IO), - io__write_int(Tag, !IO), - io__write_string(", ", !IO), - io__write_int(Body, !IO), - io__write_string(")", !IO) + io.write_string("MR_tbmkword(", !IO), + io.write_int(Tag, !IO), + io.write_string(", ", !IO), + io.write_int(Body, !IO), + io.write_string(")", !IO) ; - io__write_string("MR_tmkword(", !IO), - io__write_int(Tag, !IO), - io__write_string(", ", !IO), + io.write_string("MR_tmkword(", !IO), + io.write_int(Tag, !IO), + io.write_string(", ", !IO), output_rval_as_type(Exprn, data_ptr, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). output_rval(lval(Lval), !IO) :- % If a field is used as an rval, then we need to use the MR_const_field() @@ -4498,22 +4497,22 @@ output_rval(lval(Lval), !IO) :- ( Lval = field(MaybeTag, Rval, FieldNumRval) -> ( MaybeTag = yes(Tag), - io__write_string("MR_ctfield(", !IO), - io__write_int(Tag, !IO), - io__write_string(", ", !IO) + io.write_string("MR_ctfield(", !IO), + io.write_int(Tag, !IO), + io.write_string(", ", !IO) ; MaybeTag = no, - io__write_string("MR_const_mask_field(", !IO) + io.write_string("MR_const_mask_field(", !IO) ), output_rval(Rval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ( FieldNumRval = const(int_const(FieldNum)) -> % Avoid emitting the (MR_Integer) cast. - io__write_int(FieldNum, !IO) + io.write_int(FieldNum, !IO) ; output_rval(FieldNumRval, !IO) ), - io__write_string(")", !IO) + io.write_string(")", !IO) ; output_lval(Lval, !IO) ). @@ -4523,32 +4522,32 @@ output_rval(mem_addr(MemRef), !IO) :- ( MemRef = stackvar_ref(N), output_llds_type_cast(data_ptr, !IO), - io__write_string("&MR_sv(", !IO), - io__write_int(N, !IO), - io__write_string(")", !IO) + io.write_string("&MR_sv(", !IO), + io.write_int(N, !IO), + io.write_string(")", !IO) ; MemRef = framevar_ref(N), output_llds_type_cast(data_ptr, !IO), - io__write_string("&MR_fv(", !IO), - io__write_int(N, !IO), - io__write_string(")", !IO) + io.write_string("&MR_fv(", !IO), + io.write_int(N, !IO), + io.write_string(")", !IO) ; MemRef = heap_ref(Rval, Tag, FieldNum), output_llds_type_cast(data_ptr, !IO), - io__write_string("&MR_tfield(", !IO), - io__write_int(Tag, !IO), - io__write_string(", ", !IO), + io.write_string("&MR_tfield(", !IO), + io.write_int(Tag, !IO), + io.write_string(", ", !IO), output_rval(Rval, !IO), - io__write_string(", ", !IO), - io__write_int(FieldNum, !IO), - io__write_string(")", !IO) + io.write_string(", ", !IO), + io.write_int(FieldNum, !IO), + io.write_string(")", !IO) ). :- pred output_unary_op(unary_op::in, io::di, io::uo) is det. output_unary_op(Op, !IO) :- - c_util__unary_prefix_op(Op, OpString), - io__write_string(OpString, !IO). + c_util.unary_prefix_op(Op, OpString), + io.write_string(OpString, !IO). :- pred output_rval_const(rval_const::in, io::di, io::uo) is det. @@ -4556,29 +4555,29 @@ output_rval_const(int_const(N), !IO) :- % We need to cast to (Integer) to ensure things like 1 << 32 work % when `Integer' is 64 bits but `int' is 32 bits. output_llds_type_cast(integer, !IO), - io__write_int(N, !IO). + io.write_int(N, !IO). output_rval_const(float_const(FloatVal), !IO) :- % The cast to (Float) here lets the C compiler do arithmetic in `float' % rather than `double' if `Float' is `float' not `double'. output_llds_type_cast(float, !IO), - c_util__output_float_literal(FloatVal, !IO). + c_util.output_float_literal(FloatVal, !IO). output_rval_const(string_const(String), !IO) :- - io__write_string("MR_string_const(""", !IO), - c_util__output_quoted_string(String, !IO), - string__length(String, StringLength), - io__write_string(""", ", !IO), - io__write_int(StringLength, !IO), - io__write_string(")", !IO). + io.write_string("MR_string_const(""", !IO), + c_util.output_quoted_string(String, !IO), + string.length(String, StringLength), + io.write_string(""", ", !IO), + io.write_int(StringLength, !IO), + io.write_string(")", !IO). output_rval_const(multi_string_const(Length, String), !IO) :- - io__write_string("MR_string_const(""", !IO), - c_util__output_quoted_multi_string(Length, String, !IO), - io__write_string(""", ", !IO), - io__write_int(Length, !IO), - io__write_string(")", !IO). + io.write_string("MR_string_const(""", !IO), + c_util.output_quoted_multi_string(Length, String, !IO), + io.write_string(""", ", !IO), + io.write_int(Length, !IO), + io.write_string(")", !IO). output_rval_const(true, !IO) :- - io__write_string("MR_TRUE", !IO). + io.write_string("MR_TRUE", !IO). output_rval_const(false, !IO) :- - io__write_string("MR_FALSE", !IO). + io.write_string("MR_FALSE", !IO). output_rval_const(code_addr_const(CodeAddress), !IO) :- output_code_addr(CodeAddress, !IO). output_rval_const(data_addr_const(DataAddr, MaybeOffset), !IO) :- @@ -4595,9 +4594,9 @@ output_rval_const(data_addr_const(DataAddr, MaybeOffset), !IO) :- DataAddr = data_addr(_, DataName), DataName = common(CellNum, _TypeNum) -> - io__write_string("MR_COMMON(", !IO), - io__write_int(CellNum, !IO), - io__write_string(")", !IO) + io.write_string("MR_COMMON(", !IO), + io.write_int(CellNum, !IO), + io.write_string(")", !IO) ; DataAddr = rtti_addr(RttiId), rtti_id_emits_type_ctor_info(RttiId, Ctor), @@ -4608,18 +4607,18 @@ output_rval_const(data_addr_const(DataAddr, MaybeOffset), !IO) :- output_type_ctor_addr(Module, Name, Arity, !IO) ; output_llds_type_cast(data_ptr, !IO), - io__write_string("&", !IO), + io.write_string("&", !IO), output_data_addr(DataAddr, !IO) ) ; MaybeOffset = yes(Offset), - io__write_string("((", !IO), + io.write_string("((", !IO), output_llds_type_cast(data_ptr, !IO), - io__write_string("&", !IO), + io.write_string("&", !IO), output_data_addr(DataAddr, !IO), - io__write_string(") + ", !IO), - io__write_int(Offset, !IO), - io__write_string(")", !IO) + io.write_string(") + ", !IO), + io.write_int(Offset, !IO), + io.write_string(")", !IO) ). :- pred output_type_ctor_addr(module_name::in, string::in, int::in, @@ -4649,19 +4648,19 @@ output_type_ctor_addr(Module0, Name, Arity, !IO) :- fail ) -> - io__write_string(Macro, !IO) + io.write_string(Macro, !IO) ; ModuleStr = "io", Name = "state" -> - io__write_string("MR_IO_CTOR_ADDR", !IO) + io.write_string("MR_IO_CTOR_ADDR", !IO) ; ModuleStr = "bool", Name = "bool" -> - io__write_string("MR_BOOL_CTOR_ADDR", !IO) + io.write_string("MR_BOOL_CTOR_ADDR", !IO) ; - io__write_strings(["MR_CTOR0_ADDR(", ModuleStr, ", ", Name, ")"], + io.write_strings(["MR_CTOR0_ADDR(", ModuleStr, ", ", Name, ")"], !IO) ) ; Arity = 1 -> @@ -4669,34 +4668,34 @@ output_type_ctor_addr(Module0, Name, Arity, !IO) :- Name = "list", ModuleStr = "list" -> - io__write_string("MR_LIST_CTOR_ADDR", !IO) + io.write_string("MR_LIST_CTOR_ADDR", !IO) ; Name = "private_builtin", ModuleStr = "type_info" -> - io__write_string("MR_TYPE_INFO_CTOR_ADDR", !IO) + io.write_string("MR_TYPE_INFO_CTOR_ADDR", !IO) ; - io__write_strings(["MR_CTOR1_ADDR(", ModuleStr, ", ", Name, ")"], + io.write_strings(["MR_CTOR1_ADDR(", ModuleStr, ", ", Name, ")"], !IO) ) ; - io__write_strings(["MR_CTOR_ADDR(", ModuleStr, ", ", Name, + io.write_strings(["MR_CTOR_ADDR(", ModuleStr, ", ", Name, ", ", int_to_string(Arity), ")"], !IO) ). :- pred output_lval_as_word(lval::in, io::di, io::uo) is det. output_lval_as_word(Lval, !IO) :- - llds__lval_type(Lval, ActualType), + llds.lval_type(Lval, ActualType), ( types_match(word, ActualType) -> output_lval(Lval, !IO) ; ActualType = float -> % Sanity check -- if this happens, the LLDS is ill-typed. unexpected(this_file, "output_lval_as_word: got float") ; - io__write_string("MR_LVALUE_CAST(MR_Word,", !IO), + io.write_string("MR_LVALUE_CAST(MR_Word,", !IO), output_lval(Lval, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred output_lval(lval::in, io::di, io::uo) is det. @@ -4709,83 +4708,83 @@ output_lval(stackvar(N), !IO) :- ; true ), - io__write_string("MR_sv(", !IO), - io__write_int(N, !IO), - io__write_string(")", !IO). + io.write_string("MR_sv(", !IO), + io.write_int(N, !IO), + io.write_string(")", !IO). output_lval(framevar(N), !IO) :- ( N =< 0 -> unexpected(this_file, "frame var out of range") ; true ), - io__write_string("MR_fv(", !IO), - io__write_int(N, !IO), - io__write_string(")", !IO). + io.write_string("MR_fv(", !IO), + io.write_int(N, !IO), + io.write_string(")", !IO). output_lval(succip, !IO) :- - io__write_string("MR_succip", !IO). + io.write_string("MR_succip", !IO). output_lval(sp, !IO) :- - io__write_string("MR_sp", !IO). + io.write_string("MR_sp", !IO). output_lval(hp, !IO) :- - io__write_string("MR_hp", !IO). + io.write_string("MR_hp", !IO). output_lval(maxfr, !IO) :- - io__write_string("MR_maxfr", !IO). + io.write_string("MR_maxfr", !IO). output_lval(curfr, !IO) :- - io__write_string("MR_curfr", !IO). + io.write_string("MR_curfr", !IO). output_lval(succfr(Rval), !IO) :- - io__write_string("MR_succfr_slot(", !IO), + io.write_string("MR_succfr_slot(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval(prevfr(Rval), !IO) :- - io__write_string("MR_prevfr_slot(", !IO), + io.write_string("MR_prevfr_slot(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval(redofr(Rval), !IO) :- - io__write_string("MR_redofr_slot(", !IO), + io.write_string("MR_redofr_slot(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval(redoip(Rval), !IO) :- - io__write_string("MR_redoip_slot(", !IO), + io.write_string("MR_redoip_slot(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval(succip(Rval), !IO) :- - io__write_string("MR_succip_slot(", !IO), + io.write_string("MR_succip_slot(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval(field(MaybeTag, Rval, FieldNumRval), !IO) :- ( MaybeTag = yes(Tag), - io__write_string("MR_tfield(", !IO), - io__write_int(Tag, !IO), - io__write_string(", ", !IO) + io.write_string("MR_tfield(", !IO), + io.write_int(Tag, !IO), + io.write_string(", ", !IO) ; MaybeTag = no, - io__write_string("MR_mask_field(", !IO) + io.write_string("MR_mask_field(", !IO) ), output_rval(Rval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ( FieldNumRval = const(int_const(FieldNum)) -> % Avoid emitting the (MR_Integer) cast. - io__write_int(FieldNum, !IO) + io.write_int(FieldNum, !IO) ; output_rval(FieldNumRval, !IO) ), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval(lvar(_), !IO) :- unexpected(this_file, "output_lval/3: illegal to output an lvar."). output_lval(temp(Type, Num), !IO) :- ( Type = r, - io__write_string("MR_tempr", !IO), - io__write_int(Num, !IO) + io.write_string("MR_tempr", !IO), + io.write_int(Num, !IO) ; Type = f, - io__write_string("MR_tempf", !IO), - io__write_int(Num, !IO) + io.write_string("MR_tempf", !IO), + io.write_int(Num, !IO) ). output_lval(mem_ref(Rval), !IO) :- - io__write_string("* (MR_Word *) (", !IO), + io.write_string("* (MR_Word *) (", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). :- pred output_lval_for_assign(lval::in, llds_type::out, io::di, io::uo) is det. @@ -4799,80 +4798,80 @@ output_lval_for_assign(stackvar(N), word, !IO) :- ; true ), - io__write_string("MR_sv(", !IO), - io__write_int(N, !IO), - io__write_string(")", !IO). + io.write_string("MR_sv(", !IO), + io.write_int(N, !IO), + io.write_string(")", !IO). output_lval_for_assign(framevar(N), word, !IO) :- ( N =< 0 -> unexpected(this_file, "frame var out of range") ; true ), - io__write_string("MR_fv(", !IO), - io__write_int(N, !IO), - io__write_string(")", !IO). + io.write_string("MR_fv(", !IO), + io.write_int(N, !IO), + io.write_string(")", !IO). output_lval_for_assign(succip, word, !IO) :- - io__write_string("MR_succip_word", !IO). + io.write_string("MR_succip_word", !IO). output_lval_for_assign(sp, word, !IO) :- - io__write_string("MR_sp_word", !IO). + io.write_string("MR_sp_word", !IO). output_lval_for_assign(hp, word, !IO) :- - io__write_string("MR_hp_word", !IO). + io.write_string("MR_hp_word", !IO). output_lval_for_assign(maxfr, word, !IO) :- - io__write_string("MR_maxfr_word", !IO). + io.write_string("MR_maxfr_word", !IO). output_lval_for_assign(curfr, word, !IO) :- - io__write_string("MR_curfr_word", !IO). + io.write_string("MR_curfr_word", !IO). output_lval_for_assign(succfr(Rval), word, !IO) :- - io__write_string("MR_succfr_slot_word(", !IO), + io.write_string("MR_succfr_slot_word(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval_for_assign(prevfr(Rval), word, !IO) :- - io__write_string("MR_prevfr_slot_word(", !IO), + io.write_string("MR_prevfr_slot_word(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval_for_assign(redofr(Rval), word, !IO) :- - io__write_string("MR_redofr_slot_word(", !IO), + io.write_string("MR_redofr_slot_word(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval_for_assign(redoip(Rval), word, !IO) :- - io__write_string("MR_redoip_slot_word(", !IO), + io.write_string("MR_redoip_slot_word(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval_for_assign(succip(Rval), word, !IO) :- - io__write_string("MR_succip_slot_word(", !IO), + io.write_string("MR_succip_slot_word(", !IO), output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval_for_assign(field(MaybeTag, Rval, FieldNumRval), word, !IO) :- ( MaybeTag = yes(Tag), - io__write_string("MR_tfield(", !IO), - io__write_int(Tag, !IO), - io__write_string(", ", !IO) + io.write_string("MR_tfield(", !IO), + io.write_int(Tag, !IO), + io.write_string(", ", !IO) ; MaybeTag = no, - io__write_string("MR_mask_field(", !IO) + io.write_string("MR_mask_field(", !IO) ), output_rval(Rval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ( FieldNumRval = const(int_const(FieldNum)) -> % Avoid emitting the (MR_Integer) cast. - io__write_int(FieldNum, !IO) + io.write_int(FieldNum, !IO) ; output_rval(FieldNumRval, !IO) ), - io__write_string(")", !IO). + io.write_string(")", !IO). output_lval_for_assign(lvar(_), _, !IO) :- unexpected(this_file, "output_lval_for_assign: lvar"). output_lval_for_assign(temp(RegType, Num), Type, !IO) :- ( RegType = r, Type = word, - io__write_string("MR_tempr", !IO), - io__write_int(Num, !IO) + io.write_string("MR_tempr", !IO), + io.write_int(Num, !IO) ; RegType = f, Type = float, - io__write_string("MR_tempf", !IO), - io__write_int(Num, !IO) + io.write_string("MR_tempf", !IO), + io.write_int(Num, !IO) ). output_lval_for_assign(mem_ref(MemRef), word, !IO) :- output_lval(mem_ref(MemRef), !IO). @@ -4882,28 +4881,28 @@ output_lval_for_assign(mem_ref(MemRef), word, !IO) :- :- pred output_set_line_num(prog_context::in, io::di, io::uo) is det. output_set_line_num(Context, !IO) :- - term__context_file(Context, File), - term__context_line(Context, Line), - c_util__set_line_num(File, Line, !IO). + term.context_file(Context, File), + term.context_line(Context, Line), + c_util.set_line_num(File, Line, !IO). :- pred output_reset_line_num(io::di, io::uo) is det. output_reset_line_num(!IO) :- - c_util__reset_line_num(!IO). + c_util.reset_line_num(!IO). %-----------------------------------------------------------------------------% :- pred output_binary_op(binary_op::in, io::di, io::uo) is det. output_binary_op(Op, !IO) :- - ( c_util__binary_infix_op(Op, String) -> - io__write_string(String, !IO) + ( c_util.binary_infix_op(Op, String) -> + io.write_string(String, !IO) ; unexpected(this_file, "output_binary_op/3: invalid binary operator") ). binary_op_to_string(Op) = Name :- - ( c_util__binary_infix_op(Op, Name0) -> + ( c_util.binary_infix_op(Op, Name0) -> Name = Name0 ; % The following is just for debugging purposes - @@ -4944,13 +4943,13 @@ max_virtual_r_reg = 1024. gather_c_file_labels(Modules, Labels) :- gather_labels_from_c_modules(Modules, [], Labels1), - list__reverse(Labels1, Labels). + list.reverse(Labels1, Labels). :- pred gather_c_module_labels(list(c_procedure)::in, list(label)::out) is det. gather_c_module_labels(Procs, Labels) :- gather_labels_from_c_procs(Procs, [], Labels1), - list__reverse(Labels1, Labels). + list.reverse(Labels1, Labels). %-----------------------------------------------------------------------------% @@ -4992,7 +4991,7 @@ gather_labels_from_instrs([Instr | Instrs], !Labels) :- %-----------------------------------------------------------------------------% explain_stack_slots(StackSlots, VarSet) = Explanation :- - map__to_assoc_list(StackSlots, StackSlotsList), + map.to_assoc_list(StackSlots, StackSlotsList), explain_stack_slots_2(StackSlotsList, VarSet, "", Explanation1), Explanation = "\nStack slot assignments (if any):\n" ++ Explanation1. @@ -5010,8 +5009,8 @@ explain_stack_slots_2([Var - Slot | Rest], VarSet, !Explanation) :- StackStr = "fv" ), int_to_string(SlotNum, SlotStr), - varset__lookup_name(VarSet, Var, VarName), - string__append_list([VarName, "\t ->\t", StackStr, SlotStr, "\n", + varset.lookup_name(VarSet, Var, VarName), + string.append_list([VarName, "\t ->\t", StackStr, SlotStr, "\n", !.Explanation], !:Explanation). %---------------------------------------------------------------------------% diff --git a/compiler/lookup_switch.m b/compiler/lookup_switch.m index 5fdeeb019..1efa50325 100644 --- a/compiler/lookup_switch.m +++ b/compiler/lookup_switch.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1996-2005 The University of Melbourne. +% Copyright (C) 1996-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -39,7 +39,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__lookup_switch. +:- module ll_backend.lookup_switch. :- interface. :- import_module backend_libs.switch_util. @@ -116,20 +116,20 @@ is_lookup_switch(CaseVar, TaggedCases, GoalInfo, SwitchCanFail, % some circumstances, but it would take a pretty complex heuristic to get % it right, so, lets just use a simple one - no static ground terms, % no lookup switch. - code_info__get_globals(!.CI, Globals), - globals__lookup_bool_option(Globals, static_ground_terms, yes), + code_info.get_globals(!.CI, Globals), + globals.lookup_bool_option(Globals, static_ground_terms, yes), % We want to generate a lookup switch for any switch that is dense enough % - we don't care how many cases it has. A memory lookup tends to be % cheaper than a branch. - list__length(TaggedCases, NumCases), + list.length(TaggedCases, NumCases), TaggedCases = [FirstCase | _], FirstCase = case(_, int_constant(FirstCaseVal), _, _), - list__index1_det(TaggedCases, NumCases, LastCase), + list.index1_det(TaggedCases, NumCases, LastCase), LastCase = case(_, int_constant(LastCaseVal), _, _), Span = LastCaseVal - FirstCaseVal, Range = Span + 1, - dense_switch__calc_density(NumCases, Range, Density), + dense_switch.calc_density(NumCases, Range, Density), Density > ReqDensity, % If there are going to be no gaps in the lookup table then we won't need @@ -146,12 +146,12 @@ is_lookup_switch(CaseVar, TaggedCases, GoalInfo, SwitchCanFail, % range of the type is sufficiently small, we can make the jump table % large enough to hold all of the values for the type, but then we % will need to do the bitvector test. - Type = code_info__variable_type(!.CI, CaseVar), - code_info__get_module_info(!.CI, ModuleInfo), + Type = code_info.variable_type(!.CI, CaseVar), + code_info.get_module_info(!.CI, ModuleInfo), classify_type(ModuleInfo, Type) = TypeCategory, ( - dense_switch__type_range(!.CI, TypeCategory, Type, TypeRange), - dense_switch__calc_density(NumCases, TypeRange, DetDensity), + dense_switch.type_range(!.CI, TypeCategory, Type, TypeRange), + dense_switch.calc_density(NumCases, TypeRange, DetDensity), DetDensity > ReqDensity -> NeedRangeCheck = cannot_fail, @@ -189,17 +189,17 @@ figure_out_output_vars(CI, GoalInfo, OutVars) :- ( instmap_delta_is_unreachable(InstMapDelta) -> OutVars = [] ; - code_info__get_instmap(CI, CurrentInstMap), - code_info__get_module_info(CI, ModuleInfo), + code_info.get_instmap(CI, CurrentInstMap), + code_info.get_module_info(CI, ModuleInfo), instmap_delta_changed_vars(InstMapDelta, ChangedVars), - instmap__apply_instmap_delta(CurrentInstMap, InstMapDelta, + instmap.apply_instmap_delta(CurrentInstMap, InstMapDelta, InstMapAfter), Lambda = (pred(Var::out) is nondet :- % If a variable has a final inst, then it changed % instantiatedness during the switch. - set__member(Var, ChangedVars), - instmap__lookup_var(CurrentInstMap, Var, Initial), - instmap__lookup_var(InstMapAfter, Var, Final), + set.member(Var, ChangedVars), + instmap.lookup_var(CurrentInstMap, Var, Initial), + instmap.lookup_var(InstMapAfter, Var, Final), mode_is_output(ModuleInfo, (Initial -> Final)) ), solutions(Lambda, OutVars) @@ -220,17 +220,17 @@ generate_constants([], _Vars, _StoreMap, !MaybeEnd, _CodeModel, [], no, !CI). generate_constants([Case | Cases], Vars, StoreMap, !MaybeEnd, CodeModel, [CaseVal | Rest], yes(Liveness), !CI) :- Case = case(_, int_constant(CaseTag), _, Goal), - code_info__remember_position(!.CI, BranchStart), - code_gen__generate_goal(CodeModel, Goal, Code, !CI), - tree__tree_of_lists_is_empty(Code), - code_info__get_forward_live_vars(!.CI, Liveness), + code_info.remember_position(!.CI, BranchStart), + code_gen.generate_goal(CodeModel, Goal, Code, !CI), + tree.tree_of_lists_is_empty(Code), + code_info.get_forward_live_vars(!.CI, Liveness), get_case_rvals(Vars, CaseRvals, !CI), CaseVal = CaseTag - CaseRvals, % EndCode code may contain instructions that place Vars in the locations % dictated by StoreMap, and thus does not have to be empty. (The array % lookup code will put those variables in those locations directly.) - code_info__generate_branch_end(StoreMap, !MaybeEnd, _EndCode, !CI), - code_info__reset_to_position(BranchStart, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, _EndCode, !CI), + code_info.reset_to_position(BranchStart, !CI), generate_constants(Cases, Vars, StoreMap, !MaybeEnd, CodeModel, Rest, _, !CI). @@ -241,11 +241,11 @@ generate_constants([Case | Cases], Vars, StoreMap, !MaybeEnd, CodeModel, get_case_rvals([], [], !CI). get_case_rvals([Var | Vars], [Rval | Rvals], !CI) :- - code_info__produce_variable(Var, Code, Rval, !CI), - tree__tree_of_lists_is_empty(Code), - code_info__get_globals(!.CI, Globals), - globals__get_options(Globals, Options), - exprn_aux__init_exprn_opts(Options, ExprnOpts), + code_info.produce_variable(Var, Code, Rval, !CI), + tree.tree_of_lists_is_empty(Code), + code_info.get_globals(!.CI, Globals), + globals.get_options(Globals, Options), + exprn_aux.init_exprn_opts(Options, ExprnOpts), rval_is_constant(Rval, ExprnOpts), get_case_rvals(Vars, Rvals, !CI). @@ -258,7 +258,7 @@ get_case_rvals([Var | Vars], [Rval | Rvals], !CI) :- :- pred rval_is_constant(rval::in, exprn_opts::in) is semidet. rval_is_constant(const(Const), ExprnOpts) :- - exprn_aux__const_is_constant(Const, ExprnOpts, yes). + exprn_aux.const_is_constant(Const, ExprnOpts, yes). rval_is_constant(unop(_, Exprn), ExprnOpts) :- rval_is_constant(Exprn, ExprnOpts). rval_is_constant(binop(_, Exprn0, Exprn1), ExprnOpts) :- @@ -283,7 +283,7 @@ generate_lookup_switch(Var, OutVars, CaseValues, StartVal, EndVal, Code, !CI) :- % Evaluate the variable which we are going to be switching on. - code_info__produce_variable(Var, VarCode, Rval, !CI), + code_info.produce_variable(Var, VarCode, Rval, !CI), % If the case values start at some number other than 0, % then subtract that number to give us a zero-based index. @@ -298,7 +298,7 @@ generate_lookup_switch(Var, OutVars, CaseValues, StartVal, EndVal, ( NeedRangeCheck = can_fail, Difference = EndVal - StartVal, - code_info__fail_if_rval_is_false( + code_info.fail_if_rval_is_false( binop(unsigned_le, Index, const(int_const(Difference))), RangeCheck, !CI) ; @@ -322,12 +322,12 @@ generate_lookup_switch(Var, OutVars, CaseValues, StartVal, EndVal, % last would yield the wrong liveness. ( MLiveness = yes(Liveness), - code_info__set_forward_live_vars(Liveness, !CI) + code_info.set_forward_live_vars(Liveness, !CI) ; MLiveness = no, unexpected(this_file, "generate_lookup_switch: no liveness!") ), - code_info__generate_branch_end(StoreMap, MaybeEnd0, _MaybeEnd, LookupCode, + code_info.generate_branch_end(StoreMap, MaybeEnd0, _MaybeEnd, LookupCode, !CI), Comment = node([comment("lookup switch") - ""]), Code = tree_list([Comment, VarCode, RangeCheck, CheckBitVec, LookupCode]). @@ -369,7 +369,7 @@ generate_bitvec_test(Index, CaseVals, Start, _End, CheckCode, !CI) :- ), HasBit = binop(bitwise_and, binop(unchecked_left_shift, const(int_const(1)), BitNum), Word), - code_info__fail_if_rval_is_false(HasBit, CheckCode, !CI). + code_info.fail_if_rval_is_false(HasBit, CheckCode, !CI). % Prevent cross-compilation errors by making sure that the bitvector % uses a number of bits that will fit both on this machine (so that @@ -381,18 +381,18 @@ generate_bitvec_test(Index, CaseVals, Start, _End, CheckCode, !CI) :- :- pred get_word_bits(code_info::in, int::out, int::out) is det. get_word_bits(CI, WordBits, Log2WordBits) :- - int__bits_per_int(HostWordBits), - code_info__get_globals(CI, Globals), - globals__lookup_int_option(Globals, bits_per_word, TargetWordBits), - int__min(HostWordBits, TargetWordBits, WordBits0), + int.bits_per_int(HostWordBits), + code_info.get_globals(CI, Globals), + globals.lookup_int_option(Globals, bits_per_word, TargetWordBits), + int.min(HostWordBits, TargetWordBits, WordBits0), % round down to the nearest power of 2 Log2WordBits = log2_rounded_down(WordBits0), - int__pow(2, Log2WordBits, WordBits). + int.pow(2, Log2WordBits, WordBits). :- func log2_rounded_down(int) = int. log2_rounded_down(X) = Log :- - int__log2(X + 1, Log + 1). % int__log2 rounds up + int.log2(X + 1, Log + 1). % int.log2 rounds up % We generate the bitvector by iterating through the cases marking the bit % for each case. (We represent the bitvector here as a map from the word @@ -402,9 +402,9 @@ log2_rounded_down(X) = Log :- list(rval)::out, rval::out, code_info::in, code_info::out) is det. generate_bit_vec(CaseVals, Start, WordBits, Args, BitVec, !CI) :- - map__init(Empty), + map.init(Empty), generate_bit_vec_2(CaseVals, Start, WordBits, Empty, BitMap), - map__to_assoc_list(BitMap, WordVals), + map.to_assoc_list(BitMap, WordVals), generate_bit_vec_args(WordVals, 0, Args), add_static_cell_natural_types(Args, DataAddr, !CI), BitVec = const(data_addr_const(DataAddr, no)). @@ -417,12 +417,12 @@ generate_bit_vec_2([Tag - _ | Rest], Start, WordBits, Bits0, Bits) :- Val = Tag - Start, Word = Val // WordBits, Offset = Val mod WordBits, - ( map__search(Bits0, Word, X0) -> + ( map.search(Bits0, Word, X0) -> X1 = X0 \/ (1 << Offset) ; X1 = (1 << Offset) ), - map__set(Bits0, Word, X1, Bits1), + map.set(Bits0, Word, X1, Bits1), generate_bit_vec_2(Rest, Start, WordBits, Bits1, Bits). :- pred generate_bit_vec_args(list(pair(int))::in, int::in, @@ -452,7 +452,7 @@ generate_bit_vec_args([Word - Bits | Rest], Count, [Rval | Rvals]) :- code_info::in, code_info::out) is det. generate_terms(Index, OutVars, CaseVals, Start, !CI) :- - map__init(Empty), + map.init(Empty), rearrange_vals(OutVars, CaseVals, Start, Empty, ValMap), generate_terms_2(Index, OutVars, ValMap, !CI). @@ -461,14 +461,14 @@ generate_terms(Index, OutVars, CaseVals, Start, !CI) :- generate_terms_2(_Index, [], _Map, !CI). generate_terms_2(Index, [Var | Vars], Map, !CI) :- - map__lookup(Map, Var, Vals0), - list__sort(Vals0, Vals), + map.lookup(Map, Var, Vals0), + list.sort(Vals0, Vals), construct_args(Vals, 0, Args), - code_info__add_static_cell_natural_types(Args, DataAddr, !CI), + code_info.add_static_cell_natural_types(Args, DataAddr, !CI), ArrayTerm = const(data_addr_const(DataAddr, no)), LookupLval = field(yes(0), ArrayTerm, Index), - code_info__assign_lval_to_var(Var, LookupLval, Code, !CI), - expect(tree__is_empty(Code), this_file, "generate_terms_2: nonempty code"), + code_info.assign_lval_to_var(Var, LookupLval, Code, !CI), + expect(tree.is_empty(Code), this_file, "generate_terms_2: nonempty code"), generate_terms_2(Index, Vars, Map, !CI). :- pred construct_args(list(pair(int, rval))::in, int::in, list(rval)::out) @@ -499,7 +499,7 @@ construct_args([Index - Rval | Rest], Count0, [Arg | Args]) :- rearrange_vals(_Vars, [], _Start, Map, Map). rearrange_vals(Vars, [Tag - Rvals | Rest], Start, Map0, Map) :- - assoc_list__from_corresponding_lists(Vars, Rvals, Pairs), + assoc_list.from_corresponding_lists(Vars, Rvals, Pairs), Index = Tag - Start, rearrange_vals_2(Pairs, Index, Map0, Map1), rearrange_vals(Vars, Rest, Start, Map1, Map). @@ -509,12 +509,12 @@ rearrange_vals(Vars, [Tag - Rvals | Rest], Start, Map0, Map) :- rearrange_vals_2([], _, Map, Map). rearrange_vals_2([Var - Rval | Rest], Tag, Map0, Map) :- - ( map__search(Map0, Var, Vals0) -> + ( map.search(Map0, Var, Vals0) -> Vals = [Tag - Rval | Vals0] ; Vals = [Tag - Rval] ), - map__set(Map0, Var, Vals, Map1), + map.set(Map0, Var, Vals, Map1), rearrange_vals_2(Rest, Tag, Map1, Map). %-----------------------------------------------------------------------------% diff --git a/compiler/loop_inv.m b/compiler/loop_inv.m index bd8beaee0..408a56d65 100644 --- a/compiler/loop_inv.m +++ b/compiler/loop_inv.m @@ -95,7 +95,7 @@ % model-det recursive paths. %-----------------------------------------------------------------------------% -:- module transform_hlds__loop_inv. +:- module transform_hlds.loop_inv. :- interface. :- import_module hlds. @@ -150,7 +150,7 @@ hoist_loop_invariants(PredId, ProcId, PredInfo, !ProcInfo, !ModuleInfo) :- % We only want to apply this optimization to pure preds (e.g. % not benchmark_det_loop). % - hlds_pred__pred_info_get_purity(PredInfo, purity_pure), + hlds_pred.pred_info_get_purity(PredInfo, purity_pure), % Next, work out whether this predicate is optimizable and % compute some auxiliary results along the way. @@ -158,10 +158,10 @@ hoist_loop_invariants(PredId, ProcId, PredInfo, !ProcInfo, !ModuleInfo) :- % Obtain the requisite info for this procedure. % PredProcId = proc(PredId, ProcId), - hlds_pred__proc_info_goal(!.ProcInfo, Body), - hlds_pred__proc_info_headvars(!.ProcInfo, HeadVars), - hlds_pred__proc_info_argmodes(!.ProcInfo, HeadVarModes), - hlds_pred__proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, + hlds_pred.proc_info_goal(!.ProcInfo, Body), + hlds_pred.proc_info_headvars(!.ProcInfo, HeadVars), + hlds_pred.proc_info_argmodes(!.ProcInfo, HeadVarModes), + hlds_pred.proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, InitialInstMap), % Find the set of variables that are used as (partly) unique @@ -314,7 +314,7 @@ invariant_goal_candidates(PredProcId, Body, invariant_goal_candidates_acc(_, RecCalls) = invariant_goal_candidates_2(PredProcId, Body, invariant_goal_candidates_acc([], [])), - assoc_list__keys_and_values(RecCalls, RecCallGoals, CandidateInvGoalsList), + assoc_list.keys_and_values(RecCalls, RecCallGoals, CandidateInvGoalsList), CandidateInvGoals = intersect_candidate_inv_goals(CandidateInvGoalsList). %-----------------------------------------------------------------------------% @@ -351,23 +351,23 @@ invariant_goal_candidates_2(PPId, = IGCs :- ( ConjType = plain_conj, - IGCs = list__foldl(invariant_goal_candidates_2(PPId), Conjuncts, IGCs0) + IGCs = list.foldl(invariant_goal_candidates_2(PPId), Conjuncts, IGCs0) ; ConjType = parallel_conj, - IGCs = list__foldl( + IGCs = list.foldl( invariant_goal_candidates_keeping_path_candidates(PPId), Conjuncts, IGCs0) ). invariant_goal_candidates_2(PPId, disj(Disjuncts) - _GoalInfo, IGCs) = - list__foldl(invariant_goal_candidates_keeping_path_candidates(PPId), + list.foldl(invariant_goal_candidates_keeping_path_candidates(PPId), Disjuncts, IGCs). invariant_goal_candidates_2(PPId, switch(_, _, Cases) - _GoalInfo, IGCs) = - list__foldl(invariant_goal_candidates_keeping_path_candidates(PPId), + list.foldl(invariant_goal_candidates_keeping_path_candidates(PPId), case_goals(Cases), IGCs). @@ -409,7 +409,7 @@ invariant_goal_candidates_keeping_path_candidates(PPId, Goal, IGCs) = :- func case_goals(list(case)) = hlds_goals. case_goals(Cases) = - list__map(func(case(_ConsId, Goal)) = Goal, Cases). + list.map(func(case(_ConsId, Goal)) = Goal, Cases). %-----------------------------------------------------------------------------% @@ -422,7 +422,7 @@ case_goals(Cases) = % add_recursive_call(Goal, IGCs) = IGCs ^ rec_calls := - [Goal - list__reverse(IGCs ^ path_candidates) | IGCs ^ rec_calls]. + [Goal - list.reverse(IGCs ^ path_candidates) | IGCs ^ rec_calls]. %-----------------------------------------------------------------------------% @@ -447,8 +447,8 @@ invariant_goal_candidates_handle_non_recursive_call( :- pred model_non(hlds_goal_info::in) is semidet. model_non(GoalInfo) :- - hlds_goal__goal_info_get_determinism(GoalInfo, Detism), - code_model__determinism_to_code_model(Detism, model_non). + hlds_goal.goal_info_get_determinism(GoalInfo, Detism), + code_model.determinism_to_code_model(Detism, model_non). %-----------------------------------------------------------------------------% @@ -457,7 +457,7 @@ model_non(GoalInfo) :- intersect_candidate_inv_goals([]) = []. intersect_candidate_inv_goals([Goals | Goalss]) = - list__filter(common_goal(Goalss), Goals). + list.filter(common_goal(Goalss), Goals). %-----------------------------------------------------------------------------% @@ -465,10 +465,10 @@ intersect_candidate_inv_goals([Goals | Goalss]) = common_goal(Goalss, Goal) :- all [Gs] ( - list__member(Gs, Goalss) + list.member(Gs, Goalss) => ( - list__member(G, Gs), + list.member(G, Gs), equivalent_goals(G, Goal) ) ). @@ -494,12 +494,12 @@ equivalent_goals(GoalExprX - _GoalInfoX, GoalExprY - _GoalInfoY) :- inv_args(ModuleInfo, HeadVars, HeadVarModes, RecCalls) = InvArgs :- MaybeInvArgs0 = - list__map_corresponding( + list.map_corresponding( arg_to_maybe_inv_arg(ModuleInfo), HeadVars, HeadVarModes), MaybeInvArgs = - list__foldl(refine_candidate_inv_args, RecCalls, MaybeInvArgs0), + list.foldl(refine_candidate_inv_args, RecCalls, MaybeInvArgs0), InvArgs = - list__filter_map(func(yes(Arg)) = Arg is semidet, MaybeInvArgs). + list.filter_map(func(yes(Arg)) = Arg is semidet, MaybeInvArgs). %-----------------------------------------------------------------------------% @@ -519,7 +519,7 @@ arg_to_maybe_inv_arg(ModuleInfo, Arg, Mode) = refine_candidate_inv_args(RecCall - _RecCallInfo, MaybeInvArgs) = ( if RecCall = call(_, _, CallArgs, _, _, _) - then list__map_corresponding(refine_candidate_inv_args_2, + then list.map_corresponding(refine_candidate_inv_args_2, MaybeInvArgs, CallArgs) else unexpected(this_file, "refine_candidate_inv_args/2: " ++ @@ -554,7 +554,7 @@ refine_candidate_inv_args_2(yes(X), Y) = ( if X = Y then yes(X) else no ). inv_goals_vars(ModuleInfo, UniquelyUsedVars, InvGoals0, InvGoals, InvVars0, InvVars) :- - list__foldl2( + list.foldl2( inv_goals_vars_2(ModuleInfo, UniquelyUsedVars), InvGoals0, [], InvGoals, @@ -584,16 +584,16 @@ inv_goals_vars_2(MI, UUVs, Goal, IGs0, IGs, IVs0, IVs) :- :- pred has_uniquely_used_arg(prog_vars::in, hlds_goal::in) is semidet. has_uniquely_used_arg(UUVs, _GoalExpr - GoalInfo) :- - hlds_goal__goal_info_get_nonlocals(GoalInfo, NonLocals), - list__member(UUV, UUVs), - set__member(UUV, NonLocals). + hlds_goal.goal_info_get_nonlocals(GoalInfo, NonLocals), + list.member(UUV, UUVs), + set.member(UUV, NonLocals). %-----------------------------------------------------------------------------% :- pred invariant_goal(hlds_goals::in, hlds_goal::in) is semidet. invariant_goal(InvariantGoals, Goal) :- - list__member(InvariantGoal, InvariantGoals), + list.member(InvariantGoal, InvariantGoals), equivalent_goals(InvariantGoal, Goal). %-----------------------------------------------------------------------------% @@ -604,9 +604,9 @@ invariant_goal(InvariantGoals, Goal) :- input_args_are_invariant(ModuleInfo, Goal, InvVars) :- Inputs = goal_inputs(ModuleInfo, Goal), all [V] ( - list__member(V, Inputs) + list.member(V, Inputs) => - list__member(V, InvVars) + list.member(V, InvVars) ). %-----------------------------------------------------------------------------% @@ -615,7 +615,7 @@ input_args_are_invariant(ModuleInfo, Goal, InvVars) :- hlds_goals::out, prog_vars::out) is det. dont_hoist(MI, InvGoals, DontHoistGoals, DontHoistVars) :- - list__foldl2(dont_hoist_2(MI), InvGoals, + list.foldl2(dont_hoist_2(MI), InvGoals, [], DontHoistGoals, [], DontHoistVars). :- pred dont_hoist_2(module_info::in, hlds_goal::in, @@ -681,7 +681,7 @@ cannot_succeed(_GoalExpr - GoalInfo) :- arg_is_input(InstInfo, Arg) :- InstInfo = {_ModuleInfo, InstMap}, - instmap__lookup_var(InstMap, Arg, Inst), + instmap.lookup_var(InstMap, Arg, Inst), inst_is_input(InstInfo, Inst). %-----------------------------------------------------------------------------% @@ -692,8 +692,8 @@ arg_is_input(InstInfo, Arg) :- :- pred inst_is_input(inst_info::in, mer_inst::in) is semidet. inst_is_input({ModuleInfo, _InstMap}, Inst) :- - inst_match__inst_is_ground(ModuleInfo, Inst), - inst_match__inst_is_not_partly_unique(ModuleInfo, Inst). + inst_match.inst_is_ground(ModuleInfo, Inst), + inst_match.inst_is_not_partly_unique(ModuleInfo, Inst). %-----------------------------------------------------------------------------% @@ -701,13 +701,13 @@ inst_is_input({ModuleInfo, _InstMap}, Inst) :- prog_vars. add_outputs(ModuleInfo, UUVs, Goal, InvVars) = - list__foldl(add_output(UUVs), goal_outputs(ModuleInfo, Goal), InvVars). + list.foldl(add_output(UUVs), goal_outputs(ModuleInfo, Goal), InvVars). :- func add_output(prog_vars, prog_var, prog_vars) = prog_vars. add_output(UniquelyUsedVars, X, InvVars) = - ( if not list__member(X, InvVars), - not list__member(X, UniquelyUsedVars) + ( if not list.member(X, InvVars), + not list.member(X, UniquelyUsedVars) then [X | InvVars] else InvVars ). @@ -716,11 +716,11 @@ add_output(UniquelyUsedVars, X, InvVars) = :- func compute_initial_aux_instmap(hlds_goals, instmap) = instmap. -compute_initial_aux_instmap(Gs, IM) = list__foldl(ApplyGoalInstMap, Gs, IM) :- +compute_initial_aux_instmap(Gs, IM) = list.foldl(ApplyGoalInstMap, Gs, IM) :- ApplyGoalInstMap = ( func(_GoalExpr - GoalInfo, IM0) = IM1 :- - hlds_goal__goal_info_get_instmap_delta(GoalInfo, IMD), - instmap__apply_instmap_delta(IM0, IMD, IM1) + hlds_goal.goal_info_get_instmap_delta(GoalInfo, IMD), + instmap.apply_instmap_delta(IM0, IMD, IM1) ). %-----------------------------------------------------------------------------% @@ -731,35 +731,34 @@ compute_initial_aux_instmap(Gs, IM) = list__foldl(ApplyGoalInstMap, Gs, IM) :- create_aux_pred(PredProcId, HeadVars, ComputedInvArgs, InitialAuxInstMap, AuxPredProcId, CallAux, - AuxPredInfo, AuxProcInfo, - ModuleInfo0, ModuleInfo) :- + AuxPredInfo, AuxProcInfo, ModuleInfo0, ModuleInfo) :- PredProcId = proc(PredId, ProcId), AuxHeadVars = HeadVars ++ ComputedInvArgs, - hlds_module__module_info_get_name(ModuleInfo0, ModuleName), - hlds_module__module_info_pred_proc_info(ModuleInfo0, PredId, ProcId, - PredInfo, ProcInfo), + hlds_module.module_info_get_name(ModuleInfo0, ModuleName), + hlds_module.module_info_pred_proc_info(ModuleInfo0, PredId, ProcId, + PredInfo, ProcInfo), - hlds_pred__proc_info_goal(ProcInfo, Goal @ (_GoalExpr - GoalInfo)), - hlds_pred__pred_info_typevarset(PredInfo, TVarSet), - hlds_pred__proc_info_vartypes(ProcInfo, VarTypes), - hlds_pred__pred_info_get_class_context(PredInfo, ClassContext), - hlds_pred__proc_info_rtti_varmaps(ProcInfo, RttiVarMaps), - hlds_pred__proc_info_varset(ProcInfo, VarSet), - hlds_pred__proc_info_inst_varset(ProcInfo, InstVarSet), - hlds_pred__pred_info_get_markers(PredInfo, Markers), - hlds_pred__pred_info_get_origin(PredInfo, OrigOrigin), + hlds_pred.proc_info_goal(ProcInfo, Goal @ (_GoalExpr - GoalInfo)), + hlds_pred.pred_info_typevarset(PredInfo, TVarSet), + hlds_pred.proc_info_vartypes(ProcInfo, VarTypes), + hlds_pred.pred_info_get_class_context(PredInfo, ClassContext), + hlds_pred.proc_info_rtti_varmaps(ProcInfo, RttiVarMaps), + hlds_pred.proc_info_varset(ProcInfo, VarSet), + hlds_pred.proc_info_inst_varset(ProcInfo, InstVarSet), + hlds_pred.pred_info_get_markers(PredInfo, Markers), + hlds_pred.pred_info_get_origin(PredInfo, OrigOrigin), - PredName = hlds_pred__pred_info_name(PredInfo), - PredOrFunc = hlds_pred__pred_info_is_pred_or_func(PredInfo), - hlds_goal__goal_info_get_context(GoalInfo, Context), - term__context_line(Context, Line), - hlds_pred__proc_id_to_int(ProcId, ProcNo), - AuxNamePrefix = string__format("loop_inv_%d", [i(ProcNo)]), - prog_util__make_pred_name_with_context(ModuleName, AuxNamePrefix, - PredOrFunc, PredName, Line, 1, AuxPredSymName), + PredName = hlds_pred.pred_info_name(PredInfo), + PredOrFunc = hlds_pred.pred_info_is_pred_or_func(PredInfo), + hlds_goal.goal_info_get_context(GoalInfo, Context), + term.context_line(Context, Line), + hlds_pred.proc_id_to_int(ProcId, ProcNo), + AuxNamePrefix = string.format("loop_inv_%d", [i(ProcNo)]), + prog_util.make_pred_name_with_context(ModuleName, AuxNamePrefix, + PredOrFunc, PredName, Line, 1, AuxPredSymName), ( AuxPredSymName = unqualified(AuxPredName) ; @@ -769,7 +768,7 @@ create_aux_pred(PredProcId, HeadVars, ComputedInvArgs, % Put in oven at gas mark 11 and bake. % Origin = transformed(loop_invariant(ProcNo), OrigOrigin, PredId), - hlds_pred__define_new_pred( + hlds_pred.define_new_pred( Origin, % in - The origin of this new predicate Goal, % in - The goal for the new aux proc. CallAux, % out - How we can call the new aux proc. @@ -799,7 +798,7 @@ create_aux_pred(PredProcId, HeadVars, ComputedInvArgs, % over the entire goal after we've transformed it. AuxPredProcId = proc(AuxPredId, AuxProcId), - hlds_module__module_info_pred_proc_info(ModuleInfo, AuxPredId, AuxProcId, + hlds_module.module_info_pred_proc_info(ModuleInfo, AuxPredId, AuxProcId, AuxPredInfo, AuxProcInfo). %-----------------------------------------------------------------------------% @@ -830,12 +829,12 @@ gen_aux_proc(InvGoals, PredProcId, AuxPredProcId, CallAux, Body, % Put the new proc body and instmap into the module_info. % AuxPredProcId = proc(AuxPredId, AuxProcId), - hlds_pred__proc_info_set_goal(AuxBody, !AuxProcInfo), + hlds_pred.proc_info_set_goal(AuxBody, !AuxProcInfo), - quantification__requantify_proc(!AuxProcInfo), - mode_util__recompute_instmap_delta_proc(no, !AuxProcInfo, !ModuleInfo), + quantification.requantify_proc(!AuxProcInfo), + mode_util.recompute_instmap_delta_proc(no, !AuxProcInfo, !ModuleInfo), - hlds_module__module_info_set_pred_proc_info(AuxPredId, AuxProcId, + hlds_module.module_info_set_pred_proc_info(AuxPredId, AuxProcId, AuxPredInfo, !.AuxProcInfo, !ModuleInfo). %-----------------------------------------------------------------------------% @@ -887,14 +886,14 @@ gen_aux_proc_2(_Info, shorthand(_) - _GoalInfo) = _ :- :- func gen_aux_proc_list(gen_aux_proc_info, hlds_goals) = hlds_goals. -gen_aux_proc_list(Info, Goals) = list__map(gen_aux_proc_2(Info), Goals). +gen_aux_proc_list(Info, Goals) = list.map(gen_aux_proc_2(Info), Goals). %-----------------------------------------------------------------------------% :- func gen_aux_proc_switch(gen_aux_proc_info, list(case)) = list(case). gen_aux_proc_switch(Info, Cases) = - list__map( + list.map( func(case(CaseId, Goal)) = case(CaseId, gen_aux_proc_2(Info, Goal)), Cases ). @@ -930,19 +929,19 @@ gen_out_proc(PredProcId, PredInfo0, ProcInfo0, ProcInfo, CallAux, Body0, % PredProcId = proc(PredId, ProcId), - hlds_pred__proc_info_varset(ProcInfo0, VarSet), - hlds_pred__proc_info_vartypes(ProcInfo0, VarTypes), - hlds_pred__proc_info_headvars(ProcInfo0, HeadVars), - hlds_pred__proc_info_rtti_varmaps(ProcInfo0, RttiVarMaps), + hlds_pred.proc_info_varset(ProcInfo0, VarSet), + hlds_pred.proc_info_vartypes(ProcInfo0, VarTypes), + hlds_pred.proc_info_headvars(ProcInfo0, HeadVars), + hlds_pred.proc_info_rtti_varmaps(ProcInfo0, RttiVarMaps), - hlds_pred__proc_info_set_body(VarSet, VarTypes, HeadVars, Body, + hlds_pred.proc_info_set_body(VarSet, VarTypes, HeadVars, Body, RttiVarMaps, ProcInfo0, ProcInfo1), - quantification__requantify_proc(ProcInfo1, ProcInfo2), - mode_util__recompute_instmap_delta_proc(no, ProcInfo2, ProcInfo, - ModuleInfo0, ModuleInfo1), + quantification.requantify_proc(ProcInfo1, ProcInfo2), + mode_util.recompute_instmap_delta_proc(no, ProcInfo2, ProcInfo, + ModuleInfo0, ModuleInfo1), - hlds_module__module_info_set_pred_proc_info(PredId, ProcId, + hlds_module.module_info_set_pred_proc_info(PredId, ProcId, PredInfo0, ProcInfo, ModuleInfo1, ModuleInfo). %-----------------------------------------------------------------------------% @@ -973,16 +972,16 @@ gen_out_proc_2(_PPId, _CallAux, gen_out_proc_2(PPId, CallAux, conj(ConjType, Conjuncts) - GoalInfo) = - conj(ConjType, list__map(gen_out_proc_2(PPId, CallAux), Conjuncts)) + conj(ConjType, list.map(gen_out_proc_2(PPId, CallAux), Conjuncts)) - GoalInfo. gen_out_proc_2(PPId, CallAux, disj(Disjuncts) - GoalInfo) = - disj(list__map(gen_out_proc_2(PPId, CallAux), Disjuncts)) - GoalInfo. + disj(list.map(gen_out_proc_2(PPId, CallAux), Disjuncts)) - GoalInfo. gen_out_proc_2(PPId, CallAux, switch(Var, CanFail, Cases) - GoalInfo) = - switch(Var, CanFail, list__map(GOPCase, Cases)) - GoalInfo + switch(Var, CanFail, list.map(GOPCase, Cases)) - GoalInfo :- GOPCase = ( func(case(ConsId, Goal)) = @@ -1056,18 +1055,18 @@ replace_initial_args([_ | _], [] ) = _ :- :- func uniquely_used_vars(module_info, hlds_goal) = prog_vars. uniquely_used_vars(ModuleInfo, Goal) = - list__sort_and_remove_dups(uniquely_used_vars_2(ModuleInfo, Goal)). + list.sort_and_remove_dups(uniquely_used_vars_2(ModuleInfo, Goal)). %-----------------------------------------------------------------------------% :- func uniquely_used_vars_2(module_info, hlds_goal) = prog_vars. uniquely_used_vars_2(MI, call(PredId, ProcId, Args, _, _, _) - _) = - list__filter_map_corresponding(uniquely_used_args(MI), Args, + list.filter_map_corresponding(uniquely_used_args(MI), Args, argmodes(MI,PredId,ProcId)). uniquely_used_vars_2(MI, generic_call(_, Args, Modes, _) - _) = - list__filter_map_corresponding(uniquely_used_args(MI), Args, Modes). + list.filter_map_corresponding(uniquely_used_args(MI), Args, Modes). uniquely_used_vars_2(MI, foreign_proc(_, PredId, ProcId, Args, Extras, _) - _) = @@ -1079,8 +1078,8 @@ uniquely_used_vars_2(MI, foreign_proc(_, PredId, ProcId, Args, Extras, _) - _) % `Extras' may not be empty. As a work-around we just add any variables % in `Extras' to the set of variables that cannot be hoisted. % - list__filter_map_corresponding(uniquely_used_args(MI), - list__map(foreign_arg_var, Args), + list.filter_map_corresponding(uniquely_used_args(MI), + list.map(foreign_arg_var, Args), argmodes(MI,PredId,ProcId)) ++ list.map(foreign_arg_var, Extras). % XXX This is very conservative! @@ -1088,13 +1087,13 @@ uniquely_used_vars_2(MI, foreign_proc(_, PredId, ProcId, Args, Extras, _) - _) uniquely_used_vars_2(_MI, unify(_LHS, _RHS, _UMode, _UKind, _) - _) = []. uniquely_used_vars_2(MI, conj(_, Conjuncts) - _) = - list__condense(list__map(uniquely_used_vars_2(MI), Conjuncts)). + list.condense(list.map(uniquely_used_vars_2(MI), Conjuncts)). uniquely_used_vars_2(MI, disj(Disjuncts) - _) = - list__condense(list__map(uniquely_used_vars_2(MI), Disjuncts)). + list.condense(list.map(uniquely_used_vars_2(MI), Disjuncts)). uniquely_used_vars_2(MI, switch(_, _, Cases) - _) = - list__condense(list__map(uniquely_used_vars_2(MI), case_goals(Cases))). + list.condense(list.map(uniquely_used_vars_2(MI), case_goals(Cases))). uniquely_used_vars_2(MI, not(NegatedGoal) - _) = uniquely_used_vars_2(MI, NegatedGoal). @@ -1116,17 +1115,17 @@ uniquely_used_vars_2(_MI, shorthand(_) - _) = _ :- is semidet. uniquely_used_args(MI, X, M) = X :- - mode_util__mode_get_insts(MI, M, InInst, _OutInst), - not inst_match__inst_is_not_partly_unique(MI, InInst). + mode_util.mode_get_insts(MI, M, InInst, _OutInst), + not inst_match.inst_is_not_partly_unique(MI, InInst). %-----------------------------------------------------------------------------% :- func argmodes(module_info, pred_id, proc_id) = list(mer_mode). argmodes(ModuleInfo, PredId, ProcId) = ArgModes :- - hlds_module__module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, - ProcInfo), - hlds_pred__proc_info_argmodes(ProcInfo, ArgModes). + hlds_module.module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, + ProcInfo), + hlds_pred.proc_info_argmodes(ProcInfo, ArgModes). %-----------------------------------------------------------------------------% @@ -1136,30 +1135,29 @@ argmodes(ModuleInfo, PredId, ProcId) = ArgModes :- :- func goal_inputs(module_info, hlds_goal) = prog_vars. goal_inputs(MI, call(PredId, ProcId, Args, _, _, _) - _) = - list__filter_map_corresponding( - input_arg(MI), Args, argmodes(MI, PredId, ProcId)). + list.filter_map_corresponding(input_arg(MI), Args, + argmodes(MI, PredId, ProcId)). goal_inputs(MI, generic_call(_, Args, ArgModes, _) - _) = - list__filter_map_corresponding( - input_arg(MI), Args, ArgModes). + list.filter_map_corresponding(input_arg(MI), Args, ArgModes). goal_inputs(MI, foreign_proc(_, PredId, ProcId, Args, _, _) - _) = - list__filter_map_corresponding(input_arg(MI), - list__map(foreign_arg_var, Args), argmodes(MI, PredId, ProcId)). + list.filter_map_corresponding(input_arg(MI), + list.map(foreign_arg_var, Args), argmodes(MI, PredId, ProcId)). goal_inputs(MI, unify(LHS, UnifyRHS, _, Kind, _) - _) = Inputs :- ( % The LHS is always an output var in constructions. % Kind = construct(_, _, RHSArgs, ArgUniModes, _, _, _), - Inputs = list__filter_map_corresponding( + Inputs = list.filter_map_corresponding( input_arg(MI), RHSArgs, rhs_modes(ArgUniModes)) ; % The LHS is always in input var in deconstructions. % Kind = deconstruct(_, _, RHSArgs, ArgUniModes, _, _), Inputs = [ LHS - | list__filter_map_corresponding( + | list.filter_map_corresponding( input_arg(MI), RHSArgs, rhs_modes(ArgUniModes)) ] ; % The RHS is the only input in an assignment. @@ -1206,8 +1204,8 @@ goal_inputs(_MI, shorthand(_) - _) = _ :- :- func input_arg(module_info, prog_var, mer_mode) = prog_var is semidet. input_arg(MI, X, M) = X :- - mode_util__mode_get_insts(MI, M, InInst, _OutInst), - not inst_match__inst_is_free(MI, InInst). + mode_util.mode_get_insts(MI, M, InInst, _OutInst), + not inst_match.inst_is_free(MI, InInst). %-----------------------------------------------------------------------------% @@ -1217,17 +1215,15 @@ input_arg(MI, X, M) = X :- :- func goal_outputs(module_info, hlds_goal) = prog_vars. goal_outputs(MI, call(PredId, ProcId, Args, _, _, _) - _) = - list__filter_map_corresponding( - output_arg(MI), Args, argmodes(MI, PredId, ProcId)). + list.filter_map_corresponding(output_arg(MI), Args, + argmodes(MI, PredId, ProcId)). goal_outputs(MI, generic_call(_, Args, ArgModes, _) - _) = - list__filter_map_corresponding( - output_arg(MI), Args, ArgModes). + list.filter_map_corresponding(output_arg(MI), Args, ArgModes). goal_outputs(MI, foreign_proc(_, PredId, ProcId, Args, _, _) - _) = - list__filter_map_corresponding( - output_arg(MI), list__map(foreign_arg_var, Args), - argmodes(MI, PredId, ProcId)). + list.filter_map_corresponding(output_arg(MI), + list.map(foreign_arg_var, Args), argmodes(MI, PredId, ProcId)). goal_outputs(MI, unify(LHS, _RHS, _, Kind, _) - _) = Outputs :- ( @@ -1239,7 +1235,7 @@ goal_outputs(MI, unify(LHS, _RHS, _, Kind, _) - _) = Outputs :- % The LHS is always in input in deconstructions. % Kind = deconstruct(_, _, RHSArgs, ArgUniModes, _, _), - Outputs = list__filter_map_corresponding( + Outputs = list.filter_map_corresponding( output_arg(MI), RHSArgs, rhs_modes(ArgUniModes)) ; % The LHS is the only output in an assignment. @@ -1286,22 +1282,22 @@ goal_outputs(_MI, shorthand(_) - _) = _ :- :- func output_arg(module_info, prog_var, mer_mode) = prog_var is semidet. output_arg(MI, X, M) = X :- - mode_util__mode_get_insts(MI, M, InInst, _OutInst), - inst_match__inst_is_free(MI, InInst). + mode_util.mode_get_insts(MI, M, InInst, _OutInst), + inst_match.inst_is_free(MI, InInst). %-----------------------------------------------------------------------------% :- func rhs_modes(list(uni_mode)) = list(mer_mode). rhs_modes(UniModes) = - list__map(func((_ - Pre) -> (_ - Post)) = (Pre -> Post), UniModes). + list.map(func((_ - Pre) -> (_ - Post)) = (Pre -> Post), UniModes). %-----------------------------------------------------------------------------% :- func lhs_modes(list(uni_mode)) = list(mer_mode). lhs_modes(UniModes) = - list__map(func((Pre - _) -> (Post - _)) = (Pre -> Post), UniModes). + list.map(func((Pre - _) -> (Post - _)) = (Pre -> Post), UniModes). %-----------------------------------------------------------------------------% diff --git a/compiler/make.dependencies.m b/compiler/make.dependencies.m index 1566b3781..05a9ea90c 100644 --- a/compiler/make.dependencies.m +++ b/compiler/make.dependencies.m @@ -117,14 +117,14 @@ :- implementation. :- import_module transform_hlds. -:- import_module transform_hlds__mmc_analysis. +:- import_module transform_hlds.mmc_analysis. %-----------------------------------------------------------------------------% :- type deps_result(T) == pair(bool, set(T)). :- type module_deps_result == deps_result(module_name). -union_deps(FindDeps, ModuleName, Success, Deps0, set__union(Deps0, Deps), +union_deps(FindDeps, ModuleName, Success, Deps0, set.union(Deps0, Deps), !Info, !IO) :- FindDeps(ModuleName, Success, Deps, !Info, !IO). @@ -158,7 +158,7 @@ combine_deps_2(FindDeps1, FindDeps2, ModuleName, Success, Deps, !Info, !IO) :- ; FindDeps2(ModuleName, Success2, Deps2, !Info, !IO), Success = Success1 `and` Success2, - Deps = set__union(Deps1, Deps2) + Deps = set.union(Deps1, Deps2) ). :- func combine_deps_list(list( @@ -191,9 +191,9 @@ target_dependencies(Globals, java_code) = compiled_code_dependencies(Globals). target_dependencies(Globals, asm_code(_)) = compiled_code_dependencies(Globals). target_dependencies(Globals, object_code(PIC)) = Deps :- - globals__get_target(Globals, CompilationTarget), + globals.get_target(Globals, CompilationTarget), TargetCode = ( CompilationTarget = asm -> asm_code(PIC) ; c_code ), - globals__lookup_bool_option(Globals, highlevel_code, HighLevelCode), + globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode), % % For --highlevel-code, the `.c' file will #include the header @@ -252,7 +252,7 @@ target_dependencies(Globals, fact_table_object(PIC, _)) = (find_module_deps(dependency_file)::out(find_module_deps)) is det. get_foreign_deps(Globals, PIC) = Deps :- - globals__get_target(Globals, CompilationTarget), + globals.get_target(Globals, CompilationTarget), TargetCode = ( CompilationTarget = asm -> asm_code(PIC) ; c_code ), Deps = combine_deps_list([ TargetCode `of` self @@ -273,8 +273,8 @@ interface_file_dependencies = (find_module_deps(dependency_file)::out(find_module_deps)) is det. compiled_code_dependencies(Globals) = Deps :- - globals__lookup_bool_option(Globals, intermodule_optimization, Intermod), - globals__lookup_bool_option(Globals, intermodule_analysis, + globals.lookup_bool_option(Globals, intermodule_optimization, Intermod), + globals.lookup_bool_option(Globals, intermodule_analysis, IntermodAnalysis), ( Intermod = yes, @@ -334,8 +334,8 @@ FileType `of` FindDeps = of_2(FileType, FindDeps, ModuleName, Success, TargetFiles, !Info, !IO) :- FindDeps(ModuleName, Success, ModuleNames, !Info, !IO), - TargetFiles = set__sorted_list_to_set( - make_dependency_list(set__to_sorted_list(ModuleNames), FileType)). + TargetFiles = set.sorted_list_to_set( + make_dependency_list(set.to_sorted_list(ModuleNames), FileType)). :- func find_module_deps(pair(file_name, maybe(option))) `files_of` find_module_deps(module_name) = find_module_deps(dependency_file). @@ -359,16 +359,16 @@ files_of_2(FindFiles, FindDeps, ModuleName, Success, DepFiles, !Info, !IO) :- KeepGoing = no -> Success = no, - DepFiles = set__init + DepFiles = set.init ; foldl3_maybe_stop_at_error(KeepGoing, union_deps(FindFiles), - set__to_sorted_list(ModuleNames), Success1, set__init, FileNames, + set.to_sorted_list(ModuleNames), Success1, set.init, FileNames, !Info, !IO), Success = Success0 `and` Success1, - DepFiles = set__sorted_list_to_set( - list__map( + DepFiles = set.sorted_list_to_set( + list.map( (func(FileName - Option) = file(FileName, Option)), - set__to_sorted_list(FileNames))) + set.to_sorted_list(FileNames))) ). :- pred map_find_module_deps(find_module_deps(T)::in(find_module_deps), @@ -385,10 +385,10 @@ map_find_module_deps(FindDeps2, FindDeps1, ModuleName, KeepGoing = no -> Success = no, - Result = set__init + Result = set.init ; foldl3_maybe_stop_at_error(KeepGoing, union_deps(FindDeps2), - set__to_sorted_list(Modules0), Success1, set__init, Result, + set.to_sorted_list(Modules0), Success1, set.init, Result, !Info, !IO), Success = Success0 `and` Success1 ). @@ -398,7 +398,7 @@ map_find_module_deps(FindDeps2, FindDeps1, ModuleName, :- pred no_deps(module_name::in, bool::out, set(T)::out, make_info::in, make_info::out, io::di, io::uo) is det. -no_deps(_, yes, set__init, !Info, !IO). +no_deps(_, yes, set.init, !Info, !IO). :- pred self(module_name::in, bool::out, set(module_name)::out, make_info::in, make_info::out, io::di, io::uo) is det. @@ -414,7 +414,7 @@ parents(ModuleName, yes, list_to_set(get_ancestors(ModuleName)), !Info, !IO). :- type cached_direct_imports == map(module_name, module_deps_result). -init_cached_direct_imports = map__init. +init_cached_direct_imports = map.init. :- pred direct_imports(module_name::in, bool::out, set(module_name)::out, make_info::in, make_info::out, io::di, io::uo) is det. @@ -432,7 +432,7 @@ direct_imports(ModuleName, Success, Modules, !Info, !IO) :- KeepGoing = no -> Success = no, - Modules = set__init + Modules = set.init ; % % We also read `.int' files for the modules for @@ -446,15 +446,15 @@ direct_imports(ModuleName, Success, Modules, !Info, !IO) :- KeepGoing = no -> Success = no, - Modules = set__init + Modules = set.init ; foldl3_maybe_stop_at_error(!.Info ^ keep_going, union_deps(non_intermod_direct_imports), - set__to_sorted_list(IntermodModules), Success2, - set__union(Modules0, IntermodModules), Modules1, + set.to_sorted_list(IntermodModules), Success2, + set.union(Modules0, IntermodModules), Modules1, !Info, !IO), Success = Success0 `and` Success1 `and` Success2, - Modules = set__delete(Modules1, ModuleName) + Modules = set.delete(Modules1, ModuleName) ) ), !:Info = !.Info ^ cached_direct_imports ^ elem(ModuleName) @@ -493,13 +493,13 @@ non_intermod_direct_imports(ModuleName, Success, Modules, !Info, !IO) :- % However, that should not be a major problem. % (This duplicates how this is handled by modules.m). % - Modules0 = set__union(set__list_to_set(Imports ^ impl_deps), - set__list_to_set(Imports ^ int_deps)), + Modules0 = set.union(set.list_to_set(Imports ^ impl_deps), + set.list_to_set(Imports ^ int_deps)), ( ModuleName = qualified(ParentModule, _), non_intermod_direct_imports(ParentModule, Success, ParentImports, !Info, !IO), - Modules = set__union(ParentImports, Modules0) + Modules = set.union(ParentImports, Modules0) ; ModuleName = unqualified(_), Success = yes, @@ -508,7 +508,7 @@ non_intermod_direct_imports(ModuleName, Success, Modules, !Info, !IO) :- ; MaybeImports = no, Success = no, - Modules = set__init + Modules = set.init ). %-----------------------------------------------------------------------------% @@ -550,14 +550,14 @@ indirect_imports_2(FindDirectImports, ModuleName, Success, IndirectImports, KeepGoing = no -> Success = no, - IndirectImports = set__init + IndirectImports = set.init ; foldl3_maybe_stop_at_error(!.Info ^ keep_going, union_deps(find_transitive_implementation_imports), - set__to_sorted_list(DirectImports), IndirectSuccess, - set__init, IndirectImports0, !Info, !IO), - IndirectImports = set__difference( - set__delete(IndirectImports0, ModuleName), + set.to_sorted_list(DirectImports), IndirectSuccess, + set.init, IndirectImports0, !Info, !IO), + IndirectImports = set.difference( + set.delete(IndirectImports0, ModuleName), DirectImports), Success = DirectSuccess `and` IndirectSuccess ). @@ -570,10 +570,10 @@ indirect_imports_2(FindDirectImports, ModuleName, Success, IndirectImports, make_info::in, make_info::out, io::di, io::uo) is det. intermod_imports(ModuleName, Success, Modules, !Info, !IO) :- - globals__io_lookup_bool_option(intermodule_optimization, Intermod, !IO), + globals.io_lookup_bool_option(intermodule_optimization, Intermod, !IO), ( Intermod = yes, - globals__io_lookup_bool_option(read_opt_files_transitively, + globals.io_lookup_bool_option(read_opt_files_transitively, Transitive, !IO), ( Transitive = yes, @@ -587,7 +587,7 @@ intermod_imports(ModuleName, Success, Modules, !Info, !IO) :- ; Intermod = no, Success = yes, - Modules = set__init + Modules = set.init ). %-----------------------------------------------------------------------------% @@ -601,13 +601,13 @@ foreign_imports(ModuleName, Success, Modules, !Info, !IO) :- % mentioned in `:- pragma foreign_import_module' declarations % in the current module and the `.opt' files it imports. % - globals__io_get_globals(Globals, !IO), - globals__get_backend_foreign_languages(Globals, Languages), + globals.io_get_globals(Globals, !IO), + globals.get_backend_foreign_languages(Globals, Languages), intermod_imports(ModuleName, IntermodSuccess, IntermodModules, !Info, !IO), foldl3_maybe_stop_at_error(!.Info ^ keep_going, - union_deps(find_module_foreign_imports(set__list_to_set(Languages))), - [ModuleName | set__to_sorted_list(IntermodModules)], - ForeignSuccess, set__init, Modules, !Info, !IO), + union_deps(find_module_foreign_imports(set.list_to_set(Languages))), + [ModuleName | set.to_sorted_list(IntermodModules)], + ForeignSuccess, set.init, Modules, !Info, !IO), Success = IntermodSuccess `and` ForeignSuccess. :- pred find_module_foreign_imports(set(foreign_language)::in, module_name::in, @@ -623,11 +623,11 @@ find_module_foreign_imports(Languages, ModuleName, Success, ForeignModules, foldl3_maybe_stop_at_error(!.Info ^ keep_going, union_deps(find_module_foreign_imports_2(Languages)), [ModuleName | to_sorted_list(ImportedModules)], - Success, set__init, ForeignModules, !Info, !IO) + Success, set.init, ForeignModules, !Info, !IO) ; Success0 = no, Success = no, - ForeignModules = set__init + ForeignModules = set.init ). :- pred find_module_foreign_imports_2(set(foreign_language)::in, @@ -639,13 +639,13 @@ find_module_foreign_imports_2(Languages, ModuleName, get_module_dependencies(ModuleName, MaybeImports, !Info, !IO), ( MaybeImports = yes(Imports), - ForeignModules = set__list_to_set( + ForeignModules = set.list_to_set( get_foreign_imported_modules(Languages, Imports ^ foreign_import_module_info)), Success = yes ; MaybeImports = no, - ForeignModules = set__init, + ForeignModules = set.init, Success = no ). @@ -665,7 +665,7 @@ get_foreign_imported_modules(Languages, ForeignImportModules) = foreign_import_module_info) = list(module_name). get_foreign_imported_modules_2(MaybeLanguages, ForeignImportModules) = - list__filter_map(get_foreign_imported_modules_3(MaybeLanguages), + list.filter_map(get_foreign_imported_modules_3(MaybeLanguages), ForeignImportModules). :- func get_foreign_imported_modules_3(maybe(set(foreign_language)), @@ -676,7 +676,7 @@ get_foreign_imported_modules_3(MaybeLanguages, ForeignImportModule) ForeignImportModule = foreign_import_module(Language, ForeignModule, _), ( MaybeLanguages = yes(Languages), - set__member(Language, Languages) + set.member(Language, Languages) ; MaybeLanguages = no ). @@ -698,15 +698,15 @@ foreign_imports(Lang, ModuleName, Success, Modules, !Info, !IO) :- get_module_dependencies(ModuleName, MaybeImports, !Info, !IO), ( MaybeImports = yes(Imports), - list__filter_map( + list.filter_map( (pred(FI::in, M::out) is semidet :- FI = foreign_import_module(Lang, M, _) ), Imports ^ foreign_import_module_info, ModulesList), - set__list_to_set(ModulesList, Modules), + set.list_to_set(ModulesList, Modules), Success = yes ; MaybeImports = no, - Modules = set__init, + Modules = set.init, Success = no ). @@ -726,7 +726,7 @@ foreign_imports(Lang, ModuleName, Success, Modules, !Info, !IO) :- filter(Filter, F, ModuleName, Success, Modules, !Info, !IO) :- F(ModuleName, Success, Modules0, !Info, !IO), - Modules = set__filter((pred(M::in) is semidet :- Filter(ModuleName, M)), + Modules = set.filter((pred(M::in) is semidet :- Filter(ModuleName, M)), Modules0). @@ -755,12 +755,12 @@ fact_table(ModuleName, Success, Files, !Info, !IO) :- ( MaybeImports = yes(Imports), Success = yes, - Files = set__list_to_set( + Files = set.list_to_set( make_target_list(Imports ^ fact_table_deps, no)) ; MaybeImports = no, Success = no, - Files = set__init + Files = set.init ). %-----------------------------------------------------------------------------% @@ -786,7 +786,7 @@ fact_table(ModuleName, Success, Files, !Info, !IO) :- :- type cached_transitive_dependencies == map(transitive_dependencies_root, transitive_deps_result). -init_cached_transitive_dependencies = map__init. +init_cached_transitive_dependencies = map.init. find_reachable_local_modules(ModuleName, Success, Modules, !Info, !IO) :- find_transitive_module_dependencies(all_dependencies, local_module, @@ -800,7 +800,7 @@ find_transitive_implementation_imports(ModuleName, Success, Modules, !Info, !IO) :- find_transitive_module_dependencies(all_dependencies, any_module, ModuleName, Success, Modules0, !Info, !IO), - Modules = set__insert(Modules0, ModuleName). + Modules = set.insert(Modules0, ModuleName). :- pred find_transitive_interface_imports(module_name::in, bool::out, set(module_name)::out, make_info::in, make_info::out, @@ -809,7 +809,7 @@ find_transitive_implementation_imports(ModuleName, Success, Modules, find_transitive_interface_imports(ModuleName, Success, Modules, !Info, !IO) :- find_transitive_module_dependencies(interface_imports, any_module, ModuleName, Success, Modules0, !Info, !IO), - set__delete(Modules0, ModuleName, Modules). + set.delete(Modules0, ModuleName, Modules). :- pred find_transitive_module_dependencies(transitive_dependencies_type::in, module_locn::in, module_name::in, bool::out, set(module_name)::out, @@ -817,10 +817,10 @@ find_transitive_interface_imports(ModuleName, Success, Modules, !Info, !IO) :- find_transitive_module_dependencies(DependenciesType, ModuleLocn, ModuleName, Success, Modules, !Info, !IO) :- - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), find_transitive_module_dependencies_2(KeepGoing, DependenciesType, ModuleLocn, ModuleName, - Success, set__init, Modules, !Info, !IO), + Success, set.init, Modules, !Info, !IO), DepsRoot = transitive_dependencies_root(ModuleName, DependenciesType, ModuleLocn), !:Info = !.Info ^ cached_transitive_dependencies ^ elem(DepsRoot) @@ -835,7 +835,7 @@ find_transitive_module_dependencies(DependenciesType, ModuleLocn, find_transitive_module_dependencies_2(KeepGoing, DependenciesType, ModuleLocn, ModuleName, Success, Modules0, Modules, !Info, !IO) :- ( - set__member(ModuleName, Modules0) + set.member(ModuleName, Modules0) -> Success = yes, Modules = Modules0 @@ -845,7 +845,7 @@ find_transitive_module_dependencies_2(KeepGoing, DependenciesType, Result0 = !.Info ^ cached_transitive_dependencies ^ elem(DepsRoot) -> Result0 = Success - Modules1, - Modules = set__union(Modules0, Modules1) + Modules = set.union(Modules0, Modules1) ; get_module_dependencies(ModuleName, MaybeImports, !Info, !IO), ( @@ -855,7 +855,7 @@ find_transitive_module_dependencies_2(KeepGoing, DependenciesType, ModuleLocn = any_module ; ModuleLocn = local_module, - Imports ^ module_dir = dir__this_directory + Imports ^ module_dir = dir.this_directory ) -> ( @@ -868,7 +868,7 @@ find_transitive_module_dependencies_2(KeepGoing, DependenciesType, ; DependenciesType = all_dependencies, ImportsToCheck = - list__condense([ + list.condense([ Imports ^ int_deps, Imports ^ impl_deps, Imports ^ parent_deps, @@ -883,7 +883,7 @@ find_transitive_module_dependencies_2(KeepGoing, DependenciesType, find_transitive_module_dependencies_2(KeepGoing, DependenciesType, ModuleLocn), ImportsToCheck, Success, - set__insert(Modules0, ModuleName), Modules, + set.insert(Modules0, ModuleName), Modules, !Info, !IO), !:Info = !.Info ^ importing_module := ImportingModule ; @@ -917,21 +917,21 @@ make_local_module_id_option(ModuleName, Opts, io::di, io::uo) is det. check_dependencies_debug_unbuilt(TargetFileName, UnbuiltDependencies, !IO) :- - io__write_string(TargetFileName, !IO), - io__write_string(": dependencies could not be built.\n\t", !IO), - io__write_list(UnbuiltDependencies, ",\n\t", + io.write_string(TargetFileName, !IO), + io.write_string(": dependencies could not be built.\n\t", !IO), + io.write_list(UnbuiltDependencies, ",\n\t", (pred((DepTarget - DepStatus)::in, !.IO::di, !:IO::uo) is det :- write_dependency_file(DepTarget, !IO), - io__write_string(" - ", !IO), - io__write(DepStatus, !IO) + io.write_string(" - ", !IO), + io.write(DepStatus, !IO) ), !IO), - io__nl(!IO). + io.nl(!IO). check_dependencies(TargetFileName, MaybeTimestamp, BuildDepsSucceeded, DepFiles, DepsResult, !Info, !IO) :- - list__map_foldl2(dependency_status, DepFiles, DepStatusList, !Info, !IO), - assoc_list__from_corresponding_lists(DepFiles, DepStatusList, DepStatusAL), - list__filter( + list.map_foldl2(dependency_status, DepFiles, DepStatusList, !Info, !IO), + assoc_list.from_corresponding_lists(DepFiles, DepStatusList, DepStatusAL), + list.filter( (pred((_ - DepStatus)::in) is semidet :- DepStatus \= up_to_date ), DepStatusAL, UnbuiltDependencies), @@ -944,10 +944,10 @@ check_dependencies(TargetFileName, MaybeTimestamp, BuildDepsSucceeded, UnbuiltDependencies = [], debug_msg( (pred(!.IO::di, !:IO::uo) is det :- - io__write_string(TargetFileName, !IO), - io__write_string(": finished dependencies\n", !IO) + io.write_string(TargetFileName, !IO), + io.write_string(": finished dependencies\n", !IO) ), !IO), - list__map_foldl2(get_dependency_timestamp, DepFiles, + list.map_foldl2(get_dependency_timestamp, DepFiles, DepTimestamps, !Info, !IO), check_dependency_timestamps(TargetFileName, MaybeTimestamp, @@ -961,20 +961,20 @@ check_dependencies(TargetFileName, MaybeTimestamp, BuildDepsSucceeded, check_dependencies_timestamps_write_missing_deps(TargetFileName, BuildDepsSucceeded, DepFiles, WriteDepFile, DepTimestamps, !IO) :- - assoc_list__from_corresponding_lists(DepFiles, DepTimestamps, + assoc_list.from_corresponding_lists(DepFiles, DepTimestamps, DepTimestampAL), solutions( (pred(DepFile::out) is nondet :- - list__member(DepFile - error(_), DepTimestampAL) + list.member(DepFile - error(_), DepTimestampAL) ), ErrorDeps), - io__write_string("** dependencies for `", !IO), - io__write_string(TargetFileName, !IO), - io__write_string("' do not exist: ", !IO), - io__write_list(ErrorDeps, ", ", WriteDepFile, !IO), - io__nl(!IO), + io.write_string("** dependencies for `", !IO), + io.write_string(TargetFileName, !IO), + io.write_string("' do not exist: ", !IO), + io.write_list(ErrorDeps, ", ", WriteDepFile, !IO), + io.nl(!IO), ( BuildDepsSucceeded = yes, - io__write_string("** This indicates a bug in `mmc --make'.\n", !IO) + io.write_string("** This indicates a bug in `mmc --make'.\n", !IO) ; BuildDepsSucceeded = no ). @@ -986,14 +986,14 @@ check_dependency_timestamps(TargetFileName, MaybeTimestamp, BuildDepsSucceeded, DepsResult = out_of_date, debug_msg( (pred(!.IO::di, !:IO::uo) is det :- - io__write_string(TargetFileName, !IO), - io__write_string(" does not exist.\n", !IO) + io.write_string(TargetFileName, !IO), + io.write_string(" does not exist.\n", !IO) ), !IO) ; MaybeTimestamp = ok(Timestamp), - globals__io_lookup_bool_option(rebuild, Rebuild, !IO), + globals.io_lookup_bool_option(rebuild, Rebuild, !IO), ( - list__member(MaybeDepTimestamp1, DepTimestamps), + list.member(MaybeDepTimestamp1, DepTimestamps), MaybeDepTimestamp1 = error(_) -> DepsResult = error, @@ -1023,7 +1023,7 @@ check_dependency_timestamps(TargetFileName, MaybeTimestamp, BuildDepsSucceeded, % DepsResult = out_of_date ; - list__member(MaybeDepTimestamp2, DepTimestamps), + list.member(MaybeDepTimestamp2, DepTimestamps), MaybeDepTimestamp2 = ok(DepTimestamp), compare((>), DepTimestamp, Timestamp) -> @@ -1050,13 +1050,13 @@ debug_newer_dependencies(TargetFileName, MaybeTimestamp, debug_newer_dependencies_2(TargetFileName, MaybeTimestamp, DepFiles, WriteDepFile, DepTimestamps, !IO) :- - io__write_string(TargetFileName, !IO), - io__write_string(": newer dependencies: ", !IO), - assoc_list__from_corresponding_lists(DepFiles, DepTimestamps, + io.write_string(TargetFileName, !IO), + io.write_string(": newer dependencies: ", !IO), + assoc_list.from_corresponding_lists(DepFiles, DepTimestamps, DepTimestampAL), solutions( (pred(DepFile::out) is nondet :- - list__member(DepFile - MaybeDepTimestamp, DepTimestampAL), + list.member(DepFile - MaybeDepTimestamp, DepTimestampAL), ( MaybeDepTimestamp = error(_) ; @@ -1065,8 +1065,8 @@ debug_newer_dependencies_2(TargetFileName, MaybeTimestamp, compare((>), DepTimestamp, Timestamp) ) ), NewerDeps), - io__write_list(NewerDeps, ",\n\t", WriteDepFile, !IO), - io__nl(!IO). + io.write_list(NewerDeps, ",\n\t", WriteDepFile, !IO), + io.nl(!IO). dependency_status(file(FileName, _) @ Dep, Status, !Info, !IO) :- ( @@ -1081,11 +1081,11 @@ dependency_status(file(FileName, _) @ Dep, Status, !Info, !IO) :- ; MaybeTimestamp = error(Error), Status = error, - io__write_string("** Error: file `", !IO), - io__write_string(FileName, !IO), - io__write_string("' not found: ", !IO), - io__write_string(Error, !IO), - io__nl(!IO) + io.write_string("** Error: file `", !IO), + io.write_string(FileName, !IO), + io.write_string("' not found: ", !IO), + io.write_string(Error, !IO), + io.nl(!IO) ), !:Info = !.Info ^ dependency_status ^ elem(Dep) := Status ). @@ -1105,7 +1105,7 @@ dependency_status(target(Target) @ Dep, Status, !Info, !IO) :- Status = error ; MaybeImports = yes(Imports), - ( Imports ^ module_dir \= dir__this_directory -> + ( Imports ^ module_dir \= dir.this_directory -> % % Targets from libraries are always considered to be % up-to-date if they exist. @@ -1117,11 +1117,11 @@ dependency_status(target(Target) @ Dep, Status, !Info, !IO) :- ; MaybeTimestamp = error(Error), Status = error, - io__write_string("** Error: file `", !IO), + io.write_string("** Error: file `", !IO), write_target_file(Target, !IO), - io__write_string("' not found: ", !IO), - io__write_string(Error, !IO), - io__nl(!IO) + io.write_string("' not found: ", !IO), + io.write_string(Error, !IO), + io.nl(!IO) ) ; Status = not_considered diff --git a/compiler/make.m b/compiler/make.m index f93b0c288..fa1657324 100644 --- a/compiler/make.m +++ b/compiler/make.m @@ -18,8 +18,8 @@ :- module make. :- interface. -:- include_module make__options_file. -:- include_module make__util. +:- include_module make.options_file. +:- include_module make.util. :- import_module make.options_file. :- import_module mdbcomp. @@ -33,15 +33,14 @@ %-----------------------------------------------------------------------------% - % make__process_args(OptionArgs, NonOptionArgs). + % make.process_args(OptionArgs, NonOptionArgs). % -:- pred make__process_args(options_variables::in, list(string)::in, +:- pred make_process_args(options_variables::in, list(string)::in, list(file_name)::in, io::di, io::uo) is det. -:- pred make__write_module_dep_file(module_imports::in, - io::di, io::uo) is det. +:- pred make_write_module_dep_file(module_imports::in, io::di, io::uo) is det. -:- func make__module_dep_file_extension = string. +:- func make_module_dep_file_extension = string. :- type make_info. @@ -50,10 +49,10 @@ :- implementation. -:- include_module make__dependencies. -:- include_module make__module_dep_file. -:- include_module make__module_target. -:- include_module make__program_target. +:- include_module make.dependencies. +:- include_module make.module_dep_file. +:- include_module make.module_target. +:- include_module make.program_target. :- import_module hlds. :- import_module libs. @@ -97,59 +96,61 @@ %-----------------------------------------------------------------------------% -:- type make_info ---> - make_info( - % The items field of each module_imports structure should be empty - % -- we're not trying to cache the items here. - module_dependencies :: map(module_name, maybe(module_imports)), +:- type make_info + ---> make_info( + % The items field of each module_imports structure should be + % empty -- we're not trying to cache the items here. + module_dependencies :: map(module_name, + maybe(module_imports)), - file_timestamps :: file_timestamps, + file_timestamps :: file_timestamps, - % The original set of options passed to mmc, not including - % the targets to be made. - option_args :: list(string), + % The original set of options passed to mmc, not including + % the targets to be made. + option_args :: list(string), - % The contents of the Mercury.options file. - options_variables :: options_variables, + % The contents of the Mercury.options file. + options_variables :: options_variables, - dependency_status :: map(dependency_file, dependency_status), + dependency_status :: map(dependency_file, + dependency_status), - % For each module, the set of modules for - % which the `.int' files are read, excluding - % those read as a result of reading `.opt' files. - % The bool records whether there was an error - % in the dependencies. - % XXX Use a better representation for the sets. - cached_direct_imports :: cached_direct_imports, + % For each module, the set of modules for which the `.int' + % files are read, excluding those read as a result of reading + % `.opt' files. The bool records whether there was an error + % in the dependencies. + % XXX Use a better representation for the sets. + cached_direct_imports :: cached_direct_imports, - % The boolean is `yes' if the result is complete. - % XXX Use a better representation for the sets. - cached_transitive_dependencies :: cached_transitive_dependencies, + % The boolean is `yes' if the result is complete. + % XXX Use a better representation for the sets. + cached_transitive_dependencies + :: cached_transitive_dependencies, - % Should the `.module_dep' files be rebuilt. - % Set to `no' for `mmc --make clean'. - rebuild_dependencies :: bool, + % Should the `.module_dep' files be rebuilt. + % Set to `no' for `mmc --make clean'. + rebuild_dependencies :: bool, - keep_going :: bool, + keep_going :: bool, - % Modules for which we have redirected output - % to a `.err' file during this invocation of mmc. - error_file_modules :: set(module_name), + % Modules for which we have redirected output + % to a `.err' file during this invocation of mmc. + error_file_modules :: set(module_name), - % Used for reporting which module imported - % a nonexistent module. - importing_module :: maybe(module_name), + % Used for reporting which module imported a nonexistent + % module. + importing_module :: maybe(module_name), - % Targets specified on the command line. - command_line_targets :: set(pair(module_name, target_type)), + % Targets specified on the command line. + command_line_targets :: set(pair(module_name, target_type)), - % The remaining number of analysis passes that we will allow on - % `suboptimal' modules. It starts at the value of `--analysis-repeat' - % and decrements to zero as analysis passes on `suboptimal' modules are - % performed. `invalid' modules are not affected as they will always be - % reanalysed. - reanalysis_passes :: int - ). + % The remaining number of analysis passes that we will allow on + % `suboptimal' modules. It starts at the value of + % `--analysis-repeat' and decrements to zero as analysis passes + % on `suboptimal' modules are performed. `invalid' modules + % are not affected as they will always be reanalysed. + reanalysis_passes :: int + ). :- type make_error ---> target_error(target_file) @@ -223,12 +224,12 @@ %-----------------------------------------------------------------------------% -make__write_module_dep_file(Imports, !IO) :- - make__module_dep_file__write_module_dep_file(Imports, !IO). +make_write_module_dep_file(Imports, !IO) :- + make.module_dep_file.write_module_dep_file(Imports, !IO). -make__module_dep_file_extension = ".module_dep". +make_module_dep_file_extension = ".module_dep". -make__process_args(Variables, OptionArgs, Targets0, !IO) :- +make_process_args(Variables, OptionArgs, Targets0, !IO) :- ( Targets0 = [], lookup_main_target(Variables, MaybeMAIN_TARGET, !IO), @@ -240,7 +241,7 @@ make__process_args(Variables, OptionArgs, Targets0, !IO) :- ; Targets = [], Continue = no, - io__write_string("** Error: no targets specified " ++ + io.write_string("** Error: no targets specified " ++ "and `MAIN_TARGET' not defined.\n", !IO) ) ; @@ -255,11 +256,11 @@ make__process_args(Variables, OptionArgs, Targets0, !IO) :- ), ( Continue = no, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; Continue = yes, - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_get_globals(Globals, !IO), % % Accept and ignore `.depend' targets. @@ -267,25 +268,25 @@ make__process_args(Variables, OptionArgs, Targets0, !IO) :- % make depend step. The dependencies for % each module are regenerated on demand. % - NonDependTargets = list__filter( + NonDependTargets = list.filter( (pred(Target::in) is semidet :- - \+ string__remove_suffix(Target, ".depend", _) + \+ string.remove_suffix(Target, ".depend", _) ), Targets), % % Classify the remaining targets. % - list__map(classify_target(Globals), NonDependTargets, + list.map(classify_target(Globals), NonDependTargets, ClassifiedTargets), ShouldRebuildDeps = yes, - globals__io_lookup_int_option(analysis_repeat, AnalysisRepeat, !IO), - MakeInfo0 = make_info(map__init, map__init, OptionArgs, Variables, - map__init, + globals.io_lookup_int_option(analysis_repeat, AnalysisRepeat, !IO), + MakeInfo0 = make_info(map.init, map.init, OptionArgs, Variables, + map.init, init_cached_direct_imports, init_cached_transitive_dependencies, ShouldRebuildDeps, KeepGoing, - set__init, no, set__list_to_set(ClassifiedTargets), + set.init, no, set.list_to_set(ClassifiedTargets), AnalysisRepeat), % @@ -297,7 +298,7 @@ make__process_args(Variables, OptionArgs, Targets0, !IO) :- ( Success = no, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; Success = yes ) @@ -333,16 +334,16 @@ make_target(Target, Success, !Info, !IO) :- classify_target(Globals, FileName, ModuleName - TargetType) :- ( - string__length(FileName, NameLength), + string.length(FileName, NameLength), search_backwards_for_dot(FileName, NameLength - 1, DotLocn), - string__split(FileName, DotLocn, ModuleNameStr0, Suffix), + string.split(FileName, DotLocn, ModuleNameStr0, Suffix), solutions(classify_target_2(Globals, ModuleNameStr0, Suffix), TargetFiles), TargetFiles = [TargetFile] -> TargetFile = ModuleName - TargetType ; - string__append("lib", ModuleNameStr, FileName) + string.append("lib", ModuleNameStr, FileName) -> TargetType = misc_target(build_library), file_name_to_module_name(ModuleNameStr, ModuleName) @@ -361,26 +362,26 @@ classify_target_2(Globals, ModuleNameStr0, Suffix, ModuleName - TargetType) :- ModuleNameStr = ModuleNameStr0, TargetType = module_target(ModuleTargetType) ; - globals__lookup_string_option(Globals, library_extension, Suffix), - string__append("lib", ModuleNameStr1, ModuleNameStr0) + globals.lookup_string_option(Globals, library_extension, Suffix), + string.append("lib", ModuleNameStr1, ModuleNameStr0) -> ModuleNameStr = ModuleNameStr1, TargetType = linked_target(static_library) ; - globals__lookup_string_option(Globals, shared_library_extension, + globals.lookup_string_option(Globals, shared_library_extension, Suffix), - string__append("lib", ModuleNameStr1, ModuleNameStr0) + string.append("lib", ModuleNameStr1, ModuleNameStr0) -> ModuleNameStr = ModuleNameStr1, TargetType = linked_target(shared_library) ; - globals__lookup_string_option(Globals, executable_file_extension, + globals.lookup_string_option(Globals, executable_file_extension, Suffix) -> ModuleNameStr = ModuleNameStr0, TargetType = linked_target(executable) ; - string__append(Suffix1, "s", Suffix), + string.append(Suffix1, "s", Suffix), yes(Suffix1) = target_extension(Globals, ModuleTargetType), % Not yet implemented. `build_all' targets are only used by % tools/bootcheck, so it doesn't really matter. @@ -410,7 +411,7 @@ classify_target_2(Globals, ModuleNameStr0, Suffix, ModuleName - TargetType) :- TargetType = misc_target(realclean) ; Suffix = ".install", - string__append("lib", ModuleNameStr1, ModuleNameStr0) + string.append("lib", ModuleNameStr1, ModuleNameStr0) -> ModuleNameStr = ModuleNameStr1, TargetType = misc_target(install_library) @@ -423,7 +424,7 @@ classify_target_2(Globals, ModuleNameStr0, Suffix, ModuleName - TargetType) :- search_backwards_for_dot(String, Index, DotIndex) :- Index >= 0, - ( string__index_det(String, Index, '.') -> + ( string.index_det(String, Index, '.') -> DotIndex = Index ; search_backwards_for_dot(String, Index - 1, DotIndex) diff --git a/compiler/make.module_dep_file.m b/compiler/make.module_dep_file.m index 66a45e068..3ff5a3fab 100644 --- a/compiler/make.module_dep_file.m +++ b/compiler/make.module_dep_file.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module make__module_dep_file. +:- module make.module_dep_file. :- interface. :- import_module parse_tree.modules. @@ -48,7 +48,7 @@ get_module_dependencies(ModuleName, MaybeImports, !Info, !IO) :- ( ModuleName = unqualified(_) -> maybe_get_module_dependencies(RebuildDeps, ModuleName, MaybeImports, !Info, !IO) - ; map__search(!.Info ^ module_dependencies, ModuleName, MaybeImports0) -> + ; map.search(!.Info ^ module_dependencies, ModuleName, MaybeImports0) -> MaybeImports = MaybeImports0 ; % @@ -60,7 +60,7 @@ get_module_dependencies(ModuleName, MaybeImports, !Info, !IO) :- % dependencies. % Ancestors = get_ancestors(ModuleName), - list__foldl3(generate_ancestor_dependencies(RebuildDeps), + list.foldl3(generate_ancestor_dependencies(RebuildDeps), Ancestors, no, Error, !Info, !IO), ( Error = yes, @@ -98,7 +98,7 @@ generate_ancestor_dependencies(RebuildDeps, ModuleName, no, Error, maybe_get_module_dependencies(RebuildDeps, ModuleName, MaybeImports, !Info, !IO) :- - ( map__search(!.Info ^ module_dependencies, ModuleName, MaybeImports0) -> + ( map.search(!.Info ^ module_dependencies, ModuleName, MaybeImports0) -> MaybeImports = MaybeImports0 ; do_get_module_dependencies(RebuildDeps, ModuleName, @@ -118,13 +118,12 @@ do_get_module_dependencies(RebuildDeps, ModuleName, !:MaybeImports, !Info, % will fail if the module name doesn't match the file name, but % that case is handled below. module_name_to_file_name(ModuleName, ".m", no, SourceFileName, !IO), - get_file_timestamp([dir__this_directory], SourceFileName, + get_file_timestamp([dir.this_directory], SourceFileName, MaybeSourceFileTimestamp, !Info, !IO), - module_name_to_file_name(ModuleName, module_dep_file_extension, no, - DepFileName, !IO), - globals__io_lookup_accumulating_option(search_directories, SearchDirs, - !IO), + module_name_to_file_name(ModuleName, make_module_dep_file_extension, + no, DepFileName, !IO), + globals.io_lookup_accumulating_option(search_directories, SearchDirs, !IO), get_file_timestamp(SearchDirs, DepFileName, MaybeDepFileTimestamp, !Info, !IO), ( @@ -151,13 +150,13 @@ do_get_module_dependencies(RebuildDeps, ModuleName, !:MaybeImports, !Info, % the module dependency file, then check whether the % module dependency file is up to date. % - map__lookup(!.Info ^ module_dependencies, ModuleName, !:MaybeImports), + map.lookup(!.Info ^ module_dependencies, ModuleName, !:MaybeImports), ( !.MaybeImports = yes(Imports0), - Imports0 ^ module_dir = dir__this_directory + Imports0 ^ module_dir = dir.this_directory -> SourceFileName1 = Imports0 ^ source_file_name, - get_file_timestamp([dir__this_directory], SourceFileName1, + get_file_timestamp([dir.this_directory], SourceFileName1, MaybeSourceFileTimestamp1, !Info, !IO), ( MaybeSourceFileTimestamp1 = ok(SourceFileTimestamp1), @@ -172,11 +171,11 @@ do_get_module_dependencies(RebuildDeps, ModuleName, !:MaybeImports, !Info, ) ; MaybeSourceFileTimestamp1 = error(Message), - io__write_string("** Error reading file `", !IO), - io__write_string(SourceFileName1, !IO), - io__write_string("' to generate dependencies: ", !IO), - io__write_string(Message, !IO), - io__write_string(".\n", !IO), + io.write_string("** Error reading file `", !IO), + io.write_string(SourceFileName1, !IO), + io.write_string("' to generate dependencies: ", !IO), + io.write_string(Message, !IO), + io.write_string(".\n", !IO), maybe_write_importing_module(ModuleName, !.Info ^ importing_module, !IO) ) @@ -216,7 +215,7 @@ module_dependencies_version_number = 1. write_module_dep_file(Imports0, !IO) :- % Make sure all the required fields are filled in. - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), strip_imported_items(Imports0 ^ items, Items), init_dependencies(Imports0 ^ source_file_name, Imports0 ^ source_file_module_name, @@ -228,88 +227,88 @@ write_module_dep_file(Imports0, !IO) :- do_write_module_dep_file(Imports, !IO) :- ModuleName = Imports ^ module_name, - module_name_to_file_name(ModuleName, module_dep_file_extension, + module_name_to_file_name(ModuleName, make_module_dep_file_extension, yes, ProgDepFile, !IO), - io__open_output(ProgDepFile, ProgDepResult, !IO), + io.open_output(ProgDepFile, ProgDepResult, !IO), ( ProgDepResult = ok(ProgDepStream), - io__set_output_stream(ProgDepStream, OldOutputStream, !IO), - io__write_string("module(", !IO), - io__write_int(module_dependencies_version_number, !IO), - io__write_string(", """, !IO), - io__write_string(Imports ^ source_file_name, !IO), - io__write_string(""",\n\t", !IO), + io.set_output_stream(ProgDepStream, OldOutputStream, !IO), + io.write_string("module(", !IO), + io.write_int(module_dependencies_version_number, !IO), + io.write_string(", """, !IO), + io.write_string(Imports ^ source_file_name, !IO), + io.write_string(""",\n\t", !IO), mercury_output_bracketed_sym_name( Imports ^ source_file_module_name, !IO), - io__write_string(",\n\t{", !IO), - io__write_list(Imports ^ parent_deps, + io.write_string(",\n\t{", !IO), + io.write_list(Imports ^ parent_deps, ", ", mercury_output_bracketed_sym_name, !IO), - io__write_string("},\n\t{", !IO), - io__write_list(Imports ^ int_deps, + io.write_string("},\n\t{", !IO), + io.write_list(Imports ^ int_deps, ", ", mercury_output_bracketed_sym_name, !IO), - io__write_string("},\n\t{", !IO), - io__write_list(Imports ^ impl_deps, + io.write_string("},\n\t{", !IO), + io.write_list(Imports ^ impl_deps, ", ", mercury_output_bracketed_sym_name, !IO), - io__write_string("},\n\t{", !IO), - io__write_list(Imports ^ children, + io.write_string("},\n\t{", !IO), + io.write_list(Imports ^ children, ", ", mercury_output_bracketed_sym_name, !IO), - io__write_string("},\n\t{", !IO), - io__write_list(Imports ^ nested_children, + io.write_string("},\n\t{", !IO), + io.write_list(Imports ^ nested_children, ", ", mercury_output_bracketed_sym_name, !IO), - io__write_string("},\n\t{", !IO), - io__write_list(Imports ^ fact_table_deps, - ", ", io__write, !IO), - io__write_string("},\n\t{", !IO), + io.write_string("},\n\t{", !IO), + io.write_list(Imports ^ fact_table_deps, + ", ", io.write, !IO), + io.write_string("},\n\t{", !IO), ( Imports ^ foreign_code = contains_foreign_code(ForeignLanguages0) -> - ForeignLanguages = set__to_sorted_list(ForeignLanguages0) + ForeignLanguages = set.to_sorted_list(ForeignLanguages0) ; ForeignLanguages = [] ), - io__write_list(ForeignLanguages, ", ", + io.write_list(ForeignLanguages, ", ", mercury_output_foreign_language_string, !IO), - io__write_string("},\n\t{", !IO), - io__write_list(Imports ^ foreign_import_module_info, ", ", + io.write_string("},\n\t{", !IO), + io.write_list(Imports ^ foreign_import_module_info, ", ", (pred(ForeignImportModule::in, di, uo) is det --> { ForeignImportModule = foreign_import_module(Lang, ForeignImport, _) }, mercury_output_foreign_language_string(Lang), - io__write_string(" - "), + io.write_string(" - "), mercury_output_bracketed_sym_name(ForeignImport) ), !IO), - io__write_string("},\n\t", !IO), - io__write(Imports ^ contains_foreign_export, !IO), - io__write_string(",\n\t", !IO), - io__write(Imports ^ has_main, !IO), - io__write_string("\n).\n", !IO), - io__set_output_stream(OldOutputStream, _, !IO), - io__close_output(ProgDepStream, !IO) + io.write_string("},\n\t", !IO), + io.write(Imports ^ contains_foreign_export, !IO), + io.write_string(",\n\t", !IO), + io.write(Imports ^ has_main, !IO), + io.write_string("\n).\n", !IO), + io.set_output_stream(OldOutputStream, _, !IO), + io.close_output(ProgDepStream, !IO) ; ProgDepResult = error(Error), - io__error_message(Error, Msg), - io__write_strings(["Error opening ", ProgDepFile, + io.error_message(Error, Msg), + io.write_strings(["Error opening ", ProgDepFile, " for output: ", Msg, "\n"], !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). :- pred read_module_dependencies(bool::in, module_name::in, make_info::in, make_info::out, io::di, io::uo) is det. read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO) :- - module_name_to_search_file_name(ModuleName, module_dep_file_extension, + module_name_to_search_file_name(ModuleName, make_module_dep_file_extension, ModuleDepFile, !IO), - globals__io_lookup_accumulating_option(search_directories, SearchDirs, + globals.io_lookup_accumulating_option(search_directories, SearchDirs, !IO), - io__input_stream(OldInputStream, !IO), + io.input_stream(OldInputStream, !IO), search_for_file_returning_dir(SearchDirs, ModuleDepFile, SearchResult, !IO), ( SearchResult = ok(ModuleDir), - parser__read_term(ImportsTermResult, !IO), - io__set_input_stream(OldInputStream, ModuleDepStream, !IO), - io__close_input(ModuleDepStream, !IO), + parser.read_term(ImportsTermResult, !IO), + io.set_input_stream(OldInputStream, ModuleDepStream, !IO), + io.close_input(ModuleDepStream, !IO), ( ImportsTermResult = term(_, ImportsTerm), - ImportsTerm = term__functor(term__atom("module"), ModuleArgs, _), + ImportsTerm = term.functor(term.atom("module"), ModuleArgs, _), ModuleArgs = [ VersionNumberTerm, SourceFileTerm, @@ -325,10 +324,10 @@ read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO) :- ContainsForeignExportTerm, HasMainTerm ], - VersionNumberTerm = term__functor( - term__integer(module_dependencies_version_number), [], _), - SourceFileTerm = term__functor( - term__string(SourceFileName), [], _), + VersionNumberTerm = term.functor( + term.integer(module_dependencies_version_number), [], _), + SourceFileTerm = term.functor( + term.string(SourceFileName), [], _), sym_name_and_args(SourceFileModuleNameTerm, SourceFileModuleName, []), parse_sym_name_list(ParentsTerm, Parents), @@ -336,39 +335,38 @@ read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO) :- parse_sym_name_list(ImplDepsTerm, ImplDeps), parse_sym_name_list(ChildrenTerm, Children), parse_sym_name_list(NestedChildrenTerm, NestedChildren), - FactDepsTerm = term__functor(term__atom("{}"), FactDepsStrings, _), - list__map( + FactDepsTerm = term.functor(term.atom("{}"), FactDepsStrings, _), + list.map( (pred(StringTerm::in, String::out) is semidet :- - StringTerm = term__functor( - term__string(String), [], _) + StringTerm = term.functor(term.string(String), [], _) ), FactDepsStrings, FactDeps), - ForeignLanguagesTerm = term__functor( - term__atom("{}"), ForeignLanguagesTerms, _), - list__map( + ForeignLanguagesTerm = term.functor( + term.atom("{}"), ForeignLanguagesTerms, _), + list.map( (pred(LanguageTerm::in, Language::out) is semidet :- - LanguageTerm = term__functor( - term__string(LanguageString), [], _), - globals__convert_foreign_language(LanguageString, Language) + LanguageTerm = term.functor( + term.string(LanguageString), [], _), + globals.convert_foreign_language(LanguageString, Language) ), ForeignLanguagesTerms, ForeignLanguages), - ForeignImportsTerm = term__functor(term__atom("{}"), + ForeignImportsTerm = term.functor(term.atom("{}"), ForeignImportTerms, _), - list__map( + list.map( (pred(ForeignImportTerm::in, ForeignImportModule::out) is semidet :- - ForeignImportTerm = term__functor(term__atom("-"), + ForeignImportTerm = term.functor(term.atom("-"), [LanguageTerm, ImportedModuleTerm], _), - LanguageTerm = term__functor( - term__string(LanguageString), [], _), - globals__convert_foreign_language(LanguageString, + LanguageTerm = term.functor( + term.string(LanguageString), [], _), + globals.convert_foreign_language(LanguageString, Language), sym_name_and_args(ImportedModuleTerm, ImportedModuleName, []), ForeignImportModule = foreign_import_module(Language, - ImportedModuleName, term__context_init) + ImportedModuleName, term.context_init) ), ForeignImportTerms, ForeignImports), ContainsForeignExportTerm = - term__functor(term__atom(ContainsForeignExportStr), [], _), + term.functor(term.atom(ContainsForeignExportStr), [], _), ( ContainsForeignExportStr = "contains_foreign_export", ContainsForeignExport = contains_foreign_export @@ -377,7 +375,7 @@ read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO) :- ContainsForeignExport = no_foreign_export ), - HasMainTerm = term__functor(term__atom(HasMainStr), [], _), + HasMainTerm = term.functor(term.atom(HasMainStr), [], _), ( HasMainStr = "has_main", HasMain = has_main ; HasMainStr = "no_main", HasMain = no_main ) @@ -388,7 +386,7 @@ read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO) :- ; ForeignLanguages = [_ | _], ContainsForeignCode = contains_foreign_code( - set__list_to_set(ForeignLanguages)) + set.list_to_set(ForeignLanguages)) ), % Imports = module_imports(^...), @@ -424,12 +422,12 @@ read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO) :- % the top-level module in the source file). % SubRebuildDeps = no, - list__foldl2(read_module_dependencies(SubRebuildDeps), + list.foldl2(read_module_dependencies(SubRebuildDeps), NestedChildren, !Info, !IO), ( - list__member(NestedChild, NestedChildren), + list.member(NestedChild, NestedChildren), ( - map__search(!.Info ^ module_dependencies, + map.search(!.Info ^ module_dependencies, NestedChild, ChildImports) -> ChildImports = no @@ -470,18 +468,18 @@ read_module_dependencies_remake(RebuildDeps, ModuleName, Msg, !Info, !IO) :- io::di, io::uo) is det. read_module_dependencies_remake_msg(ModuleName, Msg, !IO) :- - module_name_to_file_name(ModuleName, module_dep_file_extension, no, - ModuleDepsFile, !IO), - io__write_string("Error reading file `", !IO), - io__write_string(ModuleDepsFile, !IO), - io__write_string("rebuilding: ", !IO), - io__write_string(Msg, !IO), - io__nl(!IO). + module_name_to_file_name(ModuleName, make_module_dep_file_extension, + no, ModuleDepsFile, !IO), + io.write_string("Error reading file `", !IO), + io.write_string(ModuleDepsFile, !IO), + io.write_string("rebuilding: ", !IO), + io.write_string(Msg, !IO), + io.nl(!IO). :- pred parse_sym_name_list(term::in, list(sym_name)::out) is semidet. -parse_sym_name_list(term__functor(term__atom("{}"), Args, _), SymNames) :- - list__map( +parse_sym_name_list(term.functor(term.atom("{}"), Args, _), SymNames) :- + list.map( (pred(Arg::in, SymName::out) is semidet :- sym_name_and_args(Arg, SymName, []) ), Args, SymNames). @@ -500,43 +498,43 @@ make_module_dependencies(ModuleName, !Info, !IO) :- redirect_output(ModuleName, MaybeErrorStream, !Info, !IO), ( MaybeErrorStream = yes(ErrorStream), - io__set_output_stream(ErrorStream, OldOutputStream, !IO), + io.set_output_stream(ErrorStream, OldOutputStream, !IO), read_mod(ModuleName, ".m", "Getting dependencies for module", Search, ReturnTimestamp, Items, Error, SourceFileName, _, !IO), ( Error = fatal_module_errors -> - io__set_output_stream(OldOutputStream, _, !IO), - io__write_string("** Error: error reading file `", !IO), - io__write_string(SourceFileName, !IO), - io__write_string("' to generate dependencies.\n", !IO), + io.set_output_stream(OldOutputStream, _, !IO), + io.write_string("** Error: error reading file `", !IO), + io.write_string(SourceFileName, !IO), + io.write_string("' to generate dependencies.\n", !IO), maybe_write_importing_module(ModuleName, !.Info ^ importing_module, !IO), % Display the contents of the `.err' file, then remove it % so we don't leave `.err' files lying around for nonexistent % modules. - globals__io_lookup_int_option(output_compile_error_lines, Lines, + globals.io_lookup_int_option(output_compile_error_lines, Lines, !IO), - globals__io_set_option(output_compile_error_lines, int(10000), + globals.io_set_option(output_compile_error_lines, int(10000), !IO), unredirect_output(ModuleName, ErrorStream, !Info, !IO), - globals__io_set_option(output_compile_error_lines, int(Lines), + globals.io_set_option(output_compile_error_lines, int(Lines), !IO), + module_name_to_file_name(ModuleName, ".err", no, ErrFileName, !IO), - module_name_to_file_name(ModuleName, ".err", no, ErrFileName, !IO), - io__remove_file(ErrFileName, _, !IO), + io.remove_file(ErrFileName, _, !IO), !:Info = !.Info ^ module_dependencies ^ elem(ModuleName) := no ; - io__set_exit_status(0, !IO), - io__set_output_stream(ErrorStream, _, !IO), + io.set_exit_status(0, !IO), + io.set_output_stream(ErrorStream, _, !IO), split_into_submodules(ModuleName, Items, SubModuleList, !IO), - io__set_output_stream(OldOutputStream, _, !IO), + io.set_output_stream(OldOutputStream, _, !IO), - globals__io_get_globals(Globals, !IO), - assoc_list__keys(SubModuleList, SubModuleNames), - list__map(init_dependencies(SourceFileName, ModuleName, + globals.io_get_globals(Globals, !IO), + assoc_list.keys(SubModuleList, SubModuleNames), + list.map(init_dependencies(SourceFileName, ModuleName, SubModuleNames, Error, Globals), SubModuleList, ModuleImportList), - list__foldl( + list.foldl( (pred(ModuleImports::in, Info0::in, Info::out) is det :- SubModuleName = ModuleImports ^ module_name, Info = Info0 ^ module_dependencies ^ elem(SubModuleName) @@ -564,9 +562,8 @@ make_module_dependencies(ModuleName, !Info, !IO) :- ), build_with_check_for_interrupt( - (pred(yes::out, MakeInfo::in, MakeInfo::out, di, uo) - is det --> - list__foldl(do_write_module_dep_file, + (pred(yes::out, MakeInfo::in, MakeInfo::out, di, uo) is det --> + list.foldl(do_write_module_dep_file, ModuleImportList) ), cleanup_module_dep_files(SubModuleNames), _, !Info, !IO), @@ -578,31 +575,31 @@ make_module_dependencies(ModuleName, !Info, !IO) :- MaybeErrorStream = no ). -:- pred make_short_interfaces(io__output_stream::in, file_name::in, +:- pred make_short_interfaces(io.output_stream::in, file_name::in, assoc_list(module_name, item_list)::in, list(string)::in, bool::out, make_info::in, make_info::out, io::di, io::uo) is det. make_short_interfaces(ErrorStream, SourceFileName, SubModuleList, _, Succeeded, !Info, !IO) :- - io__set_output_stream(ErrorStream, OutputStream, !IO), - list__foldl( + io.set_output_stream(ErrorStream, OutputStream, !IO), + list.foldl( (pred(SubModule::in, !.IO::di, !:IO::uo) is det :- SubModule = SubModuleName - SubModuleItems, - modules__make_short_interface(SourceFileName, + modules.make_short_interface(SourceFileName, SubModuleName, SubModuleItems, !IO) ), SubModuleList, !IO), - io__set_output_stream(OutputStream, _, !IO), - io__get_exit_status(ExitStatus, !IO), + io.set_output_stream(OutputStream, _, !IO), + io.get_exit_status(ExitStatus, !IO), Succeeded = ( ExitStatus = 0 -> yes ; no ). :- pred cleanup_short_interfaces(list(module_name)::in, make_info::in, make_info::out, io::di, io::uo) is det. cleanup_short_interfaces(SubModuleNames, !Info, !IO) :- - list__foldl2( + list.foldl2( (pred(SubModuleName::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo) is det :- - remove_target_file(SubModuleName, unqualified_short_interface, + make_remove_target_file(SubModuleName, unqualified_short_interface, !Info, !IO) ), SubModuleNames, !Info, !IO). @@ -610,10 +607,10 @@ cleanup_short_interfaces(SubModuleNames, !Info, !IO) :- make_info::in, make_info::out, io::di, io::uo) is det. cleanup_module_dep_files(SubModuleNames, !Info, !IO) :- - list__foldl2( + list.foldl2( (pred(SubModuleName::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo) is det :- - remove_file(SubModuleName, module_dep_file_extension, + make_remove_file(SubModuleName, make_module_dep_file_extension, !Info, !IO) ), SubModuleNames, !Info, !IO). @@ -622,11 +619,11 @@ cleanup_module_dep_files(SubModuleNames, !Info, !IO) :- maybe_write_importing_module(_, no, !IO). maybe_write_importing_module(ModuleName, yes(ImportingModuleName), !IO) :- - io__write_string("** Module `", !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string("' is imported or included by module `", !IO), - prog_out__write_sym_name(ImportingModuleName, !IO), - io__write_string("'.\n", !IO). + io.write_string("** Module `", !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string("' is imported or included by module `", !IO), + prog_out.write_sym_name(ImportingModuleName, !IO), + io.write_string("'.\n", !IO). %-----------------------------------------------------------------------------% :- end_module make.module_dep_file. diff --git a/compiler/make.module_target.m b/compiler/make.module_target.m index 30684fd6c..e6ee797e6 100644 --- a/compiler/make.module_target.m +++ b/compiler/make.module_target.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module make__module_target. +:- module make.module_target. :- interface. %-----------------------------------------------------------------------------% @@ -40,7 +40,7 @@ % Record whether building a target succeeded or not. % Makes sure any timestamps for files which may have changed % in building the target are recomputed next time they are needed. - % Exported for use by make__module_dep_file__write_module_dep_file. + % Exported for use by make.module_dep_file.write_module_dep_file. % :- pred record_made_target(target_file::in, compilation_task_type::in, bool::in, make_info::in, make_info::out, io::di, io::uo) is det. @@ -104,7 +104,7 @@ make_module_target_extra_options(ExtraOptions, target(TargetFile) @ Dep, !:Info = !.Info ^ dependency_status ^ elem(Dep) := error ; MaybeImports = yes(Imports), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), CompilationTask = compilation_task(Globals, FileType), ( % For a target built by processing a Mercury source file, @@ -121,7 +121,7 @@ make_module_target_extra_options(ExtraOptions, target(TargetFile) @ Dep, CompilationTask = CompilationTaskType - _, touched_files(TargetFile, CompilationTaskType, TouchedTargetFiles, TouchedFiles, !Info, !IO), - list__foldl(update_target_status(being_built), + list.foldl(update_target_status(being_built), TouchedTargetFiles, !Info), debug_file_msg(TargetFile, "checking dependencies", !IO), @@ -134,31 +134,31 @@ make_module_target_extra_options(ExtraOptions, target(TargetFile) @ Dep, foldl3_maybe_stop_at_error(!.Info ^ keep_going, union_deps(target_dependencies(Globals, FileType)), - ModulesToCheck, DepsSuccess, set__init, DepFiles0, + ModulesToCheck, DepsSuccess, set.init, DepFiles0, !Info, !IO), ( TargetFile = _ - private_interface -> % Avoid circular dependencies (the `.int0' files % for the nested sub-modules depend on this module's % `.int0' file). - DepFilesToMake = set__to_sorted_list( - set__delete_list(DepFiles0, + DepFilesToMake = set.to_sorted_list( + set.delete_list(DepFiles0, make_dependency_list(ModulesToCheck, private_interface))) ; - DepFilesToMake = set__to_sorted_list(DepFiles0) + DepFilesToMake = set.to_sorted_list(DepFiles0) ), - DepFiles = set__to_sorted_list(DepFiles0), + DepFiles = set.to_sorted_list(DepFiles0), debug_msg( (pred(!.IO::di, !:IO::uo) is det :- write_target_file(TargetFile, !IO), - io__write_string(": dependencies:\n", !IO), - io__write_list(DepFiles, ", ", write_dependency_file, + io.write_string(": dependencies:\n", !IO), + io.write_list(DepFiles, ", ", write_dependency_file, !IO), - io__nl(!IO) + io.nl(!IO) ), !IO), - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), ( DepsSuccess = no, KeepGoing = no @@ -173,12 +173,12 @@ make_module_target_extra_options(ExtraOptions, target(TargetFile) @ Dep, ( DepsResult = error, Succeeded = no, - list__foldl(update_target_status(error), + list.foldl(update_target_status(error), TouchedTargetFiles, !Info) ; DepsResult = out_of_date, !:Info = !.Info ^ command_line_targets := - set__delete(!.Info ^ command_line_targets, + set.delete(!.Info ^ command_line_targets, ModuleName - module_target(FileType)), build_target(CompilationTask, TargetFile, Imports, TouchedTargetFiles, TouchedFiles, ExtraOptions, @@ -189,7 +189,7 @@ make_module_target_extra_options(ExtraOptions, target(TargetFile) @ Dep, ModuleName - module_target(FileType), !Info, !IO), debug_file_msg(TargetFile, "up to date", !IO), Succeeded = yes, - list__foldl(update_target_status(up_to_date), + list.foldl(update_target_status(up_to_date), [TargetFile | TouchedTargetFiles], !Info) ) @@ -201,14 +201,14 @@ make_module_target_extra_options(ExtraOptions, target(TargetFile) @ Dep, ; Status = being_built, ( TargetFile = _FileName - foreign_il_asm(_Lang) -> - io__write_string("Error: circular dependency detected " ++ + io.write_string("Error: circular dependency detected " ++ "while building\n", !IO), - io__write_string(" `", !IO), + io.write_string(" `", !IO), write_dependency_file(Dep, !IO), - io__write_string("'.\n", !IO), - io__write_string(" This is due to a forbidden " ++ + io.write_string("'.\n", !IO), + io.write_string(" This is due to a forbidden " ++ "foreign_import_module cycle.\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; unexpected(this_file, "make_module_target: " ++ "target being built, circular dependencies?") @@ -228,14 +228,14 @@ make_dependency_files(TargetFile, DepFilesToMake, TouchedTargetFiles, % % Build the dependencies. % - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), foldl2_maybe_stop_at_error(KeepGoing, make_module_target, DepFilesToMake, MakeDepsSuccess, !Info, !IO), % % Check that the target files exist. % - list__map_foldl2(get_target_timestamp(no), TouchedTargetFiles, + list.map_foldl2(get_target_timestamp(no), TouchedTargetFiles, TargetTimestamps, !Info, !IO), ( MakeDepsSuccess = no @@ -243,7 +243,7 @@ make_dependency_files(TargetFile, DepFilesToMake, TouchedTargetFiles, debug_file_msg(TargetFile, "error making dependencies", !IO), DepsResult = error ; - list__member(error(_), TargetTimestamps) + list.member(error(_), TargetTimestamps) -> debug_file_msg(TargetFile, "target file does not exist", !IO), DepsResult = out_of_date @@ -263,13 +263,13 @@ make_dependency_files(TargetFile, DepFilesToMake, TouchedTargetFiles, % Compare the oldest of the timestamps of the touched % files with the timestamps of the dependencies. % - list__map_foldl2(get_timestamp_file_timestamp, + list.map_foldl2(get_timestamp_file_timestamp, TouchedTargetFiles, TouchedTargetFileTimestamps, !Info, !IO), - list__map_foldl2(get_file_timestamp([dir__this_directory]), + list.map_foldl2(get_file_timestamp([dir.this_directory]), TouchedFiles, TouchedFileTimestamps, !Info, !IO), - MaybeOldestTimestamp0 = list__foldl(find_oldest_timestamp, + MaybeOldestTimestamp0 = list.foldl(find_oldest_timestamp, TouchedTargetFileTimestamps, ok(newest_timestamp)), - MaybeOldestTimestamp = list__foldl(find_oldest_timestamp, + MaybeOldestTimestamp = list.foldl(find_oldest_timestamp, TouchedFileTimestamps, MaybeOldestTimestamp0), get_file_name(no, TargetFile, TargetFileName, !Info, !IO), @@ -285,7 +285,7 @@ force_reanalysis_of_suboptimal_module(ModuleName, ForceReanalysis, Info, !IO) :- (if Info ^ reanalysis_passes > 0 then ModuleId = module_name_to_module_id(ModuleName), - analysis__read_module_overall_status(mmc, ModuleId, + analysis.read_module_overall_status(mmc, ModuleId, MaybeAnalysisStatus, !IO), ( MaybeAnalysisStatus = yes(suboptimal) -> ForceReanalysis = yes @@ -316,7 +316,7 @@ build_target(CompilationTask, TargetFile, Imports, TouchedTargetFiles, % the mmc process which will do the compilation. % It's created here (not in invoke_mmc) so it can be % cleaned up by build_with_check_for_interrupt. - io__make_temp(ArgFileName, !IO), + io.make_temp(ArgFileName, !IO), MaybeArgFileName = yes(ArgFileName) ; MaybeArgFileName = no @@ -324,12 +324,12 @@ build_target(CompilationTask, TargetFile, Imports, TouchedTargetFiles, Cleanup = (pred(MakeInfo0::in, MakeInfo::out, di, uo) is det --> % XXX Remove `.int.tmp' files. - list__foldl2(remove_target_file, TouchedTargetFiles, + list.foldl2(make_remove_target_file, TouchedTargetFiles, MakeInfo0, MakeInfo1), - list__foldl2(remove_file, TouchedFiles, MakeInfo1, MakeInfo), + list.foldl2(make_remove_file, TouchedFiles, MakeInfo1, MakeInfo), ( { MaybeArgFileName = yes(ArgFileName2) }, - io__remove_file(ArgFileName2, _) + io.remove_file(ArgFileName2, _) ; { MaybeArgFileName = no } ) @@ -344,23 +344,23 @@ build_target(CompilationTask, TargetFile, Imports, TouchedTargetFiles, :- pred build_target_2(module_name::in, compilation_task_type::in, maybe(file_name)::in, module_imports::in, list(string)::in, - io__output_stream::in, bool::out, make_info::in, make_info::out, + io.output_stream::in, bool::out, make_info::in, make_info::out, io::di, io::uo) is det. build_target_2(ModuleName, process_module(ModuleTask), ArgFileName, _Imports, AllOptionArgs, ErrorStream, Succeeded, !Info, !IO) :- sym_name_to_string(ModuleName, ".", ModuleArg), - globals__io_lookup_bool_option(verbose_commands, Verbose, !IO), + globals.io_lookup_bool_option(verbose_commands, Verbose, !IO), ( Verbose = yes, - AllArgs = list__append(AllOptionArgs, [ModuleArg]), - io__write_string("Invoking command `mmc ", !IO), + AllArgs = list.append(AllOptionArgs, [ModuleArg]), + io.write_string("Invoking command `mmc ", !IO), % XXX Don't write the default options. - io__write_list(list__map(quote_arg, AllArgs), " ", io__write_string, + io.write_list(list.map(quote_arg, AllArgs), " ", io.write_string, !IO), - io__write_string("'", !IO), - io__nl(!IO) + io.write_string("'", !IO), + io.nl(!IO) ; Verbose = no ), @@ -376,7 +376,7 @@ build_target_2(ModuleName, process_module(ModuleTask), ArgFileName, % We do the same for intermodule-optimization interfaces % because if type checking gets overloaded by ambiguities % it can be difficult to kill the compiler otherwise. - io__set_output_stream(ErrorStream, OldOutputStream, !IO), + io.set_output_stream(ErrorStream, OldOutputStream, !IO), ( (ModuleTask = compile_to_target_code ; ModuleTask = make_optimization_interface @@ -388,7 +388,7 @@ build_target_2(ModuleName, process_module(ModuleTask), ArgFileName, ; call_mercury_compile_main([ModuleArg], Succeeded, !IO) ), - io__set_output_stream(OldOutputStream, _, !IO), + io.set_output_stream(OldOutputStream, _, !IO), ( ( ModuleTask = compile_to_target_code @@ -405,7 +405,7 @@ build_target_2(ModuleName, process_module(ModuleTask), ArgFileName, build_target_2(ModuleName, target_code_to_object_code(PIC), _, Imports, _, ErrorStream, Succeeded, !Info, !IO) :- - globals__io_get_target(CompilationTarget, !IO), + globals.io_get_target(CompilationTarget, !IO), % Run the compilation in a child process so it can % be killed if an interrupt arrives. @@ -437,50 +437,50 @@ build_target_2(ModuleName, fact_table_code_to_object_code(PIC, FactTableFile), Succeeded, !IO). :- pred build_object_code(module_name::in, compilation_target::in, pic::in, - io__output_stream::in, module_imports::in, bool::out, + io.output_stream::in, module_imports::in, bool::out, io::di, io::uo) is det. build_object_code(ModuleName, c, PIC, ErrorStream, _Imports, Succeeded, !IO) :- - compile_target_code__compile_c_file(ErrorStream, PIC, ModuleName, + compile_target_code.compile_c_file(ErrorStream, PIC, ModuleName, Succeeded, !IO). build_object_code(ModuleName, asm, PIC, ErrorStream, _Imports, Succeeded, !IO) :- - compile_target_code__assemble(ErrorStream, PIC, ModuleName, + compile_target_code.assemble(ErrorStream, PIC, ModuleName, Succeeded, !IO). build_object_code(ModuleName, java, _, ErrorStream, _Imports, Succeeded, !IO) :- module_name_to_file_name(ModuleName, ".java", yes, JavaFile, !IO), - compile_target_code__compile_java_file(ErrorStream, JavaFile, + compile_target_code.compile_java_file(ErrorStream, JavaFile, Succeeded, !IO). build_object_code(ModuleName, il, _, ErrorStream, Imports, Succeeded, !IO) :- - compile_target_code__il_assemble(ErrorStream, ModuleName, + compile_target_code.il_assemble(ErrorStream, ModuleName, Imports ^ has_main, Succeeded, !IO). -:- pred compile_foreign_code_file(io__output_stream::in, pic::in, +:- pred compile_foreign_code_file(io.output_stream::in, pic::in, module_imports::in, foreign_code_file::in, bool::out, io::di, io::uo) is det. compile_foreign_code_file(ErrorStream, PIC, _Imports, foreign_code_file(c, CFile, ObjFile), Succeeded, !IO) :- - compile_target_code__compile_c_file(ErrorStream, PIC, + compile_target_code.compile_c_file(ErrorStream, PIC, CFile, ObjFile, Succeeded, !IO). compile_foreign_code_file(ErrorStream, _, _Imports, foreign_code_file(il, ILFile, DLLFile), Succeeded, !IO) :- - compile_target_code__il_assemble(ErrorStream, ILFile, DLLFile, + compile_target_code.il_assemble(ErrorStream, ILFile, DLLFile, no_main, Succeeded, !IO). compile_foreign_code_file(ErrorStream, _, _Imports, foreign_code_file(java, JavaFile, _ClassFile), Succeeded, !IO) :- - compile_target_code__compile_java_file(ErrorStream, JavaFile, + compile_target_code.compile_java_file(ErrorStream, JavaFile, Succeeded, !IO). compile_foreign_code_file(ErrorStream, _, _Imports, foreign_code_file(managed_cplusplus, MCPPFile, DLLFile), Succeeded, !IO) :- - compile_target_code__compile_managed_cplusplus_file(ErrorStream, + compile_target_code.compile_managed_cplusplus_file(ErrorStream, MCPPFile, DLLFile, Succeeded, !IO). compile_foreign_code_file(ErrorStream, _, Imports, foreign_code_file(csharp, CSharpFile, DLLFile), Succeeded, !IO) :- - compile_target_code__compile_csharp_file(ErrorStream, Imports, + compile_target_code.compile_csharp_file(ErrorStream, Imports, CSharpFile, DLLFile, Succeeded, !IO). %-----------------------------------------------------------------------------% @@ -489,7 +489,7 @@ compile_foreign_code_file(ErrorStream, _, Imports, foreign_code_file::out, io::di, io::uo) is det. foreign_code_file(ModuleName, PIC, Lang, ForeignCodeFile, !IO) :- - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), ( ForeignModName0 = foreign_language_module_name( ModuleName, Lang), SrcExt0 = foreign_language_file_extension(Lang) @@ -509,7 +509,7 @@ foreign_code_file(ModuleName, PIC, Lang, ForeignCodeFile, !IO) :- fact_table_foreign_code_file(ModuleName, PIC, FactTableName, ForeignCodeFile, !IO) :- - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), ObjExt = get_object_extension(Globals, PIC), fact_table_file_name(ModuleName, FactTableName, ".c", yes, CFile, !IO), fact_table_file_name(ModuleName, FactTableName, ObjExt, yes, ObjFile, !IO), @@ -518,7 +518,7 @@ fact_table_foreign_code_file(ModuleName, PIC, FactTableName, ForeignCodeFile, :- func get_object_extension(globals, pic) = string. get_object_extension(Globals, PIC) = Ext :- - globals__get_target(Globals, CompilationTarget), + globals.get_target(Globals, CompilationTarget), ( CompilationTarget = c, maybe_pic_object_file_extension(Globals, PIC, Ext) @@ -539,20 +539,20 @@ get_object_extension(Globals, PIC) = Ext :- io::di, io::uo) is det. call_mercury_compile_main(Args, Succeeded, !Io) :- - io__get_exit_status(Status0, !Io), - io__set_exit_status(0, !Io), - mercury_compile__main(Args, !Io), - io__get_exit_status(Status, !Io), + io.get_exit_status(Status0, !Io), + io.set_exit_status(0, !Io), + mercury_compile.main(Args, !Io), + io.get_exit_status(Status, !Io), Succeeded = ( Status = 0 -> yes ; no ), - io__set_exit_status(Status0, !Io). + io.set_exit_status(Status0, !Io). -:- pred invoke_mmc(io__output_stream::in, maybe(file_name)::in, +:- pred invoke_mmc(io.output_stream::in, maybe(file_name)::in, list(string)::in, bool::out, io::di, io::uo) is det. invoke_mmc(ErrorStream, MaybeArgFileName, Args, Succeeded, !IO) :- - io__progname("", ProgName, !IO), + io.progname("", ProgName, !IO), ( ProgName = "" -> - io__get_environment_var("MERCURY_COMPILER", MaybeMercuryCompiler, !IO), + io.get_environment_var("MERCURY_COMPILER", MaybeMercuryCompiler, !IO), ( MaybeMercuryCompiler = yes(MercuryCompiler) ; @@ -563,7 +563,7 @@ invoke_mmc(ErrorStream, MaybeArgFileName, Args, Succeeded, !IO) :- MercuryCompiler = ProgName ), - QuotedArgs = list__map(quote_arg, Args), + QuotedArgs = list.map(quote_arg, Args), % Some operating systems (e.g. Windows) have shells with % ludicrously short limits on the length of command lines, @@ -582,15 +582,15 @@ invoke_mmc(ErrorStream, MaybeArgFileName, Args, Succeeded, !IO) :- "make.module_target.invoke_mmc: argument file not created") ), - io__open_output(ArgFileName, ArgFileOpenRes, !IO), + io.open_output(ArgFileName, ArgFileOpenRes, !IO), ( ArgFileOpenRes = ok(ArgFileStream), - io__write_string(ArgFileStream, "MCFLAGS = ", !IO), - io__write_list(ArgFileStream, QuotedArgs, " ", io__write_string, !IO), - io__nl(ArgFileStream, !IO), - io__close_output(ArgFileStream, !IO), + io.write_string(ArgFileStream, "MCFLAGS = ", !IO), + io.write_list(ArgFileStream, QuotedArgs, " ", io.write_string, !IO), + io.nl(ArgFileStream, !IO), + io.close_output(ArgFileStream, !IO), - Command = string__join_list(" ", + Command = string.join_list(" ", [quote_arg(MercuryCompiler), "--arg-file", quote_arg(ArgFileName)]), @@ -601,13 +601,13 @@ invoke_mmc(ErrorStream, MaybeArgFileName, Args, Succeeded, !IO) :- ; ArgFileOpenRes = error(Error), Succeeded = no, - io__write_string("Error opening `", !IO), - io__write_string(ArgFileName, !IO), - io__write_string("' for output: ", !IO), - io__write_string(io__error_message(Error), !IO), - io__nl(!IO) + io.write_string("Error opening `", !IO), + io.write_string(ArgFileName, !IO), + io.write_string("' for output: ", !IO), + io.write_string(io.error_message(Error), !IO), + io.nl(!IO) ), - io__remove_file(ArgFileName, _, !IO). + io.remove_file(ArgFileName, _, !IO). %-----------------------------------------------------------------------------% @@ -631,17 +631,17 @@ record_made_target_2(Succeeded, TargetFile, TouchedTargetFiles, target_file_error(TargetFile, !IO) ), - list__foldl(update_target_status(TargetStatus), TouchedTargetFiles, !Info), + list.foldl(update_target_status(TargetStatus), TouchedTargetFiles, !Info), DeleteTimestamp = (pred(TouchedFile::in, MakeInfo0::in, MakeInfo::out) is det :- MakeInfo = MakeInfo0 ^ file_timestamps := - map__delete(MakeInfo0 ^ file_timestamps, TouchedFile) + map.delete(MakeInfo0 ^ file_timestamps, TouchedFile) ), - list__map_foldl2(get_file_name(no), TouchedTargetFiles, + list.map_foldl2(get_file_name(no), TouchedTargetFiles, TouchedTargetFileNames, !Info, !IO), - list__foldl(DeleteTimestamp, TouchedTargetFileNames, !Info), - list__foldl(DeleteTimestamp, OtherTouchedFiles, !Info). + list.foldl(DeleteTimestamp, TouchedTargetFileNames, !Info), + list.foldl(DeleteTimestamp, OtherTouchedFiles, !Info). :- pred update_target_status(dependency_status::in, target_file::in, make_info::in, make_info::out) is det. @@ -724,13 +724,13 @@ touched_files(TargetFile, process_module(Task), TouchedTargetFiles, NestedChildren = Imports ^ nested_children, SourceFileModuleNames = [ModuleName | NestedChildren], - list__map_foldl2(get_module_dependencies, NestedChildren, + list.map_foldl2(get_module_dependencies, NestedChildren, MaybeNestedImportsList, !Info, !IO), ( - list__map( - (pred(yes(NestedModuleImports)::in, - NestedModuleImports::out) is semidet), - MaybeNestedImportsList, NestedImportsList) + list.map( + (pred(yes(NestedModuleImports)::in, + NestedModuleImports::out) is semidet), + MaybeNestedImportsList, NestedImportsList) -> ModuleImportsList = [Imports | NestedImportsList] ; @@ -741,7 +741,7 @@ touched_files(TargetFile, process_module(Task), TouchedTargetFiles, unexpected(this_file, "touched_files: no nested module dependencies") ), - globals__io_get_target(CompilationTarget, !IO), + globals.io_get_target(CompilationTarget, !IO), ( Task = compile_to_target_code, CompilationTarget = asm @@ -760,15 +760,15 @@ touched_files(TargetFile, process_module(Task), TouchedTargetFiles, ( Task = compile_to_target_code -> - list__map_foldl( + list.map_foldl( external_foreign_code_files(target_type_to_pic(FileType)), ModuleImportsList, ForeignCodeFileList, !IO), ForeignCodeFiles = - list__map((func(ForeignFile) = ForeignFile ^ target_file), - list__condense(ForeignCodeFileList)), + list.map((func(ForeignFile) = ForeignFile ^ target_file), + list.condense(ForeignCodeFileList)), ( CompilationTarget = c, - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), ( HighLevelCode = yes, % @@ -789,7 +789,7 @@ touched_files(TargetFile, process_module(Task), TouchedTargetFiles, % a header file if the module contains foreign code. % HeaderModuleNames = - list__filter_map( + list.filter_map( (func(MImports) = MImports ^ module_name is semidet :- contains_foreign_code(_) = MImports ^ foreign_code ), ModuleImportsList), @@ -829,8 +829,8 @@ touched_files(TargetFile, process_module(Task), TouchedTargetFiles, ForeignCodeFiles = [], TouchedTargetFiles = make_target_list(TargetModuleNames, FileType) ), - globals__io_get_globals(Globals, !IO), - list__foldl2( + globals.io_get_globals(Globals, !IO), + list.foldl2( (pred((TargetModuleName - TargetFileType)::in, !.TimestampFiles::in, !:TimestampFiles::out, !.IO::di, !:IO::uo) is det :- ( @@ -843,7 +843,7 @@ touched_files(TargetFile, process_module(Task), TouchedTargetFiles, true ) ), TouchedTargetFiles, [], TimestampFileNames, !IO), - TouchedFileNames = list__condense([ForeignCodeFiles, TimestampFileNames]). + TouchedFileNames = list.condense([ForeignCodeFiles, TimestampFileNames]). touched_files(TargetFile, target_code_to_object_code(_), [TargetFile], [], !Info, !IO). @@ -857,7 +857,7 @@ touched_files(TargetFile, foreign_code_to_object_code(PIC, Lang), touched_files(TargetFile, fact_table_code_to_object_code(PIC, FactTableName), [TargetFile], [FactTableObjectFile], !Info, !IO) :- TargetFile = ModuleName - _, - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), ObjExt = get_object_extension(Globals, PIC), fact_table_file_name(ModuleName, FactTableName, ObjExt, yes, FactTableObjectFile, !IO). @@ -868,12 +868,12 @@ external_foreign_code_files(PIC, Imports, ForeignFiles, !IO) :- % `:- pragma foreign_proc' declarations. % maybe_pic_object_file_extension(PIC, ObjExt, !IO), - globals__io_get_target(CompilationTarget, !IO), + globals.io_get_target(CompilationTarget, !IO), ModuleName = Imports ^ module_name, ( CompilationTarget = asm, Imports ^ foreign_code = contains_foreign_code(Langs), - set__member(c, Langs) + set.member(c, Langs) -> module_name_to_file_name(foreign_language_module_name(ModuleName, c), ".c", no, CCodeFileName, !IO), @@ -884,9 +884,9 @@ external_foreign_code_files(PIC, Imports, ForeignFiles, !IO) :- CompilationTarget = il, Imports ^ foreign_code = contains_foreign_code(Langs) -> - list__map_foldl(external_foreign_code_files_for_il(ModuleName), - set__to_sorted_list(Langs), ForeignFilesList, !IO), - list__condense(ForeignFilesList, ForeignFiles0) + list.map_foldl(external_foreign_code_files_for_il(ModuleName), + set.to_sorted_list(Langs), ForeignFilesList, !IO), + list.condense(ForeignFilesList, ForeignFiles0) ; ForeignFiles0 = [] ), @@ -899,7 +899,7 @@ external_foreign_code_files(PIC, Imports, ForeignFiles, !IO) :- ; CompilationTarget = asm ) -> - list__map_foldl( + list.map_foldl( (pred(FactTableFile::in, FactTableForeignFile::out, di, uo) is det --> fact_table_file_name(ModuleName, FactTableFile, diff --git a/compiler/make.program_target.m b/compiler/make.program_target.m index cd4787dfc..7a1b6e03c 100644 --- a/compiler/make.program_target.m +++ b/compiler/make.program_target.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module make__program_target. +:- module make.program_target. :- interface. %-----------------------------------------------------------------------------% @@ -72,7 +72,7 @@ make_linked_target(MainModuleName - FileType, Succeeded, !Info, !IO) :- % The analysis of one module may invalidate the results of a module we % analysed earlier, so this step must be carried out until all the % `.analysis' files are in a valid state before we can continue. - globals__io_lookup_bool_option(intermodule_analysis, + globals.io_lookup_bool_option(intermodule_analysis, IntermoduleAnalysis, !IO), ( IntermoduleAnalysis = yes, @@ -99,7 +99,7 @@ make_linked_target(MainModuleName - FileType, Succeeded, !Info, !IO) :- make_linked_target_2(MainModuleName - FileType, _, Succeeded, !Info, !IO) :- find_reachable_local_modules(MainModuleName, DepsSuccess, AllModules, !Info, !IO), - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), ( DepsSuccess = no, KeepGoing = no @@ -110,7 +110,7 @@ make_linked_target_2(MainModuleName - FileType, _, Succeeded, !Info, !IO) :- % Build the `.c' files first so that errors are reported % as soon as possible. - globals__io_get_target(CompilationTarget, !IO), + globals.io_get_target(CompilationTarget, !IO), ( CompilationTarget = c, IntermediateTargetType = c_code, @@ -131,14 +131,14 @@ make_linked_target_2(MainModuleName - FileType, _, Succeeded, !Info, !IO) :- ), get_target_modules(IntermediateTargetType, - set__to_sorted_list(AllModules), ObjModules, !Info, !IO), + set.to_sorted_list(AllModules), ObjModules, !Info, !IO), IntermediateTargets = make_dependency_list(ObjModules, IntermediateTargetType), ObjTargets = make_dependency_list(ObjModules, ObjectTargetType), - list__map_foldl2(get_foreign_object_targets(PIC), + list.map_foldl2(get_foreign_object_targets(PIC), ObjModules, ForeignObjTargetsList, !Info, !IO), - ForeignObjTargets = list__condense(ForeignObjTargetsList), + ForeignObjTargets = list.condense(ForeignObjTargetsList), foldl2_maybe_stop_at_error(KeepGoing, foldl2_maybe_stop_at_error(KeepGoing, make_module_target), @@ -146,7 +146,7 @@ make_linked_target_2(MainModuleName - FileType, _, Succeeded, !Info, !IO) :- BuildDepsSucceeded, !Info, !IO), linked_target_file_name(MainModuleName, FileType, OutputFileName, !IO), - get_file_timestamp([dir__this_directory], OutputFileName, + get_file_timestamp([dir.this_directory], OutputFileName, MaybeTimestamp, !Info, !IO), check_dependencies(OutputFileName, MaybeTimestamp, BuildDepsSucceeded, ObjTargets, BuildDepsResult, !Info, !IO), @@ -173,7 +173,7 @@ make_linked_target_2(MainModuleName - FileType, _, Succeeded, !Info, !IO) :- make_info::in, make_info::out, io::di, io::uo) is det. get_target_modules(TargetType, AllModules, TargetModules, !Info, !IO) :- - globals__io_get_target(CompilationTarget, !IO), + globals.io_get_target(CompilationTarget, !IO), ( ( TargetType = errors @@ -186,7 +186,7 @@ get_target_modules(TargetType, AllModules, TargetModules, !Info, !IO) :- -> % `.err' and `.s' files are only produced for the % top-level module in each source file. - list__foldl3(get_target_modules_2, AllModules, + list.foldl3(get_target_modules_2, AllModules, [], TargetModules, !Info, !IO) ; TargetModules = AllModules @@ -215,7 +215,7 @@ get_foreign_object_targets(PIC, ModuleName, ObjectTargets, !Info, !IO) :- % Find externally compiled foreign code files for % `:- pragma foreign_proc' declarations. - globals__io_get_target(CompilationTarget, !IO), + globals.io_get_target(CompilationTarget, !IO), get_module_dependencies(ModuleName, MaybeImports, !Info, !IO), ( MaybeImports = yes(Imports) @@ -226,17 +226,16 @@ get_foreign_object_targets(PIC, ModuleName, ObjectTargets, !Info, !IO) :- ( CompilationTarget = asm, Imports ^ foreign_code = contains_foreign_code(Langs), - set__member(c, Langs) + set.member(c, Langs) -> - ForeignObjectTargets = - [target(ModuleName - foreign_object(PIC, c))] + ForeignObjectTargets = [target(ModuleName - foreign_object(PIC, c))] ; CompilationTarget = il, Imports ^ foreign_code = contains_foreign_code(Langs) -> - ForeignObjectTargets = list__map( + ForeignObjectTargets = list.map( (func(L) = target(ModuleName - foreign_il_asm(L)) - ), set__to_sorted_list(Langs)) + ), set.to_sorted_list(Langs)) ; ForeignObjectTargets = [] ), @@ -248,7 +247,7 @@ get_foreign_object_targets(PIC, ModuleName, ObjectTargets, !Info, !IO) :- ; CompilationTarget = asm ) -> - FactObjectTargets = list__map( + FactObjectTargets = list.map( (func(FactFile) = target(ModuleName - fact_table_object(PIC, FactFile)) ), @@ -261,13 +260,13 @@ get_foreign_object_targets(PIC, ModuleName, ObjectTargets, !Info, !IO) :- :- pred build_linked_target(module_name::in, linked_target_type::in, file_name::in, maybe_error(timestamp)::in, set(module_name)::in, list(module_name)::in, compilation_target::in, pic::in, - bool::in, dependencies_result::in, io__output_stream::in, + bool::in, dependencies_result::in, io.output_stream::in, bool::out, make_info::in, make_info::out, io::di, io::uo) is det. build_linked_target(MainModuleName, FileType, OutputFileName, MaybeTimestamp, AllModules, ObjModules, CompilationTarget, PIC, DepsSuccess, BuildDepsResult, ErrorStream, Succeeded, !Info, !IO) :- - globals__io_lookup_maybe_string_option(pre_link_command, + globals.io_lookup_maybe_string_option(pre_link_command, MaybePreLinkCommand, !IO), ( MaybePreLinkCommand = yes(PreLinkCommand), @@ -292,34 +291,34 @@ build_linked_target(MainModuleName, FileType, OutputFileName, MaybeTimestamp, :- pred build_linked_target_2(module_name::in, linked_target_type::in, file_name::in, maybe_error(timestamp)::in, set(module_name)::in, list(module_name)::in, compilation_target::in, pic::in, - bool::in, dependencies_result::in, io__output_stream::in, bool::out, + bool::in, dependencies_result::in, io.output_stream::in, bool::out, make_info::in, make_info::out, io::di, io::uo) is det. build_linked_target_2(MainModuleName, FileType, OutputFileName, MaybeTimestamp, AllModules, ObjModules, CompilationTarget, PIC, DepsSuccess, BuildDepsResult, ErrorStream, Succeeded, !Info, !IO) :- - globals__io_lookup_accumulating_option(link_objects, LinkObjects, !IO), + globals.io_lookup_accumulating_option(link_objects, LinkObjects, !IO), % Clear the option -- we'll pass the list of files directly. - globals__io_set_option(link_objects, accumulating([]), !IO), + globals.io_set_option(link_objects, accumulating([]), !IO), % Remake the `_init.o' file. % XXX We should probably make a `_init.o' file for shared % libraries linked using dlopen(). - AllModulesList = set__to_sorted_list(AllModules), + AllModulesList = set.to_sorted_list(AllModules), ( FileType = executable, ( CompilationTarget = c ; CompilationTarget = asm ) -> - compile_target_code__make_init_obj_file(ErrorStream, + compile_target_code.make_init_obj_file(ErrorStream, MainModuleName, AllModulesList, InitObjectResult, !IO), ( InitObjectResult = yes(InitObject), % We may need to update the timestamp of the `_init.o' file. !:Info = !.Info ^ file_timestamps := - map__delete(!.Info ^ file_timestamps, InitObject), + map.delete(!.Info ^ file_timestamps, InitObject), InitObjects = [InitObject], DepsResult2 = BuildDepsResult ; @@ -335,17 +334,17 @@ build_linked_target_2(MainModuleName, FileType, OutputFileName, MaybeTimestamp, ObjectsToCheck = InitObjects ++ LinkObjects, % Report errors if any of the extra objects aren't present. - list__map_foldl2(dependency_status, - list__map((func(F) = file(F, no)), ObjectsToCheck), + list.map_foldl2(dependency_status, + list.map((func(F) = file(F, no)), ObjectsToCheck), ExtraObjStatus, !Info, !IO), DepsResult3 = - ( list__member(error, ExtraObjStatus) -> error ; DepsResult2 ), + ( list.member(error, ExtraObjStatus) -> error ; DepsResult2 ), BuildDepsSuccess = ( DepsResult3 \= error -> yes ; no ), - list__map_foldl2(get_file_timestamp([dir__this_directory]), + list.map_foldl2(get_file_timestamp([dir.this_directory]), ObjectsToCheck, ExtraObjectTimestamps, !Info, !IO), check_dependency_timestamps(OutputFileName, MaybeTimestamp, - BuildDepsSuccess, ObjectsToCheck, io__write, + BuildDepsSuccess, ObjectsToCheck, io.write, ExtraObjectTimestamps, ExtraObjectDepsResult, !IO), DepsResult4 = ( DepsSuccess = yes -> DepsResult3 ; error ), @@ -359,13 +358,13 @@ build_linked_target_2(MainModuleName, FileType, OutputFileName, MaybeTimestamp, Succeeded = no ; DepsResult = up_to_date, - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), ( UseGradeSubdirs = yes, maybe_symlink_or_copy_linked_target_message( MainModuleName - linked_target(FileType), !IO), - compile_target_code__post_link_make_symlink_or_copy(ErrorStream, + compile_target_code.post_link_make_symlink_or_copy(ErrorStream, FileType, MainModuleName, Succeeded, !IO) ; UseGradeSubdirs = no, @@ -381,7 +380,7 @@ build_linked_target_2(MainModuleName, FileType, OutputFileName, MaybeTimestamp, % procedures and fact tables. We don't need to include these in the % timestamp checking above -- they will have been checked when the % module's object file was built. - list__map_foldl2( + list.map_foldl2( (pred(ModuleName::in, ForeignFiles::out, MakeInfo0::in, MakeInfo::out, !.IO::di, !:IO::uo) is det :- get_module_dependencies(ModuleName, MaybeImports, @@ -396,12 +395,12 @@ build_linked_target_2(MainModuleName, FileType, OutputFileName, MaybeTimestamp, "build_linked_target: error in dependencies") ) ), AllModulesList, ExtraForeignFiles, !Info, !IO), - ForeignObjects = list__map( + ForeignObjects = list.map( (func(foreign_code_file(_, _, ObjFile)) = ObjFile), - list__condense(ExtraForeignFiles)), + list.condense(ExtraForeignFiles)), maybe_pic_object_file_extension(PIC, ObjExtToUse, !IO), - list__map_foldl( + list.map_foldl( (pred(ObjModule::in, ObjToLink::out, !.IO::di, !:IO::uo) is det :- module_name_to_file_name(ObjModule, ObjExtToUse, no, ObjToLink, !IO) @@ -415,7 +414,7 @@ build_linked_target_2(MainModuleName, FileType, OutputFileName, MaybeTimestamp, % Run the link in a separate process so it can be killed % if an interrupt is received. call_in_forked_process( - compile_target_code__link(ErrorStream, + compile_target_code.link(ErrorStream, FileType, MainModuleName, AllObjects), Succeeded, !IO) ; @@ -423,7 +422,7 @@ build_linked_target_2(MainModuleName, FileType, OutputFileName, MaybeTimestamp, % Run the link in a separate process so it can % be killed if an interrupt is received. call_in_forked_process( - compile_target_code__link(ErrorStream, + compile_target_code.link(ErrorStream, FileType, MainModuleName, AllObjects), Succeeded, !IO) ; @@ -434,18 +433,18 @@ build_linked_target_2(MainModuleName, FileType, OutputFileName, MaybeTimestamp, create_java_shell_script(MainModuleName, Succeeded, !IO) ), !:Info = !.Info ^ command_line_targets := - set__delete(!.Info ^ command_line_targets, + set.delete(!.Info ^ command_line_targets, MainModuleName - linked_target(FileType)), ( Succeeded = yes, !:Info = !.Info ^ file_timestamps := - map__delete(!.Info ^ file_timestamps, OutputFileName) + map.delete(!.Info ^ file_timestamps, OutputFileName) ; Succeeded = no, file_error(OutputFileName, !IO) ) ), - globals__io_set_option(link_objects, accumulating(LinkObjects), !IO). + globals.io_set_option(link_objects, accumulating(LinkObjects), !IO). % join_string_list(Strings, Prefix, Suffix, Serarator, Result) % @@ -460,11 +459,11 @@ join_string_list([], _Prefix, _Suffix, _Separator, ""). join_string_list([String | Strings], Prefix, Suffix, Separator, Result) :- ( Strings = [], - string__append_list([Prefix, String, Suffix], Result) + string.append_list([Prefix, String, Suffix], Result) ; Strings = [_ | _], join_string_list(Strings, Prefix, Suffix, Separator, Result0), - string__append_list([Prefix, String, Suffix, Separator, + string.append_list([Prefix, String, Suffix, Separator, Result0], Result) ). @@ -474,7 +473,7 @@ join_string_list([String | Strings], Prefix, Suffix, Separator, Result) :- linked_target_cleanup(MainModuleName, FileType, OutputFileName, CompilationTarget, !Info, !IO) :- - remove_file(OutputFileName, !Info, !IO), + make_remove_file(OutputFileName, !Info, !IO), ( FileType = executable, ( CompilationTarget = c @@ -511,22 +510,22 @@ make_misc_target(MainModuleName - TargetType, _, Succeeded, !Info, !IO) :- find_reachable_local_modules(MainModuleName, Succeeded0, AllModulesSet, !Info, !IO), !:Info = !.Info ^ rebuild_dependencies := RebuildDeps, - AllModules = set__to_sorted_list(AllModulesSet), + AllModules = set.to_sorted_list(AllModulesSet), ( TargetType = clean, Succeeded = yes, - list__foldl2(make_module_clean, AllModules, !Info, !IO), + list.foldl2(make_module_clean, AllModules, !Info, !IO), remove_init_files(MainModuleName, !Info, !IO) ; TargetType = realclean, Succeeded = yes, make_main_module_realclean(MainModuleName, !Info, !IO), - list__foldl2(make_module_realclean, AllModules, !Info, !IO) + list.foldl2(make_module_realclean, AllModules, !Info, !IO) ; TargetType = build_all(ModuleTargetType), get_target_modules(ModuleTargetType, AllModules, TargetModules, !Info, !IO), - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), ( Succeeded0 = no, KeepGoing = no -> Succeeded = no ; @@ -545,7 +544,7 @@ make_misc_target(MainModuleName - TargetType, _, Succeeded, !Info, !IO) :- ShortInts = make_dependency_list(AllModules, unqualified_short_interface), LongInts = make_dependency_list(AllModules, long_interface), - globals__io_lookup_bool_option(intermodule_optimization, + globals.io_lookup_bool_option(intermodule_optimization, Intermod, !IO), ( Intermod = yes, @@ -554,7 +553,7 @@ make_misc_target(MainModuleName - TargetType, _, Succeeded, !Info, !IO) :- Intermod = no, OptFiles = [] ), - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), foldl2_maybe_stop_at_error(KeepGoing, foldl2_maybe_stop_at_error(KeepGoing, make_module_target), [ShortInts, LongInts, OptFiles], @@ -562,14 +561,14 @@ make_misc_target(MainModuleName - TargetType, _, Succeeded, !Info, !IO) :- ( IntSucceeded = yes, % Errors while making the `.init' file should be very rare. - io__output_stream(ErrorStream, !IO), - compile_target_code__make_init_file(ErrorStream, MainModuleName, + io.output_stream(ErrorStream, !IO), + compile_target_code.make_init_file(ErrorStream, MainModuleName, AllModules, InitSucceeded, !IO), ( InitSucceeded = yes, make_linked_target(MainModuleName - static_library, StaticSucceeded, !Info, !IO), - compile_target_code__shared_libraries_supported( + compile_target_code.shared_libraries_supported( SharedLibsSupported, !IO), ( StaticSucceeded = yes, @@ -614,7 +613,7 @@ build_analysis_files(MainModuleName, AllModules, Succeeded0, Succeeded, !Info, !IO) :- get_target_modules(analysis_registry, AllModules, TargetModules0, !Info, !IO), - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), ( Succeeded0 = no, KeepGoing = no -> Succeeded = no ; @@ -641,7 +640,7 @@ build_analysis_files(MainModuleName, AllModules, Succeeded0, Succeeded, build_analysis_files_2(MainModuleName, TargetModules, LocalModulesOpts, Succeeded0, Succeeded, !Info, !IO) :- - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), foldl2_maybe_stop_at_error(KeepGoing, make_module_target_extra_options(LocalModulesOpts), make_dependency_list(TargetModules, analysis_registry), @@ -657,14 +656,14 @@ build_analysis_files_2(MainModuleName, TargetModules, LocalModulesOpts, ReanalyseSuboptimal = (if ReanalysisPasses > 1 then yes else no), modules_needing_reanalysis(ReanalyseSuboptimal, TargetModules, InvalidModules, SuboptimalModules, !IO), - ( list__is_not_empty(InvalidModules) -> + ( list.is_not_empty(InvalidModules) -> maybe_reanalyse_modules_message(!IO), - list__foldl(reset_analysis_registry_dependency_status, + list.foldl(reset_analysis_registry_dependency_status, InvalidModules, !Info), build_analysis_files_2(MainModuleName, TargetModules, LocalModulesOpts, Succeeded0, Succeeded, !Info, !IO) - ; list__is_not_empty(SuboptimalModules) -> - list__foldl(reset_analysis_registry_dependency_status, + ; list.is_not_empty(SuboptimalModules) -> + list.foldl(reset_analysis_registry_dependency_status, SuboptimalModules, !Info), !:Info = !.Info ^ reanalysis_passes := ReanalysisPasses - 1, maybe_reanalyse_modules_message(!IO), @@ -683,18 +682,18 @@ build_analysis_files_2(MainModuleName, TargetModules, LocalModulesOpts, list(module_name)::in, list(module_name)::out) is det. reverse_ordered_modules(ModuleDeps, Modules0, Modules) :- - list__foldl2(add_module_relations(lookup_module_imports(ModuleDeps)), - Modules0, relation__init, _IntRel, relation__init, ImplRel), - relation__atsort(ImplRel, Order0), - list__reverse(Order0, Order1), - list__map(set__to_sorted_list, Order1, Order2), - list__condense(Order2, Modules). + list.foldl2(add_module_relations(lookup_module_imports(ModuleDeps)), + Modules0, relation.init, _IntRel, relation.init, ImplRel), + relation.atsort(ImplRel, Order0), + list.reverse(Order0, Order1), + list.map(set.to_sorted_list, Order1, Order2), + list.condense(Order2, Modules). :- func lookup_module_imports(map(module_name, maybe(module_imports)), module_name) = module_imports. lookup_module_imports(ModuleDeps, ModuleName) = ModuleImports :- - map__lookup(ModuleDeps, ModuleName, MaybeModuleImports), + map.lookup(ModuleDeps, ModuleName, MaybeModuleImports), ( MaybeModuleImports = yes(ModuleImports) ; @@ -764,35 +763,35 @@ reset_analysis_registry_dependency_status(ModuleName, Info, install_library(MainModuleName, Succeeded, !Info, !IO) :- find_reachable_local_modules(MainModuleName, DepsSuccess, AllModules0, !Info, !IO), - AllModules = set__to_sorted_list(AllModules0) , + AllModules = set.to_sorted_list(AllModules0) , make_install_dirs(DirSucceeded, LinkSucceeded, !IO), ( DepsSuccess = yes, DirSucceeded = yes -> - globals__io_lookup_string_option(install_prefix, Prefix, !IO), + globals.io_lookup_string_option(install_prefix, Prefix, !IO), ModulesDir = Prefix/"lib"/"mercury"/"modules", module_name_to_file_name(MainModuleName, ".init", no, InitFileName, !IO), install_file(InitFileName, ModulesDir, InitSucceeded, !IO), - list__map_foldl2(install_ints_and_headers(LinkSucceeded), AllModules, + list.map_foldl2(install_ints_and_headers(LinkSucceeded), AllModules, IntsSucceeded, !Info, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), grade_directory_component(Globals, Grade), install_library_grade_files(LinkSucceeded, Grade, MainModuleName, AllModules, GradeSucceeded, !Info, !IO), ( InitSucceeded = yes, - bool__and_list(IntsSucceeded) = yes, + bool.and_list(IntsSucceeded) = yes, GradeSucceeded = yes -> % XXX With Mmake, LIBGRADES is target-specific. - globals__io_lookup_accumulating_option(libgrades, LibGrades0, !IO), - globals__io_lookup_bool_option(keep_going, KeepGoing, !IO), - LibGrades = list__delete_all(LibGrades0, Grade), + globals.io_lookup_accumulating_option(libgrades, LibGrades0, !IO), + globals.io_lookup_bool_option(keep_going, KeepGoing, !IO), + LibGrades = list.delete_all(LibGrades0, Grade), foldl2_maybe_stop_at_error(KeepGoing, install_library_grade(LinkSucceeded, MainModuleName, AllModules), @@ -812,8 +811,7 @@ install_ints_and_headers(SubdirLinkSucceeded, ModuleName, Succeeded, !Info, get_module_dependencies(ModuleName, MaybeImports, !Info, !IO), ( MaybeImports = yes(Imports), - globals__io_lookup_bool_option(intermodule_optimization, - Intermod, !IO), + globals.io_lookup_bool_option(intermodule_optimization, Intermod, !IO), ( Intermod = yes -> % `.int0' files are imported by `.opt' files. ( @@ -827,15 +825,15 @@ install_ints_and_headers(SubdirLinkSucceeded, ModuleName, Succeeded, !Info, Exts = [] ), - globals__io_lookup_string_option(install_prefix, Prefix, !IO), + globals.io_lookup_string_option(install_prefix, Prefix, !IO), LibDir = Prefix/"lib"/"mercury", - list__map_foldl( + list.map_foldl( install_subdir_file(SubdirLinkSucceeded, LibDir/"ints", ModuleName), ["int", "int2", "int3", "module_dep" | Exts], Results, !IO), - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( % `.mh' files are (were) only generated for modules containing % `:- pragma export' declarations. @@ -857,7 +855,7 @@ install_ints_and_headers(SubdirLinkSucceeded, ModuleName, Succeeded, !Info, ; HeaderSucceeded = yes ), - Succeeded = bool__and_list([HeaderSucceeded | Results]) + Succeeded = bool.and_list([HeaderSucceeded | Results]) ; MaybeImports = no, Succeeded = no @@ -889,7 +887,7 @@ install_library_grade(LinkSucceeded0, ModuleName, AllModules, Grade, Succeeded, install_library_grade_2(LinkSucceeded0, Grade, ModuleName, AllModules, Info0, Succeeded, !IO) :- - globals__io_get_globals(OrigGlobals, !IO), + globals.io_get_globals(OrigGlobals, !IO), % Set up so that grade-dependent files for the current grade % don't overwrite the files for the default grade. @@ -898,9 +896,9 @@ install_library_grade_2(LinkSucceeded0, Grade, ModuleName, AllModules, verbose_msg( (pred(!.IO::di, !:IO::uo) is det :- - io__write_string("Installing grade ", !IO), - io__write_string(Grade, !IO), - io__nl(!IO) + io.write_string("Installing grade ", !IO), + io.write_string(Grade, !IO), + io.nl(!IO) ), !IO), lookup_mmc_options(Info0 ^ options_variables, MaybeMCFlags, !IO), @@ -923,14 +921,14 @@ install_library_grade_2(LinkSucceeded0, Grade, ModuleName, AllModules, % Remove the grade-dependent targets from the status map % (we need to rebuild them in the new grade). StatusMap0 = Info0 ^ dependency_status, - StatusMap = map__from_assoc_list(list__filter( + StatusMap = map.from_assoc_list(list.filter( (pred((File - _)::in) is semidet :- \+ ( File = target(_ - Target), target_is_grade_or_arch_dependent(Target) ) ), - map__to_assoc_list(StatusMap0))), + map.to_assoc_list(StatusMap0))), Info1 = (Info0 ^ dependency_status := StatusMap) ^ option_args := OptionArgs, make_misc_target(ModuleName - build_library, LibSucceeded, @@ -939,7 +937,7 @@ install_library_grade_2(LinkSucceeded0, Grade, ModuleName, AllModules, LibSucceeded = yes, % `GradeDir' differs from `Grade' in that it is in canonical form, % and it does not include any `.picreg' component. - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), grade_directory_component(Globals, GradeDir), install_library_grade_files(LinkSucceeded0, GradeDir, ModuleName, AllModules, Succeeded, Info2, Info3, !IO), @@ -949,7 +947,7 @@ install_library_grade_2(LinkSucceeded0, Grade, ModuleName, AllModules, Succeeded = no ) ), - globals__io_set_globals(unsafe_promise_unique(OrigGlobals), !IO). + globals.io_set_globals(unsafe_promise_unique(OrigGlobals), !IO). % Install the `.a', `.so', `.jar', `.opt' and `.mih' files for the current % grade. @@ -972,7 +970,7 @@ install_library_grade_files(LinkSucceeded0, GradeDir, ModuleName, AllModules, !IO), linked_target_file_name(ModuleName, java_archive, JarFileName, !IO), - globals__io_lookup_string_option(install_prefix, Prefix, !IO), + globals.io_lookup_string_option(install_prefix, Prefix, !IO), ( GradeDir = "java" -> GradeLibDir = Prefix/"lib"/"mercury"/"lib"/"java", @@ -990,10 +988,10 @@ install_library_grade_files(LinkSucceeded0, GradeDir, ModuleName, AllModules, ) ), - list__map_foldl2( + list.map_foldl2( install_grade_ints_and_headers(LinkSucceeded, GradeDir), AllModules, IntsHeadersSucceeded, !Info, !IO), - Succeeded = bool__and_list([LibsSucceeded | IntsHeadersSucceeded]) + Succeeded = bool.and_list([LibsSucceeded | IntsHeadersSucceeded]) ; DirResult = no, Succeeded = no @@ -1009,11 +1007,11 @@ install_grade_ints_and_headers(LinkSucceeded, GradeDir, ModuleName, Succeeded, get_module_dependencies(ModuleName, MaybeImports, !Info, !IO), ( MaybeImports = yes(Imports), - globals__io_lookup_string_option(install_prefix, Prefix, !IO), + globals.io_lookup_string_option(install_prefix, Prefix, !IO), LibDir = Prefix/"lib"/"mercury", - globals__io_get_target(Target, !IO), - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), + globals.io_get_target(Target, !IO), + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), ( ( Target = c, @@ -1039,8 +1037,7 @@ install_grade_ints_and_headers(LinkSucceeded, GradeDir, ModuleName, Succeeded, ), GradeIntDir = LibDir/"ints"/GradeDir, - globals__io_lookup_bool_option(intermodule_optimization, Intermod, - !IO), + globals.io_lookup_bool_option(intermodule_optimization, Intermod, !IO), ( Intermod = yes, install_subdir_file(LinkSucceeded, GradeIntDir, ModuleName, "opt", @@ -1050,7 +1047,7 @@ install_grade_ints_and_headers(LinkSucceeded, GradeDir, ModuleName, Succeeded, OptSucceeded = yes ), - globals__io_lookup_bool_option(intermodule_analysis, IntermodAnalysis, + globals.io_lookup_bool_option(intermodule_analysis, IntermodAnalysis, !IO), ( IntermodAnalysis = yes, @@ -1106,22 +1103,22 @@ maybe_install_library_file(Linkage, FileName, InstallDir, Succeeded, !IO) :- install_file(FileName, InstallDir, Succeeded, !IO) :- verbose_msg( (pred(!.IO::di, !:IO::uo) is det :- - io__write_string("Installing file ", !IO), - io__write_string(FileName, !IO), - io__write_string(" in ", !IO), - io__write_string(InstallDir, !IO), - io__nl(!IO) + io.write_string("Installing file ", !IO), + io.write_string(FileName, !IO), + io.write_string(" in ", !IO), + io.write_string(InstallDir, !IO), + io.nl(!IO) ), !IO), - globals__io_lookup_string_option(install_command, InstallCommand, !IO), - Command = string__join_list(" ", list__map(quote_arg, + globals.io_lookup_string_option(install_command, InstallCommand, !IO), + Command = string.join_list(" ", list.map(quote_arg, [InstallCommand, FileName, InstallDir])), - io__output_stream(OutputStream, !IO), + io.output_stream(OutputStream, !IO), invoke_system_command(OutputStream, verbose, Command, Succeeded, !IO). :- pred make_install_dirs(bool::out, bool::out, io::di, io::uo) is det. make_install_dirs(Result, LinkResult, !IO) :- - globals__io_lookup_string_option(install_prefix, Prefix, !IO), + globals.io_lookup_string_option(install_prefix, Prefix, !IO), LibDir = Prefix/"lib"/"mercury", make_directory(LibDir/"inc", Result1, !IO), make_directory(LibDir/"modules", Result2, !IO), @@ -1132,15 +1129,15 @@ make_install_dirs(Result, LinkResult, !IO) :- Subdirs = ["int0", "int", "int2", "int3", "opt", "trans_opt", "mh", "mih", "module_dep"], - list__map_foldl(make_install_symlink(IntsSubdir), Subdirs, LinkResults, + list.map_foldl(make_install_symlink(IntsSubdir), Subdirs, LinkResults, !IO), - LinkResult = bool__and_list(LinkResults), + LinkResult = bool.and_list(LinkResults), ( LinkResult = yes, Results = Results0 ; LinkResult = no, - list__map_foldl( + list.map_foldl( (pred(Ext::in, MkDirResult::out, !.IO::di, !:IO::uo) is det:- make_directory(IntsSubdir/(Ext ++ "s"), MkDirResult, !IO) ), Subdirs, MkDirResults, !IO), @@ -1152,7 +1149,7 @@ make_install_dirs(Result, LinkResult, !IO) :- io::di, io::uo) is det. make_grade_install_dirs(Grade, Result, LinkResult, !IO) :- - globals__io_lookup_string_option(install_prefix, Prefix, !IO), + globals.io_lookup_string_option(install_prefix, Prefix, !IO), LibDir = Prefix/"lib"/"mercury", GradeIntsSubdir = LibDir/"ints"/Grade/"Mercury", @@ -1164,9 +1161,9 @@ make_grade_install_dirs(Grade, Result, LinkResult, !IO) :- Results0 = [Result1, Result2], make_install_symlink(GradeIncSubdir, "mih", LinkResult0, !IO), - list__map_foldl(make_install_symlink(GradeIntsSubdir), + list.map_foldl(make_install_symlink(GradeIntsSubdir), ["opt", "trans_opt", "analysis"], LinkResults, !IO), - LinkResult = bool__and_list([LinkResult0 | LinkResults]), + LinkResult = bool.and_list([LinkResult0 | LinkResults]), ( LinkResult = yes, Results = Results0 @@ -1180,16 +1177,16 @@ make_grade_install_dirs(Grade, Result, LinkResult, !IO) :- ), print_mkdir_errors(Results, Result, !IO). -:- pred print_mkdir_errors(list(io__res)::in, bool::out, +:- pred print_mkdir_errors(list(io.res)::in, bool::out, io::di, io::uo) is det. print_mkdir_errors([], yes, !IO). print_mkdir_errors([ok | Rest], Succeeded, !IO) :- print_mkdir_errors(Rest, Succeeded, !IO). print_mkdir_errors([error(Error) | Rest], no, !IO) :- - io__write_string("Error creating installation directories: ", !IO), - io__write_string(io__error_message(Error), !IO), - io__nl(!IO), + io.write_string("Error creating installation directories: ", !IO), + io.write_string(io.error_message(Error), !IO), + io.nl(!IO), print_mkdir_errors(Rest, _, !IO). :- pred make_install_symlink(string::in, string::in, bool::out, @@ -1208,7 +1205,7 @@ make_install_symlink(Subdir, Ext, Succeeded, !IO) :- make_grade_clean(ModuleName, AllModules, !Info, !IO) :- make_main_module_realclean(ModuleName, !Info, !IO), - list__foldl2(make_module_clean, AllModules, !Info, !IO). + list.foldl2(make_module_clean, AllModules, !Info, !IO). :- pred make_main_module_realclean(module_name::in, make_info::in, make_info::out, io::di, io::uo) is det. @@ -1221,34 +1218,34 @@ make_main_module_realclean(ModuleName, !Info, !IO) :- linked_target_file_name(ModuleName, java_archive, JarFileName, !IO), % Remove the symlinks created for `--use-grade-subdirs'. - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), - globals__io_set_option(use_grade_subdirs, bool(no), !IO), + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), + globals.io_set_option(use_grade_subdirs, bool(no), !IO), linked_target_file_name(ModuleName, executable, ThisDirExeFileName, !IO), linked_target_file_name(ModuleName, static_library, ThisDirLibFileName, !IO), linked_target_file_name(ModuleName, shared_library, ThisDirSharedLibFileName, !IO), linked_target_file_name(ModuleName, java_archive, ThisDirJarFileName, !IO), - globals__io_set_option(use_grade_subdirs, bool(UseGradeSubdirs), !IO), + globals.io_set_option(use_grade_subdirs, bool(UseGradeSubdirs), !IO), - list__foldl2(remove_file, + list.foldl2(make_remove_file, [ExeFileName, LibFileName, SharedLibFileName, JarFileName, ThisDirExeFileName, ThisDirLibFileName, ThisDirSharedLibFileName, ThisDirJarFileName], !Info, !IO), - remove_file(ModuleName, ".init", !Info, !IO), + make_remove_file(ModuleName, ".init", !Info, !IO), remove_init_files(ModuleName, !Info, !IO). :- pred remove_init_files(module_name::in, make_info::in, make_info::out, io::di, io::uo) is det. remove_init_files(ModuleName, !Info, !IO) :- - globals__io_lookup_string_option(object_file_extension, ObjExt, !IO), - globals__io_lookup_string_option(pic_object_file_extension, PicObjExt, + globals.io_lookup_string_option(object_file_extension, ObjExt, !IO), + globals.io_lookup_string_option(pic_object_file_extension, PicObjExt, !IO), - globals__io_lookup_string_option(link_with_pic_object_file_extension, + globals.io_lookup_string_option(link_with_pic_object_file_extension, LinkWithPicObjExt, !IO), - list__foldl2(remove_file(ModuleName), ["_init.c", "_init" ++ ObjExt, + list.foldl2(make_remove_file(ModuleName), ["_init.c", "_init" ++ ObjExt, "_init" ++ PicObjExt, "_init" ++ LinkWithPicObjExt], !Info, !IO). @@ -1256,11 +1253,11 @@ remove_init_files(ModuleName, !Info, !IO) :- io::di, io::uo) is det. make_module_clean(ModuleName, !Info, !IO) :- - list__foldl2(remove_target_file(ModuleName), + list.foldl2(make_remove_target_file(ModuleName), [errors, c_code, c_header(mih), il_code, java_code], !Info, !IO), - list__foldl2(remove_file(ModuleName), [".used", ".prof"], !Info, !IO), + list.foldl2(make_remove_file(ModuleName), [".used", ".prof"], !Info, !IO), get_module_dependencies(ModuleName, MaybeImports, !Info, !IO), ( @@ -1271,26 +1268,26 @@ make_module_clean(ModuleName, !Info, !IO) :- FactTableFiles = [] ), - list__foldl2( + list.foldl2( (pred(FactTableFile::in, !.Info::in, !:Info::out, di, uo) is det --> fact_table_file_name(ModuleName, FactTableFile, ".c", no, FactTableCFile), - remove_file(FactTableCFile, !Info) + make_remove_file(FactTableCFile, !Info) ), FactTableFiles, !Info, !IO), CCodeModule = foreign_language_module_name(ModuleName, c), - remove_target_file(CCodeModule, c_code, !Info, !IO), + make_remove_target_file(CCodeModule, c_code, !Info, !IO), % Remove object and assembler files. - list__foldl2( + list.foldl2( (pred(PIC::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo) is det :- - remove_target_file(ModuleName, object_code(PIC), !Info, !IO), - remove_target_file(ModuleName, asm_code(PIC), !Info, !IO), - remove_target_file(ModuleName, foreign_object(PIC, c), !Info, !IO), - list__foldl2( + make_remove_target_file(ModuleName, object_code(PIC), !Info, !IO), + make_remove_target_file(ModuleName, asm_code(PIC), !Info, !IO), + make_remove_target_file(ModuleName, foreign_object(PIC, c), !Info, !IO), + list.foldl2( (pred(FactTableFile::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo) is det :- - remove_target_file(ModuleName, + make_remove_target_file(ModuleName, fact_table_object(PIC, FactTableFile), !Info, !IO) ), FactTableFiles, !Info, !IO) ), @@ -1298,15 +1295,15 @@ make_module_clean(ModuleName, !Info, !IO) :- % Remove IL foreign code files. CSharpModule = foreign_language_module_name(ModuleName, csharp), - remove_file(CSharpModule, foreign_language_file_extension(csharp), + make_remove_file(CSharpModule, foreign_language_file_extension(csharp), !Info, !IO), - remove_target_file(CSharpModule, foreign_il_asm(csharp), !Info, !IO), + make_remove_target_file(CSharpModule, foreign_il_asm(csharp), !Info, !IO), McppModule = foreign_language_module_name(ModuleName, managed_cplusplus), - remove_file(McppModule, + make_remove_file(McppModule, foreign_language_file_extension(managed_cplusplus), !Info, !IO), - remove_target_file(McppModule, foreign_il_asm(managed_cplusplus), + make_remove_target_file(McppModule, foreign_il_asm(managed_cplusplus), !Info, !IO). :- pred make_module_realclean(module_name::in, make_info::in, make_info::out, @@ -1314,7 +1311,7 @@ make_module_clean(ModuleName, !Info, !IO) :- make_module_realclean(ModuleName, !Info, !IO) :- make_module_clean(ModuleName, !Info, !IO), - list__foldl2(remove_target_file(ModuleName), + list.foldl2(make_remove_target_file(ModuleName), [ private_interface, long_interface, @@ -1325,9 +1322,9 @@ make_module_realclean(ModuleName, !Info, !IO) :- c_header(mh) ], !Info, !IO), - remove_file(ModuleName, module_dep_file_extension, !Info, !IO), - remove_file(ModuleName, ".imdg", !Info, !IO), - remove_file(ModuleName, ".request", !Info, !IO). + make_remove_file(ModuleName, make_module_dep_file_extension, !Info, !IO), + make_remove_file(ModuleName, ".imdg", !Info, !IO), + make_remove_file(ModuleName, ".request", !Info, !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/make.util.m b/compiler/make.util.m index 3b6fd274a..5ff975b5b 100644 --- a/compiler/make.util.m +++ b/compiler/make.util.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module make__util. +:- module make.util. :- interface. %-----------------------------------------------------------------------------% @@ -60,7 +60,7 @@ % Succeeded, !Info). % % Perform the given closure after updating the option_table in - % the globals in the io__state to contain the module-specific + % the globals in the io.state to contain the module-specific % options for the specified module and the extra options given % in the ExtraArgs. % Adds `--invoked-by-mmc-make' and `--use-subdirs' to the option @@ -75,7 +75,7 @@ % OptionArgs, ExtraArgs, Builder, Succeeded, !Info). % % Perform the given closure after updating the option_table in - % the globals in the io__state to contain the module-specific + % the globals in the io.state to contain the module-specific % options for the specified module and the extra options given % in ExtraArgs and OptionArgs % Does not add `--invoked-by-mmc-make' and `--use-subdirs' @@ -91,18 +91,18 @@ % to append to the error file for the given module. % :- pred build_with_output_redirect(module_name::in, - build(io__output_stream)::in(build), bool::out, + build(io.output_stream)::in(build), bool::out, make_info::in, make_info::out, io::di, io::uo) is det. % Produce an output stream which writes to the error file % for the given module. % -:- pred redirect_output(module_name::in, maybe(io__output_stream)::out, +:- pred redirect_output(module_name::in, maybe(io.output_stream)::out, make_info::in, make_info::out, io::di, io::uo) is det. % Close the module error output stream. % -:- pred unredirect_output(module_name::in, io__output_stream::in, +:- pred unredirect_output(module_name::in, io.output_stream::in, make_info::in, make_info::out, io::di, io::uo) is det. %-----------------------------------------------------------------------------% @@ -111,7 +111,7 @@ :- inst build2 == (pred(in, in, out, in, out, di, uo) is det). :- pred build_with_module_options_and_output_redirect(module_name::in, - list(string)::in, build2(list(string), io__output_stream)::in(build2), + list(string)::in, build2(list(string), io.output_stream)::in(build2), bool::out, make_info::in, make_info::out, io::di, io::uo) is det. %-----------------------------------------------------------------------------% @@ -170,20 +170,20 @@ % Remove the target file and the corresponding timestamp file. % -:- pred remove_target_file(target_file::in, make_info::in, make_info::out, +:- pred make_remove_target_file(target_file::in, make_info::in, make_info::out, io::di, io::uo) is det. % Remove the target file and the corresponding timestamp file. % -:- pred remove_target_file(module_name::in, module_target_type::in, +:- pred make_remove_target_file(module_name::in, module_target_type::in, make_info::in, make_info::out, io::di, io::uo) is det. - % remove_file(ModuleName, Extension, !Info). + % make_remove_file(ModuleName, Extension, !Info). % -:- pred remove_file(module_name::in, string::in, make_info::in, make_info::out, - io::di, io::uo) is det. +:- pred make_remove_file(module_name::in, string::in, + make_info::in, make_info::out, io::di, io::uo) is det. -:- pred remove_file(file_name::in, make_info::in, make_info::out, +:- pred make_remove_file(file_name::in, make_info::in, make_info::out, io::di, io::uo) is det. %-----------------------------------------------------------------------------% @@ -237,7 +237,7 @@ % :- pred maybe_make_target_message(target_file::in, io::di, io::uo) is det. -:- pred maybe_make_target_message(io__output_stream::in, target_file::in, +:- pred maybe_make_target_message(io.output_stream::in, target_file::in, io::di, io::uo) is det. % Write a message "Reanalysing invalid/suboptimal modules" if @@ -335,7 +335,7 @@ build_with_module_options_and_output_redirect(ModuleName, ExtraOptions, Succeeded, !Info, !IO). :- pred build_with_module_options_and_output_redirect_2(module_name::in, - build2(list(string), io__output_stream)::in(build2), list(string)::in, + build2(list(string), io.output_stream)::in(build2), list(string)::in, bool::out, make_info::in, make_info::out, io::di, io::uo) is det. build_with_module_options_and_output_redirect_2(ModuleName, Build, AllOptions, @@ -345,8 +345,8 @@ build_with_module_options_and_output_redirect_2(ModuleName, Build, AllOptions, Succeeded, !Info, !IO). :- pred build_with_module_options_and_output_redirect_3(list(string)::in, - build2(list(string), io__output_stream)::in(build2), - io__output_stream::in, bool::out, make_info::in, make_info::out, + build2(list(string), io.output_stream)::in(build2), + io.output_stream::in, bool::out, make_info::in, make_info::out, io::di, io::uo) is det. build_with_module_options_and_output_redirect_3(AllOptions, Build, @@ -394,7 +394,7 @@ build_with_module_options(InvokedByMmcMake, ModuleName, OptionVariables, Succeeded = no ; OptionsResult = yes(ModuleOptionArgs), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), % --invoked-by-mmc-make disables reading DEFAULT_MCFLAGS % from the environment (DEFAULT_MCFLAGS is included in @@ -412,7 +412,7 @@ build_with_module_options(InvokedByMmcMake, ModuleName, OptionVariables, InvokedByMake = [] ), - AllOptionArgs = list__condense([InvokedByMake, ModuleOptionArgs, + AllOptionArgs = list.condense([InvokedByMake, ModuleOptionArgs, OptionArgs, ExtraOptions, UseSubdirs]), handle_options(AllOptionArgs, OptionsErrors, _, _, _, !IO), ( @@ -424,7 +424,7 @@ build_with_module_options(InvokedByMmcMake, ModuleName, OptionVariables, OptionsErrors = [], Build(AllOptionArgs, Succeeded, Info0, Info, !IO), MaybeInfo = yes(Info), - globals__io_set_globals(unsafe_promise_unique(Globals), !IO) + globals.io_set_globals(unsafe_promise_unique(Globals), !IO) ) ). @@ -433,85 +433,85 @@ redirect_output(_ModuleName, MaybeErrorStream, !Info, !IO) :- % the part of the error file that relates to the current command. It will % be appended to the error file later. - io__make_temp(ErrorFileName, !IO), - io__open_output(ErrorFileName, ErrorFileRes, !IO), + io.make_temp(ErrorFileName, !IO), + io.open_output(ErrorFileName, ErrorFileRes, !IO), ( ErrorFileRes = ok(ErrorOutputStream), MaybeErrorStream = yes(ErrorOutputStream) ; ErrorFileRes = error(IOError), MaybeErrorStream = no, - io__write_string("** Error opening `", !IO), - io__write_string(ErrorFileName, !IO), - io__write_string("' for output: ", !IO), - io__error_message(IOError, Msg), - io__write_string(Msg, !IO), - io__nl(!IO) + io.write_string("** Error opening `", !IO), + io.write_string(ErrorFileName, !IO), + io.write_string("' for output: ", !IO), + io.error_message(IOError, Msg), + io.write_string(Msg, !IO), + io.nl(!IO) ). unredirect_output(ModuleName, ErrorOutputStream, !Info, !IO) :- - io__output_stream_name(ErrorOutputStream, TmpErrorFileName, !IO), - io__close_output(ErrorOutputStream, !IO), + io.output_stream_name(ErrorOutputStream, TmpErrorFileName, !IO), + io.close_output(ErrorOutputStream, !IO), - io__open_input(TmpErrorFileName, TmpErrorInputRes, !IO), + io.open_input(TmpErrorFileName, TmpErrorInputRes, !IO), ( TmpErrorInputRes = ok(TmpErrorInputStream), module_name_to_file_name(ModuleName, ".err", yes, ErrorFileName, !IO), - ( set__member(ModuleName, !.Info ^ error_file_modules) -> - io__open_append(ErrorFileName, ErrorFileRes, !IO) + ( set.member(ModuleName, !.Info ^ error_file_modules) -> + io.open_append(ErrorFileName, ErrorFileRes, !IO) ; - io__open_output(ErrorFileName, ErrorFileRes, !IO) + io.open_output(ErrorFileName, ErrorFileRes, !IO) ), ( ErrorFileRes = ok(ErrorFileOutputStream), - globals__io_lookup_int_option(output_compile_error_lines, + globals.io_lookup_int_option(output_compile_error_lines, LinesToWrite, !IO), - io__output_stream(CurrentOutputStream, !IO), - io__input_stream_foldl2_io(TmpErrorInputStream, + io.output_stream(CurrentOutputStream, !IO), + io.input_stream_foldl2_io(TmpErrorInputStream, write_error_char(ErrorFileOutputStream, CurrentOutputStream), LinesToWrite, TmpFileInputRes, !IO), ( TmpFileInputRes = ok(_) ; TmpFileInputRes = error(_, TmpFileInputError), - io__write_string("Error reading `", !IO), - io__write_string(TmpErrorFileName, !IO), - io__write_string("': ", !IO), - io__write_string(io__error_message(TmpFileInputError), !IO), - io__nl(!IO) + io.write_string("Error reading `", !IO), + io.write_string(TmpErrorFileName, !IO), + io.write_string("': ", !IO), + io.write_string(io.error_message(TmpFileInputError), !IO), + io.nl(!IO) ), - io__close_output(ErrorFileOutputStream, !IO), + io.close_output(ErrorFileOutputStream, !IO), !:Info = !.Info ^ error_file_modules := - set__insert(!.Info ^ error_file_modules, ModuleName) + set.insert(!.Info ^ error_file_modules, ModuleName) ; ErrorFileRes = error(Error), - io__write_string("Error opening `", !IO), - io__write_string(TmpErrorFileName, !IO), - io__write_string("': ", !IO), - io__write_string(io__error_message(Error), !IO), - io__nl(!IO) + io.write_string("Error opening `", !IO), + io.write_string(TmpErrorFileName, !IO), + io.write_string("': ", !IO), + io.write_string(io.error_message(Error), !IO), + io.nl(!IO) ), - io__close_input(TmpErrorInputStream, !IO) + io.close_input(TmpErrorInputStream, !IO) ; TmpErrorInputRes = error(Error), - io__write_string("Error opening `", !IO), - io__write_string(TmpErrorFileName, !IO), - io__write_string("': ", !IO), - io__write_string(io__error_message(Error), !IO), - io__nl(!IO) + io.write_string("Error opening `", !IO), + io.write_string(TmpErrorFileName, !IO), + io.write_string("': ", !IO), + io.write_string(io.error_message(Error), !IO), + io.nl(!IO) ), - io__remove_file(TmpErrorFileName, _, !IO). + io.remove_file(TmpErrorFileName, _, !IO). -:- pred write_error_char(io__output_stream::in, io__output_stream::in, +:- pred write_error_char(io.output_stream::in, io.output_stream::in, char::in, int::in, int::out, io::di, io::uo) is det. write_error_char(FullOutputStream, PartialOutputStream, Char, !LinesRemaining, !IO) :- - io__write_char(FullOutputStream, Char, !IO), + io.write_char(FullOutputStream, Char, !IO), ( !.LinesRemaining > 0 -> - io__write_char(PartialOutputStream, Char, !IO), + io.write_char(PartialOutputStream, Char, !IO), ( Char = '\n' -> !:LinesRemaining = !.LinesRemaining - 1 ; @@ -533,7 +533,7 @@ write_error_char(FullOutputStream, PartialOutputStream, Char, get_timestamp_file_timestamp(ModuleName - FileType, MaybeTimestamp, !Info, !IO) :- - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), ( TimestampExt = timestamp_extension(Globals, FileType) -> module_name_to_file_name(ModuleName, TimestampExt, no, FileName, !IO) ; @@ -544,17 +544,17 @@ get_timestamp_file_timestamp(ModuleName - FileType, MaybeTimestamp, % in the current directory. Timestamp files are % only used when processing a module, and only % modules in the current directory are processed. - SearchDirs = [dir__this_directory], + SearchDirs = [dir.this_directory], get_file_timestamp(SearchDirs, FileName, MaybeTimestamp, !Info, !IO). get_dependency_timestamp(file(FileName, MaybeOption), MaybeTimestamp, !Info, !IO) :- ( MaybeOption = yes(Option), - globals__io_lookup_accumulating_option(Option, SearchDirs, !IO) + globals.io_lookup_accumulating_option(Option, SearchDirs, !IO) ; MaybeOption = no, - SearchDirs = [dir__this_directory] + SearchDirs = [dir.this_directory] ), get_file_timestamp(SearchDirs, FileName, MaybeTimestamp, !Info, !IO). get_dependency_timestamp(target(Target), MaybeTimestamp, !Info, !IO) :- @@ -636,7 +636,7 @@ get_target_timestamp_2(Search, ModuleName - FileType, MaybeTimestamp, get_search_directories(FileType, SearchDirs, !IO) ; Search = no, - SearchDirs = [dir__this_directory] + SearchDirs = [dir.this_directory] ), get_file_timestamp(SearchDirs, FileName, MaybeTimestamp0, !Info, !IO), ( @@ -653,7 +653,7 @@ get_target_timestamp_2(Search, ModuleName - FileType, MaybeTimestamp, get_module_dependencies(ModuleName, MaybeImports, !Info, !IO), ( MaybeImports = yes(Imports), - Imports ^ module_dir \= dir__this_directory + Imports ^ module_dir \= dir.this_directory -> MaybeTimestamp = ok(oldest_timestamp), !:Info = !.Info ^ file_timestamps ^ elem(FileName) @@ -682,7 +682,7 @@ get_file_name(Search, ModuleName - FileType, FileName, !Info, !IO) :- module_name_to_file_name(ModuleName, ".m", no, FileName, !IO) ) ; - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), MaybeExt = target_extension(Globals, FileType), ( MaybeExt = yes(Ext), @@ -704,20 +704,20 @@ get_file_timestamp(SearchDirs, FileName, MaybeTimestamp, !Info, !IO) :- ( MaybeTimestamp0 = !.Info ^ file_timestamps ^ elem(FileName) -> MaybeTimestamp = MaybeTimestamp0 ; - io__input_stream(OldInputStream, !IO), + io.input_stream(OldInputStream, !IO), search_for_file(SearchDirs, FileName, SearchResult, !IO), ( SearchResult = ok(_) -> - io__input_stream_name(FullFileName, !IO), - io__set_input_stream(OldInputStream, FileStream, !IO), - io__close_input(FileStream, !IO), - io__file_modification_time(FullFileName, TimeTResult, !IO), + io.input_stream_name(FullFileName, !IO), + io.set_input_stream(OldInputStream, FileStream, !IO), + io.close_input(FileStream, !IO), + io.file_modification_time(FullFileName, TimeTResult, !IO), ( TimeTResult = ok(TimeT), Timestamp = time_t_to_timestamp(TimeT), MaybeTimestamp = ok(Timestamp) ; TimeTResult = error(Error), - MaybeTimestamp = error(io__error_message(Error)) + MaybeTimestamp = error(io.error_message(Error)) ), !:Info = !.Info ^ file_timestamps ^ elem(FileName) := MaybeTimestamp @@ -733,18 +733,18 @@ get_search_directories(FileType, SearchDirs, !IO) :- MaybeOpt = search_for_file_type(FileType), ( MaybeOpt = yes(SearchDirOpt), - globals__io_lookup_accumulating_option(SearchDirOpt, SearchDirs0, !IO), + globals.io_lookup_accumulating_option(SearchDirOpt, SearchDirs0, !IO), % Make sure the current directory is searched % for C headers and libraries. SearchDirs = - ( list__member(dir__this_directory, SearchDirs0) -> + ( list.member(dir.this_directory, SearchDirs0) -> SearchDirs0 ; - [dir__this_directory | SearchDirs0] + [dir.this_directory | SearchDirs0] ) ; MaybeOpt = no, - SearchDirs = [dir__this_directory] + SearchDirs = [dir.this_directory] ). find_oldest_timestamp(error(_) @ MaybeTimestamp, _) = MaybeTimestamp. @@ -758,42 +758,42 @@ find_oldest_timestamp(ok(Timestamp1), ok(Timestamp2)) = ok(Timestamp) :- %-----------------------------------------------------------------------------% -remove_target_file(ModuleName - FileType, !Info, !IO) :- - remove_target_file(ModuleName, FileType, !Info, !IO). +make_remove_target_file(ModuleName - FileType, !Info, !IO) :- + make_remove_target_file(ModuleName, FileType, !Info, !IO). -remove_target_file(ModuleName, FileType, !Info, !IO) :- - globals__io_get_globals(Globals, !IO), +make_remove_target_file(ModuleName, FileType, !Info, !IO) :- + globals.io_get_globals(Globals, !IO), module_target_to_file_name(ModuleName, FileType, no, FileName, !IO), - remove_file(FileName, !Info, !IO), + make_remove_file(FileName, !Info, !IO), ( TimestampExt = timestamp_extension(Globals, FileType) -> - remove_file(ModuleName, TimestampExt, !Info, !IO) + make_remove_file(ModuleName, TimestampExt, !Info, !IO) ; true ). -remove_file(ModuleName, Ext, !Info, !IO) :- +make_remove_file(ModuleName, Ext, !Info, !IO) :- module_name_to_file_name(ModuleName, Ext, no, FileName, !IO), - remove_file(FileName, !Info, !IO). + make_remove_file(FileName, !Info, !IO). -remove_file(FileName, !Info, !IO) :- +make_remove_file(FileName, !Info, !IO) :- verbose_msg(report_remove_file(FileName), !IO), - io__remove_file(FileName, _, !IO), + io.remove_file(FileName, _, !IO), !:Info = !.Info ^ file_timestamps := - map__delete(!.Info ^ file_timestamps, FileName). + map.delete(!.Info ^ file_timestamps, FileName). :- pred report_remove_file(string::in, io::di, io::uo) is det. report_remove_file(FileName, !IO) :- - io__write_string("Removing ", !IO), - io__write_string(FileName, !IO), - io__nl(!IO). + io.write_string("Removing ", !IO), + io.write_string(FileName, !IO), + io.nl(!IO). %-----------------------------------------------------------------------------% -make_target_list(Ks, V) = list__map((func(K) = K - V), Ks). +make_target_list(Ks, V) = list.map((func(K) = K - V), Ks). make_dependency_list(ModuleNames, FileType) = - list__map((func(Module) = target(Module - FileType)), ModuleNames). + list.map((func(Module) = target(Module - FileType)), ModuleNames). target_extension(_, source) = yes(".m"). target_extension(_, errors) = yes(".err"). @@ -823,13 +823,13 @@ target_extension(_, foreign_il_asm(_)) = no. target_extension(_, fact_table_object(_, _)) = no. linked_target_file_name(ModuleName, executable, FileName) --> - globals__io_lookup_string_option(executable_file_extension, Ext), + globals.io_lookup_string_option(executable_file_extension, Ext), module_name_to_file_name(ModuleName, Ext, no, FileName). linked_target_file_name(ModuleName, static_library, FileName) --> - globals__io_lookup_string_option(library_extension, Ext), + globals.io_lookup_string_option(library_extension, Ext), module_name_to_lib_file_name("lib", ModuleName, Ext, no, FileName). linked_target_file_name(ModuleName, shared_library, FileName) --> - globals__io_lookup_string_option(shared_library_extension, Ext), + globals.io_lookup_string_option(shared_library_extension, Ext), module_name_to_lib_file_name("lib", ModuleName, Ext, no, FileName). linked_target_file_name(ModuleName, java_archive, FileName) --> module_name_to_file_name(ModuleName, ".jar", no, FileName). @@ -852,7 +852,7 @@ module_target_to_search_file_name(ModuleName, TargetType, FileName, !IO) :- module_target_to_file_name(ModuleName, TargetType, MkDir, Search, FileName, !IO) :- - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), target_extension(Globals, TargetType) = MaybeExt, ( MaybeExt = yes(Ext), @@ -911,7 +911,7 @@ timestamp_extension(_, intermodule_interface) = ".optdate". timestamp_extension(_, analysis_registry) = ".analysis_date". timestamp_extension(_, c_code) = ".c_date". timestamp_extension(Globals, c_header(_)) = Ext :- - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), Ext = timestamp_extension(Globals, (Target = asm -> asm_code(non_pic) ; c_code)). timestamp_extension(_, il_code) = ".il_date". @@ -970,21 +970,21 @@ target_is_grade_or_arch_dependent(fact_table_object(_, _), yes). %-----------------------------------------------------------------------------% debug_msg(P, !IO) :- - globals__io_lookup_bool_option(debug_make, Debug, !IO), + globals.io_lookup_bool_option(debug_make, Debug, !IO), ( Debug = yes, P(!IO), - io__flush_output(!IO) + io.flush_output(!IO) ; Debug = no ). verbose_msg(P, !IO) :- - globals__io_lookup_bool_option(verbose_make, Verbose, !IO), + globals.io_lookup_bool_option(verbose_make, Verbose, !IO), ( Verbose = yes, P(!IO), - io__flush_output(!IO) + io.flush_output(!IO) ; Verbose = no ). @@ -993,69 +993,69 @@ debug_file_msg(TargetFile, Msg, !IO) :- debug_msg( (pred(di, uo) is det --> write_target_file(TargetFile), - io__write_string(": "), - io__write_string(Msg), - io__nl + io.write_string(": "), + io.write_string(Msg), + io.nl ), !IO). write_dependency_file(target(TargetFile), !IO) :- write_target_file(TargetFile, !IO). write_dependency_file(file(FileName, _), !IO) :- - io__write_string(FileName, !IO). + io.write_string(FileName, !IO). write_target_file(ModuleName - FileType, !IO) :- module_target_to_file_name(ModuleName, FileType, no, FileName, !IO), - io__write_string(FileName, !IO). + io.write_string(FileName, !IO). maybe_make_linked_target_message(TargetFile, !IO) :- verbose_msg( (pred(di, uo) is det --> - io__write_string("Making "), - io__write_string(TargetFile), - io__nl + io.write_string("Making "), + io.write_string(TargetFile), + io.nl ), !IO). maybe_make_target_message(TargetFile, !IO) :- - io__output_stream(OutputStream, !IO), + io.output_stream(OutputStream, !IO), maybe_make_target_message(OutputStream, TargetFile, !IO). maybe_make_target_message(OutputStream, TargetFile, !IO) :- verbose_msg( (pred(di, uo) is det --> - io__set_output_stream(OutputStream, OldOutputStream), - io__write_string("Making "), + io.set_output_stream(OutputStream, OldOutputStream), + io.write_string("Making "), write_target_file(TargetFile), - io__nl, - io__set_output_stream(OldOutputStream, _) + io.nl, + io.set_output_stream(OldOutputStream, _) ), !IO). maybe_reanalyse_modules_message(!IO) :- - io__output_stream(OutputStream, !IO), + io.output_stream(OutputStream, !IO), verbose_msg( (pred(!.IO::di, !:IO::uo) is det :- - io__set_output_stream(OutputStream, OldOutputStream, !IO), - io__write_string("Reanalysing invalid/suboptimal modules\n", !IO), - io__set_output_stream(OldOutputStream, _, !IO) + io.set_output_stream(OutputStream, OldOutputStream, !IO), + io.write_string("Reanalysing invalid/suboptimal modules\n", !IO), + io.set_output_stream(OldOutputStream, _, !IO) ), !IO). target_file_error(TargetFile, !IO) :- - io__write_string("** Error making `", !IO), + io.write_string("** Error making `", !IO), write_target_file(TargetFile, !IO), - io__write_string("'.\n", !IO). + io.write_string("'.\n", !IO). file_error(TargetFile, !IO) :- - io__write_string("** Error making `", !IO), - io__write_string(TargetFile, !IO), - io__write_string("'.\n", !IO). + io.write_string("** Error making `", !IO), + io.write_string(TargetFile, !IO), + io.write_string("'.\n", !IO). maybe_warn_up_to_date_target(Target, !Info, !IO) :- - globals__io_lookup_bool_option(warn_up_to_date, Warn, !IO), + globals.io_lookup_bool_option(warn_up_to_date, Warn, !IO), ( Warn = yes, - ( set__member(Target, !.Info ^ command_line_targets) -> - io__write_string("** Nothing to be done for `", !IO), + ( set.member(Target, !.Info ^ command_line_targets) -> + io.write_string("** Nothing to be done for `", !IO), write_module_or_linked_target(Target, !IO), - io__write_string("'.\n", !IO) + io.write_string("'.\n", !IO) ; true ) @@ -1063,14 +1063,14 @@ maybe_warn_up_to_date_target(Target, !Info, !IO) :- Warn = no ), !:Info = !.Info ^ command_line_targets := - set__delete(!.Info ^ command_line_targets, Target). + set.delete(!.Info ^ command_line_targets, Target). maybe_symlink_or_copy_linked_target_message(Target, !IO) :- verbose_msg( (pred(!.IO::di, !:IO::uo) is det :- - io__write_string("Making symlink/copy of ", !IO), + io.write_string("Making symlink/copy of ", !IO), write_module_or_linked_target(Target, !IO), - io__write_string("\n", !IO) + io.write_string("\n", !IO) ), !IO). :- pred write_module_or_linked_target(pair(module_name, target_type)::in, @@ -1084,7 +1084,7 @@ write_module_or_linked_target(ModuleName - FileType, !IO) :- FileType = linked_target(LinkedTargetType), linked_target_file_name(ModuleName, LinkedTargetType, FileName, !IO), - io__write_string(FileName, !IO) + io.write_string(FileName, !IO) ; FileType = misc_target(_), unexpected(this_file, diff --git a/compiler/make_hlds_error.m b/compiler/make_hlds_error.m index 6b21e1f88..e68bd2a56 100644 --- a/compiler/make_hlds_error.m +++ b/compiler/make_hlds_error.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__make_hlds_error. +:- module hlds.make_hlds.make_hlds_error. :- interface. :- import_module hlds.hlds_module. @@ -52,7 +52,7 @@ :- pred maybe_undefined_pred_error(sym_name::in, int::in, pred_or_func::in, import_status::in, bool::in, prog_context::in, string::in, io::di, io::uo) is det. - + % Emit an error if something is exported. (Used to check for % when things shouldn't be exported.) % @@ -96,7 +96,7 @@ multiple_def_error(Status, Name, Arity, DefType, Context, OrigContext, fixed(DefType), sym_name_and_arity(Name / Arity), suffix(".")], write_error_pieces(OrigContext, 0, OrigPieces, !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), FoundError = yes ; % We don't take care not to read the same declaration @@ -113,53 +113,53 @@ undefined_pred_or_func_error(Name, Arity, Context, Description, !IO) :- sym_name_and_arity(Name / Arity), words("without corresponding `pred' or `func' declaration.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). undefined_mode_error(Name, Arity, Context, Description, !IO) :- Pieces = [words("Error:"), words(Description), words("for"), sym_name_and_arity(Name / Arity), words("specifies non-existent mode.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). undeclared_mode_error(ModeList, VarSet, PredId, PredInfo, ModuleInfo, Context, !IO) :- - prog_out__write_context(Context, !IO), - io__write_string("In clause for ", !IO), - hlds_out__write_pred_id(ModuleInfo, PredId, !IO), - io__write_string(":\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string("In clause for ", !IO), + hlds_out.write_pred_id(ModuleInfo, PredId, !IO), + io.write_string(":\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string( " error: mode annotation specifies undeclared mode\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" `", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" `", !IO), strip_builtin_qualifiers_from_mode_list(ModeList, StrippedModeList), PredOrFunc = pred_info_is_pred_or_func(PredInfo), Name = pred_info_name(PredInfo), MaybeDet = no, - mercury_output_mode_subdecl(PredOrFunc, varset__coerce(VarSet), + mercury_output_mode_subdecl(PredOrFunc, varset.coerce(VarSet), unqualified(Name), StrippedModeList, MaybeDet, Context, !IO), - io__write_string("'\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" of ", !IO), - hlds_out__write_pred_id(ModuleInfo, PredId, !IO), - io__write_string(".\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + io.write_string("'\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" of ", !IO), + hlds_out.write_pred_id(ModuleInfo, PredId, !IO), + io.write_string(".\n", !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ProcIds = pred_info_all_procids(PredInfo), ( ProcIds = [], - prog_out__write_context(Context, !IO), - io__write_string(" (There are no declared modes for this ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" (There are no declared modes for this ", !IO), write_pred_or_func(PredOrFunc, !IO), - io__write_string(".)\n", !IO) + io.write_string(".)\n", !IO) ; ProcIds = [_ | _], ( VerboseErrors = yes, - io__write_string("\tThe declared modes for this ", !IO), + io.write_string("\tThe declared modes for this ", !IO), write_pred_or_func(PredOrFunc, !IO), - io__write_string(" are the following:\n", !IO), - list__foldl(output_mode_decl_for_pred_info(PredInfo), ProcIds, !IO) + io.write_string(" are the following:\n", !IO), + list.foldl(output_mode_decl_for_pred_info(PredInfo), ProcIds, !IO) ; VerboseErrors = no, globals.io_set_extra_error_info(yes, !IO) @@ -170,9 +170,9 @@ undeclared_mode_error(ModeList, VarSet, PredId, PredInfo, ModuleInfo, io::di, io::uo) is det. output_mode_decl_for_pred_info(PredInfo, ProcId, !IO) :- - io__write_string("\t\t:- mode ", !IO), + io.write_string("\t\t:- mode ", !IO), output_mode_decl(ProcId, PredInfo, !IO), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). % This is not considered an unconditional error anymore: % if there is no `:- pred' or `:- func' declaration, @@ -185,7 +185,7 @@ maybe_undefined_pred_error(Name, Arity, PredOrFunc, Status, IsClassMethod, Context, Description, !IO) :- status_defined_in_this_module(Status, DefinedInThisModule), status_is_exported(Status, IsExported), - globals__io_lookup_bool_option(infer_types, InferTypes, !IO), + globals.io_lookup_bool_option(infer_types, InferTypes, !IO), ( DefinedInThisModule = yes, IsExported = no, @@ -200,26 +200,24 @@ maybe_undefined_pred_error(Name, Arity, PredOrFunc, Status, IsClassMethod, fixed("`" ++ pred_or_func_to_str(PredOrFunc) ++ "'"), words("declaration.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). % % This predicate is currently unused. -% +% % :- pred clause_for_imported_pred_error(sym_name::in, arity::in, % pred_or_func::in, prog_context::in, io::di, io::uo) is det. -% +% % clause_for_imported_pred_error(Name, Arity, PredOrFunc, Context, !IO) :- % Pieces = [words("Error: clause for imported"), % pred_or_func(PredOrFunc), % sym_name_and_arity(Name / Arity), % suffix(".")], % write_error_pieces(Context, 0, Pieces, !IO), -% io__set_exit_status(1, !IO). +% io.set_exit_status(1, !IO). error_is_exported(Context, Message, !IO) :- - Error = [ words("Error:"), - fixed(Message), - words("in module interface.")], + Error = [words("Error:"), fixed(Message), words("in module interface.")], write_error_pieces(Context, 0, Error, !IO), io.set_exit_status(1, !IO). diff --git a/compiler/make_hlds_passes.m b/compiler/make_hlds_passes.m index d816ec090..5f8974ecc 100644 --- a/compiler/make_hlds_passes.m +++ b/compiler/make_hlds_passes.m @@ -6,7 +6,7 @@ % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__make_hlds_passes. +:- module hlds.make_hlds.make_hlds_passes. :- interface. :- import_module hlds.hlds_module. @@ -49,7 +49,7 @@ qual_info::in, qual_info::out, io::di, io::uo) is det. :- pred add_stratified_pred(string::in, sym_name::in, arity::in, - term__context::in, module_info::in, module_info::out, io::di, io::uo) + term.context::in, module_info::in, module_info::out, io::di, io::uo) is det. % add_pred_marker(PragmaName, Name, Arity, Status, @@ -67,7 +67,7 @@ :- inst add_marker_pred_info == (pred(in, out) is det). :- pred do_add_pred_marker(string::in, sym_name::in, arity::in, - import_status::in, bool::in, term__context::in, + import_status::in, bool::in, term.context::in, add_marker_pred_info::in(add_marker_pred_info), module_info::in, module_info::out, list(pred_id)::out, io::di, io::uo) is det. @@ -129,13 +129,13 @@ do_parse_tree_to_hlds(module(Name, Items), MQInfo0, EqvMap, ModuleInfo, QualInfo, InvalidTypes, InvalidModes, !IO) :- some [!Module] ( - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), mq_info_get_partial_qualifier_info(MQInfo0, PQInfo), module_info_init(Name, Items, Globals, PQInfo, no, !:Module), add_item_list_decls_pass_1(Items, item_status(local, may_be_unqualified), !Module, no, InvalidModes0, !IO), - globals__io_lookup_bool_option(statistics, Statistics, !IO), + globals.io_lookup_bool_option(statistics, Statistics, !IO), maybe_write_string(Statistics, "% Processed all items in pass 1\n", !IO), maybe_report_stats(Statistics, !IO), @@ -153,7 +153,7 @@ do_parse_tree_to_hlds(module(Name, Items), MQInfo0, EqvMap, ModuleInfo, ( InvalidTypes1 = no, module_info_get_type_table(!.Module, Types), - map__foldl3(process_type_defn, Types, no, InvalidTypes2, !Module, + map.foldl3(process_type_defn, Types, no, InvalidTypes2, !Module, !IO) ; InvalidTypes1 = yes, @@ -166,11 +166,11 @@ do_parse_tree_to_hlds(module(Name, Items), MQInfo0, EqvMap, ModuleInfo, Name = mercury_public_builtin_module, compiler_generated_rtti_for_builtins(!.Module) -> - varset__init(TVarSet), + varset.init(TVarSet), Body = abstract_type(non_solver_type), - term__context_init(Context), + term.context_init(Context), Status = local, - list__foldl( + list.foldl( (pred(TypeCtor::in, M0::in, M::out) is det :- construct_type(TypeCtor, [], Type), add_special_preds(TVarSet, Type, TypeCtor, Body, Context, @@ -205,12 +205,12 @@ do_parse_tree_to_hlds(module(Name, Items), MQInfo0, EqvMap, ModuleInfo, ). check_for_errors(P, FoundError, !ModuleInfo, !IO) :- - io__get_exit_status(BeforeStatus, !IO), - io__set_exit_status(0, !IO), + io.get_exit_status(BeforeStatus, !IO), + io.set_exit_status(0, !IO), module_info_get_num_errors(!.ModuleInfo, BeforeNumErrors), P(!ModuleInfo, !IO), module_info_get_num_errors(!.ModuleInfo, AfterNumErrors), - io__get_exit_status(AfterStatus, !IO), + io.get_exit_status(AfterStatus, !IO), ( AfterStatus = 0, BeforeNumErrors = AfterNumErrors @@ -220,7 +220,7 @@ check_for_errors(P, FoundError, !ModuleInfo, !IO) :- FoundError = yes ), ( BeforeStatus \= 0 -> - io__set_exit_status(BeforeStatus, !IO) + io.set_exit_status(BeforeStatus, !IO) ; true ). @@ -243,7 +243,7 @@ add_item_list_decls_pass_1([Item - Context | Items], Status0, !ModuleInfo, !InvalidModes, !IO) :- add_item_decl_pass_1(Item, Context, Status0, Status1, !ModuleInfo, NewInvalidModes, !IO), - !:InvalidModes = bool__or(!.InvalidModes, NewInvalidModes), + !:InvalidModes = bool.or(!.InvalidModes, NewInvalidModes), add_item_list_decls_pass_1(Items, Status1, !ModuleInfo, !InvalidModes, !IO). @@ -427,7 +427,7 @@ add_item_decl_pass_1(Item, Context, !Status, !ModuleInfo, no, !IO) :- ; ModuleDefn = transitively_imported -> true ; - prog_out__write_context(Context, !IO), + prog_out.write_context(Context, !IO), report_warning("Warning: declaration not yet implemented.\n", !IO) ). add_item_decl_pass_1(Item, _, !Status, !ModuleInfo, no, !IO) :- @@ -543,7 +543,7 @@ add_item_decl_pass_2(Item, _Context, !Status, !ModuleInfo, !IO) :- PredOrFunc = predicate ; PredOrFunc = function, - list__length(TypesAndModes, Arity), + list.length(TypesAndModes, Arity), adjust_func_arity(function, FuncArity, Arity), module_info_get_predicate_table(!.ModuleInfo, PredTable0), ( @@ -800,7 +800,7 @@ add_item_clause(Item, !Status, Context, !ModuleInfo, !QualInfo, !IO) :- PredOrFunc = predicate ; PredOrFunc = function, - list__length(TypesAndModes, PredArity), + list.length(TypesAndModes, PredArity), adjust_func_arity(function, FuncArity, PredArity), maybe_check_field_access_function(SymName, FuncArity, !.Status, Context, !.ModuleInfo, !IO) @@ -817,7 +817,7 @@ add_item_clause(Item, !Status, _, !ModuleInfo, !QualInfo, !IO) :- apply_to_recompilation_info( (pred(RecompInfo0::in, RecompInfo::out) is det :- RecompInfo = RecompInfo0 ^ version_numbers ^ - map__elem(ModuleName) := ModuleVersionNumbers + map.elem(ModuleName) := ModuleVersionNumbers ), !QualInfo) ; module_defn_update_import_status(Defn, ItemStatus1) -> @@ -850,7 +850,7 @@ add_item_clause(Item, !Status, Context, !ModuleInfo, !QualInfo, !IO) :- ; Pragma = tabled(Type, Name, Arity, PredOrFunc, Mode) -> - globals__io_lookup_bool_option(type_layout, TypeLayout, !IO), + globals.io_lookup_bool_option(type_layout, TypeLayout, !IO), ( TypeLayout = yes, module_add_pragma_tabled(Type, Name, Arity, PredOrFunc, @@ -858,14 +858,14 @@ add_item_clause(Item, !Status, Context, !ModuleInfo, !QualInfo, !IO) :- ; TypeLayout = no, module_info_incr_errors(!ModuleInfo), - prog_out__write_context(Context, !IO), - io__write_string("Error: `:- pragma ", !IO), + prog_out.write_context(Context, !IO), + io.write_string("Error: `:- pragma ", !IO), EvalMethodS = eval_method_to_one_string(Type), - io__write_string(EvalMethodS, !IO), - io__write_string("' declaration requires the type_ctor_layout\n", + io.write_string(EvalMethodS, !IO), + io.write_string("' declaration requires the type_ctor_layout\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" structures. Use " ++ + prog_out.write_context(Context, !IO), + io.write_string(" structures. Use " ++ "the --type-layout flag to enable them.\n", !IO) ) ; @@ -877,7 +877,7 @@ add_item_clause(Item, !Status, Context, !ModuleInfo, !QualInfo, !IO) :- % name length. So we ignore these pragmas for the % Java back-end. % - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( Target = java -> true ; @@ -930,7 +930,7 @@ add_item_clause(promise(PromiseType, Goal, VarSet, UnivVars), % type variables as this implicity adds a universal % quantification of the typevariables needed. % - term__var_list_to_term_list(UnivVars, HeadVars), + term.var_list_to_term_list(UnivVars, HeadVars), % extra error checking for promise ex declarations ( PromiseType \= true -> @@ -1377,9 +1377,9 @@ module_defn_update_import_status(abstract_imported, add_promise_clause(PromiseType, HeadVars, VarSet, Goal, Context, Status, !ModuleInfo, !QualInfo, !IO) :- - term__context_line(Context, Line), - term__context_file(Context, File), - string__format(prog_out__promise_to_string(PromiseType) ++ + term.context_line(Context, Line), + term.context_file(Context, File), + string.format(prog_out.promise_to_string(PromiseType) ++ "__%d__%s", [i(Line), s(File)], Name), % % Promise declarations are recorded as a predicate with a @@ -1391,7 +1391,7 @@ add_promise_clause(PromiseType, HeadVars, VarSet, Goal, Context, Status, % % becomes % - % promise__lineno_filename(A, B, R) :- + % promise.lineno_filename(A, B, R) :- % ( R = A + B <=> R = B + A ). % GoalType = promise(PromiseType) , @@ -1406,10 +1406,10 @@ add_stratified_pred(PragmaName, Name, Arity, Context, !ModuleInfo, !IO) :- Name, Arity, PredIds) -> module_info_get_stratified_preds(!.ModuleInfo, StratPredIds0), - set__insert_list(StratPredIds0, PredIds, StratPredIds), + set.insert_list(StratPredIds0, PredIds, StratPredIds), module_info_set_stratified_preds(StratPredIds, !ModuleInfo) ; - string__append_list(["`:- pragma ", PragmaName, "' declaration"], + string.append_list(["`:- pragma ", PragmaName, "' declaration"], Description), undefined_pred_or_func_error(Name, Arity, Context, Description, !IO), module_info_incr_errors(!ModuleInfo) @@ -1457,7 +1457,7 @@ do_add_pred_marker(PragmaName, Name, Arity, Status, MustBeExported, Context, module_info_set_predicate_table(PredTable, !ModuleInfo) ; PredIds = [], - string__append_list(["`:- pragma ", PragmaName, "' declaration"], + string.append_list(["`:- pragma ", PragmaName, "' declaration"], Description), undefined_pred_or_func_error(Name, Arity, Context, Description, !IO), module_info_incr_errors(!ModuleInfo) @@ -1499,9 +1499,9 @@ module_mark_as_external(PredName, Arity, Context, !ModuleInfo, !IO) :- module_mark_preds_as_external([], !ModuleInfo). module_mark_preds_as_external([PredId | PredIds], !ModuleInfo) :- module_info_preds(!.ModuleInfo, Preds0), - map__lookup(Preds0, PredId, PredInfo0), + map.lookup(Preds0, PredId, PredInfo0), pred_info_mark_as_external(PredInfo0, PredInfo), - map__det_update(Preds0, PredId, PredInfo, Preds), + map.det_update(Preds0, PredId, PredInfo, Preds), module_info_set_preds(Preds, !ModuleInfo), module_mark_preds_as_external(PredIds, !ModuleInfo). @@ -1515,10 +1515,10 @@ module_mark_preds_as_external([PredId | PredIds], !ModuleInfo) :- pragma_check_markers(_, [], _, no). pragma_check_markers(PredTable, [PredId | PredIds], ConflictList, WasConflict) :- - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), pred_info_get_markers(PredInfo, Markers), ( - list__member(Marker, ConflictList), + list.member(Marker, ConflictList), check_marker(Markers, Marker) -> WasConflict = yes @@ -1536,7 +1536,7 @@ pragma_check_markers(PredTable, [PredId | PredIds], ConflictList, pragma_add_marker([], _, _, _, !PredTable, no). pragma_add_marker([PredId | PredIds], UpdatePredInfo, Status, MustBeExported, !PredTable, WrongStatus) :- - map__lookup(!.PredTable, PredId, PredInfo0), + map.lookup(!.PredTable, PredId, PredInfo0), call(UpdatePredInfo, PredInfo0, PredInfo), ( pred_info_is_exported(PredInfo), @@ -1547,13 +1547,12 @@ pragma_add_marker([PredId | PredIds], UpdatePredInfo, Status, MustBeExported, ; WrongStatus0 = no ), - map__det_update(!.PredTable, PredId, PredInfo, !:PredTable), + map.det_update(!.PredTable, PredId, PredInfo, !:PredTable), pragma_add_marker(PredIds, UpdatePredInfo, Status, MustBeExported, !PredTable, WrongStatus1), - bool__or(WrongStatus0, WrongStatus1, WrongStatus). + bool.or(WrongStatus0, WrongStatus1, WrongStatus). -:- pred add_marker_pred_info(marker::in, pred_info::in, pred_info::out) - is det. +:- pred add_marker_pred_info(marker::in, pred_info::in, pred_info::out) is det. add_marker_pred_info(Marker, !PredInfo) :- pred_info_get_markers(!.PredInfo, Markers0), @@ -1597,7 +1596,7 @@ check_field_access_function(_AccessType, FieldName, FuncName, FuncArity, % Abstract types have status `abstract_exported', % so errors won't be reported for local field % access functions for them. - map__search(CtorFieldTable, FieldName, [FieldDefn]), + map.search(CtorFieldTable, FieldName, [FieldDefn]), FieldDefn = hlds_ctor_field_defn(_, DefnStatus, _, _, _), DefnStatus = exported, FuncStatus \= exported -> @@ -1617,8 +1616,8 @@ report_field_status_mismatch(Context, CallId, !IO) :- words("error: a field access function for an"), words("exported field must also be exported.") ], - error_util__write_error_pieces(Context, 0, ErrorPieces, !IO), - io__set_exit_status(1, !IO). + write_error_pieces(Context, 0, ErrorPieces, !IO), + io.set_exit_status(1, !IO). :- pred report_unexpected_decl(string::in, prog_context::in, io::di, io::uo) is det. @@ -1627,7 +1626,7 @@ report_unexpected_decl(Descr, Context, !IO) :- Pieces = [words("Error: unexpected or incorrect"), words("`" ++ Descr ++ "' declaration.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred pragma_status_error(sym_name::in, int::in, prog_context::in, string::in, io::di, io::uo) is det. @@ -1638,7 +1637,7 @@ pragma_status_error(Name, Arity, Context, PragmaName, !IO) :- sym_name_and_arity(Name / Arity), words("must also be exported.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred pragma_conflict_error(sym_name::in, int::in, prog_context::in, string::in, io::di, io::uo) is det. @@ -1648,7 +1647,7 @@ pragma_conflict_error(Name, Arity, Context, PragmaName, !IO) :- words("declaration conflicts with previous pragma for"), sym_name_and_arity(Name / Arity), suffix(".")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- func this_file = string. diff --git a/compiler/make_hlds_warn.m b/compiler/make_hlds_warn.m index 709461948..84d1a4548 100644 --- a/compiler/make_hlds_warn.m +++ b/compiler/make_hlds_warn.m @@ -8,7 +8,7 @@ % % Generate whatever warnings the module being transformed to HLDS deserves. -:- module hlds__make_hlds__make_hlds_warn. +:- module hlds.make_hlds.make_hlds_warn. :- interface. :- import_module hlds.hlds_goal. @@ -71,7 +71,7 @@ %----------------------------------------------------------------------------% maybe_warn_overlap(Warnings, VarSet, PredCallId, !IO) :- - globals__io_lookup_bool_option(warn_overlapping_scopes, + globals.io_lookup_bool_option(warn_overlapping_scopes, WarnOverlappingScopes, !IO), ( WarnOverlappingScopes = yes, @@ -104,11 +104,11 @@ warn_overlap([Warn | Warns], VarSet, PredCallId, !IO) :- %-----------------------------------------------------------------------------% maybe_warn_singletons(VarSet, PredCallId, ModuleInfo, Body, !IO) :- - globals__io_lookup_bool_option(warn_singleton_vars, WarnSingletonVars, + globals.io_lookup_bool_option(warn_singleton_vars, WarnSingletonVars, !IO), ( WarnSingletonVars = yes, - set__init(QuantVars), + set.init(QuantVars), warn_singletons_in_goal(Body, QuantVars, VarSet, PredCallId, ModuleInfo, !IO) ; @@ -149,21 +149,19 @@ warn_singletons_in_goal_2(Goal, _GoalInfo, QuantVars, VarSet, PredCallId, warn_singletons_in_goal_2(Goal, GoalInfo, QuantVars, VarSet, PredCallId, MI, !IO) :- Goal = scope(Reason, SubGoal), - % - % warn if any quantified variables occur only in the quantifier - % + % Warn if any quantified variables occur only in the quantifier. ( ( Reason = exist_quant(Vars) ; Reason = promise_solutions(Vars, _) ), Vars = [_ | _] -> - quantification__goal_vars(SubGoal, SubGoalVars), + quantification.goal_vars(SubGoal, SubGoalVars), goal_info_get_context(GoalInfo, Context), - set__init(EmptySet), + set.init(EmptySet), warn_singletons(Vars, GoalInfo, EmptySet, SubGoalVars, VarSet, Context, PredCallId, !IO), - set__insert_list(QuantVars, Vars, SubQuantVars) + set.insert_list(QuantVars, Vars, SubQuantVars) ; SubQuantVars = QuantVars ), @@ -178,17 +176,17 @@ warn_singletons_in_goal_2(Goal, GoalInfo, QuantVars, VarSet, PredCallId, % ( Vars = [_ | _], - quantification__goal_vars(Cond, CondVars), - quantification__goal_vars(Then, ThenVars), - set__union(CondVars, ThenVars, CondThenVars), + quantification.goal_vars(Cond, CondVars), + quantification.goal_vars(Then, ThenVars), + set.union(CondVars, ThenVars, CondThenVars), goal_info_get_context(GoalInfo, Context), - set__init(EmptySet), + set.init(EmptySet), warn_singletons(Vars, GoalInfo, EmptySet, CondThenVars, VarSet, Context, PredCallId, !IO) ; Vars = [] ), - set__insert_list(QuantVars, Vars, QuantVars1), + set.insert_list(QuantVars, Vars, QuantVars1), warn_singletons_in_goal(Cond, QuantVars1, VarSet, PredCallId, MI, !IO), warn_singletons_in_goal(Then, QuantVars1, VarSet, PredCallId, MI, !IO), warn_singletons_in_goal(Else, QuantVars, VarSet, PredCallId, MI, !IO). @@ -202,8 +200,8 @@ warn_singletons_in_goal_2(Goal, GoalInfo, QuantVars, VarSet, PredCallId, warn_singletons_in_goal_2(Goal, GoalInfo, QuantVars, VarSet, PredCallId, _, !IO) :- Goal = generic_call(GenericCall, Args0, _, _), - goal_util__generic_call_vars(GenericCall, Args1), - list__append(Args0, Args1, Args), + goal_util.generic_call_vars(GenericCall, Args1), + list.append(Args0, Args1, Args), goal_info_get_nonlocals(GoalInfo, NonLocals), goal_info_get_context(GoalInfo, Context), warn_singletons(Args, GoalInfo, NonLocals, QuantVars, VarSet, Context, @@ -218,7 +216,7 @@ warn_singletons_in_goal_2(Goal, GoalInfo, _QuantVars, _VarSet, PredCallId, Goal = foreign_proc(Attrs, _, _, Args, _, PragmaImpl), goal_info_get_context(GoalInfo, Context), Lang = foreign_language(Attrs), - NamesModes = list__map(foreign_arg_maybe_name_mode, Args), + NamesModes = list.map(foreign_arg_maybe_name_mode, Args), warn_singletons_in_pragma_foreign_proc(PragmaImpl, Lang, NamesModes, Context, PredCallId, MI, !IO). warn_singletons_in_goal_2(Goal, GoalInfo, QuantVars, VarSet, PredCallId, @@ -301,8 +299,7 @@ warn_singletons_in_unify(X, lambda_goal(_Purity, _PredOrFunc, _Eval, maybe_warn_pragma_singletons(PragmaImpl, Lang, ArgInfo, Context, CallId, MI, !IO) :- - globals__io_lookup_bool_option(warn_singleton_vars, WarnSingletonVars, - !IO), + globals.io_lookup_bool_option(warn_singleton_vars, WarnSingletonVars, !IO), ( WarnSingletonVars = yes -> warn_singletons_in_pragma_foreign_proc(PragmaImpl, Lang, ArgInfo, Context, CallId, MI, !IO) @@ -330,9 +327,9 @@ warn_singletons_in_pragma_foreign_proc(PragmaImpl, Lang, Args, Context, PragmaImpl = ordinary(C_Code, _), c_code_to_name_list(C_Code, C_CodeList), Filter = (pred(Name::out) is nondet :- - list__member(yes(Name - _), Args), - \+ string__prefix(Name, "_"), - \+ list__member(Name, C_CodeList) + list.member(yes(Name - _), Args), + \+ string.prefix(Name, "_"), + \+ list.member(Name, C_CodeList) ), solutions(Filter, UnmentionedVars), ( @@ -352,10 +349,10 @@ warn_singletons_in_pragma_foreign_proc(PragmaImpl, Lang, Args, Context, c_code_to_name_list(LaterCode, LaterCodeList), c_code_to_name_list(SharedCode, SharedCodeList), InputFilter = (pred(Name::out) is nondet :- - list__member(yes(Name - Mode), Args), + list.member(yes(Name - Mode), Args), mode_is_input(ModuleInfo, Mode), - \+ string__prefix(Name, "_"), - \+ list__member(Name, FirstCodeList) + \+ string.prefix(Name, "_"), + \+ list.member(Name, FirstCodeList) ), solutions(InputFilter, UnmentionedInputVars), ( @@ -369,11 +366,11 @@ warn_singletons_in_pragma_foreign_proc(PragmaImpl, Lang, Args, Context, write_error_pieces(Context, 0, Pieces1, !IO) ), FirstOutputFilter = (pred(Name::out) is nondet :- - list__member(yes(Name - Mode), Args), + list.member(yes(Name - Mode), Args), mode_is_output(ModuleInfo, Mode), - \+ string__prefix(Name, "_"), - \+ list__member(Name, FirstCodeList), - \+ list__member(Name, SharedCodeList) + \+ string.prefix(Name, "_"), + \+ list.member(Name, FirstCodeList), + \+ list.member(Name, SharedCodeList) ), solutions(FirstOutputFilter, UnmentionedFirstOutputVars), ( @@ -388,11 +385,11 @@ warn_singletons_in_pragma_foreign_proc(PragmaImpl, Lang, Args, Context, write_error_pieces(Context, 0, Pieces2, !IO) ), LaterOutputFilter = (pred(Name::out) is nondet :- - list__member(yes(Name - Mode), Args), + list.member(yes(Name - Mode), Args), mode_is_output(ModuleInfo, Mode), - \+ string__prefix(Name, "_"), - \+ list__member(Name, LaterCodeList), - \+ list__member(Name, SharedCodeList) + \+ string.prefix(Name, "_"), + \+ list.member(Name, LaterCodeList), + \+ list.member(Name, SharedCodeList) ), solutions(LaterOutputFilter, UnmentionedLaterOutputVars), ( @@ -417,7 +414,7 @@ variable_warning_start(UnmentionedVars) = Str :- Str = "warning: variable `" ++ Var ++ "' does" ; Str = "warning: variables `" ++ - string__join_list(", ", UnmentionedVars) ++ "' do" + string.join_list(", ", UnmentionedVars) ++ "' do" ). % c_code_to_name_list(Code, List) is true iff List is a list of the @@ -426,7 +423,7 @@ variable_warning_start(UnmentionedVars) = Str :- :- pred c_code_to_name_list(string::in, list(string)::out) is det. c_code_to_name_list(Code, List) :- - string__to_char_list(Code, CharList), + string.to_char_list(Code, CharList), c_code_to_name_list_2(CharList, List). :- pred c_code_to_name_list_2(list(char)::in, list(string)::out) is det. @@ -440,7 +437,7 @@ c_code_to_name_list_2(C_Code, List) :- ; NameCharList = [_ | _], c_code_to_name_list_2(TheRest, Names), - string__from_char_list(NameCharList, Name), + string.from_char_list(NameCharList, Name), List = [Name | Names] ). @@ -449,7 +446,7 @@ c_code_to_name_list_2(C_Code, List) :- get_first_c_name([], [], []). get_first_c_name([C | CodeChars], NameCharList, TheRest) :- - ( char__is_alnum_or_underscore(C) -> + ( char.is_alnum_or_underscore(C) -> get_first_c_name_in_word(CodeChars, NameCharList0, TheRest), NameCharList = [C | NameCharList0] ; @@ -463,7 +460,7 @@ get_first_c_name([C | CodeChars], NameCharList, TheRest) :- get_first_c_name_in_word([], [], []). get_first_c_name_in_word([C | CodeChars], NameCharList, TheRest) :- - ( char__is_alnum_or_underscore(C) -> + ( char.is_alnum_or_underscore(C) -> % There are more characters in the word get_first_c_name_in_word(CodeChars, NameCharList0, TheRest), NameCharList = [C|NameCharList0] @@ -477,24 +474,24 @@ get_first_c_name_in_word([C | CodeChars], NameCharList, TheRest) :- set(prog_var)::in, prog_varset::in, prog_var::out) is nondet. generate_singleton_vars(GoalVars, NonLocals, QuantVars, VarSet, Var) :- - list__member(Var, GoalVars), - \+ set__member(Var, NonLocals), - varset__search_name(VarSet, Var, Name), - \+ string__prefix(Name, "_"), - \+ string__prefix(Name, "DCG_"), + list.member(Var, GoalVars), + \+ set.member(Var, NonLocals), + varset.search_name(VarSet, Var, Name), + \+ string.prefix(Name, "_"), + \+ string.prefix(Name, "DCG_"), \+ ( - set__member(QuantVar, QuantVars), - varset__search_name(VarSet, QuantVar, Name) + set.member(QuantVar, QuantVars), + varset.search_name(VarSet, QuantVar, Name) ). :- pred generate_multi_vars(list(prog_var)::in, set(prog_var)::in, prog_varset::in, prog_var::out) is nondet. generate_multi_vars(GoalVars, NonLocals, VarSet, Var) :- - list__member(Var, GoalVars), - set__member(Var, NonLocals), - varset__search_name(VarSet, Var, Name), - string__prefix(Name, "_"). + list.member(Var, GoalVars), + set.member(Var, NonLocals), + varset.search_name(VarSet, Var, Name), + string.prefix(Name, "_"). % warn_singletons(Vars, GoalInfo, NonLocals, QuantVars, ...): % @@ -600,7 +597,7 @@ check_promise_ex_goal(PromiseType, GoalExpr - Context, !IO) :- ( GoalExpr = some(_, Goal) -> check_promise_ex_goal(PromiseType, Goal, !IO) ; GoalExpr = ( _ ; _ ) -> flatten_to_disj_list(GoalExpr - Context, DisjList), - list__map(flatten_to_conj_list, DisjList, DisjConjList), + list.map(flatten_to_conj_list, DisjList, DisjConjList), check_disjunction(PromiseType, DisjConjList, !IO) ; GoalExpr = all(_UnivVars, Goal) -> promise_ex_error(PromiseType, Context, @@ -693,13 +690,13 @@ check_disj_arm(PromiseType, Goals, CallUsed, !IO) :- promise_ex_error(PromiseType, Context, Message, !IO) :- ErrorPieces = [ words("In"), - fixed("`" ++ prog_out__promise_to_string(PromiseType) ++ "'"), + quote(prog_out.promise_to_string(PromiseType)), words("declaration:"), nl, words("error:"), words(Message) ], - error_util__write_error_pieces(Context, 0, ErrorPieces, !IO). + write_error_pieces(Context, 0, ErrorPieces, !IO). %-----------------------------------------------------------------------------% :- end_module make_hlds_warn. diff --git a/compiler/make_tags.m b/compiler/make_tags.m index 5fefb1d64..84acba8a3 100644 --- a/compiler/make_tags.m +++ b/compiler/make_tags.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-1996, 1998-2005 The University of Melbourne. +% Copyright (C) 1994-1996, 1998-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -57,7 +57,7 @@ %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- module hlds__make_tags. +:- module hlds.make_tags. :- interface. :- import_module hlds.hlds_data. @@ -101,16 +101,16 @@ assign_constructor_tags(Ctors, UserEqCmp, TypeCtor, ReservedTagPragma, Globals, CtorTags, EnumDummy) :- % Work out how many tag bits and reserved addresses we've got to play with. - globals__lookup_int_option(Globals, num_tag_bits, NumTagBits), - globals__lookup_int_option(Globals, num_reserved_addresses, + globals.lookup_int_option(Globals, num_tag_bits, NumTagBits), + globals.lookup_int_option(Globals, num_reserved_addresses, NumReservedAddresses), - globals__lookup_int_option(Globals, num_reserved_objects, + globals.lookup_int_option(Globals, num_reserved_objects, NumReservedObjects), - globals__lookup_bool_option(Globals, highlevel_code, HighLevelCode), + globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode), % Determine if we need to reserve a tag for use by HAL's Herbrand % constraint solver. (This also disables enumerations and no_tag types.) - globals__lookup_bool_option(Globals, reserve_tag, GlobalReserveTag), + globals.lookup_bool_option(Globals, reserve_tag, GlobalReserveTag), ReserveTag = GlobalReserveTag `or` ReservedTagPragma, ( @@ -122,11 +122,11 @@ assign_constructor_tags(Ctors, UserEqCmp, TypeCtor, ReservedTagPragma, Globals, ), % Now assign them. - map__init(CtorTags0), + map.init(CtorTags0), ( % Try representing the type as an enumeration: all the constructors % must be constant, and we must be allowed to make unboxed enums. - globals__lookup_bool_option(Globals, unboxed_enums, yes), + globals.lookup_bool_option(Globals, unboxed_enums, yes), ctors_are_all_constants(Ctors), ReserveTag = no -> @@ -145,7 +145,7 @@ assign_constructor_tags(Ctors, UserEqCmp, TypeCtor, ReservedTagPragma, Globals, -> SingleConsId = make_cons_id_from_qualified_sym_name(SingleFunc, [SingleArg]), - map__set(CtorTags0, SingleConsId, no_tag, CtorTags) + map.set(CtorTags0, SingleConsId, no_tag, CtorTags) ; NumTagBits = 0 -> @@ -176,9 +176,9 @@ assign_constructor_tags(Ctors, UserEqCmp, TypeCtor, ReservedTagPragma, Globals, % Assign shared_with_reserved_address(...) representations % for the remaining constructors. RemainingCtors = LeftOverConstants ++ Functors, - ReservedAddresses = list__filter_map( + ReservedAddresses = list.filter_map( (func(reserved_address(RA)) = RA is semidet), - map__values(CtorTags2)), + map.values(CtorTags2)), assign_unshared_tags(RemainingCtors, 0, 0, ReservedAddresses, CtorTags2, CtorTags) ; @@ -199,7 +199,7 @@ assign_enum_constants([Ctor | Rest], Val, !CtorTags) :- Ctor = ctor(_ExistQVars, _Constraints, Name, Args), ConsId = make_cons_id_from_qualified_sym_name(Name, Args), Tag = int_constant(Val), - svmap__set(ConsId, Tag, !CtorTags), + svmap.set(ConsId, Tag, !CtorTags), assign_enum_constants(Rest, Val + 1, !CtorTags). % Assign the representations null_pointer, small_pointer(1), @@ -223,7 +223,7 @@ assign_reserved_numeric_addresses([Ctor | Rest], LeftOverConstants, ; Tag = reserved_address(small_pointer(Address)) ), - svmap__set(ConsId, Tag, !CtorTags), + svmap.set(ConsId, Tag, !CtorTags), assign_reserved_numeric_addresses(Rest, LeftOverConstants, !CtorTags, Address + 1, NumReservedAddresses) ). @@ -242,10 +242,10 @@ assign_reserved_symbolic_addresses([Ctor | Ctors], LeftOverConstants, TypeCtor, LeftOverConstants = [Ctor | Ctors] ; Ctor = ctor(_ExistQVars, _Constraints, Name, Args), - Arity = list__length(Args), + Arity = list.length(Args), Tag = reserved_address(reserved_object(TypeCtor, Name, Arity)), ConsId = make_cons_id_from_qualified_sym_name(Name, Args), - svmap__set(ConsId, Tag, !CtorTags), + svmap.set(ConsId, Tag, !CtorTags), assign_reserved_symbolic_addresses(Ctors, LeftOverConstants, TypeCtor, !CtorTags, Num + 1, Max) ). @@ -289,7 +289,7 @@ assign_unshared_tags([Ctor | Rest], Val, MaxTag, ReservedAddresses, Rest = [] -> Tag = maybe_add_reserved_addresses(ReservedAddresses, single_functor), - svmap__set(ConsId, Tag, !CtorTags) + svmap.set(ConsId, Tag, !CtorTags) ; % If we're about to run out of unshared tags, start assigning % shared remote tags instead. @@ -301,7 +301,7 @@ assign_unshared_tags([Ctor | Rest], Val, MaxTag, ReservedAddresses, ; Tag = maybe_add_reserved_addresses(ReservedAddresses, unshared_tag(Val)), - svmap__set(ConsId, Tag, !CtorTags), + svmap.set(ConsId, Tag, !CtorTags), assign_unshared_tags(Rest, Val + 1, MaxTag, ReservedAddresses, !CtorTags) ). @@ -317,7 +317,7 @@ assign_shared_remote_tags([Ctor | Rest], PrimaryVal, SecondaryVal, ConsId = make_cons_id_from_qualified_sym_name(Name, Args), Tag = maybe_add_reserved_addresses(ReservedAddresses, shared_remote_tag(PrimaryVal, SecondaryVal)), - svmap__set(ConsId, Tag, !CtorTags), + svmap.set(ConsId, Tag, !CtorTags), SecondaryVal1 = SecondaryVal + 1, assign_shared_remote_tags(Rest, PrimaryVal, SecondaryVal1, ReservedAddresses, !CtorTags). @@ -330,7 +330,7 @@ assign_shared_local_tags([Ctor | Rest], PrimaryVal, SecondaryVal, !CtorTags) :- Ctor = ctor(_ExistQVars, _Constraints, Name, Args), ConsId = make_cons_id_from_qualified_sym_name(Name, Args), Tag = shared_local_tag(PrimaryVal, SecondaryVal), - svmap__set(ConsId, Tag, !CtorTags), + svmap.set(ConsId, Tag, !CtorTags), SecondaryVal1 = SecondaryVal + 1, assign_shared_local_tags(Rest, PrimaryVal, SecondaryVal1, !CtorTags). @@ -351,7 +351,7 @@ maybe_add_reserved_addresses(ReservedAddresses, Tag0) = Tag :- :- func max_num_tags(int) = int. max_num_tags(NumTagBits) = MaxTags :- - int__pow(2, NumTagBits, MaxTags). + int.pow(2, NumTagBits, MaxTags). %-----------------------------------------------------------------------------% diff --git a/compiler/mark_static_terms.m b/compiler/mark_static_terms.m index 7c9dd3b6f..8476cb7e0 100644 --- a/compiler/mark_static_terms.m +++ b/compiler/mark_static_terms.m @@ -18,7 +18,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__mark_static_terms. +:- module ml_backend.mark_static_terms. :- interface. :- import_module hlds.hlds_module. @@ -58,7 +58,7 @@ mark_static_terms(_ModuleInfo, !Proc) :- % The ModuleInfo argument is there just for passes_aux. proc_info_goal(!.Proc, Goal0), - map__init(StaticInfo0), + map.init(StaticInfo0), goal_mark_static_terms(Goal0, Goal, StaticInfo0, _StaticInfo), proc_info_set_goal(Goal, !Proc). @@ -121,7 +121,7 @@ goal_expr_mark_static_terms(shorthand(_), _, !SI) :- static_info::in, static_info::out) is det. conj_mark_static_terms(Goals0, Goals, !SI) :- - list__map_foldl(goal_mark_static_terms, Goals0, Goals, !SI). + list.map_foldl(goal_mark_static_terms, Goals0, Goals, !SI). :- pred disj_mark_static_terms(hlds_goals::in, hlds_goals::out, static_info::in) is det. @@ -153,10 +153,10 @@ unification_mark_static_terms(Unification0, Unification, !StaticVars) :- ( % If all the arguments are static, then the newly constructed % variable is static too. - list__map(map__search(!.StaticVars), ArgVars, StaticArgs) + list.map(map.search(!.StaticVars), ArgVars, StaticArgs) -> HowToConstruct = construct_statically(StaticArgs), - svmap__det_insert(Var, static_cons(ConsId, ArgVars, StaticArgs), + svmap.det_insert(Var, static_cons(ConsId, ArgVars, StaticArgs), !StaticVars) ; HowToConstruct = HowToConstruct0 @@ -179,7 +179,7 @@ unification_mark_static_terms(Unification0, Unification, !StaticVars) :- % % then the newly extracted argument variables % % are static too % % (XXX is the "cannot fail" bit really necessary?) -% map__search(StaticVars0, Var, Data), +% map.search(StaticVars0, Var, Data), % CanFail = cannot_fail % -> % XXX insert ArgVars into StaticVars0 @@ -192,9 +192,9 @@ unification_mark_static_terms(Unification0, Unification, !StaticVars) :- ( % If the variable being assign from is static, % then the variable being assigned to is static too. - map__search(!.StaticVars, SourceVar, Data) + map.search(!.StaticVars, SourceVar, Data) -> - svmap__det_insert(TargetVar, Data, !StaticVars) + svmap.det_insert(TargetVar, Data, !StaticVars) ; true ) diff --git a/compiler/matching.m b/compiler/matching.m index 85e3a3286..295815cf7 100644 --- a/compiler/matching.m +++ b/compiler/matching.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2001-2005 The University of Melbourne. +% Copyright (C) 2001-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -16,7 +16,7 @@ %-----------------------------------------------------------------------------% -:- module backend_libs__matching. +:- module backend_libs.matching. :- interface. :- import_module parse_tree.prog_data. @@ -159,29 +159,29 @@ find_via_cell_vars(CellVar, CandidateFieldVars, CellVarFlushedLater, InclAllCand = MatchingParams ^ include_all_candidates, ( InclAllCand = no, - AllSegmentVars = set__union_list([BeforeFlush | AfterFlush]), - set__intersect(CandidateFieldVars, AllSegmentVars, + AllSegmentVars = set.union_list([BeforeFlush | AfterFlush]), + set.intersect(CandidateFieldVars, AllSegmentVars, OccurringCandidateFieldVars), - set__difference(CandidateFieldVars, OccurringCandidateFieldVars, + set.difference(CandidateFieldVars, OccurringCandidateFieldVars, NonOccurringCandidateFieldVars) ; InclAllCand = yes, OccurringCandidateFieldVars = CandidateFieldVars, - NonOccurringCandidateFieldVars = set__init + NonOccurringCandidateFieldVars = set.init ), - set__to_sorted_list(OccurringCandidateFieldVars, + set.to_sorted_list(OccurringCandidateFieldVars, OccurringCandidateFieldVarList), - list__filter_map(simplify_segment(CellVar, OccurringCandidateFieldVars), + list.filter_map(simplify_segment(CellVar, OccurringCandidateFieldVars), AfterFlush, FilteredAfterFlush), NumberedAfterFlush = number_segments(2, FilteredAfterFlush), - CostsBenefits = list__map( + CostsBenefits = list.map( find_costs_benefits(CellVar, BeforeFlush, NumberedAfterFlush, CellVarFlushedLater, MatchingParams), OccurringCandidateFieldVarList), - list__foldl(gather_benefits, CostsBenefits, set__init, BenefitNodes), - list__foldl(gather_costs, CostsBenefits, set__init, CostNodes), - set__to_sorted_list(BenefitNodes, BenefitNodeList), - set__to_sorted_list(CostNodes, CostNodeList), + list.foldl(gather_benefits, CostsBenefits, set.init, BenefitNodes), + list.foldl(gather_costs, CostsBenefits, set.init, CostNodes), + set.to_sorted_list(BenefitNodes, BenefitNodeList), + set.to_sorted_list(CostNodes, CostNodeList), Graph = create_graph(CostsBenefits), MaximalMatching = maximal_matching(BenefitNodeList, Graph), MaximalMatching = matching(MaximalMatchingCostToBenefit, _), @@ -191,22 +191,22 @@ find_via_cell_vars(CellVar, CandidateFieldVars, CellVarFlushedLater, Graph, MaximalMatching), ViaCellOccurringVars0 = compute_via_cell_vars(CostsBenefits, MarkedBenefitNodes), - list__filter(realized_costs_benefits(ViaCellOccurringVars0), + list.filter(realized_costs_benefits(ViaCellOccurringVars0), CostsBenefits, RealizedCostsBenefits), - list__foldl(gather_benefits, RealizedCostsBenefits, - set__init, RealizedBenefitNodes), - list__foldl(gather_costs, RealizedCostsBenefits, - set__init, RealizedCostNodes), - RealizedBenefitOps = set__map(project_benefit_op, RealizedBenefitNodes), - RealizedCostOps = set__map(project_cost_op, RealizedCostNodes), - set__to_sorted_list(RealizedBenefitNodes, RealizedBenefitNodeList), - set__to_sorted_list(RealizedCostNodes, RealizedCostNodeList), - set__to_sorted_list(RealizedBenefitOps, RealizedBenefitOpList), - set__to_sorted_list(RealizedCostOps, RealizedCostOpList), - list__length(RealizedBenefitNodeList, RealizedBenefitNodeCount), - list__length(RealizedBenefitOpList, RealizedBenefitOpCount), - list__length(RealizedCostNodeList, RealizedCostNodeCount), - list__length(RealizedCostOpList, RealizedCostOpCount), + list.foldl(gather_benefits, RealizedCostsBenefits, + set.init, RealizedBenefitNodes), + list.foldl(gather_costs, RealizedCostsBenefits, + set.init, RealizedCostNodes), + RealizedBenefitOps = set.map(project_benefit_op, RealizedBenefitNodes), + RealizedCostOps = set.map(project_cost_op, RealizedCostNodes), + set.to_sorted_list(RealizedBenefitNodes, RealizedBenefitNodeList), + set.to_sorted_list(RealizedCostNodes, RealizedCostNodeList), + set.to_sorted_list(RealizedBenefitOps, RealizedBenefitOpList), + set.to_sorted_list(RealizedCostOps, RealizedCostOpList), + list.length(RealizedBenefitNodeList, RealizedBenefitNodeCount), + list.length(RealizedBenefitOpList, RealizedBenefitOpCount), + list.length(RealizedCostNodeList, RealizedCostNodeCount), + list.length(RealizedCostOpList, RealizedCostOpCount), OpRatio = MatchingParams ^ one_path_op_ratio, NodeRatio = MatchingParams ^ one_path_node_ratio, ( @@ -218,12 +218,12 @@ find_via_cell_vars(CellVar, CandidateFieldVars, CellVarFlushedLater, % the .err file. % Nullified = no ; - ViaCellOccurringVars = set__init + ViaCellOccurringVars = set.init % Uncomment if you want to dump performance information into % the .err file. % Nullified = yes ), - ViaCellVars = set__union(ViaCellOccurringVars, + ViaCellVars = set.union(ViaCellOccurringVars, NonOccurringCandidateFieldVars). % Uncomment if you want to dump performance information into % the .err file. @@ -245,8 +245,8 @@ find_via_cell_vars(CellVar, CandidateFieldVars, CellVarFlushedLater, set(prog_var)::out) is semidet. simplify_segment(CellVar, CandidateArgVars, SegmentVars0, SegmentVars) :- - \+ set__member(CellVar, SegmentVars0), - SegmentVars = set__intersect(SegmentVars0, CandidateArgVars). + \+ set.member(CellVar, SegmentVars0), + SegmentVars = set.intersect(SegmentVars0, CandidateArgVars). :- func number_segments(int, list(set(prog_var))) = assoc_list(int, set(prog_var)). @@ -275,7 +275,7 @@ find_costs_benefits(CellVar, BeforeFlush, AfterFlush, CellVarFlushedLater, CostOps = [cell_var_store | CostOps0] ), BenefitOps0 = [field_var_store(FieldVar)], - ( set__member(CellVar, BeforeFlush) -> + ( set.member(CellVar, BeforeFlush) -> BenefitOps = BenefitOps0 ; BenefitOps = [field_var_load(FieldVar) | BenefitOps0] @@ -283,18 +283,18 @@ find_costs_benefits(CellVar, BeforeFlush, AfterFlush, CellVarFlushedLater, CellVarStoreCost = MatchingParams ^ cell_var_store_cost, CellVarLoadCost = MatchingParams ^ cell_var_load_cost, - CostNodeLists = list__map( + CostNodeLists = list.map( replicate_cost_op(CellVarStoreCost, CellVarLoadCost), CostOps), - list__condense(CostNodeLists, CostNodes), - set__list_to_set(CostNodes, CostNodeSet), + list.condense(CostNodeLists, CostNodes), + set.list_to_set(CostNodes, CostNodeSet), FieldVarStoreCost = MatchingParams ^ field_var_store_cost, FieldVarLoadCost = MatchingParams ^ field_var_load_cost, - BenefitNodeLists = list__map( + BenefitNodeLists = list.map( replicate_benefit_op(FieldVarStoreCost, FieldVarLoadCost), BenefitOps), - list__condense(BenefitNodeLists, BenefitNodes), - set__list_to_set(BenefitNodes, BenefitNodeSet), + list.condense(BenefitNodeLists, BenefitNodes), + set.list_to_set(BenefitNodes, BenefitNodeSet), FieldCostsBenefits = field_costs_benefits(FieldVar, CostNodeSet, BenefitNodeSet). @@ -304,7 +304,7 @@ find_costs_benefits(CellVar, BeforeFlush, AfterFlush, CellVarFlushedLater, find_cell_var_loads_for_field([], _, !CostOps). find_cell_var_loads_for_field([SegmentNum - SegmentVars | AfterFlush], FieldVar, !CostOps) :- - ( set__member(FieldVar, SegmentVars) -> + ( set.member(FieldVar, SegmentVars) -> !:CostOps = [cell_var_load(SegmentNum) | !.CostOps] ; true @@ -353,7 +353,7 @@ make_benefit_op_copies(Cur, Op) = set(benefit_node)::out) is det. gather_benefits(field_costs_benefits(_, _, FieldBenefits), !Benefits) :- - set__union(FieldBenefits, !Benefits). + set.union(FieldBenefits, !Benefits). % Accumulate all the cost nodes. % @@ -361,7 +361,7 @@ gather_benefits(field_costs_benefits(_, _, FieldBenefits), !Benefits) :- set(cost_node)::out) is det. gather_costs(field_costs_benefits(_, FieldCosts, _), !Costs) :- - set__union(FieldCosts, !Costs). + set.union(FieldCosts, !Costs). %-----------------------------------------------------------------------------% @@ -370,8 +370,8 @@ gather_costs(field_costs_benefits(_, FieldCosts, _), !Costs) :- :- func create_graph(list(field_costs_benefits)) = stack_slot_graph. create_graph(CostsBenefits) = Graph :- - list__foldl2(create_graph_links, CostsBenefits, - map__init, CostToBenefitsMap, map__init, BenefitToCostsMap), + list.foldl2(create_graph_links, CostsBenefits, + map.init, CostToBenefitsMap, map.init, BenefitToCostsMap), Graph = stack_slot_graph(CostToBenefitsMap, BenefitToCostsMap). :- pred create_graph_links(field_costs_benefits::in, @@ -382,21 +382,21 @@ create_graph(CostsBenefits) = Graph :- create_graph_links(field_costs_benefits(_FieldVar, Costs, Benefits), !CostToBenefitsMap, !BenefitToCostsMap) :- - list__foldl(add_cost_benefit_links(Benefits), - set__to_sorted_list(Costs), !CostToBenefitsMap), - list__foldl(add_benefit_cost_links(Costs), - set__to_sorted_list(Benefits), !BenefitToCostsMap). + list.foldl(add_cost_benefit_links(Benefits), + set.to_sorted_list(Costs), !CostToBenefitsMap), + list.foldl(add_benefit_cost_links(Costs), + set.to_sorted_list(Benefits), !BenefitToCostsMap). :- pred add_cost_benefit_links(set(benefit_node)::in, cost_node::in, map(cost_node, set(benefit_node))::in, map(cost_node, set(benefit_node))::out) is det. add_cost_benefit_links(Benefits, Cost, !CostToBenefitsMap) :- - ( map__search(!.CostToBenefitsMap, Cost, CostBenefits0) -> - set__union(CostBenefits0, Benefits, CostBenefits), - svmap__det_update(Cost, CostBenefits, !CostToBenefitsMap) + ( map.search(!.CostToBenefitsMap, Cost, CostBenefits0) -> + set.union(CostBenefits0, Benefits, CostBenefits), + svmap.det_update(Cost, CostBenefits, !CostToBenefitsMap) ; - svmap__det_insert(Cost, Benefits, !CostToBenefitsMap) + svmap.det_insert(Cost, Benefits, !CostToBenefitsMap) ). :- pred add_benefit_cost_links(set(cost_node)::in, benefit_node::in, @@ -404,11 +404,11 @@ add_cost_benefit_links(Benefits, Cost, !CostToBenefitsMap) :- map(benefit_node, set(cost_node))::out) is det. add_benefit_cost_links(Costs, Benefit, !BenefitToCostsMap) :- - ( map__search(!.BenefitToCostsMap, Benefit, BenefitCosts0) -> - set__union(BenefitCosts0, Costs, BenefitCosts), - svmap__det_update(Benefit, BenefitCosts, !BenefitToCostsMap) + ( map.search(!.BenefitToCostsMap, Benefit, BenefitCosts0) -> + set.union(BenefitCosts0, Costs, BenefitCosts), + svmap.det_update(Benefit, BenefitCosts, !BenefitToCostsMap) ; - svmap__det_insert(Benefit, Costs, !BenefitToCostsMap) + svmap.det_insert(Benefit, Costs, !BenefitToCostsMap) ). %-----------------------------------------------------------------------------% @@ -418,7 +418,7 @@ add_benefit_cost_links(Costs, Benefit, !BenefitToCostsMap) :- :- func maximal_matching(list(benefit_node), stack_slot_graph) = matching. maximal_matching(BenefitNodes, Graph) = Matching :- - Matching0 = matching(map__init, map__init), + Matching0 = matching(map.init, map.init), maximize_matching(BenefitNodes, Graph, Matching0, Matching). :- pred maximize_matching(list(benefit_node)::in, stack_slot_graph::in, @@ -437,8 +437,8 @@ maximize_matching(BenefitNodes, Graph, !Matching) :- update_matches([], Matching0) = Matching0. update_matches([BenefitNode - CostNode | Path], Matching0) = Matching :- Matching0 = matching(CostToBenefitMap0, BenefitToCostMap0), - map__set(CostToBenefitMap0, CostNode, BenefitNode, CostToBenefitMap1), - map__set(BenefitToCostMap0, BenefitNode, CostNode, BenefitToCostMap1), + map.set(CostToBenefitMap0, CostNode, BenefitNode, CostToBenefitMap1), + map.set(BenefitToCostMap0, BenefitNode, CostNode, BenefitToCostMap1), Matching1 = matching(CostToBenefitMap1, BenefitToCostMap1), Matching = update_matches(Path, Matching1). @@ -468,7 +468,7 @@ find_augmenting_path(BenefitNodes, Graph, Matching) = Path :- = edge_list is semidet. find_first_path_bf(BenefitNodes, Graph, Matching) = Path :- - Queue = initial_queue(BenefitNodes, queue__init), + Queue = initial_queue(BenefitNodes, queue.init), Path = augpath_bf(Queue, BenefitNodes, Graph, Matching). :- func initial_queue(list(benefit_node), queue(benefit_node_and_edge_list)) @@ -476,20 +476,20 @@ find_first_path_bf(BenefitNodes, Graph, Matching) = Path :- initial_queue([], Q) = Q. initial_queue([N | Ns], Q0) = Q :- - Q1 = queue__put(Q0, N - []), + Q1 = queue.put(Q0, N - []), Q = initial_queue(Ns, Q1). :- func augpath_bf(queue(benefit_node_and_edge_list), list(benefit_node), stack_slot_graph, matching) = edge_list is semidet. augpath_bf(Queue0, Seen0, Graph, Matching) = Path :- - queue__get(Queue0, NodePath, Queue1), + queue.get(Queue0, NodePath, Queue1), NodePath = BenefitNode - Path0, Graph = stack_slot_graph(_, BenefitToCostsMap), - map__lookup(BenefitToCostsMap, BenefitNode, AdjCostNodes), + map.lookup(BenefitToCostsMap, BenefitNode, AdjCostNodes), Matching = matching(CostToBenefitMap, _), CostMatches = map_adjs_to_matched_cost( - set__to_sorted_list(AdjCostNodes), CostToBenefitMap), + set.to_sorted_list(AdjCostNodes), CostToBenefitMap), ( find_unmatched_cost(CostMatches) = UnmatchedCostNode -> Path = [BenefitNode - UnmatchedCostNode | Path0] ; @@ -524,10 +524,10 @@ add_alternates([CostNode - MaybeAdjBenefitNode | CostMatches], !Seen, BenefitNode, Path, !Queue) :- ( MaybeAdjBenefitNode = yes(AdjBenefitNode), - not list__member(AdjBenefitNode, !.Seen) + not list.member(AdjBenefitNode, !.Seen) -> !:Seen = [AdjBenefitNode | !.Seen], - svqueue__put(AdjBenefitNode - [BenefitNode - CostNode | Path], !Queue) + svqueue.put(AdjBenefitNode - [BenefitNode - CostNode | Path], !Queue) ; true ), @@ -551,7 +551,7 @@ add_alternates([CostNode - MaybeAdjBenefitNode | CostMatches], !Seen, reachable_by_alternating_path(SelectedCostNodes, Graph, Matching) = ReachableBenefitNodes :- reachable_by_alternating_path(SelectedCostNodes, Graph, Matching, - set__init, ReachableBenefitNodes). + set.init, ReachableBenefitNodes). :- pred reachable_by_alternating_path(list(cost_node)::in, stack_slot_graph::in, matching::in, set(benefit_node)::in, @@ -564,13 +564,13 @@ reachable_by_alternating_path(SelectedCostNodes, Graph, Matching, ; SelectedCostNodes = [_ | _], Graph = stack_slot_graph(CostToBenefitsMap, _), - list__foldl(adjacents(CostToBenefitsMap), SelectedCostNodes, - set__init, AdjBenefitNodes), - set__difference(!.BenefitNodes, AdjBenefitNodes, NewBenefitNodes), - set__union(AdjBenefitNodes, !BenefitNodes), - set__to_sorted_list(NewBenefitNodes, NewBenefitNodeList), + list.foldl(adjacents(CostToBenefitsMap), SelectedCostNodes, + set.init, AdjBenefitNodes), + set.difference(!.BenefitNodes, AdjBenefitNodes, NewBenefitNodes), + set.union(AdjBenefitNodes, !BenefitNodes), + set.to_sorted_list(NewBenefitNodes, NewBenefitNodeList), Matching = matching(_, BenefitToCostMap), - LinkedCostNodes = list__map(map__lookup(BenefitToCostMap), + LinkedCostNodes = list.map(map.lookup(BenefitToCostMap), NewBenefitNodeList), reachable_by_alternating_path(LinkedCostNodes, Graph, Matching, !BenefitNodes) @@ -580,8 +580,8 @@ reachable_by_alternating_path(SelectedCostNodes, Graph, Matching, set(benefit_node)::in, set(benefit_node)::out) is det. adjacents(CostToBenefitsMap, CostNode, !BenefitNodes) :- - map__lookup(CostToBenefitsMap, CostNode, AdjBenefitNodes), - set__union(AdjBenefitNodes, !BenefitNodes). + map.lookup(CostToBenefitsMap, CostNode, AdjBenefitNodes), + set.union(AdjBenefitNodes, !BenefitNodes). %-----------------------------------------------------------------------------% @@ -593,14 +593,14 @@ adjacents(CostToBenefitsMap, CostNode, !BenefitNodes) :- = assoc_list(cost_node, maybe(benefit_node)). map_adjs_to_matched_cost(AdjCostNodes, CostToBenefitMap) = CostMatches :- - CostMatches = list__map(adj_to_matched_cost(CostToBenefitMap), + CostMatches = list.map(adj_to_matched_cost(CostToBenefitMap), AdjCostNodes). :- func adj_to_matched_cost(map(cost_node, benefit_node), cost_node) = pair(cost_node, maybe(benefit_node)). adj_to_matched_cost(CostToBenefitMap, CostNode) = Match :- - ( map__search(CostToBenefitMap, CostNode, BenefitNode) -> + ( map.search(CostToBenefitMap, CostNode, BenefitNode) -> Match = CostNode - yes(BenefitNode) ; Match = CostNode - no @@ -611,15 +611,15 @@ adj_to_matched_cost(CostToBenefitMap, CostNode) = Match :- :- func compute_via_cell_vars(list(field_costs_benefits), set(benefit_node)) = set(prog_var). -compute_via_cell_vars([], _MarkedBenefits) = set__init. +compute_via_cell_vars([], _MarkedBenefits) = set.init. compute_via_cell_vars([FieldCostsBenefits | FieldsCostsBenefits], MarkedBenefits) = ViaCellVars :- ViaCellVars1 = compute_via_cell_vars(FieldsCostsBenefits, MarkedBenefits), FieldCostsBenefits = field_costs_benefits(FieldVar, _, FieldBenefits), - set__intersect(FieldBenefits, MarkedBenefits, MarkedFieldBenefits), - ( set__empty(MarkedFieldBenefits) -> - set__insert(ViaCellVars1, FieldVar, ViaCellVars) - ; set__equal(MarkedFieldBenefits, FieldBenefits) -> + set.intersect(FieldBenefits, MarkedBenefits, MarkedFieldBenefits), + ( set.empty(MarkedFieldBenefits) -> + set.insert(ViaCellVars1, FieldVar, ViaCellVars) + ; set.equal(MarkedFieldBenefits, FieldBenefits) -> ViaCellVars = ViaCellVars1 ; unexpected(this_file, "compute_via_cell_vars: theorem violation: " ++ @@ -637,7 +637,7 @@ compute_via_cell_vars([FieldCostsBenefits | FieldsCostsBenefits], get_unmatched_benefit_nodes([], _) = []. get_unmatched_benefit_nodes([Node | Nodes], MatchingBC) = UnmatchedNodes :- UnmatchedNodes1 = get_unmatched_benefit_nodes(Nodes, MatchingBC), - ( map__search(MatchingBC, Node, _Match) -> + ( map.search(MatchingBC, Node, _Match) -> UnmatchedNodes = UnmatchedNodes1 ; UnmatchedNodes = [Node | UnmatchedNodes1] @@ -652,7 +652,7 @@ get_unmatched_benefit_nodes([Node | Nodes], MatchingBC) = UnmatchedNodes :- get_unmatched_cost_nodes([], _) = []. get_unmatched_cost_nodes([Node | Nodes], MatchingCB) = UnmatchedNodes :- UnmatchedNodes1 = get_unmatched_cost_nodes(Nodes, MatchingCB), - ( map__search(MatchingCB, Node, _Match) -> + ( map.search(MatchingCB, Node, _Match) -> UnmatchedNodes = UnmatchedNodes1 ; UnmatchedNodes = [Node | UnmatchedNodes1] @@ -674,67 +674,67 @@ get_unmatched_cost_nodes([Node | Nodes], MatchingCB) = UnmatchedNodes :- dump_results(CellVar, CandidateFieldVars, OccurringCandidateFieldVarList, ViaCellOccurringVars, Nullified, BeforeFlush, AfterFlush, - BenefitNodes, BenefitOps, CostNodes, CostOps) --> - { term__var_to_int(CellVar, CellVarInt) }, - { set__to_sorted_list(CandidateFieldVars, CandidateFieldVarList) }, - { set__to_sorted_list(ViaCellOccurringVars, ViaCellVarList) }, - { set__to_sorted_list(BeforeFlush, BeforeFlushList) }, - { list__map(term__var_to_int, CandidateFieldVarList, - CandidateFieldVarInts) }, - { list__map(term__var_to_int, OccurringCandidateFieldVarList, - OccurringCandidateFieldVarInts) }, - { list__map(term__var_to_int, ViaCellVarList, ViaCellVarInts) }, - { list__map(term__var_to_int, BeforeFlushList, BeforeFlushInts) }, - io__write_string("%\n% FIND_VIA_CELL_VARS "), - io__write_int(CellVarInt), - io__write_string(" => f("), - io__write_list(CandidateFieldVarInts, ", ", io__write_int), - io__write_string(")\n"), - io__write_string("% occurring ["), - io__write_list(OccurringCandidateFieldVarInts, ", ", io__write_int), - io__write_string("]\n"), - io__write_string("% via cell ["), - io__write_list(ViaCellVarInts, ", ", io__write_int), - io__write_string("]"), + BenefitNodes, BenefitOps, CostNodes, CostOps, !IO) :- + term.var_to_int(CellVar, CellVarInt), + set.to_sorted_list(CandidateFieldVars, CandidateFieldVarList), + set.to_sorted_list(ViaCellOccurringVars, ViaCellVarList), + set.to_sorted_list(BeforeFlush, BeforeFlushList), + list.map(term.var_to_int, CandidateFieldVarList, + CandidateFieldVarInts), + list.map(term.var_to_int, OccurringCandidateFieldVarList, + OccurringCandidateFieldVarInts), + list.map(term.var_to_int, ViaCellVarList, ViaCellVarInts), + list.map(term.var_to_int, BeforeFlushList, BeforeFlushInts), + io.write_string("%\n% FIND_VIA_CELL_VARS ", !IO), + io.write_int(CellVarInt, !IO), + io.write_string(" => f(", !IO), + io.write_list(CandidateFieldVarInts, ", ", io.write_int, !IO), + io.write_string(")\n", !IO), + io.write_string("% occurring [", !IO), + io.write_list(OccurringCandidateFieldVarInts, ", ", io.write_int, !IO), + io.write_string("]\n", !IO), + io.write_string("% via cell [", !IO), + io.write_list(ViaCellVarInts, ", ", io.write_int, !IO), + io.write_string("]", !IO), ( - { Nullified = no }, - io__write_string("\n") + Nullified = no, + io.write_string("\n", !IO) ; - { Nullified = yes }, - io__write_string(" nullified\n") + Nullified = yes, + io.write_string(" nullified\n", !IO) ), - io__write_string("% before flush, segment 1: ["), - io__write_list(BeforeFlushInts, ", ", io__write_int), - io__write_string("]\n"), - list__foldl(dump_after_flush, AfterFlush), - io__write_string("% realized benefits: "), - io__write_int(list__length(BenefitOps)), - io__write_string(" ops, "), - io__write_int(list__length(BenefitNodes)), - io__write_string(" nodes:\n"), - io__write_string("% "), - io__write(BenefitOps), - io__write_string("\n"), - io__write_string("% realized costs: "), - io__write_int(list__length(CostOps)), - io__write_string(" ops, "), - io__write_int(list__length(CostNodes)), - io__write_string(" nodes:\n"), - io__write_string("% "), - io__write(CostOps), - io__write_string("\n%\n"). + io.write_string("% before flush, segment 1: [", !IO), + io.write_list(BeforeFlushInts, ", ", io.write_int, !IO), + io.write_string("]\n", !IO), + list.foldl(dump_after_flush, AfterFlush, !IO), + io.write_string("% realized benefits: ", !IO), + io.write_int(list.length(BenefitOps), !IO), + io.write_string(" ops, ", !IO), + io.write_int(list.length(BenefitNodes), !IO), + io.write_string(" nodes:\n", !IO), + io.write_string("% ", !IO), + io.write(BenefitOps, !IO), + io.write_string("\n", !IO), + io.write_string("% realized costs: ", !IO), + io.write_int(list.length(CostOps), !IO), + io.write_string(" ops, ", !IO), + io.write_int(list.length(CostNodes), !IO), + io.write_string(" nodes:\n", !IO), + io.write_string("% ", !IO), + io.write(CostOps, !IO), + io.write_string("\n%\n", !IO). :- pred dump_after_flush(pair(int, set(prog_var))::in, io::di, io::uo) is det. -dump_after_flush(SegmentNum - SegmentVars) --> - { set__to_sorted_list(SegmentVars, SegmentVarList) }, - { list__map(term__var_to_int, SegmentVarList, SegmentVarInts) }, - io__write_string("% after flush, segment "), - io__write_int(SegmentNum), - io__write_string(": ["), - io__write_list(SegmentVarInts, ", ", io__write_int), - io__write_string("]\n"). +dump_after_flush(SegmentNum - SegmentVars, !IO) :- + set.to_sorted_list(SegmentVars, SegmentVarList), + list.map(term.var_to_int, SegmentVarList, SegmentVarInts), + io.write_string("% after flush, segment ", !IO), + io.write_int(SegmentNum, !IO), + io.write_string(": [", !IO), + io.write_list(SegmentVarInts, ", ", io.write_int, !IO), + io.write_string("]\n", !IO). %-----------------------------------------------------------------------------% @@ -743,7 +743,7 @@ dump_after_flush(SegmentNum - SegmentVars) --> realized_costs_benefits(ViaCellOccurringVars, FieldCostsBenefits) :- FieldCostsBenefits = field_costs_benefits(FieldVar, _, _), - set__member(FieldVar, ViaCellOccurringVars). + set.member(FieldVar, ViaCellOccurringVars). :- func project_benefit_op(benefit_node) = benefit_operation. diff --git a/compiler/mcsolver.m b/compiler/mcsolver.m index ef8559a0b..d8bbbc052 100644 --- a/compiler/mcsolver.m +++ b/compiler/mcsolver.m @@ -13,12 +13,12 @@ % Ralph Becket % Fri Dec 31 14:45:18 EST 2004 % -% A constraint solver targetted specifically at David Overton's +% A constraint solver targeted specifically at David Overton's % constraint-based mode analysis. % %-----------------------------------------------------------------------------% -:- module check_hlds__mcsolver. +:- module check_hlds.mcsolver. :- interface. @@ -146,27 +146,26 @@ % Complex constraints. % -:- type complex_cstrt ---> eqv_disj(var, vars) - % var <-> OR(vars) - ; at_most_one(vars) - ; exactly_one(vars) - ; disj_of_assgts(list(assgts)). - % Each element of the list is a - % list of assignments which should - % occur concurrently. +:- type complex_cstrt + ---> eqv_disj(var, vars) + % var <-> OR(vars) + ; at_most_one(vars) + ; exactly_one(vars) + ; disj_of_assgts(list(assgts)). + % Each element of the list is a list of assignments + % which should occur concurrently. + :- type complex_cstrts == list(complex_cstrt). - % Map from a variable to the complex constraints it participates - % in. + % Map from a variable to the complex constraints it participates in. % :- type complex_cstrt_map == multi_map(var, complex_cstrt). - % A propagation graph is an optimised representation of a set - % of binary implication constraints. It is comprised of a pair - % of mappings from vars to consequent assignments, where the - % LHS of the pair is the mapping when the var in question is - % bound to `yes' and the RHS is the mapping when the var in - % question is bound to `no'. + % A propagation graph is an optimised representation of a set of + % binary implication constraints. It consists of a pair of mappings + % from vars to consequent assignments, where the LHS of the pair + % is the mapping when the var in question is bound to `yes' + % and the RHS is the mapping when the var in question is bound to `no'. % :- type prop_graph == pair(multi_map(var, assgt)). @@ -254,8 +253,8 @@ prepare_abstract_constraint(disj(Formulae), !PCs) :- then disjunction_of_assignments(DisjOfAssgts, !PCs) else - compiler_util.sorry(this_file, "Disjuction of constraints." - ++ " - general case.") + compiler_util.sorry(this_file, + "Disjuction of constraints - general case.") ). % Prepares an atomic constraint (as described in @@ -291,7 +290,6 @@ equivalent(X, Y, PCs0, PCs) :- %-----------------------------------------------------------------------------% equivalent([], PCs, PCs). - equivalent([X | Xs], PCs0, PCs) :- list.foldl(equivalent(X), Xs, PCs0, PCs). diff --git a/compiler/mercury_compile.m b/compiler/mercury_compile.m index b2438fe35..8978f7bf1 100644 --- a/compiler/mercury_compile.m +++ b/compiler/mercury_compile.m @@ -17,7 +17,7 @@ %-----------------------------------------------------------------------------% -:- module top_level__mercury_compile. +:- module top_level.mercury_compile. :- interface. :- import_module io. @@ -200,11 +200,11 @@ real_main(!IO) :- gc_init(!IO), % All messages go to stderr - io__stderr_stream(StdErr, !IO), - io__set_output_stream(StdErr, _, !IO), - io__command_line_arguments(Args0, !IO), + io.stderr_stream(StdErr, !IO), + io.set_output_stream(StdErr, _, !IO), + io.command_line_arguments(Args0, !IO), - % read_args_file and globals__io_printing_usage may attempt + % read_args_file and globals.io_printing_usage may attempt % to look up options, so we need to initialize the globals. handle_options([], _, _, _, _, !IO), @@ -215,7 +215,7 @@ real_main(!IO) :- % by the parent `mmc --make' process. % - options_file__read_args_file(ArgFile, MaybeArgs1, !IO), + options_file.read_args_file(ArgFile, MaybeArgs1, !IO), ( MaybeArgs1 = yes(Args1), process_options(Args1, OptionArgs, NonOptionArgs, _, !IO), @@ -273,7 +273,7 @@ real_main(!IO) :- main_2(Errors, Variables, OptionArgs, NonOptionArgs, Link, !IO) ; MaybeMCFlags = no, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). :- pred real_main_2(list(string)::in, maybe(list(string))::out, @@ -293,7 +293,7 @@ real_main_2(MCFlags0, MaybeMCFlags, Args0, Variables0, Variables, !IO) :- MaybeMCFlags = no ; Errors = [], - globals__io_lookup_maybe_string_option(config_file, + globals.io_lookup_maybe_string_option(config_file, MaybeConfigFile, !IO), ( MaybeConfigFile = yes(ConfigFile), @@ -351,60 +351,60 @@ gc_init(!IO). main_2(Errors @ [_ | _], _, _, _, _, !IO) :- usage_errors(Errors, !IO). main_2([], OptionVariables, OptionArgs, Args, Link, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, version, Version), - globals__lookup_bool_option(Globals, help, Help), - globals__lookup_bool_option(Globals, generate_source_file_mapping, + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, version, Version), + globals.lookup_bool_option(Globals, help, Help), + globals.lookup_bool_option(Globals, generate_source_file_mapping, GenerateMapping), - globals__lookup_bool_option(Globals, output_grade_string, + globals.lookup_bool_option(Globals, output_grade_string, OutputGrade), - globals__lookup_bool_option(Globals, output_link_command, + globals.lookup_bool_option(Globals, output_link_command, OutputLinkCommand), - globals__lookup_bool_option(Globals, output_shared_lib_link_command, + globals.lookup_bool_option(Globals, output_shared_lib_link_command, OutputShLibLinkCommand), - globals__lookup_bool_option(Globals, filenames_from_stdin, + globals.lookup_bool_option(Globals, filenames_from_stdin, FileNamesFromStdin), - globals__lookup_bool_option(Globals, make, Make), + globals.lookup_bool_option(Globals, make, Make), ( Version = yes -> - io__stdout_stream(Stdout, !IO), - io__set_output_stream(Stdout, OldOutputStream, !IO), + io.stdout_stream(Stdout, !IO), + io.set_output_stream(Stdout, OldOutputStream, !IO), display_compiler_version(!IO), - io__set_output_stream(OldOutputStream, _, !IO) + io.set_output_stream(OldOutputStream, _, !IO) ; Help = yes -> - io__stdout_stream(Stdout, !IO), - io__set_output_stream(Stdout, OldOutputStream, !IO), + io.stdout_stream(Stdout, !IO), + io.set_output_stream(Stdout, OldOutputStream, !IO), long_usage(!IO), - io__set_output_stream(OldOutputStream, _, !IO) + io.set_output_stream(OldOutputStream, _, !IO) ; OutputGrade = yes -> % When Mmake asks for the grade, it really wants % the directory component to use. This is consistent % with scripts/canonical_grade. grade_directory_component(Globals, Grade), - io__stdout_stream(Stdout, !IO), - io__write_string(Stdout, Grade, !IO), - io__write_string(Stdout, "\n", !IO) + io.stdout_stream(Stdout, !IO), + io.write_string(Stdout, Grade, !IO), + io.write_string(Stdout, "\n", !IO) ; OutputLinkCommand = yes -> - globals__lookup_string_option(Globals, link_executable_command, + globals.lookup_string_option(Globals, link_executable_command, LinkCommand), - io__stdout_stream(Stdout, !IO), - io__write_string(Stdout, LinkCommand, !IO), - io__write_string(Stdout, "\n", !IO) + io.stdout_stream(Stdout, !IO), + io.write_string(Stdout, LinkCommand, !IO), + io.write_string(Stdout, "\n", !IO) ; OutputShLibLinkCommand = yes -> - globals__lookup_string_option(Globals, link_shared_lib_command, + globals.lookup_string_option(Globals, link_shared_lib_command, LinkCommand), - io__stdout_stream(Stdout, !IO), - io__write_string(Stdout, LinkCommand, !IO), - io__write_string(Stdout, "\n", !IO) + io.stdout_stream(Stdout, !IO), + io.write_string(Stdout, LinkCommand, !IO), + io.write_string(Stdout, "\n", !IO) ; GenerateMapping = yes -> - source_file_map__write_source_file_map(Args, !IO) + source_file_map.write_source_file_map(Args, !IO) ; Make = yes -> - make__process_args(OptionVariables, OptionArgs, Args, !IO) + make_process_args(OptionVariables, OptionArgs, Args, !IO) ; Args = [], FileNamesFromStdin = no -> usage(!IO) ; process_all_args(OptionVariables, OptionArgs, Args, ModulesToLink, FactTableObjFiles, !IO), - io__get_exit_status(ExitStatus, !IO), + io.get_exit_status(ExitStatus, !IO), ( ExitStatus = 0 -> ( Link = yes, @@ -412,7 +412,7 @@ main_2([], OptionVariables, OptionArgs, Args, Link, !IO) :- -> file_name_to_module_name(FirstModule, MainModuleName), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( Target = java -> % For Java, at the "link" step we just % generate a shell script; the actual @@ -435,14 +435,14 @@ main_2([], OptionVariables, OptionArgs, Args, Link, !IO) :- % hint about it. Of course, we should only output the % hint when we have further information to give the user. - globals__lookup_bool_option(Globals, verbose_errors, + globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors), - globals__get_extra_error_info(Globals, ExtraErrorInfo), + globals.get_extra_error_info(Globals, ExtraErrorInfo), ( VerboseErrors = no, ( ExtraErrorInfo = yes, - io__write_string("For more information, " ++ + io.write_string("For more information, " ++ "recompile with `-E'.\n", !IO) ; ExtraErrorInfo = no @@ -451,10 +451,10 @@ main_2([], OptionVariables, OptionArgs, Args, Link, !IO) :- VerboseErrors = yes ) ), - globals__lookup_bool_option(Globals, statistics, Statistics), + globals.lookup_bool_option(Globals, statistics, Statistics), ( Statistics = yes, - io__report_stats("full_memory_stats", !IO) + io.report_stats("full_memory_stats", !IO) ; Statistics = no ) @@ -473,10 +473,10 @@ process_all_args(OptionVariables, OptionArgs, Args, ModulesToLink, % assembler files for each module. % So if we're generating code using the GCC back-end, % we need to call run_gcc_backend here at the top level. - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), ( compiling_to_asm(Globals) -> ( Args = [FirstArg | OtherArgs] -> - globals__lookup_bool_option(Globals, smart_recompilation, Smart), + globals.lookup_bool_option(Globals, smart_recompilation, Smart), ( Smart = yes, ( @@ -493,7 +493,7 @@ process_all_args(OptionVariables, OptionArgs, Args, ModulesToLink, "`--target asm' with `--smart-recompilation' " ++ "with more than one module to compile.", write_error_pieces_plain([words(Msg)], !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), ModulesToLink = [], FactTableObjFiles = [] ) @@ -510,7 +510,7 @@ process_all_args(OptionVariables, OptionArgs, Args, ModulesToLink, Msg = "Sorry, not implemented: `--target asm' " ++ "with `--filenames-from-stdin", write_error_pieces_plain([words(Msg)], !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), ModulesToLink = [], FactTableObjFiles = [] ) @@ -525,7 +525,7 @@ process_all_args(OptionVariables, OptionArgs, Args, ModulesToLink, :- pred compiling_to_asm(globals::in) is semidet. compiling_to_asm(Globals) :- - globals__get_target(Globals, asm), + globals.get_target(Globals, asm), % even if --target asm is specified, % it can be overridden by other options: OptionList = [convert_to_mercury, generate_dependencies, @@ -534,10 +534,10 @@ compiling_to_asm(Globals) :- make_optimization_interface, make_transitive_opt_interface, make_analysis_registry, typecheck_only, errorcheck_only], - BoolList = list__map((func(Opt) = Bool :- - globals__lookup_bool_option(Globals, Opt, Bool)), + BoolList = list.map((func(Opt) = Bool :- + globals.lookup_bool_option(Globals, Opt, Bool)), OptionList), - bool__or_list(BoolList) = no. + bool.or_list(BoolList) = no. :- pred compile_using_gcc_backend(options_variables::in, list(string)::in, file_or_module::in, @@ -559,7 +559,7 @@ compile_using_gcc_backend(OptionVariables, OptionArgs, FirstFileOrModule, % this is needed to handle the case where % the module name does not match the file % name, e.g. file "browse.m" containing - % ":- module mdb__browse." as its first item. + % ":- module mdb.browse." as its first item. % Rather than reading in the source file here, % we just pick a name % for the asm file based on the file name argument, @@ -583,14 +583,14 @@ compile_using_gcc_backend(OptionVariables, OptionArgs, FirstFileOrModule, % and then we'll continue with the normal work of % the compilation, which will be done by the callback % function (`process_args'). - maybe_mlds_to_gcc__run_gcc_backend(FirstModuleName, CallBack, + maybe_mlds_to_gcc.run_gcc_backend(FirstModuleName, CallBack, ModulesToLink, !IO), % Now we know what the real module name was, so we % can rename the assembler file if needed (see above). ( ModulesToLink = [Module | _] -> file_name_to_module_name(Module, ModuleName), - globals__io_lookup_bool_option(pic, Pic, !IO), + globals.io_lookup_bool_option(pic, Pic, !IO), AsmExt = (Pic = yes -> ".pic_s" ; ".s"), module_name_to_file_name(ModuleName, AsmExt, yes, AsmFile, !IO), ( ModuleName \= FirstModuleName -> @@ -603,17 +603,17 @@ compile_using_gcc_backend(OptionVariables, OptionArgs, FirstFileOrModule, % Invoke the assembler to produce an object file, % if needed. - globals__io_lookup_bool_option(target_code_only, TargetCodeOnly, !IO), + globals.io_lookup_bool_option(target_code_only, TargetCodeOnly, !IO), ( Result = ok, TargetCodeOnly = no -> - io__output_stream(OutputStream, !IO), + io.output_stream(OutputStream, !IO), get_linked_target_type(TargetType, !IO), get_object_code_type(TargetType, PIC, !IO), compile_with_module_options(ModuleName, OptionVariables, OptionArgs, - compile_target_code__assemble(OutputStream, PIC, ModuleName), + compile_target_code.assemble(OutputStream, PIC, ModuleName), AssembleOK, !IO), maybe_set_exit_status(AssembleOK, !IO) ; @@ -625,35 +625,35 @@ compile_using_gcc_backend(OptionVariables, OptionArgs, FirstFileOrModule, true ). -:- pred do_rename_file(string::in, string::in, io__res::out, +:- pred do_rename_file(string::in, string::in, io.res::out, io::di, io::uo) is det. do_rename_file(OldFileName, NewFileName, Result, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), maybe_write_string(Verbose, "% Renaming `", !IO), maybe_write_string(Verbose, OldFileName, !IO), maybe_write_string(Verbose, "' as `", !IO), maybe_write_string(Verbose, NewFileName, !IO), maybe_write_string(Verbose, "'...", !IO), maybe_flush_output(Verbose, !IO), - io__rename_file(OldFileName, NewFileName, Result0, !IO), + io.rename_file(OldFileName, NewFileName, Result0, !IO), ( Result0 = error(Error0) -> maybe_write_string(VeryVerbose, " failed.\n", !IO), maybe_flush_output(VeryVerbose, !IO), - io__error_message(Error0, ErrorMsg0), + io.error_message(Error0, ErrorMsg0), % On some systems, we need to remove the existing file % first, if any. So try again that way. maybe_write_string(VeryVerbose, "% Removing `", !IO), maybe_write_string(VeryVerbose, OldFileName, !IO), maybe_write_string(VeryVerbose, "'...", !IO), maybe_flush_output(VeryVerbose, !IO), - io__remove_file(NewFileName, Result1, !IO), + io.remove_file(NewFileName, Result1, !IO), ( Result1 = error(Error1) -> maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(Error1, ErrorMsg1), - string__append_list(["can't rename file `", OldFileName, + io.error_message(Error1, ErrorMsg1), + string.append_list(["can't rename file `", OldFileName, "' as `", NewFileName, "': ", ErrorMsg0, "; and can't remove file `", NewFileName, "': ", ErrorMsg1], Message), @@ -667,12 +667,12 @@ do_rename_file(OldFileName, NewFileName, Result, !IO) :- maybe_write_string(VeryVerbose, NewFileName, !IO), maybe_write_string(VeryVerbose, "' again...", !IO), maybe_flush_output(VeryVerbose, !IO), - io__rename_file(OldFileName, NewFileName, Result2, !IO), + io.rename_file(OldFileName, NewFileName, Result2, !IO), ( Result2 = error(Error2) -> maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(Error2, ErrorMsg), - string__append_list( + io.error_message(Error2, ErrorMsg), + string.append_list( ["can't rename file `", OldFileName, "' as `", NewFileName, "': ", ErrorMsg], Message), report_error(Message, !IO) @@ -699,7 +699,7 @@ process_args_no_fact_table(OptionVariables, OptionArgs, Args, ModulesToLink, process_args(OptionVariables, OptionArgs, Args, ModulesToLink, FactTableObjFiles, !IO) :- - globals__io_lookup_bool_option(filenames_from_stdin, FileNamesFromStdin, + globals.io_lookup_bool_option(filenames_from_stdin, FileNamesFromStdin, !IO), ( FileNamesFromStdin = yes, @@ -723,24 +723,24 @@ process_stdin_arg_list(OptionVariables, OptionArgs, !Modules, ; !.Modules = [] ), - io__read_line_as_string(FileResult, !IO), + io.read_line_as_string(FileResult, !IO), ( FileResult = ok(Line), Arg = string.rstrip(Line), process_arg(OptionVariables, OptionArgs, Arg, Module, FactTableObjFileList, !IO), - list__append(Module, !Modules), - list__append(FactTableObjFileList, !FactTableObjFiles), + list.append(Module, !Modules), + list.append(FactTableObjFileList, !FactTableObjFiles), process_stdin_arg_list(OptionVariables, OptionArgs, !Modules, !FactTableObjFiles, !IO) ; FileResult = eof ; FileResult = error(Error), - io__error_message(Error, Msg), - io__write_string("Error reading module name: ", !IO), - io__write_string(Msg, !IO), - io__set_exit_status(1, !IO) + io.error_message(Error, Msg), + io.write_string("Error reading module name: ", !IO), + io.write_string(Msg, !IO), + io.set_exit_status(1, !IO) ). :- pred process_arg_list(options_variables::in, list(string)::in, @@ -751,8 +751,8 @@ process_arg_list(OptionVariables, OptionArgs, Args, Modules, FactTableObjFiles, !IO) :- process_arg_list_2(OptionVariables, OptionArgs, Args, ModulesList, FactTableObjFileLists, !IO), - list__condense(ModulesList, Modules), - list__condense(FactTableObjFileLists, FactTableObjFiles). + list.condense(ModulesList, Modules), + list.condense(FactTableObjFileLists, FactTableObjFiles). :- pred process_arg_list_2(options_variables::in, list(string)::in, list(string)::in, list(list(string))::out, list(list(string))::out, @@ -785,7 +785,7 @@ process_arg_list_2(OptionVariables, OptionArgs, [Arg | Args], process_arg(OptionVariables, OptionArgs, Arg, ModulesToLink, FactTableObjFiles, !IO) :- FileOrModule = string_to_file_or_module(Arg), - globals__io_lookup_bool_option(invoked_by_mmc_make, InvokedByMake, !IO), + globals.io_lookup_bool_option(invoked_by_mmc_make, InvokedByMake, !IO), ( InvokedByMake = no, build_with_module_options(file_or_module_to_module_name(FileOrModule), @@ -821,7 +821,7 @@ process_arg_build(FileOrModule, OptionVariables, OptionArgs, _, yes, process_arg_2(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, FactTableObjFiles, !IO) :- - globals__io_lookup_bool_option(generate_dependencies, GenerateDeps, !IO), + globals.io_lookup_bool_option(generate_dependencies, GenerateDeps, !IO), ( GenerateDeps = yes, ModulesToLink = [], FactTableObjFiles = [], @@ -833,7 +833,7 @@ process_arg_2(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, generate_module_dependencies(ModuleName, !IO) ) ; GenerateDeps = no, - globals__io_lookup_bool_option(generate_dependency_file, + globals.io_lookup_bool_option(generate_dependency_file, GenerateDepFile, !IO), ( GenerateDepFile = yes, ModulesToLink = [], @@ -858,7 +858,7 @@ process_arg_2(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, :- func string_to_file_or_module(string) = file_or_module. string_to_file_or_module(String) = FileOrModule :- - ( string__remove_suffix(String, ".m", FileName) -> + ( string.remove_suffix(String, ".m", FileName) -> % If the argument name ends in `.m', then we assume it is % a file name. FileOrModule = file(FileName) @@ -885,9 +885,9 @@ file_or_module_to_module_name(module(ModuleName)) = ModuleName. read_module(module(ModuleName), ReturnTimestamp, ModuleName, FileName, MaybeTimestamp, Items, Error, !ReadModules, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Parsing module `", !IO), - mdbcomp__prim_data__sym_name_to_string(ModuleName, ModuleNameString), + sym_name_to_string(ModuleName, ModuleNameString), maybe_write_string(Verbose, ModuleNameString, !IO), maybe_write_string(Verbose, "' and imported interfaces...\n", !IO), ( @@ -896,7 +896,7 @@ read_module(module(ModuleName), ReturnTimestamp, ModuleName, FileName, find_read_module(!.ReadModules, ModuleName, ".m", ReturnTimestamp, Items0, MaybeTimestamp0, Error0, FileName0) -> - map__delete(!.ReadModules, ModuleName - ".m", !:ReadModules), + map.delete(!.ReadModules, ModuleName - ".m", !:ReadModules), FileName = FileName0, Items = Items0, Error = Error0, @@ -909,11 +909,11 @@ read_module(module(ModuleName), ReturnTimestamp, ModuleName, FileName, read_mod(ModuleName, ".m", "Reading module", Search, ReturnTimestamp, Items, Error, FileName, MaybeTimestamp, !IO) ), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_report_stats(Stats, !IO). read_module(file(FileName), ReturnTimestamp, ModuleName, SourceFileName, MaybeTimestamp, Items, Error, !ReadModules, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Parsing file `", !IO), maybe_write_string(Verbose, FileName, !IO), maybe_write_string(Verbose, "' and imported interfaces...\n", !IO), @@ -925,7 +925,7 @@ read_module(file(FileName), ReturnTimestamp, ModuleName, SourceFileName, find_read_module(!.ReadModules, DefaultModuleName, ".m", ReturnTimestamp, Items0, MaybeTimestamp0, Error0, _) -> - map__delete(!.ReadModules, ModuleName - ".m", !:ReadModules), + map.delete(!.ReadModules, ModuleName - ".m", !:ReadModules), ModuleName = DefaultModuleName, Items = Items0, Error = Error0, @@ -946,12 +946,12 @@ read_module(file(FileName), ReturnTimestamp, ModuleName, SourceFileName, % This will be fixed when mmake functionality % is moved into the compiler. % - globals__io_lookup_bool_option(smart_recompilation, Smart, !IO), + globals.io_lookup_bool_option(smart_recompilation, Smart, !IO), ( Smart = yes, ModuleName \= DefaultModuleName -> - globals__io_lookup_bool_option(warn_smart_recompilation, Warn, + globals.io_lookup_bool_option(warn_smart_recompilation, Warn, !IO), ( Warn = yes, @@ -968,14 +968,14 @@ read_module(file(FileName), ReturnTimestamp, ModuleName, SourceFileName, ; Warn = no ), - globals__io_set_option(smart_recompilation, bool(no), !IO) + globals.io_set_option(smart_recompilation, bool(no), !IO) ; true ) ), - globals__io_lookup_bool_option(detailed_statistics, Stats, !IO), + globals.io_lookup_bool_option(detailed_statistics, Stats, !IO), maybe_report_stats(Stats, !IO), - string__append(FileName, ".m", SourceFileName). + string.append(FileName, ".m", SourceFileName). :- pred process_module(options_variables::in, list(string)::in, file_or_module::in, list(string)::out, list(string)::out, @@ -983,17 +983,17 @@ read_module(file(FileName), ReturnTimestamp, ModuleName, SourceFileName, process_module(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, FactTableObjFiles, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, halt_at_syntax_errors, + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, halt_at_syntax_errors, HaltSyntax), - globals__lookup_bool_option(Globals, make_interface, MakeInterface), - globals__lookup_bool_option(Globals, make_short_interface, + globals.lookup_bool_option(Globals, make_interface, MakeInterface), + globals.lookup_bool_option(Globals, make_short_interface, MakeShortInterface), - globals__lookup_bool_option(Globals, make_private_interface, + globals.lookup_bool_option(Globals, make_private_interface, MakePrivateInterface), - globals__lookup_bool_option(Globals, convert_to_mercury, + globals.lookup_bool_option(Globals, convert_to_mercury, ConvertToMercury), - globals__lookup_bool_option(Globals, generate_item_version_numbers, + globals.lookup_bool_option(Globals, generate_item_version_numbers, GenerateVersionNumbers), ( ( MakeInterface = yes -> @@ -1010,12 +1010,12 @@ process_module(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, ) -> read_module(FileOrModule, ReturnTimestamp, ModuleName, FileName, - MaybeTimestamp, Items, Error, map__init, _, !IO), + MaybeTimestamp, Items, Error, map.init, _, !IO), ( halt_at_module_error(HaltSyntax, Error) -> true ; split_into_submodules(ModuleName, Items, SubModuleList, !IO), - list__foldl(apply_process_module(ProcessModule, + list.foldl(apply_process_module(ProcessModule, FileName, ModuleName, MaybeTimestamp), SubModuleList, !IO) ), ModulesToLink = [], @@ -1024,7 +1024,7 @@ process_module(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, ConvertToMercury = yes -> read_module(FileOrModule, no, ModuleName, _, _, - Items, Error, map__init, _, !IO), + Items, Error, map.init, _, !IO), ( halt_at_module_error(HaltSyntax, Error) -> true ; @@ -1035,9 +1035,9 @@ process_module(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, ModulesToLink = [], FactTableObjFiles = [] ; - globals__lookup_bool_option(Globals, smart_recompilation, + globals.lookup_bool_option(Globals, smart_recompilation, Smart), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( Smart = yes, ( @@ -1058,7 +1058,7 @@ process_module(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, find_smart_recompilation_target_files(ModuleName, Globals, FindTargetFiles), find_timestamp_files(ModuleName, Globals, FindTimestampFiles), - recompilation__check__should_recompile(ModuleName, FindTargetFiles, + recompilation.check.should_recompile(ModuleName, FindTargetFiles, FindTimestampFiles, ModulesToRecompile0, ReadModules, !IO), ( Target = asm, @@ -1076,7 +1076,7 @@ process_module(OptionVariables, OptionArgs, FileOrModule, ModulesToLink, ) ; Smart = no, - map__init(ReadModules), + map.init(ReadModules), ModulesToRecompile = all_modules ), ( ModulesToRecompile = some_modules([]) -> @@ -1134,7 +1134,7 @@ process_module_2(FileOrModule, MaybeModulesToRecompile, ReadModules0, ModulesToLink, FactTableObjFiles, !IO) :- read_module(FileOrModule, yes, ModuleName, FileName, MaybeTimestamp, Items, Error, ReadModules0, ReadModules, !IO), - globals__io_lookup_bool_option(halt_at_syntax_errors, HaltSyntax, !IO), + globals.io_lookup_bool_option(halt_at_syntax_errors, HaltSyntax, !IO), ( halt_at_module_error(HaltSyntax, Error) -> ModulesToLink = [], FactTableObjFiles = [] @@ -1142,16 +1142,16 @@ process_module_2(FileOrModule, MaybeModulesToRecompile, ReadModules0, split_into_submodules(ModuleName, Items, SubModuleList0, !IO), ( MaybeModulesToRecompile = some_modules(ModulesToRecompile) -> ToRecompile = (pred((SubModule - _)::in) is semidet :- - list__member(SubModule, ModulesToRecompile) + list.member(SubModule, ModulesToRecompile) ), - list__filter(ToRecompile, SubModuleList0, SubModuleListToCompile) + list.filter(ToRecompile, SubModuleList0, SubModuleListToCompile) ; SubModuleListToCompile = SubModuleList0 ), - assoc_list__keys(SubModuleList0, NestedSubModules0), - list__delete_all(NestedSubModules0, ModuleName, NestedSubModules), + assoc_list.keys(SubModuleList0, NestedSubModules0), + list.delete_all(NestedSubModules0, ModuleName, NestedSubModules), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), find_timestamp_files(ModuleName, Globals, FindTimestampFiles), globals.io_lookup_bool_option(trace_prof, TraceProf, !IO), @@ -1169,18 +1169,18 @@ process_module_2(FileOrModule, MaybeModulesToRecompile, ReadModules0, % there should never be part of an execution trace % anyway; they are effectively language primitives. % (They may still be parts of stack traces.) - globals__io_lookup_bool_option(trace_stack_layout, TSL, !IO), - globals__io_get_trace_level(TraceLevel, !IO), + globals.io_lookup_bool_option(trace_stack_layout, TSL, !IO), + globals.io_get_trace_level(TraceLevel, !IO), - globals__io_set_option(trace_stack_layout, bool(no), !IO), - globals__io_set_trace_level_none(!IO), + globals.io_set_option(trace_stack_layout, bool(no), !IO), + globals.io_set_trace_level_none(!IO), compile_all_submodules(FileName, ModuleName, NestedSubModules, MaybeTimestamp, ReadModules, FindTimestampFiles, SubModuleListToCompile, ModulesToLink, FactTableObjFiles, !IO), - globals__io_set_option(trace_stack_layout, bool(TSL), !IO), - globals__io_set_trace_level(TraceLevel, !IO) + globals.io_set_option(trace_stack_layout, bool(TSL), !IO), + globals.io_set_trace_level(TraceLevel, !IO) ; compile_all_submodules(FileName, ModuleName, NestedSubModules, MaybeTimestamp, ReadModules, FindTimestampFiles, @@ -1192,7 +1192,7 @@ process_module_2(FileOrModule, MaybeModulesToRecompile, ReadModules0, % compile each sub-module to its own C file. % XXX it would be better to do something like % - % list__map2_foldl(compile_to_llds, SubModuleList, + % list.map2_foldl(compile_to_llds, SubModuleList, % LLDS_FragmentList), % merge_llds_fragments(LLDS_FragmentList, LLDS), % output_pass(LLDS_FragmentList) @@ -1208,11 +1208,11 @@ process_module_2(FileOrModule, MaybeModulesToRecompile, ReadModules0, compile_all_submodules(FileName, SourceFileModuleName, NestedSubModules, MaybeTimestamp, ReadModules, FindTimestampFiles, SubModuleList, ModulesToLink, FactTableObjFiles, !IO) :- - list__map_foldl(compile(FileName, SourceFileModuleName, NestedSubModules, + list.map_foldl(compile(FileName, SourceFileModuleName, NestedSubModules, MaybeTimestamp, ReadModules, FindTimestampFiles), SubModuleList, FactTableObjFileLists, !IO), - list__map(module_to_link, SubModuleList, ModulesToLink), - list__condense(FactTableObjFileLists, FactTableObjFiles). + list.map(module_to_link, SubModuleList, ModulesToLink), + list.condense(FactTableObjFileLists, FactTableObjFiles). :- pred make_interface(file_name::in, module_name::in, maybe(timestamp)::in, pair(module_name, item_list)::in, io::di, io::uo) is det. @@ -1257,7 +1257,7 @@ module_to_link(ModuleName - _Items, ModuleToLink) :- compile_with_module_options(ModuleName, OptionVariables, OptionArgs, Compile, Succeeded, !IO) :- - globals__io_lookup_bool_option(invoked_by_mmc_make, InvokedByMake, !IO), + globals.io_lookup_bool_option(invoked_by_mmc_make, InvokedByMake, !IO), ( InvokedByMake = yes, % `mmc --make' has already set up the options. @@ -1288,7 +1288,7 @@ compile_with_module_options(ModuleName, OptionVariables, OptionArgs, find_smart_recompilation_target_files(TopLevelModuleName, Globals, FindTargetFiles) :- - globals__get_target(Globals, CompilationTarget), + globals.get_target(Globals, CompilationTarget), ( CompilationTarget = c, TargetSuffix = ".c" ; CompilationTarget = il, TargetSuffix = ".il" ; CompilationTarget = java, TargetSuffix = ".java" @@ -1320,8 +1320,8 @@ usual_find_target_files(CompilationTarget, TargetSuffix, TopLevelModuleName, find_timestamp_file_names::out(find_timestamp_file_names)) is det. find_timestamp_files(TopLevelModuleName, Globals, FindTimestampFiles) :- - globals__lookup_bool_option(Globals, pic, Pic), - globals__get_target(Globals, CompilationTarget), + globals.lookup_bool_option(Globals, pic, Pic), + globals.get_target(Globals, CompilationTarget), ( CompilationTarget = c, TimestampSuffix = ".c_date" @@ -1409,9 +1409,9 @@ mercury_compile(Module, NestedSubModules, FindTimestampFiles, module_imports_get_module_name(Module, ModuleName), % If we are only typechecking or error checking, then we should not % modify any files, this includes writing to .d files. - globals__io_lookup_bool_option(typecheck_only, TypeCheckOnly, !IO), - globals__io_lookup_bool_option(errorcheck_only, ErrorCheckOnly, !IO), - bool__or(TypeCheckOnly, ErrorCheckOnly, DontWriteDFile), + globals.io_lookup_bool_option(typecheck_only, TypeCheckOnly, !IO), + globals.io_lookup_bool_option(errorcheck_only, ErrorCheckOnly, !IO), + bool.or(TypeCheckOnly, ErrorCheckOnly, DontWriteDFile), pre_hlds_pass(Module, DontWriteDFile, HLDS1, QualInfo, MaybeTimestamps, UndefTypes, UndefModes, Errors1, !DumpInfo, !IO), frontend_pass(QualInfo, UndefTypes, UndefModes, Errors1, Errors2, @@ -1420,24 +1420,24 @@ mercury_compile(Module, NestedSubModules, FindTimestampFiles, Errors1 = no, Errors2 = no -> - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_dependency_graph(Verbose, Stats, HLDS20, HLDS21, !IO), - globals__io_lookup_bool_option(make_optimization_interface, + globals.io_lookup_bool_option(make_optimization_interface, MakeOptInt, !IO), - globals__io_lookup_bool_option(make_transitive_opt_interface, + globals.io_lookup_bool_option(make_transitive_opt_interface, MakeTransOptInt, !IO), - globals__io_lookup_bool_option(make_analysis_registry, + globals.io_lookup_bool_option(make_analysis_registry, MakeAnalysisRegistry, !IO), ( TypeCheckOnly = yes -> FactTableObjFiles = [] ; ErrorCheckOnly = yes -> % we may still want to run `unused_args' so that we get % the appropriate warnings - globals__io_lookup_bool_option(warn_unused_args, UnusedArgs, !IO), + globals.io_lookup_bool_option(warn_unused_args, UnusedArgs, !IO), ( UnusedArgs = yes, - globals__io_set_option(optimize_unused_args, bool(no), !IO), + globals.io_set_option(optimize_unused_args, bool(no), !IO), maybe_unused_args(Verbose, Stats, HLDS21, _HLDS22, !IO) ; UnusedArgs = no @@ -1460,9 +1460,9 @@ mercury_compile(Module, NestedSubModules, FindTimestampFiles, ; % If the number of errors is > 0, make sure that the compiler % exits with a non-zero exit status. - io__get_exit_status(ExitStatus, !IO), + io.get_exit_status(ExitStatus, !IO), ( ExitStatus = 0 -> - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; true ), @@ -1477,13 +1477,13 @@ mercury_compile(Module, NestedSubModules, FindTimestampFiles, mercury_compile_after_front_end(NestedSubModules, FindTimestampFiles, MaybeTimestamps, ModuleName, !.HLDS, FactTableBaseFiles, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_output_prof_call_graph(Verbose, Stats, !HLDS, !IO), middle_pass(ModuleName, !HLDS, !DumpInfo, !IO), - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), - globals__io_get_target(Target, !IO), - globals__io_lookup_bool_option(target_code_only, TargetCodeOnly, !IO), + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), + globals.io_get_target(Target, !IO), + globals.io_lookup_bool_option(target_code_only, TargetCodeOnly, !IO), % % Remove any existing `.used' file before writing the @@ -1493,7 +1493,7 @@ mercury_compile_after_front_end(NestedSubModules, FindTimestampFiles, % `.used' file is written. % module_name_to_file_name(ModuleName, ".used", no, UsageFileName, !IO), - io__remove_file(UsageFileName, _, !IO), + io.remove_file(UsageFileName, _, !IO), module_info_get_num_errors(!.HLDS, NumErrors), ( NumErrors = 0 -> @@ -1507,8 +1507,8 @@ mercury_compile_after_front_end(NestedSubModules, FindTimestampFiles, % .mh containing function prototypes % for the `:- pragma export'ed procedures. % - export__get_foreign_export_decls(!.HLDS, ExportDecls), - export__produce_header_file(ExportDecls, ModuleName, !IO) + export.get_foreign_export_decls(!.HLDS, ExportDecls), + export.produce_header_file(ExportDecls, ModuleName, !IO) ; true ), @@ -1521,8 +1521,8 @@ mercury_compile_after_front_end(NestedSubModules, FindTimestampFiles, TargetCodeOnly = no, HasMain = mlds_has_main(MLDS), mlds_to_il_assembler(MLDS, !IO), - io__output_stream(OutputStream, !IO), - compile_target_code__il_assemble(OutputStream, ModuleName, + io.output_stream(OutputStream, !IO), + compile_target_code.il_assemble(OutputStream, ModuleName, HasMain, Succeeded, !IO), maybe_set_exit_status(Succeeded, !IO) ), @@ -1534,10 +1534,10 @@ mercury_compile_after_front_end(NestedSubModules, FindTimestampFiles, TargetCodeOnly = yes ; TargetCodeOnly = no, - io__output_stream(OutputStream, !IO), + io.output_stream(OutputStream, !IO), module_name_to_file_name(ModuleName, ".java", no, JavaFile, !IO), - compile_target_code__compile_java_file(OutputStream, JavaFile, + compile_target_code.compile_java_file(OutputStream, JavaFile, Succeeded, !IO), maybe_set_exit_status(Succeeded, !IO) ), @@ -1576,8 +1576,8 @@ mercury_compile_after_front_end(NestedSubModules, FindTimestampFiles, get_object_code_type(TargetType, PIC, !IO), maybe_pic_object_file_extension(PIC, Obj, !IO), module_name_to_file_name(ModuleName, Obj, yes, O_File, !IO), - io__output_stream(OutputStream, !IO), - compile_target_code__compile_c_file(OutputStream, PIC, C_File, + io.output_stream(OutputStream, !IO), + compile_target_code.compile_c_file(OutputStream, PIC, C_File, O_File, CompileOK, !IO), maybe_set_exit_status(CompileOK, !IO) ), @@ -1587,16 +1587,16 @@ mercury_compile_after_front_end(NestedSubModules, FindTimestampFiles, output_pass(!.HLDS, GlobalData, LLDS, ModuleName, _CompileErrors, FactTableBaseFiles, !IO) ), - recompilation__usage__write_usage_file(!.HLDS, NestedSubModules, + recompilation.usage.write_usage_file(!.HLDS, NestedSubModules, MaybeTimestamps, !IO), FindTimestampFiles(ModuleName, TimestampFiles, !IO), - list__foldl(touch_datestamp, TimestampFiles, !IO) + list.foldl(touch_datestamp, TimestampFiles, !IO) ; % If the number of errors is > 0, make sure that the compiler % exits with a non-zero exit status. - io__get_exit_status(ExitStatus, !IO), + io.get_exit_status(ExitStatus, !IO), ( ExitStatus = 0 -> - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; true ), @@ -1612,14 +1612,14 @@ mercury_compile_asm_c_code(ModuleName, !IO) :- module_name_to_file_name(ModuleName, ".c", no, CCode_C_File, !IO), ForeignModuleName = foreign_language_module_name(ModuleName, c), module_name_to_file_name(ForeignModuleName, Obj, yes, CCode_O_File, !IO), - io__output_stream(OutputStream, !IO), - compile_target_code__compile_c_file(OutputStream, PIC, + io.output_stream(OutputStream, !IO), + compile_target_code.compile_c_file(OutputStream, PIC, CCode_C_File, CCode_O_File, CompileOK, !IO), maybe_set_exit_status(CompileOK, !IO), % add this object file to the list % of extra object files to link in - globals__io_lookup_accumulating_option(link_objects, LinkObjects, !IO), - globals__io_set_option(link_objects, + globals.io_lookup_accumulating_option(link_objects, LinkObjects, !IO), + globals.io_set_option(link_objects, accumulating([CCode_O_File | LinkObjects]), !IO). % return `yes' iff this module defines the main/2 entry point. @@ -1638,7 +1638,7 @@ mlds_has_main(MLDS) = :- pred get_linked_target_type(linked_target_type::out, io::di, io::uo) is det. get_linked_target_type(LinkedTargetType, !IO) :- - globals__io_lookup_bool_option(compile_to_shared_lib, MakeSharedLib, !IO), + globals.io_lookup_bool_option(compile_to_shared_lib, MakeSharedLib, !IO), ( MakeSharedLib = yes -> LinkedTargetType = shared_library ; @@ -1655,15 +1655,15 @@ get_linked_target_type(LinkedTargetType, !IO) :- pre_hlds_pass(ModuleImports0, DontWriteDFile0, HLDS1, QualInfo, MaybeTimestamps, UndefTypes, UndefModes, FoundError, !DumpInfo, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, statistics, Stats), - globals__lookup_bool_option(Globals, verbose, Verbose), - globals__lookup_bool_option(Globals, invoked_by_mmc_make, MMCMake), + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, statistics, Stats), + globals.lookup_bool_option(Globals, verbose, Verbose), + globals.lookup_bool_option(Globals, invoked_by_mmc_make, MMCMake), DontWriteDFile1 = DontWriteDFile0 `or` MMCMake, % Don't write the `.d' file when making the `.opt' file because % we can't work out the full transitive implementation dependencies. - globals__lookup_bool_option(Globals, make_optimization_interface, + globals.lookup_bool_option(Globals, make_optimization_interface, MakeOptInt), DontWriteDFile = DontWriteDFile1 `or` MakeOptInt, @@ -1694,13 +1694,13 @@ pre_hlds_pass(ModuleImports0, DontWriteDFile0, HLDS1, QualInfo, expand_equiv_types(Module, Items2, Verbose, Stats, Items, CircularTypes, EqvMap, RecompInfo0, RecompInfo, !IO), mq_info_set_recompilation_info(RecompInfo, MQInfo0, MQInfo), - bool__or(UndefTypes0, CircularTypes, UndefTypes1), + bool.or(UndefTypes0, CircularTypes, UndefTypes1), make_hlds(Module, Items, MQInfo, EqvMap, Verbose, Stats, HLDS0, QualInfo, UndefTypes2, UndefModes2, FoundError, !IO), - bool__or(UndefTypes1, UndefTypes2, UndefTypes), - bool__or(UndefModes0, UndefModes2, UndefModes), + bool.or(UndefTypes1, UndefTypes2, UndefTypes), + bool.or(UndefModes0, UndefModes2, UndefModes), maybe_dump_hlds(HLDS0, 1, "initial", !DumpInfo, !IO), @@ -1710,11 +1710,11 @@ pre_hlds_pass(ModuleImports0, DontWriteDFile0, HLDS1, QualInfo, DontWriteDFile = no, module_info_get_all_deps(HLDS0, AllDeps), write_dependency_file(ModuleImports0, AllDeps, MaybeTransOptDeps, !IO), - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, generate_mmc_make_module_dependencies, OutputMMCMakeDeps), ( OutputMMCMakeDeps = yes, - make__write_module_dep_file(ModuleImports0, !IO) + make_write_module_dep_file(ModuleImports0, !IO) ; OutputMMCMakeDeps = no ) @@ -1739,7 +1739,7 @@ module_qualify_items(Items0, Items, ModuleName, Verbose, Stats, MQInfo, NumErrors, UndefTypes, UndefModes, !IO) :- maybe_write_string(Verbose, "% Module qualifying items...\n", !IO), maybe_flush_output(Verbose, !IO), - module_qual__module_qualify_items(Items0, Items, ModuleName, yes, + module_qual.module_qualify_items(Items0, Items, ModuleName, yes, MQInfo, NumErrors, UndefTypes, UndefModes, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO). @@ -1750,14 +1750,14 @@ module_qualify_items(Items0, Items, ModuleName, Verbose, Stats, MQInfo, maybe_grab_optfiles(Imports0, Verbose, MaybeTransOptDeps, Imports, Error, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, intermodule_optimization, + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, intermodule_optimization, IntermodOpt), - globals__lookup_bool_option(Globals, use_opt_files, UseOptInt), - globals__lookup_bool_option(Globals, make_optimization_interface, + globals.lookup_bool_option(Globals, use_opt_files, UseOptInt), + globals.lookup_bool_option(Globals, make_optimization_interface, MakeOptInt), - globals__lookup_bool_option(Globals, transitive_optimization, TransOpt), - globals__lookup_bool_option(Globals, make_transitive_opt_interface, + globals.lookup_bool_option(Globals, transitive_optimization, TransOpt), + globals.lookup_bool_option(Globals, make_transitive_opt_interface, MakeTransOptInt), ( ( UseOptInt = yes @@ -1767,7 +1767,7 @@ maybe_grab_optfiles(Imports0, Verbose, MaybeTransOptDeps, Imports, Error, -> maybe_write_string(Verbose, "% Reading .opt files...\n", !IO), maybe_flush_output(Verbose, !IO), - intermod__grab_optfiles(Imports0, Imports1, Error1, !IO), + intermod.grab_optfiles(Imports0, Imports1, Error1, !IO), maybe_write_string(Verbose, "% Done.\n", !IO) ; Imports1 = Imports0, @@ -1778,14 +1778,14 @@ maybe_grab_optfiles(Imports0, Verbose, MaybeTransOptDeps, Imports, Error, MaybeTransOptDeps = yes(TransOptDeps), % When creating the trans_opt file, only import the % trans_opt files which are lower in the ordering. - trans_opt__grab_optfiles(TransOptDeps, Imports1, Imports, Error2, + trans_opt.grab_optfiles(TransOptDeps, Imports1, Imports, Error2, !IO) ; MaybeTransOptDeps = no, Imports = Imports1, Error2 = no, module_imports_get_module_name(Imports, ModuleName), - globals__lookup_bool_option(Globals, warn_missing_trans_opt_deps, + globals.lookup_bool_option(Globals, warn_missing_trans_opt_deps, WarnNoTransOptDeps), ( WarnNoTransOptDeps = yes, @@ -1812,9 +1812,9 @@ maybe_grab_optfiles(Imports0, Verbose, MaybeTransOptDeps, Imports, Error, % not creating the .opt or .trans opt file, then import % the trans_opt files for all the modules that are % imported (or used), and for all ancestor modules. - list__condense([Imports0 ^ parent_deps, + list.condense([Imports0 ^ parent_deps, Imports0 ^ int_deps, Imports0 ^ impl_deps], TransOptFiles), - trans_opt__grab_optfiles(TransOptFiles, Imports1, Imports, Error2, + trans_opt.grab_optfiles(TransOptFiles, Imports1, Imports, Error2, !IO) ; TransOpt = no, @@ -1822,7 +1822,7 @@ maybe_grab_optfiles(Imports0, Verbose, MaybeTransOptDeps, Imports, Error, Error2 = no ) ), - bool__or(Error1, Error2, Error). + bool.or(Error1, Error2, Error). :- pred expand_equiv_types(module_name::in, item_list::in, bool::in, bool::in, item_list::out, bool::out, eqv_map::out, @@ -1833,7 +1833,7 @@ expand_equiv_types(ModuleName, Items0, Verbose, Stats, Items, CircularTypes, EqvMap, RecompInfo0, RecompInfo, !IO) :- maybe_write_string(Verbose, "% Expanding equivalence types...", !IO), maybe_flush_output(Verbose, !IO), - equiv_type__expand_eqv_types(ModuleName, Items0, Items, CircularTypes, + equiv_type.expand_eqv_types(ModuleName, Items0, Items, CircularTypes, EqvMap, RecompInfo0, RecompInfo, !IO), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO). @@ -1850,14 +1850,14 @@ make_hlds(Module, Items, MQInfo, EqvMap, Verbose, Stats, HLDS, QualInfo, parse_tree_to_hlds(Prog, MQInfo, EqvMap, HLDS, QualInfo, UndefTypes, UndefModes, !IO), module_info_get_num_errors(HLDS, NumErrors), - io__get_exit_status(Status, !IO), + io.get_exit_status(Status, !IO), ( ( Status \= 0 ; NumErrors > 0 ) -> FoundSemanticError = yes, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; FoundSemanticError = no ), @@ -1875,18 +1875,18 @@ frontend_pass(QualInfo0, FoundUndefTypeError, FoundUndefModeError, !FoundError, !HLDS, !DumpInfo, !IO) :- % We can't continue after an undefined type error, since typecheck % would get internal errors. - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, verbose, Verbose), + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, verbose, Verbose), ( FoundUndefTypeError = yes, !:FoundError = yes, maybe_write_string(Verbose, "% Program contains undefined type error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; FoundUndefTypeError = no, maybe_write_string(Verbose, "% Checking typeclasses...\n", !IO), - check_typeclass__check_typeclasses(QualInfo0, QualInfo, !HLDS, + check_typeclass.check_typeclasses(QualInfo0, QualInfo, !HLDS, FoundTypeclassError, !IO), maybe_dump_hlds(!.HLDS, 5, "typeclass", !DumpInfo, !IO), set_module_recomp_info(QualInfo, !HLDS), @@ -1909,12 +1909,12 @@ frontend_pass(QualInfo0, FoundUndefTypeError, FoundUndefModeError, !FoundError, frontend_pass_no_type_error(FoundUndefModeError, !FoundError, !HLDS, !DumpInfo, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, verbose, Verbose), - globals__lookup_bool_option(Globals, statistics, Stats), - globals__lookup_bool_option(Globals, intermodule_optimization, Intermod), - globals__lookup_bool_option(Globals, use_opt_files, UseOptFiles), - globals__lookup_bool_option(Globals, make_optimization_interface, + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, verbose, Verbose), + globals.lookup_bool_option(Globals, statistics, Stats), + globals.lookup_bool_option(Globals, intermodule_optimization, Intermod), + globals.lookup_bool_option(Globals, use_opt_files, UseOptFiles), + globals.lookup_bool_option(Globals, make_optimization_interface, MakeOptInt), ( ( Intermod = yes @@ -1943,7 +1943,7 @@ frontend_pass_no_type_error(FoundUndefModeError, !FoundError, !HLDS, !DumpInfo, FoundTypeError = yes, maybe_write_string(Verbose, "% Program contains type error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; FoundTypeError = no, maybe_write_string(Verbose, "% Program is type-correct.\n", !IO) @@ -1963,12 +1963,12 @@ frontend_pass_no_type_error(FoundUndefModeError, !FoundError, !HLDS, !DumpInfo, maybe_write_string(Verbose, "% Program contains undefined inst " ++ "or undefined mode error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; ExceededTypeCheckIterationLimit = yes -> % FoundTypeError will always be true here, so we've already % printed a message about the program containing type errors. !:FoundError = yes, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; puritycheck(Verbose, Stats, !HLDS, FoundTypeError, FoundPostTypecheckError, !IO), @@ -1979,7 +1979,7 @@ frontend_pass_no_type_error(FoundUndefModeError, !FoundError, !HLDS, !DumpInfo, % % Stop here if `--typecheck-only' was specified. % - globals__lookup_bool_option(Globals, typecheck_only, TypecheckOnly), + globals.lookup_bool_option(Globals, typecheck_only, TypecheckOnly), ( TypecheckOnly = yes -> @@ -2024,27 +2024,27 @@ frontend_pass_no_type_error(FoundUndefModeError, !FoundError, !HLDS, !DumpInfo, dump_info::in, dump_info::out, io::di, io::uo) is det. maybe_write_optfile(MakeOptInt, !HLDS, !DumpInfo, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, intermodule_optimization, Intermod), - globals__lookup_bool_option(Globals, intermod_unused_args, IntermodArgs), - globals__lookup_accumulating_option(Globals, intermod_directories, + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, intermodule_optimization, Intermod), + globals.lookup_bool_option(Globals, intermod_unused_args, IntermodArgs), + globals.lookup_accumulating_option(Globals, intermod_directories, IntermodDirs), - globals__lookup_bool_option(Globals, use_opt_files, UseOptFiles), - globals__lookup_bool_option(Globals, verbose, Verbose), - globals__lookup_bool_option(Globals, statistics, Stats), - globals__lookup_bool_option(Globals, termination, Termination), - globals__lookup_bool_option(Globals, termination2, Termination2), - globals__lookup_bool_option(Globals, structure_sharing_analysis, + globals.lookup_bool_option(Globals, use_opt_files, UseOptFiles), + globals.lookup_bool_option(Globals, verbose, Verbose), + globals.lookup_bool_option(Globals, statistics, Stats), + globals.lookup_bool_option(Globals, termination, Termination), + globals.lookup_bool_option(Globals, termination2, Termination2), + globals.lookup_bool_option(Globals, structure_sharing_analysis, SharingAnalysis), - globals__lookup_bool_option(Globals, analyse_exceptions, + globals.lookup_bool_option(Globals, analyse_exceptions, ExceptionAnalysis), - globals__lookup_bool_option(Globals, analyse_closures, + globals.lookup_bool_option(Globals, analyse_closures, ClosureAnalysis), - globals__lookup_bool_option(Globals, analyse_trail_usage, + globals.lookup_bool_option(Globals, analyse_trail_usage, TrailingAnalysis), ( MakeOptInt = yes, - intermod__write_optfile(!HLDS, !IO), + intermod.write_optfile(!HLDS, !IO), % If intermod_unused_args is being performed, run polymorphism, % mode analysis and determinism analysis, then run unused_args @@ -2110,7 +2110,7 @@ maybe_write_optfile(MakeOptInt, !HLDS, !DumpInfo, !IO) :- TrailingAnalysis = no ) ; - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ) ; true @@ -2131,7 +2131,7 @@ maybe_write_optfile(MakeOptInt, !HLDS, !DumpInfo, !IO) :- search_for_file(IntermodDirs, OptName, Found, !IO), ( Found = ok(_) -> UpdateStatus = yes, - io__seen(!IO) + io.seen(!IO) ; UpdateStatus = no ) @@ -2140,7 +2140,7 @@ maybe_write_optfile(MakeOptInt, !HLDS, !DumpInfo, !IO) :- ), ( UpdateStatus = yes, - intermod__adjust_pred_import_status(!HLDS, !IO) + intermod.adjust_pred_import_status(!HLDS, !IO) ; UpdateStatus = no ) @@ -2150,9 +2150,9 @@ maybe_write_optfile(MakeOptInt, !HLDS, !DumpInfo, !IO) :- io::di, io::uo) is det. output_trans_opt_file(!.HLDS, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), - globals__io_lookup_bool_option(analyse_closures, ClosureAnalysis, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(analyse_closures, ClosureAnalysis, !IO), % % Closure analysis assumes that lambda expressions have % been converted into separate predicates. @@ -2176,16 +2176,16 @@ output_trans_opt_file(!.HLDS, !DumpInfo, !IO) :- maybe_dump_hlds(!.HLDS, 167, "trail_usage", !DumpInfo, !IO), maybe_structure_sharing_analysis(Verbose, Stats, !HLDS, !IO), maybe_dump_hlds(!.HLDS, 193, "structure_sharing", !DumpInfo, !IO), - trans_opt__write_optfile(!.HLDS, !IO). + trans_opt.write_optfile(!.HLDS, !IO). :- pred output_analysis_file(module_name::in, module_info::in, dump_info::in, dump_info::out, io::di, io::uo) is det. output_analysis_file(ModuleName, !.HLDS, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), - globals__io_lookup_bool_option(analyse_closures, ClosureAnalysis, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(analyse_closures, ClosureAnalysis, !IO), % % Closure analysis assumes that lambda expressions have % been converted into separate predicates. @@ -2215,15 +2215,15 @@ output_analysis_file(ModuleName, !.HLDS, !DumpInfo, !IO) :- ModuleId = module_name_to_module_id(ModuleName), ImportedModuleIds = set.map(module_name_to_module_id, ImportedModules), - analysis__write_analysis_files(mmc, ModuleId, ImportedModuleIds, + analysis.write_analysis_files(mmc, ModuleId, ImportedModuleIds, AnalysisInfo, _AnalysisInfo, !IO). :- pred frontend_pass_by_phases(module_info::in, module_info::out, bool::out, dump_info::in, dump_info::out, io::di, io::uo) is det. frontend_pass_by_phases(!HLDS, FoundError, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_polymorphism(Verbose, Stats, !HLDS, !IO), maybe_dump_hlds(!.HLDS, 30, "polymorphism", !DumpInfo, !IO), @@ -2259,7 +2259,7 @@ frontend_pass_by_phases(!HLDS, FoundError, !DumpInfo, !IO) :- maybe_dump_hlds(!.HLDS, 65, "frontend_simplify", !DumpInfo, !IO), % Work out whether we encountered any errors. - io__get_exit_status(ExitStatus, !IO), + io.get_exit_status(ExitStatus, !IO), ( FoundModeError = no, FoundDetError = no, @@ -2284,8 +2284,8 @@ frontend_pass_by_phases(!HLDS, FoundError, !DumpInfo, !IO) :- dump_info::in, dump_info::out, io::di, io::uo) is det. middle_pass(ModuleName, !HLDS, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_read_experimental_complexity_file(!HLDS, !IO), @@ -2428,14 +2428,14 @@ middle_pass(ModuleName, !HLDS, !DumpInfo, !IO) :- backend_pass(!HLDS, GlobalData, LLDS, !DumpInfo, !IO) :- module_info_get_name(!.HLDS, ModuleName), - globals__io_lookup_bool_option(unboxed_float, UnboxFloat, !IO), - globals__io_lookup_bool_option(common_data, DoCommonData, !IO), + globals.io_lookup_bool_option(unboxed_float, UnboxFloat, !IO), + globals.io_lookup_bool_option(common_data, DoCommonData, !IO), StaticCellInfo0 = init_static_cell_info(ModuleName, UnboxFloat, DoCommonData), global_data_init(StaticCellInfo0, GlobalData0), - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), % map_args_to_regs affects the interface to a predicate, % so it must be done in one phase immediately before code generation @@ -2443,7 +2443,7 @@ backend_pass(!HLDS, GlobalData, LLDS, !DumpInfo, !IO) :- map_args_to_regs(Verbose, Stats, !HLDS, !IO), maybe_dump_hlds(!.HLDS, 305, "args_to_regs", !DumpInfo, !IO), - globals__io_lookup_bool_option(trad_passes, TradPasses, !IO), + globals.io_lookup_bool_option(trad_passes, TradPasses, !IO), ( TradPasses = no, backend_pass_by_phases(!HLDS, GlobalData0, GlobalData, LLDS, !DumpInfo, @@ -2460,8 +2460,8 @@ backend_pass(!HLDS, GlobalData, LLDS, !DumpInfo, !IO) :- dump_info::in, dump_info::out, io::di, io::uo) is det. backend_pass_by_phases(!HLDS, !GlobalData, LLDS, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_saved_vars(Verbose, Stats, !HLDS, !IO), maybe_dump_hlds(!.HLDS, 310, "saved_vars_const", !DumpInfo, !IO), @@ -2502,17 +2502,17 @@ backend_pass_by_phases(!HLDS, !GlobalData, LLDS, !DumpInfo, !IO) :- backend_pass_by_preds(!HLDS, !GlobalData, LLDS, !IO) :- module_info_predids(!.HLDS, PredIds), - globals__io_lookup_bool_option(optimize_proc_dups, ProcDups, !IO), + globals.io_lookup_bool_option(optimize_proc_dups, ProcDups, !IO), ( ProcDups = no, OrderedPredIds = PredIds, MaybeDupProcMap = no ; ProcDups = yes, - dependency_graph__build_pred_dependency_graph(!.HLDS, + dependency_graph.build_pred_dependency_graph(!.HLDS, do_not_include_imported, DepInfo), hlds_dependency_info_get_dependency_ordering(DepInfo, PredSCCs), - list__condense(PredSCCs, OrderedPredIds), + list.condense(PredSCCs, OrderedPredIds), MaybeDupProcMap = yes(map.init) ), backend_pass_by_preds_2(OrderedPredIds, !HLDS, !GlobalData, @@ -2520,27 +2520,27 @@ backend_pass_by_preds(!HLDS, !GlobalData, LLDS, !IO) :- :- pred backend_pass_by_preds_2(list(pred_id)::in, module_info::in, module_info::out, global_data::in, global_data::out, - maybe(map(mdbcomp__prim_data__proc_label, - mdbcomp__prim_data__proc_label))::in, + maybe(map(mdbcomp.prim_data.proc_label, + mdbcomp.prim_data.proc_label))::in, list(c_procedure)::out, io::di, io::uo) is det. backend_pass_by_preds_2([], !HLDS, !GlobalData, _, [], !IO). backend_pass_by_preds_2([PredId | PredIds], !HLDS, !GlobalData, !.MaybeDupProcMap, Code, !IO) :- module_info_preds(!.HLDS, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), ProcIds = pred_info_non_imported_procids(PredInfo), ( ProcIds = [], ProcList = [] ; ProcIds = [_ | _], - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), ( Verbose = yes, - io__write_string("% Generating code for ", !IO), - hlds_out__write_pred_id(!.HLDS, PredId, !IO), - io__write_string("\n", !IO) + io.write_string("% Generating code for ", !IO), + hlds_out.write_pred_id(!.HLDS, PredId, !IO), + io.write_string("\n", !IO) ; Verbose = no ), @@ -2555,25 +2555,25 @@ backend_pass_by_preds_2([PredId | PredIds], !HLDS, % modules, we must switch off the tracing of such preds on a % pred-by-pred basis; module-by-module wouldn't work. module_info_get_globals(!.HLDS, Globals0), - globals__get_trace_level(Globals0, TraceLevel), - globals__set_trace_level_none(Globals0, Globals1), + globals.get_trace_level(Globals0, TraceLevel), + globals.set_trace_level_none(Globals0, Globals1), module_info_set_globals(Globals1, !HLDS), copy(Globals1, Globals1Unique), - globals__io_set_globals(Globals1Unique, !IO), + globals.io_set_globals(Globals1Unique, !IO), backend_pass_by_preds_3(ProcIds, PredId, PredInfo, !HLDS, !GlobalData, IdProcList, !IO), module_info_get_globals(!.HLDS, Globals2), - globals__set_trace_level(TraceLevel, Globals2, Globals), + globals.set_trace_level(TraceLevel, Globals2, Globals), module_info_set_globals(Globals, !HLDS), copy(Globals, GlobalsUnique), - globals__io_set_globals(GlobalsUnique, !IO) + globals.io_set_globals(GlobalsUnique, !IO) ; backend_pass_by_preds_3(ProcIds, PredId, PredInfo, !HLDS, !GlobalData, IdProcList, !IO) ), ( !.MaybeDupProcMap = no, - assoc_list__values(IdProcList, ProcList) + assoc_list.values(IdProcList, ProcList) ; !.MaybeDupProcMap = yes(DupProcMap0), eliminate_duplicate_procs(IdProcList, ProcList, @@ -2583,11 +2583,11 @@ backend_pass_by_preds_2([PredId | PredIds], !HLDS, ), backend_pass_by_preds_2(PredIds, !HLDS, !GlobalData, !.MaybeDupProcMap, TailPredsCode, !IO), - list__append(ProcList, TailPredsCode, Code). + list.append(ProcList, TailPredsCode, Code). :- pred backend_pass_by_preds_3(list(proc_id)::in, pred_id::in, pred_info::in, module_info::in, module_info::out, global_data::in, global_data::out, - assoc_list(mdbcomp__prim_data__proc_label, c_procedure)::out, + assoc_list(mdbcomp.prim_data.proc_label, c_procedure)::out, io::di, io::uo) is det. backend_pass_by_preds_3([], _, _, !HLDS, !GlobalData, [], !IO). @@ -2595,7 +2595,7 @@ backend_pass_by_preds_3([ProcId | ProcIds], PredId, PredInfo, !HLDS, !GlobalData, [ProcLabel - Proc | Procs], !IO) :- ProcLabel = make_proc_label(!.HLDS, PredId, ProcId), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, ProcInfo), + map.lookup(ProcTable, ProcId, ProcInfo), backend_pass_by_preds_4(PredInfo, ProcInfo, _, ProcId, PredId, !HLDS, !GlobalData, Proc, !IO), backend_pass_by_preds_3(ProcIds, PredId, PredInfo, !HLDS, !GlobalData, @@ -2609,7 +2609,7 @@ backend_pass_by_preds_3([ProcId | ProcIds], PredId, PredInfo, !HLDS, backend_pass_by_preds_4(PredInfo, !ProcInfo, ProcId, PredId, !HLDS, !GlobalData, ProcCode, !IO) :- module_info_get_globals(!.HLDS, Globals), - globals__lookup_bool_option(Globals, optimize_saved_vars_const, + globals.lookup_bool_option(Globals, optimize_saved_vars_const, SavedVarsConst), ( SavedVarsConst = yes, @@ -2617,7 +2617,7 @@ backend_pass_by_preds_4(PredInfo, !ProcInfo, ProcId, PredId, !HLDS, ; SavedVarsConst = no ), - globals__lookup_bool_option(Globals, optimize_saved_vars_cell, + globals.lookup_bool_option(Globals, optimize_saved_vars_cell, SavedVarsCell), ( SavedVarsCell = yes, @@ -2625,8 +2625,8 @@ backend_pass_by_preds_4(PredInfo, !ProcInfo, ProcId, PredId, !HLDS, ; SavedVarsCell = no ), - globals__lookup_bool_option(Globals, follow_code, FollowCode), - globals__lookup_bool_option(Globals, prev_code, PrevCode), + globals.lookup_bool_option(Globals, follow_code, FollowCode), + globals.lookup_bool_option(Globals, prev_code, PrevCode), ( ( FollowCode = yes ; PrevCode = yes @@ -2669,11 +2669,11 @@ backend_pass_by_preds_4(PredInfo, !ProcInfo, ProcId, PredId, !HLDS, "% Allocating storage locations for live vars in ", PredId, ProcId, !.HLDS, !IO), allocate_store_maps(final_allocation, PredId, !.HLDS, !ProcInfo), - globals__io_get_trace_level(TraceLevel, !IO), + globals.io_get_trace_level(TraceLevel, !IO), ( given_trace_level_is_none(TraceLevel) = no -> write_proc_progress_message("% Calculating goal paths in ", PredId, ProcId, !.HLDS, !IO), - goal_path__fill_slots(!.HLDS, !ProcInfo) + fill_goal_path_slots(!.HLDS, !ProcInfo) ; true ), @@ -2681,7 +2681,7 @@ backend_pass_by_preds_4(PredInfo, !ProcInfo, ProcId, PredId, !HLDS, PredId, ProcId, !.HLDS, !IO), generate_proc_code(PredInfo, !.ProcInfo, ProcId, PredId, !.HLDS, !GlobalData, ProcCode0), - globals__lookup_bool_option(Globals, optimize, Optimize), + globals.lookup_bool_option(Globals, optimize, Optimize), ( Optimize = yes, optimize_proc(!.GlobalData, ProcCode0, ProcCode, !IO) @@ -2693,7 +2693,7 @@ backend_pass_by_preds_4(PredInfo, !ProcInfo, ProcId, PredId, !HLDS, write_proc_progress_message( "% Generating call continuation information for ", PredId, ProcId, !.HLDS, !IO), - continuation_info__maybe_process_proc_llds(Instructions, PredProcId, + continuation_info.maybe_process_proc_llds(Instructions, PredProcId, !.HLDS, !GlobalData). %-----------------------------------------------------------------------------% @@ -2710,7 +2710,7 @@ puritycheck(Verbose, Stats, !HLDS, FoundTypeError, FoundPostTypecheckError, ( NumErrors \= NumErrors0 -> maybe_write_string(Verbose, "% Program contains purity error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; maybe_write_string(Verbose, "% Program is purity-correct.\n", !IO) @@ -2732,7 +2732,7 @@ modecheck(Verbose, Stats, !HLDS, FoundModeError, UnsafeToContinue, !IO) :- FoundModeError = yes, maybe_write_string(Verbose, "% Program contains mode error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; FoundModeError = no, maybe_write_string(Verbose, "% Program is mode-correct.\n", !IO) @@ -2743,12 +2743,12 @@ modecheck(Verbose, Stats, !HLDS, FoundModeError, UnsafeToContinue, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_mode_constraints(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(mode_constraints, ModeConstraints, !IO), + globals.io_lookup_bool_option(mode_constraints, ModeConstraints, !IO), ( ModeConstraints = yes, maybe_write_string(Verbose, "% Dumping mode constraints...\n", !IO), maybe_flush_output(Verbose, !IO), - maybe_benchmark_modes(mode_constraints__process_module, + maybe_benchmark_modes(mode_constraints.process_module, "mode-constraints", !HLDS, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO) @@ -2760,15 +2760,15 @@ maybe_mode_constraints(Verbose, Stats, !HLDS, !IO) :- is det), string::in, T1::in, T2::out, io::di, io::uo) is det. maybe_benchmark_modes(Pred, Stage, A0, A, !IO) :- - globals__io_lookup_bool_option(benchmark_modes, BenchmarkModes, !IO), + globals.io_lookup_bool_option(benchmark_modes, BenchmarkModes, !IO), ( BenchmarkModes = yes, - globals__io_lookup_int_option(benchmark_modes_repeat, Repeats, !IO), - io__format("%s %d ", [s(Stage), i(Repeats)], !IO), + globals.io_lookup_int_option(benchmark_modes_repeat, Repeats, !IO), + io.format("%s %d ", [s(Stage), i(Repeats)], !IO), promise_equivalent_solutions [A, Time, !:IO] ( do_io_benchmark(Pred, Repeats, A0, A - Time, !IO) ), - io__format("%d ms\n", [i(Time)], !IO) + io.format("%d ms\n", [i(Time)], !IO) ; BenchmarkModes = no, Pred(A0, A, !IO) @@ -2794,7 +2794,7 @@ detect_switches(Verbose, Stats, !HLDS, !IO) :- io::di, io::uo) is det. detect_cse(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(common_goal, CommonGoal, !IO), + globals.io_lookup_bool_option(common_goal, CommonGoal, !IO), ( CommonGoal = yes, maybe_write_string(Verbose, @@ -2817,7 +2817,7 @@ check_determinism(Verbose, Stats, !HLDS, FoundError, !IO) :- FoundError = yes, maybe_write_string(Verbose, "% Program contains determinism error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; FoundError = no, maybe_write_string(Verbose, "% Program is determinism-correct.\n", !IO) @@ -2859,9 +2859,9 @@ mercury_compile.maybe_exception_analysis(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_termination(Verbose, Stats, !HLDS, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, polymorphism, Polymorphism), - globals__lookup_bool_option(Globals, termination, Termination), + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, polymorphism, Polymorphism), + globals.lookup_bool_option(Globals, termination, Termination), % Termination analysis requires polymorphism to be run, % since it does not handle complex unification ( @@ -2880,8 +2880,8 @@ maybe_termination(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_termination2(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(polymorphism, Polymorphism, !IO), - globals__io_lookup_bool_option(termination2, Termination2, !IO), + globals.io_lookup_bool_option(polymorphism, Polymorphism, !IO), + globals.io_lookup_bool_option(termination2, Termination2, !IO), % Termination analysis requires polymorphism to be run, % as termination analysis does not handle complex unification. ( @@ -2889,7 +2889,7 @@ maybe_termination2(Verbose, Stats, !HLDS, !IO) :- Termination2 = yes -> maybe_write_string(Verbose, "% Detecting termination 2...\n", !IO), - term_constr_main__pass(!HLDS, !IO), + term_constr_main.pass(!HLDS, !IO), maybe_write_string(Verbose, "% Termination 2 checking done.\n", !IO), maybe_report_stats(Stats, !IO) ; @@ -2917,13 +2917,13 @@ check_unique_modes(Verbose, Stats, !HLDS, FoundError, !IO) :- maybe_write_string(Verbose, "% Checking for backtracking over unique modes...\n", !IO), module_info_get_num_errors(!.HLDS, NumErrors0), - unique_modes__check_module(!HLDS, !IO), + unique_modes.check_module(!HLDS, !IO), module_info_get_num_errors(!.HLDS, NumErrors), ( NumErrors \= NumErrors0 -> FoundError = yes, maybe_write_string(Verbose, "% Program contains unique mode error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; FoundError = no, maybe_write_string(Verbose, "% Program is unique-mode-correct.\n", !IO) @@ -2936,18 +2936,18 @@ check_unique_modes(Verbose, Stats, !HLDS, FoundError, !IO) :- check_stratification(Verbose, Stats, !HLDS, FoundError, !IO) :- module_info_get_stratified_preds(!.HLDS, StratifiedPreds), - globals__io_lookup_bool_option(warn_non_stratification, Warn, !IO), + globals.io_lookup_bool_option(warn_non_stratification, Warn, !IO), ( - ( \+ set__empty(StratifiedPreds) + ( \+ set.empty(StratifiedPreds) ; Warn = yes ) -> maybe_write_string(Verbose, "% Checking stratification...\n", !IO), - io__get_exit_status(OldStatus, !IO), - io__set_exit_status(0, !IO), - stratify__check_stratification(!HLDS, !IO), - io__get_exit_status(NewStatus, !IO), + io.get_exit_status(OldStatus, !IO), + io.set_exit_status(0, !IO), + stratify.check_stratification(!HLDS, !IO), + io.get_exit_status(NewStatus, !IO), ( NewStatus \= 0 -> FoundError = yes, maybe_write_string(Verbose, @@ -2955,7 +2955,7 @@ check_stratification(Verbose, Stats, !HLDS, FoundError, ; FoundError = no, maybe_write_string(Verbose, "% done.\n", !IO), - io__set_exit_status(OldStatus, !IO) + io.set_exit_status(OldStatus, !IO) ), maybe_report_stats(Stats, !IO) ; @@ -2966,7 +2966,7 @@ check_stratification(Verbose, Stats, !HLDS, FoundError, module_info::in, module_info::out, io::di, io::uo) is det. maybe_warn_dead_procs(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(warn_dead_procs, WarnDead, !IO), + globals.io_lookup_bool_option(warn_dead_procs, WarnDead, !IO), ( WarnDead = yes, maybe_write_string(Verbose, "% Warning about dead procedures...\n", @@ -2985,7 +2985,7 @@ maybe_warn_dead_procs(Verbose, Stats, !HLDS, !IO) :- % `pragma type_spec' declarations. So we can't use the % code below. Instead we need to keep original HLDS. % -% %%% globals__io_lookup_bool_option(optimize_dead_procs, +% %%% globals.io_lookup_bool_option(optimize_dead_procs, % %%% OptimizeDead, !IO), % %%% ( OptimizeDead = yes -> % %%% !:HLDS = HLDS1 @@ -3089,7 +3089,7 @@ simplify(Warn, SimplifyPass, Verbose, Stats, Process, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_mark_static_terms(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(static_ground_terms, StaticGroundTerms, + globals.io_lookup_bool_option(static_ground_terms, StaticGroundTerms, !IO), ( StaticGroundTerms = yes, @@ -3109,13 +3109,13 @@ maybe_mark_static_terms(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_add_trail_ops(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(use_trail, UseTrail, !IO), + globals.io_lookup_bool_option(use_trail, UseTrail, !IO), ( UseTrail = no, EmitTrailOps = no ; UseTrail = yes, - globals__io_lookup_bool_option(disable_trail_ops, DisableTrailOps, + globals.io_lookup_bool_option(disable_trail_ops, DisableTrailOps, !IO), ( DisableTrailOps = yes, @@ -3157,10 +3157,10 @@ maybe_add_trail_ops(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_add_heap_ops(Verbose, Stats, !HLDS, !IO) :- - globals__io_get_gc_method(GC, !IO), - globals__io_lookup_bool_option(reclaim_heap_on_semidet_failure, + globals.io_get_gc_method(GC, !IO), + globals.io_lookup_bool_option(reclaim_heap_on_semidet_failure, SemidetReclaim, !IO), - globals__io_lookup_bool_option(reclaim_heap_on_nondet_failure, + globals.io_lookup_bool_option(reclaim_heap_on_nondet_failure, NondetReclaim, !IO), ( gc_is_conservative(GC) = yes @@ -3188,7 +3188,7 @@ maybe_add_heap_ops(Verbose, Stats, !HLDS, !IO) :- "`--reclaim-heap-on-nondet-failure'. " ++ "Use `--(no-)reclaim-heap-on-failure' instead.", write_error_pieces_plain([words(Msg)], !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ). %-----------------------------------------------------------------------------% @@ -3197,19 +3197,19 @@ maybe_add_heap_ops(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_write_dependency_graph(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(show_dependency_graph, ShowDepGraph, !IO), + globals.io_lookup_bool_option(show_dependency_graph, ShowDepGraph, !IO), ( ShowDepGraph = yes, maybe_write_string(Verbose, "% Writing dependency graph...", !IO), module_info_get_name(!.HLDS, ModuleName), module_name_to_file_name(ModuleName, ".dependency_graph", yes, FileName, !IO), - io__open_output(FileName, Res, !IO), + io.open_output(FileName, Res, !IO), ( Res = ok(FileStream) -> - io__set_output_stream(FileStream, OutputStream, !IO), - dependency_graph__write_dependency_graph(!HLDS, !IO), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO), + io.set_output_stream(FileStream, OutputStream, !IO), + dependency_graph.write_dependency_graph(!HLDS, !IO), + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO), maybe_write_string(Verbose, " done.\n", !IO) ; report_error("unable to write dependency graph.", !IO) @@ -3226,8 +3226,8 @@ maybe_write_dependency_graph(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_output_prof_call_graph(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(profile_calls, ProfileCalls, !IO), - globals__io_lookup_bool_option(profile_time, ProfileTime, !IO), + globals.io_lookup_bool_option(profile_calls, ProfileCalls, !IO), + globals.io_lookup_bool_option(profile_time, ProfileTime, !IO), ( ( ProfileCalls = yes ; ProfileTime = yes @@ -3238,12 +3238,12 @@ maybe_output_prof_call_graph(Verbose, Stats, !HLDS, !IO) :- maybe_flush_output(Verbose, !IO), module_info_get_name(!.HLDS, ModuleName), module_name_to_file_name(ModuleName, ".prof", yes, ProfFileName, !IO), - io__open_output(ProfFileName, Res, !IO), + io.open_output(ProfFileName, Res, !IO), ( Res = ok(FileStream) -> - io__set_output_stream(FileStream, OutputStream, !IO), - dependency_graph__write_prof_dependency_graph(!HLDS, !IO), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO) + io.set_output_stream(FileStream, OutputStream, !IO), + dependency_graph.write_prof_dependency_graph(!HLDS, !IO), + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO) ; report_error("unable to write profiling static call graph.", !IO) ), @@ -3261,7 +3261,7 @@ maybe_output_prof_call_graph(Verbose, Stats, !HLDS, !IO) :- tabling(Verbose, Stats, !HLDS, !IO) :- maybe_write_string(Verbose, "% Transforming tabled predicates...", !IO), maybe_flush_output(Verbose, !IO), - table_gen__process_module(!HLDS, !IO), + table_gen.process_module(!HLDS, !IO), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO). @@ -3273,7 +3273,7 @@ tabling(Verbose, Stats, !HLDS, !IO) :- process_lambdas(Verbose, Stats, !HLDS, !IO) :- maybe_write_string(Verbose, "% Transforming lambda expressions...", !IO), maybe_flush_output(Verbose, !IO), - lambda__process_module(!HLDS), + lambda.process_module(!HLDS), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO). @@ -3285,7 +3285,7 @@ process_lambdas(Verbose, Stats, !HLDS, !IO) :- expand_equiv_types_hlds(Verbose, Stats, !HLDS, !IO) :- maybe_write_string(Verbose, "% Fully expanding equivalence types...", !IO), maybe_flush_output(Verbose, !IO), - equiv_type_hlds__replace_in_hlds(!HLDS), + equiv_type_hlds.replace_in_hlds(!HLDS), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO). @@ -3295,13 +3295,13 @@ expand_equiv_types_hlds(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_polymorphism(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(polymorphism, Polymorphism, !IO), + globals.io_lookup_bool_option(polymorphism, Polymorphism, !IO), ( Polymorphism = yes, maybe_write_string(Verbose, "% Transforming polymorphic unifications...", !IO), maybe_flush_output(Verbose, !IO), - polymorphism__process_module(!HLDS, !IO), + polymorphism.process_module(!HLDS, !IO), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO) ; @@ -3318,13 +3318,13 @@ maybe_polymorphism(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_type_ctor_infos(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(type_ctor_info, TypeCtorInfo, !IO), + globals.io_lookup_bool_option(type_ctor_info, TypeCtorInfo, !IO), ( TypeCtorInfo = yes, maybe_write_string(Verbose, "% Generating type_ctor_info structures...", !IO), maybe_flush_output(Verbose, !IO), - type_ctor_info__generate_hlds(!HLDS), + type_ctor_info.generate_hlds(!HLDS), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO) ; @@ -3335,14 +3335,14 @@ maybe_type_ctor_infos(Verbose, Stats, !HLDS, !IO) :- bool::in, bool::in, dump_info::in, dump_info::out, io::di, io::uo) is det. maybe_bytecodes(HLDS0, ModuleName, Verbose, Stats, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(generate_bytecode, GenBytecode, !IO), + globals.io_lookup_bool_option(generate_bytecode, GenBytecode, !IO), ( GenBytecode = yes, map_args_to_regs(Verbose, Stats, HLDS0, HLDS1, !IO), maybe_dump_hlds(HLDS1, 505, "bytecode_args_to_regs", !DumpInfo, !IO), maybe_write_string(Verbose, "% Generating bytecodes...\n", !IO), maybe_flush_output(Verbose, !IO), - bytecode_gen__gen_module(HLDS1, Bytecode, !IO), + bytecode_gen.gen_module(HLDS1, Bytecode, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO), module_name_to_file_name(ModuleName, ".bytedebug", yes, BytedebugFile, @@ -3403,9 +3403,9 @@ maybe_tuple_arguments(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_higher_order(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(optimize_higher_order, HigherOrder, !IO), + globals.io_lookup_bool_option(optimize_higher_order, HigherOrder, !IO), % --type-specialization implies --user-guided-type-specialization. - globals__io_lookup_bool_option(user_guided_type_specialization, Types, + globals.io_lookup_bool_option(user_guided_type_specialization, Types, !IO), % Always produce the specialized versions for which @@ -3416,7 +3416,7 @@ maybe_higher_order(Verbose, Stats, !HLDS, !IO) :- ( ( HigherOrder = yes ; Types = yes - ; \+ set__empty(TypeSpecPreds) + ; \+ set.empty(TypeSpecPreds) ) -> maybe_write_string(Verbose, @@ -3435,10 +3435,10 @@ maybe_higher_order(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_do_inlining(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(allow_inlining, Allow, !IO), - globals__io_lookup_bool_option(inline_simple, Simple, !IO), - globals__io_lookup_bool_option(inline_single_use, SingleUse, !IO), - globals__io_lookup_int_option(inline_compound_threshold, Threshold, !IO), + globals.io_lookup_bool_option(allow_inlining, Allow, !IO), + globals.io_lookup_bool_option(inline_simple, Simple, !IO), + globals.io_lookup_bool_option(inline_single_use, SingleUse, !IO), + globals.io_lookup_int_option(inline_compound_threshold, Threshold, !IO), ( Allow = yes, ( Simple = yes @@ -3459,10 +3459,10 @@ maybe_do_inlining(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_deforestation(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(deforestation, Deforest, !IO), + globals.io_lookup_bool_option(deforestation, Deforest, !IO), % --constraint-propagation implies --local-constraint-propagation. - globals__io_lookup_bool_option(local_constraint_propagation, Constraints, + globals.io_lookup_bool_option(local_constraint_propagation, Constraints, !IO), ( ( Deforest = yes @@ -3500,7 +3500,7 @@ maybe_deforestation(Verbose, Stats, !HLDS, !IO) :- io::di, io::uo) is det. maybe_loop_inv(Verbose, Stats, !HLDS, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(loop_invariants, LoopInv, !IO), + globals.io_lookup_bool_option(loop_invariants, LoopInv, !IO), ( LoopInv = yes, % We run the mark_static pass because we need the construct_how flag @@ -3523,7 +3523,7 @@ maybe_loop_inv(Verbose, Stats, !HLDS, !DumpInfo, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_delay_construct(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(delay_construct, DelayConstruct, !IO), + globals.io_lookup_bool_option(delay_construct, DelayConstruct, !IO), ( DelayConstruct = yes, maybe_write_string(Verbose, @@ -3541,10 +3541,10 @@ maybe_delay_construct(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_unused_args(Verbose, Stats, !HLDS, !IO) :- - globals__io_get_globals(Globals, !IO), - globals__lookup_bool_option(Globals, intermod_unused_args, Intermod), - globals__lookup_bool_option(Globals, optimize_unused_args, Optimize), - globals__lookup_bool_option(Globals, warn_unused_args, Warn), + globals.io_get_globals(Globals, !IO), + globals.lookup_bool_option(Globals, intermod_unused_args, Intermod), + globals.lookup_bool_option(Globals, optimize_unused_args, Optimize), + globals.lookup_bool_option(Globals, warn_unused_args, Warn), ( ( Optimize = yes ; Warn = yes @@ -3553,7 +3553,7 @@ maybe_unused_args(Verbose, Stats, !HLDS, !IO) :- -> maybe_write_string(Verbose, "% Finding unused arguments ...\n", !IO), maybe_flush_output(Verbose, !IO), - unused_args__process_module(!HLDS, !IO), + unused_args.process_module(!HLDS, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO) ; @@ -3564,14 +3564,14 @@ maybe_unused_args(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_unneeded_code(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(unneeded_code, UnneededCode, !IO), + globals.io_lookup_bool_option(unneeded_code, UnneededCode, !IO), ( UnneededCode = yes, maybe_write_string(Verbose, "% Removing unneeded code from procedure bodies...\n", !IO), maybe_flush_output(Verbose, !IO), process_all_nonimported_procs( - update_module_io(unneeded_code__process_proc_msg), !HLDS, !IO), + update_module_io(unneeded_code.process_proc_msg), !HLDS, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO) ; @@ -3582,7 +3582,7 @@ maybe_unneeded_code(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_eliminate_dead_procs(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(optimize_dead_procs, Dead, !IO), + globals.io_lookup_bool_option(optimize_dead_procs, Dead, !IO), ( Dead = yes, maybe_write_string(Verbose, "% Eliminating dead procedures...\n", !IO), @@ -3598,7 +3598,7 @@ maybe_eliminate_dead_procs(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_structure_sharing_analysis(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(structure_sharing_analysis, + globals.io_lookup_bool_option(structure_sharing_analysis, Sharing, !IO), ( Sharing = yes, @@ -3617,8 +3617,8 @@ maybe_structure_sharing_analysis(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_term_size_prof(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(record_term_sizes_as_words, AsWords, !IO), - globals__io_lookup_bool_option(record_term_sizes_as_cells, AsCells, !IO), + globals.io_lookup_bool_option(record_term_sizes_as_words, AsWords, !IO), + globals.io_lookup_bool_option(record_term_sizes_as_cells, AsCells, !IO), ( AsWords = yes, AsCells = yes, @@ -3642,7 +3642,7 @@ maybe_term_size_prof(Verbose, Stats, !HLDS, !IO) :- "% Applying term size profiling transformation...\n", !IO), maybe_flush_output(Verbose, !IO), process_all_nonimported_procs( - update_module_io(size_prof__process_proc_msg(Transform)), + update_module_io(size_prof.process_proc_msg(Transform)), !HLDS, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO) @@ -3654,12 +3654,12 @@ maybe_term_size_prof(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_read_experimental_complexity_file(!HLDS, !IO) :- - globals__io_lookup_string_option(experimental_complexity, FileName, !IO), - globals__io_lookup_bool_option(record_term_sizes_as_words, + globals.io_lookup_string_option(experimental_complexity, FileName, !IO), + globals.io_lookup_bool_option(record_term_sizes_as_words, RecordTermSizesAsWords, !IO), - globals__io_lookup_bool_option(record_term_sizes_as_cells, + globals.io_lookup_bool_option(record_term_sizes_as_cells, RecordTermSizesAsCells, !IO), - bool__or(RecordTermSizesAsWords, RecordTermSizesAsCells, + bool.or(RecordTermSizesAsWords, RecordTermSizesAsCells, RecordTermSizes), ( FileName = "" -> % While we could include the following sanity check, it is overly @@ -3686,7 +3686,7 @@ maybe_read_experimental_complexity_file(!HLDS, !IO) :- report_error("the --experimental-complexity option " ++ "requires a term size profiling grade", !IO) ), - complexity__read_spec_file(FileName, MaybeNumProcMap, !IO), + complexity.read_spec_file(FileName, MaybeNumProcMap, !IO), ( MaybeNumProcMap = ok(NumProcs - ProcMap), module_info_set_maybe_complexity_proc_map(yes(NumProcs - ProcMap), @@ -3710,7 +3710,7 @@ maybe_experimental_complexity(Verbose, Stats, !HLDS, !IO) :- "% Applying complexity experiment transformation...\n", !IO), maybe_flush_output(Verbose, !IO), process_all_nonimported_procs( - update_module_io(complexity__process_proc_msg(NumProcs, ProcMap)), + update_module_io(complexity.process_proc_msg(NumProcs, ProcMap)), !HLDS, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO) @@ -3720,7 +3720,7 @@ maybe_experimental_complexity(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_deep_profiling(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(profile_deep, ProfileDeep, !IO), + globals.io_lookup_bool_option(profile_deep, ProfileDeep, !IO), ( ProfileDeep = yes, maybe_write_string(Verbose, @@ -3737,14 +3737,14 @@ maybe_deep_profiling(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_introduce_accumulators(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(introduce_accumulators, Optimize, !IO), + globals.io_lookup_bool_option(introduce_accumulators, Optimize, !IO), ( Optimize = yes, maybe_write_string(Verbose, "% Attempting to introduce accumulators...\n", !IO), maybe_flush_output(Verbose, !IO), process_all_nonimported_procs( - update_module_io(accumulator__process_proc), !HLDS, !IO), + update_module_io(accumulator.process_proc), !HLDS, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO) ; @@ -3755,7 +3755,7 @@ maybe_introduce_accumulators(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_lco(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(optimize_constructor_last_call, LCO, !IO), + globals.io_lookup_bool_option(optimize_constructor_last_call, LCO, !IO), ( LCO = yes, maybe_write_string(Verbose, @@ -3786,7 +3786,7 @@ map_args_to_regs(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_saved_vars(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(optimize_saved_vars_const, SavedVars, !IO), + globals.io_lookup_bool_option(optimize_saved_vars_const, SavedVars, !IO), ( SavedVars = yes, maybe_write_string(Verbose, @@ -3804,7 +3804,7 @@ maybe_saved_vars(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_stack_opt(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(optimize_saved_vars_cell, SavedVars, !IO), + globals.io_lookup_bool_option(optimize_saved_vars_cell, SavedVars, !IO), ( SavedVars = yes, maybe_write_string(Verbose, @@ -3822,8 +3822,8 @@ maybe_stack_opt(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_followcode(Verbose, Stats, !HLDS, !IO) :- - globals__io_lookup_bool_option(follow_code, FollowCode, !IO), - globals__io_lookup_bool_option(prev_code, PrevCode, !IO), + globals.io_lookup_bool_option(follow_code, FollowCode, !IO), + globals.io_lookup_bool_option(prev_code, PrevCode, !IO), ( ( FollowCode = yes ; PrevCode = yes @@ -3876,11 +3876,11 @@ allocate_store_map(Verbose, Stats, !HLDS, !IO) :- module_info::in, module_info::out, io::di, io::uo) is det. maybe_goal_paths(Verbose, Stats, !HLDS, !IO) :- - globals__io_get_trace_level(TraceLevel, !IO), + globals.io_get_trace_level(TraceLevel, !IO), ( given_trace_level_is_none(TraceLevel) = no -> maybe_write_string(Verbose, "% Calculating goal paths...", !IO), maybe_flush_output(Verbose, !IO), - process_all_nonimported_procs(update_proc(goal_path__fill_slots), + process_all_nonimported_procs(update_proc(fill_goal_path_slots), !HLDS, !IO), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO) @@ -3903,7 +3903,7 @@ generate_code(HLDS, Verbose, Stats, !GlobalData, LLDS, !IO) :- list(c_procedure)::in, list(c_procedure)::out, io::di, io::uo) is det. maybe_do_optimize(GlobalData, Verbose, Stats, !LLDS, !IO) :- - globals__io_lookup_bool_option(optimize, Optimize, !IO), + globals.io_lookup_bool_option(optimize, Optimize, !IO), ( Optimize = yes, maybe_write_string(Verbose, "% Doing optimizations...\n", !IO), @@ -3923,7 +3923,7 @@ maybe_generate_stack_layouts(HLDS, LLDS, Verbose, Stats, !GlobalData, !IO) :- maybe_write_string(Verbose, "% Generating call continuation information...", !IO), maybe_flush_output(Verbose, !IO), - continuation_info__maybe_process_llds(LLDS, HLDS, !GlobalData), + continuation_info.maybe_process_llds(LLDS, HLDS, !GlobalData), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO). @@ -3935,7 +3935,7 @@ maybe_generate_stack_layouts(HLDS, LLDS, Verbose, Stats, !GlobalData, !IO) :- % interface. % This stuff mostly just gets passed directly to the LLDS unchanged, but % we do do a bit of code generation -- for example, we call - % export__get_foreign_export_{decls,defns} here, which do the generation + % export.get_foreign_export_{decls,defns} here, which do the generation % of C code for `pragma export' declarations. % :- pred get_c_interface_info(module_info::in, foreign_language::in, @@ -3946,14 +3946,14 @@ get_c_interface_info(HLDS, UseForeignLanguage, Foreign_InterfaceInfo) :- module_info_get_foreign_decl(HLDS, ForeignDecls), module_info_get_foreign_import_module(HLDS, ForeignImports), module_info_get_foreign_body_code(HLDS, ForeignBodyCode), - foreign__filter_decls(UseForeignLanguage, ForeignDecls, + foreign.filter_decls(UseForeignLanguage, ForeignDecls, WantedForeignDecls, _OtherDecls), - foreign__filter_imports(UseForeignLanguage, ForeignImports, + foreign.filter_imports(UseForeignLanguage, ForeignImports, WantedForeignImports, _OtherImports), - foreign__filter_bodys(UseForeignLanguage, ForeignBodyCode, + foreign.filter_bodys(UseForeignLanguage, ForeignBodyCode, WantedForeignBodys, _OtherBodys), - export__get_foreign_export_decls(HLDS, Foreign_ExportDecls), - export__get_foreign_export_defns(HLDS, Foreign_ExportDefns), + export.get_foreign_export_decls(HLDS, Foreign_ExportDecls), + export.get_foreign_export_defns(HLDS, Foreign_ExportDefns), Foreign_InterfaceInfo = foreign_interface_info(ModuleName, WantedForeignDecls, WantedForeignImports, @@ -3969,8 +3969,8 @@ get_c_interface_info(HLDS, UseForeignLanguage, Foreign_InterfaceInfo) :- output_pass(HLDS, GlobalData0, Procs, ModuleName, CompileErrors, FactTableObjFiles, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), % % Here we generate the LLDS representations for % various data structures used for RTTI, type classes, @@ -3978,16 +3978,16 @@ output_pass(HLDS, GlobalData0, Procs, ModuleName, CompileErrors, % XXX this should perhaps be part of backend_pass % rather than output_pass. % - type_ctor_info__generate_rtti(HLDS, TypeCtorRttiData), - base_typeclass_info__generate_rtti(HLDS, OldTypeClassInfoRttiData), - globals__io_lookup_bool_option(new_type_class_rtti, NewTypeClassRtti, !IO), - type_class_info__generate_rtti(HLDS, NewTypeClassRtti, + type_ctor_info.generate_rtti(HLDS, TypeCtorRttiData), + generate_base_typeclass_info_rtti(HLDS, OldTypeClassInfoRttiData), + globals.io_lookup_bool_option(new_type_class_rtti, NewTypeClassRtti, !IO), + generate_type_class_info_rtti(HLDS, NewTypeClassRtti, NewTypeClassInfoRttiData), - list__append(OldTypeClassInfoRttiData, NewTypeClassInfoRttiData, + list.append(OldTypeClassInfoRttiData, NewTypeClassInfoRttiData, TypeClassInfoRttiData), - list__map(llds__wrap_rtti_data, TypeCtorRttiData, TypeCtorTables), - list__map(llds__wrap_rtti_data, TypeClassInfoRttiData, TypeClassInfos), - stack_layout__generate_llds(HLDS, GlobalData0, GlobalData, StackLayouts, + list.map(llds.wrap_rtti_data, TypeCtorRttiData, TypeCtorTables), + list.map(llds.wrap_rtti_data, TypeClassInfoRttiData, TypeClassInfos), + stack_layout.generate_llds(HLDS, GlobalData0, GlobalData, StackLayouts, LayoutLabels), % % Here we perform some optimizations on the LLDS data. @@ -4004,7 +4004,7 @@ output_pass(HLDS, GlobalData0, Procs, ModuleName, CompileErrors, % % Next we put it all together and output it to one or more C files. % - list__condense([StaticCells, ClosureLayouts, StackLayouts, + list.condense([StaticCells, ClosureLayouts, StackLayouts, TypeCtorTables, TypeClassInfos], AllData), construct_c_file(HLDS, C_InterfaceInfo, Procs, GlobalVars, AllData, CFile, !IO), @@ -4013,22 +4013,22 @@ output_pass(HLDS, GlobalData0, Procs, ModuleName, CompileErrors, Verbose, Stats, !IO), C_InterfaceInfo = foreign_interface_info(_, _, _, _, C_ExportDecls, _), - export__produce_header_file(C_ExportDecls, ModuleName, !IO), + export.produce_header_file(C_ExportDecls, ModuleName, !IO), % % Finally we invoke the C compiler to compile it. % - globals__io_lookup_bool_option(target_code_only, TargetCodeOnly, !IO), + globals.io_lookup_bool_option(target_code_only, TargetCodeOnly, !IO), ( TargetCodeOnly = no, - io__output_stream(OutputStream, !IO), + io.output_stream(OutputStream, !IO), c_to_obj(OutputStream, ModuleName, CompileOK, !IO), module_get_fact_table_files(HLDS, FactTableBaseFiles), - list__map2_foldl(compile_fact_table_file(OutputStream), + list.map2_foldl(compile_fact_table_file(OutputStream), FactTableBaseFiles, FactTableObjFiles, FactTableCompileOKs, !IO), - bool__and_list([CompileOK | FactTableCompileOKs], AllOk), + bool.and_list([CompileOK | FactTableCompileOKs], AllOk), maybe_set_exit_status(AllOk, !IO), - bool__not(AllOk, CompileErrors) + bool.not(AllOk, CompileErrors) ; TargetCodeOnly = yes, CompileErrors = no, @@ -4046,18 +4046,18 @@ construct_c_file(ModuleInfo, C_InterfaceInfo, Procedures, GlobalVars, AllData, C_InterfaceInfo = foreign_interface_info(ModuleSymName, C_HeaderCode0, C_Includes, C_BodyCode0, _C_ExportDecls, C_ExportDefns), MangledModuleName = sym_name_mangle(ModuleSymName), - string__append(MangledModuleName, "_module", ModuleName), - globals__io_lookup_int_option(procs_per_c_function, ProcsPerFunc, !IO), + string.append(MangledModuleName, "_module", ModuleName), + globals.io_lookup_int_option(procs_per_c_function, ProcsPerFunc, !IO), get_c_body_code(C_BodyCode0, C_BodyCode), ( ProcsPerFunc = 0 -> % ProcsPerFunc = 0 really means infinity - % we store all the procs in a single function. ChunkedModules = [comp_gen_c_module(ModuleName, Procedures)] ; - list__chunk(Procedures, ProcsPerFunc, ChunkedProcs), + list.chunk(Procedures, ProcsPerFunc, ChunkedProcs), combine_chunks(ChunkedProcs, ModuleName, ChunkedModules) ), - list__map_foldl(make_foreign_import_header_code, C_Includes, + list.map_foldl(make_foreign_import_header_code, C_Includes, C_IncludeHeaderCode, !IO), % The lists are reversed because insertions into them are at the front. @@ -4065,10 +4065,10 @@ construct_c_file(ModuleInfo, C_InterfaceInfo, Procedures, GlobalVars, AllData, % C_IncludeHeaderCode may include our own header file, which defines % the module's guard macro, which in turn #ifdefs out the stuff between % Start and End. - list__filter(foreign_decl_code_is_local, list__reverse(C_HeaderCode0), + list.filter(foreign_decl_code_is_local, list.reverse(C_HeaderCode0), C_LocalHeaderCode, C_ExportedHeaderCode), make_decl_guards(ModuleSymName, Start, End), - C_HeaderCode = list__reverse(C_IncludeHeaderCode) ++ + C_HeaderCode = list.reverse(C_IncludeHeaderCode) ++ C_LocalHeaderCode ++ [Start | C_ExportedHeaderCode] ++ [End], module_info_user_init_pred_c_names(ModuleInfo, UserInitPredCNames), @@ -4091,9 +4091,9 @@ make_decl_guards(ModuleName, StartGuard, EndGuard) :- Start = "#ifndef " ++ Define ++ "\n#define " ++ Define ++ "\n", End = "\n#endif", StartGuard = foreign_decl_code(c, foreign_decl_is_exported, Start, - term__context_init), + term.context_init), EndGuard = foreign_decl_code(c, foreign_decl_is_exported, End, - term__context_init). + term.context_init). :- pred make_foreign_import_header_code(foreign_import_module::in, foreign_decl_code::out, io::di, io::uo) is det. @@ -4144,14 +4144,14 @@ combine_chunks(ChunkList, ModName, Modules) :- combine_chunks_2([], _ModName, _N, []). combine_chunks_2([Chunk | Chunks], ModuleName, Num, [Module | Modules]) :- - string__int_to_string(Num, NumString), - string__append(ModuleName, NumString, ThisModuleName), + string.int_to_string(Num, NumString), + string.append(ModuleName, NumString, ThisModuleName), Module = comp_gen_c_module(ThisModuleName, Chunk), Num1 = Num + 1, combine_chunks_2(Chunks, ModuleName, Num1, Modules). :- pred output_llds(module_name::in, c_file::in, - list(complexity_proc_info)::in, map(llds__label, llds__data_addr)::in, + list(complexity_proc_info)::in, map(llds.label, llds.data_addr)::in, bool::in, bool::in, io::di, io::uo) is det. output_llds(ModuleName, LLDS0, ComplexityProcs, StackLayoutLabels, @@ -4167,7 +4167,7 @@ output_llds(ModuleName, LLDS0, ComplexityProcs, StackLayoutLabels, maybe_flush_output(Verbose, !IO), maybe_report_stats(Stats, !IO). -:- pred c_to_obj(io__output_stream::in, module_name::in, bool::out, +:- pred c_to_obj(io.output_stream::in, module_name::in, bool::out, io::di, io::uo) is det. c_to_obj(ErrorStream, ModuleName, Succeeded, !IO) :- @@ -4176,19 +4176,19 @@ c_to_obj(ErrorStream, ModuleName, Succeeded, !IO) :- maybe_pic_object_file_extension(PIC, Obj, !IO), module_name_to_file_name(ModuleName, ".c", no, C_File, !IO), module_name_to_file_name(ModuleName, Obj, yes, O_File, !IO), - compile_target_code__compile_c_file(ErrorStream, PIC, C_File, O_File, + compile_target_code.compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO). -:- pred compile_fact_table_file(io__output_stream::in, string::in, +:- pred compile_fact_table_file(io.output_stream::in, string::in, string::out, bool::out, io::di, io::uo) is det. compile_fact_table_file(ErrorStream, BaseName, O_File, Succeeded, !IO) :- get_linked_target_type(LinkedTargetType, !IO), get_object_code_type(LinkedTargetType, PIC, !IO), maybe_pic_object_file_extension(PIC, Obj, !IO), - string__append(BaseName, ".c", C_File), - string__append(BaseName, Obj, O_File), - compile_target_code__compile_c_file(ErrorStream, PIC, C_File, O_File, + string.append(BaseName, ".c", C_File), + string.append(BaseName, Obj, O_File), + compile_target_code.compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO). %-----------------------------------------------------------------------------% @@ -4200,8 +4200,8 @@ compile_fact_table_file(ErrorStream, BaseName, O_File, Succeeded, !IO) :- dump_info::in, dump_info::out, io::di, io::uo) is det. mlds_backend(!HLDS, MLDS, !DumpInfo, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), simplify(no, ml_backend, Verbose, Stats, process_all_nonimported_procs, !HLDS, !IO), @@ -4245,7 +4245,7 @@ mlds_backend(!HLDS, MLDS, !DumpInfo, !IO) :- % chain_gc_stack_frame pass of ml_elim_nested, % because we need to unlink the stack frame from the % stack chain before tail calls. - globals__io_lookup_bool_option(optimize_tailcalls, OptimizeTailCalls, !IO), + globals.io_lookup_bool_option(optimize_tailcalls, OptimizeTailCalls, !IO), ( OptimizeTailCalls = yes, maybe_write_string(Verbose, "% Detecting tail calls...\n", !IO), @@ -4260,7 +4260,7 @@ mlds_backend(!HLDS, MLDS, !DumpInfo, !IO) :- % Warning about non-tail calls needs to come after detection % of tail calls - globals__io_lookup_bool_option(warn_non_tail_recursion, WarnTailCalls, + globals.io_lookup_bool_option(warn_non_tail_recursion, WarnTailCalls, !IO), ( OptimizeTailCalls = yes, @@ -4286,17 +4286,17 @@ mlds_backend(!HLDS, MLDS, !DumpInfo, !IO) :- % However, we need to disable optimize_initializations, % because ml_elim_nested doesn't correctly handle % code containing initializations. - globals__io_lookup_bool_option(optimize, Optimize, !IO), + globals.io_lookup_bool_option(optimize, Optimize, !IO), ( Optimize = yes, - globals__io_lookup_bool_option(optimize_initializations, + globals.io_lookup_bool_option(optimize_initializations, OptimizeInitializations, !IO), - globals__io_set_option(optimize_initializations, bool(no), !IO), + globals.io_set_option(optimize_initializations, bool(no), !IO), maybe_write_string(Verbose, "% Optimizing MLDS...\n", !IO), - ml_optimize__optimize(MLDS20, MLDS25, !IO), + ml_optimize.optimize(MLDS20, MLDS25, !IO), maybe_write_string(Verbose, "% done.\n", !IO), - globals__io_set_option(optimize_initializations, + globals.io_set_option(optimize_initializations, bool(OptimizeInitializations), !IO) ; Optimize = no, @@ -4317,7 +4317,7 @@ mlds_backend(!HLDS, MLDS, !DumpInfo, !IO) :- % generates. % - globals__io_get_gc_method(GC, !IO), + globals.io_get_gc_method(GC, !IO), ( GC = accurate -> maybe_write_string(Verbose, "% Threading GC stack frames...\n", !IO), @@ -4329,7 +4329,7 @@ mlds_backend(!HLDS, MLDS, !DumpInfo, !IO) :- maybe_report_stats(Stats, !IO), maybe_dump_mlds(MLDS30, 30, "gc_frames", !IO), - globals__io_lookup_bool_option(gcc_nested_functions, NestedFuncs, !IO), + globals.io_lookup_bool_option(gcc_nested_functions, NestedFuncs, !IO), ( NestedFuncs = no, maybe_write_string(Verbose, "% Flattening nested functions...\n", !IO), @@ -4349,7 +4349,7 @@ mlds_backend(!HLDS, MLDS, !DumpInfo, !IO) :- ( Optimize = yes, maybe_write_string(Verbose, "% Optimizing MLDS again...\n", !IO), - ml_optimize__optimize(MLDS35, MLDS40, !IO), + ml_optimize.optimize(MLDS35, MLDS40, !IO), maybe_write_string(Verbose, "% done.\n", !IO) ; Optimize = no, @@ -4364,20 +4364,20 @@ mlds_backend(!HLDS, MLDS, !DumpInfo, !IO) :- :- pred mlds_gen_rtti_data(module_info::in, mlds::in, mlds::out) is det. mlds_gen_rtti_data(HLDS, MLDS0, MLDS) :- - type_ctor_info__generate_rtti(HLDS, TypeCtorRtti), - base_typeclass_info__generate_rtti(HLDS, TypeClassInfoRtti), + type_ctor_info.generate_rtti(HLDS, TypeCtorRtti), + generate_base_typeclass_info_rtti(HLDS, TypeClassInfoRtti), module_info_get_globals(HLDS, Globals), - globals__lookup_bool_option(Globals, new_type_class_rtti, + globals.lookup_bool_option(Globals, new_type_class_rtti, NewTypeClassRtti), - type_class_info__generate_rtti(HLDS, NewTypeClassRtti, + generate_type_class_info_rtti(HLDS, NewTypeClassRtti, NewTypeClassInfoRttiData), - list__condense([TypeCtorRtti, TypeClassInfoRtti, + list.condense([TypeCtorRtti, TypeClassInfoRtti, NewTypeClassInfoRttiData], RttiData), RttiDefns = rtti_data_list_to_mlds(HLDS, RttiData), MLDS0 = mlds(ModuleName, ForeignCode, Imports, Defns0, InitPreds, FinalPreds), - list__append(RttiDefns, Defns0, Defns), + list.append(RttiDefns, Defns0, Defns), MLDS = mlds(ModuleName, ForeignCode, Imports, Defns, InitPreds, FinalPreds). @@ -4386,45 +4386,45 @@ mlds_gen_rtti_data(HLDS, MLDS0, MLDS) :- :- pred mlds_to_high_level_c(mlds::in, io::di, io::uo) is det. mlds_to_high_level_c(MLDS, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Converting MLDS to C...\n", !IO), - mlds_to_c__output_mlds(MLDS, "", !IO), + mlds_to_c.output_mlds(MLDS, "", !IO), maybe_write_string(Verbose, "% Finished converting MLDS to C.\n", !IO), maybe_report_stats(Stats, !IO). :- pred mlds_to_java(module_info::in, mlds::in, io::di, io::uo) is det. mlds_to_java(ModuleInfo, MLDS, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Converting MLDS to Java...\n", !IO), - mlds_to_java__output_mlds(ModuleInfo, MLDS, !IO), + mlds_to_java.output_mlds(ModuleInfo, MLDS, !IO), maybe_write_string(Verbose, "% Finished converting MLDS to Java.\n", !IO), maybe_report_stats(Stats, !IO). :- pred maybe_mlds_to_gcc(mlds::in, bool::out, io::di, io::uo) is det. maybe_mlds_to_gcc(MLDS, ContainsCCode, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Passing MLDS to GCC and compiling to assembler...\n", !IO), - maybe_mlds_to_gcc__compile_to_asm(MLDS, ContainsCCode, !IO), + maybe_mlds_to_gcc.compile_to_asm(MLDS, ContainsCCode, !IO), maybe_write_string(Verbose, "% Finished compiling to assembler.\n", !IO), maybe_report_stats(Stats, !IO). :- pred mlds_to_il_assembler(mlds::in, io::di, io::uo) is det. mlds_to_il_assembler(MLDS, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Converting MLDS to IL...\n", !IO), - mlds_to_ilasm__output_mlds(MLDS, !IO), + mlds_to_ilasm.output_mlds(MLDS, !IO), maybe_write_string(Verbose, "% Finished converting MLDS to IL.\n", !IO), maybe_report_stats(Stats, !IO). @@ -4439,7 +4439,7 @@ mlds_to_il_assembler(MLDS, !IO) :- dump_info::in, dump_info::out, io::di, io::uo) is det. maybe_dump_hlds(HLDS, StageNum, StageName, !DumpInfo, !IO) :- - globals__io_lookup_accumulating_option(dump_hlds, DumpStages, !IO), + globals.io_lookup_accumulating_option(dump_hlds, DumpStages, !IO), StageNumStr = stage_num_str(StageNum), ( should_dump_stage(StageNum, StageNumStr, StageName, DumpStages) -> module_info_get_name(HLDS, ModuleName), @@ -4451,13 +4451,13 @@ maybe_dump_hlds(HLDS, StageNum, StageName, !DumpInfo, !IO) :- HLDS = PrevHLDS -> CurDumpFileName = PrevDumpFileName, - io__open_output(DumpFileName, Res, !IO), + io.open_output(DumpFileName, Res, !IO), ( Res = ok(FileStream) -> - io__write_string(FileStream, "This stage is identical " ++ + io.write_string(FileStream, "This stage is identical " ++ "to the stage in " ++ PrevDumpFileName ++ ".\n", !IO), - io__close_output(FileStream, !IO) + io.close_output(FileStream, !IO) ; - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "\n", !IO), Msg = "can't open file `" ++ DumpFileName ++ "' for output.", report_error(Msg, !IO) @@ -4475,9 +4475,9 @@ maybe_dump_hlds(HLDS, StageNum, StageName, !DumpInfo, !IO) :- stage_num_str(StageNum) = StageNumStr :- int_to_string(StageNum, StageNumStr0), - ( string__length(StageNumStr0, 1) -> + ( string.length(StageNumStr0, 1) -> StageNumStr = "00" ++ StageNumStr0 - ; string__length(StageNumStr0, 2) -> + ; string.length(StageNumStr0, 2) -> StageNumStr = "0" ++ StageNumStr0 ; StageNumStr = StageNumStr0 @@ -4487,7 +4487,7 @@ stage_num_str(StageNum) = StageNumStr :- is semidet. should_dump_stage(StageNum, StageNumStr, StageName, DumpStages) :- - list__member(DumpStage, DumpStages), + list.member(DumpStage, DumpStages), ( StageName = DumpStage ; @@ -4496,31 +4496,31 @@ should_dump_stage(StageNum, StageNumStr, StageName, DumpStages) :- ( DumpStage = StageNumStr ; - string__append("0", DumpStage, StageNumStr) + string.append("0", DumpStage, StageNumStr) ; - string__append("00", DumpStage, StageNumStr) + string.append("00", DumpStage, StageNumStr) ) ; - string__append(From, "+", DumpStage), - string__to_int(From, FromInt), + string.append(From, "+", DumpStage), + string.to_int(From, FromInt), StageNum >= FromInt ). :- pred dump_hlds(string::in, module_info::in, io::di, io::uo) is det. dump_hlds(DumpFile, HLDS, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Dumping out HLDS to `", !IO), maybe_write_string(Verbose, DumpFile, !IO), maybe_write_string(Verbose, "'...", !IO), maybe_flush_output(Verbose, !IO), - io__open_output(DumpFile, Res, !IO), + io.open_output(DumpFile, Res, !IO), ( Res = ok(FileStream) -> - io__set_output_stream(FileStream, OutputStream, !IO), - hlds_out__write_hlds(0, HLDS, !IO), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO), + io.set_output_stream(FileStream, OutputStream, !IO), + hlds_out.write_hlds(0, HLDS, !IO), + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO) ; @@ -4532,26 +4532,26 @@ dump_hlds(DumpFile, HLDS, !IO) :- :- pred maybe_dump_mlds(mlds::in, int::in, string::in, io::di, io::uo) is det. maybe_dump_mlds(MLDS, StageNum, StageName, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_accumulating_option(dump_mlds, DumpStages, !IO), - globals__io_lookup_accumulating_option(verbose_dump_mlds, + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_accumulating_option(dump_mlds, DumpStages, !IO), + globals.io_lookup_accumulating_option(verbose_dump_mlds, VerboseDumpStages, !IO), StageNumStr = stage_num_str(StageNum), ( should_dump_stage(StageNum, StageNumStr, StageName, DumpStages) -> maybe_write_string(Verbose, "% Dumping out MLDS as C...\n", !IO), maybe_flush_output(Verbose, !IO), DumpSuffix = "_dump." ++ StageNumStr ++ "-" ++ StageName, - mlds_to_c__output_mlds(MLDS, DumpSuffix, !IO), + mlds_to_c.output_mlds(MLDS, DumpSuffix, !IO), maybe_write_string(Verbose, "% done.\n", !IO) ; true ), ( should_dump_stage(StageNum, StageNumStr, StageName, VerboseDumpStages) -> maybe_write_string(Verbose, "% Dumping out raw MLDS...\n", !IO), - ModuleName = mlds__get_module_name(MLDS), + ModuleName = mlds_get_module_name(MLDS), module_name_to_file_name(ModuleName, ".mlds_dump", yes, BaseFileName, !IO), - string__append_list([BaseFileName, ".", StageNumStr, "-", StageName], + string.append_list([BaseFileName, ".", StageNumStr, "-", StageName], DumpFile), dump_mlds(DumpFile, MLDS, !IO), maybe_write_string(Verbose, "% done.\n", !IO) @@ -4562,24 +4562,24 @@ maybe_dump_mlds(MLDS, StageNum, StageName, !IO) :- :- pred dump_mlds(string::in, mlds::in, io::di, io::uo) is det. dump_mlds(DumpFile, MLDS, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Dumping out MLDS to `", !IO), maybe_write_string(Verbose, DumpFile, !IO), maybe_write_string(Verbose, "'...", !IO), maybe_flush_output(Verbose, !IO), - io__open_output(DumpFile, Res, !IO), + io.open_output(DumpFile, Res, !IO), ( Res = ok(FileStream) -> - io__set_output_stream(FileStream, OutputStream, !IO), - pprint__write(80, pprint__to_doc(MLDS), !IO), - io__nl(!IO), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO), + io.set_output_stream(FileStream, OutputStream, !IO), + pprint.write(80, pprint.to_doc(MLDS), !IO), + io.nl(!IO), + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO), maybe_write_string(Verbose, " done.\n", !IO), maybe_report_stats(Stats, !IO) ; maybe_write_string(Verbose, "\n", !IO), - string__append_list(["can't open file `", DumpFile, "' for output."], + string.append_list(["can't open file `", DumpFile, "' for output."], ErrorMessage), report_error(ErrorMessage, !IO) ). diff --git a/compiler/mercury_to_mercury.m b/compiler/mercury_to_mercury.m index aa8780b0c..b4f6a9652 100644 --- a/compiler/mercury_to_mercury.m +++ b/compiler/mercury_to_mercury.m @@ -20,7 +20,7 @@ % :- pred mercury_format_xyz(..., U::di, U::uo) is det <= output(U). % % The first two simply forward all the work to the third. This is possible -% because both io__state and string are members of the required typeclass, +% because both io.state and string are members of the required typeclass, % which is defined at the end of this module. % % For the mercury_output_xyz versions, going through a typeclass interface is @@ -35,14 +35,14 @@ % strings (longer than a few lines), then we should use a typeclass % instance implementation that represents the entity being converted to string % as a list of strings that must be concatenated together at the end using -% string__append_list (probably after being un-reversed, so that you can +% string.append_list (probably after being un-reversed, so that you can % represent appending to the string by consing onto the front of the list). % The complexity of an implementation like that can be linear in the size % of the string being built, although it will have a higher constant factor. %-----------------------------------------------------------------------------% -:- module parse_tree__mercury_to_mercury. +:- module parse_tree.mercury_to_mercury. :- interface. :- import_module libs.globals. @@ -347,12 +347,12 @@ pred add_eval_method(eval_method::in, U::di, U::uo) is det, pred add_lambda_eval_method(lambda_eval_method::in, U::di, U::uo) is det, pred add_escaped_string(string::in, U::di, U::uo) is det, - pred add_format(string::in, list(io__poly_type)::in, U::di, U::uo) is det, + pred add_format(string::in, list(io.poly_type)::in, U::di, U::uo) is det, pred add_list(list(T)::in, string::in, pred(T, U, U)::in(pred(in, di, uo) is det), U::di, U::uo) is det ]. -:- instance output(io__state). +:- instance output(io.state). :- instance output(string). % We use the following type class to share code between mercury_output_inst, @@ -404,42 +404,42 @@ %-----------------------------------------------------------------------------% convert_to_mercury(ModuleName, OutputFileName, Items, !IO) :- - io__open_output(OutputFileName, Res, !IO), + io.open_output(OutputFileName, Res, !IO), ( Res = ok(FileStream), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), ( Verbose = yes, - io__write_string("% Writing output to ", !IO), - io__write_string(OutputFileName, !IO), - io__write_string("...", !IO), - io__flush_output(!IO) + io.write_string("% Writing output to ", !IO), + io.write_string(OutputFileName, !IO), + io.write_string("...", !IO), + io.flush_output(!IO) ; Verbose = no ), - io__set_output_stream(FileStream, OutputStream, !IO), - io__write_string(":- module ", !IO), + io.set_output_stream(FileStream, OutputStream, !IO), + io.write_string(":- module ", !IO), mercury_output_bracketed_sym_name(ModuleName, !IO), - io__write_string(".\n", !IO), + io.write_string(".\n", !IO), % Module qualifiers on items are redundant after the % declaration above. UnqualifiedItemNames = yes, mercury_output_item_list(UnqualifiedItemNames, Items, !IO), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO), + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO), ( Verbose = yes, - io__write_string(" done\n", !IO) + io.write_string(" done\n", !IO) ; Verbose = no ) ; Res = error(_), - io__write_string("Error: couldn't open file `", !IO), - io__write_string(OutputFileName, !IO), - io__write_string("' for output.\n", !IO) + io.write_string("Error: couldn't open file `", !IO), + io.write_string(OutputFileName, !IO), + io.write_string("' for output.\n", !IO) ). %-----------------------------------------------------------------------------% @@ -547,7 +547,7 @@ mercury_output_item(UnqualifiedItemNames, mercury_output_func_clause(VarSet, PredName, FuncArgs, Result, Body, Context, !IO) ), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). mercury_output_item(_UnqualifiedItemNames, pragma(_, Pragma), Context, !IO) :- maybe_output_line_number(Context, !IO), ( @@ -672,7 +672,7 @@ mercury_output_item(_, promise(PromiseType, Goal0, VarSet, UnivVars), _, % for an assertion, we put back any universally % quantified variables that were stripped off during % parsing so that the clause will output correctly - io__write_string(":- promise ", !IO), + io.write_string(":- promise ", !IO), ( UnivVars = [_ | _], Goal0 = _GoalExpr - Context, @@ -686,57 +686,57 @@ mercury_output_item(_, promise(PromiseType, Goal0, VarSet, UnivVars), _, % standard formatting from an assertion; the universal % quantification comes before the rest of the % declaration - io__write_string(":- all [", !IO), + io.write_string(":- all [", !IO), AppendVarNum = no, mercury_output_vars(UnivVars, VarSet, AppendVarNum, !IO), - io__write_string("]", !IO), + io.write_string("]", !IO), mercury_output_newline(Indent, !IO), - prog_out__write_promise_type(PromiseType, !IO), + prog_out.write_promise_type(PromiseType, !IO), Goal0 = Goal ), mercury_output_newline(Indent, !IO), mercury_output_goal(Goal, VarSet, Indent, !IO), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). mercury_output_item(_, nothing(_), _, !IO). mercury_output_item(UnqualifiedItemNames, typeclass(Constraints, FunDeps, ClassName0, Vars, Interface, VarSet), _, !IO) :- maybe_unqualify_sym_name(UnqualifiedItemNames, ClassName0, ClassName), - io__write_string(":- typeclass ", !IO), + io.write_string(":- typeclass ", !IO), % We put an extra set of brackets around the class name in % case the name is an operator mercury_output_sym_name(ClassName, !IO), - io__write_char('(', !IO), - io__write_list(Vars, ", ", + io.write_char('(', !IO), + io.write_list(Vars, ", ", (pred(V::in, IO0::di, IO::uo) is det :- - varset__lookup_name(VarSet, V, VarName), - io__write_string(VarName, IO0, IO) + varset.lookup_name(VarSet, V, VarName), + io.write_string(VarName, IO0, IO) ), !IO), - io__write_char(')', !IO), + io.write_char(')', !IO), AppendVarnums = no, mercury_format_fundeps_and_prog_constraint_list(FunDeps, Constraints, VarSet, AppendVarnums, !IO), ( Interface = abstract, - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ; Interface = concrete(Methods), - io__write_string(" where [\n", !IO), + io.write_string(" where [\n", !IO), output_class_methods(Methods, !IO), - io__write_string("\n].\n", !IO) + io.write_string("\n].\n", !IO) ). mercury_output_item(_, instance(Constraints, ClassName, Types, Body, VarSet, _InstanceModuleName), _, !IO) :- - io__write_string(":- instance ", !IO), + io.write_string(":- instance ", !IO), % We put an extra set of brackets around the class name in % case the name is an operator. - io__write_char('(', !IO), + io.write_char('(', !IO), mercury_output_sym_name(ClassName, !IO), - io__write_char('(', !IO), - io__write_list(Types, ", ", mercury_output_type(VarSet, no), !IO), - io__write_char(')', !IO), - io__write_char(')', !IO), + io.write_char('(', !IO), + io.write_list(Types, ", ", mercury_output_type(VarSet, no), !IO), + io.write_char(')', !IO), + io.write_char(')', !IO), AppendVarnums = no, mercury_format_prog_constraint_list(Constraints, VarSet, "<=", AppendVarnums, !IO), @@ -744,11 +744,11 @@ mercury_output_item(_, instance(Constraints, ClassName, Types, Body, Body = abstract ; Body = concrete(Methods), - io__write_string(" where [\n", !IO), + io.write_string(" where [\n", !IO), mercury_output_instance_methods(Methods, !IO), - io__write_string("\n]", !IO) + io.write_string("\n]", !IO) ), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). mercury_output_item(_, initialise(_, PredSymName, Arity), _, !IO) :- io.write_string(":- initialise ", !IO), mercury_output_sym_name(PredSymName, !IO), @@ -762,17 +762,17 @@ mercury_output_item(_, finalise(_, PredSymName, Arity), _, !IO) :- io.write_int(Arity, !IO), io.write_string(".\n", !IO). mercury_output_item(_, mutable(Name, Type, InitTerm, Inst, Attrs), _, !IO) :- - io__write_string(":- mutable(", !IO), - io__write_string(Name, !IO), - io__write_string(", ", !IO), - mercury_output_type(varset__init, no, Type, !IO), - io__write_string(", ", !IO), - mercury_output_term(InitTerm, varset__init, no, !IO), - io__write_string(", ", !IO), - mercury_output_inst(Inst, varset__init, !IO), - io__write_string(", ", !IO), - io__print(Attrs, !IO), - io__write_string(").\n", !IO). + io.write_string(":- mutable(", !IO), + io.write_string(Name, !IO), + io.write_string(", ", !IO), + mercury_output_type(varset.init, no, Type, !IO), + io.write_string(", ", !IO), + mercury_output_term(InitTerm, varset.init, no, !IO), + io.write_string(", ", !IO), + mercury_output_inst(Inst, varset.init, !IO), + io.write_string(", ", !IO), + io.print(Attrs, !IO), + io.write_string(").\n", !IO). :- func mercury_to_string_promise_type(promise_type) = string. @@ -787,12 +787,12 @@ mercury_to_string_promise_type(true) = "promise". :- pred output_class_methods(class_methods::in, io::di, io::uo) is det. output_class_methods(Methods, !IO) :- - io__write_list(Methods, ",\n", output_class_method, !IO). + io.write_list(Methods, ",\n", output_class_method, !IO). :- pred output_class_method(class_method::in, io::di, io::uo) is det. output_class_method(Method, !IO) :- - io__write_string("\t", !IO), + io.write_string("\t", !IO), ( Method = pred_or_func(TypeVarSet, InstVarSet, ExistQVars, PredOrFunc, Name0, TypesAndModes, WithType, WithInst, @@ -842,7 +842,7 @@ output_class_method(Method, !IO) :- ). mercury_output_instance_methods(Methods, !IO) :- - io__write_list(Methods, ",\n", output_instance_method, !IO). + io.write_list(Methods, ",\n", output_instance_method, !IO). :- pred output_instance_method(instance_method::in, io::di, io::uo) is det. @@ -850,26 +850,26 @@ output_instance_method(Method, !IO) :- Method = instance_method(PredOrFunc, Name1, Defn, Arity, Context), ( Defn = name(Name2), - io__write_char('\t', !IO), + io.write_char('\t', !IO), ( PredOrFunc = function, - io__write_string("func(", !IO) + io.write_string("func(", !IO) ; PredOrFunc = predicate, - io__write_string("pred(", !IO) + io.write_string("pred(", !IO) ), mercury_output_bracketed_sym_name(Name1, next_to_graphic_token, !IO), - io__write_string("/", !IO), - io__write_int(Arity, !IO), - io__write_string(") is ", !IO), + io.write_string("/", !IO), + io.write_int(Arity, !IO), + io.write_string(") is ", !IO), mercury_output_bracketed_sym_name(Name2, !IO) ; Defn = clauses(ItemList), % XXX should we output the term contexts? - io__write_string("\t(", !IO), - io__write_list(ItemList, "),\n\t(", + io.write_string("\t(", !IO), + io.write_list(ItemList, "),\n\t(", output_instance_method_clause(Name1, Context), !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred output_instance_method_clause(sym_name::in, prog_context::in, item::in, @@ -894,46 +894,46 @@ output_instance_method_clause(Name1, Context, Item, !IO) :- %-----------------------------------------------------------------------------% :- pred mercury_output_module_defn(prog_varset::in, module_defn::in, - term__context::in, io::di, io::uo) is det. + term.context::in, io::di, io::uo) is det. mercury_output_module_defn(_VarSet, ModuleDefn, _Context, !IO) :- ( ModuleDefn = import(module(ImportedModules)) -> - io__write_string(":- import_module ", !IO), + io.write_string(":- import_module ", !IO), mercury_write_module_spec_list(ImportedModules, !IO), - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ; ModuleDefn = use(module(UsedModules)) -> - io__write_string(":- use_module ", !IO), + io.write_string(":- use_module ", !IO), mercury_write_module_spec_list(UsedModules, !IO), - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ; ModuleDefn = interface -> - io__write_string(":- interface.\n", !IO) + io.write_string(":- interface.\n", !IO) ; ModuleDefn = implementation -> - io__write_string(":- implementation.\n", !IO) + io.write_string(":- implementation.\n", !IO) ; ModuleDefn = include_module(IncludedModules) -> - io__write_string(":- include_module ", !IO), + io.write_string(":- include_module ", !IO), mercury_write_module_spec_list(IncludedModules, !IO), - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ; ModuleDefn = module(Module) -> - io__write_string(":- module ", !IO), + io.write_string(":- module ", !IO), mercury_output_bracketed_sym_name(Module, !IO), - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ; ModuleDefn = end_module(Module) -> - io__write_string(":- end_module ", !IO), + io.write_string(":- end_module ", !IO), mercury_output_bracketed_sym_name(Module, !IO), - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ; ModuleDefn = version_numbers(Module, VersionNumbers) -> - io__write_string(":- version_numbers(", !IO), - io__write_int(version_numbers_version_number, !IO), - io__write_string(", ", !IO), + io.write_string(":- version_numbers(", !IO), + io.write_int(version_numbers_version_number, !IO), + io.write_string(", ", !IO), mercury_output_bracketed_sym_name(Module, !IO), - io__write_string(",\n", !IO), - recompilation__version__write_version_numbers(VersionNumbers, !IO), - io__write_string(").\n", !IO) + io.write_string(",\n", !IO), + recompilation.version.write_version_numbers(VersionNumbers, !IO), + io.write_string(").\n", !IO) ; % XXX unimplemented - io__write_string("% unimplemented module declaration ", !IO), - io__write(ModuleDefn, !IO), - io__nl(!IO) + io.write_string("% unimplemented module declaration ", !IO), + io.write(ModuleDefn, !IO), + io.nl(!IO) ). :- pred mercury_write_module_spec_list(list(module_specifier)::in, @@ -946,7 +946,7 @@ mercury_write_module_spec_list([ModuleName | ModuleNames], !IO) :- ModuleNames = [] ; ModuleNames = [_ | _], - io__write_string(", ", !IO), + io.write_string(", ", !IO), mercury_write_module_spec_list(ModuleNames, !IO) ). @@ -955,19 +955,19 @@ mercury_write_module_spec_list([ModuleName | ModuleNames], !IO) :- io::di, io::uo) is det. mercury_output_inst_defn(VarSet, Name, Args, abstract_inst, Context, !IO) :- - io__write_string(":- inst (", !IO), - list__map(pred(V::in, variable(V)::out) is det, Args, ArgTerms), + io.write_string(":- inst (", !IO), + list.map(pred(V::in, variable(V)::out) is det, Args, ArgTerms), construct_qualified_term(Name, ArgTerms, Context, InstTerm), mercury_output_term(InstTerm, VarSet, no, !IO), - io__write_string(").\n", !IO). + io.write_string(").\n", !IO). mercury_output_inst_defn(VarSet, Name, Args, eqv_inst(Body), Context, !IO) :- - io__write_string(":- inst (", !IO), - list__map(pred(V::in, variable(V)::out) is det, Args, ArgTerms), + io.write_string(":- inst (", !IO), + list.map(pred(V::in, variable(V)::out) is det, Args, ArgTerms), construct_qualified_term(Name, ArgTerms, Context, InstTerm), mercury_output_term(InstTerm, VarSet, no, !IO), - io__write_string(") == ", !IO), + io.write_string(") == ", !IO), mercury_output_inst(Body, VarSet, !IO), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). mercury_output_structured_inst_list(Insts, Indent, VarSet, !IO) :- mercury_format_structured_inst_list(Insts, Indent, VarSet, !IO). @@ -1293,14 +1293,14 @@ mercury_format_structured_inst_name(typed_ground(Uniqueness, Type), add_string("$typed_ground(", !U), mercury_format_uniqueness(Uniqueness, "shared", !U), add_string(", ", !U), - varset__init(TypeVarSet), + varset.init(TypeVarSet), mercury_format_type(TypeVarSet, no, Type, !U), add_string(")\n", !U). mercury_format_structured_inst_name(typed_inst(Type, InstName), Indent, VarSet, !U) :- mercury_format_tabs(Indent, !U), add_string("$typed_inst(", !U), - varset__init(TypeVarSet), + varset.init(TypeVarSet), mercury_format_type(TypeVarSet, no, Type, !U), add_string(",\n", !U), mercury_format_structured_inst_name(InstName, Indent + 1, VarSet, !U), @@ -1359,12 +1359,12 @@ mercury_format_inst_name(typed_ground(Uniqueness, Type), _InstInfo, !U) :- add_string("$typed_ground(", !U), mercury_format_uniqueness(Uniqueness, "shared", !U), add_string(", ", !U), - varset__init(TypeVarSet), + varset.init(TypeVarSet), mercury_format_type(TypeVarSet, no, Type, !U), add_string(")", !U). mercury_format_inst_name(typed_inst(Type, InstName), InstInfo, !U) :- add_string("$typed_inst(", !U), - varset__init(TypeVarSet), + varset.init(TypeVarSet), mercury_format_type(TypeVarSet, no, Type, !U), add_string(", ", !U), mercury_format_inst_name(InstName, InstInfo, !U), @@ -1489,8 +1489,8 @@ mercury_format_cons_id(pred_const(ShroudedPredProcId, EvalMethod), _, !U) :- add_lambda_eval_method(EvalMethod, !U), add_string(")>", !U). mercury_format_cons_id(type_ctor_info_const(Module, Type, Arity), _, !U) :- - mdbcomp__prim_data__sym_name_to_string(Module, ModuleString), - string__int_to_string(Arity, ArityString), + sym_name_to_string(Module, ModuleString), + string.int_to_string(Arity, ArityString), add_strings([""], !U). mercury_format_cons_id(base_typeclass_info_const(Module, Class, InstanceNum, @@ -1521,7 +1521,7 @@ mercury_format_cons_id(table_io_decl(_), _, !U) :- <= (output(U), inst_info(InstInfo)). mercury_format_constrained_inst_vars(Vars0, Inst, InstInfo, !U) :- - ( set__remove_least(Vars0, Var, Vars1) -> + ( set.remove_least(Vars0, Var, Vars1) -> add_string("(", !U), mercury_format_var(InstInfo ^ instvarset, no, Var, !U), add_string(" =< ", !U), @@ -1537,7 +1537,7 @@ mercury_format_constrained_inst_vars(Vars0, Inst, InstInfo, !U) :- mercury_format_mode_defn(VarSet, Name, Args, eqv_mode(Mode), Context, !U) :- add_string(":- mode (", !U), - list__map(pred(V::in, variable(V)::out) is det, Args, ArgTerms), + list.map(pred(V::in, variable(V)::out) is det, Args, ArgTerms), construct_qualified_term(Name, ArgTerms, Context, ModeTerm), mercury_format_term(ModeTerm, VarSet, no, !U), add_string(") == ", !U), @@ -1609,60 +1609,60 @@ mercury_format_mode(user_defined_mode(Name, Args), InstInfo, !U) :- mercury_output_type_defn(TVarSet, Name, TParams, abstract_type(IsSolverType), Context, !IO) :- mercury_output_begin_type_decl(IsSolverType, !IO), - Args = list__map((func(V) = term__variable(V)), TParams), + Args = list.map((func(V) = term.variable(V)), TParams), construct_qualified_term(Name, Args, Context, TypeTerm), mercury_output_term(TypeTerm, TVarSet, no, next_to_graphic_token, !IO), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). mercury_output_type_defn(TVarSet, Name, TParams, eqv_type(Body), Context, !IO) :- mercury_output_begin_type_decl(non_solver_type, !IO), - Args = list__map((func(V) = term__variable(V)), TParams), + Args = list.map((func(V) = term.variable(V)), TParams), construct_qualified_term(Name, Args, Context, TypeTerm), mercury_output_term(TypeTerm, TVarSet, no, !IO), - io__write_string(" == ", !IO), + io.write_string(" == ", !IO), mercury_output_type(TVarSet, no, Body, !IO), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). mercury_output_type_defn(TVarSet, Name, TParams, du_type(Ctors, MaybeUserEqComp), Context, !IO) :- mercury_output_begin_type_decl(non_solver_type, !IO), - Args = list__map((func(V) = term__variable(V)), TParams), + Args = list.map((func(V) = term.variable(V)), TParams), construct_qualified_term(Name, Args, Context, TypeTerm), mercury_output_term(TypeTerm, TVarSet, no, !IO), - io__write_string("\n\t--->\t", !IO), + io.write_string("\n\t--->\t", !IO), mercury_output_ctors(Ctors, TVarSet, !IO), mercury_output_where_attributes(TVarSet, no, MaybeUserEqComp, !IO), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). mercury_output_type_defn(TVarSet, Name, TParams, solver_type(SolverTypeDetails, MaybeUserEqComp), Context, !IO) :- mercury_output_begin_type_decl(solver_type, !IO), - Args = list__map((func(V) = term__variable(V)), TParams), + Args = list.map((func(V) = term.variable(V)), TParams), construct_qualified_term(Name, Args, Context, TypeTerm), mercury_output_term(TypeTerm, TVarSet, no, !IO), mercury_output_where_attributes(TVarSet, yes(SolverTypeDetails), MaybeUserEqComp, !IO), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). mercury_output_type_defn(TVarSet, Name, TParams, foreign_type(ForeignType, MaybeUserEqComp, Assertions), _Context, !IO) :- - io__write_string(":- pragma foreign_type(", !IO), + io.write_string(":- pragma foreign_type(", !IO), ( ForeignType = il(_), - io__write_string("il, ", !IO) + io.write_string("il, ", !IO) ; ForeignType = c(_), - io__write_string("c, ", !IO) + io.write_string("c, ", !IO) ; ForeignType = java(_), - io__write_string("java, ", !IO) + io.write_string("java, ", !IO) ), - Args = list__map((func(V) = term__variable(V)), TParams), + Args = list.map((func(V) = term.variable(V)), TParams), construct_qualified_term(Name, Args, MercuryType), mercury_output_term(MercuryType, TVarSet, no, !IO), - io__write_string(", \"", !IO), + io.write_string(", \"", !IO), ( ForeignType = il(il(RefOrVal, ForeignLocStr, ForeignTypeName)), ( @@ -1679,36 +1679,36 @@ mercury_output_type_defn(TVarSet, Name, TParams, ; ForeignType = java(java(ForeignTypeStr)) ), - io__write_string(ForeignTypeStr, !IO), - io__write_string("\"", !IO), + io.write_string(ForeignTypeStr, !IO), + io.write_string("\"", !IO), ( Assertions = [] ; Assertions = [_ | _], - io__write_string(", [", !IO), - io__write_list(Assertions, ", ", mercury_output_foreign_type_assertion, + io.write_string(", [", !IO), + io.write_list(Assertions, ", ", mercury_output_foreign_type_assertion, !IO), - io__write_string("]", !IO) + io.write_string("]", !IO) ), - io__write_string(")", !IO), + io.write_string(")", !IO), mercury_output_where_attributes(TVarSet, no, MaybeUserEqComp, !IO), - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). :- pred mercury_output_foreign_type_assertion(foreign_type_assertion::in, io::di, io::uo) is det. mercury_output_foreign_type_assertion(can_pass_as_mercury_type, !IO) :- - io__write_string("can_pass_as_mercury_type", !IO). + io.write_string("can_pass_as_mercury_type", !IO). mercury_output_foreign_type_assertion(stable, !IO) :- - io__write_string("stable", !IO). + io.write_string("stable", !IO). :- pred mercury_output_begin_type_decl(is_solver_type::in, io::di, io::uo) is det. mercury_output_begin_type_decl(solver_type, !IO) :- - io__write_string(":- solver type ", !IO). + io.write_string(":- solver type ", !IO). mercury_output_begin_type_decl(non_solver_type, !IO) :- - io__write_string(":- type ", !IO). + io.write_string(":- type ", !IO). mercury_output_where_attributes(TVarSet, MaybeSolverTypeDetails, MaybeUserEqComp, !IO) :- @@ -1728,9 +1728,9 @@ mercury_output_where_attributes(TVarSet, MaybeUnifyPred = no, MaybeComparePred = no ), - io__write_string("\n\twhere\t", !IO), + io.write_string("\n\twhere\t", !IO), ( MaybeUserEqComp = yes(abstract_noncanonical_type(_)) -> - io__write_string("type_is_abstract_noncanonical", !IO) + io.write_string("type_is_abstract_noncanonical", !IO) ; ( MaybeSolverTypeDetails = yes(SolverTypeDetails), @@ -1741,7 +1741,7 @@ mercury_output_where_attributes(TVarSet, ; MaybeComparePred = yes(_) ) -> - io__write_string(",\n\t\t", !IO) + io.write_string(",\n\t\t", !IO) ; true ) @@ -1751,11 +1751,11 @@ mercury_output_where_attributes(TVarSet, ), ( MaybeUnifyPred = yes(UnifyPredName), - io__write_string("equality is ", !IO), + io.write_string("equality is ", !IO), mercury_output_bracketed_sym_name(UnifyPredName, !IO), ( MaybeComparePred = yes(_), - io__write_string(",\n\t\t", !IO) + io.write_string(",\n\t\t", !IO) ; MaybeComparePred = no ) @@ -1764,7 +1764,7 @@ mercury_output_where_attributes(TVarSet, ), ( MaybeComparePred = yes(ComparePredName), - io__write_string("comparison is ", !IO), + io.write_string("comparison is ", !IO), mercury_output_bracketed_sym_name(ComparePredName, !IO) ; MaybeComparePred = no @@ -1777,29 +1777,29 @@ mercury_output_where_attributes(TVarSet, mercury_output_solver_type_details(TVarSet, solver_type_details(RepresentationType, InitPred, GroundInst, AnyInst, MutableItems), !IO) :- - io__write_string("representation is ", !IO), + io.write_string("representation is ", !IO), mercury_output_type(TVarSet, no, RepresentationType, !IO), - io__write_string(",\n\t\tinitialisation is ", !IO), + io.write_string(",\n\t\tinitialisation is ", !IO), mercury_output_bracketed_sym_name(InitPred, !IO), - varset__init(EmptyInstVarSet), - io__write_string(",\n\t\tground is ", !IO), + varset.init(EmptyInstVarSet), + io.write_string(",\n\t\tground is ", !IO), mercury_output_inst(GroundInst, EmptyInstVarSet, !IO), - io__write_string(",\n\t\tany is ", !IO), + io.write_string(",\n\t\tany is ", !IO), mercury_output_inst(AnyInst, EmptyInstVarSet, !IO), ( MutableItems = [] ; MutableItems = [_ | _], - io__write_string(",\n\t\tconstraint_store is [\n\t\t\t", !IO), - io__write_list(MutableItems, ",\n\t\t\t", mercury_output_item_2, + io.write_string(",\n\t\tconstraint_store is [\n\t\t\t", !IO), + io.write_list(MutableItems, ",\n\t\t\t", mercury_output_item_2, !IO), - io__write_string("\n\t\t]", !IO) + io.write_string("\n\t\t]", !IO) ). :- pred mercury_output_item_2(item::in, io::di, io::uo) is det. mercury_output_item_2(Item, !IO) :- - term__context_init(DummyContext), + term.context_init(DummyContext), mercury_output_item(Item, DummyContext, !IO). :- pred mercury_output_ctors(list(constructor)::in, tvarset::in, @@ -1812,7 +1812,7 @@ mercury_output_ctors([Ctor | Ctors], VarSet, !IO) :- Ctors = [] ; Ctors = [_ | _], - io__write_string("\n\t;\t", !IO) + io.write_string("\n\t;\t", !IO) ), mercury_output_ctors(Ctors, VarSet, !IO). @@ -1830,10 +1830,10 @@ mercury_output_ctor(Ctor, VarSet, !IO) :- ; ExistQVars = [_ | _], ParenWrap = yes, - io__write_string("(", !IO) + io.write_string("(", !IO) ), % we need to quote ';'/2, '{}'/2, '=>'/2, and 'some'/2 - list__length(Args, Arity), + list.length(Args, Arity), ( Arity = 2, ( Name = ";" @@ -1843,28 +1843,28 @@ mercury_output_ctor(Ctor, VarSet, !IO) :- ) -> BraceWrap = yes, - io__write_string("{ ", !IO) + io.write_string("{ ", !IO) ; BraceWrap = no ), ( Args = [Arg | Rest], mercury_output_sym_name(unqualified(Name), !IO), - io__write_string("(", !IO), + io.write_string("(", !IO), mercury_output_ctor_arg(VarSet, Arg, !IO), mercury_output_remaining_ctor_args(VarSet, Rest, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; Args = [], mercury_output_bracketed_sym_name(unqualified(Name), !IO), % This space prevents a terminating full stop % from being confused as part of the sym_name if % the sym_name contains graphical characters. - io__write_string(" ", !IO) + io.write_string(" ", !IO) ), ( BraceWrap = yes, - io__write_string(" }", !IO) + io.write_string(" }", !IO) ; BraceWrap = no ), @@ -1875,7 +1875,7 @@ mercury_output_ctor(Ctor, VarSet, !IO) :- ParenWrap = no ; ParenWrap = yes, - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred mercury_output_ctor_arg(tvarset::in, constructor_arg::in, @@ -1887,7 +1887,7 @@ mercury_output_ctor_arg(Varset, N - T, !IO) :- mercury_output_remaining_ctor_args(_Varset, [], !IO). mercury_output_remaining_ctor_args(Varset, [N - T | As], !IO) :- - io__write_string(", ", !IO), + io.write_string(", ", !IO), mercury_output_ctor_arg_name_prefix(N, !IO), mercury_output_type(Varset, no, T, !IO), mercury_output_remaining_ctor_args(Varset, As, !IO). @@ -1898,7 +1898,7 @@ mercury_output_remaining_ctor_args(Varset, [N - T | As], !IO) :- mercury_output_ctor_arg_name_prefix(no, !IO). mercury_output_ctor_arg_name_prefix(yes(Name), !IO) :- mercury_output_bracketed_sym_name(Name, !IO), - io__write_string(" :: ", !IO). + io.write_string(" :: ", !IO). %-----------------------------------------------------------------------------% @@ -2012,7 +2012,7 @@ mercury_format_pred_or_func_type_2(PredOrFunc, VarSet, ExistQVars, PredName, PredOrFunc = predicate, MaybeDet = no, unqualify_name(PredName, "is"), - list__length(Types, 2) + list.length(Types, 2) -> % This determinism will be ignored. mercury_format_det_annotation(yes(det), !U) @@ -2241,7 +2241,7 @@ mercury_type_list_to_string(_, []) = "". mercury_type_list_to_string(VarSet, [T | Ts]) = String :- String0 = mercury_type_to_string(VarSet, no, T), String1 = mercury_type_list_to_string_2(VarSet, Ts), - string__append(String0, String1, String). + string.append(String0, String1, String). :- func mercury_type_list_to_string_2(tvarset, list(mer_type)) = string. @@ -2249,7 +2249,7 @@ mercury_type_list_to_string_2(_, []) = "". mercury_type_list_to_string_2(VarSet, [T | Ts]) = String :- String0 = mercury_type_to_string(VarSet, no, T), String1 = mercury_type_list_to_string_2(VarSet, Ts), - string__append_list([", ", String0, String1], String). + string.append_list([", ", String0, String1], String). mercury_output_type(VarSet, AppendVarNums, Type, !IO) :- mercury_format_type(VarSet, AppendVarNums, Type, !IO). @@ -2264,7 +2264,7 @@ mercury_type_to_string(VarSet, AppendVarNums, Type) = String :- % mercury_format_type(TVarSet, AppendVarNums, Type, !U) :- unparse_type(Type, Term), - VarSet = varset__coerce(TVarSet), + VarSet = varset.coerce(TVarSet), mercury_format_term(Term, VarSet, AppendVarNums, !U). %-----------------------------------------------------------------------------% @@ -2463,17 +2463,17 @@ mercury_output_pred_clause(VarSet, PredName, Args, Body, _Context, !IO) :- mercury_output_sym_name(PredName, !IO), ( Args = [Arg | Args0], - io__write_string("(", !IO), + io.write_string("(", !IO), mercury_format_term(Arg, VarSet, no, !IO), mercury_format_remaining_terms(Args0, VarSet, no, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; Args = [] ), ( Body = true - _Context0 -> true ; - io__write_string(" :-\n\t", !IO), + io.write_string(" :-\n\t", !IO), mercury_output_goal(Body, VarSet, 1, !IO) ). @@ -2488,19 +2488,19 @@ mercury_output_func_clause(VarSet, PredName, Args, Result, Body, _Context, mercury_output_sym_name(PredName, !IO), ( Args = [Arg | Args0], - io__write_string("(", !IO), + io.write_string("(", !IO), mercury_format_term(Arg, VarSet, no, !IO), mercury_format_remaining_terms(Args0, VarSet, no, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; Args = [] ), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), ( Body = true - _Context0 -> mercury_format_term(Result, VarSet, no, next_to_graphic_token, !IO) ; mercury_format_term(Result, VarSet, no, !IO), - io__write_string(" :-\n\t", !IO), + io.write_string(" :-\n\t", !IO), mercury_output_goal(Body, VarSet, 1, !IO) ). @@ -2514,34 +2514,34 @@ mercury_output_goal(Goal - _Context, VarSet, Indent, !IO) :- io::di, io::uo) is det. mercury_output_goal_2(fail, _, _, !IO) :- - io__write_string("fail", !IO). + io.write_string("fail", !IO). mercury_output_goal_2(true, _, _, !IO) :- - io__write_string("true", !IO). + io.write_string("true", !IO). mercury_output_goal_2(implies(G1,G2), VarSet, Indent, !IO) :- Indent1 = Indent + 1, - io__write_string("(", !IO), + io.write_string("(", !IO), mercury_output_newline(Indent1, !IO), mercury_output_goal(G1, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string("=>", !IO), + io.write_string("=>", !IO), mercury_output_newline(Indent1, !IO), mercury_output_goal(G2, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mercury_output_goal_2(equivalent(G1,G2), VarSet, Indent, !IO) :- Indent1 = Indent + 1, - io__write_string("(", !IO), + io.write_string("(", !IO), mercury_output_newline(Indent1, !IO), mercury_output_goal(G1, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string("<=>", !IO), + io.write_string("<=>", !IO), mercury_output_newline(Indent1, !IO), mercury_output_goal(G2, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mercury_output_goal_2(some(Vars, Goal), VarSet, Indent, !IO) :- ( @@ -2549,14 +2549,14 @@ mercury_output_goal_2(some(Vars, Goal), VarSet, Indent, !IO) :- mercury_output_goal(Goal, VarSet, Indent, !IO) ; Vars = [_ | _], - io__write_string("some [", !IO), + io.write_string("some [", !IO), mercury_output_vars(Vars, VarSet, no, !IO), - io__write_string("] (", !IO), + io.write_string("] (", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(Goal, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). mercury_output_goal_2(some_state_vars(Vars, Goal), VarSet, Indent, !IO) :- @@ -2565,14 +2565,14 @@ mercury_output_goal_2(some_state_vars(Vars, Goal), VarSet, Indent, !IO) :- mercury_output_goal(Goal, VarSet, Indent, !IO) ; Vars = [_ | _], - io__write_string("some [", !IO), + io.write_string("some [", !IO), mercury_output_state_vars(Vars, VarSet, no, !IO), - io__write_string("] (", !IO), + io.write_string("] (", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(Goal, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). mercury_output_goal_2(all(Vars, Goal), VarSet, Indent, !IO) :- @@ -2581,14 +2581,14 @@ mercury_output_goal_2(all(Vars, Goal), VarSet, Indent, !IO) :- mercury_output_goal(Goal, VarSet, Indent, !IO) ; Vars = [_ | _], - io__write_string("all [", !IO), + io.write_string("all [", !IO), mercury_output_vars(Vars, VarSet, no, !IO), - io__write_string("] (", !IO), + io.write_string("] (", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(Goal, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). mercury_output_goal_2(all_state_vars(Vars, Goal), VarSet, Indent, !IO) :- @@ -2597,14 +2597,14 @@ mercury_output_goal_2(all_state_vars(Vars, Goal), VarSet, Indent, !IO) :- mercury_output_goal(Goal, VarSet, Indent, !IO) ; Vars = [_ | _], - io__write_string("all [", !IO), + io.write_string("all [", !IO), mercury_output_state_vars(Vars, VarSet, no, !IO), - io__write_string("] (", !IO), + io.write_string("] (", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(Goal, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). mercury_output_goal_2( @@ -2619,7 +2619,7 @@ mercury_output_goal_2( % the term, but there is no point in aborting here. mercury_output_goal(Goal, VarSet, Indent, !IO) ; - io__write_string("promise_equivalent_solutions [", !IO), + io.write_string("promise_equivalent_solutions [", !IO), mercury_output_vars(Vars, VarSet, no, !IO), ( Vars \= [], @@ -2641,94 +2641,94 @@ mercury_output_goal_2( ), mercury_output_state_vars_using_prefix(ColonSVars, "!:", VarSet, no, !IO), - io__write_string("] (", !IO), + io.write_string("] (", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(Goal, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). mercury_output_goal_2(promise_purity(_Implicit, Purity, Goal), VarSet, Indent, !IO) :- ( Purity = purity_pure, - io__write_string("promise_pure (", !IO) + io.write_string("promise_pure (", !IO) ; Purity = purity_semipure, - io__write_string("promise_semipure (", !IO) + io.write_string("promise_semipure (", !IO) ; Purity = purity_impure, - io__write_string("promise_impure (", !IO) + io.write_string("promise_impure (", !IO) ), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(Goal, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mercury_output_goal_2(if_then_else(Vars, StateVars, A, B, C), VarSet, Indent, !IO) :- - io__write_string("(if", !IO), + io.write_string("(if", !IO), mercury_output_some(Vars, StateVars, VarSet, !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(A, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string("then", !IO), + io.write_string("then", !IO), mercury_output_newline(Indent1, !IO), mercury_output_goal(B, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string("else", !IO), + io.write_string("else", !IO), mercury_output_newline(Indent1, !IO), mercury_output_goal(C, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mercury_output_goal_2(if_then(Vars, StateVars, A, B), VarSet, Indent, !IO) :- - io__write_string("(if", !IO), + io.write_string("(if", !IO), mercury_output_some(Vars, StateVars, VarSet, !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(A, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string("then", !IO), + io.write_string("then", !IO), mercury_output_newline(Indent1, !IO), mercury_output_goal(B, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mercury_output_goal_2(not(Goal), VarSet, Indent, !IO) :- - io__write_string("\\+ (", !IO), + io.write_string("\\+ (", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(Goal, VarSet, Indent1, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mercury_output_goal_2((A,B), VarSet, Indent, !IO) :- mercury_output_goal(A, VarSet, Indent, !IO), - io__write_string(",", !IO), + io.write_string(",", !IO), mercury_output_newline(Indent, !IO), mercury_output_goal(B, VarSet, Indent, !IO). mercury_output_goal_2((A & B), VarSet, Indent, !IO) :- - io__write_string("(", !IO), + io.write_string("(", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(A, VarSet, Indent1, !IO), mercury_output_par_conj(B, VarSet, Indent, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mercury_output_goal_2((A;B), VarSet, Indent, !IO) :- - io__write_string("(", !IO), + io.write_string("(", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), mercury_output_goal(A, VarSet, Indent1, !IO), mercury_output_disj(B, VarSet, Indent, !IO), mercury_output_newline(Indent, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mercury_output_goal_2(call(Name, Term, Purity), VarSet, Indent, !IO) :- write_purity_prefix(Purity, !IO), @@ -2737,7 +2737,7 @@ mercury_output_goal_2(call(Name, Term, Purity), VarSet, Indent, !IO) :- mercury_output_goal_2(unify(A, B, Purity), VarSet, _Indent, !IO) :- write_purity_prefix(Purity, !IO), mercury_output_term(A, VarSet, no, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), mercury_output_term(B, VarSet, no, next_to_graphic_token, !IO). @@ -2748,12 +2748,12 @@ mercury_output_state_vars_using_prefix([], _BangPrefix, _VarSet, _AppendVarnums, !IO). mercury_output_state_vars_using_prefix([SVar | SVars], BangPrefix, VarSet, AppendVarnums, !IO) :- - io__write_string(BangPrefix, !IO), + io.write_string(BangPrefix, !IO), mercury_format_var(VarSet, AppendVarnums, SVar, !IO), ( SVars \= [] -> - io__write_string(", ", !IO) + io.write_string(", ", !IO) ; true ), @@ -2769,14 +2769,14 @@ mercury_output_call(Name, Term, VarSet, _Indent, !IO) :- Name = qualified(ModuleName, PredName), mercury_output_bracketed_sym_name(ModuleName, next_to_graphic_token, !IO), - io__write_string(".", !IO), - term__context_init(Context0), - mercury_output_term(term__functor(term__atom(PredName), + io.write_string(".", !IO), + term.context_init(Context0), + mercury_output_term(term.functor(term.atom(PredName), Term, Context0), VarSet, no, next_to_graphic_token, !IO) ; Name = unqualified(PredName), - term__context_init(Context0), - mercury_output_term(term__functor(term__atom(PredName), + term.context_init(Context0), + mercury_output_term(term.functor(term.atom(PredName), Term, Context0), VarSet, no, next_to_graphic_token, !IO) ). @@ -2785,7 +2785,7 @@ mercury_output_call(Name, Term, VarSet, _Indent, !IO) :- mercury_output_disj(Goal, VarSet, Indent, !IO) :- mercury_output_newline(Indent, !IO), - io__write_string(";", !IO), + io.write_string(";", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), ( Goal = (A;B) - _Context -> @@ -2800,7 +2800,7 @@ mercury_output_disj(Goal, VarSet, Indent, !IO) :- mercury_output_par_conj(Goal, VarSet, Indent, !IO) :- mercury_output_newline(Indent, !IO), - io__write_string("&", !IO), + io.write_string("&", !IO), Indent1 = Indent + 1, mercury_output_newline(Indent1, !IO), ( Goal = (A & B) - _Context -> @@ -2819,18 +2819,18 @@ mercury_output_some(Vars, StateVars, VarSet, !IO) :- ; StateVars = [_ | _] ) -> - io__write_string(" some [", !IO), + io.write_string(" some [", !IO), mercury_output_vars(Vars, VarSet, no, !IO), ( Vars = [_ | _], StateVars = [_ | _] -> - io__write_string(", ", !IO), + io.write_string(", ", !IO), mercury_output_state_vars(StateVars, VarSet, no, !IO) ; true ), - io__write_string("]", !IO) + io.write_string("]", !IO) ; true ). @@ -2877,16 +2877,16 @@ mercury_format_foreign_language_string(Lang, !U) :- add_string("""" ++ foreign_language_string(Lang) ++ """", !U). mercury_output_pragma_foreign_import_module(Lang, ModuleName, !IO) :- - io__write_string(":- pragma foreign_import_module(", !IO), + io.write_string(":- pragma foreign_import_module(", !IO), mercury_format_foreign_language_string(Lang, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mercury_output_bracketed_sym_name(ModuleName, not_next_to_graphic_token, !IO), - io__write_string(").\n", !IO). + io.write_string(").\n", !IO). %-----------------------------------------------------------------------------% -% The code here is similar to the code for term_io__quote_string, +% The code here is similar to the code for term_io.quote_string, % but \n and \t are output directly, rather than escaped. % Any changes here may require corresponding changes to term_io and vice versa. @@ -2902,7 +2902,7 @@ mercury_format_foreign_code_string(S, !U) :- U::di, U::uo) is det <= output(U). mercury_format_escaped_string(String, !U) :- - string__foldl(mercury_format_escaped_char, String, !U). + string.foldl(mercury_format_escaped_char, String, !U). :- pred mercury_format_escaped_char(char::in, U::di, U::uo) is det <= output(U). @@ -2933,9 +2933,9 @@ mercury_escape_char(Char) = EscapeCode :- % XXX This may cause problems interfacing with versions of the compiler % that have been built in grades which use different character % representations. - char__to_int(Char, Int), - string__int_to_base_string(Int, 8, OctalString0), - string__pad_left(OctalString0, '0', 3, OctalString), + char.to_int(Char, Int), + string.int_to_base_string(Int, 8, OctalString0), + string.pad_left(OctalString0, '0', 3, OctalString), EscapeCode = "\\" ++ OctalString ++ "\\". :- pred mercury_is_source_char(char::in) is semidet. @@ -2944,7 +2944,7 @@ mercury_escape_char(Char) = EscapeCode :- % Mercury string and character literals. mercury_is_source_char(Char) :- - ( char__is_alnum(Char) + ( char.is_alnum(Char) ; is_mercury_punctuation_char(Char) ; Char = '\n' ; Char = '\t' @@ -3010,9 +3010,9 @@ escape_special_char('\b', 'b'). :- pred mercury_output_pragma_source_file(string::in, io::di, io::uo) is det. mercury_output_pragma_source_file(SourceFileString, !IO) :- - io__write_string(":- pragma source_file(", !IO), - term_io__quote_string(SourceFileString, !IO), - io__write_string(").\n", !IO). + io.write_string(":- pragma source_file(", !IO), + term_io.quote_string(SourceFileString, !IO), + io.write_string(").\n", !IO). %-----------------------------------------------------------------------------% @@ -3021,11 +3021,11 @@ mercury_output_pragma_source_file(SourceFileString, !IO) :- string::in, io::di, io::uo) is det. mercury_output_pragma_foreign_body_code(Lang, ForeignCodeString, !IO) :- - io__write_string(":- pragma foreign_code(", !IO), + io.write_string(":- pragma foreign_code(", !IO), mercury_format_foreign_language_string(Lang, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mercury_format_foreign_code_string(ForeignCodeString, !IO), - io__write_string(").\n", !IO). + io.write_string(").\n", !IO). %-----------------------------------------------------------------------------% @@ -3052,7 +3052,7 @@ mercury_format_pragma_foreign_code(Attributes, PredName, PredOrFunc, Vars0, PragmaCode = import(C_Function, _, _, _), % The predicate or function arguments in a `:- pragma import' % declaration are not named. - ImportModes = list__map( + ImportModes = list.map( (func(pragma_var(_, _, ImportMode, _)) = ImportMode), Vars0), mercury_format_pragma_import(PredName, PredOrFunc, ImportModes, @@ -3179,7 +3179,7 @@ mercury_format_pragma_foreign_code_vars_2([Var | Vars], ProgVarset, mercury_output_pragma_type_spec(Pragma, AppendVarnums, !IO) :- Pragma = type_spec(PredName, SpecName, Arity, MaybePredOrFunc, MaybeModes, Subst, VarSet, _), - io__write_string(":- pragma type_spec(", !IO), + io.write_string(":- pragma type_spec(", !IO), ( MaybeModes = yes(Modes), ( @@ -3193,57 +3193,57 @@ mercury_output_pragma_type_spec(Pragma, AppendVarnums, !IO) :- PredOrFunc = function, pred_args_to_func_args(Modes, FuncModes, RetMode), mercury_output_sym_name(PredName, !IO), - io__write_string("(", !IO), - varset__init(InstVarSet), + io.write_string("(", !IO), + varset.init(InstVarSet), mercury_output_mode_list(FuncModes, InstVarSet, !IO), - io__write_string(") = ", !IO), + io.write_string(") = ", !IO), mercury_output_mode(RetMode, InstVarSet, !IO) ; PredOrFunc = predicate, mercury_output_sym_name(PredName, !IO), - io__write_string("(", !IO), - varset__init(InstVarSet), + io.write_string("(", !IO), + varset.init(InstVarSet), mercury_output_mode_list(Modes, InstVarSet, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ) ; MaybeModes = no, mercury_output_bracketed_sym_name(PredName, next_to_graphic_token, !IO), - io__write_string("/", !IO), - io__write_int(Arity, !IO) + io.write_string("/", !IO), + io.write_int(Arity, !IO) ), - io__write_string(", (", !IO), - io__write_list(Subst, ", ", + io.write_string(", (", !IO), + io.write_list(Subst, ", ", mercury_output_type_subst(VarSet, AppendVarnums), !IO), - io__write_string("), ", !IO), + io.write_string("), ", !IO), mercury_output_bracketed_sym_name(SpecName, not_next_to_graphic_token, !IO), - io__write_string(").\n", !IO). + io.write_string(").\n", !IO). :- pred mercury_output_type_subst(tvarset::in, bool::in, pair(tvar, mer_type)::in, io::di, io::uo) is det. mercury_output_type_subst(VarSet, AppendVarnums, Var - Type, !IO) :- mercury_output_var(Var, VarSet, AppendVarnums, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), mercury_output_type(VarSet, AppendVarnums, Type, !IO). %-----------------------------------------------------------------------------% mercury_output_pragma_unused_args(PredOrFunc, SymName, Arity, ModeNum, UnusedArgs, !IO) :- - io__write_string(":- pragma unused_args(", !IO), + io.write_string(":- pragma unused_args(", !IO), write_pred_or_func(PredOrFunc, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mercury_output_bracketed_sym_name(SymName, !IO), - io__write_string(", ", !IO), - io__write_int(Arity, !IO), - io__write_string(", ", !IO), - io__write_int(ModeNum, !IO), - io__write_string(", [", !IO), + io.write_string(", ", !IO), + io.write_int(Arity, !IO), + io.write_string(", ", !IO), + io.write_int(ModeNum, !IO), + io.write_string(", [", !IO), mercury_format_int_list(UnusedArgs, !IO), - io__write_string("]).\n", !IO). + io.write_string("]).\n", !IO). :- pred mercury_format_int_list(list(int)::in, U::di, U::uo) is det <= output(U). @@ -3366,7 +3366,7 @@ mercury_format_pragma_decl(PredName, Arity, PredOrFunc, PragmaName, MaybeAfter, mercury_format_pragma_import(Name, PredOrFunc, ModeList, Attributes, C_Function, !U) :- - varset__init(Varset), % the varset isn't really used. + varset.init(Varset), % the varset isn't really used. InstInfo = simple_inst_info(Varset), add_string(":- pragma import(", !U), mercury_format_sym_name(Name, !U), @@ -3393,7 +3393,7 @@ mercury_format_pragma_import(Name, PredOrFunc, ModeList, Attributes, list(mer_mode)::in, string::in, U::di, U::uo) is det <= output(U). mercury_format_pragma_export(Name, PredOrFunc, ModeList, C_Function, !U) :- - varset__init(Varset), % the varset isn't really used. + varset.init(Varset), % the varset isn't really used. InstInfo = simple_inst_info(Varset), add_string(":- pragma export(", !U), mercury_format_sym_name(Name, !U), @@ -3431,7 +3431,7 @@ mercury_format_pragma_fact_table(Pred, Arity, FileName, !U) :- %-----------------------------------------------------------------------------% mercury_output_newline(Indent, !IO) :- - io__write_char('\n', !IO), + io.write_char('\n', !IO), mercury_format_tabs(Indent, !IO). :- pred mercury_format_tabs(int::in, @@ -3486,12 +3486,12 @@ mercury_format_term(Term, VarSet, AppendVarnums, !U) :- :- pred mercury_format_term(term(T)::in, varset(T)::in, bool::in, needs_quotes::in, U::di, U::uo) is det <= output(U). -mercury_format_term(term__variable(Var), VarSet, AppendVarnums, _, !U) :- +mercury_format_term(term.variable(Var), VarSet, AppendVarnums, _, !U) :- mercury_format_var(VarSet, AppendVarnums, Var, !U). -mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, +mercury_format_term(term.functor(Functor, Args, _), VarSet, AppendVarnums, NextToGraphicToken, !U) :- ( - Functor = term__atom(""), + Functor = term.atom(""), Args = [F, X | Xs] -> mercury_format_term(F, VarSet, AppendVarnums, NextToGraphicToken, !U), @@ -3500,7 +3500,7 @@ mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, mercury_format_remaining_terms(Xs, VarSet, AppendVarnums, !U), add_string(")", !U) ; - Functor = term__atom("[|]"), + Functor = term.atom("[|]"), Args = [X, Xs] -> add_string("[", !U), @@ -3508,7 +3508,7 @@ mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, mercury_format_list_args(Xs, VarSet, AppendVarnums, !U), add_string("]", !U) ; - Functor = term__atom("{}"), + Functor = term.atom("{}"), Args = [X] -> % A unary tuple is usually a DCG escape, @@ -3517,7 +3517,7 @@ mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, mercury_format_term(X, VarSet, AppendVarnums, !U), add_string(" }", !U) ; - Functor = term__atom("{}"), + Functor = term.atom("{}"), Args = [X | Xs] -> add_string("{", !U), @@ -3526,7 +3526,7 @@ mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, add_string("}", !U) ; Args = [BinaryPrefixArg1, BinaryPrefixArg2], - Functor = term__atom(FunctorName), + Functor = term.atom(FunctorName), mercury_binary_prefix_op(FunctorName) -> add_string("(", !U), @@ -3538,7 +3538,7 @@ mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, add_string(")", !U) ; Args = [PrefixArg], - Functor = term__atom(FunctorName), + Functor = term.atom(FunctorName), mercury_unary_prefix_op(FunctorName) -> add_string("(", !U), @@ -3548,7 +3548,7 @@ mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, add_string(")", !U) ; Args = [PostfixArg], - Functor = term__atom(FunctorName), + Functor = term.atom(FunctorName), mercury_unary_postfix_op(FunctorName) -> add_string("(", !U), @@ -3558,7 +3558,7 @@ mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, add_string(")", !U) ; Args = [Arg1, Arg2], - Functor = term__atom(FunctorName), + Functor = term.atom(FunctorName), mercury_infix_op(FunctorName) -> add_string("(", !U), @@ -3599,14 +3599,14 @@ mercury_format_term(term__functor(Functor, Args, _), VarSet, AppendVarnums, mercury_format_list_args(Term, VarSet, AppendVarnums, !U) :- ( - Term = term__functor(term__atom("[|]"), Args, _), + Term = term.functor(term.atom("[|]"), Args, _), Args = [X, Xs] -> add_string(", ", !U), mercury_format_term(X, VarSet, AppendVarnums, !U), mercury_format_list_args(Xs, VarSet, AppendVarnums, !U) ; - Term = term__functor(term__atom("[]"), [], _) + Term = term.functor(term.atom("[]"), [], _) -> true ; @@ -3630,14 +3630,14 @@ mercury_format_remaining_terms([Term | Terms], VarSet, AppendVarnums, !U) :- io::di, io::uo) is det. mercury_output_state_vars(StateVars, VarSet, AppendVarnums, !IO) :- - io__write_list(StateVars, ", ", + io.write_list(StateVars, ", ", mercury_output_state_var(VarSet, AppendVarnums), !IO). :- pred mercury_output_state_var(varset(T)::in, bool::in, var(T)::in, io::di, io::uo) is det. mercury_output_state_var(VarSet, AppendVarnum, Var, !IO) :- - io__write_string("!", !IO), + io.write_string("!", !IO), mercury_output_var(Var, VarSet, AppendVarnum, !IO). % output a comma-separated list of variables @@ -3671,22 +3671,22 @@ mercury_var_to_string(Var, VarSet, AppendVarnum) = String :- mercury_format_var(VarSet, AppendVarnum, Var, !U) :- ( - varset__search_name(VarSet, Var, Name) + varset.search_name(VarSet, Var, Name) -> mercury_convert_var_name(Name, ConvertedName), add_string(ConvertedName, !U), ( AppendVarnum = yes, - term__var_to_int(Var, VarNum), + term.var_to_int(Var, VarNum), add_string("_", !U), add_int(VarNum, !U) ; AppendVarnum = no ) ; - term__var_to_int(Var, Id), - string__int_to_string(Id, Num), - string__append("V_", Num, VarName), + term.var_to_int(Var, Id), + string.int_to_string(Id, Num), + string.append("V_", Num, VarName), add_string(VarName, !U) ). @@ -3700,7 +3700,7 @@ mercury_format_bracketed_constant(Const, !U) :- U::di, U::uo) is det <= output(U). mercury_format_bracketed_constant(Const, NextToGraphicToken, !U) :- - ( Const = term__atom(Op), mercury_op(Op) -> + ( Const = term.atom(Op), mercury_op(Op) -> add_string("(", !U), add_quoted_atom(Op, !U), add_string(")", !U) @@ -3712,7 +3712,7 @@ mercury_format_bracketed_constant(Const, NextToGraphicToken, !U) :- U::di, U::uo) is det <= output(U). mercury_format_constant(Const, NextToGraphicToken, !U) :- - ( Const = term__atom(Atom) -> + ( Const = term.atom(Atom) -> mercury_format_quoted_atom(Atom, NextToGraphicToken, !U) ; add_constant(Const, !U) @@ -3819,7 +3819,7 @@ mercury_quoted_atom_to_string(Name, NextToGraphicToken) = String :- mercury_format_quoted_atom(Name, NextToGraphicToken, !U) :- % % If the symname is composed of only graphic token chars, - % then term_io__quote_atom will not quote it; but if + % then term_io.quote_atom will not quote it; but if % it is next another graphic token, it needs to be quoted, % otherwise the two would be considered part of one % symbol name (e.g. In "int:<", the ":<" parses as one token, @@ -3827,8 +3827,8 @@ mercury_format_quoted_atom(Name, NextToGraphicToken, !U) :- % ( NextToGraphicToken = next_to_graphic_token, - string__to_char_list(Name, Chars), - ( list__member(Char, Chars) => lexer__graphic_token_char(Char) ) + string.to_char_list(Name, Chars), + ( list.member(Char, Chars) => lexer.graphic_token_char(Char) ) -> add_string("'", !U), add_escaped_string(Name, !U), @@ -3844,27 +3844,27 @@ mercury_format_quoted_atom(Name, NextToGraphicToken, !U) :- :- pred mercury_op(string::in) is semidet. mercury_op(Op) :- - ops__lookup_op(ops__init_mercury_op_table, Op). + ops.lookup_op(ops.init_mercury_op_table, Op). :- pred mercury_binary_prefix_op(string::in) is semidet. mercury_binary_prefix_op(Op) :- - ops__lookup_binary_prefix_op(ops__init_mercury_op_table, Op, _, _, _). + ops.lookup_binary_prefix_op(ops.init_mercury_op_table, Op, _, _, _). :- pred mercury_infix_op(string::in) is semidet. mercury_infix_op(Op) :- - ops__lookup_infix_op(ops__init_mercury_op_table, Op, _, _, _). + ops.lookup_infix_op(ops.init_mercury_op_table, Op, _, _, _). :- pred mercury_unary_prefix_op(string::in) is semidet. mercury_unary_prefix_op(Op) :- - ops__lookup_prefix_op(ops__init_mercury_op_table, Op, _, _). + ops.lookup_prefix_op(ops.init_mercury_op_table, Op, _, _). :- pred mercury_unary_postfix_op(string::in) is semidet. mercury_unary_postfix_op(Op) :- - ops__lookup_postfix_op(ops__init_mercury_op_table, Op, _, _). + ops.lookup_postfix_op(ops.init_mercury_op_table, Op, _, _). %-----------------------------------------------------------------------------% @@ -3888,14 +3888,14 @@ mercury_unary_postfix_op(Op) :- % anthing else same as original name mercury_convert_var_name(Name, ConvertedName) :- - ( string__remove_suffix(Name, "'", _) -> + ( string.remove_suffix(Name, "'", _) -> strip_trailing_primes(Name, StrippedName, NumPrimes), - string__append("V_", StrippedName, Tmp1), - string__int_to_string(NumPrimes, NumString), - string__append(Tmp1, "_", Tmp2), - string__append(Tmp2, NumString, ConvertedName) - ; string__prefix(Name, "V_") -> - string__append("V_", Name, ConvertedName) + string.append("V_", StrippedName, Tmp1), + string.int_to_string(NumPrimes, NumString), + string.append(Tmp1, "_", Tmp2), + string.append(Tmp2, NumString, ConvertedName) + ; string.prefix(Name, "V_") -> + string.append("V_", Name, ConvertedName) ; ConvertedName = Name ). @@ -3905,7 +3905,7 @@ mercury_convert_var_name(Name, ConvertedName) :- % XXX This implementation is O(N*N), but it ought to be O(N) strip_trailing_primes(Name0, Name, Num) :- - ( string__remove_suffix(Name0, "'", Name1) -> + ( string.remove_suffix(Name0, "'", Name1) -> strip_trailing_primes(Name1, Name, Num0), Num = Num0 + 1 ; @@ -3918,12 +3918,12 @@ strip_trailing_primes(Name0, Name, Num) :- :- pred maybe_output_line_number(prog_context::in, io::di, io::uo) is det. maybe_output_line_number(Context, !IO) :- - globals__io_lookup_bool_option(line_numbers, LineNumbers, !IO), + globals.io_lookup_bool_option(line_numbers, LineNumbers, !IO), ( LineNumbers = yes, - io__write_string("\t% ", !IO), - prog_out__write_context(Context, !IO), - io__write_string("\n", !IO) + io.write_string("\t% ", !IO), + prog_out.write_context(Context, !IO), + io.write_string("\n", !IO) ; LineNumbers = no ). @@ -3938,22 +3938,22 @@ maybe_unqualify_sym_name(yes, Name0, unqualified(Name)) :- %-----------------------------------------------------------------------------% -:- instance output(io__state) where [ - pred(add_string/3) is io__write_string, - pred(add_strings/3) is io__write_strings, - pred(add_char/3) is io__write_char, - pred(add_int/3) is io__write_int, - pred(add_float/3) is io__write_float, +:- instance output(io.state) where [ + pred(add_string/3) is io.write_string, + pred(add_strings/3) is io.write_strings, + pred(add_char/3) is io.write_char, + pred(add_int/3) is io.write_int, + pred(add_float/3) is io.write_float, pred(add_purity_prefix/3) is write_purity_prefix, - pred(add_quoted_atom/3) is term_io__quote_atom, - pred(add_quoted_string/3) is term_io__quote_string, - pred(add_constant/3) is term_io__write_constant, - pred(add_class_id/3) is io__write, - pred(add_eval_method/3) is io__write, - pred(add_lambda_eval_method/3) is io__write, - pred(add_escaped_string/3) is term_io__write_escaped_string, - pred(add_format/4) is io__format, - pred(add_list/5) is io__write_list + pred(add_quoted_atom/3) is term_io.quote_atom, + pred(add_quoted_string/3) is term_io.quote_string, + pred(add_constant/3) is term_io.write_constant, + pred(add_class_id/3) is io.write, + pred(add_eval_method/3) is io.write, + pred(add_lambda_eval_method/3) is io.write, + pred(add_escaped_string/3) is term_io.write_escaped_string, + pred(add_format/4) is io.format, + pred(add_list/5) is io.write_list ]. :- instance output(string) where [ @@ -3977,60 +3977,60 @@ maybe_unqualify_sym_name(yes, Name0, unqualified(Name)) :- :- pred output_string(string::in, string::di, string::uo) is det. output_string(S, Str0, Str) :- - string__append(Str0, S, Str). + string.append(Str0, S, Str). :- pred output_strings(list(string)::in, string::di, string::uo) is det. output_strings(Strs, Str0, Str) :- - string__append_list([Str0 | Strs], Str). + string.append_list([Str0 | Strs], Str). :- pred output_char(char::in, string::di, string::uo) is det. output_char(C, Str0, Str) :- - string__char_to_string(C, S), - string__append(Str0, S, Str). + string.char_to_string(C, S), + string.append(Str0, S, Str). :- pred output_int(int::in, string::di, string::uo) is det. output_int(I, Str0, Str) :- - string__int_to_string(I, S), - string__append(Str0, S, Str). + string.int_to_string(I, S), + string.append(Str0, S, Str). :- pred output_float(float::in, string::di, string::uo) is det. output_float(F, Str0, Str) :- - string__float_to_string(F, S), - string__append(Str0, S, Str). + string.float_to_string(F, S), + string.append(Str0, S, Str). :- pred output_purity_prefix(purity::in, string::di, string::uo) is det. output_purity_prefix(P, Str0, Str) :- S = purity_prefix_to_string(P), - string__append(Str0, S, Str). + string.append(Str0, S, Str). :- pred output_quoted_atom(string::in, string::di, string::uo) is det. output_quoted_atom(A, Str0, Str) :- - QA = term_io__quoted_atom(A), - string__append(Str0, QA, Str). + QA = term_io.quoted_atom(A), + string.append(Str0, QA, Str). :- pred output_quoted_string(string::in, string::di, string::uo) is det. output_quoted_string(A, Str0, Str) :- - QA = term_io__quoted_string(A), - string__append(Str0, QA, Str). + QA = term_io.quoted_string(A), + string.append(Str0, QA, Str). :- pred output_constant(const::in, string::di, string::uo) is det. output_constant(C, Str0, Str) :- - CS = term_io__format_constant(C), - string__append(Str0, CS, Str). + CS = term_io.format_constant(C), + string.append(Str0, CS, Str). :- pred output_escaped_string(string::in, string::di, string::uo) is det. output_escaped_string(S, Str0, Str) :- - ES = term_io__escaped_string(S), - string__append(Str0, ES, Str). + ES = term_io.escaped_string(S), + string.append(Str0, ES, Str). :- pred output_class_id(class_id::in, string::di, string::uo) is det. @@ -4053,12 +4053,12 @@ output_eval_method(EvalMethod, !Str) :- output_lambda_eval_method(lambda_normal, !Str) :- output_string("normal", !Str). -:- pred output_format(string::in, list(io__poly_type)::in, +:- pred output_format(string::in, list(io.poly_type)::in, string::di, string::uo) is det. output_format(Format, Items, Str0, Str) :- - S = string__format(Format, Items), - string__append(Str0, S, Str). + S = string.format(Format, Items), + string.append(Str0, S, Str). :- pred output_list(list(T)::in, string::in, pred(T, string, string)::in(pred(in, di, uo) is det), @@ -4082,8 +4082,8 @@ output_list([Item | Items], Sep, Pred, !Str) :- :- pred builtin_inst_name(sym_name::in, list(inst_var)::in) is semidet. builtin_inst_name(unqualified(Name), Args0) :- - Args1 = list__map(func(V) = term__variable(term__coerce_var(V)), Args0), - Term = term__functor(term__atom(Name), Args1, term__context_init), + Args1 = list.map(func(V) = term.variable(term.coerce_var(V)), Args0), + Term = term.functor(term.atom(Name), Args1, term.context_init), convert_inst(no_allow_constrained_inst_var, Term, Inst), Inst \= defined_inst(user_inst(_, _)). @@ -4096,8 +4096,8 @@ builtin_inst_name(unqualified(Name), Args0) :- write_pragma_termination_info(PredOrFunc, SymName, ModeList, Context, MaybeArgSize, MaybeTermination, !IO) :- - io__write_string(":- pragma termination_info(", !IO), - varset__init(InitVarSet), + io.write_string(":- pragma termination_info(", !IO), + varset.init(InitVarSet), ( PredOrFunc = predicate, mercury_output_pred_mode_subdecl(InitVarSet, SymName, @@ -4108,68 +4108,68 @@ write_pragma_termination_info(PredOrFunc, SymName, ModeList, Context, mercury_output_func_mode_subdecl(InitVarSet, SymName, FuncModeList, RetMode, no, Context, !IO) ), - io__write_string(", ", !IO), + io.write_string(", ", !IO), write_maybe_arg_size_info(MaybeArgSize, no, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), write_maybe_termination_info(MaybeTermination, no, !IO), - io__write_string(").\n", !IO). + io.write_string(").\n", !IO). write_maybe_arg_size_info(MaybeArgSizeInfo, Verbose, !IO) :- ( MaybeArgSizeInfo = no, - io__write_string("not_set", !IO) + io.write_string("not_set", !IO) ; MaybeArgSizeInfo = yes(infinite(Error)), - io__write_string("infinite", !IO), + io.write_string("infinite", !IO), ( Verbose = yes, - io__write_string("(", !IO), - io__write(Error, !IO), - io__write_string(")", !IO) + io.write_string("(", !IO), + io.write(Error, !IO), + io.write_string(")", !IO) ; Verbose = no ) ; MaybeArgSizeInfo = yes(finite(Const, UsedArgs)), - io__write_string("finite(", !IO), - io__write_int(Const, !IO), - io__write_string(", ", !IO), + io.write_string("finite(", !IO), + io.write_int(Const, !IO), + io.write_string(", ", !IO), write_used_args(UsedArgs, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred write_used_args(list(bool)::in, io::di, io::uo) is det. write_used_args([], !IO) :- - io__write_string("[]", !IO). + io.write_string("[]", !IO). write_used_args([UsedArg | UsedArgs], !IO) :- - io__write_string("[", !IO), - io__write(UsedArg, !IO), + io.write_string("[", !IO), + io.write(UsedArg, !IO), write_used_args_2(UsedArgs, !IO), - io__write_string("]", !IO). + io.write_string("]", !IO). :- pred write_used_args_2(list(bool)::in, io::di, io::uo) is det. write_used_args_2([], !IO). write_used_args_2([ UsedArg | UsedArgs ], !IO) :- - io__write_string(", ", !IO), - io__write(UsedArg, !IO), + io.write_string(", ", !IO), + io.write(UsedArg, !IO), write_used_args_2(UsedArgs, !IO). write_maybe_termination_info(MaybeTerminationInfo, Verbose, !IO) :- ( MaybeTerminationInfo = no, - io__write_string("not_set", !IO) + io.write_string("not_set", !IO) ; MaybeTerminationInfo = yes(cannot_loop(_)), - io__write_string("cannot_loop", !IO) + io.write_string("cannot_loop", !IO) ; MaybeTerminationInfo = yes(can_loop(Error)), - io__write_string("can_loop", !IO), + io.write_string("can_loop", !IO), ( Verbose = yes -> - io__write_string("(", !IO), - io__write(Error, !IO), - io__write_string(")", !IO) + io.write_string("(", !IO), + io.write(Error, !IO), + io.write_string(")", !IO) ; true ) @@ -4265,19 +4265,19 @@ write_maybe_pragma_termination_info(yes(Termination), !IO) :- write_pragma_structure_sharing_info(PredOrFunc, SymName, Modes, Context, HeadVars, MaybeVarSet, HeadVarTypes, MaybeTypeVarSet, MaybeSharingAs, !IO) :- - io__write_string(":- pragma structure_sharing(", !IO), - varset__init(InitVarSet), + io.write_string(":- pragma structure_sharing(", !IO), + varset.init(InitVarSet), ( MaybeVarSet = yes(VarSet) ; MaybeVarSet = no, - varset__init(VarSet) + varset.init(VarSet) ), ( MaybeTypeVarSet = yes(TypeVarSet) ; MaybeTypeVarSet = no, - varset__init(TypeVarSet) + varset.init(TypeVarSet) ), ( @@ -4291,13 +4291,13 @@ write_pragma_structure_sharing_info(PredOrFunc, SymName, Modes, Context, FuncModeList, RetMode, no, Context, !IO) ), % write headvars and types: - io__write_string(", ", !IO), + io.write_string(", ", !IO), write_vars_and_types(HeadVars, VarSet, HeadVarTypes, TypeVarSet, !IO), % write structure sharing information. - io__write_string(", ", !IO), + io.write_string(", ", !IO), prog_ctgc.print_interface_structure_sharing_domain(VarSet, TypeVarSet, MaybeSharingAs, !IO), - io__write_string(").\n", !IO). + io.write_string(").\n", !IO). :- pred write_vars_and_types(prog_vars::in, prog_varset::in, list(mer_type)::in, tvarset::in, io::di, io::uo) is det. @@ -4306,16 +4306,16 @@ write_vars_and_types(HeadVars, VarSet, HeadVarTypes, TypeVarSet, !IO) :- ( HeadVars = [] -> - io__write_string("vars, types", !IO) + io.write_string("vars, types", !IO) ; - io__write_string("vars(", !IO), + io.write_string("vars(", !IO), mercury_output_vars(HeadVars, VarSet, no, !IO), - io__write_string("), ", !IO), + io.write_string("), ", !IO), - io__write_string("types(", !IO), - io__write_list(HeadVarTypes, ",", mercury_output_type(TypeVarSet, no), + io.write_string("types(", !IO), + io.write_list(HeadVarTypes, ",", mercury_output_type(TypeVarSet, no), !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred write_type_of_var(vartypes::in, tvarset::in, prog_var::in, io::di, diff --git a/compiler/middle_rec.m b/compiler/middle_rec.m index c446bc3cd..321bdfb42 100644 --- a/compiler/middle_rec.m +++ b/compiler/middle_rec.m @@ -13,14 +13,14 @@ % %---------------------------------------------------------------------------% -:- module ll_backend__middle_rec. +:- module ll_backend.middle_rec. :- interface. :- import_module hlds.hlds_goal. :- import_module ll_backend.code_info. :- import_module ll_backend.llds. -:- pred middle_rec__match_and_generate(hlds_goal::in, code_tree::out, +:- pred match_and_generate(hlds_goal::in, code_tree::out, code_info::in, code_info::out) is semidet. %---------------------------------------------------------------------------% @@ -56,7 +56,7 @@ %---------------------------------------------------------------------------% -middle_rec__match_and_generate(Goal, Instrs, !CI) :- +match_and_generate(Goal, Instrs, !CI) :- Goal = GoalExpr - GoalInfo, GoalExpr = switch(Var, cannot_fail, [Case1, Case2]), Case1 = case(ConsId1, Goal1), @@ -109,9 +109,9 @@ contains_simple_recursive_call_conj([Goal | Goals], CodeInfo) :- is_recursive_call(Goal, CodeInfo) :- Goal = call(CallPredId, CallProcId, _, BuiltinState, _, _), BuiltinState = not_builtin, - code_info__get_pred_id(CodeInfo, PredId), + code_info.get_pred_id(CodeInfo, PredId), PredId = CallPredId, - code_info__get_proc_id(CodeInfo, ProcId), + code_info.get_proc_id(CodeInfo, ProcId), ProcId = CallProcId. % contains_only_builtins(G) returns `yes' if G is a leaf procedure, @@ -227,66 +227,65 @@ contains_only_builtins_list([Goal | Goals]) = OnlyBuiltins :- middle_rec_generate_switch(Var, BaseConsId, Base, Recursive, SwitchGoalInfo, Instrs, !CI) :- - code_info__get_stack_slots(!.CI, StackSlots), - code_info__get_varset(!.CI, VarSet), + code_info.get_stack_slots(!.CI, StackSlots), + code_info.get_varset(!.CI, VarSet), SlotsComment = explain_stack_slots(StackSlots, VarSet), - code_info__get_module_info(!.CI, ModuleInfo), - code_info__get_pred_id(!.CI, PredId), - code_info__get_proc_id(!.CI, ProcId), - code_util__make_local_entry_label(ModuleInfo, PredId, ProcId, no, + code_info.get_module_info(!.CI, ModuleInfo), + code_info.get_pred_id(!.CI, PredId), + code_info.get_proc_id(!.CI, ProcId), + code_util.make_local_entry_label(ModuleInfo, PredId, ProcId, no, EntryLabel), - code_info__pre_goal_update(SwitchGoalInfo, no, !CI), - unify_gen__generate_tag_test(Var, BaseConsId, branch_on_success, + code_info.pre_goal_update(SwitchGoalInfo, no, !CI), + unify_gen.generate_tag_test(Var, BaseConsId, branch_on_success, BaseLabel, EntryTestCode, !CI), - tree__flatten(EntryTestCode, EntryTestListList), - list__condense(EntryTestListList, EntryTestList), + tree.flatten(EntryTestCode, EntryTestListList), + list.condense(EntryTestListList, EntryTestList), goal_info_get_store_map(SwitchGoalInfo, StoreMap), - code_info__remember_position(!.CI, BranchStart), - code_gen__generate_goal(model_det, Base, BaseGoalCode, !CI), - code_info__generate_branch_end(StoreMap, no, MaybeEnd1, + code_info.remember_position(!.CI, BranchStart), + code_gen.generate_goal(model_det, Base, BaseGoalCode, !CI), + code_info.generate_branch_end(StoreMap, no, MaybeEnd1, BaseSaveCode, !CI), - code_info__reset_to_position(BranchStart, !CI), - code_gen__generate_goal(model_det, Recursive, RecGoalCode, !CI), - code_info__generate_branch_end(StoreMap, MaybeEnd1, MaybeEnd, + code_info.reset_to_position(BranchStart, !CI), + code_gen.generate_goal(model_det, Recursive, RecGoalCode, !CI), + code_info.generate_branch_end(StoreMap, MaybeEnd1, MaybeEnd, RecSaveCode, !CI), - code_info__post_goal_update(SwitchGoalInfo, !CI), - code_info__after_all_branches(StoreMap, MaybeEnd, !CI), + code_info.post_goal_update(SwitchGoalInfo, !CI), + code_info.after_all_branches(StoreMap, MaybeEnd, !CI), - ArgModes = code_info__get_arginfo(!.CI), - HeadVars = code_info__get_headvars(!.CI), - assoc_list__from_corresponding_lists(HeadVars, ArgModes, Args), - code_info__setup_return(Args, LiveArgs, EpilogCode, !CI), + ArgModes = code_info.get_arginfo(!.CI), + HeadVars = code_info.get_headvars(!.CI), + assoc_list.from_corresponding_lists(HeadVars, ArgModes, Args), + code_info.setup_return(Args, LiveArgs, EpilogCode, !CI), BaseCode = tree(BaseGoalCode, tree(BaseSaveCode, EpilogCode)), RecCode = tree(RecGoalCode, tree(RecSaveCode, EpilogCode)), LiveValCode = [livevals(LiveArgs) - ""], - tree__flatten(BaseCode, BaseListList), - list__condense(BaseListList, BaseList), - tree__flatten(RecCode, RecListList), - list__condense(RecListList, RecList), + tree.flatten(BaseCode, BaseListList), + list.condense(BaseListList, BaseList), + tree.flatten(RecCode, RecListList), + list.condense(RecListList, RecList), % In the code we generate, the base instruction sequence is executed % in situations where this procedure has no stack frame. If this % sequence refers to stackvars, it will be to some other procedure's % variables, which is obviously incorrect. - opt_util__block_refers_stackvars(BaseList, no), + opt_util.block_refers_stackvars(BaseList, no), - list__append(BaseList, RecList, AvoidList), - middle_rec__find_unused_register(AvoidList, AuxReg), + list.append(BaseList, RecList, AvoidList), + find_unused_register(AvoidList, AuxReg), - middle_rec__split_rec_code(RecList, BeforeList0, AfterList), - middle_rec__add_counter_to_livevals(BeforeList0, AuxReg, BeforeList), + split_rec_code(RecList, BeforeList0, AfterList), + add_counter_to_livevals(BeforeList0, AuxReg, BeforeList), - code_info__get_next_label(Loop1Label, !CI), - code_info__get_next_label(Loop2Label, !CI), - code_info__get_total_stackslot_count(!.CI, FrameSize), + code_info.get_next_label(Loop1Label, !CI), + code_info.get_next_label(Loop2Label, !CI), + code_info.get_total_stackslot_count(!.CI, FrameSize), - middle_rec__generate_downloop_test(EntryTestList, - Loop1Label, Loop1Test), + generate_downloop_test(EntryTestList, Loop1Label, Loop1Test), ( FrameSize = 0 -> MaybeIncrSp = [], @@ -305,7 +304,7 @@ middle_rec_generate_switch(Var, BaseConsId, Base, Recursive, SwitchGoalInfo, label(Loop2Label)) - "test on upward loop"] ; - PushMsg = code_gen__push_msg(ModuleInfo, PredId, ProcId), + PushMsg = code_gen.push_msg(ModuleInfo, PredId, ProcId), MaybeIncrSp = [incr_sp(FrameSize, PushMsg) - ""], MaybeDecrSp = [decr_sp(FrameSize) - ""], InitAuxReg = [assign(AuxReg, lval(sp)) @@ -324,7 +323,7 @@ middle_rec_generate_switch(Var, BaseConsId, Base, Recursive, SwitchGoalInfo, ( AfterList = [], - list__condense([ + list.condense([ [ label(EntryLabel) - "Procedure entry point", comment(SlotsComment) - "" @@ -351,9 +350,9 @@ middle_rec_generate_switch(Var, BaseConsId, Base, Recursive, SwitchGoalInfo, % apply this version of the optimization, or we must consistently % substitute the labels (which will be referred to only from within the % BaseList instructions themselves). We choose the former course. - middle_rec__find_labels(BaseList, BaseLabels), + find_labels(BaseList, BaseLabels), BaseLabels = [], - list__condense([ + list.condense([ [ label(EntryLabel) - "Procedure entry point", comment(SlotsComment) - "" @@ -407,7 +406,7 @@ generate_downloop_test([Instr0 | Instrs0], Target, Instrs) :- "generate_downloop_test: " ++ "if_val followed by other instructions") ), - code_util__neg_rval(Test, NewTest), + code_util.neg_rval(Test, NewTest), Instrs = [if_val(NewTest, label(Target)) - "test on downward loop"] ; generate_downloop_test(Instrs0, Target, Instrs1), @@ -424,7 +423,7 @@ split_rec_code([], _, _) :- split_rec_code([Instr0 | Instrs1], Before, After) :- ( Instr0 = call(_, _, _, _, _, _) - _ -> ( - opt_util__skip_comments(Instrs1, Instrs2), + opt_util.skip_comments(Instrs1, Instrs2), Instrs2 = [Instr2 | Instrs3], Instr2 = label(_) - _ -> @@ -440,200 +439,198 @@ split_rec_code([Instr0 | Instrs1], Before, After) :- %---------------------------------------------------------------------------% -:- pred middle_rec__add_counter_to_livevals(list(instruction)::in, lval::in, +:- pred add_counter_to_livevals(list(instruction)::in, lval::in, list(instruction)::out) is det. -middle_rec__add_counter_to_livevals([], _Lval, []). -middle_rec__add_counter_to_livevals([I0 | Is0], Lval, [I | Is]) :- +add_counter_to_livevals([], _Lval, []). +add_counter_to_livevals([I0 | Is0], Lval, [I | Is]) :- ( I0 = livevals(Lives0) - Comment -> - set__insert(Lives0, Lval, Lives), + set.insert(Lives0, Lval, Lives), I = livevals(Lives) - Comment ; I = I0 ), - middle_rec__add_counter_to_livevals(Is0, Lval, Is). + add_counter_to_livevals(Is0, Lval, Is). %---------------------------------------------------------------------------% -:- pred middle_rec__find_unused_register(list(instruction)::in, lval::out) +:- pred find_unused_register(list(instruction)::in, lval::out) is det. -middle_rec__find_unused_register(Instrs, UnusedReg) :- - set__init(Used0), - middle_rec__find_used_registers(Instrs, Used0, Used1), - set__to_sorted_list(Used1, UsedList), - middle_rec__find_unused_register_2(UsedList, 1, UnusedReg). +find_unused_register(Instrs, UnusedReg) :- + set.init(Used0), + find_used_registers(Instrs, Used0, Used1), + set.to_sorted_list(Used1, UsedList), + find_unused_register_2(UsedList, 1, UnusedReg). -:- pred middle_rec__find_unused_register_2(list(int)::in, int::in, lval::out) - is det. +:- pred find_unused_register_2(list(int)::in, int::in, lval::out) is det. -middle_rec__find_unused_register_2([], N, reg(r, N)). -middle_rec__find_unused_register_2([H | T], N, Reg) :- +find_unused_register_2([], N, reg(r, N)). +find_unused_register_2([H | T], N, Reg) :- ( N < H -> Reg = reg(r, N) ; N1 = N + 1, - middle_rec__find_unused_register_2(T, N1, Reg) + find_unused_register_2(T, N1, Reg) ). -:- pred middle_rec__find_used_registers(list(instruction)::in, +:- pred find_used_registers(list(instruction)::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers([], !Used). -middle_rec__find_used_registers([Instr - _ | Instrs], !Used) :- - middle_rec__find_used_registers_instr(Instr, !Used), - middle_rec__find_used_registers(Instrs, !Used). +find_used_registers([], !Used). +find_used_registers([Instr - _ | Instrs], !Used) :- + find_used_registers_instr(Instr, !Used), + find_used_registers(Instrs, !Used). -:- pred middle_rec__find_used_registers_instr(instr::in, +:- pred find_used_registers_instr(instr::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers_instr(comment(_), !Used). -middle_rec__find_used_registers_instr(livevals(LvalSet), !Used) :- - set__to_sorted_list(LvalSet, LvalList), - middle_rec__find_used_registers_lvals(LvalList, !Used). -middle_rec__find_used_registers_instr(block(_, _, Instrs), !Used) :- - middle_rec__find_used_registers(Instrs, !Used). -middle_rec__find_used_registers_instr(assign(Lval, Rval), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used), - middle_rec__find_used_registers_rval(Rval, !Used). -middle_rec__find_used_registers_instr(call(_, _, _, _, _, _), !Used). -middle_rec__find_used_registers_instr(mkframe(_, _), !Used). -middle_rec__find_used_registers_instr(label(_), !Used). -middle_rec__find_used_registers_instr(goto(_), !Used). -middle_rec__find_used_registers_instr(computed_goto(Rval, _), !Used) :- - middle_rec__find_used_registers_rval(Rval, !Used). -middle_rec__find_used_registers_instr(c_code(_, _), !Used). -middle_rec__find_used_registers_instr(if_val(Rval, _), !Used) :- - middle_rec__find_used_registers_rval(Rval, !Used). -middle_rec__find_used_registers_instr(save_maxfr(Lval), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used). -middle_rec__find_used_registers_instr(restore_maxfr(Lval), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used). -middle_rec__find_used_registers_instr(incr_hp(Lval, _, _, Rval, _), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used), - middle_rec__find_used_registers_rval(Rval, !Used). -middle_rec__find_used_registers_instr(mark_hp(Lval), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used). -middle_rec__find_used_registers_instr(restore_hp(Rval), !Used) :- - middle_rec__find_used_registers_rval(Rval, !Used). -middle_rec__find_used_registers_instr(free_heap(Rval), !Used) :- - middle_rec__find_used_registers_rval(Rval, !Used). -middle_rec__find_used_registers_instr(store_ticket(Lval), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used). -middle_rec__find_used_registers_instr(reset_ticket(Rval, _Rsn), !Used) :- - middle_rec__find_used_registers_rval(Rval, !Used). -middle_rec__find_used_registers_instr(discard_ticket, !Used). -middle_rec__find_used_registers_instr(prune_ticket, !Used). -middle_rec__find_used_registers_instr(mark_ticket_stack(Lval), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used). -middle_rec__find_used_registers_instr(prune_tickets_to(Rval), !Used) :- - middle_rec__find_used_registers_rval(Rval, !Used). -middle_rec__find_used_registers_instr(incr_sp(_, _), !Used). -middle_rec__find_used_registers_instr(decr_sp(_), !Used). -middle_rec__find_used_registers_instr(decr_sp_and_return(_), !Used). -middle_rec__find_used_registers_instr(pragma_c(_, Components, +find_used_registers_instr(comment(_), !Used). +find_used_registers_instr(livevals(LvalSet), !Used) :- + set.to_sorted_list(LvalSet, LvalList), + find_used_registers_lvals(LvalList, !Used). +find_used_registers_instr(block(_, _, Instrs), !Used) :- + find_used_registers(Instrs, !Used). +find_used_registers_instr(assign(Lval, Rval), !Used) :- + find_used_registers_lval(Lval, !Used), + find_used_registers_rval(Rval, !Used). +find_used_registers_instr(call(_, _, _, _, _, _), !Used). +find_used_registers_instr(mkframe(_, _), !Used). +find_used_registers_instr(label(_), !Used). +find_used_registers_instr(goto(_), !Used). +find_used_registers_instr(computed_goto(Rval, _), !Used) :- + find_used_registers_rval(Rval, !Used). +find_used_registers_instr(c_code(_, _), !Used). +find_used_registers_instr(if_val(Rval, _), !Used) :- + find_used_registers_rval(Rval, !Used). +find_used_registers_instr(save_maxfr(Lval), !Used) :- + find_used_registers_lval(Lval, !Used). +find_used_registers_instr(restore_maxfr(Lval), !Used) :- + find_used_registers_lval(Lval, !Used). +find_used_registers_instr(incr_hp(Lval, _, _, Rval, _), !Used) :- + find_used_registers_lval(Lval, !Used), + find_used_registers_rval(Rval, !Used). +find_used_registers_instr(mark_hp(Lval), !Used) :- + find_used_registers_lval(Lval, !Used). +find_used_registers_instr(restore_hp(Rval), !Used) :- + find_used_registers_rval(Rval, !Used). +find_used_registers_instr(free_heap(Rval), !Used) :- + find_used_registers_rval(Rval, !Used). +find_used_registers_instr(store_ticket(Lval), !Used) :- + find_used_registers_lval(Lval, !Used). +find_used_registers_instr(reset_ticket(Rval, _Rsn), !Used) :- + find_used_registers_rval(Rval, !Used). +find_used_registers_instr(discard_ticket, !Used). +find_used_registers_instr(prune_ticket, !Used). +find_used_registers_instr(mark_ticket_stack(Lval), !Used) :- + find_used_registers_lval(Lval, !Used). +find_used_registers_instr(prune_tickets_to(Rval), !Used) :- + find_used_registers_rval(Rval, !Used). +find_used_registers_instr(incr_sp(_, _), !Used). +find_used_registers_instr(decr_sp(_), !Used). +find_used_registers_instr(decr_sp_and_return(_), !Used). +find_used_registers_instr(pragma_c(_, Components, _, _, _, _, _, _, _), !Used) :- - middle_rec__find_used_registers_components(Components, !Used). -middle_rec__find_used_registers_instr(init_sync_term(Lval, _), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used). -middle_rec__find_used_registers_instr(fork(_, _, _), !Used). -middle_rec__find_used_registers_instr(join_and_terminate(Lval), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used). -middle_rec__find_used_registers_instr(join_and_continue(Lval, _), !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used). + find_used_registers_components(Components, !Used). +find_used_registers_instr(init_sync_term(Lval, _), !Used) :- + find_used_registers_lval(Lval, !Used). +find_used_registers_instr(fork(_, _, _), !Used). +find_used_registers_instr(join_and_terminate(Lval), !Used) :- + find_used_registers_lval(Lval, !Used). +find_used_registers_instr(join_and_continue(Lval, _), !Used) :- + find_used_registers_lval(Lval, !Used). -:- pred middle_rec__find_used_registers_components( +:- pred find_used_registers_components( list(pragma_c_component)::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers_components([], !Used). -middle_rec__find_used_registers_components([Comp | Comps], !Used) :- - middle_rec__find_used_registers_component(Comp, !Used), - middle_rec__find_used_registers_components(Comps, !Used). +find_used_registers_components([], !Used). +find_used_registers_components([Comp | Comps], !Used) :- + find_used_registers_component(Comp, !Used), + find_used_registers_components(Comps, !Used). -:- pred middle_rec__find_used_registers_component(pragma_c_component::in, +:- pred find_used_registers_component(pragma_c_component::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers_component(pragma_c_inputs(In), !Used) :- +find_used_registers_component(pragma_c_inputs(In), !Used) :- insert_pragma_c_input_registers(In, !Used). -middle_rec__find_used_registers_component(pragma_c_outputs(Out), !Used) :- +find_used_registers_component(pragma_c_outputs(Out), !Used) :- insert_pragma_c_output_registers(Out, !Used). -middle_rec__find_used_registers_component(pragma_c_user_code(_, _), !Used). -middle_rec__find_used_registers_component(pragma_c_raw_code(_, _, _), !Used). -middle_rec__find_used_registers_component(pragma_c_fail_to(_), !Used). -middle_rec__find_used_registers_component(pragma_c_noop, !Used). +find_used_registers_component(pragma_c_user_code(_, _), !Used). +find_used_registers_component(pragma_c_raw_code(_, _, _), !Used). +find_used_registers_component(pragma_c_fail_to(_), !Used). +find_used_registers_component(pragma_c_noop, !Used). -:- pred middle_rec__find_used_registers_lvals(list(lval)::in, +:- pred find_used_registers_lvals(list(lval)::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers_lvals([], !Used). -middle_rec__find_used_registers_lvals([Lval | Lvals], !Used) :- - middle_rec__find_used_registers_lval(Lval, !Used), - middle_rec__find_used_registers_lvals(Lvals, !Used). +find_used_registers_lvals([], !Used). +find_used_registers_lvals([Lval | Lvals], !Used) :- + find_used_registers_lval(Lval, !Used), + find_used_registers_lvals(Lvals, !Used). -:- pred middle_rec__find_used_registers_lval(lval::in, +:- pred find_used_registers_lval(lval::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers_lval(Lval, !Used) :- +find_used_registers_lval(Lval, !Used) :- ( Lval = reg(r, N) -> copy(N, N1), - set__insert(!.Used, N1, !:Used) + set.insert(!.Used, N1, !:Used) ; Lval = field(_, Rval, FieldNum) -> - middle_rec__find_used_registers_rval(Rval, !Used), - middle_rec__find_used_registers_rval(FieldNum, !Used) + find_used_registers_rval(Rval, !Used), + find_used_registers_rval(FieldNum, !Used) ; Lval = lvar(_) -> unexpected(this_file, "lvar found in find_used_registers_lval") ; true ). -:- pred middle_rec__find_used_registers_rval(rval::in, - set(int)::in, set(int)::out) is det. +:- pred find_used_registers_rval(rval::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers_rval(Rval, !Used) :- +find_used_registers_rval(Rval, !Used) :- ( Rval = lval(Lval), - middle_rec__find_used_registers_lval(Lval, !Used) + find_used_registers_lval(Lval, !Used) ; Rval = var(_), unexpected(this_file, "var found in find_used_registers_rval") ; Rval = mkword(_, Rval1), - middle_rec__find_used_registers_rval(Rval1, !Used) + find_used_registers_rval(Rval1, !Used) ; Rval = const(_) ; Rval = unop(_, Rval1), - middle_rec__find_used_registers_rval(Rval1, !Used) + find_used_registers_rval(Rval1, !Used) ; Rval = binop(_, Rval1, Rval2), - middle_rec__find_used_registers_rval(Rval1, !Used), - middle_rec__find_used_registers_rval(Rval2, !Used) + find_used_registers_rval(Rval1, !Used), + find_used_registers_rval(Rval2, !Used) ; Rval = mem_addr(MemRef), - middle_rec__find_used_registers_mem_ref(MemRef, !Used) + find_used_registers_mem_ref(MemRef, !Used) ). -:- pred middle_rec__find_used_registers_mem_ref(mem_ref::in, +:- pred find_used_registers_mem_ref(mem_ref::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers_mem_ref(stackvar_ref(_), !Used). -middle_rec__find_used_registers_mem_ref(framevar_ref(_), !Used). -middle_rec__find_used_registers_mem_ref(heap_ref(Rval, _, _), !Used) :- - middle_rec__find_used_registers_rval(Rval, !Used). +find_used_registers_mem_ref(stackvar_ref(_), !Used). +find_used_registers_mem_ref(framevar_ref(_), !Used). +find_used_registers_mem_ref(heap_ref(Rval, _, _), !Used) :- + find_used_registers_rval(Rval, !Used). -:- pred middle_rec__find_used_registers_maybe_rvals(list(maybe(rval))::in, +:- pred find_used_registers_maybe_rvals(list(maybe(rval))::in, set(int)::in, set(int)::out) is det. -middle_rec__find_used_registers_maybe_rvals([], !Used). -middle_rec__find_used_registers_maybe_rvals([MaybeRval | MaybeRvals], !Used) :- +find_used_registers_maybe_rvals([], !Used). +find_used_registers_maybe_rvals([MaybeRval | MaybeRvals], !Used) :- ( MaybeRval = no ; MaybeRval = yes(Rval), - middle_rec__find_used_registers_rval(Rval, !Used) + find_used_registers_rval(Rval, !Used) ), - middle_rec__find_used_registers_maybe_rvals(MaybeRvals, !Used). + find_used_registers_maybe_rvals(MaybeRvals, !Used). :- pred insert_pragma_c_input_registers(list(pragma_c_input)::in, set(int)::in, set(int)::out) is det. @@ -641,7 +638,7 @@ middle_rec__find_used_registers_maybe_rvals([MaybeRval | MaybeRvals], !Used) :- insert_pragma_c_input_registers([], !Used). insert_pragma_c_input_registers([Input | Inputs], !Used) :- Input = pragma_c_input(_, _, _, _, Rval, _, _), - middle_rec__find_used_registers_rval(Rval, !Used), + find_used_registers_rval(Rval, !Used), insert_pragma_c_input_registers(Inputs, !Used). :- pred insert_pragma_c_output_registers(list(pragma_c_output)::in, @@ -650,32 +647,31 @@ insert_pragma_c_input_registers([Input | Inputs], !Used) :- insert_pragma_c_output_registers([], !Used). insert_pragma_c_output_registers([Output | Outputs], !Used) :- Output = pragma_c_output(Lval, _, _, _, _, _, _), - middle_rec__find_used_registers_lval(Lval, !Used), + find_used_registers_lval(Lval, !Used), insert_pragma_c_output_registers(Outputs, !Used). %---------------------------------------------------------------------------% % Find all the labels defined in an instruction sequence. % -:- pred middle_rec__find_labels(list(instruction)::in, list(label)::out) - is det. +:- pred find_labels(list(instruction)::in, list(label)::out) is det. -middle_rec__find_labels(Instrs, Label2) :- - middle_rec__find_labels_2(Instrs, [], Label2). +find_labels(Instrs, Label2) :- + find_labels_2(Instrs, [], Label2). -:- pred middle_rec__find_labels_2(list(instruction)::in, +:- pred find_labels_2(list(instruction)::in, list(label)::in, list(label)::out) is det. -middle_rec__find_labels_2([], !Labels). -middle_rec__find_labels_2([Instr - _ | Instrs], !Labels) :- +find_labels_2([], !Labels). +find_labels_2([Instr - _ | Instrs], !Labels) :- ( Instr = label(Label) -> !:Labels = [Label | !.Labels] ; Instr = block(_, _, Block) -> - middle_rec__find_labels_2(Block, !Labels) + find_labels_2(Block, !Labels) ; true ), - middle_rec__find_labels_2(Instrs, !Labels). + find_labels_2(Instrs, !Labels). %---------------------------------------------------------------------------% diff --git a/compiler/ml_call_gen.m b/compiler/ml_call_gen.m index 7bc3fa364..122030af6 100644 --- a/compiler/ml_call_gen.m +++ b/compiler/ml_call_gen.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_call_gen. +:- module ml_backend.ml_call_gen. :- interface. :- import_module hlds.code_model. @@ -34,7 +34,7 @@ % :- pred ml_gen_generic_call(generic_call::in, list(prog_var)::in, list(mer_mode)::in, determinism::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % ml_gen_call(PredId, ProcId, ArgNames, ArgLvals, ArgTypes, @@ -49,23 +49,23 @@ % should obtain the type_info from the corresponding entry in the % `type_params' local. % -:- pred ml_gen_call(pred_id::in, proc_id::in, list(var_name)::in, +:- pred ml_gen_call(pred_id::in, proc_id::in, list(mlds_var_name)::in, list(mlds_lval)::in, list(mer_type)::in, code_model::in, - prog_context::in, bool::in, mlds__defns::out, statements::out, + prog_context::in, bool::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % Generate MLDS code for a call to a builtin procedure. % :- pred ml_gen_builtin(pred_id::in, proc_id::in, list(prog_var)::in, code_model::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % Generate MLDS code for a cast. The list of argument variables % must have only two elements, the input and the output. % :- pred ml_gen_cast(prog_context::in, list(prog_var)::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % Generate an rval containing the address of the specified procedure. @@ -100,8 +100,8 @@ % (If ForClosureWrapper = no, then ArgNum is unused.) % :- pred ml_gen_box_or_unbox_lval(mer_type::in, mer_type::in, box_policy::in, - mlds_lval::in, var_name::in, prog_context::in, bool::in, int::in, - mlds_lval::out, mlds__defns::out, statements::out, statements::out, + mlds_lval::in, mlds_var_name::in, prog_context::in, bool::in, int::in, + mlds_lval::out, mlds_defns::out, statements::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % Generate the appropriate MLDS type for a continuation function @@ -111,7 +111,7 @@ % parameters. It is the caller's responsibility to fill these in properly % if needed. % -:- pred ml_gen_cont_params(list(mlds_type)::in, mlds__func_params::out, +:- pred ml_gen_cont_params(list(mlds_type)::in, mlds_func_params::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -160,14 +160,14 @@ ml_gen_generic_call(cast(_), ArgVars, _ArgModes, _Determinism, Context, :- pred ml_gen_generic_call_2(generic_call::in, list(prog_var)::in, list(mer_mode)::in, determinism::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_generic_call_2(GenericCall, ArgVars, ArgModes, Determinism, Context, Decls, Statements, !Info) :- % Allocate some fresh type variables to use as the Mercury types % of the boxed arguments. - NumArgs = list__length(ArgVars), + NumArgs = list.length(ArgVars), BoxedArgTypes = ml_make_boxed_types(NumArgs), % Create the boxed parameter types for the called function. @@ -187,12 +187,12 @@ ml_gen_generic_call_2(GenericCall, ArgVars, ArgModes, Determinism, Context, % we don't generate any actual local variable or parameter for % `closure_arg'. GC_TraceCode = no, - ClosureArgType = mlds__generic_type, - ClosureArg = mlds__argument(data(var(var_name("closure_arg", no))), + ClosureArgType = mlds_generic_type, + ClosureArg = mlds_argument(data(var(mlds_var_name("closure_arg", no))), ClosureArgType, GC_TraceCode), - Params0 = mlds__func_params(ArgParams0, RetParam), - Params = mlds__func_params([ClosureArg | ArgParams0], RetParam), - Signature = mlds__get_func_signature(Params), + Params0 = mlds_func_params(ArgParams0, RetParam), + Params = mlds_func_params([ClosureArg | ArgParams0], RetParam), + Signature = mlds_get_func_signature(Params), % Compute the function address. ( @@ -201,8 +201,8 @@ ml_gen_generic_call_2(GenericCall, ArgVars, ArgModes, Determinism, Context, FieldId = offset(const(int_const(1))), % XXX are these types right? FuncLval = field(yes(0), lval(ClosureLval), FieldId, - mlds__generic_type, ClosureArgType), - FuncType = mlds__func_type(Params), + mlds_generic_type, ClosureArgType), + FuncType = mlds_func_type(Params), FuncRval = unop(unbox(FuncType), lval(FuncLval)) ; GenericCall = class_method(TypeClassInfoVar, MethodNum, @@ -217,15 +217,15 @@ ml_gen_generic_call_2(GenericCall, ArgVars, ArgModes, Determinism, Context, BaseTypeclassInfoFieldId = offset(const(int_const(0))), BaseTypeclassInfoLval = field(yes(0), lval(TypeClassInfoLval), BaseTypeclassInfoFieldId, - mlds__generic_type, ClosureArgType), + mlds_generic_type, ClosureArgType), % Extract the method address from the base_typeclass_info. Offset = ml_base_typeclass_info_method_offset, MethodFieldNum = MethodNum + Offset, MethodFieldId = offset(const(int_const(MethodFieldNum))), FuncLval = field(yes(0), lval(BaseTypeclassInfoLval), - MethodFieldId, mlds__generic_type, mlds__generic_type), - FuncType = mlds__func_type(Params), + MethodFieldId, mlds_generic_type, mlds_generic_type), + FuncType = mlds_func_type(Params), FuncRval = unop(unbox(FuncType), lval(FuncLval)) ; GenericCall = cast(_), @@ -239,12 +239,12 @@ ml_gen_generic_call_2(GenericCall, ArgVars, ArgModes, Determinism, Context, % pointer types in casts. % ml_gen_info_new_conv_var(ConvVarNum, !Info), - FuncVarName = var_name(string__format("func_%d", [i(ConvVarNum)]), no), + FuncVarName = mlds_var_name(string.format("func_%d", [i(ConvVarNum)]), no), % The function address is always a pointer to code, % not to the heap, so the GC doesn't need to trace it. GC_TraceCode = no, FuncVarDecl = ml_gen_mlds_var_decl(var(FuncVarName), - FuncType, GC_TraceCode, mlds__make_context(Context)), + FuncType, GC_TraceCode, mlds_make_context(Context)), ml_gen_var_lval(!.Info, FuncVarName, FuncType, FuncVarLval), AssignFuncVar = ml_gen_assign(FuncVarLval, FuncRval, Context), FuncVarRval = lval(FuncVarLval), @@ -358,7 +358,7 @@ ml_gen_call(PredId, ProcId, ArgNames, ArgLvals, ActualArgTypes, CodeModel, % Compute the function signature. ml_gen_info_get_module_info(!.Info, ModuleInfo), Params = ml_gen_proc_params(ModuleInfo, PredId, ProcId), - Signature = mlds__get_func_signature(Params), + Signature = mlds_get_func_signature(Params), % Compute the function address. ml_gen_proc_addr_rval(PredId, ProcId, FuncRval, !Info), @@ -408,7 +408,7 @@ ml_gen_call(PredId, ProcId, ArgNames, ArgLvals, ActualArgTypes, CodeModel, ml_combine_conj(CodeModel, Context, DoGenCall, DoGenConvOutputAndSucceed, CallAndConvOutputDecls, CallAndConvOutputStatements, !Info), - Decls = list__append(ConvArgDecls, CallAndConvOutputDecls), + Decls = list.append(ConvArgDecls, CallAndConvOutputDecls), Statements = CallAndConvOutputStatements ). @@ -416,10 +416,10 @@ ml_gen_call(PredId, ProcId, ArgNames, ArgLvals, ActualArgTypes, CodeModel, % This is a lower-level routine called by both ml_gen_call % and ml_gen_generic_call. % -:- pred ml_gen_mlds_call(mlds__func_signature::in, maybe(mlds_rval)::in, +:- pred ml_gen_mlds_call(mlds_func_signature::in, maybe(mlds_rval)::in, mlds_rval::in, list(mlds_rval)::in, list(mlds_lval)::in, list(mlds_type)::in, determinism::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_mlds_call(Signature, ObjectRval, FuncRval, ArgRvals0, RetLvals0, @@ -444,7 +444,7 @@ ml_gen_mlds_call(Signature, ObjectRval, FuncRval, ArgRvals0, RetLvals0, % For --nondet-copy-out, the output arguments will be passed to the % continuation rather than being returned. ml_gen_info_get_globals(!.Info, Globals), - globals__lookup_bool_option(Globals, nondet_copy_out, NondetCopyOut), + globals.lookup_bool_option(Globals, nondet_copy_out, NondetCopyOut), ( NondetCopyOut = yes, RetLvals = [] @@ -458,7 +458,7 @@ ml_gen_mlds_call(Signature, ObjectRval, FuncRval, ArgRvals0, RetLvals0, % Return a bool indicating whether or not it succeeded. ml_success_lval(!.Info, Success), ArgRvals = ArgRvals0, - RetLvals = list__append([Success], RetLvals0), + RetLvals = list.append([Success], RetLvals0), Decls = [] ; CodeModel = model_det, @@ -478,11 +478,11 @@ ml_gen_mlds_call(Signature, ObjectRval, FuncRval, ArgRvals0, RetLvals0, CallKind = ordinary_call ), Stmt = call(Signature, FuncRval, ObjectRval, ArgRvals, RetLvals, CallKind), - Statement = statement(Stmt, mlds__make_context(Context)), + Statement = statement(Stmt, mlds_make_context(Context)), Statements = [Statement]. :- pred ml_gen_success_cont(list(mlds_type)::in, list(mlds_lval)::in, - prog_context::in, success_cont::out, mlds__defns::out, + prog_context::in, success_cont::out, mlds_defns::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_success_cont(OutputArgTypes, OutputArgLvals, Context, @@ -518,7 +518,7 @@ ml_gen_success_cont(OutputArgTypes, OutputArgLvals, Context, OutputArgTypes, Context, CopyDecls, CopyStatements), ml_gen_call_current_success_cont(Context, CallCont, !Info), CopyStatement = ml_gen_block(CopyDecls, - list__append(CopyStatements, [CallCont]), Context), + list.append(CopyStatements, [CallCont]), Context), % pop nesting level ml_gen_label_func(!.Info, ContFuncLabel, Params, Context, CopyStatement, ContFuncDefn), @@ -539,12 +539,12 @@ ml_gen_cont_params(OutputArgTypes, Params, !Info) :- ; UseNestedFuncs = no, ml_declare_env_ptr_arg(EnvPtrArg), - Args = list__append(Args0, [EnvPtrArg]) + Args = list.append(Args0, [EnvPtrArg]) ), - Params = mlds__func_params(Args, []). + Params = mlds_func_params(Args, []). :- pred ml_gen_cont_params_2(list(mlds_type)::in, int::in, - mlds__arguments::out) is det. + mlds_arguments::out) is det. ml_gen_cont_params_2([], _, []). ml_gen_cont_params_2([Type | Types], ArgNum, [Argument | Arguments]) :- @@ -554,11 +554,11 @@ ml_gen_cont_params_2([Type | Types], ArgNum, [Argument | Arguments]) :- % So here we just leave it blank. The caller of ml_gen_cont_param has the % reponsibility of fillling this in properly if needed. Maybe_GC_TraceCode = no, - Argument = mlds__argument(data(var(ArgName)), Type, Maybe_GC_TraceCode), + Argument = mlds_argument(data(var(ArgName)), Type, Maybe_GC_TraceCode), ml_gen_cont_params_2(Types, ArgNum + 1, Arguments). :- pred ml_gen_copy_args_to_locals(ml_gen_info::in, list(mlds_lval)::in, - list(mlds_type)::in, prog_context::in, mlds__defns::out, + list(mlds_type)::in, prog_context::in, mlds_defns::out, statements::out) is det. ml_gen_copy_args_to_locals(Info, ArgLvals, ArgTypes, Context, @@ -584,26 +584,26 @@ ml_gen_copy_args_to_locals_2(_Info, [], [_ | _], _, _, _) :- ml_gen_copy_args_to_locals_2(_Info, [_ | _], [], _, _, _) :- unexpected(this_file, "ml_gen_copy_args_to_locals_2: length mismatch"). -:- func ml_gen_arg_name(int) = mlds__var_name. +:- func ml_gen_arg_name(int) = mlds_var_name. -ml_gen_arg_name(ArgNum) = mlds__var_name(ArgName, no) :- - string__format("arg%d", [i(ArgNum)], ArgName). +ml_gen_arg_name(ArgNum) = mlds_var_name(ArgName, no) :- + string.format("arg%d", [i(ArgNum)], ArgName). ml_gen_proc_addr_rval(PredId, ProcId, CodeAddrRval, !Info) :- ml_gen_info_get_module_info(!.Info, ModuleInfo), ml_gen_pred_label(ModuleInfo, PredId, ProcId, PredLabel, PredModule), ml_gen_proc_params(PredId, ProcId, Params, !Info), - Signature = mlds__get_func_signature(Params), + Signature = mlds_get_func_signature(Params), QualifiedProcLabel = qual(PredModule, module_qual, PredLabel - ProcId), CodeAddrRval = const(code_addr_const(proc(QualifiedProcLabel, Signature))). % Generate rvals and lvals for the arguments of a procedure call % -:- pred ml_gen_arg_list(list(var_name)::in, list(mlds_lval)::in, +:- pred ml_gen_arg_list(list(mlds_var_name)::in, list(mlds_lval)::in, list(mer_type)::in, list(mer_type)::in, list(mer_mode)::in, pred_or_func::in, code_model::in, prog_context::in, bool::in, int::in, list(mlds_rval)::out, list(mlds_lval)::out, list(mlds_type)::out, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_arg_list(VarNames, VarLvals, CallerTypes, CalleeTypes, Modes, @@ -640,7 +640,7 @@ ml_gen_arg_list(VarNames, VarLvals, CallerTypes, CalleeTypes, Modes, ; ArgMode = top_unused ) -> - % Exclude arguments of type io__state etc. + % Exclude arguments of type io.state etc. % Also exclude those with arg_mode `top_unused'. InputRvals = InputRvals1, OutputLvals = OutputLvals1, @@ -654,7 +654,7 @@ ml_gen_arg_list(VarNames, VarLvals, CallerTypes, CalleeTypes, Modes, ( is_dummy_argument_type(ModuleInfo, CallerType) -> % The variable may not have been declared, so we need to % generate a dummy value for it. Using `0' here is more - % efficient than using private_builtin__dummy_var, which is + % efficient than using private_builtin.dummy_var, which is % what ml_gen_var will have generated for this variable. VarRval = const(int_const(0)) ; @@ -739,13 +739,13 @@ ml_gen_box_or_unbox_rval(SourceType, DestType, BoxPolicy, VarRval, ArgRval, ml_gen_type(!.Info, SourceType, MLDS_SourceType), ArgRval = unop(box(MLDS_SourceType), VarRval) ; - % If converting to float, cast to mlds__generic_type and then unbox. + % If converting to float, cast to mlds_generic_type and then unbox. DestType = builtin(float), SourceType \= builtin(float) -> ml_gen_type(!.Info, DestType, MLDS_DestType), ArgRval = unop(unbox(MLDS_DestType), - unop(cast(mlds__generic_type), VarRval)) + unop(cast(mlds_generic_type), VarRval)) ; % If converting from float, box and then cast the result. SourceType = builtin(float), @@ -777,7 +777,7 @@ ml_gen_box_or_unbox_rval(SourceType, DestType, BoxPolicy, VarRval, ArgRval, % This is needed to handle construction/deconstruction unifications % for no_tag types. % - \+ type_unify(SourceType, DestType, [], map__init, _) + \+ type_unify(SourceType, DestType, [], map.init, _) -> ml_gen_type(!.Info, DestType, MLDS_DestType), ArgRval = unop(cast(MLDS_DestType), VarRval) @@ -818,9 +818,9 @@ ml_gen_box_or_unbox_lval(CallerType, CalleeType, BoxPolicy, VarLval, VarName, % used to construct the type_info. ml_gen_info_new_conv_var(ConvVarNum, !Info), - VarName = mlds__var_name(VarNameStr, MaybeNum), - ArgVarName = mlds__var_name( - string__format("conv%d_%s", [i(ConvVarNum), s(VarNameStr)]), + VarName = mlds_var_name(VarNameStr, MaybeNum), + ArgVarName = mlds_var_name( + string.format("conv%d_%s", [i(ConvVarNum), s(VarNameStr)]), MaybeNum), ml_gen_type(!.Info, CalleeType, MLDS_CalleeType), ( @@ -839,7 +839,7 @@ ml_gen_box_or_unbox_lval(CallerType, CalleeType, BoxPolicy, VarLval, VarName, ml_gen_maybe_gc_trace_code(ArgVarName, CalleeType, CallerType, Context, GC_TraceCode, !Info), ArgVarDecl = ml_gen_mlds_var_decl(var(ArgVarName), MLDS_CalleeType, - GC_TraceCode, mlds__make_context(Context)) + GC_TraceCode, mlds_make_context(Context)) ), ConvDecls = [ArgVarDecl], @@ -848,7 +848,7 @@ ml_gen_box_or_unbox_lval(CallerType, CalleeType, BoxPolicy, VarLval, VarName, ml_gen_info_get_module_info(!.Info, ModuleInfo), ( is_dummy_argument_type(ModuleInfo, CallerType) -> - % If it is a dummy argument type (e.g. io__state), + % If it is a dummy argument type (e.g. io.state), % then we don't need to bother assigning it. ConvInputStatements = [], ConvOutputStatements = [] @@ -887,7 +887,7 @@ ml_gen_builtin(PredId, ProcId, ArgVars, CodeModel, Context, Decls, Statements, predicate_module(ModuleInfo, PredId, ModuleName), predicate_name(ModuleInfo, PredId, PredName), ( - builtin_ops__translate_builtin(ModuleName, PredName, + builtin_ops.translate_builtin(ModuleName, PredName, ProcId, ArgLvals, SimpleCode0) -> SimpleCode = SimpleCode0 @@ -900,7 +900,7 @@ ml_gen_builtin(PredId, ProcId, ArgVars, CodeModel, Context, Decls, Statements, SimpleCode = assign(Lval, SimpleExpr), ( % We need to avoid generating assignments to dummy variables - % introduced for types such as io__state. + % introduced for types such as io.state. Lval = var(_VarName, VarType), VarType = mercury_type(ProgDataType, _, _), is_dummy_argument_type(ModuleInfo, ProgDataType) diff --git a/compiler/ml_closure_gen.m b/compiler/ml_closure_gen.m index be96213c5..900f28c24 100644 --- a/compiler/ml_closure_gen.m +++ b/compiler/ml_closure_gen.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_closure_gen. +:- module ml_backend.ml_closure_gen. :- interface. :- import_module hlds.hlds_goal. @@ -35,7 +35,7 @@ % :- pred ml_gen_closure(pred_id::in, proc_id::in, prog_var::in, prog_vars::in, list(uni_mode)::in, how_to_construct::in, prog_context::in, - mlds__defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % ml_gen_closure_wrapper(PredId, ProcId, Offset, NumClosureArgs, @@ -72,8 +72,8 @@ % instead, generate GC tracing code that gets the typeinfo from % the ArgNum-th entry in `type_params'. % -:- pred ml_gen_local_for_output_arg(var_name::in, mer_type::in, int::in, - prog_context::in, mlds__defn::out, +:- pred ml_gen_local_for_output_arg(mlds_var_name::in, mer_type::in, int::in, + prog_context::in, mlds_defn::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -133,24 +133,24 @@ ml_gen_closure(PredId, ProcId, Var, ArgVars, ArgModes, HowToConstruct, Context, % % ml_gen_closure_wrapper will insert the wrapper function in the % extra_defns field in the ml_gen_info; ml_gen_proc will extract it - % and will insert it before the mlds__defn for the current procedure. + % and will insert it before the mlds_defn for the current procedure. % - list__length(ArgVars, NumArgs), + list.length(ArgVars, NumArgs), ml_gen_closure_wrapper(PredId, ProcId, higher_order_proc_closure, NumArgs, Context, WrapperFuncRval0, WrapperFuncType0, !Info), % Compute the rval which holds the number of arguments NumArgsRval0 = const(int_const(NumArgs)), - NumArgsType0 = mlds__native_int_type, + NumArgsType0 = mlds_native_int_type, % Put all the extra arguments of the closure together % Note that we need to box these arguments. NumArgsRval = unop(box(NumArgsType0), NumArgsRval0), - NumArgsType = mlds__generic_type, + NumArgsType = mlds_generic_type, WrapperFuncRval = unop(box(WrapperFuncType0), WrapperFuncRval0), - WrapperFuncType = mlds__generic_type, + WrapperFuncType = mlds_generic_type, ClosureLayoutRval = unop(box(ClosureLayoutType0), ClosureLayoutRval0), - ClosureLayoutType = mlds__generic_type, + ClosureLayoutType = mlds_generic_type, ExtraArgRvals = [ClosureLayoutRval, WrapperFuncRval, NumArgsRval], ExtraArgTypes = [ClosureLayoutType, WrapperFuncType, NumArgsType], @@ -169,7 +169,7 @@ ml_gen_closure(PredId, ProcId, Var, ArgVars, ArgModes, HowToConstruct, Context, % in ml_gen_closure_layout (e.g. two definitions of the same % pseudo_type_info). To avoid generating invalid MLDS code, % we need to check for and eliminate any duplicate definitions here. - Decls = list__remove_dups(Decls1). + Decls = list.remove_dups(Decls1). % Generate a value for the closure layout struct. % See MR_Closure_Layout in ../runtime/mercury_ho_call.h. @@ -178,13 +178,13 @@ ml_gen_closure(PredId, ProcId, Var, ArgVars, ArgModes, HowToConstruct, Context, % any changes here may need to be reflected there, and vice versa. % :- pred ml_gen_closure_layout(pred_id::in, proc_id::in, prog_context::in, - mlds_rval::out, mlds_type::out, mlds__defns::out, + mlds_rval::out, mlds_type::out, mlds_defns::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_closure_layout(PredId, ProcId, Context, ClosureLayoutRval, ClosureLayoutType, ClosureLayoutDefns, !Info) :- ml_gen_info_get_module_info(!.Info, ModuleInfo), - continuation_info__generate_closure_layout(ModuleInfo, PredId, ProcId, + continuation_info.generate_closure_layout(ModuleInfo, PredId, ProcId, ClosureLayoutInfo), ml_gen_closure_proc_id(ModuleInfo, Context, InitProcId, ProcIdType, @@ -209,7 +209,7 @@ ml_gen_closure_layout(PredId, ProcId, Context, % XXX There's no way in C to properly represent this type, % since it is a struct that ends with a variable-length array. % For now we just treat the whole struct as an array. - ClosureLayoutType = mlds__array_type(mlds__generic_type), + ClosureLayoutType = mlds_array_type(mlds_generic_type), ClosureLayoutDefn = ml_gen_static_const_defn(Name, ClosureLayoutType, Access, Initializer, Context), ClosureLayoutDefns = ClosureProcIdDefns ++ TVarDefns ++ @@ -220,21 +220,21 @@ ml_gen_closure_layout(PredId, ProcId, Context, ClosureLayoutType)). :- pred ml_gen_closure_proc_id(module_info::in, prog_context::in, - mlds__initializer::out, mlds_type::out, mlds__defns::out) is det. + mlds_initializer::out, mlds_type::out, mlds_defns::out) is det. ml_gen_closure_proc_id(_ModuleInfo, _Context, InitProcId, ProcIdType, ClosureProcIdDefns) :- % XXX currently we don't fill in the ProcId field! InitProcId = init_obj(const(null(ProcIdType))), - ProcIdType = mlds__generic_type, + ProcIdType = mlds_generic_type, ClosureProcIdDefns = []. % module_info_get_name(ModuleInfo, ModuleName), -% term__context_file(Context, FileName), -% term__context_line(Context, LineNumber), +% term.context_file(Context, FileName), +% term.context_line(Context, LineNumber), % % XXX We don't have the GoalInfo here, % % so we can't compute the goal path correctly % % goal_info_get_goal_path(GoalInfo, GoalPath), -% % trace__path_to_string(GoalPath, GoalPathStr), +% % trace.path_to_string(GoalPath, GoalPathStr), % GoalPathStr = "", % % DataAddr = layout_addr( % % closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel)), @@ -244,25 +244,25 @@ ml_gen_closure_proc_id(_ModuleInfo, _Context, InitProcId, ProcIdType, % % ProcIdType = ... :- pred ml_stack_layout_construct_closure_args(module_info::in, - list(closure_arg_info)::in, list(mlds__initializer)::out, - list(mlds_type)::out, mlds__defns::out) is det. + list(closure_arg_info)::in, list(mlds_initializer)::out, + list(mlds_type)::out, mlds_defns::out) is det. ml_stack_layout_construct_closure_args(ModuleInfo, ClosureArgs, ClosureArgInits, ClosureArgTypes, Defns) :- - list__map_foldl(ml_stack_layout_construct_closure_arg_rval(ModuleInfo), + list.map_foldl(ml_stack_layout_construct_closure_arg_rval(ModuleInfo), ClosureArgs, ArgInitsAndTypes, [], Defns), - assoc_list__keys(ArgInitsAndTypes, ArgInits), - assoc_list__values(ArgInitsAndTypes, ArgTypes), - Length = list__length(ArgInits), + assoc_list.keys(ArgInitsAndTypes, ArgInits), + assoc_list.values(ArgInitsAndTypes, ArgTypes), + Length = list.length(ArgInits), LengthRval = const(int_const(Length)), - LengthType = mlds__native_int_type, + LengthType = mlds_native_int_type, CastLengthRval = unop(box(LengthType), LengthRval), ClosureArgInits = [init_obj(CastLengthRval) | ArgInits], ClosureArgTypes = [LengthType | ArgTypes]. :- pred ml_stack_layout_construct_closure_arg_rval(module_info::in, - closure_arg_info::in, pair(mlds__initializer, mlds_type)::out, - mlds__defns::in, mlds__defns::out) is det. + closure_arg_info::in, pair(mlds_initializer, mlds_type)::out, + mlds_defns::in, mlds_defns::out) is det. ml_stack_layout_construct_closure_arg_rval(ModuleInfo, ClosureArg, ArgInit - ArgType, !Defns) :- @@ -275,7 +275,7 @@ ml_stack_layout_construct_closure_arg_rval(ModuleInfo, ClosureArg, ExistQTvars = [], NumUnivQTvars = -1, - pseudo_type_info__construct_pseudo_type_info(Type, NumUnivQTvars, + pseudo_type_info.construct_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, PseudoTypeInfo), ml_gen_pseudo_type_info(ModuleInfo, PseudoTypeInfo, ArgRval, ArgType, !Defns), @@ -283,27 +283,27 @@ ml_stack_layout_construct_closure_arg_rval(ModuleInfo, ClosureArg, ArgInit = init_obj(CastArgRval). :- pred ml_gen_maybe_pseudo_type_info_defn(module_info::in, - rtti_maybe_pseudo_type_info::in, mlds__defns::in, mlds__defns::out) + rtti_maybe_pseudo_type_info::in, mlds_defns::in, mlds_defns::out) is det. ml_gen_maybe_pseudo_type_info_defn(ModuleInfo, MaybePTI, !Defns) :- ml_gen_maybe_pseudo_type_info(ModuleInfo, MaybePTI, _Rval, _Type, !Defns). :- pred ml_gen_pseudo_type_info_defn(module_info::in, - rtti_pseudo_type_info::in, mlds__defns::in, mlds__defns::out) is det. + rtti_pseudo_type_info::in, mlds_defns::in, mlds_defns::out) is det. ml_gen_pseudo_type_info_defn(ModuleInfo, PTI, !Defns) :- ml_gen_pseudo_type_info(ModuleInfo, PTI, _Rval, _Type, !Defns). :- pred ml_gen_type_info_defn(module_info::in, rtti_type_info::in, - mlds__defns::in, mlds__defns::out) is det. + mlds_defns::in, mlds_defns::out) is det. ml_gen_type_info_defn(ModuleInfo, TI, !Defns) :- ml_gen_type_info(ModuleInfo, TI, _Rval, _Type, !Defns). :- pred ml_gen_maybe_pseudo_type_info(module_info::in, rtti_maybe_pseudo_type_info::in, mlds_rval::out, mlds_type::out, - mlds__defns::in, mlds__defns::out) is det. + mlds_defns::in, mlds_defns::out) is det. ml_gen_maybe_pseudo_type_info(ModuleInfo, MaybePseudoTypeInfo, Rval, Type, !Defns) :- @@ -317,13 +317,13 @@ ml_gen_maybe_pseudo_type_info(ModuleInfo, MaybePseudoTypeInfo, Rval, Type, :- pred ml_gen_pseudo_type_info(module_info::in, rtti_pseudo_type_info::in, mlds_rval::out, mlds_type::out, - mlds__defns::in, mlds__defns::out) is det. + mlds_defns::in, mlds_defns::out) is det. ml_gen_pseudo_type_info(ModuleInfo, PseudoTypeInfo, Rval, Type, !Defns) :- ( PseudoTypeInfo = type_var(N) -> % Type variables are represented just as integers. Rval = const(int_const(N)), - Type = mlds__native_int_type + Type = mlds_native_int_type ; ( PseudoTypeInfo = plain_arity_zero_pseudo_type_info(RttiTypeCtor0) -> % For zero-arity types, we just generate a reference to the @@ -343,22 +343,22 @@ ml_gen_pseudo_type_info(ModuleInfo, PseudoTypeInfo, Rval, Type, !Defns) :- % rtti_data_list_to_mlds assumes that the result will be % at file scope, but here we're generating it as a local, % so we need to convert the access to `local'. - RttiDefns = list__map(convert_to_local, RttiDefns0), + RttiDefns = list.map(convert_to_local, RttiDefns0), !:Defns = RttiDefns ++ !.Defns, % Generate definitions of any type_infos and pseudo_type_infos % referenced by this pseudo_type_info. - list__foldl(ml_gen_maybe_pseudo_type_info_defn(ModuleInfo), + list.foldl(ml_gen_maybe_pseudo_type_info_defn(ModuleInfo), arg_maybe_pseudo_type_infos(PseudoTypeInfo), !Defns) ), MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName), Rval = const(data_addr_const(data_addr(MLDS_ModuleName, rtti(RttiId)))), - Type = mlds__rtti_type(item_type(RttiId)) + Type = mlds_rtti_type(item_type(RttiId)) ). :- pred ml_gen_type_info(module_info::in, rtti_type_info::in, mlds_rval::out, mlds_type::out, - mlds__defns::in, mlds__defns::out) is det. + mlds_defns::in, mlds_defns::out) is det. ml_gen_type_info(ModuleInfo, TypeInfo, Rval, Type, !Defns) :- ( TypeInfo = plain_arity_zero_type_info(RttiTypeCtor0) -> @@ -378,15 +378,15 @@ ml_gen_type_info(ModuleInfo, TypeInfo, Rval, Type, !Defns) :- % rtti_data_list_to_mlds assumes that the result will be at file scope, % but here we're generating it as a local, so we need to convert % the access to `local'. - RttiDefns = list__map(convert_to_local, RttiDefns0), + RttiDefns = list.map(convert_to_local, RttiDefns0), !:Defns = RttiDefns ++ !.Defns, % Generate definitions of any type_infos referenced by this type_info. - list__foldl(ml_gen_type_info_defn(ModuleInfo), + list.foldl(ml_gen_type_info_defn(ModuleInfo), arg_type_infos(TypeInfo), !Defns) ), MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName), Rval = const(data_addr_const(data_addr(MLDS_ModuleName, rtti(RttiId)))), - Type = mlds__rtti_type(item_type(RttiId)). + Type = mlds_rtti_type(item_type(RttiId)). :- func arg_maybe_pseudo_type_infos(rtti_pseudo_type_info) = list(rtti_maybe_pseudo_type_info). @@ -404,20 +404,20 @@ arg_type_infos(plain_arity_zero_type_info(_)) = []. arg_type_infos(plain_type_info(_TypeCtor, ArgTIs)) = ArgTIs. arg_type_infos(var_arity_type_info(_VarArityId, ArgTIs)) = ArgTIs. -:- func convert_to_local(mlds__defn) = mlds__defn. +:- func convert_to_local(mlds_defn) = mlds_defn. -convert_to_local(mlds__defn(Name, Context, Flags0, Body)) = - mlds__defn(Name, Context, Flags, Body) :- +convert_to_local(mlds_defn(Name, Context, Flags0, Body)) = + mlds_defn(Name, Context, Flags, Body) :- Flags = set_access(Flags0, local). :- pred ml_stack_layout_construct_tvar_vector(module_info::in, - mlds__var_name::in, prog_context::in, map(tvar, set(layout_locn))::in, - mlds_rval::out, mlds_type::out, mlds__defns::out) is det. + mlds_var_name::in, prog_context::in, map(tvar, set(layout_locn))::in, + mlds_rval::out, mlds_type::out, mlds_defns::out) is det. ml_stack_layout_construct_tvar_vector(ModuleInfo, TvarVectorName, Context, TVarLocnMap, MLDS_Rval, ArrayType, Defns) :- - ArrayType = mlds__array_type(mlds__native_int_type), - ( map__is_empty(TVarLocnMap) -> + ArrayType = mlds_array_type(mlds_native_int_type), + ( map.is_empty(TVarLocnMap) -> MLDS_Rval = const(null(ArrayType)), Defns = [] ; @@ -436,16 +436,16 @@ ml_stack_layout_construct_tvar_vector(ModuleInfo, TvarVectorName, Context, ). :- pred ml_stack_layout_construct_tvar_rvals(map(tvar, set(layout_locn))::in, - list(mlds__initializer)::out, list(mlds_type)::out) is det. + list(mlds_initializer)::out, list(mlds_type)::out) is det. ml_stack_layout_construct_tvar_rvals(TVarLocnMap, Vector, VectorTypes) :- - map__to_assoc_list(TVarLocnMap, TVarLocns), + map.to_assoc_list(TVarLocnMap, TVarLocns), ml_stack_layout_construct_type_param_locn_vector(TVarLocns, 1, TypeParamLocs), - list__length(TypeParamLocs, TypeParamsLength), + list.length(TypeParamLocs, TypeParamsLength), LengthRval = const(int_const(TypeParamsLength)), Vector = [init_obj(LengthRval) | TypeParamLocs], - VectorTypes = list__duplicate(TypeParamsLength + 1, mlds__native_int_type). + VectorTypes = list.duplicate(TypeParamsLength + 1, mlds_native_int_type). % Given a association list of type variables and their locations sorted % on the type variables, represent them in an array of location @@ -454,20 +454,20 @@ ml_stack_layout_construct_tvar_rvals(TVarLocnMap, Vector, VectorTypes) :- % :- pred ml_stack_layout_construct_type_param_locn_vector( assoc_list(tvar, set(layout_locn))::in, - int::in, list(mlds__initializer)::out) is det. + int::in, list(mlds_initializer)::out) is det. ml_stack_layout_construct_type_param_locn_vector([], _, []). ml_stack_layout_construct_type_param_locn_vector([TVar - Locns | TVarLocns], CurSlot, Vector) :- - term__var_to_int(TVar, TVarNum), + term.var_to_int(TVar, TVarNum), NextSlot = CurSlot + 1, ( TVarNum = CurSlot -> - ( set__remove_least(Locns, LeastLocn, _) -> + ( set.remove_least(Locns, LeastLocn, _) -> Locn = LeastLocn ; unexpected(this_file, "tvar has empty set of locations") ), - stack_layout__represent_locn_as_int(Locn, LocnAsInt), + stack_layout.represent_locn_as_int(Locn, LocnAsInt), Rval = const(int_const(LocnAsInt)), ml_stack_layout_construct_type_param_locn_vector(TVarLocns, NextSlot, VectorTail), @@ -670,7 +670,7 @@ ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumClosureArgs, proc_info_argmodes(ProcInfo, ProcArgModes), proc_info_interface_code_model(ProcInfo, CodeModel), proc_info_varset(ProcInfo, ProcVarSet), - ProcArity = list__length(ProcHeadVars), + ProcArity = list.length(ProcHeadVars), ProcHeadVarNames = ml_gen_var_names(ProcVarSet, ProcHeadVars), % allocate some fresh type variables to use as the Mercury types @@ -684,23 +684,23 @@ ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumClosureArgs, % First generate the declarations for the boxed arguments. ( - list__drop(NumClosureArgs, ProcHeadVars, WrapperHeadVars0), - list__drop(NumClosureArgs, ProcArgModes, WrapperArgModes0), - list__drop(NumClosureArgs, ProcArgTypes, WrapperArgTypes0), - list__drop(NumClosureArgs, ProcBoxedArgTypes, WrapperBoxedArgTypes0) + list.drop(NumClosureArgs, ProcHeadVars, WrapperHeadVars0), + list.drop(NumClosureArgs, ProcArgModes, WrapperArgModes0), + list.drop(NumClosureArgs, ProcArgTypes, WrapperArgTypes0), + list.drop(NumClosureArgs, ProcBoxedArgTypes, WrapperBoxedArgTypes0) -> WrapperHeadVars = WrapperHeadVars0, WrapperArgModes = WrapperArgModes0, WrapperArgTypes = WrapperArgTypes0, WrapperBoxedArgTypes = WrapperBoxedArgTypes0 ; - unexpected(this_file, "ml_gen_closure_wrapper: list__drop failed") + unexpected(this_file, "ml_gen_closure_wrapper: list.drop failed") ), WrapperHeadVarNames = ml_gen_wrapper_head_var_names(1, - list__length(WrapperHeadVars)), + list.length(WrapperHeadVars)), ml_gen_params(WrapperHeadVarNames, WrapperBoxedArgTypes, WrapperArgModes, PredOrFunc, CodeModel, WrapperParams0, !Info), - WrapperParams0 = mlds__func_params(WrapperArgs0, WrapperRetType), + WrapperParams0 = mlds_func_params(WrapperArgs0, WrapperRetType), % The GC handling for the wrapper arguments is wrong, because we don't have % type_infos for the type variables in WrapperBoxedArgTypes. We handle this % by just deleting it, since it turns out that it's not needed anyway. @@ -709,25 +709,25 @@ ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumClosureArgs, % function to when it calls the wrapped function, and garbage collection % can't occur in that time, since there are no allocations (only an % assignment to `closure_arg' and some unbox operations). - WrapperArgs1 = list__map(arg_delete_gc_trace_code, WrapperArgs0), + WrapperArgs1 = list.map(arg_delete_gc_trace_code, WrapperArgs0), % then insert the `closure_arg' parameter, if needed. ( ClosureKind = special_pred -> MaybeClosureA = no, WrapperArgs = WrapperArgs1 ; - ClosureArgType = mlds__generic_type, - ClosureArgName = mlds__var_name("closure_arg", no), - ClosureArgDeclType = list__det_head(ml_make_boxed_types(1)), + ClosureArgType = mlds_generic_type, + ClosureArgName = mlds_var_name("closure_arg", no), + ClosureArgDeclType = list.det_head(ml_make_boxed_types(1)), gen_closure_gc_trace_code(ClosureArgName, ClosureArgDeclType, ClosureKind, WrapperArgTypes, Purity, PredOrFunc, Context, ClosureArgGCTraceCode, !Info), - ClosureArg = mlds__argument(data(var(ClosureArgName)), + ClosureArg = mlds_argument(data(var(ClosureArgName)), ClosureArgType, ClosureArgGCTraceCode), MaybeClosureA = yes({ClosureArgType, ClosureArgName}), WrapperArgs = [ClosureArg | WrapperArgs1] ), - WrapperParams = mlds__func_params(WrapperArgs, WrapperRetType), + WrapperParams = mlds_func_params(WrapperArgs, WrapperRetType), % Also compute the lvals for the parameters, % and local declarations for any by-value output parameters. @@ -747,14 +747,14 @@ ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumClosureArgs, % #endif % closure = closure_arg; % - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), ( MaybeClosureA = yes({ClosureArgType1, ClosureArgName1}), - ClosureName = mlds__var_name("closure", no), - ClosureType = mlds__generic_type, + ClosureName = mlds_var_name("closure", no), + ClosureType = mlds_generic_type, % If we were to generate GC tracing code for the closure % pointer, it would look like this: - % ClosureDeclType = list__det_head(ml_make_boxed_types(1)), + % ClosureDeclType = list.det_head(ml_make_boxed_types(1)), % gen_closure_gc_trace_code(ClosureName, ClosureDeclType, % ClosureKind, WrapperArgTypes, Purity, % PredOrFunc, Context, ClosureGCTraceCode), @@ -781,15 +781,15 @@ ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumClosureArgs, % If the wrapper function is model_non, then set up the initial success % continuation; this is needed by ml_gen_call which we call below. ( CodeModel = model_non -> - globals__lookup_bool_option(Globals, nondet_copy_out, NondetCopyOut), + globals.lookup_bool_option(Globals, nondet_copy_out, NondetCopyOut), ( NondetCopyOut = yes, - map__from_corresponding_lists(WrapperHeadVarLvals, + map.from_corresponding_lists(WrapperHeadVarLvals, WrapperBoxedArgTypes, WrapperBoxedVarTypes), WrapperOutputLvals = select_output_vars(ModuleInfo, WrapperHeadVarLvals, WrapperArgModes, WrapperBoxedVarTypes), - WrapperOutputTypes = map__apply_to_list(WrapperOutputLvals, + WrapperOutputTypes = map.apply_to_list(WrapperOutputLvals, WrapperBoxedVarTypes), ml_initial_cont(!.Info, WrapperOutputLvals, WrapperOutputTypes, InitialCont) @@ -837,7 +837,7 @@ ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumClosureArgs, MaybeClosureC = no, ClosureArgLvals = [] ), - CallLvals = list__append(ClosureArgLvals, WrapperHeadVarLvals), + CallLvals = list.append(ClosureArgLvals, WrapperHeadVarLvals), ml_gen_call(PredId, ProcId, ProcHeadVarNames, CallLvals, ProcBoxedArgTypes, CodeModel, Context, yes, Decls0, Statements0, !Info), @@ -869,7 +869,7 @@ ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumClosureArgs, module_info_get_globals(ModuleInfo, Globals), ( MaybeClosureA = yes({ClosureArgType2, ClosureArgName2}), - globals__get_gc_method(Globals, accurate) + globals.get_gc_method(Globals, accurate) -> ml_gen_closure_wrapper_gc_decls(ClosureKind, ClosureArgName2, ClosureArgType2, PredId, ProcId, Context, GC_Decls, !Info) @@ -896,21 +896,21 @@ ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumClosureArgs, WrapperFuncRval, !Info), ml_gen_wrapper_func(WrapperFuncName, WrapperParams, Context, WrapperFuncBody, WrapperFunc, !Info), - WrapperFuncType = mlds__func_type(WrapperParams), + WrapperFuncType = mlds_func_type(WrapperParams), ml_gen_info_add_extra_defn(WrapperFunc, !Info). -:- func arg_delete_gc_trace_code(mlds__argument) = mlds__argument. +:- func arg_delete_gc_trace_code(mlds_argument) = mlds_argument. arg_delete_gc_trace_code(Argument0) = Argument :- - Argument0 = mlds__argument(Name, Type, _GCTraceCode), - Argument = mlds__argument(Name, Type, no). + Argument0 = mlds_argument(Name, Type, _GCTraceCode), + Argument = mlds_argument(Name, Type, no). % Generate the GC tracing code for `closure_arg' or `closure' % (see ml_gen_closure_wrapper above). % -:- pred gen_closure_gc_trace_code(mlds__var_name::in, mer_type::in, +:- pred gen_closure_gc_trace_code(mlds_var_name::in, mer_type::in, closure_kind::in, list(mer_type)::in, purity::in, pred_or_func::in, - prog_context::in, mlds__maybe_gc_trace_code::out, + prog_context::in, mlds_maybe_gc_trace_code::out, ml_gen_info::in, ml_gen_info::out) is det. gen_closure_gc_trace_code(ClosureName, ClosureDeclType, @@ -920,7 +920,7 @@ gen_closure_gc_trace_code(ClosureName, ClosureDeclType, % for the type variables in WrapperArgTypes; those type variables come from % the callee. But when copying closures, we don't care what the types of %% the not-yet-applied arguments are. So we can just use dummy values here. - HigherOrderArgTypes = list__duplicate(list__length(WrapperArgTypes), + HigherOrderArgTypes = list.duplicate(list.length(WrapperArgTypes), c_pointer_type), ( ClosureKind = higher_order_proc_closure, @@ -937,27 +937,27 @@ gen_closure_gc_trace_code(ClosureName, ClosureDeclType, ml_gen_maybe_gc_trace_code(ClosureName, ClosureDeclType, ClosureActualType, Context, ClosureGCTraceCode, !Info). -:- pred ml_gen_wrapper_func(ml_label_func::in, mlds__func_params::in, - prog_context::in, statement::in, mlds__defn::out, +:- pred ml_gen_wrapper_func(ml_label_func::in, mlds_func_params::in, + prog_context::in, statement::in, mlds_defn::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_wrapper_func(FuncLabel, FuncParams, Context, Statement, Func, !Info) :- ml_gen_label_func(!.Info, FuncLabel, FuncParams, Context, Statement, Func0), - Func0 = mlds__defn(Name, Ctxt, DeclFlags0, Defn), + Func0 = mlds_defn(Name, Ctxt, DeclFlags0, Defn), DeclFlags1 = set_per_instance(DeclFlags0, one_copy), DeclFlags = set_access(DeclFlags1, private), - Func = mlds__defn(Name, Ctxt, DeclFlags, Defn). + Func = mlds_defn(Name, Ctxt, DeclFlags, Defn). -:- func ml_gen_wrapper_head_var_names(int, int) = list(mlds__var_name). +:- func ml_gen_wrapper_head_var_names(int, int) = list(mlds_var_name). ml_gen_wrapper_head_var_names(Num, Max) = Names :- ( Num > Max -> Names = [] ; - Name = string__format("wrapper_arg_%d", [i(Num)]), + Name = string.format("wrapper_arg_%d", [i(Num)]), Names1 = ml_gen_wrapper_head_var_names(Num + 1, Max), - Names = [mlds__var_name(Name, no) | Names1] + Names = [mlds_var_name(Name, no) | Names1] ). % ml_gen_wrapper_arg_lvals(HeadVarNames, Types, ArgModes, PredOrFunc, @@ -967,9 +967,9 @@ ml_gen_wrapper_head_var_names(Num, Max) = Names :- % modes. Also generate local definitions for output variables, if those % output variables will be copied out, rather than passed by reference. % -:- pred ml_gen_wrapper_arg_lvals(list(var_name)::in, list(mer_type)::in, +:- pred ml_gen_wrapper_arg_lvals(list(mlds_var_name)::in, list(mer_type)::in, list(mer_mode)::in, pred_or_func::in, code_model::in, prog_context::in, - int::in, list(mlds__defn)::out, list(mlds_lval)::out, + int::in, list(mlds_defn)::out, list(mlds_lval)::out, list(mlds_lval)::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_wrapper_arg_lvals(Names, Types, Modes, PredOrFunc, CodeModel, Context, @@ -1011,7 +1011,7 @@ ml_gen_wrapper_arg_lvals(Names, Types, Modes, PredOrFunc, CodeModel, Context, CodeModel = model_det, ArgMode = top_out, Types1 = [], - \+ type_util__is_dummy_argument_type(ModuleInfo, Type) + \+ type_util.is_dummy_argument_type(ModuleInfo, Type) ) -> % Output arguments are copied out, so we need to generate @@ -1055,29 +1055,29 @@ ml_gen_wrapper_arg_lvals(Names, Types, Modes, PredOrFunc, CodeModel, Context, % type_params = MR_materialize_typeclass_info_typeinfos( % closure_arg, closure_layout); % -:- pred ml_gen_closure_wrapper_gc_decls(closure_kind::in, mlds__var_name::in, +:- pred ml_gen_closure_wrapper_gc_decls(closure_kind::in, mlds_var_name::in, mlds_type::in, pred_id::in, proc_id::in, prog_context::in, - mlds__defns::out, ml_gen_info::in, ml_gen_info::out) is det. + mlds_defns::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_closure_wrapper_gc_decls(ClosureKind, ClosureArgName, ClosureArgType, PredId, ProcId, Context, GC_Decls, !Info) :- - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), ml_gen_var_lval(!.Info, ClosureArgName, ClosureArgType, ClosureArgLval), - ClosureLayoutPtrName = var_name("closure_layout_ptr", no), + ClosureLayoutPtrName = mlds_var_name("closure_layout_ptr", no), % This type is really `const MR_Closure_Layout *', but there's no easy % way to represent that in the MLDS; using MR_Box instead works fine. - ClosureLayoutPtrType = mlds__generic_type, + ClosureLayoutPtrType = mlds_generic_type, ClosureLayoutPtrDecl = ml_gen_mlds_var_decl(var(ClosureLayoutPtrName), ClosureLayoutPtrType, yes(ClosureLayoutPtrGCInit), MLDS_Context), ml_gen_var_lval(!.Info, ClosureLayoutPtrName, ClosureLayoutPtrType, ClosureLayoutPtrLval), - TypeParamsName = var_name("type_params", no), + TypeParamsName = mlds_var_name("type_params", no), % This type is really MR_TypeInfoParams, but there's no easy way to % represent that in the MLDS; using MR_Box instead works fine. - TypeParamsType = mlds__generic_type, + TypeParamsType = mlds_generic_type, TypeParamsDecl = ml_gen_mlds_var_decl(var(TypeParamsName), TypeParamsType, yes(TypeParamsGCInit), MLDS_Context), ml_gen_var_lval(!.Info, TypeParamsName, TypeParamsType, TypeParamsLval), @@ -1105,7 +1105,7 @@ ml_gen_closure_wrapper_gc_decls(ClosureKind, ClosureArgName, ClosureArgType, ClosureLayoutRval, ClosureLayoutType, ClosureLayoutDefns, !Info), ClosureLayoutPtrGCInit = statement( - mlds__block( + block( ClosureLayoutDefns, [statement(atomic( assign(ClosureLayoutPtrLval, @@ -1147,25 +1147,25 @@ ml_gen_local_for_output_arg(VarName, Type, ArgNum, Context, LocalVarDefn, % % MR_deallocate(allocated_memory_cells); % - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), - ClosureLayoutPtrName = var_name("closure_layout_ptr", no), + ClosureLayoutPtrName = mlds_var_name("closure_layout_ptr", no), % This type is really `const MR_Closure_Layout *', but there's no easy % way to represent that in the MLDS; using MR_Box instead works fine. - ClosureLayoutPtrType = mlds__generic_type, + ClosureLayoutPtrType = mlds_generic_type, ml_gen_var_lval(!.Info, ClosureLayoutPtrName, ClosureLayoutPtrType, ClosureLayoutPtrLval), - TypeParamsName = var_name("type_params", no), + TypeParamsName = mlds_var_name("type_params", no), % This type is really MR_TypeInfoParams, but there's no easy way to % represent that in the MLDS; using MR_Box instead works fine. - TypeParamsType = mlds__generic_type, + TypeParamsType = mlds_generic_type, ml_gen_var_lval(!.Info, TypeParamsName, TypeParamsType, TypeParamsLval), - TypeInfoName = var_name("type_info", no), + TypeInfoName = mlds_var_name("type_info", no), % The type for this should match the type of the first argument - % of private_builtin__gc_trace/1, i.e. `mutvar(T)', which is a no_tag type + % of private_builtin.gc_trace/1, i.e. `mutvar(T)', which is a no_tag type % whose representation is c_pointer. ml_gen_info_get_module_info(!.Info, ModuleInfo), TypeInfoMercuryType = c_pointer_type, @@ -1188,7 +1188,7 @@ ml_gen_local_for_output_arg(VarName, Type, ArgNum, Context, LocalVarDefn, target_code_input(lval(TypeParamsLval)), raw_target_code(", ((MR_Closure_Layout *)\n\t", []), target_code_input(lval(ClosureLayoutPtrLval)), - raw_target_code(string__format(")->" ++ + raw_target_code(string.format(")->" ++ "MR_closure_arg_pseudo_type_info[%d - 1],\n\t" ++ "NULL, NULL, &allocated_mem);\n", [i(ArgNum)]), []) @@ -1197,7 +1197,7 @@ ml_gen_local_for_output_arg(VarName, Type, ArgNum, Context, LocalVarDefn, raw_target_code("MR_deallocate(allocated_mem);\n", []), raw_target_code("}\n", []) ])), - GCTraceCode = mlds__block([TypeInfoDecl], [ + GCTraceCode = block([TypeInfoDecl], [ statement(MakeTypeInfoCode, MLDS_Context), CallTraceFuncCode, statement(DeallocateCode, MLDS_Context) @@ -1223,7 +1223,7 @@ ml_gen_closure_field_lvals(ClosureLval, Offset, ArgNum, NumClosureArgs, FieldId = offset(const(int_const(ArgNum + Offset))), % XXX These types might not be right. FieldLval = field(yes(0), lval(ClosureLval), FieldId, - mlds__generic_type, mlds__generic_type), + mlds_generic_type, mlds_generic_type), % Recursively handle the remaining fields. ml_gen_closure_field_lvals(ClosureLval, Offset, ArgNum + 1, NumClosureArgs, ClosureArgLvals0, !Info), diff --git a/compiler/ml_code_gen.m b/compiler/ml_code_gen.m index f86c4985c..4fb7b1584 100644 --- a/compiler/ml_code_gen.m +++ b/compiler/ml_code_gen.m @@ -160,7 +160,7 @@ % `try_commit' and `do_commit' instructions. The comments below show % the MLDS try_commit/do_commit version first, but for clarity I've also % included sample code using each of the three different techniques. -% This shows how the MLDS->target back-end can map mlds__commit_type, +% This shows how the MLDS->target back-end can map mlds_commit_type, % do_commit and try_commit into target language constructs. % % Note that if we're using GCC's __builtin_longjmp(), then it is important @@ -704,7 +704,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_code_gen. +:- module ml_backend.ml_code_gen. :- interface. :- import_module hlds.code_model. @@ -735,7 +735,7 @@ % and the other containing the generated statements. % :- pred ml_gen_goal(code_model::in, hlds_goal::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % ml_gen_wrap_goal(OuterCodeModel, InnerCodeModel, Context, @@ -754,7 +754,7 @@ % Generate declarations for a list of local variables. % :- pred ml_gen_local_var_decls(prog_varset::in, vartypes::in, - prog_context::in, prog_vars::in, mlds__defns::out, + prog_context::in, prog_vars::in, mlds_defns::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -810,39 +810,39 @@ ml_code_gen(ModuleInfo, MLDS, !IO) :- InitPreds, FinalPreds). :- pred ml_gen_foreign_code(module_info::in, - map(foreign_language, mlds__foreign_code)::out, + map(foreign_language, mlds_foreign_code)::out, io::di, io::uo) is det. ml_gen_foreign_code(ModuleInfo, AllForeignCode, !IO) :- module_info_get_foreign_decl(ModuleInfo, ForeignDecls), module_info_get_foreign_import_module(ModuleInfo, ForeignImports), module_info_get_foreign_body_code(ModuleInfo, ForeignBodys), - globals__io_get_backend_foreign_languages(BackendForeignLanguages, !IO), + globals.io_get_backend_foreign_languages(BackendForeignLanguages, !IO), - WantedForeignImports = list__condense( - list__map((func(L) = Imports :- - foreign__filter_imports(L, ForeignImports, Imports, _) + WantedForeignImports = list.condense( + list.map((func(L) = Imports :- + foreign.filter_imports(L, ForeignImports, Imports, _) ), BackendForeignLanguages)), - list__foldl(ml_gen_foreign_code_lang(ModuleInfo, ForeignDecls, + list.foldl(ml_gen_foreign_code_lang(ModuleInfo, ForeignDecls, ForeignBodys, WantedForeignImports), - BackendForeignLanguages, map__init, AllForeignCode). + BackendForeignLanguages, map.init, AllForeignCode). :- pred ml_gen_foreign_code_lang(module_info::in, foreign_decl_info::in, foreign_body_info::in, foreign_import_module_info::in, foreign_language::in, - map(foreign_language, mlds__foreign_code)::in, - map(foreign_language, mlds__foreign_code)::out) is det. + map(foreign_language, mlds_foreign_code)::in, + map(foreign_language, mlds_foreign_code)::out) is det. ml_gen_foreign_code_lang(ModuleInfo, ForeignDecls, ForeignBodys, WantedForeignImports, Lang, Map0, Map) :- - foreign__filter_decls(Lang, ForeignDecls, WantedForeignDecls, + foreign.filter_decls(Lang, ForeignDecls, WantedForeignDecls, _OtherForeignDecls), - foreign__filter_bodys(Lang, ForeignBodys, WantedForeignBodys, + foreign.filter_bodys(Lang, ForeignBodys, WantedForeignBodys, _OtherForeignBodys), ConvBody = (func(foreign_body_code(L, S, C)) = user_foreign_code(L, S, C)), - MLDSWantedForeignBodys = list__map(ConvBody, WantedForeignBodys), + MLDSWantedForeignBodys = list.map(ConvBody, WantedForeignBodys), % XXX Exports are only implemented for C and IL at the moment. ( ( Lang = c @@ -853,39 +853,39 @@ ml_gen_foreign_code_lang(ModuleInfo, ForeignDecls, ForeignBodys, ; MLDS_PragmaExports = [] ), - MLDS_ForeignCode = mlds__foreign_code(WantedForeignDecls, + MLDS_ForeignCode = mlds_foreign_code(WantedForeignDecls, WantedForeignImports, MLDSWantedForeignBodys, MLDS_PragmaExports), - map__det_insert(Map0, Lang, MLDS_ForeignCode, Map). + map.det_insert(Map0, Lang, MLDS_ForeignCode, Map). -:- pred ml_gen_imports(module_info::in, mlds__imports::out) is det. +:- pred ml_gen_imports(module_info::in, mlds_imports::out) is det. ml_gen_imports(ModuleInfo, MLDS_ImportList) :- % Determine all the mercury imports. % XXX This is overly conservative, i.e. we import more than we really need. module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), module_info_get_all_deps(ModuleInfo, AllImports0), % No module needs to import itself. module_info_get_name(ModuleInfo, ThisModule), - AllImports = set__delete(AllImports0, ThisModule), + AllImports = set.delete(AllImports0, ThisModule), P = (func(Name) = mercury_import(compiler_visible_interface, mercury_module_name_to_mlds(Name))), % For every foreign type determine the import needed to find % the declaration for that type. module_info_get_type_table(ModuleInfo, Types), - ForeignTypeImports = list__condense( - list__map(foreign_type_required_imports(Target), map__values(Types))), + ForeignTypeImports = list.condense( + list.map(foreign_type_required_imports(Target), map.values(Types))), MLDS_ImportList = ForeignTypeImports ++ - list__map(P, set__to_sorted_list(AllImports)). + list.map(P, set.to_sorted_list(AllImports)). :- func foreign_type_required_imports(compilation_target, hlds_type_defn) - = list(mlds__import). + = list(mlds_import). foreign_type_required_imports(c, _) = []. foreign_type_required_imports(il, TypeDefn) = Imports :- - hlds_data__get_type_defn_body(TypeDefn, Body), + hlds_data.get_type_defn_body(TypeDefn, Body), ( Body = foreign_type(foreign_type_body(MaybeIL, _MaybeC, _MaybeJava)) -> ( MaybeIL = yes(Data), @@ -903,35 +903,35 @@ foreign_type_required_imports(il, TypeDefn) = Imports :- foreign_type_required_imports(java, _) = []. foreign_type_required_imports(asm, _) = []. -:- pred ml_gen_defns(module_info::in, mlds__defns::out, io::di, io::uo) is det. +:- pred ml_gen_defns(module_info::in, mlds_defns::out, io::di, io::uo) is det. ml_gen_defns(ModuleInfo, Defns, !IO) :- ml_gen_types(ModuleInfo, TypeDefns, !IO), ml_gen_preds(ModuleInfo, PredDefns, !IO), - Defns = list__append(TypeDefns, PredDefns). + Defns = list.append(TypeDefns, PredDefns). %-----------------------------------------------------------------------------% % % For each pragma export declaration we associate with it the information % used to generate the function prototype for the MLDS entity. -:- pred ml_gen_pragma_export(module_info::in, list(mlds__pragma_export)::out) +:- pred ml_gen_pragma_export(module_info::in, list(mlds_pragma_export)::out) is det. ml_gen_pragma_export(ModuleInfo, MLDS_PragmaExports) :- module_info_get_pragma_exported_procs(ModuleInfo, PragmaExports), - list__map(ml_gen_pragma_export_proc(ModuleInfo), + list.map(ml_gen_pragma_export_proc(ModuleInfo), PragmaExports, MLDS_PragmaExports). :- pred ml_gen_pragma_export_proc(module_info::in, pragma_exported_proc::in, - mlds__pragma_export::out) is det. + mlds_pragma_export::out) is det. ml_gen_pragma_export_proc(ModuleInfo, pragma_exported_proc(PredId, ProcId, C_Name, ProgContext), Defn) :- ml_gen_proc_label(ModuleInfo, PredId, ProcId, Name, ModuleName), FuncParams = ml_gen_proc_params(ModuleInfo, PredId, ProcId), - MLDS_Context = mlds__make_context(ProgContext), + MLDS_Context = mlds_make_context(ProgContext), Defn = ml_pragma_export(C_Name, qual(ModuleName, module_qual, Name), FuncParams, MLDS_Context). @@ -943,21 +943,21 @@ ml_gen_pragma_export_proc(ModuleInfo, % Generate MLDS definitions for all the non-imported predicates % (and functions) in the HLDS. % -:- pred ml_gen_preds(module_info::in, mlds__defns::out, io::di, io::uo) is det. +:- pred ml_gen_preds(module_info::in, mlds_defns::out, io::di, io::uo) is det. ml_gen_preds(ModuleInfo, PredDefns, !IO) :- module_info_preds(ModuleInfo, PredTable), - map__keys(PredTable, PredIds), + map.keys(PredTable, PredIds), PredDefns0 = [], ml_gen_preds_2(ModuleInfo, PredIds, PredTable, PredDefns0, PredDefns, !IO). :- pred ml_gen_preds_2(module_info::in, list(pred_id)::in, pred_table::in, - mlds__defns::in, mlds__defns::out, io::di, io::uo) is det. + mlds_defns::in, mlds_defns::out, io::di, io::uo) is det. ml_gen_preds_2(ModuleInfo, PredIds0, PredTable, !Defns, !IO) :- ( PredIds0 = [PredId | PredIds], - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), pred_info_import_status(PredInfo, ImportStatus), ( ( @@ -983,7 +983,7 @@ ml_gen_preds_2(ModuleInfo, PredIds0, PredTable, !Defns, !IO) :- % of a given predicate (or function). % :- pred ml_gen_pred(module_info::in, pred_id::in, pred_info::in, - import_status::in, mlds__defns::in, mlds__defns::out, io::di, io::uo) + import_status::in, mlds_defns::in, mlds_defns::out, io::di, io::uo) is det. ml_gen_pred(ModuleInfo, PredId, PredInfo, ImportStatus, !Defns, !IO) :- @@ -1002,12 +1002,12 @@ ml_gen_pred(ModuleInfo, PredId, PredInfo, ImportStatus, !Defns, !IO) :- ). :- pred ml_gen_procs(list(proc_id)::in, module_info::in, pred_id::in, - pred_info::in, proc_table::in, mlds__defns::in, mlds__defns::out) is det. + pred_info::in, proc_table::in, mlds_defns::in, mlds_defns::out) is det. ml_gen_procs([], _, _, _, _, !Defns). ml_gen_procs([ProcId | ProcIds], ModuleInfo, PredId, PredInfo, ProcTable, !Defns) :- - map__lookup(ProcTable, ProcId, ProcInfo), + map.lookup(ProcTable, ProcId, ProcInfo), ml_gen_proc(ModuleInfo, PredId, ProcId, PredInfo, ProcInfo, !Defns), ml_gen_procs(ProcIds, ModuleInfo, PredId, PredInfo, ProcTable, !Defns). @@ -1019,20 +1019,20 @@ ml_gen_procs([ProcId | ProcIds], ModuleInfo, PredId, PredInfo, ProcTable, % Generate MLDS code for the specified procedure. % :- pred ml_gen_proc(module_info::in, pred_id::in, proc_id::in, pred_info::in, - proc_info::in, mlds__defns::in, mlds__defns::out) is det. + proc_info::in, mlds_defns::in, mlds_defns::out) is det. ml_gen_proc(ModuleInfo, PredId, ProcId, _PredInfo, ProcInfo, !Defns) :- proc_info_context(ProcInfo, Context), ml_gen_proc_label(ModuleInfo, PredId, ProcId, Name, _ModuleName), - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), DeclFlags = ml_gen_proc_decl_flags(ModuleInfo, PredId, ProcId), ml_gen_proc_defn(ModuleInfo, PredId, ProcId, ProcDefnBody, ExtraDefns), - ProcDefn = mlds__defn(Name, MLDS_Context, DeclFlags, ProcDefnBody), - !:Defns = list__append(ExtraDefns, [ProcDefn | !.Defns]), + ProcDefn = mlds_defn(Name, MLDS_Context, DeclFlags, ProcDefnBody), + !:Defns = list.append(ExtraDefns, [ProcDefn | !.Defns]), ml_gen_maybe_add_table_var(ModuleInfo, PredId, ProcId, ProcInfo, !Defns). :- pred ml_gen_maybe_add_table_var(module_info::in, pred_id::in, proc_id::in, - proc_info::in, mlds__defns::in, mlds__defns::out) is det. + proc_info::in, mlds_defns::in, mlds_defns::out) is det. ml_gen_maybe_add_table_var(ModuleInfo, PredId, ProcId, ProcInfo, !Defns) :- proc_info_eval_method(ProcInfo, EvalMethod), @@ -1041,12 +1041,12 @@ ml_gen_maybe_add_table_var(ModuleInfo, PredId, ProcId, ProcInfo, !Defns) :- -> ml_gen_pred_label(ModuleInfo, PredId, ProcId, PredLabel, _PredModule), Var = tabling_pointer(PredLabel - ProcId), - Type = mlds__generic_type, + Type = mlds_generic_type, Initializer = init_obj(const(null(Type))), proc_info_context(ProcInfo, Context), ( module_info_get_globals(ModuleInfo, Globals), - globals__get_gc_method(Globals, GC_Method), + globals.get_gc_method(Globals, GC_Method), GC_Method = accurate -> % XXX To handle this case properly, the GC would need to trace @@ -1061,7 +1061,7 @@ ml_gen_maybe_add_table_var(ModuleInfo, PredId, ProcId, ProcInfo, !Defns) :- GC_TraceCode = no ), TablePointerVarDefn = ml_gen_mlds_var_decl(Var, Type, Initializer, - GC_TraceCode, mlds__make_context(Context)), + GC_TraceCode, mlds_make_context(Context)), !:Defns = [TablePointerVarDefn | !.Defns] ; true @@ -1070,7 +1070,7 @@ ml_gen_maybe_add_table_var(ModuleInfo, PredId, ProcId, ProcInfo, !Defns) :- % Return the declaration flags appropriate for a procedure definition. % :- func ml_gen_proc_decl_flags(module_info, pred_id, proc_id) - = mlds__decl_flags. + = mlds_decl_flags. ml_gen_proc_decl_flags(ModuleInfo, PredId, ProcId) = DeclFlags :- module_info_pred_info(ModuleInfo, PredId, PredInfo), @@ -1090,7 +1090,7 @@ ml_gen_proc_decl_flags(ModuleInfo, PredId, ProcId) = DeclFlags :- % Generate an MLDS definition for the specified procedure. % :- pred ml_gen_proc_defn(module_info::in, pred_id::in, proc_id::in, - mlds__entity_defn::out, mlds__defns::out) is det. + mlds_entity_defn::out, mlds_defns::out) is det. ml_gen_proc_defn(ModuleInfo, PredId, ProcId, ProcDefnBody, ExtraDefns) :- module_info_pred_proc_info(ModuleInfo, PredId, ProcId, PredInfo, ProcInfo), @@ -1109,8 +1109,8 @@ ml_gen_proc_defn(ModuleInfo, PredId, ProcId, ProcDefnBody, ExtraDefns) :- Goal0 = GoalExpr - GoalInfo0, goal_info_get_code_gen_nonlocals(GoalInfo0, NonLocals0), - set__list_to_set(HeadVars, HeadVarsSet), - set__intersect(HeadVarsSet, NonLocals0, NonLocals), + set.list_to_set(HeadVars, HeadVarsSet), + set.intersect(HeadVarsSet, NonLocals0, NonLocals), goal_info_set_code_gen_nonlocals(NonLocals, GoalInfo0, GoalInfo), Goal = GoalExpr - GoalInfo, @@ -1161,13 +1161,13 @@ ml_gen_proc_defn(ModuleInfo, PredId, ProcId, ProcDefnBody, ExtraDefns) :- proc_info_vartypes(ProcInfo, VarTypes), % note that for headvars we must use the types from % the procedure interface, not from the procedure body - HeadVarTypes = map__from_corresponding_lists(HeadVars, + HeadVarTypes = map.from_corresponding_lists(HeadVars, ArgTypes), ml_gen_local_var_decls(VarSet, - map__overlay(VarTypes, HeadVarTypes), + map.overlay(VarTypes, HeadVarTypes), Context, CopiedOutputVars, OutputVarLocals, !Info) ), - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), MLDS_LocalVars = [ml_gen_succeeded_var_decl(MLDS_Context) | OutputVarLocals], modes_to_arg_modes(ModuleInfo, Modes, ArgTypes, ArgModes), @@ -1175,7 +1175,7 @@ ml_gen_proc_defn(ModuleInfo, PredId, ProcId, ProcDefnBody, ExtraDefns) :- CopiedOutputVars, Goal, Decls0, Statements, !Info), ml_gen_proc_params(PredId, ProcId, MLDS_Params, !Info), ml_gen_info_get_extra_defns(!.Info, ExtraDefns), - Decls = list__append(MLDS_LocalVars, Decls0), + Decls = list.append(MLDS_LocalVars, Decls0), Statement = ml_gen_block(Decls, Statements, Context), FunctionBody = defined_here(Statement) ) @@ -1186,7 +1186,7 @@ ml_gen_proc_defn(ModuleInfo, PredId, ProcId, ProcDefnBody, ExtraDefns) :- MLDS_Attributes = attributes_to_mlds_attributes(ModuleInfo, AttributeList), - ProcDefnBody = mlds__function(yes(proc(PredId, ProcId)), MLDS_Params, + ProcDefnBody = mlds_function(yes(proc(PredId, ProcId)), MLDS_Params, FunctionBody, MLDS_Attributes). % For model_det and model_semi procedures, figure out which output @@ -1199,7 +1199,7 @@ ml_gen_proc_defn(ModuleInfo, PredId, ProcId, ProcDefnBody, ExtraDefns) :- ml_det_copy_out_vars(ModuleInfo, CopiedOutputVars, !Info) :- ml_gen_info_get_byref_output_vars(!.Info, OutputVars), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, det_copy_out, DetCopyOut), + globals.lookup_bool_option(Globals, det_copy_out, DetCopyOut), ( % If --det-copy-out is enabled, all output variables are returned % by value, rather than passing them by reference. @@ -1215,7 +1215,7 @@ ml_det_copy_out_vars(ModuleInfo, CopiedOutputVars, !Info) :- ml_is_output_det_function(ModuleInfo, PredId, ProcId, ResultVar) -> CopiedOutputVars = [ResultVar], - list__delete_all(OutputVars, ResultVar, ByRefOutputVars) + list.delete_all(OutputVars, ResultVar, ByRefOutputVars) ; % Otherwise, all output vars are passed by reference. CopiedOutputVars = [], @@ -1234,7 +1234,7 @@ ml_det_copy_out_vars(ModuleInfo, CopiedOutputVars, !Info) :- ml_set_up_initial_succ_cont(ModuleInfo, NondetCopiedOutputVars, !Info) :- module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, nondet_copy_out, NondetCopyOut), + globals.lookup_bool_option(Globals, nondet_copy_out, NondetCopyOut), ( NondetCopyOut = yes, % For --nondet-copy-out, we generate local variables for the output @@ -1259,19 +1259,19 @@ ml_set_up_initial_succ_cont(ModuleInfo, NondetCopiedOutputVars, !Info) :- % local declarations for all the variables used in each sub-goal. % :- pred ml_gen_all_local_var_decls(hlds_goal::in, prog_varset::in, - vartypes::in, list(prog_var)::in, mlds__defns::out, + vartypes::in, list(prog_var)::in, mlds_defns::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_all_local_var_decls(Goal, VarSet, VarTypes, HeadVars, MLDS_LocalVars, !Info) :- Goal = _ - GoalInfo, goal_info_get_context(GoalInfo, Context), - goal_util__goal_vars(Goal, AllVarsSet), - set__delete_list(AllVarsSet, HeadVars, LocalVarsSet), - set__to_sorted_list(LocalVarsSet, LocalVars), + goal_util.goal_vars(Goal, AllVarsSet), + set.delete_list(AllVarsSet, HeadVars, LocalVarsSet), + set.to_sorted_list(LocalVarsSet, LocalVars), ml_gen_local_var_decls(VarSet, VarTypes, Context, LocalVars, MLDS_LocalVars0, !Info), - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), MLDS_SucceededVar = ml_gen_succeeded_var_decl(MLDS_Context), MLDS_LocalVars = [MLDS_SucceededVar | MLDS_LocalVars0]. @@ -1280,7 +1280,7 @@ ml_gen_all_local_var_decls(Goal, VarSet, VarTypes, HeadVars, MLDS_LocalVars, ml_gen_local_var_decls(_VarSet, _VarTypes, _Context, [], [], !Info). ml_gen_local_var_decls(VarSet, VarTypes, Context, [Var | Vars], Defns, !Info) :- - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ml_gen_info_get_module_info(!.Info, ModuleInfo), ( is_dummy_argument_type(ModuleInfo, Type) -> % no declaration needed for this variable @@ -1296,7 +1296,7 @@ ml_gen_local_var_decls(VarSet, VarTypes, Context, [Var | Vars], Defns, % :- pred ml_gen_proc_body(code_model::in, list(prog_var)::in, list(mer_type)::in, list(arg_mode)::in, list(prog_var)::in, - hlds_goal::in, mlds__defns::out, statements::out, + hlds_goal::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_proc_body(CodeModel, HeadVars, ArgTypes, ArgModes, CopiedOutputVars, @@ -1333,7 +1333,7 @@ ml_gen_proc_body(CodeModel, HeadVars, ArgTypes, ArgModes, CopiedOutputVars, Info0::in, Info::out) is det :- ml_gen_success(CodeModel, Context, SuccStatements, Info0, Info), NewDecls = [], - NewStatements = list__append(ConvOutputStatements, SuccStatements) + NewStatements = ConvOutputStatements ++ SuccStatements ), ml_combine_conj(CodeModel, Context, DoGenGoal, DoConvOutputs, Decls0, Statements0, !Info), @@ -1353,7 +1353,7 @@ ml_gen_proc_body(CodeModel, HeadVars, ArgTypes, ArgModes, CopiedOutputVars, % :- pred ml_gen_convert_headvars(list(prog_var)::in, list(mer_type)::in, list(arg_mode)::in, list(prog_var)::in, prog_context::in, - mlds__defns::out, statements::out, statements::out, + mlds_defns::out, statements::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_convert_headvars(Vars, HeadTypes, ArgModes, CopiedOutputVars, Context, @@ -1381,10 +1381,10 @@ ml_gen_convert_headvars(Vars, HeadTypes, ArgModes, CopiedOutputVars, Context, InputStatements, OutputStatements, !Info) ; % Check whether HeadType is the same as BodyType - % (modulo the term__contexts). If so, no conversion is needed. - map__init(Subst0), + % (modulo the term.contexts). If so, no conversion is needed. + map.init(Subst0), type_unify(HeadType, BodyType, [], Subst0, Subst), - map__is_empty(Subst) + map.is_empty(Subst) -> ml_gen_convert_headvars(Vars1, HeadTypes1, ArgModes1, CopiedOutputVars, Context, Decls, @@ -1413,8 +1413,8 @@ ml_gen_convert_headvars(Vars, HeadTypes, ArgModes, CopiedOutputVars, Context, % Add the code to convert this input or output. ml_gen_info_get_byref_output_vars(!.Info, ByRefOutputVars), ( - ( list__member(Var, ByRefOutputVars) - ; list__member(Var, CopiedOutputVars) + ( list.member(Var, ByRefOutputVars) + ; list.member(Var, CopiedOutputVars) ) -> InputStatements = InputStatements1, @@ -1423,7 +1423,7 @@ ml_gen_convert_headvars(Vars, HeadTypes, ArgModes, CopiedOutputVars, Context, InputStatements = ConvInputStatements ++ InputStatements1, OutputStatements = OutputStatements1 ), - list__append(ConvDecls, Decls1, Decls) + Decls = ConvDecls ++ Decls1 ) ; unexpected(this_file, "ml_gen_convert_headvars: length mismatch") @@ -1463,8 +1463,8 @@ ml_gen_goal(CodeModel, Goal, Decls, Statements, !Info) :- Locals = goal_local_vars(Goal), SubGoalLocals = union_of_direct_subgoal_locals(Goal), - set__difference(Locals, SubGoalLocals, VarsToDeclareHere), - set__to_sorted_list(VarsToDeclareHere, VarsList0), + set.difference(Locals, SubGoalLocals, VarsToDeclareHere), + set.to_sorted_list(VarsToDeclareHere, VarsList0), ml_gen_info_get_varset(!.Info, VarSet), ml_gen_info_get_var_types(!.Info, VarTypes), VarsList = put_typeinfo_vars_first(VarsList0, VarTypes), @@ -1491,17 +1491,17 @@ ml_gen_goal(CodeModel, Goal, Decls, Statements, !Info) :- goal_local_vars(Goal) = LocalVars :- % Find all the variables in the goal. - goal_util__goal_vars(Goal, GoalVars), + goal_util.goal_vars(Goal, GoalVars), % Delete the non-locals. Goal = _ - GoalInfo, goal_info_get_code_gen_nonlocals(GoalInfo, NonLocalVars), - set__difference(GoalVars, NonLocalVars, LocalVars). + set.difference(GoalVars, NonLocalVars, LocalVars). :- func union_of_direct_subgoal_locals(hlds_goal) = set(prog_var). union_of_direct_subgoal_locals(Goal - _GoalInfo) = UnionOfSubGoalLocals :- promise_equivalent_solutions [UnionOfSubGoalLocals] ( - set__init(EmptySet), + set.init(EmptySet), unsorted_aggregate(direct_subgoal(Goal), union_subgoal_locals, EmptySet, UnionOfSubGoalLocals) ). @@ -1511,7 +1511,7 @@ union_of_direct_subgoal_locals(Goal - _GoalInfo) = UnionOfSubGoalLocals :- union_subgoal_locals(SubGoal, UnionOfSubGoalLocals0, UnionOfSubGoalLocals) :- SubGoalLocals = goal_local_vars(SubGoal), - set__union(UnionOfSubGoalLocals0, SubGoalLocals, UnionOfSubGoalLocals). + set.union(UnionOfSubGoalLocals0, SubGoalLocals, UnionOfSubGoalLocals). % If the inner and outer code models are equal, we don't need to do % anything special. @@ -1533,7 +1533,7 @@ ml_gen_wrap_goal(model_semi, model_det, Context, !Statements, !Info) :- % succeeded = MR_TRUE % ml_gen_set_success(!.Info, const(true), Context, SetSuccessTrue), - !:Statements = list__append(!.Statements, [SetSuccessTrue]). + !:Statements = !.Statements ++ [SetSuccessTrue]. ml_gen_wrap_goal(model_non, model_det, Context, !Statements, !Info) :- % @@ -1544,7 +1544,7 @@ ml_gen_wrap_goal(model_non, model_det, Context, !Statements, !Info) :- % SUCCEED() % ml_gen_call_current_success_cont(Context, CallCont, !Info), - !:Statements = list__append(!.Statements, [CallCont]). + !:Statements = !.Statements ++ [CallCont]. ml_gen_wrap_goal(model_non, model_semi, Context, !Statements, !Info) :- % @@ -1559,8 +1559,8 @@ ml_gen_wrap_goal(model_non, model_semi, Context, !Statements, !Info) :- ml_gen_test_success(!.Info, Succeeded), ml_gen_call_current_success_cont(Context, CallCont, !Info), IfStmt = if_then_else(Succeeded, CallCont, no), - IfStatement = statement(IfStmt, mlds__make_context(Context)), - !:Statements = list__append(!.Statements, [IfStatement]). + IfStatement = statement(IfStmt, mlds_make_context(Context)), + !:Statements = !.Statements ++ [IfStatement]. % If the inner code model is less precise than the outer code model, % then simplify.m is supposed to wrap the goal inside a `some' @@ -1579,7 +1579,7 @@ ml_gen_wrap_goal(model_semi, model_non, _, _, _, !Info) :- % Generate code for a commit. % :- pred ml_gen_commit(hlds_goal::in, code_model::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_commit(Goal, CodeModel, Context, Decls, Statements, !Info) :- @@ -1635,11 +1635,11 @@ ml_gen_commit(Goal, CodeModel, Context, Decls, Statements, !Info) :- ml_gen_new_func_label(no, SuccessFuncLabel, SuccessFuncLabelRval, !Info), % push nesting level - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), ml_gen_info_new_commit_label(CommitLabelNum, !Info), - CommitRef = mlds__var_name(string__format("commit_%d", + CommitRef = mlds_var_name(string.format("commit_%d", [i(CommitLabelNum)]), no), - ml_gen_var_lval(!.Info, CommitRef, mlds__commit_type, CommitRefLval), + ml_gen_var_lval(!.Info, CommitRef, mlds_commit_type, CommitRefLval), CommitRefDecl = ml_gen_commit_var_decl(MLDS_Context, CommitRef), DoCommitStmt = do_commit(lval(CommitRefLval)), DoCommitStatement = statement(DoCommitStmt, MLDS_Context), @@ -1652,7 +1652,7 @@ ml_gen_commit(Goal, CodeModel, Context, Decls, Statements, !Info) :- ml_gen_info_push_success_cont(SuccessCont, !Info), ml_gen_goal(model_non, Goal, GoalDecls, GoalStatements, !Info), % Hoist any static constant declarations for Goal out to the top level. - list__filter(ml_decl_is_static_const, GoalDecls, + list.filter(ml_decl_is_static_const, GoalDecls, GoalStaticDecls, GoalOtherDecls), GoalStatement = ml_gen_block(GoalOtherDecls, GoalStatements, GoalContext), @@ -1661,7 +1661,7 @@ ml_gen_commit(Goal, CodeModel, Context, Decls, Statements, !Info) :- ml_gen_set_success(!.Info, const(true), Context, SetSuccessTrue), TryCommitStmt = try_commit(CommitRefLval, ml_gen_block([], [GoalStatement, SetSuccessFalse], Context), - ml_gen_block([], list__append(CopyLocalsToOutputArgs, + ml_gen_block([], list.append(CopyLocalsToOutputArgs, [SetSuccessTrue]), Context)), TryCommitStatement = statement(TryCommitStmt, MLDS_Context), CommitFuncLocalDecls = [CommitRefDecl, SuccessFunc | GoalStaticDecls], @@ -1712,11 +1712,11 @@ ml_gen_commit(Goal, CodeModel, Context, Decls, Statements, !Info) :- ml_gen_new_func_label(no, SuccessFuncLabel, SuccessFuncLabelRval, !Info), % push nesting level - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), ml_gen_info_new_commit_label(CommitLabelNum, !Info), - CommitRef = mlds__var_name( - string__format("commit_%d", [i(CommitLabelNum)]), no), - ml_gen_var_lval(!.Info, CommitRef, mlds__commit_type, CommitRefLval), + CommitRef = mlds_var_name( + string.format("commit_%d", [i(CommitLabelNum)]), no), + ml_gen_var_lval(!.Info, CommitRef, mlds_commit_type, CommitRefLval), CommitRefDecl = ml_gen_commit_var_decl(MLDS_Context, CommitRef), DoCommitStmt = do_commit(lval(CommitRefLval)), DoCommitStatement = statement(DoCommitStmt, MLDS_Context), @@ -1729,7 +1729,7 @@ ml_gen_commit(Goal, CodeModel, Context, Decls, Statements, !Info) :- ml_gen_info_push_success_cont(SuccessCont, !Info), ml_gen_goal(model_non, Goal, GoalDecls, GoalStatements, !Info), % Hoist any static constant declarations for Goal out to the top level. - list__filter(ml_decl_is_static_const, GoalDecls, + list.filter(ml_decl_is_static_const, GoalDecls, GoalStaticDecls, GoalOtherDecls), GoalStatement = ml_gen_block(GoalOtherDecls, GoalStatements, GoalContext), @@ -1780,8 +1780,8 @@ ml_gen_commit(Goal, CodeModel, Context, Decls, Statements, !Info) :- % But that would impose distributed fat and would make interoperability % difficult.] % -:- pred maybe_put_commit_in_own_func(mlds__defns::in, statements::in, - prog_context::in, mlds__defns::out, statements::out, +:- pred maybe_put_commit_in_own_func(mlds_defns::in, statements::in, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. maybe_put_commit_in_own_func(CommitFuncLocalDecls, TryCommitStatements, @@ -1810,14 +1810,14 @@ maybe_put_commit_in_own_func(CommitFuncLocalDecls, TryCommitStatements, UseNestedFuncs = no, ml_get_env_ptr(!.Info, EnvPtrRval), ArgRvals = [EnvPtrRval], - ArgTypes = [mlds__generic_env_ptr_type] + ArgTypes = [mlds_generic_env_ptr_type] ), RetTypes = [], - Signature = mlds__func_signature(ArgTypes, RetTypes), + Signature = mlds_func_signature(ArgTypes, RetTypes), CallKind = ordinary_call, CallStmt = call(Signature, CommitFuncLabelRval, no, ArgRvals, [], CallKind), - CallStatement = statement(CallStmt, mlds__make_context(Context)), + CallStatement = statement(CallStmt, mlds_make_context(Context)), % Package it all up. Statements = [CallStatement], Decls = [CommitFunc] @@ -1835,7 +1835,7 @@ maybe_put_commit_in_own_func(CommitFuncLocalDecls, TryCommitStatements, % we'll copy the local variables into the output arguments. % :- pred ml_gen_maybe_make_locals_for_output_args(hlds_goal_info::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, map(prog_var, mlds_lval)::out, ml_gen_info::in, ml_gen_info::out) is det. @@ -1843,15 +1843,15 @@ ml_gen_maybe_make_locals_for_output_args(GoalInfo, LocalVarDecls, CopyLocalsToOutputArgs, OrigVarLvalMap, !Info) :- ml_gen_info_get_var_lvals(!.Info, OrigVarLvalMap), ml_gen_info_get_globals(!.Info, Globals), - globals__lookup_bool_option(Globals, nondet_copy_out, NondetCopyOut), + globals.lookup_bool_option(Globals, nondet_copy_out, NondetCopyOut), ( NondetCopyOut = yes, goal_info_get_context(GoalInfo, Context), goal_info_get_nonlocals(GoalInfo, NonLocals), ml_gen_info_get_byref_output_vars(!.Info, ByRefOutputVars), - VarsToCopy = set__intersect(set__list_to_set(ByRefOutputVars), + VarsToCopy = set.intersect(set.list_to_set(ByRefOutputVars), NonLocals), - ml_gen_make_locals_for_output_args(set__to_sorted_list(VarsToCopy), + ml_gen_make_locals_for_output_args(set.to_sorted_list(VarsToCopy), Context, LocalVarDecls, CopyLocalsToOutputArgs, !Info) ; NondetCopyOut = no, @@ -1860,7 +1860,7 @@ ml_gen_maybe_make_locals_for_output_args(GoalInfo, LocalVarDecls, ). :- pred ml_gen_make_locals_for_output_args(list(prog_var)::in, - prog_context::in, mlds__defns::out, statements::out, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_make_locals_for_output_args([], _, [], [], !Info). @@ -1881,7 +1881,7 @@ ml_gen_make_locals_for_output_args([Var | Vars], Context, ). :- pred ml_gen_make_local_for_output_arg(prog_var::in, mer_type::in, - prog_context::in, mlds__defn::out, statement::out, + prog_context::in, mlds_defn::out, statement::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_make_local_for_output_arg(OutputVar, Type, Context, @@ -1891,14 +1891,14 @@ ml_gen_make_local_for_output_arg(OutputVar, Type, Context, OutputVarName = ml_gen_var_name(VarSet, OutputVar), % Generate a declaration for a corresponding local variable. - OutputVarName = mlds__var_name(OutputVarNameStr, MaybeNum), - LocalVarName = mlds__var_name( - string__append("local_", OutputVarNameStr), MaybeNum), + OutputVarName = mlds_var_name(OutputVarNameStr, MaybeNum), + LocalVarName = mlds_var_name( + string.append("local_", OutputVarNameStr), MaybeNum), ml_gen_type(!.Info, Type, MLDS_Type), ml_gen_maybe_gc_trace_code(LocalVarName, Type, Context, GC_TraceCode, !Info), LocalVarDefn = ml_gen_mlds_var_decl(var(LocalVarName), MLDS_Type, - GC_TraceCode, mlds__make_context(Context)), + GC_TraceCode, mlds_make_context(Context)), % Generate code to assign from the local var to the output var. ml_gen_var(!.Info, OutputVar, OutputVarLval), @@ -1913,15 +1913,15 @@ ml_gen_make_local_for_output_arg(OutputVar, Type, Context, % Generate the declaration for the `commit' variable. % -:- func ml_gen_commit_var_decl(mlds__context, mlds__var_name) = mlds__defn. +:- func ml_gen_commit_var_decl(mlds_context, mlds_var_name) = mlds_defn. ml_gen_commit_var_decl(Context, VarName) = - ml_gen_mlds_var_decl(var(VarName), mlds__commit_type, no, Context). + ml_gen_mlds_var_decl(var(VarName), mlds_commit_type, no, Context). % Generate MLDS code for the different kinds of HLDS goals. % :- pred ml_gen_goal_expr(hlds_goal_expr::in, code_model::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_goal_expr(switch(Var, CanFail, CasesList), CodeModel, Context, @@ -2006,7 +2006,7 @@ ml_gen_goal_expr(foreign_proc(Attributes, PredId, ProcId, Args, ExtraArgs, PragmaImpl = import(Name, HandleReturn, Vars, _Context), expect(unify(ExtraArgs, []), this_file, "ml_gen_goal_expr: extra args"), - ForeignCode = string__append_list([HandleReturn, " ", + ForeignCode = string.append_list([HandleReturn, " ", Name, "(", Vars, ");"]), ml_gen_ordinary_pragma_foreign_proc(CodeModel, Attributes, PredId, ProcId, Args, ExtraArgs, ForeignCode, @@ -2025,7 +2025,7 @@ ml_gen_goal_expr(shorthand(_), _, _, _, _, !Info) :- prog_context::in, string::in, maybe(prog_context)::in, string::in, maybe(prog_context)::in, string::in, maybe(prog_context)::in, string::in, maybe(prog_context)::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % For model_non pragma c_code, @@ -2098,13 +2098,13 @@ ml_gen_nondet_pragma_foreign_proc(CodeModel, Attributes, PredId, _ProcId, % Generate definitions of the FAIL, SUCCEED, SUCCEED_LAST, % and LOCALS macros % - string__append_list([ + string.append_list([ " #define FAIL (MR_done = MR_TRUE)\n", " #define SUCCEED (MR_succeeded = MR_TRUE)\n", " #define SUCCEED_LAST (MR_succeeded = MR_TRUE, MR_done = MR_TRUE)\n", " #define LOCALS (&MR_locals)\n" ], HashDefines), - string__append_list([ + string.append_list([ " #undef FAIL\n", " #undef SUCCEED\n", " #undef SUCCEED_LAST\n", @@ -2127,7 +2127,7 @@ ml_gen_nondet_pragma_foreign_proc(CodeModel, Attributes, PredId, _ProcId, ml_gen_hash_define_mr_proc_label(!.Info, HashDefine), % Put it all together. - Starting_C_Code = list__condense([ + Starting_C_Code = list.condense([ [raw_target_code("{\n", [])], HashDefine, ArgDeclsList, @@ -2156,7 +2156,7 @@ ml_gen_nondet_pragma_foreign_proc(CodeModel, Attributes, PredId, _ProcId, ]), ml_gen_info_get_module_info(!.Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( CodeModel = model_non -> % For IL code, we can't call continutations because there is no syntax @@ -2189,11 +2189,11 @@ ml_gen_nondet_pragma_foreign_proc(CodeModel, Attributes, PredId, _ProcId, ], Starting_C_Code_Stmt = inline_target_code(lang_C, Starting_C_Code), Starting_C_Code_Statement = statement( - atomic(Starting_C_Code_Stmt), mlds__make_context(Context)), + atomic(Starting_C_Code_Stmt), mlds_make_context(Context)), Ending_C_Code_Stmt = inline_target_code(lang_C, Ending_C_Code), Ending_C_Code_Statement = statement( - atomic(Ending_C_Code_Stmt), mlds__make_context(Context)), - Statements = list__condense([ + atomic(Ending_C_Code_Stmt), mlds_make_context(Context)), + Statements = list.condense([ [Starting_C_Code_Statement], ConvStatements, [CallCont, @@ -2204,7 +2204,7 @@ ml_gen_nondet_pragma_foreign_proc(CodeModel, Attributes, PredId, _ProcId, :- pred ml_gen_ordinary_pragma_foreign_proc(code_model::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, - prog_context::in, mlds__defns::out, statements::out, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_ordinary_pragma_foreign_proc(CodeModel, Attributes, PredId, ProcId, @@ -2269,7 +2269,7 @@ ml_gen_ordinary_pragma_foreign_proc(CodeModel, Attributes, PredId, ProcId, :- pred ml_gen_ordinary_pragma_java_proc(code_model::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, - prog_context::in, mlds__defns::out, statements::out, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_ordinary_pragma_java_proc(_CodeModel, Attributes, _PredId, _ProcId, @@ -2292,7 +2292,7 @@ ml_gen_ordinary_pragma_java_proc(_CodeModel, Attributes, _PredId, _ProcId, % Put it all together % XXX FIXME need to handle model_semi code here, % i.e. provide some equivalent to SUCCESS_INDICATOR. - Java_Code = list__condense([ + Java_Code = list.condense([ ArgDeclsList, AssignInputsList, [user_target_code(JavaCode, yes(Context), [])] @@ -2300,8 +2300,8 @@ ml_gen_ordinary_pragma_java_proc(_CodeModel, Attributes, _PredId, _ProcId, Java_Code_Stmt = inline_target_code(lang_java, Java_Code), Java_Code_Statement = statement( atomic(Java_Code_Stmt), - mlds__make_context(Context)), - Statements = list__condense([ + mlds_make_context(Context)), + Statements = list.condense([ [Java_Code_Statement], AssignOutputsList, ConvStatements @@ -2320,7 +2320,7 @@ ml_gen_ordinary_pragma_java_proc(_CodeModel, Attributes, _PredId, _ProcId, :- pred ml_gen_ordinary_pragma_managed_proc(ordinary_pragma_kind::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, - prog_context::in, mlds__defns::out, statements::out, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_ordinary_pragma_managed_proc(OrdinaryKind, Attributes, _PredId, _ProcId, @@ -2331,7 +2331,7 @@ ml_gen_ordinary_pragma_managed_proc(OrdinaryKind, Attributes, _PredId, _ProcId, "ml_gen_ordinary_pragma_managed_proc: extra args"), ForeignLang = foreign_language(Attributes), - MLDSContext = mlds__make_context(Context), + MLDSContext = mlds_make_context(Context), ml_gen_info_get_value_output_vars(!.Info, OutputVars), ml_gen_var_list(!.Info, OutputVars, OutputVarLvals), OutlineStmt = outline_foreign_proc(ForeignLang, OutlineArgs, @@ -2350,13 +2350,13 @@ ml_gen_ordinary_pragma_managed_proc(OrdinaryKind, Attributes, _PredId, _ProcId, OrdinaryKind = kind_semi, % If the code is semidet, we should copy SUCCESS_INDICATOR % out into "success". - SuccessIndicatorVarName = var_name("SUCCESS_INDICATOR", no), + SuccessIndicatorVarName = mlds_var_name("SUCCESS_INDICATOR", no), SuccessIndicatorDecl = ml_gen_mlds_var_decl( var(SuccessIndicatorVarName), - mlds__native_bool_type, + mlds_native_bool_type, no_initializer, no, MLDSContext), SuccessIndicatorLval = var(qual(MLDSModuleName, module_qual, - SuccessIndicatorVarName), mlds__native_bool_type), + SuccessIndicatorVarName), mlds_native_bool_type), SuccessIndicatorStatement = ml_gen_assign(SucceededLval, lval(SuccessIndicatorLval), Context), SuccessVarLocals = [SuccessIndicatorDecl], @@ -2388,7 +2388,7 @@ ml_gen_outline_args([Arg | Args], [OutlineArg | OutlineArgs], !Info) :- ml_gen_type(!.Info, OrigType, MldsType) ; BoxPolicy = always_boxed, - MldsType = mlds.generic_type + MldsType = mlds_generic_type ), ( MaybeVarMode = yes(ArgName - Mode), @@ -2413,7 +2413,7 @@ ml_gen_outline_args([Arg | Args], [OutlineArg | OutlineArgs], !Info) :- :- pred ml_gen_ordinary_pragma_il_proc(code_model::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, - prog_context::in, mlds__defns::out, statements::out, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_ordinary_pragma_il_proc(_CodeModel, Attributes, PredId, ProcId, @@ -2427,7 +2427,7 @@ ml_gen_ordinary_pragma_il_proc(_CodeModel, Attributes, PredId, ProcId, % XXX FIXME do we handle top_unused mode correctly? - MLDSContext = mlds__make_context(Context), + MLDSContext = mlds_make_context(Context), ml_gen_info_get_module_info(!.Info, ModuleInfo), module_info_pred_proc_info(ModuleInfo, PredId, ProcId, @@ -2449,22 +2449,22 @@ ml_gen_ordinary_pragma_il_proc(_CodeModel, Attributes, PredId, ProcId, % generate here with ml_gen_assign won't be type-correct. In general % you may need to box/unbox the arguments. - build_arg_map(Args, map__init, ArgMap), + build_arg_map(Args, map.init, ArgMap), % Generate statements to assign by-ref output arguments. - list__filter_map(ml_gen_pragma_il_proc_assign_output(ModuleInfo, + list.filter_map(ml_gen_pragma_il_proc_assign_output(ModuleInfo, MLDSModuleName, ArgMap, VarSet, Context, yes), ByRefOutputVars, ByRefAssignStatements), % Generate statements to assign copied output arguments. - list__filter_map(ml_gen_pragma_il_proc_assign_output(ModuleInfo, + list.filter_map(ml_gen_pragma_il_proc_assign_output(ModuleInfo, MLDSModuleName, ArgMap, VarSet, Context, no), CopiedOutputVars, CopiedOutputStatements), - ArgVars = list__map(foreign_arg_var, Args), + ArgVars = list.map(foreign_arg_var, Args), % Generate declarations for all the variables, and initializers for % input variables. - list__map(ml_gen_pragma_il_proc_var_decl_defn(ModuleInfo, + list.map(ml_gen_pragma_il_proc_var_decl_defn(ModuleInfo, MLDSModuleName, ArgMap, VarSet, MLDSContext, ByRefOutputVars, CopiedOutputVars), ArgVars, VarLocals), @@ -2478,7 +2478,7 @@ ml_gen_ordinary_pragma_il_proc(_CodeModel, Attributes, PredId, ProcId, ILCodeFragment = statement(atomic(OutlineStmt), MLDSContext), Statements = [statement(block(VarLocals, [ILCodeFragment] ++ ByRefAssignStatements ++ CopiedOutputStatements), - mlds__make_context(Context))], + mlds_make_context(Context))], Decls = []. :- pred build_arg_map(list(foreign_arg)::in, map(prog_var, foreign_arg)::in, @@ -2487,7 +2487,7 @@ ml_gen_ordinary_pragma_il_proc(_CodeModel, Attributes, PredId, ProcId, build_arg_map([], !ArgMap). build_arg_map([ForeignArg | ForeignArgs], !ArgMap) :- ForeignArg = foreign_arg(Var, _, _, _), - map__det_insert(!.ArgMap, Var, ForeignArg, !:ArgMap), + map.det_insert(!.ArgMap, Var, ForeignArg, !:ArgMap), build_arg_map(ForeignArgs, !ArgMap). :- pred ml_gen_pragma_il_proc_assign_output(module_info::in, @@ -2497,12 +2497,12 @@ build_arg_map([ForeignArg | ForeignArgs], !ArgMap) :- ml_gen_pragma_il_proc_assign_output(ModuleInfo, MLDSModuleName, ArgMap, VarSet, Context, IsByRef, Var, Statement) :- - map__lookup(ArgMap, Var, ForeignArg), + map.lookup(ArgMap, Var, ForeignArg), ForeignArg = foreign_arg(_, MaybeNameMode, Type, BoxPolicy), not is_dummy_argument_type(ModuleInfo, Type), ( BoxPolicy = always_boxed, - MLDSType = mlds.generic_type + MLDSType = mlds_generic_type ; BoxPolicy = native_if_possible, MLDSType = mercury_type_to_mlds_type(ModuleInfo, Type) @@ -2519,7 +2519,7 @@ ml_gen_pragma_il_proc_assign_output(ModuleInfo, MLDSModuleName, ArgMap, ), MaybeNameMode = yes(UserVarNameString - _), - NonMangledVarName = mlds__var_name(UserVarNameString, no), + NonMangledVarName = mlds_var_name(UserVarNameString, no), QualLocalVarName= qual(MLDSModuleName, module_qual, NonMangledVarName), LocalVarLval = var(QualLocalVarName, MLDSType), @@ -2527,24 +2527,24 @@ ml_gen_pragma_il_proc_assign_output(ModuleInfo, MLDSModuleName, ArgMap, :- pred ml_gen_pragma_il_proc_var_decl_defn(module_info::in, mlds_module_name::in, map(prog_var, foreign_arg)::in, prog_varset::in, - mlds__context::in, list(prog_var)::in, list(prog_var)::in, - prog_var::in, mlds__defn::out) is det. + mlds_context::in, list(prog_var)::in, list(prog_var)::in, + prog_var::in, mlds_defn::out) is det. ml_gen_pragma_il_proc_var_decl_defn(ModuleInfo, MLDSModuleName, ArgMap, VarSet, MLDSContext, ByRefOutputVars, CopiedOutputVars, Var, Defn) :- - map__lookup(ArgMap, Var, ForeignArg), + map.lookup(ArgMap, Var, ForeignArg), ForeignArg = foreign_arg(_, MaybeNameMode, Type, BoxPolicy), VarName = ml_gen_var_name(VarSet, Var), ( MaybeNameMode = yes(UserVarNameString - _), - NonMangledVarName = mlds__var_name(UserVarNameString, no) + NonMangledVarName = mlds_var_name(UserVarNameString, no) ; MaybeNameMode = no, sorry(this_file, "no variable name for var") ), ( BoxPolicy = always_boxed, - MLDSType0 = mlds.generic_type + MLDSType0 = mlds_generic_type ; BoxPolicy = native_if_possible, MLDSType0 = mercury_type_to_mlds_type(ModuleInfo, Type) @@ -2554,11 +2554,11 @@ ml_gen_pragma_il_proc_var_decl_defn(ModuleInfo, MLDSModuleName, ArgMap, VarSet, % used in any way that requires them to have a real value. ( is_dummy_argument_type(ModuleInfo, Type) -> Initializer = no_initializer, - MLDSType = mlds__native_int_type - ; list__member(Var, ByRefOutputVars) -> + MLDSType = mlds_native_int_type + ; list.member(Var, ByRefOutputVars) -> Initializer = no_initializer, MLDSType = MLDSType0 - ; list__member(Var, CopiedOutputVars) -> + ; list.member(Var, CopiedOutputVars) -> Initializer = no_initializer, MLDSType = MLDSType0 ; @@ -2634,7 +2634,7 @@ ml_gen_pragma_il_proc_var_decl_defn(ModuleInfo, MLDSModuleName, ArgMap, VarSet, :- pred ml_gen_ordinary_pragma_c_proc(ordinary_pragma_kind::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, - prog_context::in, mlds__defns::out, statements::out, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_ordinary_pragma_c_proc(OrdinaryKind, Attributes, PredId, _ProcId, @@ -2643,7 +2643,7 @@ ml_gen_ordinary_pragma_c_proc(OrdinaryKind, Attributes, PredId, _ProcId, Lang = foreign_language(Attributes), % Generate - list__append(OrigArgs, ExtraArgs, Args), + list.append(OrigArgs, ExtraArgs, Args), ml_gen_pragma_c_decls(!.Info, Lang, Args, ArgDeclsList), % Generate code to set the values of the input variables. @@ -2664,7 +2664,7 @@ ml_gen_ordinary_pragma_c_proc(OrdinaryKind, Attributes, PredId, _ProcId, % Put it all together. ( OrdinaryKind = kind_det, - Starting_C_Code = list__condense([ + Starting_C_Code = list.condense([ [raw_target_code("{\n", [])], HashDefine, ArgDeclsList, @@ -2686,7 +2686,7 @@ ml_gen_ordinary_pragma_c_proc(OrdinaryKind, Attributes, PredId, _ProcId, % SUCCESS_INDICATOR; the code we generate for CanSucceed = yes % would test an undefined value. ml_success_lval(!.Info, SucceededLval), - Starting_C_Code = list__condense([ + Starting_C_Code = list.condense([ [raw_target_code("{\n", [])], HashDefine, ArgDeclsList, @@ -2707,7 +2707,7 @@ ml_gen_ordinary_pragma_c_proc(OrdinaryKind, Attributes, PredId, _ProcId, ; OrdinaryKind = kind_semi, ml_success_lval(!.Info, SucceededLval), - Starting_C_Code = list__condense([ + Starting_C_Code = list.condense([ [raw_target_code("{\n", [])], HashDefine, ArgDeclsList, @@ -2733,10 +2733,10 @@ ml_gen_ordinary_pragma_c_proc(OrdinaryKind, Attributes, PredId, _ProcId, Starting_C_Code_Stmt = inline_target_code(lang_C, Starting_C_Code), Ending_C_Code_Stmt = inline_target_code(lang_C, Ending_C_Code), Starting_C_Code_Statement = statement( - atomic(Starting_C_Code_Stmt), mlds__make_context(Context)), + atomic(Starting_C_Code_Stmt), mlds_make_context(Context)), Ending_C_Code_Statement = statement(atomic(Ending_C_Code_Stmt), - mlds__make_context(Context)), - Statements = list__condense([ + mlds_make_context(Context)), + Statements = list.condense([ [Starting_C_Code_Statement], ConvStatements, [Ending_C_Code_Statement] @@ -2753,17 +2753,17 @@ ml_gen_obtain_release_global_lock(Info, ThreadSafe, PredId, ObtainLock, ReleaseLock) :- ml_gen_info_get_module_info(Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, parallel, Parallel), + globals.lookup_bool_option(Globals, parallel, Parallel), ( Parallel = yes, ThreadSafe = not_thread_safe -> module_info_pred_info(ModuleInfo, PredId, PredInfo), Name = pred_info_name(PredInfo), - c_util__quote_string(Name, MangledName), - string__append_list(["\tMR_OBTAIN_GLOBAL_LOCK(""", + c_util.quote_string(Name, MangledName), + string.append_list(["\tMR_OBTAIN_GLOBAL_LOCK(""", MangledName, """);\n"], ObtainLock), - string__append_list(["\tMR_RELEASE_GLOBAL_LOCK(""", + string.append_list(["\tMR_RELEASE_GLOBAL_LOCK(""", MangledName, """);\n"], ReleaseLock) ; ObtainLock = "", @@ -2832,9 +2832,9 @@ ml_gen_pragma_c_decl(Info, Lang, Arg, Decl) :- TypeString = "MR_Word" ; BoxPolicy = native_if_possible, - TypeString = foreign__to_type_string(Lang, ModuleInfo, Type) + TypeString = foreign.to_type_string(Lang, ModuleInfo, Type) ), - string__format("\t%s %s;\n", [s(TypeString), s(ArgName)], DeclString) + string.format("\t%s %s;\n", [s(TypeString), s(ArgName)], DeclString) ; % If the variable doesn't occur in the ArgNames list, % it can't be used, so we just ignore it. @@ -2856,7 +2856,7 @@ ml_gen_pragma_c_decl(Info, Lang, Arg, Decl) :- :- pred var_is_singleton(string::in) is semidet. var_is_singleton(Name) :- - string__first_char(Name, '_', _). + string.first_char(Name, '_', _). %-----------------------------------------------------------------------------% @@ -2868,9 +2868,9 @@ var_is_singleton(Name) :- ml_gen_info::in, ml_gen_info::out) is det. ml_gen_pragma_c_input_arg_list(Lang, ArgList, AssignInputs, !Info) :- - list__map_foldl(ml_gen_pragma_c_input_arg(Lang), ArgList, + list.map_foldl(ml_gen_pragma_c_input_arg(Lang), ArgList, AssignInputsList, !Info), - list__condense(AssignInputsList, AssignInputs). + list.condense(AssignInputsList, AssignInputs). % ml_gen_pragma_c_input_arg generates C code to assign the value of an % input arg for a `pragma foreign_proc' declaration. @@ -2907,7 +2907,7 @@ ml_gen_pragma_c_gen_input_arg(Lang, Var, ArgName, OrigType, BoxPolicy, ( is_dummy_argument_type(ModuleInfo, VarType) -> % The variable may not have been declared, so we need to generate % a dummy value for it. Using `0' here is more efficient than using - % private_builtin__dummy_var, which is what ml_gen_var will have + % private_builtin.dummy_var, which is what ml_gen_var will have % generated for this variable. ArgRval = const(int_const(0)) ; @@ -2917,9 +2917,9 @@ ml_gen_pragma_c_gen_input_arg(Lang, Var, ArgName, OrigType, BoxPolicy, % At this point we have an rval with the right type for *internal* use % in the code generated by the Mercury compiler's MLDS back-end. We need % to convert this to the appropriate type to use for the C interface. - ExportedType = foreign__to_exported_type(ModuleInfo, OrigType), - TypeString = foreign__to_type_string(Lang, ExportedType), - IsForeign = foreign__is_foreign_type(ExportedType), + ExportedType = foreign.to_exported_type(ModuleInfo, OrigType), + TypeString = foreign.to_type_string(Lang, ExportedType), + IsForeign = foreign.is_foreign_type(ExportedType), ( ( Lang = java, @@ -2931,20 +2931,20 @@ ml_gen_pragma_c_gen_input_arg(Lang, Var, ArgName, OrigType, BoxPolicy, ; Lang = c, IsForeign = yes(Assertions), - list__member(can_pass_as_mercury_type, Assertions), + list.member(can_pass_as_mercury_type, Assertions), MaybeCast = yes("(" ++ TypeString ++ ") ") ) -> % In the usual case, we can just use an assignment and perhaps a cast. module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, highlevel_data, HighLevelData), + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), ( HighLevelData = yes, % In general, the types used for the C interface are not the same % as the types used by --high-level-data, so we always use a cast % here. (Strictly speaking the cast is not needed for a few cases % like `int', but it doesn't do any harm.) - string__format("(%s)", [s(TypeString)], Cast) + string.format("(%s)", [s(TypeString)], Cast) ; HighLevelData = no, % For --no-high-level-data, we only need to use a cast is for @@ -2960,7 +2960,7 @@ ml_gen_pragma_c_gen_input_arg(Lang, Var, ArgName, OrigType, BoxPolicy, Cast = "" ) ), - string__format("\t%s = %s\n", [s(ArgName), s(Cast)], AssignToArgName), + string.format("\t%s = %s\n", [s(ArgName), s(Cast)], AssignToArgName), AssignInput = [ raw_target_code(AssignToArgName, []), target_code_input(ArgRval), @@ -2980,7 +2980,7 @@ ml_gen_pragma_c_gen_input_arg(Lang, Var, ArgName, OrigType, BoxPolicy, :- pred ml_gen_pragma_java_output_arg_list(foreign_language::in, list(foreign_arg)::in, prog_context::in, statements::out, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_pragma_java_output_arg_list(_, [], _, [], [], [], !Info). @@ -2999,7 +2999,7 @@ ml_gen_pragma_java_output_arg_list(Lang, [Java_Arg | Java_Args], Context, % :- pred ml_gen_pragma_java_output_arg(foreign_language::in, foreign_arg::in, prog_context::in, statements::out, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_pragma_java_output_arg(_Lang, ForeignArg, Context, AssignOutput, @@ -3017,7 +3017,7 @@ ml_gen_pragma_java_output_arg(_Lang, ForeignArg, Context, AssignOutput, ml_variable_type(!.Info, Var, VarType), ml_gen_var(!.Info, Var, VarLval), ml_gen_box_or_unbox_lval(VarType, OrigType, BoxPolicy, - VarLval, mlds__var_name(ArgName, no), Context, no, 0, + VarLval, mlds_var_name(ArgName, no), Context, no, 0, ArgLval, ConvDecls, _ConvInputStatements, ConvOutputStatements, !Info), % This is the MLDS type of the original argument, which we need to @@ -3027,13 +3027,13 @@ ml_gen_pragma_java_output_arg(_Lang, ForeignArg, Context, AssignOutput, % of the argument. module_info_get_name(ModuleInfo, ModuleName), MLDSModuleName = mercury_module_name_to_mlds(ModuleName), - NonMangledVarName = mlds__var_name(ArgName, no), + NonMangledVarName = mlds_var_name(ArgName, no), QualLocalVarName = qual(MLDSModuleName, module_qual, NonMangledVarName), % XXX MLDSType is the incorrect type for this variable. % It should have the Java foreign language representation % of that type. Unfortunately this is not easily expressed - % as an mlds__type. + % as an mlds_type. LocalVarLval = var(QualLocalVarName, MLDSType), % We cast this variable back to the corresponding % MLDS type before assigning it to the lval. @@ -3049,7 +3049,7 @@ ml_gen_pragma_java_output_arg(_Lang, ForeignArg, Context, AssignOutput, :- pred ml_gen_pragma_c_output_arg_list(foreign_language::in, list(foreign_arg)::in, prog_context::in, - list(target_code_component)::out, mlds__defns::out, + list(target_code_component)::out, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_pragma_c_output_arg_list(_, [], _, [], [], [], !Info). @@ -3059,16 +3059,16 @@ ml_gen_pragma_c_output_arg_list(Lang, [ForeignArg | ForeignArgs], Context, ConvDecls1, ConvStatements1, !Info), ml_gen_pragma_c_output_arg_list(Lang, ForeignArgs, Context, Components2, ConvDecls2, ConvStatements2, !Info), - Components = list__append(Components1, Components2), - ConvDecls = list__append(ConvDecls1, ConvDecls2), - ConvStatements = list__append(ConvStatements1, ConvStatements2). + Components = Components1 ++ Components2, + ConvDecls = ConvDecls1 ++ ConvDecls2, + ConvStatements = ConvStatements1 ++ ConvStatements2. % ml_gen_pragma_c_output_arg generates C code to assign the value of % an output arg for a `pragma foreign_proc' declaration. % :- pred ml_gen_pragma_c_output_arg(foreign_language::in, foreign_arg::in, prog_context::in, list(target_code_component)::out, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_pragma_c_output_arg(Lang, Arg, Context, AssignOutput, ConvDecls, @@ -3093,7 +3093,7 @@ ml_gen_pragma_c_output_arg(Lang, Arg, Context, AssignOutput, ConvDecls, :- pred ml_gen_pragma_c_gen_output_arg(foreign_language::in, prog_var::in, string::in, mer_type::in, box_policy::in, prog_context::in, - list(target_code_component)::out, mlds__defns::out, + list(target_code_component)::out, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_pragma_c_gen_output_arg(Lang, Var, ArgName, OrigType, BoxPolicy, @@ -3101,15 +3101,15 @@ ml_gen_pragma_c_gen_output_arg(Lang, Var, ArgName, OrigType, BoxPolicy, ml_variable_type(!.Info, Var, VarType), ml_gen_var(!.Info, Var, VarLval), ml_gen_box_or_unbox_lval(VarType, OrigType, BoxPolicy, VarLval, - mlds__var_name(ArgName, no), Context, no, 0, ArgLval, + mlds_var_name(ArgName, no), Context, no, 0, ArgLval, ConvDecls, _ConvInputStatements, ConvOutputStatements, !Info), % At this point we have an lval with the right type for *internal* use % in the code generated by the Mercury compiler's MLDS back-end. We need % to convert this to the appropriate type to use for the C interface. ml_gen_info_get_module_info(!.Info, ModuleInfo), - ExportedType = foreign__to_exported_type(ModuleInfo, OrigType), - TypeString = foreign__to_type_string(Lang, ExportedType), - IsForeign = foreign__is_foreign_type(ExportedType), + ExportedType = foreign.to_exported_type(ModuleInfo, OrigType), + TypeString = foreign.to_type_string(Lang, ExportedType), + IsForeign = foreign.is_foreign_type(ExportedType), ( ( Lang = java, @@ -3122,14 +3122,14 @@ ml_gen_pragma_c_gen_output_arg(Lang, Var, ArgName, OrigType, BoxPolicy, ; Lang = c, IsForeign = yes(Assertions), - list__member(can_pass_as_mercury_type, Assertions), + list.member(can_pass_as_mercury_type, Assertions), Cast = yes ) -> % In the usual case, we can just use an assignment, % perhaps with a cast. module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, highlevel_data, + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), ( HighLevelData = yes, @@ -3139,7 +3139,7 @@ ml_gen_pragma_c_gen_output_arg(Lang, Var, ArgName, OrigType, BoxPolicy, % like `int', but it doesn't do any harm.) Note that we can't % easily obtain the type string for the RHS of the assignment, % so instead we cast the LHS. - string__format("*(%s *)&", [s(TypeString)], LHS_Cast), + string.format("*(%s *)&", [s(TypeString)], LHS_Cast), RHS_Cast = "" ; HighLevelData = no, @@ -3157,9 +3157,9 @@ ml_gen_pragma_c_gen_output_arg(Lang, Var, ArgName, OrigType, BoxPolicy, ), LHS_Cast = "" ), - string__format(" = %s%s;\n", [s(RHS_Cast), s(ArgName)], + string.format(" = %s%s;\n", [s(RHS_Cast), s(ArgName)], AssignFromArgName), - string__format("\t%s\n", [s(LHS_Cast)], AssignTo), + string.format("\t%s\n", [s(LHS_Cast)], AssignTo), AssignOutput = [ raw_target_code(AssignTo, []), target_code_output(ArgLval), @@ -3181,7 +3181,7 @@ ml_gen_pragma_c_gen_output_arg(Lang, Var, ArgName, OrigType, BoxPolicy, % :- pred ml_gen_ite(code_model::in, hlds_goal::in, hlds_goal::in, hlds_goal::in, - prog_context::in, mlds__defns::out, statements::out, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_ite(CodeModel, Cond, Then, Else, Context, Decls, Statements, !Info) :- @@ -3218,7 +3218,7 @@ ml_gen_ite(CodeModel, Cond, Then, Else, Context, Decls, Statements, !Info) :- ml_gen_goal(CodeModel, Then, ThenStatement, !Info), ml_gen_goal(CodeModel, Else, ElseStatement, !Info), IfStmt = if_then_else(Succeeded, ThenStatement, yes(ElseStatement)), - IfStatement = statement(IfStmt, mlds__make_context(Context)), + IfStatement = statement(IfStmt, mlds_make_context(Context)), Decls = CondDecls, Statements = CondStatements ++ [IfStatement] ; @@ -3251,7 +3251,7 @@ ml_gen_ite(CodeModel, Cond, Then, Else, Context, Decls, Statements, !Info) :- % Generate the `cond_' var and the code to initialize it to false. ml_gen_info_new_cond_var(CondVar, !Info), - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), CondVarDecl = ml_gen_cond_var_decl(CondVar, MLDS_Context), ml_gen_set_cond_var(!.Info, CondVar, const(false), Context, SetCondFalse), @@ -3297,7 +3297,7 @@ ml_gen_ite(CodeModel, Cond, Then, Else, Context, Decls, Statements, !Info) :- % :- pred ml_gen_negation(hlds_goal::in, code_model::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_negation(Cond, CodeModel, Context, Decls, Statements, !Info) :- @@ -3327,7 +3327,7 @@ ml_gen_negation(Cond, CodeModel, Context, Decls, Statements, !Info) :- ml_gen_goal(model_det, Cond, CondDecls, CondStatements, !Info), ml_gen_set_success(!.Info, const(false), Context, SetSuccessFalse), Decls = CondDecls, - Statements = list__append(CondStatements, [SetSuccessFalse]) + Statements = list.append(CondStatements, [SetSuccessFalse]) ; % model_semi negation, model_semi goal: % @@ -3341,7 +3341,7 @@ ml_gen_negation(Cond, CodeModel, Context, Decls, Statements, !Info) :- ml_gen_set_success(!.Info, unop(std_unop(logical_not), Succeeded), Context, InvertSuccess), Decls = CondDecls, - Statements = list__append(CondStatements, [InvertSuccess]) + Statements = list.append(CondStatements, [InvertSuccess]) ; CodeModel = model_semi, CondCodeModel = model_non, unexpected(this_file, "ml_gen_negation: nondet cond") @@ -3356,7 +3356,7 @@ ml_gen_negation(Cond, CodeModel, Context, Decls, Statements, !Info) :- % :- pred ml_gen_conj(hlds_goals::in, code_model::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_conj([], CodeModel, Context, [], Statements, !Info) :- @@ -3384,7 +3384,7 @@ ml_gen_conj([First | Rest], CodeModel, Context, Decls, Statements, !Info) :- % :- pred ml_gen_disj(hlds_goals::in, code_model::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_disj([], CodeModel, Context, [], Statements, !Info) :- @@ -3460,7 +3460,7 @@ ml_gen_disj([First | Rest], CodeModel, Context, Decls, Statements, !Info) :- RestStatement = ml_gen_block(RestDecls, RestStatements, Context), IfStmt = if_then_else(unop(std_unop(logical_not), Succeeded), RestStatement, no), - IfStatement = statement(IfStmt, mlds__make_context(Context)), + IfStatement = statement(IfStmt, mlds_make_context(Context)), Decls = FirstDecls, Statements = FirstStatements ++ [IfStatement] ; @@ -3475,14 +3475,14 @@ ml_gen_disj([First | Rest], CodeModel, Context, Decls, Statements, !Info) :- % Code for handling attributes % -:- func attributes_to_mlds_attributes(module_info, list(hlds_pred__attribute)) - = list(mlds__attribute). +:- func attributes_to_mlds_attributes(module_info, list(hlds_pred.attribute)) + = list(mlds_attribute). attributes_to_mlds_attributes(ModuleInfo, Attrs) = - list__map(attribute_to_mlds_attribute(ModuleInfo), Attrs). + list.map(attribute_to_mlds_attribute(ModuleInfo), Attrs). -:- func attribute_to_mlds_attribute(module_info, hlds_pred__attribute) - = mlds__attribute. +:- func attribute_to_mlds_attribute(module_info, hlds_pred.attribute) + = mlds_attribute. attribute_to_mlds_attribute(ModuleInfo, custom(Type)) = custom(mercury_type_to_mlds_type(ModuleInfo, Type)). diff --git a/compiler/ml_code_util.m b/compiler/ml_code_util.m index c9ae06eb8..427dad187 100644 --- a/compiler/ml_code_util.m +++ b/compiler/ml_code_util.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1999-2005 The University of Melbourne. +% Copyright (C) 1999-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_code_util. +:- module ml_backend.ml_code_util. :- interface. :- import_module backend_libs.builtin_ops. @@ -52,7 +52,7 @@ % But if the block consists only of a single statement with no % declarations, then just return that statement. % -:- func ml_gen_block(mlds__defns, statements, prog_context) +:- func ml_gen_block(mlds_defns, statements, prog_context) = statement. % Join two statement lists and their corresponding declaration lists @@ -64,11 +64,11 @@ % in common, then we put each statement list and its declarations into % a block, so that the declarations remain local to each statement list. % -:- pred ml_join_decls(mlds__defns::in, statements::in, - mlds__defns::in, statements::in, prog_context::in, - mlds__defns::out, statements::out) is det. +:- pred ml_join_decls(mlds_defns::in, statements::in, + mlds_defns::in, statements::in, prog_context::in, + mlds_defns::out, statements::out) is det. -:- type gen_pred == pred(mlds__defns, statements, +:- type gen_pred == pred(mlds_defns, statements, ml_gen_info, ml_gen_info). :- inst gen_pred == (pred(out, out, in, out) is det). @@ -77,27 +77,27 @@ % :- pred ml_combine_conj(code_model::in, prog_context::in, gen_pred::in(gen_pred), gen_pred::in(gen_pred), - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % Given a function label and the statement which will comprise - % the function body for that function, generate an mlds__defn + % the function body for that function, generate an mlds_defn % which defines that function. % :- pred ml_gen_nondet_label_func(ml_gen_info::in, ml_label_func::in, - prog_context::in, statement::in, mlds__defn::out) is det. + prog_context::in, statement::in, mlds_defn::out) is det. % Given a function label, the function parameters, and the statement % which will comprise the function body for that function, - % generate an mlds__defn which defines that function. + % generate an mlds_defn which defines that function. % :- pred ml_gen_label_func(ml_gen_info::in, ml_label_func::in, - mlds__func_params::in, prog_context::in, statement::in, - mlds__defn::out) is det. + mlds_func_params::in, prog_context::in, statement::in, + mlds_defn::out) is det. % Test to see if the procedure is a model_det function whose function % result has an output mode (whose type is not a dummy argument type - % like io__state), and if so, bind RetVar to the procedure's return value. + % like io.state), and if so, bind RetVar to the procedure's return value. % These procedures need to handled specially: for such functions, % we map the Mercury function result to an MLDS return value. % @@ -128,7 +128,7 @@ % Convert the element type for an array_index operator to an MLDS type. % -:- func ml_gen_array_elem_type(builtin_ops__array_elem_type) = mlds_type. +:- func ml_gen_array_elem_type(builtin_ops.array_elem_type) = mlds_type. % Return the MLDS type corresponding to a Mercury string type. % @@ -143,7 +143,7 @@ %-----------------------------------------------------------------------------% % -% Routines for generating function declarations (i.e. mlds__func_params). +% Routines for generating function declarations (i.e. mlds_func_params). % % Note that when generating function *definitions*, the versions that take @@ -152,26 +152,26 @@ % Generate the function prototype for a given procedure. % -:- func ml_gen_proc_params(module_info, pred_id, proc_id) = mlds__func_params. +:- func ml_gen_proc_params(module_info, pred_id, proc_id) = mlds_func_params. -:- pred ml_gen_proc_params(pred_id::in, proc_id::in, mlds__func_params::out, +:- pred ml_gen_proc_params(pred_id::in, proc_id::in, mlds_func_params::out, ml_gen_info::in, ml_gen_info::out) is det. % As above, but from the rtti_proc_id rather than from the module_info, % pred_id, and proc_id. % :- func ml_gen_proc_params_from_rtti(module_info, rtti_proc_label) = - mlds__func_params. + mlds_func_params. % Generate the function prototype for a procedure with the % given argument types, modes, and code model. % -:- func ml_gen_params(module_info, list(mlds__var_name), list(mer_type), - list(mer_mode), pred_or_func, code_model) = mlds__func_params. +:- func ml_gen_params(module_info, list(mlds_var_name), list(mer_type), + list(mer_mode), pred_or_func, code_model) = mlds_func_params. -:- pred ml_gen_params(list(mlds__var_name)::in, list(mer_type)::in, +:- pred ml_gen_params(list(mlds_var_name)::in, list(mer_type)::in, list(mer_mode)::in, pred_or_func::in, code_model::in, - mlds__func_params::out, ml_gen_info::in, ml_gen_info::out) is det. + mlds_func_params::out, ml_gen_info::in, ml_gen_info::out) is det. % Given a list of variables and their corresponding modes, % return a list containing only those variables which have an output mode. @@ -184,38 +184,38 @@ % Routines for generating labels and entity names % - % Generate the mlds__entity_name and module name for the entry point + % Generate the mlds_entity_name and module name for the entry point % function corresponding to a given procedure. % :- pred ml_gen_proc_label(module_info::in, pred_id::in, proc_id::in, - mlds__entity_name::out, mlds_module_name::out) is det. + mlds_entity_name::out, mlds_module_name::out) is det. - % Generate an mlds__entity_name for a continuation function with the + % Generate an mlds_entity_name for a continuation function with the % given sequence number. The pred_id and proc_id specify the procedure % that this continuation function is part of. % :- func ml_gen_nondet_label(module_info, pred_id, proc_id, ml_label_func) - = mlds__entity_name. + = mlds_entity_name. % Allocate a new function label and return an rval containing the % function's address. If parameters are not given, we assume it is % a continuation function, and give it the appropriate arguments % (depending on whether we are doing nested functions or not). % -:- pred ml_gen_new_func_label(maybe(mlds__func_params)::in, ml_label_func::out, +:- pred ml_gen_new_func_label(maybe(mlds_func_params)::in, ml_label_func::out, mlds_rval::out, ml_gen_info::in, ml_gen_info::out) is det. - % Generate the mlds__pred_label and module name for a given procedure. + % Generate the mlds_pred_label and module name for a given procedure. % :- pred ml_gen_pred_label(module_info::in, pred_id::in, proc_id::in, - mlds__pred_label::out, mlds_module_name::out) is det. + mlds_pred_label::out, mlds_module_name::out) is det. :- pred ml_gen_pred_label_from_rtti(module_info::in, rtti_proc_label::in, - mlds__pred_label::out, mlds_module_name::out) is det. + mlds_pred_label::out, mlds_module_name::out) is det. % Allocate a new label name, for use in label statements. % -:- pred ml_gen_new_label(mlds__label::out, +:- pred ml_gen_new_label(mlds_label::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -250,47 +250,47 @@ % Generate the MLDS variable names for a list of variables. % -:- func ml_gen_var_names(prog_varset, list(prog_var)) = list(mlds__var_name). +:- func ml_gen_var_names(prog_varset, list(prog_var)) = list(mlds_var_name). % Generate the MLDS variable name for a variable. % -:- func ml_gen_var_name(prog_varset, prog_var) = mlds__var_name. +:- func ml_gen_var_name(prog_varset, prog_var) = mlds_var_name. % Generate an lval from the variable name and type. The variable % name will be qualified with the current module name. % -:- pred ml_gen_var_lval(ml_gen_info::in, mlds__var_name::in, mlds_type::in, +:- pred ml_gen_var_lval(ml_gen_info::in, mlds_var_name::in, mlds_type::in, mlds_lval::out) is det. % Generate a declaration for an MLDS variable, given its HLDS type. % -:- pred ml_gen_var_decl(var_name::in, mer_type::in, prog_context::in, - mlds__defn::out, ml_gen_info::in, ml_gen_info::out) is det. +:- pred ml_gen_var_decl(mlds_var_name::in, mer_type::in, prog_context::in, + mlds_defn::out, ml_gen_info::in, ml_gen_info::out) is det. % Generate a declaration for an MLDS variable, given its MLDS type % and the code to trace it for accurate GC (if needed). % -:- func ml_gen_mlds_var_decl(mlds__data_name, mlds_type, - maybe(statement), mlds__context) = mlds__defn. +:- func ml_gen_mlds_var_decl(mlds_data_name, mlds_type, + maybe(statement), mlds_context) = mlds_defn. % Generate a declaration for an MLDS variable, given its MLDS type % and initializer, and given the code to trace it for accurate GC % (if needed). % -:- func ml_gen_mlds_var_decl(mlds__data_name, mlds_type, mlds__initializer, - maybe(statement), mlds__context) = mlds__defn. +:- func ml_gen_mlds_var_decl(mlds_data_name, mlds_type, mlds_initializer, + maybe(statement), mlds_context) = mlds_defn. % Generate declaration flags for a local variable. % -:- func ml_gen_local_var_decl_flags = mlds__decl_flags. +:- func ml_gen_local_var_decl_flags = mlds_decl_flags. % Return the declaration flags appropriate for a public field % in the derived constructor class of a discriminated union. % -:- func ml_gen_public_field_decl_flags = mlds__decl_flags. +:- func ml_gen_public_field_decl_flags = mlds_decl_flags. % Apply the usual %s_%d formatting to a MLDS variable name. -:- func ml_var_name_to_string(mlds__var_name) = string. +:- func ml_var_name_to_string(mlds_var_name) = string. %-----------------------------------------------------------------------------% % @@ -303,27 +303,27 @@ % (or static member variable) whose address is used to represent % the specified constructor. % -:- func ml_format_reserved_object_name(string, arity) = mlds__var_name. +:- func ml_format_reserved_object_name(string, arity) = mlds_var_name. % Generate a name for a local static constant. % :- pred ml_format_static_const_name(ml_gen_info::in, string::in, const_seq::in, - mlds__var_name::out) is det. + mlds_var_name::out) is det. % Generate a definition of a static constant, given the constant's name, % type, accessibility, and initializer. % -:- func ml_gen_static_const_defn(mlds__var_name, mlds_type, mlds__access, - mlds__initializer, prog_context) = mlds__defn. +:- func ml_gen_static_const_defn(mlds_var_name, mlds_type, access, + mlds_initializer, prog_context) = mlds_defn. % Return the declaration flags appropriate for an initialized % local static constant. % -:- func ml_static_const_decl_flags = mlds__decl_flags. +:- func ml_static_const_decl_flags = mlds_decl_flags. - % Succeed iff the specified mlds__defn defines a local static constant. + % Succeed iff the specified mlds_defn defines a local static constant. % -:- pred ml_decl_is_static_const(mlds__defn::in) is semidet. +:- pred ml_decl_is_static_const(mlds_defn::in) is semidet. %-----------------------------------------------------------------------------% % @@ -333,7 +333,7 @@ % Given the user-specified field name, if any, and the argument number % (starting from one), generate an MLDS field name. % -:- func ml_gen_field_name(maybe(ctor_field_name), int) = mlds__field_name. +:- func ml_gen_field_name(maybe(ctor_field_name), int) = mlds_field_name. % Succeed iff the specified type must be boxed when used as a field. % For the MLDS->C and MLDS->asm back-ends, we need to box types that @@ -361,7 +361,7 @@ % (`succeeded' is a boolean variable used to record % the success or failure of model_semi procedures.) % -:- func ml_gen_succeeded_var_decl(mlds__context) = mlds__defn. +:- func ml_gen_succeeded_var_decl(mlds_context) = mlds_defn. % Return the lval for the `succeeded' flag. % (`succeeded' is a boolean variable used to record @@ -384,7 +384,7 @@ % (`cond' variables are boolean variables used to record % the success or failure of model_non conditions of if-then-elses.) % -:- func ml_gen_cond_var_decl(cond_seq, mlds__context) = mlds__defn. +:- func ml_gen_cond_var_decl(cond_seq, mlds_context) = mlds_defn. % Return the lval for the specified `cond' flag. % (`cond' variables are boolean variables used to record @@ -441,14 +441,14 @@ % variables in the containing procedure). Note that we generate this % as a dangling reference. The ml_elim_nested pass will insert the % declaration of the env_ptr variable. At this point, the type of these - % rvals is `mlds__unknown_type'. + % rvals is `mlds_unknown_type'. % :- pred ml_get_env_ptr(ml_gen_info::in, mlds_rval::out) is det. - % Return an mlds__argument for a pointer to the current environment + % Return an mlds_argument for a pointer to the current environment % (the set of local variables in the containing procedure). % -:- pred ml_declare_env_ptr_arg(mlds__argument::out) is det. +:- pred ml_declare_env_ptr_arg(mlds_argument::out) is det. %-----------------------------------------------------------------------------% % @@ -458,10 +458,10 @@ % ml_gen_maybe_gc_trace_code(Var, Type, Context, Code): % % If accurate GC is enabled, and the specified variable might contain - % pointers, generate code to call `private_builtin__gc_trace' to trace + % pointers, generate code to call `private_builtin.gc_trace' to trace % the variable. % -:- pred ml_gen_maybe_gc_trace_code(var_name::in, mer_type::in, +:- pred ml_gen_maybe_gc_trace_code(mlds_var_name::in, mer_type::in, prog_context::in, maybe(statement)::out, ml_gen_info::in, ml_gen_info::out) is det. @@ -483,8 +483,8 @@ % doesn't (e.g. because DeclType may be a boxed float). So we need to pass % both. % -:- pred ml_gen_maybe_gc_trace_code(var_name::in, mer_type::in, mer_type::in, - prog_context::in, maybe(statement)::out, +:- pred ml_gen_maybe_gc_trace_code(mlds_var_name::in, + mer_type::in, mer_type::in, prog_context::in, maybe(statement)::out, ml_gen_info::in, ml_gen_info::out) is det. % ml_gen_maybe_gc_trace_code_with_typeinfo(Var, DeclType, TypeInfoRval, @@ -497,8 +497,8 @@ % This is used by ml_closure_gen.m to generate GC tracing code % for the the local variables in closure wrapper functions. % -:- pred ml_gen_maybe_gc_trace_code_with_typeinfo(var_name::in, mer_type::in, - mlds_rval::in, prog_context::in, maybe(statement)::out, +:- pred ml_gen_maybe_gc_trace_code_with_typeinfo(mlds_var_name::in, + mer_type::in, mlds_rval::in, prog_context::in, maybe(statement)::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -594,7 +594,7 @@ % A number corresponding to an MLDS nested function which serves as a % label (i.e. a continuation function). % -:- type ml_label_func == mlds__func_sequence_num. +:- type ml_label_func == mlds_func_sequence_num. % Generate a new function label number. This is used to give unique names % to the nested functions used when generating code for nondet procedures. @@ -643,16 +643,16 @@ % Set the `const' variable name corresponding to the given HLDS variable. % -:- pred ml_gen_info_set_const_var_name(prog_var::in, mlds__var_name::in, +:- pred ml_gen_info_set_const_var_name(prog_var::in, mlds_var_name::in, ml_gen_info::in, ml_gen_info::out) is det. % Lookup the `const' sequence number corresponding to a given HLDS % variable. % :- pred ml_gen_info_lookup_const_var_name(ml_gen_info::in, prog_var::in, - mlds__var_name::out) is det. + mlds_var_name::out) is det. :- pred ml_gen_info_search_const_var_name(ml_gen_info::in, prog_var::in, - mlds__var_name::out) is semidet. + mlds_var_name::out) is semidet. % A success continuation specifies the (rval for the variable holding % the address of the) function that a nondet procedure should call @@ -716,12 +716,12 @@ % Insert an extra definition at the start of the list of extra % definitions. % -:- pred ml_gen_info_add_extra_defn(mlds__defn::in, +:- pred ml_gen_info_add_extra_defn(mlds_defn::in, ml_gen_info::in, ml_gen_info::out) is det. % Get the list of extra definitions. % -:- pred ml_gen_info_get_extra_defns(ml_gen_info::in, mlds__defns::out) is det. +:- pred ml_gen_info_get_extra_defns(ml_gen_info::in, mlds_defns::out) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -762,7 +762,7 @@ ml_gen_assign(Lval, Rval, Context) = Statement :- Assign = assign(Lval, Rval), Stmt = atomic(Assign), - Statement = statement(Stmt, mlds__make_context(Context)). + Statement = statement(Stmt, mlds_make_context(Context)). ml_append_return_statement(Info, CodeModel, CopiedOutputVarLvals, Context, !Statements) :- @@ -770,22 +770,22 @@ ml_append_return_statement(Info, CodeModel, CopiedOutputVarLvals, Context, CodeModel = model_semi -> ml_gen_test_success(Info, Succeeded), - CopiedOutputVarRvals = list__map(func(Lval) = lval(Lval), + CopiedOutputVarRvals = list.map(func(Lval) = lval(Lval), CopiedOutputVarLvals), ReturnStmt = return([Succeeded | CopiedOutputVarRvals]), ReturnStatement = statement(ReturnStmt, - mlds__make_context(Context)), - !:Statements = list__append(!.Statements, [ReturnStatement]) + mlds_make_context(Context)), + !:Statements = !.Statements ++ [ReturnStatement] ; CodeModel \= model_non, CopiedOutputVarLvals = [_ | _] -> - CopiedOutputVarRvals = list__map(func(Lval) = lval(Lval), + CopiedOutputVarRvals = list.map(func(Lval) = lval(Lval), CopiedOutputVarLvals), ReturnStmt = return(CopiedOutputVarRvals), ReturnStatement = statement(ReturnStmt, - mlds__make_context(Context)), - !:Statements = list__append(!.Statements, [ReturnStatement]) + mlds_make_context(Context)), + !:Statements = !.Statements ++ [ReturnStatement] ; true ). @@ -798,22 +798,22 @@ ml_gen_block(VarDecls, Statements, Context) = SingleStatement ; statement(block(VarDecls, Statements), - mlds__make_context(Context)) + mlds_make_context(Context)) ). ml_join_decls(FirstDecls, FirstStatements, RestDecls, RestStatements, Context, Decls, Statements) :- ( - list__member(mlds__defn(Name, _, _, _), FirstDecls), - list__member(mlds__defn(Name, _, _, _), RestDecls) + list.member(mlds_defn(Name, _, _, _), FirstDecls), + list.member(mlds_defn(Name, _, _, _), RestDecls) -> First = ml_gen_block(FirstDecls, FirstStatements, Context), Rest = ml_gen_block(RestDecls, RestStatements, Context), Decls = [], Statements = [First, Rest] ; - Decls = list__append(FirstDecls, RestDecls), - Statements = list__append(FirstStatements, RestStatements) + Decls = FirstDecls ++ RestDecls, + Statements = FirstStatements ++ RestStatements ). ml_combine_conj(FirstCodeModel, Context, DoGenFirst, DoGenRest, @@ -851,10 +851,9 @@ ml_combine_conj(FirstCodeModel, Context, DoGenFirst, DoGenRest, DoGenRest(RestDecls, RestStatements, !Info), IfBody = ml_gen_block([], RestStatements, Context), IfStmt = if_then_else(Succeeded, IfBody, no), - IfStatement = statement(IfStmt, - mlds__make_context(Context)), - Decls = list__append(FirstDecls, RestDecls), - Statements = list__append(FirstStatements, [IfStatement]) + IfStatement = statement(IfStmt, mlds_make_context(Context)), + Decls = FirstDecls ++ RestDecls, + Statements = FirstStatements ++ [IfStatement] ; % model_non goal: % @@ -893,19 +892,19 @@ ml_combine_conj(FirstCodeModel, Context, DoGenFirst, DoGenRest, % generate the `succ_func' % push nesting level DoGenRest(RestDecls, RestStatements, !Info), - list__filter(ml_decl_is_static_const, RestDecls, + list.filter(ml_decl_is_static_const, RestDecls, RestStaticDecls, RestOtherDecls), RestStatement = ml_gen_block(RestOtherDecls, RestStatements, Context), % pop nesting level ml_gen_nondet_label_func(!.Info, RestFuncLabel, Context, RestStatement, RestFunc), - Decls = list__condense([FirstDecls, RestStaticDecls, [RestFunc]]), + Decls = FirstDecls ++ RestStaticDecls ++ [RestFunc], Statements = FirstStatements ). ml_decl_is_static_const(Defn) :- - Defn = mlds__defn(Name, _Context, Flags, _DefnBody), + Defn = mlds_defn(Name, _Context, Flags, _DefnBody), Name = data(_), Flags = ml_static_const_decl_flags. @@ -913,11 +912,11 @@ ml_gen_nondet_label_func(Info, FuncLabel, Context, Statement, Func) :- ml_gen_info_use_gcc_nested_functions(Info, UseNested), ( UseNested = yes, - FuncParams = mlds__func_params([], []) + FuncParams = mlds_func_params([], []) ; UseNested = no, ml_declare_env_ptr_arg(EnvPtrArg), - FuncParams = mlds__func_params([EnvPtrArg], []) + FuncParams = mlds_func_params([EnvPtrArg], []) ), ml_gen_label_func(Info, FuncLabel, FuncParams, Context, Statement, Func). @@ -932,15 +931,15 @@ ml_gen_label_func(Info, FuncLabel, FuncParams, Context, Statement, Func) :- DeclFlags = ml_gen_label_func_decl_flags, MaybePredProcId = no, Attributes = [], - FuncDefn = function(MaybePredProcId, FuncParams, + FuncDefn = mlds_function(MaybePredProcId, FuncParams, defined_here(Statement), Attributes), - Func = mlds__defn(FuncName, mlds__make_context(Context), DeclFlags, + Func = mlds_defn(FuncName, mlds_make_context(Context), DeclFlags, FuncDefn). % Return the declaration flags appropriate for a label func (a label func % is a function used as a continuation when generating nondet code). % -:- func ml_gen_label_func_decl_flags = mlds__decl_flags. +:- func ml_gen_label_func_decl_flags = mlds_decl_flags. ml_gen_label_func_decl_flags = DeclFlags :- Access = local, @@ -978,20 +977,20 @@ ml_gen_type(Info, Type, MLDS_Type) :- MLDS_Type = mercury_type_to_mlds_type(ModuleInfo, Type). ml_gen_array_elem_type(elem_type_string) = ml_string_type. -ml_gen_array_elem_type(elem_type_int) = mlds__native_int_type. -ml_gen_array_elem_type(elem_type_generic) = mlds__generic_type. +ml_gen_array_elem_type(elem_type_int) = mlds_native_int_type. +ml_gen_array_elem_type(elem_type_generic) = mlds_generic_type. ml_string_type = mercury_type(string_type, type_cat_string, non_foreign_type(string_type)). ml_make_boxed_types(Arity) = BoxedTypes :- - varset__init(TypeVarSet0), - varset__new_vars(TypeVarSet0, Arity, BoxedTypeVars, _TypeVarSet), - prog_type.var_list_to_type_list(map__init, BoxedTypeVars, BoxedTypes). + varset.init(TypeVarSet0), + varset.new_vars(TypeVarSet0, Arity, BoxedTypeVars, _TypeVarSet), + prog_type.var_list_to_type_list(map.init, BoxedTypeVars, BoxedTypes). %-----------------------------------------------------------------------------% % -% Code for generating function declarations (i.e. mlds__func_params). +% Code for generating function declarations (i.e. mlds_func_params). % ml_gen_proc_params(ModuleInfo, PredId, ProcId) = FuncParams :- @@ -1037,9 +1036,9 @@ ml_gen_proc_params_from_rtti(ModuleInfo, RttiProcId) = FuncParams :- PredOrFunc = RttiProcId^pred_or_func, Detism = RttiProcId^proc_interface_detism, determinism_to_code_model(Detism, CodeModel), - HeadVarNames = list__map((func(Var - Name) = Result :- - term__var_to_int(Var, N), - Result = mlds__var_name(Name, yes(N)) + HeadVarNames = list.map((func(Var - Name) = Result :- + term.var_to_int(Var, N), + Result = mlds_var_name(Name, yes(N)) ), HeadVars), ml_gen_params_base(ModuleInfo, HeadVarNames, ArgTypes, ArgModes, PredOrFunc, CodeModel, FuncParams, no, _). @@ -1065,9 +1064,9 @@ ml_gen_params(HeadVarNames, HeadTypes, HeadModes, PredOrFunc, unexpected(this_file, "ml_gen_params: missing ml_gen_info") ). -:- pred ml_gen_params_base(module_info::in, list(mlds__var_name)::in, +:- pred ml_gen_params_base(module_info::in, list(mlds_var_name)::in, list(mer_type)::in, list(arg_mode)::in, pred_or_func::in, - code_model::in, mlds__func_params::out, + code_model::in, mlds_func_params::out, maybe(ml_gen_info)::in, maybe(ml_gen_info)::out) is det. ml_gen_params_base(ModuleInfo, HeadVarNames, HeadTypes, HeadModes, PredOrFunc, @@ -1089,8 +1088,8 @@ ml_gen_params_base(ModuleInfo, HeadVarNames, HeadTypes, HeadModes, PredOrFunc, \+ is_dummy_argument_type(ModuleInfo, ResultType) -> pred_args_to_func_args(FuncArgs0, FuncArgs, RetArg), - RetArg = mlds__argument(_RetArgName, RetTypePtr, _GC_TraceCode), - ( RetTypePtr = mlds__ptr_type(RetType) -> + RetArg = mlds_argument(_RetArgName, RetTypePtr, _GC_TraceCode), + ( RetTypePtr = mlds_ptr_type(RetType) -> RetTypes = [RetType] ; unexpected(this_file, "output mode function result " ++ @@ -1104,36 +1103,36 @@ ml_gen_params_base(ModuleInfo, HeadVarNames, HeadTypes, HeadModes, PredOrFunc, CodeModel = model_semi, % For model_semi procedures, return a bool. FuncArgs = FuncArgs0, - RetTypes = [mlds__native_bool_type | RetTypes0] + RetTypes = [mlds_native_bool_type | RetTypes0] ; CodeModel = model_non, % For model_non procedures, we return values by passing them % to the continuation. ( CopyOut = yes, - ContType = mlds__cont_type(RetTypes0), + ContType = mlds_cont_type(RetTypes0), RetTypes = [] ; CopyOut = no, - ContType = mlds__cont_type([]), + ContType = mlds_cont_type([]), RetTypes = RetTypes0 ), - ContName = data(var(var_name("cont", no))), + ContName = data(var(mlds_var_name("cont", no))), % The cont variable always points to code, not to the heap, % so the GC never needs to trace it. ContGCTraceCode = no, - ContArg = mlds__argument(ContName, ContType, ContGCTraceCode), - ContEnvType = mlds__generic_env_ptr_type, - ContEnvName = data(var(var_name("cont_env_ptr", no))), + ContArg = mlds_argument(ContName, ContType, ContGCTraceCode), + ContEnvType = mlds_generic_env_ptr_type, + ContEnvName = data(var(mlds_var_name("cont_env_ptr", no))), % The cont_env_ptr always points to the stack, since continuation % environments are always allocated on the stack (unless % put_nondet_env_on_heap is true, which won't be the case when doing % our own GC -- this is enforced in handle_options.m). % So the GC doesn't need to trace it. ContEnvGCTraceCode = no, - ContEnvArg = mlds__argument(ContEnvName, ContEnvType, + ContEnvArg = mlds_argument(ContEnvName, ContEnvType, ContEnvGCTraceCode), - globals__lookup_bool_option(Globals, gcc_nested_functions, + globals.lookup_bool_option(Globals, gcc_nested_functions, NestedFunctions), ( NestedFunctions = yes, @@ -1143,15 +1142,15 @@ ml_gen_params_base(ModuleInfo, HeadVarNames, HeadTypes, HeadModes, PredOrFunc, FuncArgs = FuncArgs0 ++ [ContArg, ContEnvArg] ) ), - FuncParams = mlds__func_params(FuncArgs, RetTypes). + FuncParams = mlds_func_params(FuncArgs, RetTypes). % Given the argument variable names, and corresponding lists of their % types and modes, generate the MLDS argument declarations % and return types. % -:- pred ml_gen_arg_decls(module_info::in, list(mlds__var_name)::in, +:- pred ml_gen_arg_decls(module_info::in, list(mlds_var_name)::in, list(mer_type)::in, list(arg_mode)::in, bool::in, - mlds__arguments::out, mlds__return_types::out, + mlds_arguments::out, mlds_return_types::out, maybe(ml_gen_info)::in, maybe(ml_gen_info)::out) is det. ml_gen_arg_decls(ModuleInfo, HeadVars, HeadTypes, HeadModes, CopyOut, @@ -1171,7 +1170,7 @@ ml_gen_arg_decls(ModuleInfo, HeadVars, HeadTypes, HeadModes, CopyOut, ml_gen_arg_decls(ModuleInfo, Vars, Types, Modes, CopyOut, FuncArgs0, RetTypes0, !MaybeInfo), ( - % Exclude types such as io__state, etc. + % Exclude types such as io.state, etc. % Also exclude values with arg_mode `top_unused'. ( is_dummy_argument_type(ModuleInfo, Type) ; Mode = top_unused @@ -1200,8 +1199,8 @@ ml_gen_arg_decls(ModuleInfo, HeadVars, HeadTypes, HeadModes, CopyOut, % Given an argument variable, and its type and mode, % generate an MLDS argument declaration for it. % -:- pred ml_gen_arg_decl(module_info::in, var_name::in, mer_type::in, - arg_mode::in, mlds__argument::out, +:- pred ml_gen_arg_decl(module_info::in, mlds_var_name::in, mer_type::in, + arg_mode::in, mlds_argument::out, maybe(ml_gen_info)::in, maybe(ml_gen_info)::out) is det. ml_gen_arg_decl(ModuleInfo, Var, Type, ArgMode, FuncArg, !MaybeInfo) :- @@ -1209,13 +1208,13 @@ ml_gen_arg_decl(ModuleInfo, Var, Type, ArgMode, FuncArg, !MaybeInfo) :- ( ArgMode = top_in -> MLDS_ArgType = MLDS_Type ; - MLDS_ArgType = mlds__ptr_type(MLDS_Type) + MLDS_ArgType = mlds_ptr_type(MLDS_Type) ), Name = data(var(Var)), ( !.MaybeInfo = yes(Info0), % XXX We should fill in this Context properly. - term__context_init(Context), + term.context_init(Context), ml_gen_maybe_gc_trace_code(Var, Type, Context, Maybe_GC_TraceCode, Info0, Info), !:MaybeInfo = yes(Info) @@ -1224,7 +1223,7 @@ ml_gen_arg_decl(ModuleInfo, Var, Type, ArgMode, FuncArg, !MaybeInfo) :- Maybe_GC_TraceCode = no, !:MaybeInfo = no ), - FuncArg = mlds__argument(Name, MLDS_ArgType, Maybe_GC_TraceCode). + FuncArg = mlds_argument(Name, MLDS_ArgType, Maybe_GC_TraceCode). ml_is_output_det_function(ModuleInfo, PredId, ProcId, RetArgVar) :- module_info_pred_proc_info(ModuleInfo, PredId, ProcId, PredInfo, ProcInfo), @@ -1244,17 +1243,17 @@ ml_is_output_det_function(ModuleInfo, PredId, ProcId, RetArgVar) :- %-----------------------------------------------------------------------------% % -% Code for generating mlds__entity_names. +% Code for generating mlds_entity_names. % - % Generate the mlds__entity_name and module name for the entry point + % Generate the mlds_entity_name and module name for the entry point % function corresponding to a given procedure. % ml_gen_proc_label(ModuleInfo, PredId, ProcId, MLDS_Name, MLDS_ModuleName) :- ml_gen_func_label(ModuleInfo, PredId, ProcId, no, MLDS_Name, MLDS_ModuleName). - % Generate an mlds__entity_name for a continuation function with the given + % Generate an mlds_entity_name for a continuation function with the given % sequence number. The pred_id and proc_id specify the procedure that this % continuation function is part of. % @@ -1263,7 +1262,7 @@ ml_gen_nondet_label(ModuleInfo, PredId, ProcId, SeqNum) = MLDS_Name :- MLDS_Name, _MLDS_ModuleName). :- pred ml_gen_func_label(module_info::in, pred_id::in, proc_id::in, - maybe(ml_label_func)::in, mlds__entity_name::out, + maybe(ml_label_func)::in, mlds_entity_name::out, mlds_module_name::out) is det. ml_gen_func_label(ModuleInfo, PredId, ProcId, MaybeSeqNum, @@ -1285,7 +1284,7 @@ ml_gen_new_func_label(MaybeParams, FuncLabel, FuncLabelRval, !Info) :- ml_gen_info_use_gcc_nested_functions(!.Info, UseNestedFuncs), ( MaybeParams = yes(Params), - Signature = mlds__get_func_signature(Params) + Signature = mlds_get_func_signature(Params) ; MaybeParams = no, ( @@ -1293,18 +1292,18 @@ ml_gen_new_func_label(MaybeParams, FuncLabel, FuncLabelRval, !Info) :- ArgTypes = [] ; UseNestedFuncs = no, - ArgTypes = [mlds__generic_env_ptr_type] + ArgTypes = [mlds_generic_env_ptr_type] ), - Signature = mlds__func_signature(ArgTypes, []) + Signature = mlds_func_signature(ArgTypes, []) ), ProcLabel = qual(PredModule, module_qual, PredLabel - ProcId), FuncLabelRval = const(code_addr_const(internal(ProcLabel, FuncLabel, Signature))). - % Generate the mlds__pred_label and module name for a given procedure. + % Generate the mlds_pred_label and module name for a given procedure. % ml_gen_pred_label(ModuleInfo, PredId, ProcId, MLDS_PredLabel, MLDS_Module) :- - RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId), + RttiProcLabel = rtti.make_rtti_proc_label(ModuleInfo, PredId, ProcId), ml_gen_pred_label_from_rtti(ModuleInfo, RttiProcLabel, MLDS_PredLabel, MLDS_Module). @@ -1331,7 +1330,7 @@ ml_gen_pred_label_from_rtti(ModuleInfo, RttiProcLabel, MLDS_PredLabel, ( ThisModule \= TypeModule, SpecialPred = spec_pred_unify, - \+ hlds_pred__in_in_unification_proc_id(ProcId) + \+ hlds_pred.in_in_unification_proc_id(ProcId) -> % This is a locally-defined instance of a unification procedure % for a type defined in some other module. @@ -1346,7 +1345,7 @@ ml_gen_pred_label_from_rtti(ModuleInfo, RttiProcLabel, MLDS_PredLabel, MLDS_PredLabel = special_pred(PredName, MaybeDeclaringModule, TypeName, TypeArity) ; - string__append_list(["ml_gen_pred_label:\n", + string.append_list(["ml_gen_pred_label:\n", "cannot make label for special pred `", PredName, "'"], ErrorMessage), unexpected(this_file, ErrorMessage) @@ -1383,7 +1382,7 @@ ml_gen_pred_label_from_rtti(ModuleInfo, RttiProcLabel, MLDS_PredLabel, ml_gen_new_label(Label, !Info) :- ml_gen_info_new_label(LabelNum, !Info), - string__format("label_%d", [i(LabelNum)], Label). + string.format("label_%d", [i(LabelNum)], Label). %-----------------------------------------------------------------------------% % @@ -1400,7 +1399,7 @@ ml_gen_var(Info, Var, Lval) :- % for this variable, use it. ml_gen_info_get_var_lvals(Info, VarLvals), - ( map__search(VarLvals, Var, VarLval) -> + ( map.search(VarLvals, Var, VarLval) -> Lval = VarLval ; % Otherwise just look up the variable's type and generate an lval @@ -1420,7 +1419,7 @@ ml_gen_var_with_type(Info, Var, Type, Lval) :- MLDS_Module = mercury_module_name_to_mlds(PrivateBuiltin), ml_gen_type(Info, Type, MLDS_Type), Lval = var(qual(MLDS_Module, module_qual, - var_name("dummy_var", no)), MLDS_Type) + mlds_var_name("dummy_var", no)), MLDS_Type) ; ml_gen_info_get_varset(Info, VarSet), VarName = ml_gen_var_name(VarSet, Var), @@ -1429,7 +1428,7 @@ ml_gen_var_with_type(Info, Var, Type, Lval) :- % Output variables may be passed by reference... ml_gen_info_get_byref_output_vars(Info, OutputVars), - ( list__member(Var, OutputVars) -> + ( list.member(Var, OutputVars) -> Lval = mem_ref(lval(VarLval), MLDS_Type) ; Lval = VarLval @@ -1443,20 +1442,20 @@ ml_variable_types(Info, [Var | Vars], [Type | Types]) :- ml_variable_type(Info, Var, Type) :- ml_gen_info_get_var_types(Info, VarTypes), - map__lookup(VarTypes, Var, Type). + map.lookup(VarTypes, Var, Type). -ml_gen_var_names(VarSet, Vars) = list__map(ml_gen_var_name(VarSet), Vars). +ml_gen_var_names(VarSet, Vars) = list.map(ml_gen_var_name(VarSet), Vars). ml_gen_var_name(VarSet, Var) = UniqueVarName :- - varset__lookup_name(VarSet, Var, VarName), - term__var_to_int(Var, VarNumber), - UniqueVarName = mlds__var_name(VarName, yes(VarNumber)). + varset.lookup_name(VarSet, Var, VarName), + term.var_to_int(Var, VarNumber), + UniqueVarName = mlds_var_name(VarName, yes(VarNumber)). ml_format_reserved_object_name(CtorName, CtorArity) = ReservedObjName :- % We add the "obj_" prefix to avoid any potential name clashes. - Name = string__format("obj_%s_%d", [s(CtorName), i(CtorArity)]), - ReservedObjName = var_name(Name, no). + Name = string.format("obj_%s_%d", [s(CtorName), i(CtorArity)]), + ReservedObjName = mlds_var_name(Name, no). ml_format_static_const_name(Info, BaseName, SequenceNum, ConstName) :- % To ensure that the names are unique, we qualify them with the pred_id @@ -1467,8 +1466,8 @@ ml_format_static_const_name(Info, BaseName, SequenceNum, ConstName) :- ml_gen_info_get_proc_id(Info, ProcId), pred_id_to_int(PredId, PredIdNum), proc_id_to_int(ProcId, ProcIdNum), - ConstName = mlds__var_name( - string__format("const_%d_%d_%d_%s", [i(PredIdNum), + ConstName = mlds_var_name( + string.format("const_%d_%d_%d_%s", [i(PredIdNum), i(ProcIdNum), i(SequenceNum), s(BaseName)]), no). ml_gen_var_lval(Info, VarName, VarType, QualifiedVarLval) :- @@ -1481,7 +1480,7 @@ ml_gen_var_decl(VarName, Type, Context, Defn, !Info) :- ml_gen_maybe_gc_trace_code(VarName, Type, Context, GC_TraceCode, !Info), Defn = ml_gen_mlds_var_decl(var(VarName), mercury_type_to_mlds_type(ModuleInfo, Type), - GC_TraceCode, mlds__make_context(Context)). + GC_TraceCode, mlds_make_context(Context)). ml_gen_mlds_var_decl(DataName, MLDS_Type, GC_TraceCode, Context) = ml_gen_mlds_var_decl(DataName, MLDS_Type, no_initializer, GC_TraceCode, @@ -1490,9 +1489,9 @@ ml_gen_mlds_var_decl(DataName, MLDS_Type, GC_TraceCode, Context) = ml_gen_mlds_var_decl(DataName, MLDS_Type, Initializer, GC_TraceCode, Context) = MLDS_Defn :- Name = data(DataName), - Defn = data(MLDS_Type, Initializer, GC_TraceCode), + Defn = mlds_data(MLDS_Type, Initializer, GC_TraceCode), DeclFlags = ml_gen_local_var_decl_flags, - MLDS_Defn = mlds__defn(Name, Context, DeclFlags, Defn). + MLDS_Defn = mlds_defn(Name, Context, DeclFlags, Defn). ml_gen_static_const_defn(ConstName, ConstType, Access, Initializer, Context) = MLDS_Defn :- @@ -1501,10 +1500,10 @@ ml_gen_static_const_defn(ConstName, ConstType, Access, Initializer, Context) = % because they can never point into the heap % (only to other static constants). GC_TraceCode = no, - Defn = data(ConstType, Initializer, GC_TraceCode), - DeclFlags = mlds__set_access(ml_static_const_decl_flags, Access), - MLDS_Context = mlds__make_context(Context), - MLDS_Defn = mlds__defn(Name, MLDS_Context, DeclFlags, Defn). + Defn = mlds_data(ConstType, Initializer, GC_TraceCode), + DeclFlags = mlds.set_access(ml_static_const_decl_flags, Access), + MLDS_Context = mlds_make_context(Context), + MLDS_Defn = mlds_defn(Name, MLDS_Context, DeclFlags, Defn). ml_gen_public_field_decl_flags = DeclFlags :- Access = public, @@ -1538,9 +1537,9 @@ ml_static_const_decl_flags = DeclFlags :- DeclFlags = init_decl_flags(Access, PerInstance, Virtuality, Finality, Constness, Abstractness). -ml_var_name_to_string(var_name(Var, yes(Num))) = - string__format("%s_%d", [s(Var), i(Num)]). -ml_var_name_to_string(var_name(Var, no)) = Var. +ml_var_name_to_string(mlds_var_name(Var, yes(Num))) = + string.format("%s_%d", [s(Var), i(Num)]). +ml_var_name_to_string(mlds_var_name(Var, no)) = Var. %-----------------------------------------------------------------------------% % @@ -1558,7 +1557,7 @@ ml_gen_field_name(MaybeFieldName, ArgNum) = FieldName :- unqualify_name(QualifiedFieldName, FieldName) ; MaybeFieldName = no, - FieldName = string__format("F%d", [i(ArgNum)]) + FieldName = string.format("F%d", [i(ArgNum)]) ). % Succeed iff the specified type must be boxed when used as a field. @@ -1643,12 +1642,12 @@ ml_gen_failure(model_non, _, Statements, !Info) :- %-----------------------------------------------------------------------------% ml_gen_succeeded_var_decl(Context) = - ml_gen_mlds_var_decl(var(var_name("succeeded", no)), - mlds__native_bool_type, no, Context). + ml_gen_mlds_var_decl(var(mlds_var_name("succeeded", no)), + mlds_native_bool_type, no, Context). ml_success_lval(Info, SucceededLval) :- - ml_gen_var_lval(Info, var_name("succeeded", no), mlds__native_bool_type, - SucceededLval). + ml_gen_var_lval(Info, mlds_var_name("succeeded", no), + mlds_native_bool_type, SucceededLval). ml_gen_test_success(Info, SucceededRval) :- ml_success_lval(Info, SucceededLval), @@ -1662,19 +1661,18 @@ ml_gen_set_success(Info, Value, Context, Statement) :- % Generate the name for the specified `cond_' variable. % -:- func ml_gen_cond_var_name(cond_seq) = mlds__var_name. +:- func ml_gen_cond_var_name(cond_seq) = mlds_var_name. ml_gen_cond_var_name(CondVar) = - mlds__var_name(string__append("cond_", string__int_to_string(CondVar)), - no). + mlds_var_name(string.append("cond_", string.int_to_string(CondVar)), no). ml_gen_cond_var_decl(CondVar, Context) = ml_gen_mlds_var_decl(var(ml_gen_cond_var_name(CondVar)), - mlds__native_bool_type, no, Context). + mlds_native_bool_type, no, Context). ml_cond_var_lval(Info, CondVar, CondVarLval) :- ml_gen_var_lval(Info, ml_gen_cond_var_name(CondVar), - mlds__native_bool_type, CondVarLval). + mlds_native_bool_type, CondVarLval). ml_gen_test_cond_var(Info, CondVar, CondVarRval) :- ml_cond_var_lval(Info, CondVar, CondVarLval), @@ -1690,15 +1688,15 @@ ml_initial_cont(Info, OutputVarLvals0, OutputVarTypes0, Cont) :- ml_gen_info_get_module_info(Info, ModuleInfo), ml_skip_dummy_argument_types(OutputVarTypes0, OutputVarLvals0, ModuleInfo, OutputVarTypes, OutputVarLvals), - list__map(ml_gen_type(Info), OutputVarTypes, MLDS_OutputVarTypes), + list.map(ml_gen_type(Info), OutputVarTypes, MLDS_OutputVarTypes), % We expect OutputVarlvals0 and OutputVarTypes0 to be empty if % `--nondet-copy-out' is not enabled. - ml_gen_var_lval(Info, mlds__var_name("cont", no), - mlds__cont_type(MLDS_OutputVarTypes), ContLval), - ml_gen_var_lval(Info, mlds__var_name("cont_env_ptr", no), - mlds__generic_env_ptr_type, ContEnvLval), + ml_gen_var_lval(Info, mlds_var_name("cont", no), + mlds_cont_type(MLDS_OutputVarTypes), ContLval), + ml_gen_var_lval(Info, mlds_var_name("cont_env_ptr", no), + mlds_generic_env_ptr_type, ContEnvLval), Cont = success_cont(lval(ContLval), lval(ContEnvLval), MLDS_OutputVarTypes, OutputVarLvals). @@ -1724,7 +1722,7 @@ ml_skip_dummy_argument_types([], [_ | _], _, _, _) :- ml_gen_call_current_success_cont(Context, Statement, !Info) :- ml_gen_info_current_success_cont(!.Info, SuccCont), SuccCont = success_cont(FuncRval, EnvPtrRval, ArgTypes0, ArgLvals0), - ArgRvals0 = list__map(func(Lval) = lval(Lval), ArgLvals0), + ArgRvals0 = list.map(func(Lval) = lval(Lval), ArgLvals0), ml_gen_info_use_gcc_nested_functions(!.Info, UseNestedFuncs), ( UseNestedFuncs = yes, @@ -1732,16 +1730,16 @@ ml_gen_call_current_success_cont(Context, Statement, !Info) :- ArgRvals = ArgRvals0 ; UseNestedFuncs = no, - ArgTypes = ArgTypes0 ++ [mlds__generic_env_ptr_type], + ArgTypes = ArgTypes0 ++ [mlds_generic_env_ptr_type], ArgRvals =ArgRvals0 ++ [EnvPtrRval] ), RetTypes = [], - Signature = mlds__func_signature(ArgTypes, RetTypes), + Signature = mlds_func_signature(ArgTypes, RetTypes), ObjectRval = no, RetLvals = [], CallKind = ordinary_call, Stmt = call(Signature, FuncRval, ObjectRval, ArgRvals, RetLvals, CallKind), - Statement = statement(Stmt, mlds__make_context(Context)). + Statement = statement(Stmt, mlds_make_context(Context)). ml_gen_call_current_success_cont_indirectly(Context, Statement, !Info) :- % XXX this code is quite similar to some of the existing code @@ -1752,7 +1750,7 @@ ml_gen_call_current_success_cont_indirectly(Context, Statement, !Info) :- ml_gen_info_current_success_cont(!.Info, SuccCont), SuccCont = success_cont(ContinuationFuncRval, EnvPtrRval, ArgTypes0, ArgLvals0), - ArgRvals0 = list__map(func(Lval) = lval(Lval), ArgLvals0), + ArgRvals0 = list.map(func(Lval) = lval(Lval), ArgLvals0), ml_gen_info_use_gcc_nested_functions(!.Info, UseNestedFuncs), ( UseNestedFuncs = yes, @@ -1760,16 +1758,16 @@ ml_gen_call_current_success_cont_indirectly(Context, Statement, !Info) :- ArgRvals = ArgRvals0 ; UseNestedFuncs = no, - ArgTypes = ArgTypes0 ++ [mlds__generic_env_ptr_type], + ArgTypes = ArgTypes0 ++ [mlds_generic_env_ptr_type], ArgRvals = ArgRvals0 ++ [EnvPtrRval] ), RetTypes = [], - Signature = mlds__func_signature(ArgTypes, RetTypes), + Signature = mlds_func_signature(ArgTypes, RetTypes), ObjectRval = no, RetLvals = [], CallKind = ordinary_call, - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), ml_gen_info_get_module_name(!.Info, PredModule), MLDS_Module = mercury_module_name_to_mlds(PredModule), @@ -1785,9 +1783,9 @@ ml_gen_call_current_success_cont_indirectly(Context, Statement, !Info) :- % GC is the .NET CLR implementation's problem, not ours.) % ml_gen_cont_params(ArgTypes0, InnerFuncParams0, !Info), - InnerFuncParams0 = func_params(InnerArgs0, Rets), - InnerArgRvals = list__map( - (func(mlds__argument(Data, Type, _GC) ) + InnerFuncParams0 = mlds_func_params(InnerArgs0, Rets), + InnerArgRvals = list.map( + (func(mlds_argument(Data, Type, _GC) ) = lval(var(qual(MLDS_Module, module_qual, VarName), Type)) :- ( Data = data(var(VarName0)) -> VarName = VarName0 @@ -1796,16 +1794,16 @@ ml_gen_call_current_success_cont_indirectly(Context, Statement, !Info) :- "expected variable name in continuation parameters") ) ), InnerArgs0), - InnerFuncArgType = mlds__cont_type(ArgTypes0), - PassedContVarName = mlds__var_name("passed_cont", no), + InnerFuncArgType = mlds_cont_type(ArgTypes0), + PassedContVarName = mlds_var_name("passed_cont", no), % The passed_cont variable always points to code, not to heap, % so the GC never needs to trace it. PassedContGCTraceCode = no, - PassedContArg = mlds__argument(data(var(PassedContVarName)), + PassedContArg = mlds_argument(data(var(PassedContVarName)), InnerFuncArgType, PassedContGCTraceCode), InnerFuncRval = lval(var(qual(MLDS_Module, module_qual, PassedContVarName), InnerFuncArgType)), - InnerFuncParams = func_params([PassedContArg | InnerArgs0], Rets), + InnerFuncParams = mlds_func_params([PassedContArg | InnerArgs0], Rets), InnerStmt = call(Signature, InnerFuncRval, ObjectRval, InnerArgRvals, RetLvals, CallKind), @@ -1814,12 +1812,12 @@ ml_gen_call_current_success_cont_indirectly(Context, Statement, !Info) :- ml_gen_label_func(!.Info, 1, InnerFuncParams, Context, InnerStatement, Defn), - ProxySignature = mlds__func_signature([InnerFuncArgType | ArgTypes], + ProxySignature = mlds_func_signature([InnerFuncArgType | ArgTypes], RetTypes), ProxyArgRvals = [ContinuationFuncRval | ArgRvals], ( - Defn = mlds__defn(function(PredLabel, ProcId, - yes(SeqNum), _), _, _, function(_, _, defined_here(_), _)) + Defn = mlds_defn(function(PredLabel, ProcId, + yes(SeqNum), _), _, _, mlds_function(_, _, defined_here(_), _)) -> % We call the proxy function. QualProcLabel = qual(MLDS_Module, module_qual, PredLabel - ProcId), @@ -1843,12 +1841,12 @@ ml_gen_call_current_success_cont_indirectly(Context, Statement, !Info) :- % ml_get_env_ptr(Info, lval(EnvPtrLval)) :- - ml_gen_var_lval(Info, mlds__var_name("env_ptr", no), - mlds__unknown_type, EnvPtrLval). + ml_gen_var_lval(Info, mlds_var_name("env_ptr", no), + mlds_unknown_type, EnvPtrLval). -ml_declare_env_ptr_arg(mlds__argument(Name, Type, GC_TraceCode)) :- - Name = data(var(mlds__var_name("env_ptr_arg", no))), - Type = mlds__generic_env_ptr_type, +ml_declare_env_ptr_arg(mlds_argument(Name, Type, GC_TraceCode)) :- + Name = data(var(mlds_var_name("env_ptr_arg", no))), + Type = mlds_generic_env_ptr_type, % The env_ptr_arg always points to the stack, since continuation % environments are always allocated on the stack (unless % put_nondet_env_on_heap is true, which won't be the case when @@ -1882,16 +1880,15 @@ ml_gen_maybe_gc_trace_code_with_typeinfo(VarName, DeclType, TypeInfoRval, ---> construct_from_type(mer_type) ; already_provided(mlds_rval). -:- pred ml_gen_maybe_gc_trace_code_2(var_name::in, mer_type::in, - how_to_get_type_info::in, prog_context::in, - maybe(statement)::out, +:- pred ml_gen_maybe_gc_trace_code_2(mlds_var_name::in, mer_type::in, + how_to_get_type_info::in, prog_context::in, maybe(statement)::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_maybe_gc_trace_code_2(VarName, DeclType, HowToGetTypeInfo, Context, Maybe_GC_TraceCode, !Info) :- ml_gen_info_get_module_info(!.Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__get_gc_method(Globals, GC), + globals.get_gc_method(Globals, GC), ( GC = accurate, MLDS_DeclType = mercury_type_to_mlds_type(ModuleInfo, DeclType), @@ -1926,19 +1923,19 @@ ml_gen_maybe_gc_trace_code_2(VarName, DeclType, HowToGetTypeInfo, Context, % collector, i.e. if it might contain pointers. % % Any type for which we return `yes' here must be word-sized, because - % we will call private_builtin__gc_trace with its address, and that + % we will call private_builtin.gc_trace with its address, and that % procedure assumes that its argument is an `MR_Word *'. % % For floats, we can (and must) return `no' even though they might % get boxed in some circumstances, because if they are boxed then they will - % be represented as mlds__generic_type. + % be represented as mlds_generic_type. % % Note that with --gcc-nested-functions, cont_type will be a function % pointer that may point to a trampoline function, which might in fact % contain pointers. But the pointers will only be pointers to code and % pointers to the stack, not pointers to the heap, so we don't need to % trace them for accurate GC. Hence we can return `no' here for - % mlds__cont_type. + % mlds_cont_type. % % Similarly, the only pointers in type_ctor_infos and base_typeclass_infos % are to static code and/or static data, which do not need to be traced. @@ -1947,27 +1944,27 @@ ml_gen_maybe_gc_trace_code_2(VarName, DeclType, HowToGetTypeInfo, Context, ml_type_might_contain_pointers(mercury_type(_Type, TypeCategory, _)) = ml_type_category_might_contain_pointers(TypeCategory). -ml_type_might_contain_pointers(mercury_array_type(_)) = yes. -ml_type_might_contain_pointers(mlds__native_int_type) = no. -ml_type_might_contain_pointers(mlds__native_float_type) = no. -ml_type_might_contain_pointers(mlds__native_bool_type) = no. -ml_type_might_contain_pointers(mlds__native_char_type) = no. -ml_type_might_contain_pointers(mlds__foreign_type(_)) = no. +ml_type_might_contain_pointers(mlds_mercury_array_type(_)) = yes. +ml_type_might_contain_pointers(mlds_native_int_type) = no. +ml_type_might_contain_pointers(mlds_native_float_type) = no. +ml_type_might_contain_pointers(mlds_native_bool_type) = no. +ml_type_might_contain_pointers(mlds_native_char_type) = no. +ml_type_might_contain_pointers(mlds_foreign_type(_)) = no. % We assume that foreign types are not allowed to contain pointers % to the Mercury heap. XXX is this requirement too strict? -ml_type_might_contain_pointers(mlds__class_type(_, _, Category)) = - (if Category = mlds__enum then no else yes). -ml_type_might_contain_pointers(mlds__ptr_type(_)) = yes. -ml_type_might_contain_pointers(mlds__array_type(_)) = yes. -ml_type_might_contain_pointers(mlds__func_type(_)) = no. -ml_type_might_contain_pointers(mlds__generic_type) = yes. -ml_type_might_contain_pointers(mlds__generic_env_ptr_type) = yes. -ml_type_might_contain_pointers(mlds__type_info_type) = yes. -ml_type_might_contain_pointers(mlds__pseudo_type_info_type) = yes. -ml_type_might_contain_pointers(mlds__cont_type(_)) = no. -ml_type_might_contain_pointers(mlds__commit_type) = no. -ml_type_might_contain_pointers(mlds__rtti_type(_)) = yes. -ml_type_might_contain_pointers(mlds__unknown_type) = yes. +ml_type_might_contain_pointers(mlds_class_type(_, _, Category)) = + (if Category = mlds_enum then no else yes). +ml_type_might_contain_pointers(mlds_ptr_type(_)) = yes. +ml_type_might_contain_pointers(mlds_array_type(_)) = yes. +ml_type_might_contain_pointers(mlds_func_type(_)) = no. +ml_type_might_contain_pointers(mlds_generic_type) = yes. +ml_type_might_contain_pointers(mlds_generic_env_ptr_type) = yes. +ml_type_might_contain_pointers(mlds_type_info_type) = yes. +ml_type_might_contain_pointers(mlds_pseudo_type_info_type) = yes. +ml_type_might_contain_pointers(mlds_cont_type(_)) = no. +ml_type_might_contain_pointers(mlds_commit_type) = no. +ml_type_might_contain_pointers(mlds_rtti_type(_)) = yes. +ml_type_might_contain_pointers(mlds_unknown_type) = yes. :- func ml_type_category_might_contain_pointers(type_category) = bool. @@ -2008,10 +2005,10 @@ trace_type_info_type(Type, RealType) :- ; Name = "zero_base_typeclass_info", RealType = c_pointer_type ). - % Generate code to call to `private_builtin__gc_trace' + % Generate code to call to `private_builtin.gc_trace' % to trace the specified variable. % -:- pred ml_gen_gc_trace_code(var_name::in, mer_type::in, mer_type::in, +:- pred ml_gen_gc_trace_code(mlds_var_name::in, mer_type::in, mer_type::in, prog_context::in, statement::out, ml_gen_info::in, ml_gen_info::out) is det. @@ -2020,10 +2017,10 @@ ml_gen_gc_trace_code(VarName, DeclType, ActualType, Context, GC_TraceCode, % Build HLDS code to construct the type_info for this type. ml_gen_make_type_info_var(ActualType, Context, TypeInfoVar, HLDS_TypeInfoGoals, !Info), - NonLocalsList = list__map( + NonLocalsList = list.map( (func(_G - GI) = NL :- goal_info_get_nonlocals(GI, NL)), HLDS_TypeInfoGoals), - NonLocals = set__union_list(NonLocalsList), + NonLocals = set.union_list(NonLocalsList), instmap_delta_from_assoc_list([TypeInfoVar - ground(shared, none)], InstMapDelta), goal_info_init(NonLocals, InstMapDelta, det, purity_impure, GoalInfo), @@ -2057,28 +2054,28 @@ ml_gen_gc_trace_code(VarName, DeclType, ActualType, Context, GC_TraceCode, % XXX This is not a very robust way of doing things... ml_gen_info_get_varset(!.Info, VarSet), ml_gen_info_get_var_types(!.Info, VarTypes), - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), GenLocalVarDecl = (func(Var) = MLDS_Defn :- LocalVarName = ml_gen_var_name(VarSet, Var), - map__lookup(VarTypes, Var, LocalVarType), + map.lookup(VarTypes, Var, LocalVarType), MLDS_Defn = ml_gen_mlds_var_decl(var(LocalVarName), mercury_type_to_mlds_type(ModuleInfo, LocalVarType), no, MLDS_Context) ), - set__to_sorted_list(NonLocals, NonLocalVarList), - MLDS_NonLocalVarDecls = list__map(GenLocalVarDecl, NonLocalVarList), + set.to_sorted_list(NonLocals, NonLocalVarList), + MLDS_NonLocalVarDecls = list.map(GenLocalVarDecl, NonLocalVarList), % Combine the MLDS code fragments together. GC_TraceCode = ml_gen_block(MLDS_NewobjLocals ++ MLDS_NonLocalVarDecls, [MLDS_TypeInfoStatement] ++ [MLDS_TraceStatement], Context). % ml_gen_trace_var(VarName, DeclType, TypeInfo, Context, Code): - % Generate a call to `private_builtin__gc_trace' + % Generate a call to `private_builtin.gc_trace' % for the specified variable, given the variable's name, type, % and the already-constructed type_info for that type. % -:- pred ml_gen_trace_var(ml_gen_info::in, var_name::in, mer_type::in, +:- pred ml_gen_trace_var(ml_gen_info::in, mlds_var_name::in, mer_type::in, mlds_rval::in, prog_context::in, statement::out) is det. ml_gen_trace_var(Info, VarName, Type, TypeInfoRval, Context, TraceStatement) :- @@ -2087,27 +2084,27 @@ ml_gen_trace_var(Info, VarName, Type, TypeInfoRval, Context, TraceStatement) :- MLDS_Type = mercury_type_to_mlds_type(ModuleInfo, Type), ml_gen_var_lval(Info, VarName, MLDS_Type, VarLval), - % Generate the address of `private_builtin__gc_trace/1#0'. + % Generate the address of `private_builtin.gc_trace/1#0'. PredName = "gc_trace", PredOrigArity = 1, Pred = pred((predicate), no, PredName, PredOrigArity, model_det, no), - ProcId = hlds_pred__initial_proc_id, + ProcId = hlds_pred.initial_proc_id, mercury_private_builtin_module(PredModule), MLDS_Module = mercury_module_name_to_mlds(PredModule), Proc = qual(MLDS_Module, module_qual, Pred - ProcId), CPointerType = mercury_type(c_pointer_type, type_cat_user_ctor, non_foreign_type(c_pointer_type)), - ArgTypes = [mlds__pseudo_type_info_type, CPointerType], - Signature = mlds__func_signature(ArgTypes, []), + ArgTypes = [mlds_pseudo_type_info_type, CPointerType], + Signature = mlds_func_signature(ArgTypes, []), FuncAddr = const(code_addr_const(proc(Proc, Signature))), % Generate the call - % `private_builtin__gc_trace(TypeInfo, (MR_C_Pointer) &Var);'. + % `private_builtin.gc_trace(TypeInfo, (MR_C_Pointer) &Var);'. CastVarAddr = unop(cast(CPointerType), mem_addr(VarLval)), TraceStatement = statement( call(Signature, FuncAddr, no, [TypeInfoRval, CastVarAddr], [], ordinary_call - ), mlds__make_context(Context)). + ), mlds_make_context(Context)). % Generate HLDS code to construct the type_info for this type. % @@ -2124,7 +2121,7 @@ ml_gen_make_type_info_var(Type, Context, TypeInfoVar, TypeInfoGoals, !Info) :- % Call polymorphism.m to generate the HLDS code to create the type_infos. create_poly_info(ModuleInfo0, PredInfo0, ProcInfo0, PolyInfo0), - polymorphism__make_type_info_var(Type, Context, + polymorphism.make_type_info_var(Type, Context, TypeInfoVar, TypeInfoGoals, PolyInfo0, PolyInfo), poly_info_extract(PolyInfo, PredInfo0, PredInfo, ProcInfo0, ProcInfo, ModuleInfo1), @@ -2145,10 +2142,10 @@ ml_gen_make_type_info_var(Type, Context, TypeInfoVar, TypeInfoGoals, !Info) :- module_name :: mlds_module_name, % the current module - context :: mlds__context, + context :: mlds_context, % the current context - locals :: mlds__defns, + locals :: mlds_defns, % the local variable declarations % accumulated so far @@ -2163,11 +2160,11 @@ ml_gen_make_type_info_var(Type, Context, TypeInfoVar, TypeInfoGoals, !Info) :- % allocation. % :- pred fixup_newobj(statement::in, mlds_module_name::in, - statement::out, mlds__defns::out) is det. + statement::out, mlds_defns::out) is det. fixup_newobj(Statement0, ModuleName, Statement, Defns) :- Statement0 = statement(Stmt0, Context), - Info0 = fixup_newobj_info(ModuleName, Context, [], counter__init(0)), + Info0 = fixup_newobj_info(ModuleName, Context, [], counter.init(0)), fixup_newobj_in_stmt(Stmt0, Stmt, Info0, Info), Statement = statement(Stmt, Context), Defns = Info ^ locals. @@ -2181,13 +2178,13 @@ fixup_newobj_in_statement(Statement0, Statement, !Info) :- fixup_newobj_in_stmt(Stmt0, Stmt, !Info), Statement = statement(Stmt, Context). -:- pred fixup_newobj_in_stmt(mlds__stmt::in, mlds__stmt::out, +:- pred fixup_newobj_in_stmt(mlds_stmt::in, mlds_stmt::out, fixup_newobj_info::in, fixup_newobj_info::out) is det. fixup_newobj_in_stmt(Stmt0, Stmt, !Fixup) :- ( Stmt0 = block(Defns, Statements0), - list__map_foldl(fixup_newobj_in_statement, + list.map_foldl(fixup_newobj_in_statement, Statements0, Statements, !Fixup), Stmt = block(Defns, Statements) ; @@ -2201,7 +2198,7 @@ fixup_newobj_in_stmt(Stmt0, Stmt, !Fixup) :- Stmt = if_then_else(Cond, Then, MaybeElse) ; Stmt0 = switch(Type, Val, Range, Cases0, Default0), - list__map_foldl(fixup_newobj_in_case, Cases0, Cases, !Fixup), + list.map_foldl(fixup_newobj_in_case, Cases0, Cases, !Fixup), fixup_newobj_in_default(Default0, Default, !Fixup), Stmt = switch(Type, Val, Range, Cases, Default) ; @@ -2233,7 +2230,7 @@ fixup_newobj_in_stmt(Stmt0, Stmt, !Fixup) :- fixup_newobj_in_atomic_statement(AtomicStmt0, Stmt, !Fixup) ). -:- pred fixup_newobj_in_case(mlds__switch_case::in, mlds__switch_case::out, +:- pred fixup_newobj_in_case(mlds_switch_case::in, mlds_switch_case::out, fixup_newobj_info::in, fixup_newobj_info::out) is det. fixup_newobj_in_case(Conds - Statement0, Conds - Statement, !Fixup) :- @@ -2247,8 +2244,8 @@ fixup_newobj_in_maybe_statement(no, no, !Fixup). fixup_newobj_in_maybe_statement(yes(Statement0), yes(Statement), !Fixup) :- fixup_newobj_in_statement(Statement0, Statement, !Fixup). -:- pred fixup_newobj_in_default(mlds__switch_default::in, - mlds__switch_default::out, +:- pred fixup_newobj_in_default(mlds_switch_default::in, + mlds_switch_default::out, fixup_newobj_info::in, fixup_newobj_info::out) is det. fixup_newobj_in_default(default_is_unreachable, default_is_unreachable, @@ -2258,8 +2255,8 @@ fixup_newobj_in_default(default_case(Statement0), default_case(Statement), !Fixup) :- fixup_newobj_in_statement(Statement0, Statement, !Fixup). -:- pred fixup_newobj_in_atomic_statement(mlds__atomic_statement::in, - mlds__stmt::out, fixup_newobj_info::in, fixup_newobj_info::out) is det. +:- pred fixup_newobj_in_atomic_statement(mlds_atomic_statement::in, + mlds_stmt::out, fixup_newobj_info::in, fixup_newobj_info::out) is det. fixup_newobj_in_atomic_statement(AtomicStatement0, Stmt, !Fixup) :- ( @@ -2274,18 +2271,18 @@ fixup_newobj_in_atomic_statement(AtomicStatement0, Stmt, !Fixup) :- % length of the array is. We initialize it with null pointers and then % later generate assignment statements to fill in the values properly % (see below). - counter__allocate(Id, !.Fixup ^ next_id, NextId), - VarName = var_name("new_obj", yes(Id)), - VarType = mlds__array_type(mlds__generic_type), - NullPointers = list__duplicate(list__length(ArgRvals), - init_obj(const(mlds__null(mlds__generic_type)))), + counter.allocate(Id, !.Fixup ^ next_id, NextId), + VarName = mlds_var_name("new_obj", yes(Id)), + VarType = mlds_array_type(mlds_generic_type), + NullPointers = list.duplicate(list.length(ArgRvals), + init_obj(const(mlds.null(mlds_generic_type)))), Initializer = init_array(NullPointers), % This is used for the type_infos allocated during tracing, % and we don't need to trace them. MaybeGCTraceCode = no, Context = !.Fixup ^ context, - VarDecl = ml_gen_mlds_var_decl(var(VarName), - VarType, Initializer, MaybeGCTraceCode, Context), + VarDecl = ml_gen_mlds_var_decl(var(VarName), VarType, Initializer, + MaybeGCTraceCode, Context), !:Fixup = !.Fixup ^ next_id := NextId, !:Fixup= !.Fixup ^ locals := !.Fixup ^ locals ++ [VarDecl], @@ -2297,11 +2294,10 @@ fixup_newobj_in_atomic_statement(AtomicStatement0, Stmt, !Fixup) :- % atomic_statement occurs, rather than at the local variable % declaration. - VarLval = mlds__var(qual(!.Fixup ^ module_name, module_qual, - VarName), VarType), - PtrRval = mlds__unop(cast(PointerType), mem_addr(VarLval)), - list__map_foldl( - init_field_n(PointerType, PtrRval, Context), + VarLval = var(qual(!.Fixup ^ module_name, module_qual, VarName), + VarType), + PtrRval = unop(cast(PointerType), mem_addr(VarLval)), + list.map_foldl(init_field_n(PointerType, PtrRval, Context), ArgRvals, ArgInitStatements, 0, _NumFields), % Generate code to assign the address of the new local variable @@ -2314,15 +2310,14 @@ fixup_newobj_in_atomic_statement(AtomicStatement0, Stmt, !Fixup) :- Stmt = atomic(AtomicStatement0) ). -:- pred init_field_n(mlds_type::in, mlds_rval::in, - mlds__context::in, mlds_rval::in, statement::out, - int::in, int::out) is det. +:- pred init_field_n(mlds_type::in, mlds_rval::in, mlds_context::in, + mlds_rval::in, statement::out, int::in, int::out) is det. init_field_n(PointerType, PointerRval, Context, ArgRval, Statement, FieldNum, FieldNum + 1) :- FieldId = offset(const(int_const(FieldNum))), % XXX FieldType is wrong for --high-level-data - FieldType = mlds__generic_type, + FieldType = mlds_generic_type, MaybeTag = yes(0), Field = field(MaybeTag, PointerRval, FieldId, FieldType, PointerType), AssignStmt = atomic(assign(Field, ArgRval)), @@ -2352,7 +2347,7 @@ maybe_tag_rval(yes(Tag), Type, Rval) = unop(cast(Type), mkword(Tag, Rval)). % (unless accurate GC is enabled, in which case the % varset and var_types may get updated if we create % fresh variables for type_info variables needed - % for calls to private_builtin__gc_trace). + % for calls to private_builtin.gc_trace). module_info :: module_info, pred_id :: pred_id, @@ -2374,7 +2369,7 @@ maybe_tag_rval(yes(Tag), Type, Rval) = unop(cast(Type), mkword(Tag, Rval)). cond_var :: counter, conv_var :: counter, const_num :: counter, - const_var_name_map :: map(prog_var, mlds__var_name), + const_var_name_map :: map(prog_var, mlds_var_name), success_cont_stack :: stack(success_cont), % A partial mapping from vars to lvals, % used to override the normal lval @@ -2384,7 +2379,7 @@ maybe_tag_rval(yes(Tag), Type, Rval) = unop(cast(Type), mkword(Tag, Rval)). % constants which should be inserted % before the definition of the function % for the current procedure. - extra_defns :: mlds__defns + extra_defns :: mlds_defns ). ml_gen_info_init(ModuleInfo, PredId, ProcId) = Info :- @@ -2405,15 +2400,15 @@ ml_gen_info_init(ModuleInfo, PredId, ProcId) = Info :- % % ( See ml_elim_nested.gen_gc_trace_func/8 for details). % - counter__init(1, FuncLabelCounter), - counter__init(0, CommitLabelCounter), - counter__init(0, LabelCounter), - counter__init(0, CondVarCounter), - counter__init(0, ConvVarCounter), - counter__init(0, ConstCounter), - map__init(ConstNumMap), - stack__init(SuccContStack), - map__init(VarLvals), + counter.init(1, FuncLabelCounter), + counter.init(0, CommitLabelCounter), + counter.init(0, LabelCounter), + counter.init(0, CondVarCounter), + counter.init(0, ConvVarCounter), + counter.init(0, ConstCounter), + map.init(ConstNumMap), + stack.init(SuccContStack), + map.init(VarLvals), ExtraDefns = [], Info = ml_gen_info( @@ -2455,12 +2450,12 @@ ml_gen_info_set_value_output_vars(OutputVars, Info, ml_gen_info_use_gcc_nested_functions(Info, UseNestedFuncs) :- ml_gen_info_get_globals(Info, Globals), - globals__lookup_bool_option(Globals, gcc_nested_functions, + globals.lookup_bool_option(Globals, gcc_nested_functions, UseNestedFuncs). ml_gen_info_put_commit_in_own_func(Info, PutCommitInNestedFunc) :- ml_gen_info_get_globals(Info, Globals), - globals__lookup_bool_option(Globals, put_commit_in_own_func, + globals.lookup_bool_option(Globals, put_commit_in_own_func, PutCommitInNestedFunc). ml_gen_info_get_globals(Info, Globals) :- @@ -2469,68 +2464,68 @@ ml_gen_info_get_globals(Info, Globals) :- ml_gen_info_new_label(Label, !Info) :- Counter0 = !.Info ^ label, - counter__allocate(Label, Counter0, Counter), + counter.allocate(Label, Counter0, Counter), !:Info = !.Info ^ label := Counter. ml_gen_info_new_func_label(Label, !Info) :- Counter0 = !.Info ^ func_label, - counter__allocate(Label, Counter0, Counter), + counter.allocate(Label, Counter0, Counter), !:Info = !.Info ^ func_label := Counter. ml_gen_info_bump_counters(!Info) :- FuncLabelCounter0 = !.Info ^ func_label, ConstNumCounter0 = !.Info ^ const_num, - counter__allocate(FuncLabel, FuncLabelCounter0, _), - counter__allocate(ConstNum, ConstNumCounter0, _), - FuncLabelCounter = counter__init(FuncLabel + 10000), - ConstNumCounter = counter__init(ConstNum + 10000), + counter.allocate(FuncLabel, FuncLabelCounter0, _), + counter.allocate(ConstNum, ConstNumCounter0, _), + FuncLabelCounter = counter.init(FuncLabel + 10000), + ConstNumCounter = counter.init(ConstNum + 10000), !:Info = !.Info ^ func_label := FuncLabelCounter, !:Info = !.Info ^ const_num := ConstNumCounter. ml_gen_info_new_commit_label(CommitLabel, !Info) :- Counter0 = !.Info ^ commit_label, - counter__allocate(CommitLabel, Counter0, Counter), + counter.allocate(CommitLabel, Counter0, Counter), !:Info = !.Info ^ commit_label := Counter. ml_gen_info_new_cond_var(CondVar, !Info) :- Counter0 = !.Info ^ cond_var, - counter__allocate(CondVar, Counter0, Counter), + counter.allocate(CondVar, Counter0, Counter), !:Info = !.Info ^ cond_var := Counter. ml_gen_info_new_conv_var(ConvVar, !Info) :- Counter0 = !.Info ^ conv_var, - counter__allocate(ConvVar, Counter0, Counter), + counter.allocate(ConvVar, Counter0, Counter), !:Info = !.Info ^ conv_var := Counter. ml_gen_info_new_const(ConstVar, !Info) :- Counter0 = !.Info ^ const_num, - counter__allocate(ConstVar, Counter0, Counter), + counter.allocate(ConstVar, Counter0, Counter), !:Info = !.Info ^ const_num := Counter. ml_gen_info_set_const_var_name(Var, Name, !Info) :- !:Info = !.Info ^ const_var_name_map := - map__set(!.Info ^ const_var_name_map, Var, Name). + map.set(!.Info ^ const_var_name_map, Var, Name). ml_gen_info_lookup_const_var_name(Info, Var, Name) :- - Name = map__lookup(Info ^ const_var_name_map, Var). + Name = map.lookup(Info ^ const_var_name_map, Var). ml_gen_info_search_const_var_name(Info, Var, Name) :- - Name = map__search(Info ^ const_var_name_map, Var). + Name = map.search(Info ^ const_var_name_map, Var). ml_gen_info_push_success_cont(SuccCont, !Info) :- !:Info = !.Info ^ success_cont_stack := - stack__push(!.Info ^ success_cont_stack, SuccCont). + stack.push(!.Info ^ success_cont_stack, SuccCont). ml_gen_info_pop_success_cont(!Info) :- Stack0 = !.Info ^ success_cont_stack, - stack__pop_det(Stack0, _SuccCont, Stack), + stack.pop_det(Stack0, _SuccCont, Stack), !:Info = !.Info ^ success_cont_stack := Stack. ml_gen_info_current_success_cont(Info, SuccCont) :- - stack__top_det(Info ^ success_cont_stack, SuccCont). + stack.top_det(Info ^ success_cont_stack, SuccCont). ml_gen_info_set_var_lval(Var, Lval, !Info) :- - !:Info = !.Info ^ var_lvals := map__set(!.Info ^ var_lvals, Var, Lval). + !:Info = !.Info ^ var_lvals := map.set(!.Info ^ var_lvals, Var, Lval). ml_gen_info_get_var_lvals(Info, Info ^ var_lvals). ml_gen_info_set_var_lvals(VarLvals, !Info) :- @@ -2551,7 +2546,7 @@ select_output_vars(ModuleInfo, HeadVars, HeadModes, VarTypes) = OutputVars :- ; HeadVars = [Var | Vars], HeadModes = [Mode | Modes], - map__lookup(VarTypes, Var, VarType), + map.lookup(VarTypes, Var, VarType), ( mode_to_arg_mode(ModuleInfo, Mode, VarType, top_out) -> @@ -2618,9 +2613,9 @@ ml_base_typeclass_info_method_offset = 4. get_copy_out_option(Globals, CodeModel) = CopyOut :- ( CodeModel = model_non -> - globals__lookup_bool_option(Globals, nondet_copy_out, CopyOut) + globals.lookup_bool_option(Globals, nondet_copy_out, CopyOut) ; - globals__lookup_bool_option(Globals, det_copy_out, CopyOut) + globals.lookup_bool_option(Globals, det_copy_out, CopyOut) ). fixup_builtin_module(ModuleName0) = ModuleName :- diff --git a/compiler/ml_elim_nested.m b/compiler/ml_elim_nested.m index fd2182a3b..bfc235290 100644 --- a/compiler/ml_elim_nested.m +++ b/compiler/ml_elim_nested.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1999-2005 The University of Melbourne. +% Copyright (C) 1999-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -415,7 +415,7 @@ %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- module ml_backend__ml_elim_nested. +:- module ml_backend.ml_elim_nested. :- interface. @@ -464,27 +464,27 @@ % Perform the specified action on the whole MLDS. % ml_elim_nested(Action, MLDS0, MLDS, !IO) :- - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), MLDS0 = mlds(ModuleName, ForeignCode, Imports, Defns0, InitPreds, FinalPreds), MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName), OuterVars = [], - DefnsList = list__map( + DefnsList = list.map( ml_elim_nested_defns(Action, MLDS_ModuleName, Globals, OuterVars), Defns0), - Defns1 = list__condense(DefnsList), + Defns1 = list.condense(DefnsList), % The MLDS code generator sometimes generates two definitions of the % same RTTI constant as local constants in two different functions. % When we hoist them out, that leads to duplicate definitions here. % So we need to check for and eliminate any duplicate definitions % of constants. - Defns = list__remove_dups(Defns1), + Defns = list.remove_dups(Defns1), MLDS = mlds(ModuleName, ForeignCode, Imports, Defns, InitPreds, FinalPreds). % Either eliminated nested functions: - % Hoist out any nested function occurring in a single mlds__defn. - % Return a list of mlds__defns that contains no nested functions. + % Hoist out any nested function occurring in a single mlds_defn. + % Return a list of mlds_defns that contains no nested functions. % % Or handle accurate GC: put all variables that might contain pointers % in structs and chain these structs together into a "shadow stack". @@ -492,12 +492,12 @@ ml_elim_nested(Action, MLDS0, MLDS, !IO) :- % whose address is stored in the shadow stack frame. % :- func ml_elim_nested_defns(action, mlds_module_name, globals, outervars, - mlds__defn) = list(mlds__defn). + mlds_defn) = list(mlds_defn). ml_elim_nested_defns(Action, ModuleName, Globals, OuterVars, Defn0) = Defns :- - Defn0 = mlds__defn(Name, Context, Flags, DefnBody0), + Defn0 = mlds_defn(Name, Context, Flags, DefnBody0), ( - DefnBody0 = mlds__function(PredProcId, Params0, + DefnBody0 = mlds_function(PredProcId, Params0, defined_here(FuncBody0), Attributes), % Don't add GC tracing code to the gc_trace/1 primitive! % (Doing so would just slow things down unnecessarily.) @@ -523,7 +523,7 @@ ml_elim_nested_defns(Action, ModuleName, Globals, OuterVars, Defn0) = Defns :- % ElimInfo0 = elim_info_init(Action, ModuleName, OuterVars, EnvTypeName, EnvPtrTypeName, Globals), - Params0 = mlds__func_params(Arguments0, RetValues), + Params0 = mlds_func_params(Arguments0, RetValues), ml_maybe_add_args(Arguments0, FuncBody0, ModuleName, Context, ElimInfo0, ElimInfo1), flatten_arguments(Arguments0, Arguments1, ElimInfo1, ElimInfo2), @@ -532,11 +532,11 @@ ml_elim_nested_defns(Action, ModuleName, Globals, OuterVars, Defn0) = Defns :- % Split the locals that we need to process into local variables % and local static constants. - list__filter(ml_decl_is_static_const, Locals, LocalStatics, LocalVars), + list.filter(ml_decl_is_static_const, Locals, LocalStatics, LocalVars), % Fix up access flags on the statics that we're going to hoist: % convert "local" to "private". - HoistedStatics = list__map(convert_local_to_global, LocalStatics), + HoistedStatics = list.map(convert_local_to_global, LocalStatics), ( % When hoisting nested functions, if there were no nested % functions, then we just hoist the local static constants. @@ -563,7 +563,7 @@ ml_elim_nested_defns(Action, ModuleName, Globals, OuterVars, Defn0) = Defns :- ml_create_env(Action, EnvName, EnvTypeName, LocalVars, Context, ModuleName, Name, Globals, EnvTypeDefn, EnvDecls, InitEnv, GCTraceFuncDefns), - list__map_foldl( + list.map_foldl( ml_insert_init_env(Action, EnvTypeName, ModuleName, Globals), NestedFuncs0, NestedFuncs, no, InsertedEnv), @@ -642,38 +642,38 @@ ml_elim_nested_defns(Action, ModuleName, Globals, OuterVars, Defn0) = Defns :- % annotation on the arguments anymore. We delete them here, because % otherwise the `#if 0 ... #endif' blocks output for the % annotations clutter up the generated C files. - Arguments = list__map(strip_gc_trace_code, Arguments1) + Arguments = list.map(strip_gc_trace_code, Arguments1) ; Action = hoist_nested_funcs, Arguments = Arguments1 ), - Params = mlds__func_params(Arguments, RetValues), - DefnBody = mlds__function(PredProcId, Params, + Params = mlds_func_params(Arguments, RetValues), + DefnBody = mlds_function(PredProcId, Params, defined_here(FuncBody), Attributes), - Defn = mlds__defn(Name, Context, Flags, DefnBody), - Defns = list__append(HoistedDefns, [Defn]) + Defn = mlds_defn(Name, Context, Flags, DefnBody), + Defns = list.append(HoistedDefns, [Defn]) ; % Leave definitions of things other than functions unchanged. Defns = [Defn0] ). -:- func strip_gc_trace_code(mlds__argument) = mlds__argument. +:- func strip_gc_trace_code(mlds_argument) = mlds_argument. strip_gc_trace_code(Argument0) = Argument :- - Argument0 = mlds__argument(Name, Type, _MaybeGCTraceCode), - Argument = mlds__argument(Name, Type, no). + Argument0 = mlds_argument(Name, Type, _MaybeGCTraceCode), + Argument = mlds_argument(Name, Type, no). % Add any arguments which are used in nested functions % to the local_data field in the elim_info. % -:- pred ml_maybe_add_args(mlds__arguments::in, statement::in, - mlds_module_name::in, mlds__context::in, +:- pred ml_maybe_add_args(mlds_arguments::in, statement::in, + mlds_module_name::in, mlds_context::in, elim_info::in, elim_info::out) is det. ml_maybe_add_args([], _, _, _, !Info). ml_maybe_add_args([Arg|Args], FuncBody, ModuleName, Context, !Info) :- ( - Arg = mlds__argument(data(var(VarName)), _Type, GC_TraceCode), + Arg = mlds_argument(data(var(VarName)), _Type, GC_TraceCode), ml_should_add_local_data(!.Info, var(VarName), GC_TraceCode, [], [FuncBody]) -> @@ -687,9 +687,9 @@ ml_maybe_add_args([Arg|Args], FuncBody, ModuleName, Context, !Info) :- % Generate code to copy any arguments which are used in nested functions % to the environment struct. % -:- pred ml_maybe_copy_args(mlds__arguments::in, statement::in, - elim_info::in, mlds_type::in, mlds_type::in, mlds__context::in, - mlds__defns::out, statements::out) is det. +:- pred ml_maybe_copy_args(mlds_arguments::in, statement::in, + elim_info::in, mlds_type::in, mlds_type::in, mlds_context::in, + mlds_defns::out, statements::out) is det. ml_maybe_copy_args([], _, _, _, _, _, [], []). ml_maybe_copy_args([Arg|Args], FuncBody, ElimInfo, ClassType, EnvPtrTypeName, @@ -698,7 +698,7 @@ ml_maybe_copy_args([Arg|Args], FuncBody, ElimInfo, ClassType, EnvPtrTypeName, EnvPtrTypeName, Context, ArgsToCopy0, CodeToCopyArgs0), ModuleName = elim_info_get_module_name(ElimInfo), ( - Arg = mlds__argument(data(var(VarName)), FieldType, GC_TraceCode), + Arg = mlds_argument(data(var(VarName)), FieldType, GC_TraceCode), ml_should_add_local_data(ElimInfo, var(VarName), GC_TraceCode, [], [FuncBody]) -> @@ -707,16 +707,16 @@ ml_maybe_copy_args([Arg|Args], FuncBody, ElimInfo, ClassType, EnvPtrTypeName, % Generate code to copy this arg to the environment struct: % env_ptr->foo = foo; % - QualVarName = qual(ModuleName, mlds__module_qual, VarName), + QualVarName = qual(ModuleName, module_qual, VarName), EnvModuleName = ml_env_module_name(ClassType, ElimInfo ^ elim_info_globals), FieldNameString = ml_var_name_to_string(VarName), - FieldName = named_field(qual(EnvModuleName, mlds__type_qual, + FieldName = named_field(qual(EnvModuleName, type_qual, FieldNameString), EnvPtrTypeName), Tag = yes(0), EnvPtrName = env_name_base(ElimInfo ^ action) ++ "_ptr", - EnvPtr = lval(var(qual(ModuleName, mlds__module_qual, - mlds__var_name(EnvPtrName, no)), EnvPtrTypeName)), + EnvPtr = lval(var(qual(ModuleName, module_qual, + mlds_var_name(EnvPtrName, no)), EnvPtrTypeName)), EnvArgLval = field(Tag, EnvPtr, FieldName, FieldType, EnvPtrTypeName), ArgRval = lval(var(QualVarName, FieldType)), AssignToEnv = assign(EnvArgLval, ArgRval), @@ -731,22 +731,22 @@ ml_maybe_copy_args([Arg|Args], FuncBody, ElimInfo, ClassType, EnvPtrTypeName, % Create the environment struct type. % -:- func ml_create_env_type_name(mlds__class_name, mlds_module_name, globals) = +:- func ml_create_env_type_name(mlds_class_name, mlds_module_name, globals) = mlds_type. ml_create_env_type_name(EnvClassName, ModuleName, Globals) = EnvTypeName :- % If we're allocating it on the heap, then we need to use a class type % rather than a struct (value type). This is needed for verifiable code % on the IL back-end. - globals__lookup_bool_option(Globals, put_nondet_env_on_heap, OnHeap), + globals.lookup_bool_option(Globals, put_nondet_env_on_heap, OnHeap), ( OnHeap = yes, - EnvTypeKind = mlds__class + EnvTypeKind = mlds_class ; OnHeap = no, - EnvTypeKind = mlds__struct + EnvTypeKind = mlds_struct ), - EnvTypeName = class_type(qual(ModuleName, module_qual, EnvClassName), + EnvTypeName = mlds_class_type(qual(ModuleName, module_qual, EnvClassName), 0, EnvTypeKind). % Create the environment struct type, the declaration of the environment @@ -773,11 +773,11 @@ ml_create_env_type_name(EnvClassName, ModuleName, Globals) = EnvTypeName :- % env_ptr = &env; % stack_chain = env_ptr; % -:- pred ml_create_env(action::in, mlds__class_name::in, mlds_type::in, - list(mlds__defn)::in, mlds__context::in, mlds_module_name::in, - mlds__entity_name::in, globals::in, mlds__defn::out, - list(mlds__defn)::out, list(statement)::out, - list(mlds__defn)::out) is det. +:- pred ml_create_env(action::in, mlds_class_name::in, mlds_type::in, + list(mlds_defn)::in, mlds_context::in, mlds_module_name::in, + mlds_entity_name::in, globals::in, mlds_defn::out, + list(mlds_defn)::out, list(statement)::out, + list(mlds_defn)::out) is det. ml_create_env(Action, EnvClassName, EnvTypeName, LocalVars, Context, ModuleName, FuncName, Globals, EnvTypeDefn, EnvDecls, InitEnv, @@ -796,23 +796,23 @@ ml_create_env(Action, EnvClassName, EnvTypeName, LocalVars, Context, % If we're allocating it on the heap, then we need to use a class type % rather than a struct (value type). This is needed for verifiable code % on the IL back-end. - globals__lookup_bool_option(Globals, put_nondet_env_on_heap, OnHeap), + globals.lookup_bool_option(Globals, put_nondet_env_on_heap, OnHeap), ( OnHeap = yes, - EnvTypeKind = mlds__class, - BaseClasses = [mlds__generic_env_ptr_type] + EnvTypeKind = mlds_class, + BaseClasses = [mlds_generic_env_ptr_type] ; OnHeap = no, - EnvTypeKind = mlds__struct, + EnvTypeKind = mlds_struct, BaseClasses = [] ), EnvTypeEntityName = type(EnvClassName, 0), EnvTypeFlags = env_type_decl_flags, - Fields0 = list__map(convert_local_to_field, LocalVars), + Fields0 = list.map(convert_local_to_field, LocalVars), % Extract the GC tracing code from the fields. - list__map2(extract_gc_trace_code, Fields0, Fields1, GC_TraceStatements0), - GC_TraceStatements = list__condense(GC_TraceStatements0), + list.map2(extract_gc_trace_code, Fields0, Fields1, GC_TraceStatements0), + GC_TraceStatements = list.condense(GC_TraceStatements0), ( Action = chain_gc_stack_frames -> ml_chain_stack_frames(Fields1, GC_TraceStatements, EnvTypeName, @@ -836,20 +836,20 @@ ml_create_env(Action, EnvClassName, EnvTypeName, LocalVars, Context, Imports = [], Ctors = [], % mlds_to_il.m will add an empty constructor if needed. Interfaces = [], - EnvTypeDefnBody = mlds__class(mlds__class_defn(EnvTypeKind, Imports, + EnvTypeDefnBody = mlds_class(mlds_class_defn(EnvTypeKind, Imports, BaseClasses, Interfaces, Ctors, Fields)), - EnvTypeDefn = mlds__defn(EnvTypeEntityName, Context, EnvTypeFlags, + EnvTypeDefn = mlds_defn(EnvTypeEntityName, Context, EnvTypeFlags, EnvTypeDefnBody), % Generate the following variable declaration: % % struct env; // = { ... } % - EnvVarName = var_name(env_name_base(Action), no), + EnvVarName = mlds_var_name(env_name_base(Action), no), EnvVarEntityName = data(var(EnvVarName)), EnvVarFlags = ml_gen_local_var_decl_flags, - EnvVarDefnBody = mlds__data(EnvTypeName, EnvInitializer, GC_TraceEnv), - EnvVarDecl = mlds__defn(EnvVarEntityName, Context, EnvVarFlags, + EnvVarDefnBody = mlds_data(EnvTypeName, EnvInitializer, GC_TraceEnv), + EnvVarDecl = mlds_defn(EnvVarEntityName, Context, EnvVarFlags, EnvVarDefnBody), % Declare the `env_ptr' var, and initialize the `env_ptr' with the @@ -877,10 +877,10 @@ ml_create_env(Action, EnvClassName, EnvTypeName, LocalVars, Context, EnvDecls = [EnvVarDecl, EnvPtrVarDecl], InitEnv = NewObj ++ [InitEnv0] ++ LinkStackChain. -:- pred ml_chain_stack_frames(mlds__defns::in, statements::in, - mlds_type::in, mlds__context::in, mlds__entity_name::in, - mlds_module_name::in, globals::in, mlds__defns::out, - mlds__initializer::out, statements::out, mlds__defns::out) +:- pred ml_chain_stack_frames(mlds_defns::in, statements::in, + mlds_type::in, mlds_context::in, mlds_entity_name::in, + mlds_module_name::in, globals::in, mlds_defns::out, + mlds_initializer::out, statements::out, mlds_defns::out) is det. ml_chain_stack_frames(Fields0, GCTraceStatements, EnvTypeName, Context, @@ -892,9 +892,10 @@ ml_chain_stack_frames(Fields0, GCTraceStatements, EnvTypeName, Context, % struct foo_frame *frame; % frame = (struct foo_frame *) this_frame; % - ThisFrameName = qual(ModuleName, module_qual, var_name("this_frame", no)), - ThisFrameRval = lval(var(ThisFrameName, mlds__generic_type)), - CastThisFrameRval = unop(cast(mlds__ptr_type(EnvTypeName)), ThisFrameRval), + ThisFrameName = qual(ModuleName, module_qual, + mlds_var_name("this_frame", no)), + ThisFrameRval = lval(var(ThisFrameName, mlds_generic_type)), + CastThisFrameRval = unop(cast(mlds_ptr_type(EnvTypeName)), ThisFrameRval), ml_init_env(chain_gc_stack_frames, EnvTypeName, CastThisFrameRval, Context, ModuleName, Globals, FramePtrDecl, InitFramePtr), @@ -915,18 +916,18 @@ ml_chain_stack_frames(Fields0, GCTraceStatements, EnvTypeName, Context, % % void *prev; % void (*trace)(...); - PrevFieldName = data(var(var_name("prev", no))), + PrevFieldName = data(var(mlds_var_name("prev", no))), PrevFieldFlags = ml_gen_public_field_decl_flags, PrevFieldType = ml_stack_chain_type, - PrevFieldDefnBody = mlds__data(PrevFieldType, no_initializer, no), - PrevFieldDecl = mlds__defn(PrevFieldName, Context, PrevFieldFlags, + PrevFieldDefnBody = mlds_data(PrevFieldType, no_initializer, no), + PrevFieldDecl = mlds_defn(PrevFieldName, Context, PrevFieldFlags, PrevFieldDefnBody), - TraceFieldName = data(var(var_name("trace", no))), + TraceFieldName = data(var(mlds_var_name("trace", no))), TraceFieldFlags = ml_gen_public_field_decl_flags, - TraceFieldType = mlds__func_type(GCTraceFuncParams), - TraceFieldDefnBody = mlds__data(TraceFieldType, no_initializer, no), - TraceFieldDecl = mlds__defn(TraceFieldName, Context, TraceFieldFlags, + TraceFieldType = mlds_func_type(GCTraceFuncParams), + TraceFieldDefnBody = mlds_data(TraceFieldType, no_initializer, no), + TraceFieldDecl = mlds_defn(TraceFieldName, Context, TraceFieldFlags, TraceFieldDefnBody), Fields = [PrevFieldDecl, TraceFieldDecl | Fields0], @@ -958,29 +959,29 @@ ml_chain_stack_frames(Fields0, GCTraceStatements, EnvTypeName, Context, % stack_chain = frame_ptr; EnvPtrTypeName = ml_make_env_ptr_type(Globals, EnvTypeName), EnvPtr = lval(var(qual(ModuleName, module_qual, - mlds__var_name("frame_ptr", no)), EnvPtrTypeName)), + mlds_var_name("frame_ptr", no)), EnvPtrTypeName)), AssignToStackChain = assign(StackChain, EnvPtr), LinkStackChain = [statement(atomic(AssignToStackChain), Context)]. -:- pred gen_gc_trace_func(mlds__entity_name::in, mlds_module_name::in, - mlds__defn::in, list(statement)::in, mlds__context::in, - mlds__code_addr::out, mlds__func_params::out, mlds__defn::out) is det. +:- pred gen_gc_trace_func(mlds_entity_name::in, mlds_module_name::in, + mlds_defn::in, list(statement)::in, mlds_context::in, + mlds_code_addr::out, mlds_func_params::out, mlds_defn::out) is det. gen_gc_trace_func(FuncName, PredModule, FramePointerDecl, GCTraceStatements, Context, GCTraceFuncAddr, FuncParams, GCTraceFuncDefn) :- % Compute the signature of the GC tracing function - ArgName = data(var(var_name("this_frame", no))), - ArgType = mlds__generic_type, - Argument = mlds__argument(ArgName, ArgType, no), - FuncParams = mlds__func_params([Argument], []), - Signature = mlds__get_func_signature(FuncParams), + ArgName = data(var(mlds_var_name("this_frame", no))), + ArgType = mlds_generic_type, + Argument = mlds_argument(ArgName, ArgType, no), + FuncParams = mlds_func_params([Argument], []), + Signature = mlds_get_func_signature(FuncParams), % Compute the name of the GC tracing function % % To compute the name, we just take the name of the original function % and add 100000 to the original function's sequence number. % XXX This is a bit of a hack; maybe we should add - % another field to the `function' ctor for mlds__entity_name. + % another field to the `function' ctor for mlds_entity_name. % ( FuncName = function(PredLabel, ProcId, MaybeSeqNum, PredId) -> ( @@ -1003,14 +1004,14 @@ gen_gc_trace_func(FuncName, PredModule, FramePointerDecl, GCTraceStatements, DeclFlags = ml_gen_gc_trace_func_decl_flags, MaybePredProcId = no, Attributes = [], - FuncDefn = function(MaybePredProcId, FuncParams, + FuncDefn = mlds_function(MaybePredProcId, FuncParams, defined_here(Statement), Attributes), - GCTraceFuncDefn = mlds__defn(GCTraceFuncName, Context, DeclFlags, + GCTraceFuncDefn = mlds_defn(GCTraceFuncName, Context, DeclFlags, FuncDefn). % Return the declaration flags appropriate for a procedure definition. % -:- func ml_gen_gc_trace_func_decl_flags = mlds__decl_flags. +:- func ml_gen_gc_trace_func_decl_flags = mlds_decl_flags. ml_gen_gc_trace_func_decl_flags = MLDS_DeclFlags :- Access = private, @@ -1022,13 +1023,13 @@ ml_gen_gc_trace_func_decl_flags = MLDS_DeclFlags :- MLDS_DeclFlags = init_decl_flags(Access, PerInstance, Virtuality, Finality, Constness, Abstractness). -:- pred extract_gc_trace_code(mlds__defn::in, mlds__defn::out, +:- pred extract_gc_trace_code(mlds_defn::in, mlds_defn::out, statements::out) is det. -extract_gc_trace_code(mlds__defn(Name, Context, Flags, Body0), - mlds__defn(Name, Context, Flags, Body), GCTraceStmts) :- - ( Body0 = data(Type, Init, yes(GCTraceStmt)) -> - Body = data(Type, Init, no), +extract_gc_trace_code(mlds_defn(Name, Context, Flags, Body0), + mlds_defn(Name, Context, Flags, Body), GCTraceStmts) :- + ( Body0 = mlds_data(Type, Init, yes(GCTraceStmt)) -> + Body = mlds_data(Type, Init, no), GCTraceStmts = [GCTraceStmt] ; Body = Body0, @@ -1041,10 +1042,10 @@ extract_gc_trace_code(mlds__defn(Name, Context, Flags, Body0), % or block, not for fields. Currently we change it to `public'. % (Perhaps changing it to `default' might be better?) % -:- func convert_local_to_field(mlds__defn) = mlds__defn. +:- func convert_local_to_field(mlds_defn) = mlds_defn. -convert_local_to_field(mlds__defn(Name, Context, Flags0, Body)) = - mlds__defn(Name, Context, Flags, Body) :- +convert_local_to_field(mlds_defn(Name, Context, Flags0, Body)) = + mlds_defn(Name, Context, Flags, Body) :- ( access(Flags0) = local -> Flags = set_access(Flags0, public) ; @@ -1054,10 +1055,10 @@ convert_local_to_field(mlds__defn(Name, Context, Flags0, Body)) = % Similarly, when converting local statics into global statics, we need to % change `local' access to something else -- we use `private'. % -:- func convert_local_to_global(mlds__defn) = mlds__defn. +:- func convert_local_to_global(mlds_defn) = mlds_defn. -convert_local_to_global(mlds__defn(Name, Context, Flags0, Body)) = - mlds__defn(Name, Context, Flags, Body) :- +convert_local_to_global(mlds_defn(Name, Context, Flags0, Body)) = + mlds_defn(Name, Context, Flags, Body) :- ( access(Flags0) = local -> Flags = set_access(Flags0, private) ; @@ -1085,24 +1086,24 @@ convert_local_to_global(mlds__defn(Name, Context, Flags0, Body)) = % otherwise leave it unchanged. % :- pred ml_insert_init_env(action::in, mlds_type::in, mlds_module_name::in, - globals::in, mlds__defn::in, mlds__defn::out, bool::in, bool::out) + globals::in, mlds_defn::in, mlds_defn::out, bool::in, bool::out) is det. ml_insert_init_env(Action, TypeName, ModuleName, Globals, Defn0, Defn, Init0, Init) :- - Defn0 = mlds__defn(Name, Context, Flags, DefnBody0), + Defn0 = mlds_defn(Name, Context, Flags, DefnBody0), ( - DefnBody0 = mlds__function(PredProcId, Params, + DefnBody0 = mlds_function(PredProcId, Params, defined_here(FuncBody0), Attributes), statement_contains_var(FuncBody0, qual(ModuleName, module_qual, - var(mlds__var_name("env_ptr", no)))) + var(mlds_var_name("env_ptr", no)))) -> EnvPtrVal = lval(var(qual(ModuleName, module_qual, - mlds__var_name("env_ptr_arg", no)), - mlds__generic_env_ptr_type)), + mlds_var_name("env_ptr_arg", no)), + mlds_generic_env_ptr_type)), EnvPtrVarType = ml_make_env_ptr_type(Globals, TypeName), - % Insert a cast, to downcast from mlds__generic_env_ptr_type to the + % Insert a cast, to downcast from mlds_generic_env_ptr_type to the % specific environment type for this procedure. CastEnvPtrVal = unop(cast(EnvPtrVarType), EnvPtrVal), @@ -1110,9 +1111,9 @@ ml_insert_init_env(Action, TypeName, ModuleName, Globals, Defn0, Defn, ModuleName, Globals, EnvPtrDecl, InitEnvPtr), FuncBody = statement(block([EnvPtrDecl], [InitEnvPtr, FuncBody0]), Context), - DefnBody = mlds__function(PredProcId, Params, + DefnBody = mlds_function(PredProcId, Params, defined_here(FuncBody), Attributes), - Defn = mlds__defn(Name, Context, Flags, DefnBody), + Defn = mlds_defn(Name, Context, Flags, DefnBody), Init = yes ; Defn = Defn0, @@ -1122,13 +1123,13 @@ ml_insert_init_env(Action, TypeName, ModuleName, Globals, Defn0, Defn, :- func ml_make_env_ptr_type(globals, mlds_type) = mlds_type. ml_make_env_ptr_type(Globals, EnvType) = EnvPtrType :- - globals__lookup_bool_option(Globals, put_nondet_env_on_heap, OnHeap), - globals__get_target(Globals, Target), + globals.lookup_bool_option(Globals, put_nondet_env_on_heap, OnHeap), + globals.get_target(Globals, Target), ( Target = il, OnHeap = yes -> % For IL, a class type is already a pointer (object reference). EnvPtrType = EnvType ; - EnvPtrType = mlds__ptr_type(EnvType) + EnvPtrType = mlds_ptr_type(EnvType) ). % Create the environment pointer and initialize it: @@ -1137,8 +1138,8 @@ ml_make_env_ptr_type(Globals, EnvType) = EnvPtrType :- % env_ptr = ; % :- pred ml_init_env(action::in, mlds_type::in, mlds_rval::in, - mlds__context::in, mlds_module_name::in, globals::in, - mlds__defn::out, statement::out) is det. + mlds_context::in, mlds_module_name::in, globals::in, + mlds_defn::out, statement::out) is det. ml_init_env(Action, EnvTypeName, EnvPtrVal, Context, ModuleName, Globals, EnvPtrVarDecl, InitEnvPtr) :- @@ -1146,16 +1147,16 @@ ml_init_env(Action, EnvTypeName, EnvPtrVal, Context, ModuleName, Globals, % % *env_ptr; % - EnvPtrVarName = mlds__var_name(env_name_base(Action) ++ "_ptr", no), + EnvPtrVarName = mlds_var_name(env_name_base(Action) ++ "_ptr", no), EnvPtrVarEntityName = data(var(EnvPtrVarName)), EnvPtrVarFlags = ml_gen_local_var_decl_flags, EnvPtrVarType = ml_make_env_ptr_type(Globals, EnvTypeName), % The env_ptr never needs to be traced by the GC, since the environment % that it points to will always be on the stack, not into the heap. GC_TraceCode = no, - EnvPtrVarDefnBody = mlds__data(EnvPtrVarType, no_initializer, + EnvPtrVarDefnBody = mlds_data(EnvPtrVarType, no_initializer, GC_TraceCode), - EnvPtrVarDecl = mlds__defn(EnvPtrVarEntityName, Context, + EnvPtrVarDecl = mlds_defn(EnvPtrVarEntityName, Context, EnvPtrVarFlags, EnvPtrVarDefnBody), % Generate the following statement: @@ -1174,19 +1175,19 @@ ml_init_env(Action, EnvTypeName, EnvPtrVal, Context, ModuleName, Globals, % We need to do this so as to include function parameter in the % environment struct. % -:- pred ml_conv_arg_to_var(mlds__context::in, mlds__argument::in, - mlds__defn::out) is det. +:- pred ml_conv_arg_to_var(mlds_context::in, mlds_argument::in, + mlds_defn::out) is det. ml_conv_arg_to_var(Context, Arg, LocalVar) :- - Arg = mlds__argument(Name, Type, GC_TraceCode), + Arg = mlds_argument(Name, Type, GC_TraceCode), Flags = ml_gen_local_var_decl_flags, - DefnBody = mlds__data(Type, no_initializer, GC_TraceCode), - LocalVar = mlds__defn(Name, Context, Flags, DefnBody). + DefnBody = mlds_data(Type, no_initializer, GC_TraceCode), + LocalVar = mlds_defn(Name, Context, Flags, DefnBody). % Return the declaration flags appropriate for an environment struct % type declaration. % -:- func env_type_decl_flags = mlds__decl_flags. +:- func env_type_decl_flags = mlds_decl_flags. env_type_decl_flags = MLDS_DeclFlags :- Access = private, @@ -1202,7 +1203,7 @@ env_type_decl_flags = MLDS_DeclFlags :- % But if the block consists only of a single statement with no % declarations, then just return that statement. % -:- func ml_block(mlds__defns, statements, mlds__context) +:- func ml_block(mlds_defns, statements, mlds_context) = statement. ml_block(VarDecls, Statements, Context) = @@ -1221,13 +1222,13 @@ ml_stack_chain_var = StackChain :- mercury_private_builtin_module(PrivateBuiltin), MLDS_Module = mercury_module_name_to_mlds(PrivateBuiltin), StackChain = var(qual(MLDS_Module, module_qual, - var_name("stack_chain", no)), ml_stack_chain_type). + mlds_var_name("stack_chain", no)), ml_stack_chain_type). % The type of the `stack_chain' pointer, i.e. `void *'. % :- func ml_stack_chain_type = mlds_type. -ml_stack_chain_type = mlds__generic_env_ptr_type. +ml_stack_chain_type = mlds_generic_env_ptr_type. %-----------------------------------------------------------------------------% % @@ -1241,7 +1242,7 @@ ml_stack_chain_type = mlds__generic_env_ptr_type. % Compute the name to use for the environment struct % for the specified function. % -:- func ml_env_name(mlds__entity_name, action) = mlds__class_name. +:- func ml_env_name(mlds_entity_name, action) = mlds_class_name. ml_env_name(type(_, _), _) = _ :- unexpected(this_file, "ml_env_name: expected function, got type"). @@ -1254,11 +1255,11 @@ ml_env_name(function(PredLabel, ProcId, MaybeSeqNum, _PredId), Action) proc_id_to_int(ProcId, ModeNum), ( MaybeSeqNum = yes(SeqNum), - string__format("%s_%d_%d_%s", + string.format("%s_%d_%d_%s", [s(PredLabelString), i(ModeNum), i(SeqNum), s(Base)], ClassName) ; MaybeSeqNum = no, - string__format("%s_%d_%s", + string.format("%s_%d_%s", [s(PredLabelString), i(ModeNum), s(Base)], ClassName) ). ml_env_name(export(_), _) = _ :- @@ -1269,7 +1270,7 @@ ml_env_name(export(_), _) = _ :- env_name_base(chain_gc_stack_frames) = "frame". env_name_base(hoist_nested_funcs) = "env". -:- func ml_pred_label_name(mlds__pred_label) = string. +:- func ml_pred_label_name(mlds_pred_label) = string. ml_pred_label_name(pred(PredOrFunc, MaybeDefiningModule, Name, Arity, _CodeModel, _NonOutputFunc)) = LabelName :- @@ -1279,11 +1280,11 @@ ml_pred_label_name(pred(PredOrFunc, MaybeDefiningModule, Name, Arity, ( MaybeDefiningModule = yes(DefiningModule), ModuleNameString = ml_module_name_string(DefiningModule), - string__format("%s_%d_%s_in__%s", + string.format("%s_%d_%s_in__%s", [s(Name), i(Arity), s(Suffix), s(ModuleNameString)], LabelName) ; MaybeDefiningModule = no, - string__format("%s_%d_%s", + string.format("%s_%d_%s", [s(Name), i(Arity), s(Suffix)], LabelName) ). ml_pred_label_name(special_pred(PredName, MaybeTypeModule, @@ -1291,12 +1292,12 @@ ml_pred_label_name(special_pred(PredName, MaybeTypeModule, ( MaybeTypeModule = yes(TypeModule), TypeModuleString = ml_module_name_string(TypeModule), - string__format("%s__%s__%s_%d", + string.format("%s__%s__%s_%d", [s(PredName), s(TypeModuleString), s(TypeName), i(TypeArity)], LabelName) ; MaybeTypeModule = no, - string__format("%s__%s_%d", + string.format("%s__%s_%d", [s(PredName), s(TypeName), i(TypeArity)], LabelName) ). @@ -1322,21 +1323,21 @@ ml_module_name_string(ModuleName) = ModuleNameString :- % Also, for Action = chain_gc_stack_frames, add code to save and % restore the stack chain pointer at any `try_commit' statements. -:- pred flatten_arguments(mlds__arguments::in, mlds__arguments::out, +:- pred flatten_arguments(mlds_arguments::in, mlds_arguments::out, elim_info::in, elim_info::out) is det. flatten_arguments(!Arguments, !Info) :- - list__map_foldl(flatten_argument, !Arguments, !Info). + list.map_foldl(flatten_argument, !Arguments, !Info). -:- pred flatten_argument(mlds__argument::in, mlds__argument::out, +:- pred flatten_argument(mlds_argument::in, mlds_argument::out, elim_info::in, elim_info::out) is det. flatten_argument(Argument0, Argument, !Info) :- - Argument0 = mlds__argument(Name, Type, MaybeGCTraceCode0), + Argument0 = mlds_argument(Name, Type, MaybeGCTraceCode0), flatten_maybe_statement(MaybeGCTraceCode0, MaybeGCTraceCode, !Info), - Argument = mlds__argument(Name, Type, MaybeGCTraceCode). + Argument = mlds_argument(Name, Type, MaybeGCTraceCode). -:- pred flatten_function_body(function_body::in, function_body::out, +:- pred flatten_function_body(mlds_function_body::in, mlds_function_body::out, elim_info::in, elim_info::out) is det. flatten_function_body(external, external, !Info). @@ -1356,7 +1357,7 @@ flatten_maybe_statement(yes(Statement0), yes(Statement), !Info) :- elim_info::in, elim_info::out) is det. flatten_statements(!Statements, !Info) :- - list__map_foldl(flatten_statement, !Statements, !Info). + list.map_foldl(flatten_statement, !Statements, !Info). :- pred flatten_statement(statement::in, statement::out, elim_info::in, elim_info::out) is det. @@ -1366,7 +1367,7 @@ flatten_statement(Statement0, Statement, !Info) :- flatten_stmt(Stmt0, Stmt, !Info), Statement = statement(Stmt, Context). -:- pred flatten_stmt(mlds__stmt::in, mlds__stmt::out, +:- pred flatten_stmt(mlds_stmt::in, mlds_stmt::out, elim_info::in, elim_info::out) is det. flatten_stmt(Stmt0, Stmt, !Info) :- @@ -1390,7 +1391,7 @@ flatten_stmt(Stmt0, Stmt, !Info) :- ; Stmt0 = switch(Type, Val0, Range, Cases0, Default0), fixup_rval(Val0, Val, !Info), - list__map_foldl(flatten_case, Cases0, Cases, !Info), + list.map_foldl(flatten_case, Cases0, Cases, !Info), flatten_default(Default0, Default, !Info), Stmt = switch(Type, Val, Range, Cases, Default) ; @@ -1436,14 +1437,14 @@ flatten_stmt(Stmt0, Stmt, !Info) :- Stmt = atomic(AtomicStmt) ). -:- pred flatten_case(mlds__switch_case::in, mlds__switch_case::out, +:- pred flatten_case(mlds_switch_case::in, mlds_switch_case::out, elim_info::in, elim_info::out) is det. flatten_case(Conds0 - Statement0, Conds - Statement, !Info) :- - list__map_foldl(fixup_case_cond, Conds0, Conds, !Info), + list.map_foldl(fixup_case_cond, Conds0, Conds, !Info), flatten_statement(Statement0, Statement, !Info). -:- pred flatten_default(mlds__switch_default::in, mlds__switch_default::out, +:- pred flatten_default(mlds_switch_default::in, mlds_switch_default::out, elim_info::in, elim_info::out) is det. flatten_default(default_is_unreachable, default_is_unreachable, !Info). @@ -1474,13 +1475,13 @@ flatten_default(default_case(Statement0), default_case(Statement), !Info) :- % :- inst try_commit ---> try_commit(ground, ground, ground). -:- pred save_and_restore_stack_chain(mlds__stmt::in(try_commit), - mlds__stmt::out, +:- pred save_and_restore_stack_chain(mlds_stmt::in(try_commit), + mlds_stmt::out, elim_info::in, elim_info::out) is det. save_and_restore_stack_chain(Stmt0, Stmt, ElimInfo0, ElimInfo) :- ModuleName = ElimInfo0 ^ module_name, - counter__allocate(Id, ElimInfo0 ^ saved_stack_chain_counter, NextId), + counter.allocate(Id, ElimInfo0 ^ saved_stack_chain_counter, NextId), ElimInfo = (ElimInfo0 ^ saved_stack_chain_counter := NextId), Stmt0 = try_commit(Ref, Statement0, Handler0), Statement0 = statement(_, StatementContext), @@ -1511,8 +1512,8 @@ save_and_restore_stack_chain(Stmt0, Stmt, ElimInfo0, ElimInfo) :- % Return the remaining (non-hoisted) definitions, % the list of assignment statements, and the updated elim_info. -:- pred flatten_nested_defns(mlds__defns::in, statements::in, - mlds__defns::out, statements::out, +:- pred flatten_nested_defns(mlds_defns::in, statements::in, + mlds_defns::out, statements::out, elim_info::in, elim_info::out) is det. flatten_nested_defns([], _, [], [], !Info). @@ -1525,15 +1526,15 @@ flatten_nested_defns([Defn0 | Defns0], FollowingStatements, Defns, Defns = Defns1 ++ Defns2, InitStatements = InitStatements1 ++ InitStatements2. -:- pred flatten_nested_defn(mlds__defn::in, mlds__defns::in, - statements::in, mlds__defns::out, statements::out, +:- pred flatten_nested_defn(mlds_defn::in, mlds_defns::in, + statements::in, mlds_defns::out, statements::out, elim_info::in, elim_info::out) is det. flatten_nested_defn(Defn0, FollowingDefns, FollowingStatements, Defns, InitStatements, !Info) :- - Defn0 = mlds__defn(Name, Context, Flags0, DefnBody0), + Defn0 = mlds_defn(Name, Context, Flags0, DefnBody0), ( - DefnBody0 = mlds__function(PredProcId, Params, FuncBody0, Attributes), + DefnBody0 = mlds_function(PredProcId, Params, FuncBody0, Attributes), % Recursively flatten the nested function. flatten_function_body(FuncBody0, FuncBody, !Info), @@ -1547,8 +1548,8 @@ flatten_nested_defn(Defn0, FollowingDefns, FollowingStatements, ; Flags = Flags0 ), - DefnBody = mlds__function(PredProcId, Params, FuncBody, Attributes), - Defn = mlds__defn(Name, Context, Flags, DefnBody), + DefnBody = mlds_function(PredProcId, Params, FuncBody, Attributes), + Defn = mlds_defn(Name, Context, Flags, DefnBody), ( Action = hoist_nested_funcs -> % Note that we assume that we can safely hoist stuff inside nested % functions into the containing function. If that wasn't the case, @@ -1558,7 +1559,7 @@ flatten_nested_defn(Defn0, FollowingDefns, FollowingStatements, % OuterVars = [LocalVars | OuterVars0], % FlattenedDefns = ml_elim_nested_defns(ModuleName, % OuterVars, Defn0), - % list__foldl(elim_info_add_nested_func, FlattenedDefns), + % list.foldl(elim_info_add_nested_func, FlattenedDefns), % Strip out the now flattened nested function, and store it % in the elim_info. @@ -1569,7 +1570,7 @@ flatten_nested_defn(Defn0, FollowingDefns, FollowingStatements, ), InitStatements = [] ; - DefnBody0 = mlds__data(Type, Init0, MaybeGCTraceCode0), + DefnBody0 = mlds_data(Type, Init0, MaybeGCTraceCode0), % For local variable definitions, if they are referenced by any nested % functions, then strip them out and store them in the elim_info. ( @@ -1598,8 +1599,8 @@ flatten_nested_defn(Defn0, FollowingDefns, FollowingStatements, % work, because it doesn't handle the case when initializers in % FollowingDefns reference this variable Init1 = no_initializer, - DefnBody1 = mlds__data(Type, Init1, MaybeGCTraceCode0), - Defn1 = mlds__defn(Name, Context, Flags0, DefnBody1), + DefnBody1 = mlds_data(Type, Init1, MaybeGCTraceCode0), + Defn1 = mlds_defn(Name, Context, Flags0, DefnBody1), VarLval = var(qual(!.Info ^ module_name, module_qual, VarName), Type), InitStatements = [statement( @@ -1614,13 +1615,13 @@ flatten_nested_defn(Defn0, FollowingDefns, FollowingStatements, fixup_initializer(Init0, Init, !Info), flatten_maybe_statement(MaybeGCTraceCode0, MaybeGCTraceCode, !Info), - DefnBody = mlds__data(Type, Init, MaybeGCTraceCode), - Defn = mlds__defn(Name, Context, Flags0, DefnBody), + DefnBody = mlds_data(Type, Init, MaybeGCTraceCode), + Defn = mlds_defn(Name, Context, Flags0, DefnBody), Defns = [Defn], InitStatements = [] ) ; - DefnBody0 = mlds__class(_), + DefnBody0 = mlds_class(_), % Leave nested class declarations alone. % % XXX That might not be the right thing to do, but currently @@ -1636,8 +1637,8 @@ flatten_nested_defn(Defn0, FollowingDefns, FollowingStatements, % to the environment struct (if it's a variable) or hoisted out to the % top level (if it's a static const). % -:- pred ml_should_add_local_data(elim_info::in, mlds__data_name::in, - mlds__maybe_gc_trace_code::in, mlds__defns::in, statements::in) +:- pred ml_should_add_local_data(elim_info::in, mlds_data_name::in, + mlds_maybe_gc_trace_code::in, mlds_defns::in, statements::in) is semidet. ml_should_add_local_data(Info, DataName, MaybeGCTraceCode, @@ -1665,22 +1666,22 @@ ml_should_add_local_data(Info, DataName, MaybeGCTraceCode, % XXX Do we need to check for references from the GC_TraceCode % fields here? % -:- pred ml_need_to_hoist(mlds_module_name::in, mlds__data_name::in, - mlds__defns::in, statements::in) is semidet. +:- pred ml_need_to_hoist(mlds_module_name::in, mlds_data_name::in, + mlds_defns::in, statements::in) is semidet. ml_need_to_hoist(ModuleName, DataName, FollowingDefns, FollowingStatements) :- QualDataName = qual(ModuleName, module_qual, DataName), ( - list__member(FollowingDefn, FollowingDefns) + list.member(FollowingDefn, FollowingDefns) ; statements_contains_defn(FollowingStatements, FollowingDefn) ), ( - FollowingDefn = mlds__defn(_, _, _, mlds__function(_, _, _, _)), + FollowingDefn = mlds_defn(_, _, _, mlds_function(_, _, _, _)), defn_contains_var(FollowingDefn, QualDataName) ; - FollowingDefn = mlds__defn(_, _, _, mlds__data(_, Initializer, _)), + FollowingDefn = mlds_defn(_, _, _, mlds_data(_, Initializer, _)), ml_decl_is_static_const(FollowingDefn), initializer_contains_var(Initializer, QualDataName) ). @@ -1693,18 +1694,18 @@ ml_need_to_hoist(ModuleName, DataName, % *before* we fix up the GC tracing code, otherwise references to the % variable itself in the GC tracing code won't get fixed. % -:- pred elim_info_add_and_flatten_local_data(mlds__defn::in, +:- pred elim_info_add_and_flatten_local_data(mlds_defn::in, elim_info::in, elim_info::out) is det. elim_info_add_and_flatten_local_data(Defn0, !Info) :- ( - Defn0 = mlds__defn(Name, Context, Flags, DefnBody0), - DefnBody0 = mlds__data(Type, Init, MaybeGCTraceCode0) + Defn0 = mlds_defn(Name, Context, Flags, DefnBody0), + DefnBody0 = mlds_data(Type, Init, MaybeGCTraceCode0) -> elim_info_add_local_data(Defn0, !Info), flatten_maybe_statement(MaybeGCTraceCode0, MaybeGCTraceCode, !Info), - DefnBody = mlds__data(Type, Init, MaybeGCTraceCode), - Defn = mlds__defn(Name, Context, Flags, DefnBody), + DefnBody = mlds_data(Type, Init, MaybeGCTraceCode), + Defn = mlds_defn(Name, Context, Flags, DefnBody), elim_info_remove_local_data(Defn0, !Info), elim_info_add_local_data(Defn, !Info) ; @@ -1725,7 +1726,7 @@ elim_info_add_and_flatten_local_data(Defn0, !Info) :- % Recursively process the specified construct, calling fixup_var on % every variable inside it. -:- pred fixup_initializer(mlds__initializer::in, mlds__initializer::out, +:- pred fixup_initializer(mlds_initializer::in, mlds_initializer::out, elim_info::in, elim_info::out) is det. fixup_initializer(no_initializer, no_initializer, !Info). @@ -1733,12 +1734,12 @@ fixup_initializer(init_obj(Rval0), init_obj(Rval), !Info) :- fixup_rval(Rval0, Rval, !Info). fixup_initializer(init_struct(Type, Members0), init_struct(Type, Members), !Info) :- - list__map_foldl(fixup_initializer, Members0, Members, !Info). + list.map_foldl(fixup_initializer, Members0, Members, !Info). fixup_initializer(init_array(Elements0), init_array(Elements), !Info) :- - list__map_foldl(fixup_initializer, Elements0, Elements, !Info). + list.map_foldl(fixup_initializer, Elements0, Elements, !Info). -:- pred fixup_atomic_stmt(mlds__atomic_statement::in, - mlds__atomic_statement::out, elim_info::in, elim_info::out) is det. +:- pred fixup_atomic_stmt(mlds_atomic_statement::in, + mlds_atomic_statement::out, elim_info::in, elim_info::out) is det. fixup_atomic_stmt(comment(C), comment(C), !Info). fixup_atomic_stmt(assign(Lval0, Rval0), assign(Lval, Rval), !Info) :- @@ -1761,13 +1762,13 @@ fixup_atomic_stmt(trail_op(TrailOp0), trail_op(TrailOp), !Info) :- fixup_trail_op(TrailOp0, TrailOp, !Info). fixup_atomic_stmt(inline_target_code(Lang, Components0), inline_target_code(Lang, Components), !Info) :- - list__map_foldl(fixup_target_code_component, + list.map_foldl(fixup_target_code_component, Components0, Components, !Info). fixup_atomic_stmt(outline_foreign_proc(Lang, Vs, Lvals0, Code), outline_foreign_proc(Lang, Vs, Lvals, Code), !Info) :- - list__map_foldl(fixup_lval, Lvals0, Lvals, !Info). + list.map_foldl(fixup_lval, Lvals0, Lvals, !Info). -:- pred fixup_case_cond(mlds__case_match_cond::in, mlds__case_match_cond::out, +:- pred fixup_case_cond(mlds_case_match_cond::in, mlds_case_match_cond::out, elim_info::in, elim_info::out) is det. fixup_case_cond(match_value(Rval0), match_value(Rval), !Info) :- @@ -1862,7 +1863,7 @@ fixup_lval(var(Var0, VarType), VarLval, !Info) :- % Change up any references to local vars in the containing function % to go via the environment pointer. % -:- pred fixup_var(mlds__var::in, mlds_type::in, mlds_lval::out, +:- pred fixup_var(mlds_var::in, mlds_type::in, mlds_lval::out, elim_info::in, elim_info::out) is det. fixup_var(ThisVar, ThisVarType, Lval, !Info) :- @@ -1878,15 +1879,15 @@ fixup_var(ThisVar, ThisVarType, Lval, !Info) :- % nested functions, and replace them with `env_ptr->foo'. ThisVarModuleName = ModuleName, IsLocalVar = (pred(VarType::out) is nondet :- - list__member(Var, Locals), - Var = mlds__defn(data(var(ThisVarName)), _, _, - data(VarType, _, _)), + list.member(Var, Locals), + Var = mlds_defn(data(var(ThisVarName)), _, _, + mlds_data(VarType, _, _)), \+ ml_decl_is_static_const(Var) - ), + ), solutions(IsLocalVar, [FieldType]) -> EnvPtr = lval(var(qual(ModuleName, QualKind, - mlds__var_name(env_name_base(Action) ++ "_ptr", no)), + mlds_var_name(env_name_base(Action) ++ "_ptr", no)), EnvPtrVarType)), EnvModuleName = ml_env_module_name(ClassType, Globals), ThisVarFieldName = ml_var_name_to_string(ThisVarName), @@ -1898,10 +1899,10 @@ fixup_var(ThisVar, ThisVarType, Lval, !Info) :- ; % Check for references to the env_ptr itself. % For those, the code generator will have left the type as - % mlds__unknown_type, and we need to fill it in here. + % mlds_unknown_type, and we need to fill it in here. Action = hoist_nested_funcs, - ThisVarName = mlds__var_name("env_ptr", no), - ThisVarType = mlds__unknown_type + ThisVarName = mlds_var_name("env_ptr", no), + ThisVarType = mlds_unknown_type -> Lval = var(ThisVar, EnvPtrVarType) ; @@ -1920,8 +1921,8 @@ fixup_var(ThisVar, ThisVarType, Lval, !Info) :- % % for `env.foo'.) % % % ThisVarModuleName = ModuleName, -% list__member(Var, Locals), -% Var = mlds__defn(data(var(ThisVarName)), _, _, _) +% list.member(Var, Locals), +% Var = mlds_defn(data(var(ThisVarName)), _, _, _) % -> % Env = var(qual(ModuleName, module_qual, "env")), % FieldName = named_field(ThisVar), @@ -1950,13 +1951,13 @@ fixup_var(ThisVar, ThisVarType, Lval, !Info) :- % % check if the specified variable is contained in the % % outervars, and if so, return the depth of nesting % % -% :- pred outervar_member(mlds__var_name::in, outervars::in, int::in, int::out) +% :- pred outervar_member(mlds_var_name::in, outervars::in, int::in, int::out) % is semidet. % % outervar_member(ThisVarName, [OuterVars | OtherOuterVars], Depth0, Depth) :- % ( -% list__member(Var, OuterVars), -% Var = mlds__defn(data(var(ThisVarName)), _, _, _) +% list.member(Var, OuterVars), +% Var = mlds_defn(data(var(ThisVarName)), _, _, _) % -> % Depth = Depth0 % ; @@ -1966,7 +1967,7 @@ fixup_var(ThisVar, ThisVarType, Lval, !Info) :- % % Produce a reference to a variable via `Depth' levels % % of `envptr->' indirections. % % -% :- func make_envptr_ref(int, mlds_rval, mlds__var, mlds__var) = lval. +% :- func make_envptr_ref(int, mlds_rval, mlds_var, mlds_var) = lval. % % make_envptr_ref(Depth, CurEnvPtr, EnvPtrVar, Var) = Lval :- % ( Depth = 1 -> @@ -1981,9 +1982,9 @@ fixup_var(ThisVar, ThisVarType, Lval, !Info) :- :- func ml_env_module_name(mlds_type, globals) = mlds_module_name. ml_env_module_name(ClassType, Globals) = EnvModuleName :- - ( ClassType = class_type(ClassModuleName, Arity, _Kind) -> + ( ClassType = mlds_class_type(ClassModuleName, Arity, _Kind) -> ClassModuleName = qual(ClassModule, QualKind, ClassName), - EnvModuleName = mlds__append_class_qualifier(ClassModule, + EnvModuleName = mlds_append_class_qualifier(ClassModule, QualKind, Globals, ClassName, Arity) ; unexpected(this_file, "ml_env_module_name: ClassType is not a class") @@ -2001,61 +2002,61 @@ ml_env_module_name(ClassType, Globals) = EnvModuleName :- % Nondeterministically return all the definitions contained % in the specified construct. -:- pred defns_contains_defn(mlds__defns::in, mlds__defn::out) is nondet. +:- pred defns_contains_defn(mlds_defns::in, mlds_defn::out) is nondet. defns_contains_defn(Defns, Name) :- - list__member(Defn, Defns), + list.member(Defn, Defns), defn_contains_defn(Defn, Name). -:- pred defn_contains_defn(mlds__defn::in, mlds__defn::out) is multi. +:- pred defn_contains_defn(mlds_defn::in, mlds_defn::out) is multi. defn_contains_defn(Defn, Defn). /* this is where we succeed! */ -defn_contains_defn(mlds__defn(_Name, _Context, _Flags, DefnBody), Defn) :- +defn_contains_defn(mlds_defn(_Name, _Context, _Flags, DefnBody), Defn) :- defn_body_contains_defn(DefnBody, Defn). -:- pred defn_body_contains_defn(mlds__entity_defn::in, mlds__defn::out) +:- pred defn_body_contains_defn(mlds_entity_defn::in, mlds_defn::out) is nondet. -% defn_body_contains_defn(mlds__data(_Type, _Initializer, _), _Defn) :- fail. -defn_body_contains_defn(mlds__function(_PredProcId, _Params, FunctionBody, +% defn_body_contains_defn(mlds_data(_Type, _Initializer, _), _Defn) :- fail. +defn_body_contains_defn(mlds_function(_PredProcId, _Params, FunctionBody, _Attrs), Name) :- function_body_contains_defn(FunctionBody, Name). -defn_body_contains_defn(mlds__class(ClassDefn), Name) :- - ClassDefn = mlds__class_defn(_Kind, _Imports, _Inherits, _Implements, +defn_body_contains_defn(mlds_class(ClassDefn), Name) :- + ClassDefn = mlds_class_defn(_Kind, _Imports, _Inherits, _Implements, CtorDefns, FieldDefns), ( defns_contains_defn(FieldDefns, Name) ; defns_contains_defn(CtorDefns, Name) ). -:- pred statements_contains_defn(statements::in, mlds__defn::out) +:- pred statements_contains_defn(statements::in, mlds_defn::out) is nondet. statements_contains_defn(Statements, Defn) :- - list__member(Statement, Statements), + list.member(Statement, Statements), statement_contains_defn(Statement, Defn). :- pred maybe_statement_contains_defn(maybe(statement)::in, - mlds__defn::out) is nondet. + mlds_defn::out) is nondet. % maybe_statement_contains_defn(no, _Defn) :- fail. maybe_statement_contains_defn(yes(Statement), Defn) :- statement_contains_defn(Statement, Defn). -:- pred function_body_contains_defn(function_body::in, mlds__defn::out) +:- pred function_body_contains_defn(mlds_function_body::in, mlds_defn::out) is nondet. % function_body_contains_defn(external, _Defn) :- fail. function_body_contains_defn(defined_here(Statement), Defn) :- statement_contains_defn(Statement, Defn). -:- pred statement_contains_defn(statement::in, mlds__defn::out) +:- pred statement_contains_defn(statement::in, mlds_defn::out) is nondet. statement_contains_defn(Statement, Defn) :- Statement = statement(Stmt, _Context), stmt_contains_defn(Stmt, Defn). -:- pred stmt_contains_defn(mlds__stmt::in, mlds__defn::out) is nondet. +:- pred stmt_contains_defn(mlds_stmt::in, mlds_defn::out) is nondet. stmt_contains_defn(Stmt, Defn) :- ( @@ -2104,15 +2105,15 @@ stmt_contains_defn(Stmt, Defn) :- fail ). -:- pred cases_contains_defn(list(mlds__switch_case)::in, mlds__defn::out) +:- pred cases_contains_defn(list(mlds_switch_case)::in, mlds_defn::out) is nondet. cases_contains_defn(Cases, Defn) :- - list__member(Case, Cases), + list.member(Case, Cases), Case = _MatchConds - Statement, statement_contains_defn(Statement, Defn). -:- pred default_contains_defn(mlds__switch_default::in, mlds__defn::out) +:- pred default_contains_defn(mlds_switch_default::in, mlds_defn::out) is nondet. % default_contains_defn(default_do_nothing, _) :- fail. @@ -2138,7 +2139,7 @@ add_unchain_stack_to_maybe_statement(yes(Statement0), yes(Statement), !Info) :- elim_info::in, elim_info::out) is det. add_unchain_stack_to_statements(!Statements, !Info) :- - list__map_foldl(add_unchain_stack_to_statement, !Statements, !Info). + list.map_foldl(add_unchain_stack_to_statement, !Statements, !Info). :- pred add_unchain_stack_to_statement(statement::in, statement::out, @@ -2149,8 +2150,8 @@ add_unchain_stack_to_statement(Statement0, Statement, !Info) :- add_unchain_stack_to_stmt(Stmt0, Context, Stmt, !Info), Statement = statement(Stmt, Context). -:- pred add_unchain_stack_to_stmt(mlds__stmt::in, mlds__context::in, - mlds__stmt::out, elim_info::in, elim_info::out) is det. +:- pred add_unchain_stack_to_stmt(mlds_stmt::in, mlds_context::in, + mlds_stmt::out, elim_info::in, elim_info::out) is det. add_unchain_stack_to_stmt(Stmt0, Context, Stmt, !Info) :- ( @@ -2168,7 +2169,7 @@ add_unchain_stack_to_stmt(Stmt0, Context, Stmt, !Info) :- Stmt = if_then_else(Cond, Then, MaybeElse) ; Stmt0 = switch(Type, Val, Range, Cases0, Default0), - list__map_foldl(add_unchain_stack_to_case, Cases0, Cases, + list.map_foldl(add_unchain_stack_to_case, Cases0, Cases, !Info), add_unchain_stack_to_default(Default0, Default, !Info), Stmt = switch(Type, Val, Range, Cases, Default) @@ -2201,8 +2202,8 @@ add_unchain_stack_to_stmt(Stmt0, Context, Stmt, !Info) :- Stmt = Stmt0 ). -:- pred add_unchain_stack_to_call(mlds__stmt::in, list(mlds_lval)::in, - mlds__call_kind::in, mlds__context::in, mlds__stmt::out, +:- pred add_unchain_stack_to_call(mlds_stmt::in, list(mlds_lval)::in, + call_kind::in, mlds_context::in, mlds_stmt::out, elim_info::in, elim_info::out) is det. add_unchain_stack_to_call(Stmt0, RetLvals, CallKind, Context, Stmt, !Info) :- @@ -2220,7 +2221,7 @@ add_unchain_stack_to_call(Stmt0, RetLvals, CallKind, Context, Stmt, !Info) :- % the already-unchained stack frame. UnchainFrame = ml_gen_unchain_frame(Context, !.Info), Statement0 = statement(Stmt0, Context), - RetRvals = list__map(func(Rval) = lval(Rval), RetLvals), + RetRvals = list.map(func(Rval) = lval(Rval), RetLvals), RetStmt = return(RetRvals), RetStatement = statement(RetStmt, Context), Stmt = block([], [UnchainFrame, Statement0, RetStatement]) @@ -2229,15 +2230,15 @@ add_unchain_stack_to_call(Stmt0, RetLvals, CallKind, Context, Stmt, !Info) :- Stmt = Stmt0 ). -:- pred add_unchain_stack_to_case(mlds__switch_case::in, - mlds__switch_case::out, elim_info::in, elim_info::out) is det. +:- pred add_unchain_stack_to_case(mlds_switch_case::in, + mlds_switch_case::out, elim_info::in, elim_info::out) is det. add_unchain_stack_to_case(Conds0 - Statement0, Conds - Statement, !Info) :- - list__map_foldl(fixup_case_cond, Conds0, Conds, !Info), + list.map_foldl(fixup_case_cond, Conds0, Conds, !Info), add_unchain_stack_to_statement(Statement0, Statement, !Info). -:- pred add_unchain_stack_to_default(mlds__switch_default::in, - mlds__switch_default::out, elim_info::in, elim_info::out) is det. +:- pred add_unchain_stack_to_default(mlds_switch_default::in, + mlds_switch_default::out, elim_info::in, elim_info::out) is det. add_unchain_stack_to_default(default_is_unreachable, default_is_unreachable, !Info). @@ -2246,23 +2247,23 @@ add_unchain_stack_to_default(default_case(Statement0), default_case(Statement), !Info) :- add_unchain_stack_to_statement(Statement0, Statement, !Info). -:- func prepend_unchain_frame(mlds__stmt, mlds__context, elim_info) = - mlds__stmt. +:- func prepend_unchain_frame(mlds_stmt, mlds_context, elim_info) = + mlds_stmt. prepend_unchain_frame(Stmt0, Context, ElimInfo) = Stmt :- UnchainFrame = ml_gen_unchain_frame(Context, ElimInfo), Statement0 = statement(Stmt0, Context), Stmt = block([], [UnchainFrame, Statement0]). -:- func append_unchain_frame(mlds__stmt, mlds__context, elim_info) = - mlds__stmt. +:- func append_unchain_frame(mlds_stmt, mlds_context, elim_info) = + mlds_stmt. append_unchain_frame(Stmt0, Context, ElimInfo) = Stmt :- UnchainFrame = ml_gen_unchain_frame(Context, ElimInfo), Statement0 = statement(Stmt0, Context), Stmt = block([], [Statement0, UnchainFrame]). -:- func ml_gen_unchain_frame(mlds__context, elim_info) = statement. +:- func ml_gen_unchain_frame(mlds_context, elim_info) = statement. ml_gen_unchain_frame(Context, ElimInfo) = UnchainFrame :- EnvPtrTypeName = ElimInfo ^ env_ptr_type_name, @@ -2285,7 +2286,7 @@ ml_gen_unchain_frame(Context, ElimInfo) = UnchainFrame :- StackChain = ml_stack_chain_var, Tag = yes(0), PrevFieldId = offset(const(int_const(0))), - PrevFieldType = mlds__generic_type, + PrevFieldType = mlds_generic_type, PrevFieldRval = lval(field(Tag, lval(StackChain), PrevFieldId, PrevFieldType, EnvPtrTypeName)), Assignment = assign(StackChain, PrevFieldRval), @@ -2296,7 +2297,7 @@ ml_gen_unchain_frame(Context, ElimInfo) = UnchainFrame :- % % void *saved_stack_chain; % -:- func gen_saved_stack_chain_var(int, mlds__context) = mlds__defn. +:- func gen_saved_stack_chain_var(int, mlds_context) = mlds_defn. gen_saved_stack_chain_var(Id, Context) = Defn :- Name = data(var(ml_saved_stack_chain_name(Id))), @@ -2306,14 +2307,14 @@ gen_saved_stack_chain_var(Id, Context) = Defn :- % The saved stack chain never needs to be traced by the GC, % since it will always point to the stack, not into the heap. GCTraceCode = no, - DefnBody = mlds__data(Type, Initializer, GCTraceCode), - Defn = mlds__defn(Name, Context, Flags, DefnBody). + DefnBody = mlds_data(Type, Initializer, GCTraceCode), + Defn = mlds_defn(Name, Context, Flags, DefnBody). % Generate a statement to save the stack chain pointer: % % saved_stack_chain = stack_chain; % -:- func gen_save_stack_chain_var(mlds_module_name, int, mlds__context) = +:- func gen_save_stack_chain_var(mlds_module_name, int, mlds_context) = statement. gen_save_stack_chain_var(MLDS_Module, Id, Context) = SaveStatement :- @@ -2326,7 +2327,7 @@ gen_save_stack_chain_var(MLDS_Module, Id, Context) = SaveStatement :- % % stack_chain = saved_stack_chain; % -:- func gen_restore_stack_chain_var(mlds_module_name, int, mlds__context) = +:- func gen_restore_stack_chain_var(mlds_module_name, int, mlds_context) = statement. gen_restore_stack_chain_var(MLDS_Module, Id, Context) = RestoreStatement :- @@ -2335,9 +2336,9 @@ gen_restore_stack_chain_var(MLDS_Module, Id, Context) = RestoreStatement :- Assignment = assign(ml_stack_chain_var, lval(SavedStackChain)), RestoreStatement = statement(atomic(Assignment), Context). -:- func ml_saved_stack_chain_name(int) = mlds__var_name. +:- func ml_saved_stack_chain_name(int) = mlds_var_name. -ml_saved_stack_chain_name(Id) = var_name("saved_stack_chain", yes(Id)). +ml_saved_stack_chain_name(Id) = mlds_var_name("saved_stack_chain", yes(Id)). %-----------------------------------------------------------------------------% @@ -2365,11 +2366,11 @@ ml_saved_stack_chain_name(Id) = var_name("saved_stack_chain", yes(Id)). % The list of nested function definitions that we must hoist % out. This list is stored in reverse order. - nested_funcs :: list(mlds__defn), + nested_funcs :: list(mlds_defn), % The list of local variables that we must put in the % environment structure This list is stored in reverse order. - local_data :: list(mlds__defn), + local_data :: list(mlds_defn), % Type of the introduced environment struct. env_type_name :: mlds_type, @@ -2388,7 +2389,7 @@ ml_saved_stack_chain_name(Id) = var_name("saved_stack_chain", yes(Id)). % The lists of local variables for each of the containing functions, % innermost first. -:- type outervars == list(list(mlds__defn)). +:- type outervars == list(list(mlds_defn)). :- func elim_info_init(action, mlds_module_name, outervars, mlds_type, mlds_type, globals) = elim_info. @@ -2396,11 +2397,11 @@ ml_saved_stack_chain_name(Id) = var_name("saved_stack_chain", yes(Id)). elim_info_init(Action, ModuleName, OuterVars, EnvTypeName, EnvPtrTypeName, Globals) = elim_info(Action, ModuleName, OuterVars, [], [], - EnvTypeName, EnvPtrTypeName, counter__init(0), Globals). + EnvTypeName, EnvPtrTypeName, counter.init(0), Globals). :- func elim_info_get_module_name(elim_info) = mlds_module_name. :- func elim_info_get_outer_vars(elim_info) = outervars. -:- func elim_info_get_local_data(elim_info) = list(mlds__defn). +:- func elim_info_get_local_data(elim_info) = list(mlds_defn). :- func elim_info_get_env_type_name(elim_info) = mlds_type. :- func elim_info_get_env_ptr_type_name(elim_info) = mlds_type. @@ -2410,34 +2411,34 @@ elim_info_get_local_data(ElimInfo) = ElimInfo ^ local_data. elim_info_get_env_type_name(ElimInfo) = ElimInfo ^ env_type_name. elim_info_get_env_ptr_type_name(ElimInfo) = ElimInfo ^ env_ptr_type_name. -:- pred elim_info_add_nested_func(mlds__defn::in, +:- pred elim_info_add_nested_func(mlds_defn::in, elim_info::in, elim_info::out) is det. elim_info_add_nested_func(NestedFunc, ElimInfo, ElimInfo ^ nested_funcs := [NestedFunc | ElimInfo ^ nested_funcs]). -:- pred elim_info_add_local_data(mlds__defn::in, +:- pred elim_info_add_local_data(mlds_defn::in, elim_info::in, elim_info::out) is det. elim_info_add_local_data(LocalVar, ElimInfo, ElimInfo ^ local_data := [LocalVar | ElimInfo ^ local_data]). -:- pred elim_info_remove_local_data(mlds__defn::in, +:- pred elim_info_remove_local_data(mlds_defn::in, elim_info::in, elim_info::out) is det. elim_info_remove_local_data(LocalVar, ElimInfo0, ElimInfo) :- - ( list__delete_first(ElimInfo0 ^ local_data, LocalVar, LocalData) -> + ( list.delete_first(ElimInfo0 ^ local_data, LocalVar, LocalData) -> ElimInfo = ElimInfo0 ^ local_data := LocalData ; unexpected(this_file, "elim_info_remove_local_data: not found") ). :- pred elim_info_finish(elim_info::in, - list(mlds__defn)::out, list(mlds__defn)::out) is det. + list(mlds_defn)::out, list(mlds_defn)::out) is det. elim_info_finish(ElimInfo, Funcs, Locals) :- - Funcs = list__reverse(ElimInfo ^ nested_funcs), - Locals = list__reverse(ElimInfo ^ local_data). + Funcs = list.reverse(ElimInfo ^ nested_funcs), + Locals = list.reverse(ElimInfo ^ local_data). %-----------------------------------------------------------------------------% diff --git a/compiler/ml_optimize.m b/compiler/ml_optimize.m index b5e4eb869..a130bb577 100644 --- a/compiler/ml_optimize.m +++ b/compiler/ml_optimize.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2000-2005 The University of Melbourne. +% Copyright (C) 2000-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -31,7 +31,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_optimize. +:- module ml_backend.ml_optimize. :- interface. :- import_module ml_backend.mlds. @@ -64,52 +64,53 @@ ---> opt_info( globals :: globals, module_name :: mlds_module_name, - entity_name :: mlds__entity_name, - func_params :: mlds__func_params, - context :: mlds__context + entity_name :: mlds_entity_name, + func_params :: mlds_func_params, + context :: mlds_context ). optimize(MLDS0, MLDS, !IO) :- - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), Defns = optimize_in_defns(MLDS0 ^ defns, Globals, mercury_module_name_to_mlds(MLDS0 ^ name)), MLDS = MLDS0 ^ defns := Defns. -:- func optimize_in_defns(mlds__defns, globals, mlds_module_name) - = mlds__defns. +:- func optimize_in_defns(mlds_defns, globals, mlds_module_name) + = mlds_defns. optimize_in_defns(Defns, Globals, ModuleName) = - list__map(optimize_in_defn(ModuleName, Globals), Defns). + list.map(optimize_in_defn(ModuleName, Globals), Defns). -:- func optimize_in_defn(mlds_module_name, globals, mlds__defn) = mlds__defn. +:- func optimize_in_defn(mlds_module_name, globals, mlds_defn) = mlds_defn. optimize_in_defn(ModuleName, Globals, Defn0) = Defn :- - Defn0 = mlds__defn(Name, Context, Flags, DefnBody0), + Defn0 = mlds_defn(Name, Context, Flags, DefnBody0), ( - DefnBody0 = mlds__function(PredProcId, Params, FuncBody0, Attributes), + DefnBody0 = mlds_function(PredProcId, Params, FuncBody0, Attributes), OptInfo = opt_info(Globals, ModuleName, Name, Params, Context), FuncBody1 = optimize_func(OptInfo, FuncBody0), FuncBody = optimize_in_function_body(OptInfo, FuncBody1), - DefnBody = mlds__function(PredProcId, Params, FuncBody, Attributes), - Defn = mlds__defn(Name, Context, Flags, DefnBody) + DefnBody = mlds_function(PredProcId, Params, FuncBody, Attributes), + Defn = mlds_defn(Name, Context, Flags, DefnBody) ; - DefnBody0 = mlds__data(_, _, _), + DefnBody0 = mlds_data(_, _, _), Defn = Defn0 ; - DefnBody0 = mlds__class(ClassDefn0), - ClassDefn0 = class_defn(Kind, Imports, BaseClasses, Implements, + DefnBody0 = mlds_class(ClassDefn0), + ClassDefn0 = mlds_class_defn(Kind, Imports, BaseClasses, Implements, CtorDefns0, MemberDefns0), MemberDefns = optimize_in_defns(MemberDefns0, Globals, ModuleName), CtorDefns = optimize_in_defns(CtorDefns0, Globals, ModuleName), - ClassDefn = class_defn(Kind, Imports, BaseClasses, Implements, + ClassDefn = mlds_class_defn(Kind, Imports, BaseClasses, Implements, CtorDefns, MemberDefns), - DefnBody = mlds__class(ClassDefn), - Defn = mlds__defn(Name, Context, Flags, DefnBody) + DefnBody = mlds_class(ClassDefn), + Defn = mlds_defn(Name, Context, Flags, DefnBody) ). -:- func optimize_in_function_body(opt_info, function_body) = function_body. +:- func optimize_in_function_body(opt_info, mlds_function_body) + = mlds_function_body. optimize_in_function_body(_, external) = external. optimize_in_function_body(OptInfo, defined_here(Statement0)) = @@ -126,14 +127,14 @@ optimize_in_maybe_statement(OptInfo, yes(Statement0)) = yes(Statement) :- :- func optimize_in_statements(opt_info, list(statement)) = list(statement). optimize_in_statements(OptInfo, Statements) = - list__map(optimize_in_statement(OptInfo), Statements). + list.map(optimize_in_statement(OptInfo), Statements). :- func optimize_in_statement(opt_info, statement) = statement. optimize_in_statement(OptInfo, statement(Stmt, Context)) = statement(optimize_in_stmt(OptInfo ^ context := Context, Stmt), Context). -:- func optimize_in_stmt(opt_info, mlds__stmt) = mlds__stmt. +:- func optimize_in_stmt(opt_info, mlds_stmt) = mlds_stmt. optimize_in_stmt(OptInfo, Stmt0) = Stmt :- ( @@ -159,7 +160,7 @@ optimize_in_stmt(OptInfo, Stmt0) = Stmt :- ; Stmt0 = switch(Type, Rval, Range, Cases0, Default0), Stmt = switch(Type, Rval, Range, - list__map(optimize_in_case(OptInfo), Cases0), + list.map(optimize_in_case(OptInfo), Cases0), optimize_in_default(OptInfo, Default0)) ; Stmt0 = do_commit(_), @@ -186,13 +187,13 @@ optimize_in_stmt(OptInfo, Stmt0) = Stmt :- Stmt = Stmt0 ). -:- func optimize_in_case(opt_info, mlds__switch_case) = mlds__switch_case. +:- func optimize_in_case(opt_info, mlds_switch_case) = mlds_switch_case. optimize_in_case(OptInfo, Conds - Statement0) = Conds - Statement :- Statement = optimize_in_statement(OptInfo, Statement0). -:- func optimize_in_default(opt_info, mlds__switch_default) = - mlds__switch_default. +:- func optimize_in_default(opt_info, mlds_switch_default) = + mlds_switch_default. optimize_in_default(_OptInfo, default_is_unreachable) = default_is_unreachable. optimize_in_default(_OptInfo, default_do_nothing) = default_do_nothing. @@ -203,10 +204,10 @@ optimize_in_default(OptInfo, default_case(Statement0)) = %-----------------------------------------------------------------------------% :- inst g == ground. -:- inst call ---> ml_backend__mlds__call(g, g, g, g, g, g). +:- inst call ---> ml_backend.mlds.call(g, g, g, g, g, g). -:- func optimize_in_call_stmt(opt_info::in, mlds__stmt::in(call)) - = (mlds__stmt::out) is det. +:- func optimize_in_call_stmt(opt_info::in, mlds_stmt::in(call)) + = (mlds_stmt::out) is det. optimize_in_call_stmt(OptInfo, Stmt0) = Stmt :- Stmt0 = call(_Signature, FuncRval, _MaybeObject, CallArgs, @@ -214,7 +215,7 @@ optimize_in_call_stmt(OptInfo, Stmt0) = Stmt :- % If we have a self-tailcall, assign to the arguments and % then goto the top of the tailcall loop. ( - globals__lookup_bool_option(OptInfo ^ globals, + globals.lookup_bool_option(OptInfo ^ globals, optimize_tailcalls, yes), can_optimize_tailcall(qual(OptInfo ^ module_name, module_qual, OptInfo ^ entity_name), Stmt0) @@ -225,7 +226,7 @@ optimize_in_call_stmt(OptInfo, Stmt0) = Stmt :- GotoStatement = statement( goto(tailcall_loop_top(OptInfo ^ globals)), OptInfo ^ context), - OptInfo ^ func_params = mlds__func_params(FuncArgs, _RetTypes), + OptInfo ^ func_params = mlds_func_params(FuncArgs, _RetTypes), generate_assign_args(OptInfo, FuncArgs, CallArgs, AssignStatements, AssignDefns), AssignVarsStatement = statement(block(AssignDefns, @@ -273,7 +274,7 @@ optimize_in_call_stmt(OptInfo, Stmt0) = Stmt :- % This specifies how we should branch to the top of the loop % introduced by tailcall opptimization. % -:- func tailcall_loop_top(globals) = mlds__goto_target. +:- func tailcall_loop_top(globals) = mlds_goto_target. tailcall_loop_top(Globals) = ( target_supports_break_and_continue(Globals) -> @@ -300,8 +301,8 @@ tailcall_loop_label_name = "loop_top". % Assign the specified list of rvals to the arguments. % This is used as part of tail recursion optimization (see above). % -:- pred generate_assign_args(opt_info::in, mlds__arguments::in, - list(mlds_rval)::in, list(statement)::out, list(mlds__defn)::out) is det. +:- pred generate_assign_args(opt_info::in, mlds_arguments::in, + list(mlds_rval)::in, list(statement)::out, list(mlds_defn)::out) is det. generate_assign_args(_, [], [], [], []). generate_assign_args(_, [_|_], [], [], []) :- @@ -310,7 +311,7 @@ generate_assign_args(_, [], [_|_], [], []) :- unexpected(this_file, "generate_assign_args: length mismatch"). generate_assign_args(OptInfo, [Arg | Args], [ArgRval | ArgRvals], Statements, TempDefns) :- - Arg = mlds__argument(Name, Type, _ArgGCTraceCode), + Arg = mlds_argument(Name, Type, _ArgGCTraceCode), ( % Extract the variable name. Name = data(var(VarName)) @@ -343,8 +344,8 @@ generate_assign_args(OptInfo, [Arg | Args], [ArgRval | ArgRvals], % ml_elem_nested.m, and ml_elim_nested.m doesn't handle code % containing initializers. - VarName = mlds__var_name(VarNameStr, MaybeNum), - TempName = mlds__var_name(VarNameStr ++ "__tmp_copy", MaybeNum), + VarName = mlds_var_name(VarNameStr, MaybeNum), + TempName = mlds_var_name(VarNameStr ++ "__tmp_copy", MaybeNum), QualTempName = qual(OptInfo ^ module_name, module_qual, TempName), Initializer = no_initializer, % We don't need to trace the temporary variables for GC, since they @@ -373,7 +374,7 @@ generate_assign_args(OptInfo, [Arg | Args], [ArgRval | ArgRvals], %---------------------------------------------------------------------------- -:- func optimize_func(opt_info, function_body) = function_body. +:- func optimize_func(opt_info, mlds_function_body) = mlds_function_body. optimize_func(_, external) = external. optimize_func(OptInfo, defined_here(Statement)) = @@ -387,8 +388,7 @@ optimize_func_stmt(OptInfo, statement(Stmt0, Context)) = % Tailcall optimization -- if we do a self tailcall, we can turn it % into a loop. ( - globals__lookup_bool_option(OptInfo ^ globals, - optimize_tailcalls, yes), + globals.lookup_bool_option(OptInfo ^ globals, optimize_tailcalls, yes), stmt_contains_statement(Stmt0, Call), Call = statement(CallStmt, _), can_optimize_tailcall( @@ -438,7 +438,7 @@ optimize_func_stmt(OptInfo, statement(Stmt0, Context)) = :- pred target_supports_break_and_continue(globals::in) is semidet. target_supports_break_and_continue(Globals) :- - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), target_supports_break_and_continue_2(Target) = yes. :- func target_supports_break_and_continue_2(compilation_target) = bool. @@ -459,7 +459,7 @@ target_supports_break_and_continue_2(java) = yes. :- pred maybe_flatten_block(statements::in, statements::out) is det. maybe_flatten_block(!Stmts) :- - !:Stmts = list__condense(list__map(flatten_block, !.Stmts)). + !:Stmts = list.condense(list.map(flatten_block, !.Stmts)). :- func flatten_block(statement) = statements. @@ -556,13 +556,13 @@ flatten_block(Statement) = % ... :- pred maybe_convert_assignments_into_initializers(opt_info::in, - mlds__defns::in, mlds__defns::out, + mlds_defns::in, mlds_defns::out, statements::in, statements::out) is det. maybe_convert_assignments_into_initializers(OptInfo, !Defns, !Statements) :- ( % Check if --optimize-initializations is enabled - globals__lookup_bool_option(OptInfo ^ globals, + globals.lookup_bool_option(OptInfo ^ globals, optimize_initializations, yes) -> convert_assignments_into_initializers(OptInfo, !Defns, !Statements) @@ -571,7 +571,7 @@ maybe_convert_assignments_into_initializers(OptInfo, !Defns, !Statements) :- ). :- pred convert_assignments_into_initializers(opt_info::in, - mlds__defns::in, mlds__defns::out, + mlds_defns::in, mlds_defns::out, statements::in, statements::out) is det. convert_assignments_into_initializers(OptInfo, !Defns, !Statements) :- @@ -584,7 +584,7 @@ convert_assignments_into_initializers(OptInfo, !Defns, !Statements) :- ThisVar = qual(Qualifier, QualKind, VarName), ThisData = qual(Qualifier, QualKind, var(VarName)), Qualifier = OptInfo ^ module_name, - list__takewhile(isnt(var_defn(VarName)), !.Defns, + list.takewhile(isnt(var_defn(VarName)), !.Defns, _PrecedingDefns, [_VarDefn | FollowingDefns]), % We must check that the value being assigned doesn't refer to the @@ -593,9 +593,9 @@ convert_assignments_into_initializers(OptInfo, !Defns, !Statements) :- % of the variables that follow this one don't refer to this variable. \+ rval_contains_var(RHS, ThisData), \+ ( - list__member(OtherDefn, FollowingDefns), - OtherDefn = mlds__defn(data(OtherVarName), - _, _, data(_Type, OtherInitializer, _GC)), + list.member(OtherDefn, FollowingDefns), + OtherDefn = mlds_defn(data(OtherVarName), + _, _, mlds_data(_Type, OtherInitializer, _GC)), ( rval_contains_var(RHS, qual(Qualifier, QualKind, OtherVarName)) ; @@ -614,29 +614,29 @@ convert_assignments_into_initializers(OptInfo, !Defns, !Statements) :- true ). -:- pred var_defn(var_name::in, mlds__defn::in) is semidet. +:- pred var_defn(mlds_var_name::in, mlds_defn::in) is semidet. var_defn(VarName, Defn) :- - Defn = mlds__defn(data(var(VarName)), _, _, _). + Defn = mlds_defn(data(var(VarName)), _, _, _). % set_initializer(Defns0, VarName, Rval, Defns): % % Finds the first definition of the specified variable in Defns0, % and replaces the initializer of that definition with init_obj(Rval). % -:- pred set_initializer(mlds__defns::in, mlds__var_name::in, mlds_rval::in, - mlds__defns::out) is det. +:- pred set_initializer(mlds_defns::in, mlds_var_name::in, mlds_rval::in, + mlds_defns::out) is det. set_initializer([], _, _, _) :- unexpected(this_file, "set_initializer: var not found!"). set_initializer([Defn0 | Defns0], VarName, Rval, [Defn | Defns]) :- - Defn0 = mlds__defn(Name, Context, Flags, DefnBody0), + Defn0 = mlds_defn(Name, Context, Flags, DefnBody0), ( Name = data(var(VarName)), - DefnBody0 = mlds__data(Type, _OldInitializer, GC_TraceCode) + DefnBody0 = mlds_data(Type, _OldInitializer, GC_TraceCode) -> - DefnBody = mlds__data(Type, init_obj(Rval), GC_TraceCode), - Defn = mlds__defn(Name, Context, Flags, DefnBody), + DefnBody = mlds_data(Type, init_obj(Rval), GC_TraceCode), + Defn = mlds_defn(Name, Context, Flags, DefnBody), Defns = Defns0 ; Defn = Defn0, @@ -653,11 +653,11 @@ set_initializer([Defn0 | Defns0], VarName, Rval, [Defn | Defns]) :- % would be to do one pass to figure out which variables could be eliminated, % and then do another pass to actually eliminate them. -:- pred maybe_eliminate_locals(opt_info::in, mlds__defns::in, mlds__defns::out, +:- pred maybe_eliminate_locals(opt_info::in, mlds_defns::in, mlds_defns::out, statements::in, statements::out) is det. maybe_eliminate_locals(OptInfo, !Defns, !Statements) :- - globals__lookup_bool_option(OptInfo ^ globals, eliminate_local_vars, + globals.lookup_bool_option(OptInfo ^ globals, eliminate_local_vars, EliminateLocalVars), ( EliminateLocalVars = yes, @@ -666,7 +666,7 @@ maybe_eliminate_locals(OptInfo, !Defns, !Statements) :- EliminateLocalVars = no ). -:- pred eliminate_locals(opt_info::in, mlds__defns::in, mlds__defns::out, +:- pred eliminate_locals(opt_info::in, mlds_defns::in, mlds_defns::out, statements::in, statements::out) is det. eliminate_locals(_OptInfo, [], [], Statements, Statements). @@ -684,7 +684,7 @@ eliminate_locals(OptInfo, [Defn0 | Defns0], Defns, !Statements) :- ---> var_elim_info( % These fields remain constant. - var_name :: mlds__var, + var_name :: mlds_var, % The name of the variable to eliminate. var_value :: mlds_rval, @@ -708,16 +708,16 @@ eliminate_locals(OptInfo, [Defn0 | Defns0], Defns, !Statements) :- % or if any of the statements or definitions take the address % of the variable, or assign to it. % -:- pred try_to_eliminate_defn(opt_info::in, mlds__defn::in, mlds__defns::in, - mlds__defns::out, statements::in, statements::out) is semidet. +:- pred try_to_eliminate_defn(opt_info::in, mlds_defn::in, mlds_defns::in, + mlds_defns::out, statements::in, statements::out) is semidet. try_to_eliminate_defn(OptInfo, Defn0, Defns0, Defns, !Statements) :- - Defn0 = mlds__defn(Name, _Context, Flags, DefnBody), + Defn0 = mlds_defn(Name, _Context, Flags, DefnBody), % Check if this definition is a local variable definition... Name = data(var(VarName)), Flags = ml_gen_local_var_decl_flags, - DefnBody = mlds__data(_Type, Initializer, _MaybeGCTraceCode), + DefnBody = mlds_data(_Type, Initializer, _MaybeGCTraceCode), % ... with a known initial value. QualVarName = qual(OptInfo ^ module_name, module_qual, VarName), @@ -743,8 +743,8 @@ try_to_eliminate_defn(OptInfo, Defn0, Defns0, Defns, !Statements) :- ( rval_cannot_throw(Rval) ; - globals__lookup_bool_option(OptInfo ^ globals, reorder_conj, yes), - globals__lookup_bool_option(OptInfo ^ globals, reorder_disj, yes) + globals.lookup_bool_option(OptInfo ^ globals, reorder_conj, yes), + globals.lookup_bool_option(OptInfo ^ globals, reorder_disj, yes) ), % Replace uses of this variable with the variable's value, @@ -805,7 +805,7 @@ rval_cannot_throw(self(_)). % of statements with the initial assignment deleted. Fail if the first % value can't be determined. % -:- pred find_initial_val_in_statements(mlds__var::in, mlds_rval::out, +:- pred find_initial_val_in_statements(mlds_var::in, mlds_rval::out, statements::in, statements::out) is semidet. find_initial_val_in_statements(VarName, Rval, [Statement0 | Statements0], @@ -835,7 +835,7 @@ find_initial_val_in_statements(VarName, Rval, [Statement0 | Statements0], Statements = [Statement0 | Statements1] ). -:- pred find_initial_val_in_statement(mlds__var::in, mlds_rval::out, +:- pred find_initial_val_in_statement(mlds_var::in, mlds_rval::out, statement::in, statement::out) is semidet. find_initial_val_in_statement(Var, Rval, Statement0, Statement) :- @@ -862,8 +862,8 @@ find_initial_val_in_statement(Var, Rval, Statement0, Statement) :- % Invalidated = yes if any of the statements or definitions take % the address of the variable, or assign to it; in that case, the % transformation should not be performed. -:- pred eliminate_var(mlds__var::in, mlds_rval::in, - mlds__defns::in, mlds__defns::out, +:- pred eliminate_var(mlds_var::in, mlds_rval::in, + mlds_defns::in, mlds_defns::out, statements::in, statements::out, int::out, bool::out) is det. @@ -882,7 +882,7 @@ eliminate_var(QualVarName, VarRval, !Defns, !Statements, Count, Invalidated) :- % ^replace_count field for each occurrence as an rvalue, and setting % ^invalidated to yes if the variable occurs as an lvalue. -:- pred eliminate_var_in_block(mlds__defns::in, mlds__defns::out, +:- pred eliminate_var_in_block(mlds_defns::in, mlds_defns::out, statements::in, statements::out, var_elim_info::in, var_elim_info::out) is det. @@ -890,35 +890,35 @@ eliminate_var_in_block(!Defns, !Statements, !VarElimInfo) :- eliminate_var_in_defns(!Defns, !VarElimInfo), eliminate_var_in_statements(!Statements, !VarElimInfo). -:- pred eliminate_var_in_defns(mlds__defns::in, mlds__defns::out, +:- pred eliminate_var_in_defns(mlds_defns::in, mlds_defns::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_defns(!Defns, !VarElimInfo) :- - list__map_foldl(eliminate_var_in_defn, !Defns, !VarElimInfo). + list.map_foldl(eliminate_var_in_defn, !Defns, !VarElimInfo). -:- pred eliminate_var_in_defn(mlds__defn::in, mlds__defn::out, +:- pred eliminate_var_in_defn(mlds_defn::in, mlds_defn::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_defn(Defn0, Defn, !VarElimInfo) :- - Defn0 = mlds__defn(Name, Context, Flags, DefnBody0), + Defn0 = mlds_defn(Name, Context, Flags, DefnBody0), ( - DefnBody0 = mlds__data(Type, Initializer0, MaybeGCTraceCode), + DefnBody0 = mlds_data(Type, Initializer0, MaybeGCTraceCode), eliminate_var_in_initializer(Initializer0, Initializer, !VarElimInfo), - DefnBody = mlds__data(Type, Initializer, MaybeGCTraceCode) + DefnBody = mlds_data(Type, Initializer, MaybeGCTraceCode) ; - DefnBody0 = mlds__class(_), + DefnBody0 = mlds_class(_), % We assume that nested classes don't refer to local variables % in the containing scope. DefnBody = DefnBody0 ; - DefnBody0 = mlds__function(Id, Params, Body0, Attributes), + DefnBody0 = mlds_function(Id, Params, Body0, Attributes), eliminate_var_in_function_body(Body0, Body, !VarElimInfo), - DefnBody = mlds__function(Id, Params, Body, Attributes) + DefnBody = mlds_function(Id, Params, Body, Attributes) ), - Defn = mlds__defn(Name, Context, Flags, DefnBody). + Defn = mlds_defn(Name, Context, Flags, DefnBody). :- pred eliminate_var_in_function_body( - mlds__function_body::in, mlds__function_body::out, + mlds_function_body::in, mlds_function_body::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_function_body(external, external, !VarElimInfo). @@ -927,7 +927,7 @@ eliminate_var_in_function_body(defined_here(Stmt0), defined_here(Stmt), eliminate_var_in_statement(Stmt0, Stmt, !VarElimInfo). :- pred eliminate_var_in_initializer( - mlds__initializer::in, mlds__initializer::out, + mlds_initializer::in, mlds_initializer::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_initializer(no_initializer, no_initializer, !VarElimInfo). @@ -935,18 +935,18 @@ eliminate_var_in_initializer(init_obj(Rval0), init_obj(Rval), !VarElimInfo) :- eliminate_var_in_rval(Rval0, Rval, !VarElimInfo). eliminate_var_in_initializer(init_array(Elements0), init_array(Elements), !VarElimInfo) :- - list__map_foldl(eliminate_var_in_initializer, Elements0, Elements, + list.map_foldl(eliminate_var_in_initializer, Elements0, Elements, !VarElimInfo). eliminate_var_in_initializer(init_struct(Type, Members0), init_struct(Type, Members), !VarElimInfo) :- - list__map_foldl(eliminate_var_in_initializer, Members0, Members, + list.map_foldl(eliminate_var_in_initializer, Members0, Members, !VarElimInfo). :- pred eliminate_var_in_rvals(list(mlds_rval)::in, list(mlds_rval)::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_rvals(!Rvals, !VarElimInfo) :- - list__map_foldl(eliminate_var_in_rval, !Rvals, !VarElimInfo). + list.map_foldl(eliminate_var_in_rval, !Rvals, !VarElimInfo). :- pred eliminate_var_in_maybe_rval( maybe(mlds_rval)::in, maybe(mlds_rval)::out, @@ -1003,7 +1003,7 @@ eliminate_var_in_rval(Rval0, Rval, !VarElimInfo) :- var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_lvals(!Lvals, !VarElimInfo) :- - list__map_foldl(eliminate_var_in_lval, !Lvals, !VarElimInfo). + list.map_foldl(eliminate_var_in_lval, !Lvals, !VarElimInfo). :- pred eliminate_var_in_lval(mlds_lval::in, mlds_lval::out, var_elim_info::in, var_elim_info::out) is det. @@ -1036,7 +1036,7 @@ eliminate_var_in_lval(Lval0, Lval, !VarElimInfo) :- var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_statements(!Statements, !VarElimInfo) :- - list__map_foldl(eliminate_var_in_statement, !Statements, !VarElimInfo). + list.map_foldl(eliminate_var_in_statement, !Statements, !VarElimInfo). :- pred eliminate_var_in_maybe_statement( maybe(statement)::in, maybe(statement)::out, @@ -1055,7 +1055,7 @@ eliminate_var_in_statement(Statement0, Statement, !VarElimInfo) :- eliminate_var_in_stmt(Stmt0, Stmt, !VarElimInfo), Statement = statement(Stmt, Context). -:- pred eliminate_var_in_stmt(mlds__stmt::in, mlds__stmt::out, +:- pred eliminate_var_in_stmt(mlds_stmt::in, mlds_stmt::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_stmt(Stmt0, Stmt, !VarElimInfo) :- @@ -1078,7 +1078,7 @@ eliminate_var_in_stmt(Stmt0, Stmt, !VarElimInfo) :- ; Stmt0 = switch(Type, Val0, Range, Cases0, Default0), eliminate_var_in_rval(Val0, Val, !VarElimInfo), - list__map_foldl(eliminate_var_in_case, Cases0, Cases, !VarElimInfo), + list.map_foldl(eliminate_var_in_case, Cases0, Cases, !VarElimInfo), eliminate_var_in_default(Default0, Default, !VarElimInfo), Stmt = switch(Type, Val, Range, Cases, Default) ; @@ -1119,15 +1119,15 @@ eliminate_var_in_stmt(Stmt0, Stmt, !VarElimInfo) :- Stmt = atomic(AtomicStmt) ). -:- pred eliminate_var_in_case(mlds__switch_case::in, mlds__switch_case::out, +:- pred eliminate_var_in_case(mlds_switch_case::in, mlds_switch_case::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_case(Conds0 - Statement0, Conds - Statement, !VarElimInfo) :- - list__map_foldl(eliminate_var_in_case_cond, Conds0, Conds, !VarElimInfo), + list.map_foldl(eliminate_var_in_case_cond, Conds0, Conds, !VarElimInfo), eliminate_var_in_statement(Statement0, Statement, !VarElimInfo). :- pred eliminate_var_in_default( - mlds__switch_default::in, mlds__switch_default::out, + mlds_switch_default::in, mlds_switch_default::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_default(default_is_unreachable, default_is_unreachable, @@ -1139,7 +1139,7 @@ eliminate_var_in_default(default_case(Statement0), default_case(Statement), eliminate_var_in_statement(Statement0, Statement, !VarElimInfo). :- pred eliminate_var_in_atomic_stmt( - mlds__atomic_statement::in, mlds__atomic_statement::out, + mlds_atomic_statement::in, mlds_atomic_statement::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_atomic_stmt(comment(C), comment(C), !VarElimInfo). @@ -1168,14 +1168,14 @@ eliminate_var_in_atomic_stmt(trail_op(TrailOp0), trail_op(TrailOp), eliminate_var_in_trail_op(TrailOp0, TrailOp, !VarElimInfo). eliminate_var_in_atomic_stmt(inline_target_code(Lang, Components0), inline_target_code(Lang, Components), !VarElimInfo) :- - list__map_foldl(eliminate_var_in_target_code_component, + list.map_foldl(eliminate_var_in_target_code_component, Components0, Components, !VarElimInfo). eliminate_var_in_atomic_stmt(outline_foreign_proc(Lang, Vs, Lvals0, Code), outline_foreign_proc(Lang, Vs, Lvals, Code), !VarElimInfo) :- eliminate_var_in_lvals(Lvals0, Lvals, !VarElimInfo). :- pred eliminate_var_in_case_cond( - mlds__case_match_cond::in, mlds__case_match_cond::out, + mlds_case_match_cond::in, mlds_case_match_cond::out, var_elim_info::in, var_elim_info::out) is det. eliminate_var_in_case_cond(match_value(Rval0), match_value(Rval), diff --git a/compiler/ml_simplify_switch.m b/compiler/ml_simplify_switch.m index 666eac456..d3c038a0c 100644 --- a/compiler/ml_simplify_switch.m +++ b/compiler/ml_simplify_switch.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2000-2001, 2003-2005 The University of Melbourne. +% Copyright (C) 2000-2001, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -22,13 +22,13 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_simplify_switch. +:- module ml_backend.ml_simplify_switch. :- interface. :- import_module ml_backend.mlds. :- import_module ml_backend.ml_code_util. -:- pred ml_simplify_switch(mlds__stmt::in, mlds__context::in, +:- pred ml_simplify_switch(mlds_stmt::in, mlds_context::in, statement::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -66,16 +66,16 @@ ml_simplify_switch(Stmt0, MLDS_Context, Statement, !Info) :- target_supports_computed_goto(Globals), \+ ( target_supports_int_switch(Globals), - globals__lookup_bool_option(Globals, prefer_switch, yes) + globals.lookup_bool_option(Globals, prefer_switch, yes) ), % Is the switch big enough? - list__length(Cases, NumCases), - globals__lookup_int_option(Globals, dense_switch_size, DenseSize), + list.length(Cases, NumCases), + globals.lookup_int_option(Globals, dense_switch_size, DenseSize), NumCases >= DenseSize, % ... and dense enough? - globals__lookup_int_option(Globals, dense_switch_req_density, + globals.lookup_int_option(Globals, dense_switch_req_density, ReqDensity), is_dense_switch(Cases, ReqDensity) -> @@ -94,7 +94,7 @@ ml_simplify_switch(Stmt0, MLDS_Context, Statement, !Info) :- is_integral_type(Type), \+ ( target_supports_int_switch(Globals), - globals__lookup_bool_option(Globals, prefer_switch, yes) + globals.lookup_bool_option(Globals, prefer_switch, yes) ) -> Statement = ml_switch_to_if_else_chain(Cases, Default, Rval, @@ -116,17 +116,17 @@ ml_simplify_switch(Stmt0, MLDS_Context, Statement, !Info) :- :- pred is_integral_type(mlds_type::in) is semidet. -is_integral_type(mlds__native_int_type). -is_integral_type(mlds__native_char_type). -is_integral_type(mlds__mercury_type(_, type_cat_int, _)). -is_integral_type(mlds__mercury_type(_, type_cat_char, _)). -is_integral_type(mlds__mercury_type(_, type_cat_enum, _)). +is_integral_type(mlds_native_int_type). +is_integral_type(mlds_native_char_type). +is_integral_type(mercury_type(_, type_cat_int, _)). +is_integral_type(mercury_type(_, type_cat_char, _)). +is_integral_type(mercury_type(_, type_cat_enum, _)). -:- pred is_dense_switch(list(mlds__switch_case)::in, int::in) is semidet. +:- pred is_dense_switch(list(mlds_switch_case)::in, int::in) is semidet. is_dense_switch(Cases, ReqDensity) :- % Need at least two cases - NumCases = list__length(Cases), + NumCases = list.length(Cases), NumCases > 2, % The switch needs to be dense enough. @@ -141,8 +141,8 @@ is_dense_switch(Cases, ReqDensity) :- % we can make the jump table large enough to hold all % of the values for the type. % -:- pred maybe_eliminate_default(mlds__switch_range::in, - list(mlds__switch_case)::in, mlds__switch_default::in, int::in, +:- pred maybe_eliminate_default(mlds_switch_range::in, + list(mlds_switch_case)::in, mlds_switch_default::in, int::in, int::out, int::out, bool::out) is det. maybe_eliminate_default(Range, Cases, Default, ReqDensity, @@ -151,7 +151,7 @@ maybe_eliminate_default(Range, Cases, Default, ReqDensity, Default \= default_is_unreachable, Range = range(Min, Max), TypeRange = Max - Min + 1, - NumCases = list__length(Cases), + NumCases = list.length(Cases), NoDefaultDensity = calc_density(NumCases, TypeRange), NoDefaultDensity > ReqDensity -> @@ -180,28 +180,28 @@ calc_density(NumCases, Range) = Density :- % Find the highest and lowest case values in a list of cases. % -:- pred find_first_and_last_case(list(mlds__switch_case)::in, +:- pred find_first_and_last_case(list(mlds_switch_case)::in, int::out, int::out) is det. find_first_and_last_case(Cases, Min, Max) :- - list__foldl2(find_first_and_last_case_2, Cases, 0, Min, 0, Max). + list.foldl2(find_first_and_last_case_2, Cases, 0, Min, 0, Max). -:- pred find_first_and_last_case_2(mlds__switch_case::in, +:- pred find_first_and_last_case_2(mlds_switch_case::in, int::in, int::out, int::in, int::out) is det. find_first_and_last_case_2(Case, !Min, !Max) :- Case = CaseConds - _CaseStatement, - list__foldl2(find_first_and_last_case_3, CaseConds, !Min, !Max). + list.foldl2(find_first_and_last_case_3, CaseConds, !Min, !Max). -:- pred find_first_and_last_case_3(mlds__case_match_cond::in, +:- pred find_first_and_last_case_3(mlds_case_match_cond::in, int::in, int::out, int::in, int::out) is det. find_first_and_last_case_3(match_value(Rval), !Min, !Max) :- ( Rval = const(int_const(Val)) -> - int__min(Val, !Min), - int__max(Val, !Max) + int.min(Val, !Min), + int.max(Val, !Max) ; unexpected(this_file, "find_first_and_last_case_3: non-int case") ). @@ -211,8 +211,8 @@ find_first_and_last_case_3(match_range(MinRval, MaxRval), MinRval = const(int_const(RvalMin)), MaxRval = const(int_const(RvalMax)) -> - int__min(RvalMin, !Min), - int__max(RvalMax, !Max) + int.min(RvalMin, !Min), + int.max(RvalMax, !Max) ; unexpected(this_file, "find_first_and_last_case_3: non-int case") ). @@ -221,10 +221,10 @@ find_first_and_last_case_3(match_range(MinRval, MaxRval), % Generate code for a switch using a dense jump table. % -:- pred generate_dense_switch(list(mlds__switch_case)::in, - mlds__switch_default::in, int::in, int::in, bool::in, - mlds_type::in, mlds_rval::in, mlds__context::in, - mlds__defns::out, statements::out, +:- pred generate_dense_switch(list(mlds_switch_case)::in, + mlds_switch_default::in, int::in, int::in, bool::in, + mlds_type::in, mlds_rval::in, mlds_context::in, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. generate_dense_switch(Cases, Default, FirstVal, LastVal, NeedRangeCheck, @@ -239,7 +239,7 @@ generate_dense_switch(Cases, Default, FirstVal, LastVal, NeedRangeCheck, % Now generate the jump table. ml_gen_new_label(EndLabel, !Info), - map__init(CaseLabelsMap0), + map.init(CaseLabelsMap0), generate_cases(Cases, EndLabel, CaseLabelsMap0, CaseLabelsMap, CasesDecls, CasesCode, !Info), ml_gen_new_label(DefaultLabel, !Info), @@ -288,9 +288,9 @@ generate_dense_switch(Cases, Default, FirstVal, LastVal, NeedRangeCheck, ), Decls = CasesDecls. -:- pred generate_cases(list(mlds__switch_case)::in, mlds__label::in, +:- pred generate_cases(list(mlds_switch_case)::in, mlds_label::in, case_labels_map::in, case_labels_map::out, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. generate_cases([], _EndLabel, CaseLabelsMap, CaseLabelsMap, [], [], !Info). @@ -308,9 +308,9 @@ generate_cases([Case | Cases], EndLabel, CaseLabelsMap0, % by adding a label at the front and a `goto ' at the end. % It also inserts the label for this case into the CaseLabelsMap. % -:- pred generate_case(mlds__switch_case::in, mlds__label::in, +:- pred generate_case(mlds_switch_case::in, mlds_label::in, case_labels_map::in, case_labels_map::out, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. generate_case(Case, EndLabel, CaseLabelsMap0, CaseLabelsMap, @@ -336,9 +336,9 @@ generate_case(Case, EndLabel, CaseLabelsMap0, CaseLabelsMap, % We build up a map which records which label should be used for % each case value. -:- type case_labels_map == map(int, mlds__label). +:- type case_labels_map == map(int, mlds_label). -:- pred insert_cases_into_map(mlds__case_match_conds::in, mlds__label::in, +:- pred insert_cases_into_map(mlds_case_match_conds::in, mlds_label::in, case_labels_map::in, case_labels_map::out) is det. insert_cases_into_map([], _ThisLabel, !CaseLabelsMap). @@ -346,12 +346,12 @@ insert_cases_into_map([Cond|Conds], ThisLabel, !CaseLabelsMap) :- insert_case_into_map(Cond, ThisLabel, !CaseLabelsMap), insert_cases_into_map(Conds, ThisLabel, !CaseLabelsMap). -:- pred insert_case_into_map(mlds__case_match_cond::in, mlds__label::in, +:- pred insert_case_into_map(mlds_case_match_cond::in, mlds_label::in, case_labels_map::in, case_labels_map::out) is det. insert_case_into_map(match_value(Rval), ThisLabel, !CaseLabelsMap) :- ( Rval = const(int_const(Val)) -> - map__det_insert(!.CaseLabelsMap, Val, ThisLabel, !:CaseLabelsMap) + map.det_insert(!.CaseLabelsMap, Val, ThisLabel, !:CaseLabelsMap) ; unexpected(this_file, "insert_case_into_map: non-int case") ). @@ -366,14 +366,14 @@ insert_case_into_map(match_range(MinRval, MaxRval), ThisLabel, unexpected(this_file, "insert_case_into_map: non-int case") ). -:- pred insert_range_into_map(int::in, int::in, mlds__label::in, +:- pred insert_range_into_map(int::in, int::in, mlds_label::in, case_labels_map::in, case_labels_map::out) is det. insert_range_into_map(Min, Max, ThisLabel, !CaseLabelsMap) :- ( Min > Max -> true ; - map__det_insert(!.CaseLabelsMap, Min, ThisLabel, !:CaseLabelsMap), + map.det_insert(!.CaseLabelsMap, Min, ThisLabel, !:CaseLabelsMap), insert_range_into_map(Min + 1, Max, ThisLabel, !CaseLabelsMap) ). @@ -384,14 +384,14 @@ insert_range_into_map(Min, Max, ThisLabel, !CaseLabelsMap) :- % the map, this function returns the list of labels to use for the case % values. % -:- func get_case_labels(int, int, map(int, mlds__label), mlds__label) - = list(mlds__label). +:- func get_case_labels(int, int, map(int, mlds_label), mlds_label) + = list(mlds_label). get_case_labels(ThisVal, LastVal, CaseLabelsMap, DefaultLabel) = CaseLabels :- ( ThisVal > LastVal -> CaseLabels = [] ; - ( map__search(CaseLabelsMap, ThisVal, CaseLabel0) -> + ( map.search(CaseLabelsMap, ThisVal, CaseLabel0) -> CaseLabel = CaseLabel0 ; CaseLabel = DefaultLabel @@ -406,8 +406,8 @@ get_case_labels(ThisVal, LastVal, CaseLabelsMap, DefaultLabel) = CaseLabels :- % Convert an int switch to a chain of if-then-elses that test each case % in turn. % -:- func ml_switch_to_if_else_chain(mlds__switch_cases, mlds__switch_default, - mlds_rval, mlds__context) = statement. +:- func ml_switch_to_if_else_chain(mlds_switch_cases, mlds_switch_default, + mlds_rval, mlds_context) = statement. ml_switch_to_if_else_chain([], Default, _Rval, MLDS_Context) = Statement :- ( @@ -440,7 +440,7 @@ ml_switch_to_if_else_chain([Case | Cases], Default, SwitchRval, MLDS_Context) = % case conditions matches the specified rval (which must have integral % type). % -:- func ml_gen_case_match_conds(mlds__case_match_conds, mlds_rval) = mlds_rval. +:- func ml_gen_case_match_conds(mlds_case_match_conds, mlds_rval) = mlds_rval. ml_gen_case_match_conds([], _) = const(false). ml_gen_case_match_conds([Cond], SwitchRval) = @@ -453,7 +453,7 @@ ml_gen_case_match_conds([Cond1, Cond2 | Conds], SwitchRval) = % Generate an rval which will be true iff the specified case condition % matches the specified rval (which must have integral type). % -:- func ml_gen_case_match_cond(mlds__case_match_cond, mlds_rval) = mlds_rval. +:- func ml_gen_case_match_cond(mlds_case_match_cond, mlds_rval) = mlds_rval. ml_gen_case_match_cond(match_value(CaseRval), SwitchRval) = binop(eq, CaseRval, SwitchRval). diff --git a/compiler/ml_string_switch.m b/compiler/ml_string_switch.m index 6ea9fec16..e08498312 100644 --- a/compiler/ml_string_switch.m +++ b/compiler/ml_string_switch.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -17,7 +17,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_string_switch. +:- module ml_backend.ml_string_switch. :- interface. :- import_module backend_libs.switch_util. @@ -27,7 +27,7 @@ :- import_module parse_tree.prog_data. :- pred generate(cases_list::in, prog_var::in, code_model::in, can_fail::in, - prog_context::in, mlds__defns::out, statements::out, + prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -55,7 +55,7 @@ :- import_module string. generate(Cases, Var, CodeModel, _CanFail, Context, Decls, Statements, !Info) :- - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), % Compute the value we're going to switch on. ml_gen_var(!.Info, Var, VarLval), @@ -66,17 +66,17 @@ generate(Cases, Var, CodeModel, _CanFail, Context, Decls, Statements, !Info) :- % MR_String str; ml_gen_info_new_cond_var(SlotVarSeq, !Info), - SlotVarName = mlds__var_name( - string__format("slot_%d", [i(SlotVarSeq)]), no), - SlotVarType = mlds__native_int_type, + SlotVarName = mlds_var_name( + string.format("slot_%d", [i(SlotVarSeq)]), no), + SlotVarType = mlds_native_int_type, SlotVarGCTraceCode = no, % never need to trace ints SlotVarDefn = ml_gen_mlds_var_decl(var(SlotVarName), SlotVarType, SlotVarGCTraceCode, MLDS_Context), ml_gen_var_lval(!.Info, SlotVarName, SlotVarType, SlotVarLval), ml_gen_info_new_cond_var(StringVarSeq, !Info), - StringVarName = mlds__var_name( - string__format("str_%d", [i(StringVarSeq)]), no), + StringVarName = mlds_var_name( + string.format("str_%d", [i(StringVarSeq)]), no), StringVarType = ml_string_type, % This variable always points to an element of the string_table array, % which are all static constants; it can never point into the heap. @@ -95,16 +95,16 @@ generate(Cases, Var, CodeModel, _CanFail, Context, Decls, Statements, !Info) :- % of cases up to the nearest power of two, and then double it. This should % hopefully ensure that we don't get too many hash collisions. % - list__length(Cases, NumCases), - int__log2(NumCases, LogNumCases), - int__pow(2, LogNumCases, RoundedNumCases), + list.length(Cases, NumCases), + int.log2(NumCases, LogNumCases), + int.pow(2, LogNumCases, RoundedNumCases), TableSize = 2 * RoundedNumCases, HashMask = TableSize - 1, % Compute the hash table. - switch_util__string_hash_cases(Cases, HashMask, HashValsMap), - map__to_assoc_list(HashValsMap, HashValsList), - switch_util__calc_hash_slots(HashValsList, HashValsMap, HashSlotsMap), + switch_util.string_hash_cases(Cases, HashMask, HashValsMap), + map.to_assoc_list(HashValsMap, HashValsList), + switch_util.calc_hash_slots(HashValsList, HashValsMap, HashSlotsMap), % Generate the code for when the hash lookup fails. ml_gen_failure(CodeModel, Context, FailStatements, !Info), @@ -120,7 +120,7 @@ generate(Cases, Var, CodeModel, _CanFail, Context, Decls, Statements, !Info) :- ml_gen_info_new_const(NextSlotsSeq, !Info), ml_format_static_const_name(!.Info, "next_slots_table", NextSlotsSeq, NextSlotsName), - NextSlotsType = mlds__array_type(SlotVarType), + NextSlotsType = mlds_array_type(SlotVarType), NextSlotsDefn = ml_gen_static_const_defn(NextSlotsName, NextSlotsType, local, init_array(NextSlots), Context), ml_gen_var_lval(!.Info, NextSlotsName, NextSlotsType, NextSlotsLval), @@ -128,7 +128,7 @@ generate(Cases, Var, CodeModel, _CanFail, Context, Decls, Statements, !Info) :- ml_gen_info_new_const(StringTableSeq, !Info), ml_format_static_const_name(!.Info, "string_table", StringTableSeq, StringTableName), - StringTableType = mlds__array_type(StringVarType), + StringTableType = mlds_array_type(StringVarType), StringTableDefn = ml_gen_static_const_defn(StringTableName, StringTableType, local, init_array(Strings), Context), ml_gen_var_lval(!.Info, StringTableName, StringTableType, @@ -214,8 +214,8 @@ generate(Cases, Var, CodeModel, _CanFail, Context, Decls, Statements, !Info) :- :- pred gen_hash_slots(int::in, int::in, map(int, hash_slot)::in, code_model::in, prog_context::in, - list(mlds__initializer)::out, list(mlds__initializer)::out, - list(mlds__switch_case)::out, + list(mlds_initializer)::out, list(mlds_initializer)::out, + list(mlds_switch_case)::out, ml_gen_info::in, ml_gen_info::out) is det. gen_hash_slots(Slot, TableSize, HashSlotMap, CodeModel, Context, Strings, @@ -225,7 +225,7 @@ gen_hash_slots(Slot, TableSize, HashSlotMap, CodeModel, Context, Strings, NextSlots = [], MLDS_Cases = [] ; - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), gen_hash_slot(Slot, HashSlotMap, CodeModel, MLDS_Context, String, NextSlot, SlotCases, !Info), gen_hash_slots(Slot + 1, TableSize, HashSlotMap, CodeModel, Context, @@ -236,13 +236,13 @@ gen_hash_slots(Slot, TableSize, HashSlotMap, CodeModel, Context, Strings, ). :- pred gen_hash_slot(int::in, map(int, hash_slot)::in, - code_model::in, mlds__context::in, mlds__initializer::out, - mlds__initializer::out, list(mlds__switch_case)::out, + code_model::in, mlds_context::in, mlds_initializer::out, + mlds_initializer::out, list(mlds_switch_case)::out, ml_gen_info::in, ml_gen_info::out) is det. gen_hash_slot(Slot, HashSlotMap, CodeModel, MLDS_Context, init_obj(StringRval), init_obj(NextSlotRval), MLDS_Cases, !Info) :- - ( map__search(HashSlotMap, Slot, hash_slot(Case, Next)) -> + ( map.search(HashSlotMap, Slot, hash_slot(Case, Next)) -> NextSlotRval = const(int_const(Next)), Case = case(_, ConsTag, _, Goal), ( ConsTag = string_constant(String0) -> @@ -253,7 +253,7 @@ gen_hash_slot(Slot, HashSlotMap, CodeModel, MLDS_Context, StringRval = const(string_const(String)), ml_gen_goal(CodeModel, Goal, GoalStatement, !Info), - string__append_list(["case """, String, """"], CommentString), + string.append_list(["case """, String, """"], CommentString), Comment = statement(atomic(comment(CommentString)), MLDS_Context), CaseStatement = statement(block([], [Comment, GoalStatement]), diff --git a/compiler/ml_switch_gen.m b/compiler/ml_switch_gen.m index 8c4badae1..9c0a528ed 100644 --- a/compiler/ml_switch_gen.m +++ b/compiler/ml_switch_gen.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -62,7 +62,7 @@ % %-----------------------------------------------------------------------------% -:- module ml_backend__ml_switch_gen. +:- module ml_backend.ml_switch_gen. :- interface. @@ -79,13 +79,13 @@ % :- pred ml_gen_switch(prog_var::in, can_fail::in, list(case)::in, code_model::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % Generate an appropriate default for a switch. % :- pred ml_switch_generate_default(can_fail::in, code_model::in, - prog_context::in, switch_default::out, + prog_context::in, mlds_switch_default::out, ml_gen_info::in, ml_gen_info::out) is det. % Succeed iff the target supports the specified construct. @@ -121,23 +121,23 @@ %-----------------------------------------------------------------------------% -ml_gen_switch(CaseVar, CanFail, Cases, CodeModel, Context, - Decls, Statements, !Info) :- +ml_gen_switch(CaseVar, CanFail, Cases, CodeModel, Context, Decls, Statements, + !Info) :- % Lookup the representation of the constructors for the tag tests % and their corresponding priorities. ml_switch_lookup_tags(!.Info, Cases, CaseVar, TaggedCases0), % Sort the cases according to the priority of their tag tests. - list__sort_and_remove_dups(TaggedCases0, TaggedCases), + list.sort_and_remove_dups(TaggedCases0, TaggedCases), % Figure out what kind of switch this is. - ml_switch_gen__determine_category(!.Info, CaseVar, SwitchCategory), + SwitchCategory = determine_category(!.Info, CaseVar), ml_gen_info_get_globals(!.Info, Globals), - globals__lookup_bool_option(Globals, smart_indexing, Indexing), + globals.lookup_bool_option(Globals, smart_indexing, Indexing), ( % Check for a switch on a type whose representation % uses reserved addresses. - list__member(Case, TaggedCases), + list.member(Case, TaggedCases), Case = case(_Priority, Tag, _ConsId, _Goal), ( Tag = reserved_address(_) @@ -157,27 +157,27 @@ ml_gen_switch(CaseVar, CanFail, Cases, CodeModel, Context, % % Note that if/when the MLDS back-end supports execution % % tracing, we would also need to check that tracing is not % % enabled. -% list__length(TaggedCases, NumCases), -% globals__lookup_int_option(Globals, lookup_switch_size, +% list.length(TaggedCases, NumCases), +% globals.lookup_int_option(Globals, lookup_switch_size, % LookupSize), % NumCases >= LookupSize, -% globals__lookup_int_option(Globals, lookup_switch_req_density, +% globals.lookup_int_option(Globals, lookup_switch_req_density, % ReqDensity), -% lookup_switch__is_lookup_switch(CaseVar, TaggedCases, GoalInfo, +% lookup_switch.is_lookup_switch(CaseVar, TaggedCases, GoalInfo, % CanFail, ReqDensity, % CodeModel, FirstVal, LastVal, NeedRangeCheck, % NeedBitVecCheck, OutVars, CaseVals, !Info) % -> % MaybeEnd = MaybeEndPrime, -% ml_lookup_switch__generate(CaseVar, OutVars, CaseVals, +% ml_lookup_switch.generate(CaseVar, OutVars, CaseVals, % FirstVal, LastVal, NeedRangeCheck, NeedBitVecCheck, % Decls, Statements, !Info) % ; % Try using a string hash switch. Indexing = yes, SwitchCategory = string_switch, - list__length(TaggedCases, NumCases), - globals__lookup_int_option(Globals, string_switch_size, StringSize), + list.length(TaggedCases, NumCases), + globals.lookup_int_option(Globals, string_switch_size, StringSize), NumCases >= StringSize, % We can implement string hash switches using either % computed gotos or int switches. @@ -195,21 +195,21 @@ ml_gen_switch(CaseVar, CanFail, Cases, CodeModel, Context, % We may prefer to do a direct-mapped string switch. \+ ( target_supports_string_switch(Globals), - globals__lookup_bool_option(Globals, prefer_switch, yes) + globals.lookup_bool_option(Globals, prefer_switch, yes) ) -> - ml_string_switch__generate(TaggedCases, CaseVar, CodeModel, + ml_string_switch.generate(TaggedCases, CaseVar, CodeModel, CanFail, Context, Decls, Statements, !Info) ; % Try using a tag switch. Indexing = yes, SwitchCategory = tag_switch, - list__length(TaggedCases, NumCases), - globals__lookup_int_option(Globals, tag_switch_size, TagSize), + list.length(TaggedCases, NumCases), + globals.lookup_int_option(Globals, tag_switch_size, TagSize), NumCases >= TagSize, target_supports_int_switch(Globals) -> - ml_tag_switch__generate(TaggedCases, CaseVar, CodeModel, + ml_tag_switch.generate(TaggedCases, CaseVar, CodeModel, CanFail, Context, Decls, Statements, !Info) ; % Try using a "direct-mapped" switch. This also handles dense @@ -236,8 +236,7 @@ ml_gen_switch(CaseVar, CanFail, Cases, CodeModel, Context, %-----------------------------------------------------------------------------% -:- pred target_supports_switch(switch_category::in, globals::in) - is semidet. +:- pred target_supports_switch(switch_category::in, globals::in) is semidet. target_supports_switch(SwitchCategory, Globals) :- ( @@ -249,19 +248,19 @@ target_supports_switch(SwitchCategory, Globals) :- ). target_supports_int_switch(Globals) :- - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), target_supports_int_switch_2(Target) = yes. target_supports_string_switch(Globals) :- - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), target_supports_string_switch_2(Target) = yes. target_supports_goto(Globals) :- - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), target_supports_goto_2(Target) = yes. target_supports_computed_goto(Globals) :- - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), target_supports_computed_goto_2(Target) = yes. :- func target_supports_int_switch_2(compilation_target) = bool. @@ -300,14 +299,13 @@ target_supports_goto_2(java) = no. % We categorize switches according to whether the value being switched on % is an atomic type, a string, or something more complicated. % -:- pred ml_switch_gen__determine_category(ml_gen_info::in, prog_var::in, - switch_category::out) is det. +:- func determine_category(ml_gen_info, prog_var) = switch_category. -ml_switch_gen__determine_category(Info, CaseVar, SwitchCategory) :- +determine_category(Info, CaseVar) = SwitchCategory :- ml_variable_type(Info, CaseVar, Type), ml_gen_info_get_module_info(Info, ModuleInfo), - type_util__classify_type(ModuleInfo, Type) = TypeCategory, - SwitchCategory = switch_util__type_cat_to_switch_cat(TypeCategory). + type_util.classify_type(ModuleInfo, Type) = TypeCategory, + SwitchCategory = switch_util.type_cat_to_switch_cat(TypeCategory). %-----------------------------------------------------------------------------% @@ -322,7 +320,7 @@ ml_switch_lookup_tags(Info, [Case | Cases], Var, [TaggedCase | TaggedCases]) :- Case = case(ConsId, Goal), ml_variable_type(Info, Var, Type), ml_cons_id_to_tag(Info, ConsId, Type, Tag), - Priority = switch_util__switch_priority(Tag), + Priority = switch_util.switch_priority(Tag), TaggedCase = case(Priority, Tag, ConsId, Goal), ml_switch_lookup_tags(Info, Cases, Var, TaggedCases). @@ -332,7 +330,7 @@ ml_switch_lookup_tags(Info, [Case | Cases], Var, [TaggedCase | TaggedCases]) :- % :- pred ml_switch_generate_if_else_chain(list(extended_case)::in, prog_var::in, code_model::in, can_fail::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_switch_generate_if_else_chain([], _Var, CodeModel, CanFail, Context, @@ -360,7 +358,7 @@ ml_switch_generate_if_else_chain([Case | Cases], Var, CodeModel, CanFail, CanFail, Context, RestDecls, RestStatements, !Info), Rest = ml_gen_block(RestDecls, RestStatements, Context), IfStmt = if_then_else(TagTestExpression, GoalStatement, yes(Rest)), - IfStatement = statement(IfStmt, mlds__make_context(Context)), + IfStatement = statement(IfStmt, mlds_make_context(Context)), Decls = TagTestDecls, Statements = TagTestStatements ++ [IfStatement] ). @@ -372,34 +370,33 @@ ml_switch_generate_if_else_chain([Case | Cases], Var, CodeModel, CanFail, % language. % :- pred ml_switch_generate_mlds_switch(list(extended_case)::in, prog_var::in, - code_model::in, can_fail::in, prog_context::in, - mlds__defns::out, statements::out, - ml_gen_info::in, ml_gen_info::out) is det. + code_model::in, can_fail::in, prog_context::in, mlds_defns::out, + statements::out, ml_gen_info::in, ml_gen_info::out) is det. -ml_switch_generate_mlds_switch(Cases, Var, CodeModel, CanFail, - Context, Decls, Statements, !Info) :- +ml_switch_generate_mlds_switch(Cases, Var, CodeModel, CanFail, Context, + Decls, Statements, !Info) :- ml_variable_type(!.Info, Var, Type), ml_gen_type(!.Info, Type, MLDS_Type), ml_gen_var(!.Info, Var, Lval), - Rval = mlds__lval(Lval), + Rval = lval(Lval), ml_switch_gen_range(!.Info, MLDS_Type, Range), ml_switch_generate_mlds_cases(Cases, CodeModel, MLDS_Cases, !Info), ml_switch_generate_default(CanFail, CodeModel, Context, Default, !Info), SwitchStmt0 = switch(MLDS_Type, Rval, Range, MLDS_Cases, Default), - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), ml_simplify_switch(SwitchStmt0, MLDS_Context, SwitchStatement, !Info), Decls = [], Statements = [SwitchStatement]. :- pred ml_switch_gen_range(ml_gen_info::in, mlds_type::in, - mlds__switch_range::out) is det. + mlds_switch_range::out) is det. ml_switch_gen_range(Info, MLDS_Type, Range) :- ( ml_gen_info_get_module_info(Info, ModuleInfo), ExportedType = to_exported_type(ModuleInfo, Type), MLDS_Type = mercury_type(Type, TypeCategory, ExportedType), - switch_util__type_range(TypeCategory, Type, ModuleInfo, + switch_util.type_range(TypeCategory, Type, ModuleInfo, MinRange, MaxRange) -> Range = range(MinRange, MaxRange) @@ -408,7 +405,7 @@ ml_switch_gen_range(Info, MLDS_Type, Range) :- ). :- pred ml_switch_generate_mlds_cases(list(extended_case)::in, - code_model::in, list(mlds__switch_case)::out, + code_model::in, list(mlds_switch_case)::out, ml_gen_info::in, ml_gen_info::out) is det. ml_switch_generate_mlds_cases([], _, [], !Info). @@ -418,7 +415,7 @@ ml_switch_generate_mlds_cases([Case | Cases], CodeModel, ml_switch_generate_mlds_cases(Cases, CodeModel, MLDS_Cases, !Info). :- pred ml_switch_generate_mlds_case(extended_case::in, code_model::in, - mlds__switch_case::out, + mlds_switch_case::out, ml_gen_info::in, ml_gen_info::out) is det. ml_switch_generate_mlds_case(Case, CodeModel, MLDS_Case, !Info) :- diff --git a/compiler/ml_tag_switch.m b/compiler/ml_tag_switch.m index a53f1ddb3..04527bb08 100644 --- a/compiler/ml_tag_switch.m +++ b/compiler/ml_tag_switch.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2000, 2003-2005 The University of Melbourne. +% Copyright (C) 2000, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_tag_switch. +:- module ml_backend.ml_tag_switch. :- interface. @@ -29,7 +29,7 @@ % Generate efficient indexing code for tag based switches. % :- pred generate(list(extended_case)::in, prog_var::in, code_model::in, - can_fail::in, prog_context::in, mlds__defns::out, statements::out, + can_fail::in, prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -68,11 +68,11 @@ generate(Cases, Var, CodeModel, CanFail, Context, Decls, Statements, !Info) :- ml_gen_info_get_module_info(!.Info, ModuleInfo), ml_variable_type(!.Info, Var, Type), - switch_util__get_ptag_counts(Type, ModuleInfo, MaxPrimary, PtagCountMap), - map__to_assoc_list(PtagCountMap, PtagCountList), - map__init(PtagCaseMap0), - switch_util__group_cases_by_ptag(Cases, PtagCaseMap0, PtagCaseMap), - switch_util__order_ptags_by_count(PtagCountList, PtagCaseMap, + switch_util.get_ptag_counts(Type, ModuleInfo, MaxPrimary, PtagCountMap), + map.to_assoc_list(PtagCountMap, PtagCountList), + map.init(PtagCaseMap0), + switch_util.group_cases_by_ptag(Cases, PtagCaseMap0, PtagCaseMap), + switch_util.order_ptags_by_count(PtagCountList, PtagCaseMap, PtagCaseList), % Generate the switch on the primary tag. @@ -82,16 +82,16 @@ generate(Cases, Var, CodeModel, CanFail, Context, Decls, Statements, !Info) :- % Package up the results into a switch statement. Range = range(0, MaxPrimary), - SwitchStmt0 = switch(mlds__native_int_type, PTagRval, Range, MLDS_Cases, + SwitchStmt0 = switch(mlds_native_int_type, PTagRval, Range, MLDS_Cases, Default), - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), ml_simplify_switch(SwitchStmt0, MLDS_Context, SwitchStatement, !Info), Decls = [], Statements = [SwitchStatement]. :- pred gen_ptag_cases(ptag_case_list::in, prog_var::in, can_fail::in, code_model::in, ptag_count_map::in, - prog_context::in, list(mlds__switch_case)::out, + prog_context::in, list(mlds_switch_case)::out, ml_gen_info::in, ml_gen_info::out) is det. gen_ptag_cases([], _, _, _, _, _, [], !Info). @@ -104,17 +104,17 @@ gen_ptag_cases([Case | Cases], Var, CanFail, CodeModel, :- pred gen_ptag_case(pair(tag_bits, ptag_case)::in, prog_var::in, can_fail::in, code_model::in, ptag_count_map::in, - prog_context::in, mlds__switch_case::out, + prog_context::in, mlds_switch_case::out, ml_gen_info::in, ml_gen_info::out) is det. gen_ptag_case(Case, Var, CanFail, CodeModel, PtagCountMap, Context, MLDS_Case, !Info) :- Case = PrimaryTag - ptag_case(SecTagLocn, GoalMap), - map__lookup(PtagCountMap, PrimaryTag, CountInfo), + map.lookup(PtagCountMap, PrimaryTag, CountInfo), CountInfo = SecTagLocn1 - MaxSecondary, expect(unify(SecTagLocn, SecTagLocn1), this_file, "ml_tag_switch.m: secondary tag locations differ"), - map__to_assoc_list(GoalMap, GoalList), + map.to_assoc_list(GoalMap, GoalList), ( SecTagLocn = none -> % There is no secondary tag, so there is no switch on it. ( @@ -133,7 +133,7 @@ gen_ptag_case(Case, Var, CanFail, CodeModel, PtagCountMap, Context, MLDS_Case, -> CaseCanFail = cannot_fail ; - list__length(GoalList, GoalCount), + list.length(GoalList, GoalCount), FullGoalCount = MaxSecondary + 1, FullGoalCount = GoalCount -> @@ -186,13 +186,13 @@ gen_stag_switch(Cases, PrimaryTag, StagLocn, Var, CodeModel, CanFail, Context, % Package up the results into a switch statement. Range = range_unknown, % XXX could do better - SwitchStmt = switch(mlds__native_int_type, STagRval, Range, MLDS_Cases, + SwitchStmt = switch(mlds_native_int_type, STagRval, Range, MLDS_Cases, Default), - MLDS_Context = mlds__make_context(Context), + MLDS_Context = mlds_make_context(Context), ml_simplify_switch(SwitchStmt, MLDS_Context, Statement, !Info). :- pred gen_stag_cases(stag_goal_list::in, code_model::in, - list(mlds__switch_case)::out, ml_gen_info::in, ml_gen_info::out) is det. + list(mlds_switch_case)::out, ml_gen_info::in, ml_gen_info::out) is det. gen_stag_cases([], _, [], !Info). gen_stag_cases([Case | Cases], CodeModel, [MLDS_Case | MLDS_Cases], !Info) :- @@ -200,7 +200,7 @@ gen_stag_cases([Case | Cases], CodeModel, [MLDS_Case | MLDS_Cases], !Info) :- gen_stag_cases(Cases, CodeModel, MLDS_Cases, !Info). :- pred gen_stag_case(pair(tag_bits, stag_goal)::in, - code_model::in, mlds__switch_case::out, + code_model::in, mlds_switch_case::out, ml_gen_info::in, ml_gen_info::out) is det. gen_stag_case(Case, CodeModel, MLDS_Case, !Info) :- diff --git a/compiler/ml_tailcall.m b/compiler/ml_tailcall.m index 82f54623c..a236baf4d 100644 --- a/compiler/ml_tailcall.m +++ b/compiler/ml_tailcall.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1999-2005 The University of Melbourne. +% Copyright (C) 1999-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -53,7 +53,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_tailcall. +:- module ml_backend.ml_tailcall. :- interface. @@ -104,8 +104,8 @@ ml_mark_tailcalls(MLDS0, MLDS, !IO) :- % which are in scope. :- type locals == list(local_defns). :- type local_defns - ---> params(mlds__arguments) - ; defns(mlds__defns). + ---> params(mlds_arguments) + ; defns(mlds_defns). %-----------------------------------------------------------------------------% @@ -127,18 +127,18 @@ ml_mark_tailcalls(MLDS0, MLDS, !IO) :- % The `Locals' argument contains a list of the % local definitions which are in scope at this point. -:- func mark_tailcalls_in_defns(mlds__defns) = mlds__defns. +:- func mark_tailcalls_in_defns(mlds_defns) = mlds_defns. -mark_tailcalls_in_defns(Defns) = list__map(mark_tailcalls_in_defn, Defns). +mark_tailcalls_in_defns(Defns) = list.map(mark_tailcalls_in_defn, Defns). -:- func mark_tailcalls_in_defn(mlds__defn) = mlds__defn. +:- func mark_tailcalls_in_defn(mlds_defn) = mlds_defn. mark_tailcalls_in_defn(Defn0) = Defn :- - Defn0 = mlds__defn(Name, Context, Flags, DefnBody0), + Defn0 = mlds_defn(Name, Context, Flags, DefnBody0), ( - DefnBody0 = mlds__function(PredProcId, Params, FuncBody0, Attributes), + DefnBody0 = mlds_function(PredProcId, Params, FuncBody0, Attributes), % Compute the initial value of the `Locals' and `AtTail' arguments. - Params = mlds__func_params(Args, RetTypes), + Params = mlds_func_params(Args, RetTypes), Locals = [params(Args)], ( RetTypes = [], @@ -148,25 +148,25 @@ mark_tailcalls_in_defn(Defn0) = Defn :- AtTail = no ), FuncBody = mark_tailcalls_in_function_body(FuncBody0, AtTail, Locals), - DefnBody = mlds__function(PredProcId, Params, FuncBody, Attributes), - Defn = mlds__defn(Name, Context, Flags, DefnBody) + DefnBody = mlds_function(PredProcId, Params, FuncBody, Attributes), + Defn = mlds_defn(Name, Context, Flags, DefnBody) ; - DefnBody0 = mlds__data(_, _, _), + DefnBody0 = mlds_data(_, _, _), Defn = Defn0 ; - DefnBody0 = mlds__class(ClassDefn0), - ClassDefn0 = class_defn(Kind, Imports, BaseClasses, Implements, + DefnBody0 = mlds_class(ClassDefn0), + ClassDefn0 = mlds_class_defn(Kind, Imports, BaseClasses, Implements, CtorDefns0, MemberDefns0), CtorDefns = mark_tailcalls_in_defns(CtorDefns0), MemberDefns = mark_tailcalls_in_defns(MemberDefns0), - ClassDefn = class_defn(Kind, Imports, BaseClasses, Implements, + ClassDefn = mlds_class_defn(Kind, Imports, BaseClasses, Implements, CtorDefns, MemberDefns), - DefnBody = mlds__class(ClassDefn), - Defn = mlds__defn(Name, Context, Flags, DefnBody) + DefnBody = mlds_class(ClassDefn), + Defn = mlds_defn(Name, Context, Flags, DefnBody) ). -:- func mark_tailcalls_in_function_body(function_body, at_tail, locals) - = function_body. +:- func mark_tailcalls_in_function_body(mlds_function_body, at_tail, locals) + = mlds_function_body. mark_tailcalls_in_function_body(external, _, _) = external. mark_tailcalls_in_function_body(defined_here(Statement0), AtTail, Locals) = @@ -212,7 +212,7 @@ mark_tailcalls_in_statement(Statement0, AtTail, Locals) = Statement :- Stmt = mark_tailcalls_in_stmt(Stmt0, AtTail, Locals), Statement = statement(Stmt, Context). -:- func mark_tailcalls_in_stmt(mlds__stmt, at_tail, locals) = mlds__stmt. +:- func mark_tailcalls_in_stmt(mlds_stmt, at_tail, locals) = mlds_stmt. mark_tailcalls_in_stmt(Stmt0, AtTail, Locals) = Stmt :- ( @@ -307,8 +307,8 @@ mark_tailcalls_in_stmt(Stmt0, AtTail, Locals) = Stmt :- Stmt = Stmt0 ). -:- func mark_tailcalls_in_cases(list(mlds__switch_case), at_tail, locals) = - list(mlds__switch_case). +:- func mark_tailcalls_in_cases(list(mlds_switch_case), at_tail, locals) = + list(mlds_switch_case). mark_tailcalls_in_cases([], _, _) = []. mark_tailcalls_in_cases([Case0 | Cases0], AtTail, Locals) = @@ -316,15 +316,15 @@ mark_tailcalls_in_cases([Case0 | Cases0], AtTail, Locals) = Case = mark_tailcalls_in_case(Case0, AtTail, Locals), Cases = mark_tailcalls_in_cases(Cases0, AtTail, Locals). -:- func mark_tailcalls_in_case(mlds__switch_case, at_tail, locals) = - mlds__switch_case. +:- func mark_tailcalls_in_case(mlds_switch_case, at_tail, locals) = + mlds_switch_case. mark_tailcalls_in_case(Cond - Statement0, AtTail, Locals) = Cond - Statement :- Statement = mark_tailcalls_in_statement(Statement0, AtTail, Locals). -:- func mark_tailcalls_in_default(mlds__switch_default, at_tail, locals) = - mlds__switch_default. +:- func mark_tailcalls_in_default(mlds_switch_default, at_tail, locals) = + mlds_switch_default. mark_tailcalls_in_default(default_do_nothing, _, _) = default_do_nothing. mark_tailcalls_in_default(default_is_unreachable, _, _) = @@ -457,7 +457,7 @@ check_const(Const, Locals) :- % It would be safe to fail for variables declared static (i.e. `one_copy'), % but currently we just take a conservative approach. % -:- pred var_is_local(mlds__var::in, locals::in) is semidet. +:- pred var_is_local(mlds_var::in, locals::in) is semidet. var_is_local(Var, Locals) :- % XXX we ignore the ModuleName -- that is safe, but overly conservative. @@ -470,7 +470,7 @@ var_is_local(Var, Locals) :- % Check whether the specified function is defined locally (i.e. as a % nested function). % -:- pred function_is_local(mlds__code_addr::in, locals::in) is semidet. +:- pred function_is_local(mlds_code_addr::in, locals::in) is semidet. function_is_local(CodeAddr, Locals) :- ( @@ -493,31 +493,31 @@ function_is_local(CodeAddr, Locals) :- % % Nondeterministically enumerates the names of all the entities in Locals. % -:- pred locals_member(mlds__entity_name::out, locals::in) is nondet. +:- pred locals_member(mlds_entity_name::out, locals::in) is nondet. locals_member(Name, LocalsList) :- - list__member(Locals, LocalsList), + list.member(Locals, LocalsList), ( Locals = defns(Defns), - list__member(Defn, Defns), - Defn = mlds__defn(Name, _, _, _) + list.member(Defn, Defns), + Defn = mlds_defn(Name, _, _, _) ; Locals = params(Params), - list__member(Param, Params), - Param = mlds__argument(Name, _, _) + list.member(Param, Params), + Param = mlds_argument(Name, _, _) ). %-----------------------------------------------------------------------------% ml_warn_tailcalls(MLDS, !IO) :- solutions(nontailcall_in_mlds(MLDS), Warnings), - list__foldl(report_nontailcall_warning, Warnings, !IO). + list.foldl(report_nontailcall_warning, Warnings, !IO). :- type tailcall_warning ---> tailcall_warning( - mlds__pred_label, + mlds_pred_label, proc_id, - mlds__context + mlds_context ). :- pred nontailcall_in_mlds(mlds::in, tailcall_warning::out) is nondet. @@ -527,33 +527,33 @@ nontailcall_in_mlds(MLDS, Warning) :- MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName), nontailcall_in_defns(MLDS_ModuleName, Defns, Warning). -:- pred nontailcall_in_defns(mlds_module_name::in, mlds__defns::in, +:- pred nontailcall_in_defns(mlds_module_name::in, mlds_defns::in, tailcall_warning::out) is nondet. nontailcall_in_defns(ModuleName, Defns, Warning) :- - list__member(Defn, Defns), + list.member(Defn, Defns), nontailcall_in_defn(ModuleName, Defn, Warning). -:- pred nontailcall_in_defn(mlds_module_name::in, mlds__defn::in, +:- pred nontailcall_in_defn(mlds_module_name::in, mlds_defn::in, tailcall_warning::out) is nondet. nontailcall_in_defn(ModuleName, Defn, Warning) :- - Defn = mlds__defn(Name, _Context, _Flags, DefnBody), + Defn = mlds_defn(Name, _Context, _Flags, DefnBody), ( - DefnBody = mlds__function(_PredProcId, _Params, FuncBody, + DefnBody = mlds_function(_PredProcId, _Params, FuncBody, _Attributes), FuncBody = defined_here(Body), nontailcall_in_statement(ModuleName, Name, Body, Warning) ; - DefnBody = mlds__class(ClassDefn), - ClassDefn = class_defn(_Kind, _Imports, _BaseClasses, + DefnBody = mlds_class(ClassDefn), + ClassDefn = mlds_class_defn(_Kind, _Imports, _BaseClasses, _Implements, CtorDefns, MemberDefns), ( nontailcall_in_defns(ModuleName, CtorDefns, Warning) ; nontailcall_in_defns(ModuleName, MemberDefns, Warning) ) ). -:- pred nontailcall_in_statement(mlds_module_name::in, mlds__entity_name::in, +:- pred nontailcall_in_statement(mlds_module_name::in, mlds_entity_name::in, statement::in, tailcall_warning::out) is nondet. nontailcall_in_statement(CallerModule, CallerFuncName, Statement, Warning) :- @@ -588,8 +588,8 @@ report_nontailcall_warning(tailcall_warning(PredLabel, ProcId, Context), unqualified(Name) / Arity), proc_id_to_int(ProcId, ProcNumber0), ProcNumber = ProcNumber0 + 1, - ProcNumberStr = string__int_to_string(ProcNumber), - report_warning(mlds__get_prog_context(Context), 0, [ + ProcNumberStr = string.int_to_string(ProcNumber), + report_warning(mlds_get_prog_context(Context), 0, [ words("In mode number"), words(ProcNumberStr), words("of"), fixed(CallId ++ ":"), nl, words("warning: recursive call is not tail recursive.") diff --git a/compiler/ml_type_gen.m b/compiler/ml_type_gen.m index 9bc9dc2e4..d32c96f6e 100644 --- a/compiler/ml_type_gen.m +++ b/compiler/ml_type_gen.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1999-2005 The University of Melbourne. +% Copyright (C) 1999-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -23,7 +23,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_type_gen. +:- module ml_backend.ml_type_gen. :- interface. :- import_module hlds.hlds_data. @@ -35,30 +35,30 @@ % Generate MLDS definitions for all the types in the HLDS. % -:- pred ml_gen_types(module_info::in, mlds__defns::out, io::di, io::uo) is det. +:- pred ml_gen_types(module_info::in, mlds_defns::out, io::di, io::uo) is det. % Given an HLDS type_ctor, generate the MLDS class name and arity % for the corresponding MLDS type. % -:- pred ml_gen_type_name(type_ctor::in, mlds__class::out, arity::out) is det. +:- pred ml_gen_type_name(type_ctor::in, mlds_class::out, arity::out) is det. % Return the declaration flags appropriate for a type. % -:- func ml_gen_type_decl_flags = mlds__decl_flags. +:- func ml_gen_type_decl_flags = mlds_decl_flags. % Return the declaration flags appropriate for an enumeration constant. % -:- func ml_gen_enum_constant_decl_flags = mlds__decl_flags. +:- func ml_gen_enum_constant_decl_flags = mlds_decl_flags. % Return the declaration flags appropriate for a member variable. % -:- func ml_gen_member_decl_flags = mlds__decl_flags. +:- func ml_gen_member_decl_flags = mlds_decl_flags. % Return the declaration flags appropriate for a member of a class % that was transformed from a special predicate. These differ % from normal members in that their finality is `final'. % -:- func ml_gen_special_member_decl_flags = mlds__decl_flags. +:- func ml_gen_special_member_decl_flags = mlds_decl_flags. % % ml_uses_secondary_tag(ConsTagValues, Ctor, SecondaryTag): @@ -100,16 +100,16 @@ :- import_module term. ml_gen_types(ModuleInfo, MLDS_TypeDefns, !IO) :- - globals__io_lookup_bool_option(highlevel_data, HighLevelData, !IO), - globals__io_get_target(Target, !IO), + globals.io_lookup_bool_option(highlevel_data, HighLevelData, !IO), + globals.io_get_target(Target, !IO), ( HighLevelData = yes, module_info_get_type_table(ModuleInfo, TypeTable), - map__keys(TypeTable, TypeCtors0), - list__filter((pred(TypeCtor::in) is semidet :- + map.keys(TypeTable, TypeCtors0), + list.filter((pred(TypeCtor::in) is semidet :- \+ type_ctor_needs_lowlevel_rep(Target, TypeCtor) ), TypeCtors0, TypeCtors), - list__foldl(ml_gen_type_defn(ModuleInfo, TypeTable), TypeCtors, + list.foldl(ml_gen_type_defn(ModuleInfo, TypeTable), TypeCtors, [], MLDS_TypeDefns) ; HighLevelData = no, @@ -117,13 +117,13 @@ ml_gen_types(ModuleInfo, MLDS_TypeDefns, !IO) :- ). :- pred ml_gen_type_defn(module_info::in, type_table::in, type_ctor::in, - mlds__defns::in, mlds__defns::out) is det. + mlds_defns::in, mlds_defns::out) is det. ml_gen_type_defn(ModuleInfo, TypeTable, TypeCtor, MLDS_Defns0, MLDS_Defns) :- - map__lookup(TypeTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_status(TypeDefn, Status), + map.lookup(TypeTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_status(TypeDefn, Status), ( status_defined_in_this_module(Status, yes) -> - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), ml_gen_type_2(TypeBody, ModuleInfo, TypeCtor, TypeDefn, MLDS_Defns0, MLDS_Defns) ; @@ -131,7 +131,7 @@ ml_gen_type_defn(ModuleInfo, TypeTable, TypeCtor, MLDS_Defns0, MLDS_Defns) :- ). :- pred ml_gen_type_2(hlds_type_body::in, module_info::in, type_ctor::in, - hlds_type_defn::in, mlds__defns::in, mlds__defns::out) is det. + hlds_type_defn::in, mlds_defns::in, mlds_defns::out) is det. ml_gen_type_2(abstract_type(_), _, _, _, !Defns). ml_gen_type_2(eqv_type(_EqvType), _, _, _, !Defns). @@ -175,18 +175,18 @@ ml_gen_type_2(solver_type(_, _), _, _, _, !Defns). % int value; % }; % - % It is marked as an mlds__enum so that the MLDS -> target code + % It is marked as an mlds_enum so that the MLDS -> target code % generator can treat it specially if need be (e.g. generating % a C enum rather than a class). % :- pred ml_gen_enum_type(type_ctor::in, hlds_type_defn::in, - list(constructor)::in, cons_tag_values::in, mlds__defns::in, - mlds__defns::in, mlds__defns::out) is det. + list(constructor)::in, cons_tag_values::in, mlds_defns::in, + mlds_defns::in, mlds_defns::out) is det. ml_gen_enum_type(TypeCtor, TypeDefn, Ctors, TagValues, MaybeEqualityMembers, MLDS_Defns0, MLDS_Defns) :- - hlds_data__get_type_defn_context(TypeDefn, Context), - MLDS_Context = mlds__make_context(Context), + hlds_data.get_type_defn_context(TypeDefn, Context), + MLDS_Context = mlds_make_context(Context), % Generate the class name. ml_gen_type_name(TypeCtor, QualifiedClassName, MLDS_ClassArity), @@ -194,10 +194,9 @@ ml_gen_enum_type(TypeCtor, TypeDefn, Ctors, TagValues, % Generate the class members. ValueMember = ml_gen_enum_value_member(Context), - EnumConstMembers = list__map(ml_gen_enum_constant(Context, TagValues), + EnumConstMembers = list.map(ml_gen_enum_constant(Context, TagValues), Ctors), - Members = list__append(MaybeEqualityMembers, - [ValueMember|EnumConstMembers]), + Members = MaybeEqualityMembers ++ [ValueMember | EnumConstMembers], % Enums don't import or inherit anything. Imports = [], @@ -207,29 +206,29 @@ ml_gen_enum_type(TypeCtor, TypeDefn, Ctors, TagValues, % Put it all together. MLDS_TypeName = type(MLDS_ClassName, MLDS_ClassArity), MLDS_TypeFlags = ml_gen_type_decl_flags, - MLDS_TypeDefnBody = mlds__class(mlds__class_defn(mlds__enum, + MLDS_TypeDefnBody = mlds_class(mlds_class_defn(mlds_enum, Imports, Inherits, Implements, [], Members)), - MLDS_TypeDefn = mlds__defn(MLDS_TypeName, MLDS_Context, MLDS_TypeFlags, + MLDS_TypeDefn = mlds_defn(MLDS_TypeName, MLDS_Context, MLDS_TypeFlags, MLDS_TypeDefnBody), MLDS_Defns = [MLDS_TypeDefn | MLDS_Defns0]. -:- func ml_gen_enum_value_member(prog_context) = mlds__defn. +:- func ml_gen_enum_value_member(prog_context) = mlds_defn. ml_gen_enum_value_member(Context) = - mlds__defn(data(var(mlds__var_name("value", no))), - mlds__make_context(Context), + mlds_defn(data(var(mlds_var_name("value", no))), + mlds_make_context(Context), ml_gen_member_decl_flags, - mlds__data(mlds__native_int_type, no_initializer, no)). + mlds_data(mlds_native_int_type, no_initializer, no)). :- func ml_gen_enum_constant(prog_context, cons_tag_values, constructor) - = mlds__defn. + = mlds_defn. ml_gen_enum_constant(Context, ConsTagValues, Ctor) = MLDS_Defn :- % Figure out the value of this enumeration constant. Ctor = ctor(_ExistQTVars, _Constraints, Name, Args), - list__length(Args, Arity), - map__lookup(ConsTagValues, cons(Name, Arity), TagVal), + list.length(Args, Arity), + map.lookup(ConsTagValues, cons(Name, Arity), TagVal), ( TagVal = int_constant(Int) -> ConstValue = const(int_const(Int)) ; @@ -242,10 +241,10 @@ ml_gen_enum_constant(Context, ConsTagValues, Ctor) = MLDS_Defn :- % Generate an MLDS definition for this enumeration constant. unqualify_name(Name, UnqualifiedName), - MLDS_Defn = mlds__defn(data(var(mlds__var_name(UnqualifiedName, no))), - mlds__make_context(Context), + MLDS_Defn = mlds_defn(data(var(mlds_var_name(UnqualifiedName, no))), + mlds_make_context(Context), ml_gen_enum_constant_decl_flags, - mlds__data(mlds__native_int_type, init_obj(ConstValue), no)). + mlds_data(mlds_native_int_type, init_obj(ConstValue), no)). %-----------------------------------------------------------------------------% % @@ -337,20 +336,20 @@ ml_gen_enum_constant(Context, ConsTagValues, Ctor) = MLDS_Defn :- % :- pred ml_gen_du_parent_type(module_info::in, type_ctor::in, hlds_type_defn::in, list(constructor)::in, cons_tag_values::in, - mlds__defns::in, mlds__defns::in, mlds__defns::out) is det. + mlds_defns::in, mlds_defns::in, mlds_defns::out) is det. ml_gen_du_parent_type(ModuleInfo, TypeCtor, TypeDefn, Ctors, TagValues, MaybeEqualityMembers, MLDS_Defns0, MLDS_Defns) :- - hlds_data__get_type_defn_context(TypeDefn, Context), - MLDS_Context = mlds__make_context(Context), + hlds_data.get_type_defn_context(TypeDefn, Context), + MLDS_Context = mlds_make_context(Context), % generate the class name ml_gen_type_name(TypeCtor, QualBaseClassName, BaseClassArity), - BaseClassId = mlds__class_type(QualBaseClassName, BaseClassArity, - mlds__class), + BaseClassId = mlds_class_type(QualBaseClassName, BaseClassArity, + mlds_class), QualBaseClassName = qual(BaseClassModuleName, QualKind, BaseClassName), module_info_get_globals(ModuleInfo, Globals), - BaseClassQualifier = mlds__append_class_qualifier( + BaseClassQualifier = mlds_append_class_qualifier( BaseClassModuleName, QualKind, Globals, BaseClassName, BaseClassArity), @@ -359,7 +358,7 @@ ml_gen_du_parent_type(ModuleInfo, TypeCtor, TypeDefn, Ctors, TagValues, % then we don't need the members for the secondary tag. % \+ (some [Ctor] ( - list__member(Ctor, Ctors), + list.member(Ctor, Ctors), ml_needs_secondary_tag(TagValues, Ctor) )) -> @@ -371,7 +370,7 @@ ml_gen_du_parent_type(ModuleInfo, TypeCtor, TypeDefn, Ctors, TagValues, TagConstMembers = [], % XXX we don't yet bother with these; % mlds_to_c.m doesn't support static (one_copy) members. - % TagConstMembers = list__condense(list__map( + % TagConstMembers = list.condense(list.map( % ml_gen_tag_constant(Context, TagValues), Ctors)), TagMembers0 = [TagDataMember | TagConstMembers], @@ -381,7 +380,7 @@ ml_gen_du_parent_type(ModuleInfo, TypeCtor, TypeDefn, Ctors, TagValues, % ( (all [Ctor] ( - list__member(Ctor, Ctors) + list.member(Ctor, Ctors) => ml_needs_secondary_tag(TagValues, Ctor) )) @@ -389,7 +388,7 @@ ml_gen_du_parent_type(ModuleInfo, TypeCtor, TypeDefn, Ctors, TagValues, TagMembers = TagMembers0, TagClassId = BaseClassId ; - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ml_gen_secondary_tag_class(MLDS_Context, BaseClassQualifier, BaseClassId, TagMembers0, Target, TagTypeDefn, TagClassId), TagMembers = [TagTypeDefn] @@ -400,7 +399,7 @@ ml_gen_du_parent_type(ModuleInfo, TypeCtor, TypeDefn, Ctors, TagValues, % or static (one_copy) member objects for constructors with % reserved_object representations, or fields and a constructor method % for the single_functor case. - list__foldl2(ml_gen_du_ctor_member(ModuleInfo, BaseClassId, + list.foldl2(ml_gen_du_ctor_member(ModuleInfo, BaseClassId, BaseClassQualifier, TagClassId, TypeDefn, TagValues), Ctors, [], CtorMembers, [], BaseClassCtorMethods), @@ -410,28 +409,28 @@ ml_gen_du_parent_type(ModuleInfo, TypeCtor, TypeDefn, Ctors, TagValues, Implements = [], % Put it all together. - Members = list__condense([MaybeEqualityMembers, TagMembers, CtorMembers]), + Members = MaybeEqualityMembers ++ TagMembers ++ CtorMembers, MLDS_TypeName = type(BaseClassName, BaseClassArity), MLDS_TypeFlags = ml_gen_type_decl_flags, - MLDS_TypeDefnBody = mlds__class(mlds__class_defn(mlds__class, + MLDS_TypeDefnBody = mlds_class(mlds_class_defn(mlds_class, Imports, Inherits, Implements, BaseClassCtorMethods, Members)), - MLDS_TypeDefn = mlds__defn(MLDS_TypeName, MLDS_Context, MLDS_TypeFlags, + MLDS_TypeDefn = mlds_defn(MLDS_TypeName, MLDS_Context, MLDS_TypeFlags, MLDS_TypeDefnBody), MLDS_Defns = [MLDS_TypeDefn | MLDS_Defns0]. % Generate the declaration for the field that holds the secondary tag. % -:- func ml_gen_tag_member(string, prog_context) = mlds__defn. +:- func ml_gen_tag_member(string, prog_context) = mlds_defn. ml_gen_tag_member(Name, Context) = - mlds__defn(data(var(mlds__var_name(Name, no))), - mlds__make_context(Context), + mlds_defn(data(var(mlds_var_name(Name, no))), + mlds_make_context(Context), ml_gen_member_decl_flags, - mlds__data(mlds__native_int_type, no_initializer, no)). + mlds_data(mlds_native_int_type, no_initializer, no)). :- func ml_gen_tag_constant(prog_context, cons_tag_values, constructor) - = mlds__defns. + = mlds_defns. ml_gen_tag_constant(Context, ConsTagValues, Ctor) = MLDS_Defns :- % Check if this constructor uses a secondary tag. @@ -444,10 +443,10 @@ ml_gen_tag_constant(Context, ConsTagValues, Ctor) = MLDS_Defns :- Ctor = ctor(_ExistQTVars, _Constraints, Name, _Args), unqualify_name(Name, UnqualifiedName), ConstValue = const(int_const(SecondaryTag)), - MLDS_Defn = mlds__defn(data(var(mlds__var_name(UnqualifiedName, no))), - mlds__make_context(Context), + MLDS_Defn = mlds_defn(data(var(mlds_var_name(UnqualifiedName, no))), + mlds_make_context(Context), ml_gen_enum_constant_decl_flags, - mlds__data(mlds__native_int_type, init_obj(ConstValue), no)), + mlds_data(mlds_native_int_type, init_obj(ConstValue), no)), MLDS_Defns = [MLDS_Defn] ; MLDS_Defns = [] @@ -499,16 +498,16 @@ tagval_is_reserved_addr(shared_with_reserved_addresses(_, TagVal), RA) :- get_tagval(ConsTagValues, Ctor) = TagVal :- Ctor = ctor(_ExistQTVars, _Constraints, Name, Args), - list__length(Args, Arity), - map__lookup(ConsTagValues, cons(Name, Arity), TagVal). + list.length(Args, Arity), + map.lookup(ConsTagValues, cons(Name, Arity), TagVal). % Generate a definition for the class used for the secondary tag type. % This is needed for discriminated unions for which some but not all % constructors use secondary tags. % -:- pred ml_gen_secondary_tag_class(mlds__context::in, mlds_module_name::in, - mlds__class_id::in, mlds__defns::in, compilation_target::in, - mlds__defn::out, mlds__class_id::out) is det. +:- pred ml_gen_secondary_tag_class(mlds_context::in, mlds_module_name::in, + mlds_class_id::in, mlds_defns::in, compilation_target::in, + mlds_defn::out, mlds_class_id::out) is det. ml_gen_secondary_tag_class(MLDS_Context, BaseClassQualifier, BaseClassId, Members, Target, MLDS_TypeDefn, SecondaryTagClassId) :- @@ -518,7 +517,7 @@ ml_gen_secondary_tag_class(MLDS_Context, BaseClassQualifier, BaseClassId, UnqualClassName = "tag_type", ClassName = qual(BaseClassQualifier, type_qual, UnqualClassName), ClassArity = 0, - SecondaryTagClassId = mlds__class_type(ClassName, ClassArity, mlds__class), + SecondaryTagClassId = mlds_class_type(ClassName, ClassArity, mlds_class), % The secondary tag class inherits the base class for this type, % unless we're compiling to C -- in that case, we omit it, @@ -536,9 +535,9 @@ ml_gen_secondary_tag_class(MLDS_Context, BaseClassQualifier, BaseClassId, % Put it all together. MLDS_TypeName = type(UnqualClassName, ClassArity), MLDS_TypeFlags = ml_gen_type_decl_flags, - MLDS_TypeDefnBody = mlds__class(mlds__class_defn(mlds__class, + MLDS_TypeDefnBody = mlds_class(mlds_class_defn(mlds_class, Imports, Inherits, Implements, Ctors, Members)), - MLDS_TypeDefn = mlds__defn(MLDS_TypeName, MLDS_Context, MLDS_TypeFlags, + MLDS_TypeDefn = mlds_defn(MLDS_TypeName, MLDS_Context, MLDS_TypeFlags, MLDS_TypeDefnBody). % Generate definitions corresponding to a constructor of a discriminated @@ -549,10 +548,10 @@ ml_gen_secondary_tag_class(MLDS_Context, BaseClassQualifier, BaseClassId, % - (for the single_functor case) a bunch of fields and % a constructor method. % -:- pred ml_gen_du_ctor_member(module_info::in, mlds__class_id::in, - mlds_module_name::in, mlds__class_id::in, hlds_type_defn::in, - cons_tag_values::in, constructor::in, mlds__defns::in, - mlds__defns::out, mlds__defns::in, mlds__defns::out) is det. +:- pred ml_gen_du_ctor_member(module_info::in, mlds_class_id::in, + mlds_module_name::in, mlds_class_id::in, hlds_type_defn::in, + cons_tag_values::in, constructor::in, mlds_defns::in, + mlds_defns::out, mlds_defns::in, mlds_defns::out) is det. ml_gen_du_ctor_member(ModuleInfo, BaseClassId, BaseClassQualifier, SecondaryTagClassId, TypeDefn, ConsTagValues, Ctor, @@ -561,12 +560,12 @@ ml_gen_du_ctor_member(ModuleInfo, BaseClassId, BaseClassQualifier, % XXX We should keep a context for the constructor, % but we don't, so we just use the context from the type. - hlds_data__get_type_defn_context(TypeDefn, Context), - MLDS_Context = mlds__make_context(Context), + hlds_data.get_type_defn_context(TypeDefn, Context), + MLDS_Context = mlds_make_context(Context), % Generate the class name for this constructor. unqualify_name(CtorName, UnqualCtorName), - list__length(Args, CtorArity), + list.length(Args, CtorArity), TagVal = get_tagval(ConsTagValues, Ctor), ( tagval_is_reserved_addr(TagVal, ReservedAddr) -> @@ -611,36 +610,36 @@ ml_gen_du_ctor_member(ModuleInfo, BaseClassId, BaseClassQualifier, ; ExistQTVars = [_ | _], constraint_list_get_tvars(Constraints, ConstrainedTVars), - list__delete_elems(ExistQTVars, ConstrainedTVars, + list.delete_elems(ExistQTVars, ConstrainedTVars, UnconstrainedTVars), - list__map_foldl(ml_gen_type_info_member(ModuleInfo, Context), + list.map_foldl(ml_gen_type_info_member(ModuleInfo, Context), UnconstrainedTVars, TypeInfoMembers, ArgNum0, ArgNum1), - list__map_foldl(ml_gen_typeclass_info_member(ModuleInfo, Context), + list.map_foldl(ml_gen_typeclass_info_member(ModuleInfo, Context), Constraints, TypeClassInfoMembers, ArgNum1, ArgNum2), ExtraMembers = TypeInfoMembers ++ TypeClassInfoMembers ), % Generate the class members for the ordinary fields % of this constructor. - list__map_foldl(ml_gen_du_ctor_field(ModuleInfo, Context), + list.map_foldl(ml_gen_du_ctor_field(ModuleInfo, Context), Args, OrdinaryMembers, ArgNum2, _ArgNum3), - list__append(ExtraMembers, OrdinaryMembers, Members), + list.append(ExtraMembers, OrdinaryMembers, Members), % Generate a constructor function to initialize the fields, if needed % (not all back-ends use constructor functions). MaybeSecTagVal = get_secondary_tag(TagVal), module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( target_uses_constructors(Target) = yes -> ( ml_tag_uses_base_class(TagVal) -> CtorClassType = BaseClassId, CtorClassQualifier = BaseClassQualifier ; - CtorClassType = mlds__class_type( + CtorClassType = mlds_class_type( qual(BaseClassQualifier, type_qual, UnqualCtorName), - CtorArity, mlds__class), - CtorClassQualifier = mlds__append_class_qualifier( + CtorArity, mlds_class), + CtorClassQualifier = mlds_append_class_qualifier( BaseClassQualifier, type_qual, Globals, UnqualCtorName, CtorArity) ), @@ -654,7 +653,7 @@ ml_gen_du_ctor_member(ModuleInfo, BaseClassId, BaseClassQualifier, ( TagVal = shared_with_reserved_addresses(RAs, single_functor), some [RA] ( - list__member(RA, RAs), + list.member(RA, RAs), RA = reserved_object(_, _, _) ), Members \= [] @@ -696,9 +695,9 @@ ml_gen_du_ctor_member(ModuleInfo, BaseClassId, BaseClassQualifier, % Put it all together. MLDS_TypeName = type(UnqualCtorName, CtorArity), MLDS_TypeFlags = ml_gen_type_decl_flags, - MLDS_TypeDefnBody = mlds__class(mlds__class_defn( - mlds__class, Imports, Inherits, Implements, Ctors, Members)), - MLDS_TypeDefn = mlds__defn(MLDS_TypeName, MLDS_Context, + MLDS_TypeDefnBody = mlds_class(mlds_class_defn( + mlds_class, Imports, Inherits, Implements, Ctors, Members)), + MLDS_TypeDefn = mlds_defn(MLDS_TypeName, MLDS_Context, MLDS_TypeFlags, MLDS_TypeDefnBody), MLDS_Members = [MLDS_TypeDefn | MLDS_Members0], MLDS_CtorMethods = MLDS_CtorMethods0 @@ -741,17 +740,17 @@ target_requires_module_qualified_params(il) = no. target_requires_module_qualified_params(java) = yes. target_requires_module_qualified_params(asm) = no. -:- func gen_constructor_function(globals, mlds__class_id, - mlds_type, mlds_module_name, mlds__class_id, maybe(int), mlds__defns, - mlds__context) = mlds__defn. +:- func gen_constructor_function(globals, mlds_class_id, + mlds_type, mlds_module_name, mlds_class_id, maybe(int), mlds_defns, + mlds_context) = mlds_defn. gen_constructor_function(Globals, BaseClassId, ClassType, ClassQualifier, SecondaryTagClassId, MaybeTag, Members, Context) = CtorDefn :- - Args = list__map(make_arg, Members), + Args = list.map(make_arg, Members), ReturnValues = [], - globals__get_target(Globals, Target), - InitMembers0 = list__map(gen_init_field(Target, BaseClassId, + globals.get_target(Globals, Target), + InitMembers0 = list.map(gen_init_field(Target, BaseClassId, ClassType, ClassQualifier), Members), ( MaybeTag = yes(TagVal), @@ -766,43 +765,43 @@ gen_constructor_function(Globals, BaseClassId, ClassType, ClassQualifier, Stmt = statement(block([], InitMembers), Context), Attributes = [], - Ctor = mlds__function(no, func_params(Args, ReturnValues), + Ctor = mlds_function(no, mlds_func_params(Args, ReturnValues), defined_here(Stmt), Attributes), CtorFlags = init_decl_flags(public, per_instance, non_virtual, overridable, modifiable, concrete), % Note that the name of constructor is determined by the backend % convention. - CtorDefn = mlds__defn(export(""), Context, CtorFlags, Ctor). + CtorDefn = mlds_defn(export(""), Context, CtorFlags, Ctor). % Get the name and type from the field definition, for use as a % constructor argument name and type. % -:- func make_arg(mlds__defn) = mlds__argument is det. +:- func make_arg(mlds_defn) = mlds_argument is det. -make_arg(mlds__defn(Name, _Context, _Flags, Defn)) = Arg :- - ( Defn = data(Type, _Init, GC_TraceCode) -> - Arg = mlds__argument(Name, Type, GC_TraceCode) +make_arg(mlds_defn(Name, _Context, _Flags, Defn)) = Arg :- + ( Defn = mlds_data(Type, _Init, GC_TraceCode) -> + Arg = mlds_argument(Name, Type, GC_TraceCode) ; unexpected(this_file, "make_arg: non-data member") ). % Generate "this-> = ;". % -:- func gen_init_field(compilation_target, mlds__class_id, mlds_type, - mlds_module_name, mlds__defn) = statement is det. +:- func gen_init_field(compilation_target, mlds_class_id, mlds_type, + mlds_module_name, mlds_defn) = statement is det. gen_init_field(Target, BaseClassId, ClassType, ClassQualifier, Member) = Statement :- - Member = mlds__defn(EntityName, Context, _Flags, Defn), - ( Defn = data(Type0, _Init, _GC_TraceCode) -> + Member = mlds_defn(EntityName, Context, _Flags, Defn), + ( Defn = mlds_data(Type0, _Init, _GC_TraceCode) -> Type = Type0 ; unexpected(this_file, "gen_init_field: non-data member") ), ( EntityName = data(var(VarName0)), - VarName0 = mlds__var_name(Name0, no) + VarName0 = mlds_var_name(Name0, no) -> Name = Name0, VarName = VarName0 @@ -812,7 +811,7 @@ gen_init_field(Target, BaseClassId, ClassType, ClassQualifier, Member) = ( target_requires_module_qualified_params(Target) = yes -> - ( BaseClassId = mlds__class_type(qual(ModuleName, _, _), _, _) -> + ( BaseClassId = mlds_class_type(qual(ModuleName, _, _), _, _) -> QualVarName = qual(ModuleName, module_qual, VarName) ; unexpected(this_file, @@ -821,10 +820,10 @@ gen_init_field(Target, BaseClassId, ClassType, ClassQualifier, Member) = ; QualVarName = qual(ClassQualifier, type_qual, VarName) ), - Param = mlds__lval(mlds__var(QualVarName, Type)), - Field = mlds__field(yes(0), self(ClassType), + Param = lval(var(QualVarName, Type)), + Field = field(yes(0), self(ClassType), named_field(qual(ClassQualifier, type_qual, Name), - mlds__ptr_type(ClassType)), + mlds_ptr_type(ClassType)), % XXX we should use ClassType rather than BaseClassId here. % But doing so breaks the IL back-end, because then the hack in % fixup_class_qualifiers doesn't work. @@ -833,37 +832,37 @@ gen_init_field(Target, BaseClassId, ClassType, ClassQualifier, Member) = % Generate "this->data_tag = ;". % -:- func gen_init_tag(mlds_type, mlds__class_id, int, mlds__context, globals) +:- func gen_init_tag(mlds_type, mlds_class_id, int, mlds_context, globals) = statement. gen_init_tag(ClassType, SecondaryTagClassId, TagVal, Context, Globals) = Statement :- - ( SecondaryTagClassId = mlds__class_type(TagClass, TagArity, _) -> + ( SecondaryTagClassId = mlds_class_type(TagClass, TagArity, _) -> TagClass = qual(BaseClassQualifier, QualKind, TagClassName), - TagClassQualifier = mlds__append_class_qualifier(BaseClassQualifier, + TagClassQualifier = mlds_append_class_qualifier(BaseClassQualifier, QualKind, Globals, TagClassName, TagArity) ; unexpected(this_file, "gen_init_tag: class_id should be a class") ), Name = "data_tag", - Type = mlds__native_int_type, + Type = mlds_native_int_type, Val = const(int_const(TagVal)), - Field = mlds__field(yes(0), self(ClassType), + Field = field(yes(0), self(ClassType), named_field(qual(TagClassQualifier, type_qual, Name), - mlds__ptr_type(SecondaryTagClassId)), + mlds_ptr_type(SecondaryTagClassId)), Type, ClassType), Statement = statement(atomic(assign(Field, Val)), Context). :- pred ml_gen_typeclass_info_member(module_info::in, prog_context::in, - prog_constraint::in, mlds__defn::out, int::in, int::out) is det. + prog_constraint::in, mlds_defn::out, int::in, int::out) is det. ml_gen_typeclass_info_member(ModuleInfo, Context, Constraint, MLDS_Defn, ArgNum0, ArgNum) :- - polymorphism__build_typeclass_info_type(Constraint, Type), + polymorphism.build_typeclass_info_type(Constraint, Type), ml_gen_field(ModuleInfo, Context, no, Type, MLDS_Defn, ArgNum0, ArgNum). :- pred ml_gen_type_info_member(module_info::in, prog_context::in, tvar::in, - mlds__defn::out, int::in, int::out) is det. + mlds_defn::out, int::in, int::out) is det. ml_gen_type_info_member(ModuleInfo, Context, TypeVar, MLDS_Defn, ArgNum0, ArgNum) :- @@ -871,11 +870,11 @@ ml_gen_type_info_member(ModuleInfo, Context, TypeVar, MLDS_Defn, % since the type will only be checked to see that it is a variable, % and won't be used in any other way. Kind = star, - polymorphism__build_type_info_type(variable(TypeVar, Kind), Type), + polymorphism.build_type_info_type(variable(TypeVar, Kind), Type), ml_gen_field(ModuleInfo, Context, no, Type, MLDS_Defn, ArgNum0, ArgNum). :- pred ml_gen_du_ctor_field(module_info::in, prog_context::in, - constructor_arg::in, mlds__defn::out, int::in, int::out) is det. + constructor_arg::in, mlds_defn::out, int::in, int::out) is det. ml_gen_du_ctor_field(ModuleInfo, Context, MaybeFieldName - Type, MLDS_Defn, ArgNum0, ArgNum) :- @@ -883,31 +882,31 @@ ml_gen_du_ctor_field(ModuleInfo, Context, MaybeFieldName - Type, MLDS_Defn, ArgNum0, ArgNum). :- pred ml_gen_field(module_info::in, prog_context::in, - maybe(ctor_field_name)::in, mer_type::in, mlds__defn::out, + maybe(ctor_field_name)::in, mer_type::in, mlds_defn::out, int::in, int::out) is det. ml_gen_field(ModuleInfo, Context, MaybeFieldName, Type, MLDS_Defn, ArgNum0, ArgNum) :- ( ml_must_box_field_type(Type, ModuleInfo) -> - MLDS_Type = mlds__generic_type + MLDS_Type = mlds_generic_type ; MLDS_Type = mercury_type_to_mlds_type(ModuleInfo, Type) ), FieldName = ml_gen_field_name(MaybeFieldName, ArgNum0), - MLDS_Defn = ml_gen_mlds_field_decl(var(mlds__var_name(FieldName, no)), - MLDS_Type, mlds__make_context(Context)), + MLDS_Defn = ml_gen_mlds_field_decl(var(mlds_var_name(FieldName, no)), + MLDS_Type, mlds_make_context(Context)), ArgNum = ArgNum0 + 1. -:- func ml_gen_mlds_field_decl(mlds__data_name, mlds_type, mlds__context) - = mlds__defn. +:- func ml_gen_mlds_field_decl(mlds_data_name, mlds_type, mlds_context) + = mlds_defn. ml_gen_mlds_field_decl(DataName, MLDS_Type, Context) = MLDS_Defn :- Name = data(DataName), % We only need GC tracing code for top-level variables, not for fields GC_TraceCode = no, - Defn = data(MLDS_Type, no_initializer, GC_TraceCode), + Defn = mlds_data(MLDS_Type, no_initializer, GC_TraceCode), DeclFlags = ml_gen_public_field_decl_flags, - MLDS_Defn = mlds__defn(Name, Context, DeclFlags, Defn). + MLDS_Defn = mlds_defn(Name, Context, DeclFlags, Defn). %-----------------------------------------------------------------------------% % @@ -930,7 +929,7 @@ ml_gen_type_name(Name - Arity, QualifiedTypeName, Arity) :- % (as do e.g. C++, Java). % :- pred ml_gen_equality_members(maybe(unify_compare)::in, - list(mlds__defn)::out) is det. + list(mlds_defn)::out) is det. ml_gen_equality_members(_, []). % XXX generation of `==' members % is not yet implemented. diff --git a/compiler/ml_unify_gen.m b/compiler/ml_unify_gen.m index 95905885f..520cc26d5 100644 --- a/compiler/ml_unify_gen.m +++ b/compiler/ml_unify_gen.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_unify_gen. +:- module ml_backend.ml_unify_gen. :- interface. :- import_module hlds.code_model. @@ -34,7 +34,7 @@ % Generate MLDS code for a unification. % :- pred ml_gen_unification(unification::in, code_model::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. % Convert a cons_id for a given type to a cons_tag. @@ -52,7 +52,7 @@ % by ConsId. % :- pred ml_gen_tag_test(prog_var::in, cons_id::in, - mlds__defns::out, statements::out, mlds_rval::out, + mlds_defns::out, statements::out, mlds_rval::out, ml_gen_info::in, ml_gen_info::out) is det. % ml_gen_secondary_tag_rval(PrimaryTag, VarType, ModuleInfo, VarRval): @@ -81,7 +81,7 @@ :- pred ml_gen_new_object(maybe(cons_id)::in, mlds_tag::in, bool::in, maybe(ctor_name)::in, prog_var::in, list(mlds_rval)::in, list(mlds_type)::in, prog_vars::in, list(uni_mode)::in, list(int)::in, - how_to_construct::in, prog_context::in, mlds__defns::out, + how_to_construct::in, prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. %-----------------------------------------------------------------------------% @@ -212,7 +212,7 @@ ml_gen_unification(Unification, CodeModel, Context, Decls, Statements, CanCGC = can_cgc, ml_gen_var(!.Info, Var, VarLval), Stmt = atomic(delete_object(VarLval)), - CGC_Statements = [statement(Stmt, mlds__make_context(Context)) ] + CGC_Statements = [statement(Stmt, mlds_make_context(Context)) ] ; CanCGC = cannot_cgc, CGC_Statements = [] @@ -238,7 +238,7 @@ ml_gen_unification(complicated_unify(_, _, _), _, _, [], [], !Info) :- % :- pred ml_gen_construct(prog_var::in, cons_id::in, prog_vars::in, list(uni_mode)::in, list(int)::in, how_to_construct::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_construct(Var, ConsId, Args, ArgModes, TakeAddr, HowToConstruct, @@ -251,7 +251,7 @@ ml_gen_construct(Var, ConsId, Args, ArgModes, TakeAddr, HowToConstruct, :- pred ml_gen_construct_2(cons_tag::in, mer_type::in, prog_var::in, cons_id::in, prog_vars::in, list(uni_mode)::in, list(int)::in, - how_to_construct::in, prog_context::in, mlds__defns::out, + how_to_construct::in, prog_context::in, mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_construct_2(Tag, Type, Var, ConsId, Args, ArgModes, TakeAddr, @@ -382,7 +382,7 @@ ml_gen_static_const_arg_2(Tag, VarType, Var, StaticCons, Rval, !Info) :- ml_gen_type(!.Info, VarType, MLDS_VarType), ml_gen_info_get_globals(!.Info, Globals), - globals__lookup_bool_option(Globals, highlevel_data, HighLevelData), + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), UsesBaseClass = (ml_tag_uses_base_class(Tag) -> yes ; no), ConstType = get_type_for_cons_id(MLDS_VarType, UsesBaseClass, yes(ConsId), HighLevelData, Globals), @@ -491,7 +491,7 @@ ml_gen_reserved_address(ModuleInfo, reserved_object(TypeCtor, QualCtorName, MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName), TypeCtor = TypeName - TypeArity, unqualify_name(TypeName, UnqualTypeName), - MLDS_TypeName = mlds__append_class_qualifier(MLDS_ModuleName, + MLDS_TypeName = mlds_append_class_qualifier(MLDS_ModuleName, module_qual, Globals, UnqualTypeName, TypeArity), Name = ml_format_reserved_object_name(CtorName, CtorArity), Rval0 = const(data_addr_const( @@ -506,13 +506,13 @@ ml_gen_reserved_address(ModuleInfo, reserved_object(TypeCtor, QualCtorName, % .NET back-end (where the JIT probably doesn't optimize downcasts). %% So we only do it if the back-end requires it. % - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( target_supports_inheritence(Target) = yes -> Rval = Rval0 ; - MLDS_Type = mlds__ptr_type(mlds__class_type( + MLDS_Type = mlds_ptr_type(mlds_class_type( qual(MLDS_ModuleName, module_qual, UnqualTypeName), - TypeArity, mlds__class)), + TypeArity, mlds_class)), Rval = unop(cast(MLDS_Type), Rval0) ) ; @@ -541,7 +541,7 @@ ml_cons_id_to_tag(Info, ConsId, Type, Tag) :- % :- pred ml_gen_compound(cons_tag::in, cons_id::in, prog_var::in, prog_vars::in, list(uni_mode)::in, list(int)::in, how_to_construct::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_compound(Tag, ConsId, Var, ArgVars, ArgModes, TakeAddr, HowToConstruct, @@ -567,18 +567,18 @@ ml_gen_compound(Tag, ConsId, Var, ArgVars, ArgModes, TakeAddr, HowToConstruct, MaybeSecondaryTag = yes(SecondaryTag), HasSecTag = yes, SecondaryTagRval0 = const(int_const(SecondaryTag)), - SecondaryTagType0 = mlds__native_int_type, + SecondaryTagType0 = mlds_native_int_type, % With the low-level data representation, all fields -- even the % secondary tag -- are boxed, and so we need box it here. ml_gen_info_get_module_info(!.Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, highlevel_data, HighLevelData), + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), ( HighLevelData = no, SecondaryTagRval = unop(box(SecondaryTagType0), SecondaryTagRval0), - SecondaryTagType = mlds__generic_type + SecondaryTagType = mlds_generic_type ; HighLevelData = yes, SecondaryTagRval = SecondaryTagRval0, @@ -631,11 +631,11 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, TakeAddrInfos, !Info), % Insert the extra rvals at the start. - list__append(ExtraRvals, ArgRvals0, ArgRvals), - list__append(ExtraTypes, MLDS_ArgTypes0, MLDS_ArgTypes), + ArgRvals = ExtraRvals ++ ArgRvals0, + MLDS_ArgTypes = ExtraTypes ++ MLDS_ArgTypes0, % Compute the number of words to allocate. - list__length(ArgRvals, NumArgs), + list.length(ArgRvals, NumArgs), SizeInWordsRval = const(int_const(NumArgs)), % Generate a `new_object' statement to dynamically allocate the memory @@ -644,7 +644,7 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, MakeNewObject = new_object(VarLval, MaybeTag, HasSecTag, MLDS_Type, yes(SizeInWordsRval), MaybeCtorName, ArgRvals, MLDS_ArgTypes), Stmt = atomic(MakeNewObject), - Statement = statement(Stmt, mlds__make_context(Context)), + Statement = statement(Stmt, mlds_make_context(Context)), ml_gen_field_take_address_assigns(TakeAddrInfos, VarLval, MLDS_Type, MaybeTag, Context, !.Info, FieldAssigns), @@ -659,22 +659,21 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, ml_gen_info_get_module_info(!.Info, ModuleInfo), get_maybe_cons_id_arg_types(MaybeConsId, ArgTypes, Type, ModuleInfo, ConsArgTypes), - list__map(ml_gen_field_type(!.Info), ConsArgTypes, FieldTypes), + list.map(ml_gen_field_type(!.Info), ConsArgTypes, FieldTypes), % Generate rvals for the arguments. - list__map(ml_gen_type(!.Info), ArgTypes, MLDS_ArgTypes0), + list.map(ml_gen_type(!.Info), ArgTypes, MLDS_ArgTypes0), ml_gen_static_const_arg_list(ArgVars, StaticArgs, ArgRvals0, !Info), % Box or unbox the arguments, if needed, and insert the extra rvals % at the start. ml_gen_info_get_globals(!.Info, Globals), - globals__lookup_bool_option(Globals, highlevel_data, HighLevelData), + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), ( HighLevelData = no, % Box *all* the arguments, including the ExtraRvals. - list__append(ExtraRvals, ArgRvals0, ArgRvals1), - list__append(ExtraTypes, MLDS_ArgTypes0, - MLDS_ArgTypes), + ArgRvals1 = ExtraRvals ++ ArgRvals0, + MLDS_ArgTypes = ExtraTypes ++ MLDS_ArgTypes0, ml_gen_box_const_rval_list(MLDS_ArgTypes, ArgRvals1, Context, BoxConstDefns, ArgRvals, !Info) ; @@ -684,7 +683,7 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, % For --high-level-data, the ExtraRvals should already have % the right type, so we don't need to worry about boxing % or unboxing them. - list__append(ExtraRvals, ArgRvals1, ArgRvals) + ArgRvals = ExtraRvals ++ ArgRvals1 ), % Generate a local static constant for this term. @@ -696,8 +695,8 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, % initializer should be wrapped in `init_struct([init_obj(X)])' % rather than just `init_obj(X)' -- the fact that we don't leads to % some warnings from GNU C about missing braces in initializers. - ArgInits = list__map(func(X) = init_obj(X), ArgRvals), - ( ConstType = mlds__array_type(_) -> + ArgInits = list.map(func(X) = init_obj(X), ArgRvals), + ( ConstType = mlds_array_type(_) -> Initializer = init_array(ArgInits) ; Initializer = init_struct(ConstType, ArgInits) @@ -716,7 +715,7 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, ), Rval = unop(cast(MLDS_Type), TaggedRval), AssignStatement = ml_gen_assign(VarLval, Rval, Context), - Decls = list__append(BoxConstDefns, [ConstDefn]), + Decls = BoxConstDefns ++ [ConstDefn], Statements = [AssignStatement] ; HowToConstruct = reuse_cell(CellToReuse), @@ -728,7 +727,7 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, MaybeConsId = no, unexpected(this_file, "ml_gen_new_object: unknown cons id") ), - list__map( + list.map( (pred(ReuseConsId::in, ReusePrimTag::out) is det :- ml_variable_type(!.Info, ReuseVar, ReuseType), ml_cons_id_to_tag(!.Info, ReuseConsId, @@ -736,7 +735,7 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, ml_tag_offset_and_argnum(ReuseConsIdTag, ReusePrimTag, _ReuseOffSet, _ReuseArgNum) ), ReuseConsIds, ReusePrimaryTags0), - list__remove_dups(ReusePrimaryTags0, ReusePrimaryTags), + list.remove_dups(ReusePrimaryTags0, ReusePrimaryTags), ml_cons_id_to_tag(!.Info, ConsId, Type, ConsIdTag), ml_field_names_and_types(!.Info, Type, ConsId, ArgTypes, Fields), @@ -745,7 +744,7 @@ ml_gen_new_object(MaybeConsId, Tag, HasSecTag, MaybeCtorName, Var, ml_gen_var(!.Info, Var, Var1Lval), ml_gen_var(!.Info, ReuseVar, Var2Lval), - list__filter((pred(ReuseTag::in) is semidet :- + list.filter((pred(ReuseTag::in) is semidet :- ReuseTag \= PrimaryTag ), ReusePrimaryTags, DifferentTags), ( @@ -795,7 +794,7 @@ ml_gen_field_take_address_assigns([TakeAddrInfo | TakeAddrInfos], SourceRval = mem_addr(field(MaybeTag, lval(CellLval), offset(const(int_const(Offset))), FieldType, CellType)), ml_gen_var(Info, AddrVar, AddrLval), - CastSourceRval = unop(cast(ptr_type(ConsArgType)), SourceRval), + CastSourceRval = unop(cast(mlds_ptr_type(ConsArgType)), SourceRval), Assign = ml_gen_assign(AddrLval, CastSourceRval, Context), ml_gen_field_take_address_assigns(TakeAddrInfos, CellLval, CellType, MaybeTag, Context, Info, Assigns). @@ -810,7 +809,7 @@ get_type_for_cons_id(MLDS_Type, UsesBaseClass, MaybeConsId, HighLevelData, Globals) = ConstType :- ( HighLevelData = no, - ConstType = mlds__array_type(mlds__generic_type) + ConstType = mlds_array_type(mlds_generic_type) ; HighLevelData = yes, ( @@ -824,7 +823,7 @@ get_type_for_cons_id(MLDS_Type, UsesBaseClass, MaybeConsId, HighLevelData, ; TypeCategory = type_cat_base_typeclass_info ) -> - ConstType = mlds__array_type(mlds__generic_type) + ConstType = mlds_array_type(mlds_generic_type) ; % Check if we're constructing a value for a discriminated union % where the specified cons_id which is represented as a derived @@ -834,7 +833,7 @@ get_type_for_cons_id(MLDS_Type, UsesBaseClass, MaybeConsId, HighLevelData, MaybeConsId = yes(ConsId), ConsId = cons(CtorSymName, CtorArity), ( - MLDS_Type = mlds__class_type(QualTypeName, TypeArity, _) + MLDS_Type = mlds_class_type(QualTypeName, TypeArity, _) ; MLDS_Type = mercury_type(MercuryType, type_cat_user_ctor, _), type_to_ctor_and_args(MercuryType, TypeCtor, _ArgsTypes), @@ -846,28 +845,28 @@ get_type_for_cons_id(MLDS_Type, UsesBaseClass, MaybeConsId, HighLevelData, % nested inside the base class). unqualify_name(CtorSymName, CtorName), QualTypeName = qual(MLDS_Module, _QualKind, TypeName), - ClassQualifier = mlds__append_class_qualifier(MLDS_Module, + ClassQualifier = mlds_append_class_qualifier(MLDS_Module, module_qual, Globals, TypeName, TypeArity), - ConstType = mlds__class_type( + ConstType = mlds_class_type( qual(ClassQualifier, type_qual, CtorName), - CtorArity, mlds__class) + CtorArity, mlds_class) ; % Convert mercury_types for user-defined types to the corresponding - % `mlds__class_type'. This is needed because these types get - % mapped to `mlds__ptr_type(mlds__class_type(...))', but when + % `mlds_class_type'. This is needed because these types get + % mapped to `mlds_ptr_type(mlds_class_type(...))', but when % declarating static constants we want just the class type, % not the pointer type. MLDS_Type = mercury_type(MercuryType, type_cat_user_ctor, _), type_to_ctor_and_args(MercuryType, TypeCtor, _ArgsTypes) -> ml_gen_type_name(TypeCtor, ClassName, ClassArity), - ConstType = mlds__class_type(ClassName, ClassArity, mlds__class) + ConstType = mlds_class_type(ClassName, ClassArity, mlds_class) ; % For tuples, a similar issue arises; we want tuple constants % to have array type, not the pointer type MR_Tuple. MLDS_Type = mercury_type(_, type_cat_tuple, _) -> - ConstType = mlds__array_type(mlds__generic_type) + ConstType = mlds_array_type(mlds_generic_type) ; % Likewise for closures, we need to use an array type rather than % the pointer type MR_ClosurePtr. Note that we use a low-level @@ -875,7 +874,7 @@ get_type_for_cons_id(MLDS_Type, UsesBaseClass, MaybeConsId, HighLevelData, % is enabled. MLDS_Type = mercury_type(_, type_cat_higher_order, _) -> - ConstType = mlds__array_type(mlds__generic_type) + ConstType = mlds_array_type(mlds_generic_type) ; ConstType = MLDS_Type ) @@ -887,7 +886,7 @@ get_type_for_cons_id(MLDS_Type, UsesBaseClass, MaybeConsId, HighLevelData, ml_gen_field_type(Info, Type, FieldType) :- ml_gen_info_get_module_info(Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, highlevel_data, HighLevelData), + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), ml_type_as_field(Type, ModuleInfo, HighLevelData, FieldType). :- pred ml_type_as_field(mer_type::in, module_info::in, bool::in, @@ -913,8 +912,8 @@ ml_type_as_field(FieldType, ModuleInfo, HighLevelData, BoxedFieldType) :- ml_must_box_field_type(FieldType, ModuleInfo) ) -> - varset__init(TypeVarSet0), - varset__new_var(TypeVarSet0, TypeVar, _TypeVarSet), + varset.init(TypeVarSet0), + varset.new_var(TypeVarSet0, TypeVar, _TypeVarSet), % The kind is `star' since there are values with this type. BoxedFieldType = variable(TypeVar, star) ; @@ -933,7 +932,7 @@ get_maybe_cons_id_arg_types(MaybeConsId, ArgTypes, Type, ModuleInfo, ; MaybeConsId = no, % It's a closure. In this case, the arguments are all boxed. - ConsArgTypes = ml_make_boxed_types(list__length(ArgTypes)) + ConsArgTypes = ml_make_boxed_types(list.length(ArgTypes)) ). :- func constructor_arg_types(cons_id, list(mer_type), mer_type, module_info) @@ -955,10 +954,10 @@ constructor_arg_types(CtorId, ArgTypes, Type, ModuleInfo) = ConsArgTypes :- % Given the type_ctor, lookup up the constructor. ( - type_util__get_cons_defn(ModuleInfo, TypeCtor, CtorId, ConsDefn) + type_util.get_cons_defn(ModuleInfo, TypeCtor, CtorId, ConsDefn) -> ConsDefn = hlds_cons_defn(_, _, ConsArgDefns, _, _), - assoc_list__values(ConsArgDefns, ConsArgTypes0), + assoc_list.values(ConsArgDefns, ConsArgTypes0), % There may have been additional types inserted to hold the % type_infos and type_class_infos for existentially quantified @@ -977,9 +976,9 @@ constructor_arg_types(CtorId, ArgTypes, Type, ModuleInfo) = ConsArgTypes :- % here, since all we really care about at this point is whether % something is a type variable or not, not which type variable it % is. - ConsArgTypes = ml_make_boxed_types(list__length(ArgTypes)) + ConsArgTypes = ml_make_boxed_types(list.length(ArgTypes)) ; - % Type_util__get_cons_defn shouldn't have failed. + % Type_util.get_cons_defn shouldn't have failed. unexpected(this_file, "cons_id_to_arg_types: get_cons_defn failed") ) ; @@ -996,7 +995,7 @@ ml_gen_mktag(Tag) = unop(std_unop(mktag), const(int_const(Tag))). :- pred ml_gen_box_or_unbox_const_rval_list(list(mer_type)::in, list(mer_type)::in, list(mlds_rval)::in, prog_context::in, - mlds__defns::out, list(mlds_rval)::out, + mlds_defns::out, list(mlds_rval)::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_box_or_unbox_const_rval_list(ArgTypes, FieldTypes, ArgRvals, @@ -1038,7 +1037,7 @@ ml_gen_box_or_unbox_const_rval_list(ArgTypes, FieldTypes, ArgRvals, ). :- pred ml_gen_box_const_rval_list(list(mlds_type)::in, list(mlds_rval)::in, - prog_context::in, mlds__defns::out, list(mlds_rval)::out, + prog_context::in, mlds_defns::out, list(mlds_rval)::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_box_const_rval_list([], [], _, [], [], !Info). @@ -1047,20 +1046,20 @@ ml_gen_box_const_rval_list([Type | Types], [Rval | Rvals], Context, ml_gen_box_const_rval(Type, Rval, Context, ConstDefns1, BoxedRval, !Info), ml_gen_box_const_rval_list(Types, Rvals, Context, ConstDefns2, BoxedRvals, !Info), - ConstDefns = list__append(ConstDefns1, ConstDefns2). + ConstDefns = ConstDefns1 ++ ConstDefns2. ml_gen_box_const_rval_list([], [_|_], _, _, _, !Info) :- unexpected(this_file, "ml_gen_box_const_rval_list: length mismatch"). ml_gen_box_const_rval_list([_|_], [], _, _, _, !Info) :- unexpected(this_file, "ml_gen_box_const_rval_list: length mismatch"). :- pred ml_gen_box_const_rval(mlds_type::in, mlds_rval::in, prog_context::in, - mlds__defns::out, mlds_rval::out, + mlds_defns::out, mlds_rval::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_box_const_rval(Type, Rval, Context, ConstDefns, BoxedRval, !Info) :- ( ( Type = mercury_type(variable(_, _), _, _) - ; Type = mlds__generic_type + ; Type = mlds_generic_type ) -> BoxedRval = Rval, @@ -1076,7 +1075,7 @@ ml_gen_box_const_rval(Type, Rval, Context, ConstDefns, BoxedRval, !Info) :- % optimization for those back-ends.] % ( Type = mercury_type(builtin(float), _, _) - ; Type = mlds__native_float_type + ; Type = mlds_native_float_type ) -> % Generate a local static constant for this float. @@ -1085,7 +1084,7 @@ ml_gen_box_const_rval(Type, Rval, Context, ConstDefns, BoxedRval, !Info) :- ml_gen_info_get_proc_id(!.Info, ProcId), pred_id_to_int(PredId, PredIdNum), proc_id_to_int(ProcId, ProcIdNum), - ConstName = mlds__var_name(string__format("float_%d_%d_%d", + ConstName = mlds_var_name(string.format("float_%d_%d_%d", [i(PredIdNum), i(ProcIdNum), i(SequenceNum)]), no), Initializer = init_obj(Rval), ConstDefn = ml_gen_static_const_defn(ConstName, Type, @@ -1093,10 +1092,10 @@ ml_gen_box_const_rval(Type, Rval, Context, ConstDefns, BoxedRval, !Info) :- ConstDefns = [ConstDefn], % Return as the boxed rval the address of that constant, - % cast to mlds__generic_type. + % cast to mlds_generic_type. ml_gen_var_lval(!.Info, ConstName, Type, ConstLval), ConstAddrRval = mem_addr(ConstLval), - BoxedRval = unop(cast(mlds__generic_type), ConstAddrRval) + BoxedRval = unop(cast(mlds_generic_type), ConstAddrRval) ; BoxedRval = unop(box(Type), Rval), ConstDefns = [] @@ -1117,7 +1116,7 @@ ml_gen_static_const_arg_list([], [_|_], _, !Info) :- % Generate the name of the local static constant for a given variable. % -:- pred ml_gen_static_const_name(prog_var::in, mlds__var_name::out, +:- pred ml_gen_static_const_name(prog_var::in, mlds_var_name::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_static_const_name(Var, ConstName, !Info) :- @@ -1129,7 +1128,7 @@ ml_gen_static_const_name(Var, ConstName, !Info) :- ml_gen_info_set_const_var_name(Var, ConstName, !Info). :- pred ml_lookup_static_const_name(ml_gen_info::in, prog_var::in, - mlds__var_name::out) is det. + mlds_var_name::out) is det. ml_lookup_static_const_name(Info, Var, ConstName) :- ml_gen_info_lookup_const_var_name(Info, Var, ConstName). @@ -1155,7 +1154,7 @@ ml_cons_name(HLDS_ConsId, QualifiedConsId) :- ConsId = ctor_id(ConsName, Arity), ModuleName = mercury_module_name_to_mlds(SymModuleName) ; - ConsName = hlds_out__cons_id_to_string(HLDS_ConsId), + ConsName = hlds_out.cons_id_to_string(HLDS_ConsId), ConsId = ctor_id(ConsName, 0), ModuleName = mercury_module_name_to_mlds(unqualified("")) ), @@ -1211,7 +1210,7 @@ ml_gen_cons_args_2([Var | Vars], [Lval | Lvals], [ArgType | ArgTypes], % Figure out the type of the field. Note that for the MLDS->C and % MLDS->asm back-ends, we need to box floating point fields. module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, highlevel_data, HighLevelData), + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), ml_type_as_field(ConsArgType, ModuleInfo, HighLevelData, BoxedArgType), MLDS_Type = mercury_type_to_mlds_type(ModuleInfo, BoxedArgType), @@ -1261,7 +1260,7 @@ ml_gen_cons_args_2([Var | Vars], [Lval | Lvals], [ArgType | ArgTypes], % :- pred ml_gen_det_deconstruct(prog_var::in, cons_id::in, prog_vars::in, list(uni_mode)::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_det_deconstruct(Var, ConsId, Args, Modes, Context, Decls, Statements, @@ -1445,26 +1444,26 @@ ml_field_names_and_types(Info, Type, ConsId, ArgTypes, Fields) :- MakeUnnamedField = (func(FieldType) = no - FieldType), ( type_is_tuple(Type, _), - list__length(ArgTypes, TupleArity) + list.length(ArgTypes, TupleArity) -> % The argument types for tuples are unbound type variables. FieldTypes = ml_make_boxed_types(TupleArity), - Fields = list__map(MakeUnnamedField, FieldTypes) + Fields = list.map(MakeUnnamedField, FieldTypes) ; ml_gen_info_get_module_info(Info, ModuleInfo), - type_util__get_type_and_cons_defn(ModuleInfo, Type, ConsId, + type_util.get_type_and_cons_defn(ModuleInfo, Type, ConsId, _TypeDefn, ConsDefn), ConsDefn = hlds_cons_defn(_, _, Fields0, _, _), % Add the fields for any type_infos and/or typeclass_infos inserted % for existentially quantified data types. For these, we just copy % the types from the ArgTypes. - NumArgs = list__length(ArgTypes), - NumFieldTypes0 = list__length(Fields0), + NumArgs = list.length(ArgTypes), + NumFieldTypes0 = list.length(Fields0), NumExtraTypes = NumArgs - NumFieldTypes0, - ExtraFieldTypes = list__take_upto(NumExtraTypes, ArgTypes), - ExtraFields = list__map(MakeUnnamedField, ExtraFieldTypes), - Fields = list__append(ExtraFields, Fields0) + ExtraFieldTypes = list.take_upto(NumExtraTypes, ArgTypes), + ExtraFields = list.map(MakeUnnamedField, ExtraFieldTypes), + Fields = ExtraFields ++ Fields0 ). :- pred ml_gen_unify_args(cons_id::in, prog_vars::in, list(uni_mode)::in, @@ -1512,7 +1511,7 @@ ml_gen_unify_arg(ConsId, Arg, Mode, ArgType, Field, VarType, VarLval, Field = MaybeFieldName - FieldType, ml_gen_info_get_module_info(!.Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, highlevel_data, HighLevelData), + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), ( % With the low-level data representation, we access all fields % using offsets. @@ -1522,7 +1521,7 @@ ml_gen_unify_arg(ConsId, Arg, Mode, ArgType, Field, VarType, VarLval, % With the high-level data representation, we always used named fields, % except for tuple types. HighLevelData = yes, - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( ( type_is_tuple(VarType, _) ; type_needs_lowlevel_rep(Target, VarType) @@ -1633,7 +1632,7 @@ ml_gen_sub_unify(Mode, ArgLval, ArgType, FieldLval, FieldType, Context, % :- pred ml_gen_semi_deconstruct(prog_var::in, cons_id::in, prog_vars::in, list(uni_mode)::in, prog_context::in, - mlds__defns::out, statements::out, + mlds_defns::out, statements::out, ml_gen_info::in, ml_gen_info::out) is det. ml_gen_semi_deconstruct(Var, ConsId, Args, ArgModes, Context, @@ -1650,11 +1649,11 @@ ml_gen_semi_deconstruct(Var, ConsId, Args, ArgModes, Context, GetArgsStatements = [] -> Decls = TagTestDecls, - Statements = list__append(TagTestStatements, [SetTagTestResult]) + Statements = TagTestStatements ++ [SetTagTestResult] ; GetArgs = ml_gen_block(GetArgsDecls, GetArgsStatements, Context), IfStmt = if_then_else(SucceededExpression, GetArgs, no), - IfStatement = statement(IfStmt, mlds__make_context(Context)), + IfStatement = statement(IfStmt, mlds_make_context(Context)), Decls = TagTestDecls, Statements = TagTestStatements ++ [SetTagTestResult, IfStatement] ). @@ -1723,7 +1722,7 @@ ml_gen_tag_test_rval(shared_remote_tag(PrimaryTagVal, SecondaryTagVal), SecondaryTagTest = binop(eq, SecondaryTagField, const(int_const(SecondaryTagVal))), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_int_option(Globals, num_tag_bits, NumTagBits), + globals.lookup_int_option(Globals, num_tag_bits, NumTagBits), ( NumTagBits = 0 -> % No need to test the primary tag. TagTest = SecondaryTagTest @@ -1755,7 +1754,7 @@ ml_gen_tag_test_rval(shared_with_reserved_addresses(ReservedAddrs, ThisTag), TestRval = ml_gen_and(ml_gen_not(EqualRA), TestRval0) ), MatchesThisTag = ml_gen_tag_test_rval(ThisTag, VarType, ModuleInfo, Rval), - FinalTestRval = list__foldr(CheckReservedAddrs, ReservedAddrs, + FinalTestRval = list.foldr(CheckReservedAddrs, ReservedAddrs, MatchesThisTag). % ml_gen_secondary_tag_rval(PrimaryTag, VarType, ModuleInfo, VarRval): @@ -1767,8 +1766,8 @@ ml_gen_secondary_tag_rval(PrimaryTagVal, VarType, ModuleInfo, Rval) = SecondaryTagField :- MLDS_VarType = mercury_type_to_mlds_type(ModuleInfo, VarType), module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), - globals__lookup_bool_option(Globals, highlevel_data, HighLevelData), + globals.get_target(Globals, Target), + globals.lookup_bool_option(Globals, highlevel_data, HighLevelData), ( ( HighLevelData = no ; type_needs_lowlevel_rep(Target, VarType) @@ -1778,20 +1777,20 @@ ml_gen_secondary_tag_rval(PrimaryTagVal, VarType, ModuleInfo, Rval) = % the secondary tag -- are boxed, and so we need to unbox (i.e. cast) % it back to the right type here. SecondaryTagField = - unop(unbox(mlds__native_int_type), + unop(unbox(mlds_native_int_type), lval(field(yes(PrimaryTagVal), Rval, offset(const(int_const(0))), - mlds__generic_type, MLDS_VarType))) + mlds_generic_type, MLDS_VarType))) ; FieldId = ml_gen_hl_tag_field_id(VarType, ModuleInfo), SecondaryTagField = lval(field(yes(PrimaryTagVal), Rval, - FieldId, mlds__native_int_type, MLDS_VarType)) + FieldId, mlds_native_int_type, MLDS_VarType)) ). % Return the field_id for the "data_tag" field of the specified % Mercury type, which holds the secondary tag. % -:- func ml_gen_hl_tag_field_id(mer_type, module_info) = mlds__field_id. +:- func ml_gen_hl_tag_field_id(mer_type, module_info) = mlds_field_id. ml_gen_hl_tag_field_id(Type, ModuleInfo) = FieldId :- FieldName = "data_tag", @@ -1810,21 +1809,21 @@ ml_gen_hl_tag_field_id(Type, ModuleInfo) = FieldId :- % rather than in the base class itself. module_info_get_globals(ModuleInfo, Globals), module_info_get_type_table(ModuleInfo, TypeTable), - TypeDefn = map__lookup(TypeTable, TypeCtor), - hlds_data__get_type_defn_body(TypeDefn, TypeDefnBody), + TypeDefn = map.lookup(TypeTable, TypeCtor), + hlds_data.get_type_defn_body(TypeDefn, TypeDefnBody), ( TypeDefnBody = du_type(Ctors, TagValues, _, _, _ReservedTag, _) -> % XXX we probably shouldn't ignore ReservedTag here ( some [Ctor] ( - list__member(Ctor, Ctors), + list.member(Ctor, Ctors), ml_uses_secondary_tag(TagValues, Ctor, _) ), some [Ctor] ( - list__member(Ctor, Ctors), + list.member(Ctor, Ctors), \+ ml_uses_secondary_tag(TagValues, Ctor, _) ) -> - ClassQualifier = mlds__append_class_qualifier(MLDS_Module, + ClassQualifier = mlds_append_class_qualifier(MLDS_Module, module_qual, Globals, TypeName, TypeArity), ClassQualKind = TypeQualKind, ClassName = "tag_type", @@ -1841,37 +1840,37 @@ ml_gen_hl_tag_field_id(Type, ModuleInfo) = FieldId :- % Put it all together. QualClassName = qual(ClassQualifier, ClassQualKind, ClassName), - ClassPtrType = mlds__ptr_type(mlds__class_type(QualClassName, ClassArity, - mlds__class)), - FieldQualifier = mlds__append_class_qualifier(ClassQualifier, + ClassPtrType = mlds_ptr_type(mlds_class_type(QualClassName, ClassArity, + mlds_class)), + FieldQualifier = mlds_append_class_qualifier(ClassQualifier, ClassQualKind, Globals, ClassName, ClassArity), QualifiedFieldName = qual(FieldQualifier, type_qual, FieldName), FieldId = named_field(QualifiedFieldName, ClassPtrType). -:- func ml_gen_field_id(mer_type, cons_tag, mlds__class_name, arity, - mlds__field_name, globals) = mlds__field_id. +:- func ml_gen_field_id(mer_type, cons_tag, mlds_class_name, arity, + mlds_field_name, globals) = mlds_field_id. ml_gen_field_id(Type, Tag, ConsName, ConsArity, FieldName, Globals) = FieldId :- ( type_to_ctor_and_args(Type, TypeCtor, _) -> ml_gen_type_name(TypeCtor, QualTypeName, TypeArity), QualTypeName = qual(MLDS_Module, QualKind, TypeName), - TypeQualifier = mlds__append_class_qualifier( + TypeQualifier = mlds_append_class_qualifier( MLDS_Module, QualKind, Globals, TypeName, TypeArity), ( ml_tag_uses_base_class(Tag) -> % In this case, there's only one functor for the type (other than % reserved_address constants), and so the class name is determined % by the type name. - ClassPtrType = mlds__ptr_type(mlds__class_type(QualTypeName, - TypeArity, mlds__class)), + ClassPtrType = mlds_ptr_type(mlds_class_type(QualTypeName, + TypeArity, mlds_class)), QualifiedFieldName = qual(TypeQualifier, type_qual, FieldName) ; % In this case, the class name is determined by the constructor. QualConsName = qual(TypeQualifier, type_qual, ConsName), - ClassPtrType = mlds__ptr_type(mlds__class_type(QualConsName, - ConsArity, mlds__class)), - FieldQualifier = mlds__append_class_qualifier(TypeQualifier, + ClassPtrType = mlds_ptr_type(mlds_class_type(QualConsName, + ConsArity, mlds_class)), + FieldQualifier = mlds_append_class_qualifier(TypeQualifier, type_qual, Globals, ConsName, ConsArity), QualifiedFieldName = qual(FieldQualifier, type_qual, FieldName) ), diff --git a/compiler/ml_util.m b/compiler/ml_util.m index c8bd3c2f6..780dc5c8e 100644 --- a/compiler/ml_util.m +++ b/compiler/ml_util.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1999-2005 The University of Melbourne. +% Copyright (C) 1999-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__ml_util. +:- module ml_backend.ml_util. :- interface. :- import_module libs.globals. % for foreign_language @@ -28,14 +28,14 @@ % Succeeds iff the definitions contain the entry point to % the a main predicate. % -:- pred defns_contain_main(mlds__defns::in) is semidet. +:- pred defns_contain_main(mlds_defns::in) is semidet. %-----------------------------------------------------------------------------% % Return `true' if the statement is a tail call which can be optimized % into a jump back to the start of the function. % -:- pred can_optimize_tailcall(mlds__qualified_entity_name::in, mlds__stmt::in) +:- pred can_optimize_tailcall(mlds_qualified_entity_name::in, mlds_stmt::in) is semidet. %-----------------------------------------------------------------------------% @@ -51,13 +51,13 @@ :- pred statement_contains_statement(statement::in, statement::out) is multi. -:- pred stmt_contains_statement(mlds__stmt::in, statement::out) +:- pred stmt_contains_statement(mlds_stmt::in, statement::out) is nondet. % Succeeds iff this statement contains a reference to the % specified variable. % -:- pred statement_contains_var(statement::in, mlds__data::in) is semidet. +:- pred statement_contains_var(statement::in, mlds_data::in) is semidet. :- pred has_foreign_languages(statement::in, list(foreign_language)::out) is det. @@ -77,7 +77,7 @@ % because it shouldn't be generated with target language different to the % native target language in the long run. % -:- pred defn_contains_foreign_code(target_lang::in, mlds__defn::in) is semidet. +:- pred defn_contains_foreign_code(target_lang::in, mlds_defn::in) is semidet. % defn_contains_foreign_code(ForeignLang, Defn): % @@ -85,40 +85,40 @@ % for the given foreign language. % :- pred defn_contains_outline_foreign_proc(foreign_language::in, - mlds__defn::in) is semidet. + mlds_defn::in) is semidet. % Succeeds iff this definition is a type definition. % -:- pred defn_is_type(mlds__defn::in) is semidet. +:- pred defn_is_type(mlds_defn::in) is semidet. % Succeeds iff this definition is a function definition. % -:- pred defn_is_function(mlds__defn::in) is semidet. +:- pred defn_is_function(mlds_defn::in) is semidet. % Succeeds iff this definition is a data definition which % defines a type_ctor_info constant. % -:- pred defn_is_type_ctor_info(mlds__defn::in) is semidet. +:- pred defn_is_type_ctor_info(mlds_defn::in) is semidet. % Succeeds iff this definition is a data definition which - % defines a variable whose type is mlds__commit_type. + % defines a variable whose type is mlds_commit_type. % -:- pred defn_is_commit_type_var(mlds__defn::in) is semidet. +:- pred defn_is_commit_type_var(mlds_defn::in) is semidet. % Succeeds iff this definition has `public' in the access % field in its decl_flags. % -:- pred defn_is_public(mlds__defn::in) is semidet. +:- pred defn_is_public(mlds_defn::in) is semidet. % Succeeds iff these definitions contains a reference to % the specified variable. % -:- pred defns_contains_var(mlds__defns::in, mlds__data::in) is semidet. +:- pred defns_contains_var(mlds_defns::in, mlds_data::in) is semidet. % Succeeds iff this definition contains a reference to % the specified variable. % -:- pred defn_contains_var(mlds__defn::in, mlds__data::in) is semidet. +:- pred defn_contains_var(mlds_defn::in, mlds_data::in) is semidet. %-----------------------------------------------------------------------------% % @@ -134,19 +134,19 @@ % Succeeds iff the specified construct contains a reference to % the specified variable. -:- pred initializer_contains_var(mlds__initializer::in, mlds__data::in) +:- pred initializer_contains_var(mlds_initializer::in, mlds_data::in) is semidet. -:- pred rvals_contains_var(list(mlds_rval)::in, mlds__data::in) is semidet. +:- pred rvals_contains_var(list(mlds_rval)::in, mlds_data::in) is semidet. -:- pred maybe_rval_contains_var(maybe(mlds_rval)::in, mlds__data::in) +:- pred maybe_rval_contains_var(maybe(mlds_rval)::in, mlds_data::in) is semidet. -:- pred rval_contains_var(mlds_rval::in, mlds__data::in) is semidet. +:- pred rval_contains_var(mlds_rval::in, mlds_data::in) is semidet. -:- pred lvals_contains_var(list(mlds_lval)::in, mlds__data::in) is semidet. +:- pred lvals_contains_var(list(mlds_lval)::in, mlds_data::in) is semidet. -:- pred lval_contains_var(mlds_lval::in, mlds__data::in) is semidet. +:- pred lval_contains_var(mlds_lval::in, mlds_data::in) is semidet. %-----------------------------------------------------------------------------% @@ -178,8 +178,8 @@ %-----------------------------------------------------------------------------% defns_contain_main(Defns) :- - list__member(Defn, Defns), - Defn = mlds__defn(Name, _, _, _), + list.member(Defn, Defns), + Defn = mlds_defn(Name, _, _, _), Name = function(FuncName, _, _, _), FuncName = pred(predicate, _, "main", 2, _, _). @@ -222,7 +222,7 @@ can_optimize_tailcall(Name, Call) :- % nondeterministically generates sub-statements from statements. statements_contains_statement(Statements, SubStatement) :- - list__member(Statement, Statements), + list.member(Statement, Statements), statement_contains_statement(Statement, SubStatement). :- pred maybe_statement_contains_statement(maybe(statement)::in, @@ -282,15 +282,15 @@ stmt_contains_statement(Stmt, SubStatement) :- fail ). -:- pred cases_contains_statement(list(mlds__switch_case)::in, +:- pred cases_contains_statement(list(mlds_switch_case)::in, statement::out) is nondet. cases_contains_statement(Cases, SubStatement) :- - list__member(Case, Cases), + list.member(Case, Cases), Case = _MatchCond - Statement, statement_contains_statement(Statement, SubStatement). -:- pred default_contains_statement(mlds__switch_default::in, +:- pred default_contains_statement(mlds_switch_default::in, statement::out) is nondet. default_contains_statement(default_do_nothing, _) :- fail. @@ -306,15 +306,15 @@ default_contains_statement(default_case(Statement), SubStatement) :- % Succeeds iff the specified construct contains a reference to % the specified variable. -:- pred statements_contains_var(statements::in, mlds__data::in) +:- pred statements_contains_var(statements::in, mlds_data::in) is semidet. statements_contains_var(Statements, Name) :- - list__member(Statement, Statements), + list.member(Statement, Statements), statement_contains_var(Statement, Name). :- pred maybe_statement_contains_var(maybe(statement)::in, - mlds__data::in) is semidet. + mlds_data::in) is semidet. % maybe_statement_contains_var(no, _) :- fail. maybe_statement_contains_var(yes(Statement), Name) :- @@ -324,7 +324,7 @@ statement_contains_var(Statement, Name) :- Statement = statement(Stmt, _Context), stmt_contains_var(Stmt, Name). -:- pred stmt_contains_var(mlds__stmt::in, mlds__data::in) is semidet. +:- pred stmt_contains_var(mlds_stmt::in, mlds_data::in) is semidet. stmt_contains_var(Stmt, Name) :- ( @@ -382,15 +382,15 @@ stmt_contains_var(Stmt, Name) :- atomic_stmt_contains_var(AtomicStmt, Name) ). -:- pred cases_contains_var(list(mlds__switch_case)::in, mlds__data::in) +:- pred cases_contains_var(list(mlds_switch_case)::in, mlds_data::in) is semidet. cases_contains_var(Cases, Name) :- - list__member(Case, Cases), + list.member(Case, Cases), Case = _MatchConds - Statement, statement_contains_var(Statement, Name). -:- pred default_contains_var(mlds__switch_default::in, mlds__data::in) +:- pred default_contains_var(mlds_switch_default::in, mlds_data::in) is semidet. % default_contains_var(default_do_nothing, _) :- fail. @@ -398,7 +398,7 @@ cases_contains_var(Cases, Name) :- default_contains_var(default_case(Statement), Name) :- statement_contains_var(Statement, Name). -:- pred atomic_stmt_contains_var(mlds__atomic_statement::in, mlds__data::in) +:- pred atomic_stmt_contains_var(mlds_atomic_statement::in, mlds_data::in) is semidet. % atomic_stmt_contains_var(comment(_), _Name) :- fail. @@ -419,10 +419,10 @@ atomic_stmt_contains_var(restore_hp(Rval), Name) :- atomic_stmt_contains_var(trail_op(TrailOp), Name) :- trail_op_contains_var(TrailOp, Name). atomic_stmt_contains_var(inline_target_code(_Lang, Components), Name) :- - list__member(Component, Components), + list.member(Component, Components), target_code_component_contains_var(Component, Name). -:- pred trail_op_contains_var(trail_op::in, mlds__data::in) is semidet. +:- pred trail_op_contains_var(trail_op::in, mlds_data::in) is semidet. trail_op_contains_var(store_ticket(Lval), Name) :- lval_contains_var(Lval, Name). @@ -436,7 +436,7 @@ trail_op_contains_var(prune_tickets_to(Rval), Name) :- rval_contains_var(Rval, Name). :- pred target_code_component_contains_var(target_code_component::in, - mlds__data::in) is semidet. + mlds_data::in) is semidet. %target_code_component_contains_var(raw_target_code(_Code), _Name) :- % fail. @@ -466,8 +466,8 @@ has_foreign_languages(Statement, Langs) :- % defn_contains_foreign_code(NativeTargetLang, Defn) :- - Defn = mlds__defn(_Name, _Context, _Flags, Body), - Body = function(_, _, defined_here(FunctionBody), _), + Defn = mlds_defn(_Name, _Context, _Flags, Body), + Body = mlds_function(_, _, defined_here(FunctionBody), _), statement_contains_statement(FunctionBody, Statement), Statement = statement(Stmt, _), ( @@ -478,34 +478,34 @@ defn_contains_foreign_code(NativeTargetLang, Defn) :- ). defn_contains_outline_foreign_proc(ForeignLang, Defn) :- - Defn = mlds__defn(_Name, _Context, _Flags, Body), - Body = function(_, _, defined_here(FunctionBody), _), + Defn = mlds_defn(_Name, _Context, _Flags, Body), + Body = mlds_function(_, _, defined_here(FunctionBody), _), statement_contains_statement(FunctionBody, Statement), Statement = statement(Stmt, _), Stmt = atomic(outline_foreign_proc(ForeignLang, _, _, _)). defn_is_type(Defn) :- - Defn = mlds__defn(Name, _Context, _Flags, _Body), + Defn = mlds_defn(Name, _Context, _Flags, _Body), Name = type(_, _). defn_is_function(Defn) :- - Defn = mlds__defn(Name, _Context, _Flags, _Body), + Defn = mlds_defn(Name, _Context, _Flags, _Body), Name = function(_, _, _, _). defn_is_type_ctor_info(Defn) :- - Defn = mlds__defn(_Name, _Context, _Flags, Body), - Body = mlds__data(Type, _, _), - Type = mlds__rtti_type(item_type(RttiId)), + Defn = mlds_defn(_Name, _Context, _Flags, Body), + Body = mlds_data(Type, _, _), + Type = mlds_rtti_type(item_type(RttiId)), RttiId = ctor_rtti_id(_, RttiName), RttiName = type_ctor_info. defn_is_commit_type_var(Defn) :- - Defn = mlds__defn(_Name, _Context, _Flags, Body), - Body = mlds__data(Type, _, _), - Type = mlds__commit_type. + Defn = mlds_defn(_Name, _Context, _Flags, Body), + Body = mlds_data(Type, _, _), + Type = mlds_commit_type. defn_is_public(Defn) :- - Defn = mlds__defn(_Name, _Context, Flags, _Body), + Defn = mlds_defn(_Name, _Context, Flags, _Body), access(Flags) = public. % defns_contains_var: @@ -516,29 +516,29 @@ defn_is_public(Defn) :- % the specified variable. % defns_contains_var(Defns, Name) :- - list__member(Defn, Defns), + list.member(Defn, Defns), defn_contains_var(Defn, Name). -defn_contains_var(mlds__defn(_Name, _Context, _Flags, DefnBody), Name) :- +defn_contains_var(mlds_defn(_Name, _Context, _Flags, DefnBody), Name) :- defn_body_contains_var(DefnBody, Name). -:- pred defn_body_contains_var(mlds__entity_defn::in, mlds__data::in) +:- pred defn_body_contains_var(mlds_entity_defn::in, mlds_data::in) is semidet. % XXX Should we include variables in the GC_TraceCode field here? -defn_body_contains_var(mlds__data(_Type, Initializer, _GC_TraceCode), Name) :- +defn_body_contains_var(mlds_data(_Type, Initializer, _GC_TraceCode), Name) :- initializer_contains_var(Initializer, Name). -defn_body_contains_var(mlds__function(_PredProcId, _Params, FunctionBody, +defn_body_contains_var(mlds_function(_PredProcId, _Params, FunctionBody, _Attrs), Name) :- function_body_contains_var(FunctionBody, Name). -defn_body_contains_var(mlds__class(ClassDefn), Name) :- - ClassDefn = mlds__class_defn(_Kind, _Imports, _Inherits, _Implements, +defn_body_contains_var(mlds_class(ClassDefn), Name) :- + ClassDefn = mlds_class_defn(_Kind, _Imports, _Inherits, _Implements, CtorDefns, FieldDefns), ( defns_contains_var(FieldDefns, Name) ; defns_contains_var(CtorDefns, Name) ). -:- pred function_body_contains_var(function_body::in, mlds__data::in) +:- pred function_body_contains_var(mlds_function_body::in, mlds_data::in) is semidet. % function_body_contains_var(external, _) :- fail. @@ -563,14 +563,14 @@ function_body_contains_var(defined_here(Statement), Name) :- initializer_contains_var(init_obj(Rval), Name) :- rval_contains_var(Rval, Name). initializer_contains_var(init_struct(_Type, Inits), Name) :- - list__member(Init, Inits), + list.member(Init, Inits), initializer_contains_var(Init, Name). initializer_contains_var(init_array(Inits), Name) :- - list__member(Init, Inits), + list.member(Init, Inits), initializer_contains_var(Init, Name). rvals_contains_var(Rvals, Name) :- - list__member(Rval, Rvals), + list.member(Rval, Rvals), rval_contains_var(Rval, Name). % maybe_rval_contains_var(no, _Name) :- fail. @@ -597,7 +597,7 @@ rval_contains_var(mem_addr(Lval), Name) :- lval_contains_var(Lval, Name). lvals_contains_var(Lvals, Name) :- - list__member(Lval, Lvals), + list.member(Lval, Lvals), lval_contains_var(Lval, Name). lval_contains_var(field(_MaybeTag, Rval, _FieldId, _, _), Name) :- diff --git a/compiler/mlds.m b/compiler/mlds.m index 03e7de922..2ea99e425 100644 --- a/compiler/mlds.m +++ b/compiler/mlds.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1999-2005 The University of Melbourne. +% Copyright (C) 1999-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -69,7 +69,7 @@ % % MLDS function signatures are determined by the HLDS procedure's % argument types, modes, and determinism. -% Procedures arguments with type `io__state' or `store(_)' are not passed. +% Procedures arguments with type `io.state' or `store(_)' are not passed. % Procedure arguments with top_unused modes are not passed. % Procedures arguments with top_in modes are passed as input. % Procedures arguments with top_out modes are normally passed by reference. @@ -326,7 +326,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__mlds. +:- module ml_backend.mlds. :- interface. @@ -349,7 +349,7 @@ %-----------------------------------------------------------------------------% -:- type mercury_module_name == prim_data__module_name. +:- type mercury_module_name == prim_data.module_name. % % The type `mlds' is the actual MLDS. @@ -363,15 +363,15 @@ % Code defined in some other language, e.g. for % `pragma c_header_code', etc. foreign_code :: map(foreign_language, - mlds__foreign_code), + mlds_foreign_code), % The MLDS code itself. % Packages/classes to import - toplevel_imports :: mlds__imports, + toplevel_imports :: mlds_imports, % Definitions of code and data - defns :: mlds__defns, + defns :: mlds_defns, % The names of init and final preds. % XXX These only work for the C backend, because @@ -380,9 +380,9 @@ final_preds :: list(string) ). -:- func get_module_name(mlds) = mercury_module_name. +:- func mlds_get_module_name(mlds) = mercury_module_name. -:- type mlds__imports == list(mlds__import). +:- type mlds_imports == list(mlds_import). % For the C backend, we generate a `.mh' file containing the % prototypes for C functions generated for `:- pragma export' @@ -396,11 +396,11 @@ ---> user_visible_interface ; compiler_visible_interface. - % An mlds__import specifies FIXME + % An mlds_import specifies FIXME % Currently an import just gives the name of the package to be imported. % This might perhaps need to be expanded to cater to different kinds of % imports, e.g. imports with wild-cards ("import java.lang.*"). -:- type mlds__import +:- type mlds_import ---> mercury_import( mercury_mlds_import_type :: mercury_mlds_import_type, import_name :: mlds_module_name @@ -415,8 +415,8 @@ % An mlds_module_name specifies the name of an mlds package or class. :- type mlds_module_name. - % An mlds__package_name specifies the name of an mlds package. -:- type mlds__package_name == mlds_module_name. + % An mlds_package_name specifies the name of an mlds package. +:- type mlds_package_name == mlds_module_name. % Given the name of a Mercury module, return the name of the corresponding % MLDS package in which this module is defined. @@ -436,7 +436,7 @@ % name, e.g. for the name System.Object which is defined in the source % package mscorlib, it will return System.Object. % -:- func mlds_module_name_to_sym_name(mlds__package_name) = sym_name. +:- func mlds_module_name_to_sym_name(mlds_package_name) = sym_name. % Give the name of a Mercury module, return the name of the corresponding % MLDS package. @@ -454,18 +454,18 @@ % The qual_kind argument specifies the qualifier kind of the module_name % argument. % -:- func mlds__append_class_qualifier(mlds_module_name, mlds__qual_kind, - globals, mlds__class_name, arity) = mlds_module_name. +:- func mlds_append_class_qualifier(mlds_module_name, mlds_qual_kind, + globals, mlds_class_name, arity) = mlds_module_name. % Append a wrapper class qualifier to the module name and leave the % package name unchanged. % -:- func mlds__append_wrapper_class(mlds_module_name) = mlds_module_name. +:- func mlds_append_wrapper_class(mlds_module_name) = mlds_module_name. % Append an arbitrary qualifier to the module name and leave the package % name unchanged. % -:- func mlds__append_name(mlds_module_name, string) = mlds_module_name. +:- func mlds_append_name(mlds_module_name, string) = mlds_module_name. % When targetting languages such as IL, C#, and Java, which don't support % global methods or global variables, we need to wrap all the generated @@ -474,64 +474,64 @@ % :- func wrapper_class_name = string. -:- type mlds__defns == list(mlds__defn). +:- type mlds_defns == list(mlds_defn). -:- type mlds__defn - ---> mlds__defn( - % The name of the entity being declared. - mlds_entity_name :: mlds__entity_name, +:- type mlds_defn + ---> mlds_defn( + % The name of the entity being declared. + mlds_entity_name :: mlds_entity_name, - % The source location. - mlds_context :: mlds__context, + % The source location. + mlds_context :: mlds_context, - % these contain the following: - % mlds__access, % public/private/protected - % mlds__member_type, % static/per_instance - % mlds__virtuality, % virtual/non_virtual - % mlds__finality, % final/overridable (funcs only) - % mlds__constness, % const/modifiable (data only) - % mlds__is_abstract, % abstract/concrete - % etc. - mlds_decl_flags :: mlds__decl_flags, + % these contain the following: + % access, % public/private/protected + % member_type, % static/per_instance + % virtuality, % virtual/non_virtual + % finality, % final/overridable (funcs only) + % constness, % const/modifiable (data only) + % is_abstract, % abstract/concrete + % etc. + mlds_decl_flags :: mlds_decl_flags, - mlds_entity_defn :: mlds__entity_defn - ). + mlds_entity_defn :: mlds_entity_defn + ). % An mlds name may contain arbitrary characters. % If the target language has restrictions on what names can be used % in identifiers, then it is the responsibility of the target language % generator to mangle these names accordingly. -:- type mlds__qualified_entity_name - == mlds__fully_qualified_name(mlds__entity_name). +:- type mlds_qualified_entity_name + == mlds_fully_qualified_name(mlds_entity_name). -:- type mlds__fully_qualified_name(T) - ---> qual(mlds_module_name, mlds__qual_kind, T). +:- type mlds_fully_qualified_name(T) + ---> qual(mlds_module_name, mlds_qual_kind, T). % For the Java back-end, we need to distinguish between module qualifiers % and type qualifiers, because type names get the case of their initial % letter inverted (i.e. lowercase => uppercase). -:- type mlds__qual_kind +:- type mlds_qual_kind ---> module_qual ; type_qual. -:- type mlds__entity_name - ---> type(mlds__class_name, arity) % Name, arity. - ; data(mlds__data_name) +:- type mlds_entity_name + ---> type(mlds_class_name, arity) % Name, arity. + ; data(mlds_data_name) ; function( % Identifies the source code predicate or function. - mlds__pred_label, + mlds_pred_label, proc_id, % A sequence number used to distinguish different MLDS % functions when compiling a single HLDS predicate into % multiple MLDS functions (e.g. to handle backtracking). - maybe(mlds__func_sequence_num), + maybe(mlds_func_sequence_num), % Specifies the HLDS pred_id. % This should generally not be needed much, since all the - % necessary information should be in the mlds__pred_label - % and/or in the mlds__entity_defn. However, the target + % necessary information should be in the mlds_pred_label + % and/or in the mlds_entity_defn. However, the target % generator may want to refer to the HLDS for additional % information. pred_id @@ -541,7 +541,7 @@ string ). -:- type mlds__func_sequence_num == int. +:- type mlds_func_sequence_num == int. % This specifies information about some entity being defined % The entity may be any of the following: @@ -552,28 +552,28 @@ % interface (abstract class, no data members) % struct (value class) % enum -:- type mlds__entity_defn - ---> mlds__data( +:- type mlds_entity_defn + ---> mlds_data( % Represents a constant or variable. mlds_type, - mlds__initializer, + mlds_initializer, % If accurate GC is enabled, we associate with each variable % the code needed to trace that variable when doing GC. - mlds__maybe_gc_trace_code + mlds_maybe_gc_trace_code ) - ; mlds__function( + ; mlds_function( % Represents functions. maybe(pred_proc_id), % Identifies the original % Mercury procedure, if any. - mlds__func_params, % The arguments & return types. - mlds__function_body, % The function body. - list(mlds__attribute) % Attributes. + mlds_func_params, % The arguments & return types. + mlds_function_body, % The function body. + list(mlds_attribute) % Attributes. ) - ; mlds__class( + ; mlds_class( % Represents packages, classes, interfaces, structs, enums. - mlds__class_defn + mlds_class_defn ). % If accurate GC is enabled, we associate with each variable @@ -582,13 +582,13 @@ % `no' here indicates that no GC tracing code is needed, % e.g. because accurate GC isn't enabled, or because the % variable can never contain pointers to objects on the heap. -:- type mlds__maybe_gc_trace_code == maybe(statement). +:- type mlds_maybe_gc_trace_code == maybe(statement). % It is possible for the function to be defined externally % (i.e. the original Mercury procedure was declared `:- external'). % (If you want to generate an abstract body consider adding another % alternative here). -:- type mlds__function_body +:- type mlds_function_body ---> defined_here(statement) ; external. @@ -596,86 +596,86 @@ % (the GCC back-end relies on this). % XXX Currently we only record the type for structs. % We should do the same for objects and arrays. -:- type mlds__initializer +:- type mlds_initializer ---> init_obj(mlds_rval) - ; init_struct(mlds_type, list(mlds__initializer)) - ; init_array(list(mlds__initializer)) + ; init_struct(mlds_type, list(mlds_initializer)) + ; init_array(list(mlds_initializer)) ; no_initializer. -:- type mlds__func_params - ---> mlds__func_params( - mlds__arguments, % names and types of arguments (inputs) - mlds__return_types % types of return values (outputs) - ). +:- type mlds_func_params + ---> mlds_func_params( + mlds_arguments, % names and types of arguments (inputs) + mlds_return_types % types of return values (outputs) + ). -:- type mlds__arguments == list(mlds__argument). -:- type mlds__argument - ---> mlds__argument( - mlds__entity_name, % argument name - mlds_type, % argument type - mlds__maybe_gc_trace_code % GC tracing code for this argument, - % if needed - ). +:- type mlds_arguments == list(mlds_argument). +:- type mlds_argument + ---> mlds_argument( + mlds_entity_name, % argument name + mlds_type, % argument type + mlds_maybe_gc_trace_code % GC tracing code for this argument, + % if needed + ). -:- type mlds__arg_types == list(mlds_type). -:- type mlds__return_types == list(mlds_type). +:- type mlds_arg_types == list(mlds_type). +:- type mlds_return_types == list(mlds_type). -:- func mlds__get_arg_types(mlds__arguments) = list(mlds_type). +:- func mlds_get_arg_types(mlds_arguments) = list(mlds_type). - % An mlds__func_signature is like an mlds__func_params + % An mlds_func_signature is like an mlds_func_params % except that it only includes the function's type, not % the parameter names. -:- type mlds__func_signature - ---> mlds__func_signature( - mlds__arg_types, % argument types - mlds__return_types % return types - ). +:- type mlds_func_signature + ---> mlds_func_signature( + mlds_arg_types, % argument types + mlds_return_types % return types + ). -:- func mlds__get_func_signature(mlds__func_params) = mlds__func_signature. +:- func mlds_get_func_signature(mlds_func_params) = mlds_func_signature. -:- type mlds__class_kind - ---> mlds__class % A generic class: can inherit other classes and +:- type mlds_class_kind + ---> mlds_class % A generic class: can inherit other classes and % interfaces (but most targets will only support % single inheritence, so usually there will be % at most one class). - ; mlds__package % A class with only static members (can only + ; mlds_package % A class with only static members (can only % inherit other packages). Unlike other kinds % of classes, packages should not be used as types. - ; mlds__interface % A class with no variable data members (can only + ; mlds_interface % A class with no variable data members (can only % inherit other interfaces). - ; mlds__struct % A value class (can only inherit other structs). + ; mlds_struct % A value class (can only inherit other structs). - ; mlds__enum. % A class with one integer member and a bunch + ; mlds_enum. % A class with one integer member and a bunch % of static consts (cannot inherit anything). -:- type mlds__class_name == string. -:- type mlds__class == mlds__fully_qualified_name(mlds__class_name). +:- type mlds_class_name == string. +:- type mlds_class == mlds_fully_qualified_name(mlds_class_name). % Note that standard C doesn't support empty structs, % so when targetting C, it is the MLDS code generator's % responsibility to ensure that each generated MLDS class % has at least one base class or non-static data member. -:- type mlds__class_defn - ---> mlds__class_defn( - kind :: mlds__class_kind, - imports :: mlds__imports, - % Imports these classes (or modules, packages, ...). +:- type mlds_class_defn + ---> mlds_class_defn( + kind :: mlds_class_kind, + imports :: mlds_imports, + % Imports these classes (or modules, packages, ...). - inherits :: list(mlds__class_id), - % Inherits these base classes. + inherits :: list(mlds_class_id), + % Inherits these base classes. - implements :: list(mlds__interface_id), - % Implements these interfaces. + implements :: list(mlds_interface_id), + % Implements these interfaces. - ctors :: mlds__defns, - % Has these constructors. + ctors :: mlds_defns, + % Has these constructors. - members :: mlds__defns - % Contains these members. - ). + members :: mlds_defns + % Contains these members. + ). % Note: the definition of the `mlds_type' type is subject to change. % In particular, we might add new alternatives here, so try to avoid @@ -691,7 +691,7 @@ % representation of the type. ) - ; mlds__mercury_array_type(mlds_type) + ; mlds_mercury_array_type(mlds_type) % The Mercury array type is treated specially, some backends % will treat it like any other mercury_type, whereas other may % use a special representation for it. @@ -701,16 +701,16 @@ % only classify the topmost level of the type, whereas we % really want to classify the element type for arrays, so % we can generate int[] for array(int)). - % Note that mlds__mercury_array_type/1 is used for representing - % Mercury arrays, whereas mlds__array_type/1 (see below) + % Note that mlds_mercury_array_type/1 is used for representing + % Mercury arrays, whereas mlds_array_type/1 (see below) % is used for representing the target language's native arrays. - ; mlds__cont_type(mlds__return_types) + ; mlds_cont_type(mlds_return_types) % The type for the continuation functions used to handle % nondeterminism - ; mlds__commit_type - % mlds__commit_type is used for storing information about a + ; mlds_commit_type + % mlds_commit_type is used for storing information about a % commit. This is an abstract type; the exact definition % will depend on the back-end. The only operations on this ADT % are `try_commit' and `do_commit'. This type holds @@ -718,7 +718,7 @@ % needed to unwind the stack when a `do_commit' is executed. % % For the C back-end, if we're implementing do_commit/try_commit - % using setjmp/longmp, then mlds__commit_type will be jmp_buf. + % using setjmp/longmp, then mlds_commit_type will be jmp_buf. % If we're implementing them using GNU C nested functions, then % it will be `__label__'; in this case, the local variable % of this "type" is actually a label, and doing a goto to that @@ -734,37 +734,37 @@ % See also the comments in ml_code_gen.m which show how commits % can be implemented for different target languages. - ; mlds__native_bool_type - ; mlds__native_int_type - ; mlds__native_float_type - ; mlds__native_char_type + ; mlds_native_bool_type + ; mlds_native_int_type + ; mlds_native_float_type + ; mlds_native_char_type % MLDS native builtin types. % These are the builtin types of the MLDS target language, % whatever that may be. % Currently we don't actually use many of these. - ; mlds__foreign_type( + ; mlds_foreign_type( % This is a type of the target language. foreign_language_type ) - ; mlds__class_type( - % MLDS types defined using mlds__class_defn. + ; mlds_class_type( + % MLDS types defined using mlds_class_defn. - mlds__class, % name + mlds_class, % name arity, - mlds__class_kind + mlds_class_kind ) - ; mlds__array_type(mlds_type) + ; mlds_array_type(mlds_type) % MLDS array types. % These are single-dimensional, and can be indexed - % using the `field' lval with an `offset' field_id; + % using the `field' lval with an `offset' mlds_field_id; % indices start at zero. % - % Note that mlds__array_type/1 is used for representing + % Note that mlds_array_type/1 is used for representing % the target language's native arrays, whereas - % mlds__mercury_array_type/1 (see above) is used for + % mlds_mercury_array_type/1 (see above) is used for % representing Mercury arrays. % % Currently MLDS array types are used for @@ -779,33 +779,33 @@ % MLDS code generator, e.g. the arrays used for % string switches. - ; mlds__ptr_type(mlds_type) + ; mlds_ptr_type(mlds_type) % Pointer types. % Currently these are used for handling output arguments. - ; mlds__func_type(mlds__func_params) + ; mlds_func_type(mlds_func_params) % Function types. % For the C back-end, these are mapped to function pointer types, % since C doesn't have first-class function types. - ; mlds__generic_type + ; mlds_generic_type % A generic type (e.g. `Word') that can hold any Mercury value. % This is used for implementing polymorphism. - ; mlds__generic_env_ptr_type + ; mlds_generic_env_ptr_type % A generic pointer type (e.g. `void *' in C) that can be used % to point to the environment (set of local variables) of the % containing function. This is used for handling nondeterminism, % if the target language doesn't support nested functions, and % also for handling closures for higher-order code. - ; mlds__type_info_type + ; mlds_type_info_type - ; mlds__pseudo_type_info_type + ; mlds_pseudo_type_info_type - ; mlds__rtti_type(rtti_id_maybe_element) + ; mlds_rtti_type(rtti_id_maybe_element) - ; mlds__unknown_type. + ; mlds_unknown_type. % A type used by the ML code generator for references to variables % that have yet to be declared. This occurs once in ml_code_util.m % where references to env_ptr's are generated but the declaration @@ -814,15 +814,15 @@ :- func mercury_type_to_mlds_type(module_info, mer_type) = mlds_type. % Hmm... this is tentative. -:- type mlds__class_id == mlds_type. -:- type mlds__interface_id == mlds_type. +:- type mlds_class_id == mlds_type. +:- type mlds_interface_id == mlds_type. %-----------------------------------------------------------------------------% % % Declaration flags % -:- type mlds__decl_flags. +:- type mlds_decl_flags. :- type access % The following used for class members (this includes globals, @@ -866,22 +866,22 @@ ---> concrete ; abstract. -:- func access(mlds__decl_flags) = access. -:- func per_instance(mlds__decl_flags) = per_instance. -:- func virtuality(mlds__decl_flags) = virtuality. -:- func finality(mlds__decl_flags) = finality. -:- func constness(mlds__decl_flags) = constness. -:- func abstractness(mlds__decl_flags) = abstractness. +:- func access(mlds_decl_flags) = access. +:- func per_instance(mlds_decl_flags) = per_instance. +:- func virtuality(mlds_decl_flags) = virtuality. +:- func finality(mlds_decl_flags) = finality. +:- func constness(mlds_decl_flags) = constness. +:- func abstractness(mlds_decl_flags) = abstractness. -:- func set_access(mlds__decl_flags, access) = mlds__decl_flags. -:- func set_per_instance(mlds__decl_flags, per_instance) = mlds__decl_flags. -:- func set_virtuality(mlds__decl_flags, virtuality) = mlds__decl_flags. -:- func set_finality(mlds__decl_flags, finality) = mlds__decl_flags. -:- func set_constness(mlds__decl_flags, constness) = mlds__decl_flags. -:- func set_abstractness(mlds__decl_flags, abstractness) = mlds__decl_flags. +:- func set_access(mlds_decl_flags, access) = mlds_decl_flags. +:- func set_per_instance(mlds_decl_flags, per_instance) = mlds_decl_flags. +:- func set_virtuality(mlds_decl_flags, virtuality) = mlds_decl_flags. +:- func set_finality(mlds_decl_flags, finality) = mlds_decl_flags. +:- func set_constness(mlds_decl_flags, constness) = mlds_decl_flags. +:- func set_abstractness(mlds_decl_flags, abstractness) = mlds_decl_flags. :- func init_decl_flags(access, per_instance, virtuality, finality, - constness, abstractness) = mlds__decl_flags. + constness, abstractness) = mlds_decl_flags. %-----------------------------------------------------------------------------% % @@ -891,28 +891,28 @@ % When compiling to a language other than the foreign language, % this part still needs to be generated as C (or whatever) code % and compiled with a C (or whatever) compiler. -:- type mlds__foreign_code - ---> mlds__foreign_code( +:- type mlds_foreign_code + ---> mlds_foreign_code( foreign_decl_info, foreign_import_module_info, list(user_foreign_code), - list(mlds__pragma_export) + list(mlds_pragma_export) ). % Information required to generate code for each `pragma export'. -:- type mlds__pragma_export +:- type mlds_pragma_export ---> ml_pragma_export( string, % Exported name - mlds__qualified_entity_name, % MLDS name for exported entity - mlds__func_params, % MLDS function parameters - mlds__context + mlds_qualified_entity_name, % MLDS name for exported entity + mlds_func_params, % MLDS function parameters + mlds_context ). %-----------------------------------------------------------------------------% % % Attributes -:- type mlds__attribute +:- type mlds_attribute ---> custom( mlds_type ). @@ -921,13 +921,13 @@ % % Contexts (i.e. source code locations) - % Mlds__context is probably == prog_context, + % mlds.context is probably == prog_context, % but might also contain goal_path or other information. -:- type mlds__context. +:- type mlds_context. -:- func mlds__make_context(prog_context) = mlds__context. +:- func mlds_make_context(prog_context) = mlds_context. -:- func mlds__get_prog_context(mlds__context) = prog_context. +:- func mlds_get_prog_context(mlds_context) = prog_context. %-----------------------------------------------------------------------------% % @@ -938,14 +938,14 @@ :- type statement ---> statement( - mlds__stmt, - mlds__context + mlds_stmt, + mlds_context ). -:- type mlds__stmt +:- type mlds_stmt % Sequence. - ---> block(mlds__defns, list(statement)) + ---> block(mlds_defns, list(statement)) % Iteration. @@ -980,25 +980,25 @@ % The range of possible values which the value might take % (if known). - mlds__switch_range, + mlds_switch_range, % The different cases. - mlds__switch_cases, + mlds_switch_cases, % What to do if none of the cases match. - mlds__switch_default + mlds_switch_default ) % Transfer of control. - ; label(mlds__label) + ; label(mlds_label) % Defines a label that can be used as the target of calls, % gotos, etc. - ; goto(mlds__goto_target) + ; goto(mlds_goto_target) % goto(Target): Branch to the specified address. - ; computed_goto(mlds_rval, list(mlds__label)) + ; computed_goto(mlds_rval, list(mlds_label)) % Evaluate rval, which should be an integer, and jump to the % (rval+1)th label in the list. e.g. computed_goto(2, [A, B, C, D]) % will branch to label C. @@ -1006,7 +1006,7 @@ % Function call/return. ; call( - mlds__func_signature, % Signature of the function. + mlds_func_signature, % Signature of the function. mlds_rval, % The function to call. maybe(mlds_rval), % For method calls, this field % specifies the `this' object. @@ -1035,7 +1035,7 @@ % that was specified in that try_commit instruction. % % For both try_commit and do_commit instructions, Ref should be - % the name of a local variable of type mlds__commit_type. + % the name of a local variable of type mlds_commit_type. % (This variable can be used by the back-end's implementation % of do_commit and try_commit to store information needed to unwind % the stack.) There should be exactly one try_commit instruction @@ -1070,7 +1070,7 @@ % ; try_catch( % statement, -% list(mlds__exception_handler) +% list(mlds_exception_handler) % ) % % Execute the specified statement, and if it throws an exception, % % and the exception matches any of the exception handlers, @@ -1078,7 +1078,7 @@ % Atomic statements. - ; atomic(mlds__atomic_statement). + ; atomic(mlds_atomic_statement). %-----------------------------------------------------------------------------% % @@ -1086,7 +1086,7 @@ % % The range of possible values which the % switch variable might take (if known) -:- type mlds__switch_range +:- type mlds_switch_range ---> range_unknown ; range(range_min::int, range_max::int). % From range_min to range_max, inclusive. @@ -1095,15 +1095,15 @@ % and the statement to execute if the match succeeds. % Unlike C, cases do NOT fall through; if you want to achieve that % effect, you need to use an explicit goto. -:- type mlds__switch_cases == list(mlds__switch_case). -:- type mlds__switch_case == pair(mlds__case_match_conds, statement). +:- type mlds_switch_cases == list(mlds_switch_case). +:- type mlds_switch_case == pair(mlds_case_match_conds, statement). % Case_match_conds should be a _non-empty_ list of conditions; % if _any_ of the conditions match, this case will be selected. -:- type mlds__case_match_conds == list(mlds__case_match_cond). +:- type mlds_case_match_conds == list(mlds_case_match_cond). % A case_match_cond specifies when a switch case will be selected -:- type mlds__case_match_cond +:- type mlds_case_match_cond ---> match_value(mlds_rval) % match_value(Val) matches if the switch value is equal to % the specified Val. @@ -1116,7 +1116,7 @@ % The switch_default specifies what to do if none of the switch % conditions match. -:- type mlds__switch_default +:- type mlds_switch_default ---> default_is_unreachable % The switch is exhaustive, so the default case should % never be reached. @@ -1132,10 +1132,10 @@ % % Extra info for labels -:- type mlds__label == string. +:- type mlds_label == string. -:- type mlds__goto_target - ---> label(mlds__label) % Branch to the specified label. +:- type mlds_goto_target + ---> label(mlds_label) % Branch to the specified label. ; break % Branch to just after the end of the % immediately enclosing loop or switch, @@ -1176,7 +1176,7 @@ % XXX This is tentative -- the current definition may be % a bit too specific to C++-style exceptions. % It might not be a good choice for different target languages. -:- type mlds__exception_handler +:- type mlds_exception_handler ---> handler( maybe(mlds_type), % If `yes(T)', specifies the type of exceptions to catch. @@ -1193,7 +1193,7 @@ % % atomic statements % -:- type mlds__atomic_statement +:- type mlds_atomic_statement ---> comment(string) % Insert a comment into the output code. @@ -1248,10 +1248,10 @@ % % Note that for --low-level-data, we box all fields of objects % created with new_object, i.e. they are reprsented with type - % mlds__generic_type. We also do that for some fields even + % mlds_generic_type. We also do that for some fields even % for --high-level-data (e.g. floating point fields for the % MLDS->C and MLDS->asm back-ends). In such cases, the type - % here should be mlds__generic_type; it is the responsibility + % here should be mlds_generic_type; it is the responsibility % of the HLDS->MLDS code generator to insert code to box/unbox % the arguments. list(mlds_type) @@ -1365,7 +1365,7 @@ ; target_code_input(mlds_rval) ; target_code_output(mlds_lval) - ; name(mlds__qualified_entity_name). + ; name(mlds_qualified_entity_name). :- type target_code_attributes == list(target_code_attribute). @@ -1380,16 +1380,16 @@ % of stack items. % Constructor id. -:- type ctor_name == mlds__qualified_ctor_id. -:- type mlds__ctor_id ---> ctor_id(mlds__class_name, arity). -:- type mlds__qualified_ctor_id == mlds__fully_qualified_name(mlds__ctor_id). +:- type ctor_name == mlds_qualified_ctor_id. +:- type mlds_ctor_id ---> ctor_id(mlds_class_name, arity). +:- type mlds_qualified_ctor_id == mlds_fully_qualified_name(mlds_ctor_id). % Trail management. % For documentation, see the corresponding LLDS instructions in llds.m. % :- type trail_op ---> store_ticket(mlds_lval) - ; reset_ticket(mlds_rval, mlds__reset_trail_reason) + ; reset_ticket(mlds_rval, mlds_reset_trail_reason) ; discard_ticket ; prune_ticket ; mark_ticket_stack(mlds_lval) @@ -1398,12 +1398,12 @@ %-----------------------------------------------------------------------------% - % A field_id represents some data within an object. -:- type field_id + % An mlds_field_id represents some data within an object. +:- type mlds_field_id ---> offset(mlds_rval) % offset(N) represents the field at offset N Words. - ; named_field(mlds__fully_qualified_name(field_name), mlds_type). + ; named_field(mlds_fully_qualified_name(mlds_field_name), mlds_type). % named_field(Name, CtorType) represents the field with the % specified name. The CtorType gives the MLDS type for this % particular constructor. The type of the object is given by @@ -1413,12 +1413,12 @@ % for inserting a downcast from PtrType to CtorType before % accessing the field. -:- type field_name == string. +:- type mlds_field_name == string. - % An mlds__var represents a variable or constant. -:- type mlds__var == mlds__fully_qualified_name(mlds__var_name). -:- type mlds__var_name - ---> mlds__var_name(string, maybe(int)). + % An mlds_var represents a variable or constant. +:- type mlds_var == mlds_fully_qualified_name(mlds_var_name). +:- type mlds_var_name + ---> mlds_var_name(string, maybe(int)). % Var name and perhaps a unique number to be added as a % suffix where necessary. @@ -1443,17 +1443,17 @@ % % Note that for --low-level-data, we box all fields of objects % created with new_object, i.e. they are reprsented with type - % mlds__generic_type. We also do that for some fields even + % mlds_generic_type. We also do that for some fields even % for --high-level-data (e.g. floating point fields for the % MLDS->C and MLDS->asm back-ends). In such cases, the type - % here should be mlds__generic_type, not the actual type of + % here should be mlds_generic_type, not the actual type of % the field. If the actual type is different, then it is the % HLDS->MLDS code generator's responsibility to insert the % necessary code to handle boxing/unboxing. field_tag :: maybe(mlds_tag), field_addr :: mlds_rval, - field_field_id :: field_id, + field_field_id :: mlds_field_id, field_type :: mlds_type, field_ptr_type :: mlds_type ) @@ -1474,7 +1474,7 @@ % the variable name should be fully qualified. ; var( - mlds__var, + mlds_var, mlds_type ). @@ -1512,11 +1512,11 @@ :- type mlds_unary_op ---> box(mlds_type) - % box(MLDSType); convert from MLDSType to mlds__generic_type, + % box(MLDSType); convert from MLDSType to mlds_generic_type, % by boxing if necessary, or just casting if not. ; unbox(mlds_type) - % unbox(MLDSType): convert from mlds__generic_type to MLDSType, + % unbox(MLDSType): convert from mlds_generic_type to MLDSType, % applying the inverse transformation to box/1, i.e. unboxing % if boxing was necessary, and just casting otherwise. @@ -1524,7 +1524,7 @@ % cast(MLDSType): Coerce the type of the rval to be MLDSType. % XXX It might be worthwhile adding the type that we cast from. - ; std_unop(builtin_ops__unary_op). + ; std_unop(builtin_ops.unary_op). :- type mlds_rval_const ---> true @@ -1537,37 +1537,37 @@ % whose real length is given by the integer, and not the location % of the first null character. - ; code_addr_const(mlds__code_addr) - ; data_addr_const(mlds__data_addr) + ; code_addr_const(mlds_code_addr) + ; data_addr_const(mlds_data_addr) ; null(mlds_type). % A null value, of the given type. Usually the type will be a - % pointer (mlds__ptr_type) but it could also be string or a + % pointer (mlds_ptr_type) but it could also be string or a % func_type. (Null is not a valid value of type string or % func_type, but null values of those types may be useful as % placeholders in cases where the value will never be used.) -:- type mlds__code_addr +:- type mlds_code_addr ---> proc( - mlds__qualified_proc_label, - mlds__func_signature + mlds_qualified_proc_label, + mlds_func_signature ) ; internal( - mlds__qualified_proc_label, - mlds__func_sequence_num, - mlds__func_signature + mlds_qualified_proc_label, + mlds_func_sequence_num, + mlds_func_signature ). -:- type mlds__data_addr +:- type mlds_data_addr ---> data_addr( mlds_module_name, % The name of the module module. - mlds__data_name % The id of the variable inside the module. + mlds_data_name % The id of the variable inside the module. ). -:- type mlds__data == mlds__fully_qualified_name(mlds__data_name). +:- type mlds_data == mlds_fully_qualified_name(mlds_data_name). -:- type mlds__data_name - ---> var(mlds__var_name) +:- type mlds_data_name + ---> var(mlds_var_name) % Ordinary variables. ; common(int) @@ -1586,15 +1586,15 @@ ; module_layout % Layout information for the current module. - ; proc_layout(mlds__proc_label) + ; proc_layout(mlds_proc_label) % Layout structure for the given procedure. - ; internal_layout(mlds__proc_label, mlds__func_sequence_num) + ; internal_layout(mlds_proc_label, mlds_func_sequence_num) % Layout structure for the given internal MLDS func. % Stuff for tabling - ; tabling_pointer(mlds__proc_label). + ; tabling_pointer(mlds_proc_label). % A variable that contains a pointer that points to the table % used to implement memoization, loopcheck or minimal model % semantics for the given procedure. @@ -1613,7 +1613,7 @@ :- type mlds_tag == int. % see runtime/mercury_trail.h -:- type reset_trail_reason +:- type mlds_reset_trail_reason ---> undo ; commit ; solve @@ -1622,15 +1622,15 @@ %-----------------------------------------------------------------------------% -:- type mlds__qualified_proc_label - == mlds__fully_qualified_name(mlds__proc_label). -:- type mlds__proc_label - == pair(mlds__pred_label, proc_id). +:- type mlds_qualified_proc_label + == mlds_fully_qualified_name(mlds_proc_label). +:- type mlds_proc_label + == pair(mlds_pred_label, proc_id). -:- type mlds__qualified_pred_label - == mlds__fully_qualified_name(mlds__pred_label). +:- type mlds_qualified_pred_label + == mlds_fully_qualified_name(mlds_pred_label). - % An mlds__pred_label is a structure containing information that + % An mlds_pred_label is a structure containing information that % uniquely identifies a HLDS predicate within a given module. % % Note that a predicate can have both a declaring and a defining module. @@ -1639,7 +1639,7 @@ % When these are different, as for specialised versions of predicates % from `.opt' files, the defining module's name is added as a % qualifier to the pred name. -:- type mlds__pred_label +:- type mlds_pred_label ---> pred( pred_or_func, % predicate/function maybe(mercury_module_name), @@ -1695,18 +1695,18 @@ %-----------------------------------------------------------------------------% -mlds__get_module_name(mlds(ModuleName, _, _, _, _, _)) = ModuleName. +mlds_get_module_name(mlds(ModuleName, _, _, _, _, _)) = ModuleName. %-----------------------------------------------------------------------------% -% Currently mlds__contexts just contain a prog_context. +% Currently mlds_contexts just contain a prog_context. -:- type mlds__context - ---> mlds__context(prog_context). +:- type mlds_context + ---> mlds_context(prog_context). -mlds__make_context(Context) = mlds__context(Context). +mlds_make_context(Context) = mlds_context(Context). -mlds__get_prog_context(mlds__context(Context)) = Context. +mlds_get_prog_context(mlds_context(Context)) = Context. %-----------------------------------------------------------------------------% @@ -1724,23 +1724,23 @@ mercury_type_to_mlds_type(ModuleInfo, Type) = MLDSType :- TypeCtor = qualified(unqualified("array"), "array") - 1 -> MLDSElemType = mercury_type_to_mlds_type(ModuleInfo, ElemType), - MLDSType = mlds__mercury_array_type(MLDSElemType) + MLDSType = mlds_mercury_array_type(MLDSElemType) ; type_to_ctor_and_args(Type, TypeCtor, [RefType]), TypeCtor = qualified(mercury_private_builtin_module, "store_by_ref_type") - 1 -> MLDSRefType = mercury_type_to_mlds_type(ModuleInfo, RefType), - MLDSType = mlds__ptr_type(MLDSRefType) + MLDSType = mlds_ptr_type(MLDSRefType) ; type_to_ctor_and_args(Type, TypeCtor, _), module_info_get_type_table(ModuleInfo, Types), - map__search(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, Body), + map.search(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, Body), Body = foreign_type(foreign_type_body(MaybeIL, MaybeC, MaybeJava)) -> module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( Target = c, ( @@ -1791,7 +1791,7 @@ mercury_type_to_mlds_type(ModuleInfo, Type) = MLDSType :- "mercury_type_to_mlds_type: No C foreign type") ) ), - MLDSType = mlds__foreign_type(ForeignType) + MLDSType = mlds_foreign_type(ForeignType) ; classify_type(ModuleInfo, Type) = Category, ExportedType = to_exported_type(ModuleInfo, Type), @@ -1800,13 +1800,13 @@ mercury_type_to_mlds_type(ModuleInfo, Type) = MLDSType :- %-----------------------------------------------------------------------------% -mlds__get_func_signature(func_params(Parameters, RetTypes)) = - func_signature(ParamTypes, RetTypes) :- - ParamTypes = mlds__get_arg_types(Parameters). +mlds_get_func_signature(mlds_func_params(Parameters, RetTypes)) = + mlds_func_signature(ParamTypes, RetTypes) :- + ParamTypes = mlds_get_arg_types(Parameters). -mlds__get_arg_types(Parameters) = ArgTypes :- - GetArgType = (func(mlds__argument(_, Type, _)) = Type), - ArgTypes = list__map(GetArgType, Parameters). +mlds_get_arg_types(Parameters) = ArgTypes :- + GetArgType = (func(mlds_argument(_, Type, _)) = Type), + ArgTypes = list.map(GetArgType, Parameters). %-----------------------------------------------------------------------------% @@ -1819,11 +1819,11 @@ mlds__get_arg_types(Parameters) = ArgTypes :- % prefix e.g. `mercury.builtin', `mercury.io', `mercury.std_util', etc., % when mapped to MLDS package names. -% :- type mlds_module_name == prim_data__module_name. +% :- type mlds_module_name == prim_data.module_name. :- type mlds_module_name ---> name( - package_name :: prim_data__module_name, - module_name :: prim_data__module_name + package_name :: prim_data.module_name, + module_name :: prim_data.module_name ). mercury_module_and_package_name_to_mlds(MLDS_Package, MercuryModule) @@ -1851,13 +1851,13 @@ mlds_module_name_to_sym_name(Module) = Module ^ module_name. mlds_module_name_to_package_name(Module) = Module ^ package_name. -mlds__append_class_qualifier(name(Package, Module), QualKind, Globals, +mlds_append_class_qualifier(name(Package, Module), QualKind, Globals, ClassName, ClassArity) = name(Package, qualified(AdjustedModule, ClassQualifier)) :- % For the Java back-end, we flip the initial case of an type qualifiers, % in order to match the usual Java conventions. ( - globals__get_target(Globals, CompilationTarget), + globals.get_target(Globals, CompilationTarget), CompilationTarget = java, QualKind = type_qual -> @@ -1865,11 +1865,11 @@ mlds__append_class_qualifier(name(Package, Module), QualKind, Globals, ; AdjustedModule = Module ), - string__format("%s_%d", [s(ClassName), i(ClassArity)], ClassQualifier). + string.format("%s_%d", [s(ClassName), i(ClassArity)], ClassQualifier). -mlds__append_wrapper_class(Name) = mlds__append_name(Name, wrapper_class_name). +mlds_append_wrapper_class(Name) = mlds_append_name(Name, wrapper_class_name). -mlds__append_name(name(Package, Module), Name) +mlds_append_name(name(Package, Module), Name) = name(Package, qualified(Module, Name)). wrapper_class_name = "mercury_code". @@ -1881,15 +1881,15 @@ flip_initial_case_of_final_part(qualified(Qual, Name)) = % Invert the case of the first letter of the string. flip_initial_case(S0) = S :- - ( string__first_char(S0, First0, Rest) -> - ( char__is_upper(First0) -> - First = char__to_lower(First0) - ; char__is_lower(First0) -> - First = char__to_upper(First0) + ( string.first_char(S0, First0, Rest) -> + ( char.is_upper(First0) -> + First = char.to_lower(First0) + ; char.is_lower(First0) -> + First = char.to_upper(First0) ; First = First0 ), - string__first_char(S, First, Rest) + string.first_char(S, First, Rest) ; S = S0 ). @@ -1898,14 +1898,14 @@ flip_initial_case(S0) = S :- % We represent the set of declaration flags as a bunch of bit-fields packed % into a single int. -:- type mlds__decl_flags == int. +:- type mlds_decl_flags == int. % Here we define which bits are used to store each bitfield. % % It would be nicer to use a language builtin, e.g. index/2, for these. -% But currently builtin__index/2 does not work in the reverse mode, -% and you can't use std_util__construct/4 since that numbers the -% alternatives in a different order than builtin__index/2. +% But currently builtin.index/2 does not work in the reverse mode, +% and you can't use construct.construct/4 since that numbers the +% alternatives in a different order than builtin.index/2. % % It would also be nice to use a typeclass: % :- typeclass bitfield(T) where [ diff --git a/compiler/mlds_to_c.m b/compiler/mlds_to_c.m index df36d3711..8ebac1098 100644 --- a/compiler/mlds_to_c.m +++ b/compiler/mlds_to_c.m @@ -22,7 +22,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__mlds_to_c. +:- module ml_backend.mlds_to_c. :- interface. :- import_module ml_backend.mlds. @@ -37,7 +37,7 @@ % for debugging dumps. For normal output, the suffix should be the empty % string.) % -:- pred mlds_to_c__output_mlds(mlds::in, string::in, io::di, io::uo) is det. +:- pred output_mlds(mlds::in, string::in, io::di, io::uo) is det. % output_header_file(MLDS, Suffix): % @@ -45,7 +45,7 @@ % module to the appropriate .mih header file. See output_mlds for the % meaning of Suffix. % -:- pred mlds_to_c__output_header_file(mlds::in, string::in, +:- pred output_header_file(mlds::in, string::in, io::di, io::uo) is det. % output_c_file(MLDS, Suffix): @@ -53,13 +53,13 @@ % Output C code for the specified MLDS module to the appropriate C file. % See output_mlds for the meaning of Suffix. % -:- pred mlds_to_c__output_c_file(mlds::in, string::in, io::di, io::uo) is det. +:- pred output_c_file(mlds::in, string::in, io::di, io::uo) is det. % Output an MLDS context in C #line format. % This is useful for other foreign language interfaces such as % managed extensions for C++. % -:- pred mlds_to_c__output_context(mlds__context::in, io::di, io::uo) is det. +:- pred output_context(mlds_context::in, io::di, io::uo) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -109,7 +109,7 @@ %-----------------------------------------------------------------------------% -mlds_to_c__output_mlds(MLDS, Suffix, !IO) :- +output_mlds(MLDS, Suffix, !IO) :- % We output the source file before outputting the header, since the Mmake % dependencies say the header file depends on the source file, and so if % we wrote them out in the other order, this might lead to unnecessary @@ -121,21 +121,21 @@ mlds_to_c__output_mlds(MLDS, Suffix, !IO) :- output_c_file(MLDS, Suffix, !IO), output_header_file(MLDS, Suffix, !IO). -mlds_to_c__output_c_file(MLDS, Suffix, !IO) :- - ModuleName = mlds__get_module_name(MLDS), +output_c_file(MLDS, Suffix, !IO) :- + ModuleName = mlds_get_module_name(MLDS), module_name_to_file_name(ModuleName, ".c" ++ Suffix, yes, SourceFile, !IO), Indent = 0, output_to_file(SourceFile, mlds_output_src_file(Indent, MLDS), !IO). % Generate the header file. % -mlds_to_c__output_header_file(MLDS, Suffix, !IO) :- +output_header_file(MLDS, Suffix, !IO) :- % We write the header file out to .mih.tmp and then call % `update_interface' to move the .mih.tmp file to .mih; % this avoids updating the timestamp on the `.mih' file if it hasn't % changed. - ModuleName = mlds__get_module_name(MLDS), + ModuleName = mlds_get_module_name(MLDS), module_name_to_file_name(ModuleName, ".mih" ++ Suffix ++ ".tmp", yes, TmpHeaderFile, !IO), module_name_to_file_name(ModuleName, ".mih" ++ Suffix, yes, @@ -150,14 +150,14 @@ mlds_output_hdr_file(Indent, MLDS, !IO) :- MLDS = mlds(ModuleName, AllForeignCode, Imports, Defns, _InitPreds, _FinalPreds), mlds_output_hdr_start(Indent, ModuleName, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_hdr_imports(Indent, Imports, !IO), - io__nl(!IO), + io.nl(!IO), % Get the foreign code for C ForeignCode = mlds_get_c_foreign_code(AllForeignCode), mlds_output_c_hdr_decls(MLDS_ModuleName, Indent, ForeignCode, !IO), - io__nl(!IO), + io.nl(!IO), % The header file must contain _definitions_ of all public types, but only % _declarations_ of all public variables, constants, and functions. @@ -167,30 +167,30 @@ mlds_output_hdr_file(Indent, MLDS, !IO) :- % are generated by mlds_output_type_forward_decls. See the comment % in mlds_output_decl. - list__filter(defn_is_public, Defns, PublicDefns), - list__filter(defn_is_type, PublicDefns, PublicTypeDefns, + list.filter(defn_is_public, Defns, PublicDefns), + list.filter(defn_is_type, PublicDefns, PublicTypeDefns, PublicNonTypeDefns), MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName), mlds_output_defns(Indent, yes, MLDS_ModuleName, PublicTypeDefns, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_decls(Indent, MLDS_ModuleName, PublicNonTypeDefns, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_init_fn_decls(MLDS_ModuleName, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_hdr_end(Indent, ModuleName, !IO). -:- pred mlds_output_hdr_imports(indent::in, mlds__imports::in, +:- pred mlds_output_hdr_imports(indent::in, mlds_imports::in, io::di, io::uo) is det. % XXX currently we assume all imports are source imports, i.e. that the header % file does not depend on any types defined in other header files. mlds_output_hdr_imports(_Indent, _Imports, !IO). -:- pred mlds_output_src_imports(indent::in, mlds__imports::in, +:- pred mlds_output_src_imports(indent::in, mlds_imports::in, io::di, io::uo) is det. mlds_output_src_imports(Indent, Imports, !IO) :- - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( Target = asm -> % For --target asm, we don't create the header files for modules that % don't contain C code, so we'd better not include them, since they @@ -201,10 +201,10 @@ mlds_output_src_imports(Indent, Imports, !IO) :- % `pragma export') may not have been declared. true ; - list__foldl(mlds_output_src_import(Indent), Imports, !IO) + list.foldl(mlds_output_src_import(Indent), Imports, !IO) ). -:- pred mlds_output_src_import(indent::in, mlds__import::in, +:- pred mlds_output_src_import(indent::in, mlds_import::in, io::di, io::uo) is det. mlds_output_src_import(_Indent, Import, !IO) :- @@ -234,7 +234,7 @@ mlds_output_src_import(_Indent, Import, !IO) :- ), module_name_to_search_file_name(ModuleName, HeaderExt, HeaderFile, !IO), - io__write_strings(["#include """, HeaderFile, """\n"], !IO). + io.write_strings(["#include """, HeaderFile, """\n"], !IO). % Generate the `.c' file. % @@ -251,12 +251,12 @@ mlds_output_src_file(Indent, MLDS, !IO) :- ForeignCode = mlds_get_c_foreign_code(AllForeignCode), mlds_output_src_start(Indent, ModuleName, ForeignCode, InitPreds, FinalPreds, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_src_imports(Indent, Imports, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_c_decls(Indent, ForeignCode, !IO), - io__nl(!IO), + io.nl(!IO), % The public types have already been defined in the header file, and the % public vars, consts, and functions have already been declared in the @@ -275,28 +275,28 @@ mlds_output_src_file(Indent, MLDS, !IO) :- % are generated by mlds_output_type_forward_decls. See the comment in % mlds_output_decl. - list__filter(defn_is_public, Defns, _PublicDefns, PrivateDefns), - list__filter(defn_is_type, PrivateDefns, PrivateTypeDefns, + list.filter(defn_is_public, Defns, _PublicDefns, PrivateDefns), + list.filter(defn_is_type, PrivateDefns, PrivateTypeDefns, PrivateNonTypeDefns), - list__filter(defn_is_type, Defns, _TypeDefns, NonTypeDefns), - list__filter(defn_is_function, NonTypeDefns, FuncDefns), - list__filter(defn_is_type_ctor_info, NonTypeDefns, + list.filter(defn_is_type, Defns, _TypeDefns, NonTypeDefns), + list.filter(defn_is_function, NonTypeDefns, FuncDefns), + list.filter(defn_is_type_ctor_info, NonTypeDefns, TypeCtorInfoDefns), MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName), mlds_output_defns(Indent, yes, MLDS_ModuleName, PrivateTypeDefns, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_decls(Indent, MLDS_ModuleName, PrivateNonTypeDefns, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_c_defns(MLDS_ModuleName, Indent, ForeignCode, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_defns(Indent, yes, MLDS_ModuleName, NonTypeDefns, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_init_fn_defns(MLDS_ModuleName, FuncDefns, TypeCtorInfoDefns, !IO), - io__nl(!IO), + io.nl(!IO), mlds_output_grade_var(!IO), - io__nl(!IO), + io.nl(!IO), mlds_output_src_end(Indent, ModuleName, !IO). :- pred mlds_output_hdr_start(indent::in, mercury_module_name::in, @@ -305,57 +305,57 @@ mlds_output_src_file(Indent, MLDS, !IO) :- mlds_output_hdr_start(Indent, ModuleName, !IO) :- mlds_output_auto_gen_comment(ModuleName, !IO), mlds_indent(Indent, !IO), - io__write_string("/* :- module ", !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string(". */\n", !IO), + io.write_string("/* :- module ", !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string(". */\n", !IO), mlds_indent(Indent, !IO), - io__write_string("/* :- interface. */\n", !IO), - io__nl(!IO), + io.write_string("/* :- interface. */\n", !IO), + io.nl(!IO), mlds_indent(Indent, !IO), - io__write_string("#ifndef MR_HEADER_GUARD_", !IO), + io.write_string("#ifndef MR_HEADER_GUARD_", !IO), MangledModuleName = sym_name_mangle(ModuleName), - io__write_string(MangledModuleName, !IO), - io__nl(!IO), + io.write_string(MangledModuleName, !IO), + io.nl(!IO), mlds_indent(Indent, !IO), - io__write_string("#define MR_HEADER_GUARD_", !IO), - io__write_string(MangledModuleName, !IO), - io__nl(!IO), - io__nl(!IO), + io.write_string("#define MR_HEADER_GUARD_", !IO), + io.write_string(MangledModuleName, !IO), + io.nl(!IO), + io.nl(!IO), % If we're outputting C (rather than C++), then add a conditional % `extern "C"' wrapper around the header file, so that the header file % can be #included by C++ programs. - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( Target = c -> mlds_indent(Indent, !IO), - io__write_string("#ifdef __cplusplus\n", !IO), + io.write_string("#ifdef __cplusplus\n", !IO), mlds_indent(Indent, !IO), - io__write_string("extern ""C"" {\n", !IO), + io.write_string("extern ""C"" {\n", !IO), mlds_indent(Indent, !IO), - io__write_string("#endif\n", !IO), - io__nl(!IO) + io.write_string("#endif\n", !IO), + io.nl(!IO) ; true ), mlds_indent(Indent, !IO), - io__write_string("#include ""mercury.h""\n", !IO). + io.write_string("#include ""mercury.h""\n", !IO). :- pred mlds_output_src_start(indent::in, mercury_module_name::in, - mlds__foreign_code::in, list(string)::in, list(string)::in, + mlds_foreign_code::in, list(string)::in, list(string)::in, io::di, io::uo) is det. mlds_output_src_start(Indent, ModuleName, ForeignCode, InitPreds, FinalPreds, !IO) :- mlds_output_auto_gen_comment(ModuleName, !IO), mlds_indent(Indent, !IO), - io__write_string("/* :- module ", !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string(". */\n", !IO), + io.write_string("/* :- module ", !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string(". */\n", !IO), mlds_indent(Indent, !IO), - io__write_string("/* :- implementation. */\n", !IO), + io.write_string("/* :- implementation. */\n", !IO), mlds_output_src_bootstrap_defines(!IO), - io__nl(!IO), + io.nl(!IO), mlds_output_init_and_final_comments(ModuleName, InitPreds, FinalPreds, !IO), @@ -364,14 +364,14 @@ mlds_output_src_start(Indent, ModuleName, ForeignCode, InitPreds, FinalPreds, mercury_module_name_to_mlds(ModuleName)), !IO), % If there are `:- pragma export' declarations, #include the `.mh' file. - ( ForeignCode = mlds__foreign_code(_, _, _, []) -> + ( ForeignCode = mlds_foreign_code(_, _, _, []) -> true ; mlds_output_src_import(Indent, mercury_import(user_visible_interface, mercury_module_name_to_mlds(ModuleName)), !IO) ), - io__nl(!IO). + io.nl(!IO). % Output a comment to tell mkinit what module initialisation % predicates to call from _init.c. @@ -406,9 +406,9 @@ mlds_output_init_and_final_comments(ModuleName, is det. mlds_output_required_user_init_comment(CName, !IO) :- - io__write_string("REQUIRED_INIT ", !IO), - io__write_string(CName, !IO), - io__nl(!IO). + io.write_string("REQUIRED_INIT ", !IO), + io.write_string(CName, !IO), + io.nl(!IO). :- pred mlds_output_required_user_final_comment(string::in, io::di, io::uo) is det. @@ -427,37 +427,37 @@ mlds_output_src_bootstrap_defines(!IO). io::di, io::uo) is det. mlds_output_hdr_end(Indent, ModuleName, !IO) :- - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( Target = c -> % Terminate the `extern "C"' wrapper. mlds_indent(Indent, !IO), - io__write_string("#ifdef __cplusplus\n", !IO), + io.write_string("#ifdef __cplusplus\n", !IO), mlds_indent(Indent, !IO), - io__write_string("}\n", !IO), + io.write_string("}\n", !IO), mlds_indent(Indent, !IO), - io__write_string("#endif\n", !IO), - io__nl(!IO) + io.write_string("#endif\n", !IO), + io.nl(!IO) ; true ), mlds_indent(Indent, !IO), - io__write_string("#endif /* MR_HEADER_GUARD_", !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string(" */\n", !IO), - io__nl(!IO), + io.write_string("#endif /* MR_HEADER_GUARD_", !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string(" */\n", !IO), + io.nl(!IO), mlds_indent(Indent, !IO), - io__write_string("/* :- end_interface ", !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string(". */\n", !IO). + io.write_string("/* :- end_interface ", !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string(". */\n", !IO). :- pred mlds_output_src_end(indent::in, mercury_module_name::in, io::di, io::uo) is det. mlds_output_src_end(Indent, ModuleName, !IO) :- mlds_indent(Indent, !IO), - io__write_string("/* :- end_module ", !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string(". */\n", !IO). + io.write_string("/* :- end_module ", !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string(". */\n", !IO). % Output a C comment saying that the file was automatically generated % (and giving details such as the compiler version). @@ -465,10 +465,10 @@ mlds_output_src_end(Indent, ModuleName, !IO) :- :- pred mlds_output_auto_gen_comment(module_name::in, io::di, io::uo) is det. mlds_output_auto_gen_comment(ModuleName, !IO) :- - library__version(Version), + library.version(Version), module_name_to_file_name(ModuleName, ".m", no, SourceFileName, !IO), output_c_file_intro_and_grade(SourceFileName, Version, !IO), - io__nl(!IO). + io.nl(!IO). % Output a reference to the mangled grade name for the grade that the C % file gets compiled with. This ensures that we don't try to link objects @@ -477,25 +477,25 @@ mlds_output_auto_gen_comment(ModuleName, !IO) :- :- pred mlds_output_grade_var(io::di, io::uo) is det. mlds_output_grade_var(!IO) :- - io__write_string( + io.write_string( "/* ensure everything is compiled with the same grade */\n", !IO), - io__write_string( + io.write_string( "static const void *const MR_grade = &MR_GRADE_VAR;\n", !IO). % Get the foreign code for C. % -:- func mlds_get_c_foreign_code(map(foreign_language, mlds__foreign_code)) - = mlds__foreign_code. +:- func mlds_get_c_foreign_code(map(foreign_language, mlds_foreign_code)) + = mlds_foreign_code. mlds_get_c_foreign_code(AllForeignCode) = ForeignCode :- - ( map__search(AllForeignCode, c, ForeignCode0) -> + ( map.search(AllForeignCode, c, ForeignCode0) -> ForeignCode = ForeignCode0 ; % This can occur when compiling to a non-C target using % "--mlds-dump all". - ForeignCode = foreign_code([], [], [], []) + ForeignCode = mlds_foreign_code([], [], [], []) ). %-----------------------------------------------------------------------------% @@ -508,50 +508,50 @@ mlds_get_c_foreign_code(AllForeignCode) = ForeignCode :- mlds_output_init_fn_decls(ModuleName, !IO) :- output_init_fn_name(ModuleName, "", !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), output_init_fn_name(ModuleName, "_type_tables", !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), output_init_fn_name(ModuleName, "_debugger", !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). -:- pred mlds_output_init_fn_defns(mlds_module_name::in, mlds__defns::in, - mlds__defns::in, io::di, io::uo) is det. +:- pred mlds_output_init_fn_defns(mlds_module_name::in, mlds_defns::in, + mlds_defns::in, io::di, io::uo) is det. mlds_output_init_fn_defns(ModuleName, FuncDefns, TypeCtorInfoDefns, !IO) :- output_init_fn_name(ModuleName, "", !IO), - io__write_string("\n{\n", !IO), - globals__io_get_globals(Globals, !IO), + io.write_string("\n{\n", !IO), + globals.io_get_globals(Globals, !IO), ( need_to_init_entries(Globals), FuncDefns = [_ | _] -> - io__write_strings(["\tstatic MR_bool initialised = MR_FALSE;\n", + io.write_strings(["\tstatic MR_bool initialised = MR_FALSE;\n", "\tif (initialised) return;\n", "\tinitialised = MR_TRUE;\n\n"], !IO), mlds_output_calls_to_init_entry(ModuleName, FuncDefns, !IO) ; true ), - io__write_string("}\n\n", !IO), + io.write_string("}\n\n", !IO), output_init_fn_name(ModuleName, "_type_tables", !IO), - io__write_string("\n{\n", !IO), + io.write_string("\n{\n", !IO), ( TypeCtorInfoDefns = [_ | _], - io__write_strings(["\tstatic MR_bool initialised = MR_FALSE;\n", + io.write_strings(["\tstatic MR_bool initialised = MR_FALSE;\n", "\tif (initialised) return;\n", "\tinitialised = MR_TRUE;\n\n"], !IO), mlds_output_calls_to_register_tci(ModuleName, TypeCtorInfoDefns, !IO) ; TypeCtorInfoDefns = [] ), - io__write_string("}\n\n", !IO), + io.write_string("}\n\n", !IO), output_init_fn_name(ModuleName, "_debugger", !IO), - io__write_string("\n{\n", !IO), - io__write_string("\tMR_fatal_error(""debugger initialization " ++ + io.write_string("\n{\n", !IO), + io.write_string("\tMR_fatal_error(""debugger initialization " ++ "in MLDS grade"");\n", !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). :- pred output_init_fn_name(mlds_module_name::in, string::in, io::di, io::uo) is det. @@ -561,16 +561,16 @@ output_init_fn_name(ModuleName, Suffix, !IO) :- % of the function name. sym_name_to_string(mlds_module_name_to_sym_name(ModuleName), "__", ModuleNameString0), - ( string__prefix(ModuleNameString0, "mercury__") -> + ( string.prefix(ModuleNameString0, "mercury__") -> ModuleNameString = ModuleNameString0 ; ModuleNameString = "mercury__" ++ ModuleNameString0 ), - io__write_string("void ", !IO), - io__write_string(ModuleNameString, !IO), - io__write_string("__init", !IO), - io__write_string(Suffix, !IO), - io__write_string("(void)", !IO). + io.write_string("void ", !IO), + io.write_string(ModuleNameString, !IO), + io.write_string("__init", !IO), + io.write_string(Suffix, !IO), + io.write_string("(void)", !IO). :- pred need_to_init_entries(globals::in) is semidet. @@ -583,36 +583,36 @@ need_to_init_entries(Globals) :- ; Option = profile_time ; Option = profile_memory ), - globals__lookup_bool_option(Globals, Option, yes). + globals.lookup_bool_option(Globals, Option, yes). % Generate calls to MR_init_entry() for the specified functions. % -:- pred mlds_output_calls_to_init_entry(mlds_module_name::in, mlds__defns::in, +:- pred mlds_output_calls_to_init_entry(mlds_module_name::in, mlds_defns::in, io::di, io::uo) is det. mlds_output_calls_to_init_entry(_ModuleName, [], !IO). mlds_output_calls_to_init_entry(ModuleName, [FuncDefn | FuncDefns], !IO) :- - FuncDefn = mlds__defn(EntityName, _, _, _), - io__write_string("\tMR_init_entry(", !IO), + FuncDefn = mlds_defn(EntityName, _, _, _), + io.write_string("\tMR_init_entry(", !IO), mlds_output_fully_qualified_name(qual(ModuleName, module_qual, EntityName), !IO), - io__write_string(");\n", !IO), + io.write_string(");\n", !IO), mlds_output_calls_to_init_entry(ModuleName, FuncDefns, !IO). % Generate calls to MR_register_type_ctor_info() for the specified % type_ctor_infos. % :- pred mlds_output_calls_to_register_tci(mlds_module_name::in, - mlds__defns::in, io::di, io::uo) is det. + mlds_defns::in, io::di, io::uo) is det. mlds_output_calls_to_register_tci(_ModuleName, [], !IO). mlds_output_calls_to_register_tci(ModuleName, [TypeCtorInfoDefn | TypeCtorInfoDefns], !IO) :- - TypeCtorInfoDefn = mlds__defn(EntityName, _, _, _), - io__write_string("\tMR_register_type_ctor_info(&", !IO), + TypeCtorInfoDefn = mlds_defn(EntityName, _, _, _), + io.write_string("\tMR_register_type_ctor_info(&", !IO), mlds_output_fully_qualified_name(qual(ModuleName, module_qual, EntityName), !IO), - io__write_string(");\n", !IO), + io.write_string(");\n", !IO), mlds_output_calls_to_register_tci(ModuleName, TypeCtorInfoDefns, !IO). %-----------------------------------------------------------------------------% @@ -621,23 +621,23 @@ mlds_output_calls_to_register_tci(ModuleName, % :- pred mlds_output_c_hdr_decls(mlds_module_name::in, indent::in, - mlds__foreign_code::in, io::di, io::uo) is det. + mlds_foreign_code::in, io::di, io::uo) is det. mlds_output_c_hdr_decls(ModuleName, Indent, ForeignCode, !IO) :- - ForeignCode = mlds__foreign_code(RevHeaderCode, _RevImports, + ForeignCode = mlds_foreign_code(RevHeaderCode, _RevImports, _RevBodyCode, _ExportDefns), - HeaderCode = list__reverse(RevHeaderCode), + HeaderCode = list.reverse(RevHeaderCode), ( is_std_lib_module(ModuleName, ModuleNameStr) -> SymName = unqualified(ModuleNameStr) ; SymName = mlds_module_name_to_sym_name(ModuleName) ), DeclGuard = decl_guard(SymName), - io__write_strings(["#ifndef ", DeclGuard, "\n#define ", DeclGuard, "\n"], + io.write_strings(["#ifndef ", DeclGuard, "\n#define ", DeclGuard, "\n"], !IO), - io__write_list(HeaderCode, "\n", + io.write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent, yes(foreign_decl_is_exported)), !IO), - io__write_string("\n#endif\n", !IO). + io.write_string("\n#endif\n", !IO). :- pred mlds_output_c_hdr_decl(indent::in, maybe(foreign_decl_is_local)::in, foreign_decl_code::in, io::di, io::uo) is det. @@ -654,8 +654,8 @@ mlds_output_c_hdr_decl(_Indent, MaybeDesiredIsLocal, DeclCode, !IO) :- IsLocal = DesiredIsLocal ) -> - mlds_to_c__output_context(mlds__make_context(Context), !IO), - io__write_string(Code, !IO) + output_context(mlds_make_context(Context), !IO), + io.write_string(Code, !IO) ; true ) @@ -663,28 +663,28 @@ mlds_output_c_hdr_decl(_Indent, MaybeDesiredIsLocal, DeclCode, !IO) :- sorry(this_file, "foreign code other than C") ). -:- pred mlds_output_c_decls(indent::in, mlds__foreign_code::in, +:- pred mlds_output_c_decls(indent::in, mlds_foreign_code::in, io::di, io::uo) is det. mlds_output_c_decls(Indent, ForeignCode, !IO) :- - ForeignCode = mlds__foreign_code(RevHeaderCode, _RevImports, + ForeignCode = mlds_foreign_code(RevHeaderCode, _RevImports, _RevBodyCode, _ExportDefns), - HeaderCode = list__reverse(RevHeaderCode), - io__write_list(HeaderCode, "\n", + HeaderCode = list.reverse(RevHeaderCode), + io.write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent, yes(foreign_decl_is_local)), !IO). :- pred mlds_output_c_defns(mlds_module_name::in, indent::in, - mlds__foreign_code::in, io::di, io::uo) is det. + mlds_foreign_code::in, io::di, io::uo) is det. mlds_output_c_defns(ModuleName, Indent, ForeignCode, !IO) :- - ForeignCode = mlds__foreign_code(_RevHeaderCode, RevImports, + ForeignCode = mlds_foreign_code(_RevHeaderCode, RevImports, RevBodyCode, ExportDefns), - Imports = list__reverse(RevImports), - list__foldl(mlds_output_c_foreign_import_module(Indent), Imports, !IO), - BodyCode = list__reverse(RevBodyCode), - io__write_list(BodyCode, "\n", mlds_output_c_defn(Indent), !IO), - io__write_string("\n", !IO), - io__write_list(ExportDefns, "\n", + Imports = list.reverse(RevImports), + list.foldl(mlds_output_c_foreign_import_module(Indent), Imports, !IO), + BodyCode = list.reverse(RevBodyCode), + io.write_list(BodyCode, "\n", mlds_output_c_defn(Indent), !IO), + io.write_string("\n", !IO), + io.write_list(ExportDefns, "\n", mlds_output_pragma_export_defn(ModuleName, Indent), !IO). :- pred mlds_output_c_foreign_import_module(int::in, foreign_import_module::in, @@ -704,8 +704,8 @@ mlds_output_c_foreign_import_module(Indent, ForeignImport, !IO) :- io::di, io::uo) is det. mlds_output_c_defn(_Indent, user_foreign_code(c, Code, Context), !IO) :- - mlds_to_c__output_context(mlds__make_context(Context), !IO), - io__write_string(Code, !IO). + output_context(mlds_make_context(Context), !IO), + io.write_string(Code, !IO). mlds_output_c_defn(_Indent, user_foreign_code(managed_cplusplus, _, _), !IO) :- sorry(this_file, "foreign code other than C"). mlds_output_c_defn(_Indent, user_foreign_code(csharp, _, _), !IO) :- @@ -716,22 +716,22 @@ mlds_output_c_defn(_Indent, user_foreign_code(java, _, _), !IO) :- sorry(this_file, "foreign code other than C"). :- pred mlds_output_pragma_export_defn(mlds_module_name::in, indent::in, - mlds__pragma_export::in, io::di, io::uo) is det. + mlds_pragma_export::in, io::di, io::uo) is det. mlds_output_pragma_export_defn(ModuleName, Indent, PragmaExport, !IO) :- PragmaExport = ml_pragma_export(_C_name, MLDS_Name, MLDS_Signature, Context), mlds_output_pragma_export_func_name(ModuleName, Indent, PragmaExport, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), mlds_indent(Context, Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), mlds_indent(Context, Indent, !IO), mlds_output_pragma_export_defn_body(ModuleName, MLDS_Name, MLDS_Signature, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). :- pred mlds_output_pragma_export_func_name(mlds_module_name::in, indent::in, - mlds__pragma_export::in, io::di, io::uo) is det. + mlds_pragma_export::in, io::di, io::uo) is det. mlds_output_pragma_export_func_name(ModuleName, Indent, Export, !IO) :- Export = ml_pragma_export(C_name, _MLDS_Name, Signature, Context), @@ -759,27 +759,27 @@ mlds_output_pragma_export_type(Type, !IO) :- io::di, io::uo) is det. mlds_output_pragma_export_type(suffix, _Type, !IO). -mlds_output_pragma_export_type(prefix, mercury_array_type(_ElemType), !IO) :- - io__write_string("MR_ArrayPtr", !IO). +mlds_output_pragma_export_type(prefix, mlds_mercury_array_type(_ElemType), !IO) :- + io.write_string("MR_ArrayPtr", !IO). mlds_output_pragma_export_type(prefix, mercury_type(_, _, ExportedType), !IO) :- - io__write_string(foreign__to_type_string(c, ExportedType), !IO). -mlds_output_pragma_export_type(prefix, mlds__cont_type(_), !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__commit_type, !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__native_bool_type, !IO) :- - io__write_string("MR_bool", !IO). -mlds_output_pragma_export_type(prefix, mlds__native_int_type, !IO) :- - io__write_string("MR_Integer", !IO). -mlds_output_pragma_export_type(prefix, mlds__native_float_type, !IO) :- - io__write_string("MR_Float", !IO). -mlds_output_pragma_export_type(prefix, mlds__native_char_type, !IO) :- - io__write_string("MR_Char", !IO). -mlds_output_pragma_export_type(prefix, mlds__foreign_type(ForeignType), !IO) :- + io.write_string(foreign.to_type_string(c, ExportedType), !IO). +mlds_output_pragma_export_type(prefix, mlds_cont_type(_), !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_commit_type, !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_native_bool_type, !IO) :- + io.write_string("MR_bool", !IO). +mlds_output_pragma_export_type(prefix, mlds_native_int_type, !IO) :- + io.write_string("MR_Integer", !IO). +mlds_output_pragma_export_type(prefix, mlds_native_float_type, !IO) :- + io.write_string("MR_Float", !IO). +mlds_output_pragma_export_type(prefix, mlds_native_char_type, !IO) :- + io.write_string("MR_Char", !IO). +mlds_output_pragma_export_type(prefix, mlds_foreign_type(ForeignType), !IO) :- ( ForeignType = c(c(Name)), - io__write_string(Name, !IO) + io.write_string(Name, !IO) ; ForeignType = il(_), unexpected(this_file, "mlds_output_type_prefix: il foreign_type") @@ -787,65 +787,65 @@ mlds_output_pragma_export_type(prefix, mlds__foreign_type(ForeignType), !IO) :- ForeignType = java(_), unexpected(this_file, "mlds_output_type_prefix: java foreign_type") ). -mlds_output_pragma_export_type(prefix, mlds__class_type(_, _, _), !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__array_type(_), !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__ptr_type(Type), !IO) :- +mlds_output_pragma_export_type(prefix, mlds_class_type(_, _, _), !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_array_type(_), !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_ptr_type(Type), !IO) :- mlds_output_pragma_export_type(prefix, Type, !IO), - io__write_string(" *", !IO). -mlds_output_pragma_export_type(prefix, mlds__func_type(_), !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__generic_type, !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__generic_env_ptr_type, !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__type_info_type, !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__pseudo_type_info_type, !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__rtti_type(_), !IO) :- - io__write_string("MR_Word", !IO). -mlds_output_pragma_export_type(prefix, mlds__unknown_type, !IO) :- + io.write_string(" *", !IO). +mlds_output_pragma_export_type(prefix, mlds_func_type(_), !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_generic_type, !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_generic_env_ptr_type, !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_type_info_type, !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_pseudo_type_info_type, !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_rtti_type(_), !IO) :- + io.write_string("MR_Word", !IO). +mlds_output_pragma_export_type(prefix, mlds_unknown_type, !IO) :- unexpected(this_file, "mlds_output_pragma_export_type: unknown_type"). % Output the definition body for a pragma export % :- pred mlds_output_pragma_export_defn_body(mlds_module_name::in, - mlds__qualified_entity_name::in, func_params::in, io::di, io::uo) + mlds_qualified_entity_name::in, mlds_func_params::in, io::di, io::uo) is det. mlds_output_pragma_export_defn_body(ModuleName, FuncName, Signature, !IO) :- - Signature = mlds__func_params(Parameters, RetTypes), + Signature = mlds_func_params(Parameters, RetTypes), % Declare local variables corresponding to any foreign_type % parameters. IsCForeignType = (pred(Arg::in) is semidet :- - Arg = mlds__argument(_Name, Type, _GCTraceCode), - Type = mlds__foreign_type(c(_))), + Arg = mlds_argument(_Name, Type, _GCTraceCode), + Type = mlds_foreign_type(c(_))), IsCForeignTypePtr = (pred(Arg::in) is semidet :- - Arg = mlds__argument(_Name, Type, _GCTraceCode), - Type = mlds__ptr_type(mlds__foreign_type(c(_)))), - CForeignTypeInputs = list__filter(IsCForeignType, Parameters), - CForeignTypeOutputs = list__filter(IsCForeignTypePtr, Parameters), - io__write_list(CForeignTypeInputs, "", + Arg = mlds_argument(_Name, Type, _GCTraceCode), + Type = mlds_ptr_type(mlds_foreign_type(c(_)))), + CForeignTypeInputs = list.filter(IsCForeignType, Parameters), + CForeignTypeOutputs = list.filter(IsCForeignTypePtr, Parameters), + io.write_list(CForeignTypeInputs, "", mlds_output_pragma_export_input_defns(ModuleName), !IO), - io__write_list(CForeignTypeOutputs, "", + io.write_list(CForeignTypeOutputs, "", mlds_output_pragma_export_output_defns(ModuleName), !IO), % Declare a local variable or two for the return value, if needed ( RetTypes = [RetType1] -> - ( RetType1 = mlds__foreign_type(c(_)) -> - io__write_string("\t", !IO), + ( RetType1 = mlds_foreign_type(c(_)) -> + io.write_string("\t", !IO), mlds_output_pragma_export_type(RetType1, !IO), - io__write_string(" ret_value;\n", !IO), - io__write_string("\t", !IO), + io.write_string(" ret_value;\n", !IO), + io.write_string("\t", !IO), mlds_output_type(RetType1, !IO), - io__write_string(" boxed_ret_value;\n", !IO) + io.write_string(" boxed_ret_value;\n", !IO) ; - io__write_string("\t", !IO), + io.write_string("\t", !IO), mlds_output_pragma_export_type(RetType1, !IO), - io__write_string(" ret_value;\n", !IO) + io.write_string(" ret_value;\n", !IO) ) ; true @@ -854,148 +854,148 @@ mlds_output_pragma_export_defn_body(ModuleName, FuncName, Signature, !IO) :- % Generate code to box any non-word-sized foreign_type input parameters; % these need to be converted to a uniform size before passing them % to Mercury code. - io__write_list(CForeignTypeInputs, "", + io.write_list(CForeignTypeInputs, "", mlds_output_pragma_input_arg(ModuleName), !IO), % Generate code to actually call the Mercury procedure which % is being exported ( RetTypes = [] -> - io__write_string("\t", !IO), + io.write_string("\t", !IO), mlds_output_pragma_export_call(ModuleName, FuncName, Parameters, !IO) ; RetTypes = [RetType2] -> - ( RetType2 = mlds__foreign_type(c(_)) -> - io__write_string("\tboxed_ret_value = ", !IO) + ( RetType2 = mlds_foreign_type(c(_)) -> + io.write_string("\tboxed_ret_value = ", !IO) ; - io__write_string("\tret_value = (", !IO), + io.write_string("\tret_value = (", !IO), mlds_output_pragma_export_type(RetType2, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ), mlds_output_pragma_export_call(ModuleName, FuncName, Parameters, !IO) ; % This is just for MLDS dumps when compiling to non-C targets. % So we don't need to worry about boxing/unboxing foreign types % here. - io__write_string("\treturn (", !IO), + io.write_string("\treturn (", !IO), mlds_output_return_list(RetTypes, mlds_output_pragma_export_type, !IO), - io__write_string(") ", !IO) + io.write_string(") ", !IO) ), % Generate code to unbox any foreign_type output parameters, % since we are returning those parameters to C code. - io__write_list(CForeignTypeOutputs, "", + io.write_list(CForeignTypeOutputs, "", mlds_output_pragma_output_arg(ModuleName), !IO), % Generate the final statement to unbox and return the % return value, if needed. ( RetTypes = [RetType3] -> - ( RetType3 = mlds__foreign_type(c(_)) -> - io__write_string("\tMR_MAYBE_UNBOX_FOREIGN_TYPE(", !IO), + ( RetType3 = mlds_foreign_type(c(_)) -> + io.write_string("\tMR_MAYBE_UNBOX_FOREIGN_TYPE(", !IO), mlds_output_pragma_export_type(RetType3, !IO), - io__write_string(", boxed_ret_value, ret_value);\n", !IO) + io.write_string(", boxed_ret_value, ret_value);\n", !IO) ; true ), - io__write_string("\treturn ret_value;\n", !IO) + io.write_string("\treturn ret_value;\n", !IO) ; true ). -:- pred mlds_output_pragma_input_arg(mlds_module_name::in, mlds__argument::in, +:- pred mlds_output_pragma_input_arg(mlds_module_name::in, mlds_argument::in, io::di, io::uo) is det. mlds_output_pragma_input_arg(ModuleName, Arg, !IO) :- - Arg = mlds__argument(Name, Type, _GC_TraceCode), + Arg = mlds_argument(Name, Type, _GC_TraceCode), QualName = qual(ModuleName, module_qual, Name), BoxedQualName = qual(ModuleName, module_qual, boxed_name(Name)), - io__write_string("\tMR_MAYBE_BOX_FOREIGN_TYPE(", !IO), + io.write_string("\tMR_MAYBE_BOX_FOREIGN_TYPE(", !IO), mlds_output_pragma_export_type(Type, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_fully_qualified_name(QualName, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_fully_qualified_name(BoxedQualName, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). -:- pred mlds_output_pragma_output_arg(mlds_module_name::in, mlds__argument::in, +:- pred mlds_output_pragma_output_arg(mlds_module_name::in, mlds_argument::in, io::di, io::uo) is det. mlds_output_pragma_output_arg(ModuleName, Arg, !IO) :- - Arg = mlds__argument(Name, Type, _GC_TraceCode), + Arg = mlds_argument(Name, Type, _GC_TraceCode), QualName = qual(ModuleName, module_qual, Name), BoxedQualName = qual(ModuleName, module_qual, boxed_name(Name)), - io__write_string("\tMR_MAYBE_UNBOX_FOREIGN_TYPE(", !IO), + io.write_string("\tMR_MAYBE_UNBOX_FOREIGN_TYPE(", !IO), mlds_output_pragma_export_type(pointed_to_type(Type), !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_fully_qualified_name(BoxedQualName, !IO), - io__write_string(", *", !IO), + io.write_string(", *", !IO), mlds_output_fully_qualified_name(QualName, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). :- pred mlds_output_pragma_export_input_defns(mlds_module_name::in, - mlds__argument::in, io::di, io::uo) is det. + mlds_argument::in, io::di, io::uo) is det. mlds_output_pragma_export_input_defns(ModuleName, Arg, !IO) :- - Arg = mlds__argument(Name, Type, _GC_TraceCode), - io__write_string("\t", !IO), + Arg = mlds_argument(Name, Type, _GC_TraceCode), + io.write_string("\t", !IO), mlds_output_data_decl_ho(mlds_output_type_prefix, mlds_output_type_suffix, qual(ModuleName, module_qual, boxed_name(Name)), Type, !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). :- pred mlds_output_pragma_export_output_defns(mlds_module_name::in, - mlds__argument::in, io::di, io::uo) is det. + mlds_argument::in, io::di, io::uo) is det. mlds_output_pragma_export_output_defns(ModuleName, Arg, !IO) :- - Arg = mlds__argument(Name, Type, _GC_TraceCode), - io__write_string("\t", !IO), + Arg = mlds_argument(Name, Type, _GC_TraceCode), + io.write_string("\t", !IO), mlds_output_data_decl_ho(mlds_output_type_prefix, mlds_output_type_suffix, qual(ModuleName, module_qual, boxed_name(Name)), pointed_to_type(Type), !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). :- func pointed_to_type(mlds_type) = mlds_type. pointed_to_type(PtrType) = - ( PtrType = mlds__ptr_type(Type) -> + ( PtrType = mlds_ptr_type(Type) -> Type ; unexpected(this_file, "pointed_to_type: not pointer") ). -:- func boxed_name(mlds__entity_name) = mlds__entity_name. +:- func boxed_name(mlds_entity_name) = mlds_entity_name. boxed_name(Name) = BoxedName :- - ( Name = data(var(var_name(VarName, Seq))) -> - BoxedName = data(var(var_name("boxed_" ++ VarName, Seq))) + ( Name = data(var(mlds_var_name(VarName, Seq))) -> + BoxedName = data(var(mlds_var_name("boxed_" ++ VarName, Seq))) ; unexpected(this_file, "boxed_name called for non-var argument") ). :- pred mlds_output_pragma_export_call(mlds_module_name::in, - mlds__qualified_entity_name::in, mlds__arguments::in, + mlds_qualified_entity_name::in, mlds_arguments::in, io::di, io::uo) is det. mlds_output_pragma_export_call(ModuleName, FuncName, Parameters, !IO) :- mlds_output_fully_qualified_name(FuncName, !IO), - io__write_string("(", !IO), - io__write_list(Parameters, ", ", mlds_output_pragma_export_arg(ModuleName), + io.write_string("(", !IO), + io.write_list(Parameters, ", ", mlds_output_pragma_export_arg(ModuleName), !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). % Output a fully qualified name preceded by a cast. % -:- pred mlds_output_pragma_export_arg(mlds_module_name::in, mlds__argument::in, +:- pred mlds_output_pragma_export_arg(mlds_module_name::in, mlds_argument::in, io::di, io::uo) is det. mlds_output_pragma_export_arg(ModuleName, Arg, !IO) :- - Arg = mlds__argument(Name, Type, _GC_TraceCode), - ( Type = mlds__foreign_type(c(_)) -> + Arg = mlds_argument(Name, Type, _GC_TraceCode), + ( Type = mlds_foreign_type(c(_)) -> % This is a foreign_type input. Pass in the already-boxed value. BoxedName = boxed_name(Name), mlds_output_fully_qualified_name( qual(ModuleName, module_qual, BoxedName), !IO) - ; Type = mlds__ptr_type(mlds__foreign_type(c(_))) -> + ; Type = mlds_ptr_type(mlds_foreign_type(c(_))) -> % This is a foreign_type output. Pass in the address of the % local variable which will hold the boxed value. - io__write_string("&", !IO), + io.write_string("&", !IO), BoxedName = boxed_name(Name), mlds_output_fully_qualified_name( qual(ModuleName, module_qual, BoxedName), !IO) @@ -1009,12 +1009,12 @@ mlds_output_pragma_export_arg(ModuleName, Arg, !IO) :- % Generates the signature for det functions in the forward mode. % -:- func det_func_signature(mlds__func_params) = mlds__func_params. +:- func det_func_signature(mlds_func_params) = mlds_func_params. -det_func_signature(mlds__func_params(Args, _RetTypes)) = Params :- - list__length(Args, NumArgs), +det_func_signature(mlds_func_params(Args, _RetTypes)) = Params :- + list.length(Args, NumArgs), NumFuncArgs = NumArgs - 1, - ( list__split_list(NumFuncArgs, Args, InputArgs0, [ReturnArg0]) -> + ( list.split_list(NumFuncArgs, Args, InputArgs0, [ReturnArg0]) -> InputArgs = InputArgs0, ReturnArg = ReturnArg0 ; @@ -1022,58 +1022,58 @@ det_func_signature(mlds__func_params(Args, _RetTypes)) = Params :- "det_func_signature: function missing return value?") ), ( - ReturnArg = mlds__argument(_ReturnArgName, - mlds__ptr_type(ReturnArgType0), _GC_TraceCode) + ReturnArg = mlds_argument(_ReturnArgName, + mlds_ptr_type(ReturnArgType0), _GC_TraceCode) -> ReturnArgType = ReturnArgType0 ; unexpected(this_file, "det_func_signature: function return type!") ), - Params = mlds__func_params(InputArgs, [ReturnArgType]). + Params = mlds_func_params(InputArgs, [ReturnArgType]). %-----------------------------------------------------------------------------% % % Code to output declarations and definitions % -:- pred mlds_output_decls(indent::in, mlds_module_name::in, mlds__defns::in, +:- pred mlds_output_decls(indent::in, mlds_module_name::in, mlds_defns::in, io::di, io::uo) is det. mlds_output_decls(Indent, ModuleName, Defns, !IO) :- - list__foldl(mlds_output_decl(Indent, ModuleName), Defns, !IO). + list.foldl(mlds_output_decl(Indent, ModuleName), Defns, !IO). :- pred mlds_output_defns(indent::in, bool::in, mlds_module_name::in, - mlds__defns::in, io::di, io::uo) is det. + mlds_defns::in, io::di, io::uo) is det. mlds_output_defns(Indent, Separate, ModuleName, Defns, !IO) :- OutputDefn = mlds_output_defn(Indent, Separate, ModuleName), - globals__io_lookup_bool_option(gcc_local_labels, GCC_LocalLabels, !IO), + globals.io_lookup_bool_option(gcc_local_labels, GCC_LocalLabels, !IO), ( GCC_LocalLabels = yes, % GNU C __label__ declarations must precede ordinary variable % declarations. - list__filter(defn_is_commit_type_var, Defns, LabelDecls, OtherDefns), - list__foldl(OutputDefn, LabelDecls, !IO), - list__foldl(OutputDefn, OtherDefns, !IO) + list.filter(defn_is_commit_type_var, Defns, LabelDecls, OtherDefns), + list.foldl(OutputDefn, LabelDecls, !IO), + list.foldl(OutputDefn, OtherDefns, !IO) ; GCC_LocalLabels = no, - list__foldl(OutputDefn, Defns, !IO) + list.foldl(OutputDefn, Defns, !IO) ). -:- pred mlds_output_decl(indent::in, mlds_module_name::in, mlds__defn::in, +:- pred mlds_output_decl(indent::in, mlds_module_name::in, mlds_defn::in, io::di, io::uo) is det. mlds_output_decl(Indent, ModuleName, Defn, !IO) :- - Defn = mlds__defn(Name, Context, Flags, DefnBody), + Defn = mlds_defn(Name, Context, Flags, DefnBody), ( % ANSI C does not permit forward declarations of enumeration types. % So we just skip those. Currently they're not needed since we don't % actually use the enum types. - DefnBody = mlds__class(ClassDefn), - ClassDefn ^ kind = mlds__enum + DefnBody = mlds_class(ClassDefn), + ClassDefn ^ kind = mlds_enum -> true ; @@ -1091,19 +1091,19 @@ mlds_output_decl(Indent, ModuleName, Defn, !IO) :- % the type declarations in a different header file than the function % declarations). - globals__io_lookup_bool_option(highlevel_data, HighLevelData, !IO), + globals.io_lookup_bool_option(highlevel_data, HighLevelData, !IO), ( HighLevelData = yes, - DefnBody = mlds__function(_, Params, _, _) + DefnBody = mlds_function(_, Params, _, _) -> - Params = mlds__func_params(Arguments, _RetTypes), - ParamTypes = mlds__get_arg_types(Arguments), + Params = mlds_func_params(Arguments, _RetTypes), + ParamTypes = mlds_get_arg_types(Arguments), mlds_output_type_forward_decls(Indent, ParamTypes, !IO) ; true ), - % Now output the declaration for this mlds__defn. + % Now output the declaration for this mlds_defn. mlds_indent(Context, Indent, !IO), mlds_output_decl_flags(Flags, forward_decl, Name, DefnBody, !IO), mlds_output_decl_body(Indent, qual(ModuleName, module_qual, Name), @@ -1129,7 +1129,7 @@ mlds_output_type_forward_decls(Indent, ParamTypes, !IO) :- is nondet. mlds_type_list_contains_type(Types, SubType) :- - list__member(Type, Types), + list.member(Type, Types), mlds_type_contains_type(Type, SubType). % mlds_type_contains_type(Type, SubType): @@ -1139,13 +1139,13 @@ mlds_type_list_contains_type(Types, SubType) :- :- pred mlds_type_contains_type(mlds_type::in, mlds_type::out) is multi. mlds_type_contains_type(Type, Type). -mlds_type_contains_type(mlds__mercury_array_type(Type), Type). -mlds_type_contains_type(mlds__array_type(Type), Type). -mlds_type_contains_type(mlds__ptr_type(Type), Type). -mlds_type_contains_type(mlds__func_type(Parameters), Type) :- - Parameters = mlds__func_params(Arguments, RetTypes), - ( list__member(mlds__argument(_Name, Type, _GC_TraceCode), Arguments) - ; list__member(Type, RetTypes) +mlds_type_contains_type(mlds_mercury_array_type(Type), Type). +mlds_type_contains_type(mlds_array_type(Type), Type). +mlds_type_contains_type(mlds_ptr_type(Type), Type). +mlds_type_contains_type(mlds_func_type(Parameters), Type) :- + Parameters = mlds_func_params(Arguments, RetTypes), + ( list.member(mlds_argument(_Name, Type, _GC_TraceCode), Arguments) + ; list.member(Type, RetTypes) ). :- pred mlds_output_type_forward_decl(indent::in, mlds_type::in, @@ -1154,32 +1154,32 @@ mlds_type_contains_type(mlds__func_type(Parameters), Type) :- mlds_output_type_forward_decl(Indent, Type, !IO) :- ( ( - Type = mlds__class_type(_Name, _Arity, Kind), - Kind \= mlds__enum, + Type = mlds_class_type(_Name, _Arity, Kind), + Kind \= mlds_enum, ClassType = Type ; Type = mercury_type(MercuryType, type_cat_user_ctor, _), type_to_ctor_and_args(MercuryType, TypeCtor, _ArgsTypes), ml_gen_type_name(TypeCtor, ClassName, ClassArity), - ClassType = mlds__class_type(ClassName, ClassArity, mlds__class) + ClassType = mlds_class_type(ClassName, ClassArity, mlds_class) ) -> mlds_indent(Indent, !IO), mlds_output_type(ClassType, !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ; true ). :- pred mlds_output_defn(indent::in, bool::in, mlds_module_name::in, - mlds__defn::in, io::di, io::uo) is det. + mlds_defn::in, io::di, io::uo) is det. mlds_output_defn(Indent, Separate, ModuleName, Defn, !IO) :- - Defn = mlds__defn(Name, Context, Flags, DefnBody), - ( DefnBody \= mlds__data(_, _, _) -> - io__nl(!IO) + Defn = mlds_defn(Name, Context, Flags, DefnBody), + ( DefnBody \= mlds_data(_, _, _) -> + io.nl(!IO) ; Separate = yes -> - io__nl(!IO) + io.nl(!IO) ; true ), @@ -1188,46 +1188,46 @@ mlds_output_defn(Indent, Separate, ModuleName, Defn, !IO) :- mlds_output_defn_body(Indent, qual(ModuleName, module_qual, Name), Context, DefnBody, !IO). -:- pred mlds_output_decl_body(indent::in, mlds__qualified_entity_name::in, - mlds__context::in, mlds__entity_defn::in, io::di, io::uo) is det. +:- pred mlds_output_decl_body(indent::in, mlds_qualified_entity_name::in, + mlds_context::in, mlds_entity_defn::in, io::di, io::uo) is det. mlds_output_decl_body(Indent, Name, Context, DefnBody, !IO) :- ( - DefnBody = mlds__data(Type, Initializer, _GC_TraceCode), + DefnBody = mlds_data(Type, Initializer, _GC_TraceCode), mlds_output_data_decl(Name, Type, initializer_array_size(Initializer), !IO) ; - DefnBody = mlds__function(MaybePredProcId, Signature, + DefnBody = mlds_function(MaybePredProcId, Signature, _MaybeBody, _Attrs), mlds_output_maybe(MaybePredProcId, mlds_output_pred_proc_id, !IO), mlds_output_func_decl(Indent, Name, Context, Signature, !IO) ; - DefnBody = mlds__class(ClassDefn), + DefnBody = mlds_class(ClassDefn), mlds_output_class_decl(Indent, Name, ClassDefn, !IO) ), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). -:- pred mlds_output_defn_body(indent::in, mlds__qualified_entity_name::in, - mlds__context::in, mlds__entity_defn::in, io::di, io::uo) is det. +:- pred mlds_output_defn_body(indent::in, mlds_qualified_entity_name::in, + mlds_context::in, mlds_entity_defn::in, io::di, io::uo) is det. mlds_output_defn_body(Indent, Name, Context, DefnBody, !IO) :- ( - DefnBody = mlds__data(Type, Initializer, Maybe_GC_TraceCode), + DefnBody = mlds_data(Type, Initializer, Maybe_GC_TraceCode), mlds_output_data_defn(Name, Type, Initializer, !IO), mlds_output_maybe_gc_trace_code(Indent, Name, Maybe_GC_TraceCode, "", !IO) ; - DefnBody = mlds__function(MaybePredProcId, Signature, + DefnBody = mlds_function(MaybePredProcId, Signature, MaybeBody, _Attributes), mlds_output_maybe(MaybePredProcId, mlds_output_pred_proc_id, !IO), mlds_output_func(Indent, Name, Context, Signature, MaybeBody, !IO) ; - DefnBody = mlds__class(ClassDefn), + DefnBody = mlds_class(ClassDefn), mlds_output_class(Indent, Name, Context, ClassDefn, !IO) ). :- pred mlds_output_maybe_gc_trace_code(indent::in, - mlds__qualified_entity_name::in, maybe(statement)::in, + mlds_qualified_entity_name::in, maybe(statement)::in, string::in, io::di, io::uo) is det. mlds_output_maybe_gc_trace_code(Indent, Name, Maybe_GC_TraceCode, MaybeNewLine, @@ -1236,13 +1236,13 @@ mlds_output_maybe_gc_trace_code(Indent, Name, Maybe_GC_TraceCode, MaybeNewLine, Maybe_GC_TraceCode = no ; Maybe_GC_TraceCode = yes(GC_TraceCode), - io__write_string(MaybeNewLine, !IO), - io__write_string("#if 0 /* GC trace code */\n", !IO), + io.write_string(MaybeNewLine, !IO), + io.write_string("#if 0 /* GC trace code */\n", !IO), % XXX This value for FuncInfo is bogus. However, this output is only % for debugging anyway, so it doesn't really matter. - FuncInfo = func_info(Name, mlds__func_signature([], [])), + FuncInfo = func_info(Name, mlds_func_signature([], [])), mlds_output_statement(Indent, FuncInfo, GC_TraceCode, !IO), - io__write_string("#endif\n", !IO) + io.write_string("#endif\n", !IO) ). %-----------------------------------------------------------------------------% @@ -1250,22 +1250,22 @@ mlds_output_maybe_gc_trace_code(Indent, Name, Maybe_GC_TraceCode, MaybeNewLine, % Code to output type declarations/definitions % -:- pred mlds_output_class_decl(indent::in, mlds__qualified_entity_name::in, - mlds__class_defn::in, io::di, io::uo) is det. +:- pred mlds_output_class_decl(indent::in, mlds_qualified_entity_name::in, + mlds_class_defn::in, io::di, io::uo) is det. mlds_output_class_decl(_Indent, Name, ClassDefn, !IO) :- - ( ClassDefn^kind = mlds__enum -> - io__write_string("enum ", !IO), + ( ClassDefn^kind = mlds_enum -> + io.write_string("enum ", !IO), mlds_output_fully_qualified_name(Name, !IO), - io__write_string("_e", !IO) + io.write_string("_e", !IO) ; - io__write_string("struct ", !IO), + io.write_string("struct ", !IO), mlds_output_fully_qualified_name(Name, !IO), - io__write_string("_s", !IO) + io.write_string("_s", !IO) ). -:- pred mlds_output_class(indent::in, mlds__qualified_entity_name::in, - mlds__context::in, mlds__class_defn::in, io::di, io::uo) is det. +:- pred mlds_output_class(indent::in, mlds_qualified_entity_name::in, + mlds_context::in, mlds_class_defn::in, io::di, io::uo) is det. mlds_output_class(Indent, Name, Context, ClassDefn, !IO) :- % To avoid name clashes, we need to qualify the names of the member @@ -1276,8 +1276,8 @@ mlds_output_class(Indent, Name, Context, ClassDefn, !IO) :- Name = qual(ModuleName, QualKind, UnqualName), ( UnqualName = type(ClassName, ClassArity) -> - globals__io_get_globals(Globals, !IO), - ClassModuleName = mlds__append_class_qualifier(ModuleName, + globals.io_get_globals(Globals, !IO), + ClassModuleName = mlds_append_class_qualifier(ModuleName, QualKind, Globals, ClassName, ClassArity) ; unexpected(this_file, "mlds_output_enum_constants") @@ -1289,16 +1289,16 @@ mlds_output_class(Indent, Name, Context, ClassDefn, !IO) :- % XXX this should be conditional: only when compiling to C, % not when compiling to C++ - ClassDefn = class_defn(Kind, _Imports, BaseClasses, _Implements, + ClassDefn = mlds_class_defn(Kind, _Imports, BaseClasses, _Implements, Ctors, Members), AllMembers = Ctors ++ Members, - ( Kind = mlds__enum -> + ( Kind = mlds_enum -> StaticMembers = [], StructMembers = AllMembers ; - list__filter(is_static_member, AllMembers, + list.filter(is_static_member, AllMembers, StaticMembers, NonStaticMembers), StructMembers = NonStaticMembers ), @@ -1309,9 +1309,9 @@ mlds_output_class(Indent, Name, Context, ClassDefn, !IO) :- % XXX this should be conditional: only when compiling to C, % not when compiling to C++ - list__map_foldl(mlds_make_base_class(Context), BaseClasses, BaseDefns, + list.map_foldl(mlds_make_base_class(Context), BaseClasses, BaseDefns, 1, _), - list__append(BaseDefns, StructMembers, BasesAndMembers), + list.append(BaseDefns, StructMembers, BasesAndMembers), % Output the class declaration and the class members. % We treat enumerations specially. @@ -1326,8 +1326,8 @@ mlds_output_class(Indent, Name, Context, ClassDefn, !IO) :- % Hence we don't need to check for empty structs here. mlds_output_class_decl(Indent, Name, ClassDefn, !IO), - io__write_string(" {\n", !IO), - ( Kind = mlds__enum -> + io.write_string(" {\n", !IO), + ( Kind = mlds_enum -> mlds_output_enum_constants(Indent + 1, ClassModuleName, BasesAndMembers, !IO) ; @@ -1335,13 +1335,13 @@ mlds_output_class(Indent, Name, Context, ClassDefn, !IO) :- BasesAndMembers, !IO) ), mlds_indent(Context, Indent, !IO), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), mlds_output_defns(Indent, yes, ClassModuleName, StaticMembers, !IO). -:- pred is_static_member(mlds__defn::in) is semidet. +:- pred is_static_member(mlds_defn::in) is semidet. is_static_member(Defn) :- - Defn = mlds__defn(Name, _, Flags, _), + Defn = mlds_defn(Name, _, Flags, _), ( Name = type(_, _) ; per_instance(Flags) = one_copy ). @@ -1349,51 +1349,51 @@ is_static_member(Defn) :- % Convert a base class class_id into a member variable % that holds the value of the base class. % -:- pred mlds_make_base_class(mlds__context::in, mlds__class_id::in, - mlds__defn::out, int::in, int::out) is det. +:- pred mlds_make_base_class(mlds_context::in, mlds_class_id::in, + mlds_defn::out, int::in, int::out) is det. mlds_make_base_class(Context, ClassId, MLDS_Defn, BaseNum0, BaseNum) :- - BaseName = mlds__var_name(string__format("base_%d", [i(BaseNum0)]), no), + BaseName = mlds_var_name(string.format("base_%d", [i(BaseNum0)]), no), Type = ClassId, % We only need GC tracing code for top-level variables, % not for base classes. GC_TraceCode = no, - MLDS_Defn = mlds__defn(data(var(BaseName)), Context, + MLDS_Defn = mlds_defn(data(var(BaseName)), Context, ml_gen_public_field_decl_flags, - data(Type, no_initializer, GC_TraceCode)), + mlds_data(Type, no_initializer, GC_TraceCode)), BaseNum = BaseNum0 + 1. % Output the definitions of the enumeration constants % for an enumeration type. % :- pred mlds_output_enum_constants(indent::in, mlds_module_name::in, - mlds__defns::in, io::di, io::uo) is det. + mlds_defns::in, io::di, io::uo) is det. mlds_output_enum_constants(Indent, EnumModuleName, Members, !IO) :- % Select the enumeration constants from the list of members % for this enumeration type, and output them. - EnumConsts = list__filter(is_enum_const, Members), - io__write_list(EnumConsts, ",\n", + EnumConsts = list.filter(is_enum_const, Members), + io.write_list(EnumConsts, ",\n", mlds_output_enum_constant(Indent, EnumModuleName), !IO), - io__nl(!IO). + io.nl(!IO). - % Test whether one of the members of an mlds__enum class + % Test whether one of the members of an mlds_enum class % is an enumeration constant. % -:- pred is_enum_const(mlds__defn::in) is semidet. +:- pred is_enum_const(mlds_defn::in) is semidet. is_enum_const(Defn) :- - Defn = mlds__defn(_Name, _Context, Flags, _DefnBody), + Defn = mlds_defn(_Name, _Context, Flags, _DefnBody), constness(Flags) = const. % Output the definition of a single enumeration constant. % :- pred mlds_output_enum_constant(indent::in, mlds_module_name::in, - mlds__defn::in, io::di, io::uo) is det. + mlds_defn::in, io::di, io::uo) is det. mlds_output_enum_constant(Indent, EnumModuleName, Defn, !IO) :- - Defn = mlds__defn(Name, Context, _Flags, DefnBody), - ( DefnBody = data(Type, Initializer, _GC_TraceCode) -> + Defn = mlds_defn(Name, Context, _Flags, DefnBody), + ( DefnBody = mlds_data(Type, Initializer, _GC_TraceCode) -> mlds_indent(Context, Indent, !IO), mlds_output_fully_qualified_name( qual(EnumModuleName, type_qual, Name), !IO), @@ -1408,7 +1408,7 @@ mlds_output_enum_constant(Indent, EnumModuleName, Defn, !IO) :- % Code to output data declarations/definitions % -:- pred mlds_output_data_decl(mlds__qualified_entity_name::in, mlds_type::in, +:- pred mlds_output_data_decl(mlds_qualified_entity_name::in, mlds_type::in, initializer_array_size::in, io::di, io::uo) is det. mlds_output_data_decl(Name, Type, InitializerSize, !IO) :- @@ -1422,23 +1422,23 @@ mlds_output_data_decl_2(InitializerSize, Type, !IO) :- mlds_output_type_suffix(Type, InitializerSize, !IO). :- pred mlds_output_data_decl_ho(output_type::in(output_type), - output_type::in(output_type), mlds__qualified_entity_name::in, + output_type::in(output_type), mlds_qualified_entity_name::in, mlds_type::in, io::di, io::uo) is det. mlds_output_data_decl_ho(OutputPrefix, OutputSuffix, Name, Type, !IO) :- OutputPrefix(Type, !IO), - io__write_char(' ', !IO), + io.write_char(' ', !IO), mlds_output_fully_qualified_name(Name, !IO), OutputSuffix(Type, !IO). -:- pred mlds_output_data_defn(mlds__qualified_entity_name::in, mlds_type::in, - mlds__initializer::in, io::di, io::uo) is det. +:- pred mlds_output_data_defn(mlds_qualified_entity_name::in, mlds_type::in, + mlds_initializer::in, io::di, io::uo) is det. mlds_output_data_defn(Name, Type, Initializer, !IO) :- mlds_output_data_decl(Name, Type, initializer_array_size(Initializer), !IO), mlds_output_initializer(Type, Initializer, !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). :- pred mlds_output_maybe(maybe(T)::in, pred(T, io, io)::in(pred(in, di, uo) is det), io::di, io::uo) is det. @@ -1451,18 +1451,18 @@ mlds_output_maybe(MaybeValue, OutputAction, !IO) :- MaybeValue = no ). -:- pred mlds_output_initializer(mlds_type::in, mlds__initializer::in, +:- pred mlds_output_initializer(mlds_type::in, mlds_initializer::in, io::di, io::uo) is det. mlds_output_initializer(_Type, Initializer, !IO) :- ( mlds_needs_initialization(Initializer) = yes -> - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), mlds_output_initializer_body(0, Initializer, !IO) ; true ). -:- func mlds_needs_initialization(mlds__initializer) = bool. +:- func mlds_needs_initialization(mlds_initializer) = bool. mlds_needs_initialization(no_initializer) = no. mlds_needs_initialization(init_obj(_)) = yes. @@ -1470,7 +1470,7 @@ mlds_needs_initialization(init_struct(_Type, [])) = no. mlds_needs_initialization(init_struct(_Type, [_|_])) = yes. mlds_needs_initialization(init_array(_)) = yes. -:- pred mlds_output_initializer_body(int::in, mlds__initializer::in, +:- pred mlds_output_initializer_body(int::in, mlds_initializer::in, io::di, io::uo) is det. mlds_output_initializer_body(_, no_initializer, !IO). @@ -1482,10 +1482,10 @@ mlds_output_initializer_body(Indent, init_struct(_Type, FieldInits), !IO) :- % the responsibility of the MLDS code generator to not generate any. % So we don't need to handle empty initializers specially here. mlds_indent(Indent, !IO), - io__write_string("{\n", !IO), - io__write_list(FieldInits, ",\n", mlds_output_initializer_body(Indent + 1), + io.write_string("{\n", !IO), + io.write_list(FieldInits, ",\n", mlds_output_initializer_body(Indent + 1), !IO), - io__write_string("}", !IO). + io.write_string("}", !IO). mlds_output_initializer_body(Indent, init_array(ElementInits), !IO) :- % Standard ANSI/ISO C does not allow empty arrays. But the MLDS does. % To keep the C compiler happy, we therefore convert zero-element MLDS @@ -1494,17 +1494,17 @@ mlds_output_initializer_body(Indent, init_array(ElementInits), !IO) :- % here is empty, we need to output a single initializer. We can initialize % the extra element with any value; we use "0", since that is a valid % initializer for any type. - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), ( ElementInits = [], mlds_indent(Indent, !IO), - io__write_string("0", !IO) + io.write_string("0", !IO) ; ElementInits = [_ | _], - io__write_list(ElementInits, ",\n", + io.write_list(ElementInits, ",\n", mlds_output_initializer_body(Indent + 1), !IO) ), - io__write_string(" }", !IO). + io.write_string(" }", !IO). %-----------------------------------------------------------------------------% % @@ -1514,48 +1514,48 @@ mlds_output_initializer_body(Indent, init_array(ElementInits), !IO) :- :- pred mlds_output_pred_proc_id(pred_proc_id::in, io::di, io::uo) is det. mlds_output_pred_proc_id(proc(PredId, ProcId), !IO) :- - globals__io_lookup_bool_option(auto_comments, AddComments, !IO), + globals.io_lookup_bool_option(auto_comments, AddComments, !IO), ( AddComments = yes, - io__write_string("/* pred_id: ", !IO), + io.write_string("/* pred_id: ", !IO), pred_id_to_int(PredId, PredIdNum), - io__write_int(PredIdNum, !IO), - io__write_string(", proc_id: ", !IO), + io.write_int(PredIdNum, !IO), + io.write_string(", proc_id: ", !IO), proc_id_to_int(ProcId, ProcIdNum), - io__write_int(ProcIdNum, !IO), - io__write_string(" */\n", !IO) + io.write_int(ProcIdNum, !IO), + io.write_string(" */\n", !IO) ; AddComments = no ). -:- pred mlds_output_func(indent::in, qualified_entity_name::in, - mlds__context::in, func_params::in, function_body::in, +:- pred mlds_output_func(indent::in, mlds_qualified_entity_name::in, + mlds_context::in, mlds_func_params::in, mlds_function_body::in, io::di, io::uo) is det. mlds_output_func(Indent, Name, Context, Params, FunctionBody, !IO) :- mlds_output_func_decl(Indent, Name, Context, Params, !IO), ( FunctionBody = external, - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ; FunctionBody = defined_here(Body), - io__write_string("\n", !IO), + io.write_string("\n", !IO), mlds_indent(Context, Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), mlds_maybe_output_time_profile_instr(Context, Indent + 1, Name, !IO), - Signature = mlds__get_func_signature(Params), + Signature = mlds_get_func_signature(Params), FuncInfo = func_info(Name, Signature), mlds_output_statement(Indent + 1, FuncInfo, Body, !IO), mlds_indent(Context, Indent, !IO), - io__write_string("}\n", !IO) % end the function + io.write_string("}\n", !IO) % end the function ). -:- pred mlds_output_func_decl(indent::in, qualified_entity_name::in, - mlds__context::in, func_params::in, io::di, io::uo) is det. +:- pred mlds_output_func_decl(indent::in, mlds_qualified_entity_name::in, + mlds_context::in, mlds_func_params::in, io::di, io::uo) is det. mlds_output_func_decl(Indent, QualifiedName, Context, Signature, !IO) :- CallingConvention = "MR_CALL ", @@ -1563,17 +1563,17 @@ mlds_output_func_decl(Indent, QualifiedName, Context, Signature, !IO) :- CallingConvention, Signature, mlds_output_type_prefix, mlds_output_type_suffix, !IO). -:- pred mlds_output_func_decl_ho(indent::in, qualified_entity_name::in, - mlds__context::in, string::in, func_params::in, +:- pred mlds_output_func_decl_ho(indent::in, mlds_qualified_entity_name::in, + mlds_context::in, string::in, mlds_func_params::in, output_type::in(output_type), output_type::in(output_type), io::di, io::uo) is det. mlds_output_func_decl_ho(Indent, QualifiedName, Context, CallingConvention, Signature, OutputPrefix, OutputSuffix, !IO) :- - Signature = mlds__func_params(Parameters, RetTypes), + Signature = mlds_func_params(Parameters, RetTypes), ( RetTypes = [], - io__write_string("void", !IO) + io.write_string("void", !IO) ; RetTypes = [RetType], OutputPrefix(RetType, !IO) @@ -1582,8 +1582,8 @@ mlds_output_func_decl_ho(Indent, QualifiedName, Context, CallingConvention, mlds_output_return_list(RetTypes, mlds_output_prefix_suffix(OutputPrefix, OutputSuffix), !IO) ), - io__write_char(' ', !IO), - io__write_string(CallingConvention, !IO), + io.write_char(' ', !IO), + io.write_string(CallingConvention, !IO), mlds_output_fully_qualified_name(QualifiedName, !IO), QualifiedName = qual(ModuleName, _, _), mlds_output_params(OutputPrefix, OutputSuffix, @@ -1603,43 +1603,44 @@ mlds_output_prefix_suffix(OutputPrefix, OutputSuffix, Value, !IO) :- :- pred mlds_output_params(output_type::in(output_type), output_type::in(output_type), indent::in, mlds_module_name::in, - mlds__context::in, mlds__arguments::in, io::di, io::uo) is det. + mlds_context::in, mlds_arguments::in, io::di, io::uo) is det. mlds_output_params(OutputPrefix, OutputSuffix, Indent, ModuleName, Context, Parameters, !IO) :- - io__write_char('(', !IO), + io.write_char('(', !IO), ( Parameters = [], - io__write_string("void", !IO) + io.write_string("void", !IO) ; Parameters = [_ | _], - io__nl(!IO), - io__write_list(Parameters, ",\n", + io.nl(!IO), + io.write_list(Parameters, ",\n", mlds_output_param(OutputPrefix, OutputSuffix, Indent + 1, ModuleName, Context), !IO) ), - io__write_char(')', !IO). + io.write_char(')', !IO). :- pred mlds_output_param(output_type::in(output_type), output_type::in(output_type), indent::in, mlds_module_name::in, - mlds__context::in, mlds__argument::in, io::di, io::uo) is det. + mlds_context::in, mlds_argument::in, io::di, io::uo) is det. mlds_output_param(OutputPrefix, OutputSuffix, Indent, ModuleName, Context, Arg, !IO) :- - Arg = mlds__argument(Name, Type, Maybe_GC_TraceCode), + Arg = mlds_argument(Name, Type, Maybe_GC_TraceCode), QualName = qual(ModuleName, module_qual, Name), mlds_indent(Context, Indent, !IO), mlds_output_data_decl_ho(OutputPrefix, OutputSuffix, QualName, Type, !IO), mlds_output_maybe_gc_trace_code(Indent, QualName, Maybe_GC_TraceCode, "\n", !IO). -:- pred mlds_output_func_type_prefix(func_params::in, io::di, io::uo) is det. +:- pred mlds_output_func_type_prefix(mlds_func_params::in, io::di, io::uo) + is det. mlds_output_func_type_prefix(Params, !IO) :- - Params = mlds__func_params(_Parameters, RetTypes), + Params = mlds_func_params(_Parameters, RetTypes), ( RetTypes = [], - io__write_string("void", !IO) + io.write_string("void", !IO) ; RetTypes = [RetType], mlds_output_type(RetType, !IO) @@ -1647,34 +1648,35 @@ mlds_output_func_type_prefix(Params, !IO) :- RetTypes = [_, _ | _], mlds_output_return_list(RetTypes, mlds_output_type, !IO) ), - % Note that mlds__func_type actually corresponds to a function _pointer_ + % Note that mlds_func_type actually corresponds to a function _pointer_ % type in C. This is necessary because function types in C are not first % class. - io__write_string(" MR_CALL (*", !IO). + io.write_string(" MR_CALL (*", !IO). -:- pred mlds_output_func_type_suffix(func_params::in, io::di, io::uo) is det. +:- pred mlds_output_func_type_suffix(mlds_func_params::in, io::di, io::uo) + is det. mlds_output_func_type_suffix(Params, !IO) :- - Params = mlds__func_params(Parameters, _RetTypes), - io__write_string(")", !IO), + Params = mlds_func_params(Parameters, _RetTypes), + io.write_string(")", !IO), mlds_output_param_types(Parameters, !IO). -:- pred mlds_output_param_types(mlds__arguments::in, io::di, io::uo) is det. +:- pred mlds_output_param_types(mlds_arguments::in, io::di, io::uo) is det. mlds_output_param_types(Parameters, !IO) :- - io__write_char('(', !IO), + io.write_char('(', !IO), ( Parameters = [], - io__write_string("void", !IO) + io.write_string("void", !IO) ; Parameters = [_ | _], - io__write_list(Parameters, ", ", mlds_output_param_type, !IO) + io.write_list(Parameters, ", ", mlds_output_param_type, !IO) ), - io__write_char(')', !IO). + io.write_char(')', !IO). -:- pred mlds_output_param_type(mlds__argument::in, io::di, io::uo) is det. +:- pred mlds_output_param_type(mlds_argument::in, io::di, io::uo) is det. -mlds_output_param_type(mlds__argument(_Name, Type, _GC_TraceCode), !IO) :- +mlds_output_param_type(mlds_argument(_Name, Type, _GC_TraceCode), !IO) :- mlds_output_type(Type, !IO). %-----------------------------------------------------------------------------% @@ -1682,7 +1684,7 @@ mlds_output_param_type(mlds__argument(_Name, Type, _GC_TraceCode), !IO) :- % Code to output names of various entities % -:- pred mlds_output_fully_qualified_name(mlds__qualified_entity_name::in, +:- pred mlds_output_fully_qualified_name(mlds_qualified_entity_name::in, io::di, io::uo) is det. mlds_output_fully_qualified_name(QualifiedName, !IO) :- @@ -1705,7 +1707,7 @@ mlds_output_fully_qualified_name(QualifiedName, !IO) :- mlds_output_fully_qualified(QualifiedName, mlds_output_name, !IO) ). -:- pred mlds_output_fully_qualified_proc_label(mlds__qualified_proc_label::in, +:- pred mlds_output_fully_qualified_proc_label(mlds_qualified_proc_label::in, io::di, io::uo) is det. mlds_output_fully_qualified_proc_label(QualifiedName, !IO) :- @@ -1720,15 +1722,15 @@ mlds_output_fully_qualified_proc_label(QualifiedName, !IO) :- mlds_output_fully_qualified(QualifiedName, mlds_output_proc_label, !IO) ). -:- pred mlds_output_fully_qualified(mlds__fully_qualified_name(T)::in, +:- pred mlds_output_fully_qualified(mlds_fully_qualified_name(T)::in, pred(T, io, io)::in(pred(in, di, uo) is det), io::di, io::uo) is det. mlds_output_fully_qualified(qual(ModuleName, _QualKind, Name), OutputFunc, !IO) :- SymName = mlds_module_name_to_sym_name(ModuleName), MangledModuleName = sym_name_mangle(SymName), - io__write_string(MangledModuleName, !IO), - io__write_string("__", !IO), + io.write_string(MangledModuleName, !IO), + io.write_string("__", !IO), OutputFunc(Name, !IO). :- pred mlds_output_module_name(mercury_module_name::in, io::di, io::uo) @@ -1736,31 +1738,31 @@ mlds_output_fully_qualified(qual(ModuleName, _QualKind, Name), OutputFunc, mlds_output_module_name(ModuleName, !IO) :- MangledModuleName = sym_name_mangle(ModuleName), - io__write_string(MangledModuleName, !IO). + io.write_string(MangledModuleName, !IO). -:- pred mlds_output_name(mlds__entity_name::in, io::di, io::uo) is det. +:- pred mlds_output_name(mlds_entity_name::in, io::di, io::uo) is det. % XXX We should avoid appending the arity, modenum, and seqnum % if they are not needed. mlds_output_name(type(Name, Arity), !IO) :- MangledName = name_mangle(Name), - io__format("%s_%d", [s(MangledName), i(Arity)], !IO). + io.format("%s_%d", [s(MangledName), i(Arity)], !IO). mlds_output_name(data(DataName), !IO) :- mlds_output_data_name(DataName, !IO). mlds_output_name(function(PredLabel, ProcId, MaybeSeqNum, _PredId), !IO) :- mlds_output_pred_label(PredLabel, !IO), proc_id_to_int(ProcId, ModeNum), - io__format("_%d", [i(ModeNum)], !IO), + io.format("_%d", [i(ModeNum)], !IO), ( MaybeSeqNum = yes(SeqNum), - io__format("_%d", [i(SeqNum)], !IO) + io.format("_%d", [i(SeqNum)], !IO) ; MaybeSeqNum = no ). mlds_output_name(export(Name), !IO) :- - io__write_string(Name, !IO). + io.write_string(Name, !IO). -:- pred mlds_output_pred_label(mlds__pred_label::in, io::di, io::uo) is det. +:- pred mlds_output_pred_label(mlds_pred_label::in, io::di, io::uo) is det. mlds_output_pred_label(pred(PredOrFunc, MaybeDefiningModule, Name, Arity, _CodeModel, _NonOutputFunc), !IO) :- @@ -1768,10 +1770,10 @@ mlds_output_pred_label(pred(PredOrFunc, MaybeDefiningModule, Name, Arity, ; PredOrFunc = function, Suffix = "f" ), MangledName = name_mangle(Name), - io__format("%s_%d_%s", [s(MangledName), i(Arity), s(Suffix)], !IO), + io.format("%s_%d_%s", [s(MangledName), i(Arity), s(Suffix)], !IO), ( MaybeDefiningModule = yes(DefiningModule), - io__write_string("_in__", !IO), + io.write_string("_in__", !IO), mlds_output_module_name(DefiningModule, !IO) ; MaybeDefiningModule = no @@ -1780,29 +1782,29 @@ mlds_output_pred_label(special_pred(PredName, MaybeTypeModule, TypeName, TypeArity), !IO) :- MangledPredName = name_mangle(PredName), MangledTypeName = name_mangle(TypeName), - io__write_string(MangledPredName, !IO), - io__write_string("__", !IO), + io.write_string(MangledPredName, !IO), + io.write_string("__", !IO), ( MaybeTypeModule = yes(TypeModule), mlds_output_module_name(TypeModule, !IO), - io__write_string("__", !IO) + io.write_string("__", !IO) ; MaybeTypeModule = no ), - io__write_string(MangledTypeName, !IO), - io__write_string("_", !IO), - io__write_int(TypeArity, !IO). + io.write_string(MangledTypeName, !IO), + io.write_string("_", !IO), + io.write_int(TypeArity, !IO). -:- pred mlds_output_data_name(mlds__data_name::in, io::di, io::uo) is det. +:- pred mlds_output_data_name(mlds_data_name::in, io::di, io::uo) is det. mlds_output_data_name(var(Name), !IO) :- mlds_output_mangled_name(ml_var_name_to_string(Name), !IO). mlds_output_data_name(common(Num), !IO) :- - io__write_string("common_", !IO), - io__write_int(Num, !IO). + io.write_string("common_", !IO), + io.write_int(Num, !IO). mlds_output_data_name(rtti(RttiId), !IO) :- - rtti__id_to_c_identifier(RttiId, RttiAddrName), - io__write_string(RttiAddrName, !IO). + rtti.id_to_c_identifier(RttiId, RttiAddrName), + io.write_string(RttiAddrName, !IO). mlds_output_data_name(module_layout, !IO) :- sorry(this_file, "NYI: module_layout"). mlds_output_data_name(proc_layout(_ProcLabel), !IO) :- @@ -1810,7 +1812,7 @@ mlds_output_data_name(proc_layout(_ProcLabel), !IO) :- mlds_output_data_name(internal_layout(_ProcLabel, _FuncSeqNum), !IO) :- sorry(this_file, "NYI: internal_layout"). mlds_output_data_name(tabling_pointer(ProcLabel), !IO) :- - io__write_string("table_for_", !IO), + io.write_string("table_for_", !IO), mlds_output_proc_label(ProcLabel, !IO). %-----------------------------------------------------------------------------% @@ -1834,8 +1836,8 @@ mlds_output_type(Type, !IO) :- mlds_output_type_prefix(mercury_type(Type, TypeCategory, _), !IO) :- mlds_output_mercury_type_prefix(Type, TypeCategory, !IO). -mlds_output_type_prefix(mercury_array_type(_ElemType), !IO) :- - globals__io_lookup_bool_option(highlevel_data, HighLevelData, !IO), +mlds_output_type_prefix(mlds_mercury_array_type(_ElemType), !IO) :- + globals.io_lookup_bool_option(highlevel_data, HighLevelData, !IO), ( HighLevelData = yes, mlds_output_mercury_user_type_name( @@ -1843,23 +1845,23 @@ mlds_output_type_prefix(mercury_array_type(_ElemType), !IO) :- type_cat_user_ctor, !IO) ; HighLevelData = no, - io__write_string("MR_ArrayPtr", !IO) + io.write_string("MR_ArrayPtr", !IO) ). -mlds_output_type_prefix(mlds__native_int_type, !IO) :- - io__write_string("int", !IO). -mlds_output_type_prefix(mlds__native_float_type, !IO) :- - io__write_string("float", !IO). -mlds_output_type_prefix(mlds__native_bool_type, !IO) :- - io__write_string("MR_bool", !IO). -mlds_output_type_prefix(mlds__native_char_type, !IO) :- - io__write_string("char", !IO). -mlds_output_type_prefix(mlds__foreign_type(_ForeignType), !IO) :- +mlds_output_type_prefix(mlds_native_int_type, !IO) :- + io.write_string("int", !IO). +mlds_output_type_prefix(mlds_native_float_type, !IO) :- + io.write_string("float", !IO). +mlds_output_type_prefix(mlds_native_bool_type, !IO) :- + io.write_string("MR_bool", !IO). +mlds_output_type_prefix(mlds_native_char_type, !IO) :- + io.write_string("char", !IO). +mlds_output_type_prefix(mlds_foreign_type(_ForeignType), !IO) :- % For binary compatibility with the --target asm back-end, % we need to output these as a generic type, rather than making % use of the C type name - io__write_string("MR_Box", !IO). -mlds_output_type_prefix(mlds__class_type(Name, Arity, ClassKind), !IO) :- - ( ClassKind = mlds__enum -> + io.write_string("MR_Box", !IO). +mlds_output_type_prefix(mlds_class_type(Name, Arity, ClassKind), !IO) :- + ( ClassKind = mlds_enum -> % We can't just use the enumeration type, since the enumeration type's % definition is not guaranteed to be in scope at this point. (Fixing % that would be somewhat complicated; it would require writing enum @@ -1868,63 +1870,63 @@ mlds_output_type_prefix(mlds__class_type(Name, Arity, ClassKind), !IO) :- % `std_util.arg/2'. So we just use `MR_Integer', and output the % actual enumeration type as a comment. - io__write_string("MR_Integer /* actually `enum ", !IO), + io.write_string("MR_Integer /* actually `enum ", !IO), mlds_output_fully_qualified(Name, mlds_output_mangled_name, !IO), - io__format("_%d_e", [i(Arity)], !IO), - io__write_string("' */", !IO) + io.format("_%d_e", [i(Arity)], !IO), + io.write_string("' */", !IO) ; % For struct types it's OK to output an incomplete type, % since don't use these types directly, we only use pointers to them. - io__write_string("struct ", !IO), + io.write_string("struct ", !IO), mlds_output_fully_qualified(Name, mlds_output_mangled_name, !IO), - io__format("_%d_s", [i(Arity)], !IO) + io.format("_%d_s", [i(Arity)], !IO) ). -mlds_output_type_prefix(mlds__ptr_type(Type), !IO) :- +mlds_output_type_prefix(mlds_ptr_type(Type), !IO) :- mlds_output_type(Type, !IO), - io__write_string(" *", !IO). -mlds_output_type_prefix(mlds__array_type(Type), !IO) :- + io.write_string(" *", !IO). +mlds_output_type_prefix(mlds_array_type(Type), !IO) :- % Here we just output the element type. The "[]" goes in the type suffix. mlds_output_type(Type, !IO). -mlds_output_type_prefix(mlds__func_type(FuncParams), !IO) :- +mlds_output_type_prefix(mlds_func_type(FuncParams), !IO) :- mlds_output_func_type_prefix(FuncParams, !IO). -mlds_output_type_prefix(mlds__generic_type, !IO) :- - io__write_string("MR_Box", !IO). -mlds_output_type_prefix(mlds__generic_env_ptr_type, !IO) :- - io__write_string("void *", !IO). -mlds_output_type_prefix(mlds__type_info_type, !IO) :- - io__write_string("MR_TypeInfo", !IO). -mlds_output_type_prefix(mlds__pseudo_type_info_type, !IO) :- - io__write_string("MR_PseudoTypeInfo", !IO). -mlds_output_type_prefix(mlds__cont_type(ArgTypes), !IO) :- +mlds_output_type_prefix(mlds_generic_type, !IO) :- + io.write_string("MR_Box", !IO). +mlds_output_type_prefix(mlds_generic_env_ptr_type, !IO) :- + io.write_string("void *", !IO). +mlds_output_type_prefix(mlds_type_info_type, !IO) :- + io.write_string("MR_TypeInfo", !IO). +mlds_output_type_prefix(mlds_pseudo_type_info_type, !IO) :- + io.write_string("MR_PseudoTypeInfo", !IO). +mlds_output_type_prefix(mlds_cont_type(ArgTypes), !IO) :- ( ArgTypes = [], - globals__io_lookup_bool_option(gcc_nested_functions, GCC_NestedFuncs, + globals.io_lookup_bool_option(gcc_nested_functions, GCC_NestedFuncs, !IO), ( GCC_NestedFuncs = yes, - io__write_string("MR_NestedCont", !IO) + io.write_string("MR_NestedCont", !IO) ; GCC_NestedFuncs = no, - io__write_string("MR_Cont", !IO) + io.write_string("MR_Cont", !IO) ) ; ArgTypes = [_ | _], % This case only happens for --nondet-copy-out - io__write_string("void MR_CALL (*", !IO) + io.write_string("void MR_CALL (*", !IO) ). -mlds_output_type_prefix(mlds__commit_type, !IO) :- - globals__io_lookup_bool_option(gcc_local_labels, GCC_LocalLabels, !IO), +mlds_output_type_prefix(mlds_commit_type, !IO) :- + globals.io_lookup_bool_option(gcc_local_labels, GCC_LocalLabels, !IO), ( GCC_LocalLabels = yes, - io__write_string("__label__", !IO) + io.write_string("__label__", !IO) ; GCC_LocalLabels = no, - io__write_string("jmp_buf", !IO) + io.write_string("jmp_buf", !IO) ). -mlds_output_type_prefix(mlds__rtti_type(RttiIdMaybeElement), !IO) :- +mlds_output_type_prefix(mlds_rtti_type(RttiIdMaybeElement), !IO) :- rtti_id_maybe_element_c_type(RttiIdMaybeElement, CType, _IsArray), - io__write_string(CType, !IO). -mlds_output_type_prefix(mlds__unknown_type, !IO) :- + io.write_string(CType, !IO). +mlds_output_type_prefix(mlds_unknown_type, !IO) :- unexpected(this_file, "prefix has unknown type"). :- pred mlds_output_mercury_type_prefix(mer_type::in, type_category::in, @@ -1933,22 +1935,22 @@ mlds_output_type_prefix(mlds__unknown_type, !IO) :- mlds_output_mercury_type_prefix(Type, TypeCategory, !IO) :- ( TypeCategory = type_cat_char, - io__write_string("MR_Char", !IO) + io.write_string("MR_Char", !IO) ; TypeCategory = type_cat_int, - io__write_string("MR_Integer", !IO) + io.write_string("MR_Integer", !IO) ; TypeCategory = type_cat_string, - io__write_string("MR_String", !IO) + io.write_string("MR_String", !IO) ; TypeCategory = type_cat_float, - io__write_string("MR_Float", !IO) + io.write_string("MR_Float", !IO) ; TypeCategory = type_cat_void, - io__write_string("MR_Word", !IO) + io.write_string("MR_Word", !IO) ; TypeCategory = type_cat_variable, - io__write_string("MR_Box", !IO) + io.write_string("MR_Box", !IO) ; TypeCategory = type_cat_type_info, % runtime/mercury_hlc_types requires typeclass_infos @@ -1971,16 +1973,16 @@ mlds_output_mercury_type_prefix(Type, TypeCategory, !IO) :- mlds_output_mercury_user_type_prefix(Type, type_cat_user_ctor, !IO) ; TypeCategory = type_cat_tuple, - io__write_string("MR_Tuple", !IO) + io.write_string("MR_Tuple", !IO) ; TypeCategory = type_cat_higher_order, - globals__io_lookup_bool_option(highlevel_data, HighLevelData, !IO), + globals.io_lookup_bool_option(highlevel_data, HighLevelData, !IO), ( HighLevelData = yes, - io__write_string("MR_ClosurePtr", !IO) + io.write_string("MR_ClosurePtr", !IO) ; HighLevelData = no, - io__write_string("MR_Word", !IO) + io.write_string("MR_Word", !IO) ) ; TypeCategory = type_cat_enum, @@ -1997,7 +1999,7 @@ mlds_output_mercury_type_prefix(Type, TypeCategory, !IO) :- type_category::in, io::di, io::uo) is det. mlds_output_mercury_user_type_prefix(Type, TypeCategory, !IO) :- - globals__io_lookup_bool_option(highlevel_data, HighLevelData, !IO), + globals.io_lookup_bool_option(highlevel_data, HighLevelData, !IO), ( HighLevelData = yes, ( type_to_ctor_and_args(Type, TypeCtor, _ArgsTypes) -> @@ -2008,7 +2010,7 @@ mlds_output_mercury_user_type_prefix(Type, TypeCategory, !IO) :- ; HighLevelData = no, % In this case, we just treat everything as `MR_Word'. - io__write_string("MR_Word", !IO) + io.write_string("MR_Word", !IO) ). :- pred mlds_output_mercury_user_type_name(type_ctor::in, type_category::in, @@ -2017,10 +2019,10 @@ mlds_output_mercury_user_type_prefix(Type, TypeCategory, !IO) :- mlds_output_mercury_user_type_name(TypeCtor, TypeCategory, !IO) :- ml_gen_type_name(TypeCtor, ClassName, ClassArity), ( TypeCategory = type_cat_enum -> - MLDS_Type = mlds__class_type(ClassName, ClassArity, mlds__enum) + MLDS_Type = mlds_class_type(ClassName, ClassArity, mlds_enum) ; - MLDS_Type = mlds__ptr_type( - mlds__class_type(ClassName, ClassArity, mlds__class)) + MLDS_Type = mlds_ptr_type( + mlds_class_type(ClassName, ClassArity, mlds_class)) ), mlds_output_type_prefix(MLDS_Type, !IO). @@ -2034,74 +2036,74 @@ mlds_output_type_suffix(Type, !IO) :- ; no_size. % Either the size is unknown, % or the data is not an array. -:- func initializer_array_size(mlds__initializer) = initializer_array_size. +:- func initializer_array_size(mlds_initializer) = initializer_array_size. initializer_array_size(no_initializer) = no_size. initializer_array_size(init_obj(_)) = no_size. initializer_array_size(init_struct(_, _)) = no_size. -initializer_array_size(init_array(Elems)) = array_size(list__length(Elems)). +initializer_array_size(init_array(Elems)) = array_size(list.length(Elems)). :- pred mlds_output_type_suffix(mlds_type::in, initializer_array_size::in, io::di, io::uo) is det. mlds_output_type_suffix(mercury_type(_, _, _), _, !IO). -mlds_output_type_suffix(mercury_array_type(_), _, !IO). -mlds_output_type_suffix(mlds__native_int_type, _, !IO). -mlds_output_type_suffix(mlds__native_float_type, _, !IO). -mlds_output_type_suffix(mlds__native_bool_type, _, !IO). -mlds_output_type_suffix(mlds__native_char_type, _, !IO). +mlds_output_type_suffix(mlds_mercury_array_type(_), _, !IO). +mlds_output_type_suffix(mlds_native_int_type, _, !IO). +mlds_output_type_suffix(mlds_native_float_type, _, !IO). +mlds_output_type_suffix(mlds_native_bool_type, _, !IO). +mlds_output_type_suffix(mlds_native_char_type, _, !IO). % XXX Currently we can't output a type suffix. -mlds_output_type_suffix(mlds__foreign_type(_), _, !IO). -mlds_output_type_suffix(mlds__class_type(_, _, _), _, !IO). -mlds_output_type_suffix(mlds__ptr_type(_), _, !IO). -mlds_output_type_suffix(mlds__array_type(_), ArraySize, !IO) :- +mlds_output_type_suffix(mlds_foreign_type(_), _, !IO). +mlds_output_type_suffix(mlds_class_type(_, _, _), _, !IO). +mlds_output_type_suffix(mlds_ptr_type(_), _, !IO). +mlds_output_type_suffix(mlds_array_type(_), ArraySize, !IO) :- mlds_output_array_type_suffix(ArraySize, !IO). -mlds_output_type_suffix(mlds__func_type(FuncParams), _, !IO) :- +mlds_output_type_suffix(mlds_func_type(FuncParams), _, !IO) :- mlds_output_func_type_suffix(FuncParams, !IO). -mlds_output_type_suffix(mlds__generic_type, _, !IO). -mlds_output_type_suffix(mlds__generic_env_ptr_type, _, !IO). -mlds_output_type_suffix(mlds__type_info_type, _, !IO). -mlds_output_type_suffix(mlds__pseudo_type_info_type, _, !IO). -mlds_output_type_suffix(mlds__cont_type(ArgTypes), _, !IO) :- +mlds_output_type_suffix(mlds_generic_type, _, !IO). +mlds_output_type_suffix(mlds_generic_env_ptr_type, _, !IO). +mlds_output_type_suffix(mlds_type_info_type, _, !IO). +mlds_output_type_suffix(mlds_pseudo_type_info_type, _, !IO). +mlds_output_type_suffix(mlds_cont_type(ArgTypes), _, !IO) :- ( ArgTypes = [] ; ArgTypes = [_ | _], % This case only happens for --nondet-copy-out. - io__write_string(")(", !IO), - io__write_list(ArgTypes, ", ", mlds_output_type, !IO), + io.write_string(")(", !IO), + io.write_list(ArgTypes, ", ", mlds_output_type, !IO), % add the type for the environment parameter, if needed - globals__io_lookup_bool_option(gcc_nested_functions, GCC_NestedFuncs, + globals.io_lookup_bool_option(gcc_nested_functions, GCC_NestedFuncs, !IO), ( GCC_NestedFuncs = no, - io__write_string(", void *", !IO) + io.write_string(", void *", !IO) ; GCC_NestedFuncs = yes ), - io__write_string(")", !IO) + io.write_string(")", !IO) ). -mlds_output_type_suffix(mlds__commit_type, _, !IO). -mlds_output_type_suffix(mlds__rtti_type(RttiIdMaybeElement), ArraySize, !IO) :- +mlds_output_type_suffix(mlds_commit_type, _, !IO). +mlds_output_type_suffix(mlds_rtti_type(RttiIdMaybeElement), ArraySize, !IO) :- ( rtti_id_maybe_element_has_array_type(RttiIdMaybeElement) = yes -> mlds_output_array_type_suffix(ArraySize, !IO) ; true ). -mlds_output_type_suffix(mlds__unknown_type, _, !IO) :- +mlds_output_type_suffix(mlds_unknown_type, _, !IO) :- unexpected(this_file, "mlds_output_type_suffix: unknown_type"). :- pred mlds_output_array_type_suffix(initializer_array_size::in, io::di, io::uo) is det. mlds_output_array_type_suffix(no_size, !IO) :- - io__write_string("[]", !IO). + io.write_string("[]", !IO). mlds_output_array_type_suffix(array_size(Size0), !IO) :- % Standard ANSI/ISO C does not allow arrays of size 0. But the MLDS does. % To keep the C compiler happy, we therefore convert zero-element MLDS % arrays into one-element C arrays. - int__max(Size0, 1, Size), - io__format("[%d]", [i(Size)], !IO). + int.max(Size0, 1, Size), + io.format("[%d]", [i(Size)], !IO). %-----------------------------------------------------------------------------% % @@ -2112,12 +2114,12 @@ mlds_output_array_type_suffix(array_size(Size0), !IO) :- ---> forward_decl ; definition. -:- pred mlds_output_decl_flags(mlds__decl_flags::in, decl_or_defn::in, - mlds__entity_name::in, mlds__entity_defn::in, io::di, io::uo) is det. +:- pred mlds_output_decl_flags(mlds_decl_flags::in, decl_or_defn::in, + mlds_entity_name::in, mlds_entity_defn::in, io::di, io::uo) is det. mlds_output_decl_flags(Flags, DeclOrDefn, Name, DefnBody, !IO) :- % mlds_output_extern_or_static handles both the `access' and the - % `per_instance' fields of the mlds__decl_flags. We have to handle them + % `per_instance' fields of the mlds_decl_flags. We have to handle them % together because C overloads `static' to mean both `private' and % `one_copy', rather than having separate keywords for each. To make it % clear which MLDS construct each `static' keyword means, we precede the @@ -2136,7 +2138,7 @@ mlds_output_decl_flags(Flags, DeclOrDefn, Name, DefnBody, !IO) :- :- pred mlds_output_access_comment(access::in, io::di, io::uo) is det. mlds_output_access_comment(Access, !IO) :- - globals__io_lookup_bool_option(auto_comments, Comments, !IO), + globals.io_lookup_bool_option(auto_comments, Comments, !IO), ( Comments = yes, mlds_output_access_comment_2(Access, !IO) @@ -2147,21 +2149,21 @@ mlds_output_access_comment(Access, !IO) :- :- pred mlds_output_access_comment_2(access::in, io::di, io::uo) is det. mlds_output_access_comment_2(public, !IO) :- - io__write_string("/* public: */ ", !IO). + io.write_string("/* public: */ ", !IO). mlds_output_access_comment_2(private, !IO) :- - io__write_string("/* private: */ ", !IO). + io.write_string("/* private: */ ", !IO). mlds_output_access_comment_2(protected, !IO) :- - io__write_string("/* protected: */ ", !IO). + io.write_string("/* protected: */ ", !IO). mlds_output_access_comment_2(default, !IO) :- - io__write_string("/* default access */ ", !IO). + io.write_string("/* default access */ ", !IO). mlds_output_access_comment_2(local, !IO) :- - io__write_string("/* local: */ ", !IO). + io.write_string("/* local: */ ", !IO). :- pred mlds_output_per_instance_comment(per_instance::in, io::di, io::uo) is det. mlds_output_per_instance_comment(PerInstance, !IO) :- - globals__io_lookup_bool_option(auto_comments, Comments, !IO), + globals.io_lookup_bool_option(auto_comments, Comments, !IO), ( Comments = yes, mlds_output_per_instance_comment_2(PerInstance, !IO) @@ -2174,10 +2176,10 @@ mlds_output_per_instance_comment(PerInstance, !IO) :- mlds_output_per_instance_comment_2(per_instance, !IO). mlds_output_per_instance_comment_2(one_copy, !IO) :- - io__write_string("/* one_copy */ ", !IO). + io.write_string("/* one_copy */ ", !IO). :- pred mlds_output_extern_or_static(access::in, per_instance::in, - decl_or_defn::in, mlds__entity_name::in, mlds__entity_defn::in, + decl_or_defn::in, mlds_entity_name::in, mlds_entity_defn::in, io::di, io::uo) is det. mlds_output_extern_or_static(Access, PerInstance, DeclOrDefn, Name, DefnBody, @@ -2192,14 +2194,14 @@ mlds_output_extern_or_static(Access, PerInstance, DeclOrDefn, Name, DefnBody, Name \= type(_, _), % Don't output "static" for functions that don't have a body. % This can happen for Mercury procedures declared `:- external' - DefnBody \= mlds__function(_, _, external, _) + DefnBody \= mlds_function(_, _, external, _) -> - io__write_string("static ", !IO) + io.write_string("static ", !IO) ; DeclOrDefn = forward_decl, Name = data(_) -> - io__write_string("extern ", !IO) + io.write_string("extern ", !IO) ; % Forward declarations for GNU C nested functions need to be prefixed % with "auto". @@ -2207,7 +2209,7 @@ mlds_output_extern_or_static(Access, PerInstance, DeclOrDefn, Name, DefnBody, Name = function(_, _, _, _), Access = local -> - io__write_string("auto ", !IO) + io.write_string("auto ", !IO) ; true ). @@ -2215,25 +2217,25 @@ mlds_output_extern_or_static(Access, PerInstance, DeclOrDefn, Name, DefnBody, :- pred mlds_output_virtuality(virtuality::in, io::di, io::uo) is det. mlds_output_virtuality(virtual, !IO) :- - io__write_string("virtual ", !IO). + io.write_string("virtual ", !IO). mlds_output_virtuality(non_virtual, !IO). :- pred mlds_output_finality(finality::in, io::di, io::uo) is det. mlds_output_finality(final, !IO) :- - io__write_string("/* final */ ", !IO). + io.write_string("/* final */ ", !IO). mlds_output_finality(overridable, !IO). :- pred mlds_output_constness(constness::in, io::di, io::uo) is det. mlds_output_constness(const, !IO) :- - io__write_string("const ", !IO). + io.write_string("const ", !IO). mlds_output_constness(modifiable, !IO). :- pred mlds_output_abstractness(abstractness::in, io::di, io::uo) is det. mlds_output_abstractness(abstract, !IO) :- - io__write_string("/* abstract */ ", !IO). + io.write_string("/* abstract */ ", !IO). mlds_output_abstractness(concrete, !IO). %-----------------------------------------------------------------------------% @@ -2242,28 +2244,28 @@ mlds_output_abstractness(concrete, !IO). % :- type func_info - ---> func_info(mlds__qualified_entity_name, mlds__func_signature). + ---> func_info(mlds_qualified_entity_name, mlds_func_signature). :- pred mlds_output_statements(indent::in, func_info::in, list(statement)::in, io::di, io::uo) is det. mlds_output_statements(Indent, FuncInfo, Statements, !IO) :- - list__foldl(mlds_output_statement(Indent, FuncInfo), Statements, !IO). + list.foldl(mlds_output_statement(Indent, FuncInfo), Statements, !IO). :- pred mlds_output_statement(indent::in, func_info::in, statement::in, io::di, io::uo) is det. mlds_output_statement(Indent, FuncInfo, statement(Statement, Context), !IO) :- - mlds_to_c__output_context(Context, !IO), + output_context(Context, !IO), mlds_output_stmt(Indent, FuncInfo, Statement, Context, !IO). -:- pred mlds_output_stmt(indent::in, func_info::in, mlds__stmt::in, - mlds__context::in, io::di, io::uo) is det. +:- pred mlds_output_stmt(indent::in, func_info::in, mlds_stmt::in, + mlds_context::in, io::di, io::uo) is det. mlds_output_stmt(Indent, FuncInfo, block(Defns, Statements), Context, !IO) :- mlds_indent(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), ( Defns = [_ | _], FuncInfo = func_info(FuncName, _), @@ -2271,39 +2273,39 @@ mlds_output_stmt(Indent, FuncInfo, block(Defns, Statements), Context, !IO) :- % Output forward declarations for any nested functions defined in % this block, in case they are referenced before they are defined. - list__filter(defn_is_function, Defns, NestedFuncDefns), + list.filter(defn_is_function, Defns, NestedFuncDefns), ( NestedFuncDefns = [_ | _], mlds_output_decls(Indent + 1, ModuleName, NestedFuncDefns, !IO), - io__write_string("\n", !IO) + io.write_string("\n", !IO) ; NestedFuncDefns = [] ), mlds_output_defns(Indent + 1, no, ModuleName, Defns, !IO), - io__write_string("\n", !IO) + io.write_string("\n", !IO) ; Defns = [] ), mlds_output_statements(Indent + 1, FuncInfo, Statements, !IO), mlds_indent(Context, Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). mlds_output_stmt(Indent, FuncInfo, while(Cond, Statement, no), _, !IO) :- mlds_indent(Indent, !IO), - io__write_string("while (", !IO), + io.write_string("while (", !IO), mlds_output_rval(Cond, !IO), - io__write_string(")\n", !IO), + io.write_string(")\n", !IO), mlds_output_statement(Indent + 1, FuncInfo, Statement, !IO). mlds_output_stmt(Indent, FuncInfo, while(Cond, Statement, yes), Context, !IO) :- mlds_indent(Indent, !IO), - io__write_string("do\n", !IO), + io.write_string("do\n", !IO), mlds_output_statement(Indent + 1, FuncInfo, Statement, !IO), mlds_indent(Context, Indent, !IO), - io__write_string("while (", !IO), + io.write_string("while (", !IO), mlds_output_rval(Cond, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). mlds_output_stmt(Indent, FuncInfo, if_then_else(Cond, Then0, MaybeElse), Context, !IO) :- @@ -2348,14 +2350,14 @@ mlds_output_stmt(Indent, FuncInfo, if_then_else(Cond, Then0, MaybeElse), ), mlds_indent(Indent, !IO), - io__write_string("if (", !IO), + io.write_string("if (", !IO), mlds_output_rval(Cond, !IO), - io__write_string(")\n", !IO), + io.write_string(")\n", !IO), mlds_output_statement(Indent + 1, FuncInfo, Then, !IO), ( MaybeElse = yes(Else), mlds_indent(Context, Indent, !IO), - io__write_string("else\n", !IO), + io.write_string("else\n", !IO), mlds_output_statement(Indent + 1, FuncInfo, Else, !IO) ; MaybeElse = no @@ -2363,16 +2365,16 @@ mlds_output_stmt(Indent, FuncInfo, if_then_else(Cond, Then0, MaybeElse), mlds_output_stmt(Indent, FuncInfo, switch(_Type, Val, _Range, Cases, Default), Context, !IO) :- mlds_indent(Context, Indent, !IO), - io__write_string("switch (", !IO), + io.write_string("switch (", !IO), mlds_output_rval(Val, !IO), - io__write_string(") {\n", !IO), + io.write_string(") {\n", !IO), % we put the default case first, so that if it is unreachable, % it will get merged in with the first case. mlds_output_switch_default(Indent + 1, FuncInfo, Context, Default, !IO), - list__foldl(mlds_output_switch_case(Indent + 1, FuncInfo, Context), + list.foldl(mlds_output_switch_case(Indent + 1, FuncInfo, Context), Cases, !IO), mlds_indent(Context, Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). mlds_output_stmt(Indent, _FuncInfo, label(LabelName), _, !IO) :- % Note: MLDS allows labels at the end of blocks. C doesn't. Hence we need @@ -2381,33 +2383,33 @@ mlds_output_stmt(Indent, _FuncInfo, label(LabelName), _, !IO) :- mlds_indent(Indent - 1, !IO), mlds_output_label_name(LabelName, !IO), - io__write_string(":;\n", !IO). + io.write_string(":;\n", !IO). mlds_output_stmt(Indent, _FuncInfo, goto(label(LabelName)), _, !IO) :- mlds_indent(Indent, !IO), - io__write_string("goto ", !IO), + io.write_string("goto ", !IO), mlds_output_label_name(LabelName, !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). mlds_output_stmt(Indent, _FuncInfo, goto(break), _, !IO) :- mlds_indent(Indent, !IO), - io__write_string("break;\n", !IO). + io.write_string("break;\n", !IO). mlds_output_stmt(Indent, _FuncInfo, goto(continue), _, !IO) :- mlds_indent(Indent, !IO), - io__write_string("continue;\n", !IO). + io.write_string("continue;\n", !IO). mlds_output_stmt(Indent, _FuncInfo, computed_goto(Expr, Labels), Context, !IO) :- % XXX For GNU C, we could output potentially more efficient code % by using an array of labels; this would tell the compiler that % it didn't need to do any range check. mlds_indent(Indent, !IO), - io__write_string("switch (", !IO), + io.write_string("switch (", !IO), mlds_output_rval(Expr, !IO), - io__write_string(") {\n", !IO), - list__foldl2(mlds_output_computed_goto_label(Context, Indent), Labels, + io.write_string(") {\n", !IO), + list.foldl2(mlds_output_computed_goto_label(Context, Indent), Labels, 0, _FinalCount, !IO), mlds_indent(Context, Indent + 1, !IO), - io__write_string("default: /*NOTREACHED*/ MR_assert(0);\n", !IO), + io.write_string("default: /*NOTREACHED*/ MR_assert(0);\n", !IO), mlds_indent(Context, Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). mlds_output_stmt(Indent, CallerFuncInfo, Call, Context, !IO) :- Call = call(Signature, FuncRval, MaybeObject, CallArgs, @@ -2420,7 +2422,7 @@ mlds_output_stmt(Indent, CallerFuncInfo, Call, Context, !IO) :- % and the generated code is e.g. inside an if-then-else. mlds_indent(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), mlds_maybe_output_call_profile_instr(Context, Indent + 1, FuncRval, CallerName, !IO), @@ -2440,8 +2442,8 @@ mlds_output_stmt(Indent, CallerFuncInfo, Call, Context, !IO) :- % can be marked as tail calls if they are known to never return.) mlds_indent(Context, Indent + 1, !IO), - Signature = mlds__func_signature(_, RetTypes), - CallerSignature = mlds__func_signature(_, CallerRetTypes), + Signature = mlds_func_signature(_, RetTypes), + CallerSignature = mlds_func_signature(_, CallerRetTypes), ( ( IsTailCall = tail_call ; IsTailCall = no_return_call @@ -2449,14 +2451,14 @@ mlds_output_stmt(Indent, CallerFuncInfo, Call, Context, !IO) :- Results = [_ | _], RetTypes = CallerRetTypes -> - io__write_string("return ", !IO) + io.write_string("return ", !IO) ; true ), ( MaybeObject = yes(Object), mlds_output_bracketed_rval(Object, !IO), - io__write_string(".", !IO) % XXX should this be "->"? + io.write_string(".", !IO) % XXX should this be "->"? ; MaybeObject = no ), @@ -2465,16 +2467,16 @@ mlds_output_stmt(Indent, CallerFuncInfo, Call, Context, !IO) :- ; Results = [Lval], mlds_output_lval(Lval, !IO), - io__write_string(" = ", !IO) + io.write_string(" = ", !IO) ; Results = [_, _ | _], mlds_output_return_list(Results, mlds_output_lval, !IO), - io__write_string(" = ", !IO) + io.write_string(" = ", !IO) ), mlds_output_bracketed_rval(FuncRval, !IO), - io__write_string("(", !IO), - io__write_list(CallArgs, ", ", mlds_output_rval, !IO), - io__write_string(");\n", !IO), + io.write_string("(", !IO), + io.write_list(CallArgs, ", ", mlds_output_rval, !IO), + io.write_string(");\n", !IO), ( ( IsTailCall = tail_call @@ -2483,36 +2485,36 @@ mlds_output_stmt(Indent, CallerFuncInfo, Call, Context, !IO) :- CallerRetTypes = [] -> mlds_indent(Context, Indent + 1, !IO), - io__write_string("return;\n", !IO) + io.write_string("return;\n", !IO) ; mlds_maybe_output_time_profile_instr(Context, Indent + 1, CallerName, !IO) ), mlds_indent(Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). mlds_output_stmt(Indent, _FuncInfo, return(Results), _, !IO) :- mlds_indent(Indent, !IO), - io__write_string("return", !IO), + io.write_string("return", !IO), ( Results = [] ; Results = [Rval], - io__write_char(' ', !IO), + io.write_char(' ', !IO), mlds_output_rval(Rval, !IO) ; Results = [_, _ | _], mlds_output_return_list(Results, mlds_output_rval, !IO) ), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). mlds_output_stmt(Indent, _FuncInfo, do_commit(Ref), _, !IO) :- mlds_indent(Indent, !IO), - globals__io_lookup_bool_option(gcc_local_labels, GCC_LocalLabels, !IO), + globals.io_lookup_bool_option(gcc_local_labels, GCC_LocalLabels, !IO), ( GCC_LocalLabels = yes, % Output "goto ". - io__write_string("goto ", !IO), + io.write_string("goto ", !IO), mlds_output_rval(Ref, !IO) ; GCC_LocalLabels = no, @@ -2520,14 +2522,14 @@ mlds_output_stmt(Indent, _FuncInfo, do_commit(Ref), _, !IO) :- % to either the standard longjmp() or the GNU C's __builtin_longjmp(). % Note that the second argument to GNU C's __builtin_longjmp() *must* % be `1'. - io__write_string("MR_builtin_longjmp(", !IO), + io.write_string("MR_builtin_longjmp(", !IO), mlds_output_rval(Ref, !IO), - io__write_string(", 1)", !IO) + io.write_string(", 1)", !IO) ), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). mlds_output_stmt(Indent, FuncInfo, try_commit(Ref, Stmt0, Handler), Context, !IO) :- - globals__io_lookup_bool_option(gcc_local_labels, GCC_LocalLabels, !IO), + globals.io_lookup_bool_option(gcc_local_labels, GCC_LocalLabels, !IO), ( GCC_LocalLabels = yes, @@ -2546,19 +2548,19 @@ mlds_output_stmt(Indent, FuncInfo, try_commit(Ref, Stmt0, Handler), Context, mlds_output_statement(Indent, FuncInfo, Stmt0, !IO), mlds_indent(Context, Indent, !IO), - io__write_string("goto ", !IO), + io.write_string("goto ", !IO), mlds_output_lval(Ref, !IO), - io__write_string("_done;\n", !IO), + io.write_string("_done;\n", !IO), mlds_indent(Context, Indent - 1, !IO), mlds_output_lval(Ref, !IO), - io__write_string(":\n", !IO), + io.write_string(":\n", !IO), mlds_output_statement(Indent, FuncInfo, Handler, !IO), mlds_indent(Context, Indent - 1, !IO), mlds_output_lval(Ref, !IO), - io__write_string("_done:\t;\n", !IO) + io.write_string("_done:\t;\n", !IO) ; GCC_LocalLabels = no, @@ -2593,28 +2595,28 @@ mlds_output_stmt(Indent, FuncInfo, try_commit(Ref, Stmt0, Handler), Context, ), mlds_indent(Indent, !IO), - io__write_string("if (MR_builtin_setjmp(", !IO), + io.write_string("if (MR_builtin_setjmp(", !IO), mlds_output_lval(Ref, !IO), - io__write_string(") == 0)\n", !IO), + io.write_string(") == 0)\n", !IO), mlds_output_statement(Indent + 1, FuncInfo, Stmt, !IO), mlds_indent(Context, Indent, !IO), - io__write_string("else\n", !IO), + io.write_string("else\n", !IO), mlds_output_statement(Indent + 1, FuncInfo, Handler, !IO) ). -:- pred mlds_output_computed_goto_label(mlds__context::in, int::in, - mlds__label::in, int::in, int::out, io::di, io::uo) is det. +:- pred mlds_output_computed_goto_label(mlds_context::in, int::in, + mlds_label::in, int::in, int::out, io::di, io::uo) is det. mlds_output_computed_goto_label(Context, Indent, Label, Count0, Count, !IO) :- mlds_indent(Context, Indent + 1, !IO), - io__write_string("case ", !IO), - io__write_int(Count0, !IO), - io__write_string(": goto ", !IO), + io.write_string("case ", !IO), + io.write_int(Count0, !IO), + io.write_string(": goto ", !IO), mlds_output_label_name(Label, !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), Count = Count0 + 1. %-----------------------------------------------------------------------------% @@ -2623,87 +2625,87 @@ mlds_output_computed_goto_label(Context, Indent, Label, Count0, Count, !IO) :- % Extra code for outputting switch statements % -:- pred mlds_output_switch_case(indent::in, func_info::in, mlds__context::in, - mlds__switch_case::in, io::di, io::uo) is det. +:- pred mlds_output_switch_case(indent::in, func_info::in, mlds_context::in, + mlds_switch_case::in, io::di, io::uo) is det. mlds_output_switch_case(Indent, FuncInfo, Context, Case, !IO) :- Case = (Conds - Statement), - list__foldl(mlds_output_case_cond(Indent, Context), Conds, !IO), + list.foldl(mlds_output_case_cond(Indent, Context), Conds, !IO), mlds_output_statement(Indent + 1, FuncInfo, Statement, !IO), mlds_indent(Context, Indent + 1, !IO), - io__write_string("break;\n", !IO). + io.write_string("break;\n", !IO). -:- pred mlds_output_case_cond(indent::in, mlds__context::in, - mlds__case_match_cond::in, io::di, io::uo) is det. +:- pred mlds_output_case_cond(indent::in, mlds_context::in, + mlds_case_match_cond::in, io::di, io::uo) is det. mlds_output_case_cond(Indent, Context, match_value(Val), !IO) :- mlds_indent(Context, Indent, !IO), - io__write_string("case ", !IO), + io.write_string("case ", !IO), mlds_output_rval(Val, !IO), - io__write_string(":\n", !IO). + io.write_string(":\n", !IO). mlds_output_case_cond(Indent, Context, match_range(Low, High), !IO) :- % This uses the GNU C extension `case ... :'. mlds_indent(Context, Indent, !IO), - io__write_string("case ", !IO), + io.write_string("case ", !IO), mlds_output_rval(Low, !IO), - io__write_string(" ... ", !IO), + io.write_string(" ... ", !IO), mlds_output_rval(High, !IO), - io__write_string(":\n", !IO). + io.write_string(":\n", !IO). :- pred mlds_output_switch_default(indent::in, func_info::in, - mlds__context::in, mlds__switch_default::in, io::di, io::uo) is det. + mlds_context::in, mlds_switch_default::in, io::di, io::uo) is det. mlds_output_switch_default(Indent, _FuncInfo, Context, default_is_unreachable, !IO) :- mlds_indent(Context, Indent, !IO), - io__write_string("default: /*NOTREACHED*/ MR_assert(0);\n", !IO). + io.write_string("default: /*NOTREACHED*/ MR_assert(0);\n", !IO). mlds_output_switch_default(_Indent, _FuncInfo, _Context, default_do_nothing, !IO). mlds_output_switch_default(Indent, FuncInfo, Context, default_case(Statement), !IO) :- mlds_indent(Context, Indent, !IO), - io__write_string("default:\n", !IO), + io.write_string("default:\n", !IO), mlds_output_statement(Indent + 1, FuncInfo, Statement, !IO), mlds_indent(Context, Indent + 1, !IO), - io__write_string("break;\n", !IO). + io.write_string("break;\n", !IO). %-----------------------------------------------------------------------------% % If memory profiling is turned on, output an instruction to % record the heap allocation. % -:- pred mlds_maybe_output_heap_profile_instr(mlds__context::in, - indent::in, list(mlds_rval)::in, mlds__qualified_entity_name::in, +:- pred mlds_maybe_output_heap_profile_instr(mlds_context::in, + indent::in, list(mlds_rval)::in, mlds_qualified_entity_name::in, maybe(ctor_name)::in, io::di, io::uo) is det. mlds_maybe_output_heap_profile_instr(Context, Indent, Args, FuncName, MaybeCtorName, !IO) :- - globals__io_lookup_bool_option(profile_memory, ProfileMem, !IO), + globals.io_lookup_bool_option(profile_memory, ProfileMem, !IO), ( ProfileMem = yes, mlds_indent(Context, Indent, !IO), - io__write_string("MR_record_allocation(", !IO), - io__write_int(list__length(Args), !IO), - io__write_string(", ", !IO), + io.write_string("MR_record_allocation(", !IO), + io.write_int(list.length(Args), !IO), + io.write_string(", ", !IO), mlds_output_fully_qualified_name(FuncName, !IO), - io__write_string(", """, !IO), + io.write_string(", """, !IO), mlds_output_fully_qualified_name(FuncName, !IO), - io__write_string(""", ", !IO), + io.write_string(""", ", !IO), ( MaybeCtorName = yes(CtorId), - io__write_char('"', !IO), + io.write_char('"', !IO), CtorId = qual(_ModuleName, _QualKind, CtorDefn), CtorDefn = ctor_id(CtorName, _CtorArity), - c_util__output_quoted_string(CtorName, !IO), - io__write_char('"', !IO) + c_util.output_quoted_string(CtorName, !IO), + io.write_char('"', !IO) ; MaybeCtorName = no, % Just use an empty string. Note that we can't use a null pointer % here, because MR_record_allocation() requires its string % arguments to not be NULL. - io__write_string("\"\"", !IO) + io.write_string("\"\"", !IO) ), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; ProfileMem = no ). @@ -2711,20 +2713,20 @@ mlds_maybe_output_heap_profile_instr(Context, Indent, Args, FuncName, % If call profiling is turned on output an instruction to record % an arc in the call profile between the callee and caller. % -:- pred mlds_maybe_output_call_profile_instr(mlds__context::in, indent::in, - mlds_rval::in, mlds__qualified_entity_name::in, io::di, io::uo) is det. +:- pred mlds_maybe_output_call_profile_instr(mlds_context::in, indent::in, + mlds_rval::in, mlds_qualified_entity_name::in, io::di, io::uo) is det. mlds_maybe_output_call_profile_instr(Context, Indent, CalleeFuncRval, CallerName, !IO) :- - globals__io_lookup_bool_option(profile_calls, ProfileCalls, !IO), + globals.io_lookup_bool_option(profile_calls, ProfileCalls, !IO), ( ProfileCalls = yes, mlds_indent(Context, Indent, !IO), - io__write_string("MR_prof_call_profile(", !IO), + io.write_string("MR_prof_call_profile(", !IO), mlds_output_bracketed_rval(CalleeFuncRval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_fully_qualified_name(CallerName, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; ProfileCalls = no ). @@ -2732,17 +2734,17 @@ mlds_maybe_output_call_profile_instr(Context, Indent, % If time profiling is turned on output an instruction which informs % the runtime which procedure we are currently located in. % -:- pred mlds_maybe_output_time_profile_instr(mlds__context::in, - indent::in, mlds__qualified_entity_name::in, io::di, io::uo) is det. +:- pred mlds_maybe_output_time_profile_instr(mlds_context::in, + indent::in, mlds_qualified_entity_name::in, io::di, io::uo) is det. mlds_maybe_output_time_profile_instr(Context, Indent, Name, !IO) :- - globals__io_lookup_bool_option(profile_time, ProfileTime, !IO), + globals.io_lookup_bool_option(profile_time, ProfileTime, !IO), ( ProfileTime = yes, mlds_indent(Context, Indent, !IO), - io__write_string("MR_set_prof_current_proc(", !IO), + io.write_string("MR_set_prof_current_proc(", !IO), mlds_output_fully_qualified_name(Name, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ; ProfileTime = no ). @@ -2752,28 +2754,28 @@ mlds_maybe_output_time_profile_instr(Context, Indent, Name, !IO) :- mlds_output_stmt(Indent, FuncInfo, atomic(AtomicStatement), Context, !IO) :- mlds_output_atomic_stmt(Indent, FuncInfo, AtomicStatement, Context, !IO). -:- pred mlds_output_label_name(mlds__label::in, io::di, io::uo) is det. +:- pred mlds_output_label_name(mlds_label::in, io::di, io::uo) is det. mlds_output_label_name(LabelName, !IO) :- mlds_output_mangled_name(LabelName, !IO). :- pred mlds_output_atomic_stmt(indent::in, func_info::in, - mlds__atomic_statement::in, mlds__context::in, io::di, io::uo) is det. + mlds_atomic_statement::in, mlds_context::in, io::di, io::uo) is det. mlds_output_atomic_stmt(Indent, _FuncInfo, comment(Comment), _, !IO) :- % XXX We should escape any "*/"'s in the Comment. We should also split % the comment into lines and indent each line appropriately. mlds_indent(Indent, !IO), - io__write_string("/* ", !IO), - io__write_string(Comment, !IO), - io__write_string(" */\n", !IO). + io.write_string("/* ", !IO), + io.write_string(Comment, !IO), + io.write_string(" */\n", !IO). mlds_output_atomic_stmt(Indent, _FuncInfo, assign(Lval, Rval), _, !IO) :- mlds_indent(Indent, !IO), mlds_output_lval(Lval, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), mlds_output_rval(Rval, !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). mlds_output_atomic_stmt(_Indent, _FuncInfo, delete_object(_Lval), _, !IO) :- sorry(this_file, "delete_object not implemented"). @@ -2782,7 +2784,7 @@ mlds_output_atomic_stmt(Indent, FuncInfo, NewObject, Context, !IO) :- NewObject = new_object(Target, MaybeTag, _HasSecTag, Type, MaybeSize, MaybeCtorName, Args, ArgTypes), mlds_indent(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), % When filling in the fields of a newly allocated cell, use a fresh % local variable as the base address for the field references in @@ -2800,18 +2802,18 @@ mlds_output_atomic_stmt(Indent, FuncInfo, NewObject, Context, !IO) :- Base = string(BaseVarName), mlds_indent(Context, Indent + 1, !IO), mlds_output_type_prefix(Type, !IO), - io__write_string(" ", !IO), - io__write_string(BaseVarName, !IO), + io.write_string(" ", !IO), + io.write_string(BaseVarName, !IO), mlds_output_type_suffix(Type, !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ), % For --gc accurate, we need to insert a call to GC_check() % before every allocation. - globals__io_get_gc_method(GC_Method, !IO), + globals.io_get_gc_method(GC_Method, !IO), ( GC_Method = accurate -> mlds_indent(Context, Indent + 1, !IO), - io__write_string("MR_GC_check();\n", !IO), + io.write_string("MR_GC_check();\n", !IO), % For types which hold RTTI that will be traversed by the collector % at GC-time, we need to allocate an extra word at the start, to hold % the forwarding pointer. Normally we would just overwrite the first @@ -2820,10 +2822,10 @@ mlds_output_atomic_stmt(Indent, FuncInfo, NewObject, Context, !IO) :- % process. ( type_needs_forwarding_pointer_space(Type) = yes -> mlds_indent(Context, Indent + 1, !IO), - io__write_string("/* reserve space for " ++ + io.write_string("/* reserve space for " ++ "GC forwarding pointer*/\n", !IO), mlds_indent(Context, Indent + 1, !IO), - io__write_string("MR_hp_alloc(1);\n", !IO) + io.write_string("MR_hp_alloc(1);\n", !IO) ; true ) @@ -2837,14 +2839,14 @@ mlds_output_atomic_stmt(Indent, FuncInfo, NewObject, Context, !IO) :- mlds_indent(Context, Indent + 1, !IO), write_lval_or_string(Base, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), ( MaybeTag = yes(Tag0), Tag = Tag0, mlds_output_cast(Type, !IO), - io__write_string("MR_mkword(", !IO), + io.write_string("MR_mkword(", !IO), mlds_output_tag(Tag, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), EndMkword = ")" ; MaybeTag = no, @@ -2854,64 +2856,64 @@ mlds_output_atomic_stmt(Indent, FuncInfo, NewObject, Context, !IO) :- mlds_output_cast(Type, !IO), EndMkword = "" ), - io__write_string("MR_new_object(", !IO), + io.write_string("MR_new_object(", !IO), mlds_output_type(Type, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ( MaybeSize = yes(Size), - io__write_string("(", !IO), + io.write_string("(", !IO), mlds_output_rval(Size, !IO), - io__write_string(" * sizeof(MR_Word))", !IO) + io.write_string(" * sizeof(MR_Word))", !IO) ; MaybeSize = no, % XXX what should we do here? - io__write_int(-1, !IO) + io.write_int(-1, !IO) ), - io__write_string(", ", !IO), + io.write_string(", ", !IO), ( MaybeCtorName = yes(QualifiedCtorId), - io__write_char('"', !IO), + io.write_char('"', !IO), QualifiedCtorId = qual(_ModuleName, _QualKind, CtorDefn), CtorDefn = ctor_id(CtorName, _CtorArity), - c_util__output_quoted_string(CtorName, !IO), - io__write_char('"', !IO) + c_util.output_quoted_string(CtorName, !IO), + io.write_char('"', !IO) ; MaybeCtorName = no, - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ), - io__write_string(")", !IO), - io__write_string(EndMkword, !IO), - io__write_string(";\n", !IO), + io.write_string(")", !IO), + io.write_string(EndMkword, !IO), + io.write_string(";\n", !IO), ( Base = lval(_) ; Base = string(BaseVarName1), mlds_indent(Context, Indent + 1, !IO), mlds_output_lval(Target, !IO), - io__write_string(" = ", !IO), - io__write_string(BaseVarName1, !IO), - io__write_string(";\n", !IO) + io.write_string(" = ", !IO), + io.write_string(BaseVarName1, !IO), + io.write_string(";\n", !IO) ), mlds_output_init_args(Args, ArgTypes, Context, 0, Base, Tag, Indent + 1, !IO), mlds_indent(Context, Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). mlds_output_atomic_stmt(Indent, _FuncInfo, gc_check, _, !IO) :- mlds_indent(Indent, !IO), - io__write_string("MR_GC_check();\n", !IO). + io.write_string("MR_GC_check();\n", !IO). mlds_output_atomic_stmt(Indent, _FuncInfo, mark_hp(Lval), _, !IO) :- mlds_indent(Indent, !IO), - io__write_string("MR_mark_hp(", !IO), + io.write_string("MR_mark_hp(", !IO), mlds_output_lval(Lval, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). mlds_output_atomic_stmt(Indent, _FuncInfo, restore_hp(Rval), _, !IO) :- mlds_indent(Indent, !IO), - io__write_string("MR_restore_hp(", !IO), + io.write_string("MR_restore_hp(", !IO), mlds_output_rval(Rval, !IO), - io__write_string(");\n", !IO). + io.write_string(");\n", !IO). mlds_output_atomic_stmt(_Indent, _FuncInfo, trail_op(_TrailOp), _, !IO) :- sorry(this_file, "trail_ops not implemented"). @@ -2919,7 +2921,7 @@ mlds_output_atomic_stmt(_Indent, _FuncInfo, trail_op(_TrailOp), _, !IO) :- mlds_output_atomic_stmt(_Indent, _FuncInfo, inline_target_code(TargetLang, Components), Context, !IO) :- ( TargetLang = lang_C -> - list__foldl(mlds_output_target_code_component(Context), Components, + list.foldl(mlds_output_target_code_component(Context), Components, !IO) ; sorry(this_file, "inline_target_code only works for lang_C") @@ -2929,13 +2931,13 @@ mlds_output_atomic_stmt(_Indent, _FuncInfo, outline_foreign_proc(_Lang, _Vs, _Lvals, _Code), _Context, !IO) :- unexpected(this_file, "outline_foreign_proc is not used in C backend"). -:- pred mlds_output_target_code_component(mlds__context::in, +:- pred mlds_output_target_code_component(mlds_context::in, target_code_component::in, io::di, io::uo) is det. % Note: `name(Name)' target_code_components are used to % generate the #define for `MR_PROC_LABEL'. % The fact that they're used in a #define means that we can't do - % an mlds_to_c__output_context(Context) here, since #line directives + % an output_context(Context) here, since #line directives % aren't allowed inside #defines. % Similarly, all the target_code_components except user_target_code % can get emitted inside calls to the MR_BOX_FOREIGN_TYPE @@ -2947,53 +2949,53 @@ mlds_output_target_code_component(Context, user_target_code(CodeString, MaybeUserContext, _Attrs), !IO) :- ( MaybeUserContext = yes(UserContext), - mlds_to_c__output_context(mlds__make_context(UserContext), !IO) + output_context(mlds_make_context(UserContext), !IO) ; MaybeUserContext = no, - mlds_to_c__output_context(Context, !IO) + output_context(Context, !IO) ), - io__write_string(CodeString, !IO), - io__write_string("\n", !IO), - mlds_to_c__reset_context(!IO). + io.write_string(CodeString, !IO), + io.write_string("\n", !IO), + reset_context(!IO). mlds_output_target_code_component(_Context, raw_target_code(CodeString, _Attrs), !IO) :- - io__write_string(CodeString, !IO). + io.write_string(CodeString, !IO). mlds_output_target_code_component(_Context, target_code_input(Rval), !IO) :- mlds_output_rval(Rval, !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). mlds_output_target_code_component(_Context, target_code_output(Lval), !IO) :- mlds_output_lval(Lval, !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). mlds_output_target_code_component(_Context, name(Name), !IO) :- mlds_output_fully_qualified_name(Name, !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). :- func type_needs_forwarding_pointer_space(mlds_type) = bool. -type_needs_forwarding_pointer_space(mlds__type_info_type) = yes. -type_needs_forwarding_pointer_space(mlds__pseudo_type_info_type) = yes. +type_needs_forwarding_pointer_space(mlds_type_info_type) = yes. +type_needs_forwarding_pointer_space(mlds_pseudo_type_info_type) = yes. type_needs_forwarding_pointer_space(mercury_type(_, TypeCategory, _)) = is_introduced_type_info_type_category(TypeCategory). -type_needs_forwarding_pointer_space(mercury_array_type(_)) = no. -type_needs_forwarding_pointer_space(mlds__cont_type(_)) = no. -type_needs_forwarding_pointer_space(mlds__commit_type) = no. -type_needs_forwarding_pointer_space(mlds__native_bool_type) = no. -type_needs_forwarding_pointer_space(mlds__native_int_type) = no. -type_needs_forwarding_pointer_space(mlds__native_float_type) = no. -type_needs_forwarding_pointer_space(mlds__native_char_type) = no. -type_needs_forwarding_pointer_space(mlds__foreign_type(_)) = no. -type_needs_forwarding_pointer_space(mlds__class_type(_, _, _)) = no. -type_needs_forwarding_pointer_space(mlds__array_type(_)) = no. -type_needs_forwarding_pointer_space(mlds__ptr_type(_)) = no. -type_needs_forwarding_pointer_space(mlds__func_type(_)) = no. -type_needs_forwarding_pointer_space(mlds__generic_type) = no. -type_needs_forwarding_pointer_space(mlds__generic_env_ptr_type) = no. -type_needs_forwarding_pointer_space(mlds__rtti_type(_)) = _ :- +type_needs_forwarding_pointer_space(mlds_mercury_array_type(_)) = no. +type_needs_forwarding_pointer_space(mlds_cont_type(_)) = no. +type_needs_forwarding_pointer_space(mlds_commit_type) = no. +type_needs_forwarding_pointer_space(mlds_native_bool_type) = no. +type_needs_forwarding_pointer_space(mlds_native_int_type) = no. +type_needs_forwarding_pointer_space(mlds_native_float_type) = no. +type_needs_forwarding_pointer_space(mlds_native_char_type) = no. +type_needs_forwarding_pointer_space(mlds_foreign_type(_)) = no. +type_needs_forwarding_pointer_space(mlds_class_type(_, _, _)) = no. +type_needs_forwarding_pointer_space(mlds_array_type(_)) = no. +type_needs_forwarding_pointer_space(mlds_ptr_type(_)) = no. +type_needs_forwarding_pointer_space(mlds_func_type(_)) = no. +type_needs_forwarding_pointer_space(mlds_generic_type) = no. +type_needs_forwarding_pointer_space(mlds_generic_env_ptr_type) = no. +type_needs_forwarding_pointer_space(mlds_rtti_type(_)) = _ :- % These should all be statically allocated, not dynamically allocated, % so we should never get here. unexpected(this_file, "type_needs_forwarding_pointer_space: rtti_type"). -type_needs_forwarding_pointer_space(mlds__unknown_type) = _ :- +type_needs_forwarding_pointer_space(mlds_unknown_type) = _ :- unexpected(this_file, "type_needs_forwarding_pointer_space: unknown_type"). :- type lval_or_string @@ -3001,12 +3003,12 @@ type_needs_forwarding_pointer_space(mlds__unknown_type) = _ :- ; string(string). :- pred mlds_output_init_args(list(mlds_rval)::in, list(mlds_type)::in, - mlds__context::in, int::in, lval_or_string::in, mlds_tag::in, + mlds_context::in, int::in, lval_or_string::in, mlds_tag::in, indent::in, io::di, io::uo) is det. -mlds_output_init_args([_|_], [], _, _, _, _, _, !IO) :- +mlds_output_init_args([_ | _], [], _, _, _, _, _, !IO) :- unexpected(this_file, "mlds_output_init_args: length mismatch"). -mlds_output_init_args([], [_|_], _, _, _, _, _, !IO) :- +mlds_output_init_args([], [_ | _], _, _, _, _, _, !IO) :- unexpected(this_file, "mlds_output_init_args: length mismatch"). mlds_output_init_args([], [], _, _, _, _, _, !IO). mlds_output_init_args([Arg | Args], [ArgType | ArgTypes], Context, @@ -3020,15 +3022,15 @@ mlds_output_init_args([Arg | Args], [ArgType | ArgTypes], Context, % MR_hl_field() macro. mlds_indent(Context, Indent, !IO), - io__write_string("MR_hl_field(", !IO), + io.write_string("MR_hl_field(", !IO), mlds_output_tag(Tag, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), write_lval_or_string(Base, !IO), - io__write_string(", ", !IO), - io__write_int(ArgNum, !IO), - io__write_string(") = ", !IO), + io.write_string(", ", !IO), + io.write_int(ArgNum, !IO), + io.write_string(") = ", !IO), mlds_output_boxed_rval(ArgType, Arg, !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), mlds_output_init_args(Args, ArgTypes, Context, ArgNum + 1, Base, Tag, Indent, !IO). @@ -3040,7 +3042,7 @@ write_lval_or_string(Base, !IO) :- mlds_output_lval(Target, !IO) ; Base = string(BaseVarName), - io__write_string(BaseVarName, !IO) + io.write_string(BaseVarName, !IO) ). %-----------------------------------------------------------------------------% @@ -3053,11 +3055,11 @@ write_lval_or_string(Base, !IO) :- mlds_output_lval(field(MaybeTag, Rval, offset(OffsetRval), FieldType, _ClassType), !IO) :- ( - ( FieldType = mlds__generic_type - ; FieldType = mlds__mercury_type(variable(_, _), _, _) + ( FieldType = mlds_generic_type + ; FieldType = mercury_type(variable(_, _), _, _) ) -> - io__write_string("(", !IO) + io.write_string("(", !IO) ; % The field type for field(_, _, offset(_), _, _) lvals % must be something that maps to MR_Box. @@ -3065,21 +3067,21 @@ mlds_output_lval(field(MaybeTag, Rval, offset(OffsetRval), ), ( MaybeTag = yes(Tag), - io__write_string("MR_hl_field(", !IO), + io.write_string("MR_hl_field(", !IO), mlds_output_tag(Tag, !IO), - io__write_string(", ", !IO) + io.write_string(", ", !IO) ; MaybeTag = no, - io__write_string("MR_hl_mask_field(", !IO), - io__write_string("(MR_Word) ", !IO) + io.write_string("MR_hl_mask_field(", !IO), + io.write_string("(MR_Word) ", !IO) ), mlds_output_rval(Rval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_rval(OffsetRval, !IO), - io__write_string("))", !IO). + io.write_string("))", !IO). mlds_output_lval(field(MaybeTag, PtrRval, named_field(FieldName, CtorType), _FieldType, PtrType), !IO) :- - io__write_string("(", !IO), + io.write_string("(", !IO), ( MaybeTag = yes(0) -> ( PtrType \= CtorType -> mlds_output_cast(CtorType, !IO) @@ -3088,39 +3090,39 @@ mlds_output_lval(field(MaybeTag, PtrRval, named_field(FieldName, CtorType), ), ( PtrRval = mem_addr(Lval) -> mlds_output_lval(Lval, !IO), - io__write_string(").", !IO) + io.write_string(").", !IO) ; mlds_output_bracketed_rval(PtrRval, !IO), - io__write_string(")->", !IO) + io.write_string(")->", !IO) ) ; mlds_output_cast(CtorType, !IO), ( MaybeTag = yes(Tag), - io__write_string("MR_body(", !IO), + io.write_string("MR_body(", !IO), mlds_output_rval(PtrRval, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_tag(Tag, !IO) ; MaybeTag = no, - io__write_string("MR_strip_tag(", !IO), + io.write_string("MR_strip_tag(", !IO), mlds_output_rval(PtrRval, !IO) ), - io__write_string("))->", !IO) + io.write_string("))->", !IO) ), mlds_output_fully_qualified(FieldName, mlds_output_mangled_name, !IO). mlds_output_lval(mem_ref(Rval, _Type), !IO) :- - io__write_string("*", !IO), + io.write_string("*", !IO), mlds_output_bracketed_rval(Rval, !IO). mlds_output_lval(var(VarName, _VarType), !IO) :- mlds_output_var(VarName, !IO). -:- pred mlds_output_var(mlds__var::in, io::di, io::uo) is det. +:- pred mlds_output_var(mlds_var::in, io::di, io::uo) is det. mlds_output_var(VarName, !IO) :- mlds_output_fully_qualified(VarName, mlds_output_var_name, !IO). -:- pred mlds_output_var_name(mlds__var_name::in, io::di, io::uo) is det. +:- pred mlds_output_var_name(mlds_var_name::in, io::di, io::uo) is det. mlds_output_var_name(VarName, !IO) :- mlds_output_mangled_name(ml_var_name_to_string(VarName), !IO). @@ -3128,7 +3130,7 @@ mlds_output_var_name(VarName, !IO) :- :- pred mlds_output_mangled_name(string::in, io::di, io::uo) is det. mlds_output_mangled_name(Name, !IO) :- - io__write_string(name_mangle(Name), !IO). + io.write_string(name_mangle(Name), !IO). :- pred mlds_output_bracketed_lval(mlds_lval::in, io::di, io::uo) is det. @@ -3139,9 +3141,9 @@ mlds_output_bracketed_lval(Lval, !IO) :- -> mlds_output_lval(Lval, !IO) ; - io__write_char('(', !IO), + io.write_char('(', !IO), mlds_output_lval(Lval, !IO), - io__write_char(')', !IO) + io.write_char(')', !IO) ). :- pred mlds_output_bracketed_rval(mlds_rval::in, io::di, io::uo) is det. @@ -3155,9 +3157,9 @@ mlds_output_bracketed_rval(Rval, !IO) :- -> mlds_output_rval(Rval, !IO) ; - io__write_char('(', !IO), + io.write_char('(', !IO), mlds_output_rval(Rval, !IO), - io__write_char(')', !IO) + io.write_char(')', !IO) ). % mlds_output_return_list(List, OutputPred, IO0, IO) outputs a List @@ -3172,10 +3174,10 @@ mlds_output_return_list(List, OutputPred, !IO) :- % to be handled for e.g. MLDS dumps when compiling to Java. We generate % an "#error" directive to make the error message clearer, but then we go % ahead and generate C-like psuedo-code for the purposes of MLDS dumps. - io__write_string("\n#error multiple return values\n", !IO), - io__write_string("\t{", !IO), - io__write_list(List, ", ", OutputPred, !IO), - io__write_string("}", !IO). + io.write_string("\n#error multiple return values\n", !IO), + io.write_string("\t{", !IO), + io.write_list(List, ", ", OutputPred, !IO), + io.write_string("}", !IO). :- pred mlds_output_rval(mlds_rval::in, io::di, io::uo) is det. @@ -3190,26 +3192,26 @@ mlds_output_rval(lval(Lval), !IO) :- % % and similarly for MR_mask_field. % ( Lval = field(MaybeTag, Rval, FieldNum, _, _) -> % ( MaybeTag = yes(Tag) -> -% io__write_string("MR_hl_const_field(", !IO), +% io.write_string("MR_hl_const_field(", !IO), % mlds_output_tag(Tag, !IO), -% io__write_string(", ", !IO) +% io.write_string(", ", !IO) % ; -% io__write_string("MR_hl_const_mask_field(", !IO) +% io.write_string("MR_hl_const_mask_field(", !IO) % ), % mlds_output_rval(Rval, !IO), -% io__write_string(", ", !IO), +% io.write_string(", ", !IO), % mlds_output_rval(FieldNum, !IO), -% io__write_string(")", !IO) +% io.write_string(")", !IO) % ; % mlds_output_lval(Lval, !IO) % ). mlds_output_rval(mkword(Tag, Rval), !IO) :- - io__write_string("MR_mkword(", !IO), + io.write_string("MR_mkword(", !IO), mlds_output_tag(Tag, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_rval(Rval, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). mlds_output_rval(const(Const), !IO) :- mlds_output_rval_const(Const, !IO). @@ -3222,11 +3224,11 @@ mlds_output_rval(binop(Op, Rval1, Rval2), !IO) :- mlds_output_rval(mem_addr(Lval), !IO) :- % XXX are parentheses needed? - io__write_string("&", !IO), + io.write_string("&", !IO), mlds_output_lval(Lval, !IO). mlds_output_rval(self(_), !IO) :- - io__write_string("this", !IO). + io.write_string("this", !IO). :- pred mlds_output_unop(mlds_unary_op::in, mlds_rval::in, io::di, io::uo) is det. @@ -3250,17 +3252,17 @@ mlds_output_cast_rval(Type, Exprn, !IO) :- :- pred mlds_output_cast(mlds_type::in, io::di, io::uo) is det. mlds_output_cast(Type, !IO) :- - io__write_string("(", !IO), + io.write_string("(", !IO), mlds_output_type(Type, !IO), - io__write_string(") ", !IO). + io.write_string(") ", !IO). :- pred mlds_output_boxed_rval(mlds_type::in, mlds_rval::in, io::di, io::uo) is det. mlds_output_boxed_rval(Type, Exprn, !IO) :- ( - ( Type = mlds__generic_type - ; Type = mlds__mercury_type(_, type_cat_variable, _) + ( Type = mlds_generic_type + ; Type = mercury_type(_, type_cat_variable, _) ) -> % It already has type MR_Box, so no cast is needed. @@ -3276,30 +3278,30 @@ mlds_output_boxed_rval(Type, Exprn, !IO) :- % from pointers to integers in static initializers. mlds_output_boxed_rval(Type, InnerExprn, !IO) ; - ( Type = mlds__mercury_type(builtin(float), _, _) - ; Type = mlds__native_float_type + ( Type = mercury_type(builtin(float), _, _) + ; Type = mlds_native_float_type ) -> - io__write_string("MR_box_float(", !IO), + io.write_string("MR_box_float(", !IO), mlds_output_rval(Exprn, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - ( Type = mlds__mercury_type(builtin(character), _, _) - ; Type = mlds__native_char_type - ; Type = mlds__native_bool_type - ; Type = mlds__native_int_type + ( Type = mercury_type(builtin(character), _, _) + ; Type = mlds_native_char_type + ; Type = mlds_native_bool_type + ; Type = mlds_native_int_type ) -> % We cast first to MR_Word, and then to MR_Box. % This is done to avoid spurious warnings about "cast from % integer to pointer of different size" from gcc. - io__write_string("((MR_Box) (MR_Word) (", !IO), + io.write_string("((MR_Box) (MR_Word) (", !IO), mlds_output_rval(Exprn, !IO), - io__write_string("))", !IO) + io.write_string("))", !IO) ; - io__write_string("((MR_Box) (", !IO), + io.write_string("((MR_Box) (", !IO), mlds_output_rval(Exprn, !IO), - io__write_string("))", !IO) + io.write_string("))", !IO) ). % Succeed if the specified rval is an address (possibly tagged and/or @@ -3321,51 +3323,51 @@ is_an_address(const(data_addr_const(_))). mlds_output_unboxed_rval(Type, Exprn, !IO) :- ( - ( Type = mlds__mercury_type(builtin(float), _, _) - ; Type = mlds__native_float_type + ( Type = mercury_type(builtin(float), _, _) + ; Type = mlds_native_float_type ) -> - io__write_string("MR_unbox_float(", !IO), + io.write_string("MR_unbox_float(", !IO), mlds_output_rval(Exprn, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - ( Type = mlds__mercury_type(builtin(character), _, _) - ; Type = mlds__native_char_type - ; Type = mlds__native_bool_type - ; Type = mlds__native_int_type + ( Type = mercury_type(builtin(character), _, _) + ; Type = mlds_native_char_type + ; Type = mlds_native_bool_type + ; Type = mlds_native_int_type ) -> % We cast first to MR_Word, and then to the desired type. % This is done to avoid spurious warnings about "cast from % pointer to integer of different size" from gcc. - io__write_string("(", !IO), + io.write_string("(", !IO), mlds_output_cast(Type, !IO), - io__write_string("(MR_Word) ", !IO), + io.write_string("(MR_Word) ", !IO), mlds_output_rval(Exprn, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - io__write_string("(", !IO), + io.write_string("(", !IO), mlds_output_cast(Type, !IO), mlds_output_rval(Exprn, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). -:- pred mlds_output_std_unop(builtin_ops__unary_op::in, mlds_rval::in, +:- pred mlds_output_std_unop(builtin_ops.unary_op::in, mlds_rval::in, io::di, io::uo) is det. mlds_output_std_unop(UnaryOp, Exprn, !IO) :- - c_util__unary_prefix_op(UnaryOp, UnaryOpString), - io__write_string(UnaryOpString, !IO), - io__write_string("(", !IO), + c_util.unary_prefix_op(UnaryOp, UnaryOpString), + io.write_string(UnaryOpString, !IO), + io.write_string("(", !IO), ( UnaryOp = tag -> % The MR_tag macro requires its argument to be of type `MR_Word'. % XXX Should we put this cast inside the definition of MR_tag? - io__write_string("(MR_Word) ", !IO) + io.write_string("(MR_Word) ", !IO) ; true ), mlds_output_rval(Exprn, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). :- pred mlds_output_binop(binary_op::in, mlds_rval::in, mlds_rval::in, io::di, io::uo) is det. @@ -3375,45 +3377,45 @@ mlds_output_binop(Op, X, Y, !IO) :- Op = array_index(_Type) -> mlds_output_bracketed_rval(X, !IO), - io__write_string("[", !IO), + io.write_string("[", !IO), mlds_output_rval(Y, !IO), - io__write_string("]", !IO) + io.write_string("]", !IO) ; Op = body -> - io__write_string("MR_body(", !IO), + io.write_string("MR_body(", !IO), mlds_output_rval(X, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_rval(Y, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - c_util__string_compare_op(Op, OpStr) + c_util.string_compare_op(Op, OpStr) -> - io__write_string("(strcmp(", !IO), + io.write_string("(strcmp(", !IO), mlds_output_rval(X, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), mlds_output_rval(Y, !IO), - io__write_string(")", !IO), - io__write_string(" ", !IO), - io__write_string(OpStr, !IO), - io__write_string(" ", !IO), - io__write_string("0)", !IO) + io.write_string(")", !IO), + io.write_string(" ", !IO), + io.write_string(OpStr, !IO), + io.write_string(" ", !IO), + io.write_string("0)", !IO) ; - ( c_util__float_compare_op(Op, OpStr1) -> + ( c_util.float_compare_op(Op, OpStr1) -> OpStr = OpStr1 - ; c_util__float_op(Op, OpStr2) -> + ; c_util.float_op(Op, OpStr2) -> OpStr = OpStr2 ; fail ) -> - io__write_string("(", !IO), + io.write_string("(", !IO), mlds_output_bracketed_rval(X, !IO), - io__write_string(" ", !IO), - io__write_string(OpStr, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), + io.write_string(OpStr, !IO), + io.write_string(" ", !IO), mlds_output_bracketed_rval(Y, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; % XXX Broken for C == minint, (since `NewC is 0 - C' overflows) % Op = (+), @@ -3423,28 +3425,28 @@ mlds_output_binop(Op, X, Y, !IO) :- % NewOp = (-), % NewC is 0 - C, % NewY = const(int_const(NewC)), -% io__write_string("(", !IO), +% io.write_string("(", !IO), % mlds_output_rval(X, !IO), -% io__write_string(" ", !IO), +% io.write_string(" ", !IO), % mlds_output_binary_op(NewOp, !IO), -% io__write_string(" ", !IO), +% io.write_string(" ", !IO), % mlds_output_rval(NewY, !IO), -% io__write_string(")", !IO) +% io.write_string(")", !IO) % ; - io__write_string("(", !IO), + io.write_string("(", !IO), mlds_output_rval(X, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), mlds_output_binary_op(Op, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), mlds_output_rval(Y, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred mlds_output_binary_op(binary_op::in, io::di, io::uo) is det. mlds_output_binary_op(Op, !IO) :- - ( c_util__binary_infix_op(Op, OpStr) -> - io__write_string(OpStr, !IO) + ( c_util.binary_infix_op(Op, OpStr) -> + io.write_string(OpStr, !IO) ; unexpected(this_file, "mlds_output_binary_op: invalid binary operator") @@ -3453,65 +3455,65 @@ mlds_output_binary_op(Op, !IO) :- :- pred mlds_output_rval_const(mlds_rval_const::in, io::di, io::uo) is det. mlds_output_rval_const(true, !IO) :- - io__write_string("MR_TRUE", !IO). + io.write_string("MR_TRUE", !IO). mlds_output_rval_const(false, !IO) :- - io__write_string("MR_FALSE", !IO). + io.write_string("MR_FALSE", !IO). mlds_output_rval_const(int_const(N), !IO) :- % We need to cast to (MR_Integer) to ensure things like 1 << 32 work % when `Integer' is 64 bits but `int' is 32 bits. - io__write_string("(MR_Integer) ", !IO), - io__write_int(N, !IO). + io.write_string("(MR_Integer) ", !IO), + io.write_int(N, !IO). mlds_output_rval_const(float_const(FloatVal), !IO) :- % The cast to (MR_Float) here lets the C compiler do arithmetic in `float' % rather than `double' if `MR_Float' is `float' not `double'. - io__write_string("(MR_Float) ", !IO), - c_util__output_float_literal(FloatVal, !IO). + io.write_string("(MR_Float) ", !IO), + c_util.output_float_literal(FloatVal, !IO). mlds_output_rval_const(string_const(String), !IO) :- % The cast avoids the following gcc warning % "assignment discards qualifiers from pointer target type". - io__write_string("(MR_String) ", !IO), - io__write_string("""", !IO), - c_util__output_quoted_string(String, !IO), - io__write_string("""", !IO). + io.write_string("(MR_String) ", !IO), + io.write_string("""", !IO), + c_util.output_quoted_string(String, !IO), + io.write_string("""", !IO). mlds_output_rval_const(multi_string_const(Length, String), !IO) :- - io__write_string("""", !IO), - c_util__output_quoted_multi_string(Length, String, !IO), - io__write_string("""", !IO). + io.write_string("""", !IO), + c_util.output_quoted_multi_string(Length, String, !IO), + io.write_string("""", !IO). mlds_output_rval_const(code_addr_const(CodeAddr), !IO) :- mlds_output_code_addr(CodeAddr, !IO). mlds_output_rval_const(data_addr_const(DataAddr), !IO) :- mlds_output_data_addr(DataAddr, !IO). mlds_output_rval_const(null(_), !IO) :- - io__write_string("NULL", !IO). + io.write_string("NULL", !IO). %-----------------------------------------------------------------------------% :- pred mlds_output_tag(mlds_tag::in, io::di, io::uo) is det. mlds_output_tag(Tag, !IO) :- - io__write_string("MR_mktag(", !IO), - io__write_int(Tag, !IO), - io__write_string(")", !IO). + io.write_string("MR_mktag(", !IO), + io.write_int(Tag, !IO), + io.write_string(")", !IO). %-----------------------------------------------------------------------------% -:- pred mlds_output_code_addr(mlds__code_addr::in, io::di, io::uo) is det. +:- pred mlds_output_code_addr(mlds_code_addr::in, io::di, io::uo) is det. mlds_output_code_addr(proc(Label, _Sig), !IO) :- mlds_output_fully_qualified_proc_label(Label, !IO). mlds_output_code_addr(internal(Label, SeqNum, _Sig), !IO) :- mlds_output_fully_qualified_proc_label(Label, !IO), - io__write_string("_", !IO), - io__write_int(SeqNum, !IO). + io.write_string("_", !IO), + io.write_int(SeqNum, !IO). -:- pred mlds_output_proc_label(mlds__proc_label::in, io::di, io::uo) is det. +:- pred mlds_output_proc_label(mlds_proc_label::in, io::di, io::uo) is det. mlds_output_proc_label(PredLabel - ProcId, !IO) :- mlds_output_pred_label(PredLabel, !IO), proc_id_to_int(ProcId, ModeNum), - io__format("_%d", [i(ModeNum)], !IO). + io.format("_%d", [i(ModeNum)], !IO). -:- pred mlds_output_data_addr(mlds__data_addr::in, io::di, io::uo) is det. +:- pred mlds_output_data_addr(mlds_data_addr::in, io::di, io::uo) is det. mlds_output_data_addr(data_addr(ModuleName, DataName), !IO) :- ( @@ -3522,12 +3524,12 @@ mlds_output_data_addr(data_addr(ModuleName, DataName), !IO) :- -> mlds_output_data_var_name(ModuleName, DataName, !IO) ; - io__write_string("(&", !IO), + io.write_string("(&", !IO), mlds_output_data_var_name(ModuleName, DataName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). -:- pred mlds_output_data_var_name(mlds_module_name::in, mlds__data_name::in, +:- pred mlds_output_data_var_name(mlds_module_name::in, mlds_data_name::in, io::di, io::uo) is det. mlds_output_data_var_name(ModuleName, DataName, !IO) :- @@ -3538,7 +3540,7 @@ mlds_output_data_var_name(ModuleName, DataName, !IO) :- true ; mlds_output_module_name(mlds_module_name_to_sym_name(ModuleName), !IO), - io__write_string("__", !IO) + io.write_string("__", !IO) ), mlds_output_data_name(DataName, !IO). @@ -3548,21 +3550,21 @@ mlds_output_data_var_name(ModuleName, DataName, !IO) :- % source context annotations (#line directives). % -mlds_to_c__output_context(Context, !IO) :- - ProgContext = mlds__get_prog_context(Context), - term__context_file(ProgContext, FileName), - term__context_line(ProgContext, LineNumber), - c_util__set_line_num(FileName, LineNumber, !IO). +output_context(Context, !IO) :- + ProgContext = mlds_get_prog_context(Context), + term.context_file(ProgContext, FileName), + term.context_line(ProgContext, LineNumber), + c_util.set_line_num(FileName, LineNumber, !IO). -:- pred mlds_to_c__reset_context(io::di, io::uo) is det. +:- pred reset_context(io::di, io::uo) is det. -mlds_to_c__reset_context(!IO) :- - c_util__reset_line_num(!IO). +reset_context(!IO) :- + c_util.reset_line_num(!IO). -:- pred mlds_indent(mlds__context::in, indent::in, io::di, io::uo) is det. +:- pred mlds_indent(mlds_context::in, indent::in, io::di, io::uo) is det. mlds_indent(Context, N, !IO) :- - mlds_to_c__output_context(Context, !IO), + output_context(Context, !IO), mlds_indent(N, !IO). % A value of type `indent' records the number of levels @@ -3576,7 +3578,7 @@ mlds_indent(N, !IO) :- ( N =< 0 -> true ; - io__write_string(" ", !IO), + io.write_string(" ", !IO), mlds_indent(N - 1, !IO) ). diff --git a/compiler/mlds_to_gcc.m b/compiler/mlds_to_gcc.m index d5d44f6e8..2661514bf 100644 --- a/compiler/mlds_to_gcc.m +++ b/compiler/mlds_to_gcc.m @@ -278,7 +278,7 @@ mlds_to_gcc__compile_to_asm(MLDS, ContainsCCode) --> % that were defined in other modules, but to create the `.c' % file if there are foreign_decls that were defined in the % module that we're compiling. - { ForeignCode = mlds__foreign_code(_Decls, _Imports, [], []) }, + { ForeignCode = mlds_foreign_code(_Decls, _Imports, [], []) }, { ForeignDefns = [] } -> { ContainsCCode = no }, @@ -370,9 +370,9 @@ mlds_output_grade_var --> "static const void *const MR_grade = &MR_GRADE_VAR;\n"). ******/ -:- func make_public(mlds__defn) = mlds__defn. -make_public(mlds__defn(Name, Context, Flags0, Defn)) = - mlds__defn(Name, Context, Flags, Defn) :- +:- func make_public(mlds_defn) = mlds_defn. +make_public(mlds_defn(Name, Context, Flags0, Defn)) = + mlds_defn(Name, Context, Flags, Defn) :- Flags = mlds__set_access(Flags0, public). %-----------------------------------------------------------------------------% @@ -402,7 +402,7 @@ gen_init_fn_defns(MLDS_ModuleName, GlobalInfo0, GlobalInfo) --> SymbolTable, LabelTable) }, { term__context_init(Context) }, { FuncBody = statement(block([], []), - mlds__make_context(Context)) }, + mlds_make_context(Context)) }, gcc__start_function(GCC_FuncDecl), gen_statement(DefnInfo, FuncBody), gcc__end_function. @@ -449,8 +449,8 @@ mlds_output_init_fn_decls(ModuleName) --> output_init_fn_name(ModuleName, "_debugger"), io__write_string(";\n"). -:- pred mlds_output_init_fn_defns(mlds_module_name::in, mlds__defns::in, - mlds__defns::in, io__state::di, io__state::uo) is det. +:- pred mlds_output_init_fn_defns(mlds_module_name::in, mlds_defns::in, + mlds_defns::in, io__state::di, io__state::uo) is det. mlds_output_init_fn_defns(ModuleName, FuncDefns, TypeCtorInfoDefns) --> output_init_fn_name(ModuleName, ""), @@ -527,12 +527,12 @@ need_to_init_entries(Globals) :- % Generate calls to MR_init_entry() for the specified functions. % -:- pred mlds_output_calls_to_init_entry(mlds_module_name::in, mlds__defns::in, +:- pred mlds_output_calls_to_init_entry(mlds_module_name::in, mlds_defns::in, io__state::di, io__state::uo) is det. mlds_output_calls_to_init_entry(_ModuleName, []) --> []. mlds_output_calls_to_init_entry(ModuleName, [FuncDefn | FuncDefns]) --> - { FuncDefn = mlds__defn(EntityName, _, _, _) }, + { FuncDefn = mlds_defn(EntityName, _, _, _) }, % Generate a call to MR_insert_entry_label(), which is declared as % MR_insert_entry_label(const char *name, MR_Code *addr, % const MR_Stack_Layout_Entry *entry_layout); @@ -548,12 +548,12 @@ mlds_output_calls_to_init_entry(ModuleName, [FuncDefn | FuncDefns]) --> % type_ctor_infos. % :- pred mlds_output_calls_to_register_tci(mlds_module_name::in, - mlds__defns::in, io__state::di, io__state::uo) is det. + mlds_defns::in, io__state::di, io__state::uo) is det. mlds_output_calls_to_register_tci(_ModuleName, []) --> []. mlds_output_calls_to_register_tci(ModuleName, [TypeCtorInfoDefn | TypeCtorInfoDefns]) --> - { TypeCtorInfoDefn = mlds__defn(EntityName, _, _, _) }, + { TypeCtorInfoDefn = mlds_defn(EntityName, _, _, _) }, io__write_string("\tMR_register_type_ctor_info(&"), mlds_output_fully_qualified_name( qual(ModuleName, module_qual, EntityName)), @@ -573,7 +573,7 @@ The code below is copied from mlds_to_c.m. It shows what we need to do. :- pred mlds_output_pragma_export_decl(mlds_module_name, indent, - mlds__pragma_export, io__state, io__state). + mlds_pragma_export, io__state, io__state). :- mode mlds_output_pragma_export_decl(in, in, in, di, uo) is det. mlds_output_pragma_export_decl(ModuleName, Indent, PragmaExport) --> @@ -581,7 +581,7 @@ mlds_output_pragma_export_decl(ModuleName, Indent, PragmaExport) --> io__write_string(";"). :- pred mlds_output_pragma_export_defn(mlds_module_name, indent, - mlds__pragma_export, io__state, io__state). + mlds_pragma_export, io__state, io__state). :- mode mlds_output_pragma_export_defn(in, in, in, di, uo) is det. mlds_output_pragma_export_defn(ModuleName, Indent, PragmaExport) --> @@ -597,7 +597,7 @@ mlds_output_pragma_export_defn(ModuleName, Indent, PragmaExport) --> io__write_string("}\n"). :- pred mlds_output_pragma_export_func_name(mlds_module_name, indent, - mlds__pragma_export, io__state, io__state). + mlds_pragma_export, io__state, io__state). :- mode mlds_output_pragma_export_func_name(in, in, in, di, uo) is det. mlds_output_pragma_export_func_name(ModuleName, Indent, @@ -620,34 +620,34 @@ mlds_output_pragma_export_type(suffix, _Type) --> []. mlds_output_pragma_export_type(prefix, mercury_type(Type, _)) --> { export__type_to_type_string(Type, String) }, io__write_string(String). -mlds_output_pragma_export_type(prefix, mlds__cont_type(_)) --> +mlds_output_pragma_export_type(prefix, mlds_cont_type(_)) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__commit_type) --> +mlds_output_pragma_export_type(prefix, mlds_commit_type) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__native_bool_type) --> +mlds_output_pragma_export_type(prefix, mlds_native_bool_type) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__native_int_type) --> +mlds_output_pragma_export_type(prefix, mlds_native_int_type) --> io__write_string("MR_Integer"). -mlds_output_pragma_export_type(prefix, mlds__native_float_type) --> +mlds_output_pragma_export_type(prefix, mlds_native_float_type) --> io__write_string("MR_Float"). -mlds_output_pragma_export_type(prefix, mlds__native_char_type) --> +mlds_output_pragma_export_type(prefix, mlds_native_char_type) --> io__write_string("MR_Char"). -mlds_output_pragma_export_type(prefix, mlds__class_type(_, _, _)) --> +mlds_output_pragma_export_type(prefix, mlds_class_type(_, _, _)) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__array_type(_)) --> +mlds_output_pragma_export_type(prefix, mlds_array_type(_)) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__ptr_type(Type)) --> +mlds_output_pragma_export_type(prefix, mlds_ptr_type(Type)) --> mlds_output_pragma_export_type(prefix, Type), io__write_string(" *"). -mlds_output_pragma_export_type(prefix, mlds__func_type(_)) --> +mlds_output_pragma_export_type(prefix, mlds_func_type(_)) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__generic_type) --> +mlds_output_pragma_export_type(prefix, mlds_generic_type) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__generic_env_ptr_type) --> +mlds_output_pragma_export_type(prefix, mlds_generic_env_ptr_type) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__pseudo_type_info_type) --> +mlds_output_pragma_export_type(prefix, mlds_pseudo_type_info_type) --> io__write_string("MR_Word"). -mlds_output_pragma_export_type(prefix, mlds__rtti_type(_)) --> +mlds_output_pragma_export_type(prefix, mlds_rtti_type(_)) --> io__write_string("MR_Word"). @@ -655,11 +655,11 @@ mlds_output_pragma_export_type(prefix, mlds__rtti_type(_)) --> % Output the definition body for a pragma export % :- pred mlds_output_pragma_export_defn_body(mlds_module_name, - mlds__qualified_entity_name, func_params, io__state, io__state). + mlds_qualified_entity_name, func_params, io__state, io__state). :- mode mlds_output_pragma_export_defn_body(in, in, in, di, uo) is det. mlds_output_pragma_export_defn_body(ModuleName, FuncName, Signature) --> - { Signature = mlds__func_params(Parameters, RetTypes) }, + { Signature = mlds_func_params(Parameters, RetTypes) }, ( { RetTypes = [] } -> io__write_string("\t") @@ -684,7 +684,7 @@ mlds_output_pragma_export_defn_body(ModuleName, FuncName, Signature) --> % in the list of the arguments is the return value, so it must % be "&arg" % -:- pred write_func_args(mlds_module_name::in, mlds__arguments::in, +:- pred write_func_args(mlds_module_name::in, mlds_arguments::in, io__state::di, io__state::uo) is det. write_func_args(_ModuleName, []) --> @@ -701,7 +701,7 @@ write_func_args(ModuleName, [Arg | Args]) --> % Output a fully qualified name preceded by a cast. % :- pred mlds_output_name_with_cast(mlds_module_name::in, - pair(mlds__entity_name, mlds_type)::in, + pair(mlds_entity_name, mlds_type)::in, io__state::di, io__state::uo) is det. mlds_output_name_with_cast(ModuleName, Name - Type) --> @@ -717,7 +717,7 @@ mlds_output_name_with_cast(ModuleName, Name - Type) --> % Handle MLDS definitions that occur at global scope. -:- pred gen_defns(mlds_module_name, mlds__defns, global_info, global_info, +:- pred gen_defns(mlds_module_name, mlds_defns, global_info, global_info, io__state, io__state). :- mode gen_defns(in, in, in, out, di, uo) is det. @@ -729,7 +729,7 @@ gen_defns(ModuleName, [Defn | Defns], GlobalInfo0, GlobalInfo) --> % Handle MLDS definitions that are nested inside a % function definition (or inside a block within a function), % and which are hence local to that function. -:- pred build_local_defns(mlds__defns, mlds_module_name, defn_info, defn_info, +:- pred build_local_defns(mlds_defns, mlds_module_name, defn_info, defn_info, io__state, io__state). :- mode build_local_defns(in, in, in, out, di, uo) is det. @@ -742,7 +742,7 @@ build_local_defns([Defn|Defns], ModuleName, DefnInfo0, DefnInfo) --> % nested local variables, so we use map__det_insert rather % than map__set here. (Actually nothing in this module depends % on it, so this sanity check here is perhaps a bit paranoid.) - { Defn = mlds__defn(Name, _, _, _) }, + { Defn = mlds_defn(Name, _, _, _) }, { DefnInfo1 = DefnInfo0 ^ local_vars := map__det_insert(DefnInfo0 ^ local_vars, qual(ModuleName, module_qual, Name), GCC_Defn) }, @@ -750,7 +750,7 @@ build_local_defns([Defn|Defns], ModuleName, DefnInfo0, DefnInfo) --> % Handle MLDS definitions that are nested inside a type, % i.e. fields of that type. -:- pred build_field_defns(mlds__defns, mlds_module_name, global_info, +:- pred build_field_defns(mlds_defns, mlds_module_name, global_info, gcc__field_decls, field_table, field_table, io__state, io__state). :- mode build_field_defns(in, in, in, out, in, out, di, uo) is det. @@ -761,7 +761,7 @@ build_field_defns([Defn|Defns], ModuleName, GlobalInfo, FieldList, FieldTable0, FieldTable) --> build_field_defn(Defn, ModuleName, GlobalInfo, GCC_FieldDefn), % Insert the field definition into our field symbol table. - { Defn = mlds__defn(Name, _, _, _) }, + { Defn = mlds_defn(Name, _, _, _) }, ( { Name = data(var(FieldName)) } -> { GCC_FieldName = ml_var_name_to_string(FieldName) }, { FieldTable1 = map__det_insert(FieldTable0, @@ -774,42 +774,42 @@ build_field_defns([Defn|Defns], ModuleName, GlobalInfo, FieldList, FieldTable1, FieldTable), gcc__cons_field_list(GCC_FieldDefn, FieldList0, FieldList). -:- pred gen_defn(mlds_module_name, mlds__defn, global_info, global_info, +:- pred gen_defn(mlds_module_name, mlds_defn, global_info, global_info, io__state, io__state). :- mode gen_defn(in, in, in, out, di, uo) is det. gen_defn(ModuleName, Defn, GlobalInfo0, GlobalInfo) --> - { Defn = mlds__defn(Name, Context, Flags, DefnBody) }, + { Defn = mlds_defn(Name, Context, Flags, DefnBody) }, gen_defn_body(qual(ModuleName, module_qual, Name), Context, Flags, DefnBody, GlobalInfo0, GlobalInfo). -:- pred build_local_defn(mlds__defn, defn_info, mlds_module_name, +:- pred build_local_defn(mlds_defn, defn_info, mlds_module_name, gcc__var_decl, io__state, io__state). :- mode build_local_defn(in, in, in, out, di, uo) is det. build_local_defn(Defn, DefnInfo, ModuleName, GCC_Defn) --> - { Defn = mlds__defn(Name, Context, Flags, DefnBody) }, + { Defn = mlds_defn(Name, Context, Flags, DefnBody) }, build_local_defn_body(qual(ModuleName, module_qual, Name), DefnInfo, Context, Flags, DefnBody, GCC_Defn). -:- pred build_field_defn(mlds__defn, mlds_module_name, global_info, +:- pred build_field_defn(mlds_defn, mlds_module_name, global_info, gcc__field_decl, io__state, io__state). :- mode build_field_defn(in, in, in, out, di, uo) is det. build_field_defn(Defn, ModuleName, GlobalInfo, GCC_Defn) --> - { Defn = mlds__defn(Name, Context, Flags, DefnBody) }, + { Defn = mlds_defn(Name, Context, Flags, DefnBody) }, build_field_defn_body(qual(ModuleName, type_qual, Name), Context, Flags, DefnBody, GlobalInfo, GCC_Defn). -:- pred gen_defn_body(mlds__qualified_entity_name, - mlds__context, mlds__decl_flags, mlds__entity_defn, +:- pred gen_defn_body(mlds_qualified_entity_name, + mlds_context, mlds_decl_flags, mlds_entity_defn, global_info, global_info, io__state, io__state). :- mode gen_defn_body(in, in, in, in, in, out, di, uo) is det. gen_defn_body(Name, Context, Flags, DefnBody, GlobalInfo0, GlobalInfo) --> ( - { DefnBody = mlds__data(Type, Initializer, _GC_TraceCode) }, + { DefnBody = mlds_data(Type, Initializer, _GC_TraceCode) }, { LocalVars = map__init }, { LabelTable = map__init }, { DefnInfo = defn_info(GlobalInfo0, Name, LocalVars, @@ -830,43 +830,43 @@ gen_defn_body(Name, Context, Flags, DefnBody, GlobalInfo0, GlobalInfo) --> { GlobalVars = map__det_insert(GlobalVars0, Name, GCC_Defn) }, { GlobalInfo = GlobalInfo0 ^ global_vars := GlobalVars } ; - { DefnBody = mlds__function(_MaybePredProcId, Signature, + { DefnBody = mlds_function(_MaybePredProcId, Signature, FunctionBody, _Attributes) }, gen_func(Name, Context, Flags, Signature, FunctionBody, GlobalInfo0, GlobalInfo) ; - { DefnBody = mlds__class(ClassDefn) }, + { DefnBody = mlds_class(ClassDefn) }, gen_class(Name, Context, ClassDefn, GlobalInfo0, GlobalInfo) ). -:- pred build_local_defn_body(mlds__qualified_entity_name, defn_info, - mlds__context, mlds__decl_flags, mlds__entity_defn, +:- pred build_local_defn_body(mlds_qualified_entity_name, defn_info, + mlds_context, mlds_decl_flags, mlds_entity_defn, gcc__var_decl, io__state, io__state). :- mode build_local_defn_body(in, in, in, in, in, out, di, uo) is det. build_local_defn_body(Name, DefnInfo, _Context, Flags, DefnBody, GCC_Defn) --> ( - { DefnBody = mlds__data(Type, Initializer, _GC_TraceCode) }, + { DefnBody = mlds_data(Type, Initializer, _GC_TraceCode) }, build_local_data_defn(Name, Flags, Type, Initializer, DefnInfo, GCC_Defn) ; - { DefnBody = mlds__function(_, _, _, _) }, + { DefnBody = mlds_function(_, _, _, _) }, % nested functions should get eliminated by ml_elim_nested, % unless --gcc-nested-functions is enabled. % XXX --gcc-nested-functions is not yet implemented { sorry(this_file, "nested function (`--gcc-nested-functions' " ++ "not yet supported with `--target asm')") } ; - { DefnBody = mlds__class(_) }, + { DefnBody = mlds_class(_) }, % currently the MLDS code generator doesn't generate % types nested inside functions, so we don't need to % implement this { unexpected(this_file, "nested type") } ). -:- pred build_field_defn_body(mlds__qualified_entity_name, - mlds__context, mlds__decl_flags, mlds__entity_defn, +:- pred build_field_defn_body(mlds_qualified_entity_name, + mlds_context, mlds_decl_flags, mlds_entity_defn, global_info, gcc__field_decl, io__state, io__state). :- mode build_field_defn_body(in, in, in, in, in, out, di, uo) is det. @@ -874,15 +874,15 @@ build_local_defn_body(Name, DefnInfo, _Context, Flags, DefnBody, GCC_Defn) --> build_field_defn_body(Name, _Context, Flags, DefnBody, GlobalInfo, GCC_Defn) --> ( - { DefnBody = mlds__data(Type, Initializer, _GC_TraceCode) }, + { DefnBody = mlds_data(Type, Initializer, _GC_TraceCode) }, build_field_data_defn(Name, Type, Initializer, GlobalInfo, GCC_Defn), add_field_decl_flags(Flags, GCC_Defn) ; - { DefnBody = mlds__function(_, _, _, _) }, + { DefnBody = mlds_function(_, _, _, _) }, { unexpected(this_file, "function nested in type") } ; - { DefnBody = mlds__class(_) }, + { DefnBody = mlds_class(_) }, { unexpected(this_file, "type nested in type") } ). @@ -895,7 +895,7 @@ build_field_defn_body(Name, _Context, Flags, DefnBody, GlobalInfo, % decl flags for variables % -:- pred add_var_decl_flags(mlds__decl_flags, gcc__var_decl, +:- pred add_var_decl_flags(mlds_decl_flags, gcc__var_decl, io__state, io__state). :- mode add_var_decl_flags(in, in, di, uo) is det. @@ -908,7 +908,7 @@ add_var_decl_flags(Flags, GCC_Defn) --> add_var_constness_flag( constness(Flags), GCC_Defn), add_var_abstractness_flag( abstractness(Flags), GCC_Defn). -:- pred add_var_access_flag(mlds__access, gcc__var_decl, io__state, io__state). +:- pred add_var_access_flag(access, gcc__var_decl, io__state, io__state). :- mode add_var_access_flag(in, in, di, uo) is det. add_var_access_flag(public, GCC_Defn) --> @@ -926,7 +926,7 @@ add_var_access_flag(local, _GCC_Defn) --> % where it is the default []. -:- pred add_var_virtuality_flag(mlds__virtuality, gcc__var_decl, +:- pred add_var_virtuality_flag(virtuality, gcc__var_decl, io__state, io__state). :- mode add_var_virtuality_flag(in, in, di, uo) is det. @@ -938,7 +938,7 @@ add_var_virtuality_flag(non_virtual, _GCC_Defn) --> % this is the default []. -:- pred add_var_constness_flag(mlds__constness, gcc__var_decl, +:- pred add_var_constness_flag(constness, gcc__var_decl, io__state, io__state). :- mode add_var_constness_flag(in, in, di, uo) is det. @@ -948,7 +948,7 @@ add_var_constness_flag(modifiable, _GCC_Defn) --> % this is the default []. -:- pred add_var_finality_flag(mlds__finality, gcc__var_decl, +:- pred add_var_finality_flag(finality, gcc__var_decl, io__state, io__state). :- mode add_var_finality_flag(in, in, di, uo) is det. @@ -974,7 +974,7 @@ add_var_abstractness_flag(abstract, _GCC_Defn) --> % decl flags for fields % -:- pred add_field_decl_flags(mlds__decl_flags, gcc__field_decl, +:- pred add_field_decl_flags(mlds_decl_flags, gcc__field_decl, io__state, io__state). :- mode add_field_decl_flags(in, in, di, uo) is det. @@ -986,7 +986,7 @@ add_field_decl_flags(Flags, GCC_Defn) --> add_field_constness_flag( constness(Flags), GCC_Defn), add_field_abstractness_flag( abstractness(Flags), GCC_Defn). -:- pred add_field_access_flag(mlds__access, gcc__field_decl, +:- pred add_field_access_flag(access, gcc__field_decl, io__state, io__state). :- mode add_field_access_flag(in, in, di, uo) is det. @@ -1013,7 +1013,7 @@ add_field_per_instance_flag(one_copy, _GCC_Defn) --> % Static fields should be hoisted out as global variables { unexpected(this_file, "`static' field") }. -:- pred add_field_virtuality_flag(mlds__virtuality, gcc__field_decl, +:- pred add_field_virtuality_flag(virtuality, gcc__field_decl, io__state, io__state). :- mode add_field_virtuality_flag(in, in, di, uo) is det. @@ -1023,7 +1023,7 @@ add_field_virtuality_flag(non_virtual, _GCC_Defn) --> % this is the default []. -:- pred add_field_constness_flag(mlds__constness, gcc__field_decl, +:- pred add_field_constness_flag(constness, gcc__field_decl, io__state, io__state). :- mode add_field_constness_flag(in, in, di, uo) is det. @@ -1033,7 +1033,7 @@ add_field_constness_flag(modifiable, _GCC_Defn) --> % this is the default []. -:- pred add_field_finality_flag(mlds__finality, gcc__field_decl, +:- pred add_field_finality_flag(finality, gcc__field_decl, io__state, io__state). :- mode add_field_finality_flag(in, in, di, uo) is det. @@ -1057,7 +1057,7 @@ add_field_abstractness_flag(abstract, _GCC_Defn) --> % decl flags for functions % -:- pred add_func_decl_flags(mlds__decl_flags, gcc__func_decl, +:- pred add_func_decl_flags(mlds_decl_flags, gcc__func_decl, io__state, io__state). :- mode add_func_decl_flags(in, in, di, uo) is det. @@ -1069,7 +1069,7 @@ add_func_decl_flags(Flags, GCC_Defn) --> add_func_constness_flag( constness(Flags), GCC_Defn), add_func_abstractness_flag( abstractness(Flags), GCC_Defn). -:- pred add_func_access_flag(mlds__access, gcc__func_decl, +:- pred add_func_access_flag(access, gcc__func_decl, io__state, io__state). :- mode add_func_access_flag(in, in, di, uo) is det. @@ -1097,7 +1097,7 @@ add_func_access_flag(local, _GCC_Defn) --> add_func_per_instance_flag(per_instance, _GCC_Defn) --> []. add_func_per_instance_flag(one_copy, _GCC_Defn) --> []. -:- pred add_func_virtuality_flag(mlds__virtuality, gcc__func_decl, +:- pred add_func_virtuality_flag(virtuality, gcc__func_decl, io__state, io__state). :- mode add_func_virtuality_flag(in, in, di, uo) is det. @@ -1107,7 +1107,7 @@ add_func_virtuality_flag(non_virtual, _GCC_Defn) --> % this is the default []. -:- pred add_func_constness_flag(mlds__constness, gcc__func_decl, +:- pred add_func_constness_flag(constness, gcc__func_decl, io__state, io__state). :- mode add_func_constness_flag(in, in, di, uo) is det. @@ -1117,7 +1117,7 @@ add_func_constness_flag(modifiable, _GCC_Defn) --> % this is the default []. -:- pred add_func_finality_flag(mlds__finality, gcc__func_decl, +:- pred add_func_finality_flag(finality, gcc__func_decl, io__state, io__state). :- mode add_func_finality_flag(in, in, di, uo) is det. @@ -1145,8 +1145,8 @@ add_func_abstractness_flag(concrete, _GCC_Defn) --> % Handle an MLDS data definition that is nested inside a % function definition (or inside a block within a function), % and which is hence local to that function. -:- pred build_local_data_defn(mlds__qualified_entity_name, mlds__decl_flags, - mlds_type, mlds__initializer, defn_info, gcc__var_decl, +:- pred build_local_data_defn(mlds_qualified_entity_name, mlds_decl_flags, + mlds_type, mlds_initializer, defn_info, gcc__var_decl, io__state, io__state). :- mode build_local_data_defn(in, in, in, in, in, out, di, uo) is det. @@ -1157,7 +1157,7 @@ build_local_data_defn(Name, Flags, Type, Initializer, DefnInfo, GCC_Defn) --> ( { UnqualName = data(var(VarName0)) } -> { VarName = VarName0 } ; - % var/1 should be the only kind of mlds__data_name for which + % var/1 should be the only kind of mlds_data_name for which % the MLDS code generator generates local definitions % (within functions) { unexpected(this_file, "build_local_data_defn: non-var") } @@ -1193,8 +1193,8 @@ build_local_data_defn(Name, Flags, Type, Initializer, DefnInfo, GCC_Defn) --> % Handle an MLDS data definition that is nested inside a type, % i.e. a field definition. -:- pred build_field_data_defn(mlds__qualified_entity_name, mlds_type, - mlds__initializer, global_info, gcc__field_decl, +:- pred build_field_data_defn(mlds_qualified_entity_name, mlds_type, + mlds_initializer, global_info, gcc__field_decl, io__state, io__state). :- mode build_field_data_defn(in, in, in, in, out, di, uo) is det. @@ -1215,7 +1215,7 @@ build_field_data_defn(Name, Type, Initializer, GlobalInfo, GCC_Defn) --> { sorry(this_file, "build_field_data_defn: initializer") } ). -:- pred build_initializer(mlds__initializer, gcc__type, defn_info, +:- pred build_initializer(mlds_initializer, gcc__type, defn_info, gcc__expr, io__state, io__state) is det. :- mode build_initializer(in, in, in, out, di, uo) is det. @@ -1240,7 +1240,7 @@ build_initializer(Initializer, GCC_Type, DefnInfo, GCC_Expr) --> gcc__build_initializer_expr(GCC_InitList, GCC_Type, GCC_Expr) ). -:- pred build_array_initializer(list(mlds__initializer), gcc__type, int, +:- pred build_array_initializer(list(mlds_initializer), gcc__type, int, defn_info, gcc__init_list, io__state, io__state) is det. :- mode build_array_initializer(in, in, in, in, out, di, uo) is det. @@ -1255,7 +1255,7 @@ build_array_initializer([Init | Inits], GCC_ElemType, Index, DefnInfo, gcc__cons_init_list(GCC_InitIndex, GCC_InitValue, GCC_InitList0, GCC_InitList). -:- pred build_struct_initializer(list(mlds__initializer), gcc__field_decls, +:- pred build_struct_initializer(list(mlds_initializer), gcc__field_decls, defn_info, gcc__init_list, io__state, io__state) is det. :- mode build_struct_initializer(in, in, in, out, di, uo) is det. @@ -1278,8 +1278,8 @@ build_struct_initializer([Init | Inits], GCC_FieldDecls, DefnInfo, % Code to output type definitions % -:- pred gen_class(mlds__qualified_entity_name, mlds__context, - mlds__class_defn, global_info, global_info, +:- pred gen_class(mlds_qualified_entity_name, mlds_context, + mlds_class_defn, global_info, global_info, io__state, io__state). :- mode gen_class(in, in, in, in, out, di, uo) is det. @@ -1295,7 +1295,7 @@ gen_class(Name, Context, ClassDefn, GlobalInfo0, GlobalInfo) --> { Name = qual(ModuleName, QualKind, UnqualName) }, globals__io_get_globals(Globals), { UnqualName = type(ClassName, ClassArity) -> - ClassModuleName = mlds__append_class_qualifier(ModuleName, + ClassModuleName = mlds_append_class_qualifier(ModuleName, QualKind, Globals, ClassName, ClassArity) ; unexpected(this_file, "mlds_output_enum_constants") @@ -1308,14 +1308,14 @@ gen_class(Name, Context, ClassDefn, GlobalInfo0, GlobalInfo) --> % XXX this should be conditional: only when compiling to C, % not when compiling to C++ % - { ClassDefn = class_defn(Kind, _Imports, BaseClasses, _Implements, + { ClassDefn = mlds_class_defn(Kind, _Imports, BaseClasses, _Implements, Ctors, AllMembers) }, { Ctors = [] -> true ; unexpected(this_file, "constructors") }, - ( { Kind = mlds__enum } -> + ( { Kind = mlds_enum } -> { StaticMembers = [] }, { StructMembers = AllMembers } ; @@ -1341,7 +1341,7 @@ gen_class(Name, Context, ClassDefn, GlobalInfo0, GlobalInfo) --> % Output the class declaration and the class members. % We treat enumerations specially. % - ( { Kind = mlds__enum } -> + ( { Kind = mlds_enum } -> % XXX enumeration definitions are not yet implemented { sorry(this_file, "enum type (`--high-level-data' not yet " ++ "implemented for `--target asm')") } @@ -1378,10 +1378,10 @@ gen_class(Name, Context, ClassDefn, GlobalInfo0, GlobalInfo) --> % gen_defns(ClassModuleName, StaticMembers, GlobalInfo1, GlobalInfo). -:- pred is_static_member(mlds__defn::in) is semidet. +:- pred is_static_member(mlds_defn::in) is semidet. is_static_member(Defn) :- - Defn = mlds__defn(Name, _, Flags, _), + Defn = mlds_defn(Name, _, Flags, _), ( Name = type(_, _) ; per_instance(Flags) = one_copy ). @@ -1389,7 +1389,7 @@ is_static_member(Defn) :- % Convert a base class class_id into a member variable % that holds the value of the base class. % -:- pred mlds_make_base_class(mlds__context, mlds__class_id, mlds__defn, +:- pred mlds_make_base_class(mlds_context, mlds_class_id, mlds_defn, int, int). :- mode mlds_make_base_class(in, in, out, in, out) is det. @@ -1399,9 +1399,9 @@ mlds_make_base_class(Context, ClassId, MLDS_Defn, BaseNum0, BaseNum) :- % We only need GC tracing code for top-level variables, % not for base classes. GC_TraceCode = no, - MLDS_Defn = mlds__defn(data(var(var_name(BaseName, no))), Context, + MLDS_Defn = mlds_defn(data(var(mlds_var_name(BaseName, no))), Context, ml_gen_public_field_decl_flags, - data(Type, no_initializer, GC_TraceCode)), + mlds_data(Type, no_initializer, GC_TraceCode)), BaseNum = BaseNum0 + 1. /*********** @@ -1409,12 +1409,12 @@ XXX enumeration definitions are not yet implemented for mlds_to_gcc.m. The following code for handling enumeration definitions is copied from mlds_to_c.m. It shows what we should generate. -:- pred mlds_output_class_decl(indent, mlds__qualified_entity_name, - mlds__class_defn, io__state, io__state). +:- pred mlds_output_class_decl(indent, mlds_qualified_entity_name, + mlds_class_defn, io__state, io__state). :- mode mlds_output_class_decl(in, in, in, di, uo) is det. mlds_output_class_decl(_Indent, Name, ClassDefn) --> - ( { ClassDefn^kind = mlds__enum } -> + ( { ClassDefn^kind = mlds_enum } -> io__write_string("enum "), mlds_output_fully_qualified_name(Name), io__write_string("_e") @@ -1428,7 +1428,7 @@ mlds_output_class_decl(_Indent, Name, ClassDefn) --> % for an enumeration type. % :- pred mlds_output_enum_constants(indent, mlds_module_name, - mlds__defns, io__state, io__state). + mlds_defns, io__state, io__state). :- mode mlds_output_enum_constants(in, in, in, di, uo) is det. mlds_output_enum_constants(Indent, EnumModuleName, Members) --> @@ -1441,24 +1441,24 @@ mlds_output_enum_constants(Indent, EnumModuleName, Members) --> mlds_output_enum_constant(Indent, EnumModuleName)), io__nl. - % Test whether one of the members of an mlds__enum class + % Test whether one of the members of an mlds_enum class % is an enumeration constant. % -:- pred is_enum_const(mlds__defn). +:- pred is_enum_const(mlds_defn). :- mode is_enum_const(in) is semidet. is_enum_const(Defn) :- - Defn = mlds__defn(_Name, _Context, Flags, _DefnBody), + Defn = mlds_defn(_Name, _Context, Flags, _DefnBody), constness(Flags) = const. % Output the definition of a single enumeration constant. % -:- pred mlds_output_enum_constant(indent, mlds_module_name, mlds__defn, +:- pred mlds_output_enum_constant(indent, mlds_module_name, mlds_defn, io__state, io__state). :- mode mlds_output_enum_constant(in, in, in, di, uo) is det. mlds_output_enum_constant(Indent, EnumModuleName, Defn) --> - { Defn = mlds__defn(Name, Context, _Flags, DefnBody) }, + { Defn = mlds_defn(Name, Context, _Flags, DefnBody) }, ( { DefnBody = data(Type, Initializer) } -> @@ -1478,8 +1478,8 @@ mlds_output_enum_constant(Indent, EnumModuleName, Defn) --> % Code to output function declarations/definitions % -:- pred gen_func(qualified_entity_name, mlds__context, - mlds__decl_flags, func_params, function_body, +:- pred gen_func(mlds_qualified_entity_name, mlds_context, + mlds_decl_flags, mlds_func_params, mlds_function_body, global_info, global_info, io__state, io__state). :- mode gen_func(in, in, in, in, in, in, out, di, uo) is det. @@ -1519,7 +1519,7 @@ build_label_table(Statement, LabelTable) --> { map__from_corresponding_lists(Labels, GCC_LabelDecls, LabelTable) }. -:- pred statement_contains_label(statement::in, mlds__label::out) +:- pred statement_contains_label(statement::in, mlds_label::out) is nondet. statement_contains_label(Statement, Label) :- statement_contains_statement(Statement, SubStatement), @@ -1527,11 +1527,11 @@ statement_contains_label(Statement, Label) :- % XXX we should lookup the existing definition, if there is one, % rather than always making a new one -:- pred make_func_decl(mlds__qualified_entity_name::in, - mlds__func_signature::in, global_info::in, +:- pred make_func_decl(mlds_qualified_entity_name::in, + mlds_func_signature::in, global_info::in, gcc__func_decl::out, io__state::di, io__state::uo) is det. make_func_decl(Name, Signature, GlobalInfo, GCC_FuncDecl) --> - { Signature = func_signature(Arguments, ReturnTypes) }, + { Signature = mlds_func_signature(Arguments, ReturnTypes) }, get_return_type(ReturnTypes, GlobalInfo, RetType), { get_qualified_func_name(Name, _ModuleName, FuncName, AsmFuncName) }, build_param_types(Arguments, GlobalInfo, GCC_Types, GCC_ParamTypes), @@ -1551,12 +1551,12 @@ build_dummy_param_decls([Type | Types], % Like make_func_decl, except that it fills in the % function parameters properly -:- pred make_func_decl_for_defn(mlds__qualified_entity_name::in, - mlds__func_params::in, global_info::in, gcc__func_decl::out, +:- pred make_func_decl_for_defn(mlds_qualified_entity_name::in, + mlds_func_params::in, global_info::in, gcc__func_decl::out, symbol_table::out, io__state::di, io__state::uo) is det. make_func_decl_for_defn(Name, Parameters, GlobalInfo, FuncDecl, SymbolTable) --> - { Parameters = func_params(Arguments, ReturnTypes) }, + { Parameters = mlds_func_params(Arguments, ReturnTypes) }, get_return_type(ReturnTypes, GlobalInfo, RetType), { get_qualified_func_name(Name, ModuleName, FuncName, AsmFuncName) }, build_param_types_and_decls(Arguments, ModuleName, GlobalInfo, @@ -1580,7 +1580,7 @@ get_return_type(List, GlobalInfo, GCC_Type) --> % `FuncName' is the name used for generating debug symbols, % whereas `AsmFuncName' is what we actually spit out in the % assembler file. -:- pred get_qualified_func_name(mlds__qualified_entity_name::in, +:- pred get_qualified_func_name(mlds_qualified_entity_name::in, mlds_module_name::out, string::out, string::out) is det. get_qualified_func_name(Name, ModuleName, FuncName, AsmFuncName) :- Name = qual(ModuleName, _QualKind, EntityName), @@ -1592,7 +1592,7 @@ get_qualified_func_name(Name, ModuleName, FuncName, AsmFuncName) :- % `FuncName' is the name used for generating debug symbols, % whereas `AsmFuncName' is what we actually spit out in the % assembler file. -:- pred get_func_name(mlds__entity_name::in, +:- pred get_func_name(mlds_entity_name::in, string::out, string::out) is det. get_func_name(FunctionName, FuncName, AsmFuncName) :- ( FunctionName = function(PredLabel, ProcId, MaybeSeqNum, _PredId) -> @@ -1633,7 +1633,7 @@ get_func_name(FunctionName, FuncName, AsmFuncName) :- % XXX same as mlds_output_pred_label in mlds_to_c, % except that it returns a string. -:- pred get_pred_label_name(mlds__pred_label, string). +:- pred get_pred_label_name(mlds_pred_label, string). :- mode get_pred_label_name(in, out) is det. get_pred_label_name(pred(PredOrFunc, MaybeDefiningModule, Name, Arity, @@ -1668,7 +1668,7 @@ get_pred_label_name(special_pred(PredName, MaybeTypeModule, get_module_name(ModuleName) = sym_name_mangle(ModuleName). -:- pred build_param_types(mlds__arg_types::in, global_info::in, +:- pred build_param_types(mlds_arg_types::in, global_info::in, list(gcc__type)::out, gcc__param_types::out, io__state::di, io__state::uo) is det. @@ -1678,7 +1678,7 @@ build_param_types(ArgTypes, GlobalInfo, GCC_Types, ParamTypes) --> % build a list of parameter types, and prepend this list to the % gcc__param_types list passed as input -:- pred build_param_types(mlds__arg_types::in, global_info::in, +:- pred build_param_types(mlds_arg_types::in, global_info::in, list(gcc__type)::out, gcc__param_types::in, gcc__param_types::out, io__state::di, io__state::uo) is det. @@ -1690,7 +1690,7 @@ build_param_types([ArgType | ArgTypes], GlobalInfo, [GCC_Type | GCC_Types], build_type(ArgType, GlobalInfo, GCC_Type), { ParamTypes = gcc__cons_param_types(GCC_Type, ParamTypes1) }. -:- pred build_param_types_and_decls(mlds__arguments::in, mlds_module_name::in, +:- pred build_param_types_and_decls(mlds_arguments::in, mlds_module_name::in, global_info::in, gcc__param_types::out, gcc__param_decls::out, symbol_table::out, io__state::di, io__state::uo) is det. @@ -1701,7 +1701,7 @@ build_param_types_and_decls([Arg|Args], ModuleName, GlobalInfo, ParamTypes, ParamDecls, SymbolTable) --> build_param_types_and_decls(Args, ModuleName, GlobalInfo, ParamTypes0, ParamDecls0, SymbolTable0), - { Arg = mlds__argument(ArgName, Type, _GC_TraceCode) }, + { Arg = mlds_argument(ArgName, Type, _GC_TraceCode) }, build_type(Type, GlobalInfo, GCC_Type), ( { ArgName = data(var(ArgVarName)) } -> { GCC_ArgVarName = ml_var_name_to_string(ArgVarName) }, @@ -1731,7 +1731,7 @@ build_type(Type, GlobalInfo, GCC_Type) --> :- mode build_type(in, in, in, out, di, uo) is det. % Just represent Mercury arrays as MR_Word. -build_type(mercury_array_type(_ElemType), _, _, GCC_Type) --> +build_type(mlds_mercury_array_type(_ElemType), _, _, GCC_Type) --> globals__io_lookup_bool_option(highlevel_data, HighLevelData), ( { HighLevelData = yes } -> { sorry(this_file, "--high-level-data (mercury_array_type)") } @@ -1740,14 +1740,14 @@ build_type(mercury_array_type(_ElemType), _, _, GCC_Type) --> ). build_type(mercury_type(Type, TypeCategory, _), _, _, GCC_Type) --> build_mercury_type(Type, TypeCategory, GCC_Type). -build_type(mlds__foreign_type(_), _, _, 'MR_Box') --> []. -build_type(mlds__native_int_type, _, _, gcc__integer_type_node) --> []. -build_type(mlds__native_float_type, _, _, gcc__double_type_node) --> []. -build_type(mlds__native_bool_type, _, _, gcc__boolean_type_node) --> []. -build_type(mlds__native_char_type, _, _, gcc__char_type_node) --> []. -build_type(mlds__class_type(Name, Arity, ClassKind), _, GlobalInfo, +build_type(mlds_foreign_type(_), _, _, 'MR_Box') --> []. +build_type(mlds_native_int_type, _, _, gcc__integer_type_node) --> []. +build_type(mlds_native_float_type, _, _, gcc__double_type_node) --> []. +build_type(mlds_native_bool_type, _, _, gcc__boolean_type_node) --> []. +build_type(mlds_native_char_type, _, _, gcc__char_type_node) --> []. +build_type(mlds_class_type(Name, Arity, ClassKind), _, GlobalInfo, GCC_Type) --> - ( { ClassKind = mlds__enum } -> + ( { ClassKind = mlds_enum } -> % % XXX following comment is copied from mlds_to_c; % it is wrong for mlds_to_gcc back-end @@ -1802,15 +1802,15 @@ build_type(mlds__class_type(Name, Arity, ClassKind), _, GlobalInfo, io__nl ) ). -build_type(mlds__ptr_type(Type), _, GlobalInfo, GCC_PtrType) --> +build_type(mlds_ptr_type(Type), _, GlobalInfo, GCC_PtrType) --> build_type(Type, GlobalInfo, GCC_Type), gcc__build_pointer_type(GCC_Type, GCC_PtrType). -build_type(mlds__array_type(Type), ArraySize, GlobalInfo, GCC_ArrayType) --> +build_type(mlds_array_type(Type), ArraySize, GlobalInfo, GCC_ArrayType) --> build_type(Type, GlobalInfo, GCC_Type), build_sized_array_type(GCC_Type, ArraySize, GCC_ArrayType). -build_type(mlds__func_type(Params), _, GlobalInfo, GCC_FuncPtrType) --> - { Signature = mlds__get_func_signature(Params) }, - { Signature = mlds__func_signature(ArgTypes, RetTypes) }, +build_type(mlds_func_type(Params), _, GlobalInfo, GCC_FuncPtrType) --> + { Signature = mlds_get_func_signature(Params) }, + { Signature = mlds_func_signature(ArgTypes, RetTypes) }, ( { RetTypes = [] } -> { GCC_RetType = gcc__void_type_node } ; { RetTypes = [RetType] } -> @@ -1821,11 +1821,11 @@ build_type(mlds__func_type(Params), _, GlobalInfo, GCC_FuncPtrType) --> build_param_types(ArgTypes, GlobalInfo, _, GCC_ParamTypes), gcc__build_function_type(GCC_RetType, GCC_ParamTypes, GCC_FuncType), gcc__build_pointer_type(GCC_FuncType, GCC_FuncPtrType). -build_type(mlds__generic_type, _, _, 'MR_Box') --> []. -build_type(mlds__generic_env_ptr_type, _, _, gcc__ptr_type_node) --> []. -build_type(mlds__type_info_type, _, _, 'MR_TypeInfo') --> []. -build_type(mlds__pseudo_type_info_type, _, _, 'MR_PseudoTypeInfo') --> []. -build_type(mlds__cont_type(ArgTypes), _, GlobalInfo, GCC_Type) --> +build_type(mlds_generic_type, _, _, 'MR_Box') --> []. +build_type(mlds_generic_env_ptr_type, _, _, gcc__ptr_type_node) --> []. +build_type(mlds_type_info_type, _, _, 'MR_TypeInfo') --> []. +build_type(mlds_pseudo_type_info_type, _, _, 'MR_PseudoTypeInfo') --> []. +build_type(mlds_cont_type(ArgTypes), _, GlobalInfo, GCC_Type) --> % mlds_to_c treats the ArgTypes = [] case specially -- it generates % references to typedefs `MR_NestedCont' and `MR_Cont', which are % defined as follows: @@ -1847,11 +1847,11 @@ build_type(mlds__cont_type(ArgTypes), _, GlobalInfo, GCC_Type) --> GCC_ParamTypes0, GCC_ParamTypes), gcc__build_function_type(gcc__void_type_node, GCC_ParamTypes, FuncType), gcc__build_pointer_type(FuncType, GCC_Type). -build_type(mlds__commit_type, _, _, gcc__jmpbuf_type_node) --> []. -build_type(mlds__rtti_type(RttiIdMaybeElement), InitializerSize, _GlobalInfo, +build_type(mlds_commit_type, _, _, gcc__jmpbuf_type_node) --> []. +build_type(mlds_rtti_type(RttiIdMaybeElement), InitializerSize, _GlobalInfo, GCC_Type) --> build_rtti_type(RttiIdMaybeElement, InitializerSize, GCC_Type). -build_type(mlds__unknown_type, _, _, _) --> +build_type(mlds_unknown_type, _, _, _) --> { unexpected(this_file, "build_type: unknown type") }. :- pred build_mercury_type(mer_type, type_category, gcc__type, @@ -1953,7 +1953,7 @@ build_sized_array_type(GCC_Type, ArraySize, GCC_ArrayType) --> ; no_size. % either the size is unknown, % or the data is not an array -:- func initializer_array_size(mlds__initializer) = initializer_array_size. +:- func initializer_array_size(mlds_initializer) = initializer_array_size. initializer_array_size(no_initializer) = no_size. initializer_array_size(init_obj(_)) = no_size. initializer_array_size(init_struct(_, _)) = no_size. @@ -2529,14 +2529,14 @@ build_fields([Type - Name | Fields0], GCC_Fields) --> % Code to output names of various entities % -:- func build_qualified_name(mlds__qualified_entity_name) = string. +:- func build_qualified_name(mlds_qualified_entity_name) = string. build_qualified_name(QualifiedName) = AsmName :- QualifiedName = qual(_ModuleName, _QualKind, Name), AsmName0 = build_name(Name), maybe_add_module_qualifier(QualifiedName, AsmName0, AsmName). -:- pred maybe_add_module_qualifier(mlds__qualified_entity_name::in, +:- pred maybe_add_module_qualifier(mlds_qualified_entity_name::in, string::in, string::out) is det. maybe_add_module_qualifier(QualifiedName, AsmName0, AsmName) :- QualifiedName = qual(ModuleName, _QualKind, Name), @@ -2566,7 +2566,7 @@ maybe_add_module_qualifier(QualifiedName, AsmName0, AsmName) :- % XXX we should consider not appending the arity, modenum, and seqnum % if they are not needed. -:- func build_name(mlds__entity_name) = string. +:- func build_name(mlds_entity_name) = string. build_name(type(Name, Arity)) = TypeName :- MangledName = name_mangle(Name), @@ -2577,7 +2577,7 @@ build_name(EntityName) = AsmFuncName :- get_func_name(EntityName, _FuncName, AsmFuncName). build_name(export(Name)) = Name. -:- func build_data_name(mlds__data_name) = string. +:- func build_data_name(mlds_data_name) = string. build_data_name(var(Name)) = name_mangle(ml_var_name_to_string(Name)). build_data_name(common(Num)) = @@ -2661,20 +2661,20 @@ fixup_pseudo_type_info(PseudoTypeInfo0) = PseudoTypeInfo :- % The type field table records the mapping from MLDS type names % to the table of field declarations for that type. -:- type gcc_type_table == map(mlds__qualified_entity_name, gcc_type_info). +:- type gcc_type_table == map(mlds_qualified_entity_name, gcc_type_info). :- type gcc_type_info ---> gcc_type_info(gcc__type_decl, field_table). % The field table records the mapping from MLDS field names % to GCC field declarations. :- type field_table == - map(mlds__fully_qualified_name(field_name), gcc__field_decl). + map(mlds_fully_qualified_name(mlds_field_name), gcc.field_decl). % The defn_info holds information used while generating code % inside a function, or in the initializers for a global variable. :- type defn_info ---> defn_info( global_info :: global_info, - func_name :: mlds__qualified_entity_name, + func_name :: mlds_qualified_entity_name, local_vars :: symbol_table, label_table :: label_table ). @@ -2683,13 +2683,13 @@ fixup_pseudo_type_info(PseudoTypeInfo0) = PseudoTypeInfo :- % to GCC variable declarations. % We initialize the symbol table with the function parameters, % and update it whenever we enter a block with local variables. -:- type symbol_table == map(mlds__qualified_entity_name, gcc__var_decl). +:- type symbol_table == map(mlds_qualified_entity_name, gcc__var_decl). % The label table records the mapping from MLDS label names % to GCC label declaration tree nodes. % We initialize it using a separate pass over the function body % before we generate code for the function. -:- type label_table == map(mlds__label, gcc__label). +:- type label_table == map(mlds_label, gcc__label). %-----------------------------------------------------------------------------% % @@ -2711,7 +2711,7 @@ gen_statement(DefnInfo, statement(Statement, Context)) --> gen_context(Context), gen_stmt(DefnInfo, Statement, Context). -:- pred gen_stmt(defn_info, mlds__stmt, mlds__context, +:- pred gen_stmt(defn_info, mlds_stmt, mlds_context, io__state, io__state). :- mode gen_stmt(in, in, in, di, uo) is det. @@ -2907,19 +2907,19 @@ gen_stmt(DefnInfo, atomic(AtomicStatement), Context) --> % Extra code for outputting switch statements % -:- pred gen_cases(defn_info::in, mlds__switch_cases::in, +:- pred gen_cases(defn_info::in, mlds_switch_cases::in, io__state::di, io__state::uo) is det. gen_cases(DefnInfo, Cases) --> list__foldl(gen_case(DefnInfo), Cases). -:- pred gen_case(defn_info::in, mlds__switch_case::in, +:- pred gen_case(defn_info::in, mlds_switch_case::in, io__state::di, io__state::uo) is det. gen_case(DefnInfo, MatchConds - Code) --> list__foldl(gen_case_label(DefnInfo), MatchConds), gen_statement(DefnInfo, Code), gcc__gen_break. -:- pred gen_case_label(defn_info::in, mlds__case_match_cond::in, +:- pred gen_case_label(defn_info::in, mlds_case_match_cond::in, io__state::di, io__state::uo) is det. gen_case_label(DefnInfo, match_value(Val)) --> build_rval(Val, DefnInfo, GCC_Val), @@ -2935,7 +2935,7 @@ gen_case_label(DefnInfo, match_range(Min, Max)) --> %%% gcc__gen_case_range_label(GCC_Min, GCC_Max, Label). { sorry(this_file, "match_range") }. -:- pred gen_default(defn_info::in, mlds__switch_default::in, +:- pred gen_default(defn_info::in, mlds_switch_default::in, io__state::di, io__state::uo) is det. gen_default(_, default_do_nothing) --> []. gen_default(_, default_is_unreachable) --> @@ -2962,9 +2962,9 @@ mlds_to_c.m. It shows what we should generate. % If memory profiling is turned on output an instruction to % record the heap allocation. % -:- pred mlds_maybe_output_heap_profile_instr(mlds__context::in, +:- pred mlds_maybe_output_heap_profile_instr(mlds_context::in, indent::in, list(mlds_rval)::in, - mlds__qualified_entity_name::in, maybe(ctor_name)::in, + mlds_qualified_entity_name::in, maybe(ctor_name)::in, io__state::di, io__state::uo) is det. mlds_maybe_output_heap_profile_instr(Context, Indent, Args, FuncName, @@ -2997,8 +2997,8 @@ mlds_maybe_output_heap_profile_instr(Context, Indent, Args, FuncName, % If call profiling is turned on output an instruction to record % an arc in the call profile between the callee and caller. % -:- pred mlds_maybe_output_call_profile_instr(mlds__context::in, - indent::in, mlds_rval::in, mlds__qualified_entity_name::in, +:- pred mlds_maybe_output_call_profile_instr(mlds_context::in, + indent::in, mlds_rval::in, mlds_qualified_entity_name::in, io__state::di, io__state::uo) is det. mlds_maybe_output_call_profile_instr(Context, Indent, @@ -3020,8 +3020,8 @@ mlds_maybe_output_call_profile_instr(Context, Indent, % informs the runtime which procedure we are currently located % in. % -:- pred mlds_maybe_output_time_profile_instr(mlds__context::in, - indent::in, mlds__qualified_entity_name::in, +:- pred mlds_maybe_output_time_profile_instr(mlds_context::in, + indent::in, mlds_qualified_entity_name::in, io__state::di, io__state::uo) is det. mlds_maybe_output_time_profile_instr(Context, Indent, Name) --> @@ -3046,7 +3046,7 @@ mlds_maybe_output_time_profile_instr(Context, Indent, Name) --> % :- pred gen_atomic_stmt(defn_info, - mlds__atomic_statement, mlds__context, io__state, io__state). + mlds_atomic_statement, mlds_context, io__state, io__state). :- mode gen_atomic_stmt(in, in, in, di, uo) is det. % @@ -3166,7 +3166,7 @@ gen_atomic_stmt(_DefnInfo, outline_foreign_proc(_, _, _, _), _Context) --> % gen_init_args generates code to initialize the fields % of an object allocated with a new_object MLDS instruction. % -:- pred gen_init_args(list(mlds_rval), list(mlds_type), mlds__context, int, +:- pred gen_init_args(list(mlds_rval), list(mlds_type), mlds_context, int, mlds_lval, mlds_type, mlds_tag, defn_info, io__state, io__state). :- mode gen_init_args(in, in, in, in, in, in, in, in, di, uo) is det. @@ -3183,7 +3183,7 @@ gen_init_args([Arg | Args], [ArgType | ArgTypes], Context, % represented as MR_Box, so we need to box them if necessary. % { Lval = field(yes(Tag), lval(Target), - offset(const(int_const(ArgNum))), mlds__generic_type, Type) }, + offset(const(int_const(ArgNum))), mlds_generic_type, Type) }, { Rval = unop(box(ArgType), Arg) }, build_lval(Lval, DefnInfo, GCC_Lval), build_rval(Rval, DefnInfo, GCC_Rval), @@ -3203,7 +3203,7 @@ build_lval(field(MaybeTag, Rval, offset(OffsetRval), FieldType, _ClassType), DefnInfo, GCC_FieldRef) --> % sanity check (copied from mlds_to_c.m) ( - { FieldType = mlds__generic_type + { FieldType = mlds_generic_type ; FieldType = mlds__mercury_type(variable(_, _), _, _) } -> @@ -3309,7 +3309,7 @@ build_lval(var(qual(ModuleName, QualKind, VarName), _VarType), DefnInfo, % and is an RTTI enumeration constant { mercury_private_builtin_module(PrivateBuiltin) }, { mercury_module_name_to_mlds(PrivateBuiltin) = ModuleName }, - { VarName = var_name(VarNameBase, _MaybeNum) }, + { VarName = mlds_var_name(VarNameBase, _MaybeNum) }, { rtti_enum_const(VarNameBase, IntVal) } -> gcc__build_int(IntVal, Expr) @@ -3317,7 +3317,7 @@ build_lval(var(qual(ModuleName, QualKind, VarName), _VarType), DefnInfo, % check if it's private_builtin:dummy_var { mercury_private_builtin_module(PrivateBuiltin) }, { mercury_module_name_to_mlds(PrivateBuiltin) = ModuleName }, - { VarName = var_name("dummy_var", _) } + { VarName = mlds_var_name("dummy_var", _) } -> % if so, generate an extern declaration for it, and use that. { GCC_VarName = build_data_var_name(ModuleName, var(VarName)) }, @@ -3329,13 +3329,13 @@ build_lval(var(qual(ModuleName, QualKind, VarName), _VarType), DefnInfo, build_qualified_name(Name)) } ). -:- func get_class_type_name(mlds_type) = mlds__qualified_entity_name. +:- func get_class_type_name(mlds_type) = mlds_qualified_entity_name. get_class_type_name(Type) = Name :- ( ( - Type = mlds__class_type(ClassName, Arity, _Kind) + Type = mlds_class_type(ClassName, Arity, _Kind) ; - Type = mlds__ptr_type(mlds__class_type(ClassName, + Type = mlds_ptr_type(mlds_class_type(ClassName, Arity, _Kind)) ) -> @@ -3386,25 +3386,25 @@ build_unop(box(Type), Rval, DefnInfo, GCC_Expr) --> build_call(gcc__box_float_func_decl, [Rval], DefnInfo, GCC_Expr) ; - { Type = mlds__array_type(_) } + { Type = mlds_array_type(_) } -> % When boxing arrays, we need to take the address of the array. % This implies that the array must be an lval. % But we also allow null arrays as a special case; % boxing a null array results in a null pointer. ( { Rval = const(null(_)) } -> - { PtrRval = const(null(mlds__generic_type)) }, + { PtrRval = const(null(mlds_generic_type)) }, build_rval(PtrRval, DefnInfo, GCC_Expr) ; { Rval = lval(ArrayLval) } -> { PtrRval = mem_addr(ArrayLval) }, - build_cast_rval(mlds__generic_type, PtrRval, DefnInfo, + build_cast_rval(mlds_generic_type, PtrRval, DefnInfo, GCC_Expr) ; { unexpected(this_file, "boxing non-lval, non-null array") } ) ; - build_cast_rval(mlds__generic_type, Rval, DefnInfo, GCC_Expr) + build_cast_rval(mlds_generic_type, Rval, DefnInfo, GCC_Expr) ). build_unop(unbox(Type), Rval, DefnInfo, GCC_Expr) --> ( @@ -3425,7 +3425,7 @@ build_unop(std_unop(Unop), Exprn, DefnInfo, GCC_Expr) --> :- pred type_is_float(mlds_type::in) is semidet. type_is_float(Type) :- ( Type = mlds__mercury_type(builtin(float), _, _) - ; Type = mlds__native_float_type + ; Type = mlds_native_float_type ). :- pred build_cast_rval(mlds_type, mlds_rval, defn_info, gcc__expr, @@ -3654,7 +3654,7 @@ build_rval_const(null(_Type), _, Expr) --> % XXX is it OK to ignore the type here? gcc__build_null_pointer(Expr). -:- pred build_code_addr(mlds__code_addr, global_info, gcc__expr, +:- pred build_code_addr(mlds_code_addr, global_info, gcc__expr, io__state, io__state). :- mode build_code_addr(in, in, out, di, uo) is det. @@ -3676,14 +3676,14 @@ build_code_addr(CodeAddr, GlobalInfo, Expr) --> make_func_decl(Name, Signature, GlobalInfo, FuncDecl), gcc__build_func_addr_expr(FuncDecl, Expr). -:- pred build_data_addr(mlds__data_addr, gcc__expr, io__state, io__state). +:- pred build_data_addr(mlds_data_addr, gcc__expr, io__state, io__state). :- mode build_data_addr(in, out, di, uo) is det. build_data_addr(DataAddr, Expr) --> build_data_decl(DataAddr, Decl), gcc__build_addr_expr(gcc__var_expr(Decl), Expr). -:- pred build_data_decl(mlds__data_addr, gcc__var_decl, io__state, io__state). +:- pred build_data_decl(mlds_data_addr, gcc__var_decl, io__state, io__state). :- mode build_data_decl(in, out, di, uo) is det. build_data_decl(data_addr(ModuleName, DataName), Decl) --> @@ -3693,7 +3693,7 @@ build_data_decl(data_addr(ModuleName, DataName), Decl) --> { Type = 'MR_Word' }, gcc__build_extern_var_decl(VarName, Type, Decl). -:- func build_data_var_name(mlds_module_name, mlds__data_name) = string. +:- func build_data_var_name(mlds_module_name, mlds_data_name) = string. build_data_var_name(ModuleName, DataName) = ModuleQualifier ++ build_data_name(DataName) :- @@ -3713,19 +3713,19 @@ build_data_var_name(ModuleName, DataName) = % Generation of source context info (file name and line number annotations). % -:- pred set_context(mlds__context::in, io__state::di, io__state::uo) is det. +:- pred set_context(mlds_context::in, io__state::di, io__state::uo) is det. set_context(MLDS_Context) --> - { ProgContext = mlds__get_prog_context(MLDS_Context) }, + { ProgContext = mlds_get_prog_context(MLDS_Context) }, { FileName = term__context_file(ProgContext) }, { LineNumber = term__context_line(ProgContext) }, gcc__set_context(FileName, LineNumber). -:- pred gen_context(mlds__context, io__state, io__state). +:- pred gen_context(mlds_context, io__state, io__state). :- mode gen_context(in, di, uo) is det. gen_context(MLDS_Context) --> - { ProgContext = mlds__get_prog_context(MLDS_Context) }, + { ProgContext = mlds_get_prog_context(MLDS_Context) }, { FileName = term__context_file(ProgContext) }, { LineNumber = term__context_line(ProgContext) }, gcc__gen_line_note(FileName, LineNumber). diff --git a/compiler/mlds_to_il.m b/compiler/mlds_to_il.m index 0a64ccf91..5a02d3b90 100644 --- a/compiler/mlds_to_il.m +++ b/compiler/mlds_to_il.m @@ -91,16 +91,16 @@ % XXX we should reduce the dependencies here to a bare minimum. :- func params_to_il_signature(il_data_rep, mlds_module_name, - mlds.func_params) = signature. + mlds_func_params) = signature. % Generate an IL identifier for a pred label. % -:- pred predlabel_to_id(mlds.pred_label::in, proc_id::in, - maybe(mlds.func_sequence_num)::in, ilds.id::out) is det. +:- pred predlabel_to_id(mlds_pred_label::in, proc_id::in, + maybe(mlds_func_sequence_num)::in, ilds.id::out) is det. % Generate an IL identifier for a MLDS var. % -:- pred mangle_mlds_var(mlds.var::in, ilds.id::out) is det. +:- pred mangle_mlds_var(mlds_var::in, ilds.id::out) is det. % This type stores information affecting our IL data representation. % @@ -108,7 +108,7 @@ ---> il_data_rep( highlevel_data :: bool, % Do we use high-level data? il_envptr_type :: il_type % What IL type do we use for - % mlds.generic_env_ptr_type? + % mlds_generic_env_ptr_type? ). :- pred get_il_data_rep(il_data_rep::out, io::di, io::uo) is det. @@ -126,8 +126,8 @@ % Turn a proc name into an IL class_name and a method name. % -:- pred mangle_mlds_proc_label(mlds.qualified_proc_label::in, - maybe(mlds.func_sequence_num)::in, ilds.class_name::out, ilds.id::out) +:- pred mangle_mlds_proc_label(mlds_qualified_proc_label::in, + maybe(mlds_func_sequence_num)::in, ilds.class_name::out, ilds.id::out) is det. % class_name(Module, Name) returns a class name representing @@ -190,7 +190,7 @@ % file-wide attributes (all static) module_name :: mlds_module_name, assembly_name :: ilds.id, - imports :: mlds.imports, + imports :: mlds_imports, file_foreign_langs :: set(foreign_language), % file foreign code @@ -363,12 +363,12 @@ get_il_data_rep(ILDataRep, !IO) :- ILDataRep = il_data_rep(HighLevelData, ILEnvPtrType). :- pred has_foreign_code_defined( - map(foreign_language, mlds.foreign_code)::in, + map(foreign_language, mlds_foreign_code)::in, foreign_language::in) is semidet. has_foreign_code_defined(ForeignCodeMap, Lang) :- ForeignCode = map.search(ForeignCodeMap, Lang), - ForeignCode = mlds.foreign_code(Decls, Imports, Codes, Exports), + ForeignCode = mlds_foreign_code(Decls, Imports, Codes, Exports), ( Decls = [_ | _] ; Imports = [_ | _] ; Codes = [_ | _] @@ -387,7 +387,7 @@ has_foreign_code_defined(ForeignCodeMap, Lang) :- transform_mlds(MLDS0) = MLDS :- AllExports = list.condense( list.map( - (func(mlds.foreign_code(_, _, _, Exports)) = Exports), + (func(mlds_foreign_code(_, _, _, Exports)) = Exports), map.values(MLDS0 ^ foreign_code)) ), @@ -396,8 +396,8 @@ transform_mlds(MLDS0) = MLDS :- list.map(mlds_export_to_mlds_defn, AllExports, ExportDefns), list.filter((pred(D::in) is semidet :- - ( D = mlds.defn(_, _, _, mlds.function(_, _, _, _)) - ; D = mlds.defn(_, _, _, mlds.data(_, _, _)) + ( D = mlds_defn(_, _, _, mlds_function(_, _, _, _)) + ; D = mlds_defn(_, _, _, mlds_data(_, _, _)) ) ), MLDS0 ^ defns ++ ExportDefns, MercuryCodeMembers, Others), WrapperClass = wrapper_class( @@ -406,26 +406,26 @@ transform_mlds(MLDS0) = MLDS :- % must precede the references to those types in WrapperClass. MLDS = MLDS0 ^ defns := list.map(rename_defn, Others) ++ [WrapperClass]. -:- func wrapper_class(mlds.defns) = mlds.defn. +:- func wrapper_class(mlds_defns) = mlds_defn. wrapper_class(Members) = - mlds.defn( + mlds_defn( export(wrapper_class_name), - mlds.make_context(term.context_init), + mlds_make_context(term.context_init), ml_gen_type_decl_flags, - mlds.class(mlds.class_defn(mlds.package, [], [], [], [], Members)) + mlds_class(mlds_class_defn(mlds_package, [], [], [], [], Members)) ). -:- func rename_defn(mlds.defn) = mlds.defn. +:- func rename_defn(mlds_defn) = mlds_defn. -rename_defn(defn(Name, Context, Flags, Entity0)) - = defn(Name, Context, Flags, Entity) :- +rename_defn(mlds_defn(Name, Context, Flags, Entity0)) + = mlds_defn(Name, Context, Flags, Entity) :- ( - Entity0 = data(Type, Initializer, GC_TraceCode), - Entity = data(Type, rename_initializer(Initializer), + Entity0 = mlds_data(Type, Initializer, GC_TraceCode), + Entity = mlds_data(Type, rename_initializer(Initializer), rename_maybe_statement(GC_TraceCode)) ; - Entity0 = function(MaybePredProcId, Params, FunctionBody0, + Entity0 = mlds_function(MaybePredProcId, Params, FunctionBody0, Attributes), ( FunctionBody0 = defined_here(Stmt), @@ -434,15 +434,15 @@ rename_defn(defn(Name, Context, Flags, Entity0)) FunctionBody0 = external, FunctionBody = external ), - Entity = function(MaybePredProcId, Params, FunctionBody, + Entity = mlds_function(MaybePredProcId, Params, FunctionBody, Attributes) ; - Entity0 = class(ClassDefn), - ClassDefn = class_defn(Kind, Imports, Inherits, Implements, + Entity0 = mlds_class(ClassDefn0), + ClassDefn0 = mlds_class_defn(Kind, Imports, Inherits, Implements, Ctors, Members), - Entity = class(class_defn(Kind, Imports, Inherits, Implements, - list.map(rename_defn, Ctors), - list.map(rename_defn, Members))) + ClassDefn = mlds_class_defn(Kind, Imports, Inherits, Implements, + list.map(rename_defn, Ctors), list.map(rename_defn, Members)), + Entity = mlds_class(ClassDefn) ). :- func rename_maybe_statement(maybe(statement)) = maybe(statement). @@ -507,18 +507,18 @@ rename_statement(statement(do_commit(Rval), Context)) rename_statement(statement(atomic(Stmt), Context)) = statement(atomic(rename_atomic(Stmt)), Context). -:- func rename_switch_case(switch_case) = switch_case. +:- func rename_switch_case(mlds_switch_case) = mlds_switch_case. rename_switch_case(Conds - Stmt) = list.map(rename_cond, Conds) - rename_statement(Stmt). -:- func rename_cond(case_match_cond) = case_match_cond. +:- func rename_cond(mlds_case_match_cond) = mlds_case_match_cond. rename_cond(match_value(Rval)) = match_value(rename_rval(Rval)). rename_cond(match_range(RvalA, RvalB)) = match_range(rename_rval(RvalA), rename_rval(RvalB)). -:- func rename_atomic(atomic_statement) = atomic_statement. +:- func rename_atomic(mlds_atomic_statement) = mlds_atomic_statement. rename_atomic(comment(S)) = comment(S). rename_atomic(assign(L, R)) = assign(rename_lval(L), rename_rval(R)). @@ -558,7 +558,7 @@ rename_const(code_addr_const(C)) = code_addr_const(rename_code_addr(C)). rename_const(data_addr_const(A)) = data_addr_const(rename_data_addr(A)). rename_const(null(T)) = null(T). -:- func rename_code_addr(mlds.code_addr) = mlds.code_addr. +:- func rename_code_addr(mlds_code_addr) = mlds_code_addr. rename_code_addr(proc(Label, Signature)) = proc(rename_proc_label(Label), Signature). @@ -566,7 +566,7 @@ rename_code_addr(internal(Label, Seq, Signature)) = internal(rename_proc_label(Label), Seq, Signature). rename_proc_label(qual(Module, _QualKind, Name)) - = qual(append_wrapper_class(Module), type_qual, Name). + = qual(mlds_append_wrapper_class(Module), type_qual, Name). :- func rename_lval(mlds_lval) = mlds_lval. @@ -576,12 +576,12 @@ rename_lval(field(Tag, Address, FieldName, FieldType, PtrType)) rename_lval(mem_ref(Rval, Type)) = mem_ref(rename_rval(Rval), Type). rename_lval(var(Var, Type)) = var(rename_var(Var, Type), Type). -:- func rename_field_id(field_id) = field_id. +:- func rename_field_id(mlds_field_id) = mlds_field_id. rename_field_id(offset(Rval)) = offset(rename_rval(Rval)). rename_field_id(named_field(Name, Type)) = named_field(Name, Type). -:- func rename_initializer(mlds.initializer) = mlds.initializer. +:- func rename_initializer(mlds_initializer) = mlds_initializer. rename_initializer(init_obj(Rval)) = init_obj(rename_rval(Rval)). rename_initializer(init_struct(Type, Inits)) @@ -593,90 +593,91 @@ rename_initializer(no_initializer) = no_initializer. % We need to append a wrapper class qualifier so that we access % the RTTI fields correctly. % -:- func rename_data_addr(data_addr) = data_addr. +:- func rename_data_addr(mlds_data_addr) = mlds_data_addr. rename_data_addr(data_addr(ModuleName, Name)) - = data_addr(append_wrapper_class(ModuleName), Name). + = data_addr(mlds_append_wrapper_class(ModuleName), Name). % We need to append a wrapper class qualifier so that we refer to the % methods of the wrapper class. % -:- func rename_proc_label(mlds.qualified_proc_label) - = mlds.qualified_proc_label. +:- func rename_proc_label(mlds_qualified_proc_label) + = mlds_qualified_proc_label. % Again append a wrapper class qualifier to the var name. % -:- func rename_var(mlds.var, mlds_type) = mlds.var. +:- func rename_var(mlds_var, mlds_type) = mlds_var. rename_var(qual(ModuleName, _QualKind, Name), _Type) - = qual(append_wrapper_class(ModuleName), type_qual, Name). + = qual(mlds_append_wrapper_class(ModuleName), type_qual, Name). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- pred mlds_defn_to_ilasm_decl(mlds.defn::in, ilasm.decl::out, +:- pred mlds_defn_to_ilasm_decl(mlds_defn::in, ilasm.decl::out, il_info::in, il_info::out) is det. % IL supports top-level (i.e. "global") function definitions and % data definitions, but they're not part of the CLS. % Since they are not part of the CLS, we don't generate them, % and so there's no need to handle them here. -mlds_defn_to_ilasm_decl(defn(_Name, _Context, _Flags, data(_Type, _Init, _GC)), - _Decl, !Info) :- - sorry(this_file, "top level data definition!"). -mlds_defn_to_ilasm_decl(defn(_Name, _Context, _Flags, - function(_MaybePredProcId, _Params, _MaybeStmts, _Attrs)), - _Decl, !Info) :- - sorry(this_file, "top level function definition!"). -mlds_defn_to_ilasm_decl(defn(Name, Context, Flags0, class(ClassDefn)), - Decl, !Info) :- - il_info_new_class(ClassDefn, !Info), - - generate_class_body(Name, Context, ClassDefn, ClassName, EntityName, - Extends, Interfaces, MethodsAndFieldsAndCtors, !Info), - - % Only the wrapper class needs to have the initialization instructions - % executed by the class constructor. - ( EntityName = wrapper_class_name -> - Imports = !.Info ^ imports, - InitInstrs = list.condense(tree.flatten(!.Info ^ init_instrs)), - AllocInstrs = list.condense(tree.flatten(!.Info ^ alloc_instrs)), - - % Generate a field that records whether we have finished - % RTTI initialization. - generate_rtti_initialization_field(ClassName, - AllocDoneFieldRef, AllocDoneField), - - % Generate a class constructor. - make_class_constructor_class_member(AllocDoneFieldRef, - Imports, AllocInstrs, InitInstrs, CCtor, !Info), - - % The declarations in this class. - MethodDecls = [AllocDoneField, CCtor | MethodsAndFieldsAndCtors] +mlds_defn_to_ilasm_decl(mlds_defn(Name, Context, Flags0, Data), Decl, !Info) :- + ( + Data = mlds_data(_Type, _Init, _GC), + sorry(this_file, "top level data definition!") ; - MethodDecls = MethodsAndFieldsAndCtors - ), - % XXX Needed to work around a bug where private classes aren't accessible - % from classes in the same assembly when that assembly is created by - % al.exe. This occurs for nondet environment classes in the mercury std - % library. - ( ClassName = structured_name(assembly("mercury"), _, _) -> - Flags = set_access(Flags0, public) + Data = mlds_function(_MaybePredProcId, _Params, _MaybeStmts, _Attrs), + sorry(this_file, "top level function definition!") ; - Flags = Flags0 - ), - Decl = class(decl_flags_to_classattrs(Flags), EntityName, Extends, - Interfaces, MethodDecls). + Data = mlds_class(ClassDefn), + il_info_new_class(ClassDefn, !Info), -:- pred generate_class_body(mlds.entity_name::in, mlds.context::in, - mlds.class_defn::in, ilds.class_name::out, ilds.id::out, + generate_class_body(Name, Context, ClassDefn, ClassName, EntityName, + Extends, Interfaces, MethodsAndFieldsAndCtors, !Info), + + % Only the wrapper class needs to have the initialization instructions + % executed by the class constructor. + ( EntityName = wrapper_class_name -> + Imports = !.Info ^ imports, + InitInstrs = list.condense(tree.flatten(!.Info ^ init_instrs)), + AllocInstrs = list.condense(tree.flatten(!.Info ^ alloc_instrs)), + + % Generate a field that records whether we have finished + % RTTI initialization. + generate_rtti_initialization_field(ClassName, + AllocDoneFieldRef, AllocDoneField), + + % Generate a class constructor. + make_class_constructor_class_member(AllocDoneFieldRef, + Imports, AllocInstrs, InitInstrs, CCtor, !Info), + + % The declarations in this class. + MethodDecls = [AllocDoneField, CCtor | MethodsAndFieldsAndCtors] + ; + MethodDecls = MethodsAndFieldsAndCtors + ), + % XXX Needed to work around a bug where private classes aren't + % accessible from classes in the same assembly when that assembly + % is created by al.exe. This occurs for nondet environment classes + % in the mercury std library. + ( ClassName = structured_name(assembly("mercury"), _, _) -> + Flags = set_access(Flags0, public) + ; + Flags = Flags0 + ), + Decl = class(decl_flags_to_classattrs(Flags), EntityName, Extends, + Interfaces, MethodDecls) + ). + +:- pred generate_class_body(mlds_entity_name::in, mlds_context::in, + mlds_class_defn::in, ilds.class_name::out, ilds.id::out, extends::out, implements::out, list(class_member)::out, il_info::in, il_info::out) is det. generate_class_body(Name, Context, ClassDefn, ClassName, EntityName, Extends, Interfaces, ClassMembers, !Info) :- EntityName = entity_name_to_ilds_id(Name), - ClassDefn = class_defn(Kind, _Imports, Inherits, Implements, + ClassDefn = mlds_class_defn(Kind, _Imports, Inherits, Implements, Ctors0, Members), Parent - Extends = generate_parent_and_extends(!.Info ^ il_data_rep, Kind, Inherits), @@ -694,47 +695,47 @@ generate_class_body(Name, Context, ClassDefn, ClassName, EntityName, Extends, % newobj instruction to allocate instances of the class. So if a class % doesn't already have one, we add an empty one. % -:- func maybe_add_empty_ctor(mlds.defns, mlds.class_kind, mlds.context) = - mlds.defns. +:- func maybe_add_empty_ctor(mlds_defns, mlds_class_kind, mlds_context) = + mlds_defns. maybe_add_empty_ctor(Ctors0, Kind, Context) = Ctors :- ( - Kind = mlds.class, + Kind = mlds_class, Ctors0 = [] -> % Generate an empty block for the body of the constructor. Stmt = statement(block([], []), Context), Attributes = [], - Ctor = mlds.function(no, func_params([], []), defined_here(Stmt), + Ctor = mlds_function(no, mlds_func_params([], []), defined_here(Stmt), Attributes), CtorFlags = init_decl_flags(public, per_instance, non_virtual, overridable, modifiable, concrete), - CtorDefn = mlds.defn(export(".ctor"), Context, CtorFlags, Ctor), + CtorDefn = mlds_defn(export(".ctor"), Context, CtorFlags, Ctor), Ctors = [CtorDefn] ; Ctors = Ctors0 ). -:- func generate_parent_and_extends(il_data_rep, mlds.class_kind, - list(mlds.class_id)) = pair(ilds.class_name, extends). +:- func generate_parent_and_extends(il_data_rep, mlds_class_kind, + list(mlds_class_id)) = pair(ilds.class_name, extends). generate_parent_and_extends(DataRep, Kind, Inherits) = Parent - Extends :- ( Inherits = [], ( - Kind = mlds.struct, + Kind = mlds_struct, Parent = il_generic_valuetype_name, Extends = extends(Parent) ; - Kind = mlds.enum, + Kind = mlds_enum, Parent = il_generic_enum_name, Extends = extends(Parent) ; - ( Kind = mlds.class - ; Kind = mlds.package - ; Kind = mlds.interface + ( Kind = mlds_class + ; Kind = mlds_package + ; Kind = mlds_interface ), Parent = il_generic_class_name, Extends = extends_nothing @@ -760,7 +761,7 @@ sym_name_to_list(unqualified(Name)) = [Name]. sym_name_to_list(qualified(Module, Name)) = sym_name_to_list(Module) ++ [Name]. -:- func decl_flags_to_classattrs(mlds.decl_flags) = list(ilasm.classattr). +:- func decl_flags_to_classattrs(mlds_decl_flags) = list(ilasm.classattr). decl_flags_to_classattrs(Flags) = list.condense([Access, decl_flags_to_classattrs_2(Flags)]) :- @@ -786,7 +787,7 @@ decl_flags_to_classattrs(Flags) = "decl_flags_to_classattrs: local access flag") ). -:- func decl_flags_to_nestedclassattrs(mlds.decl_flags) = +:- func decl_flags_to_nestedclassattrs(mlds_decl_flags) = list(ilasm.classattr). decl_flags_to_nestedclassattrs(Flags) @@ -810,7 +811,7 @@ decl_flags_to_nestedclassattrs(Flags) "decl_flags_to_classattrs: local access flag") ). -:- func decl_flags_to_classattrs_2(mlds.decl_flags) = list(ilasm.classattr). +:- func decl_flags_to_classattrs_2(mlds_decl_flags) = list(ilasm.classattr). decl_flags_to_classattrs_2(Flags) = list.condense([Finality, Abstractness]) :- FinalityFlag = finality(Flags), @@ -830,7 +831,7 @@ decl_flags_to_classattrs_2(Flags) = list.condense([Finality, Abstractness]) :- Abstractness = [abstract] ). -:- func decl_flags_to_methattrs(mlds.decl_flags) = list(ilasm.methattr). +:- func decl_flags_to_methattrs(mlds_decl_flags) = list(ilasm.methattr). decl_flags_to_methattrs(Flags) = list.condense([Access, PerInstance, Virtuality, @@ -886,7 +887,7 @@ decl_flags_to_methattrs(Flags) Abstractness = [abstract] ). -:- func decl_flags_to_fieldattrs(mlds.decl_flags) = list(ilasm.fieldattr). +:- func decl_flags_to_fieldattrs(mlds_decl_flags) = list(ilasm.fieldattr). decl_flags_to_fieldattrs(Flags) = list.condense([Access, PerInstance, Constness]) :- @@ -926,7 +927,7 @@ decl_flags_to_fieldattrs(Flags) Constness = [initonly] ). -:- func entity_name_to_ilds_id(mlds.entity_name) = ilds.id. +:- func entity_name_to_ilds_id(mlds_entity_name) = ilds.id. entity_name_to_ilds_id(export(Name)) = Name. entity_name_to_ilds_id(function(PredLabel, ProcId, MaybeSeqNum, _)) = Name :- @@ -936,7 +937,7 @@ entity_name_to_ilds_id(type(Name, Arity)) entity_name_to_ilds_id(data(DataName)) = mangle_dataname(DataName). -:- func interface_id_to_class_name(mlds.interface_id) = ilds.class_name. +:- func interface_id_to_class_name(mlds_interface_id) = ilds.class_name. interface_id_to_class_name(_) = Result :- % XXX @@ -949,11 +950,11 @@ interface_id_to_class_name(_) = Result :- %-----------------------------------------------------------------------------% :- pred generate_method(ilds.class_name::in, maybe(ilds.class_name)::in, - mlds.defn::in, class_member::out, il_info::in, il_info::out) is det. + mlds_defn::in, class_member::out, il_info::in, il_info::out) is det. -generate_method(ClassName, _, defn(Name, Context, Flags, Entity), +generate_method(ClassName, _, mlds_defn(Name, Context, Flags, Entity), ClassMember, !Info) :- - Entity = data(Type, DataInitializer, _GC_TraceCode), + Entity = mlds_data(Type, DataInitializer, _GC_TraceCode), FieldName = entity_name_to_ilds_id(Name), @@ -1035,9 +1036,9 @@ generate_method(ClassName, _, defn(Name, Context, Flags, Entity), ClassMember = field(Attrs, ILType, FieldName, MaybeOffset, Initializer). -generate_method(_, IsCons, defn(Name, Context, Flags, Entity), ClassMember, - !Info) :- - Entity = function(_MaybePredProcId, Params, MaybeStatement, +generate_method(_, IsCons, mlds_defn(Name, Context, Flags, Entity), + ClassMember, !Info) :- + Entity = mlds_function(_MaybePredProcId, Params, MaybeStatement, Attributes), il_info_get_module_name(!.Info, ModuleName), @@ -1050,7 +1051,7 @@ generate_method(_, IsCons, defn(Name, Context, Flags, Entity), ClassMember, % term.type_to_term(defn(Name, Context, Flags, Entity), _MLDSDefnTerm), % Generate the signature - Params = mlds.func_params(Args, Returns), + Params = mlds_func_params(Args, Returns), ILArgs = list.map(mlds_arg_to_il_arg, Args), DataRep = !.Info ^ il_data_rep, ILSignature = params_to_il_signature(DataRep, ModuleName, Params), @@ -1290,9 +1291,9 @@ generate_method(_, IsCons, defn(Name, Context, Flags, Entity), ClassMember, ClassMember = ilasm.method(methodhead(Attrs, MemberName, ILSignature, []), MethodContents). -generate_method(_, _, defn(Name, Context, Flags, Entity), ClassMember, +generate_method(_, _, mlds_defn(Name, Context, Flags, Entity), ClassMember, !Info) :- - Entity = class(ClassDefn), + Entity = mlds_class(ClassDefn), generate_class_body(Name, Context, ClassDefn, _ClassName, EntityName, Extends, Interfaces, ClassMembers, !Info), ClassMember = nested_class(decl_flags_to_nestedclassattrs(Flags), @@ -1300,13 +1301,13 @@ generate_method(_, _, defn(Name, Context, Flags, Entity), ClassMember, %-----------------------------------------------------------------------------% -:- func attributes_to_custom_attributes(il_data_rep, list(mlds.attribute)) +:- func attributes_to_custom_attributes(il_data_rep, list(mlds_attribute)) = list(method_body_decl). attributes_to_custom_attributes(DataRep, Attrs) = list.map(attribute_to_custom_attribute(DataRep), Attrs). -:- func attribute_to_custom_attribute(il_data_rep, mlds.attribute) +:- func attribute_to_custom_attribute(il_data_rep, mlds_attribute) = method_body_decl. attribute_to_custom_attribute(DataRep, custom(MLDSType)) @@ -1317,7 +1318,7 @@ attribute_to_custom_attribute(DataRep, custom(MLDSType)) %-----------------------------------------------------------------------------% -:- func mangle_dataname(mlds.data_name) = string. +:- func mangle_dataname(mlds_data_name) = string. mangle_dataname(var(MLDSVarName)) = mangle_mlds_var_name(MLDSVarName). @@ -1349,17 +1350,17 @@ mangle_dataname(tabling_pointer(_)) = _MangledName :- % We could use almost the same approach for outline_foreign_code % to generate the forwarding function. % -:- pred mlds_export_to_mlds_defn(mlds.pragma_export::in, mlds.defn::out) +:- pred mlds_export_to_mlds_defn(mlds_pragma_export::in, mlds_defn::out) is det. mlds_export_to_mlds_defn( ml_pragma_export(ExportName, EntityName, Params, Context), Defn) :- EntityName = qual(ModuleName, _QualKind, UnqualName), - Params = mlds.func_params(Inputs, RetTypes), + Params = mlds_func_params(Inputs, RetTypes), list.map_foldl( (pred(RT::in, RV - Lval::out, N0::in, N0 + 1::out) is det :- - VN = var_name("returnval" ++ int_to_string(N0), no), + VN = mlds_var_name("returnval" ++ int_to_string(N0), no), % We don't need to worry about tracing variables for % accurate GC in the IL back-end -- the .NET runtime % system itself provides accurate GC. @@ -1378,9 +1379,9 @@ mlds_export_to_mlds_defn( "exported method has argument without var name") ) ), - ArgTypes = mlds.get_arg_types(Inputs), + ArgTypes = mlds_get_arg_types(Inputs), ArgRvals = list.map( - (func(mlds.argument(EntName, Type, _GC_TraceCode)) = + (func(mlds_argument(EntName, Type, _GC_TraceCode)) = lval(var(VarName, Type)) :- VarName = EntNameToVarName(EntName) ), Inputs), @@ -1388,7 +1389,7 @@ mlds_export_to_mlds_defn( ReturnLvals = assoc_list.values(ReturnVars), ReturnRvals = list.map((func(X) = lval(X)), ReturnLvals), - Signature = func_signature(ArgTypes, RetTypes), + Signature = mlds_func_signature(ArgTypes, RetTypes), ( UnqualName = function(PredLabel, ProcId, _MaybeSeq, _PredId) -> CodeRval = const(code_addr_const(proc( qual(ModuleName, module_qual, PredLabel - ProcId), Signature))) @@ -1402,7 +1403,7 @@ mlds_export_to_mlds_defn( ordinary_call), Context), ReturnStatement = statement(return(ReturnRvals), Context), - Statement = statement(mlds.block(ReturnVarDecls, + Statement = statement(block(ReturnVarDecls, ( ReturnRvals = [] -> [CallStatement] ; @@ -1411,11 +1412,12 @@ mlds_export_to_mlds_defn( ), Context), Attributes = [], - DefnEntity = function(no, Params, defined_here(Statement), Attributes), + DefnEntity = mlds_function(no, Params, defined_here(Statement), + Attributes), Flags = init_decl_flags(public, one_copy, non_virtual, overridable, const, concrete), - Defn = defn(export(ExportName), Context, Flags, DefnEntity). + Defn = mlds_defn(export(ExportName), Context, Flags, DefnEntity). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -1426,14 +1428,14 @@ mlds_export_to_mlds_defn( % Generate initializer code from an MLDS defn. We are only expecting % data defns at this point (local vars), not functions or classes. % -:- pred generate_defn_initializer(mlds.defn::in, +:- pred generate_defn_initializer(mlds_defn::in, instr_tree::in, instr_tree::out, il_info::in, il_info::out) is det. -generate_defn_initializer(defn(Name, Context, _DeclFlags, Entity), +generate_defn_initializer(mlds_defn(Name, Context, _DeclFlags, Entity), !Tree, !Info) :- ( Name = data(DataName), - Entity = mlds.data(MLDSType, Initializer, _GC_TraceCode) + Entity = mlds_data(MLDSType, Initializer, _GC_TraceCode) -> ( Initializer = no_initializer -> true @@ -1472,7 +1474,7 @@ generate_defn_initializer(defn(Name, Context, _DeclFlags, Entity), % XXX the code generator doesn't box these values % we need to look ahead at them and box them appropriately. % -:- pred data_initializer_to_instrs(mlds.initializer::in, mlds_type::in, +:- pred data_initializer_to_instrs(mlds_initializer::in, mlds_type::in, instr_tree::out, instr_tree::out, il_info::in, il_info::out) is det. data_initializer_to_instrs(init_obj(Rval), _Type, node([]), InitInstrs, @@ -1502,13 +1504,13 @@ data_initializer_to_instrs(init_array(InitList), Type, % Figure out the array element type. DataRep = !.Info ^ il_data_rep, - ( Type = mlds.array_type(ElemType0) -> + ( Type = mlds_array_type(ElemType0) -> ElemType = ElemType0, ILElemType = mlds_type_to_ilds_type(DataRep, ElemType) ; - % XXX We assume struct fields have type mlds.generic_type + % XXX We assume struct fields have type mlds_generic_type % This is probably wrong for --high-level-data. - ElemType = mlds.generic_type, + ElemType = mlds_generic_type, ILElemType = il_generic_type ), ILElemType = il_type(_, ILElemSimpleType), @@ -1535,7 +1537,7 @@ data_initializer_to_instrs(init_array(InitList), Type, Info0::in, Info::out) is det :- % we may need to box the arguments % XXX is this right? - ( ElemType = mlds.generic_type -> + ( ElemType = mlds_generic_type -> maybe_box_initializer(Init0, Init) ; Init = Init0 @@ -1551,7 +1553,7 @@ data_initializer_to_instrs(no_initializer, _, node([]), node([]), !Info). % If we are initializing an array or struct, we need to box % all the things inside it. % -:- pred maybe_box_initializer(mlds.initializer::in, mlds.initializer::out) +:- pred maybe_box_initializer(mlds_initializer::in, mlds_initializer::out) is det. % nothing to do @@ -1567,11 +1569,11 @@ maybe_box_initializer(init_obj(Rval), init_obj(NewRval)) :- % Code to flatten nested intializers. % -:- func flatten_inits(list(mlds.initializer)) = list(mlds.initializer). +:- func flatten_inits(list(mlds_initializer)) = list(mlds_initializer). flatten_inits(Inits) = list.condense(list.map(flatten_init, Inits)). -:- func flatten_init(mlds.initializer) = list(mlds.initializer). +:- func flatten_init(mlds_initializer) = list(mlds_initializer). flatten_init(I) = Inits :- ( I = init_struct(_Type, Inits0) -> @@ -1887,7 +1889,7 @@ statement_to_il(statement(computed_goto(Rval, MLDSLabels), Context), instr_node(switch(Targets)) ]). -:- pred atomic_statement_to_il(mlds.atomic_statement::in, instr_tree::out, +:- pred atomic_statement_to_il(mlds_atomic_statement::in, instr_tree::out, il_info::in, il_info::out) is det. atomic_statement_to_il(gc_check, node(Instrs), !Info) :- @@ -2000,12 +2002,12 @@ atomic_statement_to_il(new_object(Target, _MaybeTag, HasSecTag, Type, Size, DataRep = !.Info ^ il_data_rep, ( ( - Type = mlds.generic_env_ptr_type + Type = mlds_generic_env_ptr_type ; - Type = mlds.class_type(_, _, mlds.class) + Type = mlds_class_type(_, _, mlds_class) ; DataRep ^ highlevel_data = yes, - Type = mlds.mercury_type(MercuryType, type_cat_user_ctor, _), + Type = mercury_type(MercuryType, type_cat_user_ctor, _), \+ type_needs_lowlevel_rep(il, MercuryType) ) -> @@ -2144,7 +2146,7 @@ inline_code_to_il_asm([T | Ts]) = tree(Instrs, Rest) :- ( yes(max_stack_size(N)) = get_max_stack_attribute(Attrs) -> Instrs = tree_list([ ( MaybeContext = yes(Context) -> - context_node(mlds.make_context( Context)) + context_node(mlds_make_context( Context)) ; empty ), @@ -2865,7 +2867,7 @@ const_rval_to_function(Const, MemberName) :- % // Maybe initialise the runtime % call void [mercury]mercury.runtime::init_runtime(bool) % -:- pred make_class_constructor_class_member(fieldref::in, mlds.imports::in, +:- pred make_class_constructor_class_member(fieldref::in, mlds_imports::in, list(instr)::in, list(instr)::in, class_member::out, il_info::in, il_info::out) is det. @@ -2933,28 +2935,29 @@ mlds_inherits_to_ilds_inherits(DataRep, Inherits) = Extends :- ). :- pred mlds_signature_to_ilds_type_params(il_data_rep::in, - mlds.func_signature::in, list(il_type)::out) is det. + mlds_func_signature::in, list(il_type)::out) is det. mlds_signature_to_ilds_type_params(DataRep, - func_signature(Args, _Returns), Params) :- + mlds_func_signature(Args, _Returns), Params) :- Params = list.map(mlds_type_to_ilds_type(DataRep), Args). -:- func mlds_arg_to_il_arg(mlds.argument) = pair(ilds.id, mlds_type). +:- func mlds_arg_to_il_arg(mlds_argument) = pair(ilds.id, mlds_type). -mlds_arg_to_il_arg(mlds.argument(EntityName, Type, _GC_TraceCode)) = +mlds_arg_to_il_arg(mlds_argument(EntityName, Type, _GC_TraceCode)) = Id - Type :- mangle_entity_name(EntityName, Id). -:- func mlds_signature_to_ilds_type_params(il_data_rep, mlds.func_signature) +:- func mlds_signature_to_ilds_type_params(il_data_rep, mlds_func_signature) = list(il_type). -mlds_signature_to_ilds_type_params(DataRep, func_signature(Args, _Returns)) = +mlds_signature_to_ilds_type_params(DataRep, + mlds_func_signature(Args, _Returns)) = list.map(mlds_type_to_ilds_type(DataRep), Args). -:- func mlds_signature_to_il_return_param(il_data_rep, mlds.func_signature) +:- func mlds_signature_to_il_return_param(il_data_rep, mlds_func_signature) = ret_type. -mlds_signature_to_il_return_param(DataRep, func_signature(_, Returns)) +mlds_signature_to_il_return_param(DataRep, mlds_func_signature(_, Returns)) = Param :- ( Returns = [], @@ -2972,7 +2975,7 @@ mlds_signature_to_il_return_param(DataRep, func_signature(_, Returns)) params_to_il_signature(DataRep, ModuleName, FuncParams) = ILSignature :- ILInputTypes = list.map(input_param_to_ilds_type(DataRep, ModuleName), Inputs), - FuncParams = mlds.func_params(Inputs, Outputs), + FuncParams = mlds_func_params(Inputs, Outputs), ( Outputs = [], Param = void @@ -2987,11 +2990,11 @@ params_to_il_signature(DataRep, ModuleName, FuncParams) = ILSignature :- ), ILSignature = signature(call_conv(no, default), Param, ILInputTypes). -:- func input_param_to_ilds_type(il_data_rep, mlds_module_name, mlds.argument) +:- func input_param_to_ilds_type(il_data_rep, mlds_module_name, mlds_argument) = ilds.param. input_param_to_ilds_type(DataRep, _ModuleName, Arg) = ILType - yes(Id) :- - Arg = mlds.argument(EntityName, MldsType, _GC_TraceCode), + Arg = mlds_argument(EntityName, MldsType, _GC_TraceCode), mangle_entity_name(EntityName, Id), ILType = mlds_type_to_ilds_type(DataRep, MldsType). @@ -3003,61 +3006,60 @@ mlds_type_to_ilds_simple_type(DataRep, MLDSType) = SimpleType :- % XXX Make sure all the types are converted correctly. -mlds_type_to_ilds_type(_, mlds.rtti_type(_RttiName)) = il_object_array_type. +mlds_type_to_ilds_type(_, mlds_rtti_type(_RttiName)) = il_object_array_type. -mlds_type_to_ilds_type(DataRep, mlds.mercury_array_type(ElementType)) = - ( ElementType = mlds.mercury_type(_, type_cat_variable, _) -> +mlds_type_to_ilds_type(DataRep, mlds_mercury_array_type(ElementType)) = + ( ElementType = mercury_type(_, type_cat_variable, _) -> il_generic_array_type ; - il_type([], '[]'(mlds_type_to_ilds_type(DataRep, - ElementType), [])) + il_type([], '[]'(mlds_type_to_ilds_type(DataRep, ElementType), [])) ). -mlds_type_to_ilds_type(DataRep, mlds.array_type(ElementType)) = +mlds_type_to_ilds_type(DataRep, mlds_array_type(ElementType)) = il_type([], '[]'(mlds_type_to_ilds_type(DataRep, ElementType), [])). % XXX Should be checked. -mlds_type_to_ilds_type(_, mlds.type_info_type) = il_generic_type. +mlds_type_to_ilds_type(_, mlds_type_info_type) = il_generic_type. % This is tricky. It could be an integer, or it could be a System.Array. -mlds_type_to_ilds_type(_, mlds.pseudo_type_info_type) = il_generic_type. +mlds_type_to_ilds_type(_, mlds_pseudo_type_info_type) = il_generic_type. % IL has a pretty fuzzy idea about function types. We treat them % as integers for now % XXX This means the code is not verifiable. -mlds_type_to_ilds_type(_, mlds.func_type(_)) = il_type([], int32). +mlds_type_to_ilds_type(_, mlds_func_type(_)) = il_type([], int32). -mlds_type_to_ilds_type(_, mlds.generic_type) = il_generic_type. +mlds_type_to_ilds_type(_, mlds_generic_type) = il_generic_type. % XXX Using int32 here means the code is not verifiable % see comments about function types above. -mlds_type_to_ilds_type(_, mlds.cont_type(_ArgTypes)) = il_type([], int32). +mlds_type_to_ilds_type(_, mlds_cont_type(_ArgTypes)) = il_type([], int32). -mlds_type_to_ilds_type(_, mlds.class_type(Class, Arity, Kind)) = +mlds_type_to_ilds_type(_, mlds_class_type(Class, Arity, Kind)) = il_type([], SimpleType) :- ClassName = mlds_class_name_to_ilds_class_name(Class, Arity), SimpleType = mlds_class_to_ilds_simple_type(Kind, ClassName). -mlds_type_to_ilds_type(_, mlds.commit_type) = il_commit_type. +mlds_type_to_ilds_type(_, mlds_commit_type) = il_commit_type. -mlds_type_to_ilds_type(ILDataRep, mlds.generic_env_ptr_type) = +mlds_type_to_ilds_type(ILDataRep, mlds_generic_env_ptr_type) = ILDataRep^il_envptr_type. -mlds_type_to_ilds_type(_, mlds.native_bool_type) = il_type([], bool). +mlds_type_to_ilds_type(_, mlds_native_bool_type) = il_type([], bool). -mlds_type_to_ilds_type(_, mlds.native_char_type) = il_type([], char). +mlds_type_to_ilds_type(_, mlds_native_char_type) = il_type([], char). % These two following choices are arbitrary -- IL has native integer % and float types too. It's not clear whether there is any benefit % in mapping to them instead -- it all depends what the indended use - % of mlds.native_int_type and mlds.native_float_type is. + % of mlds_native_int_type and mlds_native_float_type is. % Any mapping other than int32 would have to be examined to see % whether it is going to be compatible with int32. -mlds_type_to_ilds_type(_, mlds.native_int_type) = il_type([], int32). +mlds_type_to_ilds_type(_, mlds_native_int_type) = il_type([], int32). -mlds_type_to_ilds_type(_, mlds.native_float_type) = il_type([], float64). +mlds_type_to_ilds_type(_, mlds_native_float_type) = il_type([], float64). -mlds_type_to_ilds_type(_, mlds.foreign_type(ForeignType)) +mlds_type_to_ilds_type(_, mlds_foreign_type(ForeignType)) = il_type([], Class) :- ( ForeignType = il(il(RefOrVal, Assembly, Type)), @@ -3079,13 +3081,13 @@ mlds_type_to_ilds_type(_, mlds.foreign_type(ForeignType)) unexpected(this_file, "java foreign type") ). -mlds_type_to_ilds_type(ILDataRep, mlds.ptr_type(MLDSType)) = +mlds_type_to_ilds_type(ILDataRep, mlds_ptr_type(MLDSType)) = il_type([], '&'(mlds_type_to_ilds_type(ILDataRep, MLDSType))). mlds_type_to_ilds_type(ILDataRep, mercury_type(MercuryType, TypeCategory, _)) = mlds_mercury_type_to_ilds_type(ILDataRep, MercuryType, TypeCategory). -mlds_type_to_ilds_type(_, mlds.unknown_type) = _ :- +mlds_type_to_ilds_type(_, mlds_unknown_type) = _ :- unexpected(this_file, "mlds_type_to_ilds_type: unknown_type"). % Get the corresponding ILDS type for an MLDS mercury type @@ -3126,15 +3128,15 @@ mlds_mercury_type_to_ilds_type(DataRep, MercuryType, type_cat_user_ctor) = il_object_array_type ). -:- func mlds_class_to_ilds_simple_type(mlds.class_kind, ilds.class_name) = +:- func mlds_class_to_ilds_simple_type(mlds_class_kind, ilds.class_name) = ilds.simple_type. mlds_class_to_ilds_simple_type(Kind, ClassName) = SimpleType :- - ( Kind = mlds.package, SimpleType = class(ClassName) - ; Kind = mlds.class, SimpleType = class(ClassName) - ; Kind = mlds.interface, SimpleType = class(ClassName) - ; Kind = mlds.struct, SimpleType = valuetype(ClassName) - ; Kind = mlds.enum, SimpleType = valuetype(ClassName) + ( Kind = mlds_package, SimpleType = class(ClassName) + ; Kind = mlds_class, SimpleType = class(ClassName) + ; Kind = mlds_interface, SimpleType = class(ClassName) + ; Kind = mlds_struct, SimpleType = valuetype(ClassName) + ; Kind = mlds_enum, SimpleType = valuetype(ClassName) ). :- func mercury_type_to_highlevel_class_type(mer_type) = il_type. @@ -3148,7 +3150,7 @@ mercury_type_to_highlevel_class_type(MercuryType) = ILType :- unexpected(this_file, "type_to_ctor_and_args failed") ). -:- func mlds_class_name_to_ilds_class_name(mlds.class, arity) = +:- func mlds_class_name_to_ilds_class_name(mlds_class, arity) = ilds.class_name. mlds_class_name_to_ilds_class_name(QualClassName, Arity) = IldsClassName :- @@ -3297,14 +3299,14 @@ predlabel_to_id(special_pred(PredName, MaybeModuleName, TypeName, Arity), Id = UnMangledId. % Id = name_mangle(UnMangledId). - % If an mlds.var is not an argument or a local, what is it? + % If an mlds_var is not an argument or a local, what is it? % We assume the given variable is a static field; % either a compiler-generated static, % or possibly a handwritten RTTI reference or a % reference to some hand-written code in the % modulename__csharp_code.mercury_code class. % -:- func make_static_fieldref(il_data_rep, mlds.var, mlds_type) = fieldref. +:- func make_static_fieldref(il_data_rep, mlds_var, mlds_type) = fieldref. make_static_fieldref(DataRep, Var, VarType) = FieldRef :- Var = qual(ModuleName, _QualKind, VarName), @@ -3360,7 +3362,7 @@ mangle_foreign_code_module(Lang, ModuleName0, ModuleName) :- % if the RTTI is defined in C code by hand. If no data_name is provided, % always do the mangling. % -:- pred mangle_dataname_module(maybe(mlds.data_name)::in, +:- pred mangle_dataname_module(maybe(mlds_data_name)::in, mlds_module_name::in, mlds_module_name::out) is det. mangle_dataname_module(no, !ModuleName) :- @@ -3383,7 +3385,7 @@ mangle_dataname_module(yes(DataName), !ModuleName) :- true ). -:- pred mangle_dataname(mlds.data_name::in, string::out) is det. +:- pred mangle_dataname(mlds_data_name::in, string::out) is det. mangle_dataname(var(MLDSVarName), Name) :- Name = mangle_mlds_var_name(MLDSVarName). @@ -3406,7 +3408,7 @@ mangle_mlds_proc_label(qual(ModuleName, _, PredLabel - ProcId), MaybeSeqNum, ClassName = mlds_module_name_to_class_name(ModuleName), predlabel_to_id(PredLabel, ProcId, MaybeSeqNum, PredStr). -:- pred mangle_entity_name(mlds.entity_name::in, string::out) is det. +:- pred mangle_entity_name(mlds_entity_name::in, string::out) is det. mangle_entity_name(type(_TypeName, _), _MangledName) :- unexpected(this_file, "can't mangle type names"). @@ -3423,11 +3425,11 @@ mangle_entity_name(export(_), _MangledName) :- mangle_mlds_var(qual(_ModuleName, _, VarName), Str) :- Str = mangle_mlds_var_name(VarName). -:- func mangle_mlds_var_name(mlds.var_name) = string. +:- func mangle_mlds_var_name(mlds_var_name) = string. -mangle_mlds_var_name(mlds.var_name(Name, yes(Num))) = +mangle_mlds_var_name(mlds_var_name(Name, yes(Num))) = string.format("%s_%d", [s(Name), i(Num)]). -mangle_mlds_var_name(mlds.var_name(Name, no)) = Name. +mangle_mlds_var_name(mlds_var_name(Name, no)) = Name. :- pred mlds_to_il.sym_name_to_string(sym_name::in, string::out) is det. @@ -3520,7 +3522,7 @@ is_argument(VarName, Info) :- is_local(VarName, Info) :- map.contains(Info ^ locals, VarName). -:- pred is_local_field(mlds.var::in, mlds_type::in, il_info::in, +:- pred is_local_field(mlds_var::in, mlds_type::in, il_info::in, fieldref::out) is semidet. is_local_field(Var, VarType, Info, FieldRef) :- @@ -3553,7 +3555,7 @@ rval_to_type(mkword(_, _), _) :- rval_to_type(unop(Unop, _), Type) :- ( Unop = box(_), - Type = mlds.generic_type + Type = mlds_generic_type ; Unop = unbox(UnboxType), Type = UnboxType @@ -3575,9 +3577,9 @@ rval_to_type(const(Const), Type) :- :- func rval_const_to_type(mlds_rval_const) = mlds_type. -rval_const_to_type(data_addr_const(_)) = mlds.array_type(mlds.generic_type). +rval_const_to_type(data_addr_const(_)) = mlds_array_type(mlds_generic_type). rval_const_to_type(code_addr_const(_)) - = mlds.func_type(mlds.func_params([], [])). + = mlds_func_type(mlds_func_params([], [])). rval_const_to_type(int_const(_)) = mercury_type(IntType, type_cat_int, non_foreign_type(IntType)) :- IntType = builtin(int). @@ -3585,8 +3587,8 @@ rval_const_to_type(float_const(_)) = mercury_type(FloatType, type_cat_float, non_foreign_type(FloatType)) :- FloatType = builtin(float). -rval_const_to_type(false) = mlds.native_bool_type. -rval_const_to_type(true) = mlds.native_bool_type. +rval_const_to_type(false) = mlds_native_bool_type. +rval_const_to_type(true) = mlds_native_bool_type. rval_const_to_type(string_const(_)) = mercury_type(StrType, type_cat_string, non_foreign_type(StrType)) :- StrType = builtin(string). @@ -3597,7 +3599,7 @@ rval_const_to_type(null(MldsType)) = MldsType. %-----------------------------------------------------------------------------% -:- func code_addr_constant_to_methodref(il_data_rep, mlds.code_addr) = +:- func code_addr_constant_to_methodref(il_data_rep, mlds_code_addr) = methodref. code_addr_constant_to_methodref(DataRep, proc(ProcLabel, Sig)) = MethodRef :- @@ -3619,7 +3621,7 @@ code_addr_constant_to_methodref(DataRep, % Assumed to be a field of a class. % -:- pred data_addr_constant_to_fieldref(mlds.data_addr::in, fieldref::out) +:- pred data_addr_constant_to_fieldref(mlds_data_addr::in, fieldref::out) is det. data_addr_constant_to_fieldref(data_addr(ModuleName, DataName), FieldRef) :- @@ -3639,12 +3641,12 @@ data_addr_constant_to_fieldref(data_addr(ModuleName, DataName), FieldRef) :- % in a separate pass. See defn_to_class_decl which does the same thing % when creating the fields. % -:- pred get_fieldref(il_data_rep::in, field_id::in, mlds_type::in, +:- pred get_fieldref(il_data_rep::in, mlds_field_id::in, mlds_type::in, mlds_type::in, fieldref::out, instr_tree::out) is det. get_fieldref(DataRep, FieldNum, FieldType, ClassType0, FieldRef, CastClassInstrs) :- - ( ClassType0 = mlds.ptr_type(ClassType1) -> + ( ClassType0 = mlds_ptr_type(ClassType1) -> ClassType = ClassType1 ; ClassType = ClassType0 @@ -3734,18 +3736,18 @@ common_prefix([X | Xs], [Y | Ys], Prefix, TailXs, TailYs) :- %-----------------------------------------------------------------------------% -:- pred defn_to_local(mlds_module_name::in, mlds.defn::in, +:- pred defn_to_local(mlds_module_name::in, mlds_defn::in, pair(ilds.id, mlds_type)::out) is det. defn_to_local(ModuleName, Defn, Id - MLDSType) :- - Defn = mlds.defn(Name, _Context, _DeclFlags, Entity), + Defn = mlds_defn(Name, _Context, _DeclFlags, Entity), ( Name = data(DataName), - Entity = mlds.data(MLDSType0, _Initializer, _GC_TraceCode) + Entity = mlds_data(MLDSType0, _Initializer, _GC_TraceCode) -> mangle_dataname(DataName, MangledDataName), mangle_mlds_var(qual(ModuleName, module_qual, - var_name(MangledDataName, no)), Id), + mlds_var_name(MangledDataName, no)), Id), MLDSType0 = MLDSType ; unexpected(this_file, "defn_to_local: definition name was not data/1") @@ -4073,7 +4075,7 @@ il_system_namespace_name = "System". % Generate extern decls for any assembly we reference. % :- pred generate_extern_assembly(string::in, assembly_decl::in, - bool::in, bool::in, mlds.imports::in, list(decl)::out) is det. + bool::in, bool::in, mlds_imports::in, list(decl)::out) is det. generate_extern_assembly(CurrentAssembly, Version, SignAssembly, SeparateAssemblies, Imports, AllDecls) :- @@ -4279,7 +4281,7 @@ responsible_for_init_runtime_name = id("responsible_for_initialising_runtime"). % Predicates for manipulating il_info % -:- func il_info_init(mlds_module_name, ilds.id, mlds.imports, +:- func il_info_init(mlds_module_name, ilds.id, mlds_imports, il_data_rep, bool, bool, bool, bool, bool) = il_info. il_info_init(ModuleName, AssemblyName, Imports, ILDataRep, @@ -4293,12 +4295,13 @@ il_info_init(ModuleName, AssemblyName, Imports, ILDataRep, DefaultSignature = signature(call_conv(no, default), void, []), MethodName = id(""). -:- pred il_info_new_class(class_defn::in, il_info::in, il_info::out) is det. +:- pred il_info_new_class(mlds_class_defn::in, il_info::in, il_info::out) + is det. il_info_new_class(ClassDefn, !Info) :- - ClassDefn = class_defn(_, _, _, _, _, Members), + ClassDefn = mlds_class_defn(_, _, _, _, _, Members), list.filter_map((pred(M::in, S::out) is semidet :- - M = mlds.defn(Name, _, _, data(_, _, _)), + M = mlds_defn(Name, _, _, mlds_data(_, _, _)), S = entity_name_to_ilds_id(Name) ), Members, FieldNames), !:Info = !.Info ^ alloc_instrs := empty, @@ -4359,11 +4362,11 @@ il_info_get_mlds_type(Id, Type, !Info) :- ). % RTTI creates global variables -- these all happen to be of - % type mlds.native_int_type. + % type mlds_native_int_type. % :- func mlds_type_for_rtti_global = mlds_type. -mlds_type_for_rtti_global = native_int_type. +mlds_type_for_rtti_global = mlds_native_int_type. :- pred il_info_set_modulename(mlds_module_name::in, il_info::in, il_info::out) is det. @@ -4464,14 +4467,14 @@ comment_node(S) = node([comment(S)]). % Use this to make contexts into trees easily. % -:- func context_node(mlds.context) = instr_tree. +:- func context_node(mlds_context) = instr_tree. context_node(Context) = node([context_instr(Context)]). -:- func context_instr(mlds.context) = instr. +:- func context_instr(mlds_context) = instr. context_instr(Context) = context(FileName, LineNumber) :- - ProgContext = mlds.get_prog_context(Context), + ProgContext = mlds_get_prog_context(Context), term.context_file(ProgContext, FileName), term.context_line(ProgContext, LineNumber). diff --git a/compiler/mlds_to_ilasm.m b/compiler/mlds_to_ilasm.m index 5c05e77b6..4bcf7fc41 100644 --- a/compiler/mlds_to_ilasm.m +++ b/compiler/mlds_to_ilasm.m @@ -69,7 +69,7 @@ %-----------------------------------------------------------------------------% output_mlds(MLDS, !IO) :- - ModuleName = mlds.get_module_name(MLDS), + ModuleName = mlds_get_module_name(MLDS), module_name_to_file_name(ModuleName, ".il", yes, ILAsmFile, !IO), output_to_file(ILAsmFile, output_assembler(MLDS), Result, !IO), @@ -89,7 +89,7 @@ output_mlds(MLDS, !IO) :- io::di, io::uo) is det. output_foreign_file(MLDS, ForeignLang, !IO) :- - ModuleName = mlds.get_module_name(MLDS), + ModuleName = mlds_get_module_name(MLDS), ( ForeignModuleName = foreign_language_module_name(ModuleName, ForeignLang), @@ -140,10 +140,10 @@ output_assembler(MLDS, ForeignLangs, !IO) :- globals.io_lookup_bool_option(verifiable_code, Verifiable, !IO), ( Peephole = yes -> VerifyOnly = no, - il_peephole.optimize(VerifyOnly, ILAsm0, ILAsm) + il_peephole_optimize(VerifyOnly, ILAsm0, ILAsm) ; Verifiable = yes -> VerifyOnly = yes, - il_peephole.optimize(VerifyOnly, ILAsm0, ILAsm) + il_peephole_optimize(VerifyOnly, ILAsm0, ILAsm) ; ILAsm0 = ILAsm ), diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m index 735c2d311..bb99bca6c 100644 --- a/compiler/mlds_to_java.m +++ b/compiler/mlds_to_java.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2000-2005 The University of Melbourne. +% Copyright (C) 2000-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -81,7 +81,7 @@ %-----------------------------------------------------------------------------% -:- module ml_backend__mlds_to_java. +:- module ml_backend.mlds_to_java. :- interface. :- import_module hlds.hlds_module. @@ -89,17 +89,16 @@ :- import_module io. -:- pred mlds_to_java__output_mlds(module_info::in, mlds::in, io::di, io::uo) - is det. +:- pred output_mlds(module_info::in, mlds::in, io::di, io::uo) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% :- implementation. - % XXX needed for c_util__output_quoted_string, - % c_util__output_quoted_multi_string, and - % c_util__make_float_literal. + % XXX needed for c_util.output_quoted_string, + % c_util.output_quoted_multi_string, and + % c_util.make_float_literal. :- import_module backend_libs.builtin_ops. :- import_module backend_libs.c_util. :- import_module backend_libs.export. % for export.type_to_type_string @@ -140,11 +139,11 @@ %-----------------------------------------------------------------------------% -mlds_to_java__output_mlds(ModuleInfo, MLDS, !IO) :- +output_mlds(ModuleInfo, MLDS, !IO) :- % Note that the Java file name that we use for modules in the % Mercury standard library do not include a "mercury." prefix; % that's why we don't call mercury_module_name_to_mlds here. - ModuleName = mlds__get_module_name(MLDS), + ModuleName = mlds_get_module_name(MLDS), JavaSafeModuleName = valid_module_name(ModuleName), module_name_to_file_name(JavaSafeModuleName, ".java", yes, JavaSourceFile, !IO), @@ -174,12 +173,12 @@ qualified_name_is_stdlib(qualified(Module, Name)) :- % Succeeds iff this definition is a data definition which % defines RTTI. % -:- pred defn_is_rtti_data(mlds__defn::in) is semidet. +:- pred defn_is_rtti_data(mlds_defn::in) is semidet. defn_is_rtti_data(Defn) :- - Defn = mlds__defn(_Name, _Context, _Flags, Body), - Body = mlds__data(Type, _, _), - Type = mlds__rtti_type(_). + Defn = mlds_defn(_Name, _Context, _Flags, Body), + Body = mlds_data(Type, _, _), + Type = mlds_rtti_type(_). % Succeeds iff this type is a enumeration. % @@ -223,7 +222,7 @@ type_category_is_object(type_cat_user_ctor) = yes. mlds_lval_type(var(_, VarType)) = VarType. mlds_lval_type(field(_, _, _, FieldType, _)) = FieldType. mlds_lval_type(mem_ref(_, PtrType)) = - ( PtrType = mlds__ptr_type(Type) -> + ( PtrType = mlds_ptr_type(Type) -> Type ; unexpected(this_file, "mlds_lval_type: mem_ref of non-pointer") @@ -285,12 +284,12 @@ enforce_java_names(Name, JavaName) :- % If the Name contains one or more dots (`.'), then capitalize % the first letter after the last dot. reverse_string(Name, RevName), - ( string__sub_string_search(RevName, ".", Pos) -> - string__split(RevName, Pos, Head0, Tail0), + ( string.sub_string_search(RevName, ".", Pos) -> + string.split(RevName, Pos, Head0, Tail0), reverse_string(Tail0, Tail), reverse_string(Head0, Head1), - string__capitalize_first(Head1, Head), - string__append(Tail, Head, JavaName) + string.capitalize_first(Head1, Head), + string.append(Tail, Head, JavaName) ; JavaName = Name ). @@ -298,11 +297,11 @@ enforce_java_names(Name, JavaName) :- :- pred reverse_string(string::in, string::out) is det. reverse_string(String0, String) :- - string__to_char_list(String0, String1), - string__from_rev_char_list(String1, String). + string.to_char_list(String0, String1), + string.from_rev_char_list(String1, String). -:- pred mangle_mlds_sym_name_for_java(sym_name::in, qual_kind::in, string::in, - string::out) is det. +:- pred mangle_mlds_sym_name_for_java(sym_name::in, mlds_qual_kind::in, + string::in, string::out) is det. mangle_mlds_sym_name_for_java(unqualified(Name), QualKind, _QualifierOp, JavaSafeName) :- @@ -328,7 +327,7 @@ mangle_mlds_sym_name_for_java(qualified(ModuleName0, PlainName), QualKind, ), MangledPlainName = name_mangle(FlippedPlainName), JavaSafePlainName = valid_symbol_name(MangledPlainName), - string__append_list([MangledModuleName, QualifierOp, JavaSafePlainName], + string.append_list([MangledModuleName, QualifierOp, JavaSafePlainName], JavaSafeName). %-----------------------------------------------------------------------------% @@ -343,10 +342,10 @@ mangle_mlds_sym_name_for_java(qualified(ModuleName0, PlainName), QualKind, valid_symbol_name(SymName) = ValidSymName :- Prefix = "mr_", - ( java_util__is_keyword(SymName) -> + ( java_is_keyword(SymName) -> % This is a reserved Java word, add the above prefix. ValidSymName = Prefix ++ SymName - ; string__append(Prefix, Suffix, SymName) -> + ; string.append(Prefix, Suffix, SymName) -> % This name already contains the prefix we are adding to % variables to avoid conficts, so add an additional '_'. ValidSymName = Prefix ++ "_" ++ Suffix @@ -372,14 +371,14 @@ valid_module_name(qualified(ModuleSpecifier, String)) = ValidModuleName :- % Code to output imports. % -:- pred output_imports(mlds__imports::in, io::di, io::uo) is det. +:- pred output_imports(mlds_imports::in, io::di, io::uo) is det. output_imports(Imports, !IO) :- - list__foldl(output_import, Imports, !IO), + list.foldl(output_import, Imports, !IO), % We should always import the mercury.runtime classes. - io__write_string("import mercury.runtime.*;\n\n", !IO). + io.write_string("import mercury.runtime.*;\n\n", !IO). -:- pred output_import(mlds__import::in, io::di, io::uo) is det. +:- pred output_import(mlds_import::in, io::di, io::uo) is det. output_import(Import, !IO) :- % XXX Handle `:- pragma export' to Java. @@ -398,14 +397,14 @@ output_import(Import, !IO) :- ), SymName = mlds_module_name_to_sym_name(ImportName), JavaSafeSymName = valid_module_name(SymName), - mdbcomp__prim_data__sym_name_to_string(JavaSafeSymName, ".", File), + sym_name_to_string(JavaSafeSymName, ".", File), % XXX Name mangling code should be put here when we start enforcing % Java's naming conventions. ClassFile = File, % There are issues related to using import statements and Java's naming % conventions. To avoid these problems, we output dependencies as comments % only. This is ok, since we always use fully qualified names anyway. - io__write_strings(["// import ", ClassFile, ";\n"], !IO). + io.write_strings(["// import ", ClassFile, ";\n"], !IO). %-----------------------------------------------------------------------------% % @@ -424,7 +423,7 @@ output_java_src_file(ModuleInfo, Indent, MLDS, !IO) :- % Find and build list of all methods which would have their addresses % taken to be used as a function pointer. find_pointer_addressed_methods(Defns0, [], CodeAddrs0), - CodeAddrs = list__sort_and_remove_dups(CodeAddrs0), + CodeAddrs = list.sort_and_remove_dups(CodeAddrs0), % Create wrappers in MLDS for all pointer addressed methods. generate_code_addr_wrappers(Indent + 1, CodeAddrs, [], WrapperDefns), @@ -433,10 +432,10 @@ output_java_src_file(ModuleInfo, Indent, MLDS, !IO) :- % Get the foreign code for Java % XXX We should not ignore _RevImports and _ExportDefns ForeignCode = mlds_get_java_foreign_code(AllForeignCode), - ForeignCode = mlds__foreign_code(RevForeignDecls, _RevImports, + ForeignCode = mlds_foreign_code(RevForeignDecls, _RevImports, RevBodyCode, _ExportDefns), - ForeignDecls = list__reverse(RevForeignDecls), - ForeignBodyCode = list__reverse(RevBodyCode), + ForeignDecls = list.reverse(RevForeignDecls), + ForeignBodyCode = list.reverse(RevBodyCode), % Output transformed MLDS as Java source. % @@ -446,10 +445,10 @@ output_java_src_file(ModuleInfo, Indent, MLDS, !IO) :- % library/private_builtin.m they contain static constants % that will get used in the RTTI definitions. output_src_start(Indent, ModuleName, Imports, ForeignDecls, Defns, !IO), - io__write_list(ForeignBodyCode, "\n", output_java_body_code(Indent), !IO), + io.write_list(ForeignBodyCode, "\n", output_java_body_code(Indent), !IO), CtorData = none, % Not a constructor. % XXX do we need to split this into RTTI and non-RTTI defns??? - list__filter(defn_is_rtti_data, Defns, RttiDefns, NonRttiDefns), + list.filter(defn_is_rtti_data, Defns, RttiDefns, NonRttiDefns), output_defns(Indent + 1, ModuleInfo, MLDS_ModuleName, CtorData, RttiDefns, !IO), output_defns(Indent + 1, ModuleInfo, MLDS_ModuleName, CtorData, @@ -468,36 +467,36 @@ output_java_src_file(ModuleInfo, Indent, MLDS, !IO) :- output_java_decl(Indent, DeclCode, !IO) :- DeclCode = foreign_decl_code(Lang, _IsLocal, Code, Context), ( Lang = java -> - indent_line(make_context(Context), Indent, !IO), - io__write_string(Code, !IO), - io__nl(!IO) + indent_line(mlds_make_context(Context), Indent, !IO), + io.write_string(Code, !IO), + io.nl(!IO) ; sorry(this_file, "foreign code other than Java") ). :- pred output_java_body_code(indent::in, user_foreign_code::in, io::di, - io__state::uo) is det. + io.state::uo) is det. output_java_body_code(Indent, user_foreign_code(Lang, Code, Context), !IO) :- % Only output Java code. ( Lang = java -> - indent_line(make_context(Context), Indent, !IO), - io__write_string(Code, !IO), - io__nl(!IO) + indent_line(mlds_make_context(Context), Indent, !IO), + io.write_string(Code, !IO), + io.nl(!IO) ; sorry(this_file, "foreign code other than Java") ). % Get the foreign code for Java. % -:- func mlds_get_java_foreign_code(map(foreign_language, mlds__foreign_code)) - = mlds__foreign_code. +:- func mlds_get_java_foreign_code(map(foreign_language, mlds_foreign_code)) + = mlds_foreign_code. mlds_get_java_foreign_code(AllForeignCode) = ForeignCode :- - ( map__search(AllForeignCode, java, ForeignCode0) -> + ( map.search(AllForeignCode, java, ForeignCode0) -> ForeignCode = ForeignCode0 ; - ForeignCode = foreign_code([], [], [], []) + ForeignCode = mlds_foreign_code([], [], [], []) ). %-----------------------------------------------------------------------------% @@ -508,36 +507,36 @@ mlds_get_java_foreign_code(AllForeignCode) = ForeignCode :- % Returns code-address information (function label and signature) % for each method/function which has its address taken in the MLDS. % -:- pred find_pointer_addressed_methods(mlds__defns::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. +:- pred find_pointer_addressed_methods(mlds_defns::in, + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. find_pointer_addressed_methods([], !CodeAddrs). find_pointer_addressed_methods([Defn | Defns], !CodeAddrs) :- - Defn = mlds__defn(_Name, _Context, _Flags, Body), + Defn = mlds_defn(_Name, _Context, _Flags, Body), method_ptrs_in_entity_defn(Body, !CodeAddrs), find_pointer_addressed_methods(Defns, !CodeAddrs). -:- pred method_ptrs_in_entity_defn(mlds__entity_defn::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_entity_defn(mlds_entity_defn::in, + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. -method_ptrs_in_entity_defn(mlds__function(_MaybeID, _Params, Body, +method_ptrs_in_entity_defn(mlds_function(_MaybeID, _Params, Body, _Attributes), !CodeAddrs) :- ( - Body = mlds__defined_here(Statement), + Body = defined_here(Statement), method_ptrs_in_statement(Statement, !CodeAddrs) ; - Body = mlds__external + Body = external ). -method_ptrs_in_entity_defn(mlds__data(_Type, Initializer, _GC_TraceCode), +method_ptrs_in_entity_defn(mlds_data(_Type, Initializer, _GC_TraceCode), !CodeAddrs) :- method_ptrs_in_initializer(Initializer, !CodeAddrs). -method_ptrs_in_entity_defn(mlds__class(ClassDefn), !CodeAddrs) :- - ClassDefn = mlds__class_defn(_, _, _, _, Ctors, Members), +method_ptrs_in_entity_defn(mlds_class(ClassDefn), !CodeAddrs) :- + ClassDefn = mlds_class_defn(_, _, _, _, Ctors, Members), method_ptrs_in_defns(Ctors, !CodeAddrs), method_ptrs_in_defns(Members, !CodeAddrs). :- pred method_ptrs_in_statements(statements::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. method_ptrs_in_statements([], !CodeAddrs). method_ptrs_in_statements([Statement | Statements], !CodeAddrs) :- @@ -545,21 +544,21 @@ method_ptrs_in_statements([Statement | Statements], !CodeAddrs) :- method_ptrs_in_statements(Statements, !CodeAddrs). :- pred method_ptrs_in_statement(statement::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. method_ptrs_in_statement(statement(Stmt, _Context), !CodeAddrs) :- method_ptrs_in_stmt(Stmt, !CodeAddrs). -:- pred method_ptrs_in_stmt(mlds__stmt::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_stmt(mlds_stmt::in, + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. -method_ptrs_in_stmt(mlds__block(Defns, Statements), !CodeAddrs) :- +method_ptrs_in_stmt(block(Defns, Statements), !CodeAddrs) :- method_ptrs_in_defns(Defns, !CodeAddrs), method_ptrs_in_statements(Statements, !CodeAddrs). -method_ptrs_in_stmt(mlds__while(Rval, Statement, _Bool), !CodeAddrs) :- +method_ptrs_in_stmt(while(Rval, Statement, _Bool), !CodeAddrs) :- method_ptrs_in_rval(Rval, !CodeAddrs), method_ptrs_in_statement(Statement, !CodeAddrs). -method_ptrs_in_stmt(mlds__if_then_else(Rval, StatementThen, +method_ptrs_in_stmt(if_then_else(Rval, StatementThen, MaybeStatementElse), !CodeAddrs) :- method_ptrs_in_rval(Rval, !CodeAddrs), method_ptrs_in_statement(StatementThen, !CodeAddrs), @@ -569,64 +568,64 @@ method_ptrs_in_stmt(mlds__if_then_else(Rval, StatementThen, ; MaybeStatementElse = no ). -method_ptrs_in_stmt(mlds__switch(_Type, Rval, _Range, Cases, Default), +method_ptrs_in_stmt(switch(_Type, Rval, _Range, Cases, Default), !CodeAddrs) :- method_ptrs_in_rval(Rval, !CodeAddrs), method_ptrs_in_switch_cases(Cases, !CodeAddrs), method_ptrs_in_switch_default(Default, !CodeAddrs). -method_ptrs_in_stmt(mlds__label(_), _, _) :- +method_ptrs_in_stmt(label(_), _, _) :- unexpected(this_file, "method_ptrs_in_stmt: labels not supported in Java."). -method_ptrs_in_stmt(mlds__goto(break), !CodeAddrs). -method_ptrs_in_stmt(mlds__goto(continue), !CodeAddrs). -method_ptrs_in_stmt(mlds__goto(label(_)), _, _) :- +method_ptrs_in_stmt(goto(break), !CodeAddrs). +method_ptrs_in_stmt(goto(continue), !CodeAddrs). +method_ptrs_in_stmt(goto(label(_)), _, _) :- unexpected(this_file, "method_ptrs_in_stmt: goto label not supported in Java."). -method_ptrs_in_stmt(mlds__computed_goto(_, _), _, _) :- +method_ptrs_in_stmt(computed_goto(_, _), _, _) :- unexpected(this_file, "method_ptrs_in_stmt: computed gotos not supported in Java."). -method_ptrs_in_stmt(mlds__try_commit(_Lval, StatementGoal, +method_ptrs_in_stmt(try_commit(_Lval, StatementGoal, StatementHandler), !CodeAddrs) :- % We don't check "_Lval" here as we expect it to be a local variable - % of type mlds__commit_type. + % of type mlds_commit_type. method_ptrs_in_statement(StatementGoal, !CodeAddrs), method_ptrs_in_statement(StatementHandler, !CodeAddrs). -method_ptrs_in_stmt(mlds__do_commit(_Rval), !CodeAddrs). +method_ptrs_in_stmt(do_commit(_Rval), !CodeAddrs). % We don't check "_Rval" here as we expect it to be a local variable - % of type mlds__commit_type. -method_ptrs_in_stmt(mlds__return(Rvals), !CodeAddrs) :- + % of type mlds_commit_type. +method_ptrs_in_stmt(return(Rvals), !CodeAddrs) :- method_ptrs_in_rvals(Rvals, !CodeAddrs). -method_ptrs_in_stmt(mlds__call(_FuncSig, _Rval, _MaybeThis, Rvals, _ReturnVars, +method_ptrs_in_stmt(call(_FuncSig, _Rval, _MaybeThis, Rvals, _ReturnVars, _IsTailCall), !CodeAddrs) :- % We don't check "_Rval" - it may be a code address but is a % standard call rather than a function pointer use. method_ptrs_in_rvals(Rvals, !CodeAddrs). -method_ptrs_in_stmt(mlds__atomic(AtomicStatement), !CodeAddrs) :- +method_ptrs_in_stmt(atomic(AtomicStatement), !CodeAddrs) :- ( - AtomicStatement = mlds__new_object(Lval, _MaybeTag, _Bool, + AtomicStatement = new_object(Lval, _MaybeTag, _Bool, _Type, _MemRval, _MaybeCtorName, Rvals, _Types) -> % We don't need to check "_MemRval" since this just stores % the amount of memory needed for the new object. method_ptrs_in_lval(Lval, !CodeAddrs), method_ptrs_in_rvals(Rvals, !CodeAddrs) - ; AtomicStatement = mlds__assign(Lval, Rval) -> + ; AtomicStatement = assign(Lval, Rval) -> method_ptrs_in_lval(Lval, !CodeAddrs), method_ptrs_in_rval(Rval, !CodeAddrs) ; true ). -:- pred method_ptrs_in_switch_default(mlds__switch_default::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_switch_default(mlds_switch_default::in, + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. -method_ptrs_in_switch_default(mlds__default_is_unreachable, !CodeAddrs). -method_ptrs_in_switch_default(mlds__default_do_nothing, !CodeAddrs). -method_ptrs_in_switch_default(mlds__default_case(Statement), !CodeAddrs) :- +method_ptrs_in_switch_default(default_is_unreachable, !CodeAddrs). +method_ptrs_in_switch_default(default_do_nothing, !CodeAddrs). +method_ptrs_in_switch_default(default_case(Statement), !CodeAddrs) :- method_ptrs_in_statement(Statement, !CodeAddrs). -:- pred method_ptrs_in_switch_cases(mlds__switch_cases::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_switch_cases(mlds_switch_cases::in, + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. method_ptrs_in_switch_cases([], !CodeAddrs). method_ptrs_in_switch_cases([Case | Cases], !CodeAddrs) :- @@ -634,79 +633,79 @@ method_ptrs_in_switch_cases([Case | Cases], !CodeAddrs) :- method_ptrs_in_statement(Statement, !CodeAddrs), method_ptrs_in_switch_cases(Cases, !CodeAddrs). -:- pred method_ptrs_in_defns(mlds__defns::in, list(mlds__code_addr)::in, - list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_defns(mlds_defns::in, list(mlds_code_addr)::in, + list(mlds_code_addr)::out) is det. method_ptrs_in_defns([], !CodeAddrs). method_ptrs_in_defns([Defn | Defns], !CodeAddrs) :- method_ptrs_in_defn(Defn, !CodeAddrs), method_ptrs_in_defns(Defns, !CodeAddrs). -:- pred method_ptrs_in_defn(mlds__defn::in, list(mlds__code_addr)::in, - list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_defn(mlds_defn::in, list(mlds_code_addr)::in, + list(mlds_code_addr)::out) is det. -method_ptrs_in_defn(mlds__defn(_Name, _Context, _Flags, Body), !CodeAddrs) :- +method_ptrs_in_defn(mlds_defn(_Name, _Context, _Flags, Body), !CodeAddrs) :- method_ptrs_in_entity_defn(Body, !CodeAddrs). -:- pred method_ptrs_in_initializer(mlds__initializer::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_initializer(mlds_initializer::in, + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. -method_ptrs_in_initializer(mlds__no_initializer, !CodeAddrs). -method_ptrs_in_initializer(mlds__init_struct(_Type, Initializers), +method_ptrs_in_initializer(no_initializer, !CodeAddrs). +method_ptrs_in_initializer(init_struct(_Type, Initializers), !CodeAddrs) :- method_ptrs_in_initializers(Initializers, !CodeAddrs). -method_ptrs_in_initializer(mlds__init_array(Initializers), !CodeAddrs) :- +method_ptrs_in_initializer(init_array(Initializers), !CodeAddrs) :- method_ptrs_in_initializers(Initializers, !CodeAddrs). -method_ptrs_in_initializer(mlds__init_obj(Rval), !CodeAddrs) :- +method_ptrs_in_initializer(init_obj(Rval), !CodeAddrs) :- method_ptrs_in_rval(Rval, !CodeAddrs). -:- pred method_ptrs_in_initializers(list(mlds__initializer)::in, - list(mlds__code_addr)::in, list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_initializers(list(mlds_initializer)::in, + list(mlds_code_addr)::in, list(mlds_code_addr)::out) is det. method_ptrs_in_initializers([], !CodeAddrs). method_ptrs_in_initializers([Initializer | Initializers], !CodeAddrs) :- method_ptrs_in_initializer(Initializer, !CodeAddrs), method_ptrs_in_initializers(Initializers, !CodeAddrs). -:- pred method_ptrs_in_rvals(list(mlds_rval)::in, list(mlds__code_addr)::in, - list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_rvals(list(mlds_rval)::in, list(mlds_code_addr)::in, + list(mlds_code_addr)::out) is det. method_ptrs_in_rvals([], !CodeAddrs). method_ptrs_in_rvals([Rval | Rvals], !CodeAddrs) :- method_ptrs_in_rval(Rval, !CodeAddrs), method_ptrs_in_rvals(Rvals, !CodeAddrs). -:- pred method_ptrs_in_rval(mlds_rval::in, list(mlds__code_addr)::in, - list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_rval(mlds_rval::in, list(mlds_code_addr)::in, + list(mlds_code_addr)::out) is det. method_ptrs_in_rval(lval(Lval), !CodeAddrs) :- method_ptrs_in_lval(Lval, !CodeAddrs). -method_ptrs_in_rval(mlds__mkword(_Tag, Rval), !CodeAddrs) :- +method_ptrs_in_rval(mkword(_Tag, Rval), !CodeAddrs) :- method_ptrs_in_rval(Rval, !CodeAddrs). -method_ptrs_in_rval(mlds__const(RvalConst), !CodeAddrs) :- - ( RvalConst = mlds__code_addr_const(CodeAddr) -> +method_ptrs_in_rval(const(RvalConst), !CodeAddrs) :- + ( RvalConst = code_addr_const(CodeAddr) -> !:CodeAddrs = !.CodeAddrs ++ [CodeAddr] ; true ). -method_ptrs_in_rval(mlds__unop(_UnaryOp, Rval), !CodeAddrs) :- +method_ptrs_in_rval(unop(_UnaryOp, Rval), !CodeAddrs) :- method_ptrs_in_rval(Rval, !CodeAddrs). -method_ptrs_in_rval(mlds__binop(_BinaryOp, Rval1, Rval2), !CodeAddrs) :- +method_ptrs_in_rval(binop(_BinaryOp, Rval1, Rval2), !CodeAddrs) :- method_ptrs_in_rval(Rval1, !CodeAddrs), method_ptrs_in_rval(Rval2, !CodeAddrs). -method_ptrs_in_rval(mlds__mem_addr(_Address), !CodeAddrs). -method_ptrs_in_rval(mlds__self(_Type), !CodeAddrs). +method_ptrs_in_rval(mem_addr(_Address), !CodeAddrs). +method_ptrs_in_rval(self(_Type), !CodeAddrs). -:- pred method_ptrs_in_lval(mlds_lval::in, list(mlds__code_addr)::in, - list(mlds__code_addr)::out) is det. +:- pred method_ptrs_in_lval(mlds_lval::in, list(mlds_code_addr)::in, + list(mlds_code_addr)::out) is det. % Here, "_Rval" is the address of a variable so we don't check it. -method_ptrs_in_lval(mlds__mem_ref(_Rval, _Type), !CodeAddrs). +method_ptrs_in_lval(mem_ref(_Rval, _Type), !CodeAddrs). % Here, "_Rval" is a pointer to a cell on the heap, and doesn't need % to be considered. -method_ptrs_in_lval(mlds__field(_MaybeTag, _Rval, _FieldId, _FieldType, +method_ptrs_in_lval(field(_MaybeTag, _Rval, _FieldId, _FieldType, _PtrType), !CodeAddrs). -method_ptrs_in_lval(mlds__var(_Variable, _Type), !CodeAddrs). +method_ptrs_in_lval(var(_Variable, _Type), !CodeAddrs). %-----------------------------------------------------------------------------% % @@ -729,15 +728,15 @@ method_ptrs_in_lval(mlds__var(_Variable, _Type), !CodeAddrs). % Generates the MLDS to output the required wrapper classes % -:- pred generate_code_addr_wrappers(indent::in, list(mlds__code_addr)::in, - mlds__defns::in, mlds__defns::out) is det. +:- pred generate_code_addr_wrappers(indent::in, list(mlds_code_addr)::in, + mlds_defns::in, mlds_defns::out) is det. generate_code_addr_wrappers(_, [], !Defns). generate_code_addr_wrappers(Indent, [CodeAddr | CodeAddrs], !Defns) :- % XXX We should fill in the Context properly. This would probably involve % also returning context information for each "code_addr" returned by the % "method_ptrs_*" predicates above. - Context = mlds__make_context(term__context_init), + Context = mlds_make_context(term.context_init), InterfaceModuleName = mercury_module_name_to_mlds( qualified(unqualified("mercury"), "runtime")), Interface = qual(InterfaceModuleName, module_qual, "MethodPtr"), @@ -747,24 +746,24 @@ generate_code_addr_wrappers(Indent, [CodeAddr | CodeAddrs], !Defns) :- % Generate the MLDS wrapper class for a given code_addr. % -:- pred generate_addr_wrapper_class(mlds__class::in, - mlds__context::in, mlds__code_addr::in, mlds__defn::out) is det. +:- pred generate_addr_wrapper_class(mlds_class::in, + mlds_context::in, mlds_code_addr::in, mlds_defn::out) is det. generate_addr_wrapper_class(Interface, Context, CodeAddr, ClassDefn) :- ( - CodeAddr = mlds__proc(ProcLabel, _FuncSig), + CodeAddr = proc(ProcLabel, _FuncSig), MaybeSeqNum = no ; - CodeAddr = mlds__internal(ProcLabel, SeqNum, _FuncSig), + CodeAddr = internal(ProcLabel, SeqNum, _FuncSig), MaybeSeqNum = yes(SeqNum) ), - ProcLabel = mlds__qual(ModuleQualifier, QualKind, PredLabel - ProcID), + ProcLabel = qual(ModuleQualifier, QualKind, PredLabel - ProcID), PredName = make_pred_name_string(PredLabel, ProcID, MaybeSeqNum), % Create class components. ClassImports = [], ClassExtends = [], - InterfaceDefn = mlds__class_type(Interface, 0, mlds__interface), + InterfaceDefn = mlds_class_type(Interface, 0, mlds_interface), ClassImplements = [InterfaceDefn], % Create a method that calls the original predicate. @@ -784,27 +783,27 @@ generate_addr_wrapper_class(Interface, Context, CodeAddr, ClassDefn) :- ClassName = type(MangledClassEntityName, 0), ClassContext = Context, ClassFlags = ml_gen_type_decl_flags, - ClassBodyDefn = mlds__class_defn(mlds__class, ClassImports, + ClassBodyDefn = mlds_class_defn(mlds_class, ClassImports, ClassExtends, ClassImplements, ClassCtors, ClassMembers), - ClassBody = mlds__class(ClassBodyDefn), - ClassDefn = mlds__defn(ClassName, ClassContext, ClassFlags, ClassBody). + ClassBody = mlds_class(ClassBodyDefn), + ClassDefn = mlds_defn(ClassName, ClassContext, ClassFlags, ClassBody). % Generates a call methods which calls the original method we have % created the wrapper for. % -:- pred generate_call_method(mlds__code_addr::in, mlds__defn::out) is det. +:- pred generate_call_method(mlds_code_addr::in, mlds_defn::out) is det. generate_call_method(CodeAddr, MethodDefn) :- ( - CodeAddr = mlds__proc(ProcLabel, OrigFuncSignature) + CodeAddr = proc(ProcLabel, OrigFuncSignature) ; - CodeAddr = mlds__internal(ProcLabel, _SeqNum, OrigFuncSignature) + CodeAddr = internal(ProcLabel, _SeqNum, OrigFuncSignature) ), - OrigFuncSignature = mlds__func_signature(OrigArgTypes, OrigRetTypes), + OrigFuncSignature = mlds_func_signature(OrigArgTypes, OrigRetTypes), % XXX We should fill in the Context properly. - Context = mlds__make_context(term__context_init), + Context = mlds_make_context(term.context_init), ModuleName = ProcLabel ^ mod_name, - PredID = hlds_pred__initial_pred_id, + PredID = hlds_pred.initial_pred_id, ProcID = initial_proc_id, % Create new method name. @@ -814,43 +813,43 @@ generate_call_method(CodeAddr, MethodDefn) :- % Create method argument and return type. % It will have the argument type java.lang.Object[] % It will have the return type java.lang.Object - MethodArgVariable = var_name("args", no), - MethodArgType = argument(data(var(MethodArgVariable)), - mlds__array_type(mlds__generic_type), no), - MethodRetType = mlds__generic_type, + MethodArgVariable = mlds_var_name("args", no), + MethodArgType = mlds_argument(data(var(MethodArgVariable)), + mlds_array_type(mlds_generic_type), no), + MethodRetType = mlds_generic_type, MethodArgs = [MethodArgType], MethodRets = [MethodRetType], % Create a temporary variable to store the result of the call to the % original method. - ReturnVarName = var_name("return_value", no), - ReturnVar = mlds__qual(ModuleName, module_qual, ReturnVarName), + ReturnVarName = mlds_var_name("return_value", no), + ReturnVar = qual(ModuleName, module_qual, ReturnVarName), % Create a declaration for this variable. ( OrigRetTypes = [], - ReturnVarType = mlds__generic_type + ReturnVarType = mlds_generic_type ; OrigRetTypes = [CallRetType], ReturnVarType = CallRetType ; OrigRetTypes = [_, _ | _], - ReturnVarType = mlds__array_type(mlds__generic_type) + ReturnVarType = mlds_array_type(mlds_generic_type) ), - ReturnLval = mlds__var(ReturnVar, ReturnVarType), - ReturnEntityName = mlds__data(mlds__var(ReturnVarName)), + ReturnLval = var(ReturnVar, ReturnVarType), + ReturnEntityName = data(var(ReturnVarName)), ReturnDecFlags = ml_gen_local_var_decl_flags, GCTraceCode = no, % The Java back-end does its own garbage collection. - ReturnEntityDefn = mlds__data(ReturnVarType, no_initializer, GCTraceCode), - ReturnVarDefn = mlds__defn(ReturnEntityName, Context, ReturnDecFlags, + ReturnEntityDefn = mlds_data(ReturnVarType, no_initializer, GCTraceCode), + ReturnVarDefn = mlds_defn(ReturnEntityName, Context, ReturnDecFlags, ReturnEntityDefn), MethodDefns = [ReturnVarDefn], % Create the call to the original method. - CallArgLabel = mlds__qual(ModuleName, module_qual, MethodArgVariable), + CallArgLabel = qual(ModuleName, module_qual, MethodArgVariable), generate_call_method_args(OrigArgTypes, CallArgLabel, 0, [], CallArgs), - CallRval = mlds__const(mlds__code_addr_const(CodeAddr)), + CallRval = const(code_addr_const(CodeAddr)), % If the original method has a return type of void, then we obviously % cannot assign its return value to "return_value". Thus, in this @@ -863,41 +862,41 @@ generate_call_method(CodeAddr, MethodDefn) :- OrigRetTypes = [_ | _], CallRetLvals = [ReturnLval] ), - Call = mlds__call(OrigFuncSignature, CallRval, no, CallArgs, + Call = call(OrigFuncSignature, CallRval, no, CallArgs, CallRetLvals, ordinary_call), CallStatement = statement(Call, Context), % Create a return statement that returns the result of the call to the % original method, boxed as a java.lang.Object. ReturnRval = unop(box(ReturnVarType), lval(ReturnLval)), - Return = mlds__return([ReturnRval]), + Return = return([ReturnRval]), ReturnStatement = statement(Return, Context), Block = block(MethodDefns, [CallStatement, ReturnStatement]), Statements = statement(Block, Context), % Put it all together. - MethodParams = mlds__func_params(MethodArgs, MethodRets), + MethodParams = mlds_func_params(MethodArgs, MethodRets), MethodMaybeID = no, MethodAttribs = [], - MethodBody = mlds__function(MethodMaybeID, MethodParams, + MethodBody = mlds_function(MethodMaybeID, MethodParams, defined_here(Statements), MethodAttribs), MethodFlags = ml_gen_special_member_decl_flags, - MethodDefn = mlds__defn(MethodName, Context, MethodFlags, MethodBody). + MethodDefn = mlds_defn(MethodName, Context, MethodFlags, MethodBody). -:- pred generate_call_method_args(list(mlds_type)::in, mlds__var::in, int::in, +:- pred generate_call_method_args(list(mlds_type)::in, mlds_var::in, int::in, list(mlds_rval)::in, list(mlds_rval)::out) is det. generate_call_method_args([], _, _, Args, Args). generate_call_method_args([Type | Types], Variable, Counter, Args0, Args) :- - ArrayRval = lval(mlds__var(Variable, mlds__native_int_type)), + ArrayRval = lval(var(Variable, mlds_native_int_type)), IndexRval = const(int_const(Counter)), Rval = binop(array_index(elem_type_generic), ArrayRval, IndexRval), UnBoxedRval = unop(unbox(Type), Rval), Args1 = Args0 ++ [UnBoxedRval], generate_call_method_args(Types, Variable, Counter + 1, Args1, Args). -:- func mlds_module_name_to_string(mlds__mlds_module_name) = string. +:- func mlds_module_name_to_string(mlds_module_name) = string. mlds_module_name_to_string(MldsModuleName) = ModuleNameStr :- ModuleName = mlds_module_name_to_sym_name(MldsModuleName), @@ -912,22 +911,22 @@ symbol_name_to_string(qualified(Qualifier, SymName), SymNameStr0) SymNameStr1 = symbol_name_to_string(Qualifier, SymNameStr0), SymNameStr = SymNameStr1 ++ "__" ++ SymName. -:- func make_pred_name_string(mlds__pred_label, proc_id, - maybe(mlds__func_sequence_num)) = string. +:- func make_pred_name_string(mlds_pred_label, proc_id, + maybe(mlds_func_sequence_num)) = string. make_pred_name_string(PredLabel, ProcId, MaybeSeqNum) = NameStr :- PredLabelStr = pred_label_string(PredLabel), proc_id_to_int(ProcId, ModeNum), - NameStr0 = PredLabelStr ++ "_" ++ string__int_to_string(ModeNum), + NameStr0 = PredLabelStr ++ "_" ++ string.int_to_string(ModeNum), ( MaybeSeqNum = yes(SeqNum), - NameStr = NameStr0 ++ "_" ++ string__int_to_string(SeqNum) + NameStr = NameStr0 ++ "_" ++ string.int_to_string(SeqNum) ; MaybeSeqNum = no, NameStr = NameStr0 ). -:- func pred_label_string(mlds__pred_label) = string. +:- func pred_label_string(mlds_pred_label) = string. pred_label_string(pred(PredOrFunc, MaybeDefiningModule, Name, PredArity, _CodeModel, _NonOutputFunc)) = PredLabelStr :- @@ -941,7 +940,7 @@ pred_label_string(pred(PredOrFunc, MaybeDefiningModule, Name, PredArity, OrigArity = PredArity - 1 ), MangledName = name_mangle(Name), - PredLabelStr0 = MangledName ++ "_" ++ string__int_to_string(OrigArity) + PredLabelStr0 = MangledName ++ "_" ++ string.int_to_string(OrigArity) ++ "_" ++ Suffix, ( MaybeDefiningModule = yes(DefiningModule), @@ -965,7 +964,7 @@ pred_label_string(special_pred(PredName, MaybeTypeModule, TypeName, TypeArity)) PredLabelStr1 = PredLabelStr0 ), PredLabelStr = PredLabelStr1 ++ MangledTypeName ++ "_" ++ - string__int_to_string(TypeArity). + string.int_to_string(TypeArity). %-----------------------------------------------------------------------------% % @@ -973,7 +972,7 @@ pred_label_string(special_pred(PredName, MaybeTypeModule, TypeName, TypeArity)) % :- pred output_src_start(indent::in, mercury_module_name::in, - mlds__imports::in, list(foreign_decl_code)::in, mlds__defns::in, + mlds_imports::in, list(foreign_decl_code)::in, mlds_defns::in, io::di, io::uo) is det. output_src_start(Indent, MercuryModuleName, Imports, ForeignDecls, Defns, @@ -983,16 +982,16 @@ output_src_start(Indent, MercuryModuleName, Imports, ForeignDecls, Defns, JavaSafeModuleName = valid_module_name(ModuleSymName), output_auto_gen_comment(MercuryModuleName, !IO), indent_line(Indent, !IO), - io__write_string("/* :- module ", !IO), - prog_out__write_sym_name(MercuryModuleName, !IO), - io__write_string(". */\n\n", !IO), + io.write_string("/* :- module ", !IO), + prog_out.write_sym_name(MercuryModuleName, !IO), + io.write_string(". */\n\n", !IO), output_package_info(JavaSafeModuleName, !IO), output_imports(Imports, !IO), - io__write_list(ForeignDecls, "\n", output_java_decl(Indent), !IO), - io__write_string("public class ", !IO), + io.write_list(ForeignDecls, "\n", output_java_decl(Indent), !IO), + io.write_string("public class ", !IO), unqualify_name(JavaSafeModuleName, ClassName), - io__write_string(ClassName, !IO), - io__write_string(" {\n", !IO), + io.write_string(ClassName, !IO), + io.write_string(" {\n", !IO), maybe_write_main_driver(Indent + 1, JavaSafeModuleName, Defns, !IO). % Output a `package' directive at the top of the Java source file, @@ -1002,10 +1001,10 @@ output_src_start(Indent, MercuryModuleName, Imports, ForeignDecls, Defns, output_package_info(unqualified(_), !IO). output_package_info(qualified(Module, _), !IO) :- - io__write_string("package ", !IO), - mdbcomp__prim_data__sym_name_to_string(Module, ".", Package), - io__write_string(Package, !IO), - io__write_string(";\n", !IO). + io.write_string("package ", !IO), + sym_name_to_string(Module, ".", Package), + io.write_string(Package, !IO), + io.write_string(";\n", !IO). % Check if this module contains a `main' predicate and if it does insert % a `main' method in the resulting Java class that calls the @@ -1013,52 +1012,52 @@ output_package_info(qualified(Module, _), !IO) :- % variable `args' in the class `mercury.runtime.JavaInternal'. % :- pred maybe_write_main_driver(indent::in, java_module_name::in, - mlds__defns::in, io::di, io::uo) is det. + mlds_defns::in, io::di, io::uo) is det. maybe_write_main_driver(Indent, JavaSafeModuleName, Defns, !IO) :- ( defns_contain_main(Defns) -> indent_line(Indent, !IO), - io__write_string("public static void main", !IO), - io__write_string("(java.lang.String[] args)\n", !IO), + io.write_string("public static void main", !IO), + io.write_string("(java.lang.String[] args)\n", !IO), indent_line(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), % Save the progname and command line arguments in the class variables % of `mercury.runtime.JavaInternal', as well as setting the default % exit status. unqualify_name(JavaSafeModuleName, ClassName), indent_line(Indent + 1, !IO), - io__write_string("mercury.runtime.JavaInternal.progname = """, !IO), - io__write_string(ClassName, !IO), - io__write_string(""";\n", !IO), + io.write_string("mercury.runtime.JavaInternal.progname = """, !IO), + io.write_string(ClassName, !IO), + io.write_string(""";\n", !IO), indent_line(Indent + 1, !IO), - io__write_string("mercury.runtime.JavaInternal.args = args;\n", !IO), + io.write_string("mercury.runtime.JavaInternal.args = args;\n", !IO), indent_line(Indent + 1, !IO), - io__write_string("mercury.runtime.JavaInternal.exit_status = ", !IO), - io__write_string("0;\n", !IO), + io.write_string("mercury.runtime.JavaInternal.exit_status = ", !IO), + io.write_string("0;\n", !IO), indent_line(Indent + 1, !IO), - prog_out__write_sym_name(JavaSafeModuleName, !IO), - io__write_string(".main_2_p_0();\n", !IO), + prog_out.write_sym_name(JavaSafeModuleName, !IO), + io.write_string(".main_2_p_0();\n", !IO), indent_line(Indent + 1, !IO), - io__write_string("java.lang.System.exit", !IO), - io__write_string("(mercury.runtime.JavaInternal.exit_status);", !IO), - io__nl(!IO), + io.write_string("java.lang.System.exit", !IO), + io.write_string("(mercury.runtime.JavaInternal.exit_status);", !IO), + io.nl(!IO), indent_line(Indent, !IO), - io__write_string("}\n", !IO) + io.write_string("}\n", !IO) ; true ), - io__nl(!IO). + io.nl(!IO). :- pred output_src_end(indent::in, mercury_module_name::in, io::di, io::uo) is det. output_src_end(Indent, ModuleName, !IO) :- - io__write_string("}\n", !IO), + io.write_string("}\n", !IO), indent_line(Indent, !IO), - io__write_string("// :- end_module ", !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string(".\n", !IO). + io.write_string("// :- end_module ", !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string(".\n", !IO). % Output a Java comment saying that the file was automatically % generated and give details such as the compiler version. @@ -1067,17 +1066,17 @@ output_src_end(Indent, ModuleName, !IO) :- is det. output_auto_gen_comment(ModuleName, !IO) :- - library__version(Version), + library.version(Version), module_name_to_file_name(ModuleName, ".m", no, SourceFileName, !IO), - io__write_string("//\n//\n// Automatically generated from ", !IO), - io__write_string(SourceFileName, !IO), - io__write_string(" by the Mercury Compiler,\n", !IO), - io__write_string("// version ", !IO), - io__write_string(Version, !IO), - io__nl(!IO), - io__write_string("//\n", !IO), - io__write_string("//\n", !IO), - io__nl(!IO). + io.write_string("//\n//\n// Automatically generated from ", !IO), + io.write_string(SourceFileName, !IO), + io.write_string(" by the Mercury Compiler,\n", !IO), + io.write_string("// version ", !IO), + io.write_string(Version, !IO), + io.nl(!IO), + io.write_string("//\n", !IO), + io.write_string("//\n", !IO), + io.nl(!IO). %-----------------------------------------------------------------------------% % @@ -1089,33 +1088,33 @@ output_auto_gen_comment(ModuleName, !IO) :- % is not available for a constructor in the mlds. :- type ctor_data ---> none % not a constructor - ; cname(mlds__entity_name). % constructor class name + ; cname(mlds_entity_name). % constructor class name :- pred output_defns(indent::in, module_info::in, mlds_module_name::in, - ctor_data::in, mlds__defns::in, io::di, io::uo) is det. + ctor_data::in, mlds_defns::in, io::di, io::uo) is det. output_defns(Indent, ModuleInfo, ModuleName, CtorData, Defns, !IO) :- OutputDefn = output_defn(Indent, ModuleInfo, ModuleName, CtorData), - list__foldl(OutputDefn, Defns, !IO). + list.foldl(OutputDefn, Defns, !IO). :- pred output_defn(indent::in, module_info::in, mlds_module_name::in, - ctor_data::in, mlds__defn::in, io::di, io::uo) is det. + ctor_data::in, mlds_defn::in, io::di, io::uo) is det. output_defn(Indent, ModuleInfo, ModuleName, CtorData, Defn, !IO) :- - Defn = mlds__defn(Name, Context, Flags, DefnBody), + Defn = mlds_defn(Name, Context, Flags, DefnBody), indent_line(Context, Indent, !IO), - ( DefnBody = mlds__function(_, _, external, _) -> + ( DefnBody = mlds_function(_, _, external, _) -> % This is just a function declaration, with no body. % Java doesn't support separate declarations and definitions, % so just output the declaration as a comment. % (Note that the actual definition of an external procedure % must be given in `pragma java_code' in the same module.) - io__write_string("/* external:\n", !IO), + io.write_string("/* external:\n", !IO), output_decl_flags(Flags, Name, !IO), output_defn_body(Indent, ModuleInfo, qual(ModuleName, module_qual, Name), CtorData, Context, DefnBody, !IO), - io__write_string("*/\n", !IO) + io.write_string("*/\n", !IO) ; output_decl_flags(Flags, Name, !IO), output_defn_body(Indent, ModuleInfo, @@ -1124,19 +1123,19 @@ output_defn(Indent, ModuleInfo, ModuleName, CtorData, Defn, !IO) :- ). :- pred output_defn_body(indent::in, module_info::in, - mlds__qualified_entity_name::in, ctor_data::in, mlds__context::in, - mlds__entity_defn::in, io::di, io::uo) is det. + mlds_qualified_entity_name::in, ctor_data::in, mlds_context::in, + mlds_entity_defn::in, io::di, io::uo) is det. -output_defn_body(_, ModuleInfo, Name, _, _, mlds__data(Type, Initializer, _), +output_defn_body(_, ModuleInfo, Name, _, _, mlds_data(Type, Initializer, _), !IO) :- output_data_defn(ModuleInfo, Name, Type, Initializer, !IO). output_defn_body(Indent, ModuleInfo, Name, CtorData, Context, - mlds__function(MaybePredProcId, Signature, MaybeBody, + mlds_function(MaybePredProcId, Signature, MaybeBody, _Attributes), !IO) :- output_maybe(MaybePredProcId, output_pred_proc_id, !IO), output_func(Indent, ModuleInfo, Name, CtorData, Context, Signature, MaybeBody, !IO). -output_defn_body(Indent, ModuleInfo, Name, _, Context, mlds__class(ClassDefn), +output_defn_body(Indent, ModuleInfo, Name, _, Context, mlds_class(ClassDefn), !IO) :- output_class(Indent, ModuleInfo, Name, Context, ClassDefn, !IO). @@ -1146,7 +1145,7 @@ output_defn_body(Indent, ModuleInfo, Name, _, Context, mlds__class(ClassDefn), % :- pred output_class(indent::in, module_info::in, - mlds__qualified_entity_name::in, mlds__context::in, mlds__class_defn::in, + mlds_qualified_entity_name::in, mlds_context::in, mlds_class_defn::in, io::di, io::uo) is det. output_class(Indent, ModuleInfo, Name, _Context, ClassDefn, !IO) :- @@ -1156,46 +1155,46 @@ output_class(Indent, ModuleInfo, Name, _Context, ClassDefn, !IO) :- ; unexpected(this_file, "output_class") ), - ClassDefn = class_defn(Kind, _Imports, BaseClasses, Implements, + ClassDefn = mlds_class_defn(Kind, _Imports, BaseClasses, Implements, Ctors, AllMembers), - ( Kind = mlds__interface -> - io__write_string("interface ", !IO) + ( Kind = mlds_interface -> + io.write_string("interface ", !IO) ; - io__write_string("class ", !IO) + io.write_string("class ", !IO) ), output_class_name_and_arity(UnqualName, !IO), - io__nl(!IO), + io.nl(!IO), output_extends_list(Indent + 1, BaseClasses, !IO), output_implements_list(Indent + 1, Implements, !IO), indent_line(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), output_class_body(Indent + 1, ModuleInfo, Kind, Name, AllMembers, ModuleName, !IO), - io__nl(!IO), + io.nl(!IO), output_defns(Indent + 1, ModuleInfo, ModuleName, cname(UnqualName), Ctors, !IO), indent_line(Indent, !IO), - io__write_string("}\n\n", !IO). + io.write_string("}\n\n", !IO). % Output superclass that this class extends. Java does not support % multiple inheritance, so more than one superclass is an error. % -:- pred output_extends_list(indent::in, list(mlds__class_id)::in, +:- pred output_extends_list(indent::in, list(mlds_class_id)::in, io::di, io::uo) is det. output_extends_list(_, [], !IO). output_extends_list(Indent, [SuperClass], !IO) :- indent_line(Indent, !IO), - io__write_string("extends ", !IO), + io.write_string("extends ", !IO), output_type(SuperClass, !IO), - io__nl(!IO). + io.nl(!IO). output_extends_list(_, [_, _ | _], _, _) :- unexpected(this_file, "output_extends_list: multiple inheritance not supported in Java"). % Output list of interfaces that this class implements. % -:- pred output_implements_list(indent::in, list(mlds__interface_id)::in, +:- pred output_implements_list(indent::in, list(mlds_interface_id)::in, io::di, io::uo) is det. output_implements_list(Indent, InterfaceList, !IO) :- @@ -1204,20 +1203,21 @@ output_implements_list(Indent, InterfaceList, !IO) :- ; InterfaceList = [_ | _], indent_line(Indent, !IO), - io__write_string("implements ", !IO), - io__write_list(InterfaceList, ",", output_interface, !IO), - io__nl(!IO) + io.write_string("implements ", !IO), + io.write_list(InterfaceList, ",", output_interface, !IO), + io.nl(!IO) ). -:- pred output_interface(mlds__interface_id::in, io::di, io::uo) is det. +:- pred output_interface(mlds_interface_id::in, io::di, io::uo) is det. output_interface(Interface, !IO) :- ( - Interface = class_type(qual(ModuleQualifier, QualKind, Name), Arity, _) + Interface = mlds_class_type(qual(ModuleQualifier, QualKind, Name), + Arity, _) -> SymName = mlds_module_name_to_sym_name(ModuleQualifier), mangle_mlds_sym_name_for_java(SymName, QualKind, ".", ModuleName), - io__format("%s.%s", [s(ModuleName), s(Name)], !IO), + io.format("%s.%s", [s(ModuleName), s(Name)], !IO), % % Check if the interface is one of the ones in the runtime % system. If it is we don't need to output the arity. @@ -1225,38 +1225,38 @@ output_interface(Interface, !IO) :- ( interface_is_special(Name) -> true ; - io__format("%d", [i(Arity)], !IO) + io.format("%d", [i(Arity)], !IO) ) ; unexpected(this_file, "output_interface: interface was not a class.") ). -:- pred output_class_body(indent::in, module_info::in, mlds__class_kind::in, - mlds__qualified_entity_name::in, mlds__defns::in, +:- pred output_class_body(indent::in, module_info::in, mlds_class_kind::in, + mlds_qualified_entity_name::in, mlds_defns::in, mlds_module_name::in, io::di, io::uo) is det. -output_class_body(Indent, ModuleInfo, mlds__class, _, AllMembers, ModuleName, +output_class_body(Indent, ModuleInfo, mlds_class, _, AllMembers, ModuleName, !IO) :- CtorData = none, % Not a constructor. output_defns(Indent, ModuleInfo, ModuleName, CtorData, AllMembers, !IO). -output_class_body(_Indent, _, mlds__package, _Name, _AllMembers, _, _, _) :- +output_class_body(_Indent, _, mlds_package, _Name, _AllMembers, _, _, _) :- unexpected(this_file, "cannot use package as a type."). -output_class_body(Indent, ModuleInfo, mlds__interface, _, AllMembers, +output_class_body(Indent, ModuleInfo, mlds_interface, _, AllMembers, ModuleName, !IO) :- CtorData = none, % Not a constructor. output_defns(Indent, ModuleInfo, ModuleName, CtorData, AllMembers, !IO). -output_class_body(_Indent, _, mlds__struct, _, _AllMembers, _, _, _) :- +output_class_body(_Indent, _, mlds_struct, _, _AllMembers, _, _, _) :- unexpected(this_file, "output_class_body: structs not supported in Java."). -output_class_body(Indent, ModuleInfo, mlds__enum, Name, AllMembers, _, !IO) :- - list__filter(defn_is_const, AllMembers, EnumConsts), +output_class_body(Indent, ModuleInfo, mlds_enum, Name, AllMembers, _, !IO) :- + list.filter(defn_is_const, AllMembers, EnumConsts), Name = qual(ModuleName, _QualKind, UnqualName), output_enum_constants(Indent + 1, ModuleInfo, ModuleName, EnumConsts, !IO), indent_line(Indent + 1, !IO), - io__write_string("public int value;\n\n", !IO), + io.write_string("public int value;\n\n", !IO), output_enum_ctor(Indent + 1, UnqualName, !IO). %-----------------------------------------------------------------------------% @@ -1268,53 +1268,53 @@ output_class_body(Indent, ModuleInfo, mlds__enum, Name, AllMembers, _, !IO) :- % Here we treat them as objects (instantiations of the classes) rather than % just as integers. -:- pred defn_is_const(mlds__defn::in) is semidet. +:- pred defn_is_const(mlds_defn::in) is semidet. defn_is_const(Defn) :- - Defn = mlds__defn(_Name, _Context, Flags, _DefnBody), + Defn = mlds_defn(_Name, _Context, Flags, _DefnBody), constness(Flags) = const. % Output a (Java) constructor for the class representing the enumeration. % -:- pred output_enum_ctor(indent::in, mlds__entity_name::in, io::di, io::uo) +:- pred output_enum_ctor(indent::in, mlds_entity_name::in, io::di, io::uo) is det. output_enum_ctor(Indent, UnqualName, !IO) :- indent_line(Indent, !IO), - io__write_string("public ", !IO), + io.write_string("public ", !IO), output_name(UnqualName, !IO), - io__write_string("(int val) {\n", !IO), + io.write_string("(int val) {\n", !IO), indent_line(Indent + 1, !IO), % The use of `value' is hardcoded into ml_type_gen.m. Any changes there % should probably be reflected here. - io__write_string("this.value = val;\n", !IO), + io.write_string("this.value = val;\n", !IO), indent_line(Indent + 1, !IO), - io__write_string("return;\n", !IO), + io.write_string("return;\n", !IO), indent_line(Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). :- pred output_enum_constants(indent::in, module_info::in, - mlds_module_name::in, mlds__defns::in, io::di, io::uo) is det. + mlds_module_name::in, mlds_defns::in, io::di, io::uo) is det. output_enum_constants(Indent, ModuleInfo, EnumModuleName, EnumConsts, !IO) :- - io__write_list(EnumConsts, "\n", + io.write_list(EnumConsts, "\n", output_enum_constant(Indent, ModuleInfo, EnumModuleName), !IO), - io__nl(!IO). + io.nl(!IO). :- pred output_enum_constant(indent::in, module_info::in, - mlds_module_name::in, mlds__defn::in, io::di, io::uo) is det. + mlds_module_name::in, mlds_defn::in, io::di, io::uo) is det. output_enum_constant(Indent, ModuleInfo, EnumModuleName, Defn, !IO) :- - Defn = mlds__defn(Name, _Context, _Flags, DefnBody), + Defn = mlds_defn(Name, _Context, _Flags, DefnBody), ( - DefnBody = data(Type, Initializer, _GC_TraceCode) + DefnBody = mlds_data(Type, Initializer, _GC_TraceCode) -> indent_line(Indent, !IO), - io__write_string("public static final int ", !IO), + io.write_string("public static final int ", !IO), output_name(Name, !IO), output_initializer(ModuleInfo, EnumModuleName, Type, Initializer, !IO), - io__write_char(';', !IO) + io.write_char(';', !IO) ; unexpected(this_file, "output_enum_constant: definition body was not data.") @@ -1325,21 +1325,21 @@ output_enum_constant(Indent, ModuleInfo, EnumModuleName, Defn, !IO) :- % Code to output data declarations/definitions % -:- pred output_data_decl(mlds__qualified_entity_name::in, mlds_type::in, +:- pred output_data_decl(mlds_qualified_entity_name::in, mlds_type::in, io::di, io::uo) is det. output_data_decl(qual(_, _, Name), Type, !IO) :- output_type(Type, !IO), - io__write_char(' ', !IO), + io.write_char(' ', !IO), output_name(Name, !IO). -:- pred output_data_defn(module_info::in, mlds__qualified_entity_name::in, - mlds_type::in, mlds__initializer::in, io::di, io::uo) is det. +:- pred output_data_defn(module_info::in, mlds_qualified_entity_name::in, + mlds_type::in, mlds_initializer::in, io::di, io::uo) is det. output_data_defn(ModuleInfo, Name, Type, Initializer, !IO) :- output_data_decl(Name, Type, !IO), output_initializer(ModuleInfo, Name ^ mod_name, Type, Initializer, !IO), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). % We need to provide initializers for local variables to avoid problems % with Java's rules for definite assignment. This mirrors the default @@ -1365,24 +1365,24 @@ get_java_type_initializer(mercury_type(_, type_cat_enum, _)) = "null". get_java_type_initializer(mercury_type(_, type_cat_dummy, _)) = "null". get_java_type_initializer(mercury_type(_, type_cat_variable, _)) = "null". get_java_type_initializer(mercury_type(_, type_cat_user_ctor, _)) = "null". -get_java_type_initializer(mlds__mercury_array_type(_)) = "null". -get_java_type_initializer(mlds__cont_type(_)) = "null". -get_java_type_initializer(mlds__commit_type) = "null". -get_java_type_initializer(mlds__native_bool_type) = "false". -get_java_type_initializer(mlds__native_int_type) = "0". -get_java_type_initializer(mlds__native_float_type) = "0". -get_java_type_initializer(mlds__native_char_type) = "0". -get_java_type_initializer(mlds__foreign_type(_)) = "null". -get_java_type_initializer(mlds__class_type(_, _, _)) = "null". -get_java_type_initializer(mlds__array_type(_)) = "null". -get_java_type_initializer(mlds__ptr_type(_)) = "null". -get_java_type_initializer(mlds__func_type(_)) = "null". -get_java_type_initializer(mlds__generic_type) = "null". -get_java_type_initializer(mlds__generic_env_ptr_type) = "null". -get_java_type_initializer(mlds__type_info_type) = "null". -get_java_type_initializer(mlds__pseudo_type_info_type) = "null". -get_java_type_initializer(mlds__rtti_type(_)) = "null". -get_java_type_initializer(mlds__unknown_type) = _ :- +get_java_type_initializer(mlds_mercury_array_type(_)) = "null". +get_java_type_initializer(mlds_cont_type(_)) = "null". +get_java_type_initializer(mlds_commit_type) = "null". +get_java_type_initializer(mlds_native_bool_type) = "false". +get_java_type_initializer(mlds_native_int_type) = "0". +get_java_type_initializer(mlds_native_float_type) = "0". +get_java_type_initializer(mlds_native_char_type) = "0". +get_java_type_initializer(mlds_foreign_type(_)) = "null". +get_java_type_initializer(mlds_class_type(_, _, _)) = "null". +get_java_type_initializer(mlds_array_type(_)) = "null". +get_java_type_initializer(mlds_ptr_type(_)) = "null". +get_java_type_initializer(mlds_func_type(_)) = "null". +get_java_type_initializer(mlds_generic_type) = "null". +get_java_type_initializer(mlds_generic_env_ptr_type) = "null". +get_java_type_initializer(mlds_type_info_type) = "null". +get_java_type_initializer(mlds_pseudo_type_info_type) = "null". +get_java_type_initializer(mlds_rtti_type(_)) = "null". +get_java_type_initializer(mlds_unknown_type) = _ :- unexpected(this_file, "get_type_initializer: variable has unknown_type"). :- pred output_maybe(maybe(T)::in, @@ -1397,10 +1397,10 @@ output_maybe(MaybeValue, OutputAction, !IO) :- ). :- pred output_initializer(module_info::in, mlds_module_name::in, - mlds_type::in, mlds__initializer::in, io::di, io::uo) is det. + mlds_type::in, mlds_initializer::in, io::di, io::uo) is det. output_initializer(ModuleInfo, ModuleName, Type, Initializer, !IO) :- - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), ( needs_initialization(Initializer) = yes -> output_initializer_body(ModuleInfo, Initializer, yes(Type), ModuleName, !IO) @@ -1409,10 +1409,10 @@ output_initializer(ModuleInfo, ModuleName, Type, Initializer, !IO) :- % default java values -- note: this is strictly only necessary for % local variables, but it's not going to hurt anything else. % - io__write_string(get_java_type_initializer(Type), !IO) + io.write_string(get_java_type_initializer(Type), !IO) ). -:- func needs_initialization(mlds__initializer) = bool. +:- func needs_initialization(mlds_initializer) = bool. needs_initialization(no_initializer) = no. needs_initialization(init_obj(_)) = yes. @@ -1420,7 +1420,7 @@ needs_initialization(init_struct(_Type, [])) = no. needs_initialization(init_struct(_Type, [_ | _])) = yes. needs_initialization(init_array(_)) = yes. -:- pred output_initializer_body(module_info::in, mlds__initializer::in, +:- pred output_initializer_body(module_info::in, mlds_initializer::in, maybe(mlds_type)::in, mlds_module_name::in, io::di, io::uo) is det. output_initializer_body(_ModuleInfo, no_initializer, _, _, _, _) :- @@ -1433,20 +1433,20 @@ output_initializer_body(ModuleInfo, init_obj(Rval), MaybeType, ModuleName, rval_is_int_const(Rval) -> % If it is a enumeration object create new object. - io__write_string("new ", !IO), + io.write_string("new ", !IO), output_type(Type, !IO), - io__write_char('(', !IO), + io.write_char('(', !IO), output_rval_maybe_with_enum(ModuleInfo, Rval, ModuleName, !IO), - io__write_char(')', !IO) + io.write_char(')', !IO) ; MaybeType = yes(Type) -> % If it is an non-enumeration object, insert appropriate cast. % XXX The logic of this is a bit wrong. Fixing it would eliminate % some of the unecessary casting that happens. - io__write_string("(", !IO), + io.write_string("(", !IO), output_type(Type, !IO), - io__write_string(") ", !IO), + io.write_string(") ", !IO), output_rval(ModuleInfo, Rval, ModuleName, !IO) ; output_rval_maybe_with_enum(ModuleInfo, Rval, ModuleName, !IO) @@ -1454,33 +1454,33 @@ output_initializer_body(ModuleInfo, init_obj(Rval), MaybeType, ModuleName, output_initializer_body(ModuleInfo, init_struct(StructType, FieldInits), _MaybeType, ModuleName, !IO) :- - io__write_string("new ", !IO), + io.write_string("new ", !IO), output_type(StructType, !IO), IsArray = type_is_array(StructType), - io__write_string(if IsArray = yes then " {" else "(", !IO), - io__write_list(FieldInits, ",\n\t\t", + io.write_string(if IsArray = yes then " {" else "(", !IO), + io.write_list(FieldInits, ",\n\t\t", (pred(FieldInit::in, !.IO::di, !:IO::uo) is det :- output_initializer_body(ModuleInfo, FieldInit, no, ModuleName, !IO) ), !IO), - io__write_char(if IsArray = yes then '}' else ')', !IO). + io.write_char(if IsArray = yes then '}' else ')', !IO). output_initializer_body(ModuleInfo, init_array(ElementInits), MaybeType, ModuleName, !IO) :- - io__write_string("new ", !IO), + io.write_string("new ", !IO), ( MaybeType = yes(Type), output_type(Type, !IO) ; MaybeType = no, % XXX we need to know the type here - io__write_string("/* XXX init_array */ Object[]", !IO) + io.write_string("/* XXX init_array */ Object[]", !IO) ), - io__write_string(" {\n\t\t", !IO), - io__write_list(ElementInits, ",\n\t\t", + io.write_string(" {\n\t\t", !IO), + io.write_list(ElementInits, ",\n\t\t", (pred(ElementInit::in, !.IO::di, !:IO::uo) is det :- output_initializer_body(ModuleInfo, ElementInit, no, ModuleName, !IO)), !IO), - io__write_string("}", !IO). + io.write_string("}", !IO). %-----------------------------------------------------------------------------% % @@ -1490,91 +1490,92 @@ output_initializer_body(ModuleInfo, init_array(ElementInits), MaybeType, :- pred output_pred_proc_id(pred_proc_id::in, io::di, io::uo) is det. output_pred_proc_id(proc(PredId, ProcId), !IO) :- - globals__io_lookup_bool_option(auto_comments, AddComments, !IO), + globals.io_lookup_bool_option(auto_comments, AddComments, !IO), ( AddComments = yes, - io__write_string("// pred_id: ", !IO), + io.write_string("// pred_id: ", !IO), pred_id_to_int(PredId, PredIdNum), - io__write_int(PredIdNum, !IO), - io__write_string(", proc_id: ", !IO), + io.write_int(PredIdNum, !IO), + io.write_string(", proc_id: ", !IO), proc_id_to_int(ProcId, ProcIdNum), - io__write_int(ProcIdNum, !IO), - io__nl(!IO) + io.write_int(ProcIdNum, !IO), + io.nl(!IO) ; AddComments = no ). -:- pred output_func(indent::in, module_info::in, qualified_entity_name::in, - ctor_data::in, mlds__context::in, func_params::in, function_body::in, - io::di, io::uo) is det. +:- pred output_func(indent::in, module_info::in, + mlds_qualified_entity_name::in, ctor_data::in, mlds_context::in, + mlds_func_params::in, mlds_function_body::in, io::di, io::uo) is det. output_func(Indent, ModuleInfo, Name, CtorData, Context, Signature, MaybeBody, !IO) :- ( MaybeBody = defined_here(Body), output_func_decl(Indent, Name, CtorData, Context, Signature, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), indent_line(Context, Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), FuncInfo = func_info(Name, Signature), output_statement(Indent + 1, ModuleInfo, FuncInfo, Body, _ExitMethods, !IO), indent_line(Context, Indent, !IO), - io__write_string("}\n", !IO) % end the function + io.write_string("}\n", !IO) % end the function ; MaybeBody = external ). -:- pred output_func_decl(indent::in, qualified_entity_name::in, ctor_data::in, - mlds__context::in, func_params::in, io::di, io::uo) is det. +:- pred output_func_decl(indent::in, mlds_qualified_entity_name::in, + ctor_data::in, mlds_context::in, mlds_func_params::in, io::di, io::uo) + is det. output_func_decl(Indent, QualifiedName, cname(CtorName), Context, Signature, !IO) :- - Signature = mlds__func_params(Parameters, _RetTypes), + Signature = mlds_func_params(Parameters, _RetTypes), output_name(CtorName, !IO), output_params(Indent, QualifiedName ^ mod_name, Context, Parameters, !IO). output_func_decl(Indent, QualifiedName, none, Context, Signature, !IO) :- - Signature = mlds__func_params(Parameters, RetTypes), + Signature = mlds_func_params(Parameters, RetTypes), ( RetTypes = [], - io__write_string("void", !IO) + io.write_string("void", !IO) ; RetTypes = [RetType], output_type(RetType, !IO) ; RetTypes = [_, _ | _], % For multiple outputs, we return an array of objects. - io__write_string("java.lang.Object []", !IO) + io.write_string("java.lang.Object []", !IO) ), - io__write_char(' ', !IO), + io.write_char(' ', !IO), QualifiedName = qual(ModuleName, _QualKind, Name), output_name(Name, !IO), output_params(Indent, ModuleName, Context, Parameters, !IO). -:- pred output_params(indent::in, mlds_module_name::in, mlds__context::in, - mlds__arguments::in, io::di, io::uo) is det. +:- pred output_params(indent::in, mlds_module_name::in, mlds_context::in, + mlds_arguments::in, io::di, io::uo) is det. output_params(Indent, ModuleName, Context, Parameters, !IO) :- - io__write_char('(', !IO), + io.write_char('(', !IO), ( Parameters = [] ; Parameters = [_ | _], - io__nl(!IO), - io__write_list(Parameters, ",\n", + io.nl(!IO), + io.write_list(Parameters, ",\n", output_param(Indent + 1, ModuleName, Context), !IO) ), - io__write_char(')', !IO). + io.write_char(')', !IO). -:- pred output_param(indent::in, mlds_module_name::in, mlds__context::in, - mlds__argument::in, io::di, io::uo) is det. +:- pred output_param(indent::in, mlds_module_name::in, mlds_context::in, + mlds_argument::in, io::di, io::uo) is det. output_param(Indent, _ModuleName, Context, Arg, !IO) :- - Arg = mlds__argument(Name, Type, _GC_TraceCode), + Arg = mlds_argument(Name, Type, _GC_TraceCode), indent_line(Context, Indent, !IO), output_type(Type, !IO), - io__write_char(' ', !IO), + io.write_char(' ', !IO), output_name(Name, !IO). %-----------------------------------------------------------------------------% @@ -1583,7 +1584,7 @@ output_param(Indent, _ModuleName, Context, Arg, !IO) :- % XXX Much of the code in this section will not work when we start enforcing % names properly. -:- pred output_maybe_qualified_name(mlds__qualified_entity_name::in, +:- pred output_maybe_qualified_name(mlds_qualified_entity_name::in, mlds_module_name::in, io::di, io::uo) is det. output_maybe_qualified_name(QualifiedName, CurrentModuleName, !IO) :- @@ -1597,20 +1598,20 @@ output_maybe_qualified_name(QualifiedName, CurrentModuleName, !IO) :- output_fully_qualified(QualifiedName, output_name, ".", !IO) ). -:- pred output_fully_qualified_name(mlds__qualified_entity_name::in, +:- pred output_fully_qualified_name(mlds_qualified_entity_name::in, io::di, io::uo) is det. output_fully_qualified_name(QualifiedName, !IO) :- output_fully_qualified(QualifiedName, output_name, ".", !IO). -:- pred output_fully_qualified_proc_label(mlds__qualified_proc_label::in, +:- pred output_fully_qualified_proc_label(mlds_qualified_proc_label::in, string::in, io::di, io::uo) is det. output_fully_qualified_proc_label(QualifiedName, Qualifier, !IO) :- output_fully_qualified(QualifiedName, mlds_output_proc_label, Qualifier, !IO). -:- pred output_fully_qualified(mlds__fully_qualified_name(T)::in, +:- pred output_fully_qualified(mlds_fully_qualified_name(T)::in, pred(T, io, io)::pred(in, di, uo) is det, string::in, io::di, io::uo) is det. @@ -1619,21 +1620,21 @@ output_fully_qualified(qual(ModuleName, QualKind, Name), OutputFunc, SymName = mlds_module_name_to_sym_name(ModuleName), mangle_mlds_sym_name_for_java(SymName, QualKind, Qualifier, MangledModuleName), - io__write_string(MangledModuleName, !IO), - io__write_string(Qualifier, !IO), + io.write_string(MangledModuleName, !IO), + io.write_string(Qualifier, !IO), OutputFunc(Name, !IO). :- pred output_module_name(mercury_module_name::in, io::di, io::uo) is det. output_module_name(ModuleName, !IO) :- - io__write_string(sym_name_mangle(ModuleName), !IO). + io.write_string(sym_name_mangle(ModuleName), !IO). -:- pred output_class_name_and_arity(mlds__entity_name::in, io::di, io::uo) +:- pred output_class_name_and_arity(mlds_entity_name::in, io::di, io::uo) is det. output_class_name_and_arity(type(Name, Arity), !IO) :- output_class_name(Name, !IO), - io__format("_%d", [i(Arity)], !IO). + io.format("_%d", [i(Arity)], !IO). output_class_name_and_arity(data(_), !IO) :- unexpected(this_file, "output_class_name_and_arity"). output_class_name_and_arity(function(_, _, _, _), !IO) :- @@ -1641,15 +1642,15 @@ output_class_name_and_arity(function(_, _, _, _), !IO) :- output_class_name_and_arity(export(_), !IO) :- unexpected(this_file, "output_class_name_and_arity"). -:- pred output_class_name(mlds__class_name::in, io::di, io::uo) is det. +:- pred output_class_name(mlds_class_name::in, io::di, io::uo) is det. output_class_name(Name, !IO) :- MangledName = name_mangle(Name), % By convention, class names should start with a capital letter. UppercaseMangledName = flip_initial_case(MangledName), - io__write_string(UppercaseMangledName, !IO). + io.write_string(UppercaseMangledName, !IO). -:- pred output_name(mlds__entity_name::in, io::di, io::uo) is det. +:- pred output_name(mlds_entity_name::in, io::di, io::uo) is det. output_name(type(Name, Arity), !IO) :- output_class_name_and_arity(type(Name, Arity), !IO). @@ -1658,17 +1659,17 @@ output_name(data(DataName), !IO) :- output_name(function(PredLabel, ProcId, MaybeSeqNum, _PredId), !IO) :- output_pred_label(PredLabel, !IO), proc_id_to_int(ProcId, ModeNum), - io__format("_%d", [i(ModeNum)], !IO), + io.format("_%d", [i(ModeNum)], !IO), ( MaybeSeqNum = yes(SeqNum), - io__format("_%d", [i(SeqNum)], !IO) + io.format("_%d", [i(SeqNum)], !IO) ; MaybeSeqNum = no ). output_name(export(Name), !IO) :- - io__write_string(Name, !IO). + io.write_string(Name, !IO). -:- pred output_pred_label(mlds__pred_label::in, io::di, io::uo) is det. +:- pred output_pred_label(mlds_pred_label::in, io::di, io::uo) is det. output_pred_label(pred(PredOrFunc, MaybeDefiningModule, Name, PredArity, _, _), !IO) :- @@ -1682,10 +1683,10 @@ output_pred_label(pred(PredOrFunc, MaybeDefiningModule, Name, OrigArity = PredArity - 1 ), MangledName = name_mangle(Name), - io__format("%s_%d_%s", [s(MangledName), i(OrigArity), s(Suffix)], !IO), + io.format("%s_%d_%s", [s(MangledName), i(OrigArity), s(Suffix)], !IO), ( MaybeDefiningModule = yes(DefiningModule), - io__write_string("_in__", !IO), + io.write_string("_in__", !IO), output_module_name(DefiningModule, !IO) ; MaybeDefiningModule = no @@ -1695,27 +1696,27 @@ output_pred_label(special_pred(PredName, MaybeTypeModule, TypeName, TypeArity), !IO) :- MangledPredName = name_mangle(PredName), MangledTypeName = name_mangle(TypeName), - io__write_string(MangledPredName, !IO), - io__write_string("__", !IO), + io.write_string(MangledPredName, !IO), + io.write_string("__", !IO), ( MaybeTypeModule = yes(TypeModule), output_module_name(TypeModule, !IO), - io__write_string("__", !IO) + io.write_string("__", !IO) ; MaybeTypeModule = no ), - io__format("%s_%d", [s(MangledTypeName), i(TypeArity)], !IO). + io.format("%s_%d", [s(MangledTypeName), i(TypeArity)], !IO). -:- pred output_data_name(mlds__data_name::in, io::di, io::uo) is det. +:- pred output_data_name(mlds_data_name::in, io::di, io::uo) is det. output_data_name(var(VarName), !IO) :- output_mlds_var_name(VarName, !IO). output_data_name(common(Num), !IO) :- - io__write_string("common_", !IO), - io__write_int(Num, !IO). + io.write_string("common_", !IO), + io.write_int(Num, !IO). output_data_name(rtti(RttiId), !IO) :- - rtti__id_to_c_identifier(RttiId, RttiAddrName), - io__write_string(RttiAddrName, !IO). + rtti.id_to_c_identifier(RttiId, RttiAddrName), + io.write_string(RttiAddrName, !IO). output_data_name(module_layout, !IO) :- unexpected(this_file, "NYI: module_layout"). output_data_name(proc_layout(_ProcLabel), !IO) :- @@ -1723,15 +1724,15 @@ output_data_name(proc_layout(_ProcLabel), !IO) :- output_data_name(internal_layout(_ProcLabel, _FuncSeqNum), !IO) :- unexpected(this_file, "NYI: internal_layout"). output_data_name(tabling_pointer(ProcLabel), !IO) :- - io__write_string("table_for_", !IO), + io.write_string("table_for_", !IO), mlds_output_proc_label(ProcLabel, !IO). -:- pred output_mlds_var_name(mlds__var_name::in, io::di, io::uo) is det. +:- pred output_mlds_var_name(mlds_var_name::in, io::di, io::uo) is det. -output_mlds_var_name(var_name(Name, no), !IO) :- +output_mlds_var_name(mlds_var_name(Name, no), !IO) :- output_valid_mangled_name(Name, !IO). -output_mlds_var_name(var_name(Name, yes(Num)), !IO) :- - output_mangled_name(string__format("%s_%d", [s(Name), i(Num)]), !IO). +output_mlds_var_name(mlds_var_name(Name, yes(Num)), !IO) :- + output_mangled_name(string.format("%s_%d", [s(Name), i(Num)]), !IO). %-----------------------------------------------------------------------------% % @@ -1745,40 +1746,40 @@ output_type(mercury_type(Type, TypeCategory, _), !IO) :- % The c_pointer type is used in the c back-end as a generic way % to pass foreign types to automatically generated Compare and Unify % code. When compiling to Java we must instead use java.lang.Object. - io__write_string("/* c_pointer */ java.lang.Object", !IO) + io.write_string("/* c_pointer */ java.lang.Object", !IO) ; % We need to handle type_info (etc.) types specially -- they get mapped % to types in the runtime rather than in private_builtin. hand_defined_type(TypeCategory, SubstituteName) -> - io__write_string(SubstituteName, !IO) + io.write_string(SubstituteName, !IO) ; output_mercury_type(Type, TypeCategory, !IO) ). -output_type(mercury_array_type(ElementType), !IO) :- - ( ElementType = mlds__mercury_type(_, type_cat_variable, _) -> +output_type(mlds_mercury_array_type(ElementType), !IO) :- + ( ElementType = mercury_type(_, type_cat_variable, _) -> % We can't use `java.lang.Object []', since we want a generic type % that is capable of holding any kind of array, including e.g. % `int []'. Java doesn't have any equivalent of .NET's System.Array % class, so we just use the universal base `java.lang.Object'. - io__write_string("/* Array */ java.lang.Object", !IO) + io.write_string("/* Array */ java.lang.Object", !IO) ; output_type(ElementType, !IO), - io__write_string("[]", !IO) + io.write_string("[]", !IO) ). -output_type(mlds__native_int_type, !IO) :- - io__write_string("int", !IO). -output_type(mlds__native_float_type, !IO) :- - io__write_string("double", !IO). -output_type(mlds__native_bool_type, !IO) :- - io__write_string("boolean", !IO). -output_type(mlds__native_char_type, !IO) :- - io__write_string("char", !IO). -output_type(mlds__foreign_type(ForeignType), !IO) :- +output_type(mlds_native_int_type, !IO) :- + io.write_string("int", !IO). +output_type(mlds_native_float_type, !IO) :- + io.write_string("double", !IO). +output_type(mlds_native_bool_type, !IO) :- + io.write_string("boolean", !IO). +output_type(mlds_native_char_type, !IO) :- + io.write_string("char", !IO). +output_type(mlds_foreign_type(ForeignType), !IO) :- ( ForeignType = java(java(Name)), - io__write_string(Name, !IO) + io.write_string(Name, !IO) ; ForeignType = c(_), unexpected(this_file, "output_type: c foreign_type") @@ -1786,43 +1787,43 @@ output_type(mlds__foreign_type(ForeignType), !IO) :- ForeignType = il(_), unexpected(this_file, "output_type: il foreign_type") ). -output_type(mlds__class_type(Name, Arity, _ClassKind), !IO) :- +output_type(mlds_class_type(Name, Arity, _ClassKind), !IO) :- % We used to treat enumerations specially here, outputting % them as "int", but now we do the same for all classes. output_fully_qualified(Name, output_class_name, ".", !IO), - io__format("_%d", [i(Arity)], !IO). -output_type(mlds__ptr_type(Type), !IO) :- + io.format("_%d", [i(Arity)], !IO). +output_type(mlds_ptr_type(Type), !IO) :- % XXX should we report an error here, if the type pointed to % is not a class type? output_type(Type, !IO). -output_type(mlds__array_type(Type), !IO) :- +output_type(mlds_array_type(Type), !IO) :- output_type(Type, !IO), - io__write_string("[]", !IO). -output_type(mlds__func_type(_FuncParams), !IO) :- - io__write_string("mercury.runtime.MethodPtr", !IO). -output_type(mlds__generic_type, !IO) :- - io__write_string("java.lang.Object", !IO). -output_type(mlds__generic_env_ptr_type, !IO) :- - io__write_string("/* env_ptr */ java.lang.Object", !IO). -output_type(mlds__type_info_type, !IO) :- - io__write_string("mercury.runtime.TypeInfo", !IO). -output_type(mlds__pseudo_type_info_type, !IO) :- - io__write_string("mercury.runtime.PseudoTypeInfo", !IO). -output_type(mlds__cont_type(_), !IO) :- + io.write_string("[]", !IO). +output_type(mlds_func_type(_FuncParams), !IO) :- + io.write_string("mercury.runtime.MethodPtr", !IO). +output_type(mlds_generic_type, !IO) :- + io.write_string("java.lang.Object", !IO). +output_type(mlds_generic_env_ptr_type, !IO) :- + io.write_string("/* env_ptr */ java.lang.Object", !IO). +output_type(mlds_type_info_type, !IO) :- + io.write_string("mercury.runtime.TypeInfo", !IO). +output_type(mlds_pseudo_type_info_type, !IO) :- + io.write_string("mercury.runtime.PseudoTypeInfo", !IO). +output_type(mlds_cont_type(_), !IO) :- % XXX Should this actually be a class that extends MethodPtr? - io__write_string("mercury.runtime.MethodPtr", !IO). -output_type(mlds__commit_type, !IO) :- - io__write_string("mercury.runtime.Commit", !IO). -output_type(mlds__rtti_type(RttiIdMaybeElement), !IO) :- + io.write_string("mercury.runtime.MethodPtr", !IO). +output_type(mlds_commit_type, !IO) :- + io.write_string("mercury.runtime.Commit", !IO). +output_type(mlds_rtti_type(RttiIdMaybeElement), !IO) :- rtti_id_maybe_element_java_type(RttiIdMaybeElement, JavaTypeName, IsArray), - io__write_string(JavaTypeName, !IO), + io.write_string(JavaTypeName, !IO), ( IsArray = yes, - io__write_string("[]", !IO) + io.write_string("[]", !IO) ; IsArray = no ). -output_type(mlds__unknown_type, !IO) :- +output_type(mlds_unknown_type, !IO) :- unexpected(this_file, "output_type: unknown type"). :- pred output_mercury_type(mer_type::in, type_category::in, @@ -1831,20 +1832,20 @@ output_type(mlds__unknown_type, !IO) :- output_mercury_type(Type, TypeCategory, !IO) :- ( TypeCategory = type_cat_char, - io__write_string("char", !IO) + io.write_string("char", !IO) ; TypeCategory = type_cat_int, - io__write_string("int", !IO) + io.write_string("int", !IO) ; TypeCategory = type_cat_string, - io__write_string("java.lang.String", !IO) + io.write_string("java.lang.String", !IO) ; TypeCategory = type_cat_float, - io__write_string("double", !IO) + io.write_string("double", !IO) ; TypeCategory = type_cat_void, % Shouldn't matter what we put here. - io__write_string("int", !IO) + io.write_string("int", !IO) ; TypeCategory = type_cat_type_info, output_mercury_user_type(Type, type_cat_user_ctor, !IO) @@ -1859,13 +1860,13 @@ output_mercury_type(Type, TypeCategory, !IO) :- output_mercury_user_type(Type, type_cat_user_ctor, !IO) ; TypeCategory = type_cat_variable, - io__write_string("java.lang.Object", !IO) + io.write_string("java.lang.Object", !IO) ; TypeCategory = type_cat_tuple, - io__write_string("/* tuple */ java.lang.Object[]", !IO) + io.write_string("/* tuple */ java.lang.Object[]", !IO) ; TypeCategory = type_cat_higher_order, - io__write_string("/* closure */ java.lang.Object[]", !IO) + io.write_string("/* closure */ java.lang.Object[]", !IO) ; TypeCategory = type_cat_enum, output_mercury_user_type(Type, TypeCategory, !IO) @@ -1884,9 +1885,9 @@ output_mercury_user_type(Type, TypeCategory, !IO) :- ( type_to_ctor_and_args(Type, TypeCtor, _ArgsTypes) -> ml_gen_type_name(TypeCtor, ClassName, ClassArity), ( TypeCategory = type_cat_enum -> - MLDS_Type = mlds__class_type(ClassName, ClassArity, mlds__enum) + MLDS_Type = mlds_class_type(ClassName, ClassArity, mlds_enum) ; - MLDS_Type = mlds__class_type(ClassName, ClassArity, mlds__class) + MLDS_Type = mlds_class_type(ClassName, ClassArity, mlds_class) ), output_type(MLDS_Type, !IO) ; @@ -1897,13 +1898,13 @@ output_mercury_user_type(Type, TypeCategory, !IO) :- :- func type_is_array(mlds_type) = bool. type_is_array(Type) = IsArray :- - ( Type = mlds__array_type(_) -> + ( Type = mlds_array_type(_) -> IsArray = yes - ; Type = mlds__mercury_array_type(_) -> + ; Type = mlds_mercury_array_type(_) -> IsArray = yes ; Type = mercury_type(_, TypeCategory, _) -> IsArray = type_category_is_array(TypeCategory) - ; Type = mlds__rtti_type(RttiIdMaybeElement) -> + ; Type = mlds_rtti_type(RttiIdMaybeElement) -> rtti_id_maybe_element_java_type(RttiIdMaybeElement, _JavaTypeName, IsArray) ; @@ -1950,7 +1951,7 @@ hand_defined_type(type_cat_typeclass_info, % Code to output declaration specifiers % -:- pred output_decl_flags(mlds__decl_flags::in, mlds__entity_name::in, +:- pred output_decl_flags(mlds_decl_flags::in, mlds_entity_name::in, io::di, io::uo) is det. output_decl_flags(Flags, _Name, !IO) :- @@ -1963,16 +1964,16 @@ output_decl_flags(Flags, _Name, !IO) :- :- pred output_access(access::in, io::di, io::uo) is det. -output_access(public, !IO) :- io__write_string("public ", !IO). -output_access(private, !IO) :- io__write_string("private ", !IO). -output_access(protected, !IO) :-io__write_string("protected ", !IO). +output_access(public, !IO) :- io.write_string("public ", !IO). +output_access(private, !IO) :- io.write_string("private ", !IO). +output_access(protected, !IO) :-io.write_string("protected ", !IO). output_access(default, !IO) :- maybe_output_comment("default", !IO). output_access(local, !IO). :- pred output_per_instance(per_instance::in, io::di, io::uo) is det. output_per_instance(per_instance, !IO). -output_per_instance(one_copy, !IO) :- io__write_string("static ", !IO). +output_per_instance(one_copy, !IO) :- io.write_string("static ", !IO). :- pred output_virtuality(virtuality::in, io::di, io::uo) is det. @@ -1981,7 +1982,7 @@ output_virtuality(non_virtual, !IO). :- pred output_finality(finality::in, io::di, io::uo) is det. -output_finality(final, !IO) :- io__write_string("final ", !IO). +output_finality(final, !IO) :- io.write_string("final ", !IO). output_finality(overridable, !IO). :- pred output_constness(constness::in, io::di, io::uo) is det. @@ -1991,18 +1992,18 @@ output_constness(modifiable, !IO). :- pred output_abstractness(abstractness::in, io::di, io::uo) is det. -output_abstractness(abstract, !IO) :- io__write_string("abstract ", !IO). +output_abstractness(abstract, !IO) :- io.write_string("abstract ", !IO). output_abstractness(concrete, !IO). :- pred maybe_output_comment(string::in, io::di, io::uo) is det. maybe_output_comment(Comment, !IO) :- - globals__io_lookup_bool_option(auto_comments, AddComments, !IO), + globals.io_lookup_bool_option(auto_comments, AddComments, !IO), ( AddComments = yes, - io__write_string("/* ", !IO), - io__write_string(Comment, !IO), - io__write_string(" */", !IO) + io.write_string("/* ", !IO), + io.write_string(Comment, !IO), + io.write_string(" */", !IO) ; AddComments = no ). @@ -2019,7 +2020,7 @@ maybe_output_comment(Comment, !IO) :- % statement could complete normally (fall through). % We keep a set of exit methods since some statements (like an % if-then-else) could potentially break, and also fall through. -:- type exit_methods == set__set(exit_method). +:- type exit_methods == set.set(exit_method). :- type exit_method ---> can_break @@ -2032,32 +2033,32 @@ maybe_output_comment(Comment, !IO) :- :- type func_info ---> func_info( - func_info_name :: mlds__qualified_entity_name, - func_info_params :: mlds__func_params + func_info_name :: mlds_qualified_entity_name, + func_info_params :: mlds_func_params ). -:- func mod_name(mlds__fully_qualified_name(T)) = mlds_module_name. +:- func mod_name(mlds_fully_qualified_name(T)) = mlds_module_name. mod_name(qual(ModuleName, _, _)) = ModuleName. :- pred output_statements(indent::in, module_info::in, func_info::in, list(statement)::in, exit_methods::out, io::di, io::uo) is det. -output_statements(_, _, _, [], set__make_singleton_set(can_fall_through), !IO). +output_statements(_, _, _, [], set.make_singleton_set(can_fall_through), !IO). output_statements(Indent, ModuleInfo, FuncInfo, [Statement | Statements], ExitMethods, !IO) :- output_statement(Indent, ModuleInfo, FuncInfo, Statement, StmtExitMethods, !IO), - ( set__member(can_fall_through, StmtExitMethods) -> + ( set.member(can_fall_through, StmtExitMethods) -> output_statements(Indent, ModuleInfo, FuncInfo, Statements, StmtsExitMethods, !IO), - ExitMethods0 = StmtExitMethods `set__union` StmtsExitMethods, - ( set__member(can_fall_through, StmtsExitMethods) -> + ExitMethods0 = StmtExitMethods `set.union` StmtsExitMethods, + ( set.member(can_fall_through, StmtsExitMethods) -> ExitMethods = ExitMethods0 ; % If the last statement could not complete normally % the current block can no longer complete normally. - ExitMethods = ExitMethods0 `set__delete` can_fall_through + ExitMethods = ExitMethods0 `set.delete` can_fall_through ) ; % Don't output any more statements from the current list since @@ -2074,44 +2075,44 @@ output_statement(Indent, ModuleInfo, FuncInfo, output_stmt(Indent, ModuleInfo, FuncInfo, Statement, Context, ExitMethods, !IO). -:- pred output_stmt(indent::in, module_info::in, func_info::in, mlds__stmt::in, - mlds__context::in, exit_methods::out, io::di, io::uo) is det. +:- pred output_stmt(indent::in, module_info::in, func_info::in, mlds_stmt::in, + mlds_context::in, exit_methods::out, io::di, io::uo) is det. % sequence % output_stmt(Indent, ModuleInfo, FuncInfo, block(Defns, Statements), Context, ExitMethods, !IO) :- indent_line(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), ( Defns = [_ | _], ModuleName = FuncInfo ^ func_info_name ^ mod_name, CtorData = none, % Not a constructor. output_defns(Indent + 1, ModuleInfo, ModuleName, CtorData, Defns, !IO), - io__write_string("\n", !IO) + io.write_string("\n", !IO) ; Defns = [] ), output_statements(Indent + 1, ModuleInfo, FuncInfo, Statements, ExitMethods, !IO), indent_line(Context, Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). % iteration % output_stmt(Indent, ModuleInfo, FuncInfo, while(Cond, Statement, no), _, ExitMethods, !IO) :- indent_line(Indent, !IO), - io__write_string("while (", !IO), + io.write_string("while (", !IO), output_rval(ModuleInfo, Cond, FuncInfo ^ func_info_name ^ mod_name, !IO), - io__write_string(")\n", !IO), + io.write_string(")\n", !IO), % The contained statement is reachable iff the while statement is % reachable and the condition expression is not a constant expression % whose value is false. ( Cond = const(false) -> indent_line(Indent, !IO), - io__write_string("{ /* Unreachable code */ }\n", !IO), - ExitMethods = set__make_singleton_set(can_fall_through) + io.write_string("{ /* Unreachable code */ }\n", !IO), + ExitMethods = set.make_singleton_set(can_fall_through) ; output_statement(Indent + 1, ModuleInfo, FuncInfo, Statement, StmtExitMethods, !IO), @@ -2120,13 +2121,13 @@ output_stmt(Indent, ModuleInfo, FuncInfo, while(Cond, Statement, no), output_stmt(Indent, ModuleInfo, FuncInfo, while(Cond, Statement, yes), Context, ExitMethods, !IO) :- indent_line(Indent, !IO), - io__write_string("do\n", !IO), + io.write_string("do\n", !IO), output_statement(Indent + 1, ModuleInfo, FuncInfo, Statement, StmtExitMethods, !IO), indent_line(Context, Indent, !IO), - io__write_string("while (", !IO), + io.write_string("while (", !IO), output_rval(ModuleInfo, Cond, FuncInfo ^ func_info_name ^ mod_name, !IO), - io__write_string(");\n", !IO), + io.write_string(");\n", !IO), ExitMethods = while_exit_methods(Cond, StmtExitMethods). % selection (if-then-else) @@ -2157,26 +2158,26 @@ output_stmt(Indent, ModuleInfo, FuncInfo, if_then_else(Cond, Then0, MaybeElse), ), indent_line(Indent, !IO), - io__write_string("if (", !IO), + io.write_string("if (", !IO), output_rval(ModuleInfo, Cond, FuncInfo ^ func_info_name ^ mod_name, !IO), - io__write_string(")\n", !IO), + io.write_string(")\n", !IO), output_statement(Indent + 1, ModuleInfo, FuncInfo, Then, ThenExitMethods, !IO), ( MaybeElse = yes(Else), indent_line(Context, Indent, !IO), - io__write_string("else\n", !IO), + io.write_string("else\n", !IO), output_statement(Indent + 1, ModuleInfo, FuncInfo, Else, ElseExitMethods, !IO), % An if-then-else statement can complete normally iff the % then-statement can complete normally or the else-statement % can complete normally. - ExitMethods = ThenExitMethods `set__union` ElseExitMethods + ExitMethods = ThenExitMethods `set.union` ElseExitMethods ; MaybeElse = no, % An if-then statement can complete normally iff it is reachable. - ExitMethods = ThenExitMethods `set__union` - set__make_singleton_set(can_fall_through) + ExitMethods = ThenExitMethods `set.union` + set.make_singleton_set(can_fall_through) ). % selection (switch) @@ -2185,14 +2186,14 @@ output_stmt(Indent, ModuleInfo, FuncInfo, switch(_Type, Val, _Range, Cases, Default), Context, ExitMethods, !IO) :- indent_line(Context, Indent, !IO), - io__write_string("switch (", !IO), + io.write_string("switch (", !IO), output_rval_maybe_with_enum(ModuleInfo, Val, FuncInfo ^ func_info_name ^ mod_name, !IO), - io__write_string(") {\n", !IO), + io.write_string(") {\n", !IO), output_switch_cases(Indent + 1, ModuleInfo, FuncInfo, Context, Cases, Default, ExitMethods, !IO), indent_line(Context, Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). % transfer of control % @@ -2202,13 +2203,13 @@ output_stmt(_, _, _, goto(label(_)), _, _, _, _) :- unexpected(this_file, "output_stmt: gotos not supported in Java."). output_stmt(Indent, _, _FuncInfo, goto(break), _Context, ExitMethods, !IO) :- indent_line(Indent, !IO), - io__write_string("break;\n", !IO), - ExitMethods = set__make_singleton_set(can_break). + io.write_string("break;\n", !IO), + ExitMethods = set.make_singleton_set(can_break). output_stmt(Indent, _, _FuncInfo, goto(continue), _Context, ExitMethods, !IO) :- indent_line(Indent, !IO), - io__write_string("continue;\n", !IO), - ExitMethods = set__make_singleton_set(can_continue). + io.write_string("continue;\n", !IO), + ExitMethods = set.make_singleton_set(can_continue). output_stmt(_, _, _, computed_goto(_, _), _, _, _, _) :- unexpected(this_file, "output_stmt: computed gotos not supported in Java."). @@ -2219,17 +2220,17 @@ output_stmt(Indent, ModuleInfo, CallerFuncInfo, Call, Context, ExitMethods, !IO) :- Call = call(Signature, FuncRval, MaybeObject, CallArgs, Results, _IsTailCall), - Signature = mlds__func_signature(ArgTypes, RetTypes), + Signature = mlds_func_signature(ArgTypes, RetTypes), ModuleName = CallerFuncInfo ^ func_info_name ^ mod_name, indent_line(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), indent_line(Context, Indent + 1, !IO), ( Results = [] ; Results = [Lval], output_lval(ModuleInfo, Lval, ModuleName, !IO), - io__write_string(" = ", !IO) + io.write_string(" = ", !IO) ; Results = [_, _ | _], % for multiple return values, @@ -2240,24 +2241,24 @@ output_stmt(Indent, ModuleInfo, CallerFuncInfo, Call, Context, ExitMethods, % ... % } % - io__write_string("java.lang.Object [] result = ", !IO) + io.write_string("java.lang.Object [] result = ", !IO) ), ( FuncRval = const(code_addr_const(_)) -> % This is a standard method call. ( MaybeObject = yes(Object), output_bracketed_rval(ModuleInfo, Object, ModuleName, !IO), - io__write_string(".", !IO) + io.write_string(".", !IO) ; MaybeObject = no ), % This is a standard function call. output_call_rval(ModuleInfo, FuncRval, ModuleName, !IO), - io__write_string("(", !IO), - io__write_list(CallArgs, ", ", + io.write_string("(", !IO), + io.write_list(CallArgs, ", ", (pred(CallArg::in, !.IO::di, !:IO::uo) is det :- output_rval(ModuleInfo, CallArg, ModuleName, !IO)), !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; % This is a call using a method pointer. % @@ -2274,51 +2275,51 @@ output_stmt(Indent, ModuleInfo, CallerFuncInfo, Call, Context, ExitMethods, ; RetTypes = [RetType], ( java_builtin_type(ModuleInfo, RetType, _, JavaBoxedName, _) -> - io__write_string("((", !IO), - io__write_string(JavaBoxedName, !IO), - io__write_string(") ", !IO) + io.write_string("((", !IO), + io.write_string(JavaBoxedName, !IO), + io.write_string(") ", !IO) ; - io__write_string("((", !IO), + io.write_string("((", !IO), output_type(RetType, !IO), - io__write_string(") ", !IO) + io.write_string(") ", !IO) ) ; RetTypes = [_, _ | _], - io__write_string("((java.lang.Object[]) ", !IO) + io.write_string("((java.lang.Object[]) ", !IO) ), ( MaybeObject = yes(Object), output_bracketed_rval(ModuleInfo, Object, ModuleName, !IO), - io__write_string(".", !IO) + io.write_string(".", !IO) ; MaybeObject = no ), output_bracketed_rval(ModuleInfo, FuncRval, ModuleName, !IO), - io__write_string(".call___0_0(", !IO), + io.write_string(".call___0_0(", !IO), % We need to pass the arguments as a single array of java.lang.Object. output_args_as_array(ModuleInfo, CallArgs, ArgTypes, ModuleName, !IO), % Closes brackets, and calls unbox methods for downcasting. % XXX This is a hack, see the above comment. - io__write_string(")", !IO), + io.write_string(")", !IO), ( RetTypes = [] ; RetTypes = [RetType2], ( java_builtin_type(ModuleInfo, RetType2, _, _, UnboxMethod) -> - io__write_string(").", !IO), - io__write_string(UnboxMethod, !IO), - io__write_string("()", !IO) + io.write_string(").", !IO), + io.write_string(UnboxMethod, !IO), + io.write_string("()", !IO) ; - io__write_string(")", !IO) + io.write_string(")", !IO) ) ; RetTypes = [_, _ | _], - io__write_string(")", !IO) + io.write_string(")", !IO) ) ), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), ( Results = [_, _ | _] -> % Copy the results from the "result" array into the Result @@ -2333,14 +2334,14 @@ output_stmt(Indent, ModuleInfo, CallerFuncInfo, Call, Context, ExitMethods, % % ( IsTailCall = tail_call, Results = [] -> % indent_line(Context, Indent + 1, !IO), - % io__write_string("return;\n", !IO) + % io.write_string("return;\n", !IO) % ; % true % ), % indent_line(Indent, !IO), - io__write_string("}\n", !IO), - ExitMethods = set__make_singleton_set(can_fall_through). + io.write_string("}\n", !IO), + ExitMethods = set.make_singleton_set(can_fall_through). output_stmt(Indent, ModuleInfo, FuncInfo, return(Results0), _, ExitMethods, !IO) :- @@ -2359,66 +2360,66 @@ output_stmt(Indent, ModuleInfo, FuncInfo, return(Results0), _, ExitMethods, ( Results = [], indent_line(Indent, !IO), - io__write_string("return;\n", !IO) + io.write_string("return;\n", !IO) ; Results = [Rval], indent_line(Indent, !IO), - io__write_string("return ", !IO), + io.write_string("return ", !IO), output_rval(ModuleInfo, Rval, FuncInfo ^ func_info_name ^ mod_name, !IO), - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ; Results = [_, _ | _], FuncInfo = func_info(FuncName, Params), - Params = mlds__func_params(_Args, ReturnTypes), - TypesAndResults = assoc_list__from_corresponding_lists( + Params = mlds_func_params(_Args, ReturnTypes), + TypesAndResults = assoc_list.from_corresponding_lists( ReturnTypes, Results), - io__write_string("return new java.lang.Object[] {\n", !IO), + io.write_string("return new java.lang.Object[] {\n", !IO), indent_line(Indent + 1, !IO), Separator = ",\n" ++ duplicate_char(' ', (Indent + 1) * 2), - io__write_list(TypesAndResults, Separator, + io.write_list(TypesAndResults, Separator, (pred((Type - Result)::in, !.IO::di, !:IO::uo) is det :- output_boxed_rval(ModuleInfo, Type, Result, FuncName ^ mod_name, !IO)), !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), indent_line(Indent, !IO), - io__write_string("};\n", !IO) + io.write_string("};\n", !IO) ), - ExitMethods = set__make_singleton_set(can_return). + ExitMethods = set.make_singleton_set(can_return). output_stmt(Indent, ModuleInfo, FuncInfo, do_commit(Ref), _, ExitMethods, !IO) :- indent_line(Indent, !IO), output_rval(ModuleInfo, Ref, FuncInfo ^ func_info_name ^ mod_name, !IO), - io__write_string(" = new mercury.runtime.Commit();\n", !IO), + io.write_string(" = new mercury.runtime.Commit();\n", !IO), indent_line(Indent, !IO), - io__write_string("throw ", !IO), + io.write_string("throw ", !IO), output_rval(ModuleInfo, Ref, FuncInfo ^ func_info_name ^ mod_name, !IO), - io__write_string(";\n", !IO), - ExitMethods = set__make_singleton_set(can_throw). + io.write_string(";\n", !IO), + ExitMethods = set.make_singleton_set(can_throw). output_stmt(Indent, ModuleInfo, FuncInfo, try_commit(_Ref, Stmt, Handler), _, ExitMethods, !IO) :- indent_line(Indent, !IO), - io__write_string("try\n", !IO), + io.write_string("try\n", !IO), indent_line(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), output_statement(Indent + 1, ModuleInfo, FuncInfo, Stmt, TryExitMethods0, !IO), indent_line(Indent, !IO), - io__write_string("}\n", !IO), + io.write_string("}\n", !IO), indent_line(Indent, !IO), - io__write_string("catch (mercury.runtime.Commit commit_variable)\n", !IO), + io.write_string("catch (mercury.runtime.Commit commit_variable)\n", !IO), indent_line(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), indent_line(Indent + 1, !IO), output_statement(Indent + 1, ModuleInfo, FuncInfo, Handler, CatchExitMethods, !IO), indent_line(Indent, !IO), - io__write_string("}\n", !IO), - ExitMethods = (TryExitMethods0 `set__delete` can_throw) - `set__union` CatchExitMethods. + io.write_string("}\n", !IO), + ExitMethods = (TryExitMethods0 `set.delete` can_throw) + `set.union` CatchExitMethods. % exception handling % @@ -2431,7 +2432,7 @@ output_stmt(Indent, ModuleInfo, FuncInfo, atomic(AtomicStatement), Context, ExitMethods, !IO) :- output_atomic_stmt(Indent, ModuleInfo, FuncInfo, AtomicStatement, Context, !IO), - ExitMethods = set__make_singleton_set(can_fall_through). + ExitMethods = set.make_singleton_set(can_fall_through). % Returns a set of exit_methods that describes whether the while % statement can complete normally. @@ -2451,16 +2452,16 @@ while_exit_methods(Cond, BlockExitMethods) = ExitMethods :- % XXX This is not a sufficient way of testing for a Java % "constant expression", though determining these accurately % is a little difficult to do here. - Cond = mlds__const(mlds__true), - not set__member(can_break, BlockExitMethods) + Cond = const(true), + not set.member(can_break, BlockExitMethods) -> % Cannot complete normally - ExitMethods0 = BlockExitMethods `set__delete` can_fall_through + ExitMethods0 = BlockExitMethods `set.delete` can_fall_through ; - ExitMethods0 = BlockExitMethods `set__insert` can_fall_through + ExitMethods0 = BlockExitMethods `set.insert` can_fall_through ), - ExitMethods = (ExitMethods0 `set__delete` can_continue) - `set__delete` can_break. + ExitMethods = (ExitMethods0 `set.delete` can_continue) + `set.delete` can_break. %-----------------------------------------------------------------------------% % @@ -2471,9 +2472,9 @@ while_exit_methods(Cond, BlockExitMethods) = ExitMethods :- list(mlds_type)::in, mlds_module_name::in, io::di, io::uo) is det. output_args_as_array(ModuleInfo, CallArgs, CallArgTypes, ModuleName, !IO) :- - io__write_string("new java.lang.Object[] { ", !IO), + io.write_string("new java.lang.Object[] { ", !IO), output_boxed_args(ModuleInfo, CallArgs, CallArgTypes, ModuleName, !IO), - io__write_string("} ", !IO). + io.write_string("} ", !IO). :- pred output_boxed_args(module_info::in, list(mlds_rval)::in, list(mlds_type)::in, mlds_module_name::in, io::di, io::uo) is det. @@ -2490,7 +2491,7 @@ output_boxed_args(ModuleInfo, [CallArg | CallArgs], CallArgs = [] ; CallArgs = [_ | _], - io__write_string(", ", !IO), + io.write_string(", ", !IO), output_boxed_args(ModuleInfo, CallArgs, CallArgTypes, ModuleName, !IO) ). @@ -2528,16 +2529,16 @@ remove_dummy_vars(ModuleInfo, [Var | Vars0]) = VarList :- % :- pred output_assign_results(module_info::in, list(mlds_lval)::in, list(mlds_type)::in, int::in, mlds_module_name::in, indent::in, - mlds__context::in, io::di, io::uo) is det. + mlds_context::in, io::di, io::uo) is det. output_assign_results(_, [], [], _, _, _, _, !IO). output_assign_results(ModuleInfo, [Lval | Lvals], [Type | Types], ResultIndex, ModuleName, Indent, Context, !IO) :- indent_line(Context, Indent, !IO), output_lval(ModuleInfo, Lval, ModuleName, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), output_unboxed_result(ModuleInfo, Type, ResultIndex, !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), output_assign_results(ModuleInfo, Lvals, Types, ResultIndex + 1, ModuleName, Indent, Context, !IO). output_assign_results(_, [_ | _], [], _, _, _, _, _, _) :- @@ -2550,15 +2551,15 @@ output_assign_results(_, [], [_ | _], _, _, _, _, _, _) :- output_unboxed_result(ModuleInfo, Type, ResultIndex, !IO) :- ( java_builtin_type(ModuleInfo, Type, _, JavaBoxedName, UnboxMethod) -> - io__write_string("((", !IO), - io__write_string(JavaBoxedName, !IO), - io__write_string(") ", !IO), - io__format("result[%d]).%s()", [i(ResultIndex), s(UnboxMethod)], !IO) + io.write_string("((", !IO), + io.write_string(JavaBoxedName, !IO), + io.write_string(") ", !IO), + io.format("result[%d]).%s()", [i(ResultIndex), s(UnboxMethod)], !IO) ; - io__write_string("(", !IO), + io.write_string("(", !IO), output_type(Type, !IO), - io__write_string(") ", !IO), - io__format("result[%d]", [i(ResultIndex)], !IO) + io.write_string(") ", !IO), + io.format("result[%d]", [i(ResultIndex)], !IO) ). %-----------------------------------------------------------------------------% @@ -2567,7 +2568,7 @@ output_unboxed_result(ModuleInfo, Type, ResultIndex, !IO) :- % :- pred output_switch_cases(indent::in, module_info::in, func_info::in, - mlds__context::in, list(mlds__switch_case)::in, mlds__switch_default::in, + mlds_context::in, list(mlds_switch_case)::in, mlds_switch_default::in, exit_methods::out, io::di, io::uo) is det. output_switch_cases(Indent, ModuleInfo, FuncInfo, Context, [], Default, @@ -2580,70 +2581,70 @@ output_switch_cases(Indent, ModuleInfo, FuncInfo, Context, [Case | Cases], CaseExitMethods0, !IO), output_switch_cases(Indent, ModuleInfo, FuncInfo, Context, Cases, Default, CasesExitMethods, !IO), - ( set__member(can_break, CaseExitMethods0) -> - CaseExitMethods = (CaseExitMethods0 `set__delete` can_break) - `set__insert` can_fall_through + ( set.member(can_break, CaseExitMethods0) -> + CaseExitMethods = (CaseExitMethods0 `set.delete` can_break) + `set.insert` can_fall_through ; CaseExitMethods = CaseExitMethods0 ), - ExitMethods = CaseExitMethods `set__union` CasesExitMethods. + ExitMethods = CaseExitMethods `set.union` CasesExitMethods. :- pred output_switch_case(indent::in, module_info::in, func_info::in, - mlds__context::in, mlds__switch_case::in, exit_methods::out, + mlds_context::in, mlds_switch_case::in, exit_methods::out, io::di, io::uo) is det. output_switch_case(Indent, ModuleInfo, FuncInfo, Context, Case, ExitMethods, !IO) :- Case = (Conds - Statement), ModuleName = FuncInfo ^ func_info_name ^ mod_name, - list__foldl(output_case_cond(Indent, ModuleInfo, ModuleName, Context), + list.foldl(output_case_cond(Indent, ModuleInfo, ModuleName, Context), Conds, !IO), output_statement(Indent + 1, ModuleInfo, FuncInfo, Statement, StmtExitMethods, !IO), - ( set__member(can_fall_through, StmtExitMethods) -> + ( set.member(can_fall_through, StmtExitMethods) -> indent_line(Context, Indent + 1, !IO), - io__write_string("break;\n", !IO), - ExitMethods = (StmtExitMethods `set__insert` can_break) - `set__delete` can_fall_through + io.write_string("break;\n", !IO), + ExitMethods = (StmtExitMethods `set.insert` can_break) + `set.delete` can_fall_through ; % Don't output `break' since it would be unreachable. ExitMethods = StmtExitMethods ). :- pred output_case_cond(indent::in, module_info::in, mlds_module_name::in, - mlds__context::in, mlds__case_match_cond::in, io::di, io::uo) is det. + mlds_context::in, mlds_case_match_cond::in, io::di, io::uo) is det. output_case_cond(Indent, ModuleInfo, ModuleName, Context, match_value(Val), !IO) :- indent_line(Context, Indent, !IO), - io__write_string("case ", !IO), + io.write_string("case ", !IO), output_rval(ModuleInfo, Val, ModuleName, !IO), - io__write_string(":\n", !IO). + io.write_string(":\n", !IO). output_case_cond(_Indent, _ModuleInfo, _ModuleName, _Context, match_range(_, _), _, _) :- unexpected(this_file, "output_case_cond: cannot match ranges in Java cases"). :- pred output_switch_default(indent::in, module_info::in, func_info::in, - mlds__context::in, mlds__switch_default::in, exit_methods::out, + mlds_context::in, mlds_switch_default::in, exit_methods::out, io::di, io::uo) is det. output_switch_default(_Indent, _ModuleInfo, _FuncInfo, _Context, default_do_nothing, ExitMethods, !IO) :- - ExitMethods = set__make_singleton_set(can_fall_through). + ExitMethods = set.make_singleton_set(can_fall_through). output_switch_default(Indent, ModuleInfo, FuncInfo, Context, default_case(Statement), ExitMethods, !IO) :- indent_line(Context, Indent, !IO), - io__write_string("default:\n", !IO), + io.write_string("default:\n", !IO), output_statement(Indent + 1, ModuleInfo, FuncInfo, Statement, ExitMethods, !IO). output_switch_default(Indent, _ModuleInfo, _FuncInfo, Context, default_is_unreachable, ExitMethods, !IO) :- indent_line(Context, Indent, !IO), - io__write_string("default: /*NOTREACHED*/\n", !IO), + io.write_string("default: /*NOTREACHED*/\n", !IO), indent_line(Context, Indent + 1, !IO), - io__write_string("throw new mercury.runtime.UnreachableDefault();\n", !IO), - ExitMethods = set__make_singleton_set(can_throw). + io.write_string("throw new mercury.runtime.UnreachableDefault();\n", !IO), + ExitMethods = set.make_singleton_set(can_throw). %-----------------------------------------------------------------------------% % @@ -2651,18 +2652,17 @@ output_switch_default(Indent, _ModuleInfo, _FuncInfo, Context, % :- pred output_atomic_stmt(indent::in, module_info::in, func_info::in, - mlds__atomic_statement::in, mlds__context::in, io::di, io::uo) is det. + mlds_atomic_statement::in, mlds_context::in, io::di, io::uo) is det. % comments % output_atomic_stmt(Indent, _ModuleInfo, _FuncInfo, comment(Comment), _, !IO) :- - % XXX we should escape any "*/"'s in the Comment. - % we should also split the comment into lines and indent - % each line appropriately. + % XXX We should escape any "*/"'s in the Comment. We should also split + % the comment into lines and indent each line appropriately. indent_line(Indent, !IO), - io__write_string("/* ", !IO), - io__write_string(Comment, !IO), - io__write_string(" */\n", !IO). + io.write_string("/* ", !IO), + io.write_string(Comment, !IO), + io.write_string(" */\n", !IO). % assignment % @@ -2670,25 +2670,25 @@ output_atomic_stmt(Indent, ModuleInfo, FuncInfo, assign(Lval, Rval), _, !IO) :- ModuleName = FuncInfo ^ func_info_name ^ mod_name, indent_line(Indent, !IO), output_lval(ModuleInfo, Lval, ModuleName, !IO), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), ( LvalType = mlds_lval_type(Lval), type_is_object(LvalType) -> % If the Lval is an object. ( rval_is_int_const(Rval) -> - io__write_string("new ", !IO), + io.write_string("new ", !IO), output_type(LvalType, !IO), - io__write_string("(", !IO), + io.write_string("(", !IO), output_rval(ModuleInfo, Rval, ModuleName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; output_rval(ModuleInfo, Rval, ModuleName, !IO) ) ; output_rval_maybe_with_enum(ModuleInfo, Rval, ModuleName, !IO) ), - io__write_string(";\n", !IO). + io.write_string(";\n", !IO). % heap management % @@ -2701,10 +2701,10 @@ output_atomic_stmt(Indent, ModuleInfo, FuncInfo, NewObject, Context, !IO) :- ModuleName = FuncInfo ^ func_info_name ^ mod_name, indent_line(Indent, !IO), - io__write_string("{\n", !IO), + io.write_string("{\n", !IO), indent_line(Context, Indent + 1, !IO), output_lval(ModuleInfo, Target, ModuleName, !IO), - io__write_string(" = new ", !IO), + io.write_string(" = new ", !IO), % Generate class constructor name. ( @@ -2715,7 +2715,7 @@ output_atomic_stmt(Indent, ModuleInfo, FuncInfo, NewObject, Context, !IO) :- ) -> output_type(Type, !IO), - io__write_char('.', !IO), + io.write_char('.', !IO), QualifiedCtorId = qual(_ModuleName, _QualKind, CtorDefn), CtorDefn = ctor_id(CtorName, CtorArity), output_class_name_and_arity(type(CtorName, CtorArity), !IO) @@ -2725,19 +2725,19 @@ output_atomic_stmt(Indent, ModuleInfo, FuncInfo, NewObject, Context, !IO) :- ( type_is_array(Type) = yes -> % The new object will be an array, so we need to initialise it % using array literals syntax. - io__write_string(" {", !IO), + io.write_string(" {", !IO), output_init_args(ModuleInfo, Args, ArgTypes, 0, HasSecTag, ModuleName, !IO), - io__write_string("};\n", !IO) + io.write_string("};\n", !IO) ; % Generate constructor arguments. - io__write_string("(", !IO), + io.write_string("(", !IO), output_init_args(ModuleInfo, Args, ArgTypes, 0, HasSecTag, ModuleName, !IO), - io__write_string(");\n", !IO) + io.write_string(");\n", !IO) ), indent_line(Indent, !IO), - io__write_string("}\n", !IO). + io.write_string("}\n", !IO). output_atomic_stmt(_Indent, _, _FuncInfo, gc_check, _, _, _) :- unexpected(this_file, "gc_check not implemented."). @@ -2760,7 +2760,7 @@ output_atomic_stmt(Indent, ModuleInfo, FuncInfo, ( TargetLang = lang_java -> indent_line(Indent, !IO), ModuleName = FuncInfo ^ func_info_name ^ mod_name, - list__foldl( + list.foldl( output_target_code_component(ModuleInfo, ModuleName, Context), Components, !IO) ; @@ -2775,16 +2775,16 @@ output_atomic_stmt(_Indent, _, _FuncInfo, %-----------------------------------------------------------------------------% :- pred output_target_code_component(module_info::in, mlds_module_name::in, - mlds__context::in, target_code_component::in, io::di, io::uo) is det. + mlds_context::in, target_code_component::in, io::di, io::uo) is det. output_target_code_component(_, _ModuleName, _Context, user_target_code(CodeString, _MaybeUserContext, _Attrs), !IO) :- % XXX Java does not have an equivalent of the C #line preprocessor % directive. If it did, we should use it here. - io__write_string(CodeString, !IO). + io.write_string(CodeString, !IO). output_target_code_component(_, _ModuleName, _Context, raw_target_code(CodeString, _Attrs), !IO) :- - io__write_string(CodeString, !IO). + io.write_string(CodeString, !IO). output_target_code_component(ModuleInfo, ModuleName, _Context, target_code_input(Rval), !IO) :- output_rval(ModuleInfo, Rval, ModuleName, !IO). @@ -2823,7 +2823,7 @@ output_init_args(ModuleInfo, [Arg | Args], [_ArgType | ArgTypes], ArgNum, Args = [] ; Args = [_ | _], - io__write_string(", ", !IO) + io.write_string(", ", !IO) ) ), output_init_args(ModuleInfo, Args, ArgTypes, ArgNum + 1, HasSecTag, @@ -2841,8 +2841,8 @@ output_lval(ModuleInfo, field(_MaybeTag, Rval, offset(OffsetRval), FieldType, _), ModuleName, !IO) :- ( - ( FieldType = mlds__generic_type - ; FieldType = mlds__mercury_type(variable(_, _), _, _)) + ( FieldType = mlds_generic_type + ; FieldType = mercury_type(variable(_, _), _, _)) -> true ; @@ -2852,11 +2852,11 @@ output_lval(ModuleInfo, ), % XXX We shouldn't need this cast here, but there are cases where % it is needed and the MLDS doesn't seem to generate it. - io__write_string("((java.lang.Object[]) ", !IO), + io.write_string("((java.lang.Object[]) ", !IO), output_rval(ModuleInfo, Rval, ModuleName, !IO), - io__write_string(")[", !IO), + io.write_string(")[", !IO), output_rval(ModuleInfo, OffsetRval, ModuleName, !IO), - io__write_string("]", !IO). + io.write_string("]", !IO). output_lval(ModuleInfo, field(_, PtrRval, named_field(FieldName, CtorType), _, _), @@ -2869,18 +2869,18 @@ output_lval(ModuleInfo, % If the field we are trying to access is just a `data_tag' % then it is a member of the base class. output_bracketed_rval(ModuleInfo, PtrRval, ModuleName, !IO), - io__write_string(".", !IO) + io.write_string(".", !IO) ; % Otherwise the field we are trying to access may be in a derived % class. Objects are manipulated as instances of their base class, % so we need to downcast to the derived class to access some fields. % - io__write_string("((", !IO), + io.write_string("((", !IO), output_type(CtorType, !IO), - io__write_string(") ", !IO), + io.write_string(") ", !IO), output_bracketed_rval(ModuleInfo, PtrRval, ModuleName, !IO), % The actual variable. - io__write_string(").", !IO) + io.write_string(").", !IO) ), FieldName = qual(_, _, UnqualFieldName), output_valid_mangled_name(UnqualFieldName, !IO). % the field name @@ -2897,22 +2897,22 @@ output_lval(_, var(qual(ModName, QualKind, Name), _), CurrentModuleName, output_mangled_name(Name, !IO) :- MangledName = name_mangle(Name), - io__write_string(MangledName, !IO). + io.write_string(MangledName, !IO). :- pred output_valid_mangled_name(string::in, io::di, io::uo) is det. output_valid_mangled_name(Name, !IO) :- MangledName = name_mangle(Name), JavaSafeName = valid_symbol_name(MangledName), - io__write_string(JavaSafeName, !IO). + io.write_string(JavaSafeName, !IO). :- pred output_call_rval(module_info::in, mlds_rval::in, mlds_module_name::in, io::di, io::uo) is det. output_call_rval(ModuleInfo, Rval, ModuleName, !IO) :- ( - Rval = mlds__const(Const), - Const = mlds__code_addr_const(CodeAddr) + Rval = const(Const), + Const = code_addr_const(CodeAddr) -> IsCall = yes, mlds_output_code_addr(CodeAddr, IsCall, !IO) @@ -2932,9 +2932,9 @@ output_bracketed_rval(ModuleInfo, Rval, ModuleName, !IO) :- -> output_rval(ModuleInfo, Rval, ModuleName, !IO) ; - io__write_char('(', !IO), + io.write_char('(', !IO), output_rval(ModuleInfo, Rval, ModuleName, !IO), - io__write_char(')', !IO) + io.write_char(')', !IO) ). :- pred output_rval(module_info::in, mlds_rval::in, mlds_module_name::in, @@ -2959,7 +2959,7 @@ output_rval(_, mem_addr(_Lval), _, !IO) :- unexpected(this_file, "output_rval: mem_addr(_) not supported"). output_rval(_, self(_), _, !IO) :- - io__write_string("this", !IO). + io.write_string("this", !IO). :- pred output_unop(module_info::in, mlds_unary_op::in, mlds_rval::in, mlds_module_name::in, io::di, io::uo) is det. @@ -2970,22 +2970,22 @@ output_unop(ModuleInfo, cast(Type), Exprn, ModuleName, !IO) :- % we need to treat these as constructions, not casts. % Similarly for conversions from TypeCtorInfo to TypeInfo. ( - Type = mlds__pseudo_type_info_type, + Type = mlds_pseudo_type_info_type, Exprn = const(int_const(_)) -> maybe_output_comment("cast", !IO), - io__write_string("new mercury.runtime.PseudoTypeInfo(", !IO), + io.write_string("new mercury.runtime.PseudoTypeInfo(", !IO), output_rval(ModuleInfo, Exprn, ModuleName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - ( Type = mlds__mercury_type(_, type_cat_type_info, _) - ; Type = mlds__type_info_type + ( Type = mercury_type(_, type_cat_type_info, _) + ; Type = mlds_type_info_type ) -> maybe_output_comment("cast", !IO), - io__write_string("new mercury.runtime.TypeInfo_Struct(", !IO), + io.write_string("new mercury.runtime.TypeInfo_Struct(", !IO), output_rval(ModuleInfo, Exprn, ModuleName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; output_cast_rval(ModuleInfo, Type, Exprn, ModuleName, !IO) ). @@ -3000,9 +3000,9 @@ output_unop(ModuleInfo, std_unop(Unop), Exprn, ModuleName, !IO) :- mlds_module_name::in, io::di, io::uo) is det. output_cast_rval(ModuleInfo, Type, Exprn, ModuleName, !IO) :- - io__write_string("(", !IO), + io.write_string("(", !IO), output_type(Type, !IO), - io__write_string(") ", !IO), + io.write_string(") ", !IO), ( java_builtin_type(ModuleInfo, Type, "int", _, _) -> output_rval_maybe_with_enum(ModuleInfo, Exprn, ModuleName, !IO) ; @@ -3014,15 +3014,15 @@ output_cast_rval(ModuleInfo, Type, Exprn, ModuleName, !IO) :- output_boxed_rval(ModuleInfo, Type, Exprn, ModuleName, !IO) :- ( java_builtin_type(ModuleInfo, Type, _JavaName, JavaBoxedName, _) -> - io__write_string("new ", !IO), - io__write_string(JavaBoxedName, !IO), - io__write_string("(", !IO), + io.write_string("new ", !IO), + io.write_string(JavaBoxedName, !IO), + io.write_string("(", !IO), output_rval(ModuleInfo, Exprn, ModuleName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - io__write_string("((java.lang.Object) (", !IO), + io.write_string("((java.lang.Object) (", !IO), output_rval(ModuleInfo, Exprn, ModuleName, !IO), - io__write_string("))", !IO) + io.write_string("))", !IO) ). :- pred output_unboxed_rval(module_info::in, mlds_type::in, mlds_rval::in, @@ -3030,19 +3030,19 @@ output_boxed_rval(ModuleInfo, Type, Exprn, ModuleName, !IO) :- output_unboxed_rval(ModuleInfo, Type, Exprn, ModuleName, !IO) :- ( java_builtin_type(ModuleInfo, Type, _, JavaBoxedName, UnboxMethod) -> - io__write_string("((", !IO), - io__write_string(JavaBoxedName, !IO), - io__write_string(") ", !IO), + io.write_string("((", !IO), + io.write_string(JavaBoxedName, !IO), + io.write_string(") ", !IO), output_bracketed_rval(ModuleInfo, Exprn, ModuleName, !IO), - io__write_string(").", !IO), - io__write_string(UnboxMethod, !IO), - io__write_string("()", !IO) + io.write_string(").", !IO), + io.write_string(UnboxMethod, !IO), + io.write_string("()", !IO) ; - io__write_string("((", !IO), + io.write_string("((", !IO), output_type(Type, !IO), - io__write_string(") ", !IO), + io.write_string(") ", !IO), output_rval(ModuleInfo, Exprn, ModuleName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). % java_builtin_type(ModuleInfo, MLDS_Type, JavaUnboxedType, JavaBoxedType, @@ -3057,21 +3057,21 @@ output_unboxed_rval(ModuleInfo, Type, Exprn, ModuleName, !IO) :- string::out, string::out) is semidet. java_builtin_type(_, Type, "int", "java.lang.Integer", "intValue") :- - Type = mlds__native_int_type. + Type = mlds_native_int_type. java_builtin_type(_, Type, "int", "java.lang.Integer", "intValue") :- - Type = mlds__mercury_type(builtin(int), _, _). + Type = mercury_type(builtin(int), _, _). java_builtin_type(_, Type, "double", "java.lang.Double", "doubleValue") :- - Type = mlds__native_float_type. + Type = mlds_native_float_type. java_builtin_type(_, Type, "double", "java.lang.Double", "doubleValue") :- - Type = mlds__mercury_type(builtin(float), _, _). + Type = mercury_type(builtin(float), _, _). java_builtin_type(_, Type, "char", "java.lang.Character", "charValue") :- - Type = mlds__native_char_type. + Type = mlds_native_char_type. java_builtin_type(_, Type, "char", "java.lang.Character", "charValue") :- - Type = mlds__mercury_type(builtin(character), _, _). + Type = mercury_type(builtin(character), _, _). java_builtin_type(_, Type, "boolean", "java.lang.Boolean", "booleanValue") :- - Type = mlds__native_bool_type. + Type = mlds_native_bool_type. - % io__state and store__store(S) are dummy variables + % io.state and store.store(S) are dummy variables % for which we pass an arbitrary integer. For this % reason they should have the Java type `int'. % @@ -3079,10 +3079,10 @@ java_builtin_type(ModuleInfo, Type, "int", "java.lang.Integer", "intValue") :- % The test for defined/3 is logically redundant since all dummy % types are defined types, but enables the compiler to infer that % this disjunction is a switch. - Type = mlds__mercury_type(MercuryType @ defined(_, _, _), _, _), + Type = mercury_type(MercuryType @ defined(_, _, _), _, _), is_dummy_argument_type(ModuleInfo, MercuryType). -:- pred output_std_unop(module_info::in, builtin_ops__unary_op::in, +:- pred output_std_unop(module_info::in, builtin_ops.unary_op::in, mlds_rval::in, mlds_module_name::in, io::di, io::uo) is det. % For the Java back-end, there are no tags, so all the tagging operators @@ -3091,13 +3091,13 @@ java_builtin_type(ModuleInfo, Type, "int", "java.lang.Integer", "intValue") :- % output_std_unop(ModuleInfo, UnaryOp, Exprn, ModuleName, !IO) :- ( UnaryOp = tag -> - io__write_string("/* tag */ 0", !IO) + io.write_string("/* tag */ 0", !IO) ; - java_util__unary_prefix_op(UnaryOp, UnaryOpString), - io__write_string(UnaryOpString, !IO), - io__write_string("(", !IO), + java_unary_prefix_op(UnaryOp, UnaryOpString), + io.write_string(UnaryOpString, !IO), + io.write_string("(", !IO), output_rval(ModuleInfo, Exprn, ModuleName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred output_binop(module_info::in, binary_op::in, mlds_rval::in, @@ -3106,41 +3106,41 @@ output_std_unop(ModuleInfo, UnaryOp, Exprn, ModuleName, !IO) :- output_binop(ModuleInfo, Op, X, Y, ModuleName, !IO) :- ( Op = array_index(_Type) -> output_bracketed_rval(ModuleInfo, X, ModuleName, !IO), - io__write_string("[", !IO), + io.write_string("[", !IO), output_rval(ModuleInfo, Y, ModuleName, !IO), - io__write_string("]", !IO) - ; java_util__string_compare_op(Op, OpStr) -> - io__write_string("(", !IO), + io.write_string("]", !IO) + ; java_string_compare_op(Op, OpStr) -> + io.write_string("(", !IO), output_rval(ModuleInfo, X, ModuleName, !IO), - io__write_string(".compareTo(", !IO), + io.write_string(".compareTo(", !IO), output_rval(ModuleInfo, Y, ModuleName, !IO), - io__write_string(") ", !IO), - io__write_string(OpStr, !IO), - io__write_string(" 0)", !IO) + io.write_string(") ", !IO), + io.write_string(OpStr, !IO), + io.write_string(" 0)", !IO) ; - ( java_util__float_compare_op(Op, OpStr1) -> + ( java_float_compare_op(Op, OpStr1) -> OpStr = OpStr1 - ; java_util__float_op(Op, OpStr2) -> + ; java_float_op(Op, OpStr2) -> OpStr = OpStr2 ; fail ) -> - io__write_string("(", !IO), + io.write_string("(", !IO), output_rval_maybe_with_enum(ModuleInfo, X, ModuleName, !IO), - io__write_string(" ", !IO), - io__write_string(OpStr, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), + io.write_string(OpStr, !IO), + io.write_string(" ", !IO), output_rval_maybe_with_enum(ModuleInfo, Y, ModuleName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; - io__write_string("(", !IO), + io.write_string("(", !IO), output_rval_maybe_with_enum(ModuleInfo, X, ModuleName, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), output_binary_op(Op, !IO), - io__write_string(" ", !IO), + io.write_string(" ", !IO), output_rval_maybe_with_enum(ModuleInfo, Y, ModuleName, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). % Output an Rval and if the Rval is an enumeration object append the string @@ -3160,7 +3160,7 @@ output_binop(ModuleInfo, Op, X, Y, ModuleName, !IO) :- output_rval_maybe_with_enum(ModuleInfo, Rval, ModuleName, !IO) :- output_rval(ModuleInfo, Rval, ModuleName, !IO), ( rval_is_enum_object(Rval) -> - io__write_string(".value", !IO) + io.write_string(".value", !IO) ; true ). @@ -3168,8 +3168,8 @@ output_rval_maybe_with_enum(ModuleInfo, Rval, ModuleName, !IO) :- :- pred output_binary_op(binary_op::in, io::di, io::uo) is det. output_binary_op(Op, !IO) :- - ( java_util__binary_infix_op(Op, OpStr) -> - io__write_string(OpStr, !IO) + ( java_binary_infix_op(Op, OpStr) -> + io.write_string(OpStr, !IO) ; unexpected(this_file, "output_binary_op: invalid binary operator") @@ -3178,26 +3178,26 @@ output_binary_op(Op, !IO) :- :- pred output_rval_const(mlds_rval_const::in, io::di, io::uo) is det. output_rval_const(true, !IO) :- - io__write_string("true", !IO). + io.write_string("true", !IO). output_rval_const(false, !IO) :- - io__write_string("false", !IO). + io.write_string("false", !IO). output_rval_const(int_const(N), !IO) :- - io__write_int(N, !IO). + io.write_int(N, !IO). output_rval_const(float_const(FloatVal), !IO) :- - c_util__output_float_literal(FloatVal, !IO). + c_util.output_float_literal(FloatVal, !IO). output_rval_const(string_const(String), !IO) :- - io__write_string("""", !IO), - c_util__output_quoted_string(String, !IO), - io__write_string("""", !IO). + io.write_string("""", !IO), + c_util.output_quoted_string(String, !IO), + io.write_string("""", !IO). output_rval_const(multi_string_const(Length, String), !IO) :- - io__write_string("""", !IO), - c_util__output_quoted_multi_string(Length, String, !IO), - io__write_string("""", !IO). + io.write_string("""", !IO), + c_util.output_quoted_multi_string(Length, String, !IO), + io.write_string("""", !IO). output_rval_const(code_addr_const(CodeAddr), !IO) :- IsCall = no, @@ -3207,11 +3207,11 @@ output_rval_const(data_addr_const(DataAddr), !IO) :- mlds_output_data_addr(DataAddr, !IO). output_rval_const(null(_), !IO) :- - io__write_string("null", !IO). + io.write_string("null", !IO). %-----------------------------------------------------------------------------% -:- pred mlds_output_code_addr(mlds__code_addr::in, bool::in, io::di, +:- pred mlds_output_code_addr(mlds_code_addr::in, bool::in, io::di, io::uo) is det. mlds_output_code_addr(proc(Label, _Sig), IsCall, !IO) :- @@ -3219,9 +3219,9 @@ mlds_output_code_addr(proc(Label, _Sig), IsCall, !IO) :- IsCall = no, % Not a function call, so we are taking the address of the % wrapper for that function (method). - io__write_string("new AddrOf__", !IO), + io.write_string("new AddrOf__", !IO), output_fully_qualified_proc_label(Label, "__", !IO), - io__write_string("_0()", !IO) + io.write_string("_0()", !IO) ; IsCall = yes, output_fully_qualified_proc_label(Label, ".", !IO) @@ -3231,32 +3231,32 @@ mlds_output_code_addr(internal(Label, SeqNum, _Sig), IsCall, !IO) :- IsCall = no, % Not a function call, so we are taking the address of the % wrapper for that function (method). - io__write_string("new AddrOf__", !IO), + io.write_string("new AddrOf__", !IO), output_fully_qualified_proc_label(Label, "__", !IO), - io__write_string("_", !IO), - io__write_int(SeqNum, !IO), - io__write_string("_0()", !IO) + io.write_string("_", !IO), + io.write_int(SeqNum, !IO), + io.write_string("_0()", !IO) ; IsCall = yes, output_fully_qualified_proc_label(Label, ".", !IO), - io__write_string("_", !IO), - io__write_int(SeqNum, !IO) + io.write_string("_", !IO), + io.write_int(SeqNum, !IO) ). -:- pred mlds_output_proc_label(mlds__proc_label::in, io::di, io::uo) is det. +:- pred mlds_output_proc_label(mlds_proc_label::in, io::di, io::uo) is det. mlds_output_proc_label(PredLabel - ProcId, !IO) :- output_pred_label(PredLabel, !IO), proc_id_to_int(ProcId, ModeNum), - io__format("_%d", [i(ModeNum)], !IO). + io.format("_%d", [i(ModeNum)], !IO). -:- pred mlds_output_data_addr(mlds__data_addr::in, io::di, io::uo) is det. +:- pred mlds_output_data_addr(mlds_data_addr::in, io::di, io::uo) is det. mlds_output_data_addr(data_addr(ModuleQualifier, DataName), !IO) :- SymName = mlds_module_name_to_sym_name(ModuleQualifier), mangle_mlds_sym_name_for_java(SymName, module_qual, ".", ModuleName), - io__write_string(ModuleName, !IO), - io__write_string(".", !IO), + io.write_string(ModuleName, !IO), + io.write_string(".", !IO), output_data_name(DataName, !IO). %-----------------------------------------------------------------------------% @@ -3266,11 +3266,11 @@ mlds_output_data_addr(data_addr(ModuleQualifier, DataName), !IO) :- % since Java doesn't have an equivalent of #line directives.) % -:- pred output_context(mlds__context::in, io::di, io::uo) is det. +:- pred output_context(mlds_context::in, io::di, io::uo) is det. output_context(_Context, !IO). -:- pred indent_line(mlds__context::in, indent::in, io::di, io::uo) is det. +:- pred indent_line(mlds_context::in, indent::in, io::di, io::uo) is det. indent_line(Context, N, !IO) :- output_context(Context, !IO), @@ -3288,7 +3288,7 @@ indent_line(N, !IO) :- ( N =< 0 -> true ; - io__write_string(" ", !IO), + io.write_string(" ", !IO), indent_line(N - 1, !IO) ). diff --git a/compiler/mlds_to_managed.m b/compiler/mlds_to_managed.m index 03c4b995e..ab70fcd3d 100644 --- a/compiler/mlds_to_managed.m +++ b/compiler/mlds_to_managed.m @@ -165,7 +165,7 @@ generate_code(Lang, MLDS, !IO) :- :- pred output_language_specific_header_code( foreign_language::in(managed_lang), mercury_module_name::in, - mlds.imports::in, io::di, io::uo) is det. + mlds_imports::in, io::di, io::uo) is det. output_language_specific_header_code(csharp, _ModuleName, _Imports, !IO) :- get_il_data_rep(DataRep, !IO), @@ -259,10 +259,10 @@ output_language_specific_header_code(managed_cplusplus, ModuleName, Imports, ). :- pred generate_foreign_header_code(foreign_language::in(managed_lang), - module_name::in, mlds.foreign_code::in, io::di, io::uo) is det. + module_name::in, mlds_foreign_code::in, io::di, io::uo) is det. generate_foreign_header_code(Lang, ModuleName, ForeignCode, !IO) :- - ForeignCode = mlds.foreign_code(RevHeaderCode, RevImports, + ForeignCode = mlds_foreign_code(RevHeaderCode, RevImports, _RevBodyCode, _ExportDefns), % Only MC++ can declare which assemblies it refers to in its % source file. C# declares which assemblies it refers to via @@ -320,10 +320,10 @@ generate_namespace_details(Lang, ClassName, NameSpaceFmtStr, Namespace) :- ). :- pred generate_foreign_code(foreign_language::in(managed_lang), - mlds_module_name::in, mlds.foreign_code::in, io::di, io::uo) is det. + mlds_module_name::in, mlds_foreign_code::in, io::di, io::uo) is det. generate_foreign_code(Lang, _ModuleName, ForeignCode, !IO) :- - ForeignCode = mlds.foreign_code(_RevHeaderCode, _RevImports, + ForeignCode = mlds_foreign_code(_RevHeaderCode, _RevImports, RevBodyCode, _ExportDefns), BodyCode = list.reverse(RevBodyCode), io.write_list(BodyCode, "\n", @@ -340,23 +340,23 @@ generate_foreign_code(Lang, _ModuleName, ForeignCode, !IO) :- ), !IO). :- pred generate_method_code(foreign_language::in(managed_lang), - mlds_module_name::in, mlds.defn::in, io::di, io::uo) is det. + mlds_module_name::in, mlds_defn::in, io::di, io::uo) is det. -generate_method_code(_, _, defn(export(_), _, _, _), !IO). -generate_method_code(_, _, defn(data(_), _, _, _), !IO). -generate_method_code(_, _, defn(type(_, _), _, _, _), !IO). +generate_method_code(_, _, mlds_defn(export(_), _, _, _), !IO). +generate_method_code(_, _, mlds_defn(data(_), _, _, _), !IO). +generate_method_code(_, _, mlds_defn(type(_, _), _, _, _), !IO). generate_method_code(Lang, _ModuleName, Defn, !IO) :- - Defn = defn(function(PredLabel, ProcId, MaybeSeqNum, _PredId), + Defn = mlds_defn(function(PredLabel, ProcId, MaybeSeqNum, _PredId), _Context, _DeclFlags, Entity), ( % XXX we ignore the attributes - Entity = mlds.function(_, Params, defined_here(Statement), + Entity = mlds_function(_, Params, defined_here(Statement), _Attributes), has_foreign_languages(Statement, Langs), list.member(Lang, Langs) -> get_il_data_rep(DataRep, !IO), - Params = mlds.func_params(Inputs, Outputs), + Params = mlds_func_params(Inputs, Outputs), ( Outputs = [], ReturnType = void @@ -398,7 +398,7 @@ generate_method_code(Lang, _ModuleName, Defn, !IO) :- ). :- pred write_statement(foreign_language::in(managed_lang), - mlds.arguments::in, statement::in, io::di, io::uo) is det. + mlds_arguments::in, statement::in, io::di, io::uo) is det. write_statement(Lang, Args, statement(Statement, Context), !IO) :- ( @@ -407,7 +407,7 @@ write_statement(Lang, Args, statement(Statement, Context), !IO) :- _Lvals, Code)) -> list.foldl(write_outline_arg_init(Lang), OutlineArgs, !IO), - output_context(Lang, get_prog_context(Context), !IO), + output_context(Lang, mlds_get_prog_context(Context), !IO), io.write_string(Code, !IO), io.nl(!IO), output_reset_context(Lang, !IO), @@ -478,9 +478,10 @@ write_outline_arg_final(Lang, out(_Type, VarName, Lval), !IO) :- write_outline_arg_final(_Lang, unused, !IO). :- pred write_declare_and_assign_local(foreign_language::in(managed_lang), - mlds.argument::in, io::di, io::uo) is det. + mlds_argument::in, io::di, io::uo) is det. -write_declare_and_assign_local(Lang, argument(Name, Type, _GcCode), !IO) :- +write_declare_and_assign_local(Lang, mlds_argument(Name, Type, _GcCode), + !IO) :- ( Name = data(var(VarName0)) -> VarName = VarName0 ; @@ -488,7 +489,7 @@ write_declare_and_assign_local(Lang, argument(Name, Type, _GcCode), !IO) :- ), % A pointer type is an output type. - ( Type = mlds.ptr_type(OutputType) -> + ( Type = mlds_ptr_type(OutputType) -> ( is_anonymous_variable(VarName) -> true ; @@ -517,9 +518,9 @@ write_declare_and_assign_local(Lang, argument(Name, Type, _GcCode), !IO) :- ). :- pred write_assign_local_to_output(foreign_language::in(managed_lang), - mlds.argument::in, io::di, io::uo) is det. + mlds_argument::in, io::di, io::uo) is det. -write_assign_local_to_output(Lang, argument(Name, Type, _GcCode), !IO) :- +write_assign_local_to_output(Lang, mlds_argument(Name, Type, _GcCode), !IO) :- ( Name = data(var(VarName0)) -> VarName = VarName0 ; @@ -528,7 +529,7 @@ write_assign_local_to_output(Lang, argument(Name, Type, _GcCode), !IO) :- % A pointer type is an output type. ( - Type = mlds.ptr_type(_OutputType), + Type = mlds_ptr_type(_OutputType), not is_anonymous_variable(VarName) -> ( @@ -545,9 +546,9 @@ write_assign_local_to_output(Lang, argument(Name, Type, _GcCode), !IO) :- true ). -:- pred is_anonymous_variable(var_name::in) is semidet. +:- pred is_anonymous_variable(mlds_var_name::in) is semidet. -is_anonymous_variable(var_name(Name, _)) :- +is_anonymous_variable(mlds_var_name(Name, _)) :- string.prefix(Name, "_"). %-----------------------------------------------------------------------------% @@ -693,13 +694,13 @@ write_field_selector(csharp, !IO) :- write_field_selector(managed_cplusplus, !IO) :- io.write_string("->", !IO). -:- pred write_defn_decl(foreign_language::in(managed_lang), mlds.defn::in, +:- pred write_defn_decl(foreign_language::in(managed_lang), mlds_defn::in, io::di, io::uo) is det. write_defn_decl(Lang, Defn, !IO) :- - Defn = mlds.defn(Name, _Context, _Flags, DefnBody), + Defn = mlds_defn(Name, _Context, _Flags, DefnBody), ( - DefnBody = data(Type, _Initializer, _GC_TraceCode), + DefnBody = mlds_data(Type, _Initializer, _GC_TraceCode), Name = data(var(VarName)) -> write_parameter_type(Lang, Type, !IO), @@ -720,10 +721,10 @@ write_parameter_type(Lang, Type, !IO) :- write_il_type_as_foreign_type(Lang, ILType, !IO). :- pred write_input_arg_as_foreign_type(foreign_language::in(managed_lang), - mlds.argument::in, io::di, io::uo) is det. + mlds_argument::in, io::di, io::uo) is det. write_input_arg_as_foreign_type(Lang, Arg, !IO) :- - Arg = mlds.argument(EntityName, Type, _GC_TraceCode), + Arg = mlds_argument(EntityName, Type, _GC_TraceCode), get_il_data_rep(DataRep, !IO), write_il_type_as_foreign_type(Lang, mlds_type_to_ilds_type(DataRep, Type), !IO), @@ -978,16 +979,16 @@ write_class_name(Lang, structured_name(_Asm, DottedName, NestedClasses), ), io.write_list(DottedName ++ NestedClasses, Sep, io.write_string, !IO). -:- pred write_mlds_var_name_for_local(mlds.var_name::in, +:- pred write_mlds_var_name_for_local(mlds_var_name::in, io::di, io::uo) is det. -write_mlds_var_name_for_local(var_name(Name, _MaybeNum), !IO) :- +write_mlds_var_name_for_local(mlds_var_name(Name, _MaybeNum), !IO) :- io.write_string(Name, !IO). -:- pred write_mlds_var_name_for_parameter(mlds.var_name::in, +:- pred write_mlds_var_name_for_parameter(mlds_var_name::in, io::di, io::uo) is det. -write_mlds_var_name_for_parameter(var_name(Name, MaybeNum), !IO) :- +write_mlds_var_name_for_parameter(mlds_var_name(Name, MaybeNum), !IO) :- io.write_string(Name, !IO), ( MaybeNum = yes(Num), diff --git a/compiler/mmc_analysis.m b/compiler/mmc_analysis.m index 578e7f0d5..da59dd24e 100644 --- a/compiler/mmc_analysis.m +++ b/compiler/mmc_analysis.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__mmc_analysis. +:- module transform_hlds.mmc_analysis. :- interface. :- import_module analysis. @@ -25,7 +25,8 @@ %-----------------------------------------------------------------------------% -:- type mmc ---> mmc. +:- type mmc + ---> mmc. :- instance compiler(mmc). @@ -36,7 +37,7 @@ proc_id) = func_id. :- pred module_id_func_id(module_info::in, pred_proc_id::in, - module_id::out, func_id::out) is det. + module_id::out, func_id::out) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -115,7 +116,7 @@ mmc_module_id_to_write_file_name(ModuleId, Ext, FileName, !IO) :- :- pred mmc_module_is_local(module_id::in, bool::out, io::di, io::uo) is det. mmc_module_is_local(ModuleId, IsLocal, !IO) :- - globals__io_lookup_accumulating_option(local_module_id, LocalModuleIds, + globals.io_lookup_accumulating_option(local_module_id, LocalModuleIds, !IO), IsLocal = (if ModuleId `list.member` LocalModuleIds then yes else no). @@ -126,8 +127,7 @@ module_id_to_module_name(ModuleId) = ModuleName :- string_to_sym_name(ModuleId, ".", ModuleName). pred_or_func_name_arity_to_func_id(PredOrFunc, Name, Arity, ProcId) = FuncId :- - FuncId0 = simple_call_id_to_string(PredOrFunc - - unqualified(Name)/Arity), + FuncId0 = simple_call_id_to_string(PredOrFunc - unqualified(Name)/Arity), proc_id_to_int(ProcId, ProcInt), FuncId = FuncId0 ++ "-" ++ int_to_string(ProcInt). diff --git a/compiler/mode_constraints.m b/compiler/mode_constraints.m index a0135d804..f025dd8bd 100644 --- a/compiler/mode_constraints.m +++ b/compiler/mode_constraints.m @@ -296,7 +296,7 @@ number_robdd_variables_in_pred(PredId, !ModuleInfo, !MCI) :- % `OmitModeEquivPrefix = yes' to `goal_path.fill_slots_in_clauses'. OmitModeEquivPrefix = yes, - goal_path.fill_slots_in_clauses(!.ModuleInfo, OmitModeEquivPrefix, + fill_goal_path_slots_in_clauses(!.ModuleInfo, OmitModeEquivPrefix, PredInfo0, PredInfo1), pred_info_clauses_info(PredInfo1, ClausesInfo0), @@ -422,7 +422,7 @@ number_robdd_variables_in_rhs(InstGraph, GoalPath, Vars, !RHS, !NRInfo) :- Vars = LambdaNonLocals, VarTypes = !.NRInfo ^ vartypes, ModuleInfo = !.NRInfo ^ module_info, - goal_path.fill_slots_in_goal(LambdaGoal0, VarTypes, ModuleInfo, + fill_goal_path_slots_in_goal(LambdaGoal0, VarTypes, ModuleInfo, LambdaGoal1), update_mc_info(enter_lambda_goal(GoalPath), !NRInfo), diff --git a/compiler/mode_info.m b/compiler/mode_info.m index c4c754014..2382bbe55 100644 --- a/compiler/mode_info.m +++ b/compiler/mode_info.m @@ -430,7 +430,7 @@ mode_info_init(ModuleInfo, PredId, ProcId, Context, LiveVars, InstMapping0, instmap.init_unreachable(Unreachable), mode_context_init(ModeContext), LockedVars = [], - delay_info.init(DelayInfo), + delay_info_init(DelayInfo), ErrorList = [], WarningList = [], % look up the varset and var types @@ -560,7 +560,7 @@ mode_info_set_instmap(InstMap, !MI) :- instmap.is_reachable(InstMap0) -> DelayInfo0 = !.MI ^ delay_info, - delay_info.bind_all_vars(DelayInfo0, DelayInfo), + delay_info_bind_all_vars(DelayInfo0, DelayInfo), !:MI = !.MI ^ delay_info := DelayInfo ; true @@ -599,11 +599,11 @@ mode_info_remove_live_vars(OldLiveVars, !MI) :- svbag.det_remove_set(OldLiveVars, NondetLiveVars0, NondetLiveVars), !:MI = !.MI ^ live_vars := LiveVars, !:MI = !.MI ^ nondet_live_vars := NondetLiveVars, - % when a variable becomes dead, we may be able to wake - % up a goal which is waiting on that variable + % When a variable becomes dead, we may be able to wake up a goal + % which is waiting on that variable set.to_sorted_list(OldLiveVars, VarList), DelayInfo0 = !.MI ^ delay_info, - delay_info.bind_var_list(VarList, DelayInfo0, DelayInfo), + delay_info_bind_var_list(VarList, DelayInfo0, DelayInfo), !:MI = !.MI ^ delay_info := DelayInfo. % Check whether a list of variables are live or not diff --git a/compiler/modes.m b/compiler/modes.m index ba785429b..0767a2e84 100644 --- a/compiler/modes.m +++ b/compiler/modes.m @@ -1436,11 +1436,11 @@ modecheck_goal_expr(not(SubGoal0), GoalInfo0, not(SubGoal), !ModeInfo, !IO) :- modecheck_goal_expr(scope(Reason, SubGoal0), _GoalInfo, GoalExpr, !ModeInfo, !IO) :- ( Reason = from_ground_term(TermVar) -> - % The original goal does no quantification, so deleting - % the `scope' is OK, and it is necessary for avoiding - % bad performance in later compiler phases, such as - % simplification. This deletion undoes the insertion - % done in the base case of unravel_unification in make_hlds.m. + % The original goal does no quantification, so deleting the `scope' + % is OK, and it is necessary for avoiding bad performance in + % later compiler phases, such as simplification. This deletion + % undoes the insertion done in the base case of unravel_unification + % in superhomogeneous.m. ( mode_info_get_instmap(!.ModeInfo, InstMap0), instmap.lookup_var(InstMap0, TermVar, InstOfVar), @@ -1944,7 +1944,7 @@ modecheck_conj_list(Goals0, Goals, !ModeInfo, !IO) :- mode_info_get_may_initialise_solver_vars(MayInitEntryValue, !.ModeInfo), mode_info_get_delay_info(!.ModeInfo, DelayInfo0), - delay_info.enter_conj(DelayInfo0, DelayInfo1), + delay_info_enter_conj(DelayInfo0, DelayInfo1), mode_info_set_delay_info(DelayInfo1, !ModeInfo), mode_info_get_live_vars(!.ModeInfo, LiveVars1), @@ -1959,7 +1959,7 @@ modecheck_conj_list(Goals0, Goals, !ModeInfo, !IO) :- [], RevImpurityErrors0, !ModeInfo, !IO), mode_info_get_delay_info(!.ModeInfo, DelayInfo2), - delay_info.leave_conj(DelayInfo2, DelayedGoals0, DelayInfo3), + delay_info_leave_conj(DelayInfo2, DelayedGoals0, DelayInfo3), mode_info_set_delay_info(DelayInfo3, !ModeInfo), % Otherwise try scheduling by inserting solver @@ -2102,7 +2102,7 @@ modecheck_conj_list_3(Goal0, Goals0, Goals, !ImpurityErrors, !ModeInfo, !IO) :- mode_info_set_errors([], !ModeInfo), mode_info_set_instmap(InstMap0, !ModeInfo), mode_info_add_live_vars(NonLocalVars, !ModeInfo), - delay_info.delay_goal(DelayInfo0, FirstErrorInfo, Goal0, DelayInfo1), + delay_info_delay_goal(DelayInfo0, FirstErrorInfo, Goal0, DelayInfo1), % delaying an impure goal is an impurity error ( Impure = yes, @@ -2125,7 +2125,7 @@ modecheck_conj_list_3(Goal0, Goals0, Goals, !ImpurityErrors, !ModeInfo, !IO) :- % Next, we attempt to wake up any pending goals, % and then continue scheduling the rest of the goal. - delay_info.wakeup_goals(WokenGoals, DelayInfo1, DelayInfo), + delay_info_wakeup_goals(WokenGoals, DelayInfo1, DelayInfo), list.append(WokenGoals, Goals0, Goals1), ( WokenGoals = [] @@ -2288,7 +2288,7 @@ modecheck_delayed_goals_try_det(DelayedGoals0, DelayedGoals, Goals, Goals1 = InitGoals ++ Goals0, mode_info_get_delay_info(!.ModeInfo, DelayInfo0), - delay_info.enter_conj(DelayInfo0, DelayInfo1), + delay_info_enter_conj(DelayInfo0, DelayInfo1), mode_info_set_delay_info(DelayInfo1, !ModeInfo), mode_info_add_goals_live_vars(InitGoals, !ModeInfo), @@ -2297,7 +2297,7 @@ modecheck_delayed_goals_try_det(DelayedGoals0, DelayedGoals, Goals, !IO), mode_info_get_delay_info(!.ModeInfo, DelayInfo2), - delay_info.leave_conj(DelayInfo2, DelayedGoals, DelayInfo3), + delay_info_leave_conj(DelayInfo2, DelayedGoals, DelayInfo3), mode_info_set_delay_info(DelayInfo3, !ModeInfo) ; % We couldn't identify a deterministic solution. @@ -2569,7 +2569,7 @@ modecheck_delayed_goals_eager(DelayedGoals0, DelayedGoals, Goals, Goals0 = list.map(hlds_goal_from_delayed_goal, DelayedGoals0), mode_info_get_delay_info(!.ModeInfo, DelayInfo0), - delay_info.enter_conj(DelayInfo0, DelayInfo1), + delay_info_enter_conj(DelayInfo0, DelayInfo1), mode_info_set_delay_info(DelayInfo1, !ModeInfo), mode_info_set_may_initialise_solver_vars(yes, !ModeInfo), @@ -2578,7 +2578,7 @@ modecheck_delayed_goals_eager(DelayedGoals0, DelayedGoals, Goals, mode_info_set_may_initialise_solver_vars(no, !ModeInfo), mode_info_get_delay_info(!.ModeInfo, DelayInfo2), - delay_info.leave_conj(DelayInfo2, DelayedGoals1, DelayInfo3), + delay_info_leave_conj(DelayInfo2, DelayedGoals1, DelayInfo3), mode_info_set_delay_info(DelayInfo3, !ModeInfo), % See if we scheduled any goals. @@ -2618,7 +2618,7 @@ hlds_goal_from_delayed_goal(delayed_goal(_WaitingVars, _ModeError, Goal)) = check_for_impurity_error(Goal, Goals, !ImpurityErrors, !ModeInfo, !IO) :- mode_info_get_delay_info(!.ModeInfo, DelayInfo0), - delay_info.leave_conj(DelayInfo0, DelayedGoals0, DelayInfo1), + delay_info_leave_conj(DelayInfo0, DelayedGoals0, DelayInfo1), mode_info_set_delay_info(DelayInfo1, !ModeInfo), mode_info_get_module_info(!.ModeInfo, ModuleInfo), mode_info_get_predid(!.ModeInfo, PredId), @@ -2631,7 +2631,7 @@ check_for_impurity_error(Goal, Goals, !ImpurityErrors, !ModeInfo, !IO) :- NonHeadVarUnificationGoals0, NonHeadVarUnificationGoals, !ImpurityErrors, !ModeInfo, !IO), mode_info_get_delay_info(!.ModeInfo, DelayInfo2), - delay_info.enter_conj(DelayInfo2, DelayInfo3), + delay_info_enter_conj(DelayInfo2, DelayInfo3), redelay_goals(HeadVarUnificationGoals, DelayInfo3, DelayInfo), mode_info_set_delay_info(DelayInfo, !ModeInfo), ( @@ -2691,7 +2691,7 @@ get_all_waiting_vars_2([delayed_goal(Vars1, _, _) | Rest], Vars0, Vars) :- redelay_goals([], DelayInfo, DelayInfo). redelay_goals([DelayedGoal | DelayedGoals], DelayInfo0, DelayInfo) :- DelayedGoal = delayed_goal(_WaitingVars, ModeErrorInfo, Goal), - delay_info.delay_goal(DelayInfo0, ModeErrorInfo, Goal, DelayInfo1), + delay_info_delay_goal(DelayInfo0, ModeErrorInfo, Goal, DelayInfo1), redelay_goals(DelayedGoals, DelayInfo1, DelayInfo). %-----------------------------------------------------------------------------% @@ -3038,7 +3038,7 @@ modecheck_set_var_inst(Var0, FinalInst, MaybeUInst, !ModeInfo) :- instmap.set(Var0, Inst, InstMap0, InstMap), mode_info_set_instmap(InstMap, !ModeInfo), mode_info_get_delay_info(!.ModeInfo, DelayInfo0), - delay_info.bind_var(Var0, DelayInfo0, DelayInfo), + delay_info_bind_var(Var0, DelayInfo0, DelayInfo), mode_info_set_delay_info(DelayInfo, !ModeInfo) ) ; diff --git a/compiler/modules.m b/compiler/modules.m index 7f437aad9..265987b33 100644 --- a/compiler/modules.m +++ b/compiler/modules.m @@ -38,7 +38,7 @@ % %-----------------------------------------------------------------------------% -:- module parse_tree__modules. +:- module parse_tree.modules. :- interface. :- import_module libs.globals. @@ -729,7 +729,7 @@ % % XXX This belongs in the standard library. % -:- pred copy_file(file_name::in, file_name::in, io__res::out, +:- pred copy_file(file_name::in, file_name::in, io.res::out, io::di, io::uo) is det. % make_symlink_or_copy_file(LinkTarget, LinkName, Succeeded): @@ -845,17 +845,17 @@ module_name_to_file_name(ModuleName, Ext, MkDir, FileName, !IO) :- module_name_to_file_name(ModuleName, Ext, Search, MkDir, FileName, !IO) :- ( Ext = ".m" -> % Look up the module in the module->file mapping. - source_file_map__lookup_module_source_file(ModuleName, FileName, !IO) + source_file_map.lookup_module_source_file(ModuleName, FileName, !IO) ; sym_name_to_string(ModuleName, ".", BaseFileName), - string__append(BaseFileName, Ext, BaseName), + string.append(BaseFileName, Ext, BaseName), choose_file_name(ModuleName, BaseName, Ext, Search, MkDir, FileName, !IO) ). module_name_to_lib_file_name(Prefix, ModuleName, Ext, MkDir, FileName, !IO) :- sym_name_to_string(ModuleName, ".", BaseFileName), - string__append_list([Prefix, BaseFileName, Ext], BaseName), + string.append_list([Prefix, BaseFileName, Ext], BaseName), choose_file_name(ModuleName, BaseName, Ext, no, MkDir, FileName, !IO). fact_table_file_name(ModuleName, FactTableFileName, Ext, MkDir, FileName, @@ -874,16 +874,16 @@ fact_table_file_name(ModuleName, FactTableFileName, Ext, MkDir, FileName, extra_link_obj_file_name(ModuleName, ExtraLinkObjName, Ext, MkDir, FileName, !IO) :- - string__append(ExtraLinkObjName, Ext, BaseName), + string.append(ExtraLinkObjName, Ext, BaseName), choose_file_name(ModuleName, BaseName, Ext, no, MkDir, FileName, !IO). :- pred choose_file_name(module_name::in, string::in, string::in, bool::in, bool::in, file_name::out, io::di, io::uo) is det. choose_file_name(_ModuleName, BaseName, Ext, Search, MkDir, FileName, !IO) :- - globals__io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), + globals.io_get_globals(Globals, !IO), ( ( UseSubdirs = no @@ -983,8 +983,8 @@ choose_file_name(_ModuleName, BaseName, Ext, Search, MkDir, FileName, !IO) :- ) ; % output files intended for use by the user - ( string__prefix(Ext, ".c_dump") - ; string__prefix(Ext, ".mih_dump") + ( string.prefix(Ext, ".c_dump") + ; string.prefix(Ext, ".mih_dump") ) ) -> @@ -1020,16 +1020,16 @@ choose_file_name(_ModuleName, BaseName, Ext, Search, MkDir, FileName, !IO) :- ; % _init.c, _init.s, _init.o etc. files % go in the cs, ss, os etc. subdirectories - string__append("_init.", ExtName, Ext) + string.append("_init.", ExtName, Ext) -> - string__append(ExtName, "s", SubDirName) + string.append(ExtName, "s", SubDirName) ; % .int.tmp, .opt.tmp, etc. files % need to go in the ints, opts, etc. subdirectories - string__append(".", ExtName0, Ext), - string__remove_suffix(ExtName0, ".tmp", ExtName) + string.append(".", ExtName0, Ext), + string.remove_suffix(ExtName0, ".tmp", ExtName) -> - string__append(ExtName, "s", SubDirName) + string.append(ExtName, "s", SubDirName) ; % `.dv' files go in the `deps' subdirectory, % along with the `.dep' files @@ -1039,15 +1039,15 @@ choose_file_name(_ModuleName, BaseName, Ext, Search, MkDir, FileName, !IO) :- ; % the usual case: `*.foo' files go in the `foos' % subdirectory - string__append(".", ExtName, Ext) + string.append(".", ExtName, Ext) -> - string__append(ExtName, "s", SubDirName) + string.append(ExtName, "s", SubDirName) ; Ext = "" -> SubDirName = "bin" ; - string__append_list(["unknown extension `", Ext, "'"], ErrorMsg), + string.append_list(["unknown extension `", Ext, "'"], ErrorMsg), unexpected(this_file, ErrorMsg) ), make_file_name(SubDirName, Search, MkDir, BaseName, Ext, FileName, !IO) @@ -1063,11 +1063,11 @@ module_name_to_make_var_name(ModuleName, MakeVarName) :- sym_name_to_string(ModuleName, ".", MakeVarName). maybe_make_symlink(LinkTarget, LinkName, Result, !IO) :- - globals__io_lookup_bool_option(use_symlinks, UseSymLinks, !IO), + globals.io_lookup_bool_option(use_symlinks, UseSymLinks, !IO), ( UseSymLinks = yes, - io__remove_file(LinkName, _, !IO), - io__make_symlink(LinkTarget, LinkName, LinkResult, !IO), + io.remove_file(LinkName, _, !IO), + io.make_symlink(LinkTarget, LinkName, LinkResult, !IO), Result = ( if LinkResult = ok then yes else no ) ; UseSymLinks = no, @@ -1076,27 +1076,27 @@ maybe_make_symlink(LinkTarget, LinkName, Result, !IO) :- copy_file(Source, Destination, Res, !IO) :- % Try to use the system's cp command in order to preserve metadata. - globals__io_lookup_string_option(install_command, InstallCommand, !IO), - Command = string__join_list(" ", list__map(quote_arg, + globals.io_lookup_string_option(install_command, InstallCommand, !IO), + Command = string.join_list(" ", list.map(quote_arg, [InstallCommand, Source, Destination])), - io__output_stream(OutputStream, !IO), + io.output_stream(OutputStream, !IO), invoke_system_command(OutputStream, verbose, Command, Succeeded, !IO), ( Succeeded = yes, Res = ok ; Succeeded = no, - io__open_binary_input(Source, SourceRes, !IO), + io.open_binary_input(Source, SourceRes, !IO), ( SourceRes = ok(SourceStream), - io__open_binary_output(Destination, DestRes, !IO), + io.open_binary_output(Destination, DestRes, !IO), ( DestRes = ok(DestStream), - WriteByte = io__write_byte(DestStream), - io__binary_input_stream_foldl_io(SourceStream, WriteByte, Res, + WriteByte = io.write_byte(DestStream), + io.binary_input_stream_foldl_io(SourceStream, WriteByte, Res, !IO), - io__close_binary_input(SourceStream, !IO), - io__close_binary_output(DestStream, !IO) + io.close_binary_input(SourceStream, !IO), + io.close_binary_output(DestStream, !IO) ; DestRes = error(Error), Res = error(Error) @@ -1109,11 +1109,11 @@ copy_file(Source, Destination, Res, !IO) :- make_symlink_or_copy_file(SourceFileName, DestinationFileName, Succeeded, !IO) :- - globals__io_lookup_bool_option(use_symlinks, UseSymLinks, !IO), + globals.io_lookup_bool_option(use_symlinks, UseSymLinks, !IO), ( UseSymLinks = yes, LinkOrCopy = "linking", - io__make_symlink(SourceFileName, DestinationFileName, Result, !IO) + io.make_symlink(SourceFileName, DestinationFileName, Result, !IO) ; UseSymLinks = no, LinkOrCopy = "copying", @@ -1125,27 +1125,27 @@ make_symlink_or_copy_file(SourceFileName, DestinationFileName, Succeeded, ; Result = error(Error), Succeeded = no, - io__progname_base("mercury_compile", ProgName, !IO), - io__write_string(ProgName, !IO), - io__write_string(": error ", !IO), - io__write_string(LinkOrCopy, !IO), - io__write_string(" `", !IO), - io__write_string(SourceFileName, !IO), - io__write_string("' to `", !IO), - io__write_string(DestinationFileName, !IO), - io__write_string("': ", !IO), - io__write_string(io__error_message(Error), !IO), - io__nl(!IO), - io__flush_output(!IO) + io.progname_base("mercury_compile", ProgName, !IO), + io.write_string(ProgName, !IO), + io.write_string(": error ", !IO), + io.write_string(LinkOrCopy, !IO), + io.write_string(" `", !IO), + io.write_string(SourceFileName, !IO), + io.write_string("' to `", !IO), + io.write_string(DestinationFileName, !IO), + io.write_string("': ", !IO), + io.write_string(io.error_message(Error), !IO), + io.nl(!IO), + io.flush_output(!IO) ). :- pred make_file_name(dir_name::in, bool::in, bool::in, file_name::in, string::in, file_name::out, io::di, io::uo) is det. make_file_name(SubDirName, Search, MkDir, BaseName, Ext, FileName, !IO) :- - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), - globals__io_lookup_string_option(fullarch, FullArch, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), + globals.io_lookup_string_option(fullarch, FullArch, !IO), + globals.io_get_globals(Globals, !IO), ( UseGradeSubdirs = yes, file_is_arch_or_grade_dependent(Globals, Ext), @@ -1190,29 +1190,29 @@ make_file_name(SubDirName, Search, MkDir, BaseName, Ext, FileName, !IO) :- file_is_arch_or_grade_dependent(_, Ext) :- file_is_arch_or_grade_dependent_2(Ext). file_is_arch_or_grade_dependent(Globals, Ext0) :- - string__append(Ext, ".tmp", Ext0), % for mercury_update_interface. + string.append(Ext, ".tmp", Ext0), % for mercury_update_interface. file_is_arch_or_grade_dependent(Globals, Ext). file_is_arch_or_grade_dependent(Globals, Ext) :- - globals__lookup_string_option(Globals, executable_file_extension, Ext). + globals.lookup_string_option(Globals, executable_file_extension, Ext). file_is_arch_or_grade_dependent(Globals, Ext) :- ( - globals__lookup_string_option(Globals, + globals.lookup_string_option(Globals, object_file_extension, ObjExt) ; - globals__lookup_string_option(Globals, + globals.lookup_string_option(Globals, pic_object_file_extension, ObjExt) ; - globals__lookup_string_option(Globals, + globals.lookup_string_option(Globals, link_with_pic_object_file_extension, ObjExt) ), ( Ext = ObjExt ; Ext = "_init" ++ ObjExt ). file_is_arch_or_grade_dependent(Globals, Ext) :- - globals__lookup_string_option(Globals, library_extension, LibExt), + globals.lookup_string_option(Globals, library_extension, LibExt), Ext = LibExt. file_is_arch_or_grade_dependent(Globals, Ext) :- - globals__lookup_string_option(Globals, shared_library_extension, Ext). + globals.lookup_string_option(Globals, shared_library_extension, Ext). :- pred file_is_arch_or_grade_dependent_2(string::in) is semidet. @@ -1266,19 +1266,19 @@ make_private_interface(SourceFileName, SourceFileModuleName, ModuleName, % XXX zs: why does this code not check for fatal_module_errors? ( Error = some_module_errors -> module_name_to_file_name(ModuleName, ".int0", no, FileName, !IO), - io__write_strings(["Error reading interface files.\n", + io.write_strings(["Error reading interface files.\n", "`", FileName, "' not written.\n"], !IO) ; % % Module-qualify all items. % module_imports_get_items(Module, Items1), - module_qual__module_qualify_items(Items1, Items2, ModuleName, yes, + module_qual.module_qualify_items(Items1, Items2, ModuleName, yes, _, _, _, _, !IO), - io__get_exit_status(Status, !IO), + io.get_exit_status(Status, !IO), ( Status \= 0 -> module_name_to_file_name(ModuleName, ".int0", no, FileName, !IO), - io__write_strings(["`", FileName, "' not written.\n"], !IO) + io.write_strings(["`", FileName, "' not written.\n"], !IO) ; % % Write out the `.int0' file. @@ -1378,20 +1378,20 @@ make_interface(SourceFileName, SourceFileModuleName, ModuleName, module_name_to_file_name(ModuleName, ".int", no, IntFileName, !IO), module_name_to_file_name(ModuleName, ".int2", no, Int2FileName, !IO), - io__write_strings(["Error reading short interface files.\n", + io.write_strings(["Error reading short interface files.\n", "`", IntFileName, "' and ", "`", Int2FileName, "' not written.\n"], !IO) ; % % Module-qualify all items. % - module_qual__module_qualify_items(!InterfaceItems, ModuleName, yes, + module_qual.module_qualify_items(!InterfaceItems, ModuleName, yes, _, _, _, _, !IO), - io__get_exit_status(Status, !IO), + io.get_exit_status(Status, !IO), ( Status \= 0 -> module_name_to_file_name(ModuleName, ".int", no, IntFileName, !IO), - io__write_strings(["`", IntFileName, "' ", "not written.\n"], + io.write_strings(["`", IntFileName, "' ", "not written.\n"], !IO) ; % @@ -1427,7 +1427,7 @@ make_short_interface(SourceFileName, ModuleName, Items0, !IO) :- strip_assertions(InterfaceItems0, InterfaceItems1), check_for_clauses_in_interface(InterfaceItems1, InterfaceItems, !IO), get_short_interface(InterfaceItems, int3, ShortInterfaceItems0), - module_qual__module_qualify_items(ShortInterfaceItems0, + module_qual.module_qualify_items(ShortInterfaceItems0, ShortInterfaceItems, ModuleName, no, _, _, _, _, !IO), write_interface_file(SourceFileName, ModuleName, ".int3", no, ShortInterfaceItems, !IO), @@ -1442,14 +1442,14 @@ strip_imported_items(Items0, Items) :- is det. strip_imported_items([], !Items) :- - list__reverse(!Items). + list.reverse(!Items). strip_imported_items([Item - Context | Rest], !Items) :- ( Item = module_defn(_, imported(_)) -> - list__reverse(!Items) + list.reverse(!Items) ; Item = module_defn(_, used(_)) -> - list__reverse(!Items) + list.reverse(!Items) ; Item = module_defn(_, abstract_imported) -> - list__reverse(!Items) + list.reverse(!Items) ; strip_imported_items(Rest, [Item - Context | !.Items], !:Items) ). @@ -1483,7 +1483,7 @@ strip_unnecessary_impl_defns(Items0, Items) :- strip_unnecessary_impl_defns_2(Items0, Items) :- some [!IntTypesMap, !ImplTypesMap, !ImplItems] ( gather_type_defns(no, Items0, [], IntItems0, [], !:ImplItems, - map__init, !:IntTypesMap, map__init, !:ImplTypesMap), + map.init, !:IntTypesMap, map.init, !:ImplTypesMap), % Work out which module imports in the implementation section of % the interface are required by the definitions of equivalence @@ -1494,30 +1494,30 @@ strip_unnecessary_impl_defns_2(Items0, Items) :- % If a type in the implementation section isn't dummy and doesn't have % foreign type alternatives, make it abstract. - map__map_values(make_impl_type_abstract, !ImplTypesMap), + map.map_values(make_impl_type_abstract, !ImplTypesMap), % If there is an exported type declaration for a type with an abstract % declaration in the implementation (usually it will originally % have been a d.u. type), remove the declaration in the implementation. unsorted_aggregate( (pred(TypeCtor::out) is nondet :- - map__member(!.ImplTypesMap, TypeCtor, Defns), + map.member(!.ImplTypesMap, TypeCtor, Defns), \+ ( - list__member(Defn, Defns), + list.member(Defn, Defns), Defn \= abstract_type(_) - _ ), - multi_map__contains(!.IntTypesMap, TypeCtor) + multi_map.contains(!.IntTypesMap, TypeCtor) ), (pred(TypeCtor::in, !.ImplTypesMap::in, !:ImplTypesMap::out) is det :- - multi_map__delete(!.ImplTypesMap, TypeCtor, !:ImplTypesMap) + multi_map.delete(!.ImplTypesMap, TypeCtor, !:ImplTypesMap) ), !ImplTypesMap), - map__foldl( + map.foldl( (pred(_::in, Defns::in, !.ImplItems::in, !:ImplItems::out) is det :- - list__foldl( + list.foldl( (pred((_ - Item)::in, !.ImplItems::in, !:ImplItems::out) is det :- !:ImplItems = [Item | !.ImplItems] @@ -1717,8 +1717,8 @@ insert_type_defn(Context, Item, [Head | Tail], Result) :- CompareSymName = (<) ; CompareSymName = (=), - list__length(Params, ParamsLength), - list__length(HeadParams, HeadParamsLength), + list.length(Params, ParamsLength), + list.length(HeadParams, HeadParamsLength), compare(Compare, ParamsLength, HeadParamsLength), Compare = (<) ) @@ -1856,12 +1856,12 @@ accumulate_abs_impl_exported_type_lhs(InterfaceTypeMap, % ( TypeDefn = eqv_type(_RhsType), - map__search(InterfaceTypeMap, TypeCtor, _) + map.search(InterfaceTypeMap, TypeCtor, _) -> svset.insert(TypeCtor, !AbsEqvLhsTypeCtors) ; TypeDefn = foreign_type(_, _, _), - map__search(InterfaceTypeMap, TypeCtor, _) + map.search(InterfaceTypeMap, TypeCtor, _) -> svset.insert(TypeCtor, !AbsEqvLhsTypeCtors) ; @@ -2005,7 +2005,7 @@ gather_type_defns(!.InInterface, [Item - Context | ItemContexts], type_defn_map::in, type_defn_map::out) is det. gather_type_defn(TypeCtor, Body, Item, DefnMap0, DefnMap) :- - multi_map__set(DefnMap0, TypeCtor, Body - Item, DefnMap). + multi_map.set(DefnMap0, TypeCtor, Body - Item, DefnMap). %-----------------------------------------------------------------------------% @@ -2124,7 +2124,7 @@ pragma_allowed_in_interface(structure_sharing(_, _, _, _, _, _), yes). pragma_allowed_in_interface(mode_check_clauses(_, _), yes). check_for_no_exports(Items, ModuleName, !IO) :- - globals__io_lookup_bool_option(warn_nothing_exported, ExportWarning, !IO), + globals.io_lookup_bool_option(warn_nothing_exported, ExportWarning, !IO), ( ExportWarning = no ; @@ -2161,7 +2161,7 @@ check_int_for_no_exports([Item - _Context | Items], ModuleName, !IO) :- :- pred warn_no_exports(module_name::in, io::di, io::uo) is det. warn_no_exports(ModuleName, !IO) :- - globals__io_lookup_bool_option(warn_nothing_exported, ExportWarning, !IO), + globals.io_lookup_bool_option(warn_nothing_exported, ExportWarning, !IO), ( ExportWarning = yes, module_name_to_file_name(ModuleName, ".m", no, FileName, !IO), @@ -2169,7 +2169,7 @@ warn_no_exports(ModuleName, !IO) :- [words("Warning: interface for module"), sym_name(ModuleName), words("does not export anything.")], !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, report_warning(context_init(FileName, 1), 0, @@ -2200,15 +2200,15 @@ write_interface_file(_SourceFileName, ModuleName, Suffix, MaybeTimestamp, InterfaceItems0, !IO) :- % Create (e.g.) `foo.int.tmp'. - string__append(Suffix, ".tmp", TmpSuffix), + string.append(Suffix, ".tmp", TmpSuffix), module_name_to_file_name(ModuleName, Suffix, yes, OutputFileName, !IO), module_name_to_file_name(ModuleName, TmpSuffix, no, TmpOutputFileName, !IO), - globals__io_lookup_bool_option(line_numbers, LineNumbers, !IO), - globals__io_set_option(line_numbers, bool(no), !IO), + globals.io_lookup_bool_option(line_numbers, LineNumbers, !IO), + globals.io_set_option(line_numbers, bool(no), !IO), - globals__io_lookup_bool_option(generate_item_version_numbers, + globals.io_lookup_bool_option(generate_item_version_numbers, GenerateVersionNumbers, !IO), ( @@ -2229,11 +2229,11 @@ write_interface_file(_SourceFileName, ModuleName, Suffix, MaybeTimestamp, % modification time of the source file. MaybeOldItems = no ), - recompilation__version__compute_version_numbers(Timestamp, + recompilation.version.compute_version_numbers(Timestamp, InterfaceItems0, MaybeOldItems, VersionNumbers), - VersionNumberItem = module_defn(varset__init, + VersionNumberItem = module_defn(varset.init, version_numbers(ModuleName, VersionNumbers)) - - term__context_init, + - term.context_init, ( InterfaceItems0 = [FirstItem | InterfaceItems1], FirstItem = module_defn(_, interface) - _ @@ -2254,7 +2254,7 @@ write_interface_file(_SourceFileName, ModuleName, Suffix, MaybeTimestamp, InterfaceItems = InterfaceItems0 ), convert_to_mercury(ModuleName, TmpOutputFileName, InterfaceItems, !IO), - globals__io_set_option(line_numbers, bool(LineNumbers), !IO), + globals.io_set_option(line_numbers, bool(LineNumbers), !IO), update_interface(OutputFileName, !IO). % update .int from .int.tmp if necessary @@ -2269,26 +2269,26 @@ update_interface(OutputFileName, !IO) :- ). update_interface_return_succeeded(OutputFileName, Succeeded, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Updating interface:\n", !IO), TmpOutputFileName = OutputFileName ++ ".tmp", - io__open_binary_input(OutputFileName, OutputFileRes, !IO), + io.open_binary_input(OutputFileName, OutputFileRes, !IO), ( OutputFileRes = ok(OutputFileStream), - io__open_binary_input(TmpOutputFileName, TmpOutputFileRes, !IO), + io.open_binary_input(TmpOutputFileName, TmpOutputFileRes, !IO), ( TmpOutputFileRes = ok(TmpOutputFileStream), binary_input_stream_cmp(OutputFileStream, TmpOutputFileStream, FilesDiffer, !IO), - io__close_binary_input(OutputFileStream, !IO), - io__close_binary_input(TmpOutputFileStream, !IO), + io.close_binary_input(OutputFileStream, !IO), + io.close_binary_input(TmpOutputFileStream, !IO), ( FilesDiffer = ok(ok(no)), Succeeded = yes, maybe_write_string(Verbose, "% ", !IO), maybe_write_string(Verbose, OutputFileName, !IO), maybe_write_string(Verbose, "' has not changed.\n", !IO), - io__remove_file(TmpOutputFileName, _, !IO) + io.remove_file(TmpOutputFileName, _, !IO) ; FilesDiffer = ok(ok(yes)), update_interface_create_file("CHANGED", OutputFileName, @@ -2296,11 +2296,11 @@ update_interface_return_succeeded(OutputFileName, Succeeded, !IO) :- ; FilesDiffer = ok(error(TmpFileError)), Succeeded = no, - io__write_string("Error reading `", !IO), - io__write_string(TmpOutputFileName, !IO), - io__write_string("': ", !IO), - io__write_string(io__error_message(TmpFileError), !IO), - io__nl(!IO) + io.write_string("Error reading `", !IO), + io.write_string(TmpOutputFileName, !IO), + io.write_string("': ", !IO), + io.write_string(io.error_message(TmpFileError), !IO), + io.nl(!IO) ; FilesDiffer = error(_, _), update_interface_create_file("been CREATED", OutputFileName, @@ -2310,12 +2310,12 @@ update_interface_return_succeeded(OutputFileName, Succeeded, !IO) :- TmpOutputFileRes = error(TmpOutputFileError), Succeeded = no, - io__close_binary_input(OutputFileStream, !IO), - io__write_string("Error creating `", !IO), - io__write_string(OutputFileName, !IO), - io__write_string("': ", !IO), - io__write_string(io__error_message(TmpOutputFileError), !IO), - io__nl(!IO) + io.close_binary_input(OutputFileStream, !IO), + io.write_string("Error creating `", !IO), + io.write_string(OutputFileName, !IO), + io.write_string("': ", !IO), + io.write_string(io.error_message(TmpOutputFileError), !IO), + io.nl(!IO) ) ; OutputFileRes = error(_), @@ -2323,13 +2323,13 @@ update_interface_return_succeeded(OutputFileName, Succeeded, !IO) :- TmpOutputFileName, Succeeded, !IO) ). -:- pred binary_input_stream_cmp_2(io__binary_input_stream::in, int::in, - bool::out, io__res(bool)::in, io__res(bool)::out, +:- pred binary_input_stream_cmp_2(io.binary_input_stream::in, int::in, + bool::out, io.res(bool)::in, io.res(bool)::out, io::di, io::uo) is det. binary_input_stream_cmp_2(TmpOutputFileStream, Byte, Continue, _, Differ, !IO) :- - io__read_byte(TmpOutputFileStream, TmpByteResult, !IO), + io.read_byte(TmpOutputFileStream, TmpByteResult, !IO), ( TmpByteResult = ok(TmpByte), ( TmpByte = Byte -> @@ -2345,23 +2345,23 @@ binary_input_stream_cmp_2(TmpOutputFileStream, Byte, Continue, _, Differ, Continue = no ; TmpByteResult = error(TmpByteError), - Differ = error(TmpByteError) : io__res(bool), + Differ = error(TmpByteError) : io.res(bool), Continue = no ). -:- pred binary_input_stream_cmp(io__binary_input_stream::in, - io__binary_input_stream::in, io__maybe_partial_res(io__res(bool))::out, +:- pred binary_input_stream_cmp(io.binary_input_stream::in, + io.binary_input_stream::in, io.maybe_partial_res(io.res(bool))::out, io::di, io::uo) is det. binary_input_stream_cmp(OutputFileStream, TmpOutputFileStream, FilesDiffer, !IO) :- - io__binary_input_stream_foldl2_io_maybe_stop(OutputFileStream, + io.binary_input_stream_foldl2_io_maybe_stop(OutputFileStream, binary_input_stream_cmp_2(TmpOutputFileStream), ok(no), FilesDiffer0, !IO), % Check whether there is anything left in TmpOutputFileStream ( FilesDiffer0 = ok(ok(no)) -> - io__read_byte(TmpOutputFileStream, TmpByteResult2, !IO), + io.read_byte(TmpOutputFileStream, TmpByteResult2, !IO), ( TmpByteResult2 = ok(_), FilesDiffer = ok(ok(yes)) @@ -2381,7 +2381,7 @@ binary_input_stream_cmp(OutputFileStream, TmpOutputFileStream, FilesDiffer, update_interface_create_file(Msg, OutputFileName, TmpOutputFileName, Succeeded, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% `" ++ OutputFileName ++ "' has " ++ Msg ++ ".\n", !IO), copy_file(TmpOutputFileName, OutputFileName, MoveRes, !IO), @@ -2391,11 +2391,11 @@ update_interface_create_file(Msg, OutputFileName, TmpOutputFileName, Succeeded, ; MoveRes = error(MoveError), Succeeded = no, - io__write_string("Error creating `" ++ OutputFileName ++ "': " ++ - io__error_message(MoveError), !IO), - io__nl(!IO) + io.write_string("Error creating `" ++ OutputFileName ++ "': " ++ + io.error_message(MoveError), !IO), + io.nl(!IO) ), - io__remove_file(TmpOutputFileName, _, !IO). + io.remove_file(TmpOutputFileName, _, !IO). %-----------------------------------------------------------------------------% @@ -2404,20 +2404,20 @@ touch_interface_datestamp(ModuleName, Ext, !IO) :- touch_datestamp(OutputFileName, !IO). touch_datestamp(OutputFileName, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Touching `" ++ OutputFileName ++ "'... ", !IO), maybe_flush_output(Verbose, !IO), - io__open_output(OutputFileName, Result, !IO), + io.open_output(OutputFileName, Result, !IO), ( Result = ok(OutputStream), - io__write_string(OutputStream, "\n", !IO), - io__close_output(OutputStream, !IO), + io.write_string(OutputStream, "\n", !IO), + io.close_output(OutputStream, !IO), maybe_write_string(Verbose, " done.\n", !IO) ; Result = error(IOError), - io__error_message(IOError, IOErrorMessage), - io__write_string("\nError opening `" ++ OutputFileName + io.error_message(IOError, IOErrorMessage), + io.write_string("\nError opening `" ++ OutputFileName ++ "' for output: " ++ IOErrorMessage ++ ".\n", !IO) ). @@ -2434,8 +2434,8 @@ grab_imported_modules(SourceFileName, SourceFileModuleName, ModuleName, get_dependencies(Items0, IntImportedModules0, IntUsedModules0, ImpImportedModules0, ImpUsedModules0), - list__append(IntImportedModules0, ImpImportedModules0, ImportedModules0), - list__append(IntUsedModules0, ImpUsedModules0, UsedModules0), + list.append(IntImportedModules0, ImpImportedModules0, ImportedModules0), + list.append(IntUsedModules0, ImpUsedModules0, UsedModules0), warn_if_import_self_or_ancestor(ModuleName, AncestorModules, ImportedModules0, UsedModules0, !IO), @@ -2452,7 +2452,7 @@ grab_imported_modules(SourceFileName, SourceFileModuleName, ModuleName, get_children(InterfaceItems, PublicChildren), ( MaybeTimestamp = yes(Timestamp), - MaybeTimestamps = yes(map__det_insert(map__init, ModuleName, + MaybeTimestamps = yes(map.det_insert(map.init, ModuleName, module_timestamp(".m", Timestamp, may_be_unqualified))) ; MaybeTimestamp = no, @@ -2476,7 +2476,7 @@ grab_imported_modules(SourceFileName, SourceFileModuleName, ModuleName, ; Children = [_ | _], split_clauses_and_decls(ImplItems, Clauses, ImplDecls), - list__condense( + list.condense( [[make_pseudo_decl(interface) | InterfaceItems], [make_pseudo_decl(private_interface) | ImplDecls], [make_pseudo_decl(implementation) | Clauses]], Items1), @@ -2485,7 +2485,7 @@ grab_imported_modules(SourceFileName, SourceFileModuleName, ModuleName, % Add `builtin' and `private_builtin' to the % list of imported modules - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), add_implicit_imports(Items1, Globals, IntImportedModules1, IntImportedModules2, IntUsedModules1, IntUsedModules2), @@ -2598,14 +2598,14 @@ grab_unqual_imported_modules(SourceFileName, SourceFileModuleName, ModuleName, Items0, [], [], [], no, !:Module), % Add `builtin' and `private_builtin' to the imported modules. - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), add_implicit_imports(Items0, Globals, IntImportDeps0, IntImportDeps, IntUseDeps0, IntUseDeps), % % Get the .int3s and .int0s that the current module depends on. % - map__init(ReadModules), + map.init(ReadModules), % first the .int0s for parent modules process_module_private_interfaces(ReadModules, ParentDeps, @@ -2678,7 +2678,7 @@ grab_unqual_imported_modules(SourceFileName, SourceFileModuleName, ModuleName, find_read_module(ReadModules, ModuleName, Suffix, ReturnTimestamp, Items, MaybeTimestamp, Error, FileName) :- - map__search(ReadModules, ModuleName - Suffix, ReadModule), + map.search(ReadModules, ModuleName - Suffix, ReadModule), ReadModule = read_module(ModuleTimestamp, Items, Error, FileName), ( ReturnTimestamp = yes, @@ -2702,7 +2702,7 @@ init_module_imports(SourceFileName, SourceFileModuleName, ModuleName, ModuleName, [], [], [], [], [], PublicChildren, NestedChildren, FactDeps, unknown, [], no_foreign_export, Items, no_module_errors, - MaybeTimestamps, no_main, dir__this_directory). + MaybeTimestamps, no_main, dir.this_directory). module_imports_get_source_file_name(Module, Module ^ source_file_name). module_imports_get_module_name(Module, Module ^ module_name). @@ -2719,11 +2719,11 @@ module_imports_set_indirect_deps(IndirectDeps, Module, append_pseudo_decl(PseudoDecl, Module0, Module) :- Items0 = Module0 ^ items, - list__append(Items0, [make_pseudo_decl(PseudoDecl)], Items), + list.append(Items0, [make_pseudo_decl(PseudoDecl)], Items), Module = Module0 ^ items := Items. make_pseudo_decl(PseudoDecl) = - module_defn(varset__init, PseudoDecl) - term__context_init. + module_defn(varset.init, PseudoDecl) - term.context_init. %-----------------------------------------------------------------------------% @@ -2749,18 +2749,18 @@ add_implicit_imports(Items, Globals, !ImportDeps, !UseDeps) :- % --trace-table-io is specified. % ( contains_tabling_pragma(Items) - ; globals__lookup_bool_option(Globals, + ; globals.lookup_bool_option(Globals, use_minimal_model_stack_copy, yes) - ; globals__lookup_bool_option(Globals, + ; globals.lookup_bool_option(Globals, use_minimal_model_own_stacks, yes) - ; globals__lookup_bool_option(Globals, trace_table_io, yes) + ; globals.lookup_bool_option(Globals, trace_table_io, yes) ) -> !:UseDeps = [MercuryTableBuiltin | !.UseDeps] ; true ), - globals__lookup_bool_option(Globals, profile_deep, Deep), + globals.lookup_bool_option(Globals, profile_deep, Deep), ( Deep = yes, !:UseDeps = [MercuryProfilingBuiltin | !.UseDeps] @@ -2769,10 +2769,10 @@ add_implicit_imports(Items, Globals, !ImportDeps, !UseDeps) :- ), ( ( - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, record_term_sizes_as_words, yes) ; - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, record_term_sizes_as_cells, yes) ) -> @@ -2799,16 +2799,16 @@ contains_tabling_pragma([Item | Items]) :- warn_if_import_self_or_ancestor(ModuleName, AncestorModules, ImportedModules, UsedModules, !IO) :- - globals__io_lookup_bool_option(warn_simple_code, Warn, !IO), + globals.io_lookup_bool_option(warn_simple_code, Warn, !IO), ( Warn = yes, ( - ( list__member(ModuleName, ImportedModules) - ; list__member(ModuleName, UsedModules) + ( list.member(ModuleName, ImportedModules) + ; list.member(ModuleName, UsedModules) ) -> module_name_to_file_name(ModuleName, ".m", no, FileName, !IO), - term__context_init(FileName, 1, Context), + term.context_init(FileName, 1, Context), SelfImportWarning = [ words("Warning: module"), sym_name(ModuleName), @@ -2819,9 +2819,9 @@ warn_if_import_self_or_ancestor(ModuleName, AncestorModules, true ), IsImportedAncestor = (pred(Import::out) is nondet :- - list__member(Import, AncestorModules), - ( list__member(Import, ImportedModules) - ; list__member(Import, UsedModules) + list.member(Import, AncestorModules), + ( list.member(Import, ImportedModules) + ; list.member(Import, UsedModules) ) ), aggregate(IsImportedAncestor, @@ -2835,13 +2835,13 @@ warn_if_import_self_or_ancestor(ModuleName, AncestorModules, warn_imported_ancestor(ModuleName, AncestorName, !IO) :- module_name_to_file_name(ModuleName, ".m", no, FileName, !IO), - term__context_init(FileName, 1, Context), + term.context_init(FileName, 1, Context), record_warning(!IO), report_warning(Context, 0, [words("module"), sym_name(ModuleName), words("imports its own ancestor, module"), sym_name(AncestorName), words(".")], !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, report_warning(Context, 0, @@ -2894,38 +2894,38 @@ warn_if_duplicate_use_import_decls(ModuleName, warn_if_duplicate_use_import_decls(ModuleName, !ImportedModules, !UsedModules, !IO) :- - set__list_to_set(!.ImportedModules, ImportedSet), - set__list_to_set(!.UsedModules, UsedSet), - set__intersect(ImportedSet, UsedSet, BothSet), - ( set__empty(BothSet) -> + set.list_to_set(!.ImportedModules, ImportedSet), + set.list_to_set(!.UsedModules, UsedSet), + set.intersect(ImportedSet, UsedSet, BothSet), + ( set.empty(BothSet) -> true ; - set__to_sorted_list(BothSet, BothList), - globals__io_lookup_bool_option(warn_simple_code, WarnSimple, !IO), + set.to_sorted_list(BothSet, BothList), + globals.io_lookup_bool_option(warn_simple_code, WarnSimple, !IO), ( WarnSimple = yes, module_name_to_file_name(ModuleName, ".m", no, FileName, !IO), - term__context_init(FileName, 1, Context), - prog_out__write_context(Context, !IO), - io__write_string("Warning:", !IO), + term.context_init(FileName, 1, Context), + prog_out.write_context(Context, !IO), + io.write_string("Warning:", !IO), ( BothList = [_] -> - io__write_string(" module ", !IO), - prog_out__write_module_list(BothList, !IO), - io__write_string(" is ", !IO) + io.write_string(" module ", !IO), + prog_out.write_module_list(BothList, !IO), + io.write_string(" is ", !IO) ; - io__write_string(" modules ", !IO), - prog_out__write_module_list(BothList, !IO), - io__write_string(" are ", !IO) + io.write_string(" modules ", !IO), + prog_out.write_module_list(BothList, !IO), + io.write_string(" are ", !IO) ), - io__write_string("imported using both\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" `:- import_module' and ", !IO), - io__write_string("`:- use_module' declarations.\n", !IO), + io.write_string("imported using both\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" `:- import_module' and ", !IO), + io.write_string("`:- use_module' declarations.\n", !IO), - globals__io_lookup_bool_option(halt_at_warn, Halt, !IO), + globals.io_lookup_bool_option(halt_at_warn, Halt, !IO), ( Halt = yes, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; Halt = no ) @@ -2935,7 +2935,7 @@ warn_if_duplicate_use_import_decls(ModuleName, !ImportedModules, !UsedModules, % Treat the modules with both types of import as if they % were imported using `:- import_module.' - list__delete_elems(!.UsedModules, BothList, !:UsedModules) + list.delete_elems(!.UsedModules, BothList, !:UsedModules) ). %-----------------------------------------------------------------------------% @@ -2947,7 +2947,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- ContainsForeignCode, ForeignImports0, _ContainsForeignExport, Items, _Error, _Timestamps, _HasMain, _Dir), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), module_name_to_make_var_name(ModuleName, MakeVarName), module_name_to_file_name(ModuleName, ".d", yes, DependencyFileName, !IO), module_name_to_file_name(ModuleName, ".trans_opt_date", no, @@ -2958,46 +2958,46 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % temporary name, and then rename it to the desired name % when we've finished. % - io__make_temp(dir__dirname(DependencyFileName), "tmp_d", + io.make_temp(dir.dirname(DependencyFileName), "tmp_d", TmpDependencyFileName, !IO), maybe_write_string(Verbose, "% Writing auto-dependency file `", !IO), maybe_write_string(Verbose, DependencyFileName, !IO), maybe_write_string(Verbose, "'...", !IO), maybe_flush_output(Verbose, !IO), - io__open_output(TmpDependencyFileName, Result, !IO), + io.open_output(TmpDependencyFileName, Result, !IO), ( Result = error(IOError), maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(IOError, IOErrorMessage), - string__append_list(["error opening temporary file `", + io.error_message(IOError, IOErrorMessage), + string.append_list(["error opening temporary file `", TmpDependencyFileName, "' for output: ", IOErrorMessage], Message), report_error(Message, !IO) ; Result = ok(DepStream), - list__append(IntDeps, ImplDeps, LongDeps0), + list.append(IntDeps, ImplDeps, LongDeps0), ShortDeps0 = IndirectDeps, - set__list_to_set(LongDeps0, LongDepsSet0), - set__delete(LongDepsSet0, ModuleName, LongDepsSet), - set__list_to_set(ShortDeps0, ShortDepsSet0), - set__difference(ShortDepsSet0, LongDepsSet, ShortDepsSet1), - set__delete(ShortDepsSet1, ModuleName, ShortDepsSet), - set__to_sorted_list(LongDepsSet, LongDeps), - set__to_sorted_list(ShortDepsSet, ShortDeps), - set__to_sorted_list(AllDepsSet, AllDeps), - list__sort_and_remove_dups(FactDeps0, FactDeps), + set.list_to_set(LongDeps0, LongDepsSet0), + set.delete(LongDepsSet0, ModuleName, LongDepsSet), + set.list_to_set(ShortDeps0, ShortDepsSet0), + set.difference(ShortDepsSet0, LongDepsSet, ShortDepsSet1), + set.delete(ShortDepsSet1, ModuleName, ShortDepsSet), + set.to_sorted_list(LongDepsSet, LongDeps), + set.to_sorted_list(ShortDepsSet, ShortDeps), + set.to_sorted_list(AllDepsSet, AllDeps), + list.sort_and_remove_dups(FactDeps0, FactDeps), ( MaybeTransOptDeps = yes(TransOptDeps0), - set__list_to_set(TransOptDeps0, TransOptDepsSet0), - set__intersect(TransOptDepsSet0, LongDepsSet, TransOptDepsSet), - set__to_sorted_list(TransOptDepsSet, TransOptDateDeps), + set.list_to_set(TransOptDeps0, TransOptDepsSet0), + set.intersect(TransOptDepsSet0, LongDepsSet, TransOptDepsSet), + set.to_sorted_list(TransOptDepsSet, TransOptDateDeps), % % note that maybe_read_dependency_file searches for % this exact pattern % - io__write_strings(DepStream, [TransOptDateFileName, " :"], !IO), + io.write_strings(DepStream, [TransOptDateFileName, " :"], !IO), write_dependencies_list(TransOptDateDeps, ".trans_opt", DepStream, !IO) ; @@ -3006,14 +3006,14 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- ( FactDeps = [_ | _], - io__write_strings(DepStream, + io.write_strings(DepStream, ["\n\n", MakeVarName, ".fact_tables ="], !IO), write_file_dependencies_list(FactDeps, "", DepStream, !IO), - io__nl(DepStream, !IO), - globals__io_lookup_bool_option(assume_gmake, AssumeGmake, !IO), + io.nl(DepStream, !IO), + globals.io_lookup_bool_option(assume_gmake, AssumeGmake, !IO), ( AssumeGmake = yes, - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n\n", MakeVarName, ".fact_tables.os = $(", MakeVarName, ".fact_tables:%=$(os_subdir)%.$O)\n\n", @@ -3023,21 +3023,21 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- ], !IO) ; AssumeGmake = no, - io__write_strings(DepStream, + io.write_strings(DepStream, [MakeVarName, ".fact_tables.cs ="], !IO), write_fact_table_dependencies_list(ModuleName, FactDeps, ".c", DepStream, !IO), - io__write_strings(DepStream, ["\n\n", + io.write_strings(DepStream, ["\n\n", MakeVarName, ".fact_tables.os ="], !IO), write_fact_table_dependencies_list(ModuleName, FactDeps, ".$O", DepStream, !IO), - io__nl(DepStream, !IO) + io.nl(DepStream, !IO) ) ; FactDeps = [] ), - ( string__remove_suffix(SourceFileName, ".m", SourceFileBase) -> + ( string.remove_suffix(SourceFileName, ".m", SourceFileBase) -> ErrFileName = SourceFileBase ++ ".err" ; unexpected(this_file, "source file doesn't end in `.m'") @@ -3058,7 +3058,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- module_name_to_file_name(ModuleName, ".pic_o", no, PicObjFileName, !IO), module_name_to_file_name(ModuleName, ".int0", no, Int0FileName, !IO), - io__write_strings(DepStream, ["\n\n", + io.write_strings(DepStream, ["\n\n", OptDateFileName, " ", TransOptDateFileName, " ", ErrFileName, " ", @@ -3068,12 +3068,12 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- ILDateFileName, " ", JavaDateFileName ] , !IO), - io__write_strings(DepStream, [" : ", SourceFileName], !IO), + io.write_strings(DepStream, [" : ", SourceFileName], !IO), % If the module contains nested sub-modules then `.int0' % file must first be built. ( InclDeps = [_ | _], - io__write_strings(DepStream, [" ", Int0FileName], !IO) + io.write_strings(DepStream, [" ", Int0FileName], !IO) ; InclDeps = [] ), @@ -3099,14 +3099,14 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- ; Write = (pred(Ext::in, !.LIO::di, !:LIO::uo) is det :- module_name_to_file_name(ModuleName, Ext, no, ExtName, !LIO), - io__write_strings(DepStream, ["\n\n", ExtName, " : "], !LIO), + io.write_strings(DepStream, ["\n\n", ExtName, " : "], !LIO), write_dependencies_list(NestedDeps, Ext, DepStream, !LIO) ), - list__foldl(Write, NestedExts, !IO) + list.foldl(Write, NestedExts, !IO) ), ( FactDeps = [_ | _], - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ " \\\n\t$(", MakeVarName, ".fact_tables)\n\n", "$(", MakeVarName, ".fact_tables.os) : $(", MakeVarName, ".fact_tables) ", @@ -3118,10 +3118,10 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- FactDeps = [] ), - globals__io_lookup_bool_option(use_opt_files, UseOptFiles, !IO), - globals__io_lookup_bool_option(intermodule_optimization, Intermod, + globals.io_lookup_bool_option(use_opt_files, UseOptFiles, !IO), + globals.io_lookup_bool_option(intermodule_optimization, Intermod, !IO), - globals__io_lookup_accumulating_option(intermod_directories, + globals.io_lookup_accumulating_option(intermod_directories, IntermodDirs, !IO), % If intermodule_optimization is enabled then @@ -3130,13 +3130,13 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % directly or indirectly. ( Intermod = yes, - io__write_strings(DepStream, ["\n\n", ObjFileName, " : "], !IO), + io.write_strings(DepStream, ["\n\n", ObjFileName, " : "], !IO), write_dependencies_list(AllDeps, ".mh", DepStream, !IO) ; Intermod = no ), ( ( Intermod = yes ; UseOptFiles = yes ) -> - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n\n", TransOptDateFileName, " ", ErrFileName, " ", @@ -3157,21 +3157,21 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % % XXX The code here doesn't correctly handle dependencies % on `.int' and `.int2' files needed by the `.opt' files. - globals__io_lookup_bool_option(transitive_optimization, TransOpt, + globals.io_lookup_bool_option(transitive_optimization, TransOpt, !IO), - globals__io_lookup_bool_option(use_trans_opt_files, UseTransOpt, + globals.io_lookup_bool_option(use_trans_opt_files, UseTransOpt, !IO), ( ( TransOpt = yes ; UseTransOpt = yes ) -> - bool__not(UseTransOpt, BuildOptFiles), + bool.not(UseTransOpt, BuildOptFiles), get_both_opt_deps(BuildOptFiles, [ModuleName | LongDeps], IntermodDirs, OptDeps, TransOptDeps, !IO), OptInt0Deps = sort_and_remove_dups( - condense(list__map(get_ancestors, OptDeps))), + condense(list.map(get_ancestors, OptDeps))), write_dependencies_list(OptDeps, ".opt", DepStream, !IO), write_dependencies_list(OptInt0Deps, ".int0", DepStream, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n\n", ErrFileName, " ", CDateFileName, " ", @@ -3183,11 +3183,11 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- write_dependencies_list(TransOptDeps, ".trans_opt", DepStream, !IO) ; - bool__not(UseOptFiles, BuildOptFiles), + bool.not(UseOptFiles, BuildOptFiles), get_opt_deps(BuildOptFiles, [ModuleName | LongDeps], IntermodDirs, ".opt", OptDeps, !IO), OptInt0Deps = sort_and_remove_dups( - condense(list__map(get_ancestors, OptDeps))), + condense(list.map(get_ancestors, OptDeps))), write_dependencies_list(OptDeps, ".opt", DepStream, !IO), write_dependencies_list(OptInt0Deps, ".int0", DepStream, !IO) ) @@ -3195,8 +3195,8 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- true ), - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), - globals__io_get_target(CompilationTarget, !IO), + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), + globals.io_get_target(CompilationTarget, !IO), ( HighLevelCode = yes, CompilationTarget = c @@ -3206,7 +3206,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % compiling the C files, since the generated C files % #include those header files. - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n\n", PicObjFileName, " ", ObjFileName, " :" @@ -3229,7 +3229,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- module_name_to_file_name(ModuleName, ".s", no, AsmFileName, !IO), module_name_to_file_name(ModuleName, ".mh", no, HeaderFileName, !IO), module_name_to_file_name(ModuleName, ".mih", no, HeaderFileName2, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n\n", "ifeq ($(TARGET_ASM),yes)\n", HeaderFileName, " ", HeaderFileName2, " : ", AsmFileName, "\n", @@ -3244,9 +3244,9 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % module_name_to_file_name(ModuleName, ".il", no, ILFileName, !IO), module_name_to_file_name(ModuleName, ".java", no, JavaFileName, !IO), - module_name_to_file_name(ModuleName, module_dep_file_extension, + module_name_to_file_name(ModuleName, make_module_dep_file_extension, no, ModuleDepFileName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n\n", "ifeq ($(TARGET_ASM),yes)\n", ModuleDepFileName, " : ", AsmFileName, "\n", @@ -3279,22 +3279,22 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- module_name_to_file_name(ModuleName, ".date", no, DateFileName, !IO), module_name_to_file_name(ModuleName, ".date0", no, Date0FileName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n\n", DateFileName, " ", Date0FileName ], !IO), write_dependencies_list(ParentDeps, ".date", DepStream, !IO), - io__write_strings(DepStream, [" : ", SourceFileName], !IO), + io.write_strings(DepStream, [" : ", SourceFileName], !IO), write_dependencies_list(ParentDeps, ".int0", DepStream, !IO), write_dependencies_list(LongDeps, ".int3", DepStream, !IO), write_dependencies_list(ShortDeps, ".int3", DepStream, !IO), - io__write_strings(DepStream, ["\n\n", Date0FileName], !IO), + io.write_strings(DepStream, ["\n\n", Date0FileName], !IO), write_dependencies_list(ParentDeps, ".date0", DepStream, !IO), - io__write_strings(DepStream, [" : ", SourceFileName], !IO), + io.write_strings(DepStream, [" : ", SourceFileName], !IO), write_dependencies_list(LongDeps, ".int3", DepStream, !IO), write_dependencies_list(ShortDeps, ".int3", DepStream, !IO), - io__write_string(DepStream, "\n\n", !IO), + io.write_string(DepStream, "\n\n", !IO), % % If we can pass the module name rather than the @@ -3311,9 +3311,9 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- ModuleArg = SourceFileName ), - globals__io_get_target(Target, !IO), - globals__io_lookup_bool_option(sign_assembly, SignAssembly, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_target(Target, !IO), + globals.io_lookup_bool_option(sign_assembly, SignAssembly, !IO), + globals.io_get_globals(Globals, !IO), % If we are on the IL backend, add the dependency that the % top level dll of a nested module hierachy depends on all @@ -3328,9 +3328,9 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- Target = il, SubModules = [_ | _] -> - io__write_strings(DepStream, [DllFileName, " : "], !IO), + io.write_strings(DepStream, [DllFileName, " : "], !IO), write_dll_dependencies_list(SubModules, "", DepStream, !IO), - io__nl(DepStream, !IO) + io.nl(DepStream, !IO) ; true ), @@ -3354,7 +3354,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- ) ; ContainsForeignCode = no_foreign_code, - set__init(LangSet), + set.init(LangSet), ForeignImports = ForeignImports0 ), @@ -3362,7 +3362,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % Handle dependencies introduced by % `:- pragma foreign_import_module' declarations. % - list__filter_map( + list.filter_map( (pred(ForeignImportMod::in, Import::out) is semidet :- Import = foreign_import_module_name(ForeignImportMod, SourceFileModuleName), @@ -3392,20 +3392,20 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- ForeignImportTarget = ObjFileName, ForeignImportExt = ".mh" ), - io__write_string(DepStream, "\n\n", !IO), - io__write_string(DepStream, ForeignImportTarget, !IO), - io__write_string(DepStream, " : ", !IO), + io.write_string(DepStream, "\n\n", !IO), + io.write_string(DepStream, ForeignImportTarget, !IO), + io.write_string(DepStream, " : ", !IO), write_dependencies_list(ForeignImportedModules, ForeignImportExt, DepStream, !IO), - io__write_string(DepStream, "\n\n", !IO) + io.write_string(DepStream, "\n\n", !IO) ), ( Target = il, - not set__empty(LangSet) + not set.empty(LangSet) -> - Langs = set__to_sorted_list(LangSet), - list__foldl(write_foreign_dependency_for_il(DepStream, + Langs = set.to_sorted_list(LangSet), + list.foldl(write_foreign_dependency_for_il(DepStream, ModuleName, AllDeps, ForeignImports), Langs, !IO) ; true @@ -3424,7 +3424,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- module_name_to_make_var_name(ModuleName, ModuleNameString), module_name_to_file_name(ModuleName, ".il", no, IlFileName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "ILASM_KEYFLAG-", ModuleNameString, " = /keyf=mercury.sn\n", IlFileName, " : mercury.sn\n"], !IO) @@ -3459,7 +3459,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % have a way of handling these sorts of rules in a nicer manner.) % - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n", Int0FileName, " : ", Date0FileName, "\n", "\t@:\n", @@ -3475,11 +3475,11 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- "\t@:\n" ], !IO), - globals__io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), + globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), ( UseSubdirs = yes, - io__nl(DepStream, !IO), - list__foldl(write_subdirs_shorthand_rule(DepStream, ModuleName), + io.nl(DepStream, !IO), + list.foldl(write_subdirs_shorthand_rule(DepStream, ModuleName), [".c", ".$O", ".pic_o", ".s", ".pic_s", ".java", ".class", ".il", ".dll"], !IO) ; @@ -3507,7 +3507,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % file for documentation on these rules. % - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\n", Date0FileName, " : ", SourceFileName, "\n", "\t$(MCPI) $(ALL_GRADEFLAGS) ", @@ -3553,32 +3553,32 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- true ), - io__close_output(DepStream, !IO), - io__rename_file(TmpDependencyFileName, DependencyFileName, Result3, + io.close_output(DepStream, !IO), + io.rename_file(TmpDependencyFileName, DependencyFileName, Result3, !IO), ( Result3 = error(_), % On some systems, we need to remove the existing file % first, if any. So try again that way. - io__remove_file(DependencyFileName, Result4, !IO), + io.remove_file(DependencyFileName, Result4, !IO), ( Result4 = error(Error4), maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(Error4, ErrorMsg), - string__append_list(["can't remove file `", DependencyFileName, + io.error_message(Error4, ErrorMsg), + string.append_list(["can't remove file `", DependencyFileName, "': ", ErrorMsg], Message), report_error(Message, !IO) ; Result4 = ok, - io__rename_file(TmpDependencyFileName, DependencyFileName, + io.rename_file(TmpDependencyFileName, DependencyFileName, Result5, !IO), ( Result5 = error(Error5), maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(Error5, ErrorMsg), - string__append_list(["can't rename file `", + io.error_message(Error5, ErrorMsg), + string.append_list(["can't rename file `", TmpDependencyFileName, "' as `", DependencyFileName, "': ", ErrorMsg], Message), report_error(Message, !IO) @@ -3609,7 +3609,7 @@ write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps, !IO) :- % (the rule to generate .dll from .cpp is a pattern rule in % scripts/Mmake.rules). % -:- pred write_foreign_dependency_for_il(io__output_stream::in,sym_name::in, +:- pred write_foreign_dependency_for_il(io.output_stream::in,sym_name::in, list(module_name)::in, foreign_import_module_info::in, foreign_language::in, io::di, io::uo) is det. @@ -3629,16 +3629,16 @@ write_foreign_dependency_for_il(DepStream, ModuleName, AllDeps, module_name_to_file_name(ForeignModuleName, ".dll", no, ForeignDllFileName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ForeignDllFileName, " : ", DllFileName], !IO), % XXX This change doesn't work correctly because % mmake can't find the dlls which don't reside % in the current directory. % write_dll_dependencies_list(ModuleName, AllDeps, DepStream, % !IO), - io__nl(DepStream, !IO), + io.nl(DepStream, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ForeignFileName, " : ", IlFileName, "\n\n"], !IO), ( ForeignLang = csharp -> @@ -3646,7 +3646,7 @@ write_foreign_dependency_for_il(DepStream, ModuleName, AllDeps, % CSHARP_ASSEMBLY_REFS-foreign_code_name % the command line argument to reference all the % dlls the foreign code module references. - io__write_strings(DepStream, + io.write_strings(DepStream, ["CSHARP_ASSEMBLY_REFS-", ForeignModuleNameString, "="], !IO), ( ModuleName = unqualified(Str), @@ -3656,14 +3656,14 @@ write_foreign_dependency_for_il(DepStream, ModuleName, AllDeps, ; Prefix = "/r:" ), - ForeignDeps = list__map( + ForeignDeps = list.map( (func(M) = foreign_import_module_name(M, ModuleName) ), ForeignImports), Deps = AllDeps ++ ForeignDeps, write_dll_dependencies_list(referenced_dlls(ModuleName, Deps), Prefix, DepStream, !IO), - io__nl(DepStream, !IO) + io.nl(DepStream, !IO) ; true ) @@ -3676,41 +3676,41 @@ write_foreign_dependency_for_il(DepStream, ModuleName, AllDeps, % With `--use-subdirs', allow users to type `mmake module.c' % rather than `mmake Mercury/cs/module.c'. % -:- pred write_subdirs_shorthand_rule(io__output_stream::in, +:- pred write_subdirs_shorthand_rule(io.output_stream::in, module_name::in, string::in, io::di, io::uo) is det. write_subdirs_shorthand_rule(DepStream, ModuleName, Ext, !IO) :- module_name_to_file_name(ModuleName, ModuleStr), module_name_to_file_name(ModuleName, Ext, no, Target, !IO), ShorthandTarget = ModuleStr ++ Ext, - io__write_string(DepStream, ".PHONY: ", !IO), - io__write_string(DepStream, ShorthandTarget, !IO), - io__nl(DepStream, !IO), - io__write_string(DepStream, ShorthandTarget, !IO), - io__write_string(DepStream, ": ", !IO), - io__write_string(DepStream, Target, !IO), - io__nl(DepStream, !IO). + io.write_string(DepStream, ".PHONY: ", !IO), + io.write_string(DepStream, ShorthandTarget, !IO), + io.nl(DepStream, !IO), + io.write_string(DepStream, ShorthandTarget, !IO), + io.write_string(DepStream, ": ", !IO), + io.write_string(DepStream, Target, !IO), + io.nl(DepStream, !IO). maybe_read_dependency_file(ModuleName, MaybeTransOptDeps, !IO) :- - globals__io_lookup_bool_option(transitive_optimization, TransOpt, !IO), + globals.io_lookup_bool_option(transitive_optimization, TransOpt, !IO), ( TransOpt = yes, - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), module_name_to_file_name(ModuleName, ".d", no, DependencyFileName, !IO), maybe_write_string(Verbose, "% Reading auto-dependency file `", !IO), maybe_write_string(Verbose, DependencyFileName, !IO), maybe_write_string(Verbose, "'...", !IO), maybe_flush_output(Verbose, !IO), - io__open_input(DependencyFileName, OpenResult, !IO), + io.open_input(DependencyFileName, OpenResult, !IO), ( OpenResult = ok(Stream), - io__set_input_stream(Stream, OldStream, !IO), + io.set_input_stream(Stream, OldStream, !IO), module_name_to_file_name(ModuleName, ".trans_opt_date", no, TransOptDateFileName0, !IO), - string__to_char_list(TransOptDateFileName0, + string.to_char_list(TransOptDateFileName0, TransOptDateFileName), - list__append(TransOptDateFileName, [' ', ':'], SearchPattern), + list.append(TransOptDateFileName, [' ', ':'], SearchPattern), read_dependency_file_find_start(SearchPattern, FindResult, !IO), ( FindResult = yes, @@ -3721,15 +3721,15 @@ maybe_read_dependency_file(ModuleName, MaybeTransOptDeps, !IO) :- % error reading .d file MaybeTransOptDeps = no ), - io__set_input_stream(OldStream, _, !IO), - io__close_input(Stream, !IO), + io.set_input_stream(OldStream, _, !IO), + io.close_input(Stream, !IO), maybe_write_string(Verbose, " done.\n", !IO) ; OpenResult = error(IOError), maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(IOError, IOErrorMessage), - string__append_list(["error opening file `", + io.error_message(IOError, IOErrorMessage), + string.append_list(["error opening file `", DependencyFileName, "' for input: ", IOErrorMessage], Message), report_error(Message, !IO), @@ -3746,9 +3746,9 @@ maybe_read_dependency_file(ModuleName, MaybeTransOptDeps, !IO) :- io::di, io::uo) is det. read_dependency_file_find_start(SearchPattern, Success, !IO) :- - io__read_line(Result, !IO), + io.read_line(Result, !IO), ( Result = ok(CharList) -> - ( list__append(SearchPattern, _, CharList) -> + ( list.append(SearchPattern, _, CharList) -> % Have found the start Success = yes ; @@ -3766,20 +3766,20 @@ read_dependency_file_find_start(SearchPattern, Success, !IO) :- io::di, io::uo) is det. read_dependency_file_get_modules(TransOptDeps, !IO) :- - io__read_line(Result, !IO), + io.read_line(Result, !IO), ( Result = ok(CharList0), % Remove any whitespace from the beginning of the line, % then take all characters until another whitespace occurs. - list__takewhile(char__is_whitespace, CharList0, _, CharList1), + list.takewhile(char.is_whitespace, CharList0, _, CharList1), NotIsWhitespace = (pred(Char::in) is semidet :- - \+ char__is_whitespace(Char) + \+ char.is_whitespace(Char) ), - list__takewhile(NotIsWhitespace, CharList1, CharList, _), - string__from_char_list(CharList, FileName0), - string__remove_suffix(FileName0, ".trans_opt", FileName) + list.takewhile(NotIsWhitespace, CharList1, CharList, _), + string.from_char_list(CharList, FileName0), + string.remove_suffix(FileName0, ".trans_opt", FileName) -> - ( string__append("Mercury/trans_opts/", BaseFileName, FileName) -> + ( string.append("Mercury/trans_opts/", BaseFileName, FileName) -> ModuleFileName = BaseFileName ; ModuleFileName = FileName @@ -3818,7 +3818,7 @@ get_both_opt_deps(BuildOptFiles, [Dep | Deps], IntermodDirs, Result1 = ok(_), !:OptDeps = [Dep | !.OptDeps], !:TransOptDeps = [Dep | !.TransOptDeps], - io__seen(!IO), + io.seen(!IO), Found = yes ; Result1 = error(_), @@ -3835,7 +3835,7 @@ get_both_opt_deps(BuildOptFiles, [Dep | Deps], IntermodDirs, ( Result2 = ok(_), !:OptDeps = [Dep | !.OptDeps], - io__seen(!IO) + io.seen(!IO) ; Result2 = error(_) ), @@ -3844,7 +3844,7 @@ get_both_opt_deps(BuildOptFiles, [Dep | Deps], IntermodDirs, ( Result3 = ok(_), !:TransOptDeps = [Dep | !.TransOptDeps], - io__seen(!IO) + io.seen(!IO) ; Result3 = error(_) ) @@ -3872,7 +3872,7 @@ get_opt_deps(BuildOptFiles, [Dep | Deps], IntermodDirs, Suffix, !:OptDeps, Result1 = ok(_), !:OptDeps = [Dep | !.OptDeps], Found = yes, - io__seen(!IO) + io.seen(!IO) ; Result1 = error(_), Found = no @@ -3888,7 +3888,7 @@ get_opt_deps(BuildOptFiles, [Dep | Deps], IntermodDirs, Suffix, !:OptDeps, ( Result2 = ok(_), !:OptDeps = [Dep | !.OptDeps], - io__seen(!IO) + io.seen(!IO) ; Result2 = error(_) ) @@ -3899,7 +3899,7 @@ get_opt_deps(BuildOptFiles, [Dep | Deps], IntermodDirs, Suffix, !:OptDeps, %-----------------------------------------------------------------------------% generate_module_dependencies(ModuleName, !IO) :- - map__init(DepsMap), + map.init(DepsMap), SearchIncludePath = no, generate_dependencies(output_all_dependencies, SearchIncludePath, ModuleName, DepsMap, !IO). @@ -3911,7 +3911,7 @@ generate_file_dependencies(FileName, !IO) :- SearchIncludePath, ModuleName, DepsMap, !IO). generate_module_dependency_file(ModuleName, !IO) :- - map__init(DepsMap), + map.init(DepsMap), SearchIncludePath = yes, generate_dependencies(output_d_file_only, SearchIncludePath, ModuleName, DepsMap, !IO). @@ -3929,14 +3929,14 @@ build_deps_map(FileName, ModuleName, DepsMap, !IO) :- % read in the top-level file (to figure out its module name) read_mod_from_file(FileName, ".m", "Reading file", no, no, Items, Error, ModuleName, _, !IO), - string__append(FileName, ".m", SourceFileName), + string.append(FileName, ".m", SourceFileName), split_into_submodules(ModuleName, Items, SubModuleList, !IO), - globals__io_get_globals(Globals, !IO), - assoc_list__keys(SubModuleList, SubModuleNames), - list__map(init_dependencies(SourceFileName, ModuleName, SubModuleNames, + globals.io_get_globals(Globals, !IO), + assoc_list.keys(SubModuleList, SubModuleNames), + list.map(init_dependencies(SourceFileName, ModuleName, SubModuleNames, Error, Globals), SubModuleList, ModuleImportsList), - map__init(DepsMap0), - list__foldl(insert_into_deps_map, ModuleImportsList, DepsMap0, DepsMap). + map.init(DepsMap0), + list.foldl(insert_into_deps_map, ModuleImportsList, DepsMap0, DepsMap). :- type generate_dependencies_mode ---> output_d_file_only @@ -3954,12 +3954,12 @@ generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :- % % Check whether we could read the main `.m' file. % - map__lookup(DepsMap, ModuleName, ModuleDep), + map.lookup(DepsMap, ModuleName, ModuleDep), ModuleDep = deps(_, ModuleImports), module_imports_get_error(ModuleImports, Error), ( Error = fatal_module_errors -> sym_name_to_string(ModuleName, ModuleString), - string__append_list(["can't read source file for module `", + string.append_list(["can't read source file for module `", ModuleString, "'."], Message), report_error(Message, !IO) ; @@ -3977,9 +3977,9 @@ generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :- % Compute the interface deps relation and the implementation deps % relation from the deps map. % - relation__init(IntDepsRel0), - relation__init(ImplDepsRel0), - map__values(DepsMap, DepsList), + relation.init(IntDepsRel0), + relation.init(ImplDepsRel0), + map.values(DepsMap, DepsList), deps_list_to_deps_rel(DepsList, DepsMap, IntDepsRel0, IntDepsRel, ImplDepsRel0, ImplDepsRel), @@ -3989,16 +3989,16 @@ generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :- % the subset of those for which of those we have (or can make) % trans-opt files. % - relation__atsort(ImplDepsRel, ImplDepsOrdering0), + relation.atsort(ImplDepsRel, ImplDepsOrdering0), maybe_output_module_order(ModuleName, ImplDepsOrdering0, !IO), - list__map(set__to_sorted_list, ImplDepsOrdering0, ImplDepsOrdering), - list__condense(ImplDepsOrdering, TransOptDepsOrdering0), - globals__io_lookup_accumulating_option(intermod_directories, + list.map(set.to_sorted_list, ImplDepsOrdering0, ImplDepsOrdering), + list.condense(ImplDepsOrdering, TransOptDepsOrdering0), + globals.io_lookup_accumulating_option(intermod_directories, IntermodDirs, !IO), get_opt_deps(yes, TransOptDepsOrdering0, IntermodDirs, ".trans_opt", TransOptDepsOrdering, !IO), - % relation__to_assoc_list(ImplDepsRel, ImplDepsAL), + % relation.to_assoc_list(ImplDepsRel, ImplDepsAL), % print("ImplDepsAL:\n", !IO), % write_list(ImplDepsAL, "\n", print, !IO), nl(!IO), @@ -4009,8 +4009,8 @@ generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :- % of the interface dependencies, but we now include implementation % details in the interface files). % - relation__tc(ImplDepsRel, TransImplDepsRel), - relation__compose(ImplDepsRel, TransImplDepsRel, IndirectDepsRel), + relation.tc(ImplDepsRel, TransImplDepsRel), + relation.compose(ImplDepsRel, TransImplDepsRel, IndirectDepsRel), % % Compute the indirect optimization dependencies: indirect @@ -4022,14 +4022,16 @@ generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :- % of that module's implementation dependencies; in actual fact, % it will be some subset of that. % - relation__tc(ImplDepsRel, IndirectOptDepsRel), + relation.tc(ImplDepsRel, IndirectOptDepsRel), % write_relations("Rel", IntDepsRel, TransIntDepsRel, % ImplDepsRel, IndirectDepsRel, IndirectOptDepsRel), - ( Mode = output_d_file_only, + ( + Mode = output_d_file_only, DFilesToWrite = [ModuleDep] - ; Mode = output_all_dependencies, + ; + Mode = output_all_dependencies, DFilesToWrite = DepsList ), generate_dependencies_write_d_files(DFilesToWrite, @@ -4043,7 +4045,7 @@ generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :- % file when it is needed, we just generate this file "mmake depend" % time, since that is simpler and probably more efficient anyway. % - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( Target = java, Mode = output_all_dependencies -> create_java_shell_script(ModuleName, _Succeeded, !IO) ; @@ -4059,7 +4061,7 @@ generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :- % % write_relations(FileName, IntDepsRel, TransIntDepsRel, % ImplDepsRel, IndirectDepsRel, IndirectOptDepsRel) --> -% io__open_output(FileName, Result), +% io.open_output(FileName, Result), % ( { Result = ok(Stream) } -> % write_relation(Stream, "IntDepsRel", IntDepsRel), % write_relation(Stream, "TransIntDepsRel", TransIntDepsRel), @@ -4071,60 +4073,60 @@ generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :- % { error("unable to open file: " ++ FileName) } % ). % -% :- pred write_relation(io__output_stream::in, string::in, +% :- pred write_relation(io.output_stream::in, string::in, % relation(sym_name)::in, io::di, io::uo) is det. % % write_relation(Stream, Name, Relation) --> -% io__write_string(Stream, "digraph " ++ Name ++ " {\n"), -% io__write_string(Stream, "label=\"" ++ Name ++ "\";\n"), -% io__write_string(Stream, "center=true;\n"), -% relation__traverse(Relation, write_node(Stream), write_edge(Stream)), -% io__write_string(Stream, "}\n"). +% io.write_string(Stream, "digraph " ++ Name ++ " {\n"), +% io.write_string(Stream, "label=\"" ++ Name ++ "\";\n"), +% io.write_string(Stream, "center=true;\n"), +% relation.traverse(Relation, write_node(Stream), write_edge(Stream)), +% io.write_string(Stream, "}\n"). % -% :- pred write_node(io__output_stream::in, sym_name::in, io::di, io::uo) +% :- pred write_node(io.output_stream::in, sym_name::in, io::di, io::uo) % is det. % % write_node(Stream, Node) --> % { sym_name_to_string(Node, "__", NodeStr) }, -% io__write_string(Stream, NodeStr), -% io__write_string(Stream, ";\n"). +% io.write_string(Stream, NodeStr), +% io.write_string(Stream, ";\n"). % -% :- pred write_edge(io__output_stream::in, sym_name::in, sym_name::in, +% :- pred write_edge(io.output_stream::in, sym_name::in, sym_name::in, % io::di, io::uo) is det. % % write_edge(Stream, A, B) --> % { sym_name_to_string(A, "__", AStr) }, % { sym_name_to_string(B, "__", BStr) }, -% io__write_string(Stream, AStr), -% io__write_string(Stream, " -> "), -% io__write_string(Stream, BStr), -% io__write_string(Stream, ";\n"). +% io.write_string(Stream, AStr), +% io.write_string(Stream, " -> "), +% io.write_string(Stream, BStr), +% io.write_string(Stream, ";\n"). :- pred maybe_output_module_order(module_name::in, list(set(module_name))::in, io::di, io::uo) is det. maybe_output_module_order(Module, DepsOrdering, !IO) :- - globals__io_lookup_bool_option(generate_module_order, Order, !IO), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(generate_module_order, Order, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), ( Order = yes, module_name_to_file_name(Module, ".order", yes, OrdFileName, !IO), maybe_write_string(Verbose, "% Creating module order file `", !IO), maybe_write_string(Verbose, OrdFileName, !IO), maybe_write_string(Verbose, "'...", !IO), - io__open_output(OrdFileName, OrdResult, !IO), + io.open_output(OrdFileName, OrdResult, !IO), ( OrdResult = ok(OrdStream), - io__write_list(OrdStream, DepsOrdering, "\n\n", + io.write_list(OrdStream, DepsOrdering, "\n\n", write_module_scc(OrdStream), !IO), - io__close_output(OrdStream, !IO), + io.close_output(OrdStream, !IO), maybe_write_string(Verbose, " done.\n", !IO) ; OrdResult = error(IOError), maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(IOError, IOErrorMessage), - string__append_list(["error opening file `", OrdFileName, + io.error_message(IOError, IOErrorMessage), + string.append_list(["error opening file `", OrdFileName, "' for output: ", IOErrorMessage], OrdMessage), report_error(OrdMessage, !IO) ) @@ -4132,12 +4134,12 @@ maybe_output_module_order(Module, DepsOrdering, !IO) :- Order = no ). -:- pred write_module_scc(io__output_stream::in, set(module_name)::in, +:- pred write_module_scc(io.output_stream::in, set(module_name)::in, io::di, io::uo) is det. write_module_scc(Stream, SCC0, !IO) :- - set__to_sorted_list(SCC0, SCC), - io__write_list(Stream, SCC, "\n", prog_out__write_sym_name, !IO). + set.to_sorted_list(SCC0, SCC), + io.write_list(Stream, SCC, "\n", prog_out.write_sym_name, !IO). % generate_dependencies_write_d_files(Modules, IntDepsRel, ImplDepsRel, % IndirectDepsRel, IndirectOptDepsRel, TransOptOrder, DepsMap, !IO): @@ -4173,7 +4175,7 @@ generate_dependencies_write_d_files([Dep | Deps], module_imports_get_module_name(!.Module, ModuleName), get_dependencies_from_relation(IndirectOptDepsRel, ModuleName, IndirectOptDeps), - globals__io_lookup_bool_option(intermodule_optimization, Intermod, + globals.io_lookup_bool_option(intermodule_optimization, Intermod, !IO), ( Intermod = yes, @@ -4191,7 +4193,7 @@ generate_dependencies_write_d_files([Dep | Deps], IndirectDeps) ), - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( Target = c, Lang = c ; Target = asm, Lang = c ; Target = java, Lang = java @@ -4199,9 +4201,9 @@ generate_dependencies_write_d_files([Dep | Deps], ), % Assume we need the `.mh' files for all imported modules % (we will if they define foreign types). - ForeignImports = list__map( + ForeignImports = list.map( (func(ThisDep) = foreign_import_module(Lang, ThisDep, - term__context_init)), + term.context_init)), IndirectOptDeps), !:Module = !.Module ^ foreign_import_module_info := ForeignImports, @@ -4217,7 +4219,7 @@ generate_dependencies_write_d_files([Dep | Deps], FindModule = (pred(OtherModule::in) is semidet :- ModuleName \= OtherModule ), - list__takewhile(FindModule, TransOptOrder, _, TransOptDeps0), + list.takewhile(FindModule, TransOptOrder, _, TransOptDeps0), ( TransOptDeps0 = [ _ | TransOptDeps1 ] -> % The module was found in the list TransOptDeps = TransOptDeps1 @@ -4230,7 +4232,7 @@ generate_dependencies_write_d_files([Dep | Deps], % even though it probably contains incorrect information. module_imports_get_error(!.Module, Error), ( Error \= fatal_module_errors -> - write_dependency_file(!.Module, set__list_to_set(IndirectOptDeps), + write_dependency_file(!.Module, set.list_to_set(IndirectOptDeps), yes(TransOptDeps), !IO) ; true @@ -4243,11 +4245,11 @@ generate_dependencies_write_d_files([Dep | Deps], list(module_name)::out) is det. get_dependencies_from_relation(DepsRel0, ModuleName, Deps) :- - svrelation__add_element(ModuleName, ModuleKey, DepsRel0, DepsRel), - relation__lookup_key_set_from(DepsRel, ModuleKey, DepsKeysSet), + svrelation.add_element(ModuleName, ModuleKey, DepsRel0, DepsRel), + relation.lookup_key_set_from(DepsRel, ModuleKey, DepsKeysSet), foldl( (pred(Key::in, Deps0::in, [Dep | Deps0]::out) is det :- - relation__lookup_key(DepsRel, Key, Dep) + relation.lookup_key(DepsRel, Key, Dep) ), DepsKeysSet, [], Deps). % This is the data structure we use to record the dependencies. @@ -4277,13 +4279,13 @@ generate_deps_map([Module | Modules], Search, !DepsMap, !IO) :- % having been processed. ( Done = no, - map__set(!.DepsMap, Module, deps(yes, ModuleImports), !:DepsMap), + map.set(!.DepsMap, Module, deps(yes, ModuleImports), !:DepsMap), ForeignImportedModules = - list__map( + list.map( (func(foreign_import_module(_, ImportedModule, _)) = ImportedModule), ModuleImports ^ foreign_import_module_info), - list__condense( + list.condense( [ModuleImports ^ parent_deps, ModuleImports ^ int_deps, ModuleImports ^ impl_deps, @@ -4320,7 +4322,7 @@ deps_list_to_deps_rel([Deps | DepsList], DepsMap, !IntRel, !ImplRel) :- :- func lookup_module_imports(deps_map, module_name) = module_imports. lookup_module_imports(DepsMap, ModuleName) = ModuleImports :- - map__lookup(DepsMap, ModuleName, deps(_, ModuleImports)). + map.lookup(DepsMap, ModuleName, deps(_, ModuleImports)). add_module_relations(LookupModuleImports, ModuleName, !IntRel, !ImplRel) :- ModuleImports = LookupModuleImports(ModuleName), @@ -4352,7 +4354,7 @@ module_imports_to_deps_rel(ModuleImports, LookupModuleImports, % ModuleName = ModuleImports ^ module_name, ParentDeps = ModuleImports ^ parent_deps, - svrelation__add_element(ModuleName, IntModuleKey, !IntRel), + svrelation.add_element(ModuleName, IntModuleKey, !IntRel), add_int_deps(IntModuleKey, ModuleImports, !IntRel), add_parent_impl_deps_list(LookupModuleImports, IntModuleKey, ParentDeps, !IntRel), @@ -4367,7 +4369,7 @@ module_imports_to_deps_rel(ModuleImports, LookupModuleImports, % because this module may depend on things imported % only by its parents. % - svrelation__add_element(ModuleName, ImplModuleKey, !ImplRel), + svrelation.add_element(ModuleName, ImplModuleKey, !ImplRel), add_impl_deps(ImplModuleKey, ModuleImports, !ImplRel), add_parent_impl_deps_list(LookupModuleImports, ImplModuleKey, ParentDeps, !ImplRel). @@ -4379,8 +4381,8 @@ module_imports_to_deps_rel(ModuleImports, LookupModuleImports, add_int_deps(ModuleKey, ModuleImports, Rel0, Rel) :- AddDep = add_dep(ModuleKey), - list__foldl(AddDep, ModuleImports ^ parent_deps, Rel0, Rel1), - list__foldl(AddDep, ModuleImports ^ int_deps, Rel1, Rel). + list.foldl(AddDep, ModuleImports ^ parent_deps, Rel0, Rel1), + list.foldl(AddDep, ModuleImports ^ int_deps, Rel1, Rel). % Add direct implementation dependencies for a module to the % implementation deps relation. @@ -4394,7 +4396,7 @@ add_impl_deps(ModuleKey, ModuleImports, !Rel) :- add_int_deps(ModuleKey, ModuleImports, !Rel), % then we add the impl deps module_imports_get_impl_deps(ModuleImports, ImplDeps), - list__foldl(add_dep(ModuleKey), ImplDeps, !Rel). + list.foldl(add_dep(ModuleKey), ImplDeps, !Rel). % Add parent implementation dependencies for the given Parent module % to the impl. deps relation values for the given ModuleKey. @@ -4411,7 +4413,7 @@ add_parent_impl_deps(LookupModuleImports, ModuleKey, Parent, !Rel) :- is det. add_parent_impl_deps_list(LookupModuleImports, ModuleKey, Parents, !Rel) :- - list__foldl(add_parent_impl_deps(LookupModuleImports, ModuleKey), Parents, + list.foldl(add_parent_impl_deps(LookupModuleImports, ModuleKey), Parents, !Rel). % Add a single dependency to a relation. @@ -4420,8 +4422,8 @@ add_parent_impl_deps_list(LookupModuleImports, ModuleKey, Parents, !Rel) :- is det. add_dep(ModuleRelKey, Dep, !Rel) :- - svrelation__add_element(Dep, DepRelKey, !Rel), - svrelation__add(ModuleRelKey, DepRelKey, !Rel). + svrelation.add_element(Dep, DepRelKey, !Rel), + svrelation.add(ModuleRelKey, DepRelKey, !Rel). :- type submodule_kind ---> toplevel @@ -4435,9 +4437,9 @@ add_dep(ModuleRelKey, Dep, !Rel) :- get_submodule_kind(ModuleName, DepsMap) = Kind :- Ancestors = get_ancestors(ModuleName), - ( list__last(Ancestors, Parent) -> - map__lookup(DepsMap, ModuleName, deps(_, ModuleImports)), - map__lookup(DepsMap, Parent, deps(_, ParentImports)), + ( list.last(Ancestors, Parent) -> + map.lookup(DepsMap, ModuleName, deps(_, ModuleImports)), + map.lookup(DepsMap, Parent, deps(_, ParentImports)), ModuleFileName = ModuleImports ^ source_file_name, ParentFileName = ParentImports ^ source_file_name, ( ModuleFileName = ParentFileName -> @@ -4459,23 +4461,23 @@ get_submodule_kind(ModuleName, DepsMap) = Kind :- generate_dependencies_write_dv_file(SourceFileName, ModuleName, DepsMap, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), module_name_to_file_name(ModuleName, ".dv", yes, DvFileName, !IO), maybe_write_string(Verbose, "% Creating auto-dependency file `", !IO), maybe_write_string(Verbose, DvFileName, !IO), maybe_write_string(Verbose, "'...\n", !IO), - io__open_output(DvFileName, DvResult, !IO), + io.open_output(DvFileName, DvResult, !IO), ( DvResult = ok(DvStream), generate_dv_file(SourceFileName, ModuleName, DepsMap, DvStream, !IO), - io__close_output(DvStream, !IO), + io.close_output(DvStream, !IO), maybe_write_string(Verbose, "% done.\n", !IO) ; DvResult = error(IOError), maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(IOError, IOErrorMessage), - string__append_list(["error opening file `", DvFileName, + io.error_message(IOError, IOErrorMessage), + string.append_list(["error opening file `", DvFileName, "' for output: ", IOErrorMessage], DvMessage), report_error(DvMessage, !IO) ). @@ -4488,87 +4490,87 @@ generate_dependencies_write_dv_file(SourceFileName, ModuleName, DepsMap, generate_dependencies_write_dep_file(SourceFileName, ModuleName, DepsMap, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), module_name_to_file_name(ModuleName, ".dep", yes, DepFileName, !IO), maybe_write_string(Verbose, "% Creating auto-dependency file `", !IO), maybe_write_string(Verbose, DepFileName, !IO), maybe_write_string(Verbose, "'...\n", !IO), - io__open_output(DepFileName, DepResult, !IO), + io.open_output(DepFileName, DepResult, !IO), ( DepResult = ok(DepStream), generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO), - io__close_output(DepStream, !IO), + io.close_output(DepStream, !IO), maybe_write_string(Verbose, "% done.\n", !IO) ; DepResult = error(IOError), maybe_write_string(Verbose, " failed.\n", !IO), maybe_flush_output(Verbose, !IO), - io__error_message(IOError, IOErrorMessage), - string__append_list(["error opening file `", DepFileName, + io.error_message(IOError, IOErrorMessage), + string.append_list(["error opening file `", DepFileName, "' for output: ", IOErrorMessage], DepMessage), report_error(DepMessage, !IO) ). :- pred generate_dv_file(file_name::in, module_name::in, deps_map::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- - io__write_string(DepStream, + io.write_string(DepStream, "# Automatically generated dependency variables for module `", !IO), sym_name_to_string(ModuleName, ModuleNameString), - io__write_string(DepStream, ModuleNameString, !IO), - io__write_string(DepStream, "'\n", !IO), - io__write_string(DepStream, "# generated from source file `", !IO), - io__write_string(DepStream, SourceFileName, !IO), - io__write_string(DepStream, "'\n", !IO), + io.write_string(DepStream, ModuleNameString, !IO), + io.write_string(DepStream, "'\n", !IO), + io.write_string(DepStream, "# generated from source file `", !IO), + io.write_string(DepStream, SourceFileName, !IO), + io.write_string(DepStream, "'\n", !IO), - library__version(Version), - io__write_string(DepStream, + library.version(Version), + io.write_string(DepStream, "# Generated by the Mercury compiler, version ", !IO), - io__write_string(DepStream, Version, !IO), - io__write_string(DepStream, ".\n\n", !IO), + io.write_string(DepStream, Version, !IO), + io.write_string(DepStream, ".\n\n", !IO), - map__keys(DepsMap, Modules0), + map.keys(DepsMap, Modules0), select_ok_modules(Modules0, DepsMap, Modules), module_name_to_make_var_name(ModuleName, MakeVarName), - list__map(get_source_file(DepsMap), Modules, SourceFiles0), - list__sort_and_remove_dups(SourceFiles0, SourceFiles), + list.map(get_source_file(DepsMap), Modules, SourceFiles0), + list.sort_and_remove_dups(SourceFiles0, SourceFiles), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".ms =", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".ms =", !IO), write_file_dependencies_list(SourceFiles, ".m", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".errs =", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".errs =", !IO), write_file_dependencies_list(SourceFiles, ".err", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".mods =", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".mods =", !IO), write_dependencies_list(Modules, "", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( Target = il -> ForeignModulesAndExts = foreign_modules(Modules, DepsMap) ; ForeignModulesAndExts = [] ), - ForeignModules = assoc_list__keys(ForeignModulesAndExts), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".foreign =", !IO), + ForeignModules = assoc_list.keys(ForeignModulesAndExts), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".foreign =", !IO), write_dependencies_list(ForeignModules, "", DepStream, !IO), - io__write_string(DepStream, "\n\n", !IO), + io.write_string(DepStream, "\n\n", !IO), - globals__io_lookup_bool_option(assume_gmake, Gmake, !IO), + globals.io_lookup_bool_option(assume_gmake, Gmake, !IO), ( Gmake = yes, - string__append(MakeVarName, ".mods", ModsVarName), + string.append(MakeVarName, ".mods", ModsVarName), Basis = yes(ModsVarName - ""), - string__append(MakeVarName, ".foreign", ForeignVarName), + string.append(MakeVarName, ".foreign", ForeignVarName), ForeignBasis = yes(ForeignVarName - "") ; Gmake = no, @@ -4583,80 +4585,80 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- F = "$(os_subdir)" ++ F0 ), - list__map_foldl(MakeFileName, ForeignModulesAndExts, ForeignFileNames, + list.map_foldl(MakeFileName, ForeignModulesAndExts, ForeignFileNames, !IO), % .foreign_cs are the source files which have had % foreign code placed in them. - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".foreign_cs = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".foreign_cs = ", !IO), write_file_dependencies_list(ForeignFileNames, "", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), % The dlls which contain the foreign_code. - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".foreign_dlls = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".foreign_dlls = ", !IO), write_compact_dependencies_list(ForeignModules, "$(dlls_subdir)", ".dll", ForeignBasis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".init_cs = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".init_cs = ", !IO), write_compact_dependencies_list(Modules, "$(cs_subdir)", ".c", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".cs = $(", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".init_cs) ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".cs = $(", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".init_cs) ", !IO), write_extra_link_dependencies_list(ExtraLinkObjs, ".c", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".dlls = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".dlls = ", !IO), write_compact_dependencies_list(Modules, "$(dlls_subdir)", ".dll", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_ss = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_ss = ", !IO), write_compact_dependencies_list(Modules, "$(ss_subdir)", ".s", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_pic_ss = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_pic_ss = ", !IO), write_compact_dependencies_list(Modules, "$(pic_ss_subdir)", ".pic_s", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_s_dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_s_dates = ", !IO), write_compact_dependencies_list(Modules, "$(s_dates_subdir)", ".s_date", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_pic_s_dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_pic_s_dates = ", !IO), write_compact_dependencies_list(Modules, "$(pic_s_dates_subdir)", ".pic_s_date", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_os = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_os = ", !IO), write_compact_dependencies_list(Modules, "$(os_subdir)", ".$O", Basis, DepStream, !IO), write_extra_link_dependencies_list(ExtraLinkObjs, ".$O", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_pic_os = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_pic_os = ", !IO), write_compact_dependencies_list(Modules, "$(os_subdir)", ".$(EXT_FOR_PIC_OBJECTS)", Basis, DepStream, !IO), write_extra_link_dependencies_list(ExtraLinkObjs, ".$(EXT_FOR_PIC_OBJECTS)", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), IsNested = (pred(Mod::in) is semidet :- get_submodule_kind(Mod, DepsMap) = nested_submodule @@ -4666,73 +4668,73 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % for top-level modules and separate sub-modules, not for % nested sub-modules. Target = asm, - list__filter(IsNested, Modules, NestedModules, MainModules), + list.filter(IsNested, Modules, NestedModules, MainModules), NestedModules = [_ | _] -> - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".ss = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".ss = ", !IO), write_dependencies_list(MainModules, ".s", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".pic_ss = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".pic_ss = ", !IO), write_dependencies_list(MainModules, ".pic_s", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".s_dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".s_dates = ", !IO), write_dependencies_list(MainModules, ".s_date", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".pic_s_dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".pic_s_dates = ", !IO), write_dependencies_list(MainModules, ".pic_s_date", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".os = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".os = ", !IO), write_dependencies_list(MainModules, ".$O", DepStream, !IO), write_extra_link_dependencies_list(ExtraLinkObjs, ".$O", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".pic_os = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".pic_os = ", !IO), write_dependencies_list(MainModules, ".$(EXT_FOR_PIC_OBJECTS)", DepStream, !IO), write_extra_link_dependencies_list(ExtraLinkObjs, ".$(EXT_FOR_PIC_OBJECTS)", DepStream, !IO), - io__write_string(DepStream, "\n", !IO) + io.write_string(DepStream, "\n", !IO) ; - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".ss = $(", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_ss)\n", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".ss = $(", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_ss)\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".pic_ss = $(", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_pic_ss)\n", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".pic_ss = $(", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_pic_ss)\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".s_dates = $(", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_s_dates)\n", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".s_dates = $(", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_s_dates)\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".pic_s_dates = $(", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_pic_s_dates)\n", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".pic_s_dates = $(", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_pic_s_dates)\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".os = $(", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_os)\n", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".os = $(", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_os)\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".pic_os = $(", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_pic_os)\n", !IO) + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".pic_os = $(", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_pic_os)\n", !IO) ), % @@ -4744,7 +4746,7 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % If TARGET_ASM=yes, we define $(foo.cs_or_ss) to be $(foo.ss), % otherwise it is defined to be $(foo.cs). % - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "ifeq ($(TARGET_ASM),yes)\n", MakeVarName, ".cs_or_ss =$(", MakeVarName, ".ss)\n", "else\n", @@ -4752,29 +4754,29 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- "endif\n\n" ], !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".useds = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".useds = ", !IO), write_compact_dependencies_list(Modules, "$(useds_subdir)", ".used", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".ils = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".ils = ", !IO), write_compact_dependencies_list(Modules, "$(ils_subdir)", ".il", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".javas = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".javas = ", !IO), write_compact_dependencies_list(Modules, "$(javas_subdir)", ".java", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".classes = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".classes = ", !IO), write_compact_dependencies_list(Modules, "$(classes_subdir)", ".class", Basis, DepStream, !IO), - io__write_string(DepStream, " ", !IO), + io.write_string(DepStream, " ", !IO), % The Java compiler creates a .class file for each class % within the original .java file. The filenames of all % these can be matched with `module\$*.class', hence the @@ -4782,86 +4784,86 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % If no such files exist, Make will use the pattern verbatim, % so we enclose the pattern in a `wildcard' function to prevent this. % XXX This relies on GNU Make. - io__write_string(DepStream, "$(wildcard ", !IO), + io.write_string(DepStream, "$(wildcard ", !IO), write_compact_dependencies_list(Modules, "$(classes_subdir)", "\\$$*.class", Basis, DepStream, !IO), - io__write_string(DepStream, ")\n", !IO), + io.write_string(DepStream, ")\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".dirs = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".dirs = ", !IO), write_compact_dependencies_list(Modules, "$(dirs_subdir)", ".dir", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".dir_os = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".dir_os = ", !IO), write_compact_dependencies_list(Modules, "$(dirs_subdir)", ".dir/*.$O", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".dates = ", !IO), write_compact_dependencies_list(Modules, "$(dates_subdir)", ".date", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".date0s = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".date0s = ", !IO), write_compact_dependencies_list(Modules, "$(date0s_subdir)", ".date0", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".date3s = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".date3s = ", !IO), write_compact_dependencies_list(Modules, "$(date3s_subdir)", ".date3", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".optdates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".optdates = ", !IO), write_compact_dependencies_list(Modules, "$(optdates_subdir)", ".optdate", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".trans_opt_dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".trans_opt_dates = ", !IO), write_compact_dependencies_list(Modules, "$(trans_opt_dates_subdir)", ".trans_opt_date", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".c_dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".c_dates = ", !IO), write_compact_dependencies_list(Modules, "$(c_dates_subdir)", ".c_date", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".il_dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".il_dates = ", !IO), write_compact_dependencies_list(Modules, "$(il_dates_subdir)", ".il_date", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".java_dates = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".java_dates = ", !IO), write_compact_dependencies_list(Modules, "$(java_dates_subdir)", ".java_date", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".ds = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".ds = ", !IO), write_compact_dependencies_list(Modules, "$(ds_subdir)", ".d", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".module_deps = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".module_deps = ", !IO), write_compact_dependencies_list(Modules, "$(module_deps_subdir)", - module_dep_file_extension, Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + make_module_dep_file_extension, Basis, DepStream, !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".mihs = ", !IO), - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".mihs = ", !IO), + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO), ( HighLevelCode = yes, ( ( Target = c ; Target = asm ) -> @@ -4886,17 +4888,17 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % For the LLDS back-end, we don't use `.mih' files at all HighLevelCode = no ), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".mhs = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".mhs = ", !IO), ( ( Target = c ; Target = asm ) -> write_compact_dependencies_list(Modules, "", ".mh", Basis, DepStream, !IO) ; true ), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), % The `.all_mihs' variable is like `.mihs' except % that it contains header files for all the modules, regardless @@ -4904,28 +4906,28 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % `mmake realclean', which should remove anything that could have % been automatically generated, even if the grade or --target option % has changed. - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_mihs = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_mihs = ", !IO), write_compact_dependencies_list(Modules, "$(mihs_subdir)", ".mih", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), % The `.all_mhs' variable is like `.mhs' except % that it contains header files for all the modules, as for % `.all_mihs' above. - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".all_mhs = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".all_mhs = ", !IO), write_compact_dependencies_list(Modules, "", ".mh", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".ints = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".ints = ", !IO), write_compact_dependencies_list(Modules, "$(ints_subdir)", ".int", Basis, DepStream, !IO), write_compact_dependencies_separator(Basis, DepStream, !IO), write_compact_dependencies_list(Modules, "$(int2s_subdir)", ".int2", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), % `.int0' files are only generated for modules with sub-modules. % @@ -4936,13 +4938,13 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % correct rules for .int0 files; it and the line below can be % uncommented when the dependency problem is fixed. % - % ModulesWithSubModules = list__filter( + % ModulesWithSubModules = list.filter( % (pred(Module::in) is semidet :- - % map__lookup(DepsMap, Module, deps(_, ModuleImports)), + % map.lookup(DepsMap, Module, deps(_, ModuleImports)), % ModuleImports ^ children = [_ | _] % ), Modules), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".int0s = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".int0s = ", !IO), % % These next two lines are a workaround for the bug described above. % @@ -4955,71 +4957,71 @@ generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % uncommented. % %write_dependencies_list(ModulesWithSubModules, ".int0", DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".int3s = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".int3s = ", !IO), write_compact_dependencies_list(Modules, "$(int3s_subdir)", ".int3", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".opts = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".opts = ", !IO), write_compact_dependencies_list(Modules, "$(opts_subdir)", ".opt", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".trans_opts = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".trans_opts = ", !IO), write_compact_dependencies_list(Modules, "$(trans_opts_subdir)", ".trans_opt", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".analysiss = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".analysiss = ", !IO), write_compact_dependencies_list(Modules, "$(analysiss_subdir)", ".analysis", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".requests = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".requests = ", !IO), write_compact_dependencies_list(Modules, "$(requests_subdir)", ".request", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".imdgs = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".imdgs = ", !IO), write_compact_dependencies_list(Modules, "$(imdgs_subdir)", ".imdg", Basis, DepStream, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), - io__write_string(DepStream, MakeVarName, !IO), - io__write_string(DepStream, ".profs = ", !IO), + io.write_string(DepStream, MakeVarName, !IO), + io.write_string(DepStream, ".profs = ", !IO), write_compact_dependencies_list(Modules, "", ".prof", Basis, DepStream, !IO), - io__write_string(DepStream, "\n\n", !IO). + io.write_string(DepStream, "\n\n", !IO). :- pred generate_dep_file(file_name::in, module_name::in, deps_map::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- - io__write_string(DepStream, + io.write_string(DepStream, "# Automatically generated dependencies for module `", !IO), sym_name_to_string(ModuleName, ModuleNameString), - io__write_string(DepStream, ModuleNameString, !IO), - io__write_string(DepStream, "'\n", !IO), - io__write_string(DepStream, + io.write_string(DepStream, ModuleNameString, !IO), + io.write_string(DepStream, "'\n", !IO), + io.write_string(DepStream, "# generated from source file `", !IO), - io__write_string(DepStream, SourceFileName, !IO), - io__write_string(DepStream, "'\n", !IO), + io.write_string(DepStream, SourceFileName, !IO), + io.write_string(DepStream, "'\n", !IO), - library__version(Version), - io__write_string(DepStream, + library.version(Version), + io.write_string(DepStream, "# Generated by the Mercury compiler, version ", !IO), - io__write_string(DepStream, Version, !IO), - io__write_string(DepStream, ".\n\n", !IO), + io.write_string(DepStream, Version, !IO), + io.write_string(DepStream, ".\n\n", !IO), - map__keys(DepsMap, Modules0), + map.keys(DepsMap, Modules0), select_ok_modules(Modules0, DepsMap, Modules), module_name_to_make_var_name(ModuleName, MakeVarName), @@ -5037,7 +5039,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % (and not complain about undefined variables). % These hacks rely on features of GNU Make, so should not be used % if we cannot assume we are using GNU Make. - globals__io_lookup_bool_option(assume_gmake, Gmake, !IO), + globals.io_lookup_bool_option(assume_gmake, Gmake, !IO), ( Gmake = yes, append_list(["\\\n\t\t$(foreach @,", MakeVarName, @@ -5084,7 +5086,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- EndIf2 = [" endif\n"], % XXX the output here is GNU Make-specific - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "ifneq ($(EXT_FOR_EXE),)\n", ".PHONY : ", ExeFileName, "\n", ExeFileName, " : ", ExeFileName, "$(EXT_FOR_EXE)\n", @@ -5100,7 +5102,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- "\t\t$(", MakeVarName, ".os) ", All_MLObjsString, " $(ALL_MLLIBS)\n"], EndIf = ["endif\n"], - globals__io_get_target(Target, !IO), + globals.io_get_target(Target, !IO), ( Gmake = yes, Rules = IfIL ++ ILMainRule ++ Else ++ @@ -5116,30 +5118,30 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- Rules = MainRule ) ), - io__write_strings(DepStream, Rules, !IO), + io.write_strings(DepStream, Rules, !IO), - globals__io_lookup_bool_option(intermodule_optimization, Intermod, !IO), + globals.io_lookup_bool_option(intermodule_optimization, Intermod, !IO), ( Intermod = yes, - string__append_list(["$(", MakeVarName, ".opts) "], MaybeOptsVar) + string.append_list(["$(", MakeVarName, ".opts) "], MaybeOptsVar) ; Intermod = no, MaybeOptsVar = "" ), - globals__io_lookup_bool_option(transitive_optimization, TransOpt, !IO), + globals.io_lookup_bool_option(transitive_optimization, TransOpt, !IO), ( TransOpt = yes, - string__append_list(["$(", MakeVarName, ".trans_opts) "], + string.append_list(["$(", MakeVarName, ".trans_opts) "], MaybeTransOptsVar) ; TransOpt = no, MaybeTransOptsVar = "" ), - globals__io_lookup_bool_option(generate_mmc_make_module_dependencies, + globals.io_lookup_bool_option(generate_mmc_make_module_dependencies, MmcMakeDeps, !IO), ( MmcMakeDeps = yes, - string__append_list(["$(", MakeVarName, ".module_deps) "], + string.append_list(["$(", MakeVarName, ".module_deps) "], MaybeModuleDepsVar) ; MmcMakeDeps = no, @@ -5204,12 +5206,12 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- LibRules = LibRule ) ), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ".PHONY : ", LibTargetName, "\n" | LibRules ], !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "ifneq ($(EXT_FOR_SHARED_LIB),$A)\n", SharedLibFileName, " : $(", MakeVarName, ".cs_or_ss) ", "$(", MakeVarName, ".pic_os) ", @@ -5222,7 +5224,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- "endif\n\n" ], !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ LibFileName, " : $(", MakeVarName, ".cs_or_ss) ", "$(", MakeVarName, ".os) ", All_MLObjsString, "\n", "\trm -f ", LibFileName, "\n", @@ -5233,7 +5235,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- ClassFiles = "$(" ++ MakeVarName ++ ".classes)", list_class_files_for_jar(ModuleName, ClassFiles, ListClassFiles, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ JarFileName, " : ", "$(", MakeVarName, ".classes)\n", "\t$(JAR) $(JAR_CREATE_FLAGS) ", JarFileName, " ", ListClassFiles, "\n\n" @@ -5241,18 +5243,18 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- module_name_to_file_name(ModuleName, ".dep", no, DepFileName, !IO), module_name_to_file_name(ModuleName, ".dv", no, DvFileName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ InitFileName, " : ", DepFileName, "\n", "\techo > ", InitFileName, "\n" ], !IO), - list__foldl(append_to_init_list(DepStream, InitFileName), Modules, !IO), + list.foldl(append_to_init_list(DepStream, InitFileName), Modules, !IO), % $(EXTRA_INIT_COMMAND) should expand to a command to % generate extra entries in the `.init' file for a library. % It may expand to the empty string. - io__write_string(DepStream, "\t$(EXTRA_INIT_COMMAND) >> ", !IO), - io__write_string(DepStream, InitFileName, !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\t$(EXTRA_INIT_COMMAND) >> ", !IO), + io.write_string(DepStream, InitFileName, !IO), + io.write_string(DepStream, "\n", !IO), % The `force-module_init' dependency forces the commands for % the `module_init.c' rule to be run every time the rule @@ -5260,7 +5262,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- sym_name_to_string(ModuleName, ".", ModuleFileName), ForceC2InitTarget = "force-" ++ ModuleFileName ++ "_init", TmpInitCFileName = InitCFileName ++ ".tmp", - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ForceC2InitTarget, " :\n\n", InitCFileName, " : ", ForceC2InitTarget, "\n", "\t@$(C2INIT) $(ALL_GRADEFLAGS) $(ALL_C2INITFLAGS) ", @@ -5280,7 +5282,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- ), ( Intermod = yes, - map__member(DepsMap, _, deps(_, Imports)), + map.member(DepsMap, _, deps(_, Imports)), Imports ^ children = [_ | _] -> % The `.int0' files only need to be installed with @@ -5306,7 +5308,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- DepStr = "" ), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ".PHONY : ", LibInstallIntsTargetName, "\n", LibInstallIntsTargetName, " : $(", MakeVarName, ".ints) $(", MakeVarName, ".int3s) ", MaybeInt0sVar, MaybeOptsVar, @@ -5348,16 +5350,16 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % module_name_to_lib_file_name("lib", ModuleName, ".install_opts", no, LibInstallOptsTargetName, !IO), - io__write_strings(DepStream, + io.write_strings(DepStream, [".PHONY : ", LibInstallOptsTargetName, "\n", LibInstallOptsTargetName, " : "], !IO), ( Intermod = no, TransOpt = no -> - io__write_string(DepStream, "\n\t@:\n\n", !IO) + io.write_string(DepStream, "\n\t@:\n\n", !IO) ; - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ MaybeOptsVar, MaybeTransOptsVar, "install_grade_dirs\n", "\tfiles=""", MaybeOptsVar, MaybeTransOptsVar, """; \\\n", "\tfor file in $$files; do \\\n", @@ -5401,7 +5403,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % module_name_to_lib_file_name("lib", ModuleName, ".install_hdrs", no, LibInstallHdrsTargetName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ".PHONY : ", LibInstallHdrsTargetName, "\n", LibInstallHdrsTargetName, " : ", "$(", MakeVarName, ".mhs) ", @@ -5417,7 +5419,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- module_name_to_lib_file_name("lib", ModuleName, ".install_grade_hdrs", no, LibInstallGradeHdrsTargetName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ".PHONY : ", LibInstallGradeHdrsTargetName, "\n", LibInstallGradeHdrsTargetName, " : ", "$(", MakeVarName, ".mihs) ", @@ -5471,7 +5473,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % rather than the .m -> .pic_s_date -> .pic_s -> .pic_o chain. % So don't remove the pic_ss target here. - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ".PHONY : ", CheckTargetName, "\n", CheckTargetName, " : $(", MakeVarName, ".errs)\n\n", ".PHONY : ", IntsTargetName, "\n", @@ -5507,10 +5509,10 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- % module_name_to_file_name(ModuleName, ".clean", no, CleanTargetName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "clean_local : ", CleanTargetName, "\n" ], !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ".PHONY : ", CleanTargetName, "\n", CleanTargetName, " :\n", "\t-echo $(", MakeVarName, ".dirs) | xargs rm -rf \n", @@ -5538,14 +5540,14 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- "\t-echo $(", MakeVarName, ".foreign_cs) | xargs rm -f\n" ], !IO), - io__write_string(DepStream, "\n", !IO), + io.write_string(DepStream, "\n", !IO), module_name_to_file_name(ModuleName, ".realclean", no, RealCleanTargetName, !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "realclean_local : ", RealCleanTargetName, "\n" ], !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ ".PHONY : ", RealCleanTargetName, "\n", RealCleanTargetName, " : ", CleanTargetName, "\n", "\t-echo $(", MakeVarName, ".dates) | xargs rm -f\n", @@ -5569,7 +5571,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- "\t-echo $(", MakeVarName, ".foreign_dlls) | xargs rm -f\n", "\t-echo $(", MakeVarName, ".classes) | xargs rm -f\n" ], !IO), - io__write_strings(DepStream, [ + io.write_strings(DepStream, [ "\t-rm -f ", ExeFileName, "$(EXT_FOR_EXE) ", InitFileName, " ", @@ -5583,22 +5585,22 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :- :- pred get_source_file(deps_map::in, module_name::in, file_name::out) is det. get_source_file(DepsMap, ModuleName, FileName) :- - map__lookup(DepsMap, ModuleName, Deps), + map.lookup(DepsMap, ModuleName, Deps), Deps = deps(_, ModuleImports), module_imports_get_source_file_name(ModuleImports, SourceFileName), - ( string__remove_suffix(SourceFileName, ".m", SourceFileBase) -> + ( string.remove_suffix(SourceFileName, ".m", SourceFileBase) -> FileName = SourceFileBase ; unexpected(this_file, "source file name doesn't end in `.m'") ). -:- pred append_to_init_list(io__output_stream::in, file_name::in, +:- pred append_to_init_list(io.output_stream::in, file_name::in, module_name::in, io::di, io::uo) is det. append_to_init_list(DepStream, InitFileName, Module, !IO) :- InitFuncName0 = make_init_name(Module), - string__append(InitFuncName0, "init", InitFuncName), - io__write_strings(DepStream, [ + string.append(InitFuncName0, "init", InitFuncName), + io.write_strings(DepStream, [ "\techo ""INIT ", InitFuncName, """ >> ", InitFileName, "\n" ], !IO). @@ -5611,7 +5613,7 @@ append_to_init_list(DepStream, InitFileName, Module, !IO) :- = list(module_name). modules_that_need_headers(Modules, DepsMap) = - list__filter(module_needs_header(DepsMap), Modules). + list.filter(module_needs_header(DepsMap), Modules). % Find out which modules will generate as external foreign % language files. @@ -5623,13 +5625,13 @@ modules_that_need_headers(Modules, DepsMap) = foreign_modules(Modules, DepsMap) = ForeignModules :- P = (pred(M::in, FMs::out) is semidet :- module_has_foreign(DepsMap, M, LangList), - FMs = list__filter_map((func(L) = (NewM - Ext) is semidet :- + FMs = list.filter_map((func(L) = (NewM - Ext) is semidet :- NewM = foreign_language_module_name(M, L), Ext = foreign_language_file_extension(L) ), LangList) ), - list__filter_map(P, Modules, ForeignModulesList), - ForeignModules = list__condense(ForeignModulesList). + list.filter_map(P, Modules, ForeignModulesList), + ForeignModules = list.condense(ForeignModulesList). % Succeed iff we need to generate a C header file for the specified % module, assuming we're compiling with `--target asm'. @@ -5637,9 +5639,9 @@ foreign_modules(Modules, DepsMap) = ForeignModules :- :- pred module_needs_header(deps_map::in, module_name::in) is semidet. module_needs_header(DepsMap, Module) :- - map__lookup(DepsMap, Module, deps(_, ModuleImports)), + map.lookup(DepsMap, Module, deps(_, ModuleImports)), ModuleImports ^ foreign_code = contains_foreign_code(Langs), - set__member(c, Langs). + set.member(c, Langs). % Succeed iff we need to generate a foreign language output file % for the specified module. @@ -5648,9 +5650,9 @@ module_needs_header(DepsMap, Module) :- list(foreign_language)::out) is semidet. module_has_foreign(DepsMap, Module, LangList) :- - map__lookup(DepsMap, Module, deps(_, ModuleImports)), + map.lookup(DepsMap, Module, deps(_, ModuleImports)), ModuleImports ^ foreign_code = contains_foreign_code(Langs), - LangList = set__to_sorted_list(Langs). + LangList = set.to_sorted_list(Langs). % get_extra_link_objects(Modules, DepsMap, Target, ExtraLinkObjs): % @@ -5664,7 +5666,7 @@ module_has_foreign(DepsMap, Module, LangList) :- get_extra_link_objects(Modules, DepsMap, Target, ExtraLinkObjs) :- get_extra_link_objects_2(Modules, DepsMap, Target, [], ExtraLinkObjs0), - list__reverse(ExtraLinkObjs0, ExtraLinkObjs). + list.reverse(ExtraLinkObjs0, ExtraLinkObjs). :- pred get_extra_link_objects_2(list(module_name)::in, deps_map::in, compilation_target::in, @@ -5674,14 +5676,14 @@ get_extra_link_objects(Modules, DepsMap, Target, ExtraLinkObjs) :- get_extra_link_objects_2([], _DepsMap, _Target, !ExtraLinkObjs). get_extra_link_objects_2([Module | Modules], DepsMap, Target, !ExtraLinkObjs) :- - map__lookup(DepsMap, Module, deps(_, ModuleImports)), + map.lookup(DepsMap, Module, deps(_, ModuleImports)), % % Handle object files for fact tables % FactDeps = ModuleImports ^ fact_table_deps, - list__length(FactDeps, NumFactDeps), - list__duplicate(NumFactDeps, Module, ModuleList), - assoc_list__from_corresponding_lists(FactDeps, ModuleList, FactTableObjs), + list.length(FactDeps, NumFactDeps), + list.duplicate(NumFactDeps, Module, ModuleList), + assoc_list.from_corresponding_lists(FactDeps, ModuleList, FactTableObjs), % % Handle object files for foreign code. % XXX currently we only support `C' foreign code. @@ -5689,14 +5691,14 @@ get_extra_link_objects_2([Module | Modules], DepsMap, Target, ( Target = asm, ModuleImports ^ foreign_code = contains_foreign_code(Langs), - set__member(c, Langs) + set.member(c, Langs) -> sym_name_to_string(Module, ".", FileName), NewLinkObjs = [(FileName ++ "__c_code") - Module | FactTableObjs] ; NewLinkObjs = FactTableObjs ), - list__append(NewLinkObjs, !ExtraLinkObjs), + list.append(NewLinkObjs, !ExtraLinkObjs), get_extra_link_objects_2(Modules, DepsMap, Target, !ExtraLinkObjs). :- type module_foreign_info ---> @@ -5713,12 +5715,12 @@ get_extra_link_objects_2([Module | Modules], DepsMap, Target, get_item_list_foreign_code(Globals, Items, LangSet, ForeignImports, ContainsPragmaExport) :- - Info0 = module_foreign_info(set__init, map__init, [], no_foreign_export), - list__foldl(get_item_foreign_code(Globals), Items, Info0, Info), + Info0 = module_foreign_info(set.init, map.init, [], no_foreign_export), + list.foldl(get_item_foreign_code(Globals), Items, Info0, Info), Info = module_foreign_info(LangSet0, LangMap, ForeignImports, ContainsPragmaExport), - ForeignProcLangs = map__values(LangMap), - LangSet = set__insert_list(LangSet0, ForeignProcLangs). + ForeignProcLangs = map.values(LangMap), + LangSet = set.insert_list(LangSet0, ForeignProcLangs). :- pred get_item_foreign_code(globals::in, item_and_context::in, module_foreign_info::in, module_foreign_info::out) is det. @@ -5734,14 +5736,14 @@ get_item_foreign_code(Globals, Item - Context, !Info) :- % but we should handle the Java/IL backends here as well. % (See do_get_item_foreign_code for details/5). !:Info = !.Info ^ used_foreign_languages := - set__insert(!.Info ^ used_foreign_languages, c) + set.insert(!.Info ^ used_foreign_languages, c) ; ( Item = initialise(_, _, _) ; Item = finalise(_, _, _) ) -> % Intialise/finalise declarations introduce export pragmas, but % again they won't have been expanded by the time we get here. % XXX we don't currently support these on non-C backends. Lang = c, !:Info = !.Info ^ used_foreign_languages := - set__insert(!.Info ^ used_foreign_languages, Lang), + set.insert(!.Info ^ used_foreign_languages, Lang), !:Info = !.Info ^ module_contains_foreign_export := contains_foreign_export ; @@ -5753,8 +5755,8 @@ get_item_foreign_code(Globals, Item - Context, !Info) :- is det. do_get_item_foreign_code(Globals, Pragma, Context, Info0, Info) :- - globals__get_backend_foreign_languages(Globals, BackendLangs), - globals__get_target(Globals, Target), + globals.get_backend_foreign_languages(Globals, BackendLangs), + globals.get_target(Globals, Target), % The code here should match the way that mlds_to_gcc.m % decides whether or not to call mlds_to_c.m. XXX Note @@ -5766,10 +5768,10 @@ do_get_item_foreign_code(Globals, Pragma, Context, Info0, Info) :- % intermodule optimization. ( Pragma = foreign_code(Lang, _), - list__member(Lang, BackendLangs) + list.member(Lang, BackendLangs) -> Info = Info0 ^ used_foreign_languages := - set__insert(Info0 ^ used_foreign_languages, Lang) + set.insert(Info0 ^ used_foreign_languages, Lang) ; Pragma = foreign_proc(Attrs, Name, _, _, _, _, _) -> @@ -5786,7 +5788,7 @@ do_get_item_foreign_code(Globals, Pragma, Context, Info0, Info) :- ) ; % is it one of the languages we support? - ( list__member(NewLang, BackendLangs) -> + ( list.member(NewLang, BackendLangs) -> Info = Info0 ^ foreign_proc_languages ^ elem(Name) := NewLang ; @@ -5802,17 +5804,17 @@ do_get_item_foreign_code(Globals, Pragma, Context, Info0, Info) :- % we need to treat `pragma export' like the % other pragmas for foreign code. Pragma = export(_, _, _, _), - list__member(c, BackendLangs) + list.member(c, BackendLangs) -> % XXX we assume lang = c for exports Lang = c, Info1 = Info0 ^ used_foreign_languages := - set__insert(Info0 ^ used_foreign_languages, Lang), + set.insert(Info0 ^ used_foreign_languages, Lang), Info = Info1 ^ module_contains_foreign_export := contains_foreign_export ; Pragma = foreign_import_module(Lang, Import), - list__member(Lang, BackendLangs) + list.member(Lang, BackendLangs) -> Info = Info0 ^ all_foreign_import_module_info := [foreign_import_module(Lang, Import, Context) | @@ -5828,7 +5830,7 @@ do_get_item_foreign_code(Globals, Pragma, Context, Info0, Info) :- Pragma = fact_table(_, _, _) -> Info = Info0 ^ used_foreign_languages := - set__insert(Info0 ^ used_foreign_languages, c) + set.insert(Info0 ^ used_foreign_languages, c) ; Info = Info0 ). @@ -5840,7 +5842,7 @@ do_get_item_foreign_code(Globals, Pragma, Context, Info0, Info) :- select_ok_modules([], _, []). select_ok_modules([Module | Modules0], DepsMap, Modules) :- - map__lookup(DepsMap, Module, deps(_, ModuleImports)), + map.lookup(DepsMap, Module, deps(_, ModuleImports)), module_imports_get_error(ModuleImports, Error), ( Error = fatal_module_errors -> Modules = Modules1 @@ -5852,13 +5854,13 @@ select_ok_modules([Module | Modules0], DepsMap, Modules) :- %-----------------------------------------------------------------------------% :- pred write_dependencies_list(list(module_name)::in, string::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. write_dependencies_list([], _, _, !IO). write_dependencies_list([Module | Modules], Suffix, DepStream, !IO) :- module_name_to_file_name(Module, Suffix, no, FileName, !IO), - io__write_string(DepStream, " \\\n\t", !IO), - io__write_string(DepStream, FileName, !IO), + io.write_string(DepStream, " \\\n\t", !IO), + io.write_string(DepStream, FileName, !IO), write_dependencies_list(Modules, Suffix, DepStream, !IO). referenced_dlls(Module, DepModules0) = Modules :- @@ -5873,7 +5875,7 @@ referenced_dlls(Module, DepModules0) = Modules :- -> % In the standard library we need to add the % runtime dlls. - Modules = list__remove_dups( + Modules = list.remove_dups( [unqualified("mercury_dotnet"), unqualified("mercury_il") | DepModules]) ; @@ -5888,7 +5890,7 @@ referenced_dlls(Module, DepModules0) = Modules :- unqualified(outermost_qualifier(M)) ) ), - Modules = list__remove_dups(list__map(F, DepModules)) + Modules = list.remove_dups(list.map(F, DepModules)) ). % submodules(Module, Imports): @@ -5908,91 +5910,91 @@ submodules(Module, Modules0) = Modules :- Str = outermost_qualifier(M), M \= Module ), - list__filter(P, Modules0, Modules) + list.filter(P, Modules0, Modules) ; Modules = [] ). :- pred write_dll_dependencies_list(list(module_name)::in, - string::in, io__output_stream::in, io::di, io::uo) is det. + string::in, io.output_stream::in, io::di, io::uo) is det. write_dll_dependencies_list(Modules, Prefix, DepStream, !IO) :- - list__foldl(write_dll_dependency(DepStream, Prefix), Modules, !IO). + list.foldl(write_dll_dependency(DepStream, Prefix), Modules, !IO). -:- pred write_dll_dependency(io__output_stream::in, string::in, +:- pred write_dll_dependency(io.output_stream::in, string::in, module_name::in, io::di, io::uo) is det. write_dll_dependency(DepStream, Prefix, Module, !IO) :- module_name_to_file_name(Module, ".dll", no, FileName, !IO), - io__write_string(DepStream, " \\\n\t", !IO), - io__write_string(DepStream, Prefix, !IO), - io__write_string(DepStream, FileName, !IO). + io.write_string(DepStream, " \\\n\t", !IO), + io.write_string(DepStream, Prefix, !IO), + io.write_string(DepStream, FileName, !IO). :- pred write_fact_table_dependencies_list(module_name::in, - list(file_name)::in, string::in, io__output_stream::in, + list(file_name)::in, string::in, io.output_stream::in, io::di, io::uo) is det. write_fact_table_dependencies_list(_, [], _, _, !IO). write_fact_table_dependencies_list(Module, [FactTable | FactTables], Suffix, DepStream, !IO) :- fact_table_file_name(Module, FactTable, Suffix, no, FileName, !IO), - io__write_string(DepStream, " \\\n\t", !IO), - io__write_string(DepStream, FileName, !IO), + io.write_string(DepStream, " \\\n\t", !IO), + io.write_string(DepStream, FileName, !IO), write_fact_table_dependencies_list(Module, FactTables, Suffix, DepStream, !IO). :- pred write_extra_link_dependencies_list( assoc_list(file_name, module_name)::in, string::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. write_extra_link_dependencies_list([], _, _, !IO). write_extra_link_dependencies_list([ExtraLink - Module | ExtraLinks], Suffix, DepStream, !IO) :- extra_link_obj_file_name(Module, ExtraLink, Suffix, no, FileName, !IO), - io__write_string(DepStream, " \\\n\t", !IO), - io__write_string(DepStream, FileName, !IO), + io.write_string(DepStream, " \\\n\t", !IO), + io.write_string(DepStream, FileName, !IO), write_extra_link_dependencies_list(ExtraLinks, Suffix, DepStream, !IO). :- pred write_file_dependencies_list(list(string)::in, string::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. write_file_dependencies_list([], _, _, !IO). write_file_dependencies_list([FileName | FileNames], Suffix, DepStream, !IO) :- - io__write_string(DepStream, " \\\n\t", !IO), - io__write_string(DepStream, FileName, !IO), - io__write_string(DepStream, Suffix, !IO), + io.write_string(DepStream, " \\\n\t", !IO), + io.write_string(DepStream, FileName, !IO), + io.write_string(DepStream, Suffix, !IO), write_file_dependencies_list(FileNames, Suffix, DepStream, !IO). %-----------------------------------------------------------------------------% :- pred write_compact_dependencies_list(list(module_name)::in, string::in, - string::in, maybe(pair(string))::in, io__output_stream::in, + string::in, maybe(pair(string))::in, io.output_stream::in, io::di, io::uo) is det. write_compact_dependencies_list(Modules, Prefix, Suffix, Basis, DepStream, !IO) :- ( Basis = yes(VarName - OldSuffix), - io__write_string(DepStream, "$(", !IO), - io__write_string(DepStream, VarName, !IO), - io__write_string(DepStream, ":%", !IO), - io__write_string(DepStream, OldSuffix, !IO), - io__write_string(DepStream, "=", !IO), - io__write_string(DepStream, Prefix, !IO), - io__write_string(DepStream, "%", !IO), - io__write_string(DepStream, Suffix, !IO), - io__write_string(DepStream, ")", !IO) + io.write_string(DepStream, "$(", !IO), + io.write_string(DepStream, VarName, !IO), + io.write_string(DepStream, ":%", !IO), + io.write_string(DepStream, OldSuffix, !IO), + io.write_string(DepStream, "=", !IO), + io.write_string(DepStream, Prefix, !IO), + io.write_string(DepStream, "%", !IO), + io.write_string(DepStream, Suffix, !IO), + io.write_string(DepStream, ")", !IO) ; Basis = no, write_dependencies_list(Modules, Suffix, DepStream, !IO) ). :- pred write_compact_dependencies_separator(maybe(pair(string))::in, - io__output_stream::in, io::di, io::uo) is det. + io.output_stream::in, io::di, io::uo) is det. write_compact_dependencies_separator(no, _DepStream, !IO). write_compact_dependencies_separator(yes(_), DepStream, !IO) :- - io__write_string(DepStream, " ", !IO). + io.write_string(DepStream, " ", !IO). %-----------------------------------------------------------------------------% @@ -6005,13 +6007,13 @@ write_compact_dependencies_separator(yes(_), DepStream, !IO) :- io::di, io::uo) is det. lookup_dependencies(Module, Search, Done, !DepsMap, ModuleImports, !IO) :- - ( map__search(!.DepsMap, Module, deps(DonePrime, ModuleImportsPrime)) -> + ( map.search(!.DepsMap, Module, deps(DonePrime, ModuleImportsPrime)) -> Done = DonePrime, ModuleImports = ModuleImportsPrime ; read_dependencies(Module, Search, ModuleImportsList, !IO), - list__foldl(insert_into_deps_map, ModuleImportsList, !DepsMap), - map__lookup(!.DepsMap, Module, deps(Done, ModuleImports)) + list.foldl(insert_into_deps_map, ModuleImportsList, !DepsMap), + map.lookup(!.DepsMap, Module, deps(Done, ModuleImports)) ). % insert_into_deps_map/3: @@ -6043,7 +6045,7 @@ lookup_dependencies(Module, Search, Done, !DepsMap, ModuleImports, !IO) :- insert_into_deps_map(ModuleImports, DepsMap0, DepsMap) :- module_imports_get_module_name(ModuleImports, ModuleName), - map__set(DepsMap0, ModuleName, deps(no, ModuleImports), DepsMap). + map.set(DepsMap0, ModuleName, deps(no, ModuleImports), DepsMap). % Read a module to determine the (direct) dependencies % of that module and any nested sub-modules it contains. @@ -6068,9 +6070,9 @@ read_dependencies(ModuleName, Search, ModuleImportsList, !IO) :- Items = Items0, split_into_submodules(ModuleName, Items, SubModuleList, !IO) ), - globals__io_get_globals(Globals, !IO), - assoc_list__keys(SubModuleList, SubModuleNames), - list__map(init_dependencies(FileName, ModuleName, SubModuleNames, + globals.io_get_globals(Globals, !IO), + assoc_list.keys(SubModuleList, SubModuleNames), + list.map(init_dependencies(FileName, ModuleName, SubModuleNames, Error, Globals), SubModuleList, ModuleImportsList). init_dependencies(FileName, SourceFileModuleName, NestedModuleNames, @@ -6080,14 +6082,14 @@ init_dependencies(FileName, SourceFileModuleName, NestedModuleNames, get_dependencies(Items, ImplImportDeps0, ImplUseDeps0), add_implicit_imports(Items, Globals, ImplImportDeps0, ImplImportDeps, ImplUseDeps0, ImplUseDeps), - list__append(ImplImportDeps, ImplUseDeps, ImplementationDeps), + list.append(ImplImportDeps, ImplUseDeps, ImplementationDeps), get_interface(ModuleName, no, Items, InterfaceItems), get_dependencies(InterfaceItems, InterfaceImportDeps0, InterfaceUseDeps0), add_implicit_imports(InterfaceItems, Globals, InterfaceImportDeps0, InterfaceImportDeps, InterfaceUseDeps0, InterfaceUseDeps), - list__append(InterfaceImportDeps, InterfaceUseDeps, InterfaceDeps), + list.append(InterfaceImportDeps, InterfaceUseDeps, InterfaceDeps), % We don't fill in the indirect dependencies yet. IndirectDeps = [], @@ -6096,7 +6098,7 @@ init_dependencies(FileName, SourceFileModuleName, NestedModuleNames, get_children(InterfaceItems, InterfaceIncludeDeps), ( ModuleName = SourceFileModuleName -> - list__delete_all(NestedModuleNames, ModuleName, NestedDeps) + list.delete_all(NestedModuleNames, ModuleName, NestedDeps) ; NestedDeps = [] ), @@ -6106,7 +6108,7 @@ init_dependencies(FileName, SourceFileModuleName, NestedModuleNames, % Figure out whether the items contain foreign code. get_item_list_foreign_code(Globals, Items, LangSet, ForeignImports0, ContainsPragmaExport), - ( set__empty(LangSet) -> + ( set.empty(LangSet) -> ContainsForeignCode = no_foreign_code ; ContainsForeignCode = contains_foreign_code(LangSet) @@ -6116,9 +6118,9 @@ init_dependencies(FileName, SourceFileModuleName, NestedModuleNames, % `:- pragma foreign_type' declarations, importing modules % may need to import its `.mh' file. get_foreign_self_imports(Items, SelfImportLangs), - ForeignSelfImports = list__map( + ForeignSelfImports = list.map( (func(Lang) = foreign_import_module(Lang, ModuleName, - term__context_init)), + term.context_init)), SelfImportLangs), ForeignImports = ForeignSelfImports ++ ForeignImports0, @@ -6126,7 +6128,7 @@ init_dependencies(FileName, SourceFileModuleName, NestedModuleNames, % Work out whether the items contain main/2. % ( - list__member(Item, Items), + list.member(Item, Items), Item = pred_or_func(_, _, _, predicate, Name, [_, _], WithType, _, _, _, _, _) - _, unqualify_name(Name, "main"), @@ -6153,7 +6155,7 @@ init_dependencies(FileName, SourceFileModuleName, NestedModuleNames, ImplementationDeps, IndirectDeps, IncludeDeps, InterfaceIncludeDeps, NestedDeps, FactTableDeps, ContainsForeignCode, ForeignImports, ContainsPragmaExport, - [], Error, no, HasMain, dir__this_directory). + [], Error, no, HasMain, dir.this_directory). %-----------------------------------------------------------------------------% @@ -6207,7 +6209,7 @@ read_mod_2(IgnoreErrors, ModuleName, Extension, Descr, Search, Search = no, module_name_to_file_name(ModuleName, Extension, no, FileName0, !IO) ), - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), maybe_write_string(VeryVerbose, "% ", !IO), maybe_write_string(VeryVerbose, Descr, !IO), maybe_write_string(VeryVerbose, " `", !IO), @@ -6217,11 +6219,11 @@ read_mod_2(IgnoreErrors, ModuleName, Extension, Descr, Search, ( Search = yes, - globals__io_lookup_accumulating_option(search_directories, SearchDirs, + globals.io_lookup_accumulating_option(search_directories, SearchDirs, !IO) ; Search = no, - SearchDirs = [dir__this_directory] + SearchDirs = [dir.this_directory] ), ( Extension = ".m" -> % For `.m' files we need to deal with the case where @@ -6232,12 +6234,12 @@ read_mod_2(IgnoreErrors, ModuleName, Extension, Descr, Search, ), ( MaybeOldTimestamp = yes(OldTimestamp), - prog_io__read_module_if_changed(OpenFile, ModuleName, + prog_io.read_module_if_changed(OpenFile, ModuleName, OldTimestamp, Error, MaybeFileName, ActualModuleName, Messages, Items, MaybeTimestamp0, !IO) ; MaybeOldTimestamp = no, - prog_io__read_module(OpenFile, ModuleName, + prog_io.read_module(OpenFile, ModuleName, ReturnTimestamp, Error, MaybeFileName, ActualModuleName, Messages, Items, MaybeTimestamp0, !IO) ), @@ -6267,61 +6269,61 @@ read_mod_2(IgnoreErrors, ModuleName, Extension, Descr, Search, ( Error = fatal_module_errors, maybe_write_string(VeryVerbose, "fatal error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; Error = some_module_errors, maybe_write_string(VeryVerbose, "parse error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; Error = no_module_errors, maybe_write_string(VeryVerbose, "successful parse.\n", !IO) ), - prog_out__write_messages(Messages, !IO) + prog_out.write_messages(Messages, !IO) ). read_mod_from_file(FileName, Extension, Descr, Search, ReturnTimestamp, Items, Error, ModuleName, MaybeTimestamp, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), maybe_write_string(VeryVerbose, "% ", !IO), maybe_write_string(VeryVerbose, Descr, !IO), maybe_write_string(VeryVerbose, " `", !IO), maybe_write_string(VeryVerbose, FileName, !IO), maybe_write_string(VeryVerbose, "'... ", !IO), maybe_flush_output(VeryVerbose, !IO), - string__append(FileName, Extension, FullFileName), - ( dir__basename(FileName, BaseFileName0) -> - BaseFileName = BaseFileName0 + string.append(FileName, Extension, FullFileName), + ( dir.basename(FileName, BaseFileNamePrime) -> + BaseFileName = BaseFileNamePrime ; BaseFileName = "" ), file_name_to_module_name(BaseFileName, DefaultModuleName), ( Search = yes, - globals__io_lookup_accumulating_option(search_directories, + globals.io_lookup_accumulating_option(search_directories, SearchDirs, !IO) ; Search = no, - SearchDirs = [dir__this_directory] + SearchDirs = [dir.this_directory] ), OpenFile = search_for_file(SearchDirs, FullFileName), - prog_io__read_module(OpenFile, DefaultModuleName, ReturnTimestamp, Error, + prog_io.read_module(OpenFile, DefaultModuleName, ReturnTimestamp, Error, _, ModuleName, Messages, Items, MaybeTimestamp0, !IO), check_timestamp(FullFileName, MaybeTimestamp0, MaybeTimestamp, !IO), ( Error = fatal_module_errors, maybe_write_string(VeryVerbose, "fatal error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; Error = some_module_errors, maybe_write_string(VeryVerbose, "parse error(s).\n", !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; Error = no_module_errors, maybe_write_string(VeryVerbose, "successful parse.\n", !IO) ), - prog_out__write_messages(Messages, !IO). + prog_out.write_messages(Messages, !IO). -:- pred check_timestamp(file_name::in, maybe(io__res(timestamp))::in, +:- pred check_timestamp(file_name::in, maybe(io.res(timestamp))::in, maybe(timestamp)::out, io::di, io::uo) is det. check_timestamp(FileName, MaybeTimestamp0, MaybeTimestamp, !IO) :- @@ -6331,7 +6333,7 @@ check_timestamp(FileName, MaybeTimestamp0, MaybeTimestamp, !IO) :- ; MaybeTimestamp0 = yes(error(IOError)), MaybeTimestamp = no, - globals__io_lookup_bool_option(smart_recompilation, SmartRecompilation, + globals.io_lookup_bool_option(smart_recompilation, SmartRecompilation, !IO), ( SmartRecompilation = yes, @@ -6365,7 +6367,7 @@ process_module_private_interfaces(ReadModules, [Ancestor | Ancestors], ( Ancestor = ModuleName -> unexpected(this_file, "process_module_private_interfaces: " ++ "module is its own ancestor?") - ; list__member(Ancestor, ModAncestors0) -> + ; list.member(Ancestor, ModAncestors0) -> % we've already read it process_module_private_interfaces(ReadModules, Ancestors, IntStatusItem, ImpStatusItem, @@ -6386,7 +6388,7 @@ process_module_private_interfaces(ReadModules, [Ancestor | Ancestors], PrivateIntItems, Items), maybe_add_int_error(PrivateIntError, ModError0, ModError), - globals__io_lookup_bool_option(detailed_statistics, Statistics, !IO), + globals.io_lookup_bool_option(detailed_statistics, Statistics, !IO), maybe_report_stats(Statistics, !IO), ( PrivateIntError = fatal_module_errors -> @@ -6418,9 +6420,9 @@ process_module_long_interfaces(ReadModules, NeedQualifier, [Import | Imports], ( % have we already read it? ( Import = ModuleName - ; list__member(Import, !.Module ^ parent_deps) - ; list__member(Import, !.Module ^ int_deps) - ; list__member(Import, ModImplementationImports0) + ; list.member(Import, !.Module ^ parent_deps) + ; list.member(Import, !.Module ^ int_deps) + ; list.member(Import, ModImplementationImports0) ) -> process_module_long_interfaces(ReadModules, NeedQualifier, @@ -6442,7 +6444,7 @@ process_module_long_interfaces(ReadModules, NeedQualifier, [Import | Imports], LongIntItems, Items), maybe_add_int_error(LongIntError, ModError0, ModError), - globals__io_lookup_bool_option(detailed_statistics, Statistics, !IO), + globals.io_lookup_bool_option(detailed_statistics, Statistics, !IO), maybe_report_stats(Statistics, !IO), ( LongIntError = fatal_module_errors -> @@ -6456,7 +6458,7 @@ process_module_long_interfaces(ReadModules, NeedQualifier, [Import | Imports], ++ IndirectUses1, !:ImplIndirectImports = !.ImplIndirectImports ++ ImplIndirectImports1 ++ ImplIndirectUses1, - list__append(ModItems0, Items, ModItems), + list.append(ModItems0, Items, ModItems), !:Module = !.Module ^ impl_deps := ModImplementationImports, !:Module = !.Module ^ items := ModItems, !:Module = !.Module ^ error := ModError, @@ -6482,7 +6484,7 @@ process_module_long_interfaces(ReadModules, NeedQualifier, [Import | Imports], % check_imports_accessibility(ModuleName, Imports, Items, !IO) :- get_accessible_children(Items, AccessibleSubModules), - list__foldl(check_module_accessibility(ModuleName, + list.foldl(check_module_accessibility(ModuleName, AccessibleSubModules, Items), Imports, !IO). :- pred check_module_accessibility(module_name::in, list(module_name)::in, @@ -6491,7 +6493,7 @@ check_imports_accessibility(ModuleName, Imports, Items, !IO) :- check_module_accessibility(ModuleName, AccessibleSubModules, Items, ImportedModule, !IO) :- ( ImportedModule = qualified(ParentModule, SubModule) -> - ( list__member(ImportedModule, AccessibleSubModules) -> + ( list.member(ImportedModule, AccessibleSubModules) -> true ; % The user attempted to import an inaccessible @@ -6505,15 +6507,15 @@ check_module_accessibility(ModuleName, AccessibleSubModules, Items, ( ModuleDefn = import(module(Mods)) ; ModuleDefn = use(module(Mods)) ), - list__member(ImportedModule, Mods) + list.member(ImportedModule, Mods) ), - list__filter(FindImports, Items, ImportItems), + list.filter(FindImports, Items, ImportItems), ( ImportItems = [] -> unexpected(this_file, "check_parent_module") ; true ), - list__foldl(report_inaccessible_module_error( + list.foldl(report_inaccessible_module_error( ModuleName, ParentModule, SubModule), ImportItems, !IO) ) @@ -6551,7 +6553,7 @@ report_inaccessible_module_error(ModuleName, ParentModule, SubModule, words("module"), sym_name(qualified(ParentModule, SubModule)), words("is inaccessible."), nl ], - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, @@ -6570,7 +6572,7 @@ report_inaccessible_module_error(ModuleName, ParentModule, SubModule, globals.io_set_extra_error_info(yes, !IO) ), write_error_pieces(Context, 0, ErrMsg, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% @@ -6610,10 +6612,10 @@ process_module_short_interfaces(ReadModules, [Import | Imports], Ext, ( % check if the imported module has already been imported ( Import = !.Module ^ module_name - ; list__member(Import, !.Module ^ parent_deps) - ; list__member(Import, !.Module ^ int_deps) - ; list__member(Import, !.Module ^ impl_deps) - ; list__member(Import, ModIndirectImports0) + ; list.member(Import, !.Module ^ parent_deps) + ; list.member(Import, !.Module ^ int_deps) + ; list.member(Import, !.Module ^ impl_deps) + ; list.member(Import, ModIndirectImports0) ) -> process_module_short_interfaces(ReadModules, Imports, Ext, @@ -6636,7 +6638,7 @@ process_module_short_interfaces(ReadModules, [Import | Imports], Ext, ShortIntItems, Items), maybe_add_int_error(ShortIntError, ModError0, ModError), - globals__io_lookup_bool_option(detailed_statistics, Statistics, !IO), + globals.io_lookup_bool_option(detailed_statistics, Statistics, !IO), maybe_report_stats(Statistics, !IO), ModIndirectImports = [Import | ModIndirectImports0], @@ -6652,7 +6654,7 @@ process_module_short_interfaces(ReadModules, [Import | Imports], Ext, ). replace_section_decls(IntStatusItem, ImpStatusItem, !Items) :- - list__map( + list.map( (pred(Item0::in, Item::out) is det :- ( Item0 = module_defn(_, Defn) - _, @@ -6708,7 +6710,7 @@ get_children(Items, IncludeDeps) :- get_children_2([], IncludeDeps, IncludeDeps). get_children_2([Item - _Context | Items], IncludeDeps0, IncludeDeps) :- ( Item = module_defn(_VarSet, include_module(Modules)) -> - list__append(IncludeDeps0, Modules, IncludeDeps1) + list.append(IncludeDeps0, Modules, IncludeDeps1) ; IncludeDeps1 = IncludeDeps0 ), @@ -6762,8 +6764,8 @@ get_accessible_children_2(!.Visible, [Item - _ | Items], !IncludeDeps) :- get_dependencies(Items, ImportDeps, UseDeps) :- get_dependencies_implementation(Items, [], IntImportDeps, [], IntUseDeps, [], ImpImportDeps, [], ImpUseDeps), - list__append(IntImportDeps, ImpImportDeps, ImportDeps), - list__append(IntUseDeps, ImpUseDeps, UseDeps). + list.append(IntImportDeps, ImpImportDeps, ImportDeps), + list.append(IntUseDeps, ImpUseDeps, UseDeps). % get_dependencies(Items, IntImportDeps, IntUseDeps, % ImpImportDeps, ImpUseDeps): @@ -6810,9 +6812,9 @@ get_dependencies_implementation([Item - _Context | Items], !IntImportDeps, !IntUseDeps, !ImpImportDeps, !ImpUseDeps) ; ( Item = module_defn(_VarSet, import(module(Modules))) -> - list__append(!.ImpImportDeps, Modules, !:ImpImportDeps) + list.append(!.ImpImportDeps, Modules, !:ImpImportDeps) ; Item = module_defn(_VarSet, use(module(Modules))) -> - list__append(!.ImpUseDeps, Modules, !:ImpUseDeps) + list.append(!.ImpUseDeps, Modules, !:ImpUseDeps) ; true ), @@ -6835,9 +6837,9 @@ get_dependencies_interface([Item - _Context | Items], !IntImportDeps, !IntUseDeps, !ImpImportDeps, !ImpUseDeps) ; ( Item = module_defn(_VarSet, import(module(Modules))) -> - list__append(!.IntImportDeps, Modules, !:IntImportDeps) + list.append(!.IntImportDeps, Modules, !:IntImportDeps) ; Item = module_defn(_VarSet, use(module(Modules))) -> - list__append(!.IntUseDeps, Modules, !:IntUseDeps) + list.append(!.IntUseDeps, Modules, !:IntUseDeps) ; true ), @@ -6889,11 +6891,11 @@ split_into_submodules(ModuleName, Items0, ModuleList, !IO) :- % check for modules declared as both nested and separate sub-modules % get_children(Items0, NestedSubmodules), - assoc_list__keys(ModuleList, SeparateSubModules), - Duplicates = set__intersect( - set__list_to_set(NestedSubmodules), - set__list_to_set(SeparateSubModules)), - ( set__empty(Duplicates) -> + assoc_list.keys(ModuleList, SeparateSubModules), + Duplicates = set.intersect( + set.list_to_set(NestedSubmodules), + set.list_to_set(SeparateSubModules)), + ( set.empty(Duplicates) -> true ; report_duplicate_modules(Duplicates, Items0, !IO) @@ -6908,7 +6910,7 @@ split_into_submodules_2(ModuleName, Items0, InParentInterface, Items, split_into_submodules_3(ModuleName, Items0, InParentInterface, InInterface0, ThisModuleItems, Items, SubModules, !IO), - map__to_assoc_list(SubModules, SubModuleList), + map.to_assoc_list(SubModules, SubModuleList), ModuleList = [ModuleName - ThisModuleItems | SubModuleList]. :- pred split_into_submodules_3(module_name::in, item_list::in, bool::in, @@ -6916,7 +6918,7 @@ split_into_submodules_2(ModuleName, Items0, InParentInterface, Items, map(module_name, item_list)::out, io::di, io::uo) is det. split_into_submodules_3(_ModuleName, [], _, _, [], [], SubModules, !IO) :- - map__init(SubModules). + map.init(SubModules). split_into_submodules_3(ModuleName, [Item | Items1], InParentInterface, InInterface0, ThisModuleItems, OtherItems, SubModules, !IO) :- @@ -6941,7 +6943,7 @@ split_into_submodules_3(ModuleName, [Item | Items1], % % Combine the sub-module declarations from the previous two steps. % - list__foldl(add_submodule, SubModules0, SubModules1, SubModules), + list.foldl(add_submodule, SubModules0, SubModules1, SubModules), % % Replace the nested submodule with an `include_module' declaration. % @@ -6960,7 +6962,7 @@ split_into_submodules_3(ModuleName, [Item | Items1], % ThisModuleItems = [], OtherItems = Items1, - map__init(SubModules) + map.init(SubModules) ; % % Otherwise, process the next item in this module. @@ -7028,11 +7030,11 @@ add_submodule(ModuleName - ModuleItemList, !SubModules) :- % should only have one `:- interface' and one `:- implementation' % section, and we don't enforce that either...) % - ( map__search(!.SubModules, ModuleName, ItemList0) -> - list__append(ModuleItemList, ItemList0, ItemList), - svmap__det_update(ModuleName, ItemList, !SubModules) + ( map.search(!.SubModules, ModuleName, ItemList0) -> + list.append(ModuleItemList, ItemList0, ItemList), + svmap.det_update(ModuleName, ItemList, !SubModules) ; - svmap__det_insert(ModuleName, ModuleItemList, !SubModules) + svmap.det_insert(ModuleName, ModuleItemList, !SubModules) ). :- pred report_error_implementation_in_interface(module_name::in, @@ -7051,7 +7053,7 @@ report_error_implementation_in_interface(ModuleName, Context, !IO) :- words("error: `:- implementation.' declaration for sub-module\n"), words("occurs in interface section of parent module.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred report_duplicate_modules(set(module_name)::in, item_list::in, io::di, io::uo) is det. @@ -7059,18 +7061,18 @@ report_error_implementation_in_interface(ModuleName, Context, !IO) :- report_duplicate_modules(Duplicates, Items, !IO) :- IsDuplicateError = (pred(SubModuleName - Context::out) is nondet :- - list__member(Item, Items), + list.member(Item, Items), Item = module_defn(_VarSet, ModuleDefn) - Context, ( ModuleDefn = module(SubModuleName) ; ModuleDefn = include_module(SubModuleNames), - list__member(SubModuleName, SubModuleNames) + list.member(SubModuleName, SubModuleNames) ), - set__member(SubModuleName, Duplicates) + set.member(SubModuleName, Duplicates) ), solutions(IsDuplicateError, DuplicateErrors), - list__foldl(report_error_duplicate_module_decl, DuplicateErrors, !IO). + list.foldl(report_error_duplicate_module_decl, DuplicateErrors, !IO). :- pred report_error_duplicate_module_decl(pair(module_name, prog_context)::in, io::di, io::uo) is det. @@ -7086,7 +7088,7 @@ report_error_duplicate_module_decl(ModuleName - Context, !IO) :- words("error: sub-module `" ++ ChildModule ++ "' declared"), words("as both a separate sub-module and a nested sub-module.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). :- pred report_items_after_end_module(prog_context::in, io::di, io::uo) is det. @@ -7117,7 +7119,7 @@ get_interface(ModuleName, IncludeImplTypes, Items0, Items) :- AddToImpl = (func(_, ImplItems) = ImplItems), get_interface_and_implementation_2(IncludeImplTypes, Items0, no, [], RevItems, AddToImpl, unit, _), - list__reverse(RevItems, Items1), + list.reverse(RevItems, Items1), maybe_add_foreign_import_module(ModuleName, Items1, Items2), order_items(Items2, Items). @@ -7129,8 +7131,8 @@ get_interface_and_implementation(ModuleName, IncludeImplTypes, AddToImpl = (func(ImplItem, ImplItems) = [ImplItem | ImplItems]), get_interface_and_implementation_2(IncludeImplTypes, Items0, no, [], RevIntItems, AddToImpl, [], RevImplItems), - list__reverse(RevIntItems, InterfaceItems0), - list__reverse(RevImplItems, ImplementationItems), + list.reverse(RevIntItems, InterfaceItems0), + list.reverse(RevImplItems, ImplementationItems), maybe_add_foreign_import_module(ModuleName, InterfaceItems0, InterfaceItems). @@ -7256,7 +7258,7 @@ get_interface_and_implementation_2(IncludeImplTypes, [ItemAndContext | Rest], get_short_interface(Items0, Kind, Items) :- get_short_interface_2(Items0, Kind, [], RevItems), - list__reverse(RevItems, Items1), + list.reverse(RevItems, Items1), maybe_strip_import_decls(Items1, Items2), order_items(Items2, Items). @@ -7302,9 +7304,9 @@ item_needs_imports(Item @ typeclass(_, _, _, _, _, _)) = ( Item ^ tc_class_methods = abstract, \+ ( - list__member(Constraint, Item ^ tc_constraints), + list.member(Constraint, Item ^ tc_constraints), Constraint = constraint(_, ConstraintArgs), - list__member(ConstraintArg, ConstraintArgs), + list.member(ConstraintArg, ConstraintArgs), type_is_nonvar(ConstraintArg) ) -> @@ -7437,13 +7439,13 @@ make_abstract_instance(Item0, Item) :- maybe_strip_import_decls(!Items) :- ( some [Item] ( - list__member(Item - _, !.Items), + list.member(Item - _, !.Items), item_needs_imports(Item) = yes ) -> true ; - list__filter( + list.filter( (pred((ThisItem - _)::in) is semidet :- \+ ( ThisItem = module_defn(_, Defn), @@ -7455,13 +7457,13 @@ maybe_strip_import_decls(!Items) :- ), ( some [Item] ( - list__member(Item - _, !.Items), + list.member(Item - _, !.Items), item_needs_foreign_imports(Item, _) ) -> true ; - list__filter( + list.filter( (pred((ThisItem - _)::in) is semidet :- ThisItem \= pragma(_, foreign_import_module(_, _)) ), !Items) @@ -7486,9 +7488,9 @@ order_items(Items0, Items) :- % at the end, to make Items as insensitive as we can to the number % of interface sections in the source file. If some of the % implementation sections are not empty, we won't be fully successful. - list__reverse(Items2, RevItems2), - list__takewhile(interface_or_import_marker, RevItems2, _, RevItems), - list__reverse(RevItems, Items). + list.reverse(Items2, RevItems2), + list.takewhile(interface_or_import_marker, RevItems2, _, RevItems), + list.reverse(RevItems, Items). :- pred interface_or_import_marker(item_and_context::in) is semidet. @@ -7551,19 +7553,19 @@ filter_unnecessary_flips([Item1, Item2 | Items0], CurPos, Items) :- do_order_items([], []). do_order_items([Item0 | Items0], OrderedItems) :- ( chunkable_item_and_context(Item0) = yes -> - list__takewhile(is_chunkable, Items0, FrontItems, RemainItems), - list__filter(is_reorderable, [Item0 | FrontItems], + list.takewhile(is_chunkable, Items0, FrontItems, RemainItems), + list.filter(is_reorderable, [Item0 | FrontItems], ReorderableItems, NonReorderableItems), - list__filter(import_or_use, ReorderableItems, + list.filter(import_or_use, ReorderableItems, ImportReorderableItems, NonImportReorderableItems), - list__filter(symname_orderable, NonReorderableItems, + list.filter(symname_orderable, NonReorderableItems, SymNameItems, NonSymNameItems), % We rely on the sort being stable to keep the items % with the same sym_names in their original order. - list__sort(compare_by_symname, SymNameItems, OrderedSymNameItems), + list.sort(compare_by_symname, SymNameItems, OrderedSymNameItems), do_order_items(RemainItems, OrderedRemainItems), - OrderedItems = list__sort(ImportReorderableItems) ++ - list__sort(NonImportReorderableItems) ++ + OrderedItems = list.sort(ImportReorderableItems) ++ + list.sort(NonImportReorderableItems) ++ OrderedSymNameItems ++ NonSymNameItems ++ OrderedRemainItems ; do_order_items(Items0, OrderedItemsTail), @@ -7785,7 +7787,7 @@ maybe_record_timestamp(ModuleName, Suffix, NeedQualifier, ( MaybeTimestamp = yes(Timestamp), TimestampInfo = module_timestamp(Suffix, Timestamp, NeedQualifier), - map__set(Timestamps0, ModuleName, TimestampInfo, Timestamps), + map.set(Timestamps0, ModuleName, TimestampInfo, Timestamps), !:Module = !.Module ^ maybe_timestamps := yes(Timestamps) ; MaybeTimestamp = no @@ -7794,27 +7796,27 @@ maybe_record_timestamp(ModuleName, Suffix, NeedQualifier, !.Module ^ maybe_timestamps = no ). -:- pred report_modification_time_warning(file_name::in, io__error::in, +:- pred report_modification_time_warning(file_name::in, io.error::in, io::di, io::uo) is det. report_modification_time_warning(SourceFileName, Error, !IO) :- - globals__io_set_option(smart_recompilation, bool(no), !IO), - globals__io_set_option(generate_item_version_numbers, bool(no), !IO), - globals__io_lookup_bool_option(warn_smart_recompilation, Warn, !IO), + globals.io_set_option(smart_recompilation, bool(no), !IO), + globals.io_set_option(generate_item_version_numbers, bool(no), !IO), + globals.io_lookup_bool_option(warn_smart_recompilation, Warn, !IO), ( Warn = yes, - io__write_string("Warning: cannot find modification time for ", !IO), - io__write_string(SourceFileName, !IO), - io__write_string(":\n", !IO), - io__error_message(Error, Msg), - io__write_string(" ", !IO), - io__write_string(Msg, !IO), - io__write_string(".\n", !IO), - io__write_string(" Smart recompilation will not work.\n", !IO), - globals__io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO), + io.write_string("Warning: cannot find modification time for ", !IO), + io.write_string(SourceFileName, !IO), + io.write_string(":\n", !IO), + io.error_message(Error, Msg), + io.write_string(" ", !IO), + io.write_string(Msg, !IO), + io.write_string(".\n", !IO), + io.write_string(" Smart recompilation will not work.\n", !IO), + globals.io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO), ( HaltAtWarn = yes, - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; HaltAtWarn = no ) @@ -7832,7 +7834,7 @@ create_java_shell_script(MainModuleName, Succeeded, !IO) :- Extension = "", module_name_to_file_name(MainModuleName, Extension, no, FileName, !IO), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Generating shell script `" ++ FileName ++ "'...\n", !IO), @@ -7841,25 +7843,25 @@ create_java_shell_script(MainModuleName, Succeeded, !IO) :- % XXX PathSeparator should be ";" on Windows PathSeparator = ":", - globals__io_lookup_accumulating_option(java_classpath, Java_Incl_Dirs0, + globals.io_lookup_accumulating_option(java_classpath, Java_Incl_Dirs0, !IO), % We prepend the .class files' directory and the current CLASSPATH. Java_Incl_Dirs = [DirName, "$CLASSPATH" | Java_Incl_Dirs0], ClassPath = string.join_list(PathSeparator, Java_Incl_Dirs), - globals__io_lookup_string_option(java_interpreter, Java, !IO), + globals.io_lookup_string_option(java_interpreter, Java, !IO), module_name_to_file_name(MainModuleName, "", no, Name_No_Extn, !IO), - io__open_output(FileName, OpenResult, !IO), + io.open_output(FileName, OpenResult, !IO), ( OpenResult = ok(ShellScript), % XXX On Windows we should output a .bat file instead - io__write_string(ShellScript, "#!/bin/sh\n", !IO), - io__write_string(ShellScript, "CLASSPATH=" ++ ClassPath ++ " ", !IO), - io__write_string(ShellScript, Java ++ " ", !IO), - io__write_string(ShellScript, Name_No_Extn ++ "\n", !IO), - io__close_output(ShellScript, !IO), - io__call_system("chmod a+x " ++ FileName, ChmodResult, !IO), + io.write_string(ShellScript, "#!/bin/sh\n", !IO), + io.write_string(ShellScript, "CLASSPATH=" ++ ClassPath ++ " ", !IO), + io.write_string(ShellScript, Java ++ " ", !IO), + io.write_string(ShellScript, Name_No_Extn ++ "\n", !IO), + io.close_output(ShellScript, !IO), + io.call_system("chmod a+x " ++ FileName, ChmodResult, !IO), ( ChmodResult = ok(Status), ( Status = 0 -> @@ -7871,18 +7873,18 @@ create_java_shell_script(MainModuleName, Succeeded, !IO) :- ) ; ChmodResult = error(Message), - unexpected(this_file, io__error_message(Message)), + unexpected(this_file, io.error_message(Message)), Succeeded = no ) ; OpenResult = error(Message), - unexpected(this_file, io__error_message(Message)), + unexpected(this_file, io.error_message(Message)), Succeeded = no ). list_class_files_for_jar(ModuleName, ClassFiles, ListClassFiles, !IO) :- - globals__io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), + globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO), + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO), AnySubdirs = UseSubdirs `or` UseGradeSubdirs, ( AnySubdirs = yes, @@ -7904,12 +7906,12 @@ list_class_files_for_jar(ModuleName, ClassFiles, ListClassFiles, !IO) :- ). get_env_classpath(Classpath, !IO) :- - io__get_environment_var("CLASSPATH", MaybeCP, !IO), + io.get_environment_var("CLASSPATH", MaybeCP, !IO), ( MaybeCP = yes(Classpath) ; MaybeCP = no, - io__get_environment_var("java.class.path", MaybeJCP, !IO), + io.get_environment_var("java.class.path", MaybeJCP, !IO), ( MaybeJCP = yes(Classpath) ; diff --git a/compiler/name_mangle.m b/compiler/name_mangle.m index 231f59ade..0d702e2e8 100644 --- a/compiler/name_mangle.m +++ b/compiler/name_mangle.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2003-2005 The University of Melbourne. +% Copyright (C) 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -23,7 +23,7 @@ % %-----------------------------------------------------------------------------% -:- module backend_libs__name_mangle. +:- module backend_libs.name_mangle. :- interface. :- import_module backend_libs.rtti. @@ -114,7 +114,7 @@ output_proc_label(ProcLabel, !IO) :- output_proc_label(ProcLabel, AddPrefix, !IO) :- ProcLabelString = proc_label_to_c_string(ProcLabel, AddPrefix), - io__write_string(ProcLabelString, !IO). + io.write_string(ProcLabelString, !IO). proc_label_to_c_string(proc(DefiningModule, PredOrFunc, PredModule, PredName, Arity, ModeInt), AddPrefix) = ProcLabelString :- @@ -125,9 +125,9 @@ proc_label_to_c_string(proc(DefiningModule, PredOrFunc, PredModule, ; OrigArity = Arity ), - string__int_to_string(OrigArity, ArityString), - string__int_to_string(ModeInt, ModeNumString), - string__append_list([LabelName, "_", ArityString, "_", ModeNumString], + string.int_to_string(OrigArity, ArityString), + string.int_to_string(ModeInt, ModeNumString), + string.append_list([LabelName, "_", ArityString, "_", ModeNumString], ProcLabelString). % For a special proc, output a label of the form: @@ -143,8 +143,8 @@ proc_label_to_c_string(special_proc(Module, SpecialPredId, TypeModule, unqualified(""), PredName, DummyArity, AddPrefix), % Figure out the ModeNumString. - string__int_to_string(TypeArity, TypeArityString), - string__int_to_string(ModeInt, ModeNumString), + string.int_to_string(TypeArity, TypeArityString), + string.int_to_string(ModeInt, ModeNumString), % Mangle all the relevent names. MangledModule = sym_name_mangle(Module), @@ -162,7 +162,7 @@ proc_label_to_c_string(special_proc(Module, SpecialPredId, TypeModule, QualifiedMangledTypeName), % Join it all together. - string__append_list([LabelName, "_", FullyQualifiedMangledTypeName, + string.append_list([LabelName, "_", FullyQualifiedMangledTypeName, "_", TypeArityString, "_", ModeNumString], ProcLabelString). @@ -220,12 +220,12 @@ dont_module_qualify_name(Name, Arity) :- Name = "main", Arity = 2 ; - string__prefix(Name, "__") + string.prefix(Name, "__") ). name_doesnt_need_mangling(Name) :- - string__is_alnum_or_underscore(Name), - \+ string__append("f_", _Suffix, Name). + string.is_alnum_or_underscore(Name), + \+ string.append("f_", _Suffix, Name). sym_name_doesnt_need_mangling(unqualified(Name)) :- name_doesnt_need_mangling(Name). @@ -239,38 +239,38 @@ sym_name_doesnt_need_mangling(qualified(ModuleName, PlainName)) :- :- func maybe_qualify_name(string, string) = string. maybe_qualify_name(Module0, Name0) = Name :- - string__append(Module0, "__", UnderscoresModule), - ( string__append(UnderscoresModule, _, Name0) -> + string.append(Module0, "__", UnderscoresModule), + ( string.append(UnderscoresModule, _, Name0) -> Name = Name0 ; - string__append(UnderscoresModule, Name0, Name) + string.append(UnderscoresModule, Name0, Name) ). %-----------------------------------------------------------------------------% output_base_typeclass_info_name(TCName, TypeNames, !IO) :- Str = make_base_typeclass_info_name(TCName, TypeNames), - io__write_string(mercury_data_prefix, !IO), - io__write_string("__", !IO), - io__write_string(Str, !IO). + io.write_string(mercury_data_prefix, !IO), + io.write_string("__", !IO), + io.write_string(Str, !IO). make_base_typeclass_info_name(TCName, TypeNames) = Str :- TCName = tc_name(ModuleName, ClassName, ClassArity), ClassSym = qualified(ModuleName, ClassName), MangledClassString = sym_name_mangle(ClassSym), - string__int_to_string(ClassArity, ArityString), + string.int_to_string(ClassArity, ArityString), MangledTypeNames = name_mangle(TypeNames), - string__append_list(["base_typeclass_info_", MangledClassString, + string.append_list(["base_typeclass_info_", MangledClassString, "__arity", ArityString, "__", MangledTypeNames], Str). %-----------------------------------------------------------------------------% output_init_name(ModuleName, !IO) :- InitName = make_init_name(ModuleName), - io__write_string(InitName, !IO). + io.write_string(InitName, !IO). output_tabling_pointer_var_name(ProcLabel, !IO) :- - io__write_string("mercury_var__table_root__", !IO), + io.write_string("mercury_var__table_root__", !IO), output_proc_label(ProcLabel, !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/opt_debug.m b/compiler/opt_debug.m index c1a778ad0..196af42a6 100644 --- a/compiler/opt_debug.m +++ b/compiler/opt_debug.m @@ -12,7 +12,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__opt_debug. +:- module ll_backend.opt_debug. :- interface. @@ -140,15 +140,15 @@ msg(OptDebug, LabelNo, Msg, !IO) :- ( OptDebug = yes, - io__write_string("\n", !IO), - io__write_string(Msg, !IO), + io.write_string("\n", !IO), + io.write_string(Msg, !IO), ( LabelNo >= 0 -> - io__write_string(", next label no: ", !IO), - io__write_int(LabelNo, !IO) + io.write_string(", next label no: ", !IO), + io.write_int(LabelNo, !IO) ; true ), - io__write_string("\n", !IO) + io.write_string("\n", !IO) ; OptDebug = no ). @@ -156,7 +156,7 @@ msg(OptDebug, LabelNo, Msg, !IO) :- maybe_dump_instrs(OptDebug, ProcLabel, Instrs, !IO) :- ( OptDebug = yes, - globals__io_lookup_bool_option(auto_comments, PrintComments, + globals.io_lookup_bool_option(auto_comments, PrintComments, !IO), dump_instrs_2(Instrs, ProcLabel, PrintComments, !IO) ; @@ -169,32 +169,32 @@ maybe_dump_instrs(OptDebug, ProcLabel, Instrs, !IO) :- dump_instrs_2([], _ProcLabel, _PrintComments, !IO). dump_instrs_2([Uinstr - Comment | Instrs], ProcLabel, PrintComments, !IO) :- ( Uinstr = label(_) -> - io__write_string(dump_instr(ProcLabel, PrintComments, Uinstr), !IO) + io.write_string(dump_instr(ProcLabel, PrintComments, Uinstr), !IO) ; Uinstr = comment(InstrComment) -> - io__write_string("\t% ", !IO), - string__foldl(print_comment_char, InstrComment, !IO) + io.write_string("\t% ", !IO), + string.foldl(print_comment_char, InstrComment, !IO) ; - io__write_string("\t", !IO), - io__write_string(dump_instr(ProcLabel, PrintComments, Uinstr), !IO) + io.write_string("\t", !IO), + io.write_string(dump_instr(ProcLabel, PrintComments, Uinstr), !IO) ), ( PrintComments = yes, Comment \= "" -> - io__write_string("\n\t\t" ++ Comment, !IO) + io.write_string("\n\t\t" ++ Comment, !IO) ; true ), - io__nl(!IO), + io.nl(!IO), dump_instrs_2(Instrs, ProcLabel, PrintComments, !IO). :- pred print_comment_char(char::in, io::di, io::uo) is det. print_comment_char(C, !IO) :- ( C = '\n' -> - io__write_string("\n\t% ", !IO) + io.write_string("\n\t% ", !IO) ; - io__write_char(C, !IO) + io.write_char(C, !IO) ). dump_intlist([]) = "". @@ -202,10 +202,10 @@ dump_intlist([H | T]) = " " ++ int_to_string(H) ++ dump_intlist(T). dump_livemap(Livemap) = - dump_livemaplist(map__to_assoc_list(Livemap)). + dump_livemaplist(map.to_assoc_list(Livemap)). dump_livemap(ProcLabel, Livemap) = - dump_livemaplist(ProcLabel, map__to_assoc_list(Livemap)). + dump_livemaplist(ProcLabel, map.to_assoc_list(Livemap)). dump_livemaplist([]) = "". dump_livemaplist([Label - Lvalset | Livemaplist]) = @@ -218,7 +218,7 @@ dump_livemaplist(ProcLabel, [Label - Lvalset | Livemaplist]) = ++ dump_livemaplist(ProcLabel, Livemaplist). dump_livevals(Lvalset) = - dump_livelist(set__to_sorted_list(Lvalset)). + dump_livelist(set.to_sorted_list(Lvalset)). dump_livelist(Lvals) = dump_livelist_2(Lvals, ""). @@ -258,7 +258,7 @@ dump_lval(sp) = "sp". dump_lval(field(MT, N, F)) = Str :- ( MT = yes(T), - string__int_to_string(T, T_str) + string.int_to_string(T, T_str) ; MT = no, T_str = "no" @@ -274,7 +274,7 @@ dump_lval(mem_ref(R)) = dump_rval(lval(Lval)) = dump_lval(Lval). dump_rval(var(Var)) = - "var(" ++ int_to_string(term__var_to_int(Var)) ++ ")". + "var(" ++ int_to_string(term.var_to_int(Var)) ++ ")". dump_rval(mkword(T, N)) = "mkword(" ++ int_to_string(T) ++ ", " ++ dump_rval(N) ++ ")". dump_rval(const(C)) = @@ -331,7 +331,7 @@ dump_const(data_addr_const(DataAddr, MaybeOffset)) = Str :- ). dump_data_addr(data_addr(ModuleName, DataName)) = - "data_addr(" ++ mdbcomp__prim_data__sym_name_to_string(ModuleName) ++ ", " + "data_addr(" ++ sym_name_to_string(ModuleName) ++ ", " ++ dump_data_name(DataName) ++ ")". dump_data_addr(rtti_addr(ctor_rtti_id(RttiTypeCtor, DataName))) = "rtti_addr(" ++ dump_rtti_type_ctor(RttiTypeCtor) ++ ", " @@ -426,8 +426,8 @@ dump_rtti_type_class_name(tc_name(ModuleName, ClassName, Arity)) = Str :- ++ name_mangle(ClassName) ++ int_to_string(Arity) ++ ")". dump_rtti_type_class_instance_types(TCTypes) = Str :- - EncodedTCTypes = list__map(rtti__encode_tc_instance_type, TCTypes), - string__append_list(EncodedTCTypes, TypesStr), + EncodedTCTypes = list.map(rtti.encode_tc_instance_type, TCTypes), + string.append_list(EncodedTCTypes, TypesStr), Str = "tc_instance(" ++ TypesStr ++ ")". dump_layout_name(label_layout(ProcLabel, LabelNum, LabelVars)) = Str :- @@ -497,7 +497,7 @@ dump_unop(hash_string) = "hash_string". dump_unop(bitwise_complement) = "bitwise_complement". dump_binop(Op) = - llds_out__binary_op_to_string(Op). + llds_out.binary_op_to_string(Op). dump_maybe_rvals([], _) = "". dump_maybe_rvals([MR | MRs], N) = Str :- @@ -558,7 +558,7 @@ dump_label(entry(_, ProcLabel)) = dump_proclabel(ProcLabel). dump_label(CurProcLabel, internal(N, ProcLabel)) = Str :- - string__int_to_string(N, N_str), + string.int_to_string(N, N_str), ( CurProcLabel = ProcLabel -> Str = "local_" ++ N_str ; @@ -698,14 +698,14 @@ dump_instr(ProcLabel, PrintComments, Instr) = Str :- T_str = "no" ; MaybeTag = yes(Tag), - string__int_to_string(Tag, T_str) + string.int_to_string(Tag, T_str) ), ( MaybeOffset = no, O_str = "no" ; MaybeOffset = yes(Offset), - string__int_to_string(Offset, O_str) + string.int_to_string(Offset, O_str) ), Str = "incr_hp(" ++ dump_lval(Lval) ++ ", " ++ T_str ++ ", " ++ O_str ++ ", " ++ dump_rval(Size) ++ ")" diff --git a/compiler/opt_util.m b/compiler/opt_util.m index b1ffcdbf2..a0a138ba5 100644 --- a/compiler/opt_util.m +++ b/compiler/opt_util.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__opt_util. +:- module ll_backend.opt_util. :- interface. :- import_module ll_backend.llds. @@ -322,7 +322,7 @@ get_prologue(Instrs0, LabelInstr, Comments, Instrs) :- -> LabelInstr = Instr1, gather_comments(Instrs2, Comments2, Instrs), - list__append(Comments1, Comments2, Comments) + list.append(Comments1, Comments2, Comments) ; unexpected(this_file, "procedure does not begin with label") ). @@ -392,10 +392,10 @@ next_assign_to_redoip([Instr | Instrs], AllowedBases, RevSkip, Instr = Uinstr - _Comment, ( Uinstr = assign(redoip(lval(Fr)), const(code_addr_const(Redoip0))), - list__member(Fr, AllowedBases) + list.member(Fr, AllowedBases) -> Redoip = Redoip0, - list__reverse(RevSkip, Skip), + list.reverse(RevSkip, Skip), Rest = Instrs ; Uinstr = mkframe(_, _) @@ -538,14 +538,14 @@ is_forkproceed_next(Instrs0, Sdprocmap, Between) :- Instrs1 = [Instr1 | Instrs2], Instr1 = Uinstr1 - _, ( Uinstr1 = if_val(lval(reg(r, 1)), label(JumpLabel)) -> - map__search(Sdprocmap, JumpLabel, BetweenJump), + map.search(Sdprocmap, JumpLabel, BetweenJump), is_sdproceed_next(Instrs2, BetweenFall), filter_out_r1(BetweenJump, yes(true), BetweenTrue0), filter_out_livevals(BetweenTrue0, Between), filter_out_r1(BetweenFall, yes(false), BetweenFalse0), filter_out_livevals(BetweenFalse0, Between) ; Uinstr1 = if_val(unop(logical_not, lval(reg(r, 1))), label(JumpLabel)) -> - map__search(Sdprocmap, JumpLabel, BetweenJump), + map.search(Sdprocmap, JumpLabel, BetweenJump), is_sdproceed_next(Instrs2, BetweenFall), filter_out_r1(BetweenJump, yes(false), BetweenFalse0), filter_out_livevals(BetweenFalse0, Between), @@ -568,7 +568,7 @@ filter_out_r1([Instr0 | Instrs0], Success, Instrs) :- straight_alternative(Instrs0, Between, After) :- straight_alternative_2(Instrs0, [], BetweenRev, After), - list__reverse(BetweenRev, Between). + list.reverse(BetweenRev, Between). :- pred straight_alternative_2(list(instruction)::in, list(instruction)::in, list(instruction)::out, list(instruction)::out) is semidet. @@ -600,7 +600,7 @@ straight_alternative_2([Instr0 | Instrs0], !Between, After) :- no_stack_straight_line(Instrs0, StraightLine, Instrs) :- no_stack_straight_line_2(Instrs0, [], RevStraightLine, Instrs), - list__reverse(RevStraightLine, StraightLine). + list.reverse(RevStraightLine, StraightLine). :- pred no_stack_straight_line_2(list(instruction)::in, list(instruction)::in, list(instruction)::out, list(instruction)::out) is det. @@ -646,7 +646,7 @@ lval_refers_stackvars(sp, no). lval_refers_stackvars(field(_, Rval, FieldNum), Refers) :- rval_refers_stackvars(Rval, Refers1), rval_refers_stackvars(FieldNum, Refers2), - bool__or(Refers1, Refers2, Refers). + bool.or(Refers1, Refers2, Refers). lval_refers_stackvars(lvar(_), _) :- unexpected(this_file, "found lvar in lval_refers_stackvars"). lval_refers_stackvars(temp(_, _), no). @@ -672,7 +672,7 @@ rval_refers_stackvars(unop(_, Rval), Refers) :- rval_refers_stackvars(binop(_, Rval1, Rval2), Refers) :- rval_refers_stackvars(Rval1, Refers1), rval_refers_stackvars(Rval2, Refers2), - bool__or(Refers1, Refers2, Refers). + bool.or(Refers1, Refers2, Refers). rval_refers_stackvars(mem_addr(MemRef), Refers) :- mem_ref_refers_stackvars(MemRef, Refers). @@ -751,7 +751,7 @@ block_refers_stackvars([Uinstr0 - _ | Instrs0], Need) :- Uinstr0 = assign(Lval, Rval), lval_refers_stackvars(Lval, Use1), rval_refers_stackvars(Rval, Use2), - bool__or(Use1, Use2, Use), + bool.or(Use1, Use2, Use), need_if_use_or_refers_stackvars(Use, Instrs0, Need) ; Uinstr0 = call(_, _, _, _, _, _), @@ -788,7 +788,7 @@ block_refers_stackvars([Uinstr0 - _ | Instrs0], Need) :- Uinstr0 = incr_hp(Lval, _, _, Rval, _), lval_refers_stackvars(Lval, Use1), rval_refers_stackvars(Rval, Use2), - bool__or(Use1, Use2, Use), + bool.or(Use1, Use2, Use), need_if_use_or_refers_stackvars(Use, Instrs0, Need) ; Uinstr0 = mark_hp(Lval), @@ -925,7 +925,7 @@ is_const_condition(const(Const), Taken) :- is_const_condition(unop(Op, Rval1), Taken) :- Op = logical_not, is_const_condition(Rval1, Taken1), - bool__not(Taken1, Taken). + bool.not(Taken1, Taken). is_const_condition(binop(Op, Rval1, Rval2), Taken) :- Op = eq, Rval1 = Rval2, @@ -1090,10 +1090,10 @@ can_use_livevals(pragma_c(_, _, _, _, _, _, _, _, _), no). instr_labels(Instr, Labels, CodeAddrs) :- instr_labels_2(Instr, Labels0, CodeAddrs1), instr_rvals_and_lvals(Instr, Rvals, Lvals), - exprn_aux__rval_list_addrs(Rvals, CodeAddrs2, _), - exprn_aux__lval_list_addrs(Lvals, CodeAddrs3, _), - list__append(CodeAddrs1, CodeAddrs2, CodeAddrs12), - list__append(CodeAddrs12, CodeAddrs3, CodeAddrs), + exprn_aux.rval_list_addrs(Rvals, CodeAddrs2, _), + exprn_aux.lval_list_addrs(Lvals, CodeAddrs3, _), + list.append(CodeAddrs1, CodeAddrs2, CodeAddrs12), + list.append(CodeAddrs12, CodeAddrs3, CodeAddrs), find_label_code_addrs(CodeAddrs, Labels0, Labels). % Find out which code addresses are also labels. @@ -1308,11 +1308,11 @@ pragma_c_components_get_rvals_and_lvals([Comp | Comps], !:Rvals, !:Lvals) :- pragma_c_component_get_rvals_and_lvals(pragma_c_inputs(Inputs), !Rvals, !Lvals) :- pragma_c_inputs_get_rvals(Inputs, NewRvals), - list__append(NewRvals, !Rvals). + list.append(NewRvals, !Rvals). pragma_c_component_get_rvals_and_lvals(pragma_c_outputs(Outputs), !Rvals, !Lvals) :- pragma_c_outputs_get_lvals(Outputs, NewLvals), - list__append(NewLvals, !Lvals). + list.append(NewLvals, !Lvals). pragma_c_component_get_rvals_and_lvals(pragma_c_user_code(_, _), !Rvals, !Lvals). pragma_c_component_get_rvals_and_lvals(pragma_c_raw_code(_, _, _), @@ -1351,15 +1351,15 @@ instr_list_rvals_and_lvals([], [], []). instr_list_rvals_and_lvals([Instr - _ | Instrs], Rvals, Lvals) :- instr_rvals_and_lvals(Instr, Rvals0, Lvals0), instr_list_rvals_and_lvals(Instrs, Rvals1, Lvals1), - list__append(Rvals0, Rvals1, Rvals), - list__append(Lvals0, Lvals1, Lvals). + list.append(Rvals0, Rvals1, Rvals), + list.append(Lvals0, Lvals1, Lvals). instr_list_labels([], [], []). instr_list_labels([Uinstr - _ | Instrs], Labels, CodeAddrs) :- instr_labels(Uinstr, Labels0, CodeAddrs0), instr_list_labels(Instrs, Labels1, CodeAddrs1), - list__append(Labels0, Labels1, Labels), - list__append(CodeAddrs0, CodeAddrs1, CodeAddrs). + list.append(Labels0, Labels1, Labels), + list.append(CodeAddrs0, CodeAddrs1, CodeAddrs). livevals_addr(label(Label), Result) :- ( @@ -1442,10 +1442,10 @@ count_temps_lval(Lval, !R, !F) :- ( Lval = temp(Type, N) -> ( Type = r, - int__max(N, !R) + int.max(N, !R) ; Type = f, - int__max(N, !F) + int.max(N, !F) ) ; Lval = field(_, Rval, FieldNum) -> count_temps_rval(Rval, !R, !F), @@ -1545,12 +1545,12 @@ touches_nondet_ctrl_instr(Uinstr, Touch) :- Uinstr = assign(Lval, Rval), touches_nondet_ctrl_lval(Lval, TouchLval), touches_nondet_ctrl_rval(Rval, TouchRval), - bool__or(TouchLval, TouchRval, Touch) + bool.or(TouchLval, TouchRval, Touch) ; Uinstr = incr_hp(Lval, _, _, Rval, _), touches_nondet_ctrl_lval(Lval, TouchLval), touches_nondet_ctrl_rval(Rval, TouchRval), - bool__or(TouchLval, TouchRval, Touch) + bool.or(TouchLval, TouchRval, Touch) ; Uinstr = mark_hp(Lval), touches_nondet_ctrl_lval(Lval, Touch) @@ -1580,7 +1580,7 @@ touches_nondet_ctrl_lval(sp, no). touches_nondet_ctrl_lval(field(_, Rval1, Rval2), Touch) :- touches_nondet_ctrl_rval(Rval1, Touch1), touches_nondet_ctrl_rval(Rval2, Touch2), - bool__or(Touch1, Touch2, Touch). + bool.or(Touch1, Touch2, Touch). touches_nondet_ctrl_lval(lvar(_), no). touches_nondet_ctrl_lval(temp(_, _), no). touches_nondet_ctrl_lval(mem_ref(Rval), Touch) :- @@ -1599,7 +1599,7 @@ touches_nondet_ctrl_rval(unop(_, Rval), Touch) :- touches_nondet_ctrl_rval(binop(_, Rval1, Rval2), Touch) :- touches_nondet_ctrl_rval(Rval1, Touch1), touches_nondet_ctrl_rval(Rval2, Touch2), - bool__or(Touch1, Touch2, Touch). + bool.or(Touch1, Touch2, Touch). touches_nondet_ctrl_rval(mem_addr(MemRef), Touch) :- touches_nondet_ctrl_mem_ref(MemRef, Touch). @@ -1617,7 +1617,7 @@ touches_nondet_ctrl_components([], no). touches_nondet_ctrl_components([C | Cs], Touch) :- touches_nondet_ctrl_component(C, Touch1), touches_nondet_ctrl_components(Cs, Touch2), - bool__or(Touch1, Touch2, Touch). + bool.or(Touch1, Touch2, Touch). % The inputs and outputs components get emitted as simple straight-line % code that do not refer to control slots. The compiler does not generate @@ -1697,10 +1697,10 @@ count_incr_hp_2([Uinstr0 - _ | Instrs], !N) :- %-----------------------------------------------------------------------------% propagate_livevals(Instrs0, Instrs) :- - list__reverse(Instrs0, RevInstrs0), - set__init(Livevals), + list.reverse(Instrs0, RevInstrs0), + set.init(Livevals), propagate_livevals_2(RevInstrs0, Livevals, RevInstrs), - list__reverse(RevInstrs, Instrs). + list.reverse(RevInstrs, Instrs). :- pred propagate_livevals_2(list(instruction)::in, set(lval)::in, list(instruction)::out) is det. @@ -1710,14 +1710,14 @@ propagate_livevals_2([Instr0 | Instrs0], Livevals0, [Instr | Instrs]) :- Instr0 = Uinstr0 - Comment, ( Uinstr0 = livevals(ThisLivevals) -> - set__union(Livevals0, ThisLivevals, Livevals), + set.union(Livevals0, ThisLivevals, Livevals), Instr = livevals(Livevals) - Comment ; Instr = Instr0, ( Uinstr0 = assign(Lval, _) -> - set__delete(Livevals0, Lval, Livevals) + set.delete(Livevals0, Lval, Livevals) ; can_instr_fall_through(Uinstr0, no) -> - set__init(Livevals) + set.init(Livevals) ; Livevals = Livevals0 ) @@ -1775,7 +1775,7 @@ replace_labels_instr(mkframe(NondetFrameInfo, MaybeRedoip0), ReplMap, MaybeRedoip = MaybeRedoip0 ). replace_labels_instr(label(Label), ReplMap, _, label(Label)) :- - ( map__search(ReplMap, Label, _) -> + ( map.search(ReplMap, Label, _) -> % The reason why we are replacing references to this label is that % it is being eliminated, and in fact should have been already % eliminated by the time replace_labels_instr is called. @@ -2085,7 +2085,7 @@ replace_labels_label_list([Label0 | Labels0], ReplMap, [Label | Labels]) :- label::out) is det. replace_labels_label(Label0, ReplMap, Label) :- - ( map__search(ReplMap, Label0, NewLabel) -> + ( map.search(ReplMap, Label0, NewLabel) -> Label = NewLabel ; Label = Label0 diff --git a/compiler/options.m b/compiler/options.m index 3de64bb8c..e69bb1a9b 100644 --- a/compiler/options.m +++ b/compiler/options.m @@ -18,7 +18,7 @@ %-----------------------------------------------------------------------------% -:- module libs__options. +:- module libs.options. :- interface. :- import_module char. @@ -804,7 +804,7 @@ option_defaults(Option, Default) :- option_defaults_2(_Category, OptionsList), - list__member(Option - Default, OptionsList). + list.member(Option - Default, OptionsList). :- pred option_defaults_2(option_category, list(pair(option, option_data))). :- mode option_defaults_2(in, out) is det. @@ -1100,14 +1100,14 @@ option_defaults_2(code_gen_option, [ max_jump_table_size - int(0), % 0 indicates any size. max_specialized_do_call_closure - int(5), - % mercury__do_call_closure_N + % mercury.do_call_closure_N % exists for N <= option_value; % set to -1 to disable. % Should be less than or equal to % max_spec_explicit_arg % in tools/make_spec_ho_call. max_specialized_do_call_class_method - int(6), - % mercury__do_call_class_method_N + % mercury.do_call_class_method_N % exists for N <= option_value; % set to -1 to disable. % Should be less than or equal to @@ -2218,58 +2218,58 @@ special_handler(grade, string(Grade), OptionTable0, Result) :- Result = error("invalid grade `" ++ Grade ++ "'") ). special_handler(il, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, target, string("il"), OptionTable). + map.set(OptionTable0, target, string("il"), OptionTable). special_handler(il_only, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, target, string("il"), OptionTable1), - map__set(OptionTable1, target_code_only, bool(yes), OptionTable). + map.set(OptionTable0, target, string("il"), OptionTable1), + map.set(OptionTable1, target_code_only, bool(yes), OptionTable). special_handler(compile_to_c, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, target, string("c"), OptionTable1), - map__set(OptionTable1, target_code_only, bool(yes), OptionTable). + map.set(OptionTable0, target, string("c"), OptionTable1), + map.set(OptionTable1, target_code_only, bool(yes), OptionTable). special_handler(java, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, target, string("java"), OptionTable). + map.set(OptionTable0, target, string("java"), OptionTable). special_handler(java_only, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, target, string("java"), OptionTable1), - map__set(OptionTable1, target_code_only, bool(yes), OptionTable). + map.set(OptionTable0, target, string("java"), OptionTable1), + map.set(OptionTable1, target_code_only, bool(yes), OptionTable). special_handler(profiling, bool(Value), OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, profile_time, bool(Value), OptionTable1), - map__set(OptionTable1, profile_calls, bool(Value), OptionTable2), - map__set(OptionTable2, profile_memory, bool(no), OptionTable3), - map__set(OptionTable3, profile_deep, bool(no), OptionTable). + map.set(OptionTable0, profile_time, bool(Value), OptionTable1), + map.set(OptionTable1, profile_calls, bool(Value), OptionTable2), + map.set(OptionTable2, profile_memory, bool(no), OptionTable3), + map.set(OptionTable3, profile_deep, bool(no), OptionTable). special_handler(time_profiling, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, profile_time, bool(yes), OptionTable1), - map__set(OptionTable1, profile_calls, bool(yes), OptionTable2), - map__set(OptionTable2, profile_memory, bool(no), OptionTable3), - map__set(OptionTable3, profile_deep, bool(no), OptionTable). + map.set(OptionTable0, profile_time, bool(yes), OptionTable1), + map.set(OptionTable1, profile_calls, bool(yes), OptionTable2), + map.set(OptionTable2, profile_memory, bool(no), OptionTable3), + map.set(OptionTable3, profile_deep, bool(no), OptionTable). special_handler(memory_profiling, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, profile_time, bool(no), OptionTable1), - map__set(OptionTable1, profile_calls, bool(yes), OptionTable2), - map__set(OptionTable2, profile_memory, bool(yes), OptionTable3), - map__set(OptionTable3, profile_deep, bool(no), OptionTable). + map.set(OptionTable0, profile_time, bool(no), OptionTable1), + map.set(OptionTable1, profile_calls, bool(yes), OptionTable2), + map.set(OptionTable2, profile_memory, bool(yes), OptionTable3), + map.set(OptionTable3, profile_deep, bool(no), OptionTable). special_handler(deep_profiling, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, profile_time, bool(no), OptionTable1), - map__set(OptionTable1, profile_calls, bool(no), OptionTable2), - map__set(OptionTable2, profile_memory, bool(no), OptionTable3), - map__set(OptionTable3, profile_deep, bool(yes), OptionTable). + map.set(OptionTable0, profile_time, bool(no), OptionTable1), + map.set(OptionTable1, profile_calls, bool(no), OptionTable2), + map.set(OptionTable2, profile_memory, bool(no), OptionTable3), + map.set(OptionTable3, profile_deep, bool(yes), OptionTable). special_handler(inlining, bool(Value), OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, inline_simple, bool(Value), OptionTable1), - map__set(OptionTable1, inline_builtins, bool(Value), OptionTable2), - map__set(OptionTable2, inline_single_use, bool(Value), OptionTable3), + map.set(OptionTable0, inline_simple, bool(Value), OptionTable1), + map.set(OptionTable1, inline_builtins, bool(Value), OptionTable2), + map.set(OptionTable2, inline_single_use, bool(Value), OptionTable3), ( Value = yes, - map__set(OptionTable3, inline_compound_threshold, int(10), OptionTable) + map.set(OptionTable3, inline_compound_threshold, int(10), OptionTable) ; Value = no, - map__set(OptionTable3, inline_compound_threshold, int(0), OptionTable) + map.set(OptionTable3, inline_compound_threshold, int(0), OptionTable) ). special_handler(everything_in_one_c_function, none, OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, procs_per_c_function, int(0), + map.set(OptionTable0, procs_per_c_function, int(0), OptionTable). special_handler(reclaim_heap_on_failure, bool(Value), OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, reclaim_heap_on_semidet_failure, bool(Value), + map.set(OptionTable0, reclaim_heap_on_semidet_failure, bool(Value), OptionTable1), - map__set(OptionTable1, reclaim_heap_on_nondet_failure, bool(Value), + map.set(OptionTable1, reclaim_heap_on_nondet_failure, bool(Value), OptionTable). special_handler(strict_sequential, none, OptionTable0, ok(OptionTable)) :- override_options([ @@ -2279,7 +2279,7 @@ special_handler(strict_sequential, none, OptionTable0, ok(OptionTable)) :- ], OptionTable0, OptionTable). special_handler(inhibit_warnings, bool(Inhibit), OptionTable0, ok(OptionTable)) :- - bool__not(Inhibit, Enable), + bool.not(Inhibit, Enable), override_options([ inhibit_accumulator_warnings - bool(Inhibit), warn_singleton_vars - bool(Enable), @@ -2321,13 +2321,13 @@ special_handler(opt_level, int(N0), OptionTable0, ok(OptionTable)) :- ; N = N0 ), - map__set(OptionTable0, opt_level_number, int(N), OptionTable1), + map.set(OptionTable0, opt_level_number, int(N), OptionTable1), set_opt_level(N, OptionTable1, OptionTable). special_handler(optimize_saved_vars, bool(Optimize), OptionTable0, ok(OptionTable)) :- - map__set(OptionTable0, optimize_saved_vars_const, bool(Optimize), + map.set(OptionTable0, optimize_saved_vars_const, bool(Optimize), OptionTable1), - map__set(OptionTable1, optimize_saved_vars_cell, bool(Optimize), + map.set(OptionTable1, optimize_saved_vars_cell, bool(Optimize), OptionTable). special_handler(mercury_library_directory_special, string(Dir), OptionTable0, ok(OptionTable)) :- @@ -2336,7 +2336,7 @@ special_handler(mercury_library_directory_special, string(Dir), special_handler(mercury_library_special, string(Lib), OptionTable0, ok(OptionTable)) :- OptionTable = - list__foldl(append_to_accumulating_option, [ + list.foldl(append_to_accumulating_option, [ link_libraries - Lib, mercury_libraries - Lib, init_files - (Lib ++ ".init") @@ -2344,12 +2344,12 @@ special_handler(mercury_library_special, string(Lib), special_handler(mercury_standard_library_directory_special, maybe_string(MaybeStdLibDir), OptionTable0, ok(OptionTable)) :- OptionTable = - map__set(map__set(OptionTable0, + map.set(map.set(OptionTable0, mercury_standard_library_directory, maybe_string(MaybeStdLibDir)), mercury_configuration_directory, maybe_string(MaybeStdLibDir)). special_handler(mercury_configuration_directory_special, string(ConfDir), OptionTable0, ok(OptionTable)) :- - OptionTable = map__set(OptionTable0, mercury_configuration_directory, + OptionTable = map.set(OptionTable0, mercury_configuration_directory, maybe_string(yes(ConfDir))). special_handler(quoted_cflag, string(Flag), OptionTable0, ok(OptionTable)) :- @@ -2396,10 +2396,10 @@ option_table_add_mercury_library_directory(OptionTable0, Dir) = % The link_library_directories for Mercury libraries are grade % dependent, so they need to be handled in handle_options.m % when we know the grade. - list__foldl(append_to_accumulating_option, [ - search_directories - dir__make_path_name(Dir, "ints"), - c_include_directory - dir__make_path_name(Dir, "inc"), - init_file_directories - dir__make_path_name(Dir, "modules"), + list.foldl(append_to_accumulating_option, [ + search_directories - dir.make_path_name(Dir, "ints"), + c_include_directory - dir.make_path_name(Dir, "inc"), + init_file_directories - dir.make_path_name(Dir, "modules"), mercury_library_directories - Dir ], OptionTable0). @@ -2409,7 +2409,7 @@ option_table_add_mercury_library_directory(OptionTable0, Dir) = append_to_accumulating_option(Option - Value, OptionTable0) = OptionTable0 ^ elem(Option) := accumulating( - getopt_io__lookup_accumulating_option(OptionTable0, Option) + getopt_io.lookup_accumulating_option(OptionTable0, Option) ++ [Value]). :- pred set_opt_level(int::in, option_table::in, option_table::out) is det. @@ -2442,7 +2442,7 @@ enable_opt_levels(N0, N, OptionTable0, OptionTable) :- override_options([], OptionTable, OptionTable). override_options([Option - Value | Settings], OptionTable0, OptionTable) :- - map__set(OptionTable0, Option, Value, OptionTable1), + map.set(OptionTable0, Option, Value, OptionTable1), override_options(Settings, OptionTable1, OptionTable). %-----------------------------------------------------------------------------% @@ -2502,7 +2502,7 @@ opt_level(1, OptionTable, [ optimize_tailcalls - bool(yes) % dups? ]) :- - getopt_io__lookup_bool_option(OptionTable, have_delay_slot, DelaySlot). + getopt_io.lookup_bool_option(OptionTable, have_delay_slot, DelaySlot). % Optimization level 2: apply optimizations which have a good % payoff relative to their cost; but include optimizations @@ -2621,23 +2621,23 @@ handle_quoted_flag(Option, Flag, Table, append_to_accumulating_option(Option - quote_arg(Flag), Table)). quote_arg(Arg0) = Arg :- - % XXX Instead of using dir__use_windows_paths, this should really + % XXX Instead of using dir.use_windows_paths, this should really % test whether we are using a Unix or Windows shell. - ( dir__use_windows_paths -> + ( dir.use_windows_paths -> ( ( string_contains_whitespace(Arg0) ; Arg0 = "" ) -> Arg = """" ++ Arg0 ++ """" ; Arg = Arg0 ) ; - ArgList = quote_arg_unix(string__to_char_list(Arg0)), + ArgList = quote_arg_unix(string.to_char_list(Arg0)), ( ArgList = [] -> Arg = """""" ; - list__member(Char, ArgList), - \+ ( char__is_alnum_or_underscore(Char) + list.member(Char, ArgList), + \+ ( char.is_alnum_or_underscore(Char) ; Char = ('-') ; Char = ('/') ; Char = ('.') @@ -2645,9 +2645,9 @@ quote_arg(Arg0) = Arg :- ; Char = (':') ) -> - Arg = """" ++ string__from_char_list(ArgList) ++ """" + Arg = """" ++ string.from_char_list(ArgList) ++ """" ; - Arg = string__from_char_list(ArgList) + Arg = string.from_char_list(ArgList) ) ). @@ -2681,8 +2681,8 @@ quote_char_unix('$'). %-----------------------------------------------------------------------------% options_help --> - io__write_string("\t-?, -h, --help\n"), - io__write_string("\t\tPrint this usage message.\n"), + io.write_string("\t-?, -h, --help\n"), + io.write_string("\t\tPrint this usage message.\n"), options_help_warning, options_help_verbosity, options_help_output, @@ -2706,7 +2706,7 @@ options_help --> :- pred options_help_warning(io::di, io::uo) is det. options_help_warning --> - io__write_string("\nWarning Options:\n"), + io.write_string("\nWarning Options:\n"), write_tabbed_lines([ "-w, --inhibit-warnings", "\tDisable all warning messages.", @@ -2811,7 +2811,7 @@ options_help_warning --> :- pred options_help_verbosity(io::di, io::uo) is det. options_help_verbosity --> - io__write_string("\nVerbosity Options:\n"), + io.write_string("\nVerbosity Options:\n"), write_tabbed_lines([ "-v, --verbose", "\tOutput progress messages at each stage in the compilation.", @@ -2898,7 +2898,7 @@ options_help_verbosity --> :- pred options_help_output(io::di, io::uo) is det. options_help_output --> - io__write_string("\nOutput Options:\n"), + io.write_string("\nOutput Options:\n"), write_tabbed_lines([ "These options are mutually exclusive.", "Only the first one specified will apply.", @@ -2976,7 +2976,7 @@ options_help_output --> :- pred options_help_aux_output(io::di, io::uo) is det. options_help_aux_output --> - io__write_string("\nAuxiliary Output Options:\n"), + io.write_string("\nAuxiliary Output Options:\n"), write_tabbed_lines([ "--smart-recompilation", "\tWhen compiling, write program dependency information", @@ -3032,9 +3032,9 @@ options_help_aux_output --> % "\tactions, not the printing of actions or declarative", % "\tdebugging. This reduces the size of the I/O action table.", % "--trace-table-io-states", -% "\tWhen tabling I/O actions, table the io__state arguments", +% "\tWhen tabling I/O actions, table the io.state arguments", % "\ttogether with the others. This should be required iff", -% "\tvalues of type io__state actually contain information.", +% "\tvalues of type io.state actually contain information.", % "--trace-table-io-require", % "\tRequire the tabling of I/O actions, i.e. generate an error", % "\tif an I/O primitive does not have the tabled_for_io", @@ -3132,8 +3132,8 @@ options_help_aux_output --> :- pred options_help_semantics(io::di, io::uo) is det. options_help_semantics --> - io__write_string("\nLanguage semantics options:\n"), - io__write_string("(See the Mercury language reference manual for detailed explanations.)\n"), + io.write_string("\nLanguage semantics options:\n"), + io.write_string("(See the Mercury language reference manual for detailed explanations.)\n"), write_tabbed_lines([ "--no-reorder-conj", "\tExecute conjunctions left-to-right except where the modes imply", @@ -3170,7 +3170,7 @@ options_help_semantics --> :- pred options_help_ctgc(io::di, io::uo) is det. options_help_ctgc --> - io__write_string("\nCompile Time Garbage Collection Options:\n"), + io.write_string("\nCompile Time Garbage Collection Options:\n"), write_tabbed_lines([ "--structure-sharing", "\tPerform structure sharing analysis for all encountered", @@ -3184,7 +3184,7 @@ options_help_ctgc --> :- pred options_help_termination(io::di, io::uo) is det. options_help_termination --> - io__write_string("\nTermination Analysis Options:\n"), + io.write_string("\nTermination Analysis Options:\n"), write_tabbed_lines([ "--enable-term, --enable-termination", "\tAnalyse each predicate to discover if it terminates.", @@ -3262,7 +3262,7 @@ options_help_termination --> :- pred options_help_compilation_model(io::di, io::uo) is det. options_help_compilation_model --> - io__write_string("\nCompilation model options:\n"), + io.write_string("\nCompilation model options:\n"), write_tabbed_lines([ "The following compilation options affect the generated", "code in such a way that the entire program must be", @@ -3288,7 +3288,7 @@ options_help_compilation_model --> "\twill result in an error at link time." ]), - io__write_string("\n Target selection compilation model options:\n"), + io.write_string("\n Target selection compilation model options:\n"), write_tabbed_lines([ "--target c\t\t\t(grades: none, reg, jump, fast,", "\t\t\t\t\tasm_jump, asm_fast, hl, hlc)", @@ -3336,8 +3336,8 @@ options_help_compilation_model --> "\tcode." ]), - io__write_string("\n Optional feature compilation model options:\n"), - io__write_string(" Debugging\n"), + io.write_string("\n Optional feature compilation model options:\n"), + io.write_string(" Debugging\n"), write_tabbed_lines([ "--debug\t\t\t\t(grade modifier: `.debug')", "\tEnable Mercury-level debugging.", @@ -3354,7 +3354,7 @@ options_help_compilation_model --> "\tThis option is not yet supported for the `--high-level-code'", "\tback-ends." ]), - io__write_string(" Profiling\n"), + io.write_string(" Profiling\n"), write_tabbed_lines([ "-p, --profiling, --time-profiling", "\t\t\t\t(grade modifier: `.prof')", @@ -3403,7 +3403,7 @@ options_help_compilation_model --> "\t--no-highlevel-code." ]), - io__write_string(" Miscellaneous optional features\n"), + io.write_string(" Miscellaneous optional features\n"), write_tabbed_lines([ "--gc {none, boehm, mps, accurate, automatic}", "--garbage-collection {none, boehm, mps, accurate, automatic}", @@ -3440,7 +3440,7 @@ options_help_compilation_model --> "\textend the stack when this is needed." ]), - io__write_string("\n LLDS back-end compilation model options:\n"), + io.write_string("\n LLDS back-end compilation model options:\n"), write_tabbed_lines([ "--gcc-global-registers\t\t(grades: reg, fast, asm_fast)", @@ -3469,7 +3469,7 @@ options_help_compilation_model --> "\tsystems running Unix. On other systems it has no effect." ]), - io__write_string("\n MLDS back-end compilation model options:\n"), + io.write_string("\n MLDS back-end compilation model options:\n"), write_tabbed_lines([ % These grades (hl_nest, and hlc_nest) are not yet documented, % because the --gcc-nested-functions option is not yet documented. @@ -3528,7 +3528,7 @@ options_help_compilation_model --> % "\trather than on the stack.", % % ]), -% io__write_string("\n IL back-end compilation model options:\n"), +% io.write_string("\n IL back-end compilation model options:\n"), % write_tabbed_lines([ % % The --verifiable-code option is not yet documented because it is not yet fully @@ -3562,8 +3562,8 @@ options_help_compilation_model --> % "\tthe Microsoft CLR implementation, do not support them." ]), - io__write_string("\n Developer compilation model options:\n"), - io__write_string("\n Data representation\n"), + io.write_string("\n Developer compilation model options:\n"), + io.write_string("\n Data representation\n"), write_tabbed_lines([ "--tags {none, low, high} (This option is not for general use.)", "\tSpecify whether to use the low bits or the high bits of ", @@ -3617,7 +3617,7 @@ options_help_compilation_model --> % "\tBox no-tag types. This option is disabled by default." ]), - io__write_string("\n Developer optional features\n"), + io.write_string("\n Developer optional features\n"), write_tabbed_lines([ "--use-minimal-model-stack-copy", "(This option is not for general use.)", @@ -3682,7 +3682,7 @@ options_help_compilation_model --> :- pred options_help_code_generation(io::di, io::uo) is det. options_help_code_generation --> - io__write_string("\nCode generation options:\n"), + io.write_string("\nCode generation options:\n"), write_tabbed_lines([ "--low-level-debug", "\tEnables various low-level debugging stuff, that was in", @@ -3757,7 +3757,7 @@ options_help_code_generation --> ]), - io__write_string("\n Code generation target options:\n"), + io.write_string("\n Code generation target options:\n"), write_tabbed_lines([ "--branch-delay-slot \t(This option is not for general use.)", "\tAssume that branch instructions have a delay slot.", @@ -3778,7 +3778,7 @@ options_help_code_generation --> :- pred options_help_optimization(io::di, io::uo) is det. options_help_optimization --> - io__write_string("\nOptimization Options:\n"), + io.write_string("\nOptimization Options:\n"), write_tabbed_lines([ "-O , --opt-level , --optimization-level ", "\tSet optimization level to .", @@ -3834,7 +3834,7 @@ options_help_optimization --> :- pred options_help_hlds_hlds_optimization(io::di, io::uo) is det. options_help_hlds_hlds_optimization --> - io__write_string("\n High-level (HLDS -> HLDS) optimizations:\n"), + io.write_string("\n High-level (HLDS -> HLDS) optimizations:\n"), write_tabbed_lines([ "--no-inlining", "\tDisable all forms of inlining.", @@ -4033,7 +4033,7 @@ options_help_hlds_hlds_optimization --> :- pred options_help_hlds_llds_optimization(io::di, io::uo) is det. options_help_hlds_llds_optimization --> - io__write_string("\n Medium-level (HLDS -> LLDS) optimizations:\n"), + io.write_string("\n Medium-level (HLDS -> LLDS) optimizations:\n"), write_tabbed_lines([ "--no-smart-indexing", "\tGenerate switches as a simple if-then-else chains;", @@ -4082,7 +4082,7 @@ options_help_hlds_llds_optimization --> :- pred options_help_llds_llds_optimization(io::di, io::uo) is det. options_help_llds_llds_optimization --> - io__write_string("\n Low-level (LLDS -> LLDS) optimizations:\n"), + io.write_string("\n Low-level (LLDS -> LLDS) optimizations:\n"), write_tabbed_lines([ "--no-common-data", "\tDisable optimization of common data structures.", @@ -4127,7 +4127,7 @@ options_help_llds_llds_optimization --> :- pred options_help_mlds_mlds_optimization(io::di, io::uo) is det. options_help_mlds_mlds_optimization --> - io__write_string("\n MLDS -> MLDS optimizations:\n"), + io.write_string("\n MLDS -> MLDS optimizations:\n"), write_tabbed_lines([ "--no-mlds-optimize", "\tDisable the MLDS->MLDS optimization passes.", @@ -4150,7 +4150,7 @@ options_help_mlds_mlds_optimization --> :- pred options_help_output_optimization(io::di, io::uo) is det. options_help_output_optimization --> - io__write_string("\n Output-level (LLDS -> C) optimizations:\n"), + io.write_string("\n Output-level (LLDS -> C) optimizations:\n"), write_tabbed_lines([ "--use-macro-for-redo-fail", "\tEmit the fail or redo macro instead of a branch", @@ -4173,7 +4173,7 @@ options_help_output_optimization --> :- pred options_help_target_code_compilation(io::di, io::uo) is det. options_help_target_code_compilation --> - io__write_string("\n Target code compilation:\n"), + io.write_string("\n Target code compilation:\n"), write_tabbed_lines([ "\tNote that if you are using Mmake, you need to pass these", "\toptions to the target code compiler (e.g. `mgnuc')", @@ -4274,7 +4274,7 @@ options_help_target_code_compilation --> :- pred options_help_link(io::di, io::uo) is det. options_help_link --> - io__write_string("\nLink Options:\n"), + io.write_string("\nLink Options:\n"), write_tabbed_lines([ "-o , --output-file ", "\tSpecify the name of the final executable.", @@ -4397,7 +4397,7 @@ options_help_link --> :- pred options_help_build_system(io::di, io::uo) is det. options_help_build_system --> - io__write_string("\nBuild System Options:\n"), + io.write_string("\nBuild System Options:\n"), write_tabbed_lines([ % `--invoked-by-mmc-make' is for internal use by the % compiler. `mmc --make' passes it as the first argument @@ -4497,7 +4497,7 @@ options_help_build_system --> :- pred options_help_misc(io::di, io::uo) is det. options_help_misc --> - io__write_string("\nMiscellaneous Options:\n"), + io.write_string("\nMiscellaneous Options:\n"), write_tabbed_lines([ "--filenames-from-stdin", "\tRead then compile a newline terminated module name or", @@ -4518,9 +4518,9 @@ options_help_misc --> write_tabbed_lines([], !IO). write_tabbed_lines([Str | Strs], !IO) :- - io__write_char('\t', !IO), - io__write_string(Str, !IO), - io__write_char('\n', !IO), + io.write_char('\t', !IO), + io.write_string(Str, !IO), + io.write_char('\n', !IO), write_tabbed_lines(Strs, !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/options_file.m b/compiler/options_file.m index a4783ac00..0b1bababf 100644 --- a/compiler/options_file.m +++ b/compiler/options_file.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module make__options_file. +:- module make.options_file. :- interface. :- import_module mdbcomp.prim_data. @@ -114,7 +114,7 @@ ; command_line ; environment. -options_variables_init = map__init. +options_variables_init = map.init. read_args_file(OptionsFile, MaybeMCFlags, !IO) :- read_options_file(OptionsFile, options_variables_init, MaybeVariables, @@ -129,14 +129,14 @@ read_args_file(OptionsFile, MaybeMCFlags, !IO) :- MaybeMCFlags = yes(MCFlags) ; FlagsResult = unset, - io__write_string("mercury_compile: internal error: " ++ + io.write_string("mercury_compile: internal error: " ++ "arguments file does not set MCFLAGS.\n", !IO), MaybeMCFlags = no ; FlagsResult = error(Msg), MaybeMCFlags = no, - io__write_string(Msg, !IO), - io__nl(!IO) + io.write_string(Msg, !IO), + io.nl(!IO) ) ; MaybeVariables = no, @@ -221,20 +221,20 @@ read_options_file_params(ErrorIfNotExist, Search, MaybeDirName, OptionsFile0, ( OptionsFile0 = "-" -> % Read from standard input. debug_msg(write_reading_options_file_stdin, !IO), - read_options_lines(dir__this_directory, !Variables, !IO), + read_options_lines(dir.this_directory, !Variables, !IO), debug_msg(write_done, !IO) ; debug_msg(write_reading_options_file(OptionsFile0), !IO), ( Search = search, - globals__io_lookup_accumulating_option(options_search_directories, + globals.io_lookup_accumulating_option(options_search_directories, SearchDirs, !IO) ; Search = no_search, - SearchDirs = [dir__this_directory] + SearchDirs = [dir.this_directory] ), - ( dir__split_name(OptionsFile0, OptionsDir, OptionsFile) -> - ( dir__path_name_is_absolute(OptionsDir) -> + ( dir.split_name(OptionsFile0, OptionsDir, OptionsFile) -> + ( dir.path_name_is_absolute(OptionsDir) -> FileToFind = OptionsFile, Dirs = [OptionsDir] ; MaybeDirName = yes(DirName) -> @@ -248,15 +248,15 @@ read_options_file_params(ErrorIfNotExist, Search, MaybeDirName, OptionsFile0, Dirs = SearchDirs, FileToFind = OptionsFile0 ), - io__input_stream(OldInputStream, !IO), + io.input_stream(OldInputStream, !IO), search_for_file_returning_dir(Dirs, FileToFind, MaybeDir, !IO), ( MaybeDir = ok(FoundDir), debug_msg(write_reading_options_file(FoundDir/FileToFind), !IO), read_options_lines(FoundDir, !Variables, !IO), - io__set_input_stream(OldInputStream, OptionsStream, !IO), - io__close_input(OptionsStream, !IO) + io.set_input_stream(OldInputStream, OptionsStream, !IO), + io.close_input(OptionsStream, !IO) ; MaybeDir = error(_), ( @@ -266,10 +266,10 @@ read_options_file_params(ErrorIfNotExist, Search, MaybeDirName, OptionsFile0, ; ErrorFile = FileToFind ), - io__write_string("Error reading options file `", !IO), - io__write_string(ErrorFile, !IO), - io__write_string("'.\n", !IO), - io__set_exit_status(1, !IO) + io.write_string("Error reading options file `", !IO), + io.write_string(ErrorFile, !IO), + io.write_string("'.\n", !IO), + io.set_exit_status(1, !IO) ; ErrorIfNotExist = no_error ) @@ -280,34 +280,34 @@ read_options_file_params(ErrorIfNotExist, Search, MaybeDirName, OptionsFile0, :- pred write_reading_options_file_stdin(io::di, io::uo) is det. write_reading_options_file_stdin(!IO) :- - io__write_string("Reading options file from stdin...", !IO). + io.write_string("Reading options file from stdin...", !IO). :- pred write_reading_options_file(string::in, io::di, io::uo) is det. write_reading_options_file(FileName, !IO) :- - io__write_string("Reading options file ", !IO), - io__write_string(FileName, !IO), - io__nl(!IO). + io.write_string("Reading options file ", !IO), + io.write_string(FileName, !IO), + io.nl(!IO). :- pred write_done(io::di, io::uo) is det. write_done(!IO) :- - io__write_string("done.\n", !IO). + io.write_string("done.\n", !IO). :- func maybe_add_path_name(dir_name, file_name) = file_name. maybe_add_path_name(Dir, File) = - ( Dir = dir__this_directory -> + ( Dir = dir.this_directory -> File ; - dir__make_path_name(Dir, File) + dir.make_path_name(Dir, File) ). :- pred read_options_lines(dir_name::in, options_variables::in, options_variables::out, io::di, io::uo) is det. read_options_lines(Dir, !Variables, !IO) :- - io__get_line_number(LineNumber, !IO), + io.get_line_number(LineNumber, !IO), promise_equivalent_solutions [LineResult, !:IO] ( read_options_lines_2(Dir, !.Variables, LineResult, !IO) ), @@ -322,7 +322,7 @@ read_options_lines(Dir, !Variables, !IO) :- ; LineResult = exception(Exception), ( Exception = univ(options_file_error(Error)) -> - io__input_stream_name(FileName, !IO), + io.input_stream_name(FileName, !IO), write_error_pieces(term.context_init(FileName, LineNumber), 0, [words(Error)], !IO), % @@ -366,7 +366,7 @@ read_options_lines_3(Dir, !.Variables, !:Variables - FoundEOF, !IO) :- IncludedFilesChars0, IncludedFilesChars, UndefVars, !IO), report_undefined_variables(UndefVars, !IO), IncludedFileNames = split_into_words(IncludedFilesChars), - list__foldl2( + list.foldl2( read_options_file_params(ErrorIfNotExist, search, yes(Dir)), IncludedFileNames, !Variables, !IO) ) @@ -374,10 +374,10 @@ read_options_lines_3(Dir, !.Variables, !:Variables - FoundEOF, !IO) :- :- pred read_options_line(bool::out, list(char)::out, io::di, io::uo) is det. -read_options_line(FoundEOF, list__reverse(RevChars), !IO) :- - io__ignore_whitespace(SpaceResult, !IO), +read_options_line(FoundEOF, list.reverse(RevChars), !IO) :- + io.ignore_whitespace(SpaceResult, !IO), ( SpaceResult = error(Error) -> - throw(options_file_error(io__error_message(Error))) + throw(options_file_error(io.error_message(Error))) ; true ), @@ -387,13 +387,13 @@ read_options_line(FoundEOF, list__reverse(RevChars), !IO) :- io::di, io::uo) is det. read_options_line_2(FoundEOF, !Chars, !IO) :- - read_item_or_eof(io__read_char, MaybeChar, !IO), + read_item_or_eof(io.read_char, MaybeChar, !IO), ( MaybeChar = yes(Char), ( Char = '#' -> skip_comment_line(FoundEOF, !IO) ; Char = ('\\') -> - read_item_or_eof(io__read_char, MaybeChar2, !IO), + read_item_or_eof(io.read_char, MaybeChar2, !IO), ( MaybeChar2 = yes(Char2), ( Char2 = '\n' -> @@ -425,17 +425,17 @@ update_variable(VarName, AddToValue, NewValue0, !Variables, !IO) :- expand_variables(!.Variables, NewValue0, NewValue1, Undef, !IO), report_undefined_variables(Undef, !IO), Words1 = split_into_words(NewValue1), - io__get_environment_var(VarName, MaybeEnvValue, !IO), + io.get_environment_var(VarName, MaybeEnvValue, !IO), ( MaybeEnvValue = yes(EnvValue) -> - Value = string__to_char_list(EnvValue), + Value = string.to_char_list(EnvValue), Words = split_into_words(Value), - OptVarValue = options_variable_value(string__to_char_list(EnvValue), + OptVarValue = options_variable_value(string.to_char_list(EnvValue), Words, environment), - map__set(!.Variables, VarName, OptVarValue, !:Variables) + map.set(!.Variables, VarName, OptVarValue, !:Variables) ; - map__search(!.Variables, VarName, + map.search(!.Variables, VarName, options_variable_value(OldValue, OldWords, Source)) -> ( @@ -455,11 +455,11 @@ update_variable(VarName, AddToValue, NewValue0, !Variables, !IO) :- ), OptVarValue = options_variable_value(NewValue, Words, options_file), - map__set(!.Variables, VarName, OptVarValue, !:Variables) + map.set(!.Variables, VarName, OptVarValue, !:Variables) ) ; OptVarValue = options_variable_value(NewValue1, Words1, options_file), - map__set(!.Variables, VarName, OptVarValue, !:Variables) + map.set(!.Variables, VarName, OptVarValue, !:Variables) ). :- pred expand_variables(options_variables::in, list(char)::in, @@ -467,8 +467,8 @@ update_variable(VarName, AddToValue, NewValue0, !Variables, !IO) :- expand_variables(Variables, Chars0, Chars, UndefVars, !IO) :- expand_variables_2(Variables, Chars0, [], RevChars, [], RevUndefVars, !IO), - list__reverse(RevChars, Chars), - list__reverse(RevUndefVars, UndefVars). + list.reverse(RevChars, Chars), + list.reverse(RevUndefVars, UndefVars). :- pred expand_variables_2(options_variables::in, list(char)::in, list(char)::in, list(char)::out, list(string)::in, list(string)::out, @@ -506,7 +506,7 @@ expand_variables_2(Variables, [Char | Chars], !RevChars, !RevUndef, !IO) :- ) ; Chars4 = Chars1, - VarName = string__char_to_string(Char2) + VarName = string.char_to_string(Char2) ), lookup_variable_chars(Variables, VarName, VarChars, !RevUndef, !IO), @@ -523,22 +523,22 @@ expand_variables_2(Variables, [Char | Chars], !RevChars, !RevUndef, !IO) :- :- pred report_undefined_variables(list(string)::in, io::di, io::uo) is det. report_undefined_variables(Vars, !IO) :- - report_undefined_variables_2(list__sort_and_remove_dups(Vars), !IO). + report_undefined_variables_2(list.sort_and_remove_dups(Vars), !IO). :- pred report_undefined_variables_2(list(string)::in, io::di, io::uo) is det. report_undefined_variables_2([], !IO). report_undefined_variables_2([_ | Rest] @ UndefVars, !IO) :- - globals__io_lookup_bool_option(warn_undefined_options_variables, Warn, + globals.io_lookup_bool_option(warn_undefined_options_variables, Warn, !IO), ( Warn = yes, - io__input_stream_name(FileName, !IO), - io__get_line_number(LineNumber, !IO), - Context = term__context_init(FileName, LineNumber), + io.input_stream_name(FileName, !IO), + io.get_line_number(LineNumber, !IO), + Context = term.context_init(FileName, LineNumber), - VarList = list_to_pieces(list__map(add_quotes, - list__sort_and_remove_dups(UndefVars))), + VarList = list_to_pieces(list.map(add_quotes, + list.sort_and_remove_dups(UndefVars))), ( Rest = [], Word = "variable", IsOrAre = "is" ; Rest = [_ | _], Word = "variables", IsOrAre = "are" ), @@ -546,7 +546,7 @@ report_undefined_variables_2([_ | Rest] @ UndefVars, !IO) :- ++ [words(IsOrAre), words("undefined.")], write_error_pieces(Context, 0, Pieces, !IO), - globals__io_lookup_bool_option(halt_at_warn, Halt, !IO), + globals.io_lookup_bool_option(halt_at_warn, Halt, !IO), ( Halt = yes, throw(found_options_file_error) @@ -581,13 +581,13 @@ parse_options_line(Line0, OptionsFileLine) :- ErrorIfNotExist = error, Line2 = Line0 ), - list__append(string__to_char_list("include"), Line3, Line2) + list.append(string.to_char_list("include"), Line3, Line2) -> - list__takewhile(char__is_whitespace, Line3, _, Line4), + list.takewhile(char.is_whitespace, Line3, _, Line4), OptionsFileLine = include_options_files(ErrorIfNotExist, Line4) ; parse_variable(VarName, Line0, Line1), - list__takewhile(char__is_whitespace, Line1, _, Line2), + list.takewhile(char.is_whitespace, Line1, _, Line2), ( Line2 = [('=') | Line3] -> Add = no, Line4 = Line3 @@ -601,7 +601,7 @@ parse_options_line(Line0, OptionsFileLine) :- throw(options_file_error( "expected `=', `:=' or `+=' after `" ++ VarName ++ "'")) ), - list__takewhile(char__is_whitespace, Line4, _, VarValue), + list.takewhile(char.is_whitespace, Line4, _, VarValue), OptionsFileLine = define_variable(VarName, Add, VarValue) ). @@ -612,9 +612,9 @@ parse_file_name(FileName, Chars0, Chars) :- ( Chars0 = ['"' | Chars1] -> parse_string(FileName, Chars1, Chars) ; - list__takewhile(isnt(char__is_whitespace), Chars0, + list.takewhile(isnt(char.is_whitespace), Chars0, FileNameChars, Chars), - FileName = string__from_char_list(FileNameChars) + FileName = string.from_char_list(FileNameChars) ). :- pred parse_variable(options_variable::out, @@ -622,11 +622,11 @@ parse_file_name(FileName, Chars0, Chars) :- parse_variable(VarName, Chars0, Chars) :- parse_variable_2(yes, [], VarList, Chars0, Chars), - string__from_rev_char_list(VarList, VarName), + string.from_rev_char_list(VarList, VarName), ( VarName = "" -> - list__takewhile(isnt(char__is_whitespace), Chars, FirstWord, _), + list.takewhile(isnt(char.is_whitespace), Chars, FirstWord, _), throw(options_file_error("expected variable at `" ++ - string__from_char_list(FirstWord) ++ "'")) + string.from_char_list(FirstWord) ++ "'")) ; true ). @@ -637,13 +637,13 @@ parse_variable(VarName, Chars0, Chars) :- parse_variable_2(_, Var, Var, [], []). parse_variable_2(IsFirst, Var0, Var, [Char | Chars0], Chars) :- ( - \+ char__is_whitespace(Char), + \+ char.is_whitespace(Char), ( IsFirst = yes, - char__is_alpha(Char) + char.is_alpha(Char) ; IsFirst = no, - ( char__is_alnum_or_underscore(Char) + ( char.is_alnum_or_underscore(Char) ; Char = ('-') ; Char = ('.') ) @@ -659,7 +659,7 @@ parse_variable_2(IsFirst, Var0, Var, [Char | Chars0], Chars) :- parse_string(String, Chars0, Chars) :- parse_string_chars([], StringChars, Chars0, Chars), - String = string__from_rev_char_list(StringChars). + String = string.from_rev_char_list(StringChars). :- pred parse_string_chars(list(char)::in, list(char)::out, list(char)::in, list(char)::out) is det. @@ -690,7 +690,7 @@ parse_string_chars(String0, String, [Char | Chars0], Chars) :- :- pred skip_comment_line(bool::out, io::di, io::uo) is det. skip_comment_line(FoundEOF, !IO) :- - read_item_or_eof(io__read_char, MaybeChar, !IO), + read_item_or_eof(io.read_char, MaybeChar, !IO), ( MaybeChar = yes(Char), ( Char = '\n' -> @@ -704,7 +704,7 @@ skip_comment_line(FoundEOF, !IO) :- ). :- pred read_item_or_eof( - pred(io__result(T), io, io)::(pred(out, di, uo) is det), + pred(io.result(T), io, io)::(pred(out, di, uo) is det), maybe(T)::out, io::di, io::uo) is det. read_item_or_eof(Pred, MaybeItem, !IO) :- @@ -717,7 +717,7 @@ read_item_or_eof(Pred, MaybeItem, !IO) :- MaybeItem = no ; Result = error(Error), - throw(options_file_error(io__error_message(Error))) + throw(options_file_error(io.error_message(Error))) ). %-----------------------------------------------------------------------------% @@ -745,12 +745,12 @@ checked_split_into_words(Chars) = Result :- :- func split_into_words(list(char)) = list(string). -split_into_words(Chars) = list__reverse(split_into_words_2(Chars, [])). +split_into_words(Chars) = list.reverse(split_into_words_2(Chars, [])). :- func split_into_words_2(list(char), list(string)) = list(string). split_into_words_2(Chars0, Words0) = Words :- - list__takewhile(char__is_whitespace, Chars0, _, Chars1), + list.takewhile(char.is_whitespace, Chars0, _, Chars1), ( Chars1 = [], Words = Words0 @@ -762,7 +762,7 @@ split_into_words_2(Chars0, Words0) = Words :- :- pred get_word(string::out, list(char)::in, list(char)::out) is det. -get_word(string__from_rev_char_list(RevWord), Chars0, Chars) :- +get_word(string.from_rev_char_list(RevWord), Chars0, Chars) :- get_word_2([], RevWord, Chars0, Chars). :- pred get_word_2(list(char)::in, list(char)::out, @@ -770,7 +770,7 @@ get_word(string__from_rev_char_list(RevWord), Chars0, Chars) :- get_word_2(RevWord, RevWord, [], []). get_word_2(RevWord0, RevWord, [Char | Chars0], Chars) :- - ( char__is_whitespace(Char) -> + ( char.is_whitespace(Char) -> Chars = Chars0, RevWord = RevWord0 ; Char = '"' -> @@ -830,10 +830,10 @@ lookup_mmc_module_options(Vars, ModuleName, Result, !IO) :- lookup_mmc_maybe_module_options(Vars, MaybeModuleName, Result, !IO) :- VariableTypes = options_variable_types, - list__map_foldl(lookup_options_variable(Vars, MaybeModuleName), + list.map_foldl(lookup_options_variable(Vars, MaybeModuleName), VariableTypes, Results, !IO), ( - list__map( + list.map( (pred(VarResult::in, MaybeValue::out) is semidet :- ( VarResult = set(Value), @@ -844,12 +844,12 @@ lookup_mmc_maybe_module_options(Vars, MaybeModuleName, Result, !IO) :- ) ), Results, Values) -> - assoc_list__from_corresponding_lists(VariableTypes, + assoc_list.from_corresponding_lists(VariableTypes, Values, VariableValues), % Default to `-O2', even when mercury_compile is called directly, % not by the mmc script. - Result = yes(["-O2" | list__condense( - list__map(convert_to_mmc_options, VariableValues))]) + Result = yes(["-O2" | list.condense( + list.map(convert_to_mmc_options, VariableValues))]) ; Result = no ). @@ -961,8 +961,8 @@ convert_to_mmc_options(VariableType, VariableValue) = OptionsStrings :- OptionsStrings = VariableValue ; MMCOptionType = option(InitialOptions, OptionName), - OptionsStrings = list__condense([InitialOptions | - list__map((func(Word) = [OptionName, Word]), VariableValue)]) + OptionsStrings = list.condense([InitialOptions | + list.map((func(Word) = [OptionName, Word]), VariableValue)]) ). :- type mmc_option_type @@ -1058,8 +1058,8 @@ error(E) ++ _ = error(E). lookup_variable_words_report_error(Vars, VarName, Result, !IO) :- lookup_variable_words(Vars, VarName, Result, !IO), ( Result = error(Error) -> - io__write_string(Error, !IO), - io__nl(!IO) + io.write_string(Error, !IO), + io.nl(!IO) ; true ). @@ -1077,13 +1077,13 @@ lookup_variable_words(Vars, VarName, Result) --> lookup_variable_words(LookupEnv, Vars, VarName, Result, !IO) :- ( LookupEnv = yes, - io__get_environment_var(VarName, MaybeEnvValue, !IO) + io.get_environment_var(VarName, MaybeEnvValue, !IO) ; LookupEnv = no, MaybeEnvValue = no ), ( MaybeEnvValue = yes(EnvValue) -> - SplitResult = checked_split_into_words(string__to_char_list(EnvValue)), + SplitResult = checked_split_into_words(string.to_char_list(EnvValue)), ( SplitResult = ok(EnvWords), Result = set(EnvWords) @@ -1092,7 +1092,7 @@ lookup_variable_words(LookupEnv, Vars, VarName, Result, !IO) :- Result = error("Error: in environment variable `" ++ VarName ++ "': " ++ Msg) ) - ; map__search(Vars, VarName, MapValue) -> + ; map.search(Vars, VarName, MapValue) -> MapValue = options_variable_value(_, Words, _), Result = set(Words) ; @@ -1104,13 +1104,13 @@ lookup_variable_words(LookupEnv, Vars, VarName, Result, !IO) :- io::di, io::uo) is det. lookup_variable_chars(Variables, Var, Value, !Undef, !IO) :- - io__get_environment_var(Var, MaybeValue, !IO), + io.get_environment_var(Var, MaybeValue, !IO), ( MaybeValue = yes(ValueString), - Value = string__to_char_list(ValueString) + Value = string.to_char_list(ValueString) ; MaybeValue = no, - ( map__search(Variables, Var, options_variable_value(Value0, _, _)) -> + ( map.search(Variables, Var, options_variable_value(Value0, _, _)) -> Value = Value0 ; Value = [], diff --git a/compiler/par_conj_gen.m b/compiler/par_conj_gen.m index d244d1060..73a3bf05c 100644 --- a/compiler/par_conj_gen.m +++ b/compiler/par_conj_gen.m @@ -95,7 +95,7 @@ % %---------------------------------------------------------------------------% -:- module ll_backend__par_conj_gen. +:- module ll_backend.par_conj_gen. :- interface. @@ -150,21 +150,21 @@ generate_par_conj(Goals, GoalInfo, CodeModel, Code, !CI) :- CodeModel = model_non, sorry(this_file, "nondet parallel conjunction not implemented") ), - code_info__get_globals(!.CI, Globals), - globals__lookup_int_option(Globals, sync_term_size, STSize), - code_info__get_known_variables(!.CI, Vars), - code_info__save_variables_on_stack(Vars, SaveCode, !CI), + code_info.get_globals(!.CI, Globals), + globals.lookup_int_option(Globals, sync_term_size, STSize), + code_info.get_known_variables(!.CI, Vars), + code_info.save_variables_on_stack(Vars, SaveCode, !CI), goal_info_get_code_gen_nonlocals(GoalInfo, Nonlocals), - set__to_sorted_list(Nonlocals, Variables), - code_info__get_instmap(!.CI, Initial), + set.to_sorted_list(Nonlocals, Variables), + code_info.get_instmap(!.CI, Initial), goal_info_get_instmap_delta(GoalInfo, Delta), - instmap__apply_instmap_delta(Initial, Delta, Final), - code_info__get_module_info(!.CI, ModuleInfo), + instmap.apply_instmap_delta(Initial, Delta, Final), + code_info.get_module_info(!.CI, ModuleInfo), find_outputs(Variables, Initial, Final, ModuleInfo, [], Outputs), - list__length(Goals, NumGoals), - code_info__acquire_reg(r, RegLval, !CI), - code_info__acquire_temp_slot(sync_term, SyncSlot, !CI), - code_info__acquire_temp_slot(lval(sp), SpSlot, !CI), + list.length(Goals, NumGoals), + code_info.acquire_reg(r, RegLval, !CI), + code_info.acquire_temp_slot(sync_term, SyncSlot, !CI), + code_info.acquire_temp_slot(lval(sp), SpSlot, !CI), MakeTerm = node([ assign(SpSlot, lval(sp)) - "save the parent stack pointer", @@ -176,13 +176,13 @@ generate_par_conj(Goals, GoalInfo, CodeModel, Code, !CI) :- assign(SyncSlot, lval(RegLval)) - "store the sync-term on the stack" ]), - code_info__release_reg(RegLval, !CI), - code_info__clear_all_registers(no, !CI), + code_info.release_reg(RegLval, !CI), + code_info.clear_all_registers(no, !CI), generate_det_par_conj_2(Goals, 0, SyncSlot, SpSlot, Initial, no, GoalCode, !CI), - code_info__release_temp_slot(SyncSlot, !CI), + code_info.release_temp_slot(SyncSlot, !CI), Code = tree(tree(SaveCode, MakeTerm), GoalCode), - code_info__clear_all_registers(no, !CI), + code_info.clear_all_registers(no, !CI), place_all_outputs(Outputs, !CI). :- pred generate_det_par_conj_2(list(hlds_goal)::in, int::in, @@ -192,27 +192,27 @@ generate_par_conj(Goals, GoalInfo, CodeModel, Code, !CI) :- generate_det_par_conj_2([], _N, _SyncTerm, _SpSlot, _Initial, _, empty, !CI). generate_det_par_conj_2([Goal | Goals], N, SyncTerm, SpSlot, Initial, MaybeEnd0, Code, !CI) :- - code_info__remember_position(!.CI, StartPos), - code_info__get_next_label(ThisConjunct, !CI), - code_info__get_next_label(NextConjunct, !CI), - code_gen__generate_goal(model_det, Goal, ThisGoalCode, !CI), - code_info__get_stack_slots(!.CI, AllSlots), - code_info__get_known_variables(!.CI, Variables), - set__list_to_set(Variables, LiveVars), - map__select(AllSlots, LiveVars, StoreMap0), - StoreMap = map__map_values(key_stack_slot_to_abs_locn, StoreMap0), - code_info__generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, + code_info.remember_position(!.CI, StartPos), + code_info.get_next_label(ThisConjunct, !CI), + code_info.get_next_label(NextConjunct, !CI), + code_gen.generate_goal(model_det, Goal, ThisGoalCode, !CI), + code_info.get_stack_slots(!.CI, AllSlots), + code_info.get_known_variables(!.CI, Variables), + set.list_to_set(Variables, LiveVars), + map.select(AllSlots, LiveVars, StoreMap0), + StoreMap = map.map_values(key_stack_slot_to_abs_locn, StoreMap0), + code_info.generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, SaveCode, !CI), Goal = _GoalExpr - GoalInfo, goal_info_get_instmap_delta(GoalInfo, Delta), - instmap__apply_instmap_delta(Initial, Delta, Final), - code_info__get_module_info(!.CI, ModuleInfo), + instmap.apply_instmap_delta(Initial, Delta, Final), + code_info.get_module_info(!.CI, ModuleInfo), find_outputs(Variables, Initial, Final, ModuleInfo, [], TheseOutputs), copy_outputs(!.CI, TheseOutputs, SpSlot, CopyCode), ( Goals = [_ | _], - code_info__reset_to_position(StartPos, !CI), - code_info__get_total_stackslot_count(!.CI, NumSlots), + code_info.reset_to_position(StartPos, !CI), + code_info.get_total_stackslot_count(!.CI, NumSlots), ForkCode = node([ fork(ThisConjunct, NextConjunct, NumSlots) - "fork off a child", @@ -227,7 +227,7 @@ generate_det_par_conj_2([Goal | Goals], N, SyncTerm, SpSlot, ]) ; Goals = [], - code_info__get_next_label(ContLab, !CI), + code_info.get_next_label(ContLab, !CI), ForkCode = empty, JoinCode = node([ join_and_continue(SyncTerm, ContLab) @@ -248,8 +248,8 @@ generate_det_par_conj_2([Goal | Goals], N, SyncTerm, SpSlot, find_outputs([], _Initial, _Final, _ModuleInfo, !Outputs). find_outputs([Var | Vars], Initial, Final, ModuleInfo, !Outputs) :- - instmap__lookup_var(Initial, Var, InitialInst), - instmap__lookup_var(Final, Var, FinalInst), + instmap.lookup_var(Initial, Var, InitialInst), + instmap.lookup_var(Final, Var, FinalInst), ( mode_is_output(ModuleInfo, (InitialInst -> FinalInst)) -> !:Outputs = [Var | !.Outputs] ; @@ -262,7 +262,7 @@ find_outputs([Var | Vars], Initial, Final, ModuleInfo, !Outputs) :- copy_outputs(_, [], _, empty). copy_outputs(CI, [Var | Vars], SpSlot, Code) :- - code_info__get_variable_slot(CI, Var, SrcSlot), + code_info.get_variable_slot(CI, Var, SrcSlot), ( SrcSlot = stackvar(SlotNum) -> % The stack pointer points to the last used word on the stack. % We want MR_sp[-0] = MR_sv(1), MR_sp[-1] = MR_sv(2), etc. @@ -283,15 +283,15 @@ copy_outputs(CI, [Var | Vars], SpSlot, Code) :- place_all_outputs([], !CI). place_all_outputs([Var | Vars], !CI) :- - code_info__variable_locations(!.CI, VarLocations), - code_info__get_variable_slot(!.CI, Var, Slot), + code_info.variable_locations(!.CI, VarLocations), + code_info.get_variable_slot(!.CI, Var, Slot), ( - map__search(VarLocations, Var, Locations), - set__member(Slot, Locations) + map.search(VarLocations, Var, Locations), + set.member(Slot, Locations) -> true ; - code_info__set_var_location(Var, Slot, !CI) + code_info.set_var_location(Var, Slot, !CI) ), place_all_outputs(Vars, !CI). diff --git a/compiler/passes_aux.m b/compiler/passes_aux.m index 2dca76c1c..0193d0dae 100644 --- a/compiler/passes_aux.m +++ b/compiler/passes_aux.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__passes_aux. +:- module hlds.passes_aux. :- interface. :- import_module hlds.hlds_module. @@ -173,7 +173,7 @@ % Invoke an executable. Both standard and error output will go to the % specified output stream. % -:- pred invoke_system_command(io__output_stream::in, +:- pred invoke_system_command(io.output_stream::in, command_verbosity::in, string::in, bool::out, io::di, io::uo) is det. % invoke_system_command(ErrorStream, Verbosity, Command, @@ -182,7 +182,7 @@ % Invoke an executable. Both standard and error output will go to the % specified output stream after being piped through `ProcessOutput'. % -:- pred invoke_system_command(io__output_stream::in, +:- pred invoke_system_command(io.output_stream::in, command_verbosity::in, string::in, maybe(string)::in, bool::out, io::di, io::uo) is det. @@ -228,7 +228,7 @@ process_all_nonimported_procs(!Task, !ModuleInfo, !IO) :- process_matching_nonimported_procs(Task, Filter, !ModuleInfo, !IO) :- module_info_predids(!.ModuleInfo, PredIds), ( Task = update_pred_error(Pred) -> - list__foldl2(process_nonimported_pred(Pred, Filter), PredIds, + list.foldl2(process_nonimported_pred(Pred, Filter), PredIds, !ModuleInfo, !IO) ; process_nonimported_procs_in_preds(PredIds, Task, _, Filter, @@ -255,7 +255,7 @@ process_nonimported_pred(Task, Filter, PredId, !ModuleInfo, !IO) :- ; Task(PredId, !ModuleInfo, PredInfo0, PredInfo, WarnCnt, ErrCnt, !IO), module_info_set_pred_info(PredId, PredInfo, !ModuleInfo), - passes_aux__handle_errors(WarnCnt, ErrCnt, !ModuleInfo, !IO) + passes_aux.handle_errors(WarnCnt, ErrCnt, !ModuleInfo, !IO) ). :- pred process_nonimported_procs_in_preds(list(pred_id)::in, @@ -266,7 +266,7 @@ process_nonimported_procs_in_preds([], !Task, _, !ModuleInfo, !IO). process_nonimported_procs_in_preds([PredId | PredIds], !Task, Filter, !ModuleInfo, !IO) :- module_info_preds(!.ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), ( call(Filter, PredInfo) -> ProcIds = pred_info_non_imported_procids(PredInfo), process_nonimported_procs(ProcIds, PredId, !Task, !ModuleInfo, !IO) @@ -284,9 +284,9 @@ process_nonimported_procs([], _PredId, !Task, !ModuleInfo, !IO). process_nonimported_procs([ProcId | ProcIds], PredId, !Task, !ModuleInfo, !IO) :- module_info_preds(!.ModuleInfo, Preds0), - map__lookup(Preds0, PredId, Pred0), + map.lookup(Preds0, PredId, Pred0), pred_info_procedures(Pred0, Procs0), - map__lookup(Procs0, ProcId, Proc0), + map.lookup(Procs0, ProcId, Proc0), ( !.Task = update_module(Closure), @@ -310,7 +310,7 @@ process_nonimported_procs([ProcId | ProcIds], PredId, !Task, !ModuleInfo, !.Task = update_proc_error(Closure), Closure(PredId, ProcId, !ModuleInfo, Proc0, Proc, WarnCnt, ErrCnt, !IO), - passes_aux__handle_errors(WarnCnt, ErrCnt, !ModuleInfo, !IO) + passes_aux.handle_errors(WarnCnt, ErrCnt, !ModuleInfo, !IO) ; !.Task = update_pred_error(_), unexpected(this_file, "process_non_imported_procs") @@ -324,23 +324,23 @@ process_nonimported_procs([ProcId | ProcIds], PredId, !Task, !ModuleInfo, % or the proc table for this pred_id. Don't take any chances. module_info_preds(!.ModuleInfo, Preds8), - map__lookup(Preds8, PredId, Pred8), + map.lookup(Preds8, PredId, Pred8), pred_info_procedures(Pred8, Procs8), - map__det_update(Procs8, ProcId, Proc, Procs), + map.det_update(Procs8, ProcId, Proc, Procs), pred_info_set_procedures(Procs, Pred8, Pred), - map__det_update(Preds8, PredId, Pred, Preds), + map.det_update(Preds8, PredId, Pred, Preds), module_info_set_preds(Preds, !ModuleInfo), process_nonimported_procs(ProcIds, PredId, !Task, !ModuleInfo, !IO). write_pred_progress_message(Message, PredId, ModuleInfo, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string(Message, !IO), - hlds_out__write_pred_id(ModuleInfo, PredId, !IO), - io__write_string("\n", !IO) + io.write_string(Message, !IO), + hlds_out.write_pred_id(ModuleInfo, PredId, !IO), + io.write_string("\n", !IO) ; VeryVerbose = no ). @@ -349,21 +349,21 @@ write_proc_progress_message(Message, proc(PredId, ProcId), ModuleInfo, !IO) :- write_proc_progress_message(Message, PredId, ProcId, ModuleInfo, !IO). write_proc_progress_message(Message, PredId, ProcId, ModuleInfo, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string(Message, !IO), - hlds_out__write_pred_proc_id(ModuleInfo, PredId, ProcId, !IO), - io__write_string("\n", !IO) + io.write_string(Message, !IO), + hlds_out.write_pred_proc_id(ModuleInfo, PredId, ProcId, !IO), + io.write_string("\n", !IO) ; VeryVerbose = no ). -:- pred passes_aux__handle_errors(int::in, int::in, - module_info::in, module_info::out, io::di, io::uo) is det. +:- pred handle_errors(int::in, int::in, module_info::in, module_info::out, + io::di, io::uo) is det. -passes_aux__handle_errors(WarnCnt, ErrCnt, !ModuleInfo, !IO) :- - globals__io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO), +handle_errors(WarnCnt, ErrCnt, !ModuleInfo, !IO) :- + globals.io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO), ( ( ErrCnt > 0 @@ -372,14 +372,14 @@ passes_aux__handle_errors(WarnCnt, ErrCnt, !ModuleInfo, !IO) :- HaltAtWarn = yes ) -> - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), module_info_incr_errors(!ModuleInfo) ; true ). maybe_set_exit_status(yes, !IO). -maybe_set_exit_status(no, !IO) :- io__set_exit_status(1, !IO). +maybe_set_exit_status(no, !IO) :- io.set_exit_status(1, !IO). invoke_system_command(ErrorStream, Verbosity, Command, Succeeded, !IO) :- invoke_system_command(ErrorStream, Verbosity, Command, no, Succeeded, !IO). @@ -387,21 +387,21 @@ invoke_system_command(ErrorStream, Verbosity, Command, Succeeded, !IO) :- invoke_system_command(ErrorStream, Verbosity, Command, MaybeProcessOutput, Succeeded, !IO) :- % This predicate shouldn't alter the exit status of mercury_compile. - io__get_exit_status(OldStatus, !IO), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + io.get_exit_status(OldStatus, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), ( Verbosity = verbose, PrintCommand = Verbose ; Verbosity = verbose_commands, - globals__io_lookup_bool_option(verbose_commands, PrintCommand, !IO) + globals.io_lookup_bool_option(verbose_commands, PrintCommand, !IO) ), ( PrintCommand = yes, - io__write_string("% Invoking system command `", !IO), - io__write_string(Command, !IO), - io__write_string("'...\n", !IO), - io__flush_output(!IO) + io.write_string("% Invoking system command `", !IO), + io.write_string(Command, !IO), + io.write_string("'...\n", !IO), + io.flush_output(!IO) ; PrintCommand = no ), @@ -412,7 +412,7 @@ invoke_system_command(ErrorStream, Verbosity, Command, % the output from the command would go to the current C output % and error streams. % - io__make_temp(TmpFile, !IO), + io.make_temp(TmpFile, !IO), ( use_dotnet -> % XXX can't use Bourne shell syntax to redirect on .NET % XXX the output will go to the wrong place! @@ -423,9 +423,9 @@ invoke_system_command(ErrorStream, Verbosity, Command, CommandRedirected = Command ++ " > " ++ TmpFile ; CommandRedirected = - string__append_list([Command, " > ", TmpFile, " 2>&1"]) + string.append_list([Command, " > ", TmpFile, " 2>&1"]) ), - io__call_system_return_signal(CommandRedirected, Result, !IO), + io.call_system_return_signal(CommandRedirected, Result, !IO), ( Result = ok(exited(Status)), maybe_write_string(PrintCommand, "% done.\n", !IO), @@ -445,7 +445,7 @@ invoke_system_command(ErrorStream, Verbosity, Command, CommandSucceeded = no ; Result = error(Error), - report_error(ErrorStream, io__error_message(Error), !IO), + report_error(ErrorStream, io.error_message(Error), !IO), CommandSucceeded = no ), @@ -454,22 +454,22 @@ invoke_system_command(ErrorStream, Verbosity, Command, not use_dotnet, MaybeProcessOutput = yes(ProcessOutput) -> - io__make_temp(ProcessedTmpFile, !IO), + io.make_temp(ProcessedTmpFile, !IO), ( use_win32 -> % On windows we can't in general redirect standard % error in the shell. - ProcessOutputRedirected = string__append_list( + ProcessOutputRedirected = string.append_list( [ProcessOutput, " < ", TmpFile, " > ", ProcessedTmpFile]) ; - ProcessOutputRedirected = string__append_list( + ProcessOutputRedirected = string.append_list( [ProcessOutput, " < ", TmpFile, " > ", ProcessedTmpFile, " 2>&1"]) ), - io__call_system_return_signal(ProcessOutputRedirected, + io.call_system_return_signal(ProcessOutputRedirected, ProcessOutputResult, !IO), - io__remove_file(TmpFile, _, !IO), + io.remove_file(TmpFile, _, !IO), ( ProcessOutputResult = ok(exited(ProcessOutputStatus)), maybe_write_string(PrintCommand, "% done.\n", !IO), @@ -491,7 +491,7 @@ invoke_system_command(ErrorStream, Verbosity, Command, ProcessOutputSucceeded = no ; ProcessOutputResult = error(ProcessOutputError), - report_error(ErrorStream, io__error_message(ProcessOutputError), + report_error(ErrorStream, io.error_message(ProcessOutputError), !IO), ProcessOutputSucceeded = no ) @@ -504,26 +504,26 @@ invoke_system_command(ErrorStream, Verbosity, Command, % % Write the output to the error stream. % - io__open_input(ProcessedTmpFile, TmpFileRes, !IO), + io.open_input(ProcessedTmpFile, TmpFileRes, !IO), ( TmpFileRes = ok(TmpFileStream), - io__input_stream_foldl_io(TmpFileStream, io__write_char(ErrorStream), + io.input_stream_foldl_io(TmpFileStream, io.write_char(ErrorStream), Res, !IO), ( Res = ok ; Res = error(TmpFileReadError), report_error(ErrorStream, "error reading command output: " - ++ io__error_message(TmpFileReadError), !IO) + ++ io.error_message(TmpFileReadError), !IO) ), - io__close_input(TmpFileStream, !IO) + io.close_input(TmpFileStream, !IO) ; TmpFileRes = error(TmpFileError), report_error(ErrorStream, "error opening command output: " - ++ io__error_message(TmpFileError), !IO) + ++ io.error_message(TmpFileError), !IO) ), - io__remove_file(ProcessedTmpFile, _, !IO), - io__set_exit_status(OldStatus, !IO). + io.remove_file(ProcessedTmpFile, _, !IO), + io.set_exit_status(OldStatus, !IO). make_command_string(String0, QuoteType, String) :- ( use_win32 -> @@ -534,7 +534,7 @@ make_command_string(String0, QuoteType, String) :- QuoteType = double, Quote = " """ ), - string__append_list(["sh -c ", Quote, String0, Quote], String) + string.append_list(["sh -c ", Quote, String0, Quote], String) ; String = String0 ). @@ -575,7 +575,7 @@ use_dotnet :- semidet_fail. use_win32 :- semidet_succeed. maybe_report_sizes(HLDS, !IO) :- - globals__io_lookup_bool_option(statistics, Statistics, !IO), + globals.io_lookup_bool_option(statistics, Statistics, !IO), ( Statistics = yes, report_sizes(HLDS, !IO) @@ -596,11 +596,11 @@ report_sizes(ModuleInfo, !IO) :- :- pred tree_stats(string::in, map(_K, _V)::in, io::di, io::uo) is det. tree_stats(Description, Tree, !IO) :- - map__count(Tree, Count), - io__write_string(Description, !IO), - io__write_string(": count = ", !IO), - io__write_int(Count, !IO), - io__write_string("\n", !IO). + map.count(Tree, Count), + io.write_string(Description, !IO), + io.write_string(": count = ", !IO), + io.write_int(Count, !IO), + io.write_string("\n", !IO). %-----------------------------------------------------------------------------% @@ -615,12 +615,12 @@ report_pred_proc_id(ModuleInfo, PredId, ProcId, MaybeContext, Context, !IO) :- % We need to strip off the extra type_info arguments inserted at the % front by polymorphism.m - we only want the last `PredArity' of them. - list__length(ArgModes0, NumArgModes), + list.length(ArgModes0, NumArgModes), NumToDrop = NumArgModes - Arity, - ( list__drop(NumToDrop, ArgModes0, ArgModes1) -> + ( list.drop(NumToDrop, ArgModes0, ArgModes1) -> ArgModes = ArgModes1 ; - unexpected(this_file, "report_pred_proc_id: list__drop failed") + unexpected(this_file, "report_pred_proc_id: list.drop failed") ), ( MaybeContext = yes(OutContext) @@ -628,38 +628,38 @@ report_pred_proc_id(ModuleInfo, PredId, ProcId, MaybeContext, Context, !IO) :- MaybeContext = no, OutContext = Context ), - prog_out__write_context(OutContext, !IO), - io__write_string("In `", !IO), + prog_out.write_context(OutContext, !IO), + io.write_string("In `", !IO), report_pred_name_mode(PredOrFunc, PredName, ArgModes, !IO), - io__write_string("':\n", !IO). + io.write_string("':\n", !IO). report_pred_name_mode(predicate, PredName, ArgModes, !IO) :- - io__write_string(PredName, !IO), + io.write_string(PredName, !IO), ( ArgModes = [_ | _], - varset__init(InstVarSet), % XXX inst var names - io__write_string("(", !IO), + varset.init(InstVarSet), % XXX inst var names + io.write_string("(", !IO), strip_builtin_qualifiers_from_mode_list(ArgModes, StrippedArgModes), mercury_output_mode_list(StrippedArgModes, InstVarSet, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; ArgModes = [] ). report_pred_name_mode(function, FuncName, ArgModes, !IO) :- - varset__init(InstVarSet), % XXX inst var names + varset.init(InstVarSet), % XXX inst var names strip_builtin_qualifiers_from_mode_list(ArgModes, StrippedArgModes), pred_args_to_func_args(StrippedArgModes, FuncArgModes, FuncRetMode), - io__write_string(FuncName, !IO), + io.write_string(FuncName, !IO), ( FuncArgModes = [_ | _], - io__write_string("(", !IO), + io.write_string("(", !IO), mercury_output_mode_list(FuncArgModes, InstVarSet, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; FuncArgModes = [] ), - io__write_string(" = ", !IO), + io.write_string(" = ", !IO), mercury_output_mode(FuncRetMode, InstVarSet, !IO). %-----------------------------------------------------------------------------% @@ -669,26 +669,26 @@ output_to_file(FileName, Action, !IO) :- output_to_file(FileName, NewAction, _Result, !IO). output_to_file(FileName, Action, Result, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), - globals__io_lookup_bool_option(statistics, Stats, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Stats, !IO), maybe_write_string(Verbose, "% Writing to file `", !IO), maybe_write_string(Verbose, FileName, !IO), maybe_write_string(Verbose, "'...\n", !IO), maybe_flush_output(Verbose, !IO), - io__open_output(FileName, Res, !IO), + io.open_output(FileName, Res, !IO), ( Res = ok(FileStream), - io__set_output_stream(FileStream, OutputStream, !IO), + io.set_output_stream(FileStream, OutputStream, !IO), Action(ActionResult, !IO), - io__set_output_stream(OutputStream, _, !IO), - io__close_output(FileStream, !IO), + io.set_output_stream(OutputStream, _, !IO), + io.close_output(FileStream, !IO), maybe_write_string(Verbose, "% done.\n", !IO), maybe_report_stats(Stats, !IO), Result = yes(ActionResult) ; Res = error(_), maybe_write_string(Verbose, "\n", !IO), - string__append_list(["can't open file `", FileName, "' for output."], + string.append_list(["can't open file `", FileName, "' for output."], ErrorMessage), report_error(ErrorMessage, !IO), Result = no diff --git a/compiler/pd_cost.m b/compiler/pd_cost.m index 93f0ce8c2..06893f776 100644 --- a/compiler/pd_cost.m +++ b/compiler/pd_cost.m @@ -9,33 +9,33 @@ % File: pd_cost.m % Main author: stayl -% pd_cost__goal gives a very rough guess as to how much work a given goal +% goal_cost gives a very rough guess as to how much work a given goal % will cause at runtime. This only counts the local cost not including % the time taken by called predicates. %-----------------------------------------------------------------------------% -:- module transform_hlds__pd_cost. +:- module transform_hlds.pd_cost. :- interface. :- import_module hlds.hlds_goal. %-----------------------------------------------------------------------------% -:- pred pd_cost__goal(hlds_goal::in, int::out) is det. +:- pred goal_cost(hlds_goal::in, int::out) is det. -:- pred pd_cost__reg_assign(int::out) is det. -:- pred pd_cost__heap_assign(int::out) is det. -:- pred pd_cost__simple_test(int::out) is det. -:- pred pd_cost__heap_incr(int::out) is det. -:- pred pd_cost__stack_flush(int::out) is det. -:- pred pd_cost__builtin_call(int::out) is det. -:- pred pd_cost__call(int::out) is det. -:- pred pd_cost__higher_order_call(int::out) is det. +:- func cost_of_reg_assign = int. +:- func cost_of_heap_assign = int. +:- func cost_of_simple_test = int. +:- func cost_of_heap_incr = int. +:- func cost_of_stack_flush = int. +:- func cost_of_builtin_call = int. +:- func cost_of_call = int. +:- func cost_of_higher_order_call = int. -:- pred pd_cost__eliminate_switch(int::out) is det. -:- pred pd_cost__fold(int::out) is det. -:- pred pd_cost__recursive_fold(int::out) is det. +:- func cost_of_eliminate_switch = int. +:- func cost_of_fold = int. +:- func cost_of_recursive_fold = int. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -53,136 +53,117 @@ %-----------------------------------------------------------------------------% -pd_cost__goal(conj(_, Goals) - _, Cost) :- - pd_cost__goals(Goals, 0, Cost). +goal_cost(conj(_, Goals) - _, Cost) :- + goal_costs(Goals, 0, Cost). -pd_cost__goal(disj(Goals) - _, Cost) :- - pd_cost__goals(Goals, 0, Cost0), - pd_cost__stack_flush(Cost1), - Cost = Cost0 + Cost1. +goal_cost(disj(Goals) - _, Cost) :- + goal_costs(Goals, 0, Cost0), + Cost = Cost0 + cost_of_stack_flush. -pd_cost__goal(switch(_, _, Cases) - _, Cost) :- - pd_cost__simple_test(Cost0), - pd_cost__cases(Cases, Cost0, Cost). +goal_cost(switch(_, _, Cases) - _, Cost) :- + cases_cost(Cases, cost_of_simple_test, Cost). -pd_cost__goal(if_then_else(_, Cond, Then, Else) - _, Cost) :- - pd_cost__goal(Cond, Cost1), - pd_cost__goal(Then, Cost2), - pd_cost__goal(Else, Cost3), +goal_cost(if_then_else(_, Cond, Then, Else) - _, Cost) :- + goal_cost(Cond, Cost1), + goal_cost(Then, Cost2), + goal_cost(Else, Cost3), Cost = Cost1 + Cost2 + Cost3. -pd_cost__goal(call(_, _, Args, BuiltinState, _, _) - _, Cost) :- +goal_cost(call(_, _, Args, BuiltinState, _, _) - _, Cost) :- ( BuiltinState = inline_builtin -> - pd_cost__builtin_call(Cost) + Cost = cost_of_builtin_call ; - pd_cost__stack_flush(Cost1), - list__length(Args, Arity), + list.length(Args, Arity), InputArgs = Arity // 2, % rough - pd_cost__reg_assign(AssignCost), - pd_cost__call(Cost2), - Cost = Cost1 + Cost2 + AssignCost * InputArgs + Cost = cost_of_stack_flush + cost_of_call + + cost_of_reg_assign * InputArgs ). -pd_cost__goal(not(Goal) - _, Cost) :- - pd_cost__goal(Goal, Cost). +goal_cost(not(Goal) - _, Cost) :- + goal_cost(Goal, Cost). -pd_cost__goal(scope(_, Goal) - _, Cost) :- - pd_cost__goal(Goal, Cost). +goal_cost(scope(_, Goal) - _, Cost) :- + goal_cost(Goal, Cost). -pd_cost__goal(generic_call(_, Args, _, _) - _, Cost) :- - list__length(Args, Arity), - pd_cost__reg_assign(AssignCost), - Cost0 = AssignCost * Arity // 2, - pd_cost__stack_flush(Cost1), - pd_cost__higher_order_call(Cost2), - Cost = Cost0 + Cost1 + Cost2. +goal_cost(generic_call(_, Args, _, _) - _, Cost) :- + list.length(Args, Arity), + Cost0 = cost_of_reg_assign * Arity // 2, + Cost = Cost0 + cost_of_stack_flush + cost_of_higher_order_call. -pd_cost__goal(unify(_, _, _, Unification, _) - GoalInfo, Cost) :- +goal_cost(unify(_, _, _, Unification, _) - GoalInfo, Cost) :- goal_info_get_nonlocals(GoalInfo, NonLocals), - pd_cost__unify(NonLocals, Unification, Cost). + unify_cost(NonLocals, Unification, Cost). -pd_cost__goal(foreign_proc(Attributes, _, _, Args, _, _) - _, Cost) :- +goal_cost(foreign_proc(Attributes, _, _, Args, _, _) - _, Cost) :- ( may_call_mercury(Attributes) = will_not_call_mercury -> Cost1 = 0 ; - pd_cost__stack_flush(Cost1) + Cost1 = cost_of_stack_flush ), - pd_cost__call(Cost2), - list__length(Args, Arity), + list.length(Args, Arity), InputArgs = Arity // 2, % rough - pd_cost__reg_assign(AssignCost), - Cost = Cost1 + Cost2 + AssignCost * InputArgs. + Cost = Cost1 + cost_of_call + cost_of_reg_assign * InputArgs. -pd_cost__goal(shorthand(_) - _, _) :- +goal_cost(shorthand(_) - _, _) :- % these should have been expanded out by now - unexpected(this_file, "pd_cost__goal: unexpected shorthand"). + unexpected(this_file, "goal_cost: unexpected shorthand"). -:- pred pd_cost__unify(set(prog_var)::in, unification::in, int::out) is det. +:- pred unify_cost(set(prog_var)::in, unification::in, int::out) is det. -pd_cost__unify(_, assign(_, _), 0). - -pd_cost__unify(_, complicated_unify(_, _, _), Cost) :- - pd_cost__stack_flush(Cost). - -pd_cost__unify(_, simple_test(_, _), Cost) :- - pd_cost__simple_test(Cost). - -pd_cost__unify(NonLocals, construct(Var, _, Args, _, _, _, _), Cost) :- - ( set__member(Var, NonLocals) -> - list__length(Args, Arity), - pd_cost__heap_incr(Cost1), - pd_cost__heap_assign(Cost2), - Cost = Cost1 + Arity * Cost2 +unify_cost(_, assign(_, _), 0). +unify_cost(_, complicated_unify(_, _, _), cost_of_stack_flush). +unify_cost(_, simple_test(_, _), cost_of_simple_test). +unify_cost(NonLocals, construct(Var, _, Args, _, _, _, _), Cost) :- + ( set.member(Var, NonLocals) -> + list.length(Args, Arity), + Cost = cost_of_heap_incr + Arity * cost_of_heap_assign ; Cost = 0 ). - -pd_cost__unify(NonLocals, deconstruct(_, _, Args, _, CanFail, _), Cost) :- +unify_cost(NonLocals, deconstruct(_, _, Args, _, CanFail, _), Cost) :- ( CanFail = can_fail, - pd_cost__simple_test(Cost0) + Cost0 = cost_of_simple_test ; CanFail = cannot_fail, Cost0 = 0 ), - list__filter((pred(X::in) is semidet :- - set__member(X, NonLocals) + list.filter((pred(X::in) is semidet :- + set.member(X, NonLocals) ), Args, NonLocalArgs), - list__length(NonLocalArgs, NumAssigns), - pd_cost__heap_incr(Cost1), - pd_cost__heap_assign(Cost2), - Cost = Cost0 + Cost1 + NumAssigns * Cost2. + list.length(NonLocalArgs, NumAssigns), + Cost = Cost0 + cost_of_heap_incr + NumAssigns * cost_of_heap_assign. -:- pred pd_cost__goals(list(hlds_goal)::in, int::in, int::out) is det. +:- pred goal_costs(list(hlds_goal)::in, int::in, int::out) is det. -pd_cost__goals([], Cost, Cost). -pd_cost__goals([Goal | Goals], Cost0, Cost) :- - pd_cost__goal(Goal, Cost1), +goal_costs([], Cost, Cost). +goal_costs([Goal | Goals], Cost0, Cost) :- + goal_cost(Goal, Cost1), Cost2 = Cost0 + Cost1, - pd_cost__goals(Goals, Cost2, Cost). + goal_costs(Goals, Cost2, Cost). -:- pred pd_cost__cases(list(case)::in, int::in, int::out) is det. +:- pred cases_cost(list(case)::in, int::in, int::out) is det. -pd_cost__cases([], Cost, Cost). -pd_cost__cases([case(_, Goal) | Cases], Cost0, Cost) :- - pd_cost__goal(Goal, Cost1), +cases_cost([], Cost, Cost). +cases_cost([case(_, Goal) | Cases], Cost0, Cost) :- + goal_cost(Goal, Cost1), Cost2 = Cost0 + Cost1, - pd_cost__cases(Cases, Cost2, Cost). + cases_cost(Cases, Cost2, Cost). %-----------------------------------------------------------------------------% -pd_cost__reg_assign(1). -pd_cost__heap_assign(2). -pd_cost__simple_test(3). -pd_cost__heap_incr(3). % Depends on GC, want to penalise mem usage. -pd_cost__stack_flush(5). -pd_cost__builtin_call(3). % very rough - int:'+' == float:'/' !. -pd_cost__call(3). -pd_cost__higher_order_call(8). +cost_of_reg_assign = 1. +cost_of_heap_assign = 2. +cost_of_simple_test = 3. +cost_of_heap_incr = 3. % Depends on GC, want to penalise mem usage. +cost_of_stack_flush = 5. +cost_of_builtin_call = 3. % very rough - int:'+' == float:'/' !. +cost_of_call = 3. +cost_of_higher_order_call = 8. -pd_cost__eliminate_switch(5). -pd_cost__fold(15). % reward folding -pd_cost__recursive_fold(25). % reward recursive folding more +cost_of_eliminate_switch = 5. +cost_of_fold = 15. % reward folding +cost_of_recursive_fold = 25. % reward recursive folding more %-----------------------------------------------------------------------------% diff --git a/compiler/pd_debug.m b/compiler/pd_debug.m index 21ef05928..d39cec4dd 100644 --- a/compiler/pd_debug.m +++ b/compiler/pd_debug.m @@ -1,19 +1,19 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1998-2005 University of Melbourne. +% Copyright (C) 1998-2006 University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% % -% File: pd_debug.m +% File: pd_debug_m % Main author: stayl. % % Debugging routines for partial deduction. % %-----------------------------------------------------------------------------% -:- module transform_hlds__pd_debug. +:- module transform_hlds.pd_debug. :- interface. @@ -26,29 +26,29 @@ :- import_module list. :- import_module string. -:- pred pd_debug__do_io(pred(io, io)::pred(di, uo) is det, +:- pred pd_debug_do_io(pred(io, io)::pred(di, uo) is det, io::di, io::uo) is det. -:- pred pd_debug__output_goal(pd_info::in, string::in, hlds_goal::in, +:- pred pd_debug_output_goal(pd_info::in, string::in, hlds_goal::in, io::di, io::uo) is det. -:- pred pd_debug__search_version_result(pd_info::in, maybe_version::in, +:- pred pd_debug_search_version_result(pd_info::in, maybe_version::in, io::di, io::uo) is det. -:- pred pd_debug__register_version(pd_info::in, pred_proc_id::in, +:- pred pd_debug_register_version(pd_info::in, pred_proc_id::in, version_info::in, io::di, io::uo) is det. -:- pred pd_debug__write_instmap(pd_info::in, io::di, io::uo) is det. +:- pred pd_debug_write_instmap(pd_info::in, io::di, io::uo) is det. -:- pred pd_debug__message(string::in, list(string__poly_type)::in, +:- pred pd_debug_message(string::in, list(string.poly_type)::in, io::di, io::uo) is det. -:- pred pd_debug__message(prog_context::in, string::in, - list(string__poly_type)::in, io::di, io::uo) is det. +:- pred pd_debug_message(prog_context::in, string::in, + list(string.poly_type)::in, io::di, io::uo) is det. -:- pred pd_debug__write(T::in, io::di, io::uo) is det. +:- pred pd_debug_write(T::in, io::di, io::uo) is det. -:- pred pd_debug__write_pred_proc_id_list(pd_info::in, list(pred_proc_id)::in, +:- pred pd_debug_write_pred_proc_id_list(pd_info::in, list(pred_proc_id)::in, io::di, io::uo) is det. %-----------------------------------------------------------------------------% @@ -69,173 +69,172 @@ :- import_module set. :- import_module std_util. -pd_debug__do_io(Pred, !IO) :- - globals__io_lookup_bool_option(debug_pd, DoDebug, !IO), +pd_debug_do_io(Pred, !IO) :- + globals.io_lookup_bool_option(debug_pd, DoDebug, !IO), ( DoDebug = yes, call(Pred, !IO), - io__flush_output(!IO) + io.flush_output(!IO) ; DoDebug = no ). %-----------------------------------------------------------------------------% -pd_debug__search_version_result(PDInfo, MaybeVersion, !IO) :- +pd_debug_search_version_result(PDInfo, MaybeVersion, !IO) :- pd_info_get_module_info(PDInfo, ModuleInfo), - pd_debug__do_io(pd_debug__search_version_result_2(ModuleInfo, - MaybeVersion), !IO). + pd_debug_do_io(pd_debug_search_version_result_2(ModuleInfo, MaybeVersion), + !IO). -:- pred pd_debug__search_version_result_2(module_info::in, maybe_version::in, +:- pred pd_debug_search_version_result_2(module_info::in, maybe_version::in, io::di, io::uo) is det. -pd_debug__search_version_result_2(ModuleInfo, MaybeVersion, !IO) :- +pd_debug_search_version_result_2(ModuleInfo, MaybeVersion, !IO) :- ( MaybeVersion = no_version, - io__write_string("Specialised version not found.\n", !IO) + io.write_string("Specialised version not found.\n", !IO) ; MaybeVersion = version(exact, _, _, _, _), - io__write_string("Exact match found.\n", !IO) + io.write_string("Exact match found.\n", !IO) ; MaybeVersion = version(more_general, PredProcId, Version, _, _), - io__write_string("More general version.\n", !IO), - pd_debug__output_version(ModuleInfo, PredProcId, Version, no, !IO) + io.write_string("More general version.\n", !IO), + pd_debug_output_version(ModuleInfo, PredProcId, Version, no, !IO) ). %-----------------------------------------------------------------------------% -pd_debug__register_version(PDInfo, PredProcId, Version, !IO) :- +pd_debug_register_version(PDInfo, PredProcId, Version, !IO) :- pd_info_get_module_info(PDInfo, ModuleInfo), - pd_debug__do_io( - pd_debug__register_version_2(ModuleInfo, PredProcId, Version), - !IO). + pd_debug_do_io( + pd_debug_register_version_2(ModuleInfo, PredProcId, Version), !IO). -:- pred pd_debug__register_version_2(module_info::in, pred_proc_id::in, +:- pred pd_debug_register_version_2(module_info::in, pred_proc_id::in, version_info::in, io::di, io::uo) is det. -pd_debug__register_version_2(ModuleInfo, PredProcId, Version, !IO) :- - io__write_string("Registering version:\n", !IO), - pd_debug__output_version(ModuleInfo, PredProcId, Version, no, !IO). +pd_debug_register_version_2(ModuleInfo, PredProcId, Version, !IO) :- + io.write_string("Registering version:\n", !IO), + pd_debug_output_version(ModuleInfo, PredProcId, Version, no, !IO). %-----------------------------------------------------------------------------% -:- pred pd_debug__output_version(module_info::in, pred_proc_id::in, +:- pred pd_debug_output_version(module_info::in, pred_proc_id::in, version_info::in, bool::in, io::di, io::uo) is det. -pd_debug__output_version(ModuleInfo, PredProcId, Version, WriteUnfoldedGoal, +pd_debug_output_version(ModuleInfo, PredProcId, Version, WriteUnfoldedGoal, !IO) :- Version = version_info(Goal - GoalInfo, _, Args, _, InstMap, InitialCost, CostDelta, Parents, _), predicate_name(ModuleInfo, PredId, PredName), - io__write_string(PredName, !IO), - io__write_string(": (PredProcId :", !IO), + io.write_string(PredName, !IO), + io.write_string(": (PredProcId :", !IO), PredProcId = proc(PredId, ProcId), pred_id_to_int(PredId, PredInt), proc_id_to_int(ProcId, ProcInt), - io__write_int(PredInt, !IO), - io__write_string("-", !IO), - io__write_int(ProcInt, !IO), - io__write_string(")", !IO), - io__nl(!IO), - io__write_string(" initial cost: ", !IO), - io__write_int(InitialCost, !IO), - io__nl(!IO), - io__write_string(" cost delta: ", !IO), - io__write_int(CostDelta, !IO), - io__nl(!IO), + io.write_int(PredInt, !IO), + io.write_string("-", !IO), + io.write_int(ProcInt, !IO), + io.write_string(")", !IO), + io.nl(!IO), + io.write_string(" initial cost: ", !IO), + io.write_int(InitialCost, !IO), + io.nl(!IO), + io.write_string(" cost delta: ", !IO), + io.write_int(CostDelta, !IO), + io.nl(!IO), goal_info_get_nonlocals(GoalInfo, NonLocals), module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo), proc_info_varset(ProcInfo, VarSet), - instmap__restrict(NonLocals, InstMap, InstMap1), - io__write_string(" args: ", !IO), + instmap.restrict(NonLocals, InstMap, InstMap1), + io.write_string(" args: ", !IO), mercury_output_vars(Args, VarSet, yes, !IO), - io__nl(!IO), - hlds_out__write_instmap(InstMap1, VarSet, yes, 1, !IO), - io__nl(!IO), - hlds_out__write_goal(Goal - GoalInfo, ModuleInfo, VarSet, yes, 1, "\n", + io.nl(!IO), + hlds_out.write_instmap(InstMap1, VarSet, yes, 1, !IO), + io.nl(!IO), + hlds_out.write_goal(Goal - GoalInfo, ModuleInfo, VarSet, yes, 1, "\n", !IO), - io__nl(!IO), - io__write_string("Parents: ", !IO), - set__to_sorted_list(Parents, ParentsList), - io__write_list(ParentsList, ", ", - pd_debug__write_pred_proc_id(ModuleInfo), !IO), - io__nl(!IO), + io.nl(!IO), + io.write_string("Parents: ", !IO), + set.to_sorted_list(Parents, ParentsList), + io.write_list(ParentsList, ", ", + pd_debug_write_pred_proc_id(ModuleInfo), !IO), + io.nl(!IO), ( WriteUnfoldedGoal = yes, proc_info_goal(ProcInfo, ProcGoal), - io__write_string("Unfolded goal\n", !IO), - hlds_out__write_goal(ProcGoal, ModuleInfo, VarSet, yes, 1, "\n", !IO), - io__nl(!IO) + io.write_string("Unfolded goal\n", !IO), + hlds_out.write_goal(ProcGoal, ModuleInfo, VarSet, yes, 1, "\n", !IO), + io.nl(!IO) ; WriteUnfoldedGoal = no ). %-----------------------------------------------------------------------------% -pd_debug__write_instmap(PDInfo, !IO) :- +pd_debug_write_instmap(PDInfo, !IO) :- pd_info_get_instmap(PDInfo, InstMap), pd_info_get_proc_info(PDInfo, ProcInfo), proc_info_varset(ProcInfo, VarSet), - pd_debug__do_io(hlds_out__write_instmap(InstMap, VarSet, yes, 1), !IO). + pd_debug_do_io(hlds_out.write_instmap(InstMap, VarSet, yes, 1), !IO). %-----------------------------------------------------------------------------% -pd_debug__write_pred_proc_id_list(PDInfo, PredProcIds, !IO) :- +pd_debug_write_pred_proc_id_list(PDInfo, PredProcIds, !IO) :- pd_info_get_module_info(PDInfo, ModuleInfo), - pd_debug__do_io( - pd_debug__write_pred_proc_id_list_2(ModuleInfo, PredProcIds), + pd_debug_do_io( + pd_debug_write_pred_proc_id_list_2(ModuleInfo, PredProcIds), !IO). -:- pred pd_debug__write_pred_proc_id_list_2(module_info::in, +:- pred pd_debug_write_pred_proc_id_list_2(module_info::in, list(pred_proc_id)::in, io::di, io::uo) is det. -pd_debug__write_pred_proc_id_list_2(ModuleInfo, PredProcIds, !IO) :- - io__write_list(PredProcIds, ", ", - pd_debug__write_pred_proc_id(ModuleInfo), !IO). +pd_debug_write_pred_proc_id_list_2(ModuleInfo, PredProcIds, !IO) :- + io.write_list(PredProcIds, ", ", + pd_debug_write_pred_proc_id(ModuleInfo), !IO). -:- pred pd_debug__write_pred_proc_id(module_info::in, pred_proc_id::in, +:- pred pd_debug_write_pred_proc_id(module_info::in, pred_proc_id::in, io::di, io::uo) is det. -pd_debug__write_pred_proc_id(ModuleInfo, proc(PredId, ProcId), !IO) :- - hlds_out__write_pred_proc_id(ModuleInfo, PredId, ProcId, !IO). +pd_debug_write_pred_proc_id(ModuleInfo, proc(PredId, ProcId), !IO) :- + hlds_out.write_pred_proc_id(ModuleInfo, PredId, ProcId, !IO). %-----------------------------------------------------------------------------% -pd_debug__output_goal(PDInfo, Msg, Goal, !IO) :- - pd_debug__do_io(pd_debug__output_goal_2(PDInfo, Msg, Goal), !IO). +pd_debug_output_goal(PDInfo, Msg, Goal, !IO) :- + pd_debug_do_io(pd_debug_output_goal_2(PDInfo, Msg, Goal), !IO). -:- pred pd_debug__output_goal_2(pd_info::in, string::in, hlds_goal::in, +:- pred pd_debug_output_goal_2(pd_info::in, string::in, hlds_goal::in, io::di, io::uo) is det. -pd_debug__output_goal_2(PDInfo, Msg, GoalExpr - GoalInfo, !IO) :- +pd_debug_output_goal_2(PDInfo, Msg, GoalExpr - GoalInfo, !IO) :- pd_info_get_proc_info(PDInfo, ProcInfo), proc_info_varset(ProcInfo, VarSet), pd_info_get_instmap(PDInfo, InstMap), pd_info_get_module_info(PDInfo, ModuleInfo), - io__write_string(Msg, !IO), - goal_util__goal_vars(GoalExpr - GoalInfo, Vars), - instmap__restrict(Vars, InstMap, InstMap1), - hlds_out__write_instmap(InstMap1, VarSet, yes, 1, !IO), - io__nl(!IO), - hlds_out__write_goal(GoalExpr - GoalInfo, ModuleInfo, VarSet, + io.write_string(Msg, !IO), + goal_util.goal_vars(GoalExpr - GoalInfo, Vars), + instmap.restrict(Vars, InstMap, InstMap1), + hlds_out.write_instmap(InstMap1, VarSet, yes, 1, !IO), + io.nl(!IO), + hlds_out.write_goal(GoalExpr - GoalInfo, ModuleInfo, VarSet, yes, 1, "\n", !IO), - io__nl(!IO), - io__flush_output(!IO). + io.nl(!IO), + io.flush_output(!IO). %-----------------------------------------------------------------------------% -pd_debug__message(Fmt, Args, !IO) :- - pd_debug__do_io(io__format(Fmt, Args), !IO). +pd_debug_message(Fmt, Args, !IO) :- + pd_debug_do_io(io.format(Fmt, Args), !IO). -pd_debug__message(Context, Fmt, Args, !IO) :- - pd_debug__do_io(prog_out__write_context(Context), !IO), - pd_debug__do_io(io__format(Fmt, Args), !IO). +pd_debug_message(Context, Fmt, Args, !IO) :- + pd_debug_do_io(prog_out.write_context(Context), !IO), + pd_debug_do_io(io.format(Fmt, Args), !IO). %-----------------------------------------------------------------------------% -pd_debug__write(Thing, !IO) :- - pd_debug__do_io(io__write(Thing), !IO). +pd_debug_write(Thing, !IO) :- + pd_debug_do_io(io.write(Thing), !IO). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% diff --git a/compiler/pd_info.m b/compiler/pd_info.m index 2fb5576cc..2dac66f59 100644 --- a/compiler/pd_info.m +++ b/compiler/pd_info.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__pd_info. +:- module transform_hlds.pd_info. :- interface. :- import_module hlds.hlds_goal. @@ -138,22 +138,22 @@ %-----------------------------------------------------------------------------% pd_info_init(ModuleInfo, ProcArgInfos, PDInfo) :- - map__init(GoalVersionIndex), - map__init(Versions), - set__init(ParentVersions), - pd_term__global_term_info_init(GlobalInfo), - set__init(CreatedVersions), - set__init(UselessVersions), + map.init(GoalVersionIndex), + map.init(Versions), + set.init(ParentVersions), + pd_term.global_term_info_init(GlobalInfo), + set.init(CreatedVersions), + set.init(UselessVersions), PDInfo = pd_info(ModuleInfo, no, GoalVersionIndex, Versions, - ProcArgInfos, counter__init(0), GlobalInfo, ParentVersions, + ProcArgInfos, counter.init(0), GlobalInfo, ParentVersions, 0, CreatedVersions, UselessVersions). pd_info_init_unfold_info(PredProcId, PredInfo, ProcInfo, !PDInfo) :- pd_info_get_module_info(!.PDInfo, ModuleInfo), proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap), CostDelta = 0, - pd_term__local_term_info_init(LocalTermInfo), - set__singleton_set(Parents, PredProcId), + pd_term.local_term_info_init(LocalTermInfo), + set.singleton_set(Parents, PredProcId), UnfoldInfo = unfold_info(ProcInfo, InstMap, CostDelta, LocalTermInfo, PredInfo, Parents, PredProcId, no, 0, no), pd_info_set_unfold_info(UnfoldInfo, !PDInfo). @@ -204,7 +204,7 @@ pd_info_set_useless_versions(Versions, PDInfo, pd_info_update_goal(_ - GoalInfo, !PDInfo) :- pd_info_get_instmap(!.PDInfo, InstMap0), goal_info_get_instmap_delta(GoalInfo, Delta), - instmap__apply_instmap_delta(InstMap0, Delta, InstMap), + instmap.apply_instmap_delta(InstMap0, Delta, InstMap), pd_info_set_instmap(InstMap, !PDInfo). pd_info_bind_var_to_functor(Var, ConsId, !PDInfo) :- @@ -212,8 +212,8 @@ pd_info_bind_var_to_functor(Var, ConsId, !PDInfo) :- pd_info_get_module_info(!.PDInfo, ModuleInfo0), pd_info_get_proc_info(!.PDInfo, ProcInfo), proc_info_vartypes(ProcInfo, VarTypes), - map__lookup(VarTypes, Var, Type), - instmap__bind_var_to_functor(Var, Type, ConsId, InstMap0, InstMap, + map.lookup(VarTypes, Var, Type), + instmap.bind_var_to_functor(Var, Type, ConsId, InstMap0, InstMap, ModuleInfo0, ModuleInfo), pd_info_set_instmap(InstMap, !PDInfo), pd_info_set_module_info(ModuleInfo, !PDInfo). @@ -392,29 +392,29 @@ pd_info_incr_size_delta(Delta1, !PDInfo) :- % Find the deforestation procedure which most closely % matches the given goal. % -:- pred pd_info__search_version(pd_info::in, hlds_goal::in, maybe_version::out, +:- pred pd_info.search_version(pd_info::in, hlds_goal::in, maybe_version::out, io::di, io::uo) is det. % Create a new predicate for the input goal, returning a % goal which calls the new predicate. % -:- pred pd_info__define_new_pred(pred_origin::in, hlds_goal::in, +:- pred pd_info.define_new_pred(pred_origin::in, hlds_goal::in, pred_proc_id::out, hlds_goal::out, pd_info::in, pd_info::out) is det. % Add a version to the table. % -:- pred pd_info__register_version(pred_proc_id::in, version_info::in, +:- pred pd_info.register_version(pred_proc_id::in, version_info::in, pd_info::in, pd_info::out, io::di, io::uo) is det. % Remove a version and make sure it is never recreated. % -:- pred pd_info__invalidate_version(pred_proc_id::in, +:- pred pd_info.invalidate_version(pred_proc_id::in, pd_info::in, pd_info::out) is det. % Remove a version, but allow it to be recreated if it % is used elsewhere. % -:- pred pd_info__remove_version(pred_proc_id::in, +:- pred pd_info.remove_version(pred_proc_id::in, pd_info::in, pd_info::out) is det. % The result of looking up a specialised version of a pred. @@ -461,9 +461,9 @@ pd_info_incr_size_delta(Delta1, !PDInfo) :- :- implementation. -pd_info__search_version(PDInfo, Goal, MaybeVersion, !IO) :- - pd_debug__output_goal(PDInfo, "Searching for version:\n", Goal, !IO), - pd_util__goal_get_calls(Goal, CalledPreds), +pd_info.search_version(PDInfo, Goal, MaybeVersion, !IO) :- + pd_debug_output_goal(PDInfo, "Searching for version:\n", Goal, !IO), + pd_util.goal_get_calls(Goal, CalledPreds), pd_info_get_versions(PDInfo, Versions), pd_info_get_goal_version_index(PDInfo, GoalVersionIndex), pd_info_get_module_info(PDInfo, ModuleInfo), @@ -471,36 +471,36 @@ pd_info__search_version(PDInfo, Goal, MaybeVersion, !IO) :- pd_info_get_instmap(PDInfo, InstMap), proc_info_vartypes(ProcInfo, VarTypes), ( - map__search(GoalVersionIndex, CalledPreds, VersionIds), - pd_info__get_matching_version(ModuleInfo, Goal, InstMap, + map.search(GoalVersionIndex, CalledPreds, VersionIds), + pd_info.get_matching_version(ModuleInfo, Goal, InstMap, VarTypes, VersionIds, Versions, MaybeVersion0) -> MaybeVersion = MaybeVersion0 ; MaybeVersion = no_version ), - pd_debug__search_version_result(PDInfo, MaybeVersion, !IO). + pd_debug_search_version_result(PDInfo, MaybeVersion, !IO). %-----------------------------------------------------------------------------% -:- pred pd_info__get_matching_version(module_info::in, hlds_goal::in, +:- pred pd_info.get_matching_version(module_info::in, hlds_goal::in, instmap::in, vartypes::in, list(pred_proc_id)::in, version_index::in, maybe_version::out) is semidet. -pd_info__get_matching_version(_, _, _, _, [], _, no_version). -pd_info__get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, VarTypes, +pd_info.get_matching_version(_, _, _, _, [], _, no_version). +pd_info.get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, VarTypes, [VersionId | VersionIds], Versions, MaybeVersion) :- - map__lookup(Versions, VersionId, Version), + map.lookup(Versions, VersionId, Version), Version = version_info(OldGoal, _, OldArgs, OldArgTypes, OldInstMap, _, _, _, _), ( - pd_info__goal_is_more_general(ModuleInfo, OldGoal, OldInstMap, OldArgs, + pd_info.goal_is_more_general(ModuleInfo, OldGoal, OldInstMap, OldArgs, OldArgTypes, ThisGoal, ThisInstMap, VarTypes, VersionId, Version, MaybeVersion1) -> ( MaybeVersion1 = no_version, - pd_info__get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, + pd_info.get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, VarTypes, VersionIds, Versions, MaybeVersion) ; MaybeVersion1 = version(exact, _, _, _, _), @@ -508,14 +508,14 @@ pd_info__get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, VarTypes, ; MaybeVersion1 = version(more_general, PredProcId, MoreGeneralVersion, Renaming, TypeSubn), - pd_info__get_matching_version(ModuleInfo, ThisGoal, + pd_info.get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, VarTypes, VersionIds, Versions, MaybeVersion2), - pd_info__pick_version(ModuleInfo, PredProcId, Renaming, + pd_info.pick_version(ModuleInfo, PredProcId, Renaming, TypeSubn, MoreGeneralVersion, MaybeVersion2, MaybeVersion) ) ; - pd_info__get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, + pd_info.get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, VarTypes, VersionIds, Versions, MaybeVersion) ). @@ -523,16 +523,16 @@ pd_info__get_matching_version(ModuleInfo, ThisGoal, ThisInstMap, VarTypes, % Choose between two versions. % -:- pred pd_info__pick_version(module_info::in, pred_proc_id::in, +:- pred pd_info.pick_version(module_info::in, pred_proc_id::in, map(prog_var, prog_var)::in, tsubst::in, version_info::in, maybe_version::in, maybe_version::out) is det. -pd_info__pick_version(_, PredProcId, Renaming, TSubn, VersionInfo, no_version, +pd_info.pick_version(_, PredProcId, Renaming, TSubn, VersionInfo, no_version, version(more_general, PredProcId, VersionInfo, Renaming, TSubn)). -pd_info__pick_version(_, _, _, _, _, +pd_info.pick_version(_, _, _, _, _, version(exact, PredProcId, Version2, Renaming2, TSubn2), version(exact, PredProcId, Version2, Renaming2, TSubn2)). -pd_info__pick_version(_ModuleInfo, PredProcId1, Renaming1, TSubn1, Version1, +pd_info.pick_version(_ModuleInfo, PredProcId1, Renaming1, TSubn1, Version1, version(more_general, PredProcId2, Version2, Renaming2, TSubn2), MaybeVersion) :- Version1 = version_info(_, _, _, _, _, _, CostDelta1, _, _), @@ -553,7 +553,7 @@ pd_info__pick_version(_ModuleInfo, PredProcId1, Renaming1, TSubn1, Version1, % not produce any more improvement. % % An old version is more general than a new one if: - % - the goals have the same "shape" (see pd_util__goals_match). + % - the goals have the same "shape" (see pd_util.goals_match). % - each variable in the old goal maps to exactly one % variable in the new (multiple vars in the new goal can % map to one var in the old). @@ -564,20 +564,20 @@ pd_info__pick_version(_ModuleInfo, PredProcId1, Renaming1, TSubn1, Version1, % the old inst must be at least as general as the % new one, i.e inst_matches_initial(FirstInst, SecondInst) (?) % -:- pred pd_info__goal_is_more_general(module_info::in, hlds_goal::in, +:- pred pd_info.goal_is_more_general(module_info::in, hlds_goal::in, instmap::in, list(prog_var)::in, list(mer_type)::in, hlds_goal::in, instmap::in, vartypes::in, pred_proc_id::in, version_info::in, maybe_version::out) is semidet. -pd_info__goal_is_more_general(ModuleInfo, OldGoal, OldInstMap, OldArgs, +pd_info.goal_is_more_general(ModuleInfo, OldGoal, OldInstMap, OldArgs, OldArgTypes, NewGoal, NewInstMap, NewVarTypes, PredProcId, Version, MaybeVersion) :- - pd_util__goals_match(ModuleInfo, OldGoal, OldArgs, OldArgTypes, + pd_util.goals_match(ModuleInfo, OldGoal, OldArgs, OldArgTypes, NewGoal, NewVarTypes, OldNewRenaming, TypeRenaming), OldGoal = _ - OldGoalInfo, goal_info_get_nonlocals(OldGoalInfo, OldNonLocals0), - set__to_sorted_list(OldNonLocals0, OldNonLocalsList), - pd_info__check_insts(ModuleInfo, OldNonLocalsList, OldNewRenaming, + set.to_sorted_list(OldNonLocals0, OldNonLocalsList), + pd_info.check_insts(ModuleInfo, OldNonLocalsList, OldNewRenaming, OldInstMap, NewInstMap, NewVarTypes, exact, Exact), MaybeVersion = version(Exact, PredProcId, Version, @@ -588,17 +588,17 @@ pd_info__goal_is_more_general(ModuleInfo, OldGoal, OldInstMap, OldArgs, % Check that all the insts in the old version are at least as % general as the insts in the new version. % -:- pred pd_info__check_insts(module_info::in, list(prog_var)::in, +:- pred pd_info.check_insts(module_info::in, list(prog_var)::in, map(prog_var, prog_var)::in, instmap::in, instmap::in, vartypes::in, version_is_exact::in, version_is_exact::out) is semidet. -pd_info__check_insts(_, [], _, _, _, _, !ExactSoFar). -pd_info__check_insts(ModuleInfo, [OldVar | Vars], VarRenaming, OldInstMap, +pd_info.check_insts(_, [], _, _, _, _, !ExactSoFar). +pd_info.check_insts(ModuleInfo, [OldVar | Vars], VarRenaming, OldInstMap, NewInstMap, VarTypes, !ExactSoFar) :- - instmap__lookup_var(OldInstMap, OldVar, OldVarInst), - map__lookup(VarRenaming, OldVar, NewVar), - instmap__lookup_var(NewInstMap, NewVar, NewVarInst), - map__lookup(VarTypes, NewVar, Type), + instmap.lookup_var(OldInstMap, OldVar, OldVarInst), + map.lookup(VarRenaming, OldVar, NewVar), + instmap.lookup_var(NewInstMap, NewVar, NewVarInst), + map.lookup(VarTypes, NewVar, Type), inst_matches_initial(NewVarInst, OldVarInst, Type, ModuleInfo), ( !.ExactSoFar = exact -> % Does inst_matches_initial(Inst1, Inst2, M) and @@ -615,23 +615,23 @@ pd_info__check_insts(ModuleInfo, [OldVar | Vars], VarRenaming, OldInstMap, ; !:ExactSoFar = more_general ), - pd_info__check_insts(ModuleInfo, Vars, VarRenaming, OldInstMap, + pd_info.check_insts(ModuleInfo, Vars, VarRenaming, OldInstMap, NewInstMap, VarTypes, !ExactSoFar). %-----------------------------------------------------------------------------% -pd_info__define_new_pred(Origin, Goal, PredProcId, CallGoal, !PDInfo) :- +pd_info.define_new_pred(Origin, Goal, PredProcId, CallGoal, !PDInfo) :- pd_info_get_instmap(!.PDInfo, InstMap), Goal = _ - GoalInfo, goal_info_get_nonlocals(GoalInfo, NonLocals), - set__to_sorted_list(NonLocals, Args), + set.to_sorted_list(NonLocals, Args), pd_info_get_counter(!.PDInfo, Counter0), - counter__allocate(Count, Counter0, Counter), + counter.allocate(Count, Counter0, Counter), pd_info_set_counter(Counter, !PDInfo), pd_info_get_pred_info(!.PDInfo, PredInfo), PredName = pred_info_name(PredInfo), goal_info_get_context(GoalInfo, Context), - term__context_line(Context, Line), + term.context_line(Context, Line), pd_info_get_module_info(!.PDInfo, ModuleInfo0), module_info_get_name(ModuleInfo0, ModuleName), make_pred_name_with_context(ModuleName, "DeforestationIn", @@ -648,7 +648,7 @@ pd_info__define_new_pred(Origin, Goal, PredProcId, CallGoal, !PDInfo) :- proc_info_inst_varset(ProcInfo, InstVarSet), % XXX handle the extra typeinfo arguments for % --typeinfo-liveness properly. - hlds_pred__define_new_pred(Origin, Goal, CallGoal, Args, _ExtraArgs, + hlds_pred.define_new_pred(Origin, Goal, CallGoal, Args, _ExtraArgs, InstMap, Name, TVarSet, VarTypes, ClassContext, RttiVarMaps, VarSet, InstVarSet, Markers, address_is_not_taken, ModuleInfo0, ModuleInfo, PredProcId), @@ -656,59 +656,59 @@ pd_info__define_new_pred(Origin, Goal, PredProcId, CallGoal, !PDInfo) :- %-----------------------------------------------------------------------------% -pd_info__register_version(PredProcId, Version, !PDInfo, !IO) :- - pd_debug__register_version(!.PDInfo, PredProcId, Version, !IO), +pd_info.register_version(PredProcId, Version, !PDInfo, !IO) :- + pd_debug_register_version(!.PDInfo, PredProcId, Version, !IO), pd_info_get_goal_version_index(!.PDInfo, GoalVersionIndex0), Goal = Version ^ version_orig_goal, - pd_util__goal_get_calls(Goal, Calls), - ( map__search(GoalVersionIndex0, Calls, VersionList0) -> - map__det_update(GoalVersionIndex0, Calls, + pd_util.goal_get_calls(Goal, Calls), + ( map.search(GoalVersionIndex0, Calls, VersionList0) -> + map.det_update(GoalVersionIndex0, Calls, [PredProcId | VersionList0], GoalVersionIndex) ; - map__set(GoalVersionIndex0, Calls, [PredProcId], + map.set(GoalVersionIndex0, Calls, [PredProcId], GoalVersionIndex) ), pd_info_set_goal_version_index(GoalVersionIndex, !PDInfo), pd_info_get_versions(!.PDInfo, Versions0), - map__det_insert(Versions0, PredProcId, Version, Versions), + map.det_insert(Versions0, PredProcId, Version, Versions), pd_info_set_versions(Versions, !PDInfo), pd_info_get_created_versions(!.PDInfo, CreatedVersions0), - set__insert(CreatedVersions0, PredProcId, CreatedVersions), + set.insert(CreatedVersions0, PredProcId, CreatedVersions), pd_info_set_created_versions(CreatedVersions, !PDInfo). %-----------------------------------------------------------------------------% -pd_info__invalidate_version(PredProcId, !PDInfo) :- +pd_info.invalidate_version(PredProcId, !PDInfo) :- pd_info_get_versions(!.PDInfo, Versions0), - map__lookup(Versions0, PredProcId, Version), + map.lookup(Versions0, PredProcId, Version), Goal = Version ^ version_orig_goal, - pd_util__goal_get_calls(Goal, Calls), + pd_util.goal_get_calls(Goal, Calls), ( Calls = [FirstCall | _], - list__last(Calls, LastCall) + list.last(Calls, LastCall) -> % Make sure we never create another version to deforest % this pair of calls. pd_info_get_useless_versions(!.PDInfo, Useless0), - set__insert(Useless0, FirstCall - LastCall, Useless), + set.insert(Useless0, FirstCall - LastCall, Useless), pd_info_set_useless_versions(Useless, !PDInfo) ; true ), - pd_info__remove_version(PredProcId, !PDInfo). + pd_info.remove_version(PredProcId, !PDInfo). -pd_info__remove_version(PredProcId, !PDInfo) :- +pd_info.remove_version(PredProcId, !PDInfo) :- pd_info_get_versions(!.PDInfo, Versions0), - map__lookup(Versions0, PredProcId, Version), + map.lookup(Versions0, PredProcId, Version), Goal = Version ^ version_orig_goal, - pd_util__goal_get_calls(Goal, Calls), - map__delete(Versions0, PredProcId, Versions), + pd_util.goal_get_calls(Goal, Calls), + map.delete(Versions0, PredProcId, Versions), pd_info_set_versions(Versions, !PDInfo), pd_info_get_goal_version_index(!.PDInfo, GoalIndex0), - ( map__search(GoalIndex0, Calls, GoalVersions0) -> - list__delete_all(GoalVersions0, PredProcId, GoalVersions), - map__det_update(GoalIndex0, Calls, + ( map.search(GoalIndex0, Calls, GoalVersions0) -> + list.delete_all(GoalVersions0, PredProcId, GoalVersions), + map.det_update(GoalIndex0, Calls, GoalVersions, GoalIndex), pd_info_set_goal_version_index(GoalIndex, !PDInfo) ; @@ -716,7 +716,7 @@ pd_info__remove_version(PredProcId, !PDInfo) :- ), pd_info_get_created_versions(!.PDInfo, CreatedVersions0), - set__delete(CreatedVersions0, PredProcId, CreatedVersions), + set.delete(CreatedVersions0, PredProcId, CreatedVersions), pd_info_set_created_versions(CreatedVersions, !PDInfo), pd_info_get_module_info(!.PDInfo, ModuleInfo0), diff --git a/compiler/pd_term.m b/compiler/pd_term.m index 10cbf6ce2..6479899ad 100644 --- a/compiler/pd_term.m +++ b/compiler/pd_term.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1998-2001, 2003-2005 The University of Melbourne. +% Copyright (C) 1998-2001, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -37,7 +37,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__pd_term. +:- module transform_hlds.pd_term. :- interface. :- import_module hlds.hlds_goal. @@ -51,16 +51,15 @@ %-----------------------------------------------------------------------------% - % pd_term__global_check(Module, CallGoal1, BetweenGoals, CallGoal2, + % global_check(Module, CallGoal1, BetweenGoals, CallGoal2, % InstMap, Versions, Info0, Info, Result): % % Check whether a new version can be created for the conjunction % (CallGoal1, BetweenGoals, CallGoal2) without the deforestation % process looping. % -:- pred pd_term__global_check(module_info::in, hlds_goal::in, - list(hlds_goal)::in, maybe(hlds_goal)::in, instmap::in, - version_index::in, global_term_info::in, +:- pred global_check(module_info::in, hlds_goal::in, list(hlds_goal)::in, + maybe(hlds_goal)::in, instmap::in, version_index::in, global_term_info::in, global_term_info::out, global_check_result::out) is det. % A proc_pair holds the pred_proc_ids of the procedures called at @@ -77,20 +76,20 @@ % Check whether a call can be unfolded without the % unfolding process looping. % -:- pred pd_term__local_check(module_info::in, hlds_goal::in, instmap::in, +:- pred local_check(module_info::in, hlds_goal::in, instmap::in, local_term_info::in, local_term_info::out) is semidet. -:- pred pd_term__global_term_info_init(global_term_info::out) is det. +:- pred global_term_info_init(global_term_info::out) is det. -:- pred pd_term__local_term_info_init(local_term_info::out) is det. +:- pred local_term_info_init(local_term_info::out) is det. -:- pred pd_term__get_proc_term_info(local_term_info::in, pred_proc_id::in, +:- pred get_proc_term_info(local_term_info::in, pred_proc_id::in, pd_proc_term_info::out) is semidet. % Update the global termination information when we find out the % pred_proc_id that has been assigned to a version. % -:- pred pd_term__update_global_term_info(proc_pair::in, pred_proc_id::in, +:- pred update_global_term_info(proc_pair::in, pred_proc_id::in, int::in, global_term_info::in,global_term_info::out) is det. :- type global_term_info. @@ -139,20 +138,20 @@ %-----------------------------------------------------------------------------% -pd_term__global_term_info_init(TermInfo) :- - map__init(SingleGoals), - map__init(MultipleGoals), +global_term_info_init(TermInfo) :- + map.init(SingleGoals), + map.init(MultipleGoals), TermInfo = global_term_info(SingleGoals, MultipleGoals). -pd_term__local_term_info_init(TermInfo) :- - map__init(TermInfo). +local_term_info_init(TermInfo) :- + map.init(TermInfo). -pd_term__get_proc_term_info(TermInfo, PredProcId, ProcTermInfo) :- - map__search(TermInfo, PredProcId, ProcTermInfo). +get_proc_term_info(TermInfo, PredProcId, ProcTermInfo) :- + map.search(TermInfo, PredProcId, ProcTermInfo). %-----------------------------------------------------------------------------% -pd_term__global_check(_ModuleInfo, EarlierGoal, BetweenGoals, MaybeLaterGoal, +global_check(_ModuleInfo, EarlierGoal, BetweenGoals, MaybeLaterGoal, _InstMap, Versions, !Info, Result) :- !.Info = global_term_info(SingleGoalCover0, MultipleGoalCover0), ( @@ -163,7 +162,7 @@ pd_term__global_check(_ModuleInfo, EarlierGoal, BetweenGoals, MaybeLaterGoal, expand_calls(Hd, Versions, proc(PredId1, ProcId1), FirstPredProcId), ( MaybeLaterGoal = yes(call(PredId2, ProcId2, _, _, _, _) - _), - expand_calls(list__last, Versions, proc(PredId2, ProcId2), + expand_calls(list.last, Versions, proc(PredId2, ProcId2), LastPredProcId), MaybeLastPredProcId = yes(LastPredProcId) ; @@ -172,9 +171,9 @@ pd_term__global_check(_ModuleInfo, EarlierGoal, BetweenGoals, MaybeLaterGoal, ) -> ProcPair = FirstPredProcId - MaybeLastPredProcId, - list__length(BetweenGoals, Length), + list.length(BetweenGoals, Length), ( - map__search(MultipleGoalCover0, ProcPair, + map.search(MultipleGoalCover0, ProcPair, MaxLength - MaybeCoveringPredProcId) -> ( @@ -182,7 +181,7 @@ pd_term__global_check(_ModuleInfo, EarlierGoal, BetweenGoals, MaybeLaterGoal, -> Result = ok(ProcPair, Length), % Set the maybe(pred_proc_id) when we create the new predicate. - map__set(MultipleGoalCover0, ProcPair, + map.set(MultipleGoalCover0, ProcPair, Length - no, MultipleGoalCover) ; Length = MaxLength, @@ -202,7 +201,7 @@ pd_term__global_check(_ModuleInfo, EarlierGoal, BetweenGoals, MaybeLaterGoal, Result = ok(ProcPair, Length), % Set the maybe(pred_proc_id) when we create the new predicate. - map__set(MultipleGoalCover0, ProcPair, Length - no, + map.set(MultipleGoalCover0, ProcPair, Length - no, MultipleGoalCover) ), SingleGoalCover = SingleGoalCover0 @@ -226,7 +225,7 @@ pd_term__global_check(_ModuleInfo, EarlierGoal, BetweenGoals, MaybeLaterGoal, pred_proc_id::in, pred_proc_id::out) is semidet. expand_calls(GetEnd, Versions, PredProcId0, PredProcId) :- - ( map__search(Versions, PredProcId0, VersionInfo) -> + ( map.search(Versions, PredProcId0, VersionInfo) -> Calls = VersionInfo ^ version_deforest_calls, call(GetEnd, Calls, PredProcId1), expand_calls(GetEnd, Versions, PredProcId1, PredProcId) @@ -236,83 +235,80 @@ expand_calls(GetEnd, Versions, PredProcId0, PredProcId) :- %-----------------------------------------------------------------------------% -pd_term__local_check(ModuleInfo, Goal1, InstMap, !Cover) :- +local_check(ModuleInfo, Goal1, InstMap, !Cover) :- Goal1 = call(PredId, ProcId, Args, _, _, _) - _, - ( map__search(!.Cover, proc(PredId, ProcId), CoveringInstSizes0) -> - pd_term__do_local_check(ModuleInfo, InstMap, Args, + ( map.search(!.Cover, proc(PredId, ProcId), CoveringInstSizes0) -> + do_local_check(ModuleInfo, InstMap, Args, CoveringInstSizes0, CoveringInstSizes), - map__set(!.Cover, proc(PredId, ProcId), CoveringInstSizes, !:Cover) + map.set(!.Cover, proc(PredId, ProcId), CoveringInstSizes, !:Cover) ; - pd_term__initial_sizes(ModuleInfo, InstMap, - Args, 1, ArgInstSizes), - map__set(!.Cover, proc(PredId, ProcId), ArgInstSizes, !:Cover) + initial_sizes(ModuleInfo, InstMap, Args, 1, ArgInstSizes), + map.set(!.Cover, proc(PredId, ProcId), ArgInstSizes, !:Cover) ). -:- pred pd_term__do_local_check(module_info::in, instmap::in, - list(prog_var)::in, assoc_list(int, int)::in, - assoc_list(int, int)::out) is semidet. +:- pred do_local_check(module_info::in, instmap::in, list(prog_var)::in, + assoc_list(int, int)::in, assoc_list(int, int)::out) is semidet. -pd_term__do_local_check(ModuleInfo, InstMap, Args, OldSizes, NewSizes) :- - pd_term__get_matching_sizes(ModuleInfo, InstMap, Args, - OldSizes, NewSizes1, OldTotal, NewTotal), +do_local_check(ModuleInfo, InstMap, Args, OldSizes, NewSizes) :- + get_matching_sizes(ModuleInfo, InstMap, Args, OldSizes, NewSizes1, + OldTotal, NewTotal), ( NewTotal < OldTotal -> NewSizes = NewSizes1 ; - pd_term__split_out_non_increasing(OldSizes, NewSizes1, yes, NewSizes) + split_out_non_increasing(OldSizes, NewSizes1, yes, NewSizes) ). %-----------------------------------------------------------------------------% -pd_term__update_global_term_info(ProcPair, PredProcId, Size, !TermInfo) :- +update_global_term_info(ProcPair, PredProcId, Size, !TermInfo) :- !.TermInfo = global_term_info(Single, Multiple0), - map__set(Multiple0, ProcPair, Size - yes(PredProcId), Multiple), + map.set(Multiple0, ProcPair, Size - yes(PredProcId), Multiple), !:TermInfo = global_term_info(Single, Multiple). %-----------------------------------------------------------------------------% -:- pred pd_term__initial_sizes(module_info::in, instmap::in, +:- pred initial_sizes(module_info::in, instmap::in, list(prog_var)::in, int::in, assoc_list(int, int)::out) is det. -pd_term__initial_sizes(_, _, [], _, []). -pd_term__initial_sizes(ModuleInfo, InstMap, [Arg | Args], ArgNo, +initial_sizes(_, _, [], _, []). +initial_sizes(ModuleInfo, InstMap, [Arg | Args], ArgNo, [ArgNo - Size | Sizes]) :- NextArgNo = ArgNo + 1, - pd_term__initial_sizes(ModuleInfo, InstMap, Args, NextArgNo, Sizes), - instmap__lookup_var(InstMap, Arg, ArgInst), - pd_util__inst_size(ModuleInfo, ArgInst, Size). + initial_sizes(ModuleInfo, InstMap, Args, NextArgNo, Sizes), + instmap.lookup_var(InstMap, Arg, ArgInst), + pd_util.inst_size(ModuleInfo, ArgInst, Size). %-----------------------------------------------------------------------------% -:- pred pd_term__get_matching_sizes(module_info::in, instmap::in, +:- pred get_matching_sizes(module_info::in, instmap::in, list(prog_var)::in, assoc_list(int, int)::in, assoc_list(int, int)::out, int::out, int::out) is det. -pd_term__get_matching_sizes(_, _, _, [], [], 0, 0). -pd_term__get_matching_sizes(ModuleInfo, InstMap, Args, +get_matching_sizes(_, _, _, [], [], 0, 0). +get_matching_sizes(ModuleInfo, InstMap, Args, [ArgNo - OldSize | OldSizes], [ArgNo - NewSize | NewSizes], OldTotal, NewTotal) :- - pd_term__get_matching_sizes(ModuleInfo, InstMap, Args, - OldSizes, NewSizes, OldTotal1, NewTotal1), - list__index1_det(Args, ArgNo, Arg), - instmap__lookup_var(InstMap, Arg, ArgInst), - pd_util__inst_size(ModuleInfo, ArgInst, NewSize), + get_matching_sizes(ModuleInfo, InstMap, Args, OldSizes, NewSizes, + OldTotal1, NewTotal1), + list.index1_det(Args, ArgNo, Arg), + instmap.lookup_var(InstMap, Arg, ArgInst), + pd_util.inst_size(ModuleInfo, ArgInst, NewSize), OldTotal = OldTotal1 + OldSize, NewTotal = NewTotal1 + NewSize. %-----------------------------------------------------------------------------% -:- pred pd_term__split_out_non_increasing(assoc_list(int, int)::in, +:- pred split_out_non_increasing(assoc_list(int, int)::in, assoc_list(int, int)::in, bool::out, assoc_list(int, int)::out) is semidet. -pd_term__split_out_non_increasing([], [], no, []). -pd_term__split_out_non_increasing([_|_], [], _, _) :- +split_out_non_increasing([], [], no, []). +split_out_non_increasing([_|_], [], _, _) :- unexpected(this_file, "split_out_non_increasing (1)"). -pd_term__split_out_non_increasing([], [_|_], _, _) :- +split_out_non_increasing([], [_|_], _, _) :- unexpected(this_file, "split_out_non_increasing (2)"). -pd_term__split_out_non_increasing([Arg - OldSize | Args0], +split_out_non_increasing([Arg - OldSize | Args0], [_ - NewSize | Args], FoundDecreasing, NonIncreasing) :- - pd_term__split_out_non_increasing(Args0, Args, - FoundDecreasing1, NonIncreasing1), + split_out_non_increasing(Args0, Args, FoundDecreasing1, NonIncreasing1), ( NewSize =< OldSize -> NonIncreasing = [Arg - NewSize | NonIncreasing1], ( NewSize = OldSize -> diff --git a/compiler/pd_util.m b/compiler/pd_util.m index 1ea077738..01adf354f 100644 --- a/compiler/pd_util.m +++ b/compiler/pd_util.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__pd_util. +:- module transform_hlds.pd_util. :- interface. :- import_module check_hlds.mode_errors. @@ -79,7 +79,7 @@ :- pred requantify_goal(set(prog_var)::in, hlds_goal::in, hlds_goal::out, pd_info::in, pd_info::out) is det. - % Apply mode_util__recompute_instmap_delta to the goal. + % Apply mode_util.recompute_instmap_delta to the goal. % :- pred recompute_instmap_delta(hlds_goal::in, hlds_goal::out, pd_info::in, pd_info::out) is det. @@ -192,18 +192,18 @@ goal_get_calls(Goal0, CalledPreds) :- Goal = call(PredId, ProcId, _, _, _, _) - _, CalledPred = proc(PredId, ProcId) ), - list__filter_map(GetCalls, GoalList, CalledPreds). + list.filter_map(GetCalls, GoalList, CalledPreds). %-----------------------------------------------------------------------------% propagate_constraints(!Goal, !PDInfo, !IO) :- - globals__io_lookup_bool_option(local_constraint_propagation, + globals.io_lookup_bool_option(local_constraint_propagation, ConstraintProp, !IO), ( ConstraintProp = yes, Goal0 = !.Goal, - pd_debug__message("%% Propagating constraints\n", [], !IO), - pd_debug__output_goal(!.PDInfo, "before constraints\n", Goal0, !IO), + pd_debug_message("%% Propagating constraints\n", [], !IO), + pd_debug_output_goal(!.PDInfo, "before constraints\n", Goal0, !IO), pd_info_get_module_info(!.PDInfo, ModuleInfo0), pd_info_get_proc_info(!.PDInfo, ProcInfo0), pd_info_get_instmap(!.PDInfo, InstMap), @@ -212,7 +212,7 @@ propagate_constraints(!Goal, !PDInfo, !IO) :- constraint_info_init(ModuleInfo0, VarTypes0, VarSet0, InstMap, CInfo0), Goal0 = _ - GoalInfo0, goal_info_get_nonlocals(GoalInfo0, NonLocals), - constraint__propagate_constraints_in_goal(!Goal, CInfo0, CInfo, !IO), + constraint.propagate_constraints_in_goal(!Goal, CInfo0, CInfo, !IO), constraint_info_deconstruct(CInfo, ModuleInfo, VarTypes, VarSet, Changed), pd_info_set_module_info(ModuleInfo, !PDInfo), @@ -221,13 +221,13 @@ propagate_constraints(!Goal, !PDInfo, !IO) :- pd_info_set_proc_info(ProcInfo, !PDInfo), ( Changed = yes, - pd_debug__output_goal(!.PDInfo, + pd_debug_output_goal(!.PDInfo, "after constraints, before recompute\n", !.Goal, !IO), requantify_goal(NonLocals, !Goal, !PDInfo), recompute_instmap_delta(!Goal, !PDInfo), rerun_det_analysis(!Goal, !PDInfo, !IO), module_info_get_globals(ModuleInfo, Globals), - simplify__find_simplifications(no, Globals, Simplifications), + simplify.find_simplifications(no, Globals, Simplifications), simplify_goal(Simplifications, !Goal, !PDInfo, !IO) ; % Use Goal0 rather than the output of propagate_constraints_in_goal @@ -255,7 +255,7 @@ simplify_goal(Simplifications, Goal0, Goal, !PDInfo, !IO) :- simplify_info_init(DetInfo0, Simplifications, InstMap0, ProcInfo0, SimplifyInfo0), - simplify__process_goal(Goal0, Goal, SimplifyInfo0, SimplifyInfo, !IO), + simplify.process_goal(Goal0, Goal, SimplifyInfo0, SimplifyInfo, !IO), % Deconstruct the simplify_info. simplify_info_get_module_info(SimplifyInfo, ModuleInfo), @@ -284,7 +284,7 @@ unique_modecheck_goal(LiveVars, Goal0, Goal, Errors, !PDInfo, !IO) :- PredProcId = proc(PredId, ProcId), pd_info_get_module_info(!.PDInfo, ModuleInfo0), pd_info_get_instmap(!.PDInfo, InstMap0), - term__context_init(Context), + term.context_init(Context), pd_info_get_pred_info(!.PDInfo, PredInfo0), pd_info_get_proc_info(!.PDInfo, ProcInfo0), module_info_set_pred_proc_info(PredId, ProcId, PredInfo0, ProcInfo0, @@ -296,8 +296,8 @@ unique_modecheck_goal(LiveVars, Goal0, Goal, Errors, !PDInfo, !IO) :- mode_info_init(ModuleInfo1, PredId, ProcId, Context, LiveVars, InstMap0, check_unique_modes, MayChangeCalledProc, ModeInfo0), - unique_modes__check_goal(Goal0, Goal, ModeInfo0, ModeInfo1, !IO), - globals__io_lookup_bool_option(debug_pd, Debug, !IO), + unique_modes.check_goal(Goal0, Goal, ModeInfo0, ModeInfo1, !IO), + globals.io_lookup_bool_option(debug_pd, Debug, !IO), ( Debug = yes, report_mode_errors(ModeInfo1, ModeInfo, !IO) @@ -330,8 +330,8 @@ get_goal_live_vars(PDInfo, _ - GoalInfo, !:Vars) :- goal_info_get_instmap_delta(GoalInfo, InstMapDelta), pd_info_get_instmap(PDInfo, InstMap), goal_info_get_nonlocals(GoalInfo, NonLocals), - set__to_sorted_list(NonLocals, NonLocalsList), - set__init(!:Vars), + set.to_sorted_list(NonLocals, NonLocalsList), + set.init(!:Vars), get_goal_live_vars_2(ModuleInfo, NonLocalsList, InstMap, InstMapDelta, !Vars). @@ -345,15 +345,14 @@ get_goal_live_vars_2(ModuleInfo, [NonLocal | NonLocals], ( instmap_delta_search_var(InstMapDelta, NonLocal, FinalInst0) -> FinalInst = FinalInst0 ; - instmap__lookup_var(InstMap, NonLocal, FinalInst) + instmap.lookup_var(InstMap, NonLocal, FinalInst) ), ( inst_is_clobbered(ModuleInfo, FinalInst) -> true ; - svset__insert(NonLocal, !Vars) + svset.insert(NonLocal, !Vars) ), - get_goal_live_vars_2(ModuleInfo, NonLocals, InstMap, InstMapDelta, - !Vars). + get_goal_live_vars_2(ModuleInfo, NonLocals, InstMap, InstMapDelta, !Vars). %-----------------------------------------------------------------------------% @@ -393,17 +392,17 @@ rerun_det_analysis(Goal0, Goal, !PDInfo, !IO) :- convert_branch_info(ArgInfo, Args, VarInfo) :- ArgInfo = pd_branch_info(ArgMap, LeftArgs, OpaqueArgs), - map__to_assoc_list(ArgMap, ArgList), - map__init(BranchVarMap0), + map.to_assoc_list(ArgMap, ArgList), + map.init(BranchVarMap0), convert_branch_info_2(ArgList, Args, BranchVarMap0, BranchVarMap), - set__to_sorted_list(LeftArgs, LeftArgNos), - list__map(list__index1_det(Args), LeftArgNos, LeftVars0), - set__list_to_set(LeftVars0, LeftVars), + set.to_sorted_list(LeftArgs, LeftArgNos), + list.map(list.index1_det(Args), LeftArgNos, LeftVars0), + set.list_to_set(LeftVars0, LeftVars), - set__to_sorted_list(OpaqueArgs, OpaqueArgNos), - list__map(list__index1_det(Args), OpaqueArgNos, OpaqueVars0), - set__list_to_set(OpaqueVars0, OpaqueVars), + set.to_sorted_list(OpaqueArgs, OpaqueArgNos), + list.map(list.index1_det(Args), OpaqueArgNos, OpaqueVars0), + set.list_to_set(OpaqueVars0, OpaqueVars), VarInfo = pd_branch_info(BranchVarMap, LeftVars, OpaqueVars). @@ -411,10 +410,9 @@ convert_branch_info(ArgInfo, Args, VarInfo) :- prog_vars::in, pd_var_info::in, pd_var_info::out) is det. convert_branch_info_2([], _, !VarInfo). -convert_branch_info_2([ArgNo - Branches | ArgInfos], Args, - !VarInfo) :- - list__index1_det(Args, ArgNo, Arg), - svmap__set(Arg, Branches, !VarInfo), +convert_branch_info_2([ArgNo - Branches | ArgInfos], Args, !VarInfo) :- + list.index1_det(Args, ArgNo, Arg), + svmap.set(Arg, Branches, !VarInfo), convert_branch_info_2(ArgInfos, Args, !VarInfo). %-----------------------------------------------------------------------------% @@ -424,24 +422,24 @@ convert_branch_info_2([ArgNo - Branches | ArgInfos], Args, get_branch_vars_proc(PredProcId, ProcInfo, !ArgInfo, !ModuleInfo) :- proc_info_goal(ProcInfo, Goal), proc_info_vartypes(ProcInfo, VarTypes), - instmap__init_reachable(InstMap0), - map__init(Vars0), - set__init(LeftVars0), + instmap.init_reachable(InstMap0), + map.init(Vars0), + set.init(LeftVars0), goal_to_conj_list(Goal, GoalList), ( get_branch_vars_goal_2(!.ModuleInfo, GoalList, no, VarTypes, InstMap0, LeftVars0, LeftVars, Vars0, Vars) -> proc_info_headvars(ProcInfo, HeadVars), - map__init(ThisProcArgMap0), - set__init(ThisProcLeftArgs0), + map.init(ThisProcArgMap0), + set.init(ThisProcLeftArgs0), get_extra_info_headvars(HeadVars, 1, LeftVars, Vars, ThisProcArgMap0, ThisProcArgMap1, ThisProcLeftArgs0, ThisProcLeftArgs), - set__init(OpaqueArgs0), + set.init(OpaqueArgs0), BranchInfo0 = pd_branch_info(ThisProcArgMap1, ThisProcLeftArgs, OpaqueArgs0), - svmap__set(PredProcId, BranchInfo0, !ArgInfo), + svmap.set(PredProcId, BranchInfo0, !ArgInfo), % Look for opportunities for deforestation in % the sub-branches of the top-level goal. @@ -456,13 +454,13 @@ get_branch_vars_proc(PredProcId, ProcInfo, !ArgInfo, !ModuleInfo) :- BranchInfo = pd_branch_info(ThisProcArgMap, ThisProcLeftArgs, OpaqueArgs), - svmap__set(PredProcId, BranchInfo, !ArgInfo) + svmap.set(PredProcId, BranchInfo, !ArgInfo) ; true ). % Find output arguments about which we have no extra information, - % such as io__states. If a later goal in a conjunction depends + % such as io.states. If a later goal in a conjunction depends % on one of these, it is unlikely that the deforestation will % be able to successfully fold to give a recursive definition. % @@ -474,9 +472,9 @@ get_opaque_args(ModuleInfo, ArgNo, [ArgMode | ArgModes], ExtraInfoArgs, !OpaqueArgs) :- ( mode_is_output(ModuleInfo, ArgMode), - \+ map__contains(ExtraInfoArgs, ArgNo) + \+ map.contains(ExtraInfoArgs, ArgNo) -> - set__insert(!.OpaqueArgs, ArgNo, !:OpaqueArgs) + set.insert(!.OpaqueArgs, ArgNo, !:OpaqueArgs) ; true ), @@ -496,13 +494,13 @@ get_opaque_args(ModuleInfo, ArgNo, [ArgMode | ArgModes], get_extra_info_headvars([], _, _, _, !Args, !LeftArgs). get_extra_info_headvars([HeadVar | HeadVars], ArgNo, LeftVars, VarInfo, !ThisProcArgs, !ThisProcLeftVars) :- - ( map__search(VarInfo, HeadVar, ThisVarInfo) -> - svmap__det_insert(ArgNo, ThisVarInfo, !ThisProcArgs) + ( map.search(VarInfo, HeadVar, ThisVarInfo) -> + svmap.det_insert(ArgNo, ThisVarInfo, !ThisProcArgs) ; true ), - ( set__member(HeadVar, LeftVars) -> - svset__insert(ArgNo, !ThisProcLeftVars) + ( set.member(HeadVar, LeftVars) -> + svset.insert(ArgNo, !ThisProcLeftVars) ; true ), @@ -518,8 +516,8 @@ get_branch_vars_goal(Goal, MaybeBranchInfo, !PDInfo) :- pd_info_get_proc_arg_info(!.PDInfo, ProcArgInfo), pd_info_get_proc_info(!.PDInfo, ProcInfo), proc_info_vartypes(ProcInfo, VarTypes), - set__init(LeftVars0), - map__init(Vars0), + set.init(LeftVars0), + map.init(Vars0), ( get_branch_vars_goal_2(ModuleInfo0, [Goal], no, VarTypes, InstMap0, LeftVars0, LeftVars, Vars0, Vars1) @@ -530,9 +528,8 @@ get_branch_vars_goal(Goal, MaybeBranchInfo, !PDInfo) :- pd_info_set_module_info(ModuleInfo, !PDInfo), % OpaqueVars is only filled in for calls. - set__init(OpaqueVars), - MaybeBranchInfo = yes(pd_branch_info(Vars, LeftVars, OpaqueVars) - ) + set.init(OpaqueVars), + MaybeBranchInfo = yes(pd_branch_info(Vars, LeftVars, OpaqueVars)) ; MaybeBranchInfo = no ). @@ -547,7 +544,7 @@ get_branch_vars_goal_2(ModuleInfo, [Goal | Goals], !.FoundBranch, VarTypes, InstMap0, !LeftVars, !Vars) :- Goal = _ - GoalInfo, goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap), ( get_branch_instmap_deltas(Goal, InstMapDeltas) -> % Only look for goals with one top-level branched goal, % since deforestation of goals with more than one is @@ -578,14 +575,14 @@ get_branch_instmap_deltas(switch(_, _, Cases) - _, InstMapDeltas) :- Case = case(_, _ - CaseInfo), goal_info_get_instmap_delta(CaseInfo, InstMapDelta) ), - list__map(GetCaseInstMapDelta, Cases, InstMapDeltas). + list.map(GetCaseInstMapDelta, Cases, InstMapDeltas). get_branch_instmap_deltas(disj(Disjuncts) - _, InstMapDeltas) :- GetDisjunctInstMapDelta = (pred(Disjunct::in, InstMapDelta::out) is det :- Disjunct = _ - DisjInfo, goal_info_get_instmap_delta(DisjInfo, InstMapDelta) ), - list__map(GetDisjunctInstMapDelta, Disjuncts, InstMapDeltas). + list.map(GetDisjunctInstMapDelta, Disjuncts, InstMapDeltas). % Get the variables for which we can do unfolding if the goals to % the left supply the top-level functor. Eventually this should @@ -596,7 +593,7 @@ get_branch_instmap_deltas(disj(Disjuncts) - _, InstMapDeltas) :- get_left_vars(Goal, Vars0, Vars) :- ( Goal = switch(Var, _, _) - _ -> - set__insert(Vars0, Var, Vars) + set.insert(Vars0, Var, Vars) ; Vars = Vars0 ). @@ -611,35 +608,35 @@ get_branch_vars(ModuleInfo, Goal, [InstMapDelta | InstMapDeltas], AddExtraInfoVars = (pred(ChangedVar::in, Vars0::in, Vars::out) is det :- ( - instmap__lookup_var(InstMap, ChangedVar, VarInst), + instmap.lookup_var(InstMap, ChangedVar, VarInst), instmap_delta_search_var(InstMapDelta, ChangedVar, DeltaVarInst), inst_is_bound_to_functors(ModuleInfo, DeltaVarInst, [_]), \+ inst_is_bound_to_functors(ModuleInfo, VarInst, [_]) -> - ( map__search(Vars0, ChangedVar, Set0) -> - set__insert(Set0, BranchNo, Set) + ( map.search(Vars0, ChangedVar, Set0) -> + set.insert(Set0, BranchNo, Set) ; - set__singleton_set(Set, BranchNo) + set.singleton_set(Set, BranchNo) ), - map__set(Vars0, ChangedVar, Set, Vars) + map.set(Vars0, ChangedVar, Set, Vars) ; Vars = Vars0 ) ), instmap_delta_changed_vars(InstMapDelta, ChangedVars), - set__to_sorted_list(ChangedVars, ChangedVarsList), - list__foldl(AddExtraInfoVars, ChangedVarsList, !ExtraVars), + set.to_sorted_list(ChangedVars, ChangedVarsList), + list.foldl(AddExtraInfoVars, ChangedVarsList, !ExtraVars), % We have extra information about a switched-on variable % at the end of each branch. ( Goal = switch(SwitchVar, _, _) - _ -> - ( map__search(!.ExtraVars, SwitchVar, SwitchVarSet0) -> - set__insert(SwitchVarSet0, BranchNo, SwitchVarSet) + ( map.search(!.ExtraVars, SwitchVar, SwitchVarSet0) -> + set.insert(SwitchVarSet0, BranchNo, SwitchVarSet) ; - set__singleton_set(SwitchVarSet, BranchNo) + set.singleton_set(SwitchVarSet, BranchNo) ), - svmap__set(SwitchVar, SwitchVarSet, !ExtraVars) + svmap.set(SwitchVar, SwitchVarSet, !ExtraVars) ; true ), @@ -661,7 +658,7 @@ get_sub_branch_vars_goal(ProcArgInfo, [Goal | GoalList], ( GoalExpr = if_then_else(_, Cond, Then, Else) -> Cond = _ - CondInfo, goal_info_get_instmap_delta(CondInfo, CondDelta), - instmap__apply_instmap_delta(InstMap0, CondDelta, InstMap1), + instmap.apply_instmap_delta(InstMap0, CondDelta, InstMap1), goal_to_conj_list(Then, ThenList), examine_branch(!.ModuleInfo, ProcArgInfo, 1, ThenList, VarTypes, InstMap1, Vars0, Vars1), @@ -678,7 +675,7 @@ get_sub_branch_vars_goal(ProcArgInfo, [Goal | GoalList], Vars2 = Vars0 ), goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap), get_sub_branch_vars_goal(ProcArgInfo, GoalList, VarTypes, InstMap, Vars2, SubVars, !ModuleInfo). @@ -704,8 +701,8 @@ examine_branch_list(ModuleInfo, ProcArgInfo, BranchNo, [Goal | Goals], examine_case_list(_, _, _, [], _, _, !Vars, !ModuleInfo). examine_case_list(ProcArgInfo, BranchNo, Var, [case(ConsId, Goal) | Goals], VarTypes, InstMap, !Vars, !ModuleInfo) :- - map__lookup(VarTypes, Var, Type), - instmap__bind_var_to_functor(Var, Type, ConsId, InstMap, InstMap1, + map.lookup(VarTypes, Var, Type), + instmap.bind_var_to_functor(Var, Type, ConsId, InstMap, InstMap1, !ModuleInfo), goal_to_conj_list(Goal, GoalList), examine_branch(!.ModuleInfo, ProcArgInfo, BranchNo, GoalList, @@ -722,28 +719,28 @@ examine_branch(_, _, _, [], _, _, !Vars). examine_branch(ModuleInfo, ProcArgInfo, BranchNo, [Goal | Goals], VarTypes, InstMap, !Vars) :- ( Goal = call(PredId, ProcId, Args, _, _, _) - _ -> - ( map__search(ProcArgInfo, proc(PredId, ProcId), ThisProcArgInfo) -> + ( map.search(ProcArgInfo, proc(PredId, ProcId), ThisProcArgInfo) -> convert_branch_info(ThisProcArgInfo, Args, BranchInfo), BranchInfo = pd_branch_info(!:Vars, _, _), - map__keys(!.Vars, ExtraVars1), + map.keys(!.Vars, ExtraVars1), combine_vars(BranchNo, ExtraVars1, !Vars) ; true ) ; - set__init(LeftVars0), - map__init(!:Vars), + set.init(LeftVars0), + map.init(!:Vars), get_branch_vars_goal_2(ModuleInfo, [Goal], no, VarTypes, InstMap, LeftVars0, _, !Vars) -> - map__keys(!.Vars, ExtraVars2), + map.keys(!.Vars, ExtraVars2), combine_vars(BranchNo, ExtraVars2, !Vars) ; true ), Goal = _ - GoalInfo, goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap, InstMapDelta, InstMap1), + instmap.apply_instmap_delta(InstMap, InstMapDelta, InstMap1), examine_branch(ModuleInfo, ProcArgInfo, BranchNo, Goals, VarTypes, InstMap1, !Vars). @@ -752,12 +749,12 @@ examine_branch(ModuleInfo, ProcArgInfo, BranchNo, [Goal | Goals], combine_vars(_, [], !Vars). combine_vars(BranchNo, [ExtraVar | ExtraVars], !Vars) :- - ( map__search(!.Vars, ExtraVar, Branches0) -> - set__insert(Branches0, BranchNo, Branches), - svmap__det_update(ExtraVar, Branches, !Vars) + ( map.search(!.Vars, ExtraVar, Branches0) -> + set.insert(Branches0, BranchNo, Branches), + svmap.det_update(ExtraVar, Branches, !Vars) ; - set__singleton_set(Branches, BranchNo), - svmap__det_insert(ExtraVar, Branches, !Vars) + set.singleton_set(Branches, BranchNo), + svmap.det_insert(ExtraVar, Branches, !Vars) ), combine_vars(BranchNo, ExtraVars, !Vars). @@ -786,7 +783,7 @@ recompute_instmap_delta(Goal0, Goal, !PDInfo) :- %-----------------------------------------------------------------------------% inst_MSG(InstA, InstB, ModuleInfo, Inst) :- - set__init(Expansions), + set.init(Expansions), inst_MSG_1(InstA, InstB, Expansions, ModuleInfo, Inst). :- type expansions == set(pair(mer_inst)). @@ -800,10 +797,10 @@ inst_MSG_1(InstA, InstB, Expansions, ModuleInfo, Inst) :- ; % We don't do recursive MSGs % (we could, but it's probably not worth it). - \+ set__member(InstA - InstB, Expansions), + \+ set.member(InstA - InstB, Expansions), inst_expand(ModuleInfo, InstA, InstA2), inst_expand(ModuleInfo, InstB, InstB2), - set__insert(Expansions, InstA - InstB, Expansions1), + set.insert(Expansions, InstA - InstB, Expansions1), ( InstB2 = not_reached -> Inst = InstA2 ; @@ -894,7 +891,7 @@ bound_inst_list_MSG(Xs, Ys, Expansions, ModuleInfo, Uniq, List, Inst) :- %-----------------------------------------------------------------------------% inst_size(ModuleInfo, Inst, Size) :- - set__init(Expansions), + set.init(Expansions), inst_size_2(ModuleInfo, Inst, Expansions, Size). :- pred inst_size_2(module_info::in, mer_inst::in, @@ -911,10 +908,10 @@ inst_size_2(ModuleInfo, constrained_inst_vars(_, Inst), Expansions, inst_size_2(ModuleInfo, Inst, Expansions, Size). inst_size_2(_, abstract_inst(_, _), _, 0). inst_size_2(ModuleInfo, defined_inst(InstName), Expansions0, Size) :- - ( set__member(InstName, Expansions0) -> + ( set.member(InstName, Expansions0) -> Size = 1 ; - set__insert(Expansions0, InstName, Expansions), + set.insert(Expansions0, InstName, Expansions), inst_lookup(ModuleInfo, InstName, Inst), inst_size_2(ModuleInfo, Inst, Expansions, Size) ). @@ -932,7 +929,7 @@ bound_inst_size(ModuleInfo, [functor(_, ArgInsts) | Insts], bound_inst_size(ModuleInfo, Insts, Expansions, Size2, Size). inst_list_size(ModuleInfo, Insts, Size) :- - set__init(Expansions), + set.init(Expansions), inst_list_size(ModuleInfo, Insts, Expansions, 0, Size). :- pred inst_list_size(module_info::in, list(mer_inst)::in, @@ -952,25 +949,25 @@ goals_match(_ModuleInfo, OldGoal, OldArgs, OldArgTypes, goal_to_conj_list(OldGoal, OldGoalList), goal_to_conj_list(NewGoal, NewGoalList), - map__init(OldNewRenaming0), + map.init(OldNewRenaming0), goals_match_2(OldGoalList, NewGoalList, OldNewRenaming0, OldNewRenaming), % Check that the goal produces a superset of the outputs of the % version we are searching for. Search = (pred(K1::in, V1::out) is semidet :- - map__search(OldNewRenaming, K1, V1) + map.search(OldNewRenaming, K1, V1) ), - list__map(Search, OldArgs, NewArgs), + list.map(Search, OldArgs, NewArgs), NewGoal = _ - NewGoalInfo, goal_info_get_nonlocals(NewGoalInfo, NewNonLocals), - set__delete_list(NewNonLocals, NewArgs, UnmatchedNonLocals), - set__empty(UnmatchedNonLocals), + set.delete_list(NewNonLocals, NewArgs, UnmatchedNonLocals), + set.empty(UnmatchedNonLocals), % Check that argument types of NewGoal are subsumed by those of OldGoal. collect_matching_arg_types(OldArgs, OldArgTypes, OldNewRenaming, [], MatchingArgTypes), - map__apply_to_list(NewArgs, NewVarTypes, NewArgTypes), + map.apply_to_list(NewArgs, NewVarTypes, NewArgTypes), type_list_subsumes(MatchingArgTypes, NewArgTypes, TypeSubn). :- pred collect_matching_arg_types(prog_vars::in, list(mer_type)::in, @@ -978,14 +975,14 @@ goals_match(_ModuleInfo, OldGoal, OldArgs, OldArgTypes, is det. collect_matching_arg_types([], [], _, !MatchingTypes) :- - list__reverse(!MatchingTypes). + list.reverse(!MatchingTypes). collect_matching_arg_types([_ | _], [], _, !MatchingTypes) :- unexpected(this_file, "collect_matching_arg_types"). collect_matching_arg_types([], [_ | _], _, !MatchingTypes) :- unexpected(this_file, "collect_matching_arg_types"). collect_matching_arg_types([Arg | Args], [Type | Types], Renaming, !MatchingTypes) :- - ( map__contains(Renaming, Arg) -> + ( map.contains(Renaming, Arg) -> !:MatchingTypes = [Type | !.MatchingTypes] ; true @@ -1041,24 +1038,24 @@ goals_match_2([OldGoal | OldGoals], [NewGoal | NewGoals], OldGoal = generic_call(OldGenericCall, OldArgs1, _, Det) - _, NewGoal = generic_call(NewGenericCall, NewArgs1, _, Det) - _, match_generic_call(OldGenericCall, NewGenericCall), - goal_util__generic_call_vars(OldGenericCall, OldArgs0), - goal_util__generic_call_vars(NewGenericCall, NewArgs0), - list__append(OldArgs0, OldArgs1, OldArgs), - list__append(NewArgs0, NewArgs1, NewArgs) + goal_util.generic_call_vars(OldGenericCall, OldArgs0), + goal_util.generic_call_vars(NewGenericCall, NewArgs0), + list.append(OldArgs0, OldArgs1, OldArgs), + list.append(NewArgs0, NewArgs1, NewArgs) ) -> - assoc_list__from_corresponding_lists(OldArgs, NewArgs, ONArgsList), + assoc_list.from_corresponding_lists(OldArgs, NewArgs, ONArgsList), MapInsert = (pred(KeyValue::in, Map0::in, Map::out) is semidet :- KeyValue = Key - Value, - ( map__search(Map0, Key, Value0) -> + ( map.search(Map0, Key, Value0) -> Value = Value0, Map = Map0 ; - map__det_insert(Map0, Key, Value, Map) + map.det_insert(Map0, Key, Value, Map) ) ), - list__foldl(MapInsert, ONArgsList, !ONRenaming) + list.foldl(MapInsert, ONArgsList, !ONRenaming) ; ( OldGoal = not(OldSubGoal) - _, @@ -1107,7 +1104,7 @@ can_reorder_goals(ModuleInfo, FullyStrict, EarlierGoal, LaterGoal) :- \+ goal_info_is_impure(EarlierGoalInfo), \+ goal_info_is_impure(LaterGoalInfo), - goal_util__reordering_maintains_termination(ModuleInfo, FullyStrict, + goal_util.reordering_maintains_termination(ModuleInfo, FullyStrict, EarlierGoal, LaterGoal), % Don't reorder the goals if the later goal depends on the outputs @@ -1126,8 +1123,8 @@ goal_depends_on_goal(_ - GoalInfo1, _ - GoalInfo2) :- goal_info_get_instmap_delta(GoalInfo1, InstmapDelta1), instmap_delta_changed_vars(InstmapDelta1, ChangedVars1), goal_info_get_nonlocals(GoalInfo2, NonLocals2), - set__intersect(ChangedVars1, NonLocals2, Intersection), - \+ set__empty(Intersection). + set.intersect(ChangedVars1, NonLocals2, Intersection), + \+ set.empty(Intersection). %-----------------------------------------------------------------------------% diff --git a/compiler/peephole.m b/compiler/peephole.m index ef1ec8c3b..4dde6954e 100644 --- a/compiler/peephole.m +++ b/compiler/peephole.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-1998,2002-2005 The University of Melbourne. +% Copyright (C) 1994-1998,2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -12,7 +12,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__peephole. +:- module ll_backend.peephole. :- interface. @@ -24,7 +24,7 @@ % Peephole optimize a list of instructions. % -:- pred peephole__optimize(gc_method::in, list(instruction)::in, +:- pred peephole.optimize(gc_method::in, list(instruction)::in, list(instruction)::out, bool::out) is det. :- pred combine_decr_sp(list(instruction)::in, list(instruction)::out) is det. @@ -56,18 +56,18 @@ % when we find a sequence we can't optimize, we back up and try % to optimize the sequence starting with the previous instruction. % -peephole__optimize(GC_Method, Instrs0, Instrs, Mod) :- - peephole__invalid_opts(GC_Method, InvalidPatterns), - peephole__optimize_2(InvalidPatterns, Instrs0, Instrs, Mod). +peephole.optimize(GC_Method, Instrs0, Instrs, Mod) :- + peephole.invalid_opts(GC_Method, InvalidPatterns), + peephole.optimize_2(InvalidPatterns, Instrs0, Instrs, Mod). -:- pred peephole__optimize_2(list(pattern)::in, list(instruction)::in, +:- pred peephole.optimize_2(list(pattern)::in, list(instruction)::in, list(instruction)::out, bool::out) is det. -peephole__optimize_2(_, [], [], no). -peephole__optimize_2(InvalidPatterns, [Instr0 - Comment | Instrs0], +peephole.optimize_2(_, [], [], no). +peephole.optimize_2(InvalidPatterns, [Instr0 - Comment | Instrs0], Instrs, Mod) :- - peephole__optimize_2(InvalidPatterns, Instrs0, Instrs1, Mod0), - peephole__opt_instr(Instr0, Comment, InvalidPatterns, Instrs1, Instrs, + peephole.optimize_2(InvalidPatterns, Instrs0, Instrs1, Mod0), + peephole.opt_instr(Instr0, Comment, InvalidPatterns, Instrs1, Instrs, Mod1), ( Mod0 = no, Mod1 = no -> Mod = no @@ -78,17 +78,17 @@ peephole__optimize_2(InvalidPatterns, [Instr0 - Comment | Instrs0], % Try to optimize the beginning of the given instruction sequence. % If successful, try it again. % -:- pred peephole__opt_instr(instr::in, string::in, list(pattern)::in, +:- pred peephole.opt_instr(instr::in, string::in, list(pattern)::in, list(instruction)::in, list(instruction)::out, bool::out) is det. -peephole__opt_instr(Instr0, Comment0, InvalidPatterns, Instrs0, Instrs, Mod) :- +peephole.opt_instr(Instr0, Comment0, InvalidPatterns, Instrs0, Instrs, Mod) :- ( - opt_util__skip_comments(Instrs0, Instrs1), - peephole__match(Instr0, Comment0, InvalidPatterns, Instrs1, Instrs2) + opt_util.skip_comments(Instrs0, Instrs1), + peephole.match(Instr0, Comment0, InvalidPatterns, Instrs1, Instrs2) -> ( Instrs2 = [Instr2 - Comment2 | Instrs3], - peephole__opt_instr(Instr2, Comment2, InvalidPatterns, + peephole.opt_instr(Instr2, Comment2, InvalidPatterns, Instrs3, Instrs, _) ; Instrs2 = [], @@ -105,26 +105,26 @@ peephole__opt_instr(Instr0, Comment0, InvalidPatterns, Instrs0, Instrs, Mod) :- % Build a map that associates each label in a computed goto with the % values of the switch rval that cause a jump to it. % -:- pred peephole__build_jump_label_map(list(label)::in, int::in, +:- pred peephole.build_jump_label_map(list(label)::in, int::in, map(label, list(int))::in, map(label, list(int))::out) is det. -peephole__build_jump_label_map([], _, !LabelMap). -peephole__build_jump_label_map([Label | Labels], Val, !LabelMap) :- - ( map__search(!.LabelMap, Label, Vals0) -> - map__det_update(!.LabelMap, Label, [Val | Vals0], !:LabelMap) +peephole.build_jump_label_map([], _, !LabelMap). +peephole.build_jump_label_map([Label | Labels], Val, !LabelMap) :- + ( map.search(!.LabelMap, Label, Vals0) -> + map.det_update(!.LabelMap, Label, [Val | Vals0], !:LabelMap) ; - map__det_insert(!.LabelMap, Label, [Val], !:LabelMap) + map.det_insert(!.LabelMap, Label, [Val], !:LabelMap) ), - peephole__build_jump_label_map(Labels, Val + 1, !LabelMap). + peephole.build_jump_label_map(Labels, Val + 1, !LabelMap). % If one of the two labels has only one associated value, return it and % the associated value as the first two output arguments, and the % remaining label as the last output argument. % -:- pred peephole__pick_one_val_label(pair(label, list(int))::in, +:- pred peephole.pick_one_val_label(pair(label, list(int))::in, pair(label, list(int))::in, label::out, int::out, label::out) is semidet. -peephole__pick_one_val_label(LabelVals1, LabelVals2, OneValLabel, Val, +peephole.pick_one_val_label(LabelVals1, LabelVals2, OneValLabel, Val, OtherLabel) :- LabelVals1 = Label1 - Vals1, LabelVals2 = Label2 - Vals2, @@ -142,7 +142,7 @@ peephole__pick_one_val_label(LabelVals1, LabelVals2, OneValLabel, Val, % Look for code patterns that can be optimized, and optimize them. % -:- pred peephole__match(instr::in, string::in, list(pattern)::in, +:- pred peephole.match(instr::in, string::in, list(pattern)::in, list(instruction)::in, list(instruction)::out) is semidet. % A `computed_goto' with all branches pointing to the same label @@ -152,10 +152,10 @@ peephole__pick_one_val_label(LabelVals1, LabelVals2, OneValLabel, Val, % can be replaced with a conditional branch followed by an unconditional % goto. % -peephole__match(computed_goto(SelectorRval, Labels), Comment, _, +peephole.match(computed_goto(SelectorRval, Labels), Comment, _, Instrs0, Instrs) :- - peephole__build_jump_label_map(Labels, 0, map__init, LabelMap), - map__to_assoc_list(LabelMap, LabelValsList), + peephole.build_jump_label_map(Labels, 0, map.init, LabelMap), + map.to_assoc_list(LabelMap, LabelValsList), ( LabelValsList = [Label - _] -> @@ -163,7 +163,7 @@ peephole__match(computed_goto(SelectorRval, Labels), Comment, _, Instrs = [GotoInstr | Instrs0] ; LabelValsList = [LabelVals1, LabelVals2], - peephole__pick_one_val_label(LabelVals1, LabelVals2, OneValLabel, + peephole.pick_one_val_label(LabelVals1, LabelVals2, OneValLabel, Val, OtherLabel) -> CondRval = binop(eq, SelectorRval, const(int_const(Val))), @@ -184,9 +184,9 @@ peephole__match(computed_goto(SelectorRval, Labels), Comment, _, % A conditional branch to a label followed by that label % can be eliminated. % -peephole__match(if_val(Rval, CodeAddr), Comment, _, Instrs0, Instrs) :- +peephole.match(if_val(Rval, CodeAddr), Comment, _, Instrs0, Instrs) :- ( - opt_util__is_const_condition(Rval, Taken) + opt_util.is_const_condition(Rval, Taken) -> ( Taken = yes, @@ -196,14 +196,14 @@ peephole__match(if_val(Rval, CodeAddr), Comment, _, Instrs0, Instrs) :- Instrs = Instrs0 ) ; - opt_util__skip_comments(Instrs0, Instrs1), + opt_util.skip_comments(Instrs0, Instrs1), Instrs1 = [Instr1 | _], Instr1 = goto(CodeAddr) - _ -> Instrs = Instrs0 ; CodeAddr = label(Label), - opt_util__is_this_label_next(Label, Instrs0, _) + opt_util.is_this_label_next(Label, Instrs0, _) -> Instrs = Instrs0 ; @@ -241,7 +241,7 @@ peephole__match(if_val(Rval, CodeAddr), Comment, _, Instrs0, Instrs) :- % => % succeed proceed % -peephole__match(mkframe(NondetFrameInfo, yes(Redoip1)), Comment, _, +peephole.match(mkframe(NondetFrameInfo, yes(Redoip1)), Comment, _, Instrs0, Instrs) :- ( % A mkframe sets curfr to point to the new frame @@ -251,14 +251,14 @@ peephole__match(mkframe(NondetFrameInfo, yes(Redoip1)), Comment, _, ; AllowedBases = [maxfr] ), - opt_util__next_assign_to_redoip(Instrs0, AllowedBases, [], Redoip2, + opt_util.next_assign_to_redoip(Instrs0, AllowedBases, [], Redoip2, Skipped, Rest), - opt_util__touches_nondet_ctrl(Skipped, no) + opt_util.touches_nondet_ctrl(Skipped, no) -> Instrs1 = Skipped ++ Rest, Instrs = [mkframe(NondetFrameInfo, yes(Redoip2)) - Comment | Instrs1] ; - opt_util__skip_comments_livevals(Instrs0, Instrs1), + opt_util.skip_comments_livevals(Instrs0, Instrs1), Instrs1 = [Instr1 | Instrs2], Instr1 = if_val(Test, Target) - Comment2, ( @@ -315,8 +315,8 @@ peephole__match(mkframe(NondetFrameInfo, yes(Redoip1)), Comment, _, % store_ticket(Lval) => store_ticket(Lval) % reset_ticket(Lval, _R) % -peephole__match(store_ticket(Lval), Comment, _, Instrs0, Instrs) :- - opt_util__skip_comments(Instrs0, Instrs1), +peephole.match(store_ticket(Lval), Comment, _, Instrs0, Instrs) :- + opt_util.skip_comments(Instrs0, Instrs1), Instrs1 = [reset_ticket(lval(Lval), _Reason) - _Comment2 | Instrs2], Instrs = [store_ticket(Lval) - Comment | Instrs2]. @@ -335,12 +335,12 @@ peephole__match(store_ticket(Lval), Comment, _, Instrs0, Instrs) :- % straight-line instructions, then we can discard the nondet stack % frame early. % -peephole__match(assign(redoip(lval(Base)), Redoip), Comment, _, +peephole.match(assign(redoip(lval(Base)), Redoip), Comment, _, Instrs0, Instrs) :- ( - opt_util__next_assign_to_redoip(Instrs0, [Base], [], Redoip2, + opt_util.next_assign_to_redoip(Instrs0, [Base], [], Redoip2, Skipped, Rest), - opt_util__touches_nondet_ctrl(Skipped, no) + opt_util.touches_nondet_ctrl(Skipped, no) -> Instrs1 = Skipped ++ Rest, Instrs = [assign(redoip(lval(Base)), @@ -348,11 +348,11 @@ peephole__match(assign(redoip(lval(Base)), Redoip), Comment, _, ; Base = curfr, Redoip = const(code_addr_const(do_fail)), - opt_util__straight_alternative(Instrs0, Between, After), - opt_util__touches_nondet_ctrl(Between, no), - string__sub_string_search(Comment, "curfr==maxfr", _) + opt_util.straight_alternative(Instrs0, Between, After), + opt_util.touches_nondet_ctrl(Between, no), + string.sub_string_search(Comment, "curfr==maxfr", _) -> - list__condense([Between, + list.condense([Between, [goto(do_succeed(yes)) - "early discard"], After], Instrs) ; fail @@ -372,9 +372,9 @@ peephole__match(assign(redoip(lval(Base)), Redoip), Comment, _, % succip = detstackvar(N) % decr_sp N % -peephole__match(incr_sp(N, _), _, InvalidPatterns, Instrs0, Instrs) :- - \+ list__member(incr_sp, InvalidPatterns), - ( opt_util__no_stackvars_til_decr_sp(Instrs0, N, Between, Remain) -> +peephole.match(incr_sp(N, _), _, InvalidPatterns, Instrs0, Instrs) :- + \+ list.member(incr_sp, InvalidPatterns), + ( opt_util.no_stackvars_til_decr_sp(Instrs0, N, Between, Remain) -> Instrs = Between ++ Remain ; fail @@ -384,9 +384,9 @@ peephole__match(incr_sp(N, _), _, InvalidPatterns, Instrs0, Instrs) :- % Given a GC method, return the list of invalid peephole optimizations. % -:- pred peephole__invalid_opts(gc_method::in, list(pattern)::out) is det. +:- pred peephole.invalid_opts(gc_method::in, list(pattern)::out) is det. -peephole__invalid_opts(GC_Method, InvalidPatterns) :- +peephole.invalid_opts(GC_Method, InvalidPatterns) :- ( GC_Method = accurate -> InvalidPatterns = [incr_sp] ; @@ -400,10 +400,10 @@ combine_decr_sp([Instr0 | Instrs0], Instrs) :- combine_decr_sp(Instrs0, Instrs1), ( Instr0 = assign(succip, lval(stackvar(N))) - _, - opt_util__skip_comments_livevals(Instrs1, Instrs2), + opt_util.skip_comments_livevals(Instrs1, Instrs2), Instrs2 = [Instr2 | Instrs3], Instr2 = decr_sp(N) - _, - opt_util__skip_comments_livevals(Instrs3, Instrs4), + opt_util.skip_comments_livevals(Instrs3, Instrs4), Instrs4 = [Instr4 | Instrs5], Instr4 = goto(succip) - Comment -> diff --git a/compiler/polymorphism.m b/compiler/polymorphism.m index d573e6ca0..ef2e90252 100644 --- a/compiler/polymorphism.m +++ b/compiler/polymorphism.m @@ -171,7 +171,7 @@ %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- module check_hlds__polymorphism. +:- module check_hlds.polymorphism. :- interface. :- import_module hlds.hlds_goal. @@ -230,13 +230,13 @@ % variables to the appropriate type_info structures for the types. % Update the varset and vartypes accordingly. % -:- pred make_type_info_vars(list(mer_type)::in, term__context::in, +:- pred make_type_info_vars(list(mer_type)::in, term.context::in, list(prog_var)::out, list(hlds_goal)::out, poly_info::in, poly_info::out) is det. % Likewise, but for a single type. % -:- pred make_type_info_var(mer_type::in, term__context::in, prog_var::out, +:- pred make_type_info_var(mer_type::in, term.context::in, prog_var::out, list(hlds_goal)::out, poly_info::in, poly_info::out) is det. % gen_extract_type_info(TypeVar, Kind, TypeClassInfoVar, @@ -253,8 +253,7 @@ % :- pred gen_extract_type_info(tvar::in, kind::in, prog_var::in, int::in, module_info::in, list(hlds_goal)::out, prog_var::out, - prog_varset::in, prog_varset::out, - vartypes::in, vartypes::out, + prog_varset::in, prog_varset::out, vartypes::in, vartypes::out, rtti_varmaps::in, rtti_varmaps::out) is det. :- type poly_info. @@ -365,8 +364,7 @@ :- pred new_type_info_var_raw(mer_type::in, type_info_kind::in, prog_var::out, prog_varset::in, prog_varset::out, - vartypes::in, vartypes::out, - rtti_varmaps::in, rtti_varmaps::out) is det. + vartypes::in, vartypes::out, rtti_varmaps::in, rtti_varmaps::out) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -422,11 +420,11 @@ process_module(!ModuleInfo, !IO) :- module_info_preds(!.ModuleInfo, Preds0), - map__keys(Preds0, PredIds0), - list__foldl2(maybe_process_pred, PredIds0, !ModuleInfo, !IO), + map.keys(Preds0, PredIds0), + list.foldl2(maybe_process_pred, PredIds0, !ModuleInfo, !IO), module_info_preds(!.ModuleInfo, Preds1), - map__keys(Preds1, PredIds1), - list__foldl(fixup_pred, PredIds1, !ModuleInfo), + map.keys(Preds1, PredIds1), + list.foldl(fixup_pred, PredIds1, !ModuleInfo), expand_class_method_bodies(!ModuleInfo). :- pred maybe_process_pred(pred_id::in, @@ -460,24 +458,24 @@ fixup_pred(PredId, !ModuleInfo) :- % equivalence types. % module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_clauses_info(PredInfo0, ClausesInfo0), clauses_info_vartypes(ClausesInfo0, VarTypes0), clauses_info_headvars(ClausesInfo0, HeadVars), pred_info_arg_types(PredInfo0, TypeVarSet, ExistQVars, ArgTypes0), - list__length(ArgTypes0, NumOldArgs), - list__length(HeadVars, NumNewArgs), + list.length(ArgTypes0, NumOldArgs), + list.length(HeadVars, NumNewArgs), NumExtraArgs = NumNewArgs - NumOldArgs, - ( list__split_list(NumExtraArgs, HeadVars, ExtraHeadVars0, OldHeadVars0) -> + ( list.split_list(NumExtraArgs, HeadVars, ExtraHeadVars0, OldHeadVars0) -> ExtraHeadVars = ExtraHeadVars0, OldHeadVars = OldHeadVars0 ; - unexpected(this_file, "fixup_pred: list__split_list failed") + unexpected(this_file, "fixup_pred: list.split_list failed") ), - map__apply_to_list(ExtraHeadVars, VarTypes0, ExtraArgTypes), - list__append(ExtraArgTypes, ArgTypes0, ArgTypes), + map.apply_to_list(ExtraHeadVars, VarTypes0, ExtraArgTypes), + list.append(ExtraArgTypes, ArgTypes0, ArgTypes), pred_info_set_arg_types(TypeVarSet, ExistQVars, ArgTypes, PredInfo0, PredInfo1), @@ -491,9 +489,9 @@ fixup_pred(PredId, !ModuleInfo) :- ExistQVars = [_ | _], % This can fail for unification procedures % of equivalence types. - map__apply_to_list(OldHeadVars, VarTypes0, OldHeadVarTypes), + map.apply_to_list(OldHeadVars, VarTypes0, OldHeadVarTypes), type_list_subsumes(ArgTypes0, OldHeadVarTypes, Subn), - \+ map__is_empty(Subn) + \+ map.is_empty(Subn) -> pred_info_set_existq_tvar_binding(Subn, PredInfo1, PredInfo2), introduce_exists_casts_pred(!.ModuleInfo, Subn, ExtraHeadVars, @@ -502,7 +500,7 @@ fixup_pred(PredId, !ModuleInfo) :- PredInfo = PredInfo1 ), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo). :- pred introduce_exists_casts_pred(module_info::in, tsubst::in, @@ -521,17 +519,17 @@ introduce_exists_casts_pred(ModuleInfo, Subn, ExtraHeadVars, !PredInfo) :- % pred_info_clauses_info(!.PredInfo, ClausesInfo0), clauses_info_vartypes(ClausesInfo0, VarTypes0), - list__foldl( + list.foldl( (pred(HeadVar::in, Types0::in, Types::out) is det :- - map__lookup(Types0, HeadVar, HeadVarType0), + map.lookup(Types0, HeadVar, HeadVarType0), apply_rec_subst_to_type(Subn, HeadVarType0, HeadVarType), - map__set(Types0, HeadVar, HeadVarType, Types) + map.set(Types0, HeadVar, HeadVarType, Types) ), ExtraHeadVars, VarTypes0, VarTypes), clauses_info_set_vartypes(VarTypes, ClausesInfo0, ClausesInfo), pred_info_set_clauses_info(ClausesInfo, !PredInfo), pred_info_procedures(!.PredInfo, Procs0), - map__map_values( + map.map_values( (pred(_::in, !.ProcInfo::in, !:ProcInfo::out) is det :- % Add the extra goals to each procedure. introduce_exists_casts_proc(ModuleInfo, !.PredInfo, !ProcInfo) @@ -576,7 +574,7 @@ process_pred(PredId, !ModuleInfo) :- ProcIds = pred_info_procids(PredInfo2), pred_info_procedures(PredInfo2, Procs0), - list__foldl(process_proc_in_table(PredInfo2, ClausesInfo, + list.foldl(process_proc_in_table(PredInfo2, ClausesInfo, ExtraArgModes), ProcIds, Procs0, Procs), pred_info_set_procedures(Procs, PredInfo2, PredInfo), @@ -596,7 +594,7 @@ process_clause_info(PredInfo0, ModuleInfo0, !ClausesInfo, !:Info, ExtraTypeInfoHeadVars, ExistTypeClassInfoHeadVars, !Info), clauses_info_clauses_only(!.ClausesInfo, Clauses0), - list__map_foldl( + list.map_foldl( process_clause(PredInfo0, HeadVars0, HeadVars, UnconstrainedTVars, ExtraTypeInfoHeadVars, ExistTypeClassInfoHeadVars), @@ -608,7 +606,7 @@ process_clause_info(PredInfo0, ModuleInfo0, !ClausesInfo, !:Info, poly_info_get_rtti_varmaps(!.Info, RttiVarMaps), clauses_info_explicit_vartypes(!.ClausesInfo, ExplicitVarTypes), set_clause_list(Clauses, ClausesRep), - map__init(TVarNameMap), % This is only used while adding the clauses. + map.init(TVarNameMap), % This is only used while adding the clauses. !:ClausesInfo = clauses_info(VarSet, ExplicitVarTypes, TVarNameMap, VarTypes, HeadVars, ClausesRep, RttiVarMaps, !.ClausesInfo ^ have_foreign_clauses). @@ -634,8 +632,7 @@ process_clause(PredInfo0, OldHeadVars, NewHeadVars, ExistTypeClassInfoHeadVars, Goal1, Goal2, !Info), pred_info_get_exist_quant_tvars(PredInfo0, ExistQVars), - fixup_quantification(NewHeadVars, ExistQVars, - Goal2, Goal, !Info), + fixup_quantification(NewHeadVars, ExistQVars, Goal2, Goal, !Info), !:Clause = !.Clause ^ clause_body := Goal ). @@ -644,10 +641,10 @@ process_clause(PredInfo0, OldHeadVars, NewHeadVars, process_proc_in_table(PredInfo, ClausesInfo, ExtraArgModes, ProcId, !ProcTable) :- - map__lookup(!.ProcTable, ProcId, ProcInfo0), + map.lookup(!.ProcTable, ProcId, ProcInfo0), process_proc(PredInfo, ClausesInfo, ExtraArgModes, ProcId, ProcInfo0, ProcInfo), - map__det_update(!.ProcTable, ProcId, ProcInfo, !:ProcTable). + map.det_update(!.ProcTable, ProcId, ProcInfo, !:ProcTable). :- pred process_proc(pred_info::in, clauses_info::in, list(mer_mode)::in, proc_id::in, proc_info::in, proc_info::out) is det. @@ -660,7 +657,7 @@ process_proc(PredInfo, ClausesInfo, ExtraArgModes, ProcId, pred_info_is_imported(PredInfo) ; pred_info_is_pseudo_imported(PredInfo), - hlds_pred__in_in_unification_proc_id(ProcId) + hlds_pred.in_in_unification_proc_id(ProcId) ) -> % We need to set these fields in the proc_info here, because some parts @@ -681,7 +678,7 @@ process_proc(PredInfo, ClausesInfo, ExtraArgModes, ProcId, % Add the ExtraArgModes to the proc_info argmodes. proc_info_argmodes(!.ProcInfo, ArgModes1), - list__append(ExtraArgModes, ArgModes1, ArgModes), + list.append(ExtraArgModes, ArgModes1, ArgModes), proc_info_set_argmodes(ArgModes, !ProcInfo). % XXX document me @@ -737,7 +734,7 @@ setup_headvars_instance_method(PredInfo, InstanceMethodConstraints = instance_method_constraints(_, InstanceTypes, InstanceConstraints, ClassContext), - prog_type__vars_list(InstanceTypes, InstanceTVars), + prog_type.vars_list(InstanceTypes, InstanceTVars), get_unconstrained_tvars(InstanceTVars, InstanceConstraints, UnconstrainedInstanceTVars), pred_info_arg_types(PredInfo, ArgTypeVarSet, _, _), @@ -746,13 +743,13 @@ setup_headvars_instance_method(PredInfo, make_typeclass_info_head_vars(do_record_type_info_locns, InstanceConstraints, InstanceHeadTypeClassInfoVars, !Info), poly_info_get_rtti_varmaps(!.Info, RttiVarMaps0), - list__foldl(rtti_reuse_typeclass_info_var, + list.foldl(rtti_reuse_typeclass_info_var, InstanceHeadTypeClassInfoVars, RttiVarMaps0, RttiVarMaps), poly_info_set_rtti_varmaps(RttiVarMaps, !Info), - list__append(UnconstrainedInstanceTypeInfoVars, + list.append(UnconstrainedInstanceTypeInfoVars, InstanceHeadTypeClassInfoVars, ExtraHeadVars0), in_mode(InMode), - list__duplicate(list__length(ExtraHeadVars0), InMode, ExtraArgModes0), + list.duplicate(list.length(ExtraHeadVars0), InMode, ExtraArgModes0), setup_headvars_2(PredInfo, ClassContext, ExtraHeadVars0, ExtraArgModes0, InstanceTVars, UnconstrainedInstanceTVars, UnconstrainedInstanceTypeInfoVars, @@ -793,9 +790,9 @@ setup_headvars_2(PredInfo, ClassContext, ExtraHeadVars0, % is no distinction between the internal views and the external view, so % we just use the constraints from the class context. ClassContext = constraints(UnivConstraints, ExistConstraints), - prog_type__constraint_list_get_tvars(UnivConstraints, + prog_type.constraint_list_get_tvars(UnivConstraints, UnivConstrainedTVars), - prog_type__constraint_list_get_tvars(ExistConstraints, + prog_type.constraint_list_get_tvars(ExistConstraints, ExistConstrainedTVars), poly_info_get_constraint_map(!.Info, ConstraintMap), get_improved_exists_head_constraints(ConstraintMap, ExistConstraints, @@ -818,20 +815,20 @@ setup_headvars_2(PredInfo, ClassContext, ExtraHeadVars0, make_typeclass_info_head_vars(do_record_type_info_locns, UnivConstraints, UnivHeadTypeClassInfoVars, !Info), - list__append(UnivHeadTypeClassInfoVars, ExistHeadTypeClassInfoVars, + list.append(UnivHeadTypeClassInfoVars, ExistHeadTypeClassInfoVars, ExtraHeadTypeClassInfoVars), - prog_type__vars_list(ArgTypes, HeadTypeVars), - list__delete_elems(HeadTypeVars, UnivConstrainedTVars, + prog_type.vars_list(ArgTypes, HeadTypeVars), + list.delete_elems(HeadTypeVars, UnivConstrainedTVars, UnconstrainedTVars0), - list__delete_elems(UnconstrainedTVars0, ExistConstrainedTVars, + list.delete_elems(UnconstrainedTVars0, ExistConstrainedTVars, UnconstrainedTVars1), % Typeinfos for the instance tvars have already been introduced by % setup_headvars_instance_method. - list__delete_elems(UnconstrainedTVars1, InstanceTVars, + list.delete_elems(UnconstrainedTVars1, InstanceTVars, UnconstrainedTVars2), - list__remove_dups(UnconstrainedTVars2, UnconstrainedTVars), + list.remove_dups(UnconstrainedTVars2, UnconstrainedTVars), ( ExistQVars = [], @@ -841,9 +838,9 @@ setup_headvars_2(PredInfo, ClassContext, ExtraHeadVars0, ExistHeadTypeInfoVars = [] ; ExistQVars = [_ | _], - list__delete_elems(UnconstrainedTVars, ExistQVars, + list.delete_elems(UnconstrainedTVars, ExistQVars, UnconstrainedUnivTVars), - list__delete_elems(UnconstrainedTVars, UnconstrainedUnivTVars, + list.delete_elems(UnconstrainedTVars, UnconstrainedUnivTVars, UnconstrainedExistTVars), make_head_vars(UnconstrainedExistTVars, ArgTypeVarSet, ExistHeadTypeInfoVars, !Info) @@ -855,7 +852,7 @@ setup_headvars_2(PredInfo, ClassContext, ExtraHeadVars0, AllExtraHeadTypeInfoVars = UnconstrainedInstanceTypeInfoVars ++ ExtraHeadTypeInfoVars, - list__condense([UnconstrainedInstanceTVars, UnconstrainedUnivTVars, + list.condense([UnconstrainedInstanceTVars, UnconstrainedUnivTVars, UnconstrainedExistTVars], AllUnconstrainedTVars), HeadVars = ExtraHeadVars0 ++ ExtraHeadTypeInfoVars @@ -866,15 +863,15 @@ setup_headvars_2(PredInfo, ClassContext, ExtraHeadVars0, in_mode(In), out_mode(Out), - list__length(UnconstrainedUnivTVars, NumUnconstrainedUnivTVars), - list__length(UnconstrainedExistTVars, NumUnconstrainedExistTVars), - list__length(UnivHeadTypeClassInfoVars, NumUnivClassInfoVars), - list__length(ExistHeadTypeClassInfoVars, NumExistClassInfoVars), - list__duplicate(NumUnconstrainedUnivTVars, In, UnivTypeInfoModes), - list__duplicate(NumUnconstrainedExistTVars, Out, ExistTypeInfoModes), - list__duplicate(NumUnivClassInfoVars, In, UnivTypeClassInfoModes), - list__duplicate(NumExistClassInfoVars, Out, ExistTypeClassInfoModes), - list__condense([ExtraArgModes0, UnivTypeInfoModes, ExistTypeInfoModes, + list.length(UnconstrainedUnivTVars, NumUnconstrainedUnivTVars), + list.length(UnconstrainedExistTVars, NumUnconstrainedExistTVars), + list.length(UnivHeadTypeClassInfoVars, NumUnivClassInfoVars), + list.length(ExistHeadTypeClassInfoVars, NumExistClassInfoVars), + list.duplicate(NumUnconstrainedUnivTVars, In, UnivTypeInfoModes), + list.duplicate(NumUnconstrainedExistTVars, Out, ExistTypeInfoModes), + list.duplicate(NumUnivClassInfoVars, In, UnivTypeClassInfoModes), + list.duplicate(NumExistClassInfoVars, Out, ExistTypeClassInfoModes), + list.condense([ExtraArgModes0, UnivTypeInfoModes, ExistTypeInfoModes, UnivTypeClassInfoModes, ExistTypeClassInfoModes], ExtraArgModes), % Add the locations of the typeinfos for unconstrained, universally @@ -887,21 +884,21 @@ setup_headvars_2(PredInfo, ClassContext, ExtraHeadVars0, ToLocn = (pred(TheVar::in, TheLocn::out) is det :- TheLocn = type_info(TheVar)), - list__map(ToLocn, UnivHeadTypeInfoVars, UnivTypeLocns), - list__foldl_corresponding(rtti_det_insert_type_info_locn, + list.map(ToLocn, UnivHeadTypeInfoVars, UnivTypeLocns), + list.foldl_corresponding(rtti_det_insert_type_info_locn, UnconstrainedUnivTVars, UnivTypeLocns, !RttiVarMaps), - list__map(ToLocn, ExistHeadTypeInfoVars, ExistTypeLocns), - list__foldl_corresponding(rtti_det_insert_type_info_locn, + list.map(ToLocn, ExistHeadTypeInfoVars, ExistTypeLocns), + list.foldl_corresponding(rtti_det_insert_type_info_locn, UnconstrainedExistTVars, ExistTypeLocns, !RttiVarMaps), - list__map(ToLocn, UnconstrainedInstanceTypeInfoVars, + list.map(ToLocn, UnconstrainedInstanceTypeInfoVars, UnconstrainedInstanceTypeLocns), - list__foldl_corresponding(rtti_det_insert_type_info_locn, + list.foldl_corresponding(rtti_det_insert_type_info_locn, UnconstrainedInstanceTVars, UnconstrainedInstanceTypeLocns, !RttiVarMaps), - list__foldl(rtti_reuse_typeclass_info_var, + list.foldl(rtti_reuse_typeclass_info_var, UnivHeadTypeClassInfoVars, !RttiVarMaps), poly_info_set_rtti_varmaps(!.RttiVarMaps, !Info) @@ -939,7 +936,7 @@ produce_existq_tvars(PredInfo, HeadVars0, UnconstrainedTVars, ExistQVarsForCall, Context, ExistTypeClassVars, ExtraTypeClassGoals, !Info), poly_info_get_rtti_varmaps(!.Info, RttiVarMaps0), - list__foldl(rtti_reuse_typeclass_info_var, ExistTypeClassVars, + list.foldl(rtti_reuse_typeclass_info_var, ExistTypeClassVars, RttiVarMaps0, RttiVarMaps), poly_info_set_rtti_varmaps(RttiVarMaps, !Info), assign_var_list(ExistTypeClassInfoHeadVars, @@ -948,18 +945,18 @@ produce_existq_tvars(PredInfo, HeadVars0, UnconstrainedTVars, % Figure out the bindings for any unconstrained existentially quantified % type variables in the head. - ( map__is_empty(VarTypes0) -> + ( map.is_empty(VarTypes0) -> % This can happen for compiler generated procedures. - map__init(PredToActualTypeSubst) + map.init(PredToActualTypeSubst) ; - map__apply_to_list(HeadVars0, VarTypes0, ActualArgTypes), + map.apply_to_list(HeadVars0, VarTypes0, ActualArgTypes), type_list_subsumes(ArgTypes, ActualArgTypes, ArgTypeSubst) -> PredToActualTypeSubst = ArgTypeSubst ; % This can happen for unification procedures of equivalence types % error("polymorphism.m: type_list_subsumes failed") - map__init(PredToActualTypeSubst) + map.init(PredToActualTypeSubst) ), % Apply the type bindings to the unconstrained type variables to give @@ -972,7 +969,7 @@ produce_existq_tvars(PredInfo, HeadVars0, UnconstrainedTVars, TypeInfoVars, ExtraTypeInfoGoals, !Info), assign_var_list(TypeInfoHeadVars, TypeInfoVars, ExtraTypeInfoUnifyGoals), - list__condense([[Goal0], ExtraTypeClassGoals, ExtraTypeClassUnifyGoals, + list.condense([[Goal0], ExtraTypeClassGoals, ExtraTypeClassUnifyGoals, ExtraTypeInfoGoals, ExtraTypeInfoUnifyGoals], GoalList), conj_list_to_goal(GoalList, GoalInfo, Goal). @@ -988,14 +985,13 @@ assign_var_list([Var1 | Vars1], [Var2 | Vars2], [Goal | Goals]) :- assign_var(Var1, Var2, Goal), assign_var_list(Vars1, Vars2, Goals). -:- pred assign_var(prog_var::in, prog_var::in, hlds_goal::out) - is det. +:- pred assign_var(prog_var::in, prog_var::in, hlds_goal::out) is det. assign_var(Var1, Var2, Goal) :- ( Var1 = Var2 -> Goal = true_goal ; - term__context_init(Context), + term.context_init(Context), create_atomic_complicated_unification(Var1, var(Var2), Context, explicit, [], Goal) ). @@ -1005,7 +1001,7 @@ assign_var(Var1, Var2, Goal) :- get_improved_exists_head_constraints(ConstraintMap, ExistConstraints, ActualExistConstraints) :- - list__length(ExistConstraints, NumExistConstraints), + list.length(ExistConstraints, NumExistConstraints), ( search_hlds_constraint_list(ConstraintMap, unproven, [], NumExistConstraints, ActualExistConstraints0) @@ -1046,7 +1042,7 @@ process_goal_expr(Goal0, GoalInfo0, Goal, !Info) :- ArgVars = ExtraVars ++ ArgVars0, CallExpr = Goal0 ^ call_args := ArgVars, Call = CallExpr - GoalInfo, - list__append(ExtraGoals, [Call], GoalList), + list.append(ExtraGoals, [Call], GoalList), conj_list_to_goal(GoalList, GoalInfo0, Goal). process_goal_expr(Goal0, GoalInfo0, Goal, !Info) :- @@ -1115,14 +1111,14 @@ type_info_vars(ModuleInfo, [Arg | Args], InitString) = String :- ( MaybeNameMode = yes(ArgName0 - Mode), ( mode_is_output(ModuleInfo, Mode) -> - string__append("&", ArgName0, ArgName) + string.append("&", ArgName0, ArgName) ; ArgName = ArgName0 ), ( String0 = "" -> String = ArgName ; - String = string__append_list([ArgName, ", ", String0]) + String = string.append_list([ArgName, ", ", String0]) ) ; MaybeNameMode = no, @@ -1151,7 +1147,7 @@ process_unify(XVar, Y, Mode, Unification0, UnifyContext, GoalInfo0, Goal, % requantifying things. poly_info_get_var_types(!.Info, VarTypes), - map__lookup(VarTypes, XVar, Type), + map.lookup(VarTypes, XVar, Type), unification_typeinfos(Type, Unification0, Unification, GoalInfo0, GoalInfo, !Info), Goal = unify(XVar, Y, Mode, Unification, UnifyContext) - GoalInfo @@ -1170,12 +1166,12 @@ process_unify(XVar, Y, Mode, Unification0, UnifyContext, GoalInfo0, Goal, ExistQVars = [], fixup_lambda_quantification(ArgVars0, LambdaVars, ExistQVars, LambdaGoal1, LambdaGoal, NonLocalTypeInfos, !Info), - set__to_sorted_list(NonLocalTypeInfos, NonLocalTypeInfosList), - list__append(NonLocalTypeInfosList, ArgVars0, ArgVars), + set.to_sorted_list(NonLocalTypeInfos, NonLocalTypeInfosList), + list.append(NonLocalTypeInfosList, ArgVars0, ArgVars), Y1 = lambda_goal(Purity, PredOrFunc, EvalMethod, ArgVars, LambdaVars, Modes, Det, LambdaGoal), goal_info_get_nonlocals(GoalInfo0, NonLocals0), - set__union(NonLocals0, NonLocalTypeInfos, NonLocals), + set.union(NonLocals0, NonLocalTypeInfos, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo), % Complicated (in-in) argument unifications are impossible for lambda @@ -1191,8 +1187,8 @@ process_unify(XVar, Y, Mode, Unification0, UnifyContext, GoalInfo0, Goal, unification_typeinfos(Type, !Unification, !GoalInfo, !Info) :- % Compute the type_info/type_class_info variables that would be used % if this unification ends up being a complicated_unify. - prog_type__vars(Type, TypeVars), - list__map_foldl(get_type_info_locn, TypeVars, TypeInfoLocns, !Info), + prog_type.vars(Type, TypeVars), + list.map_foldl(get_type_info_locn, TypeVars, TypeInfoLocns, !Info), add_unification_typeinfos(TypeInfoLocns, !Unification, !GoalInfo). % This variant is for use by modecheck_unify.m. @@ -1201,8 +1197,8 @@ unification_typeinfos(Type, !Unification, !GoalInfo, !Info) :- unification_typeinfos(Type, RttiVarMaps, !Unification, !GoalInfo) :- % Compute the type_info/type_class_info variables that would be used % if this unification ends up being a complicated_unify. - prog_type__vars(Type, TypeVars), - list__map(rtti_lookup_type_info_locn(RttiVarMaps), TypeVars, + prog_type.vars(Type, TypeVars), + list.map(rtti_lookup_type_info_locn(RttiVarMaps), TypeVars, TypeInfoLocns), add_unification_typeinfos(TypeInfoLocns, !Unification, !GoalInfo). @@ -1211,13 +1207,13 @@ unification_typeinfos(Type, RttiVarMaps, !Unification, !GoalInfo) :- hlds_goal_info::in, hlds_goal_info::out) is det. add_unification_typeinfos(TypeInfoLocns, !Unification, !GoalInfo) :- - list__map(type_info_locn_var, TypeInfoLocns, TypeInfoVars0), - list__remove_dups(TypeInfoVars0, TypeInfoVars), + list.map(type_info_locn_var, TypeInfoLocns, TypeInfoVars0), + list.remove_dups(TypeInfoVars0, TypeInfoVars), % Insert the TypeInfoVars into the nonlocals field of the goal_info % for the unification goal. goal_info_get_nonlocals(!.GoalInfo, NonLocals0), - set__insert_list(NonLocals0, TypeInfoVars, NonLocals), + set.insert_list(NonLocals0, TypeInfoVars, NonLocals), goal_info_set_nonlocals(NonLocals, !GoalInfo), % Also save those type_info vars into a field in the complicated_unify, @@ -1241,18 +1237,18 @@ process_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, GoalInfo0, Goal, !Info) :- poly_info_get_module_info(!.Info, ModuleInfo0), poly_info_get_var_types(!.Info, VarTypes0), - map__lookup(VarTypes0, X0, TypeOfX), - list__length(ArgVars0, Arity), + map.lookup(VarTypes0, X0, TypeOfX), + list.length(ArgVars0, Arity), ( % % We replace any unifications with higher order pred constants % by lambda expressions. For example, we replace % - % X = list__append(Y) % Y::in, X::out + % X = list.append(Y) % Y::in, X::out % % with % - % X = (pred(A1::in, A2::out) is ... :- list__append(Y, A1, A2)) + % X = (pred(A1::in, A2::out) is ... :- list.append(Y, A1, A2)) % % We do this because it makes two things easier. First, mode analysis % needs to check that the lambda goal doesn't bind any nonlocal variables @@ -1303,18 +1299,18 @@ process_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, % Check whether the functor (with the "new " prefix removed) % is an existentially typed functor. - type_util__get_existq_cons_defn(ModuleInfo0, TypeOfX, ConsId, ConsDefn) + type_util.get_existq_cons_defn(ModuleInfo0, TypeOfX, ConsId, ConsDefn) -> % Add extra arguments to the unification for the % type_info and/or type_class_info variables. - map__apply_to_list(ArgVars0, VarTypes0, ActualArgTypes), + map.apply_to_list(ArgVars0, VarTypes0, ActualArgTypes), process_existq_unify_functor(ConsDefn, IsConstruction, ActualArgTypes, TypeOfX, GoalInfo0, ExtraVars, ExtraGoals, !Info), - list__append(ExtraVars, ArgVars0, ArgVars), + list.append(ExtraVars, ArgVars0, ArgVars), goal_info_get_nonlocals(GoalInfo0, NonLocals0), - set__insert_list(NonLocals0, ExtraVars, NonLocals), + set.insert_list(NonLocals0, ExtraVars, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo1), % Some of the argument unifications may be complicated unifications, @@ -1324,7 +1320,7 @@ process_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, Unify = unify(X0, functor(ConsId, IsConstruction, ArgVars), Mode0, Unification, UnifyContext) - GoalInfo, - list__append(ExtraGoals, [Unify], GoalList), + list.append(ExtraGoals, [Unify], GoalList), conj_list_to_goal(GoalList, GoalInfo0, Goal) ; % We leave construction/deconstruction unifications alone. @@ -1343,7 +1339,7 @@ convert_pred_to_lambda_goal(Purity, EvalMethod, X0, PredId, ProcId, % Create the new lambda-quantified variables. make_fresh_vars(PredArgTypes, LambdaVars, !VarSet, !VarTypes), - list__append(ArgVars0, LambdaVars, Args), + list.append(ArgVars0, LambdaVars, Args), % Build up the hlds_goal_expr for the call that will form the lambda goal. module_info_pred_proc_info(ModuleInfo0, PredId, ProcId, @@ -1354,7 +1350,7 @@ convert_pred_to_lambda_goal(Purity, EvalMethod, X0, PredId, ProcId, QualifiedPName = qualified(PredModule, PredName), CallUnifyContext = call_unify_context(X0, - functor(cons(QualifiedPName, list__length(ArgVars0)), no, ArgVars0), + functor(cons(QualifiedPName, list.length(ArgVars0)), no, ArgVars0), UnifyContext), LambdaGoalExpr = call(PredId, ProcId, Args, not_builtin, yes(CallUnifyContext), QualifiedPName), @@ -1364,9 +1360,9 @@ convert_pred_to_lambda_goal(Purity, EvalMethod, X0, PredId, ProcId, % to compute constraint_ids correctly. % goal_info_get_nonlocals(GoalInfo0, NonLocals), - set__insert_list(NonLocals, LambdaVars, OutsideVars), - set__list_to_set(Args, InsideVars), - set__intersect(OutsideVars, InsideVars, LambdaNonLocals), + set.insert_list(NonLocals, LambdaVars, OutsideVars), + set.list_to_set(Args, InsideVars), + set.intersect(OutsideVars, InsideVars, LambdaNonLocals), goal_info_get_goal_path(GoalInfo0, GoalPath), goal_info_init(LambdaGoalInfo0), goal_info_set_context(Context, LambdaGoalInfo0, LambdaGoalInfo1), @@ -1378,12 +1374,12 @@ convert_pred_to_lambda_goal(Purity, EvalMethod, X0, PredId, ProcId, % Work out the modes of the introduced lambda variables and the determinism % of the lambda goal. proc_info_argmodes(ProcInfo, ArgModes), - list__length(ArgModes, NumArgModes), - list__length(LambdaVars, NumLambdaVars), - ( list__drop(NumArgModes - NumLambdaVars, ArgModes, LambdaModes0) -> + list.length(ArgModes, NumArgModes), + list.length(LambdaVars, NumLambdaVars), + ( list.drop(NumArgModes - NumLambdaVars, ArgModes, LambdaModes0) -> LambdaModes = LambdaModes0 ; - unexpected(this_file, "convert_pred_to_lambda_goal: list__drop failed") + unexpected(this_file, "convert_pred_to_lambda_goal: list.drop failed") ), proc_info_declared_determinism(ProcInfo, MaybeDet), ( @@ -1407,8 +1403,8 @@ convert_pred_to_lambda_goal(Purity, EvalMethod, X0, PredId, ProcId, make_fresh_vars([], [], !VarSet, !VarTypes). make_fresh_vars([Type | Types], [Var | Vars], !VarSet, !VarTypes) :- - varset__new_var(!.VarSet, Var, !:VarSet), - map__det_insert(!.VarTypes, Var, Type, !:VarTypes), + varset.new_var(!.VarSet, Var, !:VarSet), + map.det_insert(!.VarTypes, Var, Type, !:VarTypes), make_fresh_vars(Types, Vars, !VarSet, !VarTypes). %-----------------------------------------------------------------------------% @@ -1450,7 +1446,7 @@ process_existq_unify_functor(CtorDefn, IsConstruction, % Create type_class_info variables for the type class constraints. poly_info_get_constraint_map(!.Info, ConstraintMap), goal_info_get_goal_path(GoalInfo, GoalPath), - list__length(ParentExistentialConstraints, NumExistentialConstraints), + list.length(ParentExistentialConstraints, NumExistentialConstraints), goal_info_get_context(GoalInfo, Context), ( IsConstruction = yes, @@ -1473,7 +1469,7 @@ process_existq_unify_functor(CtorDefn, IsConstruction, % to figure out what types they are bound to. constraint_list_get_tvars(ParentExistentialConstraints, ParentExistConstrainedTVars), - list__delete_elems(ParentExistQVars, ParentExistConstrainedTVars, + list.delete_elems(ParentExistQVars, ParentExistConstrainedTVars, ParentUnconstrainedExistQVars), apply_rec_subst_to_tvar_list(ParentKindMap, ParentToActualTypeSubst, ParentUnconstrainedExistQVars, ActualExistentialTypes), @@ -1497,13 +1493,12 @@ process_existq_unify_functor(CtorDefn, IsConstruction, ground,ground))), hlds_goal_info::in, hlds_goal::out, poly_info::in, poly_info::out) is det. -process_foreign_proc(ModuleInfo, PredInfo, Goal0, GoalInfo0, - Goal, !Info) :- +process_foreign_proc(ModuleInfo, PredInfo, Goal0, GoalInfo0, Goal, !Info) :- % Insert the type_info vars into the argname map, so that the foreign_proc % can refer to the type_info variable for type T as `TypeInfo_for_T'. Goal0 = foreign_proc(Attributes, PredId, ProcId, Args0, ProcExtraArgs, Impl0), - ArgVars0 = list__map(foreign_arg_var, Args0), + ArgVars0 = list.map(foreign_arg_var, Args0), process_call(PredId, ArgVars0, GoalInfo0, GoalInfo, ExtraVars, ExtraGoals, !Info), ( Impl0 = import(_, _, _, _) -> @@ -1532,7 +1527,7 @@ process_foreign_proc(ModuleInfo, PredInfo, Goal0, GoalInfo0, CallExpr = foreign_proc(Attributes, PredId, ProcId, Args, ProcExtraArgs, Impl), Call = CallExpr - GoalInfo, - list__append(ExtraGoals, [Call], GoalList), + list.append(ExtraGoals, [Call], GoalList), conj_list_to_goal(GoalList, GoalInfo0, Goal). :- pred process_foreign_proc_args(pred_info::in, bool::in, @@ -1545,15 +1540,15 @@ process_foreign_proc_args(PredInfo, CanOptAwayUnnamed, Impl, Vars, Args) :- % Find out which variables are constrained (so that we don't add % type_infos for them. pred_info_get_class_context(PredInfo, constraints(UnivCs, ExistCs)), - UnivVars0 = list__map(get_constrained_vars, UnivCs), - list__condense(UnivVars0, UnivConstrainedVars), - ExistVars0 = list__map(get_constrained_vars, ExistCs), - list__condense(ExistVars0, ExistConstrainedVars), + UnivVars0 = list.map(get_constrained_vars, UnivCs), + list.condense(UnivVars0, UnivConstrainedVars), + ExistVars0 = list.map(get_constrained_vars, ExistCs), + list.condense(ExistVars0, ExistConstrainedVars), - prog_type__vars_list(PredArgTypes, PredTypeVars0), - list__remove_dups(PredTypeVars0, PredTypeVars1), - list__delete_elems(PredTypeVars1, UnivConstrainedVars, PredTypeVars2), - list__delete_elems(PredTypeVars2, ExistConstrainedVars, PredTypeVars), + prog_type.vars_list(PredArgTypes, PredTypeVars0), + list.remove_dups(PredTypeVars0, PredTypeVars1), + list.delete_elems(PredTypeVars1, UnivConstrainedVars, PredTypeVars2), + list.delete_elems(PredTypeVars2, ExistConstrainedVars, PredTypeVars), % The argument order is as follows: % first the UnivTypeInfos (for universally quantified type variables) @@ -1565,18 +1560,18 @@ process_foreign_proc_args(PredInfo, CanOptAwayUnnamed, Impl, Vars, Args) :- in_mode(In), out_mode(Out), - list__map(foreign_proc_add_typeclass_info(CanOptAwayUnnamed, Out, Impl, + list.map(foreign_proc_add_typeclass_info(CanOptAwayUnnamed, Out, Impl, PredTypeVarSet), ExistCs, ExistTypeClassArgInfos), - list__map(foreign_proc_add_typeclass_info(CanOptAwayUnnamed, In, Impl, + list.map(foreign_proc_add_typeclass_info(CanOptAwayUnnamed, In, Impl, PredTypeVarSet), UnivCs, UnivTypeClassArgInfos), TypeClassArgInfos = UnivTypeClassArgInfos ++ ExistTypeClassArgInfos, - list__filter((pred(X::in) is semidet :- list__member(X, ExistQVars)), + list.filter((pred(X::in) is semidet :- list.member(X, ExistQVars)), PredTypeVars, ExistUnconstrainedVars, UnivUnconstrainedVars), - list__map(foreign_proc_add_typeinfo(CanOptAwayUnnamed, Out, Impl, + list.map(foreign_proc_add_typeinfo(CanOptAwayUnnamed, Out, Impl, PredTypeVarSet), ExistUnconstrainedVars, ExistTypeArgInfos), - list__map(foreign_proc_add_typeinfo(CanOptAwayUnnamed, In, Impl, + list.map(foreign_proc_add_typeinfo(CanOptAwayUnnamed, In, Impl, PredTypeVarSet), UnivUnconstrainedVars, UnivTypeArgInfos), TypeInfoArgInfos = UnivTypeArgInfos ++ ExistTypeArgInfos, @@ -1585,9 +1580,9 @@ process_foreign_proc_args(PredInfo, CanOptAwayUnnamed, Impl, Vars, Args) :- % Insert type_info/typeclass_info types for all the inserted % type_info/typeclass_info vars into the argument type list. - TypeInfoTypes = list__map((func(_) = type_info_type), PredTypeVars), - list__map(build_typeclass_info_type, UnivCs, UnivTypes), - list__map(build_typeclass_info_type, ExistCs, ExistTypes), + TypeInfoTypes = list.map((func(_) = type_info_type), PredTypeVars), + list.map(build_typeclass_info_type, UnivCs, UnivTypes), + list.map(build_typeclass_info_type, ExistCs, ExistTypes), OrigArgTypes = TypeInfoTypes ++ UnivTypes ++ ExistTypes, make_foreign_args(Vars, ArgInfos, OrigArgTypes, Args). @@ -1599,10 +1594,10 @@ process_foreign_proc_args(PredInfo, CanOptAwayUnnamed, Impl, Vars, Args) :- foreign_proc_add_typeclass_info(CanOptAwayUnnamed, Mode, Impl, TypeVarSet, Constraint, MaybeArgName - native_if_possible) :- Constraint = constraint(Name0, Types), - mdbcomp__prim_data__sym_name_to_string(Name0, "__", Name), - prog_type__vars_list(Types, TypeVars), - TypeVarNames = list__map(underscore_and_tvar_name(TypeVarSet), TypeVars), - string__append_list(["TypeClassInfo_for_", Name | TypeVarNames], + sym_name_to_string(Name0, "__", Name), + prog_type.vars_list(Types, TypeVars), + TypeVarNames = list.map(underscore_and_tvar_name(TypeVarSet), TypeVars), + string.append_list(["TypeClassInfo_for_", Name | TypeVarNames], ConstraintVarName), % If the variable name corresponding to the typeclass_info isn't mentioned % in the C code fragment, don't pass the variable to the C code at all. @@ -1621,8 +1616,8 @@ foreign_proc_add_typeclass_info(CanOptAwayUnnamed, Mode, Impl, TypeVarSet, foreign_proc_add_typeinfo(CanOptAwayUnnamed, Mode, Impl, TypeVarSet, TVar, MaybeArgName - native_if_possible) :- - ( varset__search_name(TypeVarSet, TVar, TypeVarName) -> - string__append("TypeInfo_for_", TypeVarName, C_VarName), + ( varset.search_name(TypeVarSet, TVar, TypeVarName) -> + string.append("TypeInfo_for_", TypeVarName, C_VarName), % If the variable name corresponding to the type_info isn't mentioned % in the C code fragment, don't pass the variable to the C code at all. ( @@ -1650,8 +1645,8 @@ foreign_code_does_not_use_variable(Impl, VarName) :- :- func underscore_and_tvar_name(tvarset, tvar) = string. underscore_and_tvar_name(TypeVarSet, TVar) = TVarName :- - varset__lookup_name(TypeVarSet, TVar, TVarName0), - string__append("_", TVarName0, TVarName). + varset.lookup_name(TypeVarSet, TVar, TVarName0), + string.append("_", TVarName0, TVarName). :- pred process_goal_list(list(hlds_goal)::in, list(hlds_goal)::out, poly_info::in, poly_info::out) is det. @@ -1710,9 +1705,9 @@ process_call(PredId, ArgVars0, GoalInfo0, GoalInfo, ExtraVars, ExtraGoals, % in the callee to new type variables in the caller. Adding the new type % variables to TypeVarSet0 yields TypeVarSet. - ( varset__is_empty(PredTypeVarSet) -> + ( varset.is_empty(PredTypeVarSet) -> % optimize a common case - map__init(PredToParentTypeRenaming), + map.init(PredToParentTypeRenaming), TypeVarSet = TypeVarSet0, ParentArgTypes = PredArgTypes, ParentKindMap = PredKindMap, @@ -1724,7 +1719,7 @@ process_call(PredId, ArgVars0, GoalInfo0, GoalInfo, ExtraVars, ExtraGoals, PredToParentTypeRenaming), apply_variable_renaming_to_type_list(PredToParentTypeRenaming, PredArgTypes, ParentArgTypes), - prog_type__vars_list(ParentArgTypes, ParentTVars), + prog_type.vars_list(ParentArgTypes, ParentTVars), apply_variable_renaming_to_tvar_kind_map(PredToParentTypeRenaming, PredKindMap, ParentKindMap), apply_variable_renaming_to_tvar_list(PredToParentTypeRenaming, @@ -1764,31 +1759,31 @@ process_call(PredId, ArgVars0, GoalInfo0, GoalInfo, ExtraVars, ExtraGoals, % Calculate the set of unconstrained type vars. Split these into % existential and universal type vars. - list__remove_dups(ParentTVars, ParentUnconstrainedTVars0), - list__delete_elems(ParentUnconstrainedTVars0, + list.remove_dups(ParentTVars, ParentUnconstrainedTVars0), + list.delete_elems(ParentUnconstrainedTVars0, ParentUnivConstrainedTVars, ParentUnconstrainedTVars1), - list__delete_elems(ParentUnconstrainedTVars1, + list.delete_elems(ParentUnconstrainedTVars1, ParentExistConstrainedTVars, ParentUnconstrainedTVars), - list__delete_elems(ParentUnconstrainedTVars, ParentExistQVars, + list.delete_elems(ParentUnconstrainedTVars, ParentExistQVars, ParentUnconstrainedUnivTVars), - list__delete_elems(ParentUnconstrainedTVars, + list.delete_elems(ParentUnconstrainedTVars, ParentUnconstrainedUnivTVars, ParentUnconstrainedExistTVars), % Calculate the "parent to actual" binding. - map__apply_to_list(ArgVars0, VarTypes, ActualArgTypes), + map.apply_to_list(ArgVars0, VarTypes, ActualArgTypes), type_list_subsumes_det(ParentArgTypes, ActualArgTypes, ParentToActualTypeSubst), % Make the universally quantified typeclass_infos for the call. poly_info_get_constraint_map(!.Info, ConstraintMap), goal_info_get_goal_path(GoalInfo0, GoalPath), - list__length(ParentUnivConstraints, NumUnivConstraints), + list.length(ParentUnivConstraints, NumUnivConstraints), lookup_hlds_constraint_list(ConstraintMap, unproven, GoalPath, NumUnivConstraints, ActualUnivConstraints), apply_rec_subst_to_tvar_list(ParentKindMap, ParentToActualTypeSubst, ParentExistQVars, ActualExistQVarTypes), ( - prog_type__type_list_to_var_list(ActualExistQVarTypes, + prog_type.type_list_to_var_list(ActualExistQVarTypes, ActualExistQVars0) -> ActualExistQVars = ActualExistQVars0 @@ -1801,7 +1796,7 @@ process_call(PredId, ArgVars0, GoalInfo0, GoalInfo, ExtraVars, ExtraGoals, % Make variables to hold any existentially quantified typeclass_infos % in the call, insert them into the typeclass_info map. - list__length(ParentExistConstraints, NumExistConstraints), + list.length(ParentExistConstraints, NumExistConstraints), lookup_hlds_constraint_list(ConstraintMap, assumed, GoalPath, NumExistConstraints, ActualExistConstraints), make_existq_typeclass_info_vars( @@ -1830,7 +1825,7 @@ process_call(PredId, ArgVars0, GoalInfo0, GoalInfo, ExtraVars, ExtraGoals, % Update the nonlocals. goal_info_get_nonlocals(GoalInfo0, NonLocals0), - set__insert_list(NonLocals0, ExtraVars, NonLocals), + set.insert_list(NonLocals0, ExtraVars, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo) ). @@ -1846,19 +1841,19 @@ process_new_call(CalleePredInfo, CalleeProcInfo, PredId, ProcId, CallArgs0, !Info) :- poly_info_get_typevarset(!.Info, TVarSet0), poly_info_get_var_types(!.Info, VarTypes0), - ActualArgTypes0 = map__apply_to_list(CallArgs0, VarTypes0), + ActualArgTypes0 = map.apply_to_list(CallArgs0, VarTypes0), pred_info_arg_types(CalleePredInfo, PredTVarSet, _PredExistQVars, PredArgTypes), proc_info_headvars(CalleeProcInfo, CalleeHeadVars), proc_info_rtti_varmaps(CalleeProcInfo, CalleeRttiVarMaps), % Work out how many type_info args we need to prepend. - NCallArgs0 = list__length(ActualArgTypes0), - NPredArgs = list__length(PredArgTypes), + NCallArgs0 = list.length(ActualArgTypes0), + NPredArgs = list.length(PredArgTypes), NExtraArgs = NPredArgs - NCallArgs0, ( - list__drop(NExtraArgs, PredArgTypes, OrigPredArgTypes0), - list__take(NExtraArgs, CalleeHeadVars, CalleeExtraHeadVars0) + list.drop(NExtraArgs, PredArgTypes, OrigPredArgTypes0), + list.take(NExtraArgs, CalleeHeadVars, CalleeExtraHeadVars0) -> OrigPredArgTypes = OrigPredArgTypes0, CalleeExtraHeadVars = CalleeExtraHeadVars0 @@ -1879,33 +1874,33 @@ process_new_call(CalleePredInfo, CalleeProcInfo, PredId, ProcId, CallArgs0, % and apply the type bindings to calculate the types that the caller % should pass type_infos for. GetTypeInfoTypes = (pred(ProgVar::in, TypeInfoType::out) is det :- - rtti_varmaps_var_info(CalleeRttiVarMaps, ProgVar, VarInfo), - ( - VarInfo = type_info_var(TypeInfoType) - ; - VarInfo = typeclass_info_var(_), - unexpected(this_file, - "unsupported: constraints on initialisation preds") - ; - VarInfo = non_rtti_var, - unexpected(this_file, - "missing rtti_var_info for initialisation pred") - ) - ), - list__map(GetTypeInfoTypes, CalleeExtraHeadVars, PredTypeInfoTypes), + rtti_varmaps_var_info(CalleeRttiVarMaps, ProgVar, VarInfo), + ( + VarInfo = type_info_var(TypeInfoType) + ; + VarInfo = typeclass_info_var(_), + unexpected(this_file, + "unsupported: constraints on initialisation preds") + ; + VarInfo = non_rtti_var, + unexpected(this_file, + "missing rtti_var_info for initialisation pred") + ) + ), + list.map(GetTypeInfoTypes, CalleeExtraHeadVars, PredTypeInfoTypes), apply_variable_renaming_to_type_list(PredToParentRenaming, PredTypeInfoTypes, ParentTypeInfoTypes), apply_rec_subst_to_type_list(ParentToActualTSubst, ParentTypeInfoTypes, ActualTypeInfoTypes), % Construct goals to make the required type_infos. - Ctxt = term__context_init, + Ctxt = term.context_init, make_type_info_vars(ActualTypeInfoTypes, Ctxt, ExtraArgs, ExtraGoals, !Info), CallArgs = ExtraArgs ++ CallArgs0, goal_info_get_nonlocals(GoalInfo0, NonLocals0), - NonLocals1 = set__list_to_set(ExtraArgs), - NonLocals = set__union(NonLocals0, NonLocals1), + NonLocals1 = set.list_to_set(ExtraArgs), + NonLocals = set.union(NonLocals0, NonLocals1), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo), CallGoalExpr = call(PredId, ProcId, CallArgs, BuiltinState, MaybeCallUnifyContext, SymName), @@ -1942,7 +1937,7 @@ fixup_quantification(HeadVars, ExistQVars, Goal0, Goal, !Info) :- ; poly_info_get_varset(!.Info, VarSet0), poly_info_get_var_types(!.Info, VarTypes0), - set__list_to_set(HeadVars, OutsideVars), + set.list_to_set(HeadVars, OutsideVars), implicitly_quantify_goal(OutsideVars, _Warnings, Goal0, Goal, VarSet0, VarSet, VarTypes0, VarTypes), poly_info_set_varset_and_types(VarSet, VarTypes, !Info) @@ -1966,17 +1961,17 @@ fixup_lambda_quantification(ArgVars, LambdaVars, ExistQVars, !Goal, NewOutsideVars, !Info) :- poly_info_get_rtti_varmaps(!.Info, RttiVarMaps), ( rtti_varmaps_no_tvars(RttiVarMaps) -> - set__init(NewOutsideVars) + set.init(NewOutsideVars) ; poly_info_get_varset(!.Info, VarSet0), poly_info_get_var_types(!.Info, VarTypes0), !.Goal = _ - GoalInfo0, goal_info_get_nonlocals(GoalInfo0, NonLocals), - set__insert_list(NonLocals, ArgVars, NonLocalsPlusArgs0), - set__insert_list(NonLocalsPlusArgs0, LambdaVars, NonLocalsPlusArgs), - goal_util__extra_nonlocal_typeinfos(RttiVarMaps, VarTypes0, + set.insert_list(NonLocals, ArgVars, NonLocalsPlusArgs0), + set.insert_list(NonLocalsPlusArgs0, LambdaVars, NonLocalsPlusArgs), + goal_util.extra_nonlocal_typeinfos(RttiVarMaps, VarTypes0, ExistQVars, NonLocalsPlusArgs, NewOutsideVars), - set__union(NonLocals, NewOutsideVars, OutsideVars), + set.union(NonLocals, NewOutsideVars, OutsideVars), implicitly_quantify_goal(OutsideVars, _Warnings, !Goal, VarSet0, VarSet, VarTypes0, VarTypes), poly_info_set_varset_and_types(VarSet, VarTypes, !Info) @@ -2010,8 +2005,8 @@ make_typeclass_info_vars(Constraints, ExistQVars, Context, ExistQVars, Context, RevExtraVars0, RevExtraVars, RevExtraGoals0, RevExtraGoals, !Info), % We build up the vars and goals in reverse order. - list__reverse(RevExtraVars, ExtraVars), - list__reverse(RevExtraGoals, ExtraGoals). + list.reverse(RevExtraVars, ExtraVars), + list.reverse(RevExtraGoals, ExtraGoals). % Accumulator version of the above. % @@ -2049,7 +2044,7 @@ make_typeclass_info_var(Constraint, Seen, ExistQVars, % We don't have the typeclass_info, we must either have a proof that % tells us how to make it, or it will be produced by an existentially % typed goal that we will process later on. - map__search(!.Info ^ proof_map, Constraint, Proof) + map.search(!.Info ^ proof_map, Constraint, Proof) -> make_typeclass_info_from_proof(Constraint, Seen, Proof, ExistQVars, Context, MaybeVar, !ExtraGoals, !Info) @@ -2071,7 +2066,7 @@ make_typeclass_info_var(Constraint, Seen, ExistQVars, make_typeclass_info_from_proof(Constraint, Seen, Proof, ExistQVars, Context, MaybeVar, !ExtraGoals, !Info) :- Constraint = constraint(ClassName, ConstrainedTypes), - list__length(ConstrainedTypes, ClassArity), + list.length(ConstrainedTypes, ClassArity), ClassId = class_id(ClassName, ClassArity), ( % We have to construct the typeclass_info using an instance @@ -2102,17 +2097,17 @@ make_typeclass_info_from_instance(Constraint, Seen, ClassId, InstanceNum, ModuleInfo = !.Info ^ module_info, module_info_get_instance_table(ModuleInfo, InstanceTable), - map__lookup(InstanceTable, ClassId, InstanceList), - list__index1_det(InstanceList, InstanceNum, ProofInstanceDefn), + map.lookup(InstanceTable, ClassId, InstanceList), + list.index1_det(InstanceList, InstanceNum, ProofInstanceDefn), ProofInstanceDefn = hlds_instance_defn(_, _, _, InstanceConstraints0, InstanceTypes0, _, _, InstanceTVarset, SuperClassProofs0), % XXX kind inference: % we assume all tvars have kind `star'. - map__init(KindMap), + map.init(KindMap), - prog_type__vars_list(InstanceTypes0, InstanceTvars), + prog_type.vars_list(InstanceTypes0, InstanceTvars), get_unconstrained_tvars(InstanceTvars, InstanceConstraints0, UnconstrainedTvars0), @@ -2129,7 +2124,7 @@ make_typeclass_info_from_instance(Constraint, Seen, ClassId, InstanceNum, apply_rec_subst_to_prog_constraint_list(InstanceSubst, InstanceConstraints1, InstanceConstraints2), % XXX document diamond as guess - InstanceConstraints = InstanceConstraints2 `list__delete_elems` Seen, + InstanceConstraints = InstanceConstraints2 `list.delete_elems` Seen, apply_variable_renaming_to_constraint_proofs(Renaming, SuperClassProofs0, SuperClassProofs1), apply_rec_subst_to_constraint_proofs(InstanceSubst, @@ -2143,7 +2138,7 @@ make_typeclass_info_from_instance(Constraint, Seen, ClassId, InstanceNum, UnconstrainedTvars1, UnconstrainedTypes), % XXX why name of output? - map__overlay(Proofs, SuperClassProofs2, SuperClassProofs), + map.overlay(Proofs, SuperClassProofs2, SuperClassProofs), % Make the type_infos for the types that are constrained by this. % These are packaged in the typeclass_info. @@ -2162,7 +2157,7 @@ make_typeclass_info_from_instance(Constraint, Seen, ClassId, InstanceNum, UnconstrainedTypeInfoGoals, !Info), % The variables are built up in reverse order. - list__reverse(InstanceExtraTypeClassInfoVars0, + list.reverse(InstanceExtraTypeClassInfoVars0, InstanceExtraTypeClassInfoVars), construct_typeclass_info(InstanceExtraTypeInfoUnconstrainedVars, @@ -2174,11 +2169,11 @@ make_typeclass_info_from_instance(Constraint, Seen, ClassId, InstanceNum, % Oh, yuck. The type_info goals have already been reversed, so lets % reverse them back. - list__reverse(TypeInfoGoals, RevTypeInfoGoals), - list__reverse(UnconstrainedTypeInfoGoals, + list.reverse(TypeInfoGoals, RevTypeInfoGoals), + list.reverse(UnconstrainedTypeInfoGoals, RevUnconstrainedTypeInfoGoals), - list__condense([RevUnconstrainedTypeInfoGoals, NewGoals, + list.condense([RevUnconstrainedTypeInfoGoals, NewGoals, !.ExtraGoals, RevTypeInfoGoals], !:ExtraGoals). :- pred make_typeclass_info_from_subclass(prog_constraint::in, @@ -2197,7 +2192,7 @@ make_typeclass_info_from_subclass(Constraint, Seen, ClassId, MaybeVar = yes(Var), % Then work out where to extract it from. SubClassConstraint = constraint(SubClassName, SubClassTypes), - list__length(SubClassTypes, SubClassArity), + list.length(SubClassTypes, SubClassArity), SubClassId = class_id(SubClassName, SubClassArity), % Make the typeclass_info for the subclass. @@ -2214,14 +2209,14 @@ make_typeclass_info_from_subclass(Constraint, Seen, ClassId, % Look up the definition of the subclass. poly_info_get_module_info(!.Info, ModuleInfo), module_info_get_class_table(ModuleInfo, ClassTable), - map__lookup(ClassTable, SubClassId, SubClassDefn), + map.lookup(ClassTable, SubClassId, SubClassDefn), % Work out which superclass typeclass_info to take. - map__from_corresponding_lists(SubClassDefn ^ class_vars, SubClassTypes, + map.from_corresponding_lists(SubClassDefn ^ class_vars, SubClassTypes, SubTypeSubst), apply_subst_to_prog_constraint_list(SubTypeSubst, SubClassDefn ^ class_supers, SuperClasses), - ( list__nth_member_search(SuperClasses, Constraint, SuperClassIndex0) -> + ( list.nth_member_search(SuperClasses, Constraint, SuperClassIndex0) -> SuperClassIndex0 = SuperClassIndex ; % We shouldn't have got this far if the constraints were not satisfied. @@ -2236,10 +2231,10 @@ make_typeclass_info_from_subclass(Constraint, Seen, ClassId, % We extract the superclass typeclass_info by inserting a call % to superclass_from_typeclass_info in private_builtin. - goal_util__generate_simple_call(mercury_private_builtin_module, + goal_util.generate_simple_call(mercury_private_builtin_module, "superclass_from_typeclass_info", predicate, only_mode, det, [SubClassVar, IndexVar, Var], [], [], ModuleInfo, - term__context_init, SuperClassGoal), + term.context_init, SuperClassGoal), !:ExtraGoals = [SuperClassGoal, IndexGoal | !.ExtraGoals]. :- pred construct_typeclass_info(list(prog_var)::in, list(prog_var)::in, @@ -2254,15 +2249,15 @@ construct_typeclass_info(ArgUnconstrainedTypeInfoVars, ArgTypeInfoVars, poly_info_get_module_info(!.Info, ModuleInfo), module_info_get_class_table(ModuleInfo, ClassTable), - map__lookup(ClassTable, ClassId, ClassDefn), + map.lookup(ClassTable, ClassId, ClassDefn), get_arg_superclass_vars(ClassDefn, InstanceTypes, SuperClassProofs, ExistQVars, ArgSuperClassVars, SuperClassGoals, !Info), % Lay out the argument variables as expected in the typeclass_info. - list__append(ArgTypeClassInfoVars, ArgSuperClassVars, ArgVars0), - list__append(ArgVars0, ArgTypeInfoVars, ArgVars1), - list__append(ArgUnconstrainedTypeInfoVars, ArgVars1, ArgVars), + list.append(ArgTypeClassInfoVars, ArgSuperClassVars, ArgVars0), + list.append(ArgVars0, ArgTypeInfoVars, ArgVars1), + list.append(ArgUnconstrainedTypeInfoVars, ArgVars1, ArgVars), ClassId = class_id(ClassName, _Arity), @@ -2270,8 +2265,8 @@ construct_typeclass_info(ArgUnconstrainedTypeInfoVars, ArgTypeInfoVars, new_typeclass_info_var(Constraint, ClassNameString, BaseVar, !Info), module_info_get_instance_table(ModuleInfo, InstanceTable), - map__lookup(InstanceTable, ClassId, InstanceList), - list__index1_det(InstanceList, InstanceNum, InstanceDefn), + map.lookup(InstanceTable, ClassId, InstanceList), + list.index1_det(InstanceList, InstanceNum, InstanceDefn), InstanceModuleName = InstanceDefn ^ instance_module, make_instance_string(InstanceTypes, InstanceString), ConsId = base_typeclass_info_const(InstanceModuleName, ClassId, @@ -2289,7 +2284,7 @@ construct_typeclass_info(ArgUnconstrainedTypeInfoVars, ArgTypeInfoVars, BaseUnification, BaseUnifyContext), % Create a goal_info for the unification. - set__list_to_set([BaseVar], NonLocals), + set.list_to_set([BaseVar], NonLocals), instmap_delta_from_assoc_list([BaseVar - ground(shared, none)], InstmapDelta), goal_info_init(NonLocals, InstmapDelta, det, purity_pure, BaseGoalInfo), @@ -2306,8 +2301,8 @@ construct_typeclass_info(ArgUnconstrainedTypeInfoVars, ArgTypeInfoVars, % Create the construction unification to initialize the variable. UniMode = (free - ground(shared, none) -> ground(shared, none) - ground(shared, none)), - list__length(NewArgVars, NumArgVars), - list__duplicate(NumArgVars, UniMode, UniModes), + list.length(NewArgVars, NumArgVars), + list.duplicate(NumArgVars, UniMode, UniModes), Unification = construct(NewVar, NewConsId, NewArgVars, UniModes, construct_dynamically, cell_is_unique, no_construct_sub_info), UnifyMode = (free -> ground(shared, none)) - @@ -2319,9 +2314,9 @@ construct_typeclass_info(ArgUnconstrainedTypeInfoVars, ArgTypeInfoVars, % Create a goal_info for the unification. goal_info_init(GoalInfo0), - set__list_to_set([NewVar | NewArgVars], TheNonLocals), + set.list_to_set([NewVar | NewArgVars], TheNonLocals), goal_info_set_nonlocals(TheNonLocals, GoalInfo0, GoalInfo1), - list__duplicate(NumArgVars, ground(shared, none), ArgInsts), + list.duplicate(NumArgVars, ground(shared, none), ArgInsts), % Note that we could perhaps be more accurate than `ground(shared)', % but it shouldn't make any difference. InstConsId = cell_inst_cons_id(typeclass_info_cell, NumArgVars), @@ -2333,7 +2328,7 @@ construct_typeclass_info(ArgUnconstrainedTypeInfoVars, ArgTypeInfoVars, TypeClassInfoGoal = Unify - GoalInfo, NewGoals0 = [TypeClassInfoGoal, BaseGoal], - list__append(NewGoals0, SuperClassGoals, NewGoals). + list.append(NewGoals0, SuperClassGoals, NewGoals). %---------------------------------------------------------------------------% @@ -2353,7 +2348,7 @@ get_arg_superclass_vars(ClassDefn, InstanceTypes, SuperClassProofs, ExistQVars, poly_info_set_typevarset(TVarSet1, !Info), apply_variable_renaming_to_tvar_list(Renaming, ClassVars0, ClassVars), - map__from_corresponding_lists(ClassVars, InstanceTypes, TypeSubst), + map.from_corresponding_lists(ClassVars, InstanceTypes, TypeSubst), apply_variable_renaming_to_prog_constraint_list(Renaming, SuperClasses0, SuperClasses1), @@ -2376,7 +2371,7 @@ make_superclasses_from_proofs([Constraint | Constraints], ExistQVars, !Goals, !Info, !Vars) :- make_superclasses_from_proofs(Constraints, ExistQVars, !Goals, !Info, !Vars), - term__context_init(Context), + term.context_init(Context), make_typeclass_info_var(Constraint, [], ExistQVars, Context, !Goals, !Info, MaybeVar), maybe_insert_var(MaybeVar, !Vars). @@ -2402,13 +2397,13 @@ make_existq_typeclass_info_vars(ExistentialConstraints, ExtraTypeClassVars, make_typeclass_info_head_vars(do_record_type_info_locns, ExistentialConstraints, ExtraTypeClassVars, !Info), poly_info_get_rtti_varmaps(!.Info, RttiVarMaps0), - list__foldl(rtti_reuse_typeclass_info_var, ExtraTypeClassVars, + list.foldl(rtti_reuse_typeclass_info_var, ExtraTypeClassVars, RttiVarMaps0, RttiVarMaps), poly_info_set_rtti_varmaps(RttiVarMaps, !Info), constraint_list_get_tvars(ExistentialConstraints, TVars0), - list__sort_and_remove_dups(TVars0, TVars), - list__foldl2(maybe_extract_type_info(OldRttiVarMaps), TVars, + list.sort_and_remove_dups(TVars0, TVars), + list.foldl2(maybe_extract_type_info(OldRttiVarMaps), TVars, [], ExtraGoals, !Info). % For code which requires mode reordering, we may have already seen uses @@ -2579,7 +2574,7 @@ maybe_init_second_cell(Type, TypeCtorVar, TypeCtorIsVarArity, ArgTypeInfoVars, TypeCtorIsVarArity = yes, % Unfortunately, if the type's type constructor has variable arity, % we cannot use a one-cell representation for that type. - list__length(ArgTypeInfoVars, ActualArity), + list.length(ArgTypeInfoVars, ActualArity), make_int_const_construction_alloc(ActualArity, yes("ActualArity"), ArityGoal, ArityVar, !VarTypes, !VarSet), init_type_info_var(Type, [TypeCtorVar, ArityVar | ArgTypeInfoVars], @@ -2599,9 +2594,9 @@ maybe_init_second_cell(Type, TypeCtorVar, TypeCtorIsVarArity, ArgTypeInfoVars, % we need to adjust its type. Since type_ctor_info_const cons_ids % are handled specially, this should not cause problems. TypeInfoType = type_info_type, - map__det_update(!.VarTypes, TypeCtorVar, TypeInfoType, !:VarTypes), + map.det_update(!.VarTypes, TypeCtorVar, TypeInfoType, !:VarTypes), Var = TypeCtorVar, - list__append(ArgTypeInfoGoals, ExtraGoals0, ExtraGoals) + list.append(ArgTypeInfoGoals, ExtraGoals0, ExtraGoals) % The type_info to represent Type is just a type_ctor_info. We used % to simply change the type of TypeCtorVar from type_ctor_info to @@ -2613,8 +2608,8 @@ maybe_init_second_cell(Type, TypeCtorVar, TypeCtorIsVarArity, ArgTypeInfoVars, % % new_type_info_var_raw(Type, type_info, Var, !VarSet, !VarTypes), % generate_unsafe_cast(TypeCtorVar, Var, Context, CastGoal), - % list__append(ArgTypeInfoGoals, [CastGoal], ExtraGoals1), - % list__append(ExtraGoals0, ExtraGoals1, ExtraGoals) + % list.append(ArgTypeInfoGoals, [CastGoal], ExtraGoals1), + % list.append(ExtraGoals0, ExtraGoals1, ExtraGoals) ) ). @@ -2625,7 +2620,7 @@ get_special_proc(Type, SpecialPredId, ModuleInfo, PredName, PredId, ProcId) :- MaybeCategoryName = no, module_info_get_special_pred_map(ModuleInfo, SpecialPredMap), ( type_to_ctor_and_args(Type, TypeCtor, _TypeArgs) -> - map__search(SpecialPredMap, SpecialPredId - TypeCtor, PredId) + map.search(SpecialPredMap, SpecialPredId - TypeCtor, PredId) ; unexpected(this_file, "get_special_proc: type_to_ctor_and_args failed") @@ -2700,8 +2695,8 @@ init_type_info_var(Type, ArgVars, MaybePreferredVar, TypeInfoVar, TypeInfoGoal, % Create the construction unification to initialize the variable. UniMode = (free - ground(shared, none) -> ground(shared, none) - ground(shared, none)), - list__length(ArgVars, NumArgVars), - list__duplicate(NumArgVars, UniMode, UniModes), + list.length(ArgVars, NumArgVars), + list.duplicate(NumArgVars, UniMode, UniModes), Unification = construct(TypeInfoVar, ConsId, ArgVars, UniModes, construct_dynamically, cell_is_unique, no_construct_sub_info), UnifyMode = (free -> ground(shared, none)) - @@ -2712,8 +2707,8 @@ init_type_info_var(Type, ArgVars, MaybePreferredVar, TypeInfoVar, TypeInfoGoal, UnifyContext), % Create a goal_info for the unification. - set__list_to_set([TypeInfoVar | ArgVars], NonLocals), - list__duplicate(NumArgVars, ground(shared, none), ArgInsts), + set.list_to_set([TypeInfoVar | ArgVars], NonLocals), + list.duplicate(NumArgVars, ground(shared, none), ArgInsts), % note that we could perhaps be more accurate than `ground(shared)', % but it shouldn't make any difference. InstConsId = cell_inst_cons_id(Cell, NumArgVars), @@ -2726,8 +2721,8 @@ init_type_info_var(Type, ArgVars, MaybePreferredVar, TypeInfoVar, TypeInfoGoal, init_const_type_ctor_info_var(Type, TypeCtor, TypeCtorInfoVar, TypeCtorInfoGoal, ModuleInfo, !VarSet, !VarTypes, !RttiVarMaps) :- - type_util__type_ctor_module(ModuleInfo, TypeCtor, ModuleName), - type_util__type_ctor_name(ModuleInfo, TypeCtor, TypeName), + type_util.type_ctor_module(ModuleInfo, TypeCtor, ModuleName), + type_util.type_ctor_name(ModuleInfo, TypeCtor, TypeName), TypeCtor = _ - Arity, ConsId = type_ctor_info_const(ModuleName, TypeName, Arity), TypeInfoTerm = functor(ConsId, no, []), @@ -2747,7 +2742,7 @@ init_const_type_ctor_info_var(Type, TypeCtor, TypeCtorInfoVar, Unification, UnifyContext), % Create a goal_info for the unification. - set__list_to_set([TypeCtorInfoVar], NonLocals), + set.list_to_set([TypeCtorInfoVar], NonLocals), instmap_delta_from_assoc_list([TypeCtorInfoVar - ground(shared, none)], InstmapDelta), goal_info_init(NonLocals, InstmapDelta, det, purity_pure, GoalInfo), @@ -2764,10 +2759,10 @@ make_head_vars([TypeVar | TypeVars], TypeVarSet, TypeInfoVars, !Info) :- get_tvar_kind(!.Info ^ tvar_kinds, TypeVar, Kind), Type = variable(TypeVar, Kind), new_type_info_var(Type, type_info, Var, !Info), - ( varset__search_name(TypeVarSet, TypeVar, TypeVarName) -> + ( varset.search_name(TypeVarSet, TypeVar, TypeVarName) -> poly_info_get_varset(!.Info, VarSet0), - string__append("TypeInfo_for_", TypeVarName, VarName), - varset__name_var(VarSet0, Var, VarName, VarSet), + string.append("TypeInfo_for_", TypeVarName, VarName), + varset.name_var(VarSet0, Var, VarName, VarSet), poly_info_set_varset(VarSet, !Info) ; true @@ -2789,9 +2784,9 @@ new_type_info_var(Type, Kind, Var, !Info) :- new_type_info_var_raw(Type, Kind, Var, !VarSet, !VarTypes, !RttiVarMaps) :- % Introduce new variable. - varset__new_var(!.VarSet, Var, !:VarSet), - term__var_to_int(Var, VarNum), - string__int_to_string(VarNum, VarNumStr), + varset.new_var(!.VarSet, Var, !:VarSet), + term.var_to_int(Var, VarNum), + string.int_to_string(VarNum, VarNumStr), ( Kind = type_info, Prefix = typeinfo_prefix, @@ -2803,9 +2798,9 @@ new_type_info_var_raw(Type, Kind, Var, !VarSet, !VarTypes, !RttiVarMaps) :- % XXX Perhaps we should record the variables holding % type_ctor_infos in the rtti_varmaps somewhere. ), - string__append(Prefix, VarNumStr, Name), - varset__name_var(!.VarSet, Var, Name, !:VarSet), - map__set(!.VarTypes, Var, type_info_type, !:VarTypes). + string.append(Prefix, VarNumStr, Name), + varset.name_var(!.VarSet, Var, Name, !:VarSet), + map.set(!.VarTypes, Var, type_info_type, !:VarTypes). :- func typeinfo_prefix = string. @@ -2860,11 +2855,11 @@ gen_extract_type_info(TypeVar, Kind, TypeClassInfoVar, Index, ModuleInfo, Type = variable(TypeVar, Kind), new_type_info_var_raw(Type, type_info, TypeInfoVar, !VarSet, !VarTypes, !RttiVarMaps), - goal_util__generate_simple_call(mercury_private_builtin_module, + goal_util.generate_simple_call(mercury_private_builtin_module, "type_info_from_typeclass_info", predicate, only_mode, det, [TypeClassInfoVar, IndexVar, TypeInfoVar], [], [TypeInfoVar - ground(shared, none)], ModuleInfo, - term__context_init, CallGoal), + term.context_init, CallGoal), Goals = [IndexGoal, CallGoal]. %-----------------------------------------------------------------------------% @@ -2891,7 +2886,7 @@ gen_extract_type_info(TypeVar, Kind, TypeClassInfoVar, Index, ModuleInfo, make_typeclass_info_head_vars(RecordLocns, Constraints, ExtraHeadVars, !Info) :- - list__map_foldl(make_typeclass_info_head_var(RecordLocns), Constraints, + list.map_foldl(make_typeclass_info_head_var(RecordLocns), Constraints, ExtraHeadVars, !Info). :- pred make_typeclass_info_head_var(record_type_info_locns::in, @@ -2925,20 +2920,20 @@ record_constraint_type_info_locns(Constraint, ExtraHeadVar, !Info) :- % Work out how many superclasses the class has. Constraint = constraint(ClassName, ClassTypes), - list__length(ClassTypes, ClassArity), + list.length(ClassTypes, ClassArity), ClassId = class_id(ClassName, ClassArity), module_info_get_class_table(ModuleInfo, ClassTable), - map__lookup(ClassTable, ClassId, ClassDefn), + map.lookup(ClassTable, ClassId, ClassDefn), SuperClasses = ClassDefn ^ class_supers, - list__length(SuperClasses, NumSuperClasses), + list.length(SuperClasses, NumSuperClasses), % Find all the type variables in the constraint, and remember what % index they appear in in the typeclass info. % The first type_info will be just after the superclass infos. First = NumSuperClasses + 1, - prog_type__vars_list(ClassTypes, ClassTypeVars0), - list__map_foldl(make_index, ClassTypeVars0, ClassTypeVars, First, _), + prog_type.vars_list(ClassTypes, ClassTypeVars0), + list.map_foldl(make_index, ClassTypeVars0, ClassTypeVars, First, _), % Work out which type variables we haven't seen before, or which we % assumed earlier would be produced in a type_info (this can happen for @@ -2948,25 +2943,24 @@ record_constraint_type_info_locns(Constraint, ExtraHeadVar, !Info) :- poly_info_get_rtti_varmaps(!.Info, RttiVarMaps0), IsNew = (pred(TypeVar0::in) is semidet :- TypeVar0 = TypeVar - _Index, - ( - rtti_search_type_info_locn(RttiVarMaps0, TypeVar, TypeInfoLocn) - -> + ( rtti_search_type_info_locn(RttiVarMaps0, TypeVar, TypeInfoLocn) -> TypeInfoLocn = type_info(_) ; true ) ), - list__filter(IsNew, ClassTypeVars, NewClassTypeVars), + list.filter(IsNew, ClassTypeVars, NewClassTypeVars), % Make an entry in the TypeInfo locations map for each new type % variable. The type variable can be found at the previously calculated % offset with the new typeclass_info. - MakeEntry = (pred(IndexedTypeVar::in, R0::in, R::out) is det :- + MakeEntry = + (pred(IndexedTypeVar::in, R0::in, R::out) is det :- IndexedTypeVar = TheTypeVar - Index, Location = typeclass_info(ExtraHeadVar, Index), rtti_set_type_info_locn(TheTypeVar, Location, R0, R) ), - list__foldl(MakeEntry, NewClassTypeVars, RttiVarMaps0, RttiVarMaps), + list.foldl(MakeEntry, NewClassTypeVars, RttiVarMaps0, RttiVarMaps), poly_info_set_rtti_varmaps(RttiVarMaps, !Info). :- pred make_index(T::in, pair(T, int)::out, int::in, int::out) is det. @@ -2982,11 +2976,11 @@ new_typeclass_info_var(Constraint, ClassString, Var, !Info) :- poly_info_get_rtti_varmaps(!.Info, RttiVarMaps0), % Introduce new variable. - varset__new_var(VarSet0, Var, VarSet1), - string__append("TypeClassInfo_for_", ClassString, Name), - varset__name_var(VarSet1, Var, Name, VarSet), + varset.new_var(VarSet0, Var, VarSet1), + string.append("TypeClassInfo_for_", ClassString, Name), + varset.name_var(VarSet1, Var, Name, VarSet), build_typeclass_info_type(Constraint, DictionaryType), - map__set(VarTypes0, Var, DictionaryType, VarTypes), + map.set(VarTypes0, Var, DictionaryType, VarTypes), rtti_det_insert_typeclass_info_var(Constraint, Var, RttiVarMaps0, RttiVarMaps), @@ -3034,8 +3028,7 @@ build_type_info_type(Type, TypeInfoType) :- ), build_type_info_type_2(Kind, TypeInfoType). -:- pred build_type_info_type_2(type_info_kind::in, mer_type::out) - is det. +:- pred build_type_info_type_2(type_info_kind::in, mer_type::out) is det. build_type_info_type_2(Kind, TypeInfoType) :- ( @@ -3078,22 +3071,22 @@ is_typeclass_info_manipulator(ModuleInfo, PredId, TypeClassManipulator) :- expand_class_method_bodies(!ModuleInfo) :- module_info_get_class_table(!.ModuleInfo, Classes), module_info_get_name(!.ModuleInfo, ModuleName), - map__keys(Classes, ClassIds0), + map.keys(Classes, ClassIds0), module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, user_guided_type_specialization, + globals.lookup_bool_option(Globals, user_guided_type_specialization, TypeSpec), ( TypeSpec = no, % Don't expand classes from other modules. - list__filter(class_id_is_from_given_module(ModuleName), + list.filter(class_id_is_from_given_module(ModuleName), ClassIds0, ClassIds) ; TypeSpec = yes, ClassIds = ClassIds0 ), - map__apply_to_list(ClassIds, Classes, ClassDefns), - list__foldl(expand_bodies, ClassDefns, !ModuleInfo). + map.apply_to_list(ClassIds, Classes, ClassDefns), + list.foldl(expand_bodies, ClassDefns, !ModuleInfo). :- pred class_id_is_from_given_module(module_name::in, class_id::in) is semidet. @@ -3106,16 +3099,16 @@ class_id_is_from_given_module(ModuleName, ClassId) :- expand_bodies(HLDSClassDefn, !ModuleInfo) :- Interface = HLDSClassDefn ^ class_hlds_interface, - list__foldl2(expand_one_body, Interface, 1, _, !ModuleInfo). + list.foldl2(expand_one_body, Interface, 1, _, !ModuleInfo). :- pred expand_one_body(hlds_class_proc::in, int::in, int::out, module_info::in, module_info::out) is det. expand_one_body(hlds_class_proc(PredId, ProcId), !ProcNum, !ModuleInfo) :- module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), % Find which of the constraints on the pred is the one introduced % because it is a class method. @@ -3134,9 +3127,10 @@ expand_one_body(hlds_class_proc(PredId, ProcId), !ProcNum, !ModuleInfo) :- proc_info_headvars(ProcInfo0, HeadVars0), proc_info_argmodes(ProcInfo0, Modes0), proc_info_declared_determinism(ProcInfo0, MaybeDetism0), - ( MaybeDetism0 = yes(DetismPrime) -> - Detism = DetismPrime + ( + MaybeDetism0 = yes(Detism) ; + MaybeDetism0 = no, % Omitting the determinism for a method is not allowed. But make_hlds % will have already detected and reported the error. So here we can % just pick some value at random; hopefully something that won't cause @@ -3151,18 +3145,18 @@ expand_one_body(hlds_class_proc(PredId, ProcId), !ProcNum, !ModuleInfo) :- % the class_method_call. That variable becomes the "dictionary" variable % for the class_method_call. (cf. the closure for a higher order call). ( - list__nth_member_search(HeadVars0, TypeClassInfoVar, N), - delete_nth(HeadVars0, N, HeadVars1), - delete_nth(Modes0, N, Modes1) + list.nth_member_search(HeadVars0, TypeClassInfoVar, N), + delete_nth(HeadVars0, N, HeadVarsPrime), + delete_nth(Modes0, N, ModesPrime) -> - HeadVars = HeadVars1, - Modes = Modes1 + HeadVars = HeadVarsPrime, + Modes = ModesPrime ; unexpected(this_file, "expand_one_body: typeclass_info var not found") ), InstanceConstraint = constraint(ClassName, InstanceArgs), - list__length(InstanceArgs, InstanceArity), + list.length(InstanceArgs, InstanceArity), pred_info_get_call_id(PredInfo0, CallId), BodyGoalExpr = generic_call( class_method(TypeClassInfoVar, !.ProcNum, @@ -3170,7 +3164,7 @@ expand_one_body(hlds_class_proc(PredId, ProcId), !ProcNum, !ModuleInfo) :- HeadVars, Modes, Detism), % Make the goal info for the call. - set__list_to_set(HeadVars0, NonLocals), + set.list_to_set(HeadVars0, NonLocals), instmap_delta_from_mode_list(HeadVars0, Modes0, !.ModuleInfo, InstmapDelta), pred_info_get_purity(PredInfo0, Purity), @@ -3178,7 +3172,7 @@ expand_one_body(hlds_class_proc(PredId, ProcId), !ProcNum, !ModuleInfo) :- BodyGoal = BodyGoalExpr - GoalInfo, proc_info_set_goal(BodyGoal, ProcInfo0, ProcInfo), - map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable), + map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo1), ( pred_info_is_imported(PredInfo1) -> pred_info_set_import_status(opt_imported, PredInfo1, PredInfo) @@ -3186,7 +3180,7 @@ expand_one_body(hlds_class_proc(PredId, ProcId), !ProcNum, !ModuleInfo) :- PredInfo = PredInfo1 ), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo), !:ProcNum = !.ProcNum + 1. @@ -3208,7 +3202,7 @@ delete_nth([X | Xs], N0, Result) :- get_constrained_vars(Constraint) = CVars :- Constraint = constraint(_, CTypes), - prog_type__vars_list(CTypes, CVars). + prog_type.vars_list(CTypes, CVars). %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% @@ -3351,5 +3345,5 @@ poly_info_set_module_info(ModuleInfo, PI, PI ^ module_info := ModuleInfo). this_file = "polymorphism.m". %---------------------------------------------------------------------------% -:- end_module check_hlds__polymorphism. +:- end_module check_hlds.polymorphism. %---------------------------------------------------------------------------% diff --git a/compiler/post_typecheck.m b/compiler/post_typecheck.m index 98b86f719..fbabb1982 100644 --- a/compiler/post_typecheck.m +++ b/compiler/post_typecheck.m @@ -33,7 +33,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__post_typecheck. +:- module check_hlds.post_typecheck. :- interface. :- import_module hlds.hlds_goal. @@ -215,10 +215,10 @@ check_type_bindings(ModuleInfo, PredId, !PredInfo, ReportErrs, NumErrors, UnprovenConstraints0), UnprovenConstraints0 = [_ | _] -> - list__sort_and_remove_dups(UnprovenConstraints0, UnprovenConstraints), + list.sort_and_remove_dups(UnprovenConstraints0, UnprovenConstraints), report_unsatisfied_constraints(UnprovenConstraints, PredId, !.PredInfo, ModuleInfo, !IO), - list__length(UnprovenConstraints, NumErrors) + list.length(UnprovenConstraints, NumErrors) ; NumErrors = 0 ), @@ -227,8 +227,8 @@ check_type_bindings(ModuleInfo, PredId, !PredInfo, ReportErrs, NumErrors, pred_info_get_head_type_params(!.PredInfo, HeadTypeParams), clauses_info_varset(ClausesInfo0, VarSet), clauses_info_vartypes(ClausesInfo0, VarTypesMap0), - map__to_assoc_list(VarTypesMap0, VarTypesList), - set__init(Set0), + map.to_assoc_list(VarTypesMap0, VarTypesList), + set.init(Set0), check_type_bindings_2(VarTypesList, HeadTypeParams, [], Errs, Set0, Set), ( Errs = [] @@ -260,12 +260,12 @@ check_type_bindings(ModuleInfo, PredId, !PredInfo, ReportErrs, NumErrors, check_type_bindings_2([], _, !Errs, !Set). check_type_bindings_2([Var - Type | VarTypes], HeadTypeParams, !Errs, !Set) :- - prog_type__vars(Type, TVars), - set__list_to_set(TVars, TVarsSet0), - set__delete_list(TVarsSet0, HeadTypeParams, TVarsSet1), - ( \+ set__empty(TVarsSet1) -> + prog_type.vars(Type, TVars), + set.list_to_set(TVars, TVarsSet0), + set.delete_list(TVarsSet0, HeadTypeParams, TVarsSet1), + ( \+ set.empty(TVarsSet1) -> !:Errs = [Var - Type | !.Errs], - set__union(!.Set, TVarsSet1, !:Set) + set.union(!.Set, TVarsSet1, !:Set) ; true ), @@ -282,9 +282,9 @@ bind_type_vars_to_void(UnboundTypeVarsSet, !VarTypes, !Proofs, % Create a substitution that maps all of the unbound type variables % to `void'. MapToVoid = (pred(TVar::in, Subst0::in, Subst::out) is det :- - map__det_insert(Subst0, TVar, void_type, Subst) + map.det_insert(Subst0, TVar, void_type, Subst) ), - set__fold(MapToVoid, UnboundTypeVarsSet, map__init, VoidSubst), + set.fold(MapToVoid, UnboundTypeVarsSet, map.init, VoidSubst), % Then apply the substitution we just created to the various maps. apply_subst_to_vartypes(VoidSubst, !VarTypes), @@ -348,29 +348,29 @@ report_unresolved_type_warning(Errs, PredId, PredInfo, ModuleInfo, VarSet, pred_info_typevarset(PredInfo, TypeVarSet), pred_info_context(PredInfo, Context), - prog_out__write_context(Context, !IO), - io__write_string("In ", !IO), - hlds_out__write_pred_id(ModuleInfo, PredId, !IO), - io__write_string(":\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string("In ", !IO), + hlds_out.write_pred_id(ModuleInfo, PredId, !IO), + io.write_string(":\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" warning: unresolved polymorphism.\n", !IO), - prog_out__write_context(Context, !IO), + prog_out.write_context(Context, !IO), + io.write_string(" warning: unresolved polymorphism.\n", !IO), + prog_out.write_context(Context, !IO), ( Errs = [_] -> - io__write_string(" The variable with an unbound type was:\n", !IO) + io.write_string(" The variable with an unbound type was:\n", !IO) ; - io__write_string(" The variables with unbound types were:\n", !IO) + io.write_string(" The variables with unbound types were:\n", !IO) ), write_type_var_list(Errs, Context, VarSet, TypeVarSet, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" The unbound type variable(s) will be implicitly\n", + prog_out.write_context(Context, !IO), + io.write_string(" The unbound type variable(s) will be implicitly\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" bound to the builtin type `void'.\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + prog_out.write_context(Context, !IO), + io.write_string(" bound to the builtin type `void'.\n", !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - io__write_strings([ + io.write_strings([ "\tThe body of the clause contains a call to a polymorphic predicate,\n", "\tbut I can't determine which version should be called,\n", "\tbecause the type variables listed above didn't get bound.\n", @@ -389,12 +389,12 @@ report_unresolved_type_warning(Errs, PredId, PredInfo, ModuleInfo, VarSet, write_type_var_list([], _, _, _, !IO). write_type_var_list([Var - Type | Rest], Context, VarSet, TVarSet, !IO) :- - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), mercury_output_var(Var, VarSet, no, !IO), - io__write_string(": ", !IO), + io.write_string(": ", !IO), mercury_output_type(TVarSet, no, Type, !IO), - io__nl(!IO), + io.nl(!IO), write_type_var_list(Rest, Context, VarSet, TVarSet, !IO). %-----------------------------------------------------------------------------% @@ -411,7 +411,7 @@ resolve_pred_overloading(Args0, CallerPredInfo, ModuleInfo, !PredName, pred_info_get_markers(CallerPredInfo, Markers), pred_info_clauses_info(CallerPredInfo, ClausesInfo), clauses_info_vartypes(ClausesInfo, VarTypes), - map__apply_to_list(Args0, VarTypes, ArgTypes), + map.apply_to_list(Args0, VarTypes, ArgTypes), resolve_pred_overloading(ModuleInfo, Markers, ArgTypes, TVarSet, !PredName, !:PredId) ; @@ -463,7 +463,7 @@ finish_imported_pred_no_io(ModuleInfo, Errors, !PredInfo) :- pred_info_clauses_info(!.PredInfo, ClausesInfo0), clauses_info_headvars(ClausesInfo0, HeadVars), pred_info_arg_types(!.PredInfo, ArgTypes), - map__from_corresponding_lists(HeadVars, ArgTypes, VarTypes), + map.from_corresponding_lists(HeadVars, ArgTypes, VarTypes), clauses_info_set_vartypes(VarTypes, ClausesInfo0, ClausesInfo), pred_info_set_clauses_info(ClausesInfo, !PredInfo) ), @@ -491,7 +491,7 @@ finish_promise(PromiseType, PromiseId, !Module, !IO) :- % to any local symbols. module_info_pred_info(!.Module, PromiseId, PredInfo), ( pred_info_is_exported(PredInfo) -> - assertion__in_interface_check(Goal, PredInfo, !Module, !IO) + assertion.in_interface_check(Goal, PredInfo, !Module, !IO) ; true ). @@ -511,8 +511,8 @@ store_promise(PromiseType, PromiseId, !Module, Goal) :- assertion_table_add_assertion(PromiseId, AssertionId, AssertTable0, AssertTable), module_info_set_assertion_table(AssertTable, !Module), - assertion__goal(AssertionId, !.Module, Goal), - assertion__record_preds_used_in(Goal, AssertionId, !Module) + assertion.goal(AssertionId, !.Module, Goal), + assertion.record_preds_used_in(Goal, AssertionId, !Module) ; % Case for exclusivity. ( @@ -524,7 +524,7 @@ store_promise(PromiseType, PromiseId, !Module, Goal) :- promise_ex_goal(PromiseId, !.Module, Goal), predids_from_goal(Goal, PredIds), module_info_get_exclusive_table(!.Module, Table0), - list__foldl(exclusive_table_add(PromiseId), PredIds, Table0, Table), + list.foldl(exclusive_table_add(PromiseId), PredIds, Table0, Table), module_info_set_exclusive_table(Table, !Module) ; % Case for exhaustiveness -- XXX not yet implemented. @@ -540,9 +540,9 @@ promise_ex_goal(ExclusiveDecl, Module, Goal) :- pred_info_clauses_info(PredInfo, ClausesInfo), clauses_info_clauses_only(ClausesInfo, Clauses), ( Clauses = [clause(_ProcIds, Goal0, _Lang, _Context)] -> - assertion__normalise_goal(Goal0, Goal) + assertion.normalise_goal(Goal0, Goal) ; - unexpected(this_file, "promise_ex__goal: not an promise") + unexpected(this_file, "promise_ex.goal: not an promise") ). %-----------------------------------------------------------------------------% @@ -556,7 +556,7 @@ check_type_of_main(PredInfo, !IO) :- pred_info_orig_arity(PredInfo) = 2, pred_info_is_exported(PredInfo) -> - % Check that the arguments of main/2 have type `io__state'. + % Check that the arguments of main/2 have type `io.state'. pred_info_arg_types(PredInfo, ArgTypes), ( ArgTypes = [Arg1, Arg2], @@ -566,10 +566,10 @@ check_type_of_main(PredInfo, !IO) :- true ; pred_info_context(PredInfo, Context), - error_util__write_error_pieces(Context, 0, + error_util.write_error_pieces(Context, 0, [words("Error: arguments of main/2"), words("must have type `io.state'.")], !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ) ; true @@ -598,10 +598,10 @@ propagate_types_into_modes(ModuleInfo, ErrorProcs, !PredInfo) :- proc_table::in, proc_table::out) is det. propagate_types_into_proc_modes(_, [], _, - ErrorProcs, list__reverse(ErrorProcs), !Procs). + ErrorProcs, list.reverse(ErrorProcs), !Procs). propagate_types_into_proc_modes(ModuleInfo, [ProcId | ProcIds], ArgTypes, !ErrorProcs, !Procs) :- - map__lookup(!.Procs, ProcId, ProcInfo0), + map.lookup(!.Procs, ProcId, ProcInfo0), proc_info_argmodes(ProcInfo0, ArgModes0), propagate_types_into_mode_list(ModuleInfo, ArgTypes, ArgModes0, ArgModes), @@ -614,7 +614,7 @@ propagate_types_into_proc_modes(ModuleInfo, [ProcId | ProcIds], ArgTypes, !:ErrorProcs = [ProcId | !.ErrorProcs] ; proc_info_set_argmodes(ArgModes, ProcInfo0, ProcInfo), - svmap__det_update(ProcId, ProcInfo, !Procs) + svmap.det_update(ProcId, ProcInfo, !Procs) ), propagate_types_into_proc_modes(ModuleInfo, ProcIds, ArgTypes, !ErrorProcs, !Procs). @@ -629,7 +629,7 @@ report_unbound_inst_vars(ModuleInfo, PredId, ErrorProcs, !PredInfo, !IO) :- ; ErrorProcs = [_ | _], pred_info_procedures(!.PredInfo, ProcTable0), - list__foldl2(report_unbound_inst_var_error(ModuleInfo, PredId), + list.foldl2(report_unbound_inst_var_error(ModuleInfo, PredId), ErrorProcs, ProcTable0, ProcTable, !IO), pred_info_set_procedures(ProcTable, !PredInfo) ). @@ -640,17 +640,17 @@ report_unbound_inst_vars(ModuleInfo, PredId, ErrorProcs, !PredInfo, !IO) :- report_unbound_inst_var_error(ModuleInfo, PredId, ProcId, Procs0, Procs, !IO) :- - map__lookup(Procs0, ProcId, ProcInfo), + map.lookup(Procs0, ProcId, ProcInfo), unbound_inst_var_error(PredId, ProcInfo, ModuleInfo, !IO), % delete this mode, to avoid internal errors - map__det_remove(Procs0, ProcId, _, Procs). + map.det_remove(Procs0, ProcId, _, Procs). :- pred unbound_inst_var_error(pred_id::in, proc_info::in, module_info::in, io::di, io::uo) is det. unbound_inst_var_error(PredId, ProcInfo, ModuleInfo, !IO) :- proc_info_context(ProcInfo, Context), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), Pieces = [words("In mode declaration for")] ++ describe_one_pred_name(ModuleInfo, should_not_module_qualify, PredId) ++ [suffix(":"), nl, @@ -709,9 +709,9 @@ check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId1, [ProcId | ProcIds], Removed, !PredInfo, !IO) :- ( modes_are_indistinguishable(ProcId, ProcId1, !.PredInfo, ModuleInfo) -> pred_info_import_status(!.PredInfo, Status), - globals__io_lookup_bool_option(intermodule_optimization, + globals.io_lookup_bool_option(intermodule_optimization, Intermod, !IO), - globals__io_lookup_bool_option(make_optimization_interface, + globals.io_lookup_bool_option(make_optimization_interface, MakeOptInt, !IO), ( % With `--intermodule-optimization' we can read @@ -742,8 +742,8 @@ check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId1, resolve_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, GoalInfo0, ModuleInfo, !PredInfo, !VarTypes, !VarSet, Goal) :- - map__lookup(!.VarTypes, X0, TypeOfX), - list__length(ArgVars0, Arity), + map.lookup(!.VarTypes, X0, TypeOfX), + list.length(ArgVars0, Arity), ( % Is the function symbol apply/N or ''/N, representing a higher-order % function call? Or the impure/semipure equivalents impure_apply/N @@ -761,7 +761,7 @@ resolve_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, % Convert the higher-order function call (apply/N) into a higher-order % predicate call (i.e., replace `X = apply(F, A, B, C)' % with `call(F, A, B, C, X)') - list__append(FuncArgVars, [X0], ArgVars), + list.append(FuncArgVars, [X0], ArgVars), Modes = [], Det = erroneous, adjust_func_arity(function, Arity, FullArity), @@ -801,8 +801,8 @@ resolve_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, % which subsume the actual argument/return types of this function call, % and which have universal constraints consistent with what we expect. pred_info_typevarset(!.PredInfo, TVarSet), - map__apply_to_list(ArgVars0, !.VarTypes, ArgTypes0), - list__append(ArgTypes0, [TypeOfX], ArgTypes), + map.apply_to_list(ArgVars0, !.VarTypes, ArgTypes0), + list.append(ArgTypes0, [TypeOfX], ArgTypes), pred_info_get_constraint_map(!.PredInfo, ConstraintMap), goal_info_get_goal_path(GoalInfo0, GoalPath), ConstraintSearch = search_hlds_constraint_list(ConstraintMap, unproven, @@ -814,7 +814,7 @@ resolve_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, % replace `X = f(A, B, C)' with `f(A, B, C, X)'. % ProcId = invalid_proc_id, - list__append(ArgVars0, [X0], ArgVars), + list.append(ArgVars0, [X0], ArgVars), FuncCallUnifyContext = call_unify_context(X0, functor(ConsId0, no, ArgVars0), UnifyContext), FuncCall = call(PredId, ProcId, ArgVars, not_builtin, @@ -833,7 +833,7 @@ resolve_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, \+ pred_info_is_field_access_function(ModuleInfo, !.PredInfo), % Find the pred_id of the constant. - map__apply_to_list(ArgVars0, !.VarTypes, ArgTypes0), + map.apply_to_list(ArgVars0, !.VarTypes, ArgTypes0), AllArgTypes = ArgTypes0 ++ HOArgTypes, pred_info_typevarset(!.PredInfo, TVarSet), pred_info_get_markers(!.PredInfo, Markers), @@ -864,7 +864,7 @@ resolve_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, % otherwise there would have been an error reported for unresolved % overloading. pred_info_typevarset(!.PredInfo, TVarSet), - map__apply_to_list(ArgVars0, !.VarTypes, ArgTypes0), + map.apply_to_list(ArgVars0, !.VarTypes, ArgTypes0), \+ find_matching_constructor(ModuleInfo, TVarSet, ConsId0, TypeOfX, ArgTypes0) -> @@ -897,19 +897,19 @@ resolve_unify_functor(X0, ConsId0, ArgVars0, Mode0, Unification0, UnifyContext, find_matching_constructor(ModuleInfo, TVarSet, ConsId, Type, ArgTypes) :- type_to_ctor_and_args(Type, TypeCtor, _), module_info_get_cons_table(ModuleInfo, ConsTable), - map__search(ConsTable, ConsId, ConsDefns), - list__member(ConsDefn, ConsDefns), + map.search(ConsTable, ConsId, ConsDefns), + list.member(ConsDefn, ConsDefns), % Overloading resolution ignores the class constraints. ConsDefn = hlds_cons_defn(ConsExistQVars, _, ConsArgs, ConsTypeCtor, _), ConsTypeCtor = TypeCtor, module_info_get_type_table(ModuleInfo, Types), - map__search(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_tvarset(TypeDefn, TypeTVarSet), - hlds_data__get_type_defn_kind_map(TypeDefn, TypeKindMap), + map.search(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_tvarset(TypeDefn, TypeTVarSet), + hlds_data.get_type_defn_kind_map(TypeDefn, TypeKindMap), - assoc_list__values(ConsArgs, ConsArgTypes), + assoc_list.values(ConsArgs, ConsArgTypes), arg_type_list_subsumes(TVarSet, ArgTypes, TypeTVarSet, TypeKindMap, ConsExistQVars, ConsArgTypes). @@ -951,7 +951,7 @@ finish_field_access_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, translate_get_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, FieldName, UnifyContext, FieldVar, TermInputVar, OldGoalInfo, GoalExpr) :- - map__lookup(!.VarTypes, TermInputVar, TermType), + map.lookup(!.VarTypes, TermInputVar, TermType), get_constructor_containing_field(ModuleInfo, TermType, FieldName, ConsId, FieldNumber), @@ -969,8 +969,8 @@ translate_get_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, FieldName, % by typecheck.m because the result can't be well-typed). ( ExistQVars = [_ | _], - map__lookup(!.VarTypes, FieldVar, FieldType), - list__index1_det(ArgTypes0, FieldNumber, FieldArgType), + map.lookup(!.VarTypes, FieldVar, FieldType), + list.index1_det(ArgTypes0, FieldNumber, FieldArgType), ( type_list_subsumes([FieldArgType], [FieldType], FieldSubst) -> apply_rec_subst_to_type_list(FieldSubst, ArgTypes0, ArgTypes) ; @@ -988,7 +988,7 @@ translate_get_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, FieldName, make_new_vars(TypesBeforeField, VarsBeforeField, !VarTypes, !VarSet), make_new_vars(TypesAfterField, VarsAfterField, !VarTypes, !VarSet), - list__append(VarsBeforeField, [FieldVar | VarsAfterField], ArgVars), + list.append(VarsBeforeField, [FieldVar | VarsAfterField], ArgVars), goal_info_get_nonlocals(OldGoalInfo, RestrictNonLocals), create_atomic_unification_with_nonlocals(TermInputVar, @@ -1006,7 +1006,7 @@ translate_get_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, FieldName, translate_set_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, FieldName, UnifyContext, FieldVar, TermInputVar, TermOutputVar, OldGoalInfo, Goal) :- - map__lookup(!.VarTypes, TermInputVar, TermType), + map.lookup(!.VarTypes, TermInputVar, TermType), get_constructor_containing_field(ModuleInfo, TermType, FieldName, ConsId0, FieldNumber), @@ -1023,11 +1023,11 @@ translate_set_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, make_new_vars(TypesAfterField, VarsAfterField, !VarTypes, !VarSet), % Build a goal to deconstruct the input. - list__append(VarsBeforeField, [SingletonFieldVar | VarsAfterField], + list.append(VarsBeforeField, [SingletonFieldVar | VarsAfterField], DeconstructArgs), goal_info_get_nonlocals(OldGoalInfo, OldNonLocals), - list__append(VarsBeforeField, VarsAfterField, NonLocalArgs), - set__insert_list(OldNonLocals, NonLocalArgs, + list.append(VarsBeforeField, VarsAfterField, NonLocalArgs), + set.insert_list(OldNonLocals, NonLocalArgs, DeconstructRestrictNonLocals), create_atomic_unification_with_nonlocals(TermInputVar, @@ -1036,10 +1036,8 @@ translate_set_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, UnifyContext, DeconstructGoal), % Build a goal to construct the output. - list__append(VarsBeforeField, [FieldVar | VarsAfterField], - ConstructArgs), - set__insert_list(OldNonLocals, NonLocalArgs, - ConstructRestrictNonLocals), + list.append(VarsBeforeField, [FieldVar | VarsAfterField], ConstructArgs), + set.insert_list(OldNonLocals, NonLocalArgs, ConstructRestrictNonLocals), % If the cons_id is existentially quantified, add a `new' prefix % so that polymorphism.m adds the appropriate type_infos. @@ -1052,8 +1050,7 @@ translate_set_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, remove_new_prefix(ConsName, ConsName0), ConsId = cons(ConsName, ConsArity) ; - unexpected(this_file, - "translate_set_function: invalid cons_id") + unexpected(this_file, "translate_set_function: invalid cons_id") ) ), @@ -1075,10 +1072,10 @@ translate_set_function(ModuleInfo, !PredInfo, !VarTypes, !VarSet, get_cons_id_arg_types_adding_existq_tvars(ModuleInfo, GoalPath, ConsId, TermType, ActualArgTypes, ActualExistQVars, !PredInfo) :- % Split the list of argument types at the named field. - type_util__get_type_and_cons_defn(ModuleInfo, TermType, ConsId, + type_util.get_type_and_cons_defn(ModuleInfo, TermType, ConsId, TypeDefn, ConsDefn), ConsDefn = hlds_cons_defn(ConsExistQVars, ConsConstraints, ConsArgs, _, _), - assoc_list__values(ConsArgs, ConsArgTypes), + assoc_list.values(ConsArgs, ConsArgTypes), ( ConsExistQVars = [], @@ -1087,11 +1084,11 @@ get_cons_id_arg_types_adding_existq_tvars(ModuleInfo, GoalPath, ConsId, ; ConsExistQVars = [_ | _], % Rename apart the existentially quantified type variables. - list__length(ConsExistQVars, NumExistQVars), + list.length(ConsExistQVars, NumExistQVars), pred_info_typevarset(!.PredInfo, TVarSet0), - varset__new_vars(TVarSet0, NumExistQVars, ParentExistQVars, TVarSet), + varset.new_vars(TVarSet0, NumExistQVars, ParentExistQVars, TVarSet), pred_info_set_typevarset(TVarSet, !PredInfo), - map__from_corresponding_lists(ConsExistQVars, ParentExistQVars, + map.from_corresponding_lists(ConsExistQVars, ParentExistQVars, ConsToParentRenaming), apply_variable_renaming_to_type_list(ConsToParentRenaming, ConsArgTypes, ParentArgTypes), @@ -1104,7 +1101,7 @@ get_cons_id_arg_types_adding_existq_tvars(ModuleInfo, GoalPath, ConsId, % so that the varmaps remain meaningful. % pred_info_get_constraint_map(!.PredInfo, ConstraintMap), - list__length(ConsConstraints, NumConstraints), + list.length(ConsConstraints, NumConstraints), lookup_hlds_constraint_list(ConstraintMap, assumed, GoalPath, NumConstraints, ActualConstraints), constraint_list_subsumes_det(ParentConstraints, ActualConstraints, @@ -1114,7 +1111,7 @@ get_cons_id_arg_types_adding_existq_tvars(ModuleInfo, GoalPath, ConsId, % The kinds will be ignored when the types are converted back % to tvars. - map__init(KindMap), + map.init(KindMap), apply_rec_subst_to_tvar_list(KindMap, ExistTSubst, ParentExistQVars, ActualExistQVarTypes), ( type_list_to_var_list(ActualExistQVarTypes, ActualExistQVars0) -> @@ -1123,9 +1120,9 @@ get_cons_id_arg_types_adding_existq_tvars(ModuleInfo, GoalPath, ConsId, unexpected(this_file, "existq_tvar bound to non-var") ) ), - hlds_data__get_type_defn_tparams(TypeDefn, TypeParams), + hlds_data.get_type_defn_tparams(TypeDefn, TypeParams), ( type_to_ctor_and_args(TermType, _, TypeArgs) -> - map__from_corresponding_lists(TypeParams, TypeArgs, UnivTSubst) + map.from_corresponding_lists(TypeParams, TypeArgs, UnivTSubst) ; unexpected(this_file, "get_cons_id_arg_types_adding_existq_tvars: " ++ @@ -1139,7 +1136,7 @@ get_cons_id_arg_types_adding_existq_tvars(ModuleInfo, GoalPath, ConsId, constraint_list_subsumes_det(ConstraintsA, ConstraintsB, Subst) :- constraint_list_get_tvars(ConstraintsB, TVarsB), - map__init(Subst0), + map.init(Subst0), ( unify_constraint_list(ConstraintsA, ConstraintsB, TVarsB, Subst0, Subst1) @@ -1165,7 +1162,7 @@ unify_constraint_list([A | As], [B | Bs], TVars, !Subst) :- split_list_at_index(Index, List, Before, At, After) :- ( - list__split_list(Index - 1, List, Before0, AtAndAfter), + list.split_list(Index - 1, List, Before0, AtAndAfter), AtAndAfter = [At0 | After0] -> Before = Before0, @@ -1192,8 +1189,8 @@ get_constructor_containing_field(ModuleInfo, TermType, FieldName, "get_constructor_containing_field: type_to_ctor_and_args failed") ), module_info_get_type_table(ModuleInfo, Types), - map__lookup(Types, TermTypeCtor, TermTypeDefn), - hlds_data__get_type_defn_body(TermTypeDefn, TermTypeBody), + map.lookup(Types, TermTypeCtor, TermTypeDefn), + hlds_data.get_type_defn_body(TermTypeDefn, TermTypeBody), ( Ctors = TermTypeBody ^ du_type_ctors -> get_constructor_containing_field_2(Ctors, FieldName, ConsId, FieldNumber) @@ -1214,7 +1211,7 @@ get_constructor_containing_field_2([Ctor | Ctors], FieldName, get_constructor_containing_field_3(CtorArgs, FieldName, 1, FieldNumber0) -> - list__length(CtorArgs, Arity), + list.length(CtorArgs, Arity), ConsId = cons(SymName, Arity), FieldNumber = FieldNumber0 ; @@ -1254,8 +1251,8 @@ create_atomic_unification_with_nonlocals(Var, RHS, OldGoalInfo, Goal0 = GoalExpr0 - GoalInfo0, % Compute the nonlocals of the goal. - set__list_to_set(VarsList, NonLocals1), - set__intersect(RestrictNonLocals, NonLocals1, NonLocals), + set.list_to_set(VarsList, NonLocals1), + set.intersect(RestrictNonLocals, NonLocals1, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo1), % Use the goal path from the original goal, so that the constraint_ids diff --git a/compiler/pragma_c_gen.m b/compiler/pragma_c_gen.m index 71989d5da..4fdaf9fc0 100644 --- a/compiler/pragma_c_gen.m +++ b/compiler/pragma_c_gen.m @@ -20,7 +20,7 @@ %---------------------------------------------------------------------------% -:- module ll_backend__pragma_c_gen. +:- module ll_backend.pragma_c_gen. :- interface. :- import_module hlds.code_model. @@ -35,14 +35,13 @@ %---------------------------------------------------------------------------% -:- pred pragma_c_gen__generate_pragma_c_code(code_model::in, +:- pred generate_pragma_c_code(code_model::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in, list(foreign_arg)::in, list(foreign_arg)::in, hlds_goal_info::in, pragma_foreign_code_impl::in, code_tree::out, code_info::in, code_info::out) is det. -:- pred pragma_c_gen__struct_name(module_name::in, string::in, int::in, - proc_id::in, string::out) is det. +:- func struct_name(module_name, string, int, proc_id) = string. % The name of the variable model_semi foreign_procs in C assign to % to indicate success or failure. Exported for llds_out.m. @@ -287,13 +286,13 @@ % The procedure prolog creates a nondet stack frame that includes space for % a struct that is saved across calls. Since the position of this struct in % the nondet stack frame is not known until the procedure prolog is created, -% which is *after* the call to pragma_c_gen__generate_pragma_c_code, the -% prolog will #define MR_ORDINARY_SLOTS as the number of ordinary slots -% in the nondet frame. From the size of the fixed portion of the nondet stack -% frame, from MR_ORDINARY_SLOTS and from the size of the save struct itself, -% one can calculate the address of the save struct itself. The epilog will -% #undef MR_ORDINARY_SLOTS. It need not do anything else, since all the normal -% epilog stuff has been done in the code above. +% which is *after* the call to generate_pragma_c_code, the prolog will #define +% MR_ORDINARY_SLOTS as the number of ordinary slots in the nondet frame. +% From the size of the fixed portion of the nondet stack frame, from +% MR_ORDINARY_SLOTS and from the size of the save struct itself, one can +% calculate the address of the save struct itself. The epilog will #undef +% MR_ORDINARY_SLOTS. It need not do anything else, since all the normal epilog +% stuff has been done in the code above. % % Unlike with ordinary pragma C codes, with nondet C codes there are never % any live variables to save at the start, except for the input variables, @@ -346,13 +345,13 @@ %---------------------------------------------------------------------------% -pragma_c_gen__generate_pragma_c_code(CodeModel, Attributes, PredId, ProcId, - Args, ExtraArgs, GoalInfo, PragmaImpl, Code, !CI) :- +generate_pragma_c_code(CodeModel, Attributes, PredId, ProcId, Args, ExtraArgs, + GoalInfo, PragmaImpl, Code, !CI) :- ( PragmaImpl = ordinary(C_Code, Context), CanOptAwayUnnamedArgs = yes, - pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, - PredId, ProcId, Args, ExtraArgs, C_Code, Context, GoalInfo, + ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, + Args, ExtraArgs, C_Code, Context, GoalInfo, CanOptAwayUnnamedArgs, Code, !CI) ; PragmaImpl = nondet(Fields, FieldsContext, First, FirstContext, @@ -360,8 +359,8 @@ pragma_c_gen__generate_pragma_c_code(CodeModel, Attributes, PredId, ProcId, expect(unify(ExtraArgs, []), this_file, "generate_pragma_c_code: extra args nondet"), CanOptAwayUnnamedArgs = yes, - pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, - PredId, ProcId, Args, Fields, FieldsContext, + nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, + Args, Fields, FieldsContext, First, FirstContext, Later, LaterContext, Treat, Shared, SharedContext, CanOptAwayUnnamedArgs, Code, !CI) ; @@ -372,22 +371,21 @@ pragma_c_gen__generate_pragma_c_code(CodeModel, Attributes, PredId, ProcId, % The imported function was generated with all arguments present. CanOptAwayUnnamedArgs = no, - pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, - PredId, ProcId, Args, ExtraArgs, C_Code, Context, GoalInfo, + ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, + Args, ExtraArgs, C_Code, Context, GoalInfo, CanOptAwayUnnamedArgs, Code, !CI) ). %---------------------------------------------------------------------------% -:- pred pragma_c_gen__ordinary_pragma_c_code(code_model::in, +:- pred ordinary_pragma_c_code(code_model::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, maybe(prog_context)::in, hlds_goal_info::in, bool::in, code_tree::out, code_info::in, code_info::out) is det. -pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, - Args, ExtraArgs, C_Code, Context, GoalInfo, CanOptAwayUnnamedArgs, - Code, !CI) :- +ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, Args, ExtraArgs, + C_Code, Context, GoalInfo, CanOptAwayUnnamedArgs, Code, !CI) :- % Extract the attributes. MayCallMercury = may_call_mercury(Attributes), ThreadSafe = thread_safe(Attributes), @@ -404,16 +402,16 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, ThreadSafe = not_thread_safe ), % First we need to get a list of input and output arguments. - ArgInfos = code_info__get_pred_proc_arginfo(!.CI, PredId, ProcId), + ArgInfos = code_info.get_pred_proc_arginfo(!.CI, PredId, ProcId), make_c_arg_list(Args, ArgInfos, OrigCArgs), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), make_extra_c_arg_list(ExtraArgs, ModuleInfo, ArgInfos, ExtraCArgs), - list__append(OrigCArgs, ExtraCArgs, CArgs), + list.append(OrigCArgs, ExtraCArgs, CArgs), pragma_select_in_args(CArgs, InCArgs), pragma_select_out_args(CArgs, OutCArgs), goal_info_get_post_deaths(GoalInfo, PostDeaths), - set__init(DeadVars0), + set.init(DeadVars0), find_dead_input_vars(InCArgs, PostDeaths, DeadVars0, DeadVars), % Generate code to . @@ -423,14 +421,14 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, ; MayCallMercury = may_call_mercury, % The C code might call back Mercury code which clobbers the succip. - code_info__succip_is_used(!CI), + code_info.succip_is_used(!CI), % The C code might call back Mercury code which clobbers the % other registers, so we need to save any live variables % (other than the output args) onto the stack. get_c_arg_list_vars(OutCArgs, OutVars), - set__list_to_set(OutVars, OutVarsSet), - code_info__save_variables(OutVarsSet, _, SaveVarsCode, !CI) + set.list_to_set(OutVars, OutVarsSet), + code_info.save_variables(OutVarsSet, _, SaveVarsCode, !CI) ), % Generate the values of input variables. @@ -443,15 +441,15 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, % finished generating the code producing the input variables. % (The forward dead variables will be dead after the pragma_c_code, % but are live during its input phase.) - code_info__make_vars_forward_dead(DeadVars, !CI), + code_info.make_vars_forward_dead(DeadVars, !CI), % Generate . make_pragma_decls(CArgs, ModuleInfo, CanOptAwayUnnamedArgs, Decls), % Generate #define MR_PROC_LABEL /* see note (5) */ % and #undef MR_PROC_LABEL. - code_info__get_pred_id(!.CI, CallerPredId), - code_info__get_proc_id(!.CI, CallerProcId), + code_info.get_pred_id(!.CI, CallerPredId), + code_info.get_proc_id(!.CI, CallerProcId), make_proc_label_hash_define(ModuleInfo, CallerPredId, CallerProcId, ProcLabelHashDefine, ProcLabelHashUndef), @@ -462,33 +460,33 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, ( MayCallMercury = will_not_call_mercury, SaveRegsComp = pragma_c_raw_code("", cannot_branch_away, - live_lvals_info(set__init)) + live_lvals_info(set.init)) ; MayCallMercury = may_call_mercury, SaveRegsComp = pragma_c_raw_code("\tMR_save_registers();\n", - cannot_branch_away, live_lvals_info(set__init)) + cannot_branch_away, live_lvals_info(set.init)) ), % Code fragments to obtain and release the global lock. ( ThreadSafe = thread_safe, ObtainLock = pragma_c_raw_code("", cannot_branch_away, - live_lvals_info(set__init)), + live_lvals_info(set.init)), ReleaseLock = pragma_c_raw_code("", cannot_branch_away, - live_lvals_info(set__init)) + live_lvals_info(set.init)) ; ThreadSafe = not_thread_safe, module_info_pred_info(ModuleInfo, PredId, PredInfo), Name = pred_info_name(PredInfo), - c_util__quote_string(Name, MangledName), + c_util.quote_string(Name, MangledName), ObtainLockStr = "\tMR_OBTAIN_GLOBAL_LOCK(""" ++ MangledName ++ """);\n", ObtainLock = pragma_c_raw_code(ObtainLockStr, cannot_branch_away, - live_lvals_info(set__init)), + live_lvals_info(set.init)), ReleaseLockStr = "\tMR_RELEASE_GLOBAL_LOCK(""" ++ MangledName ++ """);\n", ReleaseLock = pragma_c_raw_code(ReleaseLockStr, cannot_branch_away, - live_lvals_info(set__init)) + live_lvals_info(set.init)) ), % @@ -501,7 +499,7 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, CheckSuccess_Comp = pragma_c_noop, MaybeFailLabel = no ; - code_info__get_next_label(FailLabel, !CI), + code_info.get_next_label(FailLabel, !CI), CheckSuccess_Comp = pragma_c_fail_to(FailLabel), MaybeFailLabel = yes(FailLabel) ), @@ -510,18 +508,18 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, "#undef SUCCESS_INDICATOR\n" ++ "#define SUCCESS_INDICATOR " ++ pragma_succ_ind_name ++ "\n", - cannot_branch_away, live_lvals_info(set__init)), + cannot_branch_away, live_lvals_info(set.init)), UndefSuccessComp = pragma_c_raw_code( "#undef SUCCESS_INDICATOR\n" ++ "#define SUCCESS_INDICATOR MR_r1\n", - cannot_branch_away, live_lvals_info(set__init)) + cannot_branch_away, live_lvals_info(set.init)) ; CheckSuccess_Comp = pragma_c_noop, MaybeFailLabel = no, DefSuccessComp = pragma_c_raw_code("", cannot_branch_away, - live_lvals_info(set__init)), + live_lvals_info(set.init)), UndefSuccessComp = pragma_c_raw_code("", cannot_branch_away, - live_lvals_info(set__init)) + live_lvals_info(set.init)) ), % #ifndef MR_CONSERVATIVE_GC @@ -535,7 +533,7 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, RestoreRegsComp = pragma_c_raw_code( "#ifndef MR_CONSERVATIVE_GC\n\t" ++ "MR_restore_registers();\n#endif\n", - cannot_branch_away, live_lvals_info(set__init) + cannot_branch_away, live_lvals_info(set.init) ) ), @@ -552,7 +550,7 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, ; OkToDelete = yes ), - code_info__clear_all_registers(OkToDelete, !CI) + code_info.clear_all_registers(OkToDelete, !CI) ), % @@ -592,8 +590,8 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, % % ( MaybeFailLabel = yes(TheFailLabel) -> - code_info__get_next_label(SkipLabel, !CI), - code_info__generate_failure(FailCode, !CI), + code_info.get_next_label(SkipLabel, !CI), + code_info.generate_failure(FailCode, !CI), GotoSkipLabelCode = node([ goto(label(SkipLabel)) - "Skip past failure code" ]), @@ -602,7 +600,7 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, FailureCode = tree_list([GotoSkipLabelCode, FailLabelCode, FailCode, SkipLabelCode]) ; Detism = failure -> - code_info__generate_failure(FailureCode, !CI) + code_info.generate_failure(FailureCode, !CI) ; FailureCode = empty ), @@ -615,17 +613,17 @@ pragma_c_gen__ordinary_pragma_c_code(CodeModel, Attributes, PredId, ProcId, make_proc_label_hash_define(ModuleInfo, PredId, ProcId, ProcLabelHashDef, ProcLabelHashUndef) :- - ProcLabelHashDef = pragma_c_raw_code(string__append_list([ + ProcLabelHashDef = pragma_c_raw_code(string.append_list([ "#define\tMR_PROC_LABEL\t", make_proc_label_string(ModuleInfo, PredId, ProcId), "\n"]), - cannot_branch_away, live_lvals_info(set__init)), + cannot_branch_away, live_lvals_info(set.init)), ProcLabelHashUndef = pragma_c_raw_code("#undef\tMR_PROC_LABEL\n", - cannot_branch_away, live_lvals_info(set__init)). + cannot_branch_away, live_lvals_info(set.init)). :- func make_proc_label_string(module_info, pred_id, proc_id) = string. make_proc_label_string(ModuleInfo, PredId, ProcId) = ProcLabelString :- - code_util__make_entry_label(ModuleInfo, PredId, ProcId, no, CodeAddr), + code_util.make_entry_label(ModuleInfo, PredId, ProcId, no, CodeAddr), ( CodeAddr = imported(ProcLabel) -> ProcLabelString = proc_label_to_c_string(ProcLabel, yes) ; CodeAddr = label(Label) -> @@ -636,7 +634,7 @@ make_proc_label_string(ModuleInfo, PredId, ProcId) = ProcLabelString :- %-----------------------------------------------------------------------------% -:- pred pragma_c_gen__nondet_pragma_c_code(code_model::in, +:- pred nondet_pragma_c_code(code_model::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in, list(foreign_arg)::in, string::in, maybe(prog_context)::in, @@ -645,7 +643,7 @@ make_proc_label_string(ModuleInfo, PredId, ProcId) = ProcLabelString :- string::in, maybe(prog_context)::in, bool::in, code_tree::out, code_info::in, code_info::out) is det. -pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, +nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, Args, _Fields, _FieldsContext, First, FirstContext, Later, LaterContext, Treat, Shared, SharedContext, CanOptAwayUnnamedArgs, Code, !CI) :- @@ -656,9 +654,9 @@ pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, % Generate #define MR_PROC_LABEL /* see note (5) */ % and #undef MR_PROC_LABEL. - code_info__get_module_info(!.CI, ModuleInfo), - code_info__get_pred_id(!.CI, CallerPredId), - code_info__get_proc_id(!.CI, CallerProcId), + code_info.get_module_info(!.CI, ModuleInfo), + code_info.get_pred_id(!.CI, CallerPredId), + code_info.get_proc_id(!.CI, CallerProcId), make_proc_label_hash_define(ModuleInfo, CallerPredId, CallerProcId, ProcLabelDefine, ProcLabelUndef), @@ -667,7 +665,7 @@ pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, PredId, ProcId), % Get a list of input and output arguments. - ArgInfos = code_info__get_pred_proc_arginfo(!.CI, PredId, ProcId), + ArgInfos = code_info.get_pred_proc_arginfo(!.CI, PredId, ProcId), make_c_arg_list(Args, ArgInfos, CArgs), pragma_select_in_args(CArgs, InCArgs), pragma_select_out_args(CArgs, OutCArgs), @@ -683,16 +681,15 @@ pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, ModuleName = pred_info_module(PredInfo), PredName = pred_info_name(PredInfo), Arity = pred_info_orig_arity(PredInfo), - pragma_c_gen__struct_name(ModuleName, PredName, Arity, ProcId, - StructName), + StructName = struct_name(ModuleName, PredName, Arity, ProcId), SaveStructDecl = pragma_c_struct_ptr_decl(StructName, "LOCALS"), - string__format("\tLOCALS = (struct %s *) ((char *) + string.format("\tLOCALS = (struct %s *) ((char *) (MR_curfr + 1 - MR_ORDINARY_SLOTS - MR_NONDET_FIXED_SIZE) - sizeof(struct %s));\n", [s(StructName), s(StructName)], InitSaveStruct), - code_info__get_next_label(RetryLabel, !CI), + code_info.get_next_label(RetryLabel, !CI), ModFrameCode = node([ assign(redoip(lval(curfr)), const(code_addr_const(label(RetryLabel)))) - "Set up backtracking to retry label" @@ -701,32 +698,32 @@ pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, label(RetryLabel) - "Start of the retry block" ]), - code_info__get_globals(!.CI, Globals), + code_info.get_globals(!.CI, Globals), - globals__lookup_bool_option(Globals, reclaim_heap_on_nondet_failure, + globals.lookup_bool_option(Globals, reclaim_heap_on_nondet_failure, ReclaimHeap), - code_info__maybe_save_hp(ReclaimHeap, SaveHeapCode, MaybeHpSlot, !CI), - code_info__maybe_restore_hp(MaybeHpSlot, RestoreHeapCode), + code_info.maybe_save_hp(ReclaimHeap, SaveHeapCode, MaybeHpSlot, !CI), + code_info.maybe_restore_hp(MaybeHpSlot, RestoreHeapCode), - globals__lookup_bool_option(Globals, use_trail, UseTrail), - code_info__maybe_save_ticket(UseTrail, SaveTicketCode, MaybeTicketSlot, + globals.lookup_bool_option(Globals, use_trail, UseTrail), + code_info.maybe_save_ticket(UseTrail, SaveTicketCode, MaybeTicketSlot, !CI), - code_info__maybe_reset_ticket(MaybeTicketSlot, undo, RestoreTicketCode), + code_info.maybe_reset_ticket(MaybeTicketSlot, undo, RestoreTicketCode), ( FirstContext = yes(ActualFirstContext) ; FirstContext = no, - term__context_init(ActualFirstContext) + term.context_init(ActualFirstContext) ), - trace__maybe_generate_pragma_event_code(nondet_pragma_first, + trace.maybe_generate_pragma_event_code(nondet_pragma_first, ActualFirstContext, FirstTraceCode, !CI), ( LaterContext = yes(ActualLaterContext) ; LaterContext = no, - term__context_init(ActualLaterContext) + term.context_init(ActualLaterContext) ), - trace__maybe_generate_pragma_event_code(nondet_pragma_later, + trace.maybe_generate_pragma_event_code(nondet_pragma_later, ActualLaterContext, LaterTraceCode, !CI), FirstDisjunctCode = tree_list([SaveHeapCode, SaveTicketCode, @@ -803,7 +800,7 @@ pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, Count = Count0 ) ), - string__foldl(CountSemis, Shared, 0, Semis), + string.foldl(CountSemis, Shared, 0, Semis), Semis < 32 ) -> @@ -889,7 +886,7 @@ pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, Code = tree_list([ModFrameCode, FirstDisjunctCode, CallBlockCode, RetryLabelCode, LaterDisjunctCode, RetryBlockCode]) ; - code_info__get_next_label(SharedLabel, !CI), + code_info.get_next_label(SharedLabel, !CI), SharedLabelCode = node([ label(SharedLabel) - "Start of the shared block" ]), @@ -908,7 +905,7 @@ pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId, ++ ProcLabelString ++ ":\n", LabelStr = label_to_c_string(SharedLabel, yes), - string__format("\tMR_GOTO_LABEL(%s);\n", [s(LabelStr)], + string.format("\tMR_GOTO_LABEL(%s);\n", [s(LabelStr)], GotoSharedLabel), CallDecls = [SaveStructDecl | Decls], @@ -1065,9 +1062,9 @@ make_c_arg_list([Arg | ArgTail], [ArgInfo | ArgInfoTail], [CArg | CArgTail]) :- CArg = c_arg(Var, MaybeName, Type, BoxPolicy, ArgInfo), make_c_arg_list(ArgTail, ArgInfoTail, CArgTail). make_c_arg_list([], [_ | _], _) :- - unexpected(this_file, "pragma_c_gen__make_c_arg_list length mismatch"). + unexpected(this_file, "pragma_c_gen.make_c_arg_list length mismatch"). make_c_arg_list([_ | _], [], _) :- - unexpected(this_file, "pragma_c_gen__make_c_arg_list length mismatch"). + unexpected(this_file, "pragma_c_gen.make_c_arg_list length mismatch"). %---------------------------------------------------------------------------% @@ -1082,7 +1079,7 @@ make_extra_c_arg_list(ExtraArgs, ModuleInfo, ArgInfos, ExtraCArgs) :- get_highest_arg_num([], !Max). get_highest_arg_num([arg_info(Loc, _) | ArgInfos], !Max) :- - int__max(Loc, !Max), + int.max(Loc, !Max), get_highest_arg_num(ArgInfos, !Max). :- pred make_extra_c_arg_list_seq(list(foreign_arg)::in, module_info::in, @@ -1169,7 +1166,7 @@ var_should_be_passed(CanOptAwayUnnamedArgs, Var, MaybeName) = MaybeUseName :- ( MaybeName = yes(Name), - not string__first_char(Name, '_', _) + not string.first_char(Name, '_', _) -> MaybeUseName = yes(Name) ; @@ -1178,7 +1175,7 @@ var_should_be_passed(CanOptAwayUnnamedArgs, Var, MaybeName) MaybeUseName = no ; CanOptAwayUnnamedArgs = no, - UseName = "UnnamedArg" ++ int_to_string(term__var_to_int(Var)), + UseName = "UnnamedArg" ++ int_to_string(term.var_to_int(Var)), MaybeUseName = yes(UseName) ) ). @@ -1201,7 +1198,7 @@ make_pragma_decls([Arg | Args], Module, CanOptAwayUnnamedArgs, Decls) :- MaybeName = yes(Name), ( BoxPolicy = native_if_possible, - OrigTypeString = foreign__to_type_string(c, Module, OrigType) + OrigTypeString = foreign.to_type_string(c, Module, OrigType) ; BoxPolicy = always_boxed, OrigTypeString = "MR_Word" @@ -1221,8 +1218,8 @@ make_pragma_decls([Arg | Args], Module, CanOptAwayUnnamedArgs, Decls) :- find_dead_input_vars([], _, !DeadVars). find_dead_input_vars([Arg | Args], PostDeaths, !DeadVars) :- Arg = c_arg(Var, _MaybeName, _Type, _BoxPolicy, _ArgInfo), - ( set__member(Var, PostDeaths) -> - set__insert(!.DeadVars, Var, !:DeadVars) + ( set.member(Var, PostDeaths) -> + set.insert(!.DeadVars, Var, !:DeadVars) ; true ), @@ -1245,9 +1242,9 @@ get_pragma_input_vars([Arg | Args], Inputs, CanOptAwayUnnamedArgs, Code, ( MaybeName = yes(Name), VarType = variable_type(!.CI, Var), - code_info__produce_variable(Var, FirstCode, Rval, !CI), + code_info.produce_variable(Var, FirstCode, Rval, !CI), MaybeForeign = get_maybe_foreign_type_info(!.CI, OrigType), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), ( is_dummy_argument_type(ModuleInfo, VarType) -> IsDummy = yes ; @@ -1269,12 +1266,12 @@ get_pragma_input_vars([Arg | Args], Inputs, CanOptAwayUnnamedArgs, Code, maybe(pragma_c_foreign_type). get_maybe_foreign_type_info(CI, Type) = MaybeForeignTypeInfo :- - code_info__get_module_info(CI, Module), + code_info.get_module_info(CI, Module), module_info_get_type_table(Module, Types), ( type_to_ctor_and_args(Type, TypeId, _SubTypes), - map__search(Types, TypeId, Defn), - hlds_data__get_type_defn_body(Defn, Body), + map.search(Types, TypeId, Defn), + hlds_data.get_type_defn_body(Defn, Body), Body = foreign_type(foreign_type_body(_MaybeIL, MaybeC, _MaybeJava)) -> ( @@ -1302,7 +1299,7 @@ get_maybe_foreign_type_info(CI, Type) = MaybeForeignTypeInfo :- pragma_acquire_regs([], [], !CI). pragma_acquire_regs([Arg | Args], [Reg | Regs], !CI) :- Arg = c_arg(Var, _, _, _, _), - code_info__acquire_reg_for_var(Var, Reg, !CI), + code_info.acquire_reg_for_var(Var, Reg, !CI), pragma_acquire_regs(Args, Regs, !CI). %---------------------------------------------------------------------------% @@ -1321,15 +1318,15 @@ place_pragma_output_args_in_regs([Arg | Args], [Reg | Regs], place_pragma_output_args_in_regs(Args, Regs, CanOptAwayUnnamedArgs, OutputsTail, !CI), Arg = c_arg(Var, MaybeArgName, OrigType, BoxPolicy, _ArgInfo), - code_info__release_reg(Reg, !CI), - ( code_info__variable_is_forward_live(!.CI, Var) -> - code_info__set_var_location(Var, Reg, !CI), + code_info.release_reg(Reg, !CI), + ( code_info.variable_is_forward_live(!.CI, Var) -> + code_info.set_var_location(Var, Reg, !CI), MaybeForeign = get_maybe_foreign_type_info(!.CI, OrigType), MaybeName = var_should_be_passed(CanOptAwayUnnamedArgs, Var, MaybeArgName), ( MaybeName = yes(Name), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), VarType = variable_type(!.CI, Var), ( is_dummy_argument_type(ModuleInfo, VarType) -> IsDummy = yes @@ -1370,7 +1367,7 @@ input_descs_from_arg_info(CI, [Arg | Args], CanOptAwayUnnamedArgs, Inputs) :- ArgInfo = arg_info(N, _), Reg = reg(r, N), MaybeForeign = get_maybe_foreign_type_info(CI, OrigType), - code_info__get_module_info(CI, ModuleInfo), + code_info.get_module_info(CI, ModuleInfo), ( is_dummy_argument_type(ModuleInfo, VarType) -> IsDummy = yes ; @@ -1404,7 +1401,7 @@ output_descs_from_arg_info(CI, [Arg | Args], CanOptAwayUnnamedArgs, Outputs) :- ArgInfo = arg_info(N, _), Reg = reg(r, N), MaybeForeign = get_maybe_foreign_type_info(CI, OrigType), - code_info__get_module_info(CI, ModuleInfo), + code_info.get_module_info(CI, ModuleInfo), ( is_dummy_argument_type(ModuleInfo, VarType) -> IsDummy = yes ; @@ -1420,8 +1417,8 @@ output_descs_from_arg_info(CI, [Arg | Args], CanOptAwayUnnamedArgs, Outputs) :- %---------------------------------------------------------------------------% -pragma_c_gen__struct_name(ModuleName, PredName, Arity, ProcId, StructName) :- - StructName = "mercury_save__" ++ sym_name_mangle(ModuleName) ++ "__" ++ +pragma_c_gen.struct_name(ModuleName, PredName, Arity, ProcId) = + "mercury_save__" ++ sym_name_mangle(ModuleName) ++ "__" ++ name_mangle(PredName) ++ "__" ++ int_to_string(Arity) ++ "_" ++ int_to_string(proc_id_to_int(ProcId)). diff --git a/compiler/proc_label.m b/compiler/proc_label.m index 289e50a12..c1a7372da 100644 --- a/compiler/proc_label.m +++ b/compiler/proc_label.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2003-2005 The University of Melbourne. +% Copyright (C) 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -16,7 +16,7 @@ %-----------------------------------------------------------------------------% -:- module backend_libs__proc_label. +:- module backend_libs.proc_label. :- interface. :- import_module hlds.hlds_module. @@ -88,7 +88,7 @@ make_proc_label_from_rtti(RttiProcLabel) = ProcLabel :- ( ThisModule \= TypeModule, SpecialPred = spec_pred_unify, - \+ hlds_pred__in_in_unification_proc_id(ProcId) + \+ hlds_pred.in_in_unification_proc_id(ProcId) -> DefiningModule = ThisModule ; @@ -98,7 +98,7 @@ make_proc_label_from_rtti(RttiProcLabel) = ProcLabel :- ProcLabel = special_proc(DefiningModule, SpecialPred, TypeModule, TypeName, TypeArity, ProcIdInt) ; - string__append_list(["make_proc_label:\n", + string.append_list(["make_proc_label:\n", "cannot make label for special pred `", PredName, "'"], ErrorMessage), unexpected(this_file, ErrorMessage) @@ -109,7 +109,7 @@ make_proc_label_from_rtti(RttiProcLabel) = ProcLabel :- ). make_proc_label(ModuleInfo, PredId, ProcId) = ProcLabel :- - RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId), + RttiProcLabel = rtti.make_rtti_proc_label(ModuleInfo, PredId, ProcId), make_proc_label_from_rtti(RttiProcLabel) = ProcLabel. make_user_proc_label(ThisModule, PredIsImported, PredOrFunc, PredModule, @@ -131,7 +131,7 @@ make_user_proc_label(ThisModule, PredIsImported, PredOrFunc, PredModule, make_uni_label(ModuleInfo, TypeCtor, UniModeNum) = ProcLabel :- module_info_get_name(ModuleInfo, ModuleName), ( TypeCtor = qualified(TypeModule, TypeName) - Arity -> - ( hlds_pred__in_in_unification_proc_id(UniModeNum) -> + ( hlds_pred.in_in_unification_proc_id(UniModeNum) -> Module = TypeModule ; Module = ModuleName diff --git a/compiler/prog_ctgc.m b/compiler/prog_ctgc.m index e8e589de8..a2eb34f32 100644 --- a/compiler/prog_ctgc.m +++ b/compiler/prog_ctgc.m @@ -143,7 +143,7 @@ parse_unit_selector(Term) = UnitSelector :- ( - Term = term__functor(term__atom(Cons), Args, _) + Term = term.functor(term.atom(Cons), Args, _) -> ( Cons = "sel", @@ -151,23 +151,23 @@ parse_unit_selector(Term) = UnitSelector :- -> ( sym_name_and_args(ConsTerm, ConsIdName, []), - ArityTerm = term__functor(term__integer(Arity), _, _), - PosTerm = term__functor(term__integer(Pos), _, _) + ArityTerm = term.functor(term.integer(Arity), _, _), + PosTerm = term.functor(term.integer(Pos), _, _) -> ConsId = cons(ConsIdName, Arity), UnitSelector = termsel(ConsId, Pos) ; - ConsTerm = term__functor(term__integer(X), _, _) + ConsTerm = term.functor(term.integer(X), _, _) -> ConsId = int_const(X), UnitSelector = termsel(ConsId, 0) ; - ConsTerm = term__functor(term__float(X), _, _) + ConsTerm = term.functor(term.float(X), _, _) -> ConsId = float_const(X), UnitSelector = termsel(ConsId, 0) ; - ConsTerm = term__functor(term__string(S), _, _) + ConsTerm = term.functor(term.string(S), _, _) -> ConsId = string_const(S), UnitSelector = termsel(ConsId, 0) @@ -177,9 +177,9 @@ parse_unit_selector(Term) = UnitSelector :- ) ; Cons = "typesel", - Args = [ TypeSelectorTerm ] + Args = [TypeSelectorTerm] -> - parse_type(term__coerce(TypeSelectorTerm), MaybeTypeSelector), + parse_type(term.coerce(TypeSelectorTerm), MaybeTypeSelector), ( MaybeTypeSelector = ok(TypeSelector), UnitSelector = typesel(TypeSelector) @@ -198,14 +198,13 @@ parse_unit_selector(Term) = UnitSelector :- parse_selector(Term) = Selector :- ( - Term = term__functor(term__atom(Cons), Args, _) + Term = term.functor(term.atom(Cons), Args, _) -> ( Cons = "[|]", - Args = [ First , Rest ] + Args = [First , Rest] -> - Selector = [ parse_unit_selector(First) | - parse_selector(Rest) ] + Selector = [parse_unit_selector(First) | parse_selector(Rest)] ; Selector = [] ) @@ -215,23 +214,23 @@ parse_selector(Term) = Selector :- parse_datastruct(Term) = Datastruct :- ( - Term = term__functor(term__atom(Cons), Args, _), + Term = term.functor(term.atom(Cons), Args, _), Cons = "cel", - Args = [ VarTerm, SelectorTerm ], - VarTerm = term__variable(Var) + Args = [VarTerm, SelectorTerm], + VarTerm = term.variable(Var) -> - Datastruct = selected_cel(term__coerce_var(Var), + Datastruct = selected_cel(term.coerce_var(Var), parse_selector(SelectorTerm)) ; - unexpected(this_file, "parse_datastruct: error while parsing" ++ - " datastruct.") + unexpected(this_file, + "parse_datastruct: error while parsing datastruct.") ). parse_structure_sharing_pair(Term) = SharingPair :- ( - Term = term__functor(term__atom(Cons), Args, _), + Term = term.functor(term.atom(Cons), Args, _), Cons = "pair", - Args = [ First, Second ] + Args = [First, Second] -> SharingPair = parse_datastruct(First) - parse_datastruct(Second) ; @@ -240,26 +239,26 @@ parse_structure_sharing_pair(Term) = SharingPair :- parse_structure_sharing(Term) = SharingPairs :- ( - Term = term__functor(term__atom(Cons), Args, _), + Term = term.functor(term.atom(Cons), Args, _), ( Cons = "[|]", - Args = [ SharingPairTerm, Rest], - SharingPairs0 = [ parse_structure_sharing_pair(SharingPairTerm) | - parse_structure_sharing(Rest) ] + Args = [SharingPairTerm, Rest], + SharingPairs0 = [parse_structure_sharing_pair(SharingPairTerm) | + parse_structure_sharing(Rest)] ; Cons = "[]", SharingPairs0 = [] ) -> - SharingPairs = SharingPairs0 + SharingPairs = SharingPairs0 ; - unexpected(this_file, "Error while parsing list of structure " ++ - "sharing pairs.") + unexpected(this_file, + "Error while parsing list of structure sharing pairs.") ). parse_structure_sharing_domain(Term) = SharingAs :- ( - Term = term__functor(term__atom(Cons), _, Context), + Term = term.functor(term.atom(Cons), _, Context), ( Cons = "[|]", SharingAs0 = real(parse_structure_sharing(Term)) @@ -269,7 +268,7 @@ parse_structure_sharing_domain(Term) = SharingAs :- ; Cons = "top", context_to_string(Context, ContextMsg), - SharingAs0 = top([ "imported top: " ++ ContextMsg ++ "." ]) + SharingAs0 = top(["imported top: " ++ ContextMsg ++ "."]) ) -> SharingAs = SharingAs0 @@ -292,9 +291,8 @@ selector_to_string(TVarSet, Selector) = String :- Selector = [_|_], SelectorStrings = list.map(unit_selector_to_string(TVarSet), Selector), - string.append_list(["[", - string.join_list(",", SelectorStrings), - "]"], String) + string.append_list(["[", string.join_list(",", SelectorStrings), "]"], + String) ). :- func unit_selector_to_string(tvarset, unit_selector) = string. @@ -335,9 +333,7 @@ print_structure_sharing(ProgVarSet, TypeVarSet, MaybeLimit, Start, Sep, End, ( MaybeLimit = yes(Limit), list.take_upto(Limit, SharingPairs0, SharingPairs), - ( - Limit >= list.length(SharingPairs0) - -> + ( Limit >= list.length(SharingPairs0) -> CompleteList = yes ; CompleteList = no diff --git a/compiler/prog_data.m b/compiler/prog_data.m index 5002e916c..1d86a1580 100644 --- a/compiler/prog_data.m +++ b/compiler/prog_data.m @@ -20,7 +20,7 @@ %-----------------------------------------------------------------------------% -:- module parse_tree__prog_data. +:- module parse_tree.prog_data. :- interface. :- import_module libs.globals. @@ -510,7 +510,7 @@ % is a member of the specified type class. It is an invariant of this data % structure that the types in a class constraint do not contain any % information in their prog_context fields. This invariant is needed - % to ensure that we can do unifications, map__lookups, etc., and get the + % to ensure that we can do unifications, map.lookups, etc., and get the % expected semantics. (This invariant now applies to all types, but is % especially important here.) % @@ -751,9 +751,9 @@ :- type prog_term == term(prog_var_type). :- type prog_vars == list(prog_var). - % A prog_context is just a term__context. + % A prog_context is just a term.context. % -:- type prog_context == term__context. +:- type prog_context == term.context. %-----------------------------------------------------------------------------% % @@ -1033,13 +1033,13 @@ ---> true ; where(term). - % Similar to varset__merge_subst but produces a tvar_renaming + % Similar to varset.merge_subst but produces a tvar_renaming % instead of a substitution, which is more suitable for types. % :- pred tvarset_merge_renaming(tvarset::in, tvarset::in, tvarset::out, tvar_renaming::out) is det. - % As above, but behaves like varset__merge_subst_without_names. + % As above, but behaves like varset.merge_subst_without_names. % :- pred tvarset_merge_renaming_without_names(tvarset::in, tvarset::in, tvarset::out, tvar_renaming::out) is det. @@ -1494,7 +1494,7 @@ attributes_to_strings(Attrs) = StringList :- StringList = [MayCallMercuryStr, ThreadSafeStr, TabledForIOStr | PurityStrList] ++ TerminatesStrList ++ ExceptionsStrList ++ OrdinaryDespiteDetismStrList ++ MayModifyTrailStrList ++ - BoxPolicyStr ++ list__map(extra_attribute_to_string, ExtraAttributes). + BoxPolicyStr ++ list.map(extra_attribute_to_string, ExtraAttributes). add_extra_attribute(NewAttribute, Attributes0, Attributes0 ^ extra_attributes := @@ -1506,7 +1506,7 @@ add_extra_attribute(NewAttribute, Attributes0, extra_attribute_to_string(backend(low_level_backend)) = "low_level_backend". extra_attribute_to_string(backend(high_level_backend)) = "high_level_backend". extra_attribute_to_string(max_stack_size(Size)) = - "max_stack_size(" ++ string__int_to_string(Size) ++ ")". + "max_stack_size(" ++ string.int_to_string(Size) ++ ")". %-----------------------------------------------------------------------------% % @@ -1695,12 +1695,12 @@ det_negation_det(failure, yes(det)). %-----------------------------------------------------------------------------% tvarset_merge_renaming(TVarSetA, TVarSetB, TVarSet, Renaming) :- - varset__merge_subst(TVarSetA, TVarSetB, TVarSet, Subst), - map__map_values(convert_subst_term_to_tvar, Subst, Renaming). + varset.merge_subst(TVarSetA, TVarSetB, TVarSet, Subst), + map.map_values(convert_subst_term_to_tvar, Subst, Renaming). tvarset_merge_renaming_without_names(TVarSetA, TVarSetB, TVarSet, Renaming) :- - varset__merge_subst_without_names(TVarSetA, TVarSetB, TVarSet, Subst), - map__map_values(convert_subst_term_to_tvar, Subst, Renaming). + varset.merge_subst_without_names(TVarSetA, TVarSetB, TVarSet, Subst), + map.map_values(convert_subst_term_to_tvar, Subst, Renaming). :- pred convert_subst_term_to_tvar(tvar::in, term(tvar_type)::in, tvar::out) is det. @@ -1712,7 +1712,7 @@ convert_subst_term_to_tvar(_, functor(_, _, _), _) :- %-----------------------------------------------------------------------------% get_tvar_kind(Map, TVar, Kind) :- - ( map__search(Map, TVar, Kind0) -> + ( map.search(Map, TVar, Kind0) -> Kind = Kind0 ; Kind = star diff --git a/compiler/prog_foreign.m b/compiler/prog_foreign.m index 260a9db2f..d013a65d1 100644 --- a/compiler/prog_foreign.m +++ b/compiler/prog_foreign.m @@ -87,7 +87,7 @@ ---> user_foreign_code( foreign_language, % language of this code string, % code - term__context % source code location + term.context % source code location ). % The code for `pragma export' is generated directly as strings @@ -311,10 +311,10 @@ prefer_foreign_language(_Globals, il, Lang1, Lang2) = Comp :- PreferredList = [il, csharp, managed_cplusplus], FindLangPriority = (func(L) = X :- - ( list__nth_member_search(PreferredList, L, X0) -> + ( list.nth_member_search(PreferredList, L, X0) -> X = X0 ; - X = list__length(PreferredList) + 1 + X = list.length(PreferredList) + 1 )), N1 = FindLangPriority(Lang1), N2 = FindLangPriority(Lang2), @@ -360,12 +360,12 @@ name_mangle(Name) = MangledName :- % require changes to extras/dynamic_linking/name_mangle.m, % profiler/demangle.m, util/mdemangle.c and compiler/name_mangle.m. - ( string__is_alnum_or_underscore(Name) -> + ( string.is_alnum_or_underscore(Name) -> % Any names that start with `f_' are changed so that they start with % `f__', so that we can use names starting with `f_' (followed by % anything except an underscore) without fear of name collisions. - ( string__append("f_", Suffix, Name) -> + ( string.append("f_", Suffix, Name) -> MangledName = "f__" ++ Suffix ; MangledName = Name @@ -375,7 +375,7 @@ name_mangle(Name) = MangledName :- ). qualify_name(Module0, Name0) = Name :- - string__append_list([Module0, "__", Name0], Name). + string.append_list([Module0, "__", Name0], Name). convert_to_valid_c_identifier(String) = Name :- ( name_conversion_table(String, Name0) -> @@ -420,14 +420,14 @@ name_conversion_table("[]", "f_nil"). :- func convert_to_valid_c_identifier_2(string) = string. convert_to_valid_c_identifier_2(String) = Name :- - ( string__first_char(String, Char, Rest) -> + ( string.first_char(String, Char, Rest) -> % XXX This will cause ABI incompatibilities between compilers which are % built in grades that have different character representations. - char__to_int(Char, Code), - string__int_to_string(Code, CodeString), - string__append("_", CodeString, ThisCharString), + char.to_int(Char, Code), + string.int_to_string(Code, CodeString), + string.append("_", CodeString, ThisCharString), Name0 = convert_to_valid_c_identifier_2(Rest), - string__append(ThisCharString, Name0, Name) + string.append(ThisCharString, Name0, Name) ; % String is the empty string Name = String diff --git a/compiler/prog_io.m b/compiler/prog_io.m index f394b919b..4cc1e1fb0 100644 --- a/compiler/prog_io.m +++ b/compiler/prog_io.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------e % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------e -% Copyright (C) 1993-2005 The University of Melbourne. +% Copyright (C) 1993-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -55,7 +55,7 @@ %-----------------------------------------------------------------------------% -:- module parse_tree__prog_io. +:- module parse_tree.prog_io. :- interface. :- import_module libs.timestamp. @@ -107,12 +107,12 @@ :- pred read_module(open_file(FileInfo)::in(open_file), module_name::in, bool::in, module_error::out, maybe(FileInfo)::out, module_name::out, message_list::out, item_list::out, - maybe(io__res(timestamp))::out, io::di, io::uo) is det. + maybe(io.res(timestamp))::out, io::di, io::uo) is det. :- pred read_module_if_changed(open_file(FileInfo)::in(open_file), module_name::in, timestamp::in, module_error::out, maybe(FileInfo)::out, module_name::out, message_list::out, - item_list::out, maybe(io__res(timestamp))::out, io::di, io::uo) is det. + item_list::out, maybe(io.res(timestamp))::out, io::di, io::uo) is det. % Same as read_module, but use intermod_directories instead of % search_directories when searching for the file. @@ -316,7 +316,7 @@ read_module_if_changed(OpenFile, DefaultModuleName, ModuleName, Messages, Items, MaybeModuleTimestamp, !IO). read_opt_file(FileName, DefaultModuleName, Error, Messages, Items, !IO) :- - globals__io_lookup_accumulating_option(intermod_directories, Dirs, !IO), + globals.io_lookup_accumulating_option(intermod_directories, Dirs, !IO), read_module_2(search_for_file(Dirs, FileName), DefaultModuleName, no, no, Error, _, ModuleName, Messages, Items, _, !IO), @@ -327,17 +327,17 @@ check_module_has_expected_name(FileName, ExpectedName, ActualName, !IO) :- ( ActualName \= ExpectedName -> sym_name_to_string(ActualName, ActualString), sym_name_to_string(ExpectedName, ExpectedString), - io__write_strings([ + io.write_strings([ "Error: file `", FileName, "' contains the wrong module.\n", "Expected module `", ExpectedString, "', found module `", ActualString, "'.\n" ], !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; true ). - % This implementation uses io__read_term to read in the program one term + % This implementation uses io.read_term to read in the program one term % at a time, and then converts those terms into clauses and declarations, % checking for errors as it goes. Note that rather than using difference % lists, we just build up the lists of items and messages in reverse order @@ -347,19 +347,19 @@ check_module_has_expected_name(FileName, ExpectedName, ActualName, !IO) :- :- pred read_module_2(open_file(T)::in(open_file), module_name::in, maybe(timestamp)::in, bool::in, module_error::out, maybe(T)::out, module_name::out, message_list::out, item_list::out, - maybe(io__res(timestamp))::out, io::di, io::uo) is det. + maybe(io.res(timestamp))::out, io::di, io::uo) is det. read_module_2(OpenFile, DefaultModuleName, MaybeOldTimestamp, ReturnTimestamp, Error, MaybeFileData, ModuleName, Messages, Items, MaybeModuleTimestamp, !IO) :- - io__input_stream(OldInputStream, !IO), + io.input_stream(OldInputStream, !IO), OpenFile(OpenResult, !IO), ( OpenResult = ok(FileData), MaybeFileData = yes(FileData), ( ReturnTimestamp = yes -> - io__input_stream_name(InputStreamName, !IO), - io__file_modification_time(InputStreamName, TimestampResult, !IO), + io.input_stream_name(InputStreamName, !IO), + io.file_modification_time(InputStreamName, TimestampResult, !IO), ( TimestampResult = ok(Timestamp), MaybeModuleTimestamp = yes(ok(time_t_to_timestamp(Timestamp))) @@ -387,11 +387,11 @@ read_module_2(OpenFile, DefaultModuleName, MaybeOldTimestamp, ReturnTimestamp, read_all_items(DefaultModuleName, ModuleName, Messages, Items, Error, !IO) ), - io__set_input_stream(OldInputStream, ModuleInputStream, !IO), - io__close_input(ModuleInputStream, !IO) + io.set_input_stream(OldInputStream, ModuleInputStream, !IO), + io.close_input(ModuleInputStream, !IO) ; OpenResult = error(Message0), - io__progname_base("mercury_compile", Progname, !IO), + io.progname_base("mercury_compile", Progname, !IO), Message = Progname ++ ": " ++ Message0, dummy_term(Term), Messages = [Message - Term], @@ -406,10 +406,10 @@ search_for_file(Dirs, FileName, Result, !IO) :- search_for_file_returning_dir(Dirs, FileName, Result0, !IO), ( Result0 = ok(Dir), - ( dir__this_directory(Dir) -> + ( dir.this_directory(Dir) -> PathName = FileName ; - PathName = dir__make_path_name(Dir, FileName) + PathName = dir.make_path_name(Dir, FileName) ), Result = ok(PathName) ; @@ -425,14 +425,14 @@ search_for_file_returning_dir(Dirs, FileName, R, !IO) :- search_for_file_returning_dir([], AllDirs, FileName, error(Msg), !IO) :- Msg = append_list(["cannot find `", FileName, "' in directories ", - string__join_list(", ", AllDirs)]). + string.join_list(", ", AllDirs)]). search_for_file_returning_dir([Dir | Dirs], AllDirs, FileName, R, !IO) :- - ( dir__this_directory(Dir) -> + ( dir.this_directory(Dir) -> ThisFileName = FileName ; - ThisFileName = dir__make_path_name(Dir, FileName) + ThisFileName = dir.make_path_name(Dir, FileName) ), - io__see(ThisFileName, R0, !IO), + io.see(ThisFileName, R0, !IO), ( R0 = ok -> R = ok(Dir) ; @@ -558,7 +558,7 @@ check_end_module(EndModule, !Messages, !Items, !Error) :- :- pred dummy_term(term::out) is det. dummy_term(Term) :- - term__context_init(Context), + term.context_init(Context), dummy_term_with_context(Context, Term). % Create a dummy term with the specified context. @@ -566,24 +566,24 @@ dummy_term(Term) :- % context, but for which we don't want to print out the term % (or for which the term isn't available to be printed out). % -:- pred dummy_term_with_context(term__context::in, term::out) is det. +:- pred dummy_term_with_context(term.context::in, term::out) is det. dummy_term_with_context(Context, Term) :- - Term = term__functor(term__atom(""), [], Context). + Term = term.functor(term.atom(""), [], Context). %-----------------------------------------------------------------------------% find_module_name(FileName, MaybeModuleName, !IO) :- - io__open_input(FileName, OpenRes, !IO), + io.open_input(FileName, OpenRes, !IO), ( OpenRes = ok(InputStream), - io__set_input_stream(InputStream, OldInputStream, !IO), - ( string__remove_suffix(FileName, ".m", PartialFileName0) -> + io.set_input_stream(InputStream, OldInputStream, !IO), + ( string.remove_suffix(FileName, ".m", PartialFileName0) -> PartialFileName = PartialFileName0 ; PartialFileName = FileName ), - ( dir__basename(PartialFileName, BaseName0) -> + ( dir.basename(PartialFileName, BaseName0) -> BaseName = BaseName0 ; BaseName = "" @@ -592,18 +592,18 @@ find_module_name(FileName, MaybeModuleName, !IO) :- read_first_item(DefaultModuleName, FileName, ModuleName, RevMessages, _, _, _, !IO), MaybeModuleName = yes(ModuleName), - prog_out__write_messages(list__reverse(RevMessages), !IO), - io__set_input_stream(OldInputStream, _, !IO), - io__close_input(InputStream, !IO) + prog_out.write_messages(list.reverse(RevMessages), !IO), + io.set_input_stream(OldInputStream, _, !IO), + io.close_input(InputStream, !IO) ; OpenRes = error(Error), - io__progname_base("mercury_compile", Progname, !IO), - io__write_string(Progname, !IO), - io__write_string(": error opening `", !IO), - io__write_string(FileName, !IO), - io__write_string("': ", !IO), - io__write_string(io__error_message(Error), !IO), - io__write_string(".\n", !IO), + io.progname_base("mercury_compile", Progname, !IO), + io.write_string(Progname, !IO), + io.write_string(": error opening `", !IO), + io.write_string(FileName, !IO), + io.write_string("': ", !IO), + io.write_string(io.error_message(Error), !IO), + io.write_string(".\n", !IO), MaybeModuleName = no ). @@ -620,14 +620,13 @@ find_module_name(FileName, MaybeModuleName, !IO) :- % % We use a continuation-passing style here. % -:- pred read_all_items(module_name::in, module_name::out, - message_list::out, item_list::out, module_error::out, - io__state::di, io__state::uo) is det. +:- pred read_all_items(module_name::in, module_name::out, message_list::out, + item_list::out, module_error::out, io::di, io::uo) is det. read_all_items(DefaultModuleName, ModuleName, Messages, Items, Error, !IO) :- % Read all the items (the first one is handled specially). - io__input_stream(Stream, !IO), - io__input_stream_name(Stream, SourceFileName, !IO), + io.input_stream(Stream, !IO), + io.input_stream_name(Stream, SourceFileName, !IO), read_first_item(DefaultModuleName, SourceFileName, ModuleName, RevMessages0, RevItems0, MaybeSecondTerm, Error0, !IO), ( @@ -650,8 +649,8 @@ read_all_items(DefaultModuleName, ModuleName, Messages, Items, Error, !IO) :- get_end_module(ModuleName, RevItems1, RevItems, EndModule), check_end_module(EndModule, RevMessages1, RevMessages, Items0, Items, Error1, Error), - list__reverse(RevMessages, Messages), - list__reverse(RevItems, Items0). + list.reverse(RevMessages, Messages), + list.reverse(RevItems, Items0). % We need to jump through a few hoops when reading the first item, % to allow the initial `:- module' declaration to be optional. @@ -667,17 +666,17 @@ read_all_items(DefaultModuleName, ModuleName, Messages, Items, Error, !IO) :- % :- pred read_first_item(module_name::in, file_name::in, module_name::out, message_list::out, item_list::out, maybe(read_term)::out, - module_error::out, io__state::di, io__state::uo) is det. + module_error::out, io.state::di, io.state::uo) is det. read_first_item(DefaultModuleName, SourceFileName, ModuleName, Messages, Items, MaybeSecondTerm, Error, !IO) :- - globals__io_lookup_bool_option(warn_missing_module_name, WarnMissing, !IO), - globals__io_lookup_bool_option(warn_wrong_module_name, WarnWrong, !IO), + globals.io_lookup_bool_option(warn_missing_module_name, WarnMissing, !IO), + globals.io_lookup_bool_option(warn_wrong_module_name, WarnWrong, !IO), % Parse the first term, treating it as occurring within the scope % of the special "root" module (so that any `:- module' declaration % is taken to be a non-nested module unless explicitly qualified). - parser__read_term(SourceFileName, MaybeFirstTerm, !IO), + parser.read_term(SourceFileName, MaybeFirstTerm, !IO), root_module_name(RootModuleName), process_read_term(RootModuleName, MaybeFirstTerm, MaybeFirstItem), ( @@ -704,7 +703,7 @@ read_first_item(DefaultModuleName, SourceFileName, ModuleName, Messages = [] ; sym_name_to_string(StartModuleName, StartModuleNameString), - string__append_list(["source file `", SourceFileName, + string.append_list(["source file `", SourceFileName, "' contains module named `", StartModuleNameString, "'"], WrongModuleWarning), @@ -727,7 +726,7 @@ read_first_item(DefaultModuleName, SourceFileName, ModuleName, ( MaybeFirstItem = ok(_FirstItem, FirstContext0) -> FirstContext = FirstContext0 ; - term__context_init(SourceFileName, 1, FirstContext) + term.context_init(SourceFileName, 1, FirstContext) ), ( WarnMissing = yes, @@ -750,15 +749,15 @@ read_first_item(DefaultModuleName, SourceFileName, ModuleName, Error = no_module_errors ). -:- pred make_module_decl(module_name::in, term__context::in, +:- pred make_module_decl(module_name::in, term.context::in, item_and_context::out) is det. make_module_decl(ModuleName, Context, Item - Context) :- - varset__init(EmptyVarSet), + varset.init(EmptyVarSet), ModuleDefn = module(ModuleName), Item = module_defn(EmptyVarSet, ModuleDefn). -:- pred maybe_add_warning(bool::in, read_term::in, term__context::in, +:- pred maybe_add_warning(bool::in, read_term::in, term.context::in, string::in, message_list::in, message_list::out) is det. maybe_add_warning(DoWarn, MaybeTerm, Context, Warning, !Messages) :- @@ -778,12 +777,12 @@ maybe_add_warning(DoWarn, MaybeTerm, Context, Warning, !Messages) :- % The code below was carefully optimized to run efficiently in NU-Prolog. % We used to call read_item(MaybeItem) - which does all the work for - % a single item - via io__gc_call/1, which called the goal with + % a single item - via io.gc_call/1, which called the goal with % garbage collection. But optimizing for NU-Prolog is no longer a concern. :- pred read_items_loop(module_name::in, file_name::in, message_list::in, message_list::out, item_list::in, item_list::out, - module_error::in,module_error::out, io__state::di, io__state::uo) is det. + module_error::in,module_error::out, io.state::di, io.state::uo) is det. read_items_loop(ModuleName, SourceFileName, !Msgs, !Items, !Error, !IO) :- read_item(ModuleName, SourceFileName, MaybeItem, !IO), @@ -795,7 +794,7 @@ read_items_loop(ModuleName, SourceFileName, !Msgs, !Items, !Error, !IO) :- :- pred read_items_loop_2(maybe_item_or_eof::in, module_name::in, file_name::in, message_list::in, message_list::out, item_list::in, item_list::out, module_error::in, module_error::out, - io__state::di, io__state::uo) is det. + io.state::di, io.state::uo) is det. read_items_loop_2(eof, _ModuleName, _SourceFile, !Msgs, !Items, !Error, !IO). % If the next item was end-of-file, then we're done. @@ -804,7 +803,7 @@ read_items_loop_2(syntax_error(ErrorMsg, LineNumber), ModuleName, SourceFileName, !Msgs, !Items, _Error0, Error, !IO) :- % If the next item was a syntax error, then insert it in the list % of messages and continue looping. - term__context_init(SourceFileName, LineNumber, Context), + term.context_init(SourceFileName, LineNumber, Context), dummy_term_with_context(Context, Term), ThisError = ErrorMsg - Term, !:Msgs = [ThisError | !.Msgs], @@ -827,7 +826,7 @@ read_items_loop_2(ok(Item0, Context), ModuleName0, SourceFileName0, Warning = item_warning(MaybeOption, Msg, Term), ( MaybeOption = yes(Option), - globals__io_lookup_bool_option(Option, Warn, !IO) + globals.io_lookup_bool_option(Option, Warn, !IO) ; MaybeOption = no, Warn = yes @@ -836,7 +835,7 @@ read_items_loop_2(ok(Item0, Context), ModuleName0, SourceFileName0, Warn = yes, add_warning(Msg, Term, !Msgs), - globals__io_lookup_bool_option(halt_at_warn, Halt, !IO), + globals.io_lookup_bool_option(halt_at_warn, Halt, !IO), ( Halt = yes, !:Error = some_module_errors @@ -922,7 +921,7 @@ make_pseudo_include_module_decl(Varset, Context, ModuleSpecifier) = ---> eof ; syntax_error(file_name, int) ; error(string, term) - ; ok(item, term__context). + ; ok(item, term.context). % Read_item/1 reads a single item, and if it is a valid term parses it. % @@ -930,7 +929,7 @@ make_pseudo_include_module_decl(Varset, Context, ModuleSpecifier) = io::di, io::uo) is det. read_item(ModuleName, SourceFileName, MaybeItem, !IO) :- - parser__read_term(SourceFileName, MaybeTerm, !IO), + parser.read_term(SourceFileName, MaybeTerm, !IO), process_read_term(ModuleName, MaybeTerm, MaybeItem). :- pred process_read_term(module_name::in, read_term::in, @@ -950,15 +949,15 @@ convert_item(ok(Item, Context), ok(Item, Context)). convert_item(error(M, T), error(M, T)). parse_item(ModuleName, VarSet, Term, Result) :- - ( Term = term__functor(term__atom(":-"), [Decl], _DeclContext) -> + ( Term = term.functor(term.atom(":-"), [Decl], _DeclContext) -> % It's a declaration. parse_decl(ModuleName, VarSet, Decl, Result) - ; Term = term__functor(term__atom("-->"), [DCG_H, DCG_B], DCG_Context) -> + ; Term = term.functor(term.atom("-->"), [DCG_H, DCG_B], DCG_Context) -> % It's a DCG clause. parse_dcg_clause(ModuleName, VarSet, DCG_H, DCG_B, DCG_Context, Result) ; % It's either a fact or a rule - ( Term = term__functor(term__atom(":-"), [H, B], TermContext) -> + ( Term = term.functor(term.atom(":-"), [H, B], TermContext) -> % It's a rule. Head = H, Body = B, @@ -966,19 +965,19 @@ parse_item(ModuleName, VarSet, Term, Result) :- ; % It's a fact. Head = Term, - ( Head = term__functor(_Functor, _Args, HeadContext) -> + ( Head = term.functor(_Functor, _Args, HeadContext) -> TheContext = HeadContext ; % Term consists of just a single variable - the context % has been lost. - term__context_init(TheContext) + term.context_init(TheContext) ), - Body = term__functor(term__atom("true"), [], TheContext) + Body = term.functor(term.atom("true"), [], TheContext) ), - varset__coerce(VarSet, ProgVarSet), + varset.coerce(VarSet, ProgVarSet), parse_goal(Body, Body2, ProgVarSet, ProgVarSet2), ( - Head = term__functor(term__atom("="), [FuncHead0, FuncResult], _), + Head = term.functor(term.atom("="), [FuncHead0, FuncResult], _), FuncHead = desugar_field_access(FuncHead0) -> parse_implicitly_qualified_term(ModuleName, FuncHead, Head, @@ -997,20 +996,20 @@ parse_item(ModuleName, VarSet, Term, Result) :- process_pred_clause(ok(Name, Args0), VarSet, Body, ok(clause(user, VarSet, predicate, Name, Args, Body))) :- - list__map(term__coerce, Args0, Args). + list.map(term.coerce, Args0, Args). process_pred_clause(error(ErrMessage, Term0), _, _, error(ErrMessage, Term)) :- - term__coerce(Term0, Term). + term.coerce(Term0, Term). :- pred process_func_clause(maybe_functor::in, term::in, prog_varset::in, goal::in, maybe1(item)::out) is det. process_func_clause(ok(Name, Args0), Result0, VarSet, Body, ok(clause(user, VarSet, function, Name, Args, Body))) :- - list__append(Args0, [Result0], Args1), - list__map(term__coerce, Args1, Args). + list.append(Args0, [Result0], Args1), + list.map(term.coerce, Args1, Args). process_func_clause(error(ErrMessage, Term0), _, _, _, error(ErrMessage, Term)) :- - term__coerce(Term0, Term). + term.coerce(Term0, Term). %-----------------------------------------------------------------------------% @@ -1044,7 +1043,7 @@ parse_decl(ModuleName, VarSet, F, Result) :- maybe_item_and_context::out) is det. parse_decl_2(ModuleName, VarSet, F, Attributes, Result) :- - ( F = term__functor(term__atom(Atom), Args, Context) -> + ( F = term.functor(term.atom(Atom), Args, Context) -> ( parse_decl_attribute(Atom, Args, Attribute, SubTerm) -> NewAttributes = [Attribute - F | Attributes], parse_decl_2(ModuleName, VarSet, SubTerm, NewAttributes, Result) @@ -1199,12 +1198,12 @@ process_decl(_ModuleName, VarSet, "export_op", [OpSpec], Attributes, Result) :- OpSpec, Attributes, VarSet, Result). process_decl(_ModuleName, VarSet0, "interface", [], Attributes, Result) :- - varset__coerce(VarSet0, VarSet), + varset.coerce(VarSet0, VarSet), Result0 = ok(module_defn(VarSet, interface)), check_no_attributes(Result0, Attributes, Result). process_decl(_ModuleName, VarSet0, "implementation", [], Attributes, Result) :- - varset__coerce(VarSet0, VarSet), + varset.coerce(VarSet0, VarSet), Result0 = ok(module_defn(VarSet, implementation)), check_no_attributes(Result0, Attributes, Result). @@ -1214,7 +1213,7 @@ process_decl(ModuleName, VarSet, "external", Args, Attributes, Result) :- MaybeBackend = no ; Args = [BackendArg, PredSpec], - BackendArg = term__functor(term__atom(Functor), [], _), + BackendArg = term.functor(term.atom(Functor), [], _), ( Functor = "high_level_backend", Backend = high_level_backend @@ -1234,7 +1233,7 @@ process_decl(DefaultModuleName, VarSet0, "module", [ModuleName], Attributes, parse_module_name(DefaultModuleName, ModuleName, Result0), ( Result0 = ok(ModuleNameSym), - varset__coerce(VarSet0, VarSet), + varset.coerce(VarSet0, VarSet), Result1 = ok(module_defn(VarSet, module(ModuleNameSym))) ; Result0 = error(A, B), @@ -1247,7 +1246,7 @@ process_decl(DefaultModuleName, VarSet0, "include_module", [ModuleNames], parse_list(parse_module_name(DefaultModuleName), ModuleNames, Result0), ( Result0 = ok(ModuleNameSyms), - varset__coerce(VarSet0, VarSet), + varset.coerce(VarSet0, VarSet), Result1 = ok(module_defn(VarSet, include_module(ModuleNameSyms))) ; Result0 = error(A, B), @@ -1267,7 +1266,7 @@ process_decl(DefaultModuleName, VarSet0, "end_module", [ModuleName], parse_module_name(ParentOfDefaultModuleName, ModuleName, Result0), ( Result0 = ok(ModuleNameSym), - varset__coerce(VarSet0, VarSet), + varset.coerce(VarSet0, VarSet), Result1 = ok(module_defn(VarSet, end_module(ModuleNameSym))) ; Result0 = error(A, B), @@ -1311,17 +1310,17 @@ process_decl(ModuleName, VarSet0, "version_numbers", Attributes, Result) :- parse_module_specifier(ModuleNameTerm, ModuleNameResult), ( - VersionNumberTerm = term__functor(term__integer(VersionNumber), [], _), + VersionNumberTerm = term.functor(term.integer(VersionNumber), [], _), VersionNumber = version_numbers_version_number -> ( ModuleNameResult = ok(ModuleName) -> - recompilation__version__parse_version_numbers(VersionNumbersTerm, + recompilation.version.parse_version_numbers(VersionNumbersTerm, Result0), ( Result0 = ok(VersionNumbers), - varset__coerce(VarSet0, VarSet), + varset.coerce(VarSet0, VarSet), Result1 = module_defn(VarSet, version_numbers(ModuleName, VersionNumbers)), check_no_attributes(ok(Result1), Attributes, Result) @@ -1334,7 +1333,7 @@ process_decl(ModuleName, VarSet0, "version_numbers", ModuleNameTerm) ) ; - ( VersionNumberTerm = term__functor(_, _, Context) -> + ( VersionNumberTerm = term.functor(_, _, Context) -> Msg = "interface file needs to be recreated, " ++ "the version numbers are out of date", dummy_term_with_context(Context, DummyTerm), @@ -1387,7 +1386,7 @@ check_no_attributes(Result0, Attributes, Result) :- Attributes = [Attr - Term | _] -> attribute_description(Attr, AttrDescr), - string__append(AttrDescr, " not allowed here", Message), + string.append(AttrDescr, " not allowed here", Message), Result = error(Message, Term) ; Result = Result0 @@ -1409,7 +1408,7 @@ attribute_description(solver_type, "solver type specifier"). list(term)::in, decl_attrs::in, maybe1(item)::out) is semidet. parse_promise(ModuleName, PromiseType, VarSet, [Term], Attributes, Result) :- - varset__coerce(VarSet, ProgVarSet0), + varset.coerce(VarSet, ProgVarSet0), parse_goal(Term, Goal0, ProgVarSet0, ProgVarSet), % Get universally quantified variables. @@ -1423,7 +1422,7 @@ parse_promise(ModuleName, PromiseType, VarSet, [Term], Attributes, Result) :- ) ; get_quant_vars(univ, ModuleName, Attributes, _, [], UnivVars0), - list__map(term__coerce_var, UnivVars0, UnivVars), + list.map(term.coerce_var, UnivVars0, UnivVars), Goal0 = Goal ), Result = ok(promise(PromiseType, Goal, ProgVarSet, UnivVars)). @@ -1435,7 +1434,7 @@ parse_promise(ModuleName, PromiseType, VarSet, [Term], Attributes, Result) :- parse_type_decl(ModuleName, VarSet, TypeDecl, Attributes, Result) :- ( - TypeDecl = term__functor(term__atom(Name), Args, _), + TypeDecl = term.functor(term.atom(Name), Args, _), parse_type_decl_type(ModuleName, Name, Args, Attributes, Cond, R) -> R1 = R, @@ -1453,14 +1452,14 @@ parse_type_decl(ModuleName, VarSet, TypeDecl, Attributes, Result) :- make_type_defn(VarSet0, Cond, processed_type_body(Name, Args, TypeDefn), type_defn(VarSet, Name, Args, TypeDefn, Cond)) :- - varset__coerce(VarSet0, VarSet). + varset.coerce(VarSet0, VarSet). :- pred make_external(varset::in, maybe(backend)::in, sym_name_specifier::in, item::out) is det. make_external(VarSet0, MaybeBackend, SymSpec, module_defn(VarSet, external(MaybeBackend, SymSpec))) :- - varset__coerce(VarSet0, VarSet). + varset.coerce(VarSet0, VarSet). :- pred get_is_solver_type(is_solver_type::out, decl_attrs::in, decl_attrs::out) is det. @@ -1480,7 +1479,7 @@ get_is_solver_type(IsSolverType, !Attributes) :- is det. add_warning(Warning, Term, Msgs, [Msg - Term | Msgs]) :- - string__append("Warning: ", Warning, Msg). + string.append("Warning: ", Warning, Msg). % Add an error message to the list of messages. % @@ -1488,7 +1487,7 @@ add_warning(Warning, Term, Msgs, [Msg - Term | Msgs]) :- is det. add_error(Error, Term, Msgs, [Msg - Term | Msgs]) :- - string__append("Error: ", Error, Msg). + string.append("Error: ", Error, Msg). %-----------------------------------------------------------------------------% @@ -1568,7 +1567,7 @@ parse_type_decl_type(ModuleName, "where", [H, B], Attributes0, Condition, R) :- du_type_rhs_ctors_and_where_terms(Term, CtorsTerm, MaybeWhereTerm) :- ( - Term = term__functor(term__atom("where"), [CtorsTerm0, WhereTerm], + Term = term.functor(term.atom("where"), [CtorsTerm0, WhereTerm], _Context) -> CtorsTerm = CtorsTerm0, @@ -1811,7 +1810,7 @@ parse_mutable_decl(_ModuleName, _VarSet, Terms, Result) :- Terms = [NameTerm, TypeTerm, ValueTerm, InstTerm | OptMutAttrsTerm], parse_mutable_name(NameTerm, NameResult), parse_mutable_type(TypeTerm, TypeResult), - term__coerce(ValueTerm, Value), + term.coerce(ValueTerm, Value), parse_mutable_inst(InstTerm, InstResult), ( OptMutAttrsTerm = [], @@ -1850,7 +1849,7 @@ parse_mutable_decl(_ModuleName, _VarSet, Terms, Result) :- :- pred parse_mutable_name(term::in, maybe1(string)::out) is det. parse_mutable_name(NameTerm, NameResult) :- - ( NameTerm = term__functor(atom(Name), [], _) -> + ( NameTerm = term.functor(atom(Name), [], _) -> NameResult = ok(Name) ; NameResult = error("invalid mutable name", NameTerm) @@ -1859,7 +1858,7 @@ parse_mutable_name(NameTerm, NameResult) :- :- pred parse_mutable_type(term::in, maybe1(mer_type)::out) is det. parse_mutable_type(TypeTerm, TypeResult) :- - ( term__contains_var(TypeTerm, _) -> + ( term.contains_var(TypeTerm, _) -> TypeResult = error("the type in a mutable declaration " ++ "cannot contain variables", TypeTerm) ; @@ -1869,7 +1868,7 @@ parse_mutable_type(TypeTerm, TypeResult) :- :- pred parse_mutable_inst(term::in, maybe1(mer_inst)::out) is det. parse_mutable_inst(InstTerm, InstResult) :- - ( term__contains_var(InstTerm, _) -> + ( term.contains_var(InstTerm, _) -> InstResult = error("the inst in a mutable declaration " ++ "cannot contain variables", InstTerm) ; convert_inst(no_allow_constrained_inst_var, InstTerm, Inst) -> @@ -1936,7 +1935,7 @@ process_mutable_attribute(attach_to_io_state(AttachToIOState), !Attributes) :- parse_mutable_attr(MutAttrTerm, MutAttrResult) :- ( - MutAttrTerm = term__functor(term__atom(String), [], _), + MutAttrTerm = term.functor(term.atom(String), [], _), ( String = "untrailed", MutAttr = trailed(untrailed) @@ -1989,7 +1988,7 @@ parse_mutable_attr(MutAttrTerm, MutAttrResult) :- parse_type_decl_where_part_if_present(IsSolverType, ModuleName, Term0, Term, Result) :- ( - Term0 = term__functor(term__atom("where"), [Term1, WhereTerm], + Term0 = term.functor(term.atom("where"), [Term1, WhereTerm], _Context) -> Term = Term1, @@ -2069,7 +2068,7 @@ parse_where_attribute(_Parser, ok(no), no, no ). parse_where_attribute( Parser, Result, yes(Term0), MaybeRest) :- ( - Term0 = term__functor(term__atom(","), [Term1, Term], _Context) + Term0 = term.functor(term.atom(","), [Term1, Term], _Context) -> Result = Parser(Term1), MaybeRestIfYes = yes(Term) @@ -2095,8 +2094,8 @@ parse_where_attribute( Parser, Result, yes(Term0), MaybeRest) :- maybe1(maybe(T)). parse_where_is(Name, Parser, Term) = Result :- - ( Term = term__functor(term__atom("is"), [LHS, RHS], _Context1) -> - ( LHS = term__functor(term__atom(Name), [], _Context2) -> + ( Term = term.functor(term.atom("is"), [LHS, RHS], _Context1) -> + ( LHS = term.functor(term.atom(Name), [], _Context2) -> RHSResult = Parser(RHS), ( RHSResult = ok(ParsedRHS), @@ -2116,7 +2115,7 @@ parse_where_is(Name, Parser, Term) = Result :- parse_where_type_is_abstract_noncanonical(Term) = ( - Term = term__functor(term__atom("type_is_abstract_noncanonical"), [], + Term = term.functor(term.atom("type_is_abstract_noncanonical"), [], _Context) -> ok(yes(unit)) @@ -2148,8 +2147,8 @@ parse_where_pred_is(ModuleName, Term) = Result :- parse_where_inst_is(_ModuleName, Term) = ( - prog_io_util__convert_inst(no_allow_constrained_inst_var, Term, Inst), - not prog_mode__inst_contains_unconstrained_var(Inst) + prog_io_util.convert_inst(no_allow_constrained_inst_var, Term, Inst), + not prog_mode.inst_contains_unconstrained_var(Inst) -> ok(Inst) ; @@ -2159,14 +2158,12 @@ parse_where_inst_is(_ModuleName, Term) = :- func parse_where_type_is(module_name, term) = maybe1(mer_type). parse_where_type_is(_ModuleName, Term) = Result :- - prog_io_util__parse_type(Term, Result). + prog_io_util.parse_type(Term, Result). :- func parse_where_mutable_is(module_name, term) = maybe1(list(item)). parse_where_mutable_is(ModuleName, Term) = Result :- - ( - Term = term__functor(term__atom("mutable"), _Args, _Ctxt) - -> + ( Term = term.functor(term.atom("mutable"), _Args, _Ctxt) -> parse_mutable_decl_term(ModuleName, Term, Result0), ( Result0 = ok(Mutable), @@ -2175,9 +2172,7 @@ parse_where_mutable_is(ModuleName, Term) = Result :- Result0 = error(Err, Trm), Result = error(Err, Trm) ) - ; - list_term_to_term_list(Term, Terms) - -> + ; list_term_to_term_list(Term, Terms) -> map_parser(parse_mutable_decl_term(ModuleName), Terms, Result) ; Result = error("expected a mutable declaration or a list of " ++ @@ -2189,8 +2184,8 @@ parse_where_mutable_is(ModuleName, Term) = Result :- parse_mutable_decl_term(ModuleName, Term, Result) :- ( - Term = term__functor(term__atom("mutable"), Args, _Ctxt), - varset__init(VarSet), + Term = term.functor(term.atom("mutable"), Args, _Ctxt), + varset.init(VarSet), parse_mutable_decl(ModuleName, VarSet, Args, Result0) -> Result = Result0 @@ -2373,12 +2368,12 @@ make_maybe_where_details( get_determinism(B, Body, Determinism) :- ( - B = term__functor(term__atom("is"), Args, _Context1), + B = term.functor(term.atom("is"), Args, _Context1), Args = [Body1, Determinism1] -> Body = Body1, ( - Determinism1 = term__functor(term__atom(Determinism2), [], + Determinism1 = term.functor(term.atom(Determinism2), [], _Context2), standard_det(Determinism2, Determinism3) -> @@ -2399,7 +2394,7 @@ get_determinism(B, Body, Determinism) :- get_with_inst(Body0, Body, WithInst) :- ( - Body0 = term__functor(term__atom("with_inst"), [Body1, Inst1], _) + Body0 = term.functor(term.atom("with_inst"), [Body1, Inst1], _) -> ( convert_inst(allow_constrained_inst_var, Inst1, Inst) -> WithInst = ok(yes(Inst)) @@ -2417,7 +2412,7 @@ get_with_inst(Body0, Body, WithInst) :- get_with_type(Body0, Body, Result) :- ( - Body0 = term__functor(TypeQualifier, [Body1, Type1], _), + Body0 = term.functor(TypeQualifier, [Body1, Type1], _), ( TypeQualifier = term.atom("with_type") ; @@ -2461,7 +2456,7 @@ get_condition(Body, Body, true). % % get_condition(B, Body, Condition) :- % ( -% B = term__functor(term__atom("where"), [Body1, Condition1], +% B = term.functor(term.atom("where"), [Body1, Condition1], % _Context) % -> % Body = Body1, @@ -2500,7 +2495,7 @@ process_solver_type(ModuleName, Head, MaybeSolverTypeDetails, MaybeUserEqComp, ( RepnType = SolverTypeDetails ^ representation_type, type_contains_var(RepnType, Var), - not list__member(Var, Params) + not list.member(Var, Params) -> Result = error("free type variable in " ++ "representation type", Head) @@ -2532,9 +2527,9 @@ process_eqv_type_2(error(Error, Term), _, error(Error, Term)). process_eqv_type_2(ok(Name, Params), Body0, Result) :- % Check that all the variables in the body occur in the head. ( - term__contains_var(Body0, Var), - term__coerce_var(Var, TVar), - \+ list__member(TVar, Params) + term.contains_var(Body0, Var), + term.coerce_var(Var, TVar), + \+ list.member(TVar, Params) -> Result = error("free type parameter in RHS of type definition", Body0) ; @@ -2582,12 +2577,12 @@ process_du_type_2(Functor, Params, Body, Ctors, MaybeUserEqComp, Result) :- % Check that all type variables in the body are either explicitly % existentially quantified or occur in the head. - list__member(Ctor, Ctors), + list.member(Ctor, Ctors), Ctor = ctor(ExistQVars, _Constraints, _CtorName, CtorArgs), - assoc_list__values(CtorArgs, CtorArgTypes), + assoc_list.values(CtorArgs, CtorArgTypes), type_list_contains_var(CtorArgTypes, Var), - \+ list__member(Var, ExistQVars), - \+ list__member(Var, Params) + \+ list.member(Var, ExistQVars), + \+ list.member(Var, Params) -> Result = error("free type parameter in RHS of type definition", Body) ; @@ -2595,10 +2590,10 @@ process_du_type_2(Functor, Params, Body, Ctors, MaybeUserEqComp, Result) :- % occur in the head (maybe this should just be a warning, not an error? % If we were to allow it, we would need to rename them apart.) - list__member(Ctor, Ctors), + list.member(Ctor, Ctors), Ctor = ctor(ExistQVars, _Constraints, _CtorName, _CtorArgs), - list__member(Var, ExistQVars), - list__member(Var, Params) + list.member(Var, ExistQVars), + list.member(Var, Params) -> Result = error("type variable has overlapping scopes " ++ "(explicit type quantifier shadows argument type)", Body) @@ -2606,13 +2601,13 @@ process_du_type_2(Functor, Params, Body, Ctors, MaybeUserEqComp, Result) :- % Check that all type variables in existential quantifiers occur % somewhere in the constructor argument types or constraints. - list__member(Ctor, Ctors), + list.member(Ctor, Ctors), Ctor = ctor(ExistQVars, Constraints, _CtorName, CtorArgs), - list__member(Var, ExistQVars), - assoc_list__values(CtorArgs, CtorArgTypes), + list.member(Var, ExistQVars), + assoc_list.values(CtorArgs, CtorArgTypes), \+ type_list_contains_var(CtorArgTypes, Var), constraint_list_get_tvars(Constraints, ConstraintTVars), - \+ list__member(Var, ConstraintTVars) + \+ list.member(Var, ConstraintTVars) -> Result = error("type variable in existential quantifier " ++ "does not occur in arguments or constraints of constructor", Body) @@ -2620,12 +2615,12 @@ process_du_type_2(Functor, Params, Body, Ctors, MaybeUserEqComp, Result) :- % Check that all type variables in existential constraints occur in % the existential quantifiers. - list__member(Ctor, Ctors), + list.member(Ctor, Ctors), Ctor = ctor(ExistQVars, Constraints, _CtorName, _CtorArgs), - list__member(Constraint, Constraints), + list.member(Constraint, Constraints), Constraint = constraint(_Name, ConstraintArgs), type_list_contains_var(ConstraintArgs, Var), - \+ list__member(Var, ExistQVars) + \+ list.member(Var, ExistQVars) -> Result = error("type variables in class constraints introduced " ++ "with `=>' must be explicitly existentially quantified " ++ @@ -2663,10 +2658,10 @@ process_abstract_type_2(ok(Functor, Params), IsSolverType, Result) :- %-----------------------------------------------------------------------------% parse_type_defn_head(ModuleName, Head, Body, Result) :- - ( Head = term__variable(_) -> - % `Head' has no term__context, so we need to get the + ( Head = term.variable(_) -> + % `Head' has no term.context, so we need to get the % context from `Body' - ( Body = term__functor(_, _, Context) -> + ( Body = term.functor(_, _, Context) -> dummy_term_with_context(Context, ErrorTerm) ; dummy_term(ErrorTerm) @@ -2693,13 +2688,13 @@ parse_type_defn_head_3(Name, Args, Head, Result) :- ( var_list_to_term_list(Params0, Args) -> % Check that all the head arg variables are distinct. ( - list__member(_, Params0, [Param | OtherParams]), - list__member(Param, OtherParams) + list.member(_, Params0, [Param | OtherParams]), + list.member(Param, OtherParams) -> Result = error("repeated type parameters " ++ "in LHS of type defn", Head) ; - list__map(term__coerce_var, Params0, Params), + list.map(term.coerce_var, Params0, Params), Result = ok(Name, Params) ) ; @@ -2752,9 +2747,9 @@ convert_constructors_2( ModuleName, [Term | Terms]) = Result :- :- func convert_constructor(module_name, term) = maybe1(constructor). convert_constructor(ModuleName, Term0) = Result :- - ( Term0 = term__functor(term__atom("some"), [Vars, Term1], _Context) -> + ( Term0 = term.functor(term.atom("some"), [Vars, Term1], _Context) -> ( parse_list_of_vars(Vars, ExistQVars0) -> - list__map(term__coerce_var, ExistQVars0, ExistQVars), + list.map(term.coerce_var, ExistQVars0, ExistQVars), Result = convert_constructor_2(ModuleName, ExistQVars, Term0, Term1) ; @@ -2779,7 +2774,7 @@ convert_constructor_2(ModuleName, ExistQVars, Term0, Term1) = Result :- % Note that as a special case, one level of curly braces around % the constructor are ignored. This is to allow you to define % ';'/2 and 'some'/2 constructors. - Term2 = term__functor(term__atom("{}"), [Term3], _Context) + Term2 = term.functor(term.atom("{}"), [Term3], _Context) -> Term4 = Term3 ; @@ -2868,8 +2863,8 @@ process_pred_or_func_2(PredOrFunc, ok(F, As0), PredType, VarSet0, pred_or_func_decl_string(PredOrFunc), PredType) ; get_purity(Purity, Attributes0, Attributes), - varset__coerce(VarSet0, TVarSet), - varset__coerce(VarSet0, IVarSet), + varset.coerce(VarSet0, TVarSet), + varset.coerce(VarSet0, IVarSet), Result0 = ok(pred_or_func(TVarSet, IVarSet, ExistQVars, PredOrFunc, F, As, WithType, WithInst, MaybeDet, Cond, Purity, ClassContext)), @@ -2955,17 +2950,17 @@ get_class_context_and_inst_constraints(ModuleName, RevAttributes0, % existentially quantified, and if not, issue a warning or % error message.) - list__reverse(RevAttributes0, Attributes0), + list.reverse(RevAttributes0, Attributes0), get_quant_vars(univ, ModuleName, Attributes0, Attributes1, [], _UnivQVars), get_quant_vars(exist, ModuleName, Attributes1, Attributes2, [], ExistQVars0), - list__map(term__coerce_var, ExistQVars0, ExistQVars), + list.map(term.coerce_var, ExistQVars0, ExistQVars), get_constraints(univ, ModuleName, Attributes2, Attributes3, MaybeUnivConstraints), get_constraints(exist, ModuleName, Attributes3, Attributes, MaybeExistConstraints), - list__reverse(Attributes, RevAttributes), + list.reverse(Attributes, RevAttributes), combine_quantifier_results(MaybeUnivConstraints, MaybeExistConstraints, ExistQVars, MaybeContext). @@ -2979,7 +2974,7 @@ combine_quantifier_results(ok(_, _), error(Msg, Term), _, error(Msg, Term)). combine_quantifier_results(ok(UnivConstraints, InstConstraints0), ok(ExistConstraints, InstConstraints1), ExistQVars, ok(ExistQVars, constraints(UnivConstraints, ExistConstraints), - InstConstraints0 `map__merge` InstConstraints1)). + InstConstraints0 `map.merge` InstConstraints1)). :- pred get_quant_vars(quantifier_type::in, module_name::in, decl_attrs::in, decl_attrs::out, list(var)::in, list(var)::out) is det. @@ -2988,7 +2983,7 @@ get_quant_vars(QuantType, ModuleName, !Attributes, !Vars) :- ( !.Attributes = [quantifier(QuantType, QuantVars) - _ | !:Attributes] -> - list__append(!.Vars, QuantVars, !:Vars), + list.append(!.Vars, QuantVars, !:Vars), get_quant_vars(QuantType, ModuleName, !Attributes, !Vars) ; true @@ -3011,7 +3006,7 @@ get_constraints(QuantType, ModuleName, !Attributes, MaybeConstraints) :- combine_constraint_list_results(MaybeConstraints1, MaybeConstraints0, MaybeConstraints) ; - MaybeConstraints = ok([], map__init) + MaybeConstraints = ok([], map.init) ). :- pred combine_constraint_list_results(maybe_class_and_inst_constraints::in, @@ -3021,7 +3016,7 @@ get_constraints(QuantType, ModuleName, !Attributes, MaybeConstraints) :- combine_constraint_list_results(error(Msg, Term), _, error(Msg, Term)). combine_constraint_list_results(ok(_, _), error(Msg, Term), error(Msg, Term)). combine_constraint_list_results(ok(CC0, IC0), ok(CC1, IC1), - ok(CC0 ++ CC1, IC0 `map__merge` IC1)). + ok(CC0 ++ CC1, IC0 `map.merge` IC1)). :- pred get_existential_constraints_from_term(module_name::in, term::in, term::out, maybe1(list(prog_constraint))::out) is det. @@ -3029,7 +3024,7 @@ combine_constraint_list_results(ok(CC0, IC0), ok(CC1, IC1), get_existential_constraints_from_term(ModuleName, !PredType, MaybeExistentialConstraints) :- ( - !.PredType = term__functor(term__atom("=>"), + !.PredType = term.functor(term.atom("=>"), [!:PredType, ExistentialConstraints], _) -> parse_class_constraints(ModuleName, ExistentialConstraints, @@ -3089,7 +3084,7 @@ process_func(ModuleName, VarSet, Term, Cond, MaybeDet, Attributes0, Result) :- process_func_2(ModuleName, VarSet, Term, Cond, MaybeDet, ExistQVars, Constraints, InstConstraints, Attributes, Result) :- ( - Term = term__functor(term__atom("="), + Term = term.functor(term.atom("="), [FuncTerm0, ReturnTypeTerm], _Context), FuncTerm = desugar_field_access(FuncTerm0) -> @@ -3132,9 +3127,9 @@ process_func_3(ok(F, As0), FuncTerm, ReturnTypeTerm, FullTerm, VarSet0, FuncTerm) ; get_purity(Purity, Attributes0, Attributes), - varset__coerce(VarSet0, TVarSet), - varset__coerce(VarSet0, IVarSet), - list__append(As, [ReturnType], Args), + varset.coerce(VarSet0, TVarSet), + varset.coerce(VarSet0, IVarSet), + list.append(As, [ReturnType], Args), ( inst_var_constraints_are_consistent_in_type_and_modes(Args) -> @@ -3194,7 +3189,7 @@ process_mode(ModuleName, VarSet, Term, Cond, Attributes, WithInst, MaybeDet, Result) :- ( WithInst = no, - Term = term__functor(term__atom("="), [FuncTerm0, ReturnTypeTerm], + Term = term.functor(term.atom("="), [FuncTerm0, ReturnTypeTerm], _Context), FuncTerm = desugar_field_access(FuncTerm0) -> @@ -3222,9 +3217,9 @@ process_pred_or_func_mode(ok(F, As0), ModuleName, PredMode, VarSet0, WithInst, Attributes, MaybeConstraints), ( MaybeConstraints = ok(_, _, InstConstraints), - list__map(constrain_inst_vars_in_mode(InstConstraints), + list.map(constrain_inst_vars_in_mode(InstConstraints), As1, As), - varset__coerce(VarSet0, VarSet), + varset.coerce(VarSet0, VarSet), ( inst_var_constraints_are_consistent_in_modes(As) -> ( WithInst = no, @@ -3265,14 +3260,14 @@ process_func_mode(ok(F, As0), ModuleName, FuncMode, RetMode0, FullTerm, Attributes, MaybeConstraints), ( MaybeConstraints = ok(_, _, InstConstraints), - list__map(constrain_inst_vars_in_mode(InstConstraints), As1, As), + list.map(constrain_inst_vars_in_mode(InstConstraints), As1, As), ( convert_mode(allow_constrained_inst_var, RetMode0, RetMode1) -> constrain_inst_vars_in_mode(InstConstraints, RetMode1, RetMode), - varset__coerce(VarSet0, VarSet), - list__append(As, [RetMode], ArgModes), + varset.coerce(VarSet0, VarSet), + list.append(As, [RetMode], ArgModes), ( inst_var_constraints_are_consistent_in_modes(ArgModes) -> Result0 = ok(pred_or_func_mode(VarSet, yes(function), F, ArgModes, no, MaybeDet, Cond)) @@ -3300,14 +3295,14 @@ process_func_mode(error(M, T), _, _, _, _, _, _, _, _, error(M, T)). %-----------------------------------------------------------------------------% constrain_inst_vars_in_mode(Mode0, Mode) :- - constrain_inst_vars_in_mode(map__init, Mode0, Mode). + constrain_inst_vars_in_mode(map.init, Mode0, Mode). constrain_inst_vars_in_mode(InstConstraints, I0 -> F0, I -> F) :- constrain_inst_vars_in_inst(InstConstraints, I0, I), constrain_inst_vars_in_inst(InstConstraints, F0, F). constrain_inst_vars_in_mode(InstConstraints, user_defined_mode(Name, Args0), user_defined_mode(Name, Args)) :- - list__map(constrain_inst_vars_in_inst(InstConstraints), Args0, Args). + list.map(constrain_inst_vars_in_inst(InstConstraints), Args0, Args). :- pred constrain_inst_vars_in_inst(inst_var_sub::in, mer_inst::in, mer_inst::out) is det. @@ -3316,8 +3311,8 @@ constrain_inst_vars_in_inst(_, any(U), any(U)). constrain_inst_vars_in_inst(_, free, free). constrain_inst_vars_in_inst(_, free(T), free(T)). constrain_inst_vars_in_inst(InstConstraints, bound(U, BIs0), bound(U, BIs)) :- - list__map((pred(functor(C, Is0)::in, functor(C, Is)::out) is det :- - list__map(constrain_inst_vars_in_inst(InstConstraints), Is0, Is)), + list.map((pred(functor(C, Is0)::in, functor(C, Is)::out) is det :- + list.map(constrain_inst_vars_in_inst(InstConstraints), Is0, Is)), BIs0, BIs). constrain_inst_vars_in_inst(_, ground(U, none), ground(U, none)). constrain_inst_vars_in_inst(InstConstraints, @@ -3330,7 +3325,7 @@ constrain_inst_vars_in_inst(InstConstraints, constrained_inst_vars(Vars, Inst)) :- constrain_inst_vars_in_inst(InstConstraints, Inst0, Inst1), ( Inst1 = constrained_inst_vars(Vars2, Inst2) -> - Vars = Vars0 `set__union` Vars2, + Vars = Vars0 `set.union` Vars2, Inst = Inst2 ; Vars = Vars0, @@ -3338,8 +3333,8 @@ constrain_inst_vars_in_inst(InstConstraints, ). constrain_inst_vars_in_inst(_, not_reached, not_reached). constrain_inst_vars_in_inst(InstConstraints, inst_var(Var), - constrained_inst_vars(set__make_singleton_set(Var), Inst)) :- - ( map__search(InstConstraints, Var, Inst0) -> + constrained_inst_vars(set.make_singleton_set(Var), Inst)) :- + ( map.search(InstConstraints, Var, Inst0) -> Inst = Inst0 ; Inst = ground(shared, none) @@ -3349,14 +3344,14 @@ constrain_inst_vars_in_inst(InstConstraints, defined_inst(Name0), constrain_inst_vars_in_inst_name(InstConstraints, Name0, Name). constrain_inst_vars_in_inst(InstConstraints, abstract_inst(N, Is0), abstract_inst(N, Is)) :- - list__map(constrain_inst_vars_in_inst(InstConstraints), Is0, Is). + list.map(constrain_inst_vars_in_inst(InstConstraints), Is0, Is). :- pred constrain_inst_vars_in_pred_inst_info(inst_var_sub::in, pred_inst_info::in, pred_inst_info::out) is det. constrain_inst_vars_in_pred_inst_info(InstConstraints, PII0, PII) :- PII0 = pred_inst_info(PredOrFunc, Modes0, Det), - list__map(constrain_inst_vars_in_mode(InstConstraints), Modes0, Modes), + list.map(constrain_inst_vars_in_mode(InstConstraints), Modes0, Modes), PII = pred_inst_info(PredOrFunc, Modes, Det). :- pred constrain_inst_vars_in_inst_name(inst_var_sub::in, @@ -3364,7 +3359,7 @@ constrain_inst_vars_in_pred_inst_info(InstConstraints, PII0, PII) :- constrain_inst_vars_in_inst_name(InstConstraints, Name0, Name) :- ( Name0 = user_inst(SymName, Args0) -> - list__map(constrain_inst_vars_in_inst(InstConstraints), Args0, Args), + list.map(constrain_inst_vars_in_inst(InstConstraints), Args0, Args), Name = user_inst(SymName, Args) ; Name = Name0 @@ -3373,23 +3368,23 @@ constrain_inst_vars_in_inst_name(InstConstraints, Name0, Name) :- %-----------------------------------------------------------------------------% inst_var_constraints_are_consistent_in_modes(Modes) :- - inst_var_constraints_are_consistent_in_modes(Modes, map__init, _). + inst_var_constraints_are_consistent_in_modes(Modes, map.init, _). :- pred inst_var_constraints_are_consistent_in_modes(list(mer_mode)::in, inst_var_sub::in, inst_var_sub::out) is semidet. inst_var_constraints_are_consistent_in_modes(Modes, !Sub) :- - list__foldl(inst_var_constraints_are_consistent_in_mode, Modes, !Sub). + list.foldl(inst_var_constraints_are_consistent_in_mode, Modes, !Sub). :- pred inst_var_constraints_are_consistent_in_type_and_modes( list(type_and_mode)::in) is semidet. inst_var_constraints_are_consistent_in_type_and_modes(TypeAndModes) :- - list__foldl((pred(TypeAndMode::in, in, out) is semidet --> + list.foldl((pred(TypeAndMode::in, in, out) is semidet --> ( { TypeAndMode = type_only(_) } ; { TypeAndMode = type_and_mode(_, Mode) }, inst_var_constraints_are_consistent_in_mode(Mode) - )), TypeAndModes, map__init, _). + )), TypeAndModes, map.init, _). :- pred inst_var_constraints_are_consistent_in_mode(mer_mode::in, inst_var_sub::in, inst_var_sub::out) is semidet. @@ -3405,7 +3400,7 @@ inst_var_constraints_are_consistent_in_mode(user_defined_mode(_, ArgInsts), inst_var_sub::in, inst_var_sub::out) is semidet. inst_var_constraints_are_consistent_in_insts(Insts, !Sub) :- - list__foldl(inst_var_constraints_are_consistent_in_inst, Insts, !Sub). + list.foldl(inst_var_constraints_are_consistent_in_inst, Insts, !Sub). :- pred inst_var_constraints_are_consistent_in_inst(mer_inst::in, inst_var_sub::in, inst_var_sub::out) is semidet. @@ -3414,7 +3409,7 @@ inst_var_constraints_are_consistent_in_inst(any(_), !Sub). inst_var_constraints_are_consistent_in_inst(free, !Sub). inst_var_constraints_are_consistent_in_inst(free(_), !Sub). inst_var_constraints_are_consistent_in_inst(bound(_, BoundInsts), !Sub) :- - list__foldl((pred(functor(_, Insts)::in, in, out) is semidet --> + list.foldl((pred(functor(_, Insts)::in, in, out) is semidet --> inst_var_constraints_are_consistent_in_insts(Insts)), BoundInsts, !Sub). inst_var_constraints_are_consistent_in_inst(ground(_, GroundInstInfo), !Sub) :- @@ -3438,13 +3433,13 @@ inst_var_constraints_are_consistent_in_inst(abstract_inst(_, Insts), !Sub) :- inst_var_constraints_are_consistent_in_insts(Insts, !Sub). inst_var_constraints_are_consistent_in_inst( constrained_inst_vars(InstVars, Inst), !Sub) :- - set__fold((pred(InstVar::in, in, out) is semidet --> - ( Inst0 =^ map__elem(InstVar) -> + set.fold((pred(InstVar::in, in, out) is semidet --> + ( Inst0 =^ map.elem(InstVar) -> % Check that the inst_var constraint is consistent with % the previous constraint on this inst_var. { Inst = Inst0 } ; - ^ map__elem(InstVar) := Inst + ^ map.elem(InstVar) := Inst )), InstVars, !Sub), inst_var_constraints_are_consistent_in_inst(Inst, !Sub). @@ -3457,7 +3452,7 @@ inst_var_constraints_are_consistent_in_inst( parse_inst_decl(ModuleName, VarSet, InstDefn, Result) :- ( - InstDefn = term__functor(term__atom(Op), [H, B], _Context), + InstDefn = term.functor(term.atom(Op), [H, B], _Context), Op = "==" -> get_condition(B, Body, Condition), @@ -3466,17 +3461,17 @@ parse_inst_decl(ModuleName, VarSet, InstDefn, Result) :- ; % XXX This is for `abstract inst' declarations, % which are not really supported. - InstDefn = term__functor(term__atom("is"), - [Head, term__functor(term__atom("private"), [], _)], _) + InstDefn = term.functor(term.atom("is"), + [Head, term.functor(term.atom("private"), [], _)], _) -> Condition = true, convert_abstract_inst_defn(ModuleName, Head, R), process_maybe1(make_inst_defn(VarSet, Condition), R, Result) ; - InstDefn = term__functor(term__atom("--->"), [H, B], Context) + InstDefn = term.functor(term.atom("--->"), [H, B], Context) -> get_condition(B, Body, Condition), - Body1 = term__functor(term__atom("bound"), [Body], Context), + Body1 = term.functor(term.atom("bound"), [Body], Context), convert_inst_defn(ModuleName, H, Body1, R), % We should check the condition for errs (don't bother at the moment, % since we ignore conditions anyhow :-) @@ -3502,19 +3497,19 @@ convert_inst_defn_2(error(M, T), _, _, error(M, T)). convert_inst_defn_2(ok(Name, ArgTerms), Head, Body, Result) :- ( % Check that all the head args are variables. - term__var_list_to_term_list(Args, ArgTerms) + term.var_list_to_term_list(Args, ArgTerms) -> ( % Check that all the head arg variables are distinct. - list__member(Arg2, Args, [Arg2|OtherArgs]), - list__member(Arg2, OtherArgs) + list.member(Arg2, Args, [Arg2|OtherArgs]), + list.member(Arg2, OtherArgs) -> Result = error("repeated inst parameters in LHS of inst defn", Head) ; % Check that all the variables in the body occur in the head. - term__contains_var(Body, Var2), - \+ list__member(Var2, Args) + term.contains_var(Body, Var2), + \+ list.member(Var2, Args) -> Result = error("free inst parameter in RHS of inst definition", Body) @@ -3533,7 +3528,7 @@ convert_inst_defn_2(ok(Name, ArgTerms), Head, Body, Result) :- convert_inst(no_allow_constrained_inst_var, Body, ConvertedBody) -> - list__map(term__coerce_var, Args, InstArgs), + list.map(term.coerce_var, Args, InstArgs), Result = ok(processed_inst_body(Name, InstArgs, eqv_inst(ConvertedBody))) ; @@ -3566,17 +3561,17 @@ convert_abstract_inst_defn_2(error(M, T), _, error(M, T)). convert_abstract_inst_defn_2(ok(Name, ArgTerms), Head, Result) :- ( % Check that all the head args are variables. - term__var_list_to_term_list(Args, ArgTerms) + term.var_list_to_term_list(Args, ArgTerms) -> ( % Check that all the head arg variables are distinct. - list__member(Arg2, Args, [Arg2|OtherArgs]), - list__member(Arg2, OtherArgs) + list.member(Arg2, Args, [Arg2|OtherArgs]), + list.member(Arg2, OtherArgs) -> Result = error("repeated inst parameters " ++ "in abstract inst definition", Head) ; - list__map(term__coerce_var, Args, InstArgs), + list.map(term.coerce_var, Args, InstArgs), Result = ok(processed_inst_body(Name, InstArgs, abstract_inst)) ) ; @@ -3588,7 +3583,7 @@ convert_abstract_inst_defn_2(ok(Name, ArgTerms), Head, Result) :- make_inst_defn(VarSet0, Cond, processed_inst_body(Name, Params, InstDefn), inst_defn(VarSet, Name, Params, InstDefn, Cond)) :- - varset__coerce(VarSet0, VarSet). + varset.coerce(VarSet0, VarSet). %-----------------------------------------------------------------------------% @@ -3608,7 +3603,7 @@ parse_mode_decl(ModuleName, VarSet, ModeDefn, Attributes, Result) :- :- pred mode_op(term::in, term::out, term::out) is semidet. -mode_op(term__functor(term__atom(Op), [H, B], _), H, B) :- +mode_op(term.functor(term.atom(Op), [H, B], _), H, B) :- Op = "==". :- type processed_mode_body @@ -3633,19 +3628,19 @@ convert_mode_defn_2(error(M, T), _, _, error(M, T)). convert_mode_defn_2(ok(Name, ArgTerms), Head, Body, Result) :- ( % Check that all the head args are variables. - term__var_list_to_term_list(Args, ArgTerms) + term.var_list_to_term_list(Args, ArgTerms) -> ( % Check that all the head arg variables are distinct. - list__member(Arg2, Args, [Arg2|OtherArgs]), - list__member(Arg2, OtherArgs) + list.member(Arg2, Args, [Arg2|OtherArgs]), + list.member(Arg2, OtherArgs) -> Result = error("repeated parameters in LHS of mode defn", Head) ; % Check that all the variables in the body occur in the head. - term__contains_var(Body, Var2), - \+ list__member(Var2, Args) + term.contains_var(Body, Var2), + \+ list.member(Var2, Args) -> Result = error("free inst parameter in RHS of mode definition", Body) @@ -3655,7 +3650,7 @@ convert_mode_defn_2(ok(Name, ArgTerms), Head, Body, Result) :- convert_mode(no_allow_constrained_inst_var, Body, ConvertedBody) -> - list__map(term__coerce_var, Args, InstArgs), + list.map(term.coerce_var, Args, InstArgs), Result = ok(processed_mode_body(Name, InstArgs, eqv_mode(ConvertedBody))) ; @@ -3680,7 +3675,7 @@ convert_type_and_mode_list(InstConstraints, [H0|T0], [H|T]) :- is semidet. convert_type_and_mode(InstConstraints, Term, Result) :- - ( Term = term__functor(term__atom("::"), [TypeTerm, ModeTerm], _Context) -> + ( Term = term.functor(term.atom("::"), [TypeTerm, ModeTerm], _Context) -> parse_type(TypeTerm, ok(Type)), convert_mode(allow_constrained_inst_var, ModeTerm, Mode0), constrain_inst_vars_in_mode(InstConstraints, Mode0, Mode), @@ -3695,7 +3690,7 @@ convert_type_and_mode(InstConstraints, Term, Result) :- make_mode_defn(VarSet0, Cond, processed_mode_body(Name, Params, ModeDefn), mode_defn(VarSet, Name, Params, ModeDefn, Cond)) :- - varset__coerce(VarSet0, VarSet). + varset.coerce(VarSet0, VarSet). %-----------------------------------------------------------------------------% @@ -3719,7 +3714,7 @@ parse_symlist_decl(ParserPred, MakeSymListPred, MakeModuleDefnPred, make_module_defn(MakeSymListPred, MakeModuleDefnPred, VarSet0, T, module_defn(VarSet, ModuleDefn)) :- - varset__coerce(VarSet0, VarSet), + varset.coerce(VarSet0, VarSet), call(MakeSymListPred, T, SymList), call(MakeModuleDefnPred, SymList, ModuleDefn). @@ -3789,7 +3784,7 @@ make_op(X, op(X)). :- pred parse_symbol_specifier(term::in, maybe1(sym_specifier)::out) is det. parse_symbol_specifier(MainTerm, Result) :- - ( MainTerm = term__functor(term__atom(Functor), [Term], _Context) -> + ( MainTerm = term.functor(term.atom(Functor), [Term], _Context) -> ( Functor = "cons" -> parse_constructor_specifier(Term, Result0), process_maybe1(make_cons_symbol_specifier, Result0, Result) @@ -3881,7 +3876,7 @@ parse_module_specifier(Term, Result) :- maybe1(module_name)::out) is det. parse_module_name(DefaultModuleName, Term, Result) :- - ( Term = term__variable(_) -> + ( Term = term.variable(_) -> dummy_term(ErrorContext), Result = error("module names starting with " ++ "capital letters must be quoted using " ++ @@ -3911,7 +3906,7 @@ parse_module_name(DefaultModuleName, Term, Result) :- parse_constructor_specifier(Term, Result) :- ( - Term = term__functor(term__atom("::"), [NameArgsTerm, TypeTerm], + Term = term.functor(term.atom("::"), [NameArgsTerm, TypeTerm], _Context) -> parse_arg_types_specifier(NameArgsTerm, NameArgsResult), @@ -3933,7 +3928,7 @@ parse_constructor_specifier(Term, Result) :- is det. parse_predicate_specifier(Term, Result) :- - ( Term = term__functor(term__atom("/"), [_,_], _Context) -> + ( Term = term.functor(term.atom("/"), [_,_], _Context) -> parse_symbol_name_specifier(Term, NameResult), process_maybe1(make_arity_predicate_specifier, NameResult, Result) ; @@ -3975,7 +3970,7 @@ make_arity_predicate_specifier(Result, sym(Result)). is det. parse_arg_types_specifier(Term, Result) :- - ( Term = term__functor(term__atom("/"), [_,_], _Context) -> + ( Term = term.functor(term.atom("/"), [_,_], _Context) -> parse_symbol_name_specifier(Term, NameResult), process_maybe1(make_arity_predicate_specifier, NameResult, Result) ; @@ -4026,10 +4021,10 @@ parse_symbol_name_specifier(Term, Result) :- parse_implicitly_qualified_symbol_name_specifier(DefaultModule, Term, Result) :- ( - Term = term__functor(term__atom("/"), [NameTerm, ArityTerm], _Context) + Term = term.functor(term.atom("/"), [NameTerm, ArityTerm], _Context) -> ( - ArityTerm = term__functor(term__integer(Arity), [], _Context2) + ArityTerm = term.functor(term.integer(Arity), [], _Context2) -> ( Arity >= 0 -> parse_implicitly_qualified_symbol_name(DefaultModule, NameTerm, @@ -4076,14 +4071,14 @@ make_name_specifier(Name, name(Name)). parse_symbol_name(Term, Result) :- ( - Term = term__functor(term__atom(FunctorName), [ModuleTerm, NameTerm], + Term = term.functor(term.atom(FunctorName), [ModuleTerm, NameTerm], _Context), ( FunctorName = ":" ; FunctorName = "." ) -> ( - NameTerm = term__functor(term__atom(Name), [], _Context1) + NameTerm = term.functor(term.atom(Name), [], _Context1) -> parse_symbol_name(ModuleTerm, ModuleResult), ( @@ -4091,22 +4086,22 @@ parse_symbol_name(Term, Result) :- Result = ok(qualified(Module, Name)) ; ModuleResult = error(_, _), - term__coerce(Term, ErrorTerm), + term.coerce(Term, ErrorTerm), Result = error("module name identifier " ++ "expected before ':' in qualified " ++ "symbol name", ErrorTerm) ) ; - term__coerce(Term, ErrorTerm), + term.coerce(Term, ErrorTerm), Result = error("identifier expected after ':' " ++ "in qualified symbol name", ErrorTerm) ) ; - ( Term = term__functor(term__atom(Name), [], _Context3) -> + ( Term = term.functor(term.atom(Name), [], _Context3) -> string_to_sym_name(Name, "__", SymName), Result = ok(SymName) ; - term__coerce(Term, ErrorTerm), + term.coerce(Term, ErrorTerm), Result = error("symbol name expected", ErrorTerm) ) ). @@ -4152,7 +4147,7 @@ parse_implicitly_qualified_term(DefaultModName, Term, ContainingTerm, Msg, SymName = qualified(ModName, _), \+ match_sym_name(ModName, DefaultModName) -> - term__coerce(Term, ErrorTerm), + term.coerce(Term, ErrorTerm), Result = error("module qualifier in definition " ++ "does not match preceding " ++ " `:- module' declaration", ErrorTerm) @@ -4166,42 +4161,42 @@ parse_implicitly_qualified_term(DefaultModName, Term, ContainingTerm, Msg, parse_qualified_term(Term, ContainingTerm, Msg, Result) :- ( - Term = term__functor(term__atom(FunctorName), + Term = term.functor(term.atom(FunctorName), [ModuleTerm, NameArgsTerm], _), FunctorName = "." -> - ( NameArgsTerm = term__functor(term__atom(Name), Args, _) -> + ( NameArgsTerm = term.functor(term.atom(Name), Args, _) -> parse_symbol_name(ModuleTerm, ModuleResult), ( ModuleResult = ok(Module), Result = ok(qualified(Module, Name), Args) ; ModuleResult = error(_, _), - term__coerce(Term, ErrorTerm), + term.coerce(Term, ErrorTerm), Result = error("module name identifier " ++ "expected before '.' in " ++ "qualified symbol name", ErrorTerm) ) ; - term__coerce(Term, ErrorTerm), + term.coerce(Term, ErrorTerm), Result = error("identifier expected after '.' " ++ "in qualified symbol name", ErrorTerm) ) ; - ( Term = term__functor(term__atom(Name), Args, _) -> + ( Term = term.functor(term.atom(Name), Args, _) -> string_to_sym_name(Name, "__", SymName), Result = ok(SymName, Args) ; - string__append("atom expected in ", Msg, ErrorMsg), - % Since variables don't have any term__context, if Term is + string.append("atom expected in ", Msg, ErrorMsg), + % Since variables don't have any term.context, if Term is % a variable, we use ContainingTerm instead (hopefully that - % _will_ have a term__context). - ( Term = term__variable(_) -> + % _will_ have a term.context). + ( Term = term.variable(_) -> ErrorTerm0 = ContainingTerm ; ErrorTerm0 = Term ), - term__coerce(ErrorTerm0, ErrorTerm), + term.coerce(ErrorTerm0, ErrorTerm), Result = error(ErrorMsg, ErrorTerm) ) ). @@ -4267,7 +4262,7 @@ make_op_specifier(X, sym(X)). convert_constructor_arg_list(_ModuleName, []) = ok([]). convert_constructor_arg_list( ModuleName, [Term | Terms]) = Result :- - ( Term = term__functor(term__atom("::"), [NameTerm, TypeTerm], _) -> + ( Term = term.functor(term.atom("::"), [NameTerm, TypeTerm], _) -> parse_implicitly_qualified_term(ModuleName, NameTerm, Term, "field name", NameResult), ( diff --git a/compiler/prog_io_dcg.m b/compiler/prog_io_dcg.m index cc0fc975c..77e3a4032 100644 --- a/compiler/prog_io_dcg.m +++ b/compiler/prog_io_dcg.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1996-2001, 2003-2005 The University of Melbourne. +% Copyright (C) 1996-2001, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -17,7 +17,7 @@ % roughly Head --> G1, G2, {G3}, G4. % becomes Head(!DCG) :- G1(!DCG), G2(!DCG), G3, G4(!DCG). -:- module parse_tree__prog_io_dcg. +:- module parse_tree.prog_io_dcg. :- interface. @@ -59,8 +59,8 @@ parse_dcg_clause(ModuleName, VarSet0, DCG_Head, DCG_Body, DCG_Context, Result) :- - varset__coerce(VarSet0, ProgVarSet0), - new_dcg_var(ProgVarSet0, ProgVarSet1, counter__init(0), Counter0, + varset.coerce(VarSet0, ProgVarSet0), + new_dcg_var(ProgVarSet0, ProgVarSet1, counter.init(0), Counter0, DCG_0_Var), parse_dcg_goal(DCG_Body, Body, ProgVarSet1, ProgVarSet, Counter0, _Counter, DCG_0_Var, DCG_Var), @@ -72,7 +72,7 @@ parse_dcg_clause(ModuleName, VarSet0, DCG_Head, DCG_Body, DCG_Context, %-----------------------------------------------------------------------------% parse_dcg_pred_goal(GoalTerm, Goal, DCGVar0, DCGVar, !VarSet) :- - new_dcg_var(!VarSet, counter__init(0), Counter0, DCGVar0), + new_dcg_var(!VarSet, counter.init(0), Counter0, DCGVar0), parse_dcg_goal(GoalTerm, Goal, !VarSet, Counter0, _Counter, DCGVar0, DCGVar). @@ -84,11 +84,11 @@ parse_dcg_pred_goal(GoalTerm, Goal, DCGVar0, DCGVar, !VarSet) :- counter::in, counter::out, prog_var::out) is det. new_dcg_var(!VarSet, !Counter, DCG_0_Var) :- - counter__allocate(N, !Counter), - string__int_to_string(N, StringN), - string__append("DCG_", StringN, VarName), - varset__new_var(!.VarSet, DCG_0_Var, !:VarSet), - varset__name_var(!.VarSet, DCG_0_Var, VarName, !:VarSet). + counter.allocate(N, !Counter), + string.int_to_string(N, StringN), + string.append("DCG_", StringN, VarName), + varset.new_var(!.VarSet, DCG_0_Var, !:VarSet), + varset.name_var(!.VarSet, DCG_0_Var, VarName, !:VarSet). %-----------------------------------------------------------------------------% @@ -100,20 +100,20 @@ new_dcg_var(!VarSet, !Counter, DCG_0_Var) :- parse_dcg_goal(Term, Goal, !VarSet, !Counter, !Var) :- % First, figure out the context for the goal. ( - Term = term__functor(_, _, Context) + Term = term.functor(_, _, Context) ; - Term = term__variable(_), - term__context_init(Context) + Term = term.variable(_), + term.context_init(Context) ), % Next, parse it. ( - term__coerce(Term, ProgTerm), + term.coerce(Term, ProgTerm), sym_name_and_args(ProgTerm, SymName, Args0) -> % First check for the special cases: ( SymName = unqualified(Functor), - list__map(term__coerce, Args0, Args1), + list.map(term.coerce, Args0, Args1), parse_dcg_goal_2(Functor, Args1, Context, Goal1, !VarSet, !Counter, !Var) -> @@ -123,7 +123,7 @@ parse_dcg_goal(Term, Goal, !VarSet, !Counter, !Var) :- % as the DCG output var from this goal, and append the DCG argument % pair to the non-terminal's argument list. new_dcg_var(!VarSet, !Counter, Var), - Args = Args0 ++ [term__variable(!.Var), term__variable(Var)], + Args = Args0 ++ [term.variable(!.Var), term.variable(Var)], Goal = call(SymName, Args, purity_pure) - Context, !:Var = Var ) @@ -132,9 +132,9 @@ parse_dcg_goal(Term, Goal, !VarSet, !Counter, !Var) :- % Just translate it into a call to call/3 - the typechecker % will catch calls to numbers and strings. new_dcg_var(!VarSet, !Counter, Var), - term__coerce(Term, ProgTerm), + term.coerce(Term, ProgTerm), Goal = call(unqualified("call"), - [ProgTerm, term__variable(!.Var), term__variable(Var)], + [ProgTerm, term.variable(!.Var), term.variable(Var)], purity_pure) - Context, !:Var = Var ). @@ -209,7 +209,7 @@ parse_dcg_goal_2("promise_impure_implicit", [G], Context, Goal, parse_dcg_goal_2("[]", [], Context, Goal, !VarSet, !Counter, Var0, Var) :- % Empty list - just unify the input and output DCG args. new_dcg_var(!VarSet, !Counter, Var), - Goal = unify(term__variable(Var0), term__variable(Var), purity_pure) + Goal = unify(term.variable(Var0), term.variable(Var), purity_pure) - Context. parse_dcg_goal_2("[|]", [X, Xs], Context, Goal, !VarSet, !Counter, @@ -217,21 +217,21 @@ parse_dcg_goal_2("[|]", [X, Xs], Context, Goal, !VarSet, !Counter, % Non-empty list of terminals. Append the DCG output arg as the new tail % of the list, and unify the result with the DCG input arg. new_dcg_var(!VarSet, !Counter, Var), - ConsTerm0 = term__functor(term__atom("[|]"), [X, Xs], Context), - term__coerce(ConsTerm0, ConsTerm), - term_list_append_term(ConsTerm, term__variable(Var), Term), - Goal = unify(term__variable(Var0), Term, purity_pure) - Context. + ConsTerm0 = term.functor(term.atom("[|]"), [X, Xs], Context), + term.coerce(ConsTerm0, ConsTerm), + term_list_append_term(ConsTerm, term.variable(Var), Term), + Goal = unify(term.variable(Var0), Term, purity_pure) - Context. parse_dcg_goal_2("=", [A0], Context, Goal, !VarSet, !Counter, Var, Var) :- % Call to '='/1 - unify argument with DCG input arg. - term__coerce(A0, A), - Goal = unify(A, term__variable(Var), purity_pure) - Context. + term.coerce(A0, A), + Goal = unify(A, term.variable(Var), purity_pure) - Context. parse_dcg_goal_2(":=", [A0], Context, Goal, !VarSet, !Counter, _Var0, Var) :- % Call to ':='/1 - unify argument with DCG output arg. new_dcg_var(!VarSet, !Counter, Var), - term__coerce(A0, A), - Goal = unify(A, term__variable(Var), purity_pure) - Context. + term.coerce(A0, A), + Goal = unify(A, term.variable(Var), purity_pure) - Context. % parse_dcg_goal_2("->", [Cond0, Then0], Context, VarSet0, Counter0, Var0, % Goal, VarSet, Counter, Var) :- @@ -242,12 +242,12 @@ parse_dcg_goal_2(":=", [A0], Context, Goal, !VarSet, !Counter, _Var0, Var) :- % ( Var = Var0 -> % Goal = if_then(SomeVars, StateVars, Cond, Then) - Context % ; -% Unify = unify(term__variable(Var), term__variable(Var0)), +% Unify = unify(term.variable(Var), term.variable(Var0)), % Goal = if_then_else(SomeVars, StateVars, Cond, Then, % Unify - Context) - Context % ). -parse_dcg_goal_2("if", [term__functor(term__atom("then"), [Cond0, Then0], _)], +parse_dcg_goal_2("if", [term.functor(term.atom("then"), [Cond0, Then0], _)], Context, Goal, !VarSet, !Counter, Var0, Var) :- % If-then (NU-Prolog syntax). parse_dcg_if_then(Cond0, Then0, Context, SomeVars, StateVars, @@ -255,7 +255,7 @@ parse_dcg_goal_2("if", [term__functor(term__atom("then"), [Cond0, Then0], _)], ( Var = Var0 -> Goal = if_then(SomeVars, StateVars, Cond, Then) - Context ; - Unify = unify(term__variable(Var), term__variable(Var0), purity_pure), + Unify = unify(term.variable(Var), term.variable(Var0), purity_pure), Goal = if_then_else(SomeVars, StateVars, Cond, Then, Unify - Context) - Context ). @@ -274,7 +274,7 @@ parse_dcg_goal_2("&", [A0, B0], Context, (A & B) - Context, parse_dcg_goal_2(";", [A0, B0], Context, Goal, !VarSet, !Counter, Var0, Var) :- % Disjunction or if-then-else (Prolog syntax). ( - A0 = term__functor(term__atom("->"), [Cond0, Then0], _Context) + A0 = term.functor(term.atom("->"), [Cond0, Then0], _Context) -> parse_dcg_if_then_else(Cond0, Then0, B0, Context, Goal, !VarSet, !Counter, Var0, Var) @@ -286,27 +286,27 @@ parse_dcg_goal_2(";", [A0, B0], Context, Goal, !VarSet, !Counter, Var0, Var) :- Goal = (A1 ; B1) - Context ; VarA = Var0 -> Var = VarB, - Unify = unify(term__variable(Var), term__variable(VarA), + Unify = unify(term.variable(Var), term.variable(VarA), purity_pure), append_to_disjunct(A1, Unify, Context, A2), Goal = (A2 ; B1) - Context ; VarB = Var0 -> Var = VarA, - Unify = unify(term__variable(Var), term__variable(VarB), + Unify = unify(term.variable(Var), term.variable(VarB), purity_pure), append_to_disjunct(B1, Unify, Context, B2), Goal = (A1 ; B2) - Context ; Var = VarB, - prog_util__rename_in_goal(VarA, VarB, A1, A2), + prog_util.rename_in_goal(VarA, VarB, A1, A2), Goal = (A2 ; B1) - Context ) ). parse_dcg_goal_2("else", [IF, Else0], _, Goal, !VarSet, !Counter, !Var) :- % If-then-else (NU-Prolog syntax). - IF = term__functor(term__atom("if"), - [term__functor(term__atom("then"), [Cond0, Then0], _)], Context), + IF = term.functor(term.atom("if"), + [term.functor(term.atom("then"), [Cond0, Then0], _)], Context), parse_dcg_if_then_else(Cond0, Then0, Else0, Context, Goal, !VarSet, !Counter, !Var). @@ -325,8 +325,8 @@ parse_dcg_goal_2("all", [QVars, A0], Context, GoalExpr - Context, % Universal quantification. % Extract any state variables in the quantifier. parse_quantifier_vars(QVars, StateVars0, Vars0), - list__map(term__coerce_var, StateVars0, StateVars), - list__map(term__coerce_var, Vars0, Vars), + list.map(term.coerce_var, StateVars0, StateVars), + list.map(term.coerce_var, Vars0, Vars), parse_dcg_goal(A0, A @ (GoalExprA - ContextA), !VarSet, !Counter, !Var), ( @@ -352,8 +352,8 @@ parse_dcg_goal_2("some", [QVars, A0], Context, GoalExpr - Context, % Existential quantification. % Extract any state variables in the quantifier. parse_quantifier_vars(QVars, StateVars0, Vars0), - list__map(term__coerce_var, StateVars0, StateVars), - list__map(term__coerce_var, Vars0, Vars), + list.map(term.coerce_var, StateVars0, StateVars), + list.map(term.coerce_var, Vars0, Vars), parse_dcg_goal(A0, A @ (GoalExprA - ContextA), !VarSet, !Counter, !Var), ( @@ -390,7 +390,7 @@ parse_dcg_goal_with_purity(G, Purity, Goal, !VarSet, !Counter, !Var) :- % descriptive for these errors. Goal1 = _ - Context, purity_name(Purity, PurityString), - term__coerce(G, G1), + term.coerce(G, G1), Goal = call(unqualified(PurityString), [G1], purity_pure) - Context ). @@ -412,14 +412,14 @@ append_to_disjunct(Disjunct0, Goal, Context, Disjunct) :- parse_some_vars_dcg_goal(A0, SomeVars, StateVars, A, !VarSet, !Counter, !Var) :- - ( A0 = term__functor(term__atom("some"), [QVars0, A1], _Context) -> - term__coerce(QVars0, QVars), + ( A0 = term.functor(term.atom("some"), [QVars0, A1], _Context) -> + term.coerce(QVars0, QVars), ( parse_quantifier_vars(QVars, StateVars0, SomeVars0) -> SomeVars = SomeVars0, StateVars = StateVars0 ; % XXX A hack because we do not do error checking in this module. - term__vars(QVars, SomeVars), + term.vars(QVars, SomeVars), StateVars = [] ), A2 = A1 @@ -464,7 +464,7 @@ parse_dcg_if_then(Cond0, Then0, Context, SomeVars, StateVars, Cond, Then, Var1 = Var2 -> new_dcg_var(!VarSet, !Counter, Var), - Unify = unify(term__variable(Var), term__variable(Var2), purity_pure), + Unify = unify(term.variable(Var), term.variable(Var2), purity_pure), Then = (Then1, Unify - Context) - Context ; Then = Then1, @@ -486,14 +486,14 @@ parse_dcg_if_then_else(Cond0, Then0, Else0, Context, Goal, Else = Else1 ; VarThen = Var0 -> Var = VarElse, - Unify = unify(term__variable(Var), term__variable(VarThen), + Unify = unify(term.variable(Var), term.variable(VarThen), purity_pure), Then = (Then1, Unify - Context) - Context, Else = Else1 ; VarElse = Var0 -> Var = VarThen, Then = Then1, - Unify = unify(term__variable(Var), term__variable(VarElse), + Unify = unify(term.variable(Var), term.variable(VarElse), purity_pure), Else = (Else1, Unify - Context) - Context ; @@ -507,7 +507,7 @@ parse_dcg_if_then_else(Cond0, Then0, Else0, Context, Goal, % in the condition. Var = VarElse, - prog_util__rename_in_goal(VarThen, VarElse, Then1, Then), + prog_util.rename_in_goal(VarThen, VarElse, Then1, Then), Else = Else1 ), Goal = if_then_else(SomeVars, StateVars, Cond, Then, Else) - Context. @@ -521,11 +521,11 @@ parse_dcg_if_then_else(Cond0, Then0, Else0, Context, Goal, is semidet. term_list_append_term(List0, Term, List) :- - ( List0 = term__functor(term__atom("[]"), [], _Context) -> + ( List0 = term.functor(term.atom("[]"), [], _Context) -> List = Term ; - List0 = term__functor(term__atom("[|]"), [Head, Tail0], Context2), - List = term__functor(term__atom("[|]"), [Head, Tail], Context2), + List0 = term.functor(term.atom("[|]"), [Head, Tail0], Context2), + List = term.functor(term.atom("[|]"), [Head, Tail], Context2), term_list_append_term(Tail0, Term, Tail) ). @@ -534,6 +534,6 @@ term_list_append_term(List0, Term, List) :- process_dcg_clause(ok(Name, Args0), VarSet, Var0, Var, Body, ok(clause(user, VarSet, predicate, Name, Args, Body))) :- - list__map(term__coerce, Args0, Args1), - list__append(Args1, [term__variable(Var0), term__variable(Var)], Args). + list.map(term.coerce, Args0, Args1), + list.append(Args1, [term.variable(Var0), term.variable(Var)], Args). process_dcg_clause(error(Message, Term), _, _, _, _, error(Message, Term)). diff --git a/compiler/prog_io_goal.m b/compiler/prog_io_goal.m index f1f4190da..8ce7a20e2 100644 --- a/compiler/prog_io_goal.m +++ b/compiler/prog_io_goal.m @@ -11,7 +11,7 @@ % % This module defines the predicates that parse goals. -:- module parse_tree__prog_io_goal. +:- module parse_tree.prog_io_goal. :- interface. @@ -98,23 +98,23 @@ parse_goal(Term, Goal, !VarSet) :- % First, get the goal context. ( - Term = term__functor(_, _, Context) + Term = term.functor(_, _, Context) ; - Term = term__variable(_), - term__context_init(Context) + Term = term.variable(_), + term.context_init(Context) ), % We just check if it matches the appropriate pattern for one of the % builtins. If it doesn't match any of the builtins, then it's just % a predicate call. ( % Check for builtins... - Term = term__functor(term__atom(Name), Args, Context), + Term = term.functor(term.atom(Name), Args, Context), parse_goal_2(Name, Args, GoalExpr, !VarSet) -> Goal = GoalExpr - Context ; % It's not a builtin. - term__coerce(Term, ArgsTerm), + term.coerce(Term, ArgsTerm), ( % Check for predicate calls. sym_name_and_args(ArgsTerm, SymName, Args) @@ -141,8 +141,8 @@ parse_goal(Term, Goal, !VarSet) :- parse_goal_2("true", [], true, !V). parse_goal_2("fail", [], fail, !V). parse_goal_2("=", [A0, B0], unify(A, B, purity_pure), !V) :- - term__coerce(A0, A), - term__coerce(B0, B). + term.coerce(A0, A), + term.coerce(B0, B). parse_goal_2(",", [A0, B0], (A, B), !V) :- parse_goal(A0, A, !V), parse_goal(B0, B, !V). @@ -150,7 +150,7 @@ parse_goal_2("&", [A0, B0], (A & B), !V) :- parse_goal(A0, A, !V), parse_goal(B0, B, !V). parse_goal_2(";", [A0, B0], R, !V) :- - ( A0 = term__functor(term__atom("->"), [X0, Y0], _Context) -> + ( A0 = term.functor(term.atom("->"), [X0, Y0], _Context) -> parse_some_vars_goal(X0, Vars, StateVars, X, !V), parse_goal(Y0, Y, !V), parse_goal(B0, B, !V), @@ -161,8 +161,8 @@ parse_goal_2(";", [A0, B0], R, !V) :- R = (A;B) ). parse_goal_2("else", [IF, C0], if_then_else(Vars, StateVars, A, B, C), !V) :- - IF = term__functor(term__atom("if"), - [term__functor(term__atom("then"), [A0, B0], _)], _), + IF = term.functor(term.atom("if"), + [term.functor(term.atom("then"), [A0, B0], _)], _), parse_some_vars_goal(A0, Vars, StateVars, A, !V), parse_goal(B0, B, !V), parse_goal(C0, C, !V). @@ -176,8 +176,8 @@ parse_goal_2("\\+", [A0], not(A), !V) :- parse_goal_2("all", [QVars, A0], GoalExpr, !V):- % Extract any state variables in the quantifier. parse_quantifier_vars(QVars, StateVars0, Vars0), - list__map(term__coerce_var, StateVars0, StateVars), - list__map(term__coerce_var, Vars0, Vars), + list.map(term.coerce_var, StateVars0, StateVars), + list.map(term.coerce_var, Vars0, Vars), parse_goal(A0, A @ (GoalExprA - ContextA), !V), @@ -212,8 +212,8 @@ parse_goal_2("<=>", [A0, B0], equivalent(A, B), !V):- parse_goal_2("some", [QVars, A0], GoalExpr, !V):- % Extract any state variables in the quantifier. parse_quantifier_vars(QVars, StateVars0, Vars0), - list__map(term__coerce_var, StateVars0, StateVars), - list__map(term__coerce_var, Vars0, Vars), + list.map(term.coerce_var, StateVars0, StateVars), + list.map(term.coerce_var, Vars0, Vars), parse_goal(A0, A @ (GoalExprA - ContextA), !V), ( @@ -233,9 +233,9 @@ parse_goal_2("some", [QVars, A0], GoalExpr, !V):- parse_goal_2("promise_equivalent_solutions", [OVars, A0], GoalExpr, !V):- parse_goal(A0, A, !V), parse_vars_and_state_vars(OVars, Vars0, DotSVars0, ColonSVars0), - list__map(term__coerce_var, Vars0, Vars), - list__map(term__coerce_var, DotSVars0, DotSVars), - list__map(term__coerce_var, ColonSVars0, ColonSVars), + list.map(term.coerce_var, Vars0, Vars), + list.map(term.coerce_var, DotSVars0, DotSVars), + list.map(term.coerce_var, ColonSVars0, ColonSVars), GoalExpr = promise_equivalent_solutions(Vars, DotSVars, ColonSVars, A). parse_goal_2("promise_pure", [A0], GoalExpr, !V):- @@ -266,8 +266,8 @@ parse_goal_2("promise_impure_implicit", [A0], GoalExpr, !V):- % we ought to handle it in the code generation - but then `is/2' itself % is a bit of a hack. parse_goal_2("is", [A0, B0], unify(A, B, purity_pure), !V) :- - term__coerce(A0, A), - term__coerce(B0, B). + term.coerce(A0, A), + term.coerce(B0, B). parse_goal_2("impure", [A0], A, !V) :- parse_goal_with_purity(A0, purity_impure, A, !V). parse_goal_2("semipure", [A0], A, !V) :- @@ -287,7 +287,7 @@ parse_goal_with_purity(A0, Purity, A, !V) :- % it like a predicate call. typecheck.m prints out something % descriptive for these errors. purity_name(Purity, PurityString), - term__coerce(A0, A2), + term.coerce(A0, A2), A = call(unqualified(PurityString), [A2], purity_pure) ). @@ -295,11 +295,11 @@ parse_goal_with_purity(A0, Purity, A, !V) :- parse_some_vars_goal(A0, Vars, StateVars, A, !VarSet) :- ( - A0 = term__functor(term__atom("some"), [QVars, A1], _Context), + A0 = term.functor(term.atom("some"), [QVars, A1], _Context), parse_quantifier_vars(QVars, StateVars0, Vars0) -> - list__map(term__coerce_var, StateVars0, StateVars), - list__map(term__coerce_var, Vars0, Vars), + list.map(term.coerce_var, StateVars0, StateVars), + list.map(term.coerce_var, Vars0, Vars), parse_goal(A1, A, !VarSet) ; Vars = [], @@ -312,8 +312,8 @@ parse_some_vars_goal(A0, Vars, StateVars, A, !VarSet) :- :- pred parse_lambda_arg(term::in, prog_term::out, mer_mode::out) is semidet. parse_lambda_arg(Term, ArgTerm, Mode) :- - Term = term__functor(term__atom("::"), [ArgTerm0, ModeTerm], _), - term__coerce(ArgTerm0, ArgTerm), + Term = term.functor(term.atom("::"), [ArgTerm0, ModeTerm], _), + term.coerce(ArgTerm0, ArgTerm), convert_mode(allow_constrained_inst_var, ModeTerm, Mode0), constrain_inst_vars_in_mode(Mode0, Mode). @@ -323,64 +323,64 @@ parse_lambda_arg(Term, ArgTerm, Mode) :- % parse_pred_expression(PredTerm, lambda_normal, Args, Modes, Det) :- - PredTerm = term__functor(term__atom("is"), [PredArgsTerm, DetTerm], _), - DetTerm = term__functor(term__atom(DetString), [], _), + PredTerm = term.functor(term.atom("is"), [PredArgsTerm, DetTerm], _), + DetTerm = term.functor(term.atom(DetString), [], _), standard_det(DetString, Det), - PredArgsTerm = term__functor(term__atom("pred"), PredArgsList, _), + PredArgsTerm = term.functor(term.atom("pred"), PredArgsList, _), parse_pred_expr_args(PredArgsList, Args, Modes), inst_var_constraints_are_consistent_in_modes(Modes). parse_dcg_pred_expression(PredTerm, lambda_normal, Args, Modes, Det) :- - PredTerm = term__functor(term__atom("is"), [PredArgsTerm, DetTerm], _), - DetTerm = term__functor(term__atom(DetString), [], _), + PredTerm = term.functor(term.atom("is"), [PredArgsTerm, DetTerm], _), + DetTerm = term.functor(term.atom(DetString), [], _), standard_det(DetString, Det), - PredArgsTerm = term__functor(term__atom("pred"), PredArgsList, _), + PredArgsTerm = term.functor(term.atom("pred"), PredArgsList, _), parse_dcg_pred_expr_args(PredArgsList, Args, Modes), inst_var_constraints_are_consistent_in_modes(Modes). parse_func_expression(FuncTerm, lambda_normal, Args, Modes, Det) :- % Parse a func expression with specified modes and determinism. - FuncTerm = term__functor(term__atom("is"), [EqTerm, DetTerm], _), - EqTerm = term__functor(term__atom("="), [FuncArgsTerm, RetTerm], _), - DetTerm = term__functor(term__atom(DetString), [], _), + FuncTerm = term.functor(term.atom("is"), [EqTerm, DetTerm], _), + EqTerm = term.functor(term.atom("="), [FuncArgsTerm, RetTerm], _), + DetTerm = term.functor(term.atom(DetString), [], _), standard_det(DetString, Det), - FuncArgsTerm = term__functor(term__atom("func"), FuncArgsList, _), + FuncArgsTerm = term.functor(term.atom("func"), FuncArgsList, _), ( parse_pred_expr_args(FuncArgsList, Args0, Modes0) -> parse_lambda_arg(RetTerm, RetArg, RetMode), - list__append(Args0, [RetArg], Args), - list__append(Modes0, [RetMode], Modes), + list.append(Args0, [RetArg], Args), + list.append(Modes0, [RetMode], Modes), inst_var_constraints_are_consistent_in_modes(Modes) ; % The argument modes default to `in', % the return mode defaults to `out'. in_mode(InMode), out_mode(OutMode), - list__length(FuncArgsList, NumArgs), - list__duplicate(NumArgs, InMode, Modes0), + list.length(FuncArgsList, NumArgs), + list.duplicate(NumArgs, InMode, Modes0), RetMode = OutMode, - list__append(Modes0, [RetMode], Modes), - list__append(FuncArgsList, [RetTerm], Args1), - list__map(term__coerce, Args1, Args) + list.append(Modes0, [RetMode], Modes), + list.append(FuncArgsList, [RetTerm], Args1), + list.map(term.coerce, Args1, Args) ). parse_func_expression(FuncTerm, lambda_normal, Args, Modes, Det) :- % Parse a func expression with unspecified modes and determinism. - FuncTerm = term__functor(term__atom("="), [FuncArgsTerm, RetTerm], _), - FuncArgsTerm = term__functor(term__atom("func"), Args0, _), + FuncTerm = term.functor(term.atom("="), [FuncArgsTerm, RetTerm], _), + FuncArgsTerm = term.functor(term.atom("func"), Args0, _), % The argument modes default to `in', the return mode defaults to `out', % and the determinism defaults to `det'. in_mode(InMode), out_mode(OutMode), - list__length(Args0, NumArgs), - list__duplicate(NumArgs, InMode, Modes0), + list.length(Args0, NumArgs), + list.duplicate(NumArgs, InMode, Modes0), RetMode = OutMode, Det = det, - list__append(Modes0, [RetMode], Modes), + list.append(Modes0, [RetMode], Modes), inst_var_constraints_are_consistent_in_modes(Modes), - list__append(Args0, [RetTerm], Args1), - list__map(term__coerce, Args1, Args). + list.append(Args0, [RetTerm], Args1), + list.map(term.coerce, Args1, Args). :- pred parse_pred_expr_args(list(term)::in, list(prog_term)::out, list(mer_mode)::out) is semidet. diff --git a/compiler/prog_io_pragma.m b/compiler/prog_io_pragma.m index 80c025c41..29c750bc2 100644 --- a/compiler/prog_io_pragma.m +++ b/compiler/prog_io_pragma.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module parse_tree__prog_io_pragma. +:- module parse_tree.prog_io_pragma. :- interface. :- import_module libs.globals. @@ -63,7 +63,7 @@ parse_pragma(ModuleName, VarSet, PragmaTerms, Result) :- PragmaTerms = [SinglePragmaTerm0], parse_type_decl_where_part_if_present(non_solver_type, ModuleName, SinglePragmaTerm0, SinglePragmaTerm, WherePartResult), - SinglePragmaTerm = term__functor(term__atom(PragmaType), + SinglePragmaTerm = term.functor(term.atom(PragmaType), PragmaArgs, _), parse_pragma_type(ModuleName, PragmaType, PragmaArgs, SinglePragmaTerm, VarSet, Result0) @@ -106,7 +106,7 @@ parse_pragma(ModuleName, VarSet, PragmaTerms, Result) :- parse_pragma_type(_, "source_file", PragmaTerms, ErrorTerm, _VarSet, Result) :- ( PragmaTerms = [SourceFileTerm] -> ( - SourceFileTerm = term__functor(term__string(SourceFile), [], _) + SourceFileTerm = term.functor(term.string(SourceFile), [], _) -> Result = ok(pragma(user, source_file(SourceFile))) ; @@ -141,7 +141,7 @@ parse_pragma_type(ModuleName, "foreign_type", PragmaTerms, ErrorTerm, VarSet, MaybeTypeDefnHead), ( MaybeTypeDefnHead = ok(MercuryTypeSymName, MercuryParams), - varset__coerce(VarSet, TVarSet), + varset.coerce(VarSet, TVarSet), ( parse_maybe_foreign_type_assertions(MaybeAssertionTerm, Assertions) @@ -188,9 +188,9 @@ parse_pragma_type(ModuleName, "foreign_decl", PragmaTerms, ErrorTerm, parse_pragma_type(ModuleName, "c_header_code", PragmaTerms, ErrorTerm, VarSet, Result) :- ( - PragmaTerms = [term__functor(_, _, Context) | _] + PragmaTerms = [term.functor(_, _, Context) | _] -> - LangC = term__functor(term__string("C"), [], Context), + LangC = term.functor(term.string("C"), [], Context), parse_pragma_foreign_decl_pragma(ModuleName, "c_header_code", [LangC | PragmaTerms], ErrorTerm, VarSet, Result) ; @@ -218,16 +218,16 @@ parse_pragma_type(ModuleName, "c_code", PragmaTerms, ErrorTerm, VarSet, Result) :- ( % arity = 1 (same as foreign_code) - PragmaTerms = [term__functor(_, _, Context)] + PragmaTerms = [term.functor(_, _, Context)] -> - LangC = term__functor(term__string("C"), [], Context), + LangC = term.functor(term.string("C"), [], Context), parse_pragma_foreign_code_pragma(ModuleName, "c_code", [LangC | PragmaTerms], ErrorTerm, VarSet, Result) ; % arity > 1 (same as foreign_proc) - PragmaTerms = [term__functor(_, _, Context) | _] + PragmaTerms = [term.functor(_, _, Context) | _] -> - LangC = term__functor(term__string("C"), [], Context), + LangC = term.functor(term.string("C"), [], Context), parse_pragma_foreign_proc_pragma(ModuleName, "c_code", [LangC | PragmaTerms], ErrorTerm, VarSet, Result) ; @@ -269,11 +269,11 @@ parse_pragma_type(_ModuleName, "foreign_import_module", PragmaTerms, ErrorTerm, :- pred parse_foreign_decl_is_local(term::in, foreign_decl_is_local::out) is semidet. -parse_foreign_decl_is_local(term__functor(Functor, [], _), IsLocal) :- +parse_foreign_decl_is_local(term.functor(Functor, [], _), IsLocal) :- ( - Functor = term__string(String) + Functor = term.string(String) ; - Functor = term__atom(String) + Functor = term.atom(String) ), ( String = "local", @@ -283,29 +283,29 @@ parse_foreign_decl_is_local(term__functor(Functor, [], _), IsLocal) :- IsLocal = foreign_decl_is_exported ). -parse_foreign_language(term__functor(term__string(String), _, _), Lang) :- - globals__convert_foreign_language(String, Lang). -parse_foreign_language(term__functor(term__atom(String), _, _), Lang) :- - globals__convert_foreign_language(String, Lang). +parse_foreign_language(term.functor(term.string(String), _, _), Lang) :- + globals.convert_foreign_language(String, Lang). +parse_foreign_language(term.functor(term.atom(String), _, _), Lang) :- + globals.convert_foreign_language(String, Lang). :- pred parse_foreign_language_type(term::in, foreign_language::in, maybe1(foreign_language_type)::out) is det. parse_foreign_language_type(InputTerm, Language, Result) :- ( Language = il -> - ( InputTerm = term__functor(term__string(ILTypeName), [], _) -> + ( InputTerm = term.functor(term.string(ILTypeName), [], _) -> parse_il_type_name(ILTypeName, InputTerm, Result) ; Result = error("invalid backend specification term", InputTerm) ) ; Language = c -> - ( InputTerm = term__functor(term__string(CTypeName), [], _) -> + ( InputTerm = term.functor(term.string(CTypeName), [], _) -> Result = ok(c(c(CTypeName))) ; Result = error("invalid backend specification term", InputTerm) ) ; Language = java -> - ( InputTerm = term__functor(term__string(JavaTypeName), [], _) -> + ( InputTerm = term.functor(term.string(JavaTypeName), [], _) -> Result = ok(java(java(JavaTypeName))) ; Result = error("invalid backend specification term", InputTerm) @@ -324,19 +324,19 @@ parse_il_type_name(String0, ErrorTerm, ForeignType) :- -> ForeignType = ok(il(ForeignTypeResult)) ; - string__append("class [", String1, String0), - string__sub_string_search(String1, "]", Index) + string.append("class [", String1, String0), + string.sub_string_search(String1, "]", Index) -> - string__left(String1, Index, AssemblyName), - string__split(String1, Index + 1, _, TypeNameStr), + string.left(String1, Index, AssemblyName), + string.split(String1, Index + 1, _, TypeNameStr), string_to_sym_name(TypeNameStr, ".", TypeSymName), ForeignType = ok(il(il(reference, AssemblyName, TypeSymName))) ; - string__append("valuetype [", String1, String0), - string__sub_string_search(String1, "]", Index) + string.append("valuetype [", String1, String0), + string.sub_string_search(String1, "]", Index) -> - string__left(String1, Index, AssemblyName), - string__split(String1, Index + 1, _, TypeNameStr), + string.left(String1, Index, AssemblyName), + string.split(String1, Index + 1, _, TypeNameStr), string_to_sym_name(TypeNameStr, ".", TypeSymName), ForeignType = ok(il(il(value, AssemblyName, TypeSymName))) ; @@ -403,10 +403,10 @@ parse_maybe_foreign_type_assertions(yes(Term), Assertions) :- list(foreign_type_assertion)::out) is semidet. parse_foreign_type_assertions(Term, Assertions) :- - ( Term = term__functor(term__atom("[]"), [], _) -> + ( Term = term.functor(term.atom("[]"), [], _) -> Assertions = [] ; - Term = term__functor(term__atom("[|]"), [Head, Tail], _), + Term = term.functor(term.atom("[|]"), [Head, Tail], _), parse_foreign_type_assertion(Head, HeadAssertion), parse_foreign_type_assertions(Tail, TailAssertions), Assertions = [HeadAssertion | TailAssertions] @@ -416,11 +416,11 @@ parse_foreign_type_assertions(Term, Assertions) :- foreign_type_assertion::out) is semidet. parse_foreign_type_assertion(Term, Assertion) :- - Term = term__functor(term__atom(Constant), [], _), + Term = term.functor(term.atom(Constant), [], _), Constant = "can_pass_as_mercury_type", Assertion = can_pass_as_mercury_type. parse_foreign_type_assertion(Term, Assertion) :- - Term = term__functor(term__atom(Constant), [], _), + Term = term.functor(term.atom(Constant), [], _), Constant = "stable", Assertion = stable. @@ -431,7 +431,7 @@ parse_foreign_type_assertion(Term, Assertion) :- parse_pragma_foreign_decl_pragma(_ModuleName, Pragma, PragmaTerms, ErrorTerm, _VarSet, Result) :- - string__format("invalid `:- pragma %s' declaration ", [s(Pragma)], + string.format("invalid `:- pragma %s' declaration ", [s(Pragma)], InvalidDeclStr), ( ( @@ -443,12 +443,12 @@ parse_pragma_foreign_decl_pragma(_ModuleName, Pragma, PragmaTerms, ) -> ( parse_foreign_language(LangTerm, ForeignLanguage) -> - ( HeaderTerm = term__functor(term__string( HeaderCode), [], _) -> + ( HeaderTerm = term.functor(term.string( HeaderCode), [], _) -> DeclCode = foreign_decl(ForeignLanguage, IsLocal, HeaderCode), Result = ok(pragma(user, DeclCode)) ; ErrMsg = "-- expected string for foreign declaration code", - Result = error(string__append(InvalidDeclStr, ErrMsg), + Result = error(string.append(InvalidDeclStr, ErrMsg), HeaderTerm) ) ; @@ -456,7 +456,7 @@ parse_pragma_foreign_decl_pragma(_ModuleName, Pragma, PragmaTerms, Result = error(InvalidDeclStr ++ ErrMsg, LangTerm) ) ; - string__format("invalid `:- pragma %s' declaration ", + string.format("invalid `:- pragma %s' declaration ", [s(Pragma)], ErrorStr), Result = error(ErrorStr, ErrorTerm) ). @@ -470,15 +470,15 @@ parse_pragma_foreign_decl_pragma(_ModuleName, Pragma, PragmaTerms, parse_pragma_foreign_code_pragma(_ModuleName, Pragma, PragmaTerms, ErrorTerm, _VarSet, Result) :- - string__format("invalid `:- pragma %s' declaration ", [s(Pragma)], + string.format("invalid `:- pragma %s' declaration ", [s(Pragma)], InvalidDeclStr), Check1 = (func(PTerms1, ForeignLanguage) = Res is semidet :- PTerms1 = [Just_Code_Term], - ( Just_Code_Term = term__functor(term__string(Just_Code), [], _) -> + ( Just_Code_Term = term.functor(term.string(Just_Code), [], _) -> Res = ok(pragma(user, foreign_code(ForeignLanguage, Just_Code))) ; ErrMsg = "-- expected string for foreign code", - Res = error(string__append(InvalidDeclStr, ErrMsg), ErrorTerm) + Res = error(string.append(InvalidDeclStr, ErrMsg), ErrorTerm) ) ), CheckLength = (func(PTermsLen, ForeignLanguage) = Res :- @@ -486,7 +486,7 @@ parse_pragma_foreign_code_pragma(_ModuleName, Pragma, PragmaTerms, Res = Res0 ; ErrMsg = "-- wrong number of arguments", - Res = error(string__append(InvalidDeclStr, ErrMsg), ErrorTerm) + Res = error(string.append(InvalidDeclStr, ErrMsg), ErrorTerm) ) ), CheckLanguage = (func(PTermsLang) = Res is semidet :- @@ -495,14 +495,14 @@ parse_pragma_foreign_code_pragma(_ModuleName, Pragma, PragmaTerms, Res = CheckLength(Rest, ForeignLanguage) ; ErrMsg = "-- invalid language parameter", - Res = error(string__append(InvalidDeclStr, ErrMsg), Lang) + Res = error(string.append(InvalidDeclStr, ErrMsg), Lang) ) ), ( Result0 = CheckLanguage(PragmaTerms) -> Result = Result0 ; ErrMsg0 = "-- wrong number of arguments", - Result = error(string__append(InvalidDeclStr, ErrMsg0), ErrorTerm) + Result = error(string.append(InvalidDeclStr, ErrMsg0), ErrorTerm) ). % This predicate parses both c_code and foreign_proc pragmas. @@ -512,7 +512,7 @@ parse_pragma_foreign_code_pragma(_ModuleName, Pragma, PragmaTerms, parse_pragma_foreign_proc_pragma(ModuleName, Pragma, PragmaTerms, ErrorTerm, VarSet, Result) :- - string__format("invalid `:- pragma %s' declaration ", [s(Pragma)], + string.format("invalid `:- pragma %s' declaration ", [s(Pragma)], InvalidDeclStr), Check6 = (func(PTerms6, ForeignLanguage) = Res is semidet :- PTerms6 = [PredAndVarsTerm, FlagsTerm, FieldsTerm, @@ -568,46 +568,46 @@ parse_pragma_foreign_proc_pragma(ModuleName, Pragma, PragmaTerms, ; ErrMsg = "-- invalid seventh argument, " ++ "expecting `common_code()'", - Res = error(string__append(InvalidDeclStr, + Res = error(string.append(InvalidDeclStr, ErrMsg), SharedTerm) ) ; ErrMsg = "-- invalid sixth argument, " ++ "expecting `retry_code()'", - Res = error(string__append(InvalidDeclStr, ErrMsg), + Res = error(string.append(InvalidDeclStr, ErrMsg), LaterTerm) ) ; ErrMsg = "-- invalid fifth argument, " ++ "expecting `first_code()'", - Res = error(string__append(InvalidDeclStr, ErrMsg), + Res = error(string.append(InvalidDeclStr, ErrMsg), FirstTerm) ) ; ErrMsg = "-- invalid fourth argument, " ++ "expecting `local_vars()'", - Res = error(string__append(InvalidDeclStr, ErrMsg), + Res = error(string.append(InvalidDeclStr, ErrMsg), FieldsTerm) ) ; MaybeFlags = error(FlagsErrorStr, ErrorTerm), ErrMsg = "-- invalid third argument: " ++ FlagsErrorStr, - Res = error(string__append(InvalidDeclStr, ErrMsg), ErrorTerm) + Res = error(string.append(InvalidDeclStr, ErrMsg), ErrorTerm) ) ), Check5 = (func(PTerms5, ForeignLanguage) = Res is semidet :- PTerms5 = [PredAndVarsTerm, FlagsTerm, FieldsTerm, FirstTerm, LaterTerm], - term__context_init(DummyContext), - SharedTerm = term__functor(term__atom("common_code"), - [term__functor(term__string(""), [], DummyContext)], + term.context_init(DummyContext), + SharedTerm = term.functor(term.atom("common_code"), + [term.functor(term.string(""), [], DummyContext)], DummyContext), Res = Check6([PredAndVarsTerm, FlagsTerm, FieldsTerm, FirstTerm, LaterTerm, SharedTerm], ForeignLanguage) ), Check3 = (func(PTerms3, ForeignLanguage) = Res is semidet :- PTerms3 = [PredAndVarsTerm, FlagsTerm, CodeTerm], - ( CodeTerm = term__functor(term__string(Code), [], Context) -> + ( CodeTerm = term.functor(term.string(Code), [], Context) -> parse_pragma_foreign_proc_attributes_term(ForeignLanguage, Pragma, FlagsTerm, MaybeFlags), ( @@ -633,7 +633,7 @@ parse_pragma_foreign_proc_pragma(ModuleName, Pragma, PragmaTerms, ErrMsg = "-- invalid second argument, " ++ "expecting predicate " ++ "or function mode", - Res = error(string__append(InvalidDeclStr, ErrMsg), + Res = error(string.append(InvalidDeclStr, ErrMsg), PredAndVarsTerm) ) ; @@ -646,7 +646,7 @@ parse_pragma_foreign_proc_pragma(ModuleName, Pragma, PragmaTerms, ; ErrMsg = "-- invalid fourth argument, " ++ "expecting string containing foreign code", - Res = error(string__append(InvalidDeclStr, ErrMsg), CodeTerm) + Res = error(string.append(InvalidDeclStr, ErrMsg), CodeTerm) ) ), Check2 = (func(PTerms2, ForeignLanguage) = Res is semidet :- @@ -658,7 +658,7 @@ parse_pragma_foreign_proc_pragma(ModuleName, Pragma, PragmaTerms, % may_call_mercury is a conservative default. Attributes0 = default_attributes(ForeignLanguage), set_legacy_purity_behaviour(yes, Attributes0, Attributes), - ( CodeTerm = term__functor(term__string(Code), [], Context) -> + ( CodeTerm = term.functor(term.string(Code), [], Context) -> parse_pragma_foreign_code(ModuleName, Attributes, PredAndVarsTerm, ordinary(Code, yes(Context)), VarSet, Res) ; @@ -666,11 +666,11 @@ parse_pragma_foreign_proc_pragma(ModuleName, Pragma, PragmaTerms, ++ "`may_call_mercury' or " ++ "`will_not_call_mercury', " ++ "and a string for foreign code", - Res = error(string__append(InvalidDeclStr, ErrMsg), CodeTerm) + Res = error(string.append(InvalidDeclStr, ErrMsg), CodeTerm) ) ; ErrMsg = "-- doesn't say whether it can call mercury", - Res = error(string__append(InvalidDeclStr, ErrMsg), ErrorTerm) + Res = error(string.append(InvalidDeclStr, ErrMsg), ErrorTerm) ) ), CheckLength = (func(PTermsLen, ForeignLanguage) = Res :- @@ -684,7 +684,7 @@ parse_pragma_foreign_proc_pragma(ModuleName, Pragma, PragmaTerms, Res = Res0 ; ErrMsg = "-- wrong number of arguments", - Res = error(string__append(InvalidDeclStr, ErrMsg), ErrorTerm) + Res = error(string.append(InvalidDeclStr, ErrMsg), ErrorTerm) ) ), CheckLanguage = (func(PTermsLang) = Res is semidet :- @@ -693,14 +693,14 @@ parse_pragma_foreign_proc_pragma(ModuleName, Pragma, PragmaTerms, Res = CheckLength(Rest, ForeignLanguage) ; ErrMsg = "-- invalid language parameter", - Res = error(string__append(InvalidDeclStr, ErrMsg), Lang) + Res = error(string.append(InvalidDeclStr, ErrMsg), Lang) ) ), ( Result0 = CheckLanguage(PragmaTerms) -> Result = Result0 ; ErrMsg0 = "-- wrong number of arguments", - Result = error(string__append(InvalidDeclStr, ErrMsg0), ErrorTerm) + Result = error(string.append(InvalidDeclStr, ErrMsg0), ErrorTerm) ). parse_pragma_type(ModuleName, "import", PragmaTerms, ErrorTerm, _VarSet, @@ -729,7 +729,7 @@ parse_pragma_type(ModuleName, "import", PragmaTerms, ErrorTerm, _VarSet, FlagsResult = ok(Flags) ) -> - ( FunctionTerm = term__functor(term__string(Function), [], _) -> + ( FunctionTerm = term.functor(term.string(Function), [], _) -> parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm, ErrorTerm, "`:- pragma import' declaration", PredAndArgModesResult), @@ -760,7 +760,7 @@ parse_pragma_type(_ModuleName, "export", PragmaTerms, ErrorTerm, _VarSet, Result) :- % XXX we implicitly assume exports are only for C ( PragmaTerms = [PredAndModesTerm, FunctionTerm] -> - ( FunctionTerm = term__functor(term__string(Function), [], _) -> + ( FunctionTerm = term.functor(term.string(Function), [], _) -> parse_pred_or_func_and_arg_modes(no, PredAndModesTerm, ErrorTerm, "`:- pragma export' declaration", PredAndModesResult), @@ -834,15 +834,15 @@ parse_pragma_type(ModuleName, "unused_args", PragmaTerms, ErrorTerm, _VarSet, PragmaTerms = [ PredOrFuncTerm, PredNameTerm, - term__functor(term__integer(Arity), [], _), - term__functor(term__integer(ModeNum), [], _), + term.functor(term.integer(Arity), [], _), + term.functor(term.integer(ModeNum), [], _), UnusedArgsTerm ], ( - PredOrFuncTerm = term__functor(term__atom("predicate"), [], _), + PredOrFuncTerm = term.functor(term.atom("predicate"), [], _), PredOrFunc = predicate ; - PredOrFuncTerm = term__functor(term__atom("function"), [], _), + PredOrFuncTerm = term.functor(term.atom("function"), [], _), PredOrFunc = function ), parse_implicitly_qualified_term(ModuleName, PredNameTerm, ErrorTerm, @@ -865,11 +865,11 @@ parse_pragma_type(ModuleName, "type_spec", PragmaTerms, ErrorTerm, VarSet0, MaybeName = no ; PragmaTerms = [PredAndModesTerm, TypeSubnTerm, SpecNameTerm], - SpecNameTerm = term__functor(_, _, SpecContext), + SpecNameTerm = term.functor(_, _, SpecContext), % This form of the pragma should not appear in source files. - term__context_file(SpecContext, FileName), - \+ string__remove_suffix(FileName, ".m", _), + term.context_file(SpecContext, FileName), + \+ string.remove_suffix(FileName, ".m", _), parse_implicitly_qualified_term(ModuleName, SpecNameTerm, ErrorTerm, "", NameResult), @@ -886,8 +886,8 @@ parse_pragma_type(ModuleName, "type_spec", PragmaTerms, ErrorTerm, VarSet0, conjunction_to_list(TypeSubnTerm, TypeSubnList), % The varset is actually a tvarset. - varset__coerce(VarSet0, TVarSet), - ( list__map(convert_type_spec_pair, TypeSubnList, TypeSubn) -> + varset.coerce(VarSet0, TVarSet), + ( list.map(convert_type_spec_pair, TypeSubnList, TypeSubn) -> ( MaybeName = yes(SpecializedName0), SpecializedName = SpecializedName0 @@ -899,8 +899,7 @@ parse_pragma_type(ModuleName, "type_spec", PragmaTerms, ErrorTerm, VarSet0, SpecializedName) ), TypeSpecPragma = type_spec(PredName, SpecializedName, Arity, - MaybePredOrFunc, MaybeModes, TypeSubn, TVarSet, - set__init), + MaybePredOrFunc, MaybeModes, TypeSubn, TVarSet, set.init), Result = ok(pragma(user, TypeSpecPragma)) ; Result = error("expected type substitution in " ++ @@ -929,7 +928,7 @@ parse_pragma_type(ModuleName, "fact_table", PragmaTerms, ErrorTerm, _VarSet, PredAndArityTerm, ErrorTerm, NameArityResult), ( NameArityResult = ok(PredName, Arity), - ( FileNameTerm = term__functor(term__string(FileName), [], _) -> + ( FileNameTerm = term.functor(term.string(FileName), [], _) -> Result = ok(pragma(user, fact_table(PredName, Arity, FileName))) ; @@ -979,26 +978,26 @@ parse_pragma_type(ModuleName, "termination_info", PragmaTerms, ErrorTerm, NameAndModesResult), NameAndModesResult = ok(PredName - PredOrFunc, ModeList), ( - ArgSizeTerm = term__functor(term__atom("not_set"), [], _), + ArgSizeTerm = term.functor(term.atom("not_set"), [], _), MaybeArgSizeInfo = no ; - ArgSizeTerm = term__functor(term__atom("infinite"), [], _), + ArgSizeTerm = term.functor(term.atom("infinite"), [], _), MaybeArgSizeInfo = yes(infinite(unit)) ; - ArgSizeTerm = term__functor(term__atom("finite"), + ArgSizeTerm = term.functor(term.atom("finite"), [IntTerm, UsedArgsTerm], _), - IntTerm = term__functor(term__integer(Int), [], _), + IntTerm = term.functor(term.integer(Int), [], _), convert_bool_list(UsedArgsTerm, UsedArgs), MaybeArgSizeInfo = yes(finite(Int, UsedArgs)) ), ( - TerminationTerm = term__functor(term__atom("not_set"), [], _), + TerminationTerm = term.functor(term.atom("not_set"), [], _), MaybeTerminationInfo = no ; - TerminationTerm = term__functor(term__atom("can_loop"), [], _), + TerminationTerm = term.functor(term.atom("can_loop"), [], _), MaybeTerminationInfo = yes(can_loop(unit)) ; - TerminationTerm = term__functor(term__atom("cannot_loop"), [], _), + TerminationTerm = term.functor(term.atom("cannot_loop"), [], _), MaybeTerminationInfo = yes(cannot_loop(unit)) ), Result0 = ok(pragma(user, termination_info(PredOrFunc, PredName, @@ -1028,13 +1027,13 @@ parse_pragma_type(ModuleName, "termination2_info", PragmaTerms, ErrorTerm, parse_arg_size_constraints(FailureArgSizeTerm, FailureArgSizeResult), FailureArgSizeResult = ok(FailureArgSizeInfo), ( - TerminationTerm = term__functor(term__atom("not_set"), [], _), + TerminationTerm = term.functor(term.atom("not_set"), [], _), MaybeTerminationInfo = no ; - TerminationTerm = term__functor(term__atom("can_loop"), [], _), + TerminationTerm = term.functor(term.atom("can_loop"), [], _), MaybeTerminationInfo = yes(can_loop(unit)) ; - TerminationTerm = term__functor(term__atom("cannot_loop"), [], _), + TerminationTerm = term.functor(term.atom("cannot_loop"), [], _), MaybeTerminationInfo = yes(cannot_loop(unit)) ), Result0 = ok(pragma(user, termination2_info(PredOrFunc, PredName, @@ -1084,23 +1083,22 @@ parse_pragma_type(ModuleName, "structure_sharing", PragmaTerms, ErrorTerm, NameAndModesResult = ok(PredName - PredOrFunc, ModeList), % Parse the headvariables: - HeadVarsTerm = term__functor(term__atom("vars"), ListHVTerm, _), - term__vars_list(ListHVTerm, HeadVarsGeneric), - list__map(term__coerce_var, HeadVarsGeneric, HeadVars), + HeadVarsTerm = term.functor(term.atom("vars"), ListHVTerm, _), + term.vars_list(ListHVTerm, HeadVarsGeneric), + list.map(term.coerce_var, HeadVarsGeneric, HeadVars), % Parse the types: - HeadVarTypesTerm = term__functor(term__atom("types"), ListTypeTerms, - _), + HeadVarTypesTerm = term.functor(term.atom("types"), ListTypeTerms, _), parse_types(ListTypeTerms, ok(Types)), % Parse the actual structure sharing information. ( - SharingInformationTerm = term__functor(term__atom("not_available"), + SharingInformationTerm = term.functor(term.atom("not_available"), _, _), MaybeSharingAs = no ; - SharingInformationTerm = term__functor(term__atom("yes"), + SharingInformationTerm = term.functor(term.atom("yes"), SharingTerm, _), SharingTerm = [ SharingAsTerm ], MaybeSharingAs = yes(parse_structure_sharing_domain(SharingAsTerm)) @@ -1253,7 +1251,7 @@ parse_simple_pragma_base(ModuleName, PragmaType, NameKind, MakePragma, Result = error(ErrorMsg, PredAndArityTerm) ) ; - string__append_list(["wrong number of arguments in `:- pragma ", + string.append_list(["wrong number of arguments in `:- pragma ", PragmaType, "' declaration"], ErrorMsg), Result = error(ErrorMsg, ErrorTerm) ). @@ -1274,7 +1272,7 @@ parse_simple_name_and_arity(ModuleName, PragmaType, NameKind, ( parse_name_and_arity(ModuleName, NameAndArityTerm, Name, Arity) -> Result = ok(Name, Arity) ; - string__append_list(["expected ", NameKind, " name/arity for `pragma ", + string.append_list(["expected ", NameKind, " name/arity for `pragma ", PragmaType, "' declaration"], ErrorMsg), Result = error(ErrorMsg, ErrorTerm) ). @@ -1282,11 +1280,11 @@ parse_simple_name_and_arity(ModuleName, PragmaType, NameKind, %-----------------------------------------------------------------------------% :- pred parse_pragma_keyword(string::in, term::in, string::out, - term__context::out) is semidet. + term.context::out) is semidet. parse_pragma_keyword(ExpectedKeyword, Term, StringArg, StartContext) :- - Term = term__functor(term__atom(ExpectedKeyword), [Arg], _), - Arg = term__functor(term__string(StringArg), [], StartContext). + Term = term.functor(term.atom(ExpectedKeyword), [Arg], _), + Arg = term.functor(term.string(StringArg), [], StartContext). %-----------------------------------------------------------------------------% @@ -1347,14 +1345,14 @@ parse_pragma_foreign_proc_attributes_term(ForeignLanguage, Pragma, Term, parse_pragma_foreign_proc_attributes_term0(Term, AttrList) -> ( - list__member(Conflict1 - Conflict2, ConflictingAttributes), - list__member(Conflict1, AttrList), - list__member(Conflict2, AttrList) + list.member(Conflict1 - Conflict2, ConflictingAttributes), + list.member(Conflict1, AttrList), + list.member(Conflict2, AttrList) -> MaybeAttributes = error("conflicting attributes " ++ "in attribute list", Term) ; - list__foldl(process_attribute, AttrList, Attributes2, Attributes), + list.foldl(process_attribute, AttrList, Attributes2, Attributes), MaybeAttributes = check_required_attributes(ForeignLanguage, Attributes, Term) ) @@ -1408,7 +1406,7 @@ check_required_attributes(c, Attrs, _Term) = ok(Attrs). check_required_attributes(managed_cplusplus, Attrs, _Term) = ok(Attrs). check_required_attributes(csharp, Attrs, _Term) = ok(Attrs). check_required_attributes(il, Attrs, Term) = Res :- - MaxStackAttrs = list__filter_map( + MaxStackAttrs = list.filter_map( (func(X) = X is semidet :- X = max_stack_size(_)), Attrs ^ extra_attributes), ( @@ -1428,10 +1426,10 @@ parse_pragma_foreign_proc_attributes_term0(Term, Flags) :- Flags = [Flag] ; ( - Term = term__functor(term__atom("[]"), [], _), + Term = term.functor(term.atom("[]"), [], _), Flags = [] ; - Term = term__functor(term__atom("[|]"), [Head, Tail], _), + Term = term.functor(term.atom("[|]"), [Head, Tail], _), parse_single_pragma_foreign_proc_attribute(Head, HeadFlag), parse_pragma_foreign_proc_attributes_term0(Tail, TailFlags), Flags = [HeadFlag | TailFlags] @@ -1472,22 +1470,22 @@ parse_single_pragma_foreign_proc_attribute(Term, Flag) :- :- pred parse_may_call_mercury(term::in, may_call_mercury::out) is semidet. -parse_may_call_mercury(term__functor(term__atom("recursive"), [], _), +parse_may_call_mercury(term.functor(term.atom("recursive"), [], _), may_call_mercury). -parse_may_call_mercury(term__functor(term__atom("non_recursive"), [], _), +parse_may_call_mercury(term.functor(term.atom("non_recursive"), [], _), will_not_call_mercury). -parse_may_call_mercury(term__functor(term__atom("may_call_mercury"), [], _), +parse_may_call_mercury(term.functor(term.atom("may_call_mercury"), [], _), may_call_mercury). -parse_may_call_mercury(term__functor(term__atom("will_not_call_mercury"), [], +parse_may_call_mercury(term.functor(term.atom("will_not_call_mercury"), [], _), will_not_call_mercury). :- pred parse_threadsafe(term::in, thread_safe::out) is semidet. -parse_threadsafe(term__functor(term__atom("thread_safe"), [], _), +parse_threadsafe(term.functor(term.atom("thread_safe"), [], _), thread_safe). -parse_threadsafe(term__functor(term__atom("not_thread_safe"), [], _), +parse_threadsafe(term.functor(term.atom("not_thread_safe"), [], _), not_thread_safe). -parse_threadsafe(term__functor(term__atom("maybe_thread_safe"), [], _), +parse_threadsafe(term.functor(term.atom("maybe_thread_safe"), [], _), maybe_thread_safe). :- pred parse_may_modify_trail(term::in, may_modify_trail::out) is semidet. @@ -1506,7 +1504,7 @@ parse_box_policy(term.functor(term.atom("always_boxed"), [], _), :- pred parse_tabled_for_io(term::in, tabled_for_io::out) is semidet. -parse_tabled_for_io(term__functor(term__atom(Str), [], _), TabledForIo) :- +parse_tabled_for_io(term.functor(term.atom(Str), [], _), TabledForIo) :- ( Str = "tabled_for_io", TabledForIo = tabled_for_io @@ -1528,19 +1526,19 @@ parse_tabled_for_io(term__functor(term__atom(Str), [], _), TabledForIo) :- % :- pred parse_aliasing(term::in) is semidet. -parse_aliasing(term__functor(term__atom("no_aliasing"), [], _)). -parse_aliasing(term__functor(term__atom("unknown_aliasing"), [], _)). -parse_aliasing(term__functor(term__atom("alias"), [_Types, _Alias], _)). +parse_aliasing(term.functor(term.atom("no_aliasing"), [], _)). +parse_aliasing(term.functor(term.atom("unknown_aliasing"), [], _)). +parse_aliasing(term.functor(term.atom("alias"), [_Types, _Alias], _)). :- pred parse_max_stack_size(term::in, int::out) is semidet. -parse_max_stack_size(term__functor( - term__atom("max_stack_size"), [SizeTerm], _), Size) :- - SizeTerm = term__functor(term__integer(Size), [], _). +parse_max_stack_size(term.functor( + term.atom("max_stack_size"), [SizeTerm], _), Size) :- + SizeTerm = term.functor(term.integer(Size), [], _). :- pred parse_backend(term::in, backend::out) is semidet. -parse_backend(term__functor(term__atom(Functor), [], _), Backend) :- +parse_backend(term.functor(term.atom(Functor), [], _), Backend) :- ( Functor = "high_level_backend", Backend = high_level_backend @@ -1551,16 +1549,16 @@ parse_backend(term__functor(term__atom(Functor), [], _), Backend) :- :- pred parse_purity_promise(term::in, purity::out) is semidet. -parse_purity_promise(term__functor(term__atom("promise_pure"), [], _), +parse_purity_promise(term.functor(term.atom("promise_pure"), [], _), purity_pure). -parse_purity_promise(term__functor(term__atom("promise_semipure"), [], _), +parse_purity_promise(term.functor(term.atom("promise_semipure"), [], _), purity_semipure). :- pred parse_terminates(term::in, terminates::out) is semidet. -parse_terminates(term__functor(term__atom("terminates"), [], _), +parse_terminates(term.functor(term.atom("terminates"), [], _), terminates). -parse_terminates(term__functor(term__atom("does_not_terminate"), [], _), +parse_terminates(term.functor(term.atom("does_not_terminate"), [], _), does_not_terminate). :- pred parse_no_exception_promise(term::in) is semidet. @@ -1571,7 +1569,7 @@ parse_no_exception_promise(term.functor( :- pred parse_ordinary_despite_detism(term::in) is semidet. parse_ordinary_despite_detism( - term__functor(term__atom("ordinary_despite_detism"), [], _)). + term.functor(term.atom("ordinary_despite_detism"), [], _)). % Parse a pragma foreign_code declaration. % @@ -1590,7 +1588,7 @@ parse_pragma_foreign_code(ModuleName, Flags, PredAndVarsTerm0, MaybeRetTerm = yes(FuncResultTerm0) -> PredOrFunc = function, - list__append(VarList0, [FuncResultTerm0], VarList) + list.append(VarList0, [FuncResultTerm0], VarList) ; PredOrFunc = predicate, VarList = VarList0 @@ -1598,8 +1596,8 @@ parse_pragma_foreign_code(ModuleName, Flags, PredAndVarsTerm0, parse_pragma_c_code_varlist(VarSet0, VarList, PragmaVars, Error), ( Error = no, - varset__coerce(VarSet0, ProgVarSet), - varset__coerce(VarSet0, InstVarSet), + varset.coerce(VarSet0, ProgVarSet), + varset.coerce(VarSet0, InstVarSet), Result = ok(pragma(user, foreign_proc(Flags, PredName, PredOrFunc, PragmaVars, ProgVarSet, InstVarSet, PragmaImpl))) ; @@ -1620,13 +1618,13 @@ parse_pragma_foreign_code(ModuleName, Flags, PredAndVarsTerm0, parse_pragma_c_code_varlist(_, [], [], no). parse_pragma_c_code_varlist(VarSet, [V|Vars], PragmaVars, Error):- ( - V = term__functor(term__atom("::"), [VarTerm, ModeTerm], _), - VarTerm = term__variable(Var) + V = term.functor(term.atom("::"), [VarTerm, ModeTerm], _), + VarTerm = term.variable(Var) -> - ( varset__search_name(VarSet, Var, VarName) -> + ( varset.search_name(VarSet, Var, VarName) -> ( convert_mode(allow_constrained_inst_var, ModeTerm, Mode0) -> constrain_inst_vars_in_mode(Mode0, Mode), - term__coerce_var(Var, ProgVar), + term.coerce_var(Var, ProgVar), PragmaVar = pragma_var(ProgVar, VarName, Mode, native_if_possible), parse_pragma_c_code_varlist(VarSet, Vars, PragmaVars0, Error), @@ -1662,7 +1660,7 @@ parse_tabling_pragma(ModuleName, PragmaName, TablingType, PragmaTerms, MaybeSpec = yes(SpecListTerm0) ) -> - string__append_list(["`:- pragma ", PragmaName, "' declaration"], + string.append_list(["`:- pragma ", PragmaName, "' declaration"], ParseMsg), parse_arity_or_modes(ModuleName, PredAndModesTerm0, ErrorTerm, ParseMsg, ArityModesResult), @@ -1693,7 +1691,7 @@ parse_tabling_pragma(ModuleName, PragmaName, TablingType, PragmaTerms, Result = error(Msg, Term) ) ; - string__append_list(["wrong number of arguments in `:- pragma ", + string.append_list(["wrong number of arguments in `:- pragma ", PragmaName, "' declaration"], ErrorMessage), Result = error(ErrorMessage, ErrorTerm) ). @@ -1701,13 +1699,13 @@ parse_tabling_pragma(ModuleName, PragmaName, TablingType, PragmaTerms, :- pred parse_arg_tabling_method(term::in, maybe(arg_tabling_method)::out) is semidet. -parse_arg_tabling_method(term__functor(term__atom("value"), [], _), +parse_arg_tabling_method(term.functor(term.atom("value"), [], _), yes(arg_value)). -parse_arg_tabling_method(term__functor(term__atom("addr"), [], _), +parse_arg_tabling_method(term.functor(term.atom("addr"), [], _), yes(arg_addr)). -parse_arg_tabling_method(term__functor(term__atom("promise_implied"), [], _), +parse_arg_tabling_method(term.functor(term.atom("promise_implied"), [], _), yes(arg_promise_implied)). -parse_arg_tabling_method(term__functor(term__atom("output"), [], _), no). +parse_arg_tabling_method(term.functor(term.atom("output"), [], _), no). :- type arity_or_modes ---> arity_or_modes( @@ -1724,17 +1722,17 @@ parse_arity_or_modes(ModuleName, PredAndModesTerm0, ErrorTerm, ErrorMsg, Result) :- ( % Is this a simple pred/arity pragma. - PredAndModesTerm0 = term__functor(term__atom("/"), + PredAndModesTerm0 = term.functor(term.atom("/"), [PredNameTerm, ArityTerm], _) -> ( parse_implicitly_qualified_term(ModuleName, PredNameTerm, PredAndModesTerm0, "", ok(PredName, [])), - ArityTerm = term__functor(term__integer(Arity), [], _) + ArityTerm = term.functor(term.integer(Arity), [], _) -> Result = ok(arity_or_modes(PredName, Arity, no, no)) ; - string__append("expected predname/arity for", ErrorMsg, Msg), + string.append("expected predname/arity for", ErrorMsg, Msg), Result = error(Msg, ErrorTerm) ) ; @@ -1742,7 +1740,7 @@ parse_arity_or_modes(ModuleName, PredAndModesTerm0, PredAndModesTerm0, ErrorMsg, PredAndModesResult), ( PredAndModesResult = ok(PredName - PredOrFunc, Modes), - list__length(Modes, Arity0), + list.length(Modes, Arity0), ( PredOrFunc = function -> Arity = Arity0 - 1 ; @@ -1767,8 +1765,7 @@ parse_pred_or_func_and_arg_modes(MaybeModuleName, PredAndModesTerm, parse_pred_or_func_and_args(MaybeModuleName, PredAndModesTerm, ErrorTerm, Msg, PredAndArgsResult), ( - PredAndArgsResult = - ok(PredName, ArgModeTerms - MaybeRetModeTerm), + PredAndArgsResult = ok(PredName, ArgModeTerms - MaybeRetModeTerm), ( convert_mode_list(allow_constrained_inst_var, ArgModeTerms, ArgModes0) @@ -1779,12 +1776,11 @@ parse_pred_or_func_and_arg_modes(MaybeModuleName, PredAndModesTerm, convert_mode(allow_constrained_inst_var, RetModeTerm, RetMode) -> - list__append(ArgModes0, [RetMode], ArgModes1), - list__map(constrain_inst_vars_in_mode, ArgModes1, - ArgModes), + list.append(ArgModes0, [RetMode], ArgModes1), + list.map(constrain_inst_vars_in_mode, ArgModes1, ArgModes), Result = ok(PredName - function, ArgModes) ; - string__append("error in return mode in ", Msg, ErrorMsg), + string.append("error in return mode in ", Msg, ErrorMsg), Result = error(ErrorMsg, ErrorTerm) ) ; @@ -1792,8 +1788,7 @@ parse_pred_or_func_and_arg_modes(MaybeModuleName, PredAndModesTerm, Result = ok(PredName - predicate, ArgModes0) ) ; - string__append("error in argument modes in ", Msg, - ErrorMsg), + string.append("error in argument modes in ", Msg, ErrorMsg), Result = error(ErrorMsg, ErrorTerm) ) ; @@ -1804,7 +1799,7 @@ parse_pred_or_func_and_arg_modes(MaybeModuleName, PredAndModesTerm, :- pred convert_bool(term::in, bool::out) is semidet. convert_bool(Term, Bool) :- - Term = term__functor(term__atom(Name), [], _), + Term = term.functor(term.atom(Name), [], _), ( Name = "yes", Bool = yes ; Name = "no", Bool = no ). @@ -1817,7 +1812,7 @@ convert_bool_list(ListTerm, Bools) :- :- pred convert_int(term::in, int::out) is semidet. convert_int(Term, Int) :- - Term = term__functor(term__integer(Int), [], _). + Term = term.functor(term.integer(Int), [], _). :- pred convert_int_list(term::in, maybe1(list(int))::out) is det. @@ -1833,12 +1828,12 @@ convert_int_list(ListTerm, Result) :- :- pred convert_list(term::in, pred(term, T)::(pred(in, out) is semidet), string::in, maybe1(list(T))::out) is det. -convert_list(term__variable(V), _, UnrecognizedMsg, - error(UnrecognizedMsg, term__variable(V))). -convert_list(term__functor(Functor, Args, Context), Pred, UnrecognizedMsg, +convert_list(term.variable(V), _, UnrecognizedMsg, + error(UnrecognizedMsg, term.variable(V))). +convert_list(term.functor(Functor, Args, Context), Pred, UnrecognizedMsg, Result) :- ( - Functor = term__atom("[|]"), + Functor = term.atom("[|]"), Args = [Term, RestTerm] -> ( call(Pred, Term, Element) -> @@ -1854,20 +1849,20 @@ convert_list(term__functor(Functor, Args, Context), Pred, UnrecognizedMsg, Result = error(UnrecognizedMsg, Term) ) ; - Functor = term__atom("[]"), + Functor = term.atom("[]"), Args = [] -> Result = ok([]) ; - Result = error("error in list", term__functor(Functor, Args, Context)) + Result = error("error in list", term.functor(Functor, Args, Context)) ). :- pred convert_type_spec_pair(term::in, pair(tvar, mer_type)::out) is semidet. convert_type_spec_pair(Term, TypeSpec) :- - Term = term__functor(term__atom("="), [TypeVarTerm, SpecTypeTerm0], _), - TypeVarTerm = term__variable(TypeVar0), - term__coerce_var(TypeVar0, TypeVar), + Term = term.functor(term.atom("="), [TypeVarTerm, SpecTypeTerm0], _), + TypeVarTerm = term.variable(TypeVar0), + term.coerce_var(TypeVar0, TypeVar), parse_type(SpecTypeTerm0, ok(SpecType)), TypeSpec = TypeVar - SpecType. @@ -1881,10 +1876,10 @@ convert_type_spec_pair(Term, TypeSpec) :- parse_arg_size_constraints(ArgSizeTerm, Result) :- ( - ArgSizeTerm = term__functor(term__atom("not_set"), [], _), + ArgSizeTerm = term.functor(term.atom("not_set"), [], _), Result = ok(no) ; - ArgSizeTerm = term__functor(term__atom("constraints"), + ArgSizeTerm = term.functor(term.atom("constraints"), [Constraints0], _), convert_list(Constraints0, parse_arg_size_constraint, "expected constraint", ConstraintsResult), @@ -1896,7 +1891,7 @@ parse_arg_size_constraints(ArgSizeTerm, Result) :- parse_arg_size_constraint(Term, Constr) :- ( - Term = term__functor(term__atom("le"), [Terms, ConstantTerm], _), + Term = term.functor(term.atom("le"), [Terms, ConstantTerm], _), convert_list(Terms, parse_lp_term, "expected linear term", TermsResult), TermsResult = ok(LPTerms), @@ -1904,7 +1899,7 @@ parse_arg_size_constraint(Term, Constr) :- Constr = le(LPTerms, Constant) ; - Term = term__functor(term__atom("eq"), [Terms, ConstantTerm], _), + Term = term.functor(term.atom("eq"), [Terms, ConstantTerm], _), convert_list(Terms, parse_lp_term, "expected linear term", TermsResult), TermsResult = ok(LPTerms), @@ -1915,18 +1910,18 @@ parse_arg_size_constraint(Term, Constr) :- :- pred parse_lp_term(term::in, pair(int, rat)::out) is semidet. parse_lp_term(Term, LpTerm) :- - Term = term__functor(term__atom("term"), [VarIdTerm, CoeffTerm], _), - VarIdTerm = term__functor(term__integer(VarId), [], _), + Term = term.functor(term.atom("term"), [VarIdTerm, CoeffTerm], _), + VarIdTerm = term.functor(term.integer(VarId), [], _), parse_rational(CoeffTerm, Coeff), LpTerm = VarId - Coeff. :- pred parse_rational(term::in, rat::out) is semidet. parse_rational(Term, Rational) :- - Term = term__functor(term__atom("r"), [NumerTerm, DenomTerm], _), - NumerTerm = term__functor(term__integer(Numer), [], _), - DenomTerm = term__functor(term__integer(Denom), [], _), - Rational = rat__rat(Numer, Denom). + Term = term.functor(term.atom("r"), [NumerTerm, DenomTerm], _), + NumerTerm = term.functor(term.integer(Numer), [], _), + DenomTerm = term.functor(term.integer(Denom), [], _), + Rational = rat.rat(Numer, Denom). %-----------------------------------------------------------------------------% diff --git a/compiler/prog_io_typeclass.m b/compiler/prog_io_typeclass.m index 89a1952c8..54a6bbf6b 100644 --- a/compiler/prog_io_typeclass.m +++ b/compiler/prog_io_typeclass.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module parse_tree__prog_io_typeclass. +:- module parse_tree.prog_io_typeclass. :- interface. :- import_module mdbcomp.prim_data. @@ -72,7 +72,7 @@ parse_typeclass(ModuleName, VarSet, TypeClassTerm, Result) :- % XXX We should return an error if we get more than one arg, instead of % failing. TypeClassTerm = [Arg], - ( Arg = term__functor(term__atom("where"), [Name, Methods], _) -> + ( Arg = term.functor(term.atom("where"), [Name, Methods], _) -> parse_non_empty_class(ModuleName, Name, Methods, VarSet, Result) ; parse_class_head(ModuleName, Arg, VarSet, Result) @@ -82,7 +82,7 @@ parse_typeclass(ModuleName, VarSet, TypeClassTerm, Result) :- maybe1(item)::out) is det. parse_non_empty_class(ModuleName, Name, Methods, VarSet, Result) :- - varset__coerce(VarSet, TVarSet), + varset.coerce(VarSet, TVarSet), parse_class_methods(ModuleName, Methods, VarSet, ParsedMethods), ( ParsedMethods = ok(MethodList), @@ -112,12 +112,10 @@ parse_non_empty_class(ModuleName, Name, Methods, VarSet, Result) :- maybe1(item)::out) is det. parse_class_head(ModuleName, Arg, VarSet, Result) :- - ( - Arg = term__functor(term__atom("<="), [Name, Constraints], _) - -> + ( Arg = term.functor(term.atom("<="), [Name, Constraints], _) -> parse_constrained_class(ModuleName, Name, Constraints, VarSet, Result) ; - varset__coerce(VarSet, TVarSet), + varset.coerce(VarSet, TVarSet), parse_unconstrained_class(ModuleName, Arg, TVarSet, Result) ). @@ -125,9 +123,8 @@ parse_class_head(ModuleName, Arg, VarSet, Result) :- varset::in, maybe1(item)::out) is det. parse_constrained_class(ModuleName, Decl, Constraints, VarSet, Result) :- - varset__coerce(VarSet, TVarSet), - parse_superclass_constraints(ModuleName, Constraints, - ParsedConstraints), + varset.coerce(VarSet, TVarSet), + parse_superclass_constraints(ModuleName, Constraints, ParsedConstraints), ( ParsedConstraints = ok(ConstraintList, FunDeps), parse_unconstrained_class(ModuleName, Decl, TVarSet, Result0), @@ -142,24 +139,24 @@ parse_constrained_class(ModuleName, Decl, Constraints, VarSet, Result) :- ( % Check for type variables in the constraints which do not % occur in the type class parameters. - prog_type__constraint_list_get_tvars(ConstraintList, + prog_type.constraint_list_get_tvars(ConstraintList, ConstrainedVars), - list__member(Var, ConstrainedVars), - \+ list__member(Var, Item ^ tc_class_params) + list.member(Var, ConstrainedVars), + \+ list.member(Var, Item ^ tc_class_params) -> Result = error("type variable in superclass constraint " ++ "is not a parameter of this type class", Constraints) ; % Check for type variables in the fundeps which do not occur % in the type class parameters. - list__member(FunDep, FunDeps), + list.member(FunDep, FunDeps), FunDep = fundep(Domain, Range), ( - list__member(Var, Domain) + list.member(Var, Domain) ; - list__member(Var, Range) + list.member(Var, Range) ), - \+ list__member(Var, Item ^ tc_class_params) + \+ list.member(Var, Item ^ tc_class_params) -> Result = error("type variable in functional dependency " ++ "is not a parameter of this type class", Constraints) @@ -226,11 +223,11 @@ parse_unconstrained_class(ModuleName, Name, TVarSet, Result) :- Name, Name, "typeclass declaration", MaybeClassName), ( MaybeClassName = ok(ClassName, TermVars0), - list__map(term__coerce, TermVars0, TermVars), + list.map(term.coerce, TermVars0, TermVars), ( - term__var_list_to_term_list(Vars, TermVars), - list__sort_and_remove_dups(TermVars, SortedTermVars), - list__length(SortedTermVars) = list__length(TermVars) : int + term.var_list_to_term_list(Vars, TermVars), + list.sort_and_remove_dups(TermVars, SortedTermVars), + list.length(SortedTermVars) = list.length(TermVars) : int -> Result = ok(typeclass([], [], ClassName, Vars, abstract, TVarSet)) ; @@ -250,7 +247,8 @@ parse_class_methods(ModuleName, Methods, VarSet, Result) :- % Convert the list of terms into a list of maybe1(class_method)s. list_term_to_term_list(Methods, MethodList) -> - list__map((pred(MethodTerm::in, Method::out) is det :- + list.map( + (pred(MethodTerm::in, Method::out) is det :- % Turn the term into an item. parse_decl(ModuleName, VarSet, MethodTerm, Item), % Turn the item into a class_method. @@ -267,13 +265,9 @@ parse_class_methods(ModuleName, Methods, VarSet, Result) :- item_to_class_method(error(String, Term), _, error(String, Term)). item_to_class_method(ok(Item, Context), Term, Result) :- - ( - Item = pred_or_func(A, B, C, D, E, F, G, H, I, J, K, L) - -> + ( Item = pred_or_func(A, B, C, D, E, F, G, H, I, J, K, L) -> Result = ok(pred_or_func(A, B, C, D, E, F, G, H, I, J, K, L, Context)) - ; - Item = pred_or_func_mode(A, B, C, D, E, F, G) - -> + ; Item = pred_or_func_mode(A, B, C, D, E, F, G) -> Result = ok(pred_or_func_mode(A, B, C, D, E, F, G, Context)) ; Result = error("Only pred, func and mode declarations " ++ @@ -467,15 +461,15 @@ parse_arbitrary_constraint(ConstraintTerm, Result) :- is semidet. parse_inst_constraint(Term, InstVar, Inst) :- - Term = term__functor(term__atom("=<"), [Arg1, Arg2], _), - Arg1 = term__variable(InstVar0), - term__coerce_var(InstVar0, InstVar), + Term = term.functor(term.atom("=<"), [Arg1, Arg2], _), + Arg1 = term.variable(InstVar0), + term.coerce_var(InstVar0, InstVar), convert_inst(no_allow_constrained_inst_var, Arg2, Inst). :- pred parse_fundep(term::in, maybe1(arbitrary_constraint)::out) is semidet. parse_fundep(Term, Result) :- - Term = term__functor(term__atom("->"), [DomainTerm, RangeTerm], _), + Term = term.functor(term.atom("->"), [DomainTerm, RangeTerm], _), ( parse_fundep_2(DomainTerm, Domain), parse_fundep_2(RangeTerm, Range) @@ -490,15 +484,15 @@ parse_fundep(Term, Result) :- :- pred parse_fundep_2(term::in, list(tvar)::out) is semidet. parse_fundep_2(Term, TVars) :- - TypeTerm = term__coerce(Term), + TypeTerm = term.coerce(Term), conjunction_to_list(TypeTerm, List), - term__var_list_to_term_list(TVars, List). + term.var_list_to_term_list(TVars, List). :- pred constraint_is_not_simple(prog_constraint::in) is semidet. constraint_is_not_simple(constraint(_Name, Types)) :- some [Type] ( - list__member(Type, Types), + list.member(Type, Types), type_is_nonvar(Type), type_is_nonground(Type) ). @@ -509,8 +503,8 @@ parse_instance(ModuleName, VarSet, TypeClassTerm, Result) :- % XXX We should return an error if we get more than one arg, % instead of failing. TypeClassTerm = [Arg], - varset__coerce(VarSet, TVarSet), - ( Arg = term__functor(term__atom("where"), [Name, Methods], _) -> + varset.coerce(VarSet, TVarSet), + ( Arg = term.functor(term.atom("where"), [Name, Methods], _) -> parse_non_empty_instance(ModuleName, Name, Methods, VarSet, TVarSet, Result) ; @@ -521,7 +515,7 @@ parse_instance(ModuleName, VarSet, TypeClassTerm, Result) :- maybe1(item)::out) is det. parse_instance_name(ModuleName, Arg, TVarSet, Result) :- - ( Arg = term__functor(term__atom("<="), [Name, Constraints], _) -> + ( Arg = term.functor(term.atom("<="), [Name, Constraints], _) -> parse_derived_instance(ModuleName, Name, Constraints, TVarSet, Result) ; parse_underived_instance(ModuleName, Arg, TVarSet, Result) @@ -535,13 +529,9 @@ parse_derived_instance(ModuleName, Decl, Constraints, TVarSet, Result) :- ( ParsedConstraints = ok(ConstraintList), parse_underived_instance(ModuleName, Decl, TVarSet, Result0), - ( - Result0 = error(_, _) - -> + ( Result0 = error(_, _) -> Result = Result0 - ; - Result0 = ok(instance(_, Name, Types, Body, VarSet, ModName)) - -> + ; Result0 = ok(instance(_, Name, Types, Body, VarSet, ModName)) -> Result = ok(instance(ConstraintList, Name, Types, Body, VarSet, ModName)) ; @@ -592,7 +582,7 @@ parse_underived_instance_2(ErrorTerm, ClassName, ok(Types), TVarSet, % Check that each type in the arguments of the instance decl % is a functor with vars as args. some [Type] ( - list__member(Type, Types), + list.member(Type, Types), \+ type_is_functor_and_vars(Type) ) -> @@ -628,8 +618,9 @@ type_is_functor_and_vars(kinded(Type, _)) :- functor_args_are_variables(Args) :- all [Arg] ( - list__member(Arg, Args) - => type_is_var(Arg) + list.member(Arg, Args) + => + type_is_var(Arg) ). :- pred parse_non_empty_instance(module_name::in, term::in, term::in, @@ -674,8 +665,8 @@ check_tvars_in_instance_constraint(ok(Item), InstanceTerm, Result) :- % on the instance declaration also occur in the type class % argument types in the instance declaration. ( - prog_type__constraint_list_get_tvars(Constraints, TVars), - list__member(TVar, TVars), + prog_type.constraint_list_get_tvars(Constraints, TVars), + list.member(TVar, TVars), \+ type_list_contains_var(Types, TVar) -> Result = error("unbound type variable(s) " ++ @@ -694,7 +685,7 @@ check_tvars_in_instance_constraint(ok(Item), InstanceTerm, Result) :- parse_instance_methods(ModuleName, Methods, VarSet, Result) :- ( list_term_to_term_list(Methods, MethodList) -> % Convert the list of terms into a list of maybe1(class_method)s. - list__map(term_to_instance_method(ModuleName, VarSet), MethodList, + list.map(term_to_instance_method(ModuleName, VarSet), MethodList, Interface), find_errors(Interface, Result) ; @@ -708,17 +699,17 @@ parse_instance_methods(ModuleName, Methods, VarSet, Result) :- term_to_instance_method(_ModuleName, VarSet, MethodTerm, Result) :- ( - MethodTerm = term__functor(term__atom("is"), + MethodTerm = term.functor(term.atom("is"), [ClassMethodTerm, InstanceMethod], TermContext) -> ( - ClassMethodTerm = term__functor(term__atom("pred"), - [term__functor(term__atom("/"), [ClassMethod, Arity], _)], _) + ClassMethodTerm = term.functor(term.atom("pred"), + [term.functor(term.atom("/"), [ClassMethod, Arity], _)], _) -> ( parse_qualified_term(ClassMethod, ClassMethod, "instance method", ok(ClassMethodName, [])), - Arity = term__functor(term__integer(ArityInt), [], _), + Arity = term.functor(term.integer(ArityInt), [], _), parse_qualified_term(InstanceMethod, InstanceMethod, "instance method", ok(InstanceMethodName, [])) -> @@ -729,13 +720,13 @@ term_to_instance_method(_ModuleName, VarSet, MethodTerm, Result) :- "is '", MethodTerm) ) ; - ClassMethodTerm = term__functor(term__atom("func"), - [term__functor(term__atom("/"), [ClassMethod, Arity], _)], _) + ClassMethodTerm = term.functor(term.atom("func"), + [term.functor(term.atom("/"), [ClassMethod, Arity], _)], _) -> ( parse_qualified_term(ClassMethod, ClassMethod, "instance method", ok(ClassMethodName, [])), - Arity = term__functor(term__integer(ArityInt), [], _), + Arity = term.functor(term.integer(ArityInt), [], _), parse_qualified_term(InstanceMethod, InstanceMethod, "instance method", ok(InstanceMethodName, [])) -> @@ -765,7 +756,7 @@ term_to_instance_method(_ModuleName, VarSet, MethodTerm, Result) :- Item = clause(_Origin, _VarNames, PredOrFunc, ClassMethodName, HeadArgs, _ClauseBody) -> - adjust_func_arity(PredOrFunc, ArityInt, list__length(HeadArgs)), + adjust_func_arity(PredOrFunc, ArityInt, list.length(HeadArgs)), Result = ok(instance_method(PredOrFunc, ClassMethodName, clauses([Item]), ArityInt, Context)) ; diff --git a/compiler/prog_io_util.m b/compiler/prog_io_util.m index e7cee4be4..4e013ff24 100644 --- a/compiler/prog_io_util.m +++ b/compiler/prog_io_util.m @@ -21,7 +21,7 @@ % if the parse is successful, or `error(Message, Term)' if it is not. % The `Term' there should be the term which is syntactically incorrect. -:- module parse_tree__prog_io_util. +:- module parse_tree.prog_io_util. :- interface. @@ -185,11 +185,11 @@ add_context(error(M, T), _, error(M, T)). add_context(ok(Item), Context, ok(Item, Context)). parse_name_and_arity(ModuleName, PredAndArityTerm, SymName, Arity) :- - PredAndArityTerm = term__functor(term__atom("/"), + PredAndArityTerm = term.functor(term.atom("/"), [PredNameTerm, ArityTerm], _), parse_implicitly_qualified_term(ModuleName, PredNameTerm, PredNameTerm, "", ok(SymName, [])), - ArityTerm = term__functor(term__integer(Arity), [], _). + ArityTerm = term.functor(term.integer(Arity), [], _). parse_name_and_arity(PredAndArityTerm, SymName, Arity) :- parse_name_and_arity(unqualified(""), @@ -197,7 +197,7 @@ parse_name_and_arity(PredAndArityTerm, SymName, Arity) :- parse_pred_or_func_name_and_arity(ModuleName, PorFPredAndArityTerm, PredOrFunc, SymName, Arity) :- - PorFPredAndArityTerm = term__functor(term__atom(PredOrFuncStr), Args, _), + PorFPredAndArityTerm = term.functor(term.atom(PredOrFuncStr), Args, _), ( PredOrFuncStr = "pred", PredOrFunc = predicate ; PredOrFuncStr = "func", PredOrFunc = function ), @@ -215,7 +215,7 @@ parse_pred_or_func_and_args(Term, PredOrFunc, SymName, ArgTerms) :- ( MaybeRetTerm = yes(RetTerm), PredOrFunc = function, - list__append(ArgTerms0, [RetTerm], ArgTerms) + list.append(ArgTerms0, [RetTerm], ArgTerms) ; MaybeRetTerm = no, PredOrFunc = predicate, @@ -225,7 +225,7 @@ parse_pred_or_func_and_args(Term, PredOrFunc, SymName, ArgTerms) :- parse_pred_or_func_and_args(MaybeModuleName, PredAndArgsTerm, ErrorTerm, Msg, PredAndArgsResult) :- ( - PredAndArgsTerm = term__functor(term__atom("="), + PredAndArgsTerm = term.functor(term.atom("="), [FuncAndArgsTerm, FuncResultTerm], _) -> FunctorTerm = FuncAndArgsTerm, @@ -250,10 +250,10 @@ parse_pred_or_func_and_args(MaybeModuleName, PredAndArgsTerm, ErrorTerm, PredAndArgsResult = error(ErrorMsg, Term) ). -parse_list_of_vars(term__functor(term__atom("[]"), [], _), []). -parse_list_of_vars(term__functor(term__atom("[|]"), [Head, Tail], _), +parse_list_of_vars(term.functor(term.atom("[]"), [], _), []). +parse_list_of_vars(term.functor(term.atom("[|]"), [Head, Tail], _), [V | Vs]) :- - Head = term__variable(V), + Head = term.variable(V), parse_list_of_vars(Tail, Vs). % XXX kind inference: We currently give all types kind `star'. @@ -261,9 +261,9 @@ parse_list_of_vars(term__functor(term__atom("[|]"), [Head, Tail], _), % parse_type(Term, Result) :- ( - Term = term__variable(Var0) + Term = term.variable(Var0) -> - term__coerce_var(Var0, Var), + term.coerce_var(Var0, Var), Result = ok(variable(Var, star)) ; parse_builtin_type(Term, BuiltinType) @@ -274,7 +274,7 @@ parse_type(Term, Result) :- -> Result = ok(higher_order(HOArgs, MaybeRet, Purity, EvalMethod)) ; - Term = term__functor(term__atom("{}"), Args, _) + Term = term.functor(term.atom("{}"), Args, _) -> parse_types(Args, ArgsResult), ( @@ -287,7 +287,7 @@ parse_type(Term, Result) :- ; % We don't support apply/N types yet, so we just detect them % and report an error message. - Term = term__functor(term__atom(""), _, _) + Term = term.functor(term.atom(""), _, _) -> Result = error("ill-formed type", Term) ; @@ -317,7 +317,7 @@ parse_types(Terms, Result) :- maybe1(list(mer_type))::out) is det. parse_types_2([], RevTypes, ok(Types)) :- - list__reverse(RevTypes, Types). + list.reverse(RevTypes, Types). parse_types_2([Term | Terms], RevTypes, Result) :- parse_type(Term, Result0), ( @@ -331,7 +331,7 @@ parse_types_2([Term | Terms], RevTypes, Result) :- :- pred parse_builtin_type(term::in, builtin_type::out) is semidet. parse_builtin_type(Term, BuiltinType) :- - Term = term__functor(term__atom(Name), [], _), + Term = term.functor(term.atom(Name), [], _), builtin_type_to_string(BuiltinType, Name). % If there are any ill-formed types in the argument then we just fail. @@ -343,19 +343,19 @@ parse_builtin_type(Term, BuiltinType) :- parse_higher_order_type(Term0, ArgTypes, MaybeRet, Purity, lambda_normal) :- parse_purity_annotation(Term0, Purity, Term1), - ( Term1 = term__functor(term__atom("="), [FuncAndArgs, Ret], _) -> - FuncAndArgs = term__functor(term__atom("func"), Args, _), + ( Term1 = term.functor(term.atom("="), [FuncAndArgs, Ret], _) -> + FuncAndArgs = term.functor(term.atom("func"), Args, _), parse_type(Ret, ok(RetType)), MaybeRet = yes(RetType) ; - Term1 = term__functor(term__atom("pred"), Args, _), + Term1 = term.functor(term.atom("pred"), Args, _), MaybeRet = no ), parse_types(Args, ok(ArgTypes)). parse_purity_annotation(Term0, Purity, Term) :- ( - Term0 = term__functor(term__atom(PurityName), [Term1], _), + Term0 = term.functor(term.atom(PurityName), [Term1], _), purity_name(Purity0, PurityName) -> Purity = Purity0, @@ -365,39 +365,39 @@ parse_purity_annotation(Term0, Purity, Term) :- Term = Term0 ). -unparse_type(variable(TVar, _), term__variable(Var)) :- - Var = term__coerce_var(TVar). +unparse_type(variable(TVar, _), term.variable(Var)) :- + Var = term.coerce_var(TVar). unparse_type(defined(SymName, Args, _), Term) :- unparse_type_list(Args, ArgTerms), unparse_qualified_term(SymName, ArgTerms, Term). unparse_type(builtin(BuiltinType), Term) :- - Context = term__context_init, + Context = term.context_init, builtin_type_to_string(BuiltinType, Name), - Term = term__functor(term__atom(Name), [], Context). + Term = term.functor(term.atom(Name), [], Context). unparse_type(higher_order(Args, MaybeRet, Purity, EvalMethod), Term) :- - Context = term__context_init, + Context = term.context_init, unparse_type_list(Args, ArgTerms), ( MaybeRet = yes(Ret), - Term0 = term__functor(term__atom("func"), ArgTerms, Context), + Term0 = term.functor(term.atom("func"), ArgTerms, Context), maybe_add_lambda_eval_method(EvalMethod, Term0, Term1), unparse_type(Ret, RetTerm), - Term2 = term__functor(term__atom("="), [Term1, RetTerm], Context) + Term2 = term.functor(term.atom("="), [Term1, RetTerm], Context) ; MaybeRet = no, - Term0 = term__functor(term__atom("pred"), ArgTerms, Context), + Term0 = term.functor(term.atom("pred"), ArgTerms, Context), maybe_add_lambda_eval_method(EvalMethod, Term0, Term2) ), maybe_add_purity_annotation(Purity, Term2, Term). unparse_type(tuple(Args, _), Term) :- - Context = term__context_init, + Context = term.context_init, unparse_type_list(Args, ArgTerms), - Term = term__functor(term__atom("{}"), ArgTerms, Context). + Term = term.functor(term.atom("{}"), ArgTerms, Context). unparse_type(apply_n(TVar, Args, _), Term) :- - Context = term__context_init, - Var = term__coerce_var(TVar), + Context = term.context_init, + Var = term.coerce_var(TVar), unparse_type_list(Args, ArgTerms), - Term = term__functor(term__atom(""), [term__variable(Var) | ArgTerms], + Term = term.functor(term.atom(""), [term.variable(Var) | ArgTerms], Context). unparse_type(kinded(_, _), _) :- unexpected(this_file, "prog_io_util: kind annotation"). @@ -405,18 +405,18 @@ unparse_type(kinded(_, _), _) :- :- pred unparse_type_list(list(mer_type)::in, list(term)::out) is det. unparse_type_list(Types, Terms) :- - list__map(unparse_type, Types, Terms). + list.map(unparse_type, Types, Terms). :- pred unparse_qualified_term(sym_name::in, list(term)::in, term::out) is det. unparse_qualified_term(unqualified(Name), Args, Term) :- - Context = term__context_init, - Term = term__functor(term__atom(Name), Args, Context). + Context = term.context_init, + Term = term.functor(term.atom(Name), Args, Context). unparse_qualified_term(qualified(Qualifier, Name), Args, Term) :- - Context = term__context_init, + Context = term.context_init, unparse_qualified_term(Qualifier, [], QualTerm), - Term0 = term__functor(term__atom(Name), Args, Context), - Term = term__functor(term__atom("."), [QualTerm, Term0], Context). + Term0 = term.functor(term.atom(Name), Args, Context), + Term = term.functor(term.atom("."), [QualTerm, Term0], Context). :- pred maybe_add_lambda_eval_method(lambda_eval_method::in, term::in, term::out) is det. @@ -427,11 +427,11 @@ maybe_add_lambda_eval_method(lambda_normal, Term, Term). maybe_add_purity_annotation(purity_pure, Term, Term). maybe_add_purity_annotation(purity_semipure, Term0, Term) :- - Context = term__context_init, - Term = term__functor(term__atom("semipure"), [Term0], Context). + Context = term.context_init, + Term = term.functor(term.atom("semipure"), [Term0], Context). maybe_add_purity_annotation(purity_impure, Term0, Term) :- - Context = term__context_init, - Term = term__functor(term__atom("impure"), [Term0], Context). + Context = term.context_init, + Term = term.functor(term.atom("impure"), [Term0], Context). convert_mode_list(_, [], []). convert_mode_list(AllowConstrainedInstVar, [H0 | T0], [H | T]) :- @@ -440,7 +440,7 @@ convert_mode_list(AllowConstrainedInstVar, [H0 | T0], [H | T]) :- convert_mode(AllowConstrainedInstVar, Term, Mode) :- ( - Term = term__functor(term__atom(">>"), [InstA, InstB], _) + Term = term.functor(term.atom(">>"), [InstA, InstB], _) -> convert_inst(AllowConstrainedInstVar, InstA, ConvertedInstA), convert_inst(AllowConstrainedInstVar, InstB, ConvertedInstB), @@ -454,10 +454,10 @@ convert_mode(AllowConstrainedInstVar, Term, Mode) :- % -> pred(, , ...) is % ) - Term = term__functor(term__atom("is"), [PredTerm, DetTerm], _), - PredTerm = term__functor(term__atom("pred"), ArgModesTerms, _) + Term = term.functor(term.atom("is"), [PredTerm, DetTerm], _), + PredTerm = term.functor(term.atom("pred"), ArgModesTerms, _) -> - DetTerm = term__functor(term__atom(DetString), [], _), + DetTerm = term.functor(term.atom(DetString), [], _), standard_det(DetString, Detism), convert_mode_list(AllowConstrainedInstVar, ArgModesTerms, ArgModes), PredInstInfo = pred_inst_info(predicate, ArgModes, Detism), @@ -472,15 +472,15 @@ convert_mode(AllowConstrainedInstVar, Term, Mode) :- % -> func(, , ...) = is % ) - Term = term__functor(term__atom("is"), [EqTerm, DetTerm], _), - EqTerm = term__functor(term__atom("="), [FuncTerm, RetModeTerm], _), - FuncTerm = term__functor(term__atom("func"), ArgModesTerms, _) + Term = term.functor(term.atom("is"), [EqTerm, DetTerm], _), + EqTerm = term.functor(term.atom("="), [FuncTerm, RetModeTerm], _), + FuncTerm = term.functor(term.atom("func"), ArgModesTerms, _) -> - DetTerm = term__functor(term__atom(DetString), [], _), + DetTerm = term.functor(term.atom(DetString), [], _), standard_det(DetString, Detism), convert_mode_list(AllowConstrainedInstVar, ArgModesTerms, ArgModes0), convert_mode(AllowConstrainedInstVar, RetModeTerm, RetMode), - list__append(ArgModes0, [RetMode], ArgModes), + list.append(ArgModes0, [RetMode], ArgModes), FuncInstInfo = pred_inst_info(function, ArgModes, Detism), Inst = ground(shared, higher_order(FuncInstInfo)), Mode = (Inst -> Inst) @@ -496,10 +496,10 @@ convert_inst_list(AllowConstrainedInstVar, [H0 | T0], [H | T]) :- convert_inst(AllowConstrainedInstVar, H0, H), convert_inst_list(AllowConstrainedInstVar, T0, T). -convert_inst(_, term__variable(V0), inst_var(V)) :- - term__coerce_var(V0, V). +convert_inst(_, term.variable(V0), inst_var(V)) :- + term.coerce_var(V0, V). convert_inst(AllowConstrainedInstVar, Term, Result) :- - Term = term__functor(term__atom(Name), Args0, _Context), + Term = term.functor(term.atom(Name), Args0, _Context), ( convert_simple_builtin_inst(Name, Args0, Result0) -> @@ -513,9 +513,9 @@ convert_inst(AllowConstrainedInstVar, Term, Result) :- % and is a determinism. Name = "is", Args0 = [PredTerm, DetTerm], - PredTerm = term__functor(term__atom("pred"), ArgModesTerm, _) + PredTerm = term.functor(term.atom("pred"), ArgModesTerm, _) -> - DetTerm = term__functor(term__atom(DetString), [], _), + DetTerm = term.functor(term.atom(DetString), [], _), standard_det(DetString, Detism), convert_mode_list(AllowConstrainedInstVar, ArgModesTerm, ArgModes), PredInst = pred_inst_info(predicate, ArgModes, Detism), @@ -529,14 +529,14 @@ convert_inst(AllowConstrainedInstVar, Term, Result) :- % is a mode, and is a determinism. Name = "is", Args0 = [EqTerm, DetTerm], - EqTerm = term__functor(term__atom("="), [FuncTerm, RetModeTerm], _), - FuncTerm = term__functor(term__atom("func"), ArgModesTerm, _) + EqTerm = term.functor(term.atom("="), [FuncTerm, RetModeTerm], _), + FuncTerm = term.functor(term.atom("func"), ArgModesTerm, _) -> - DetTerm = term__functor(term__atom(DetString), [], _), + DetTerm = term.functor(term.atom(DetString), [], _), standard_det(DetString, Detism), convert_mode_list(AllowConstrainedInstVar, ArgModesTerm, ArgModes0), convert_mode(AllowConstrainedInstVar, RetModeTerm, RetMode), - list__append(ArgModes0, [RetMode], ArgModes), + list.append(ArgModes0, [RetMode], ArgModes), FuncInst = pred_inst_info(function, ArgModes, Detism), Result = ground(shared, higher_order(FuncInst)) @@ -553,11 +553,11 @@ convert_inst(AllowConstrainedInstVar, Term, Result) :- Result) ; Name = "=<", Args0 = [VarTerm, InstTerm] -> AllowConstrainedInstVar = allow_constrained_inst_var, - VarTerm = term__variable(Var), + VarTerm = term.variable(Var), % Do not allow nested constrained_inst_vars. convert_inst(no_allow_constrained_inst_var, InstTerm, Inst), - Result = constrained_inst_vars(set__make_singleton_set( - term__coerce_var(Var)), Inst) + Result = constrained_inst_vars(set.make_singleton_set( + term.coerce_var(Var)), Inst) ; % Anything else must be a user-defined inst. parse_qualified_term(Term, Term, "inst", ok(QualifiedName, Args1)), @@ -632,10 +632,10 @@ parse_bound_inst_list(AllowConstrainedInstVar, Disj, Uniqueness, bound(Uniqueness, Functors)) :- disjunction_to_list(Disj, List), convert_bound_inst_list(AllowConstrainedInstVar, List, Functors0), - list__sort(Functors0, Functors), + list.sort(Functors0, Functors), % Check that the list doesn't specify the same functor twice. \+ ( - list__append(_, SubList, Functors), + list.append(_, SubList, Functors), SubList = [F1, F2 | _], F1 = functor(ConsId, _), F2 = functor(ConsId, _) @@ -653,14 +653,14 @@ convert_bound_inst_list(AllowConstrainedInstVar, [H0 | T0], [H | T]) :- bound_inst::out) is semidet. convert_bound_inst(AllowConstrainedInstVar, InstTerm, functor(ConsId, Args)) :- - InstTerm = term__functor(Functor, Args0, _), - ( Functor = term__atom(_) -> + InstTerm = term.functor(Functor, Args0, _), + ( Functor = term.atom(_) -> parse_qualified_term(InstTerm, InstTerm, "inst", ok(SymName, Args1)), - list__length(Args1, Arity), + list.length(Args1, Arity), ConsId = cons(SymName, Arity) ; Args1 = Args0, - list__length(Args1, Arity), + list.length(Args1, Arity), ConsId = make_functor_cons_id(Functor, Arity) ), convert_inst_list(AllowConstrainedInstVar, Args1, Args). @@ -674,7 +674,7 @@ conjunction_to_list(Term, List) :- list_to_conjunction(_, Term, [], Term). list_to_conjunction(Context, First, [Second | Rest], Term) :- list_to_conjunction(Context, Second, Rest, Tail), - Term = term__functor(term__atom(","), [First, Tail], Context). + Term = term.functor(term.atom(","), [First, Tail], Context). sum_to_list(Term, List) :- binop_term_to_list("+", Term, List). @@ -691,7 +691,7 @@ binop_term_to_list(Op, Term, List) :- list(term(T))::out) is det. binop_term_to_list_2(Op, Term, !List) :- - ( Term = term__functor(term__atom(Op), [L, R], _Context) -> + ( Term = term.functor(term.atom(Op), [L, R], _Context) -> binop_term_to_list_2(Op, R, !List), binop_term_to_list_2(Op, L, !List) ; @@ -759,11 +759,11 @@ parse_vars_and_state_vars(functor(atom("[|]"), [H, T], _), !:Os, !:Ds, !:Cs) :- list_term_to_term_list(Methods, MethodList) :- ( - Methods = term__functor(term__atom("[|]"), [Head, Tail0], _), + Methods = term.functor(term.atom("[|]"), [Head, Tail0], _), list_term_to_term_list(Tail0, Tail), MethodList = [Head|Tail] ; - Methods = term__functor(term__atom("[]"), [], _), + Methods = term.functor(term.atom("[]"), [], _), MethodList = [] ). @@ -774,5 +774,5 @@ list_term_to_term_list(Methods, MethodList) :- this_file = "prog_io_util.m". %-----------------------------------------------------------------------------% -:- end_module parse_tree__prog_io_util. +:- end_module parse_tree.prog_io_util. %-----------------------------------------------------------------------------% diff --git a/compiler/prog_item.m b/compiler/prog_item.m index dc8005184..c4c315fac 100644 --- a/compiler/prog_item.m +++ b/compiler/prog_item.m @@ -728,7 +728,7 @@ ; include_module(list(module_name)) - ; version_numbers(module_name, recompilation__version_numbers). + ; version_numbers(module_name, recompilation.version_numbers). % This is used to represent the version numbers of items in an % interface file for use in smart recompilation. diff --git a/compiler/prog_mode.m b/compiler/prog_mode.m index f37585136..c65c39378 100644 --- a/compiler/prog_mode.m +++ b/compiler/prog_mode.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module parse_tree__prog_mode. +:- module parse_tree.prog_mode. :- interface. :- import_module parse_tree.prog_data. @@ -215,7 +215,7 @@ mode_substitute_arg_list(Mode0, Params, Args, Mode) :- Mode = Mode0 % optimize common case ; Params = [_ | _], - map__from_corresponding_lists(Params, Args, Subst), + map.from_corresponding_lists(Params, Args, Subst), mode_apply_substitution(Subst, Mode0, Mode) ). @@ -225,7 +225,7 @@ inst_substitute_arg_list(Params, Args, Inst0, Inst) :- Inst = Inst0 % optimize common case ; Params = [_ | _], - map__from_corresponding_lists(Params, Args, Subst), + map.from_corresponding_lists(Params, Args, Subst), inst_apply_substitution(Subst, Inst0, Inst) ). @@ -243,7 +243,7 @@ mode_apply_substitution(Subst, user_defined_mode(Name, Args0), inst_list_apply_substitution_2(Subst, Args0, Args). inst_list_apply_substitution(Subst, Insts0, Insts) :- - ( map__is_empty(Subst) -> + ( map.is_empty(Subst) -> Insts = Insts0 ; inst_list_apply_substitution_2(Subst, Insts0, Insts) @@ -272,19 +272,19 @@ inst_apply_substitution(Subst, bound(Uniq, Alts0), bound(Uniq, Alts)) :- alt_list_apply_substitution(Subst, Alts0, Alts). inst_apply_substitution(_, not_reached, not_reached). inst_apply_substitution(Subst, inst_var(Var), Result) :- - ( map__search(Subst, Var, Replacement) -> + ( map.search(Subst, Var, Replacement) -> Result = Replacement ; Result = inst_var(Var) ). inst_apply_substitution(Subst, constrained_inst_vars(Vars, Inst0), Result) :- - ( set__singleton_set(Vars, Var0) -> + ( set.singleton_set(Vars, Var0) -> Var = Var0 ; unexpected(this_file, "inst_apply_substitution: multiple inst_vars found") ), - ( map__search(Subst, Var, Replacement) -> + ( map.search(Subst, Var, Replacement) -> Result = Replacement % XXX Should probably have a sanity check here that % Replacement =< Inst0 @@ -339,7 +339,7 @@ ground_inst_info_apply_substitution(Subst, Uniq, GII0, ground(Uniq, GII)) :- GII = higher_order(pred_inst_info(PredOrFunc, Modes, Det)). mode_list_apply_substitution(Subst, Modes0, Modes) :- - ( map__is_empty(Subst) -> + ( map.is_empty(Subst) -> Modes = Modes0 ; mode_list_apply_substitution_2(Subst, Modes0, Modes) @@ -356,8 +356,8 @@ mode_list_apply_substitution_2(Subst, [A0 | As0], [A | As]) :- %-----------------------------------------------------------------------------% rename_apart_inst_vars(VarSet, NewVarSet, Modes0, Modes) :- - varset__merge_subst(VarSet, NewVarSet, _, Sub), - list__map(rename_apart_inst_vars_in_mode(Sub), Modes0, Modes). + varset.merge_subst(VarSet, NewVarSet, _, Sub), + list.map(rename_apart_inst_vars_in_mode(Sub), Modes0, Modes). :- pred rename_apart_inst_vars_in_mode(substitution(inst_var_type)::in, mer_mode::in, mer_mode::out) is det. @@ -367,7 +367,7 @@ rename_apart_inst_vars_in_mode(Sub, I0 -> F0, I -> F) :- rename_apart_inst_vars_in_inst(Sub, F0, F). rename_apart_inst_vars_in_mode(Sub, user_defined_mode(Name, Insts0), user_defined_mode(Name, Insts)) :- - list__map(rename_apart_inst_vars_in_inst(Sub), Insts0, Insts). + list.map(rename_apart_inst_vars_in_inst(Sub), Insts0, Insts). :- pred rename_apart_inst_vars_in_inst(substitution(inst_var_type)::in, mer_inst::in, mer_inst::out) is det. @@ -376,13 +376,13 @@ rename_apart_inst_vars_in_inst(_, any(U), any(U)). rename_apart_inst_vars_in_inst(_, free, free). rename_apart_inst_vars_in_inst(_, free(T), free(T)). rename_apart_inst_vars_in_inst(Sub, bound(U, BIs0), bound(U, BIs)) :- - list__map((pred(functor(C, Is0)::in, functor(C, Is)::out) is det :- - list__map(rename_apart_inst_vars_in_inst(Sub), Is0, Is)), + list.map((pred(functor(C, Is0)::in, functor(C, Is)::out) is det :- + list.map(rename_apart_inst_vars_in_inst(Sub), Is0, Is)), BIs0, BIs). rename_apart_inst_vars_in_inst(Sub, ground(U, GI0), ground(U, GI)) :- ( GI0 = higher_order(pred_inst_info(PoF, Modes0, Det)), - list__map(rename_apart_inst_vars_in_mode(Sub), Modes0, Modes), + list.map(rename_apart_inst_vars_in_mode(Sub), Modes0, Modes), GI = higher_order(pred_inst_info(PoF, Modes, Det)) ; GI0 = none, @@ -390,7 +390,7 @@ rename_apart_inst_vars_in_inst(Sub, ground(U, GI0), ground(U, GI)) :- ). rename_apart_inst_vars_in_inst(_, not_reached, not_reached). rename_apart_inst_vars_in_inst(Sub, inst_var(Var0), inst_var(Var)) :- - ( map__search(Sub, Var0, term__variable(Var1)) -> + ( map.search(Sub, Var0, term.variable(Var1)) -> Var = Var1 ; Var = Var0 @@ -398,8 +398,8 @@ rename_apart_inst_vars_in_inst(Sub, inst_var(Var0), inst_var(Var)) :- rename_apart_inst_vars_in_inst(Sub, constrained_inst_vars(Vars0, Inst0), constrained_inst_vars(Vars, Inst)) :- rename_apart_inst_vars_in_inst(Sub, Inst0, Inst), - Vars = set__map(func(Var0) = - ( map__search(Sub, Var0, term__variable(Var)) -> + Vars = set.map(func(Var0) = + ( map.search(Sub, Var0, term.variable(Var)) -> Var ; Var0 @@ -412,14 +412,14 @@ rename_apart_inst_vars_in_inst(Sub, defined_inst(Name0), defined_inst(Name)) :- ). rename_apart_inst_vars_in_inst(Sub, abstract_inst(Sym, Insts0), abstract_inst(Sym, Insts)) :- - list__map(rename_apart_inst_vars_in_inst(Sub), Insts0, Insts). + list.map(rename_apart_inst_vars_in_inst(Sub), Insts0, Insts). :- pred rename_apart_inst_vars_in_inst_name(substitution(inst_var_type)::in, inst_name::in, inst_name::out) is semidet. rename_apart_inst_vars_in_inst_name(Sub, user_inst(Sym, Insts0), user_inst(Sym, Insts)) :- - list__map(rename_apart_inst_vars_in_inst(Sub), Insts0, Insts). + list.map(rename_apart_inst_vars_in_inst(Sub), Insts0, Insts). rename_apart_inst_vars_in_inst_name(Sub, typed_inst(Type, Name0), typed_inst(Type, Name)) :- rename_apart_inst_vars_in_inst_name(Sub, Name0, Name). @@ -493,22 +493,22 @@ functors_to_cons_ids([Functor | Functors], [ConsId | ConsIds]) :- %-----------------------------------------------------------------------------% get_arg_insts(not_reached, _ConsId, Arity, ArgInsts) :- - list__duplicate(Arity, not_reached, ArgInsts). + list.duplicate(Arity, not_reached, ArgInsts). get_arg_insts(ground(Uniq, _PredInst), _ConsId, Arity, ArgInsts) :- - list__duplicate(Arity, ground(Uniq, none), ArgInsts). + list.duplicate(Arity, ground(Uniq, none), ArgInsts). get_arg_insts(bound(_Uniq, List), ConsId, Arity, ArgInsts) :- ( get_arg_insts_2(List, ConsId, ArgInsts0) -> ArgInsts = ArgInsts0 ; % The code is unreachable. - list__duplicate(Arity, not_reached, ArgInsts) + list.duplicate(Arity, not_reached, ArgInsts) ). get_arg_insts(free, _ConsId, Arity, ArgInsts) :- - list__duplicate(Arity, free, ArgInsts). + list.duplicate(Arity, free, ArgInsts). get_arg_insts(free(_Type), _ConsId, Arity, ArgInsts) :- - list__duplicate(Arity, free, ArgInsts). + list.duplicate(Arity, free, ArgInsts). get_arg_insts(any(Uniq), _ConsId, Arity, ArgInsts) :- - list__duplicate(Arity, any(Uniq), ArgInsts). + list.duplicate(Arity, any(Uniq), ArgInsts). :- pred get_arg_insts_2(list(bound_inst)::in, cons_id::in, list(mer_inst)::out) is semidet. @@ -528,7 +528,7 @@ mode_id_to_int(_ - X, X). % The interesting part is strip_builtin_qualifier_from_sym_name; % the rest is basically just recursive traversals. strip_builtin_qualifiers_from_mode_list(Modes0, Modes) :- - list__map(strip_builtin_qualifiers_from_mode, Modes0, Modes). + list.map(strip_builtin_qualifiers_from_mode, Modes0, Modes). :- pred strip_builtin_qualifiers_from_mode(mer_mode::in, mer_mode::out) is det. @@ -563,7 +563,7 @@ strip_builtin_qualifier_from_sym_name(SymName0, SymName) :- ). strip_builtin_qualifiers_from_inst_list(Insts0, Insts) :- - list__map(strip_builtin_qualifiers_from_inst, Insts0, Insts). + list.map(strip_builtin_qualifiers_from_inst, Insts0, Insts). strip_builtin_qualifiers_from_inst(inst_var(V), inst_var(V)). strip_builtin_qualifiers_from_inst(constrained_inst_vars(Vars, Inst0), @@ -589,7 +589,7 @@ strip_builtin_qualifiers_from_inst(abstract_inst(Name0, Args0), list(bound_inst)::out) is det. strip_builtin_qualifiers_from_bound_inst_list(Insts0, Insts) :- - list__map(strip_builtin_qualifiers_from_bound_inst, Insts0, Insts). + list.map(strip_builtin_qualifiers_from_bound_inst, Insts0, Insts). :- pred strip_builtin_qualifiers_from_bound_inst(bound_inst::in, bound_inst::out) is det. @@ -598,7 +598,7 @@ strip_builtin_qualifiers_from_bound_inst(BoundInst0, BoundInst) :- BoundInst0 = functor(ConsId0, Insts0), strip_builtin_qualifier_from_cons_id(ConsId0, ConsId), BoundInst = functor(ConsId, Insts), - list__map(strip_builtin_qualifiers_from_inst, Insts0, Insts). + list.map(strip_builtin_qualifiers_from_inst, Insts0, Insts). :- pred strip_builtin_qualifiers_from_inst_name(inst_name::in, inst_name::out) is det. diff --git a/compiler/prog_mutable.m b/compiler/prog_mutable.m index 61f4c2c4c..58ac159d4 100644 --- a/compiler/prog_mutable.m +++ b/compiler/prog_mutable.m @@ -74,8 +74,8 @@ %-----------------------------------------------------------------------------% nonpure_get_pred_decl(ModuleName, Name, Type, Inst) = GetPredDecl :- - VarSet = varset__init, - InstVarSet = varset__init, + VarSet = varset.init, + InstVarSet = varset.init, ExistQVars = [], Constraints = constraints([], []), GetPredDecl = pred_or_func(VarSet, InstVarSet, ExistQVars, predicate, @@ -85,8 +85,8 @@ nonpure_get_pred_decl(ModuleName, Name, Type, Inst) = GetPredDecl :- true /* condition */, purity_semipure, Constraints). nonpure_set_pred_decl(ModuleName, Name, Type, Inst) = SetPredDecl :- - VarSet = varset__init, - InstVarSet = varset__init, + VarSet = varset.init, + InstVarSet = varset.init, ExistQVars = [], Constraints = constraints([], []), SetPredDecl = pred_or_func(VarSet, InstVarSet, ExistQVars, predicate, @@ -96,8 +96,8 @@ nonpure_set_pred_decl(ModuleName, Name, Type, Inst) = SetPredDecl :- true /* condition */, purity_impure, Constraints). pure_get_pred_decl(ModuleName, Name, Type, Inst) = GetPredDecl :- - VarSet = varset__init, - InstVarSet = varset__init, + VarSet = varset.init, + InstVarSet = varset.init, ExistQVars = [], Constraints = constraints([], []), GetPredDecl = pred_or_func(VarSet, InstVarSet, ExistQVars, predicate, @@ -109,8 +109,8 @@ pure_get_pred_decl(ModuleName, Name, Type, Inst) = GetPredDecl :- true /* condition */, purity_pure, Constraints). pure_set_pred_decl(ModuleName, Name, Type, Inst) = SetPredDecl :- - VarSet = varset__init, - InstVarSet = varset__init, + VarSet = varset.init, + InstVarSet = varset.init, ExistQVars = [], Constraints = constraints([], []), SetPredDecl = pred_or_func(VarSet, InstVarSet, ExistQVars, predicate, @@ -122,8 +122,8 @@ pure_set_pred_decl(ModuleName, Name, Type, Inst) = SetPredDecl :- true /* condition */, purity_pure, Constraints). init_pred_decl(ModuleName, Name) = InitPredDecl :- - VarSet = varset__init, - InstVarSet = varset__init, + VarSet = varset.init, + InstVarSet = varset.init, ExistQVars = [], Constraints = constraints([], []), InitPredDecl = pred_or_func(VarSet, InstVarSet, ExistQVars, diff --git a/compiler/prog_out.m b/compiler/prog_out.m index 1a928f8df..d3b6150ee 100644 --- a/compiler/prog_out.m +++ b/compiler/prog_out.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1993-2005 The University of Melbourne. +% Copyright (C) 1993-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -18,7 +18,7 @@ %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- module parse_tree__prog_out. +:- module parse_tree.prog_out. :- interface. :- import_module mdbcomp.prim_data. @@ -35,7 +35,7 @@ :- pred maybe_flush_output(bool::in, io::di, io::uo) is det. :- pred report_error(string::in, io::di, io::uo) is det. -:- pred report_error(io__output_stream::in, string::in, io::di, io::uo) is det. +:- pred report_error(io.output_stream::in, string::in, io::di, io::uo) is det. % Write out the list of error/warning messages which is returned % when a module is parsed. @@ -181,27 +181,27 @@ %-----------------------------------------------------------------------------% maybe_report_stats(yes, !IO) :- - io__report_stats(!IO). + io.report_stats(!IO). maybe_report_stats(no, !IO). maybe_write_string(yes, String, !IO) :- - io__write_string(String, !IO). + io.write_string(String, !IO). maybe_write_string(no, _, !IO). maybe_flush_output(yes, !IO) :- - io__flush_output(!IO). + io.flush_output(!IO). maybe_flush_output(no, !IO). report_error(ErrorMessage, !IO) :- - io__write_string("Error: ", !IO), - io__write_string(ErrorMessage, !IO), - io__write_string("\n", !IO), - io__set_exit_status(1, !IO). + io.write_string("Error: ", !IO), + io.write_string(ErrorMessage, !IO), + io.write_string("\n", !IO), + io.set_exit_status(1, !IO). report_error(Stream, ErrorMessage, !IO) :- - io__set_output_stream(Stream, OldStream, !IO), + io.set_output_stream(Stream, OldStream, !IO), report_error(ErrorMessage, !IO), - io__set_output_stream(OldStream, _, !IO). + io.set_output_stream(OldStream, _, !IO). write_messages([], !IO). write_messages([Message | Messages], !IO) :- @@ -212,36 +212,36 @@ write_messages([Message | Messages], !IO) :- io::di, io::uo) is det. write_message(Msg - Term, !IO) :- - ( Term = term__functor(_Functor, _Args, Context0) -> - Context0 = term__context(File, Line), - Context = term__context(File, Line), + ( Term = term.functor(_Functor, _Args, Context0) -> + Context0 = term.context(File, Line), + Context = term.context(File, Line), write_context(Context, !IO) ; true ), - io__write_string(Msg, !IO), - ( Term = term__functor(term__atom(""), [], _Context2) -> - io__write_string(".\n", !IO) + io.write_string(Msg, !IO), + ( Term = term.functor(term.atom(""), [], _Context2) -> + io.write_string(".\n", !IO) ; - io__write_string(": ", !IO), - varset__init(VarSet), + io.write_string(": ", !IO), + varset.init(VarSet), % XXX variable names in error messages - term_io__write_term_nl(VarSet, Term, !IO) + term_io.write_term_nl(VarSet, Term, !IO) ). %-----------------------------------------------------------------------------% write_context(Context, !IO) :- context_to_string(Context, ContextMessage), - io__write_string(ContextMessage, !IO). + io.write_string(ContextMessage, !IO). context_to_string(Context, ContextMessage) :- - term__context_file(Context, FileName), - term__context_line(Context, LineNumber), + term.context_file(Context, FileName), + term.context_line(Context, LineNumber), ( FileName = "" -> ContextMessage = "" ; - string__format("%s:%03d: ", [s(FileName), i(LineNumber)], + string.format("%s:%03d: ", [s(FileName), i(LineNumber)], ContextMessage) ). @@ -249,47 +249,47 @@ context_to_string(Context, ContextMessage) :- write_sym_name(qualified(ModuleSpec, Name), !IO) :- write_module_spec(ModuleSpec, !IO), - io__write_string(".", !IO), - term_io__write_escaped_string(Name, !IO). + io.write_string(".", !IO), + term_io.write_escaped_string(Name, !IO). write_sym_name(unqualified(Name), !IO) :- - term_io__write_escaped_string(Name, !IO). + term_io.write_escaped_string(Name, !IO). sym_name_to_escaped_string(qualified(ModuleSpec, Name)) = module_spec_to_escaped_string(ModuleSpec) ++ "." - ++ term_io__escaped_string(Name). + ++ term_io.escaped_string(Name). sym_name_to_escaped_string(unqualified(Name)) = - term_io__escaped_string(Name). + term_io.escaped_string(Name). write_sym_name_and_arity(Name / Arity, !IO) :- write_sym_name(Name, !IO), - io__write_string("/", !IO), - io__write_int(Arity, !IO). + io.write_string("/", !IO), + io.write_int(Arity, !IO). write_quoted_sym_name(SymName, !IO) :- - io__write_string("'", !IO), + io.write_string("'", !IO), write_sym_name(SymName, !IO), - io__write_string("'", !IO). + io.write_string("'", !IO). sym_name_and_arity_to_string(SymName/Arity, String) :- - mdbcomp__prim_data__sym_name_to_string(SymName, SymNameString), - string__int_to_string(Arity, ArityString), - string__append_list([SymNameString, "/", ArityString], String). + sym_name_to_string(SymName, SymNameString), + string.int_to_string(Arity, ArityString), + string.append_list([SymNameString, "/", ArityString], String). sym_name_and_arity_to_string(SymName/Arity) = String :- sym_name_and_arity_to_string(SymName/Arity, String). write_simple_call_id(PredOrFunc - Name/Arity, !IO) :- Str = simple_call_id_to_string(PredOrFunc, Name, Arity), - io__write_string(Str, !IO). + io.write_string(Str, !IO). write_simple_call_id(PredOrFunc, Name/Arity, !IO) :- Str = simple_call_id_to_string(PredOrFunc, Name, Arity), - io__write_string(Str, !IO). + io.write_string(Str, !IO). write_simple_call_id(PredOrFunc, Name, Arity, !IO) :- Str = simple_call_id_to_string(PredOrFunc, Name, Arity), - io__write_string(Str, !IO). + io.write_string(Str, !IO). simple_call_id_to_string(PredOrFunc - Name/Arity) = simple_call_id_to_string(PredOrFunc, Name, Arity). @@ -308,13 +308,13 @@ simple_call_id_to_string(PredOrFunc, Name, Arity) = Str :- Name = qualified(_, StrName) ), % Is it really a promise? - ( string__prefix(StrName, "promise__") -> + ( string.prefix(StrName, "promise__") -> MaybePromise = yes(true) - ; string__prefix(StrName, "promise_exclusive__") -> + ; string.prefix(StrName, "promise_exclusive__") -> MaybePromise = yes(exclusive) - ; string__prefix(StrName, "promise_exhaustive__") -> + ; string.prefix(StrName, "promise_exhaustive__") -> MaybePromise = yes(exhaustive) - ; string__prefix(StrName, "promise_exclusive_exhaustive__") -> + ; string.prefix(StrName, "promise_exclusive_exhaustive__") -> MaybePromise = yes(exclusive_exhaustive) ; MaybePromise = no % No, it is really a pred or func. @@ -350,17 +350,17 @@ write_module_list(Modules, !IO) :- :- pred write_module(module_name::in, io::di, io::uo) is det. write_module(Module, !IO) :- - io__write_string("`", !IO), + io.write_string("`", !IO), write_sym_name(Module, !IO), - io__write_string("'", !IO). + io.write_string("'", !IO). write_list([Import1, Import2, Import3 | Imports], Writer, !IO) :- call(Writer, Import1, !IO), - io__write_string(", ", !IO), + io.write_string(", ", !IO), write_list([Import2, Import3 | Imports], Writer, !IO). write_list([Import1, Import2], Writer, !IO) :- call(Writer, Import1, !IO), - io__write_string(" and ", !IO), + io.write_string(" and ", !IO), call(Writer, Import2, !IO). write_list([Import], Writer, !IO) :- call(Writer, Import, !IO). @@ -369,10 +369,10 @@ write_list([], _, !IO) :- write_string_list([], !IO). write_string_list([Name], !IO) :- - io__write_string(Name, !IO). + io.write_string(Name, !IO). write_string_list([Name1, Name2 | Names], !IO) :- - io__write_string(Name1, !IO), - io__write_string(", ", !IO), + io.write_string(Name1, !IO), + io.write_string(", ", !IO), write_string_list([Name2 | Names], !IO). promise_to_string(true) = "promise". @@ -387,10 +387,10 @@ builtin_type_to_string(string, "string"). builtin_type_to_string(character, "character"). write_promise_type(PromiseType, !IO) :- - io__write_string(promise_to_string(PromiseType), !IO). + io.write_string(promise_to_string(PromiseType), !IO). write_pred_or_func(PorF, !IO) :- - io__write_string(pred_or_func_to_full_str(PorF), !IO). + io.write_string(pred_or_func_to_full_str(PorF), !IO). pred_or_func_to_full_str(predicate) = "predicate". pred_or_func_to_full_str(function) = "function". @@ -403,7 +403,7 @@ write_purity_prefix(Purity, !IO) :- true ; write_purity(Purity, !IO), - io__write_string(" ", !IO) + io.write_string(" ", !IO) ). purity_prefix_to_string(Purity) = String :- @@ -411,12 +411,12 @@ purity_prefix_to_string(Purity) = String :- String = "" ; purity_name(Purity, PurityName), - String = string__append(PurityName, " ") + String = string.append(PurityName, " ") ). write_purity(Purity, !IO) :- purity_name(Purity, String), - io__write_string(String, !IO). + io.write_string(String, !IO). purity_name(purity_pure, "pure"). purity_name(purity_semipure, "semipure"). @@ -437,8 +437,8 @@ eval_method_to_string(eval_loop_check) = "loop_check" - no. eval_method_to_string(eval_memo(all_strict)) = "memo" - no. eval_method_to_string(eval_memo(all_fast_loose)) = "fast_loose_memo" - no. eval_method_to_string(eval_memo(specified(Args))) = "memo" - yes(ArgsStr) :- - ArgStrs = list__map(maybe_arg_tabling_method_to_string, Args), - ArgsStr = "[" ++ string__join_list(", ", ArgStrs) ++ "]". + ArgStrs = list.map(maybe_arg_tabling_method_to_string, Args), + ArgsStr = "[" ++ string.join_list(", ", ArgStrs) ++ "]". eval_method_to_string(eval_minimal(MinimalMethod)) = Str - no :- ( MinimalMethod = own_stacks, diff --git a/compiler/prog_rep.m b/compiler/prog_rep.m index 7eea67ecc..08e913747 100644 --- a/compiler/prog_rep.m +++ b/compiler/prog_rep.m @@ -7,7 +7,7 @@ %---------------------------------------------------------------------------% % File: prog_rep.m. -% Author: zs. +% Authors: zs, maclarty. % This module generates a representation of HLDS goals for the declarative % debugger. Since this representation is to be included in debuggable @@ -17,7 +17,7 @@ %---------------------------------------------------------------------------% -:- module ll_backend__prog_rep. +:- module ll_backend.prog_rep. :- interface. :- import_module hlds.hlds_goal. @@ -36,7 +36,7 @@ % layout structures to a number that uniquely identifies that variable, % and to its name. % - % The integer returned by term__var_to_int are a dense set when we consider + % The integer returned by term.var_to_int are a dense set when we consider % all the original variables of a procedure. However, it can become less % dense when an optimization removes all references to a variable, and % becomes less dense still when we consider only variables that occur @@ -88,7 +88,7 @@ represent_proc(HeadVars, Goal, InstMap0, VarTypes, VarNumMap, ModuleInfo, !StackInfo, ProcRepBytes) :- Goal = _ - GoalInfo, goal_info_get_context(GoalInfo, Context), - term__context_file(Context, FileName), + term.context_file(Context, FileName), MaxVarNum = map.foldl(max_var_num, VarNumMap, 0), ( MaxVarNum =< 255 -> VarNumRep = byte @@ -102,7 +102,7 @@ represent_proc(HeadVars, Goal, InstMap0, VarTypes, VarNumMap, goal_to_byte_list(Goal, InstMap0, Info, !StackInfo, GoalBytes), ProcRepBytes0 = [VarNumRepByte] ++ FileNameBytes ++ vars_to_byte_list(Info, HeadVars) ++ GoalBytes, - int32_to_byte_list(list__length(ProcRepBytes0) + 4, LimitBytes), + int32_to_byte_list(list.length(ProcRepBytes0) + 4, LimitBytes), ProcRepBytes = LimitBytes ++ ProcRepBytes0. %---------------------------------------------------------------------------% @@ -148,7 +148,7 @@ goal_expr_to_byte_list(if_then_else(_, Cond, Then, Else), _, InstMap0, Info, !StackInfo, Bytes) :- Cond = _ - CondGoalInfo, goal_info_get_instmap_delta(CondGoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap1), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap1), goal_to_byte_list(Cond, InstMap0, Info, !StackInfo, CondBytes), goal_to_byte_list(Then, InstMap1, Info, !StackInfo, ThenBytes), goal_to_byte_list(Else, InstMap0, Info, !StackInfo, ElseBytes), @@ -260,7 +260,7 @@ goal_expr_to_byte_list(call(PredId, _, Args, Builtin, _, _), AtomicBytes, _), module_info_pred_info(Info ^ module_info, PredId, PredInfo), ModuleSymName = pred_info_module(PredInfo), - mdbcomp__prim_data__sym_name_to_string(ModuleSymName, ModuleName), + mdbcomp.prim_data.sym_name_to_string(ModuleSymName, ModuleName), PredName = pred_info_name(PredInfo), string_to_byte_list(ModuleName, !StackInfo, ModuleNameBytes), string_to_byte_list(PredName, !StackInfo, PredNameBytes), @@ -279,7 +279,7 @@ goal_expr_to_byte_list(call(PredId, _, Args, Builtin, _, _), ). goal_expr_to_byte_list(foreign_proc(_, _PredId, _, Args, _, _), GoalInfo, InstMap0, Info, !StackInfo, Bytes) :- - ArgVars = list__map(foreign_arg_var, Args), + ArgVars = list.map(foreign_arg_var, Args), atomic_goal_info_to_byte_list(GoalInfo, InstMap0, Info, !StackInfo, AtomicBytes, _), Bytes = [goal_type_to_byte(goal_foreign)] ++ @@ -325,18 +325,18 @@ atomic_goal_info_to_byte_list(GoalInfo, InstMap0, Info, !StackInfo, Bytes, BoundVars) :- goal_info_get_determinism(GoalInfo, Detism), goal_info_get_context(GoalInfo, Context), - term__context_file(Context, FileName0), + term.context_file(Context, FileName0), ( FileName0 = Info ^ filename -> FileName = "" ; FileName = FileName0 ), - term__context_line(Context, LineNo), + term.context_line(Context, LineNo), goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap), instmap_changed_vars(InstMap0, InstMap, Info ^ vartypes, Info ^ module_info, ChangedVars), - set__to_sorted_list(ChangedVars, BoundVars), + set.to_sorted_list(ChangedVars, BoundVars), string_to_byte_list(FileName, !StackInfo, FileNameBytes), Bytes = [represent_determinism(Detism)] ++ FileNameBytes ++ @@ -352,13 +352,13 @@ cons_id_to_byte_list(SymName, !StackInfo, Bytes) :- :- func cons_id_to_string(cons_id) = string. cons_id_to_string(cons(SymName, _)) = - prog_rep__sym_base_name_to_string(SymName). + prog_rep.sym_base_name_to_string(SymName). cons_id_to_string(int_const(Int)) = - string__int_to_string(Int). + string.int_to_string(Int). cons_id_to_string(float_const(Float)) = - string__float_to_string(Float). + string.float_to_string(Float). cons_id_to_string(string_const(String)) = - string__append_list(["""", String, """"]). + string.append_list(["""", String, """"]). cons_id_to_string(pred_const(_, _)) = "$pred_const". cons_id_to_string(type_ctor_info_const(_, _, _)) = "$type_ctor_info_const". @@ -390,7 +390,7 @@ conj_to_byte_list([Goal | Goals], InstMap0, Info, !StackInfo, Bytes) :- goal_to_byte_list(Goal, InstMap0, Info, !StackInfo, GoalBytes), Goal = _ - GoalInfo, goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap1), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap1), conj_to_byte_list(Goals, InstMap1, Info, !StackInfo, GoalsBytes), Bytes = GoalBytes ++ GoalsBytes. @@ -437,26 +437,26 @@ cases_to_byte_list([case(_ConsId, Goal) | Cases], InstMap0, Info, !StackInfo, stack_layout_info::in, stack_layout_info::out, list(int)::out) is det. string_to_byte_list(String, !StackInfo, Bytes) :- - stack_layout__lookup_string_in_table(String, Index, !StackInfo), + stack_layout.lookup_string_in_table(String, Index, !StackInfo), int32_to_byte_list(Index, Bytes). :- func vars_to_byte_list(prog_rep_info, list(prog_var)) = list(int). vars_to_byte_list(Info, Vars) = length_to_byte_list(Vars) ++ - list__condense(list__map(var_to_byte_list(Info), Vars)). + list.condense(list.map(var_to_byte_list(Info), Vars)). :- func maybe_vars_to_byte_list(prog_rep_info, list(maybe(prog_var))) = list(int). maybe_vars_to_byte_list(Info, Vars) = length_to_byte_list(Vars) ++ - list__condense(list__map(maybe_var_to_byte_list(Info), Vars)). + list.condense(list.map(maybe_var_to_byte_list(Info), Vars)). :- func var_to_byte_list(prog_rep_info, prog_var) = list(int). var_to_byte_list(Info, Var) = Bytes :- - map__lookup(Info ^ var_num_map, Var, VarNum - _), + map.lookup(Info ^ var_num_map, Var, VarNum - _), ( Info ^ var_num_rep = byte, Bytes = [VarNum] @@ -481,7 +481,7 @@ maybe_var_to_byte_list(Info, MaybeVar) = Bytes :- :- func length_to_byte_list(list(T)) = list(int). length_to_byte_list(List) = Bytes :- - short_to_byte_list(list__length(List), Bytes). + short_to_byte_list(list.length(List), Bytes). :- func lineno_to_byte_list(int) = list(int). diff --git a/compiler/prog_type.m b/compiler/prog_type.m index 3c13e1512..bdd5f9311 100644 --- a/compiler/prog_type.m +++ b/compiler/prog_type.m @@ -684,7 +684,7 @@ strip_builtin_qualifiers_from_type(kinded(Type0, Kind), kinded(Type, Kind)) :- strip_builtin_qualifiers_from_type(Type0, Type). strip_builtin_qualifiers_from_type_list(Types0, Types) :- - list__map(strip_builtin_qualifiers_from_type, Types0, Types). + list.map(strip_builtin_qualifiers_from_type, Types0, Types). %-----------------------------------------------------------------------------% @@ -764,15 +764,15 @@ is_introduced_type_info_type_category(type_cat_user_ctor) = no. put_typeinfo_vars_first(VarsList, VarTypes) = TypeInfoVarsList ++ NonTypeInfoVarsList :- - list__filter((pred(Var::in) is semidet :- - Type = map__lookup(VarTypes, Var), + list.filter((pred(Var::in) is semidet :- + Type = map.lookup(VarTypes, Var), is_introduced_type_info_type(Type)), VarsList, TypeInfoVarsList, NonTypeInfoVarsList). remove_new_prefix(unqualified(Name0), unqualified(Name)) :- - string__append("new ", Name, Name0). + string.append("new ", Name, Name0). remove_new_prefix(qualified(Module, Name0), qualified(Module, Name)) :- - string__append("new ", Name, Name0). + string.append("new ", Name, Name0). %-----------------------------------------------------------------------------% @@ -825,7 +825,7 @@ io_state_type = defined(Name, [], star) :- % use of integers/floats/strings as type names should % be rejected by the parser in prog_io.m, not in module_qual.m. -make_type_ctor(term__atom(Name), Arity, unqualified(Name) - Arity). +make_type_ctor(term.atom(Name), Arity, unqualified(Name) - Arity). %-----------------------------------------------------------------------------% @@ -862,12 +862,12 @@ qualify_cons_id(Type, Args, ConsId0, ConsId, InstConsId) :- -> ConsId = ConsId0, InstConsId = cell_inst_cons_id(type_info_cell(CellCtor), - list__length(Args)) + list.length(Args)) ; ConsId0 = typeclass_info_cell_constructor -> ConsId = typeclass_info_cell_constructor, - InstConsId = cell_inst_cons_id(typeclass_info_cell, list__length(Args)) + InstConsId = cell_inst_cons_id(typeclass_info_cell, list.length(Args)) ; ConsId = ConsId0, InstConsId = ConsId @@ -932,8 +932,8 @@ type_with_constructors_should_be_no_tag(Globals, TypeCtor, ReserveTagPragma, MaybeArgName), ( ReserveTagPragma = no, - globals__lookup_bool_option(Globals, reserve_tag, no), - globals__lookup_bool_option(Globals, unboxed_no_tag_types, yes) + globals.lookup_bool_option(Globals, reserve_tag, no), + globals.lookup_bool_option(Globals, unboxed_no_tag_types, yes) ; % Dummy types always need to be treated as no-tag types as the % low-level C back end just passes around rubbish for them. When e.g. @@ -1238,8 +1238,8 @@ type_list_subsumes(TypesA, TypesB, TypeSubst) :- % TypesA subsumes TypesB iff TypesA can be unified with TypesB % without binding any of the type variables in TypesB. % - prog_type__vars_list(TypesB, TypesBVars), - map__init(TypeSubst0), + prog_type.vars_list(TypesB, TypesBVars), + map.init(TypeSubst0), type_unify_list(TypesA, TypesB, TypesBVars, TypeSubst0, TypeSubst). type_list_subsumes_det(TypesA, TypesB, TypeSubst) :- @@ -1282,7 +1282,7 @@ arg_type_list_subsumes(TVarSet, ActualArgTypes, CalleeTVarSet, PredKindMap, ParentExistQVars = [_ | _], apply_rec_subst_to_tvar_list(ParentKindMap, ParentToActualSubst, ParentExistQVars, ActualExistQTypes), - all [T] (list__member(T, ActualExistQTypes) => T = variable(_, _)) + all [T] (list.member(T, ActualExistQTypes) => T = variable(_, _)) % It might make sense to also check that the type substitution % did not bind any existentially typed variables to universally @@ -1294,7 +1294,7 @@ arg_type_list_subsumes(TVarSet, ActualArgTypes, CalleeTVarSet, PredKindMap, apply_partial_map_to_list(_PartialMap, [], []). apply_partial_map_to_list(PartialMap, [X | Xs], [Y | Ys]) :- - ( map__search(PartialMap, X, Y0) -> + ( map.search(PartialMap, X, Y0) -> Y = Y0 ; Y = X diff --git a/compiler/prog_type_subst.m b/compiler/prog_type_subst.m index d4e61a805..f28128dc9 100644 --- a/compiler/prog_type_subst.m +++ b/compiler/prog_type_subst.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2005 The University of Melbourne. +% Copyright (C) 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -134,36 +134,35 @@ %-----------------------------------------------------------------------------% apply_variable_renaming_to_tvar_kind_map(Renaming, KindMap0, KindMap) :- - map__foldl(apply_variable_renaming_to_tvar_kind_map_2(Renaming), - KindMap0, map__init, KindMap). + map.foldl(apply_variable_renaming_to_tvar_kind_map_2(Renaming), + KindMap0, map.init, KindMap). :- pred apply_variable_renaming_to_tvar_kind_map_2(tvar_renaming::in, tvar::in, kind::in, tvar_kind_map::in, tvar_kind_map::out) is det. apply_variable_renaming_to_tvar_kind_map_2(Renaming, TVar0, Kind, !KindMap) :- apply_variable_renaming_to_tvar(Renaming, TVar0, TVar), - svmap__det_insert(TVar, Kind, !KindMap). + svmap.det_insert(TVar, Kind, !KindMap). %-----------------------------------------------------------------------------% apply_variable_renaming_to_tvar(Renaming, TVar0, TVar) :- - ( map__search(Renaming, TVar0, TVar1) -> + ( map.search(Renaming, TVar0, TVar1) -> TVar = TVar1 ; TVar = TVar0 ). apply_subst_to_tvar(KindMap, Subst, TVar, Type) :- - ( map__search(Subst, TVar, Type0) -> + ( map.search(Subst, TVar, Type0) -> apply_subst_to_type(Subst, Type0, Type) ; get_tvar_kind(KindMap, TVar, Kind), Type = variable(TVar, Kind) ). - apply_rec_subst_to_tvar(KindMap, Subst, TVar, Type) :- - ( map__search(Subst, TVar, Type0) -> + ( map.search(Subst, TVar, Type0) -> apply_rec_subst_to_type(Subst, Type0, Type) ; get_tvar_kind(KindMap, TVar, Kind), @@ -173,13 +172,13 @@ apply_rec_subst_to_tvar(KindMap, Subst, TVar, Type) :- %-----------------------------------------------------------------------------% apply_variable_renaming_to_tvar_list(Renaming, TVars0, TVars) :- - list__map(apply_variable_renaming_to_tvar(Renaming), TVars0, TVars). + list.map(apply_variable_renaming_to_tvar(Renaming), TVars0, TVars). apply_subst_to_tvar_list(KindMap, Subst, TVars, Types) :- - list__map(apply_subst_to_tvar(KindMap, Subst), TVars, Types). + list.map(apply_subst_to_tvar(KindMap, Subst), TVars, Types). apply_rec_subst_to_tvar_list(KindMap, Subst, TVars, Types) :- - list__map(apply_rec_subst_to_tvar(KindMap, Subst), TVars, Types). + list.map(apply_rec_subst_to_tvar(KindMap, Subst), TVars, Types). %-----------------------------------------------------------------------------% @@ -214,7 +213,7 @@ apply_variable_renaming_to_type(Renaming, kinded(Type0, Kind), apply_variable_renaming_to_type(Renaming, Type0, Type). apply_subst_to_type(Subst, Type0 @ variable(TVar, Kind), Type) :- - ( map__search(Subst, TVar, Type1) -> + ( map.search(Subst, TVar, Type1) -> ensure_type_has_kind(Kind, Type1, Type) ; Type = Type0 @@ -239,7 +238,7 @@ apply_subst_to_type(Subst, tuple(Args0, Kind), tuple(Args, Kind)) :- apply_subst_to_type_list(Subst, Args0, Args). apply_subst_to_type(Subst, apply_n(TVar, Args0, Kind), Type) :- apply_subst_to_type_list(Subst, Args0, Args), - ( map__search(Subst, TVar, AppliedType) -> + ( map.search(Subst, TVar, AppliedType) -> apply_type_args(AppliedType, Args, Type) ; Type = apply_n(TVar, Args, Kind) @@ -248,7 +247,7 @@ apply_subst_to_type(Subst, kinded(Type0, Kind), kinded(Type, Kind)) :- apply_subst_to_type(Subst, Type0, Type). apply_rec_subst_to_type(Subst, Type0 @ variable(TVar, Kind), Type) :- - ( map__search(Subst, TVar, Type1) -> + ( map.search(Subst, TVar, Type1) -> ensure_type_has_kind(Kind, Type1, Type2), apply_rec_subst_to_type(Subst, Type2, Type) ; @@ -274,7 +273,7 @@ apply_rec_subst_to_type(Subst, tuple(Args0, Kind), tuple(Args, Kind)) :- apply_rec_subst_to_type_list(Subst, Args0, Args). apply_rec_subst_to_type(Subst, apply_n(TVar, Args0, Kind), Type) :- apply_rec_subst_to_type_list(Subst, Args0, Args), - ( map__search(Subst, TVar, AppliedType0) -> + ( map.search(Subst, TVar, AppliedType0) -> apply_rec_subst_to_type(Subst, AppliedType0, AppliedType), apply_type_args(AppliedType, Args, Type) ; @@ -286,18 +285,18 @@ apply_rec_subst_to_type(Subst, kinded(Type0, Kind), kinded(Type, Kind)) :- %-----------------------------------------------------------------------------% apply_variable_renaming_to_type_list(Renaming, Types0, Types) :- - list__map(apply_variable_renaming_to_type(Renaming), Types0, Types). + list.map(apply_variable_renaming_to_type(Renaming), Types0, Types). apply_subst_to_type_list(Subst, Types0, Types) :- - list__map(apply_subst_to_type(Subst), Types0, Types). + list.map(apply_subst_to_type(Subst), Types0, Types). apply_rec_subst_to_type_list(Subst, Types0, Types) :- - list__map(apply_rec_subst_to_type(Subst), Types0, Types). + list.map(apply_rec_subst_to_type(Subst), Types0, Types). %-----------------------------------------------------------------------------% apply_variable_renaming_to_vartypes(Renaming, !Map) :- - map__map_values(apply_variable_renaming_to_vartypes_2(Renaming), !Map). + map.map_values(apply_variable_renaming_to_vartypes_2(Renaming), !Map). :- pred apply_variable_renaming_to_vartypes_2(tvar_renaming::in, prog_var::in, mer_type::in, mer_type::out) is det. @@ -306,7 +305,7 @@ apply_variable_renaming_to_vartypes_2(Renaming, _, !Type) :- apply_variable_renaming_to_type(Renaming, !Type). apply_subst_to_vartypes(Subst, !VarTypes) :- - map__map_values(apply_subst_to_vartypes_2(Subst), !VarTypes). + map.map_values(apply_subst_to_vartypes_2(Subst), !VarTypes). :- pred apply_subst_to_vartypes_2(tsubst::in, prog_var::in, mer_type::in, mer_type::out) is det. @@ -315,7 +314,7 @@ apply_subst_to_vartypes_2(Subst, _, !Type) :- apply_subst_to_type(Subst, !Type). apply_rec_subst_to_vartypes(Subst, !VarTypes) :- - map__map_values(apply_rec_subst_to_vartypes_2(Subst), !VarTypes). + map.map_values(apply_rec_subst_to_vartypes_2(Subst), !VarTypes). :- pred apply_rec_subst_to_vartypes_2(tsubst::in, prog_var::in, mer_type::in, mer_type::out) is det. @@ -399,10 +398,10 @@ apply_variable_renaming_to_prog_constraint_list(Renaming, !Constraints) :- !Constraints). apply_subst_to_prog_constraint_list(Subst, !Constraints) :- - list__map(apply_subst_to_prog_constraint(Subst), !Constraints). + list.map(apply_subst_to_prog_constraint(Subst), !Constraints). apply_rec_subst_to_prog_constraint_list(Subst, !Constraints) :- - list__map(apply_rec_subst_to_prog_constraint(Subst), !Constraints). + list.map(apply_rec_subst_to_prog_constraint(Subst), !Constraints). %-----------------------------------------------------------------------------% diff --git a/compiler/prog_util.m b/compiler/prog_util.m index 831bb43be..c5c836334 100644 --- a/compiler/prog_util.m +++ b/compiler/prog_util.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2001, 2003-2005 The University of Melbourne. +% Copyright (C) 1994-2001, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module parse_tree__prog_util. +:- module parse_tree.prog_util. :- interface. :- import_module mdbcomp.prim_data. @@ -146,9 +146,9 @@ %-----------------------------------------------------------------------------% % A pred declaration may contains just types, as in - % :- pred list__append(list(T), list(T), list(T)). + % :- pred list.append(list(T), list(T), list(T)). % or it may contain both types and modes, as in - % :- pred list__append(list(T)::in, list(T)::in, list(T)::output). + % :- pred list.append(list(T)::in, list(T)::in, list(T)::output). % % This predicate takes the argument list of a pred declaration, splits it % into two separate lists for the types and (if present) the modes. @@ -165,7 +165,7 @@ % Perform a substitution on a goal. % -:- pred prog_util__rename_in_goal(prog_var::in, prog_var::in, +:- pred rename_in_goal(prog_var::in, prog_var::in, goal::in, goal::out) is det. %-----------------------------------------------------------------------------% @@ -240,7 +240,7 @@ % Parse a term of the form `Head :- Body', treating a term not in that form % as `Head :- true'. % -:- pred parse_rule_term(term__context::in, term(T)::in, term(T)::out, +:- pred parse_rule_term(term.context::in, term(T)::in, term(T)::out, term(T)::out) is det. %-----------------------------------------------------------------------------% @@ -297,14 +297,14 @@ sym_name_get_module_name(qualified(ModuleName, _PredName), _, ModuleName). construct_qualified_term(qualified(Module, Name), Args, Context, Term) :- construct_qualified_term(Module, [], Context, ModuleTerm), - UnqualifiedTerm = term__functor(term__atom(Name), Args, Context), - Term = term__functor(term__atom("."), + UnqualifiedTerm = term.functor(term.atom(Name), Args, Context), + Term = term.functor(term.atom("."), [ModuleTerm, UnqualifiedTerm], Context). construct_qualified_term(unqualified(Name), Args, Context, Term) :- - Term = term__functor(term__atom(Name), Args, Context). + Term = term.functor(term.atom(Name), Args, Context). construct_qualified_term(SymName, Args, Term) :- - term__context_init(Context), + term.context_init(Context), construct_qualified_term(SymName, Args, Context, Term). outermost_qualifier(unqualified(Name)) = Name. @@ -350,99 +350,99 @@ split_type_and_mode(type_and_mode(T,M), T, yes(M)). %-----------------------------------------------------------------------------% -prog_util__rename_in_goal(OldVar, NewVar, Goal0 - Context, Goal - Context) :- - prog_util__rename_in_goal_expr(OldVar, NewVar, Goal0, Goal). +rename_in_goal(OldVar, NewVar, Goal0 - Context, Goal - Context) :- + rename_in_goal_expr(OldVar, NewVar, Goal0, Goal). -:- pred prog_util__rename_in_goal_expr(prog_var::in, prog_var::in, +:- pred rename_in_goal_expr(prog_var::in, prog_var::in, goal_expr::in, goal_expr::out) is det. -prog_util__rename_in_goal_expr(OldVar, NewVar, (GoalA0, GoalB0), +rename_in_goal_expr(OldVar, NewVar, (GoalA0, GoalB0), (GoalA, GoalB)) :- - prog_util__rename_in_goal(OldVar, NewVar, GoalA0, GoalA), - prog_util__rename_in_goal(OldVar, NewVar, GoalB0, GoalB). -prog_util__rename_in_goal_expr(OldVar, NewVar, (GoalA0 & GoalB0), + rename_in_goal(OldVar, NewVar, GoalA0, GoalA), + rename_in_goal(OldVar, NewVar, GoalB0, GoalB). +rename_in_goal_expr(OldVar, NewVar, (GoalA0 & GoalB0), (GoalA & GoalB)) :- - prog_util__rename_in_goal(OldVar, NewVar, GoalA0, GoalA), - prog_util__rename_in_goal(OldVar, NewVar, GoalB0, GoalB). -prog_util__rename_in_goal_expr(_OldVar, _NewVar, true, true). -prog_util__rename_in_goal_expr(OldVar, NewVar, (GoalA0; GoalB0), + rename_in_goal(OldVar, NewVar, GoalA0, GoalA), + rename_in_goal(OldVar, NewVar, GoalB0, GoalB). +rename_in_goal_expr(_OldVar, _NewVar, true, true). +rename_in_goal_expr(OldVar, NewVar, (GoalA0; GoalB0), (GoalA; GoalB)) :- - prog_util__rename_in_goal(OldVar, NewVar, GoalA0, GoalA), - prog_util__rename_in_goal(OldVar, NewVar, GoalB0, GoalB). -prog_util__rename_in_goal_expr(_Var, _NewVar, fail, fail). -prog_util__rename_in_goal_expr(OldVar, NewVar, not(Goal0), not(Goal)) :- - prog_util__rename_in_goal(OldVar, NewVar, Goal0, Goal). -prog_util__rename_in_goal_expr(OldVar, NewVar, some(Vars0, Goal0), + rename_in_goal(OldVar, NewVar, GoalA0, GoalA), + rename_in_goal(OldVar, NewVar, GoalB0, GoalB). +rename_in_goal_expr(_Var, _NewVar, fail, fail). +rename_in_goal_expr(OldVar, NewVar, not(Goal0), not(Goal)) :- + rename_in_goal(OldVar, NewVar, Goal0, Goal). +rename_in_goal_expr(OldVar, NewVar, some(Vars0, Goal0), some(Vars, Goal)) :- - prog_util__rename_in_vars(OldVar, NewVar, Vars0, Vars), - prog_util__rename_in_goal(OldVar, NewVar, Goal0, Goal). -prog_util__rename_in_goal_expr(OldVar, NewVar, some_state_vars(Vars0, Goal0), + rename_in_vars(OldVar, NewVar, Vars0, Vars), + rename_in_goal(OldVar, NewVar, Goal0, Goal). +rename_in_goal_expr(OldVar, NewVar, some_state_vars(Vars0, Goal0), some_state_vars(Vars, Goal)) :- - prog_util__rename_in_vars(OldVar, NewVar, Vars0, Vars), - prog_util__rename_in_goal(OldVar, NewVar, Goal0, Goal). -prog_util__rename_in_goal_expr(OldVar, NewVar, all(Vars0, Goal0), + rename_in_vars(OldVar, NewVar, Vars0, Vars), + rename_in_goal(OldVar, NewVar, Goal0, Goal). +rename_in_goal_expr(OldVar, NewVar, all(Vars0, Goal0), all(Vars, Goal)) :- - prog_util__rename_in_vars(OldVar, NewVar, Vars0, Vars), - prog_util__rename_in_goal(OldVar, NewVar, Goal0, Goal). -prog_util__rename_in_goal_expr(OldVar, NewVar, all_state_vars(Vars0, Goal0), + rename_in_vars(OldVar, NewVar, Vars0, Vars), + rename_in_goal(OldVar, NewVar, Goal0, Goal). +rename_in_goal_expr(OldVar, NewVar, all_state_vars(Vars0, Goal0), all_state_vars(Vars, Goal)) :- - prog_util__rename_in_vars(OldVar, NewVar, Vars0, Vars), - prog_util__rename_in_goal(OldVar, NewVar, Goal0, Goal). -prog_util__rename_in_goal_expr(OldVar, NewVar, + rename_in_vars(OldVar, NewVar, Vars0, Vars), + rename_in_goal(OldVar, NewVar, Goal0, Goal). +rename_in_goal_expr(OldVar, NewVar, promise_purity(Implicit, Purity, Goal0), promise_purity(Implicit, Purity, Goal)) :- - prog_util__rename_in_goal(OldVar, NewVar, Goal0, Goal). -prog_util__rename_in_goal_expr(OldVar, NewVar, + rename_in_goal(OldVar, NewVar, Goal0, Goal). +rename_in_goal_expr(OldVar, NewVar, promise_equivalent_solutions(Vars0, DotSVars0, ColonSVars0, Goal0), promise_equivalent_solutions(Vars, DotSVars, ColonSVars, Goal)) :- - prog_util__rename_in_vars(OldVar, NewVar, Vars0, Vars), - prog_util__rename_in_vars(OldVar, NewVar, DotSVars0, DotSVars), - prog_util__rename_in_vars(OldVar, NewVar, ColonSVars0, ColonSVars), - prog_util__rename_in_goal(OldVar, NewVar, Goal0, Goal). -prog_util__rename_in_goal_expr(OldVar, NewVar, implies(GoalA0, GoalB0), + rename_in_vars(OldVar, NewVar, Vars0, Vars), + rename_in_vars(OldVar, NewVar, DotSVars0, DotSVars), + rename_in_vars(OldVar, NewVar, ColonSVars0, ColonSVars), + rename_in_goal(OldVar, NewVar, Goal0, Goal). +rename_in_goal_expr(OldVar, NewVar, implies(GoalA0, GoalB0), implies(GoalA, GoalB)) :- - prog_util__rename_in_goal(OldVar, NewVar, GoalA0, GoalA), - prog_util__rename_in_goal(OldVar, NewVar, GoalB0, GoalB). -prog_util__rename_in_goal_expr(OldVar, NewVar, equivalent(GoalA0, GoalB0), + rename_in_goal(OldVar, NewVar, GoalA0, GoalA), + rename_in_goal(OldVar, NewVar, GoalB0, GoalB). +rename_in_goal_expr(OldVar, NewVar, equivalent(GoalA0, GoalB0), equivalent(GoalA, GoalB)) :- - prog_util__rename_in_goal(OldVar, NewVar, GoalA0, GoalA), - prog_util__rename_in_goal(OldVar, NewVar, GoalB0, GoalB). -prog_util__rename_in_goal_expr(OldVar, NewVar, + rename_in_goal(OldVar, NewVar, GoalA0, GoalA), + rename_in_goal(OldVar, NewVar, GoalB0, GoalB). +rename_in_goal_expr(OldVar, NewVar, if_then(Vars0, StateVars0, Cond0, Then0), if_then(Vars, StateVars, Cond, Then)) :- - prog_util__rename_in_vars(OldVar, NewVar, Vars0, Vars), - prog_util__rename_in_vars(OldVar, NewVar, StateVars0, StateVars), - prog_util__rename_in_goal(OldVar, NewVar, Cond0, Cond), - prog_util__rename_in_goal(OldVar, NewVar, Then0, Then). -prog_util__rename_in_goal_expr(OldVar, NewVar, + rename_in_vars(OldVar, NewVar, Vars0, Vars), + rename_in_vars(OldVar, NewVar, StateVars0, StateVars), + rename_in_goal(OldVar, NewVar, Cond0, Cond), + rename_in_goal(OldVar, NewVar, Then0, Then). +rename_in_goal_expr(OldVar, NewVar, if_then_else(Vars0, StateVars0, Cond0, Then0, Else0), if_then_else(Vars, StateVars, Cond, Then, Else)) :- - prog_util__rename_in_vars(OldVar, NewVar, Vars0, Vars), - prog_util__rename_in_vars(OldVar, NewVar, StateVars0, StateVars), - prog_util__rename_in_goal(OldVar, NewVar, Cond0, Cond), - prog_util__rename_in_goal(OldVar, NewVar, Then0, Then), - prog_util__rename_in_goal(OldVar, NewVar, Else0, Else). -prog_util__rename_in_goal_expr(OldVar, NewVar, call(SymName, Terms0, Purity), + rename_in_vars(OldVar, NewVar, Vars0, Vars), + rename_in_vars(OldVar, NewVar, StateVars0, StateVars), + rename_in_goal(OldVar, NewVar, Cond0, Cond), + rename_in_goal(OldVar, NewVar, Then0, Then), + rename_in_goal(OldVar, NewVar, Else0, Else). +rename_in_goal_expr(OldVar, NewVar, call(SymName, Terms0, Purity), call(SymName, Terms, Purity)) :- - term__substitute_list(Terms0, OldVar, term__variable(NewVar), Terms). -prog_util__rename_in_goal_expr(OldVar, NewVar, unify(TermA0, TermB0, Purity), + term.substitute_list(Terms0, OldVar, term.variable(NewVar), Terms). +rename_in_goal_expr(OldVar, NewVar, unify(TermA0, TermB0, Purity), unify(TermA, TermB, Purity)) :- - term__substitute(TermA0, OldVar, term__variable(NewVar), TermA), - term__substitute(TermB0, OldVar, term__variable(NewVar), TermB). + term.substitute(TermA0, OldVar, term.variable(NewVar), TermA), + term.substitute(TermB0, OldVar, term.variable(NewVar), TermB). -:- pred prog_util__rename_in_vars(prog_var::in, prog_var::in, +:- pred rename_in_vars(prog_var::in, prog_var::in, list(prog_var)::in, list(prog_var)::out) is det. -prog_util__rename_in_vars(_, _, [], []). -prog_util__rename_in_vars(OldVar, NewVar, [Var0 | Vars0], [Var | Vars]) :- +rename_in_vars(_, _, [], []). +rename_in_vars(OldVar, NewVar, [Var0 | Vars0], [Var | Vars]) :- ( Var0 = OldVar -> Var = NewVar ; Var = Var0 ), - prog_util__rename_in_vars(OldVar, NewVar, Vars0, Vars). + rename_in_vars(OldVar, NewVar, Vars0, Vars). %-----------------------------------------------------------------------------% @@ -460,21 +460,21 @@ match_sym_name(unqualified(Name), qualified(_, Name)). remove_sym_name_prefix(qualified(Module, Name0), Prefix, qualified(Module, Name)) :- - string__append(Prefix, Name, Name0). + string.append(Prefix, Name, Name0). remove_sym_name_prefix(unqualified(Name0), Prefix, unqualified(Name)) :- - string__append(Prefix, Name, Name0). + string.append(Prefix, Name, Name0). remove_sym_name_suffix(qualified(Module, Name0), Suffix, qualified(Module, Name)) :- - string__remove_suffix(Name0, Suffix, Name). + string.remove_suffix(Name0, Suffix, Name). remove_sym_name_suffix(unqualified(Name0), Suffix, unqualified(Name)) :- - string__remove_suffix(Name0, Suffix, Name). + string.remove_suffix(Name0, Suffix, Name). add_sym_name_suffix(qualified(Module, Name0), Suffix, qualified(Module, Name)) :- - string__append(Name0, Suffix, Name). + string.append(Name0, Suffix, Name). add_sym_name_suffix(unqualified(Name0), Suffix, unqualified(Name)) :- - string__append(Name0, Suffix, Name). + string.append(Name0, Suffix, Name). transform_sym_base_name(TransformFunc, qualified(Module, Name0)) = qualified(Module, TransformFunc(Name0)). @@ -505,14 +505,14 @@ make_pred_name(ModuleName, Prefix, MaybePredOrFunc, PredName, ), ( NewPredId = counter(Line, Counter), - string__format("%d__%d", [i(Line), i(Counter)], PredIdStr) + string.format("%d__%d", [i(Line), i(Counter)], PredIdStr) ; NewPredId = type_subst(VarSet, TypeSubst), SubstToString = (pred(SubstElem::in, SubstStr::out) is det :- SubstElem = Var - Type, - varset__lookup_name(VarSet, Var, VarName), + varset.lookup_name(VarSet, Var, VarName), TypeString = mercury_type_to_string(VarSet, no, Type), - string__append_list([VarName, " = ", TypeString], SubstStr) + string.append_list([VarName, " = ", TypeString], SubstStr) ), list_to_string(SubstToString, TypeSubst, PredIdStr) ; @@ -520,7 +520,7 @@ make_pred_name(ModuleName, Prefix, MaybePredOrFunc, PredName, list_to_string(int_to_string, Args, PredIdStr) ), - string__format("%s__%s__%s__%s", + string.format("%s__%s__%s__%s", [s(Prefix), s(PFS), s(PredName), s(PredIdStr)], Name), SymName = qualified(ModuleName, Name). @@ -529,7 +529,7 @@ make_pred_name(ModuleName, Prefix, MaybePredOrFunc, PredName, list_to_string(Pred, List, String) :- list_to_string_2(Pred, List, Strings, ["]"]), - string__append_list(["[" | Strings], String). + string.append_list(["[" | Strings], String). :- pred list_to_string_2(pred(T, string)::in(pred(in, out) is det), list(T)::in, list(string)::out, list(string)::in) is det. @@ -548,14 +548,14 @@ list_to_string_2(Pred, [T | Ts]) --> %-----------------------------------------------------------------------------% cons_id_and_args_to_term(int_const(Int), [], Term) :- - term__context_init(Context), - Term = term__functor(term__integer(Int), [], Context). + term.context_init(Context), + Term = term.functor(term.integer(Int), [], Context). cons_id_and_args_to_term(float_const(Float), [], Term) :- - term__context_init(Context), - Term = term__functor(term__float(Float), [], Context). + term.context_init(Context), + Term = term.functor(term.float(Float), [], Context). cons_id_and_args_to_term(string_const(String), [], Term) :- - term__context_init(Context), - Term = term__functor(term__string(String), [], Context). + term.context_init(Context), + Term = term.functor(term.string(String), [], Context). cons_id_and_args_to_term(cons(SymName, _Arity), Args, Term) :- construct_qualified_term(SymName, Args, Term). @@ -599,10 +599,10 @@ cons_id_maybe_arity(tabling_pointer_const(_)) = no. cons_id_maybe_arity(deep_profiling_proc_layout(_)) = no. cons_id_maybe_arity(table_io_decl(_)) = no. -make_functor_cons_id(term__atom(Name), Arity) = cons(unqualified(Name), Arity). -make_functor_cons_id(term__integer(Int), _) = int_const(Int). -make_functor_cons_id(term__string(String), _) = string_const(String). -make_functor_cons_id(term__float(Float), _) = float_const(Float). +make_functor_cons_id(term.atom(Name), Arity) = cons(unqualified(Name), Arity). +make_functor_cons_id(term.integer(Int), _) = int_const(Int). +make_functor_cons_id(term.string(String), _) = string_const(String). +make_functor_cons_id(term.float(Float), _) = float_const(Float). make_cons_id(SymName0, Args, TypeCtor) = cons(SymName, Arity) :- % Use the module qualifier on the SymName, if there is one, @@ -622,10 +622,10 @@ make_cons_id(SymName0, Args, TypeCtor) = cons(SymName, Arity) :- SymName = qualified(TypeModule, ConsName) ) ), - list__length(Args, Arity). + list.length(Args, Arity). make_cons_id_from_qualified_sym_name(SymName, Args) = cons(SymName, Arity) :- - list__length(Args, Arity). + list.length(Args, Arity). %-----------------------------------------------------------------------------% @@ -640,18 +640,18 @@ make_n_fresh_vars_2(BaseName, N, Max, Vars, !VarSet) :- Vars = [] ; N1 = N + 1, - varset__new_var(!.VarSet, Var, !:VarSet), - string__int_to_string(N1, Num), - string__append(BaseName, Num, VarName), - varset__name_var(!.VarSet, Var, VarName, !:VarSet), + varset.new_var(!.VarSet, Var, !:VarSet), + string.int_to_string(N1, Num), + string.append(BaseName, Num, VarName), + varset.name_var(!.VarSet, Var, VarName, !:VarSet), Vars = [Var | Vars1], make_n_fresh_vars_2(BaseName, N1, Max, Vars1, !VarSet) ). pred_args_to_func_args(PredArgs, FuncArgs, FuncReturn) :- - list__length(PredArgs, NumPredArgs), + list.length(PredArgs, NumPredArgs), NumFuncArgs = NumPredArgs - 1, - ( list__split_list(NumFuncArgs, PredArgs, FuncArgs0, [FuncReturn0]) -> + ( list.split_list(NumFuncArgs, PredArgs, FuncArgs0, [FuncReturn0]) -> FuncArgs = FuncArgs0, FuncReturn = FuncReturn0 ; @@ -660,9 +660,9 @@ pred_args_to_func_args(PredArgs, FuncArgs, FuncReturn) :- ). get_state_args(Args0, Args, State0, State) :- - list__reverse(Args0, RevArgs0), + list.reverse(Args0, RevArgs0), RevArgs0 = [State, State0 | RevArgs], - list__reverse(RevArgs, Args). + list.reverse(RevArgs, Args). get_state_args_det(Args0, Args, State0, State) :- ( get_state_args(Args0, Args1, State0A, StateA) -> @@ -676,31 +676,31 @@ get_state_args_det(Args0, Args, State0, State) :- %-----------------------------------------------------------------------------% parse_rule_term(Context, RuleTerm, HeadTerm, GoalTerm) :- - ( RuleTerm = term__functor(term__atom(":-"), [HeadTerm0, GoalTerm0], _) -> + ( RuleTerm = term.functor(term.atom(":-"), [HeadTerm0, GoalTerm0], _) -> HeadTerm = HeadTerm0, GoalTerm = GoalTerm0 ; HeadTerm = RuleTerm, - GoalTerm = term__functor(term__atom("true"), [], Context) + GoalTerm = term.functor(term.atom("true"), [], Context) ). get_new_tvars([], _, !TVarSet, !TVarNameMap, !TVarRenaming). get_new_tvars([TVar | TVars], VarSet, !TVarSet, !TVarNameMap, !TVarRenaming) :- - ( map__contains(!.TVarRenaming, TVar) -> + ( map.contains(!.TVarRenaming, TVar) -> true ; - ( varset__search_name(VarSet, TVar, TVarName) -> - ( map__search(!.TVarNameMap, TVarName, TVarSetVar) -> - svmap__det_insert(TVar, TVarSetVar, !TVarRenaming) + ( varset.search_name(VarSet, TVar, TVarName) -> + ( map.search(!.TVarNameMap, TVarName, TVarSetVar) -> + svmap.det_insert(TVar, TVarSetVar, !TVarRenaming) ; - varset__new_var(!.TVarSet, NewTVar, !:TVarSet), - varset__name_var(!.TVarSet, NewTVar, TVarName, !:TVarSet), - svmap__det_insert(TVarName, NewTVar, !TVarNameMap), - svmap__det_insert(TVar, NewTVar, !TVarRenaming) + varset.new_var(!.TVarSet, NewTVar, !:TVarSet), + varset.name_var(!.TVarSet, NewTVar, TVarName, !:TVarSet), + svmap.det_insert(TVarName, NewTVar, !TVarNameMap), + svmap.det_insert(TVar, NewTVar, !TVarRenaming) ) ; - varset__new_var(!.TVarSet, NewTVar, !:TVarSet), - svmap__det_insert(TVar, NewTVar, !TVarRenaming) + varset.new_var(!.TVarSet, NewTVar, !:TVarSet), + svmap.det_insert(TVar, NewTVar, !TVarRenaming) ) ), get_new_tvars(TVars, VarSet, !TVarSet, !TVarNameMap, !TVarRenaming). @@ -708,13 +708,13 @@ get_new_tvars([TVar | TVars], VarSet, !TVarSet, !TVarNameMap, !TVarRenaming) :- %-----------------------------------------------------------------------------% substitute_vars(Vars0, Subst, Vars) :- - Vars = list__map(substitute_var(Subst), Vars0). + Vars = list.map(substitute_var(Subst), Vars0). :- func substitute_var(substitution(T), var(T)) = var(T). substitute_var(Subst, Var0) = Var :- - term__apply_substitution(term__variable(Var0), Subst, Term), - ( Term = term__variable(Var1) -> + term.apply_substitution(term.variable(Var0), Subst, Term), + ( Term = term.variable(Var1) -> Var = Var1 ; unexpected(this_file, "substitute_var: invalid substitution") @@ -723,27 +723,27 @@ substitute_var(Subst, Var0) = Var :- %-----------------------------------------------------------------------------% sym_name_and_args_to_term(unqualified(Name), Xs, Context) = - term__functor(term__atom(Name), Xs, Context). + term.functor(term.atom(Name), Xs, Context). sym_name_and_args_to_term(qualified(ModuleNames, Name), Xs, Context) = sym_name_and_term_to_term(ModuleNames, - term__functor(term__atom(Name), Xs, Context), Context). + term.functor(term.atom(Name), Xs, Context), Context). :- func sym_name_and_term_to_term(module_specifier, term(T), prog_context) = term(T). sym_name_and_term_to_term(unqualified(ModuleName), Term, Context) = - term__functor( - term__atom("."), - [term__functor(term__atom(ModuleName), [], Context), Term], + term.functor( + term.atom("."), + [term.functor(term.atom(ModuleName), [], Context), Term], Context ). sym_name_and_term_to_term(qualified(ModuleNames, ModuleName), Term, Context) = - term__functor( - term__atom("."), + term.functor( + term.atom("."), [sym_name_and_term_to_term( ModuleNames, - term__functor(term__atom(ModuleName), [], Context), + term.functor(term.atom(ModuleName), [], Context), Context), Term], Context diff --git a/compiler/prop_mode_constraints.m b/compiler/prop_mode_constraints.m index 21381c4d7..bef832133 100644 --- a/compiler/prop_mode_constraints.m +++ b/compiler/prop_mode_constraints.m @@ -155,7 +155,7 @@ process_pred(PredId, !ModuleInfo, !VarInfo, !Constraints) :- is det. process_pred(ModuleInfo, PredId, !PredInfo, !VarInfo, !Constraints) :- - goal_path.fill_slots_in_clauses(ModuleInfo, GoalPathOptimisation, + fill_goal_path_slots_in_clauses(ModuleInfo, GoalPathOptimisation, !PredInfo), % diff --git a/compiler/pseudo_type_info.m b/compiler/pseudo_type_info.m index 5c189232c..1a29890bd 100644 --- a/compiler/pseudo_type_info.m +++ b/compiler/pseudo_type_info.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 1996-2000,2002-2003, 2005 The University of Melbourne. +% Copyright (C) 1996-2000,2002-2003, 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -17,7 +17,7 @@ %---------------------------------------------------------------------------% -:- module backend_libs__pseudo_type_info. +:- module backend_libs.pseudo_type_info. :- interface. :- import_module backend_libs.rtti. @@ -122,13 +122,13 @@ construct_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, PseudoTypeInfo) :- % this constructor (and not those of other functors in % the same type) into account. - % XXX term__var_to_int doesn't guarantee anything about the + % XXX term.var_to_int doesn't guarantee anything about the % ints returned (other than that they be distinct for % different variables), but here we are relying more, % specifically, on the integers being allocated densely % (i.e. the first N vars get integers 1 to N). - term__var_to_int(Var, VarInt0), + term.var_to_int(Var, VarInt0), ( ( VarInt0 =< NumUnivQTvars ; NumUnivQTvars < 0 @@ -138,7 +138,7 @@ construct_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, PseudoTypeInfo) :- VarInt = VarInt0 ; % This is an existentially quantified variable. - ( list__nth_member_search(ExistQTvars, Var, ExistNum0) -> + ( list.nth_member_search(ExistQTvars, Var, ExistNum0) -> VarInt = ExistNum0 + pseudo_typeinfo_exist_var_base ; unexpected(this_file, @@ -186,7 +186,7 @@ construct_type_info(Type, TypeInfo) :- is semidet. check_var_arity(VarArityId, Args, RealArity) :- - list__length(Args, NumPseudoArgs), + list.length(Args, NumPseudoArgs), ( VarArityId = func_type_info -> NumPseudoArgs = RealArity + 1 ; @@ -196,14 +196,14 @@ check_var_arity(VarArityId, Args, RealArity) :- :- pred check_arity(list(T)::in, int::in) is semidet. check_arity(Args, RealArity) :- - list__length(Args, NumPseudoArgs), + list.length(Args, NumPseudoArgs), NumPseudoArgs = RealArity. :- pred generate_pseudo_args(list(mer_type)::in, int::in, existq_tvars::in, list(rtti_maybe_pseudo_type_info)::out) is det. generate_pseudo_args(TypeArgs, NumUnivQTvars, ExistQTvars, PseudoArgs) :- - list__map(generate_pseudo_arg(NumUnivQTvars, ExistQTvars), + list.map(generate_pseudo_arg(NumUnivQTvars, ExistQTvars), TypeArgs, PseudoArgs). :- pred generate_pseudo_arg(int::in, existq_tvars::in, mer_type::in, @@ -223,7 +223,7 @@ generate_pseudo_arg(NumUnivQTvars, ExistQTvars, TypeArg, MaybePseudoArg) :- is det. generate_plain_args(TypeArgs, PseudoArgs) :- - list__map(construct_type_info, TypeArgs, PseudoArgs). + list.map(construct_type_info, TypeArgs, PseudoArgs). %---------------------------------------------------------------------------% diff --git a/compiler/purity.m b/compiler/purity.m index a4fe2f45a..10dd69d88 100644 --- a/compiler/purity.m +++ b/compiler/purity.m @@ -93,8 +93,8 @@ % functions. % % Any non-variable arguments to the function are flattened into -% unification goals (see make_hlds__unravel_unifications) which are -% placed as pure goals before the function call itself. +% unification goals (see unravel_unifications in superhomogeneous.m) +% which are placed as pure goals before the function call itself. % % Wishlist: % It would be nice to use impure functions in DCG goals as well as @@ -113,7 +113,7 @@ % %-----------------------------------------------------------------------------% -:- module check_hlds__purity. +:- module check_hlds.purity. :- interface. :- import_module hlds.hlds_module. @@ -199,8 +199,8 @@ % puritycheck(FoundTypeError, PostTypecheckError, !HLDS, !IO) :- - globals__io_lookup_bool_option(statistics, Statistics, !IO), - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(statistics, Statistics, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Purity-checking clauses...\n", !IO), check_preds_purity(FoundTypeError, PostTypecheckError, !HLDS, !IO), @@ -218,8 +218,8 @@ check_preds_purity(FoundTypeError, PostTypecheckError, !ModuleInfo, !IO) :- % Only report error messages for unbound type variables if we didn't get % any type errors already; this avoids a lot of spurious diagnostics. - ReportTypeErrors = bool__not(FoundTypeError), - post_typecheck__finish_preds(PredIds, ReportTypeErrors, NumErrors1, + ReportTypeErrors = bool.not(FoundTypeError), + post_typecheck.finish_preds(PredIds, ReportTypeErrors, NumErrors1, PostTypecheckError, !ModuleInfo, !IO), check_preds_purity_2(PredIds, !ModuleInfo, NumErrors1, NumErrors, !IO), @@ -252,7 +252,7 @@ check_preds_purity_2([PredId | PredIds], !ModuleInfo, !NumErrors, !IO) :- % Finish processing of promise declarations. pred_info_get_goal_type(PredInfo, GoalType), ( GoalType = promise(PromiseType) -> - post_typecheck__finish_promise(PromiseType, PredId, !ModuleInfo, !IO) + post_typecheck.finish_promise(PromiseType, PredId, !ModuleInfo, !IO) ; true ), @@ -297,9 +297,9 @@ puritycheck_pred(PredId, !PredInfo, ModuleInfo, NumErrors, !IO) :- VarTypes, VarSet, RevMessages, _), clauses_info_set_vartypes(VarTypes, !ClausesInfo), clauses_info_set_varset(VarSet, !ClausesInfo), - Messages = list__reverse(RevMessages), - list__foldl(report_post_typecheck_message(ModuleInfo), Messages, !IO), - NumErrors0 = list__length(list__filter((pred(error(_)::in) is semidet), + Messages = list.reverse(RevMessages), + list.foldl(report_post_typecheck_message(ModuleInfo), Messages, !IO), + NumErrors0 = list.length(list.filter((pred(error(_)::in) is semidet), Messages)), clauses_info_set_clauses(Clauses, !ClausesInfo), pred_info_set_clauses_info(!.ClausesInfo, !PredInfo) @@ -333,7 +333,7 @@ puritycheck_pred(PredId, !PredInfo, ModuleInfo, NumErrors, !IO) :- repuritycheck_proc(ModuleInfo, proc(_PredId, ProcId), !PredInfo) :- pred_info_procedures(!.PredInfo, Procs0), - map__lookup(Procs0, ProcId, ProcInfo0), + map.lookup(Procs0, ProcId, ProcInfo0), proc_info_goal(ProcInfo0, Goal0), proc_info_vartypes(ProcInfo0, VarTypes0), proc_info_varset(ProcInfo0, VarSet0), @@ -345,7 +345,7 @@ repuritycheck_proc(ModuleInfo, proc(_PredId, ProcId), !PredInfo) :- proc_info_set_goal(Goal, ProcInfo0, ProcInfo1), proc_info_set_vartypes(VarTypes, ProcInfo1, ProcInfo2), proc_info_set_varset(VarSet, ProcInfo2, ProcInfo), - map__det_update(Procs0, ProcId, ProcInfo, Procs), + map.det_update(Procs0, ProcId, ProcInfo, Procs), pred_info_set_procedures(Procs, !PredInfo), % A predicate should never become less pure after inlining, so update @@ -445,7 +445,7 @@ applies_to_all_modes(clause(ClauseProcIds, _, _, _), ProcIds) :- ; % Otherwise the clause applies to the procids in the list. % Check if this is the same as the procids for this procedure. - list__sort(ClauseProcIds, SortedIds), + list.sort(ClauseProcIds, SortedIds), SortedIds = ProcIds ). @@ -462,7 +462,7 @@ compute_expr_purity(Goal0, Goal, GoalInfo, ActualPurity, !Info) :- ModuleInfo = !.Info ^ module_info, ( RunPostTypecheck = yes, - post_typecheck__resolve_pred_overloading(Vars, PredInfo, + post_typecheck.resolve_pred_overloading(Vars, PredInfo, ModuleInfo, Name0, Name, PredId0, PredId), ( % Convert any calls to private_builtin.unsafe_type_cast @@ -534,7 +534,7 @@ compute_expr_purity(Unif0, GoalExpr, GoalInfo, ActualPurity, !Info) :- PredInfo0 = !.Info ^ pred_info, VarTypes0 = !.Info ^ vartypes, VarSet0 = !.Info ^ varset, - post_typecheck__resolve_unify_functor(Var, ConsId, Args, Mode, + post_typecheck.resolve_unify_functor(Var, ConsId, Args, Mode, Unification, UnifyContext, GoalInfo, ModuleInfo, PredInfo0, PredInfo, VarTypes0, VarTypes, VarSet0, VarSet, Goal1), @@ -636,7 +636,7 @@ check_higher_order_purity(GoalInfo, ConsId, Var, Args, ActualPurity, !Info) :- % Check that the purity of the ConsId matches the purity of the % variable's type. VarTypes = !.Info ^ vartypes, - map__lookup(VarTypes, Var, TypeOfVar), + map.lookup(VarTypes, Var, TypeOfVar), ( ConsId = cons(PName, _), type_is_higher_order(TypeOfVar, TypePurity, PredOrFunc, @@ -644,8 +644,8 @@ check_higher_order_purity(GoalInfo, ConsId, Var, Args, ActualPurity, !Info) :- -> PredInfo = !.Info ^ pred_info, pred_info_typevarset(PredInfo, TVarSet), - map__apply_to_list(Args, VarTypes, ArgTypes0), - list__append(ArgTypes0, VarArgTypes, PredArgTypes), + map.apply_to_list(Args, VarTypes, ArgTypes0), + list.append(ArgTypes0, VarArgTypes, PredArgTypes), ModuleInfo = !.Info ^ module_info, CallerPredInfo = !.Info ^ pred_info, pred_info_get_markers(CallerPredInfo, CallerMarkers), @@ -880,7 +880,7 @@ error_inconsistent_promise(ModuleInfo, PredInfo, PredId, Purity, !IO) :- Pieces1 = PredContextPieces ++ [words("warning: declared"), fixed(PurityName), words("but promised pure.")], - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, Pieces = Pieces1 ++ @@ -932,7 +932,7 @@ warn_unnecessary_promise_pure(ModuleInfo, PredInfo, PredId, PromisedPurity, unexpected(this_file, "warn_unnecessary_promise_pure: promise_impure?") ), Pieces1 = [words("warning: unnecessary `" ++ Pragma ++ "' pragma."), nl], - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, PredOrFunc = pred_info_is_pred_or_func(PredInfo), @@ -998,7 +998,7 @@ error_inferred_impure(ModuleInfo, PredInfo, PredId, Purity, !IO) :- post_typecheck_message::in, io::di, io::uo) is det. report_post_typecheck_message(ModuleInfo, error(Message), !IO) :- - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), ( Message = missing_body_impurity_error(Context, PredId), error_missing_body_impurity_decl(ModuleInfo, PredId, Context, !IO) diff --git a/compiler/qual_info.m b/compiler/qual_info.m index faf31be39..20f098369 100644 --- a/compiler/qual_info.m +++ b/compiler/qual_info.m @@ -11,7 +11,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__qual_info. +:- module hlds.make_hlds.qual_info. :- interface. :- import_module hlds.hlds_goal. @@ -140,10 +140,10 @@ init_qual_info(MQInfo0, EqvMap, QualInfo) :- mq_info_set_need_qual_flag(may_be_unqualified, MQInfo0, MQInfo), - varset__init(TVarSet), - map__init(Renaming), - map__init(Index), - map__init(VarTypes), + varset.init(TVarSet), + map.init(Renaming), + map.init(Index), + map.init(VarTypes), FoundSyntaxError = no, QualInfo = qual_info(EqvMap, TVarSet, Renaming, Index, VarTypes, MQInfo, local, FoundSyntaxError). @@ -152,7 +152,7 @@ update_qual_info(TVarNameMap, TVarSet, VarTypes, Status, !QualInfo) :- !.QualInfo = qual_info(EqvMap, _TVarSet0, _Renaming0, _TVarNameMap0, _VarTypes0, MQInfo, _Status, _FoundError), % The renaming for one clause is useless in the others. - map__init(Renaming), + map.init(Renaming), !:QualInfo = qual_info(EqvMap, TVarSet, Renaming, TVarNameMap, VarTypes, MQInfo, Status, no). @@ -194,13 +194,13 @@ process_type_qualification(Var, Type0, VarSet, Context, !ModuleInfo, Type1 = Type0, MQInfo = MQInfo0 ; - module_qual__qualify_type_qualification(Type0, Type1, + module_qual.qualify_type_qualification(Type0, Type1, Context, MQInfo0, MQInfo, !IO) ), % Find any new type variables introduced by this type, and % add them to the var-name index and the variable renaming. - prog_type__vars(Type1, TVars), + prog_type.vars(Type1, TVars), get_new_tvars(TVars, VarSet, TVarSet0, TVarSet1, TVarNameMap0, TVarNameMap, TVarRenaming0, TVarRenaming), @@ -213,7 +213,7 @@ process_type_qualification(Var, Type0, VarSet, Context, !ModuleInfo, % because at the moment no recompilation.item_id can depend on a % clause item. RecordExpanded = no, - equiv_type__replace_in_type(EqvMap, Type2, Type, _, TVarSet1, TVarSet, + equiv_type.replace_in_type(EqvMap, Type2, Type, _, TVarSet1, TVarSet, RecordExpanded, _), update_var_types(Var, Type, Context, VarTypes0, VarTypes, !IO), !:QualInfo = qual_info(EqvMap, TVarSet, TVarRenaming, @@ -232,7 +232,7 @@ update_var_types(Var, Type, Context, !VarTypes, !IO) :- words("not match prior qualification.") ], write_error_pieces(Context, 0, ErrMsg, !IO), - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ) ; svmap.det_insert(Var, Type, !VarTypes) @@ -260,7 +260,7 @@ make_atomic_unification(Var, Rhs, Context, MainContext, SubContext, Purity, record_called_pred_or_func(PredOrFunc, SymName, Arity, !QualInfo) :- Id = SymName - Arity, - apply_to_recompilation_info(recompilation__record_used_item( + apply_to_recompilation_info(recompilation.record_used_item( pred_or_func_to_item_type(PredOrFunc), Id, Id), !QualInfo). :- pred record_used_functor(cons_id::in, qual_info::in, qual_info::out) is det. @@ -280,7 +280,7 @@ construct_pred_or_func_call(PredId, PredOrFunc, SymName, Args, GoalInfo, Goal, !QualInfo) :- do_construct_pred_or_func_call(PredId, PredOrFunc, SymName, Args, GoalInfo, Goal), - list__length(Args, Arity), + list.length(Args, Arity), adjust_func_arity(PredOrFunc, OrigArity, Arity), record_called_pred_or_func(PredOrFunc, SymName, OrigArity, !QualInfo). @@ -293,7 +293,7 @@ do_construct_pred_or_func_call(PredId, PredOrFunc, SymName, Args, ; PredOrFunc = function, pred_args_to_func_args(Args, FuncArgs, RetArg), - list__length(FuncArgs, Arity), + list.length(FuncArgs, Arity), ConsId = cons(SymName, Arity), goal_info_get_context(GoalInfo, Context), create_atomic_complicated_unification(RetArg, diff --git a/compiler/quantification.m b/compiler/quantification.m index 4908436f6..7d3a5c9fe 100644 --- a/compiler/quantification.m +++ b/compiler/quantification.m @@ -30,7 +30,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__quantification. +:- module hlds.quantification. :- interface. :- import_module hlds.hlds_goal. @@ -254,7 +254,7 @@ implicitly_quantify_goal_2(RecomputeNonLocals, OutsideVars0, Warnings, get_varset(QuantInfo, !:Varset), get_vartypes(QuantInfo, !:VarTypes), get_warnings(QuantInfo, Warnings0), - list__reverse(Warnings0, Warnings). + list.reverse(Warnings0, Warnings). :- pred implicitly_quantify_goal(hlds_goal::in, hlds_goal::out, quant_info::in, quant_info::out) is det. @@ -344,7 +344,7 @@ implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :- ; warn_overlapping_scope(RenameVars, Context, !Info), rename_apart(RenameVars, RenameMap, Goal0, Goal1, !Info), - goal_util__rename_var_list(no, RenameMap, Vars0, Vars), + goal_util.rename_var_list(no, RenameMap, Vars0, Vars), ( Reason1 = exist_quant(_), % We have already handled this case. @@ -354,7 +354,7 @@ implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :- Reason = Reason1 ; Reason1 = promise_solutions(PromiseVars0, Kind), - goal_util__rename_var_list(no, RenameMap, + goal_util.rename_var_list(no, RenameMap, PromiseVars0, PromiseVars), Reason = promise_solutions(PromiseVars, Kind) ; @@ -437,8 +437,8 @@ implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :- ; warn_overlapping_scope(RenameVars, Context, !Info), rename_apart(RenameVars, RenameMap, Cond0, Cond1, !Info), - goal_util__rename_vars_in_goal(RenameMap, Then0, Then1), - goal_util__rename_var_list(no, RenameMap, Vars0, Vars) + goal_util.rename_vars_in_goal(RenameMap, Then0, Then1), + goal_util.rename_var_list(no, RenameMap, Vars0, Vars) ), insert_list(QuantVars, Vars, QuantVars1), get_nonlocals_to_recompute(!.Info, NonLocalsToRecompute), @@ -475,8 +475,8 @@ implicitly_quantify_goal_2(Expr, Expr, _, !Info) :- implicitly_quantify_goal_2(Expr, Expr, _, !Info) :- Expr = generic_call(GenericCall, CallArgVars, _, _), - goal_util__generic_call_vars(GenericCall, ArgVars0), - list__append(ArgVars0, CallArgVars, ArgVars), + goal_util.generic_call_vars(GenericCall, ArgVars0), + list.append(ArgVars0, CallArgVars, ArgVars), implicitly_quantify_atomic_goal(ArgVars, !Info). implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :- @@ -533,9 +533,9 @@ implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :- implicitly_quantify_goal_2(Expr, Expr, _, !Info) :- Expr = foreign_proc(_, _, _, Args, ExtraArgs, _), - Vars = list__map(foreign_arg_var, Args), - ExtraVars = list__map(foreign_arg_var, ExtraArgs), - list__append(Vars, ExtraVars, AllVars), + Vars = list.map(foreign_arg_var, Args), + ExtraVars = list.map(foreign_arg_var, ExtraArgs), + list.append(Vars, ExtraVars, AllVars), implicitly_quantify_atomic_goal(AllVars, !Info). implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :- @@ -690,7 +690,7 @@ implicitly_quantify_unify_rhs(_, Context, !RHS, !Unification, !Info) :- union(RenameVars0, RenameVars1, RenameVars), rename_apart(RenameVars, RenameMap, Goal0, Goal1, !Info), - goal_util__rename_var_list(no, RenameMap, LambdaVars0, LambdaVars), + goal_util.rename_var_list(no, RenameMap, LambdaVars0, LambdaVars), % Quantified variables cannot be pushed inside a lambda goal, % so we insert the quantified vars into the outside vars set, @@ -730,7 +730,7 @@ implicitly_quantify_unify_rhs(_, Context, !RHS, !Unification, !Info) :- % Goal = _ - LambdaGoalInfo, goal_info_get_nonlocals(LambdaGoalInfo, LambdaGoalNonLocals), - list__filter(contains(LambdaGoalNonLocals), + list.filter(contains(LambdaGoalNonLocals), LambdaNonLocals0, LambdaNonLocals), % @@ -755,9 +755,9 @@ implicitly_quantify_unify_rhs(_, Context, !RHS, !Unification, !Info) :- expect(unify(MaybeSize, no), this_file, "lambda term has size info") ), - map__from_corresponding_lists(Args0, ArgModes0, ArgModesMap), + map.from_corresponding_lists(Args0, ArgModes0, ArgModesMap), to_sorted_list(NonLocals, Args), - map__apply_to_list(Args, ArgModesMap, ArgModes), + map.apply_to_list(Args, ArgModesMap, ArgModes), !:Unification = construct(ConstructVar, ConsId, Args, ArgModes, HowToConstruct, Uniq, SubInfo) ; @@ -956,7 +956,7 @@ goal_vars_2(NonLocalsToRecompute, unify(LHS, RHS, _, Unification, _), unify_rhs_vars(NonLocalsToRecompute, RHS, MaybeSetArgs, !Set, !LambdaSet). goal_vars_2(_, generic_call(GenericCall, ArgVars1, _, _), !Set, !LambdaSet) :- - goal_util__generic_call_vars(GenericCall, ArgVars0), + goal_util.generic_call_vars(GenericCall, ArgVars0), insert_list(!.Set, ArgVars0, !:Set), insert_list(!.Set, ArgVars1, !:Set). @@ -1022,9 +1022,9 @@ goal_vars_2(NonLocalsToRecompute, if_then_else(Vars, Cond, Then, Else), union(!.LambdaSet, ElseLambdaSet, !:LambdaSet). goal_vars_2(_, foreign_proc(_, _, _, Args, ExtraArgs, _), !Set, !LambdaSet) :- - Vars = list__map(foreign_arg_var, Args), - ExtraVars = list__map(foreign_arg_var, ExtraArgs), - list__append(Vars, ExtraVars, AllVars), + Vars = list.map(foreign_arg_var, Args), + ExtraVars = list.map(foreign_arg_var, ExtraArgs), + list.append(Vars, ExtraVars, AllVars), insert_list(!.Set, AllVars, !:Set). goal_vars_2(NonLocalsToRecompute, shorthand(ShorthandGoal), !Set, @@ -1143,15 +1143,15 @@ rename_apart(RenameSet, RenameMap, !Goal, !Info) :- ; NonLocalsToRecompute = code_gen_nonlocals ) -> - map__init(RenameMap) + map.init(RenameMap) ; to_sorted_list(RenameSet, RenameList), get_varset(!.Info, Varset0), get_vartypes(!.Info, VarTypes0), - map__init(RenameMap0), - goal_util__create_variables(RenameList, Varset0, VarTypes0, + map.init(RenameMap0), + goal_util.create_variables(RenameList, Varset0, VarTypes0, Varset0, Varset, VarTypes0, VarTypes, RenameMap0, RenameMap), - goal_util__rename_vars_in_goal(RenameMap, !Goal), + goal_util.rename_vars_in_goal(RenameMap, !Goal), set_varset(Varset, !Info), set_vartypes(VarTypes, !Info) @@ -1160,7 +1160,7 @@ rename_apart(RenameSet, RenameMap, !Goal, !Info) :- % This is a performance improvement because it keeps the size % of the seen var set down. % get_seen(!.Info, SeenVars0), - % map__values(RenameMap, NewVarsList), + % map.values(RenameMap, NewVarsList), % insert_list(SeenVars0, NewVarsList, SeenVars), % set_seen(SeenVars, !Info) ). @@ -1193,11 +1193,11 @@ set_goal_nonlocals(NonLocals0, NonLocals, !GoalInfo, !Info) :- :- func bitset_to_set(set_of_var) = set(prog_var). -bitset_to_set(Bitset) = set__sorted_list_to_set(to_sorted_list(Bitset)). +bitset_to_set(Bitset) = set.sorted_list_to_set(to_sorted_list(Bitset)). :- func set_to_bitset(set(prog_var)) = set_of_var. -set_to_bitset(Bitset) = sorted_list_to_set(set__to_sorted_list(Bitset)). +set_to_bitset(Bitset) = sorted_list_to_set(set.to_sorted_list(Bitset)). %-----------------------------------------------------------------------------% diff --git a/compiler/reassign.m b/compiler/reassign.m index c90fa8692..b3184e5ed 100644 --- a/compiler/reassign.m +++ b/compiler/reassign.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2002-2005 The University of Melbourne. +% Copyright (C) 2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -14,7 +14,7 @@ % entirely within extended basic blocks. % % It is intended for instruction sequences such as the following extract -% from tree234__search: +% from tree234.search: % % MR_r1 = MR_stackvar(3); % MR_r2 = MR_stackvar(4); @@ -22,7 +22,7 @@ % MR_r4 = MR_stackvar(2); % MR_succip = (MR_Code *) MR_stackvar(5); % if ((MR_tag(MR_r3) != MR_mktag((MR_Integer) 1))) { -% MR_GOTO_LABEL(mercury__x3__search_3_0_i1); +% MR_GOTO_LABEL(mercury.x3.search_3_0_i1); % } % MR_stackvar(1) = MR_r3; % MR_stackvar(2) = MR_r4; @@ -95,7 +95,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__reassign. +:- module ll_backend.reassign. :- interface. :- import_module ll_backend.llds. @@ -126,8 +126,8 @@ :- type dependent_lval_map == map(lval, set(lval)). remove_reassign(Instrs0, Instrs) :- - remove_reassign_loop(Instrs0, map__init, map__init, [], RevInstrs), - list__reverse(RevInstrs, Instrs). + remove_reassign_loop(Instrs0, map.init, map.init, [], RevInstrs), + list.reverse(RevInstrs, Instrs). :- pred remove_reassign_loop(list(instruction)::in, known_contents::in, dependent_lval_map::in, list(instruction)::in, list(instruction)::out) @@ -149,7 +149,7 @@ remove_reassign_loop([Instr0 | Instrs0], !.KnownContentsMap, !.DepLvalMap, ; Uinstr0 = assign(Target, Source), ( - map__search(!.KnownContentsMap, Target, KnownContents), + map.search(!.KnownContentsMap, Target, KnownContents), KnownContents = Source -> % By not including Instr0 in !:RevInstrs, we are deleting Instr0. @@ -174,40 +174,40 @@ remove_reassign_loop([Instr0 | Instrs0], !.KnownContentsMap, !.DepLvalMap, Uinstr0 = call(_, _, _, _, _, _), !:RevInstrs = [Instr0 | !.RevInstrs], % The call may clobber any lval. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = mkframe(_, _), !:RevInstrs = [Instr0 | !.RevInstrs], - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = label(_), !:RevInstrs = [Instr0 | !.RevInstrs], % We don't know what is stored where at the instructions that % jump here. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = goto(_), !:RevInstrs = [Instr0 | !.RevInstrs], % The value of !:KnownContentsMap doesn't really matter since the next % instruction (which must be a label) will reset it to empty anyway. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = computed_goto(_, _), !:RevInstrs = [Instr0 | !.RevInstrs], % The value of !:KnownContentsMap doesn't really matter since the next % instruction (which must be a label) will reset it to empty anyway. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = c_code(_, _), !:RevInstrs = [Instr0 | !.RevInstrs], % The C code may clobber any lval. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = if_val(_, _), !:RevInstrs = [Instr0 | !.RevInstrs] @@ -245,8 +245,8 @@ remove_reassign_loop([Instr0 | Instrs0], !.KnownContentsMap, !.DepLvalMap, Uinstr0 = reset_ticket(_, _), !:RevInstrs = [Instr0 | !.RevInstrs], % The reset operation may modify any lval. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = prune_ticket, !:RevInstrs = [Instr0 | !.RevInstrs] @@ -268,28 +268,28 @@ remove_reassign_loop([Instr0 | Instrs0], !.KnownContentsMap, !.DepLvalMap, !:RevInstrs = [Instr0 | !.RevInstrs], % All stackvars now refer to new locations. Rather than delete % only stackvars from KnownContentsMap, we delete everything. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = decr_sp(_), !:RevInstrs = [Instr0 | !.RevInstrs], % All stackvars now refer to new locations. Rather than delete % only stackvars from KnownContentsMap, we delete everything. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = decr_sp_and_return(_), !:RevInstrs = [Instr0 | !.RevInstrs], % All stackvars now refer to new locations. Rather than delete % only stackvars from KnownContentsMap, we delete everything. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = pragma_c(_, _, _, _, _, _, _, _, _), !:RevInstrs = [Instr0 | !.RevInstrs], % The C code may clobber any lval. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = init_sync_term(Target, _), !:RevInstrs = [Instr0 | !.RevInstrs], @@ -301,21 +301,21 @@ remove_reassign_loop([Instr0 | Instrs0], !.KnownContentsMap, !.DepLvalMap, % by the fork instruction, so the value of !:KnownContentsMap doesn't % really matter since the next instruction (which must be a label) % will reset it to empty anyway. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = join_and_terminate(_), !:RevInstrs = [Instr0 | !.RevInstrs], % The value of KnownContentsMap doesn't really matter since this % instruction terminates the execution of this thread. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; Uinstr0 = join_and_continue(_, _), !:RevInstrs = [Instr0 | !.RevInstrs], % Other threads may modify any lval. - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ), remove_reassign_loop(Instrs0, !.KnownContentsMap, !.DepLvalMap, !RevInstrs). @@ -335,9 +335,9 @@ no_implicit_alias_target(framevar(_)). dependent_lval_map::in, dependent_lval_map::out) is det. clobber_dependents(Target, !KnownContentsMap, !DepLvalMap) :- - ( map__search(!.DepLvalMap, Target, DepLvals) -> - set__fold(clobber_dependent, DepLvals, !KnownContentsMap), - map__delete(!.DepLvalMap, Target, !:DepLvalMap) + ( map.search(!.DepLvalMap, Target, DepLvals) -> + set.fold(clobber_dependent, DepLvals, !KnownContentsMap), + map.delete(!.DepLvalMap, Target, !:DepLvalMap) ; true ), @@ -347,13 +347,13 @@ clobber_dependents(Target, !KnownContentsMap, !DepLvalMap) :- % way the known contents map. This is a conservative approximation of the % desired behaviour, which would invalidate only the entries of lvals % that may be referred to via this mem_ref. - code_util__lvals_in_rval(lval(Target), SubLvals), + code_util.lvals_in_rval(lval(Target), SubLvals), ( - list__member(SubLval, SubLvals), + list.member(SubLval, SubLvals), SubLval = mem_ref(_) -> - !:KnownContentsMap = map__init, - !:DepLvalMap = map__init + !:KnownContentsMap = map.init, + !:DepLvalMap = map.init ; true ). @@ -362,15 +362,15 @@ clobber_dependents(Target, !KnownContentsMap, !DepLvalMap) :- is det. clobber_dependent(Dependent, KnownContentsMap0, KnownContentsMap) :- - map__delete(KnownContentsMap0, Dependent, KnownContentsMap). + map.delete(KnownContentsMap0, Dependent, KnownContentsMap). :- pred record_known(lval::in, rval::in, known_contents::in, known_contents::out, dependent_lval_map::in, dependent_lval_map::out) is det. record_known(TargetLval, SourceRval, !KnownContentsMap, !DepLvalMap) :- - code_util__lvals_in_rval(SourceRval, SourceSubLvals), - ( list__member(TargetLval, SourceSubLvals) -> + code_util.lvals_in_rval(SourceRval, SourceSubLvals), + ( list.member(TargetLval, SourceSubLvals) -> % The act of assigning to TargetLval has modified the value of % SourceRval, so we can't eliminate any copy of this assignment % or its converse. @@ -392,31 +392,31 @@ record_known(TargetLval, SourceRval, !KnownContentsMap, !DepLvalMap) :- record_known_lval_rval(TargetLval, SourceRval, !KnownContentsMap, !DepLvalMap) :- - ( map__search(!.KnownContentsMap, TargetLval, OldRval) -> + ( map.search(!.KnownContentsMap, TargetLval, OldRval) -> % TargetLval no longer depends on the lvals in OldRval; % it depends on the lvals in SourceRval instead. If any lvals % occur in both, we delete TargetLval from their entries here % and will add it back in a few lines later on. % % TargetLval still depends on the lvals inside it. - code_util__lvals_in_rval(OldRval, OldSubLvals), - list__foldl(make_not_dependent(TargetLval), OldSubLvals, !DepLvalMap) + code_util.lvals_in_rval(OldRval, OldSubLvals), + list.foldl(make_not_dependent(TargetLval), OldSubLvals, !DepLvalMap) ; true ), - code_util__lvals_in_lval(TargetLval, TargetSubLvals), - code_util__lvals_in_rval(SourceRval, SourceSubLvals), - list__append(TargetSubLvals, SourceSubLvals, AllSubLvals), - list__foldl(make_dependent(TargetLval), AllSubLvals, !DepLvalMap), - svmap__set(TargetLval, SourceRval, !KnownContentsMap). + code_util.lvals_in_lval(TargetLval, TargetSubLvals), + code_util.lvals_in_rval(SourceRval, SourceSubLvals), + list.append(TargetSubLvals, SourceSubLvals, AllSubLvals), + list.foldl(make_dependent(TargetLval), AllSubLvals, !DepLvalMap), + svmap.set(TargetLval, SourceRval, !KnownContentsMap). :- pred make_not_dependent(lval::in, lval::in, dependent_lval_map::in, dependent_lval_map::out) is det. make_not_dependent(Target, SubLval, !DepLvalMap) :- - ( map__search(!.DepLvalMap, SubLval, DepLvals0) -> - set__delete(DepLvals0, Target, DepLvals), - svmap__det_update(SubLval, DepLvals, !DepLvalMap) + ( map.search(!.DepLvalMap, SubLval, DepLvals0) -> + set.delete(DepLvals0, Target, DepLvals), + svmap.det_update(SubLval, DepLvals, !DepLvalMap) ; true ). @@ -425,12 +425,12 @@ make_not_dependent(Target, SubLval, !DepLvalMap) :- dependent_lval_map::in, dependent_lval_map::out) is det. make_dependent(Target, SubLval, !DepLvalMap) :- - ( map__search(!.DepLvalMap, SubLval, DepLvals0) -> - set__insert(DepLvals0, Target, DepLvals), - svmap__det_update(SubLval, DepLvals, !DepLvalMap) + ( map.search(!.DepLvalMap, SubLval, DepLvals0) -> + set.insert(DepLvals0, Target, DepLvals), + svmap.det_update(SubLval, DepLvals, !DepLvalMap) ; - DepLvals = set__make_singleton_set(Target), - svmap__det_insert(SubLval, DepLvals, !DepLvalMap) + DepLvals = set.make_singleton_set(Target), + svmap.det_insert(SubLval, DepLvals, !DepLvalMap) ). %-----------------------------------------------------------------------------% diff --git a/compiler/recompilation.check.m b/compiler/recompilation.check.m index 66a55cb4d..28614af55 100644 --- a/compiler/recompilation.check.m +++ b/compiler/recompilation.check.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2002-2005 The University of Melbourne. +% Copyright (C) 2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module recompilation__check. +:- module recompilation.check. :- interface. :- import_module mdbcomp.prim_data. @@ -88,11 +88,11 @@ should_recompile(ModuleName, FindTargetFiles, FindTimestampFiles, Info ^ modules_to_recompile, Info ^ read_modules, !IO) :- - globals__io_lookup_bool_option(find_all_recompilation_reasons, + globals.io_lookup_bool_option(find_all_recompilation_reasons, FindAll, !IO), - Info0 = recompilation_check_info(ModuleName, no, [], map__init, - init_item_id_set(map__init, map__init, map__init), - set__init, some_modules([]), FindAll, []), + Info0 = recompilation_check_info(ModuleName, no, [], map.init, + init_item_id_set(map.init, map.init, map.init), + set.init, some_modules([]), FindAll, []), should_recompile_2(no, FindTargetFiles, FindTimestampFiles, ModuleName, Info0, Info, !IO). @@ -106,10 +106,10 @@ should_recompile_2(IsSubModule, FindTargetFiles, FindTimestampFiles, ModuleName, !Info, !IO) :- !:Info = (!.Info ^ module_name := ModuleName) ^ sub_modules := [], module_name_to_file_name(ModuleName, ".used", no, UsageFileName, !IO), - io__open_input(UsageFileName, MaybeVersionStream, !IO), + io.open_input(UsageFileName, MaybeVersionStream, !IO), ( MaybeVersionStream = ok(VersionStream0), - io__set_input_stream(VersionStream0, OldInputStream, !IO), + io.set_input_stream(VersionStream0, OldInputStream, !IO), promise_equivalent_solutions [Result, !:IO] ( should_recompile_3_try(IsSubModule, FindTimestampFiles, @@ -136,15 +136,15 @@ should_recompile_2(IsSubModule, FindTargetFiles, FindTimestampFiles, FindTimestampFiles(ModuleName, TimestampFiles, !IO), write_recompilation_message( write_not_recompiling_message(ModuleName), !IO), - list__foldl(touch_datestamp, TimestampFiles, !IO) + list.foldl(touch_datestamp, TimestampFiles, !IO) ; Reasons = [_ | _], add_module_to_recompile(ModuleName, !Info), write_recompilation_message(write_reasons_message(ModuleName, - list__reverse(Reasons)), !IO) + list.reverse(Reasons)), !IO) ), - io__set_input_stream(OldInputStream, VersionStream, !IO), - io__close_input(VersionStream, !IO), + io.set_input_stream(OldInputStream, VersionStream, !IO), + io.close_input(VersionStream, !IO), ModulesToRecompile = !.Info ^ modules_to_recompile, ( @@ -152,7 +152,7 @@ should_recompile_2(IsSubModule, FindTargetFiles, FindTimestampFiles, ; ModulesToRecompile = some_modules(_), !:Info = !.Info ^ is_inline_sub_module := yes, - list__foldl2(should_recompile_2(yes, + list.foldl2(should_recompile_2(yes, FindTargetFiles, FindTimestampFiles), !.Info ^ sub_modules, !Info, !IO) ) @@ -166,15 +166,15 @@ should_recompile_2(IsSubModule, FindTargetFiles, FindTimestampFiles, :- pred write_not_recompiling_message(module_name::in, io::di, io::uo) is det. write_not_recompiling_message(ModuleName, !IO) :- - io__write_string("Not recompiling module ", !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string(".\n", !IO). + io.write_string("Not recompiling module ", !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string(".\n", !IO). :- pred write_reasons_message(module_name::in, list(recompile_reason)::in, io::di, io::uo) is det. write_reasons_message(ModuleName, Reasons, !IO) :- - list__foldl(write_recompile_reason(ModuleName), Reasons, !IO). + list.foldl(write_recompile_reason(ModuleName), Reasons, !IO). :- pred write_not_found_reasons_message(string::in, module_name::in, io::di, io::uo) is det. @@ -209,17 +209,17 @@ should_recompile_3(IsSubModule, FindTargetFiles, !Info, !IO) :- read_term_check_for_error_or_eof(!.Info, "usage file version number", VersionNumberTerm, !IO), ( - VersionNumberTerm = term__functor(term__atom(","), + VersionNumberTerm = term.functor(term.atom(","), [UsageFileVersionNumberTerm, VersionNumbersVersionNumberTerm], _), UsageFileVersionNumberTerm = - term__functor( term__integer(usage_file_version_number), _, _), + term.functor( term.integer(usage_file_version_number), _, _), VersionNumbersVersionNumberTerm = - term__functor( term__integer(version_numbers_version_number), _, _) + term.functor( term.integer(version_numbers_version_number), _, _) -> true ; - io__input_stream_name(UsageFileName, !IO), + io.input_stream_name(UsageFileName, !IO), throw_syntax_error( file_error(UsageFileName, "invalid usage file version number in file `" @@ -270,9 +270,9 @@ should_recompile_3(IsSubModule, FindTargetFiles, !Info, !IO) :- read_term_check_for_error_or_eof(!.Info, "inline sub-modules", SubModulesTerm, !IO), ( - SubModulesTerm = term__functor(term__atom("sub_modules"), + SubModulesTerm = term.functor(term.atom("sub_modules"), SubModuleTerms, _), - list__map( + list.map( (pred(Term::in, SubModule::out) is semidet :- sym_name_and_args(Term, SubModule, []) ), @@ -287,7 +287,7 @@ should_recompile_3(IsSubModule, FindTargetFiles, !Info, !IO) :- % Check whether the output files are present and up-to-date. FindTargetFiles(!.Info ^ module_name, TargetFiles, !IO), - list__foldl2(require_recompilation_if_not_up_to_date(RecordedTimestamp), + list.foldl2(require_recompilation_if_not_up_to_date(RecordedTimestamp), TargetFiles, !Info, !IO), % Read in the used items, used for checking for ambiguities with new items. @@ -298,11 +298,11 @@ should_recompile_3(IsSubModule, FindTargetFiles, !Info, !IO) :- read_term_check_for_error_or_eof(!.Info, "used classes", UsedClassesTerm, !IO), ( - UsedClassesTerm = term__functor(term__atom("used_classes"), + UsedClassesTerm = term.functor(term.atom("used_classes"), UsedClassTerms, _), - list__map(parse_name_and_arity_to_used, UsedClassTerms, UsedClasses) + list.map(parse_name_and_arity_to_used, UsedClassTerms, UsedClasses) -> - !:Info = !.Info ^ used_typeclasses := set__list_to_set(UsedClasses) + !:Info = !.Info ^ used_typeclasses := set.list_to_set(UsedClasses) ; Reason3 = syntax_error(get_term_context(UsedClassesTerm), "error in used_typeclasses term"), @@ -316,7 +316,7 @@ should_recompile_3(IsSubModule, FindTargetFiles, !Info, !IO) :- require_recompilation_if_not_up_to_date(RecordedTimestamp, TargetFile, !Info, !IO) :- - io__file_modification_time(TargetFile, TargetModTimeResult, !IO), + io.file_modification_time(TargetFile, TargetModTimeResult, !IO), ( TargetModTimeResult = ok(TargetModTime), compare(TargetModTimeCompare, time_t_to_timestamp(TargetModTime), @@ -346,10 +346,10 @@ parse_module_timestamp(Info, Term, ModuleName, ModuleTimestamp) :- ( Args = [ModuleNameTerm, SuffixTerm, TimestampTerm | MaybeOtherTerms], sym_name_and_args(ModuleNameTerm, ModuleName0, []), - SuffixTerm = term__functor(term__string(Suffix), [], _), + SuffixTerm = term.functor(term.string(Suffix), [], _), Timestamp = term_to_timestamp(TimestampTerm), ( - MaybeOtherTerms = [term__functor(term__atom("used"), [], _)], + MaybeOtherTerms = [term.functor(term.atom("used"), [], _)], NeedQualifier = must_be_qualified ; MaybeOtherTerms = [], @@ -370,9 +370,9 @@ parse_module_timestamp(Info, Term, ModuleName, ModuleTimestamp) :- term::in, resolved_used_items::out) is det. parse_used_items(Info, Term, UsedItems) :- - ( Term = term__functor(term__atom("used_items"), UsedItemTerms, _) -> - list__foldl(parse_used_item_set(Info), UsedItemTerms, - init_item_id_set(map__init, map__init, map__init), UsedItems) + ( Term = term.functor(term.atom("used_items"), UsedItemTerms, _) -> + list.foldl(parse_used_item_set(Info), UsedItemTerms, + init_item_id_set(map.init, map.init, map.init), UsedItems) ; Reason = syntax_error(get_term_context(Term), "error in used items"), throw_syntax_error(Reason, Info) @@ -383,22 +383,22 @@ parse_used_items(Info, Term, UsedItems) :- parse_used_item_set(Info, Term, UsedItems0, UsedItems) :- ( - Term = term__functor(term__atom(ItemTypeStr), ItemTerms, _), + Term = term.functor(term.atom(ItemTypeStr), ItemTerms, _), string_to_item_type(ItemTypeStr, ItemType) -> ( is_simple_item_type(ItemType) -> - list__foldl(parse_simple_item(Info), ItemTerms, - map__init, SimpleItems), + list.foldl(parse_simple_item(Info), ItemTerms, + map.init, SimpleItems), UsedItems = update_simple_item_set(UsedItems0, ItemType, SimpleItems) ; is_pred_or_func_item_type(ItemType) -> - list__foldl(parse_pred_or_func_item(Info), - ItemTerms, map__init, PredOrFuncItems), + list.foldl(parse_pred_or_func_item(Info), + ItemTerms, map.init, PredOrFuncItems), UsedItems = update_pred_or_func_set(UsedItems0, ItemType, PredOrFuncItems) ; ItemType = functor_item -> - list__foldl(parse_functor_item(Info), - ItemTerms, map__init, CtorItems), + list.foldl(parse_functor_item(Info), + ItemTerms, map.init, CtorItems), UsedItems = UsedItems0 ^ functors := CtorItems ; Reason = syntax_error(get_term_context(Term), @@ -415,14 +415,14 @@ parse_used_item_set(Info, Term, UsedItems0, UsedItems) :- parse_simple_item(Info, Term, Set0, Set) :- ( - Term = term__functor(term__atom("-"), [NameArityTerm, MatchesTerm], _), + Term = term.functor(term.atom("-"), [NameArityTerm, MatchesTerm], _), parse_name_and_arity(NameArityTerm, SymName, Arity) -> unqualify_name(SymName, Name), conjunction_to_list(MatchesTerm, MatchTermList), - list__foldl(parse_simple_item_match(Info), MatchTermList, - map__init, Matches), - map__det_insert(Set0, Name - Arity, Matches, Set) + list.foldl(parse_simple_item_match(Info), MatchTermList, + map.init, Matches), + map.det_insert(Set0, Name - Arity, Matches, Set) ; Reason = syntax_error(get_term_context(Term), "error in simple items"), throw_syntax_error(Reason, Info) @@ -435,7 +435,7 @@ parse_simple_item(Info, Term, Set0, Set) :- parse_simple_item_match(Info, Term, Items0, Items) :- ( ( - Term = term__functor(term__atom("=>"), + Term = term.functor(term.atom("=>"), [QualifierTerm, ModuleNameTerm], _) -> sym_name_and_args(QualifierTerm, Qualifier, []), @@ -445,7 +445,7 @@ parse_simple_item_match(Info, Term, Items0, Items) :- Qualifier = ModuleName ) -> - map__det_insert(Items0, Qualifier, ModuleName, Items) + map.det_insert(Items0, Qualifier, ModuleName, Items) ; Reason = syntax_error(get_term_context(Term), "error in simple item match"), @@ -465,12 +465,12 @@ parse_pred_or_func_item_match(Info, Term, !Items) :- PredId = invalid_pred_id, ( ( - Term = term__functor(term__atom("=>"), + Term = term.functor(term.atom("=>"), [QualifierTerm, MatchesTerm], _) -> sym_name_and_args(QualifierTerm, Qualifier, []), conjunction_to_list(MatchesTerm, MatchesList), - list__map( + list.map( (pred(MatchTerm::in, Match::out) is semidet :- sym_name_and_args(MatchTerm, MatchName, []), Match = PredId - MatchName @@ -481,7 +481,7 @@ parse_pred_or_func_item_match(Info, Term, !Items) :- Matches = [PredId - Qualifier] ) -> - svmap__det_insert(Qualifier, set__list_to_set(Matches), !Items) + svmap.det_insert(Qualifier, set.list_to_set(Matches), !Items) ; Reason = syntax_error(get_term_context(Term), "error in pred or func match"), @@ -499,13 +499,13 @@ parse_functor_item(Info, Term, !Set) :- parse_functor_matches(Info, Term, !Map) :- ( - Term = term__functor(term__atom("=>"), + Term = term.functor(term.atom("=>"), [QualifierTerm, MatchesTerm], _), sym_name_and_args(QualifierTerm, Qualifier, []) -> conjunction_to_list(MatchesTerm, MatchesList), - list__map(parse_resolved_functor(Info), MatchesList, Matches), - svmap__det_insert(Qualifier, set__list_to_set(Matches), !Map) + list.map(parse_resolved_functor(Info), MatchesList, Matches), + svmap.det_insert(Qualifier, set.list_to_set(Matches), !Map) ; Reason = syntax_error(get_term_context(Term), "error in functor match"), @@ -517,23 +517,23 @@ parse_functor_matches(Info, Term, !Map) :- parse_resolved_functor(Info, Term, Ctor) :- ( - Term = term__functor(term__atom(PredOrFuncStr), + Term = term.functor(term.atom(PredOrFuncStr), [ModuleTerm, ArityTerm], _), ( PredOrFuncStr = "predicate", PredOrFunc = predicate ; PredOrFuncStr = "function", PredOrFunc = function ), sym_name_and_args(ModuleTerm, ModuleName, []), - ArityTerm = term__functor(term__integer(Arity), [], _) + ArityTerm = term.functor(term.integer(Arity), [], _) -> PredId = invalid_pred_id, Ctor = pred_or_func(PredId, ModuleName, PredOrFunc, Arity) ; - Term = term__functor(term__atom("ctor"), [NameArityTerm], _), + Term = term.functor(term.atom("ctor"), [NameArityTerm], _), parse_name_and_arity(NameArityTerm, TypeName, TypeArity) -> Ctor = constructor(TypeName - TypeArity) ; - Term = term__functor(term__atom("field"), + Term = term.functor(term.atom("field"), [TypeNameArityTerm, ConsNameArityTerm], _), parse_name_and_arity(TypeNameArityTerm, TypeName, TypeArity), parse_name_and_arity(ConsNameArityTerm, ConsName, ConsArity) @@ -556,13 +556,13 @@ parse_resolved_functor(Info, Term, Ctor) :- parse_resolved_item_set(Info, ParseMatches, Term, Set0, Set) :- ( - Term = term__functor(term__atom("-"), [NameTerm, MatchesTerm], _), - NameTerm = term__functor(term__atom(Name), [], _) + Term = term.functor(term.atom("-"), [NameTerm, MatchesTerm], _), + NameTerm = term.functor(term.atom(Name), [], _) -> conjunction_to_list(MatchesTerm, MatchTermList), - list__map(parse_resolved_item_arity_matches(Info, ParseMatches), + list.map(parse_resolved_item_arity_matches(Info, ParseMatches), MatchTermList, Matches), - map__det_insert(Set0, Name, Matches, Set) + map.det_insert(Set0, Name, Matches, Set) ; Reason = syntax_error(get_term_context(Term), "error in resolved item matches"), @@ -576,16 +576,16 @@ parse_resolved_item_set(Info, ParseMatches, Term, Set0, Set) :- parse_resolved_item_arity_matches(Info, ParseMatches, Term, Arity - MatchMap) :- ( - Term = term__functor(term__atom("-"), [ArityTerm, MatchesTerm], _), - ArityTerm = term__functor(term__integer(Arity0), [], _), + Term = term.functor(term.atom("-"), [ArityTerm, MatchesTerm], _), + ArityTerm = term.functor(term.integer(Arity0), [], _), conjunction_to_list(MatchesTerm, MatchTermList) -> Arity = Arity0, - list__foldl( + list.foldl( (pred(MatchTerm::in, Map0::in, Map::out) is det :- ParseMatches(Info, MatchTerm, Map0, Map) ), - MatchTermList, map__init, MatchMap) + MatchTermList, map.init, MatchMap) ; Reason = syntax_error(get_term_context(Term), "error in resolved item matches"), @@ -602,10 +602,10 @@ parse_resolved_item_arity_matches(Info, ParseMatches, Term, recompilation_check_info::out, io::di, io::uo) is det. check_imported_modules(!Info, !IO) :- - parser__read_term(TermResult, !IO), + parser.read_term(TermResult, !IO), ( TermResult = term(_, Term), - ( Term = term__functor(term__atom("done"), [], _) -> + ( Term = term.functor(term.atom("done"), [], _) -> true ; check_imported_module(Term, !Info, !IO), @@ -613,17 +613,17 @@ check_imported_modules(!Info, !IO) :- ) ; TermResult = error(Message, Line), - io__input_stream_name(FileName, !IO), - Reason = syntax_error(term__context(FileName, Line), Message), + io.input_stream_name(FileName, !IO), + Reason = syntax_error(term.context(FileName, Line), Message), throw_syntax_error(Reason, !.Info) ; TermResult = eof, % There should always be an item `done.' at the end of the list % of modules to check. This is used to make sure that the writing % of the `.used' file was not interrupted. - io__input_stream_name(FileName, !IO), - io__get_line_number(Line, !IO), - Reason = syntax_error(term__context(FileName, Line), + io.input_stream_name(FileName, !IO), + io.get_line_number(Line, !IO), + Reason = syntax_error(term.context(FileName, Line), "unexpected end of file"), throw_syntax_error(Reason, !.Info) ). @@ -634,7 +634,7 @@ check_imported_modules(!Info, !IO) :- check_imported_module(Term, !Info, !IO) :- ( - Term = term__functor(term__atom("=>"), + Term = term.functor(term.atom("=>"), [TimestampTerm0, UsedItemsTerm0], _) -> TimestampTerm = TimestampTerm0, @@ -659,9 +659,9 @@ check_imported_module(Term, !Info, !IO) :- MaybeNewTimestamp = MaybeNewTimestamp0, Error = Error0, FileName = FileName0, - Recorded = bool__yes + Recorded = bool.yes ; - Recorded = bool__no, + Recorded = bool.no, read_mod_if_changed(ImportedModuleName, Suffix, "Reading interface file for module", yes, RecordedTimestamp, Items, Error, FileName, MaybeNewTimestamp, !IO) @@ -723,14 +723,14 @@ check_module_used_items(ModuleName, NeedQualifier, OldTimestamp, NewInstanceVersionNumbers), % Check whether any of the items which were used have changed. - list__foldl(check_item_version_numbers(ModuleName, UsedItemVersionNumbers, + list.foldl(check_item_version_numbers(ModuleName, UsedItemVersionNumbers, NewItemVersionNumbers), [type_item, type_body_item, inst_item, mode_item, typeclass_item, predicate_item, function_item], !Info), % Check whether added or modified items could cause name resolution % ambiguities with items which were used. - list__foldl(check_for_ambiguities(NeedQualifier, OldTimestamp, + list.foldl(check_for_ambiguities(NeedQualifier, OldTimestamp, UsedItemVersionNumbers), Items, !Info), % Check whether any instances of used typeclasses have been added, @@ -739,15 +739,15 @@ check_module_used_items(ModuleName, NeedQualifier, OldTimestamp, NewInstanceVersionNumbers, !Info), % Check for new instances for used typeclasses. - ModuleInstances = set__sorted_list_to_set( - map__sorted_keys(NewInstanceVersionNumbers)), - UsedInstances = set__sorted_list_to_set( - map__sorted_keys(UsedInstanceVersionNumbers)), + ModuleInstances = set.sorted_list_to_set( + map.sorted_keys(NewInstanceVersionNumbers)), + UsedInstances = set.sorted_list_to_set( + map.sorted_keys(UsedInstanceVersionNumbers)), UsedClasses = !.Info ^ used_typeclasses, - set__difference(set__intersect(UsedClasses, ModuleInstances), + set.difference(set.intersect(UsedClasses, ModuleInstances), UsedInstances, AddedInstances), - ( [AddedInstance | _] = set__to_sorted_list(AddedInstances) -> + ( [AddedInstance | _] = set.to_sorted_list(AddedInstances) -> Reason1 = changed_or_added_instance(ModuleName, AddedInstance), record_recompilation_reason(Reason1, !Info) ; @@ -768,7 +768,7 @@ make_item_id(Module, ItemType, Name - Arity) = check_item_version_numbers(ModuleName, UsedVersionNumbers, NewVersionNumbers, ItemType, !Info) :- NewItemTypeVersionNumbers = extract_ids(NewVersionNumbers, ItemType), - map__foldl(check_item_version_number(ModuleName, + map.foldl(check_item_version_number(ModuleName, NewItemTypeVersionNumbers, ItemType), extract_ids(UsedVersionNumbers, ItemType), !Info). @@ -778,7 +778,7 @@ check_item_version_numbers(ModuleName, UsedVersionNumbers, NewVersionNumbers, check_item_version_number(ModuleName, NewItemTypeVersionNumbers, ItemType, NameArity, UsedVersionNumber, !Info) :- - ( map__search(NewItemTypeVersionNumbers, NameArity, NewVersionNumber) -> + ( map.search(NewItemTypeVersionNumbers, NameArity, NewVersionNumber) -> ( NewVersionNumber = UsedVersionNumber -> true ; @@ -798,7 +798,7 @@ check_item_version_number(ModuleName, NewItemTypeVersionNumbers, ItemType, check_instance_version_numbers(ModuleName, UsedInstanceVersionNumbers, NewInstanceVersionNumbers, !Info) :- - map__foldl(check_instance_version_number(ModuleName, + map.foldl(check_instance_version_number(ModuleName, NewInstanceVersionNumbers), UsedInstanceVersionNumbers, !Info). :- pred check_instance_version_number(module_name::in, @@ -807,7 +807,7 @@ check_instance_version_numbers(ModuleName, UsedInstanceVersionNumbers, check_instance_version_number(ModuleName, NewInstanceVersionNumbers, ClassId, UsedVersionNumber, !Info) :- - ( map__search(NewInstanceVersionNumbers, ClassId, NewVersionNumber) -> + ( map.search(NewInstanceVersionNumbers, ClassId, NewVersionNumber) -> ( UsedVersionNumber = NewVersionNumber -> true ; @@ -833,7 +833,7 @@ check_for_ambiguities(_, _, _, clause(_, _, _, _, _, _) - _, !Info) :- unexpected(this_file, "check_for_ambiguities: clause"). check_for_ambiguities(NeedQualifier, OldTimestamp, VersionNumbers, type_defn(_, Name, Params, Body, _) - _, !Info) :- - Arity = list__length(Params), + Arity = list.length(Params), check_for_simple_item_ambiguity(NeedQualifier, OldTimestamp, VersionNumbers, type_item, Name, Arity, NeedsCheck, !Info), ( @@ -846,21 +846,21 @@ check_for_ambiguities(NeedQualifier, OldTimestamp, VersionNumbers, check_for_ambiguities(NeedQualifier, OldTimestamp, VersionNumbers, inst_defn(_, Name, Params, _, _) - _, !Info) :- check_for_simple_item_ambiguity(NeedQualifier, OldTimestamp, - VersionNumbers, inst_item, Name, list__length(Params), _, !Info). + VersionNumbers, inst_item, Name, list.length(Params), _, !Info). check_for_ambiguities(NeedQualifier, OldTimestamp, VersionNumbers, mode_defn(_, Name, Params, _, _) - _, !Info) :- check_for_simple_item_ambiguity(NeedQualifier, OldTimestamp, - VersionNumbers, mode_item, Name, list__length(Params), _, !Info). + VersionNumbers, mode_item, Name, list.length(Params), _, !Info). check_for_ambiguities(NeedQualifier, OldTimestamp, VersionNumbers, typeclass(_, _, Name, Params, Interface, _) - _, !Info) :- check_for_simple_item_ambiguity(NeedQualifier, OldTimestamp, - VersionNumbers, typeclass_item, Name, list__length(Params), + VersionNumbers, typeclass_item, Name, list.length(Params), NeedsCheck, !Info), ( NeedsCheck = yes, Interface = concrete(Methods) -> - list__foldl(check_class_method_for_ambiguities(NeedQualifier, + list.foldl(check_class_method_for_ambiguities(NeedQualifier, OldTimestamp, VersionNumbers), Methods, !Info) ; true @@ -904,7 +904,7 @@ item_is_new_or_changed(UsedFileTimestamp, UsedVersionNumbers, ItemType, SymName, Arity) :- unqualify_name(SymName, Name), ( - map__search(extract_ids(UsedVersionNumbers, ItemType), Name - Arity, + map.search(extract_ids(UsedVersionNumbers, ItemType), Name - Arity, UsedVersionNumber) -> % XXX This assumes that version numbers are timestamps. @@ -929,10 +929,10 @@ check_for_simple_item_ambiguity(NeedQualifier, UsedFileTimestamp, UsedItemMap = extract_simple_item_set(UsedItems, ItemType), unqualify_name(SymName, Name), ( - map__search(UsedItemMap, Name - Arity, + map.search(UsedItemMap, Name - Arity, MatchingQualifiers) -> - map__foldl( + map.foldl( check_for_simple_item_ambiguity_2(ItemType, NeedQualifier, SymName, Arity), MatchingQualifiers, !Info) @@ -979,10 +979,10 @@ check_for_pred_or_func_item_ambiguity(NeedsCheck, NeedQualifier, OldTimestamp, VersionNumbers, PredOrFunc, SymName, Args, WithType, !Info) :- ( WithType = no, - adjust_func_arity(PredOrFunc, Arity, list__length(Args)) + adjust_func_arity(PredOrFunc, Arity, list.length(Args)) ; WithType = yes(_), - Arity = list__length(Args) + Arity = list.length(Args) ), ItemType = pred_or_func_to_item_type(PredOrFunc), ( @@ -996,8 +996,8 @@ check_for_pred_or_func_item_ambiguity(NeedsCheck, NeedQualifier, OldTimestamp, UsedItems = !.Info ^ used_items, UsedItemMap = extract_pred_or_func_set(UsedItems, ItemType), unqualify_name(SymName, Name), - ( map__search(UsedItemMap, Name, MatchingArityList) -> - list__foldl(check_for_pred_or_func_item_ambiguity_1(WithType, + ( map.search(UsedItemMap, Name, MatchingArityList) -> + list.foldl(check_for_pred_or_func_item_ambiguity_1(WithType, ItemType, NeedQualifier, SymName, Arity), MatchingArityList, !Info) ; @@ -1041,7 +1041,7 @@ check_for_pred_or_func_item_ambiguity_1(WithType, ItemType, NeedQualifier, MatchArity = Arity ) -> - map__foldl( + map.foldl( check_for_pred_or_func_item_ambiguity_2(ItemType, NeedQualifier, SymName, MatchArity), MatchingQualifiers, !Info) @@ -1069,15 +1069,15 @@ check_for_pred_or_func_item_ambiguity_2(ItemType, NeedQualifier, match_sym_name(QualifiedName, SymName), \+ ( SymName = qualified(PredModuleName, _), - set__member(_ - PredModuleName, OldMatchingModuleNames) + set.member(_ - PredModuleName, OldMatchingModuleNames) ) -> - AmbiguousDecls = list__map( + AmbiguousDecls = list.map( (func(_ - OldMatchingModule) = Item :- OldMatchingName = qualified(OldMatchingModule, Name), Item = item_id(ItemType, OldMatchingName - Arity) ), - set__to_sorted_list(OldMatchingModuleNames)), + set.to_sorted_list(OldMatchingModuleNames)), Reason = item_ambiguity(item_id(ItemType, SymName - Arity), AmbiguousDecls), record_recompilation_reason(Reason, !Info) @@ -1097,7 +1097,7 @@ check_type_defn_ambiguity_with_functor(_, _, abstract_type(_), !Info). check_type_defn_ambiguity_with_functor(_, _, eqv_type(_), !Info). check_type_defn_ambiguity_with_functor(NeedQualifier, TypeCtor, du_type(Ctors, _), !Info) :- - list__foldl(check_functor_ambiguities(NeedQualifier, TypeCtor), Ctors, + list.foldl(check_functor_ambiguities(NeedQualifier, TypeCtor), Ctors, !Info). check_type_defn_ambiguity_with_functor(_, _, foreign_type(_, _, _), !Info). check_type_defn_ambiguity_with_functor(_, _, solver_type(_, _), !Info). @@ -1109,10 +1109,10 @@ check_type_defn_ambiguity_with_functor(_, _, solver_type(_, _), !Info). check_functor_ambiguities(NeedQualifier, TypeCtor, ctor(_, _, Name, Args), !Info) :- ResolvedCtor = constructor(TypeCtor), - Arity = list__length(Args), + Arity = list.length(Args), check_functor_ambiguities(NeedQualifier, Name, exact(Arity), ResolvedCtor, !Info), - list__foldl(check_field_ambiguities(NeedQualifier, + list.foldl(check_field_ambiguities(NeedQualifier, field(TypeCtor, Name - Arity)), Args, !Info). :- pred check_field_ambiguities(need_qualifier::in, resolved_functor::in, @@ -1147,7 +1147,7 @@ check_functor_ambiguities(NeedQualifier, Name, MatchArity, ResolvedCtor, UsedItems = !.Info ^ used_items, unqualify_name(Name, UnqualName), UsedCtors = UsedItems ^ functors, - ( map__search(UsedCtors, UnqualName, UsedCtorAL) -> + ( map.search(UsedCtors, UnqualName, UsedCtorAL) -> check_functor_ambiguities_2(NeedQualifier, Name, MatchArity, ResolvedCtor, UsedCtorAL, !Info) ; @@ -1165,8 +1165,8 @@ check_functor_ambiguities_2(NeedQualifier, Name, MatchArity, ( MatchArity = exact(ArityToMatch), ( ArityToMatch = Arity -> - Check = bool__yes, - Continue = bool__no + Check = yes, + Continue = no ; Check = no, ( Arity < ArityToMatch -> @@ -1191,7 +1191,7 @@ check_functor_ambiguities_2(NeedQualifier, Name, MatchArity, ), ( Check = yes, - map__foldl(check_functor_ambiguity(NeedQualifier, Name, Arity, + map.foldl(check_functor_ambiguity(NeedQualifier, Name, Arity, ResolvedCtor), UsedCtorMap, !Info) ; Check = no @@ -1222,11 +1222,11 @@ check_functor_ambiguity(NeedQualifier, SymName, Arity, ResolvedCtor, unqualify_name(SymName, Name), OldName = module_qualify_name(OldModuleQualifier, Name), match_sym_name(OldName, SymName), - \+ set__member(ResolvedCtor, OldResolvedCtors) + \+ set.member(ResolvedCtor, OldResolvedCtors) -> Reason = functor_ambiguity( module_qualify_name(OldModuleQualifier, Name), - Arity, ResolvedCtor, set__to_sorted_list(OldResolvedCtors) + Arity, ResolvedCtor, set.to_sorted_list(OldResolvedCtors) ), record_recompilation_reason(Reason, !Info) ; @@ -1265,7 +1265,7 @@ check_functor_ambiguity(NeedQualifier, SymName, Arity, ResolvedCtor, ) ; syntax_error( - term__context, + term.context, string ) @@ -1322,7 +1322,7 @@ add_module_to_recompile(Module, !Info) :- record_read_file(ModuleName, ModuleTimestamp, Items, Error, FileName, !Info) :- Imports0 = !.Info ^ read_modules, - map__set(Imports0, ModuleName - ModuleTimestamp ^ suffix, + map.set(Imports0, ModuleName - ModuleTimestamp ^ suffix, read_module(ModuleTimestamp, Items, Error, FileName), Imports), !:Info = !.Info ^ read_modules := Imports. @@ -1332,7 +1332,7 @@ record_read_file(ModuleName, ModuleTimestamp, Items, Error, FileName, !Info) :- io::di, io::uo) is det. write_recompilation_message(P, !IO) :- - globals__io_lookup_bool_option(verbose_recompilation, Verbose, !IO), + globals.io_lookup_bool_option(verbose_recompilation, Verbose, !IO), ( Verbose = yes, P(!IO) @@ -1346,7 +1346,7 @@ write_recompilation_message(P, !IO) :- write_recompile_reason(ModuleName, Reason, !IO) :- recompile_reason_message(Reason, MaybeContext, ErrorPieces0), ErrorPieces = [words("Recompiling module"), - words(string__append(describe_sym_name(ModuleName), ":")), nl + words(string.append(describe_sym_name(ModuleName), ":")), nl | ErrorPieces0], write_error_pieces_maybe_with_context(MaybeContext, 0, ErrorPieces, !IO). @@ -1362,7 +1362,7 @@ recompile_reason_message(module_changed(FileName), no, [words("file"), words("`" ++ FileName ++ "'"), words("has changed.")]). recompile_reason_message(item_ambiguity(Item, AmbiguousItems), no, Pieces) :- AmbiguousItemPieces = component_lists_to_pieces( - list__map(describe_item, AmbiguousItems)), + list.map(describe_item, AmbiguousItems)), Pieces = [words("addition of ") | describe_item(Item)] ++ [words("could cause an ambiguity with")] ++ AmbiguousItemPieces ++ [suffix(".")]. @@ -1370,14 +1370,14 @@ recompile_reason_message(functor_ambiguity(SymName, Arity, Functor, AmbiguousFunctors), no, Pieces) :- FunctorPieces = describe_functor(SymName, Arity, Functor), AmbiguousFunctorPieces = component_lists_to_pieces( - list__map(describe_functor(SymName, Arity), AmbiguousFunctors)), + list.map(describe_functor(SymName, Arity), AmbiguousFunctors)), Pieces = [words("addition of ") | FunctorPieces] ++ [words("could cause an ambiguity with")] ++ AmbiguousFunctorPieces ++ [suffix(".")]. recompile_reason_message(changed_item(Item), no, - list__append(describe_item(Item), [words("was modified.")])). + list.append(describe_item(Item), [words("was modified.")])). recompile_reason_message(removed_item(Item), no, - list__append(describe_item(Item), [words("was removed.")])). + list.append(describe_item(Item), [words("was removed.")])). recompile_reason_message( changed_or_added_instance(ModuleName, ClassName - ClassArity), no, @@ -1410,7 +1410,7 @@ describe_item(item_id(ItemType0, SymName - Arity)) = Pieces :- ), string_to_item_type(ItemTypeStr, ItemType), Pieces = [ - words(string__append(BodyWords, ItemTypeStr)), + words(string.append(BodyWords, ItemTypeStr)), words(describe_sym_name_and_arity(SymName / Arity)) ]. @@ -1451,30 +1451,30 @@ describe_functor(SymName, Arity, string::in, term::out, io::di, io::uo) is det. read_term_check_for_error_or_eof(Info, Item, Term, !IO) :- - parser__read_term(TermResult, !IO), + parser.read_term(TermResult, !IO), ( TermResult = term(_, Term) ; TermResult = error(Message, Line), - io__input_stream_name(FileName, !IO), - Reason = syntax_error(term__context(FileName, Line), Message), + io.input_stream_name(FileName, !IO), + Reason = syntax_error(term.context(FileName, Line), Message), throw_syntax_error(Reason, Info) ; TermResult = eof, - io__input_stream_name(FileName, !IO), - io__get_line_number(Line, !IO), - Reason = syntax_error(term__context(FileName, Line), + io.input_stream_name(FileName, !IO), + io.get_line_number(Line, !IO), + Reason = syntax_error(term.context(FileName, Line), "unexpected end of file, expected " ++ Item ++ "."), throw_syntax_error(Reason, Info) ). -:- func get_term_context(term) = term__context. +:- func get_term_context(term) = term.context. get_term_context(Term) = - ( Term = term__functor(_, _, Context) -> + ( Term = term.functor(_, _, Context) -> Context ; - term__context_init + term.context_init ). :- pred record_recompilation_reason(recompile_reason::in, diff --git a/compiler/recompilation.m b/compiler/recompilation.m index 09262173c..dc3332168 100644 --- a/compiler/recompilation.m +++ b/compiler/recompilation.m @@ -43,9 +43,9 @@ :- import_module std_util. :- import_module term. -:- include_module recompilation__check. -:- include_module recompilation__usage. -:- include_module recompilation__version. +:- include_module recompilation.check. +:- include_module recompilation.usage. +:- include_module recompilation.version. % Identify a particular version of a program item. % This could be done using a timestamp or a hash value. @@ -125,15 +125,15 @@ :- func init_recompilation_info(module_name) = recompilation_info. - % recompilation__add_used_item(ItemType, UnqualifiedId, QualifiedId, + % recompilation.add_used_item(ItemType, UnqualifiedId, QualifiedId, % !Info). % % Record a reference to UnqualifiedId, for which QualifiedId % is the only match. If a new declaration is added so that % QualifiedId is not the only match, we need to recompile. % -:- pred recompilation__record_used_item(item_type::in, item_name::in, - item_name::in, recompilation_info::in, recompilation_info::out) is det. +:- pred record_used_item(item_type::in, item_name::in, item_name::in, + recompilation_info::in, recompilation_info::out) is det. % For each imported item we need to record which equivalence types % are used because equiv_type.m removes all references to the @@ -146,7 +146,7 @@ % of the `with_type` annotation, so that needs to be recorded % here as well. % -:- pred recompilation__record_expanded_items(item_id::in, set(item_id)::in, +:- pred record_expanded_items(item_id::in, set(item_id)::in, recompilation_info::in, recompilation_info::out) is det. %-----------------------------------------------------------------------------% @@ -267,13 +267,13 @@ term_to_version_number(Term) = term_to_timestamp(Term). -term_to_timestamp(term__functor(term__string(TimestampString), [], _)) = +term_to_timestamp(term.functor(term.string(TimestampString), [], _)) = string_to_timestamp(TimestampString). write_version_number(VersionNumber, !IO) :- - io__write_string("""", !IO), - io__write_string(timestamp_to_string(VersionNumber), !IO), - io__write_string("""", !IO). + io.write_string("""", !IO), + io.write_string(timestamp_to_string(VersionNumber), !IO), + io.write_string("""", !IO). %-----------------------------------------------------------------------------% @@ -308,8 +308,8 @@ init_item_id_set(Simple, PorF, Cons) = item_id_set(Simple, Simple, Simple, Simple, Simple, Cons, PorF, PorF, PorF). -init_used_items = item_id_set(map__init, map__init, map__init, map__init, - map__init, map__init, map__init, map__init, map__init). +init_used_items = item_id_set(map.init, map.init, map.init, map.init, + map.init, map.init, map.init, map.init, map.init). extract_simple_item_set(Items, type_item) = Items ^ types. extract_simple_item_set(Items, type_body_item) = Items ^ type_bodies. @@ -355,7 +355,7 @@ update_ids(Items, mutable_item, IdMap) = Items ^ mutables := IdMap. map_ids(Func, Items0, Init) = Items :- Items1 = init_item_id_set(Init), - Items = list__foldl( + Items = list.foldl( (func(ItemType, NewItems0) = update_ids(NewItems0, ItemType, Func(ItemType, extract_ids(Items0, ItemType))) @@ -382,11 +382,11 @@ init_recompilation_info(ModuleName) = recompilation_info( ModuleName, init_used_items, - map__init, - map__init + map.init, + map.init ). -recompilation__record_used_item(ItemType, Id, QualifiedId, !Info) :- +record_used_item(ItemType, Id, QualifiedId, !Info) :- ( % Don't record builtin items (QualifiedId may be unqualified % for predicates, functions and functors because they aren't @@ -406,35 +406,34 @@ recompilation__record_used_item(ItemType, Id, QualifiedId, !Info) :- UnqualifiedId = UnqualifiedName - Arity, Id = SymName - _, ModuleQualifier = find_module_qualifier(SymName), - ( map__search(IdSet0, UnqualifiedId, MatchingNames0) -> + ( map.search(IdSet0, UnqualifiedId, MatchingNames0) -> MatchingNames1 = MatchingNames0 ; - map__init(MatchingNames1) + map.init(MatchingNames1) ), - ( map__contains(MatchingNames1, ModuleQualifier) -> + ( map.contains(MatchingNames1, ModuleQualifier) -> true ; - map__det_insert(MatchingNames1, ModuleQualifier, + map.det_insert(MatchingNames1, ModuleQualifier, ModuleName, MatchingNames), - map__set(IdSet0, UnqualifiedId, - MatchingNames, IdSet), + map.set(IdSet0, UnqualifiedId, MatchingNames, IdSet), ItemSet = update_ids(ItemSet0, ItemType, IdSet), !:Info = !.Info ^ used_items := ItemSet ) ). -recompilation__record_expanded_items(Item, ExpandedItems, !Info) :- - ( set__empty(ExpandedItems) -> +record_expanded_items(Item, ExpandedItems, !Info) :- + ( set.empty(ExpandedItems) -> true ; DepsMap0 = !.Info ^ dependencies, - ( map__search(DepsMap0, Item, Deps0) -> + ( map.search(DepsMap0, Item, Deps0) -> Deps1 = Deps0 ; - set__init(Deps1) + set.init(Deps1) ), - set__union(Deps1, ExpandedItems, Deps), - map__set(DepsMap0, Item, Deps, DepsMap), + set.union(Deps1, ExpandedItems, Deps), + map.set(DepsMap0, Item, Deps, DepsMap), !:Info = !.Info ^ dependencies := DepsMap ). diff --git a/compiler/recompilation.usage.m b/compiler/recompilation.usage.m index 481de27f6..dddb7ab51 100644 --- a/compiler/recompilation.usage.m +++ b/compiler/recompilation.usage.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2001-2005 University of Melbourne. +% Copyright (C) 2001-2006 University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module recompilation__usage. +:- module recompilation.usage. :- interface. :- import_module hlds.hlds_module. @@ -117,30 +117,30 @@ write_usage_file(ModuleInfo, NestedSubModules, MaybeRecompInfo = yes(RecompInfo), MaybeTimestamps = yes(Timestamps) -> - globals__io_lookup_bool_option(verbose, Verbose, !IO), + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Writing recompilation compilation dependency information\n", !IO), module_info_get_name(ModuleInfo, ModuleName), module_name_to_file_name(ModuleName, ".used", yes, FileName, !IO), - io__open_output(FileName, FileResult, !IO), + io.open_output(FileName, FileResult, !IO), ( FileResult = ok(Stream0), - io__set_output_stream(Stream0, OldStream, !IO), + io.set_output_stream(Stream0, OldStream, !IO), write_usage_file_2(ModuleInfo, NestedSubModules, RecompInfo, Timestamps, !IO), - io__set_output_stream(OldStream, Stream, !IO), - io__close_output(Stream, !IO) + io.set_output_stream(OldStream, Stream, !IO), + io.close_output(Stream, !IO) ; FileResult = error(IOError), - io__error_message(IOError, IOErrorMessage), - io__write_string("\nError opening `", !IO), - io__write_string(FileName, !IO), - io__write_string("'for output: ", !IO), - io__write_string(IOErrorMessage, !IO), - io__write_string(".\n", !IO), - io__set_exit_status(1, !IO) + io.error_message(IOError, IOErrorMessage), + io.write_string("\nError opening `", !IO), + io.write_string(FileName, !IO), + io.write_string("'for output: ", !IO), + io.write_string(IOErrorMessage, !IO), + io.write_string(".\n", !IO), + io.set_exit_status(1, !IO) ) ; true @@ -152,29 +152,29 @@ write_usage_file(ModuleInfo, NestedSubModules, write_usage_file_2(ModuleInfo, NestedSubModules, RecompInfo, Timestamps, !IO) :- - io__write_int(usage_file_version_number, !IO), - io__write_string(",", !IO), - io__write_int(version_numbers_version_number, !IO), - io__write_string(".\n\n", !IO), + io.write_int(usage_file_version_number, !IO), + io.write_string(",", !IO), + io.write_int(version_numbers_version_number, !IO), + io.write_string(".\n\n", !IO), module_info_get_name(ModuleInfo, ThisModuleName), - map__lookup(Timestamps, ThisModuleName, + map.lookup(Timestamps, ThisModuleName, module_timestamp(_, ThisModuleTimestamp, _)), - io__write_string("(", !IO), + io.write_string("(", !IO), mercury_output_bracketed_sym_name(ThisModuleName, !IO), - io__write_string(", "".m"", ", !IO), + io.write_string(", "".m"", ", !IO), write_version_number(ThisModuleTimestamp, !IO), - io__write_string(").\n\n", !IO), + io.write_string(").\n\n", !IO), ( NestedSubModules = [], - io__write_string("sub_modules.\n\n", !IO) + io.write_string("sub_modules.\n\n", !IO) ; NestedSubModules = [_ | _], - io__write_string("sub_modules(", !IO), - io__write_list(NestedSubModules, ", ", + io.write_string("sub_modules(", !IO), + io.write_list(NestedSubModules, ", ", mercury_output_bracketed_sym_name, !IO), - io__write_string(").\n\n", !IO) + io.write_string(").\n\n", !IO) ), UsedItems = RecompInfo ^ used_items, @@ -183,9 +183,9 @@ write_usage_file_2(ModuleInfo, NestedSubModules, UsedClasses, ImportedItems, ModuleInstances), ( UsedItems = init_used_items -> - io__write_string("used_items.\n", !IO) + io.write_string("used_items.\n", !IO) ; - io__write_string("used_items(\n\t", !IO), + io.write_string("used_items(\n\t", !IO), some [!WriteComma] ( !:WriteComma = no, write_simple_item_matches(type_item, ResolvedUsedItems, @@ -206,25 +206,25 @@ write_usage_file_2(ModuleInfo, NestedSubModules, !WriteComma, !IO), _ = !.WriteComma ), - io__write_string("\n).\n\n", !IO) + io.write_string("\n).\n\n", !IO) ), - ( set__empty(UsedClasses) -> - io__write_string("used_classes.\n", !IO) + ( set.empty(UsedClasses) -> + io.write_string("used_classes.\n", !IO) ; - io__write_string("used_classes(", !IO), - io__write_list(set__to_sorted_list(UsedClasses), ", ", + io.write_string("used_classes(", !IO), + io.write_list(set.to_sorted_list(UsedClasses), ", ", write_classname_and_arity, !IO), - io__write_string(").\n", !IO) + io.write_string(").\n", !IO) ), - map__foldl(write_module_name_and_used_items(RecompInfo, Timestamps, + map.foldl(write_module_name_and_used_items(RecompInfo, Timestamps, ModuleInstances), ImportedItems, !IO), % recompilation_check.m checks for this item when reading in the `.used' % file to make sure the earlier compilation wasn't interrupted in the % middle of writing the file. - io__nl(!IO), - io__write_string("done.\n", !IO). + io.nl(!IO), + io.write_string("done.\n", !IO). :- pred write_module_name_and_used_items(recompilation_info::in, module_timestamps::in, map(module_name, set(item_name))::in, @@ -233,25 +233,25 @@ write_usage_file_2(ModuleInfo, NestedSubModules, write_module_name_and_used_items(RecompInfo, Timestamps, ModuleInstances, ModuleName, ModuleUsedItems, !IO) :- - io__nl(!IO), - io__write_string("(", !IO), + io.nl(!IO), + io.write_string("(", !IO), mercury_output_bracketed_sym_name(ModuleName, !IO), - io__write_string(", """, !IO), - map__lookup(Timestamps, ModuleName, + io.write_string(", """, !IO), + map.lookup(Timestamps, ModuleName, module_timestamp(Suffix, ModuleTimestamp, NeedQualifier)), - io__write_string(Suffix, !IO), - io__write_string(""", ", !IO), + io.write_string(Suffix, !IO), + io.write_string(""", ", !IO), write_version_number(ModuleTimestamp, !IO), ( NeedQualifier = must_be_qualified -> - io__write_string(", used)", !IO) + io.write_string(", used)", !IO) ; - io__write_string(")", !IO) + io.write_string(")", !IO) ), ( % XXX We don't yet record all uses of items from these modules % in polymorphism.m, etc. \+ any_mercury_builtin_module(ModuleName), - map__search(RecompInfo ^ version_numbers, ModuleName, ModuleVersions) + map.search(RecompInfo ^ version_numbers, ModuleName, ModuleVersions) -> % Select out from the version numbers of all items in the imported % module the ones which are used. @@ -260,28 +260,26 @@ write_module_name_and_used_items(RecompInfo, Timestamps, ModuleInstances, ModuleUsedItemVersions = map_ids( (func(ItemType, Ids0) = Ids :- ModuleItemNames = extract_ids(ModuleUsedItems, ItemType), - map__select(Ids0, ModuleItemNames, Ids) + map.select(Ids0, ModuleItemNames, Ids) ), - ModuleItemVersions, map__init), - ( - map__search(ModuleInstances, ModuleName, ModuleUsedInstances) - -> - map__select(ModuleInstanceVersions, ModuleUsedInstances, + ModuleItemVersions, map.init), + ( map.search(ModuleInstances, ModuleName, ModuleUsedInstances) -> + map.select(ModuleInstanceVersions, ModuleUsedInstances, ModuleUsedInstanceVersions) ; - map__init(ModuleUsedInstanceVersions) + map.init(ModuleUsedInstanceVersions) ), - io__write_string(" => ", !IO), + io.write_string(" => ", !IO), ModuleUsedVersionNumbers = version_numbers(ModuleUsedItemVersions, ModuleUsedInstanceVersions), write_version_numbers(ModuleUsedVersionNumbers, !IO), - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ; % If we don't have version numbers for a module we just recompile % if the interface file's timestamp changes. - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ). :- pred write_classname_and_arity(pair(class_name, arity)::in, @@ -289,15 +287,15 @@ write_module_name_and_used_items(RecompInfo, Timestamps, ModuleInstances, write_classname_and_arity(ClassName - ClassArity, !IO) :- mercury_output_bracketed_sym_name(ClassName, !IO), - io__write_string("/", !IO), - io__write_int(ClassArity, !IO). + io.write_string("/", !IO), + io.write_int(ClassArity, !IO). :- pred write_comma_if_needed(bool::in, bool::out, io::di, io::uo) is det. write_comma_if_needed(!WriteComma, !IO) :- ( !.WriteComma = yes, - io__write_string(",\n\t", !IO) + io.write_string(",\n\t", !IO) ; !.WriteComma = no ), @@ -308,7 +306,7 @@ write_comma_if_needed(!WriteComma, !IO) :- write_simple_item_matches(ItemType, UsedItems, !WriteComma, !IO) :- Ids = extract_simple_item_set(UsedItems, ItemType), - ( map__is_empty(Ids) -> + ( map.is_empty(Ids) -> true ; write_comma_if_needed(!WriteComma, !IO), @@ -320,11 +318,11 @@ write_simple_item_matches(ItemType, UsedItems, !WriteComma, !IO) :- write_simple_item_matches_2(ItemType, ItemSet, !IO) :- string_to_item_type(ItemTypeStr, ItemType), - io__write_string(ItemTypeStr, !IO), - io__write_string("(\n\t\t", !IO), - map__to_assoc_list(ItemSet, ItemList), - io__write_list(ItemList, ",\n\t\t", write_simple_item_matches_3, !IO), - io__write_string("\n\t)", !IO). + io.write_string(ItemTypeStr, !IO), + io.write_string("(\n\t\t", !IO), + map.to_assoc_list(ItemSet, ItemList), + io.write_list(ItemList, ",\n\t\t", write_simple_item_matches_3, !IO), + io.write_string("\n\t)", !IO). :- pred write_simple_item_matches_3( pair(pair(string, arity), map(module_qualifier, module_name))::in, @@ -333,12 +331,12 @@ write_simple_item_matches_2(ItemType, ItemSet, !IO) :- write_simple_item_matches_3((Name - Arity) - Matches, !IO) :- mercury_output_bracketed_sym_name(unqualified(Name), next_to_graphic_token, !IO), - io__write_string("/", !IO), - io__write_int(Arity, !IO), - io__write_string(" - (", !IO), - map__to_assoc_list(Matches, MatchList), - io__write_list(MatchList, ", ", write_simple_item_matches_4, !IO), - io__write_string(")", !IO). + io.write_string("/", !IO), + io.write_int(Arity, !IO), + io.write_string(" - (", !IO), + map.to_assoc_list(Matches, MatchList), + io.write_list(MatchList, ", ", write_simple_item_matches_4, !IO), + io.write_string(")", !IO). :- pred write_simple_item_matches_4(pair(module_qualifier, module_name)::in, io::di, io::uo) is det. @@ -348,7 +346,7 @@ write_simple_item_matches_4(Qualifier - ModuleName, !IO) :- ( Qualifier = ModuleName -> true ; - io__write_string(" => ", !IO), + io.write_string(" => ", !IO), mercury_output_bracketed_sym_name(ModuleName, !IO) ). @@ -358,7 +356,7 @@ write_simple_item_matches_4(Qualifier - ModuleName, !IO) :- write_pred_or_func_matches(ItemType, UsedItems, !WriteComma, !IO) :- Ids = extract_pred_or_func_set(UsedItems, ItemType), - ( map__is_empty(Ids) -> + ( map.is_empty(Ids) -> true ; write_comma_if_needed(!WriteComma, !IO), @@ -377,22 +375,22 @@ write_pred_or_func_matches_2(ItemType, ItemSet, !IO) :- io::di, io::uo) is det. write_pred_or_func_matches_3(Qualifier - PredIdModuleNames, !IO) :- - ModuleNames = assoc_list__values(set__to_sorted_list(PredIdModuleNames)), + ModuleNames = assoc_list.values(set.to_sorted_list(PredIdModuleNames)), mercury_output_bracketed_sym_name(Qualifier, !IO), ( ModuleNames = [Qualifier] -> true ; - io__write_string(" => (", !IO), - io__write_list(ModuleNames, ", ", mercury_output_bracketed_sym_name, + io.write_string(" => (", !IO), + io.write_list(ModuleNames, ", ", mercury_output_bracketed_sym_name, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ). :- pred write_functor_matches(resolved_functor_set::in, bool::in, bool::out, io::di, io::uo) is det. write_functor_matches(Ids, !WriteComma, !IO) :- - ( map__is_empty(Ids) -> + ( map.is_empty(Ids) -> true ; write_comma_if_needed(!WriteComma, !IO), @@ -405,10 +403,10 @@ write_functor_matches(Ids, !WriteComma, !IO) :- write_functor_matches_2(Qualifier - MatchingCtors, !IO) :- mercury_output_bracketed_sym_name(Qualifier, !IO), - io__write_string(" => (", !IO), - io__write_list(set__to_sorted_list(MatchingCtors), ", ", + io.write_string(" => (", !IO), + io.write_list(set.to_sorted_list(MatchingCtors), ", ", write_resolved_functor, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). :- type write_resolved_item(T) == pred(pair(module_qualifier, T), io, io). :- inst write_resolved_item == (pred(in, di, uo) is det). @@ -419,12 +417,12 @@ write_functor_matches_2(Qualifier - MatchingCtors, !IO) :- write_resolved_item_set(ItemType, ItemSet, WriteMatches, !IO) :- string_to_item_type(ItemTypeStr, ItemType), - io__write_string(ItemTypeStr, !IO), - io__write_string("(\n\t\t", !IO), - map__to_assoc_list(ItemSet, ItemList), - io__write_list(ItemList, ",\n\t\t", + io.write_string(ItemTypeStr, !IO), + io.write_string("(\n\t\t", !IO), + map.to_assoc_list(ItemSet, ItemList), + io.write_list(ItemList, ",\n\t\t", write_resolved_item_set_2(WriteMatches), !IO), - io__write_string("\n\t)", !IO). + io.write_string("\n\t)", !IO). :- pred write_resolved_item_set_2( write_resolved_item(T)::in(write_resolved_item), @@ -433,48 +431,48 @@ write_resolved_item_set(ItemType, ItemSet, WriteMatches, !IO) :- write_resolved_item_set_2(WriteMatches, Name - MatchesAL, !IO) :- mercury_output_bracketed_sym_name(unqualified(Name), !IO), - io__write_string(" - (", !IO), - io__write_list(MatchesAL, ",\n\t\t\t", + io.write_string(" - (", !IO), + io.write_list(MatchesAL, ",\n\t\t\t", write_resolved_item_set_3(WriteMatches), !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). :- pred write_resolved_item_set_3( write_resolved_item(T)::in(write_resolved_item), pair(int, map(sym_name, T))::in, io::di, io::uo) is det. write_resolved_item_set_3(WriteMatches, Arity - Matches, !IO) :- - io__write_int(Arity, !IO), - io__write_string(" - (", !IO), - map__to_assoc_list(Matches, MatchList), - io__write_list(MatchList, ",\n\t\t\t\t", WriteMatches, !IO), - io__write_string(")", !IO). + io.write_int(Arity, !IO), + io.write_string(" - (", !IO), + map.to_assoc_list(Matches, MatchList), + io.write_list(MatchList, ",\n\t\t\t\t", WriteMatches, !IO), + io.write_string(")", !IO). :- pred write_resolved_functor(resolved_functor::in, io::di, io::uo) is det. write_resolved_functor(pred_or_func(_, ModuleName, PredOrFunc, Arity), !IO) :- - io__write(PredOrFunc, !IO), - io__write_string("(", !IO), + io.write(PredOrFunc, !IO), + io.write_string("(", !IO), mercury_output_bracketed_sym_name(ModuleName, !IO), - io__write_string(", ", !IO), - io__write_int(Arity, !IO), - io__write_string(")", !IO). + io.write_string(", ", !IO), + io.write_int(Arity, !IO), + io.write_string(")", !IO). write_resolved_functor(constructor(TypeName - Arity), !IO) :- - io__write_string("ctor(", !IO), + io.write_string("ctor(", !IO), mercury_output_bracketed_sym_name(TypeName, next_to_graphic_token, !IO), - io__write_string("/", !IO), - io__write_int(Arity, !IO), - io__write_string(")", !IO). + io.write_string("/", !IO), + io.write_int(Arity, !IO), + io.write_string(")", !IO). write_resolved_functor(field(TypeName - TypeArity, ConsName - ConsArity), !IO) :- - io__write_string("field(", !IO), + io.write_string("field(", !IO), mercury_output_bracketed_sym_name(TypeName, next_to_graphic_token, !IO), - io__write_string("/", !IO), - io__write_int(TypeArity, !IO), - io__write_string(", ", !IO), + io.write_string("/", !IO), + io.write_int(TypeArity, !IO), + io.write_string(", ", !IO), mercury_output_bracketed_sym_name(ConsName, next_to_graphic_token, !IO), - io__write_string("/", !IO), - io__write_int(ConsArity, !IO), - io__write_string(")", !IO). + io.write_string("/", !IO), + io.write_int(ConsArity, !IO), + io.write_string(")", !IO). usage_file_version_number = 2. @@ -515,8 +513,8 @@ visible_modules(ModuleInfo, VisibleModule) :- imported_items::in, imported_items::out) is det. insert_into_imported_items_map(VisibleModule, !ImportedItemsMap) :- - ModuleItems = init_item_id_set(set__init), - svmap__det_insert(VisibleModule, ModuleItems, !ImportedItemsMap). + ModuleItems = init_item_id_set(set.init), + svmap.det_insert(VisibleModule, ModuleItems, !ImportedItemsMap). % Go over the set of imported items found to be used and % find the transitive closure of the imported items they use. @@ -533,22 +531,22 @@ find_all_used_imported_items(ModuleInfo, % file, even if nothing was used from it. This will cause % recompilation_check.m to check for new items causing ambiguity % when the interface of the module changes. - map__init(ImportedItems0), + map.init(ImportedItems0), promise_equivalent_solutions [ImportedItems1] ( - std_util__unsorted_aggregate(visible_modules(ModuleInfo), + std_util.unsorted_aggregate(visible_modules(ModuleInfo), insert_into_imported_items_map, ImportedItems0, ImportedItems1) ), - queue__init(ItemsToProcess0), - map__init(ModuleUsedClasses), - set__init(UsedClasses0), + queue.init(ItemsToProcess0), + map.init(ModuleUsedClasses), + set.init(UsedClasses0), UsedItems = item_id_set(Types, TypeBodies, Modes, Insts, Classes, _, _, _, _), - map__init(ResolvedCtors), - map__init(ResolvedPreds), - map__init(ResolvedFuncs), - map__init(ResolvedMutables), + map.init(ResolvedCtors), + map.init(ResolvedPreds), + map.init(ResolvedFuncs), + map.init(ResolvedMutables), ResolvedUsedItems0 = item_id_set(Types, TypeBodies, Modes, Insts, Classes, ResolvedCtors, ResolvedPreds, ResolvedFuncs, ResolvedMutables), @@ -572,7 +570,7 @@ find_all_used_imported_items_2(UsedItems, !Info) :- % Find items used by imported instances for local classes. ModuleInfo = !.Info ^ module_info, module_info_get_instance_table(ModuleInfo, Instances), - map__foldl(find_items_used_by_instances, Instances, !Info), + map.foldl(find_items_used_by_instances, Instances, !Info), Predicates = UsedItems ^ predicates, find_items_used_by_preds(predicate, Predicates, !Info), @@ -605,10 +603,10 @@ find_all_used_imported_items_2(UsedItems, !Info) :- process_imported_item_queue(!Info) :- Queue0 = !.Info ^ item_queue, - !:Info = !.Info ^ item_queue := queue__init, + !:Info = !.Info ^ item_queue := queue.init, process_imported_item_queue_2(Queue0, !Info), Queue = !.Info ^ item_queue, - ( queue__is_empty(Queue) -> + ( queue.is_empty(Queue) -> true ; process_imported_item_queue(!Info) @@ -619,7 +617,7 @@ process_imported_item_queue(!Info) :- recompilation_usage_info::in, recompilation_usage_info::out) is det. process_imported_item_queue_2(Queue0, !Info) :- - ( queue__get(Queue0, Item, Queue) -> + ( queue.get(Queue0, Item, Queue) -> Item = item_id(ItemType, ItemId), find_items_used_by_item(ItemType, ItemId, !Info), process_imported_item_queue_2(Queue, !Info) @@ -660,15 +658,15 @@ do_record_used_pred_or_func(PredOrFunc, ModuleQualifier, OrigArity, MatchingPredIds) -> Recorded = yes, - PredModules = set__list_to_set(list__map( + PredModules = set.list_to_set(list.map( (func(PredId) = PredId - PredModule :- module_info_pred_info(ModuleInfo, PredId, PredInfo), PredModule = pred_info_module(PredInfo) ), MatchingPredIds)), - svmap__det_insert(ModuleQualifier, PredModules, !MatchingNames), + svmap.det_insert(ModuleQualifier, PredModules, !MatchingNames), unqualify_name(SymName, Name), - set__fold(find_items_used_by_pred(PredOrFunc, Name - Arity), + set.fold(find_items_used_by_pred(PredOrFunc, Name - Arity), PredModules, !Info) ; Recorded = no @@ -698,13 +696,13 @@ do_record_used_functor(ModuleQualifier, SymName, Arity, Recorded, find_matching_functors(ModuleInfo, SymName, Arity, MatchingCtors), unqualify_name(SymName, Name), - set__fold(find_items_used_by_functor(Name, Arity), MatchingCtors, !Info), + set.fold(find_items_used_by_functor(Name, Arity), MatchingCtors, !Info), - ( set__empty(MatchingCtors) -> + ( set.empty(MatchingCtors) -> Recorded = no ; Recorded = yes, - svmap__det_insert(ModuleQualifier, MatchingCtors, !ResolvedCtorMap) + svmap.det_insert(ModuleQualifier, MatchingCtors, !ResolvedCtorMap) ). :- pred find_matching_functors(module_info::in, @@ -713,21 +711,21 @@ do_record_used_functor(ModuleQualifier, SymName, Arity, Recorded, find_matching_functors(ModuleInfo, SymName, Arity, ResolvedConstructors) :- % Is it a constructor. module_info_get_cons_table(ModuleInfo, Ctors), - ( map__search(Ctors, cons(SymName, Arity), ConsDefns0) -> + ( map.search(Ctors, cons(SymName, Arity), ConsDefns0) -> ConsDefns1 = ConsDefns0 ; ConsDefns1 = [] ), ( remove_new_prefix(SymName, SymNameMinusNew), - map__search(Ctors, cons(SymNameMinusNew, Arity), ConsDefns2) + map.search(Ctors, cons(SymNameMinusNew, Arity), ConsDefns2) -> - ConsDefns = list__append(ConsDefns1, ConsDefns2) + ConsDefns = list.append(ConsDefns1, ConsDefns2) ; ConsDefns = ConsDefns1 ), MatchingConstructors = - list__map( + list.map( (func(ConsDefn) = Ctor :- ConsDefn = hlds_cons_defn(_,_,_, TypeCtor, _), Ctor = constructor(TypeCtor) @@ -740,7 +738,7 @@ find_matching_functors(ModuleInfo, SymName, Arity, ResolvedConstructors) :- predicate_table_search_sym(PredicateTable, may_be_partially_qualified, SymName, PredIds) -> - MatchingPreds = list__filter_map( + MatchingPreds = list.filter_map( get_pred_or_func_ctors(ModuleInfo, SymName, Arity), PredIds) @@ -753,9 +751,9 @@ find_matching_functors(ModuleInfo, SymName, Arity, ResolvedConstructors) :- is_field_access_function_name(ModuleInfo, SymName, Arity, _, FieldName), module_info_get_ctor_field_table(ModuleInfo, CtorFields), - map__search(CtorFields, FieldName, FieldDefns) + map.search(CtorFields, FieldName, FieldDefns) -> - MatchingFields = list__map( + MatchingFields = list.map( (func(FieldDefn) = FieldCtor :- FieldDefn = hlds_ctor_field_defn(_, _, TypeCtor, ConsId, _), ( ConsId = cons(ConsName, ConsArity) -> @@ -767,10 +765,8 @@ find_matching_functors(ModuleInfo, SymName, Arity, ResolvedConstructors) :- ; MatchingFields = [] ), - - ResolvedConstructors = set__list_to_set(list__condense( - [MatchingConstructors, MatchingPreds, MatchingFields]) - ). + ResolvedConstructors = set.list_to_set(list.condense( + [MatchingConstructors, MatchingPreds, MatchingFields])). :- func get_pred_or_func_ctors(module_info, sym_name, arity, pred_id) = resolved_functor is semidet. @@ -817,7 +813,7 @@ get_pred_or_func_ctors(ModuleInfo, _SymName, Arity, PredId) = ResolvedCtor :- record_resolved_item(SymName, Arity, RecordItem, !IdSet, !Info) :- unqualify_name(SymName, UnqualifiedName), ModuleQualifier = find_module_qualifier(SymName), - ( map__search(!.IdSet, UnqualifiedName, MatchingNames0) -> + ( map.search(!.IdSet, UnqualifiedName, MatchingNames0) -> MatchingNames1 = MatchingNames0 ; MatchingNames1 = [] @@ -826,7 +822,7 @@ record_resolved_item(SymName, Arity, RecordItem, !IdSet, !Info) :- Recorded, MatchingNames1, MatchingNames, !Info), ( Recorded = yes, - svmap__set(UnqualifiedName, MatchingNames, !IdSet) + svmap.set(UnqualifiedName, MatchingNames, !IdSet) ; Recorded = no ). @@ -839,7 +835,7 @@ record_resolved_item(SymName, Arity, RecordItem, !IdSet, !Info) :- record_resolved_item_2(ModuleQualifier, SymName, Arity, RecordItem, Recorded, !List, !Info) :- !.List = [], - map__init(Map0), + map.init(Map0), record_resolved_item_3(ModuleQualifier, SymName, Arity, RecordItem, Recorded, Map0, Map, !Info), ( @@ -852,7 +848,7 @@ record_resolved_item_2(ModuleQualifier, SymName, Arity, RecordItem, Recorded, !List, !Info) :- !.List = [ThisArity - ArityMap0 | ListRest0], ( Arity < ThisArity -> - map__init(NewArityMap0), + map.init(NewArityMap0), record_resolved_item_3(ModuleQualifier, SymName, Arity, RecordItem, Recorded, NewArityMap0, NewArityMap, !Info), ( @@ -888,7 +884,7 @@ record_resolved_item_2(ModuleQualifier, SymName, Arity, RecordItem, Recorded, record_resolved_item_3(ModuleQualifier, SymName, Arity, RecordItem, Recorded, !ResolvedMap, !Info) :- - ( map__contains(!.ResolvedMap, ModuleQualifier) -> + ( map.contains(!.ResolvedMap, ModuleQualifier) -> Recorded = no ; RecordItem(ModuleQualifier, SymName, Arity, Recorded, @@ -903,8 +899,8 @@ record_resolved_item_3(ModuleQualifier, SymName, Arity, RecordItem, Recorded, find_items_used_by_item(type_item, TypeCtor, !Info) :- ModuleInfo = !.Info ^ module_info, module_info_get_type_table(ModuleInfo, Types), - map__lookup(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.lookup(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), ( TypeBody = eqv_type(Type) -> % If we use an equivalence type we also use the type % it is equivalent to. @@ -915,28 +911,28 @@ find_items_used_by_item(type_item, TypeCtor, !Info) :- find_items_used_by_item(type_body_item, TypeCtor, !Info) :- ModuleInfo = !.Info ^ module_info, module_info_get_type_table(ModuleInfo, Types), - map__lookup(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.lookup(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), find_items_used_by_type_body(TypeBody, !Info). find_items_used_by_item(mode_item, ModeId, !Info):- ModuleInfo = !.Info ^ module_info, module_info_get_mode_table(ModuleInfo, Modes), mode_table_get_mode_defns(Modes, ModeDefns), - map__lookup(ModeDefns, ModeId, ModeDefn), + map.lookup(ModeDefns, ModeId, ModeDefn), find_items_used_by_mode_defn(ModeDefn, !Info). find_items_used_by_item(inst_item, InstId, !Info):- ModuleInfo = !.Info ^ module_info, module_info_get_inst_table(ModuleInfo, Insts), inst_table_get_user_insts(Insts, UserInsts), user_inst_table_get_inst_defns(UserInsts, UserInstDefns), - map__lookup(UserInstDefns, InstId, InstDefn), + map.lookup(UserInstDefns, InstId, InstDefn), find_items_used_by_inst_defn(InstDefn, !Info). find_items_used_by_item(typeclass_item, ClassItemId, !Info) :- ClassItemId = ClassName - ClassArity, ClassId = class_id(ClassName, ClassArity), ModuleInfo = !.Info ^ module_info, module_info_get_class_table(ModuleInfo, Classes), - map__lookup(Classes, ClassId, ClassDefn), + map.lookup(Classes, ClassId, ClassDefn), Constraints = ClassDefn ^ class_supers, ClassInterface = ClassDefn ^ class_interface, find_items_used_by_class_constraints(Constraints, !Info), @@ -944,11 +940,11 @@ find_items_used_by_item(typeclass_item, ClassItemId, !Info) :- ClassInterface = abstract ; ClassInterface = concrete(Methods), - list__foldl(find_items_used_by_class_method, Methods, !Info) + list.foldl(find_items_used_by_class_method, Methods, !Info) ), module_info_get_instance_table(ModuleInfo, Instances), - ( map__search(Instances, ClassId, InstanceDefns) -> - list__foldl(find_items_used_by_instance(ClassItemId), InstanceDefns, + ( map.search(Instances, ClassId, InstanceDefns) -> + list.foldl(find_items_used_by_instance(ClassItemId), InstanceDefns, !Info) ; true @@ -973,7 +969,7 @@ find_items_used_by_instances(ClassId, InstanceDefns, !Info) :- NameArity = Name - Arity, ( item_is_local(!.Info, NameArity) -> record_expanded_items_used_by_item(typeclass_item, NameArity, !Info), - list__foldl(find_items_used_by_instance(NameArity), InstanceDefns, + list.foldl(find_items_used_by_instance(NameArity), InstanceDefns, !Info) ; true @@ -995,13 +991,13 @@ find_items_used_by_instance(ClassId, Defn, !Info) :- find_items_used_by_class_constraints(Constraints, !Info), find_items_used_by_types(ArgTypes, !Info), ModuleInstances0 = !.Info ^ module_instances, - ( map__search(ModuleInstances0, InstanceModuleName, ClassIdsPrime) -> + ( map.search(ModuleInstances0, InstanceModuleName, ClassIdsPrime) -> ClassIds1 = ClassIdsPrime ; - set__init(ClassIds1) + set.init(ClassIds1) ), - set__insert(ClassIds1, ClassId, ClassIds), - map__set(ModuleInstances0, InstanceModuleName, ClassIds, + set.insert(ClassIds1, ClassId, ClassIds), + map.set(ModuleInstances0, InstanceModuleName, ClassIds, ModuleInstances), !:Info = !.Info ^ module_instances := ModuleInstances ). @@ -1013,7 +1009,7 @@ find_items_used_by_class_method(Method, !Info) :- Method = pred_or_func(_, _, _, _, _, ArgTypesAndModes, _, _, _, _, _, Constraints, _), find_items_used_by_class_context(Constraints, !Info), - list__foldl(find_items_used_by_type_and_mode, ArgTypesAndModes, !Info). + list.foldl(find_items_used_by_type_and_mode, ArgTypesAndModes, !Info). find_items_used_by_class_method(Method, !Info) :- Method = pred_or_func_mode(_, _, _, Modes, _, _, _, _), find_items_used_by_modes(Modes, !Info). @@ -1035,7 +1031,7 @@ find_items_used_by_type_and_mode(TypeAndMode, !Info) :- find_items_used_by_type_body(TypeBody, !Info) :- Ctors = TypeBody ^ du_type_ctors, - list__foldl(find_items_used_by_ctor, Ctors, !Info). + list.foldl(find_items_used_by_ctor, Ctors, !Info). find_items_used_by_type_body(eqv_type(Type), !Info) :- find_items_used_by_type(Type, !Info). find_items_used_by_type_body(abstract_type(_), !Info). @@ -1049,7 +1045,7 @@ find_items_used_by_type_body(solver_type(_, _), !Info). find_items_used_by_ctor(Ctor, !Info) :- Ctor = ctor(_, Constraints, _, CtorArgs), find_items_used_by_class_constraints(Constraints, !Info), - list__foldl(find_items_used_by_ctor_arg, CtorArgs, !Info). + list.foldl(find_items_used_by_ctor_arg, CtorArgs, !Info). :- pred find_items_used_by_ctor_arg(constructor_arg::in, recompilation_usage_info::in, recompilation_usage_info::out) is det. @@ -1081,14 +1077,14 @@ find_items_used_by_inst_defn(Defn, !Info) :- recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_preds(PredOrFunc, Set, !Info) :- - map__foldl(find_items_used_by_preds_2(PredOrFunc), Set, !Info). + map.foldl(find_items_used_by_preds_2(PredOrFunc), Set, !Info). :- pred find_items_used_by_preds_2(pred_or_func::in, pair(string, arity)::in, map(module_qualifier, module_name)::in, recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_preds_2(PredOrFunc, Name - Arity, MatchingPredMap, !Info) :- - map__foldl(find_items_used_by_preds_3( + map.foldl(find_items_used_by_preds_3( PredOrFunc, Name, Arity), MatchingPredMap, !Info). :- pred find_items_used_by_preds_3(pred_or_func::in, @@ -1133,7 +1129,7 @@ find_items_used_by_pred(PredOrFunc, Name - Arity, PredId - PredModule, MethodUnivConstraints = [constraint(ClassName0, ClassArgs) | _] -> ClassName = ClassName0, - ClassArity = list__length(ClassArgs) + ClassArity = list.length(ClassArgs) ; unexpected(this_file, "class method with no class constraints") ), @@ -1146,15 +1142,15 @@ find_items_used_by_pred(PredOrFunc, Name - Arity, PredId - PredModule, pred_info_arg_types(PredInfo, ArgTypes), find_items_used_by_types(ArgTypes, !Info), pred_info_procedures(PredInfo, Procs), - map__foldl(find_items_used_by_proc_arg_modes, Procs, !Info), + map.foldl(find_items_used_by_proc_arg_modes, Procs, !Info), pred_info_get_class_context(PredInfo, ClassContext), find_items_used_by_class_context(ClassContext, !Info), % Record items used by `:- pragma type_spec' declarations. module_info_get_type_spec_info(ModuleInfo, TypeSpecInfo), TypeSpecInfo = type_spec_info(_, _, _, PragmaMap), - ( map__search(PragmaMap, PredId, TypeSpecPragmas) -> - list__foldl(find_items_used_by_type_spec, TypeSpecPragmas, !Info) + ( map.search(PragmaMap, PredId, TypeSpecPragmas) -> + list.foldl(find_items_used_by_type_spec, TypeSpecPragmas, !Info) ; true ) @@ -1178,7 +1174,7 @@ find_items_used_by_type_spec(Pragma, !Info) :- ; MaybeModes = no ), - assoc_list__values(Subst, SubstTypes), + assoc_list.values(Subst, SubstTypes), find_items_used_by_types(SubstTypes, !Info) ; unexpected(this_file, @@ -1189,14 +1185,14 @@ find_items_used_by_type_spec(Pragma, !Info) :- recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_functors(Set, !Info) :- - map__foldl(find_items_used_by_functors_2, Set, !Info). + map.foldl(find_items_used_by_functors_2, Set, !Info). :- pred find_items_used_by_functors_2(pair(string, arity)::in, map(module_qualifier, module_name)::in, recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_functors_2(Name - Arity, MatchingCtorMap, !Info) :- - map__foldl(find_items_used_by_functors_3(Name, Arity), MatchingCtorMap, + map.foldl(find_items_used_by_functors_3(Name, Arity), MatchingCtorMap, !Info). :- pred find_items_used_by_functors_3(string::in, arity::in, @@ -1225,7 +1221,7 @@ find_items_used_by_functor(_, _, ResolverFunctor, !Info) :- recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_simple_item_set(ItemType, Set, !Info) :- - map__foldl(find_items_used_by_simple_item_set_2(ItemType), Set, !Info). + map.foldl(find_items_used_by_simple_item_set_2(ItemType), Set, !Info). :- pred find_items_used_by_simple_item_set_2(item_type::in, pair(string, arity)::in, map(module_qualifier, module_name)::in, @@ -1233,7 +1229,7 @@ find_items_used_by_simple_item_set(ItemType, Set, !Info) :- find_items_used_by_simple_item_set_2(ItemType, Name - Arity, MatchingIdMap, !Info) :- - map__foldl(find_items_used_by_simple_item_set_3(ItemType, Name, Arity), + map.foldl(find_items_used_by_simple_item_set_3(ItemType, Name, Arity), MatchingIdMap, !Info). :- pred find_items_used_by_simple_item_set_3(item_type::in, @@ -1249,7 +1245,7 @@ find_items_used_by_simple_item_set_3(ItemType, Name, Arity, _, Module, recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_types(Types, !Info) :- - list__foldl(find_items_used_by_type, Types, !Info). + list.foldl(find_items_used_by_type, Types, !Info). :- pred find_items_used_by_type(mer_type::in, recompilation_usage_info::in, recompilation_usage_info::out) is det. @@ -1274,7 +1270,7 @@ find_items_used_by_type(Type, !Info) :- recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_modes(Modes, !Info) :- - list__foldl(find_items_used_by_mode, Modes, !Info). + list.foldl(find_items_used_by_mode, Modes, !Info). :- pred find_items_used_by_mode(mer_mode::in, recompilation_usage_info::in, recompilation_usage_info::out) is det. @@ -1283,7 +1279,7 @@ find_items_used_by_mode((Inst1 -> Inst2), !Info) :- find_items_used_by_inst(Inst1, !Info), find_items_used_by_inst(Inst2, !Info). find_items_used_by_mode(user_defined_mode(ModeName, ArgInsts), !Info) :- - list__length(ArgInsts, ModeArity), + list.length(ArgInsts, ModeArity), maybe_record_item_to_process(mode_item, ModeName - ModeArity, !Info), find_items_used_by_insts(ArgInsts, !Info). @@ -1291,7 +1287,7 @@ find_items_used_by_mode(user_defined_mode(ModeName, ArgInsts), !Info) :- recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_insts(Modes, !Info) :- - list__foldl(find_items_used_by_inst, Modes, !Info). + list.foldl(find_items_used_by_inst, Modes, !Info). :- pred find_items_used_by_inst(mer_inst::in, recompilation_usage_info::in, recompilation_usage_info::out) is det. @@ -1300,7 +1296,7 @@ find_items_used_by_inst(any(_), !Info). find_items_used_by_inst(free, !Info). find_items_used_by_inst(free(_), !Info). find_items_used_by_inst(bound(_, BoundInsts), !Info) :- - list__foldl(find_items_used_by_bound_inst, BoundInsts, !Info). + list.foldl(find_items_used_by_bound_inst, BoundInsts, !Info). find_items_used_by_inst(ground(_, GroundInstInfo), !Info) :- ( GroundInstInfo = higher_order(pred_inst_info(_, Modes, _)), @@ -1315,7 +1311,7 @@ find_items_used_by_inst(constrained_inst_vars(_, Inst), !Info) :- find_items_used_by_inst(defined_inst(InstName), !Info) :- find_items_used_by_inst_name(InstName, !Info). find_items_used_by_inst(abstract_inst(Name, ArgInsts), !Info) :- - list__length(ArgInsts, Arity), + list.length(ArgInsts, Arity), maybe_record_item_to_process(inst_item, Name - Arity, !Info), find_items_used_by_insts(ArgInsts, !Info). @@ -1335,7 +1331,7 @@ find_items_used_by_bound_inst(BoundInst, !Info) :- recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_inst_name(user_inst(Name, ArgInsts), !Info) :- - list__length(ArgInsts, Arity), + list.length(ArgInsts, Arity), maybe_record_item_to_process(inst_item, Name - Arity, !Info), find_items_used_by_insts(ArgInsts, !Info). find_items_used_by_inst_name(merge_inst(Inst1, Inst2), !Info) :- @@ -1370,13 +1366,13 @@ find_items_used_by_class_context(constraints(Constraints1, Constraints2), recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_class_constraints(Constraints, !Info) :- - list__foldl(find_items_used_by_class_constraint, Constraints, !Info). + list.foldl(find_items_used_by_class_constraint, Constraints, !Info). :- pred find_items_used_by_class_constraint(prog_constraint::in, recompilation_usage_info::in, recompilation_usage_info::out) is det. find_items_used_by_class_constraint(constraint(ClassName, ArgTypes), !Info) :- - ClassArity = list__length(ArgTypes), + ClassArity = list.length(ArgTypes), maybe_record_item_to_process(typeclass_item, ClassName - ClassArity, !Info), find_items_used_by_types(ArgTypes, !Info). @@ -1387,26 +1383,22 @@ find_items_used_by_class_constraint(constraint(ClassName, ArgTypes), !Info) :- maybe_record_item_to_process(ItemType, NameArity, !Info) :- ( ItemType = typeclass_item -> Classes0 = !.Info ^ used_typeclasses, - set__insert(Classes0, NameArity, Classes), + set.insert(Classes0, NameArity, Classes), !:Info = !.Info ^ used_typeclasses := Classes ; true ), - ( - item_is_recorded_used(!.Info, ItemType, NameArity) - -> + ( item_is_recorded_used(!.Info, ItemType, NameArity) -> % This item has already been recorded. true - ; - item_is_local(!.Info, NameArity) - -> + ; item_is_local(!.Info, NameArity) -> % Ignore local items. The items used by them have already been recorded % by module_qual.m. true ; Queue0 = !.Info ^ item_queue, - queue__put(Queue0, item_id(ItemType, NameArity), Queue), + queue.put(Queue0, item_id(ItemType, NameArity), Queue), !:Info = !.Info ^ item_queue := Queue, record_imported_item(ItemType, NameArity, !Info), @@ -1419,9 +1411,9 @@ maybe_record_item_to_process(ItemType, NameArity, !Info) :- item_is_recorded_used(Info, ItemType, NameArity) :- ImportedItems = Info ^ imported_items, NameArity = qualified(ModuleName, Name) - Arity, - map__search(ImportedItems, ModuleName, ModuleIdSet), + map.search(ImportedItems, ModuleName, ModuleIdSet), ModuleItemIdSet = extract_ids(ModuleIdSet, ItemType), - set__member(Name - Arity, ModuleItemIdSet). + set.member(Name - Arity, ModuleItemIdSet). :- pred item_is_local(recompilation_usage_info::in, pair(sym_name, arity)::in) is semidet. @@ -1443,30 +1435,31 @@ record_imported_item(ItemType, SymName - Arity, !Info) :- ), ImportedItems0 = !.Info ^ imported_items, - ( map__search(ImportedItems0, Module, ModuleItems0) -> + ( map.search(ImportedItems0, Module, ModuleItems0) -> ModuleItems1 = ModuleItems0 ; - ModuleItems1 = init_item_id_set(set__init) + ModuleItems1 = init_item_id_set(set.init) ), ModuleItemIds0 = extract_ids(ModuleItems1, ItemType), - set__insert(ModuleItemIds0, Name - Arity, ModuleItemIds), + set.insert(ModuleItemIds0, Name - Arity, ModuleItemIds), ModuleItems = update_ids(ModuleItems1, ItemType, ModuleItemIds), - map__set(ImportedItems0, Module, ModuleItems, ImportedItems), + map.set(ImportedItems0, Module, ModuleItems, ImportedItems), !:Info = !.Info ^ imported_items := ImportedItems. % Uses of equivalence types have been expanded away by equiv_type.m. % equiv_type.m records which equivalence types were used by each % imported item. + % :- pred record_expanded_items_used_by_item(item_type::in, item_name::in, recompilation_usage_info::in, recompilation_usage_info::out) is det. record_expanded_items_used_by_item(ItemType, NameArity, !Info) :- Dependencies = !.Info ^ dependencies, ( - map__search(Dependencies, item_id(ItemType, NameArity), EquivTypes) + map.search(Dependencies, item_id(ItemType, NameArity), EquivTypes) -> - list__foldl(record_expanded_items_used_by_item_2, - set__to_sorted_list(EquivTypes), !Info) + list.foldl(record_expanded_items_used_by_item_2, + set.to_sorted_list(EquivTypes), !Info) ; true ). diff --git a/compiler/recompilation.version.m b/compiler/recompilation.version.m index 260fb46ad..71c392347 100644 --- a/compiler/recompilation.version.m +++ b/compiler/recompilation.version.m @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module recompilation__version. +:- module recompilation.version. :- interface. :- import_module libs.timestamp. @@ -77,10 +77,10 @@ compute_version_numbers(SourceFileTime, Items, MaybeOldItems, ; % There were no old version numbers, so every item % gets the same timestamp as the source module. - OldItemVersionNumbers = init_item_id_set(map__init), - GatheredOldItems = init_item_id_set(map__init), - map__init(OldInstanceItems), - map__init(OldInstanceVersionNumbers) + OldItemVersionNumbers = init_item_id_set(map.init), + GatheredOldItems = init_item_id_set(map.init), + map.init(OldInstanceItems), + map.init(OldInstanceVersionNumbers) ), compute_item_version_numbers(SourceFileTime, @@ -99,7 +99,7 @@ compute_item_version_numbers(SourceFileTime, GatheredItems, GatheredOldItems, OldVersionNumbers, VersionNumbers) :- VersionNumbers = map_ids(compute_item_version_numbers_2(SourceFileTime, - GatheredOldItems, OldVersionNumbers), GatheredItems, map__init). + GatheredOldItems, OldVersionNumbers), GatheredItems, map.init). :- func compute_item_version_numbers_2(timestamp, gathered_items, item_version_numbers, item_type, @@ -108,7 +108,7 @@ compute_item_version_numbers(SourceFileTime, compute_item_version_numbers_2(SourceFileTime, GatheredOldItems, OldVersionNumbers, ItemType, Items0) = - map__map_values(compute_item_version_numbers_3(SourceFileTime, + map.map_values(compute_item_version_numbers_3(SourceFileTime, GatheredOldItems, OldVersionNumbers, ItemType), Items0). :- func compute_item_version_numbers_3(timestamp, gathered_items, @@ -119,9 +119,9 @@ compute_item_version_numbers_3(SourceFileTime, GatheredOldItems, OldVersionNumbers, ItemType, NameArity, Items) = ( OldIds = extract_ids(GatheredOldItems, ItemType), - map__search(OldIds, NameArity, OldItems), + map.search(OldIds, NameArity, OldItems), items_are_unchanged(OldItems, Items), - map__search(extract_ids(OldVersionNumbers, ItemType), NameArity, + map.search(extract_ids(OldVersionNumbers, ItemType), NameArity, OldVersionNumber) -> OldVersionNumber @@ -136,12 +136,12 @@ compute_item_version_numbers_3(SourceFileTime, GatheredOldItems, compute_instance_version_numbers(SourceFileTime, InstanceItems, OldInstanceItems, OldInstanceVersionNumbers, InstanceVersionNumbers) :- - InstanceVersionNumbers = map__map_values( + InstanceVersionNumbers = map.map_values( (func(ClassId, Items) = VersionNumber :- ( - map__search(OldInstanceItems, ClassId, OldItems), + map.search(OldInstanceItems, ClassId, OldItems), items_are_unchanged(OldItems, Items), - map__search(OldInstanceVersionNumbers, ClassId, + map.search(OldInstanceVersionNumbers, ClassId, OldVersionNumber) -> VersionNumber = OldVersionNumber @@ -156,9 +156,9 @@ compute_instance_version_numbers(SourceFileTime, gathered_items::out, instance_item_map::out) is det. gather_items(Section, Items, GatheredItems, Instances) :- - list__reverse(Items, RevItems), - Info0 = gathered_item_info(init_item_id_set(map__init), [], [], map__init), - list__foldl2(gather_items_2, RevItems, Section, _, Info0, Info1), + list.reverse(Items, RevItems), + Info0 = gathered_item_info(init_item_id_set(map.init), [], [], map.init), + list.foldl2(gather_items_2, RevItems, Section, _, Info0, Info1), % Items which could appear in _OtherItems (those which aren't gathered % into the list for another type of item) can't appear in the interface @@ -167,8 +167,8 @@ gather_items(Section, Items, GatheredItems, Instances) :- % `--intermodule-optimization'. Info1 = gathered_item_info(GatheredItems1, PragmaItems, _OtherItems, Instances), - list__reverse(PragmaItems, RevPragmaItems), - list__foldl(distribute_pragma_items, RevPragmaItems, + list.reverse(PragmaItems, RevPragmaItems), + list.foldl(distribute_pragma_items, RevPragmaItems, GatheredItems1, GatheredItems). :- pred distribute_pragma_items( @@ -201,7 +201,7 @@ distribute_pragma_items({ItemId, ItemAndContext, Section}, !GatheredItems) :- ), % Pragmas can apply to typeclass methods. - map__map_values(distribute_pragma_items_class_items(MaybePredOrFunc, + map.map_values(distribute_pragma_items_class_items(MaybePredOrFunc, SymName, Arity, ItemAndContext, Section), extract_ids(!.GatheredItems, typeclass_item), GatheredTypeClasses), !:GatheredItems = update_ids(!.GatheredItems, typeclass_item, @@ -217,10 +217,10 @@ distribute_pragma_items_class_items(MaybePredOrFunc, SymName, Arity, ItemAndContext, Section, _, !ClassItems) :- ( % Does this pragma match any of the methods of this class. - list__member(_ - ClassItem, !.ClassItems), + list.member(_ - ClassItem, !.ClassItems), ClassItem = typeclass(_, _, _, _, Interface, _) - _, Interface = concrete(Methods), - list__member(Method, Methods), + list.member(Method, Methods), Method = pred_or_func(_, _, _, MethodPredOrFunc, SymName, TypesAndModes, WithType, _, _, _, _, _, _), ( MaybePredOrFunc = yes(MethodPredOrFunc) @@ -229,7 +229,7 @@ distribute_pragma_items_class_items(MaybePredOrFunc, SymName, Arity, ( WithType = no, adjust_func_arity(MethodPredOrFunc, Arity, - list__length(TypesAndModes)) + list.length(TypesAndModes)) ; % We don't know the actual arity, so just match on the name % and pred_or_func. @@ -301,7 +301,7 @@ gather_items_2(ItemAndContext, !Section, !Info) :- NameItem = Item, BodyItem = Item ), - TypeCtor = Name - list__length(Args), + TypeCtor = Name - list.length(Args), GatheredItems0 = !.Info ^ gathered_items, add_gathered_item(NameItem, item_id(type_item, TypeCtor), ItemContext, !.Section, yes, GatheredItems0, GatheredItems1), @@ -312,13 +312,13 @@ gather_items_2(ItemAndContext, !Section, !Info) :- Item = instance(_, ClassName, ClassArgs, _, _, _) -> Instances0 = !.Info ^ instances, - ClassArity = list__length(ClassArgs), - ( map__search(Instances0, ClassName - ClassArity, InstanceItems0) -> + ClassArity = list.length(ClassArgs), + ( map.search(Instances0, ClassName - ClassArity, InstanceItems0) -> InstanceItems = InstanceItems0 ; InstanceItems = [] ), - map__set(Instances0, ClassName - ClassArity, + map.set(Instances0, ClassName - ClassArity, [!.Section - (Item - ItemContext) | InstanceItems], Instances), !:Info = !.Info ^ instances := Instances ; @@ -332,7 +332,7 @@ gather_items_2(ItemAndContext, !Section, !Info) :- WithInst = yes(_) -> GatheredItems0 = !.Info ^ gathered_items, - ItemName = SymName - list__length(Modes), + ItemName = SymName - list.length(Modes), add_gathered_item(Item, item_id(predicate_item, ItemName), ItemContext, !.Section, yes, GatheredItems0, GatheredItems1), add_gathered_item(Item, item_id(function_item, ItemName), @@ -368,7 +368,7 @@ add_gathered_item(Item, ItemId, ItemContext, Section, AddIfNotExisting, unqualify_name(SymName, Name), IdMap0 = extract_ids(!.GatheredItems, ItemType), NameArity = Name - Arity, - ( map__search(IdMap0, NameArity, MatchingItems0) -> + ( map.search(IdMap0, NameArity, MatchingItems0) -> MatchingItems = MatchingItems0 ; MatchingItems = [] @@ -403,8 +403,8 @@ add_gathered_item_2(Item, ItemType, NameArity, ItemContext, Section, ; WithInst = yes(_) ) -> - TypesWithoutModes = list__map((func(Type) = type_only(Type)), Types), - varset__init(EmptyInstVarSet), + TypesWithoutModes = list.map((func(Type) = type_only(Type)), Types), + varset.init(EmptyInstVarSet), PredOrFuncItem = pred_or_func(TVarSet, EmptyInstVarSet, ExistQVars, PredOrFunc, PredName, TypesWithoutModes, WithType, no, no, Cond, Purity, ClassContext), @@ -427,8 +427,8 @@ add_gathered_item_2(Item, ItemType, NameArity, ItemContext, Section, ; Item ^ tc_class_methods = concrete(Methods0) -> - MethodsList = list__map(split_class_method_types_and_modes, Methods0), - list__condense(MethodsList, Methods), + MethodsList = list.map(split_class_method_types_and_modes, Methods0), + list.condense(MethodsList, Methods), TypeclassItem = Item ^ tc_class_methods := concrete(Methods), MatchingItems = [Section - (TypeclassItem - ItemContext) | MatchingItems0] @@ -437,7 +437,7 @@ add_gathered_item_2(Item, ItemType, NameArity, ItemContext, Section, ), IdMap0 = extract_ids(!.GatheredItems, ItemType), - map__set(IdMap0, NameArity, MatchingItems, IdMap), + map.set(IdMap0, NameArity, MatchingItems, IdMap), !:GatheredItems = update_ids(!.GatheredItems, ItemType, IdMap). :- func split_class_method_types_and_modes(class_method) = class_methods. @@ -455,7 +455,7 @@ split_class_method_types_and_modes(Method0) = Items :- ; WithInst = yes(_) ) -> - TypesWithoutModes = list__map((func(Type) = type_only(Type)), Types), + TypesWithoutModes = list.map((func(Type) = type_only(Type)), Types), ( WithInst = yes(_), % MaybePredOrFunc needs to be `no' here because when the item @@ -467,22 +467,22 @@ split_class_method_types_and_modes(Method0) = Items :- MaybePredOrFunc = yes(PredOrFunc) ), PredOrFuncModeItem = pred_or_func_mode(InstVarSet, MaybePredOrFunc, - SymName, Modes, WithInst, MaybeDet, Cond, term__context_init), + SymName, Modes, WithInst, MaybeDet, Cond, term.context_init), PredOrFuncModeItems = [PredOrFuncModeItem] ; TypesWithoutModes = TypesAndModes, PredOrFuncModeItems = [] ), - varset__init(EmptyInstVarSet), + varset.init(EmptyInstVarSet), PredOrFuncItem = pred_or_func(TVarSet, EmptyInstVarSet, ExistQVars, PredOrFunc, SymName, TypesWithoutModes, WithType, no, no, Cond, Purity, - ClassContext, term__context_init), + ClassContext, term.context_init), Items = [PredOrFuncItem | PredOrFuncModeItems]. split_class_method_types_and_modes(Method0) = [Method] :- % Always strip the context from the item -- this is needed % so the items can be easily tested for equality. Method0 = pred_or_func_mode(A, B, C, D, E, F, G, _), - Method = pred_or_func_mode(A, B, C, D, E, F, G, term__context_init). + Method = pred_or_func_mode(A, B, C, D, E, F, G, term.context_init). :- pred item_to_item_id(item::in, item_id::out) is semidet. @@ -494,13 +494,13 @@ item_to_item_id(Item, ItemId) :- item_to_item_id_2(clause(_, _, _, _, _, _), no). item_to_item_id_2(type_defn(_, Name, Params, _, _), yes(item_id(type_item, Name - Arity))) :- - list__length(Params, Arity). + list.length(Params, Arity). item_to_item_id_2(inst_defn(_, Name, Params, _, _), yes(item_id(inst_item, Name - Arity))) :- - list__length(Params, Arity). + list.length(Params, Arity). item_to_item_id_2(mode_defn(_, Name, Params, _, _), yes(item_id(mode_item, Name - Arity))) :- - list__length(Params, Arity). + list.length(Params, Arity). item_to_item_id_2(module_defn(_, _), no). item_to_item_id_2(Item, yes(item_id(ItemType, SymName - Arity))) :- Item = pred_or_func(_, _, _, PredOrFunc, SymName, TypesAndModes, WithType, @@ -511,10 +511,10 @@ item_to_item_id_2(Item, yes(item_id(ItemType, SymName - Arity))) :- % so this will work. ( WithType = no, - adjust_func_arity(PredOrFunc, Arity, list__length(TypesAndModes)) + adjust_func_arity(PredOrFunc, Arity, list.length(TypesAndModes)) ; WithType = yes(_), - Arity = list__length(TypesAndModes) + Arity = list.length(TypesAndModes) ), ItemType = pred_or_func_to_item_type(PredOrFunc). @@ -522,7 +522,7 @@ item_to_item_id_2(Item, ItemId) :- Item = pred_or_func_mode(_, MaybePredOrFunc, SymName, Modes, _, _, _), ( MaybePredOrFunc = yes(PredOrFunc), - adjust_func_arity(PredOrFunc, Arity, list__length(Modes)), + adjust_func_arity(PredOrFunc, Arity, list.length(Modes)), ItemType = pred_or_func_to_item_type(PredOrFunc), ItemId = yes(item_id(ItemType, SymName - Arity)) ; @@ -539,7 +539,7 @@ item_to_item_id_2(promise(_, _, _, _), no). item_to_item_id_2(Item, yes(item_id(typeclass_item, ClassName - ClassArity))) :- Item = typeclass(_, _, ClassName, ClassVars, _, _), - list__length(ClassVars, ClassArity). + list.length(ClassVars, ClassArity). % Instances are handled separately (unlike other items, the module % qualifier on an instance declaration is the module containing @@ -560,7 +560,7 @@ is_pred_pragma(foreign_import_module(_, _), no). is_pred_pragma(foreign_code(_, _), no). is_pred_pragma(foreign_proc(_, Name, PredOrFunc, Args, _, _, _), yes(yes(PredOrFunc) - Name / Arity)) :- - adjust_func_arity(PredOrFunc, Arity, list__length(Args)). + adjust_func_arity(PredOrFunc, Arity, list.length(Args)). is_pred_pragma(type_spec(Name, _, Arity, MaybePredOrFunc, _, _, _, _), yes(MaybePredOrFunc - Name / Arity)). is_pred_pragma(inline(Name, Arity), yes(no - Name / Arity)). @@ -568,7 +568,7 @@ is_pred_pragma(no_inline(Name, Arity), yes(no - Name / Arity)). is_pred_pragma(obsolete(Name, Arity), yes(no - Name / Arity)). is_pred_pragma(export(Name, PredOrFunc, Modes, _), yes(yes(PredOrFunc) - Name / Arity)) :- - adjust_func_arity(PredOrFunc, Arity, list__length(Modes)). + adjust_func_arity(PredOrFunc, Arity, list.length(Modes)). % Pragma import declarations are never used directly by Mercury code. is_pred_pragma(import(_, _, _, _, _), no). is_pred_pragma(source_file(_), no). @@ -588,19 +588,19 @@ is_pred_pragma(promise_equivalent_clauses(Name, Arity), yes(no - Name / Arity)). is_pred_pragma(termination_info(PredOrFunc, Name, Modes, _, _), yes(yes(PredOrFunc) - Name / Arity)) :- - adjust_func_arity(PredOrFunc, Arity, list__length(Modes)). + adjust_func_arity(PredOrFunc, Arity, list.length(Modes)). is_pred_pragma(structure_sharing(PredOrFunc, Name, Modes, _, _, _), yes(yes(PredOrFunc) - Name / Arity)) :- - adjust_func_arity(PredOrFunc, Arity, list__length(Modes)). + adjust_func_arity(PredOrFunc, Arity, list.length(Modes)). is_pred_pragma(termination2_info(PredOrFunc, Name, Modes, _, _, _), yes(yes(PredOrFunc) - Name / Arity)) :- - adjust_func_arity(PredOrFunc, Arity, list__length(Modes)). + adjust_func_arity(PredOrFunc, Arity, list.length(Modes)). is_pred_pragma(terminates(Name, Arity), yes(no - Name / Arity)). is_pred_pragma(does_not_terminate(Name, Arity), yes(no - Name / Arity)). is_pred_pragma(check_termination(Name, Arity), yes(no - Name / Arity)). is_pred_pragma(mode_check_clauses(Name, Arity), yes(no - Name / Arity)). - % XXX This is a bit brittle (need to be careful with term__contexts). + % XXX This is a bit brittle (need to be careful with term.contexts). % For example, it won't work for clauses. % It will never succeed when it shouldn't, so it will never % cause a necessary recompilation to be missed. @@ -681,15 +681,13 @@ item_is_unchanged(pragma(_, PragmaType1), Item2) = Result :- MaybePredOrFunc, MaybeModes, TypeSubst2, TVarSet2, _) -> - assoc_list__keys_and_values(TypeSubst1, TVars1, Types1), - assoc_list__keys_and_values(TypeSubst2, TVars2, Types2), + assoc_list.keys_and_values(TypeSubst1, TVars1, Types1), + assoc_list.keys_and_values(TypeSubst2, TVars2, Types2), % XXX kind inference: % we assume vars have kind `star'. - KindMap = map__init, - prog_type__var_list_to_type_list(KindMap, TVars1, - TVarTypes1), - prog_type__var_list_to_type_list(KindMap, TVars2, - TVarTypes2), + KindMap = map.init, + prog_type.var_list_to_type_list(KindMap, TVars1, TVarTypes1), + prog_type.var_list_to_type_list(KindMap, TVars2, TVarTypes2), ( type_list_is_unchanged( TVarSet1, TVarTypes1 ++ Types1, @@ -808,8 +806,8 @@ pred_or_func_type_is_unchanged(TVarSet1, ExistQVars1, TypesAndModes1, "pred_or_func_type_matches: type_and_mode") ) ), - Types1 = list__map(GetArgTypes, TypesAndModes1), - Types2 = list__map(GetArgTypes, TypesAndModes2), + Types1 = list.map(GetArgTypes, TypesAndModes1), + Types2 = list.map(GetArgTypes, TypesAndModes2), ( MaybeWithType1 = yes(WithType1), MaybeWithType2 = yes(WithType2), @@ -829,14 +827,14 @@ pred_or_func_type_is_unchanged(TVarSet1, ExistQVars1, TypesAndModes1, % % XXX kind inference: we assume all tvars have kind `star'. - map__init(KindMap2), + map.init(KindMap2), apply_variable_renaming_to_tvar_kind_map(Renaming, KindMap2, RenamedKindMap2), apply_variable_renaming_to_tvar_list(Renaming, ExistQVars2, RenamedExistQVars2), apply_rec_subst_to_tvar_list(RenamedKindMap2, Types2ToTypes1Subst, RenamedExistQVars2, SubstExistQTypes2), - ( prog_type__type_list_to_var_list(SubstExistQTypes2, SubstExistQVars2) -> + ( prog_type.type_list_to_var_list(SubstExistQTypes2, SubstExistQVars2) -> ExistQVars1 = SubstExistQVars2 ; unexpected(this_file, "pred_or_func_type_is_unchanged: non-var") @@ -870,26 +868,26 @@ type_list_is_unchanged(TVarSet1, Types1, TVarSet2, Types2, ( all [VarInItem1, VarInItem2] ( - map__member(Types2ToTypes1Subst, VarInItem2, SubstTerm), + map.member(Types2ToTypes1Subst, VarInItem2, SubstTerm), % Note that since the type comes from a substitution, % it will not contain a kind annotation. SubstTerm = variable(VarInItem1, _) ) => ( - varset__lookup_name(TVarSet, VarInItem1, VarName1), - varset__lookup_name(TVarSet, VarInItem2, VarName2), + varset.lookup_name(TVarSet, VarInItem1, VarName1), + varset.lookup_name(TVarSet, VarInItem2, VarName2), ( VarName1 = VarName2 ; % Variables written to interface files are always named, % even if the variable in the source code was not, so we can't - % just use varset__search_name to check whether the variables + % just use varset.search_name to check whether the variables % are named. VarIsNotNamed = (pred(VarName::in) is semidet :- - string__append("V_", VarNum, VarName), - string__to_int(VarNum, _) + string.append("V_", VarNum, VarName), + string.to_int(VarNum, _) ), VarIsNotNamed(VarName1), VarIsNotNamed(VarName2) @@ -903,18 +901,18 @@ type_list_is_unchanged(TVarSet1, Types1, TVarSet2, Types2, pred_or_func_mode_is_unchanged(InstVarSet1, Modes1, MaybeWithInst1, InstVarSet2, Modes2, MaybeWithInst2) :- - varset__coerce(InstVarSet1, VarSet1), - varset__coerce(InstVarSet2, VarSet2), + varset.coerce(InstVarSet1, VarSet1), + varset.coerce(InstVarSet2, VarSet2), % Apply the substitution to the modes so that the inst variables % from both declarations being checked are contained in the same % inst_varset, then check that they are identical. - varset__merge_subst(VarSet1, VarSet2, _, InstSubst), + varset.merge_subst(VarSet1, VarSet2, _, InstSubst), - % Treat modes as terms here to use term__list_subsumes, which does just + % Treat modes as terms here to use term.list_subsumes, which does just % what we want here. - ModeTerms1 = list__map(mode_to_term, Modes1), - ModeTerms2 = list__map(mode_to_term, Modes2), + ModeTerms1 = list.map(mode_to_term, Modes1), + ModeTerms2 = list.map(mode_to_term, Modes2), ( MaybeWithInst1 = yes(Inst1), MaybeWithInst2 = yes(Inst2), @@ -929,10 +927,10 @@ pred_or_func_mode_is_unchanged(InstVarSet1, Modes1, MaybeWithInst1, AllModeTerms2 = ModeTerms2 ), - term__apply_substitution_to_list(AllModeTerms2, InstSubst, + term.apply_substitution_to_list(AllModeTerms2, InstSubst, SubstAllModeTerms2), - term__list_subsumes(AllModeTerms1, SubstAllModeTerms2, _), - term__list_subsumes(SubstAllModeTerms2, AllModeTerms1, _). + term.list_subsumes(AllModeTerms1, SubstAllModeTerms2, _), + term.list_subsumes(SubstAllModeTerms2, AllModeTerms1, _). % Combined typeclass method type and mode declarations are split as for % ordinary predicate declarations, so the varsets won't necessarily match @@ -976,32 +974,32 @@ class_methods_are_unchanged([Method1 | Methods1], [Method2 | Methods2]) :- write_version_numbers(AllVersionNumbers, !IO) :- AllVersionNumbers = version_numbers(VersionNumbers, InstanceVersionNumbers), - VersionNumbersList = list__filter_map( + VersionNumbersList = list.filter_map( (func(ItemType) = (ItemType - ItemVersions) is semidet :- ItemVersions = extract_ids(VersionNumbers, ItemType), - \+ map__is_empty(ItemVersions) + \+ map.is_empty(ItemVersions) ), [type_item, type_body_item, mode_item, inst_item, predicate_item, function_item, typeclass_item]), - io__write_string("{\n\t", !IO), - io__write_list(VersionNumbersList, ",\n\t", + io.write_string("{\n\t", !IO), + io.write_list(VersionNumbersList, ",\n\t", write_item_type_and_versions, !IO), - ( map__is_empty(InstanceVersionNumbers) -> + ( map.is_empty(InstanceVersionNumbers) -> true ; ( VersionNumbersList = [] ; VersionNumbersList = [_ | _], - io__write_string(",\n\t", !IO) + io.write_string(",\n\t", !IO) ), - io__write_string("instance(", !IO), - map__to_assoc_list(InstanceVersionNumbers, InstanceAL), - io__write_list(InstanceAL, ",\n\n\t", + io.write_string("instance(", !IO), + map.to_assoc_list(InstanceVersionNumbers, InstanceAL), + io.write_list(InstanceAL, ",\n\n\t", write_symname_arity_version_number, !IO), - io__write_string(")\n\t", !IO) + io.write_string(")\n\t", !IO) ), - io__write_string("\n}", !IO). + io.write_string("\n}", !IO). :- pred write_item_type_and_versions( pair(item_type, map(pair(string, int), version_number))::in, @@ -1009,12 +1007,12 @@ write_version_numbers(AllVersionNumbers, !IO) :- write_item_type_and_versions(ItemType - ItemVersions, !IO) :- string_to_item_type(ItemTypeStr, ItemType), - io__write_string(ItemTypeStr, !IO), - io__write_string("(\n\t\t", !IO), - map__to_assoc_list(ItemVersions, ItemVersionsList), - io__write_list(ItemVersionsList, ",\n\t\t", + io.write_string(ItemTypeStr, !IO), + io.write_string("(\n\t\t", !IO), + map.to_assoc_list(ItemVersions, ItemVersionsList), + io.write_list(ItemVersionsList, ",\n\t\t", write_name_arity_version_number, !IO), - io__write_string("\n\t)", !IO). + io.write_string("\n\t)", !IO). :- pred write_name_arity_version_number( pair(pair(string, int), version_number)::in, io::di, io::uo) is det. @@ -1023,9 +1021,9 @@ write_name_arity_version_number(NameArity - VersionNumber, !IO) :- NameArity = Name - Arity, mercury_output_bracketed_sym_name(unqualified(Name), next_to_graphic_token, !IO), - io__write_string("/", !IO), - io__write_int(Arity, !IO), - io__write_string(" - ", !IO), + io.write_string("/", !IO), + io.write_int(Arity, !IO), + io.write_string(" - ", !IO), write_version_number(VersionNumber, !IO). :- pred write_symname_arity_version_number( @@ -1034,9 +1032,9 @@ write_name_arity_version_number(NameArity - VersionNumber, !IO) :- write_symname_arity_version_number(SymNameArity - VersionNumber, !IO) :- SymNameArity = SymName - Arity, mercury_output_bracketed_sym_name(SymName, next_to_graphic_token, !IO), - io__write_string("/", !IO), - io__write_int(Arity, !IO), - io__write_string(" - ", !IO), + io.write_string("/", !IO), + io.write_int(Arity, !IO), + io.write_string(" - ", !IO), write_version_number(VersionNumber, !IO). %-----------------------------------------------------------------------------% @@ -1047,7 +1045,7 @@ version_numbers_version_number = 1. parse_version_numbers(VersionNumbersTerm, Result) :- ( - VersionNumbersTerm = term__functor(term__atom("{}"), + VersionNumbersTerm = term.functor(term.atom("{}"), VersionNumbersTermList0, _) -> VersionNumbersTermList = VersionNumbersTermList0 @@ -1058,9 +1056,9 @@ parse_version_numbers(VersionNumbersTerm, Result) :- Result0), ( Result0 = ok(List), - VersionNumbers0 = version_numbers(init_item_id_set(map__init), - map__init), - VersionNumbers = list__foldl( + VersionNumbers0 = version_numbers(init_item_id_set(map.init), + map.init), + VersionNumbers = list.foldl( (func(VNResult, version_numbers(VNs0, Instances0)) = version_numbers(VNs, Instances) :- ( @@ -1087,25 +1085,25 @@ parse_version_numbers(VersionNumbersTerm, Result) :- parse_item_type_version_numbers(Term, Result) :- ( - Term = term__functor(term__atom(ItemTypeStr), ItemsVNsTerms, _), + Term = term.functor(term.atom(ItemTypeStr), ItemsVNsTerms, _), string_to_item_type(ItemTypeStr, ItemType) -> ParseName = (pred(NameTerm::in, Name::out) is semidet :- - NameTerm = term__functor(term__atom(Name), [], _) + NameTerm = term.functor(term.atom(Name), [], _) ), map_parser(parse_item_version_number(ParseName), ItemsVNsTerms, Result0), ( Result0 = ok(VNsAL), - map__from_assoc_list(VNsAL, VNsMap), + map.from_assoc_list(VNsAL, VNsMap), Result = ok(items(ItemType, VNsMap)) ; Result0 = error(A, B), Result = error(A, B) ) ; - Term = term__functor(term__atom("instance"), + Term = term.functor(term.atom("instance"), InstanceVNsTerms, _) -> ParseName = @@ -1116,7 +1114,7 @@ parse_item_type_version_numbers(Term, Result) :- InstanceVNsTerms, Result1), ( Result1 = ok(VNsAL), - map__from_assoc_list(VNsAL, VNsMap), + map.from_assoc_list(VNsAL, VNsMap), Result = ok(instances(VNsMap)) ; Result1 = error(A, B), @@ -1131,12 +1129,12 @@ parse_item_type_version_numbers(Term, Result) :- parse_item_version_number(ParseName, Term, Result) :- ( - Term = term__functor(term__atom("-"), + Term = term.functor(term.atom("-"), [ItemNameArityTerm, VersionNumberTerm], _), - ItemNameArityTerm = term__functor(term__atom("/"), + ItemNameArityTerm = term.functor(term.atom("/"), [NameTerm, ArityTerm], _), ParseName(NameTerm, Name), - ArityTerm = term__functor(term__integer(Arity), _, _), + ArityTerm = term.functor(term.integer(Arity), _, _), VersionNumber = term_to_version_number(VersionNumberTerm) -> Result = ok((Name - Arity) - VersionNumber) diff --git a/compiler/rtti.m b/compiler/rtti.m index 63d62a69c..b84661628 100644 --- a/compiler/rtti.m +++ b/compiler/rtti.m @@ -23,7 +23,7 @@ %-----------------------------------------------------------------------------% -:- module backend_libs__rtti. +:- module backend_libs.rtti. :- interface. :- import_module hlds.hlds_data. @@ -852,8 +852,8 @@ %----------------------------------------------------------------------------% encode_type_ctor_flags(FlagSet) = Encoding :- - set__to_sorted_list(FlagSet, FlagList), - Encoding = list__foldl(encode_type_ctor_flag, FlagList, 0). + set.to_sorted_list(FlagSet, FlagList), + Encoding = list.foldl(encode_type_ctor_flag, FlagList, 0). :- func encode_type_ctor_flag(type_ctor_flag, int) = int. @@ -1023,15 +1023,15 @@ make_rtti_proc_label(ModuleInfo, PredId, ProcId) = ProcLabel :- ProcIsExported = (procedure_is_exported(ModuleInfo, PredInfo, ProcId) -> yes ; no), pred_info_get_origin(PredInfo, Origin), - ProcHeadVarsWithNames = list__map((func(Var) = Var - Name :- - Name = varset__lookup_name(ProcVarSet, Var) + ProcHeadVarsWithNames = list.map((func(Var) = Var - Name :- + Name = varset.lookup_name(ProcVarSet, Var) ), ProcHeadVars), ( ( PredIsImported = yes ; PredIsPseudoImp = yes, - hlds_pred__in_in_unification_proc_id(ProcId) + hlds_pred.in_in_unification_proc_id(ProcId) ) -> ProcIsImported = yes @@ -1059,115 +1059,115 @@ name_to_string(RttiTypeCtor, RttiName) = Str :- mangle_rtti_type_ctor(RttiTypeCtor, ModuleName, TypeName, A_str), ( RttiName = exist_locns(Ordinal), - string__int_to_string(Ordinal, O_str), - string__append_list([ModuleName, "__exist_locns_", + string.int_to_string(Ordinal, O_str), + string.append_list([ModuleName, "__exist_locns_", TypeName, "_", A_str, "_", O_str], Str) ; RttiName = exist_locn, - string__append_list([ModuleName, "__exist_locn_", + string.append_list([ModuleName, "__exist_locn_", TypeName, "_", A_str], Str) ; RttiName = exist_tc_constr(Ordinal, TCCNum, _), - string__int_to_string(Ordinal, O_str), - string__int_to_string(TCCNum, N_str), - string__append_list([ModuleName, "__exist_tc_constr_", + string.int_to_string(Ordinal, O_str), + string.int_to_string(TCCNum, N_str), + string.append_list([ModuleName, "__exist_tc_constr_", TypeName, "_", A_str, "_", O_str, "_", N_str], Str) ; RttiName = exist_tc_constrs(Ordinal), - string__int_to_string(Ordinal, O_str), - string__append_list([ModuleName, "__exist_tc_constrs_", + string.int_to_string(Ordinal, O_str), + string.append_list([ModuleName, "__exist_tc_constrs_", TypeName, "_", A_str, "_", O_str], Str) ; RttiName = exist_info(Ordinal), - string__int_to_string(Ordinal, O_str), - string__append_list([ModuleName, "__exist_info_", + string.int_to_string(Ordinal, O_str), + string.append_list([ModuleName, "__exist_info_", TypeName, "_", A_str, "_", O_str], Str) ; RttiName = field_names(Ordinal), - string__int_to_string(Ordinal, O_str), - string__append_list([ModuleName, "__field_names_", + string.int_to_string(Ordinal, O_str), + string.append_list([ModuleName, "__field_names_", TypeName, "_", A_str, "_", O_str], Str) ; RttiName = field_types(Ordinal), - string__int_to_string(Ordinal, O_str), - string__append_list([ModuleName, "__field_types_", + string.int_to_string(Ordinal, O_str), + string.append_list([ModuleName, "__field_types_", TypeName, "_", A_str, "_", O_str], Str) ; RttiName = res_addrs, - string__append_list([ModuleName, "__reserved_addrs_", + string.append_list([ModuleName, "__reserved_addrs_", TypeName, "_", A_str], Str) ; RttiName = res_addr_functors, - string__append_list([ModuleName, "__reserved_addr_functors_", + string.append_list([ModuleName, "__reserved_addr_functors_", TypeName, "_", A_str], Str) ; RttiName = enum_functor_desc(Ordinal), - string__int_to_string(Ordinal, O_str), - string__append_list([ModuleName, "__enum_functor_desc_", + string.int_to_string(Ordinal, O_str), + string.append_list([ModuleName, "__enum_functor_desc_", TypeName, "_", A_str, "_", O_str], Str) ; RttiName = notag_functor_desc, - string__append_list([ModuleName, "__notag_functor_desc_", + string.append_list([ModuleName, "__notag_functor_desc_", TypeName, "_", A_str], Str) ; RttiName = du_functor_desc(Ordinal), - string__int_to_string(Ordinal, O_str), - string__append_list([ModuleName, "__du_functor_desc_", + string.int_to_string(Ordinal, O_str), + string.append_list([ModuleName, "__du_functor_desc_", TypeName, "_", A_str, "_", O_str], Str) ; RttiName = res_functor_desc(Ordinal), - string__int_to_string(Ordinal, O_str), - string__append_list([ModuleName, "__reserved_addr_functor_desc_", + string.int_to_string(Ordinal, O_str), + string.append_list([ModuleName, "__reserved_addr_functor_desc_", TypeName, "_", A_str, "_", O_str], Str) ; RttiName = enum_name_ordered_table, - string__append_list([ModuleName, "__enum_name_ordered_", + string.append_list([ModuleName, "__enum_name_ordered_", TypeName, "_", A_str], Str) ; RttiName = enum_value_ordered_table, - string__append_list([ModuleName, "__enum_value_ordered_", + string.append_list([ModuleName, "__enum_value_ordered_", TypeName, "_", A_str], Str) ; RttiName = du_name_ordered_table, - string__append_list([ModuleName, "__du_name_ordered_", + string.append_list([ModuleName, "__du_name_ordered_", TypeName, "_", A_str], Str) ; RttiName = du_stag_ordered_table(Ptag), - string__int_to_string(Ptag, P_str), - string__append_list([ModuleName, "__du_stag_ordered_", + string.int_to_string(Ptag, P_str), + string.append_list([ModuleName, "__du_stag_ordered_", TypeName, "_", A_str, "_", P_str], Str) ; RttiName = du_ptag_ordered_table, - string__append_list([ModuleName, "__du_ptag_ordered_", + string.append_list([ModuleName, "__du_ptag_ordered_", TypeName, "_", A_str], Str) ; RttiName = du_ptag_layout(Ptag), - string__int_to_string(Ptag, P_str), - string__append_list([ModuleName, "__du_ptag_layout_", + string.int_to_string(Ptag, P_str), + string.append_list([ModuleName, "__du_ptag_layout_", TypeName, "_", A_str, "_", P_str], Str) ; RttiName = res_value_ordered_table, - string__append_list([ModuleName, "__res_layout_ordered_table_", + string.append_list([ModuleName, "__res_layout_ordered_table_", TypeName, "_", A_str], Str) ; RttiName = res_name_ordered_table, - string__append_list([ModuleName, "__res_name_ordered_table_", + string.append_list([ModuleName, "__res_name_ordered_table_", TypeName, "_", A_str], Str) ; RttiName = maybe_res_addr_functor_desc, - string__append_list([ModuleName, "__maybe_res_addr_functor_desc_", + string.append_list([ModuleName, "__maybe_res_addr_functor_desc_", TypeName, "_", A_str], Str) ; RttiName = type_functors, - string__append_list([ModuleName, "__type_functors", + string.append_list([ModuleName, "__type_functors", TypeName, "_", A_str], Str) ; RttiName = type_layout, - string__append_list([ModuleName, "__type_layout", + string.append_list([ModuleName, "__type_layout", TypeName, "_", A_str], Str) ; RttiName = type_ctor_info, - string__append_list([ModuleName, "__type_ctor_info_", + string.append_list([ModuleName, "__type_ctor_info_", TypeName, "_", A_str], Str) ; RttiName = type_info(TypeInfo), @@ -1177,7 +1177,7 @@ name_to_string(RttiTypeCtor, RttiName) = Str :- Str = pseudo_type_info_to_string(PseudoTypeInfo) ; RttiName = type_hashcons_pointer, - string__append_list([ModuleName, "__hashcons_ptr_", + string.append_list([ModuleName, "__hashcons_ptr_", TypeName, "_", A_str], Str) ). @@ -1213,43 +1213,43 @@ tc_name_to_string(TCName, TCRttiName, Str) :- tc_name_to_string(TCName, TCRttiName, Str) :- TCRttiName = type_class_decl_super(Ordinal, _), mangle_rtti_type_class_name(TCName, ModuleName, ClassName, ArityStr), - string__int_to_string(Ordinal, OrdinalStr), + string.int_to_string(Ordinal, OrdinalStr), Str = ModuleName ++ "__type_class_decl_super_" ++ ClassName ++ "_" ++ ArityStr ++ "_" ++ OrdinalStr. tc_name_to_string(TCName, TCRttiName, Str) :- TCRttiName = type_class_instance(TCTypes), mangle_rtti_type_class_name(TCName, ModuleName, ClassName, ArityStr), - TypeStrs = list__map(encode_tc_instance_type, TCTypes), - TypeVectorStr = string__append_list(TypeStrs), + TypeStrs = list.map(encode_tc_instance_type, TCTypes), + TypeVectorStr = string.append_list(TypeStrs), Str = ModuleName ++ "__type_class_instance_" ++ ClassName ++ "_" ++ ArityStr ++ "_" ++ TypeVectorStr. tc_name_to_string(TCName, TCRttiName, Str) :- TCRttiName = type_class_instance_tc_type_vector(TCTypes), mangle_rtti_type_class_name(TCName, ModuleName, ClassName, ArityStr), - TypeStrs = list__map(encode_tc_instance_type, TCTypes), - TypeVectorStr = string__append_list(TypeStrs), + TypeStrs = list.map(encode_tc_instance_type, TCTypes), + TypeVectorStr = string.append_list(TypeStrs), Str = ModuleName ++ "__type_class_instance_tc_type_vector_" ++ ClassName ++ "_" ++ ArityStr ++ "_" ++ TypeVectorStr. tc_name_to_string(TCName, TCRttiName, Str) :- TCRttiName = type_class_instance_constraint(TCTypes, Ordinal, _), mangle_rtti_type_class_name(TCName, ModuleName, ClassName, ArityStr), - TypeStrs = list__map(encode_tc_instance_type, TCTypes), - TypeVectorStr = string__append_list(TypeStrs), - string__int_to_string(Ordinal, OrdinalStr), + TypeStrs = list.map(encode_tc_instance_type, TCTypes), + TypeVectorStr = string.append_list(TypeStrs), + string.int_to_string(Ordinal, OrdinalStr), Str = ModuleName ++ "__type_class_instance_constraint_" ++ ClassName ++ "_" ++ ArityStr ++ "_" ++ OrdinalStr ++ "_" ++ TypeVectorStr. tc_name_to_string(TCName, TCRttiName, Str) :- TCRttiName = type_class_instance_constraints(TCTypes), mangle_rtti_type_class_name(TCName, ModuleName, ClassName, ArityStr), - TypeStrs = list__map(encode_tc_instance_type, TCTypes), - TypeVectorStr = string__append_list(TypeStrs), + TypeStrs = list.map(encode_tc_instance_type, TCTypes), + TypeVectorStr = string.append_list(TypeStrs), Str = ModuleName ++ "__type_class_instance_constraints_" ++ ClassName ++ "_" ++ ArityStr ++ "_" ++ TypeVectorStr. tc_name_to_string(TCName, TCRttiName, Str) :- TCRttiName = type_class_instance_methods(TCTypes), mangle_rtti_type_class_name(TCName, ModuleName, ClassName, ArityStr), - TypeStrs = list__map(encode_tc_instance_type, TCTypes), - TypeVectorStr = string__append_list(TypeStrs), + TypeStrs = list.map(encode_tc_instance_type, TCTypes), + TypeVectorStr = string.append_list(TypeStrs), Str = ModuleName ++ "__type_class_instance_methods_" ++ ClassName ++ "_" ++ ArityStr ++ "_" ++ TypeVectorStr. @@ -1259,7 +1259,7 @@ encode_tc_instance_type(TCType) = Str :- % we lift that restriction, we will have to change this scheme. % % The code here is based on the code of - % base_typeclass_info__type_to_string, but its input is of type + % base_typeclass_info.type_to_string, but its input is of type % `maybe_pseudo_type_info', not of type `type'. ( TCType = plain(TI), @@ -1272,7 +1272,7 @@ encode_tc_instance_type(TCType) = Str :- TI = var_arity_type_info(VarArityId, ArgTIs), RttiTypeCtor = var_arity_id_to_rtti_type_ctor(VarArityId) ), - Arity = list__length(ArgTIs) + Arity = list.length(ArgTIs) % XXX We may wish to check that all arguments are variables. % (possible only if Arity = 0) ; @@ -1289,7 +1289,7 @@ encode_tc_instance_type(TCType) = Str :- PTI = type_var(_), unexpected(this_file, "encode_tc_instance_type: type_var") ), - Arity = list__length(ArgPTIs) + Arity = list.length(ArgPTIs) % XXX We may wish to check that all arguments are variables. ), RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, _CtorArity), @@ -1317,7 +1317,7 @@ mangle_rtti_type_ctor(RttiTypeCtor, ModuleName, TypeName, ArityStr) :- ), ModuleName = sym_name_mangle(ModuleNameSym), TypeName = name_mangle(TypeName0), - string__int_to_string(TypeArity, ArityStr). + string.int_to_string(TypeArity, ArityStr). :- pred mangle_rtti_type_class_name(tc_name::in, string::out, string::out, string::out) is det. @@ -1326,7 +1326,7 @@ mangle_rtti_type_class_name(TCName, ModuleName, ClassName, ArityStr) :- TCName = tc_name(ModuleNameSym, ClassName0, Arity), ModuleName = sym_name_mangle(ModuleNameSym), ClassName = name_mangle(ClassName0), - string__int_to_string(Arity, ArityStr). + string.int_to_string(Arity, ArityStr). %-----------------------------------------------------------------------------% @@ -1343,7 +1343,7 @@ type_info_to_string(TypeInfo) = Str :- Str = ModuleName ++ "__ti_" ++ TypeName ++ "_" ++ ArityStr ++ ArgsStr ; TypeInfo = var_arity_type_info(VarArityId, Args), - RealArity = list__length(Args), + RealArity = list.length(Args), ArgsStr = type_info_list_to_string(Args), IdStr = var_arity_ctor_id_to_string(VarArityId), Str = "__vti_" ++ IdStr ++ "_" ++ int_to_string(RealArity) ++ ArgsStr @@ -1362,13 +1362,13 @@ pseudo_type_info_to_string(PseudoTypeInfo) = Str :- Str = ModuleName ++ "__pti_" ++ TypeName ++ "_" ++ ArityStr ++ ArgsStr ; PseudoTypeInfo = var_arity_pseudo_type_info(VarArityId, Args), - RealArity = list__length(Args), + RealArity = list.length(Args), ArgsStr = maybe_pseudo_type_info_list_to_string(Args), IdStr = var_arity_ctor_id_to_string(VarArityId), Str = "__vpti_" ++ IdStr ++ "_" ++ int_to_string(RealArity) ++ ArgsStr ; PseudoTypeInfo = type_var(VarNum), - string__int_to_string(VarNum, Str) + string.int_to_string(VarNum, Str) ). :- func maybe_pseudo_type_info_to_string(rtti_maybe_pseudo_type_info) = string. @@ -1390,19 +1390,19 @@ var_arity_ctor_id_to_string(tuple_type_info) = "tuple". list(rtti_maybe_pseudo_type_info)) = string. maybe_pseudo_type_info_list_to_string(MaybePseudoTypeInfoList) = - string__append_list( - list__map(maybe_pseudo_type_info_to_string, MaybePseudoTypeInfoList)). + string.append_list( + list.map(maybe_pseudo_type_info_to_string, MaybePseudoTypeInfoList)). :- func pseudo_type_info_list_to_string(list(rtti_pseudo_type_info)) = string. pseudo_type_info_list_to_string(PseudoTypeInfoList) = - string__append_list( - list__map(pseudo_type_info_to_string, PseudoTypeInfoList)). + string.append_list( + list.map(pseudo_type_info_to_string, PseudoTypeInfoList)). :- func type_info_list_to_string(list(rtti_type_info)) = string. type_info_list_to_string(TypeInfoList) = - string__append_list(list__map(type_info_to_string, TypeInfoList)). + string.append_list(list.map(type_info_to_string, TypeInfoList)). %-----------------------------------------------------------------------------% @@ -1566,16 +1566,16 @@ maybe_pseudo_type_info_or_self_to_rtti_data(self) = type_ctor_details_num_ptags(enum(_, _, _, _, _)) = -1. type_ctor_details_num_ptags(du(_, _, PtagMap, _)) = LastPtag + 1 :- - map__keys(PtagMap, Ptags), - list__last_det(Ptags, LastPtag). + map.keys(PtagMap, Ptags), + list.last_det(Ptags, LastPtag). type_ctor_details_num_ptags(reserved(_, _, _, PtagMap, _)) = NumPtags :- - map__keys(PtagMap, Ptags), + map.keys(PtagMap, Ptags), ( Ptags = [], NumPtags = -1 ; Ptags = [_ | _], - list__last_det(Ptags, LastPtag), + list.last_det(Ptags, LastPtag), NumPtags = LastPtag + 1 ). type_ctor_details_num_ptags(notag(_, _)) = -1. @@ -1585,11 +1585,11 @@ type_ctor_details_num_ptags(impl_artifact(_)) = -1. type_ctor_details_num_ptags(foreign(_)) = -1. type_ctor_details_num_functors(enum(_, Functors, _, _, _)) = - list__length(Functors). + list.length(Functors). type_ctor_details_num_functors(du(_, Functors, _, _)) = - list__length(Functors). + list.length(Functors). type_ctor_details_num_functors(reserved(_, Functors, _, _, _)) = - list__length(Functors). + list.length(Functors). type_ctor_details_num_functors(notag(_, _)) = 1. type_ctor_details_num_functors(eqv(_)) = -1. type_ctor_details_num_functors(builtin(_)) = -1. @@ -1701,11 +1701,11 @@ rtti_id_c_type(tc_rtti_id(_, TCRttiName), CTypeName, IsArray) :- ctor_rtti_name_c_type(RttiName, CTypeName, IsArray) :- ctor_rtti_name_type(RttiName, GenTypeName, IsArray), - CTypeName = string__append("MR_", GenTypeName). + CTypeName = string.append("MR_", GenTypeName). tc_rtti_name_c_type(TCRttiName, CTypeName, IsArray) :- tc_rtti_name_type(TCRttiName, GenTypeName, IsArray), - CTypeName = string__append("MR_", GenTypeName). + CTypeName = string.append("MR_", GenTypeName). rtti_id_maybe_element_java_type(item_type(RttiId), CTypeName, IsArray) :- rtti_id_java_type(RttiId, CTypeName, IsArray). @@ -1736,7 +1736,7 @@ ctor_rtti_name_java_type(RttiName, JavaTypeName, IsArray) :- ; % In Java, every non-builtin type is a pointer, % so there's no need for the "Ptr" suffixes. - string__remove_suffix(GenTypeName0, "Ptr", GenTypeName1) + string.remove_suffix(GenTypeName0, "Ptr", GenTypeName1) -> JavaTypeName = "mercury.runtime." ++ GenTypeName1 ; @@ -1745,7 +1745,7 @@ ctor_rtti_name_java_type(RttiName, JavaTypeName, IsArray) :- % ending with arrays of the appropriate length, but in % Java we just use a single type for all of them % (with an extra level of indirection for the array). - string__prefix(GenTypeName0, "TypeClassConstraint_") + string.prefix(GenTypeName0, "TypeClassConstraint_") -> JavaTypeName = "mercury.runtime.TypeClassConstraint" ; @@ -1754,10 +1754,10 @@ ctor_rtti_name_java_type(RttiName, JavaTypeName, IsArray) :- % ending with arrays of the appropriate length, but in % Java we just use a single type for all of them % (with an extra level of indirection for the array). - ( string__prefix(GenTypeName0, "FA_PseudoTypeInfo_Struct") - ; string__prefix(GenTypeName0, "FA_TypeInfo_Struct") - ; string__prefix(GenTypeName0, "VA_PseudoTypeInfo_Struct") - ; string__prefix(GenTypeName0, "VA_TypeInfo_Struct") + ( string.prefix(GenTypeName0, "FA_PseudoTypeInfo_Struct") + ; string.prefix(GenTypeName0, "FA_TypeInfo_Struct") + ; string.prefix(GenTypeName0, "VA_PseudoTypeInfo_Struct") + ; string.prefix(GenTypeName0, "VA_TypeInfo_Struct") ) -> JavaTypeName = "mercury.runtime.TypeInfo_Struct" @@ -1786,7 +1786,7 @@ tc_rtti_name_java_type(TCRttiName, JavaTypeName, IsArray) :- % ending with arrays of the appropriate length, but in % Java we just use a single type for all of them % (with an extra level of indirection for the array). - string__prefix(GenTypeName, "TypeClassConstraint_") + string.prefix(GenTypeName, "TypeClassConstraint_") -> JavaTypeName = "mercury.runtime.TypeClassConstraint" ; @@ -1862,20 +1862,20 @@ tc_constraint_type_name(N) = type_info_name_type(plain_arity_zero_type_info(_)) = "TypeCtorInfo_Struct". type_info_name_type(plain_type_info(_, ArgTypes)) = - string__format("FA_TypeInfo_Struct%d", [i(list__length(ArgTypes))]). + string.format("FA_TypeInfo_Struct%d", [i(list.length(ArgTypes))]). type_info_name_type(var_arity_type_info(_, ArgTypes)) = - string__format("VA_TypeInfo_Struct%d", [i(list__length(ArgTypes))]). + string.format("VA_TypeInfo_Struct%d", [i(list.length(ArgTypes))]). :- func pseudo_type_info_name_type(rtti_pseudo_type_info) = string. pseudo_type_info_name_type(plain_arity_zero_pseudo_type_info(_)) = "TypeCtorInfo_Struct". pseudo_type_info_name_type(plain_pseudo_type_info(_TypeCtor, ArgTypes)) = - string__format("FA_PseudoTypeInfo_Struct%d", - [i(list__length(ArgTypes))]). + string.format("FA_PseudoTypeInfo_Struct%d", + [i(list.length(ArgTypes))]). pseudo_type_info_name_type(var_arity_pseudo_type_info(_TypeCtor, ArgTypes)) = - string__format("VA_PseudoTypeInfo_Struct%d", - [i(list__length(ArgTypes))]). + string.format("VA_PseudoTypeInfo_Struct%d", + [i(list.length(ArgTypes))]). pseudo_type_info_name_type(type_var(_)) = _ :- % we use small integers to represent type_vars, % rather than pointers, so there is no pointed-to type diff --git a/compiler/rtti_out.m b/compiler/rtti_out.m index 2173cfb88..7bc943c88 100644 --- a/compiler/rtti_out.m +++ b/compiler/rtti_out.m @@ -22,7 +22,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__rtti_out. +:- module ll_backend.rtti_out. :- interface. :- import_module backend_libs.rtti. @@ -64,14 +64,14 @@ % Output C code (e.g. a call to the MR_INIT_TYPE_CTOR_INFO() macro) % to initialize the rtti_data if necessary. % -:- pred rtti_out__init_rtti_data_if_nec(rtti_data::in, +:- pred init_rtti_data_if_nec(rtti_data::in, io::di, io::uo) is det. % Output C code (e.g. a call to MR_register_type_ctor_info()) to register % the rtti_data in the type tables, if it represents a data structure % that should be so registered. % -:- pred rtti_out__register_rtti_data_if_nec(rtti_data::in, io::di, io::uo) +:- pred register_rtti_data_if_nec(rtti_data::in, io::di, io::uo) is det. % Output the C name of the rtti_data specified by the given rtti_id. @@ -149,20 +149,20 @@ output_rtti_data_defn(type_class_instance(InstanceDecl), !DeclSet, !IO) :- output_base_typeclass_info_defn(TCName, InstanceModuleName, InstanceString, base_typeclass_info(N1, N2, N3, N4, N5, Methods), !DeclSet, !IO) :- - CodeAddrs = list__map(make_code_addr, Methods), - list__foldl2(output_code_addr_decls, CodeAddrs, !DeclSet, !IO), - io__write_string("\n", !IO), + CodeAddrs = list.map(make_code_addr, Methods), + list.foldl2(output_code_addr_decls, CodeAddrs, !DeclSet, !IO), + io.write_string("\n", !IO), RttiId = tc_rtti_id(TCName, base_typeclass_info(InstanceModuleName, InstanceString)), output_rtti_id_storage_type_name(RttiId, yes, !DeclSet, !IO), % XXX It would be nice to avoid generating redundant declarations % of base_typeclass_infos, but currently we don't. - io__write_string(" = {\n\t(MR_Code *) ", !IO), - io__write_list([N1, N2, N3, N4, N5], ",\n\t(MR_Code *) ", io__write_int, + io.write_string(" = {\n\t(MR_Code *) ", !IO), + io.write_list([N1, N2, N3, N4, N5], ",\n\t(MR_Code *) ", io.write_int, !IO), - io__write_string(",\n\t", !IO), - io__write_list(CodeAddrs, ",\n\t", output_static_code_addr, !IO), - io__write_string("\n};\n", !IO). + io.write_string(",\n\t", !IO), + io.write_list(CodeAddrs, ",\n\t", output_static_code_addr, !IO), + io.write_string("\n};\n", !IO). %-----------------------------------------------------------------------------% @@ -190,9 +190,9 @@ output_type_class_decl_defn(TCDecl, !DeclSet, !IO) :- TVarNames = [_ | _], output_generic_rtti_data_defn_start(TCIdVarNamesRttiId, !DeclSet, !IO), - io__write_string(" = {\n", !IO), - list__foldl(output_type_class_id_tvar_name, TVarNames, !IO), - io__write_string("};\n", !IO) + io.write_string(" = {\n", !IO), + list.foldl(output_type_class_id_tvar_name, TVarNames, !IO), + io.write_string("};\n", !IO) ), ( MethodIds = [] @@ -200,91 +200,91 @@ output_type_class_decl_defn(TCDecl, !DeclSet, !IO) :- MethodIds = [_ | _], output_generic_rtti_data_defn_start(TCIdMethodIdsRttiId, !DeclSet, !IO), - io__write_string(" = {\n", !IO), - list__foldl(output_type_class_id_method_id, MethodIds, !IO), - io__write_string("};\n", !IO) + io.write_string(" = {\n", !IO), + list.foldl(output_type_class_id_method_id, MethodIds, !IO), + io.write_string("};\n", !IO) ), - list__length(TVarNames, NumTVarNames), - list__length(MethodIds, NumMethodIds), + list.length(TVarNames, NumTVarNames), + list.length(MethodIds, NumMethodIds), output_generic_rtti_data_defn_start(TCIdRttiId, !DeclSet, !IO), - io__write_string(" = {\n\t""", !IO), - mdbcomp__prim_data__sym_name_to_string(ModuleSymName, ModuleName), - c_util__output_quoted_string(ModuleName, !IO), - io__write_string(""",\n\t""", !IO), - c_util__output_quoted_string(ClassName, !IO), - io__write_string(""",\n\t", !IO), - io__write_int(Arity, !IO), - io__write_string(",\n\t", !IO), - io__write_int(NumTVarNames, !IO), - io__write_string(",\n\t", !IO), - io__write_int(NumMethodIds, !IO), - io__write_string(",\n\t", !IO), + io.write_string(" = {\n\t""", !IO), + sym_name_to_string(ModuleSymName, ModuleName), + c_util.output_quoted_string(ModuleName, !IO), + io.write_string(""",\n\t""", !IO), + c_util.output_quoted_string(ClassName, !IO), + io.write_string(""",\n\t", !IO), + io.write_int(Arity, !IO), + io.write_string(",\n\t", !IO), + io.write_int(NumTVarNames, !IO), + io.write_string(",\n\t", !IO), + io.write_int(NumMethodIds, !IO), + io.write_string(",\n\t", !IO), ( TVarNames = [], - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ; TVarNames = [_ | _], output_rtti_id(TCIdVarNamesRttiId, !IO) ), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), ( MethodIds = [], - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ; MethodIds = [_ | _], output_rtti_id(TCIdMethodIdsRttiId, !IO) ), - io__write_string("\n};\n", !IO), + io.write_string("\n};\n", !IO), ( Supers = [] ; Supers = [_ | _], - list__map_foldl3(output_type_class_constraint( + list.map_foldl3(output_type_class_constraint( make_tc_decl_super_id(TCName)), Supers, SuperIds, - counter__init(1), _, !DeclSet, !IO), + counter.init(1), _, !DeclSet, !IO), output_generic_rtti_data_defn_start(TCDeclSupersRttiId, !DeclSet, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_cast_addr_of_rtti_ids("(MR_TypeClassConstraint) ", SuperIds, !IO), - io__write_string("};\n", !IO) + io.write_string("};\n", !IO) ), - list__length(Supers, NumSupers), + list.length(Supers, NumSupers), output_generic_rtti_data_defn_start(TCDeclRttiId, !DeclSet, !IO), - io__write_string(" = {\n\t&", !IO), + io.write_string(" = {\n\t&", !IO), output_rtti_id(TCIdRttiId, !IO), - io__write_string(",\n\t", !IO), - io__write_int(Version, !IO), - io__write_string(",\n\t", !IO), - io__write_int(NumSupers, !IO), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), + io.write_int(Version, !IO), + io.write_string(",\n\t", !IO), + io.write_int(NumSupers, !IO), + io.write_string(",\n\t", !IO), ( Supers = [], - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ; Supers = [_ | _], output_rtti_id(TCDeclSupersRttiId, !IO) ), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_type_class_id_tvar_name(string::in, io::di, io::uo) is det. output_type_class_id_tvar_name(TVarName, !IO) :- - io__write_string("\t""", !IO), - c_util__output_quoted_string(TVarName, !IO), - io__write_string(""",\n", !IO). + io.write_string("\t""", !IO), + c_util.output_quoted_string(TVarName, !IO), + io.write_string(""",\n", !IO). :- pred output_type_class_id_method_id(tc_method_id::in, io::di, io::uo) is det. output_type_class_id_method_id(MethodId, !IO) :- MethodId = tc_method_id(MethodName, MethodArity, PredOrFunc), - io__write_string("\t{ """, !IO), - c_util__output_quoted_string(MethodName, !IO), - io__write_string(""", ", !IO), - io__write_int(MethodArity, !IO), - io__write_string(", ", !IO), + io.write_string("\t{ """, !IO), + c_util.output_quoted_string(MethodName, !IO), + io.write_string(""", ", !IO), + io.write_int(MethodArity, !IO), + io.write_string(", ", !IO), output_pred_or_func(PredOrFunc, !IO), - io__write_string(" },\n", !IO). + io.write_string(" },\n", !IO). :- pred make_tc_decl_super_id(tc_name::in, int::in, int::in, rtti_id::out) is det. @@ -300,30 +300,30 @@ make_tc_decl_super_id(TCName, Ordinal, NumTypes, RttiId) :- output_type_class_instance_defn(Instance, !DeclSet, !IO) :- Instance = tc_instance(TCName, TCTypes, NumTypeVars, Constraints, _MethodProcLabels), - list__foldl2(output_maybe_pseudo_type_info_defn, TCTypes, !DeclSet, !IO), - TCTypeRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, TCTypes), + list.foldl2(output_maybe_pseudo_type_info_defn, TCTypes, !DeclSet, !IO), + TCTypeRttiDatas = list.map(maybe_pseudo_type_info_to_rtti_data, TCTypes), TCInstanceTypesRttiId = tc_rtti_id(TCName, type_class_instance_tc_type_vector(TCTypes)), output_generic_rtti_data_defn_start(TCInstanceTypesRttiId, !DeclSet, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", TCTypeRttiDatas, !IO), - io__write_string("};\n", !IO), + io.write_string("};\n", !IO), TCInstanceConstraintsRttiId = tc_rtti_id(TCName, type_class_instance_constraints(TCTypes)), ( Constraints = [] ; Constraints = [_ | _], - list__map_foldl3(output_type_class_constraint( + list.map_foldl3(output_type_class_constraint( make_tc_instance_constraint_id(TCName, TCTypes)), - Constraints, ConstraintIds, counter__init(1), _, !DeclSet, !IO), + Constraints, ConstraintIds, counter.init(1), _, !DeclSet, !IO), output_generic_rtti_data_defn_start(TCInstanceConstraintsRttiId, !DeclSet, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_cast_addr_of_rtti_ids("(MR_TypeClassConstraint) ", ConstraintIds, !IO), - io__write_string("};\n", !IO) + io.write_string("};\n", !IO) ), % TCInstanceMethodsRttiId = tc_rtti_id( % type_class_instance_methods(TCName, TCTypes)), @@ -331,45 +331,45 @@ output_type_class_instance_defn(Instance, !DeclSet, !IO) :- % MethodProcLabels = [] % ; % MethodProcLabels = [_ | _], -% MethodCodeAddrs = list__map(make_code_addr, MethodProcLabels), -% list__foldl2(output_code_addr_decls, MethodCodeAddrs, +% MethodCodeAddrs = list.map(make_code_addr, MethodProcLabels), +% list.foldl2(output_code_addr_decls, MethodCodeAddrs, % !DeclSet, !IO), % output_generic_rtti_data_defn_start(TCInstanceMethodsRttiId, % !DeclSet, !IO), -% io__write_string(" = {\n", !IO), -% list__foldl(output_code_addr_in_list, MethodCodeAddrs, !IO), -% io__write_string("};\n", !IO) +% io.write_string(" = {\n", !IO), +% list.foldl(output_code_addr_in_list, MethodCodeAddrs, !IO), +% io.write_string("};\n", !IO) % ), TCDeclRttiId = tc_rtti_id(TCName, type_class_decl), output_rtti_id_decls(TCDeclRttiId, "", "", 0, _, !DeclSet, !IO), TCInstanceRttiId = tc_rtti_id(TCName, type_class_instance(TCTypes)), output_generic_rtti_data_defn_start(TCInstanceRttiId, !DeclSet, !IO), - io__write_string(" = {\n\t&", !IO), + io.write_string(" = {\n\t&", !IO), output_rtti_id(TCDeclRttiId, !IO), - io__write_string(",\n\t", !IO), - io__write_int(NumTypeVars, !IO), - io__write_string(",\n\t", !IO), - io__write_int(list__length(Constraints), !IO), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), + io.write_int(NumTypeVars, !IO), + io.write_string(",\n\t", !IO), + io.write_int(list.length(Constraints), !IO), + io.write_string(",\n\t", !IO), output_rtti_id(TCInstanceTypesRttiId, !IO), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), ( Constraints = [], - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ; Constraints = [_ | _], output_rtti_id(TCInstanceConstraintsRttiId, !IO) ), -% io__write_string(",\n\t", !IO), +% io.write_string(",\n\t", !IO), % ( % MethodProcLabels = [], -% io__write_string("NULL", !IO) +% io.write_string("NULL", !IO) % ; % MethodProcLabels = [_ | _], -% io__write_string("&", !IO), +% io.write_string("&", !IO), % output_rtti_id(TCInstanceMethodsRttiId, !IO) % ), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred make_tc_instance_constraint_id(tc_name::in, list(tc_type)::in, int::in, int::in, rtti_id::out) is det. @@ -382,9 +382,9 @@ make_tc_instance_constraint_id(TCName, TCTypes, Ordinal, NumTypes, RttiId) :- io::di, io::uo) is det. output_code_addr_in_list(CodeAddr, !IO) :- - io__write_string("\t", !IO), + io.write_string("\t", !IO), output_static_code_addr(CodeAddr, !IO), - io__write_string(",\n", !IO). + io.write_string(",\n", !IO). %-----------------------------------------------------------------------------% @@ -396,19 +396,19 @@ output_code_addr_in_list(CodeAddr, !IO) :- output_type_class_constraint(MakeRttiId, Constraint, TCDeclSuperRttiId, !Counter, !DeclSet, !IO) :- Constraint = tc_constraint(TCName, Types), - list__length(Types, NumTypes), - counter__allocate(TCNum, !Counter), + list.length(Types, NumTypes), + counter.allocate(TCNum, !Counter), MakeRttiId(TCNum, NumTypes, TCDeclSuperRttiId), TCDeclRttiId = tc_rtti_id(TCName, type_class_decl), output_generic_rtti_data_decl(TCDeclRttiId, !DeclSet, !IO), - list__foldl2(output_maybe_pseudo_type_info_defn, Types, !DeclSet, !IO), - TypeRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, Types), + list.foldl2(output_maybe_pseudo_type_info_defn, Types, !DeclSet, !IO), + TypeRttiDatas = list.map(maybe_pseudo_type_info_to_rtti_data, Types), output_generic_rtti_data_defn_start(TCDeclSuperRttiId, !DeclSet, !IO), - io__write_string(" = {\n\t&", !IO), + io.write_string(" = {\n\t&", !IO), output_rtti_id(TCDeclRttiId, !IO), - io__write_string(",\n\t{\n", !IO), + io.write_string(",\n\t{\n", !IO), output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", TypeRttiDatas, !IO), - io__write_string("\t}\n};\n", !IO). + io.write_string("\t}\n};\n", !IO). %-----------------------------------------------------------------------------% @@ -457,32 +457,32 @@ do_output_type_info_defn(TypeInfo, !DeclSet, !IO) :- TypeInfo = plain_type_info(RttiTypeCtor, Args), TypeCtorRttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_info), output_rtti_id_decls(TypeCtorRttiId, "", "", 0, _, !DeclSet, !IO), - ArgRttiDatas = list__map(type_info_to_rtti_data, Args), + ArgRttiDatas = list.map(type_info_to_rtti_data, Args), output_type_ctor_arg_defns_and_decls(ArgRttiDatas, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, type_info(TypeInfo)), !DeclSet, !IO), - io__write_string(" = {\n\t&", !IO), + io.write_string(" = {\n\t&", !IO), output_ctor_rtti_id(RttiTypeCtor, type_ctor_info, !IO), - io__write_string(",\n{", !IO), + io.write_string(",\n{", !IO), output_cast_addr_of_rtti_datas("(MR_TypeInfo) ", ArgRttiDatas, !IO), - io__write_string("}};\n", !IO). + io.write_string("}};\n", !IO). do_output_type_info_defn(TypeInfo, !DeclSet, !IO) :- TypeInfo = var_arity_type_info(RttiVarArityId, Args), RttiTypeCtor = var_arity_id_to_rtti_type_ctor(RttiVarArityId), TypeCtorRttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_info), output_rtti_id_decls(TypeCtorRttiId, "", "", 0, _, !DeclSet, !IO), - ArgRttiDatas = list__map(type_info_to_rtti_data, Args), + ArgRttiDatas = list.map(type_info_to_rtti_data, Args), output_type_ctor_arg_defns_and_decls(ArgRttiDatas, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, type_info(TypeInfo)), !DeclSet, !IO), - io__write_string(" = {\n\t&", !IO), + io.write_string(" = {\n\t&", !IO), output_ctor_rtti_id(RttiTypeCtor, type_ctor_info, !IO), - io__write_string(",\n\t", !IO), - list__length(Args, Arity), - io__write_int(Arity, !IO), - io__write_string(",\n{", !IO), + io.write_string(",\n\t", !IO), + list.length(Args, Arity), + io.write_int(Arity, !IO), + io.write_string(",\n{", !IO), output_cast_addr_of_rtti_datas("(MR_TypeInfo) ", ArgRttiDatas, !IO), - io__write_string("}};\n", !IO). + io.write_string("}};\n", !IO). :- pred output_pseudo_type_info_defn(rtti_pseudo_type_info::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -513,34 +513,34 @@ do_output_pseudo_type_info_defn(PseudoTypeInfo, !DeclSet, !IO) :- PseudoTypeInfo = plain_pseudo_type_info(RttiTypeCtor, Args), TypeCtorRttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_info), output_rtti_id_decls(TypeCtorRttiId, "", "", 0, _, !DeclSet, !IO), - ArgRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, Args), + ArgRttiDatas = list.map(maybe_pseudo_type_info_to_rtti_data, Args), output_type_ctor_arg_defns_and_decls(ArgRttiDatas, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, pseudo_type_info(PseudoTypeInfo)), !DeclSet, !IO), - io__write_string(" = {\n\t&", !IO), + io.write_string(" = {\n\t&", !IO), output_ctor_rtti_id(RttiTypeCtor, type_ctor_info, !IO), - io__write_string(",\n{", !IO), + io.write_string(",\n{", !IO), output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", ArgRttiDatas, !IO), - io__write_string("}};\n", !IO). + io.write_string("}};\n", !IO). do_output_pseudo_type_info_defn(PseudoTypeInfo, !DeclSet, !IO) :- PseudoTypeInfo = var_arity_pseudo_type_info(RttiVarArityId, Args), RttiTypeCtor = var_arity_id_to_rtti_type_ctor(RttiVarArityId), TypeCtorRttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_info), output_rtti_id_decls(TypeCtorRttiId, "", "", 0, _, !DeclSet, !IO), - ArgRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, Args), + ArgRttiDatas = list.map(maybe_pseudo_type_info_to_rtti_data, Args), output_type_ctor_arg_defns_and_decls(ArgRttiDatas, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, pseudo_type_info(PseudoTypeInfo)), !DeclSet, !IO), - io__write_string(" = {\n\t&", !IO), + io.write_string(" = {\n\t&", !IO), output_ctor_rtti_id(RttiTypeCtor, type_ctor_info, !IO), - io__write_string(",\n\t", !IO), - list__length(Args, Arity), - io__write_int(Arity, !IO), - io__write_string(",\n{", !IO), + io.write_string(",\n\t", !IO), + list.length(Args, Arity), + io.write_int(Arity, !IO), + io.write_string(",\n{", !IO), output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", ArgRttiDatas, !IO), - io__write_string("}};\n", !IO). + io.write_string("}};\n", !IO). do_output_pseudo_type_info_defn(type_var(_), !DeclSet, !IO). :- pred output_type_ctor_arg_defns_and_decls(list(rtti_data)::in, @@ -553,7 +553,7 @@ output_type_ctor_arg_defns_and_decls(ArgRttiDatas, !DeclSet, !IO) :- % zero arity typeinfos and pseudo-typeinfos have empty definitions, % yet the type_ctor_info they refer to still must be declared. % This is why both calls below are needed. - list__foldl2(output_rtti_data_defn, ArgRttiDatas, !DeclSet, !IO), + list.foldl2(output_rtti_data_defn, ArgRttiDatas, !DeclSet, !IO), output_rtti_datas_decls(ArgRttiDatas, "", "", 0, _, !DeclSet, !IO). %-----------------------------------------------------------------------------% @@ -572,68 +572,68 @@ output_type_ctor_data_defn(TypeCtorData, !DeclSet, !IO) :- det_univ_to_type(CompareUniv, CompareProcLabel), CompareCodeAddr = make_code_addr(CompareProcLabel), CodeAddrs = [UnifyCodeAddr, CompareCodeAddr], - list__foldl2(output_code_addr_decls, CodeAddrs, !DeclSet, !IO), + list.foldl2(output_code_addr_decls, CodeAddrs, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, type_ctor_info), !DeclSet, !IO), - io__write_string(" = {\n\t", !IO), - io__write_int(TypeArity, !IO), - io__write_string(",\n\t", !IO), - io__write_int(Version, !IO), - io__write_string(",\n\t", !IO), - io__write_int(type_ctor_details_num_ptags(TypeCtorDetails), !IO), - io__write_string(",\n\t", !IO), - rtti__type_ctor_rep_to_string(TypeCtorData, CtorRepStr), - io__write_string(CtorRepStr, !IO), - io__write_string(",\n\t", !IO), + io.write_string(" = {\n\t", !IO), + io.write_int(TypeArity, !IO), + io.write_string(",\n\t", !IO), + io.write_int(Version, !IO), + io.write_string(",\n\t", !IO), + io.write_int(type_ctor_details_num_ptags(TypeCtorDetails), !IO), + io.write_string(",\n\t", !IO), + rtti.type_ctor_rep_to_string(TypeCtorData, CtorRepStr), + io.write_string(CtorRepStr, !IO), + io.write_string(",\n\t", !IO), output_static_code_addr(UnifyCodeAddr, !IO), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), output_static_code_addr(CompareCodeAddr, !IO), - io__write_string(",\n\t""", !IO), - mdbcomp__prim_data__sym_name_to_string(Module, ModuleName), - c_util__output_quoted_string(ModuleName, !IO), - io__write_string(""",\n\t""", !IO), - c_util__output_quoted_string(TypeName, !IO), - io__write_string(""",\n\t", !IO), + io.write_string(",\n\t""", !IO), + sym_name_to_string(Module, ModuleName), + c_util.output_quoted_string(ModuleName, !IO), + io.write_string(""",\n\t""", !IO), + c_util.output_quoted_string(TypeName, !IO), + io.write_string(""",\n\t", !IO), ( MaybeFunctorsName = yes(FunctorsName), FunctorsRttiId = ctor_rtti_id(RttiTypeCtor, FunctorsName), - io__write_string("{ ", !IO), + io.write_string("{ ", !IO), output_cast_addr_of_rtti_id("(void *)", FunctorsRttiId, !IO), - io__write_string(" }", !IO) + io.write_string(" }", !IO) ; MaybeFunctorsName = no, - io__write_string("{ 0 }", !IO) + io.write_string("{ 0 }", !IO) ), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), ( MaybeLayoutName = yes(LayoutName), LayoutRttiId = ctor_rtti_id(RttiTypeCtor, LayoutName), - io__write_string("{ ", !IO), + io.write_string("{ ", !IO), output_cast_addr_of_rtti_id("(void *)", LayoutRttiId, !IO), - io__write_string(" }", !IO) + io.write_string(" }", !IO) ; MaybeLayoutName = no, - io__write_string("{ 0 }", !IO) + io.write_string("{ 0 }", !IO) ), - io__write_string(",\n\t", !IO), - io__write_int(type_ctor_details_num_functors(TypeCtorDetails), !IO), - io__write_string(",\n\t", !IO), - io__write_int(encode_type_ctor_flags(Flags), !IO), + io.write_string(",\n\t", !IO), + io.write_int(type_ctor_details_num_functors(TypeCtorDetails), !IO), + io.write_string(",\n\t", !IO), + io.write_int(encode_type_ctor_flags(Flags), !IO), % This code is commented out while the corresponding fields of the % MR_TypeCtorInfo_Struct type are commented out. % -% io__write_string(",\n\t"), +% io.write_string(",\n\t"), % ( % { MaybeHashCons = yes(HashConsDataAddr) }, -% io__write_string("&"), +% io.write_string("&"), % output_ctor_rtti_id(RttiTypeCtor, HashConsDataAddr) % ; % { MaybeHashCons = no }, -% io__write_string("NULL") +% io.write_string("NULL") % ), -% io__write_string(",\n\t"), +% io.write_string(",\n\t"), % output_maybe_static_code_addr(Prettyprinter), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_type_ctor_details_defn(rtti_type_ctor::in, type_ctor_details::in, @@ -645,7 +645,7 @@ output_type_ctor_details_defn(RttiTypeCtor, TypeCtorDetails, ( TypeCtorDetails = enum(_, EnumFunctors, EnumByRep, EnumByName, _IsDummy), - list__foldl2(output_enum_functor_defn(RttiTypeCtor), EnumFunctors, + list.foldl2(output_enum_functor_defn(RttiTypeCtor), EnumFunctors, !DeclSet, !IO), output_enum_value_ordered_table(RttiTypeCtor, EnumByRep, !DeclSet, !IO), @@ -655,7 +655,7 @@ output_type_ctor_details_defn(RttiTypeCtor, TypeCtorDetails, MaybeFunctorsName = yes(enum_name_ordered_table) ; TypeCtorDetails = du(_, DuFunctors, DuByRep, DuByName), - list__foldl2(output_du_functor_defn(RttiTypeCtor), DuFunctors, + list.foldl2(output_du_functor_defn(RttiTypeCtor), DuFunctors, !DeclSet, !IO), output_du_ptag_ordered_table(RttiTypeCtor, DuByRep, !DeclSet, !IO), output_du_name_ordered_table(RttiTypeCtor, DuByName, !DeclSet, !IO), @@ -664,7 +664,7 @@ output_type_ctor_details_defn(RttiTypeCtor, TypeCtorDetails, ; TypeCtorDetails = reserved(_, MaybeResFunctors, ResFunctors, DuByRep, MaybeResByName), - list__foldl2(output_maybe_res_functor_defn(RttiTypeCtor), + list.foldl2(output_maybe_res_functor_defn(RttiTypeCtor), MaybeResFunctors, !DeclSet, !IO), output_res_value_ordered_table(RttiTypeCtor, ResFunctors, DuByRep, !DeclSet, !IO), @@ -715,11 +715,11 @@ output_enum_functor_defn(RttiTypeCtor, EnumFunctor, !DeclSet, !IO) :- EnumFunctor = enum_functor(FunctorName, Ordinal), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, enum_functor_desc(Ordinal)), !DeclSet, !IO), - io__write_string(" = {\n\t""", !IO), - c_util__output_quoted_string(FunctorName, !IO), - io__write_string(""",\n\t", !IO), - io__write_int(Ordinal, !IO), - io__write_string("\n};\n", !IO). + io.write_string(" = {\n\t""", !IO), + c_util.output_quoted_string(FunctorName, !IO), + io.write_string(""",\n\t", !IO), + io.write_int(Ordinal, !IO), + io.write_string("\n};\n", !IO). :- pred output_notag_functor_defn(rtti_type_ctor::in, notag_functor::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -731,9 +731,9 @@ output_notag_functor_defn(RttiTypeCtor, NotagFunctor, !DeclSet, !IO) :- output_rtti_data_decls(ArgTypeData, "", "", 0, _, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, notag_functor_desc), !DeclSet, !IO), - io__write_string(" = {\n\t""", !IO), - c_util__output_quoted_string(FunctorName, !IO), - io__write_string(""",\n\t", !IO), + io.write_string(" = {\n\t""", !IO), + c_util.output_quoted_string(FunctorName, !IO), + io.write_string(""",\n\t", !IO), ( ArgType = plain(ArgTypeInfo), output_cast_addr_of_rtti_data("(MR_PseudoTypeInfo) ", @@ -745,17 +745,17 @@ output_notag_functor_defn(RttiTypeCtor, NotagFunctor, !DeclSet, !IO) :- output_cast_addr_of_rtti_data("(MR_PseudoTypeInfo) ", pseudo_type_info(ArgPseudoTypeInfo), !IO) ), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), ( MaybeArgName = yes(ArgName), - io__write_string("""", !IO), - io__write_string(ArgName, !IO), - io__write_string("""", !IO) + io.write_string("""", !IO), + io.write_string(ArgName, !IO), + io.write_string("""", !IO) ; MaybeArgName = no, - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_du_functor_defn(rtti_type_ctor::in, du_functor::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -763,9 +763,9 @@ output_notag_functor_defn(RttiTypeCtor, NotagFunctor, !DeclSet, !IO) :- output_du_functor_defn(RttiTypeCtor, DuFunctor, !DeclSet, !IO) :- DuFunctor = du_functor(FunctorName, OrigArity, Ordinal, Rep, ArgInfos, MaybeExistInfo), - ArgTypes = list__map(du_arg_info_type, ArgInfos), - MaybeArgNames = list__map(du_arg_info_name, ArgInfos), - ArgNames = list__filter_map(project_yes, MaybeArgNames), + ArgTypes = list.map(du_arg_info_type, ArgInfos), + MaybeArgNames = list.map(du_arg_info_name, ArgInfos), + ArgNames = list.filter_map(project_yes, MaybeArgNames), ( ArgInfos = [_ | _], output_du_arg_types(RttiTypeCtor, Ordinal, ArgTypes, !DeclSet, !IO) @@ -787,14 +787,14 @@ output_du_functor_defn(RttiTypeCtor, DuFunctor, !DeclSet, !IO) :- ), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, du_functor_desc(Ordinal)), !DeclSet, !IO), - io__write_string(" = {\n\t""", !IO), - c_util__output_quoted_string(FunctorName, !IO), - io__write_string(""",\n\t", !IO), - io__write_int(OrigArity, !IO), - io__write_string(",\n\t", !IO), + io.write_string(" = {\n\t""", !IO), + c_util.output_quoted_string(FunctorName, !IO), + io.write_string(""",\n\t", !IO), + io.write_int(OrigArity, !IO), + io.write_string(",\n\t", !IO), ContainsVarBitVector = compute_contains_var_bit_vector(ArgTypes), - io__write_int(ContainsVarBitVector, !IO), - io__write_string(",\n\t", !IO), + io.write_int(ContainsVarBitVector, !IO), + io.write_string(",\n\t", !IO), ( Rep = du_ll_rep(Ptag, SectagAndLocn) ; @@ -812,39 +812,39 @@ output_du_functor_defn(RttiTypeCtor, DuFunctor, !DeclSet, !IO) :- SectagAndLocn = sectag_remote(Stag), Locn = "MR_SECTAG_REMOTE" ), - io__write_string(Locn, !IO), - io__write_string(",\n\t", !IO), - io__write_int(Ptag, !IO), - io__write_string(",\n\t", !IO), - io__write_int(Stag, !IO), - io__write_string(",\n\t", !IO), - io__write_int(Ordinal, !IO), - io__write_string(",\n\t", !IO), - io__write_string("(MR_PseudoTypeInfo *) ", !IO), % cast away const + io.write_string(Locn, !IO), + io.write_string(",\n\t", !IO), + io.write_int(Ptag, !IO), + io.write_string(",\n\t", !IO), + io.write_int(Stag, !IO), + io.write_string(",\n\t", !IO), + io.write_int(Ordinal, !IO), + io.write_string(",\n\t", !IO), + io.write_string("(MR_PseudoTypeInfo *) ", !IO), % cast away const ( ArgInfos = [_ | _], output_addr_of_ctor_rtti_id(RttiTypeCtor, field_types(Ordinal), !IO) ; ArgInfos = [], - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), ( ArgNames = [_ | _], output_addr_of_ctor_rtti_id(RttiTypeCtor, field_names(Ordinal), !IO) ; ArgNames = [], - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), ( MaybeExistInfo = yes(_), output_addr_of_ctor_rtti_id(RttiTypeCtor, exist_info(Ordinal), !IO) ; MaybeExistInfo = no, - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_res_functor_defn(rtti_type_ctor::in, reserved_functor::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -853,24 +853,24 @@ output_res_functor_defn(RttiTypeCtor, ResFunctor, !DeclSet, !IO) :- ResFunctor = reserved_functor(FunctorName, Ordinal, Rep), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, res_functor_desc(Ordinal)), !DeclSet, !IO), - io__write_string(" = {\n\t""", !IO), - c_util__output_quoted_string(FunctorName, !IO), - io__write_string(""",\n\t", !IO), - io__write_int(Ordinal, !IO), - io__write_string(",\n\t", !IO), - io__write_string("(void *) ", !IO), + io.write_string(" = {\n\t""", !IO), + c_util.output_quoted_string(FunctorName, !IO), + io.write_string(""",\n\t", !IO), + io.write_int(Ordinal, !IO), + io.write_string(",\n\t", !IO), + io.write_string("(void *) ", !IO), ( Rep = null_pointer, - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ; Rep = small_pointer(SmallPtr), - io__write_int(SmallPtr, !IO) + io.write_int(SmallPtr, !IO) ; Rep = reserved_object(_, _, _), unexpected(this_file, "output_res_functor_defn: reserved object") ), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_maybe_res_functor_defn(rtti_type_ctor::in, maybe_reserved_functor::in, decl_set::in, decl_set::out, @@ -899,11 +899,11 @@ output_exist_locns_array(RttiTypeCtor, Ordinal, Locns, !DeclSet, !IO) :- % place a dummy value in the array if necessary. Locns = [] -> - io__write_string("= { {0, 0} };\n", !IO) + io.write_string("= { {0, 0} };\n", !IO) ; - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_exist_locns(Locns, !IO), - io__write_string("};\n", !IO) + io.write_string("};\n", !IO) ). :- pred make_exist_tc_constr_id(rtti_type_ctor::in, int::in, @@ -919,15 +919,15 @@ make_exist_tc_constr_id(RttiTypeCtor, Ordinal, TCNum, Arity, RttiId) :- output_exist_constraints_data(RttiTypeCtor, Ordinal, Constraints, !DeclSet, !IO) :- - list__map_foldl3(output_type_class_constraint( + list.map_foldl3(output_type_class_constraint( make_exist_tc_constr_id(RttiTypeCtor, Ordinal)), Constraints, - ConstraintIds, counter__init(1), _, !DeclSet, !IO), + ConstraintIds, counter.init(1), _, !DeclSet, !IO), RttiId = ctor_rtti_id(RttiTypeCtor, exist_tc_constrs(Ordinal)), output_generic_rtti_data_defn_start(RttiId, !DeclSet, !IO), - io__write_string(" = {\n\t", !IO), + io.write_string(" = {\n\t", !IO), output_cast_addr_of_rtti_ids("(MR_TypeClassConstraint) ", ConstraintIds, !IO), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_exist_info(rtti_type_ctor::in, int::in, exist_info::in, decl_set::in, decl_set::out, io::di, io::uo) is det. @@ -945,41 +945,41 @@ output_exist_info(RttiTypeCtor, Ordinal, ExistInfo, !DeclSet, !IO) :- ), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, exist_info(Ordinal)), !DeclSet, !IO), - io__write_string(" = {\n\t", !IO), - io__write_int(Plain, !IO), - io__write_string(",\n\t", !IO), - io__write_int(InTci, !IO), - io__write_string(",\n\t", !IO), - list__length(Constraints, Tci), - io__write_int(Tci, !IO), - io__write_string(",\n\t", !IO), + io.write_string(" = {\n\t", !IO), + io.write_int(Plain, !IO), + io.write_string(",\n\t", !IO), + io.write_int(InTci, !IO), + io.write_string(",\n\t", !IO), + list.length(Constraints, Tci), + io.write_int(Tci, !IO), + io.write_string(",\n\t", !IO), output_ctor_rtti_id(RttiTypeCtor, exist_locns(Ordinal), !IO), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), ( Constraints = [_ | _], output_ctor_rtti_id(RttiTypeCtor, exist_tc_constrs(Ordinal), !IO) ; Constraints = [] ), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_du_arg_types(rtti_type_ctor::in, int::in, list(rtti_maybe_pseudo_type_info_or_self)::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_du_arg_types(RttiTypeCtor, Ordinal, ArgTypes, !DeclSet, !IO) :- - list__foldl2(output_maybe_pseudo_type_info_or_self_defn, ArgTypes, + list.foldl2(output_maybe_pseudo_type_info_or_self_defn, ArgTypes, !DeclSet, !IO), - ArgTypeDatas = list__map(maybe_pseudo_type_info_or_self_to_rtti_data, + ArgTypeDatas = list.map(maybe_pseudo_type_info_or_self_to_rtti_data, ArgTypes), output_rtti_datas_decls(ArgTypeDatas, "", "", 0, _, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, field_types(Ordinal)), !DeclSet, !IO), - io__write_string(" = {\n", !IO), - expect(list__is_not_empty(ArgTypes), this_file, + io.write_string(" = {\n", !IO), + expect(list.is_not_empty(ArgTypes), this_file, "output_du_arg_types: empty list"), output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", ArgTypeDatas, !IO), - io__write_string("};\n", !IO). + io.write_string("};\n", !IO). :- pred output_du_arg_names(rtti_type_ctor::in, int::in, list(maybe(string))::in, decl_set::in, decl_set::out, @@ -988,11 +988,11 @@ output_du_arg_types(RttiTypeCtor, Ordinal, ArgTypes, !DeclSet, !IO) :- output_du_arg_names(RttiTypeCtor, Ordinal, MaybeNames, !DeclSet, !IO) :- output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, field_names(Ordinal)), !DeclSet, !IO), - io__write_string(" = {\n", !IO), - expect(list__is_not_empty(MaybeNames), + io.write_string(" = {\n", !IO), + expect(list.is_not_empty(MaybeNames), this_file, "output_du_arg_names: empty list"), output_maybe_quoted_strings(MaybeNames, !IO), - io__write_string("};\n", !IO). + io.write_string("};\n", !IO). %-----------------------------------------------------------------------------% @@ -1001,42 +1001,42 @@ output_du_arg_names(RttiTypeCtor, Ordinal, MaybeNames, !DeclSet, !IO) :- io::di, io::uo) is det. output_enum_value_ordered_table(RttiTypeCtor, FunctorMap, !DeclSet, !IO) :- - Functors = map__values(FunctorMap), - FunctorRttiNames = list__map(enum_functor_rtti_name, Functors), + Functors = map.values(FunctorMap), + FunctorRttiNames = list.map(enum_functor_rtti_name, Functors), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, enum_value_ordered_table), !DeclSet, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_addr_of_ctor_rtti_names(RttiTypeCtor, FunctorRttiNames, !IO), - io__write_string("};\n", !IO). + io.write_string("};\n", !IO). :- pred output_enum_name_ordered_table(rtti_type_ctor::in, map(string, enum_functor)::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_enum_name_ordered_table(RttiTypeCtor, FunctorMap, !DeclSet, !IO) :- - Functors = map__values(FunctorMap), - FunctorRttiNames = list__map(enum_functor_rtti_name, Functors), + Functors = map.values(FunctorMap), + FunctorRttiNames = list.map(enum_functor_rtti_name, Functors), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, enum_name_ordered_table), !DeclSet, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_addr_of_ctor_rtti_names(RttiTypeCtor, FunctorRttiNames, !IO), - io__write_string("};\n", !IO). + io.write_string("};\n", !IO). :- pred output_du_name_ordered_table(rtti_type_ctor::in, map(string, map(int, du_functor))::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_du_name_ordered_table(RttiTypeCtor, NameArityMap, !DeclSet, !IO) :- - map__values(NameArityMap, ArityMaps), - list__map(map__values, ArityMaps, FunctorLists), - list__condense(FunctorLists, Functors), - FunctorRttiNames = list__map(du_functor_rtti_name, Functors), + map.values(NameArityMap, ArityMaps), + list.map(map.values, ArityMaps, FunctorLists), + list.condense(FunctorLists, Functors), + FunctorRttiNames = list.map(du_functor_rtti_name, Functors), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, du_name_ordered_table), !DeclSet, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_addr_of_ctor_rtti_names(RttiTypeCtor, FunctorRttiNames, !IO), - io__write_string("};\n", !IO). + io.write_string("};\n", !IO). :- pred output_du_stag_ordered_table(rtti_type_ctor::in, pair(int, sectag_table)::in, decl_set::in, decl_set::out, @@ -1045,26 +1045,26 @@ output_du_name_ordered_table(RttiTypeCtor, NameArityMap, !DeclSet, !IO) :- output_du_stag_ordered_table(RttiTypeCtor, Ptag - SectagTable, !DeclSet, !IO) :- SectagTable = sectag_table(_SectagLocn, _NumSharers, SectagMap), - map__values(SectagMap, SectagFunctors), - FunctorNames = list__map(du_functor_rtti_name, SectagFunctors), + map.values(SectagMap, SectagFunctors), + FunctorNames = list.map(du_functor_rtti_name, SectagFunctors), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, du_stag_ordered_table(Ptag)), !DeclSet, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), output_addr_of_ctor_rtti_names(RttiTypeCtor, FunctorNames, !IO), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_du_ptag_ordered_table(rtti_type_ctor::in, map(int, sectag_table)::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_du_ptag_ordered_table(RttiTypeCtor, PtagMap, !DeclSet, !IO) :- - map__to_assoc_list(PtagMap, PtagList), - list__foldl2(output_du_stag_ordered_table(RttiTypeCtor), PtagList, + map.to_assoc_list(PtagMap, PtagList), + list.foldl2(output_du_stag_ordered_table(RttiTypeCtor), PtagList, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, du_ptag_ordered_table), !DeclSet, !IO), - io__write_string(" = {\n", !IO), + io.write_string(" = {\n", !IO), ( PtagList = [1 - _ | _] -> % Output a dummy ptag definition for the reserved tag first. output_dummy_ptag_layout_defn(!IO), @@ -1075,7 +1075,7 @@ output_du_ptag_ordered_table(RttiTypeCtor, PtagMap, !DeclSet, !IO) :- unexpected(this_file, "output_dummy_ptag_layout_defn: bad ptag list") ), output_du_ptag_ordered_table_body(RttiTypeCtor, PtagList, FirstPtag, !IO), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_du_ptag_ordered_table_body(rtti_type_ctor::in, assoc_list(int, sectag_table)::in, int::in, io::di, io::uo) is det. @@ -1086,19 +1086,19 @@ output_du_ptag_ordered_table_body(RttiTypeCtor, expect(unify(Ptag, CurPtag), this_file, "output_du_ptag_ordered_table_body: ptag mismatch"), SectagTable = sectag_table(SectagLocn, NumSharers, _SectagMap), - io__write_string("\t{ ", !IO), - io__write_int(NumSharers, !IO), - io__write_string(", ", !IO), - rtti__sectag_locn_to_string(SectagLocn, LocnStr), - io__write_string(LocnStr, !IO), - io__write_string(",\n\t", !IO), + io.write_string("\t{ ", !IO), + io.write_int(NumSharers, !IO), + io.write_string(", ", !IO), + rtti.sectag_locn_to_string(SectagLocn, LocnStr), + io.write_string(LocnStr, !IO), + io.write_string(",\n\t", !IO), output_ctor_rtti_id(RttiTypeCtor, du_stag_ordered_table(Ptag), !IO), ( PtagTail = [], - io__write_string(" }\n", !IO) + io.write_string(" }\n", !IO) ; PtagTail = [_ | _], - io__write_string(" },\n", !IO), + io.write_string(" },\n", !IO), output_du_ptag_ordered_table_body(RttiTypeCtor, PtagTail, CurPtag + 1, !IO) ). @@ -1113,14 +1113,14 @@ output_du_ptag_ordered_table_body(RttiTypeCtor, :- pred output_dummy_ptag_layout_defn(io::di, io::uo) is det. output_dummy_ptag_layout_defn(!IO) :- - io__write_string("\t{ 0, MR_SECTAG_VARIABLE, NULL },\n", !IO). + io.write_string("\t{ 0, MR_SECTAG_VARIABLE, NULL },\n", !IO). :- pred output_res_addr_functors(rtti_type_ctor::in, reserved_functor::in, io::di, io::uo) is det. output_res_addr_functors(RttiTypeCtor, ResFunctor, !IO) :- output_ctor_rtti_id(RttiTypeCtor, res_functor_rtti_name(ResFunctor), !IO), - io__write_string(",\n", !IO). + io.write_string(",\n", !IO). :- pred output_res_value_ordered_table(rtti_type_ctor::in, list(reserved_functor)::in, map(int, sectag_table)::in, @@ -1128,91 +1128,91 @@ output_res_addr_functors(RttiTypeCtor, ResFunctor, !IO) :- output_res_value_ordered_table(RttiTypeCtor, ResFunctors, DuPtagTable, !DeclSet, !IO) :- - ResFunctorReps = list__map(res_addr_rep, ResFunctors), - list__filter(res_addr_is_numeric, ResFunctorReps, + ResFunctorReps = list.map(res_addr_rep, ResFunctors), + list.filter(res_addr_is_numeric, ResFunctorReps, NumericResFunctorReps, SymbolicResFunctorReps), - list__length(NumericResFunctorReps, NumNumericResFunctorReps), - list__length(SymbolicResFunctorReps, NumSymbolicResFunctorReps), + list.length(NumericResFunctorReps, NumNumericResFunctorReps), + list.length(SymbolicResFunctorReps, NumSymbolicResFunctorReps), expect(unify(NumSymbolicResFunctorReps, 0), this_file, "output_res_value_ordered_table: symbolic functors"), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, res_addr_functors), !DeclSet, !IO), - io__write_string(" = {\n", !IO), - list__foldl(output_res_addr_functors(RttiTypeCtor), ResFunctors, !IO), - io__write_string("};\n", !IO), + io.write_string(" = {\n", !IO), + list.foldl(output_res_addr_functors(RttiTypeCtor), ResFunctors, !IO), + io.write_string("};\n", !IO), output_du_ptag_ordered_table(RttiTypeCtor, DuPtagTable, !DeclSet, !IO), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, res_value_ordered_table), !DeclSet, !IO), - io__write_string(" = {\n\t""", !IO), - io__write_int(NumNumericResFunctorReps, !IO), - io__write_string(",\n\t", !IO), - io__write_int(NumSymbolicResFunctorReps, !IO), - io__write_string(",\n\t", !IO), - io__write_string("NULL", !IO), - io__write_string(",\n\t", !IO), + io.write_string(" = {\n\t""", !IO), + io.write_int(NumNumericResFunctorReps, !IO), + io.write_string(",\n\t", !IO), + io.write_int(NumSymbolicResFunctorReps, !IO), + io.write_string(",\n\t", !IO), + io.write_string("NULL", !IO), + io.write_string(",\n\t", !IO), output_ctor_rtti_id(RttiTypeCtor, res_addr_functors, !IO), - io__write_string(",\n\t", !IO), + io.write_string(",\n\t", !IO), output_ctor_rtti_id(RttiTypeCtor, du_ptag_ordered_table, !IO), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_res_name_ordered_table(rtti_type_ctor::in, map(string, map(int, maybe_reserved_functor))::in, decl_set::in, decl_set::out, io::di, io::uo) is det. output_res_name_ordered_table(RttiTypeCtor, NameArityMap, !DeclSet, !IO) :- - map__values(NameArityMap, ArityMaps), - list__map(map__values, ArityMaps, FunctorLists), - list__condense(FunctorLists, Functors), + map.values(NameArityMap, ArityMaps), + list.map(map.values, ArityMaps, FunctorLists), + list.condense(FunctorLists, Functors), output_generic_rtti_data_defn_start( ctor_rtti_id(RttiTypeCtor, res_name_ordered_table), !DeclSet, !IO), - io__write_string(" = {\n\t""", !IO), - list__foldl(output_res_name_ordered_table_element(RttiTypeCtor), Functors, + io.write_string(" = {\n\t""", !IO), + list.foldl(output_res_name_ordered_table_element(RttiTypeCtor), Functors, !IO), - io__write_string("\n};\n", !IO). + io.write_string("\n};\n", !IO). :- pred output_res_name_ordered_table_element(rtti_type_ctor::in, maybe_reserved_functor::in, io::di, io::uo) is det. output_res_name_ordered_table_element(RttiTypeCtor, MaybeResFunctor, !IO) :- - io__write_string("\t{ """, !IO), + io.write_string("\t{ """, !IO), ( MaybeResFunctor = res_func(ResFunctor), Name = ResFunctor ^ res_name, - io__write_string(Name, !IO), - io__write_string(""", ", !IO), - io__write_string("0, ", !IO), - io__write_string("MR_TRUE, ", !IO) + io.write_string(Name, !IO), + io.write_string(""", ", !IO), + io.write_string("0, ", !IO), + io.write_string("MR_TRUE, ", !IO) ; MaybeResFunctor = du_func(DuFunctor), Name = DuFunctor ^ du_name, Arity = DuFunctor ^ du_orig_arity, - io__write_string(Name, !IO), - io__write_string(""", ", !IO), - io__write_int(Arity, !IO), - io__write_string(", ", !IO), - io__write_string("MR_FALSE, ", !IO) + io.write_string(Name, !IO), + io.write_string(""", ", !IO), + io.write_int(Arity, !IO), + io.write_string(", ", !IO), + io.write_string("MR_FALSE, ", !IO) ), RttiName = maybe_res_functor_rtti_name(MaybeResFunctor), output_ctor_rtti_id(RttiTypeCtor, RttiName, !IO), - io__write_string(" },\n", !IO). + io.write_string(" },\n", !IO). %-----------------------------------------------------------------------------% :- func make_code_addr(rtti_proc_label) = code_addr. make_code_addr(ProcLabel) = CodeAddr :- - code_util__make_entry_label_from_rtti(ProcLabel, no, CodeAddr). + code_util.make_entry_label_from_rtti(ProcLabel, no, CodeAddr). :- pred output_reserved_address(reserved_address::in, io::di, io::uo) is det. output_reserved_address(null_pointer, !IO) :- - io__write_string("NULL", !IO). + io.write_string("NULL", !IO). output_reserved_address(small_pointer(Val), !IO) :- - io__write_string("(const void *) ", !IO), - io__write_int(Val, !IO). + io.write_string("(const void *) ", !IO), + io.write_int(Val, !IO). output_reserved_address(reserved_object(_, _, _), !IO) :- % These should only be used for the MLDS back-end. unexpected(this_file, "reserved_object"). @@ -1227,9 +1227,9 @@ output_reserved_address(reserved_object(_, _, _), !IO) :- ). output_rtti_data_decl_list(RttiDatas, !DeclSet, !IO) :- - classify_rtti_datas_to_decl(RttiDatas, multi_map__init, GroupMap), - multi_map__to_assoc_list(GroupMap, GroupList), - list__foldl2(output_rtti_data_decl_group, GroupList, !DeclSet, !IO). + classify_rtti_datas_to_decl(RttiDatas, multi_map.init, GroupMap), + multi_map.to_assoc_list(GroupMap, GroupList), + list.foldl2(output_rtti_data_decl_group, GroupList, !DeclSet, !IO). :- pred classify_rtti_datas_to_decl(list(rtti_data)::in, multi_map(data_group, rtti_id)::in, @@ -1246,7 +1246,7 @@ classify_rtti_datas_to_decl([RttiData | RttiDatas], !GroupMap) :- rtti_id_c_type(RttiId, CType, IsArray), rtti_id_linkage(RttiId, Linkage), Group = data_group(CType, IsArray, Linkage), - multi_map__set(!.GroupMap, Group, RttiId, !:GroupMap) + multi_map.set(!.GroupMap, Group, RttiId, !:GroupMap) ), classify_rtti_datas_to_decl(RttiDatas, !GroupMap). @@ -1260,8 +1260,8 @@ output_rtti_data_decl_group(Group - RttiIds, !DeclSet, !IO) :- ChunkSize = 10, % The process of creating the multi_map reverses the order of rtti_ids, % we now undo this reversal. - list__chunk(list__reverse(RttiIds), ChunkSize, RttiIdChunks), - list__foldl2(output_rtti_data_decl_chunk(Group), RttiIdChunks, + list.chunk(list.reverse(RttiIds), ChunkSize, RttiIdChunks), + list.foldl2(output_rtti_data_decl_chunk(Group), RttiIdChunks, !DeclSet, !IO). :- pred output_rtti_data_decl_chunk(data_group::in, list(rtti_id)::in, @@ -1278,16 +1278,16 @@ output_rtti_data_decl_chunk(Group, RttiIds, !DeclSet, !IO) :- ), Group = data_group(CType, IsArray, Linkage), - io__nl(!IO), + io.nl(!IO), output_rtti_type_decl(RttiId, !DeclSet, !IO), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), LinkageStr = c_data_linkage_string(Linkage, no), InclCodeAddr = rtti_id_would_include_code_addr(RttiId), - io__write_string(LinkageStr, !IO), - io__write_string(c_data_const_string(Globals, InclCodeAddr), !IO), - c_util__output_quoted_string(CType, !IO), - io__nl(!IO), + io.write_string(LinkageStr, !IO), + io.write_string(c_data_const_string(Globals, InclCodeAddr), !IO), + c_util.output_quoted_string(CType, !IO), + io.nl(!IO), output_rtti_data_decl_chunk_entries(IsArray, RttiIds, !DeclSet, !IO). @@ -1301,21 +1301,21 @@ output_rtti_data_decl_chunk_entries(IsArray, [RttiId | RttiIds], !DeclSet, !IO) :- DataAddr = rtti_addr(RttiId), decl_set_insert(data_addr(DataAddr), !DeclSet), - io__write_string("\t", !IO), + io.write_string("\t", !IO), output_rtti_id(RttiId, !IO), ( IsArray = yes, - io__write_string("[]", !IO) + io.write_string("[]", !IO) ; IsArray = no ), ( RttiIds = [_ | _], - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), output_rtti_data_decl_chunk_entries(IsArray, RttiIds, !DeclSet, !IO) ; RttiIds = [], - io__write_string(";\n", !IO) + io.write_string(";\n", !IO) ). %-----------------------------------------------------------------------------% @@ -1337,7 +1337,7 @@ output_rtti_data_decl(RttiData, !DeclSet, !IO) :- output_generic_rtti_data_decl(RttiId, !DeclSet, !IO) :- output_rtti_id_storage_type_name(RttiId, no, !DeclSet, !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), DataAddr = rtti_addr(RttiId), decl_set_insert(data_addr(DataAddr), !DeclSet). @@ -1345,7 +1345,7 @@ output_generic_rtti_data_decl(RttiId, !DeclSet, !IO) :- decl_set::in, decl_set::out, io::di, io::uo) is det. output_generic_rtti_data_defn_start(RttiId, !DeclSet, !IO) :- - io__write_string("\n", !IO), + io.write_string("\n", !IO), output_rtti_id_storage_type_name(RttiId, yes, !DeclSet, !IO), DataAddr = rtti_addr(RttiId), decl_set_insert(data_addr(DataAddr), !DeclSet). @@ -1357,20 +1357,20 @@ output_rtti_id_storage_type_name_no_decl(RttiId, BeingDefined, !IO) :- output_rtti_id_storage_type_name(RttiId, BeingDefined, !DeclSet, !IO) :- output_rtti_type_decl(RttiId, !DeclSet, !IO), rtti_id_linkage(RttiId, Linkage), - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), LinkageStr = c_data_linkage_string(Linkage, BeingDefined), - io__write_string(LinkageStr, !IO), + io.write_string(LinkageStr, !IO), InclCodeAddr = rtti_id_would_include_code_addr(RttiId), - io__write_string(c_data_const_string(Globals, InclCodeAddr), !IO), + io.write_string(c_data_const_string(Globals, InclCodeAddr), !IO), rtti_id_c_type(RttiId, CType, IsArray), - c_util__output_quoted_string(CType, !IO), - io__write_string(" ", !IO), + c_util.output_quoted_string(CType, !IO), + io.write_string(" ", !IO), output_rtti_id(RttiId, !IO), ( IsArray = yes, - io__write_string("[]", !IO) + io.write_string("[]", !IO) ; IsArray = no ). @@ -1398,7 +1398,7 @@ output_rtti_type_decl(RttiId, !DeclSet, !IO) :- MR_DECLARE_ALL_TYPE_INFO_LIKE_STRUCTS_FOR_ARITY(%d); #endif ", - io__format(Template, [i(Arity), i(Arity), i(Arity)], !IO), + io.format(Template, [i(Arity), i(Arity), i(Arity)], !IO), decl_set_insert(DeclId, !DeclSet) ) ; @@ -1416,7 +1416,7 @@ MR_DECLARE_ALL_TYPE_INFO_LIKE_STRUCTS_FOR_ARITY(%d); MR_DEFINE_TYPECLASS_CONSTRAINT_STRUCT(MR_TypeClassConstraint_%d, %d); #endif ", - io__format(Template, [i(Arity), i(Arity), i(Arity), i(Arity)], + io.format(Template, [i(Arity), i(Arity), i(Arity), i(Arity)], !IO), decl_set_insert(DeclId, !DeclSet) ) @@ -1433,7 +1433,7 @@ rtti_type_ctor_template_arity(RttiName, NumArgTypes) :- ; TypeInfo = var_arity_type_info(_, ArgTypes) ), - NumArgTypes = list__length(ArgTypes). + NumArgTypes = list.length(ArgTypes). rtti_type_ctor_template_arity(RttiName, NumArgTypes) :- RttiName = pseudo_type_info(PseudoTypeInfo), ( @@ -1441,7 +1441,7 @@ rtti_type_ctor_template_arity(RttiName, NumArgTypes) :- ; PseudoTypeInfo = var_arity_pseudo_type_info(_, ArgTypes) ), - NumArgTypes = list__length(ArgTypes). + NumArgTypes = list.length(ArgTypes). :- func max_always_declared_arity_type_ctor = int. @@ -1461,73 +1461,73 @@ max_always_declared_arity_type_class_constraint = 5. %-----------------------------------------------------------------------------% -rtti_out__init_rtti_data_if_nec(Data, !IO) :- +init_rtti_data_if_nec(Data, !IO) :- ( Data = type_ctor_info(TypeCtorData) -> RttiTypeCtor = tcd_get_rtti_type_ctor(TypeCtorData), - io__write_string("\tMR_INIT_TYPE_CTOR_INFO(\n\t\t", !IO), + io.write_string("\tMR_INIT_TYPE_CTOR_INFO(\n\t\t", !IO), output_ctor_rtti_id(RttiTypeCtor, type_ctor_info, !IO), - io__write_string(",\n\t\t", !IO), + io.write_string(",\n\t\t", !IO), RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, Arity), ModuleNameString = sym_name_mangle(ModuleName), - string__append(ModuleNameString, "__", UnderscoresModule), - ( string__append(UnderscoresModule, _, TypeName) -> + string.append(ModuleNameString, "__", UnderscoresModule), + ( string.append(UnderscoresModule, _, TypeName) -> true ; - io__write_string(UnderscoresModule, !IO) + io.write_string(UnderscoresModule, !IO) ), MangledTypeName = name_mangle(TypeName), - io__write_string(MangledTypeName, !IO), - io__write_string("_", !IO), - io__write_int(Arity, !IO), - io__write_string("_0);\n", !IO) + io.write_string(MangledTypeName, !IO), + io.write_string("_", !IO), + io.write_int(Arity, !IO), + io.write_string("_0);\n", !IO) ; Data = base_typeclass_info(TCName, _ModuleName, ClassArity, base_typeclass_info(_N1, _N2, _N3, _N4, _N5, Methods)) -> - io__write_string("#ifndef MR_STATIC_CODE_ADDRESSES\n", !IO), + io.write_string("#ifndef MR_STATIC_CODE_ADDRESSES\n", !IO), % The field number for the first method is 5, since the methods are % stored after N1 .. N5, and fields are numbered from 0. FirstFieldNum = 5, - CodeAddrs = list__map(make_code_addr, Methods), + CodeAddrs = list.map(make_code_addr, Methods), output_init_method_pointers(FirstFieldNum, CodeAddrs, TCName, ClassArity, !IO), - io__write_string("#endif /* MR_STATIC_CODE_ADDRESSES */\n", !IO) + io.write_string("#endif /* MR_STATIC_CODE_ADDRESSES */\n", !IO) ; Data = type_class_instance(_) -> - io__write_string("#ifndef MR_STATIC_CODE_ADDRESSES\n", !IO), - io__write_string("#error ""type_class_instance " ++ + io.write_string("#ifndef MR_STATIC_CODE_ADDRESSES\n", !IO), + io.write_string("#error ""type_class_instance " ++ "not yet supported without static code addresses""\n", !IO), - io__write_string("#endif /* MR_STATIC_CODE_ADDRESSES */\n", !IO) + io.write_string("#endif /* MR_STATIC_CODE_ADDRESSES */\n", !IO) ; true ). -rtti_out__register_rtti_data_if_nec(Data, !IO) :- +register_rtti_data_if_nec(Data, !IO) :- ( Data = type_ctor_info(TypeCtorData) -> RttiTypeCtor = tcd_get_rtti_type_ctor(TypeCtorData), RttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_info), - io__write_string("\t{\n\t", !IO), - io__write_string("\tMR_register_type_ctor_info(\n\t\t&", !IO), + io.write_string("\t{\n\t", !IO), + io.write_string("\tMR_register_type_ctor_info(\n\t\t&", !IO), output_rtti_id(RttiId, !IO), - io__write_string(");\n\t}\n", !IO) + io.write_string(");\n\t}\n", !IO) ; Data = type_class_decl(TCDecl) -> TCDecl = tc_decl(TCId, _, _), TCId = tc_id(TCName, _, _), RttiId = tc_rtti_id(TCName, type_class_decl), - io__write_string("\t{\n\t", !IO), - io__write_string("\tMR_register_type_class_decl(\n\t\t&", !IO), + io.write_string("\t{\n\t", !IO), + io.write_string("\tMR_register_type_class_decl(\n\t\t&", !IO), output_rtti_id(RttiId, !IO), - io__write_string(");\n\t}\n", !IO) + io.write_string(");\n\t}\n", !IO) ; Data = type_class_instance(TCInstance) -> TCInstance = tc_instance(TCName, TCTypes, _, _, _), RttiId = tc_rtti_id(TCName, type_class_instance(TCTypes)), - io__write_string("\t{\n\t", !IO), - io__write_string("\tMR_register_type_class_instance(\n\t\t&", !IO), + io.write_string("\t{\n\t", !IO), + io.write_string("\tMR_register_type_class_instance(\n\t\t&", !IO), output_rtti_id(RttiId, !IO), - io__write_string(");\n\t}\n", !IO) + io.write_string(");\n\t}\n", !IO) ; true ). @@ -1538,12 +1538,12 @@ rtti_out__register_rtti_data_if_nec(Data, !IO) :- output_init_method_pointers(_, [], _, _, !IO). output_init_method_pointers(FieldNum, [Arg | Args], TCName, InstanceStr, !IO) :- - io__write_string("\t\t", !IO), - io__write_string("MR_field(MR_mktag(0), ", !IO), + io.write_string("\t\t", !IO), + io.write_string("MR_field(MR_mktag(0), ", !IO), output_base_typeclass_info_name(TCName, InstanceStr, !IO), - io__format(", %d) =\n\t\t\t", [i(FieldNum)], !IO), + io.format(", %d) =\n\t\t\t", [i(FieldNum)], !IO), output_code_addr(Arg, !IO), - io__write_string(";\n", !IO), + io.write_string(";\n", !IO), output_init_method_pointers(FieldNum + 1, Args, TCName, InstanceStr, !IO). %-----------------------------------------------------------------------------% @@ -1588,55 +1588,55 @@ output_rtti_id_decls(RttiId, FirstIndent, LaterIndent, !N, !DeclSet, !IO) :- io::di, io::uo) is det. output_cast_addr_of_rtti_ids(_, [], !IO) :- - io__write_string( + io.write_string( "\t/* Dummy entry, since ISO C forbids zero-sized arrays */\n", !IO), - io__write_string("\t0\n", !IO). + io.write_string("\t0\n", !IO). output_cast_addr_of_rtti_ids(Cast, [TCRttiName | TCRttiNames], !IO) :- - io__write_string("\t", !IO), - io__write_list([TCRttiName | TCRttiNames], ",\n\t", + io.write_string("\t", !IO), + io.write_list([TCRttiName | TCRttiNames], ",\n\t", output_cast_addr_of_rtti_id(Cast), !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). :- pred output_addr_of_ctor_rtti_names(rtti_type_ctor::in, list(ctor_rtti_name)::in, io::di, io::uo) is det. output_addr_of_ctor_rtti_names(_, [], !IO). output_addr_of_ctor_rtti_names(RttiTypeCtor, [RttiName | RttiNames], !IO) :- - io__write_string("\t", !IO), - io__write_list([RttiName | RttiNames], ",\n\t", + io.write_string("\t", !IO), + io.write_list([RttiName | RttiNames], ",\n\t", output_addr_of_ctor_rtti_id(RttiTypeCtor), !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). :- pred output_cast_addr_of_rtti_datas(string::in, list(rtti_data)::in, io::di, io::uo) is det. output_cast_addr_of_rtti_datas(_, [], !IO) :- - io__write_string( + io.write_string( "\t/* Dummy entry, since ISO C forbids zero-sized arrays */\n", !IO), - io__write_string("\t0\n", !IO). + io.write_string("\t0\n", !IO). output_cast_addr_of_rtti_datas(Cast, [RttiData | RttiDatas], !IO) :- - io__write_string("\t", !IO), - io__write_list([RttiData | RttiDatas], ",\n\t", + io.write_string("\t", !IO), + io.write_list([RttiData | RttiDatas], ",\n\t", output_cast_addr_of_rtti_data(Cast), !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). :- pred output_addr_of_rtti_datas(list(rtti_data)::in, io::di, io::uo) is det. output_addr_of_rtti_datas([], !IO). output_addr_of_rtti_datas([RttiData | RttiDatas], !IO) :- - io__write_string("\t", !IO), - io__write_list([RttiData | RttiDatas], ",\n\t", output_addr_of_rtti_data, + io.write_string("\t", !IO), + io.write_list([RttiData | RttiDatas], ",\n\t", output_addr_of_rtti_data, !IO), - io__write_string("\n", !IO). + io.write_string("\n", !IO). output_cast_addr_of_rtti_data(Cast, RttiData, !IO) :- - io__write_string(Cast, !IO), + io.write_string(Cast, !IO), output_addr_of_rtti_data(RttiData, !IO). output_addr_of_rtti_data(RttiData, !IO) :- ( RttiData = pseudo_type_info(type_var(VarNum)) -> % rtti_data_to_name/3 does not handle this case - io__write_int(VarNum, !IO) + io.write_int(VarNum, !IO) ; rtti_data_to_id(RttiData, RttiId), output_addr_of_rtti_id(RttiId, !IO) @@ -1646,7 +1646,7 @@ output_addr_of_rtti_data(RttiData, !IO) :- io::di, io::uo) is det. output_cast_addr_of_rtti_id(Cast, RttiId, !IO) :- - io__write_string(Cast, !IO), + io.write_string(Cast, !IO), output_addr_of_rtti_id(RttiId, !IO). :- pred output_addr_of_rtti_id(rtti_id::in, io::di, io::uo) is det. @@ -1655,11 +1655,11 @@ output_addr_of_rtti_id(RttiId, !IO) :- % If the RttiName is not an array, then we need to use `&' % to take its address. ( RttiId = ctor_rtti_id(_, pseudo_type_info(type_var(VarNum))) -> - io__write_int(VarNum, !IO) + io.write_int(VarNum, !IO) ; rtti_id_has_array_type(RttiId) = yes -> output_rtti_id(RttiId, !IO) ; - io__write_string("&", !IO), + io.write_string("&", !IO), output_rtti_id(RttiId, !IO) ). @@ -1670,9 +1670,9 @@ output_addr_of_ctor_rtti_id(RttiTypeCtor, RttiName, !IO) :- output_addr_of_rtti_id(ctor_rtti_id(RttiTypeCtor, RttiName), !IO). output_rtti_id(RttiId, !IO) :- - io__write_string(mercury_data_prefix, !IO), - rtti__id_to_c_identifier(RttiId, Str), - io__write_string(Str, !IO). + io.write_string(mercury_data_prefix, !IO), + rtti.id_to_c_identifier(RttiId, Str), + io.write_string(Str, !IO). :- pred output_ctor_rtti_id(rtti_type_ctor::in, ctor_rtti_name::in, io::di, io::uo) is det. @@ -1687,21 +1687,21 @@ output_ctor_rtti_id(RttiTypeCtor, RttiName, !IO) :- output_maybe_quoted_string(MaybeName, !IO) :- ( MaybeName = yes(Name), - io__write_string("""", !IO), - c_util__output_quoted_string(Name, !IO), - io__write_string("""", !IO) + io.write_string("""", !IO), + c_util.output_quoted_string(Name, !IO), + io.write_string("""", !IO) ; MaybeName = no, - io__write_string("NULL", !IO) + io.write_string("NULL", !IO) ). :- pred output_maybe_quoted_strings(list(maybe(string))::in, io::di, io::uo) is det. output_maybe_quoted_strings(MaybeNames, !IO) :- - io__write_string("\t", !IO), - io__write_list(MaybeNames, ",\n\t", output_maybe_quoted_string, !IO), - io__write_string("\n", !IO). + io.write_string("\t", !IO), + io.write_list(MaybeNames, ",\n\t", output_maybe_quoted_string, !IO), + io.write_string("\n", !IO). %-----------------------------------------------------------------------------% @@ -1710,25 +1710,25 @@ output_maybe_quoted_strings(MaybeNames, !IO) :- output_exist_locn(Locn, !IO) :- ( Locn = plain_typeinfo(SlotInCell), - io__write_string("{ ", !IO), - io__write_int(SlotInCell, !IO), - io__write_string(", -1 }", !IO) + io.write_string("{ ", !IO), + io.write_int(SlotInCell, !IO), + io.write_string(", -1 }", !IO) ; Locn = typeinfo_in_tci(SlotInCell, SlotInTci), - io__write_string("{ ", !IO), - io__write_int(SlotInCell, !IO), - io__write_string(", ", !IO), - io__write_int(SlotInTci, !IO), - io__write_string(" }", !IO) + io.write_string("{ ", !IO), + io.write_int(SlotInCell, !IO), + io.write_string(", ", !IO), + io.write_int(SlotInTci, !IO), + io.write_string(" }", !IO) ). :- pred output_exist_locns(list(exist_typeinfo_locn)::in, io::di, io::uo) is det. output_exist_locns(Locns, !IO) :- - io__write_string("\t", !IO), - io__write_list(Locns, ",\n\t", output_exist_locn, !IO), - io__write_string("\n", !IO). + io.write_string("\t", !IO), + io.write_list(Locns, ",\n\t", output_exist_locn, !IO), + io.write_string("\n", !IO). :- pred output_maybe_static_code_addr(maybe(code_addr)::in, io::di, io::uo) is det. @@ -1736,14 +1736,14 @@ output_exist_locns(Locns, !IO) :- output_maybe_static_code_addr(yes(CodeAddr), !IO) :- output_static_code_addr(CodeAddr, !IO). output_maybe_static_code_addr(no, !IO) :- - io__write_string("NULL", !IO). + io.write_string("NULL", !IO). :- pred output_static_code_addr(code_addr::in, io::di, io::uo) is det. output_static_code_addr(CodeAddr, !IO) :- - io__write_string("MR_MAYBE_STATIC_CODE(", !IO), + io.write_string("MR_MAYBE_STATIC_CODE(", !IO), output_code_addr(CodeAddr, !IO), - io__write_string(")", !IO). + io.write_string(")", !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/rtti_to_mlds.m b/compiler/rtti_to_mlds.m index ea4be48b9..876e6b34c 100644 --- a/compiler/rtti_to_mlds.m +++ b/compiler/rtti_to_mlds.m @@ -30,13 +30,13 @@ % phases: first allocate all of the objects, then fill in the fields. % % XXX In the absence of this fix, there are still several places in the code -% below which use list__append. If possible these lists should instead be -% manipulated through some use of prepending and/or list__reverse instead, so +% below which use list.append. If possible these lists should instead be +% manipulated through some use of prepending and/or list.reverse instead, so % that the algorithm stays O(N). %-----------------------------------------------------------------------------% -:- module ml_backend__rtti_to_mlds. +:- module ml_backend.rtti_to_mlds. :- interface. :- import_module backend_libs.rtti. @@ -49,7 +49,7 @@ % Return a list of MLDS definitions for the given rtti_data list. % -:- func rtti_data_list_to_mlds(module_info, list(rtti_data)) = mlds__defns. +:- func rtti_data_list_to_mlds(module_info, list(rtti_data)) = mlds_defns. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -86,18 +86,18 @@ %-----------------------------------------------------------------------------% rtti_data_list_to_mlds(ModuleInfo, RttiDatas) = MLDS_Defns :- - RealRttiDatas = list__filter(real_rtti_data, RttiDatas), - MLDS_DefnLists0 = list__map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), - MLDS_Defns0 = list__condense(MLDS_DefnLists0), - list__filter(mlds_defn_is_potentially_duplicated, MLDS_Defns0, + RealRttiDatas = list.filter(real_rtti_data, RttiDatas), + MLDS_DefnLists0 = list.map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), + MLDS_Defns0 = list.condense(MLDS_DefnLists0), + list.filter(mlds_defn_is_potentially_duplicated, MLDS_Defns0, MaybeDupDefns0, NoDupDefns), - list__sort_and_remove_dups(MaybeDupDefns0, MaybeDupDefns), - MLDS_Defns = list__append(MaybeDupDefns, NoDupDefns). + list.sort_and_remove_dups(MaybeDupDefns0, MaybeDupDefns), + MLDS_Defns = MaybeDupDefns ++ NoDupDefns. -:- pred mlds_defn_is_potentially_duplicated(mlds__defn::in) is semidet. +:- pred mlds_defn_is_potentially_duplicated(mlds_defn::in) is semidet. mlds_defn_is_potentially_duplicated(MLDS_Defn) :- - MLDS_Defn = mlds__defn(EntityName, _, _, _), + MLDS_Defn = mlds_defn(EntityName, _, _, _), EntityName = data(DataName), DataName = rtti(ctor_rtti_id(_, RttiName)), ( RttiName = type_info(_) @@ -105,7 +105,7 @@ mlds_defn_is_potentially_duplicated(MLDS_Defn) :- ). % return a list of MLDS definitions for the given rtti_data. -:- func rtti_data_to_mlds(module_info, rtti_data) = mlds__defns. +:- func rtti_data_to_mlds(module_info, rtti_data) = mlds_defns. rtti_data_to_mlds(ModuleInfo, RttiData) = MLDS_Defns :- ( RttiData = pseudo_type_info(type_var(_)) -> @@ -120,33 +120,33 @@ rtti_data_to_mlds(ModuleInfo, RttiData) = MLDS_Defns :- Initializer, ExtraDefns), rtti_entity_name_and_init_to_defn(Name, RttiId, Initializer, MLDS_Defn), - MLDS_Defns = list__append(ExtraDefns, [MLDS_Defn]) + MLDS_Defns = ExtraDefns ++ [MLDS_Defn] ). :- pred rtti_name_and_init_to_defn(rtti_type_ctor::in, ctor_rtti_name::in, - mlds__initializer::in, mlds__defn::out) is det. + mlds_initializer::in, mlds_defn::out) is det. rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Initializer, MLDS_Defn) :- RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), rtti_id_and_init_to_defn(RttiId, Initializer, MLDS_Defn). -:- pred rtti_id_and_init_to_defn(rtti_id::in, mlds__initializer::in, - mlds__defn::out) is det. +:- pred rtti_id_and_init_to_defn(rtti_id::in, mlds_initializer::in, + mlds_defn::out) is det. rtti_id_and_init_to_defn(RttiId, Initializer, MLDS_Defn) :- Name = data(rtti(RttiId)), rtti_entity_name_and_init_to_defn(Name, RttiId, Initializer, MLDS_Defn). -:- pred rtti_entity_name_and_init_to_defn(mlds__entity_name::in, rtti_id::in, - mlds__initializer::in, mlds__defn::out) is det. +:- pred rtti_entity_name_and_init_to_defn(mlds_entity_name::in, rtti_id::in, + mlds_initializer::in, mlds_defn::out) is det. rtti_entity_name_and_init_to_defn(Name, RttiId, Initializer, MLDS_Defn) :- % Generate the context. % % XXX The rtti_data ought to include a prog_context (the context of the % corresponding type or instance definition) - term__context_init(Context), - MLDS_Context = mlds__make_context(Context), + term.context_init(Context), + MLDS_Context = mlds_make_context(Context), % Generate the declaration flags. Exported = rtti_id_is_exported(RttiId), @@ -157,15 +157,15 @@ rtti_entity_name_and_init_to_defn(Name, RttiId, Initializer, MLDS_Defn) :- GC_TraceCode = no, % Generate the declaration body, i.e. the type and the initializer - MLDS_Type = rtti_type(item_type(RttiId)), - DefnBody = mlds__data(MLDS_Type, Initializer, GC_TraceCode), - MLDS_Defn = mlds__defn(Name, MLDS_Context, Flags, DefnBody). + MLDS_Type = mlds_rtti_type(item_type(RttiId)), + DefnBody = mlds_data(MLDS_Type, Initializer, GC_TraceCode), + MLDS_Defn = mlds_defn(Name, MLDS_Context, Flags, DefnBody). % Return the declaration flags appropriate for an rtti_data. % Note that this must be the same as ml_static_const_decl_flags, % except for the access, so that ml_decl_is_static_const works. % -:- func rtti_data_decl_flags(bool) = mlds__decl_flags. +:- func rtti_data_decl_flags(bool) = mlds_decl_flags. rtti_data_decl_flags(Exported) = MLDS_DeclFlags :- ( @@ -189,14 +189,14 @@ rtti_data_decl_flags(Exported) = MLDS_DeclFlags :- % occurring in the given module. % :- pred gen_init_rtti_data_defn(rtti_data::in, rtti_id::in, module_info::in, - mlds__initializer::out, list(mlds__defn)::out) is det. + mlds_initializer::out, list(mlds_defn)::out) is det. gen_init_rtti_data_defn(RttiData, _RttiId, ModuleInfo, Init, ExtraDefns) :- RttiData = base_typeclass_info(_InstanceModule, _ClassId, _InstanceStr, BaseTypeClassInfo), BaseTypeClassInfo = base_typeclass_info(N1, N2, N3, N4, N5, Methods), NumExtra = BaseTypeClassInfo ^ num_extra, - list__map_foldl(gen_init_method(ModuleInfo, NumExtra), + list.map_foldl(gen_init_method(ModuleInfo, NumExtra), Methods, MethodInitializers, [], ExtraDefns), Init = init_array([ gen_init_boxed_int(N1), @@ -224,7 +224,7 @@ gen_init_rtti_data_defn(RttiData, RttiId, ModuleInfo, Init, SubDefns) :- TypeCtorData = type_ctor_data(Version, TypeModule, TypeName, TypeArity, UnifyUniv, CompareUniv, Flags, TypeCtorDetails), RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName, TypeArity), - mdbcomp__prim_data__sym_name_to_string(TypeModule, TypeModuleName), + sym_name_to_string(TypeModule, TypeModuleName), NumPtags = type_ctor_details_num_ptags(TypeCtorDetails), NumFunctors = type_ctor_details_num_functors(TypeCtorDetails), FunctorsRttiId = ctor_rtti_id(RttiTypeCtor, type_functors), @@ -244,7 +244,7 @@ gen_init_rtti_data_defn(RttiData, RttiId, ModuleInfo, Init, SubDefns) :- SubDefns = !.Defns ), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_int(TypeArity), gen_init_int(Version), gen_init_int(NumPtags), @@ -256,10 +256,10 @@ gen_init_rtti_data_defn(RttiData, RttiId, ModuleInfo, Init, SubDefns) :- % In the C back-end, these two "structs" are actually unions. % We need to use `init_struct' here so that the initializers % get enclosed in curly braces. - init_struct(mlds__rtti_type(item_type(FunctorsRttiId)), [ + init_struct(mlds_rtti_type(item_type(FunctorsRttiId)), [ FunctorsInfo ]), - init_struct(mlds__rtti_type(item_type(LayoutRttiId)), [ + init_struct(mlds_rtti_type(item_type(LayoutRttiId)), [ LayoutInfo ]), gen_init_int(NumFunctors), @@ -275,7 +275,7 @@ gen_init_rtti_data_defn(RttiData, RttiId, ModuleInfo, Init, SubDefns) :- %-----------------------------------------------------------------------------% :- pred gen_type_class_decl_defn(tc_decl::in, rtti_id::in, module_info::in, - mlds__initializer::out, list(mlds__defn)::out) is det. + mlds_initializer::out, list(mlds_defn)::out) is det. gen_type_class_decl_defn(TCDecl, RttiId, ModuleInfo, Init, SubDefns) :- TCDecl = tc_decl(TCId, Version, Supers), @@ -287,7 +287,7 @@ gen_type_class_decl_defn(TCDecl, RttiId, ModuleInfo, Init, SubDefns) :- TVarNames = [], TVarNameDefns = [], TVarNamesInit = gen_init_null_pointer( - mlds__rtti_type(item_type(TVarNamesRttiId))) + mlds_rtti_type(item_type(TVarNamesRttiId))) ; TVarNames = [_ | _], gen_tc_id_var_names(TVarNamesRttiId, TVarNames, TVarNameDefn), @@ -299,7 +299,7 @@ gen_type_class_decl_defn(TCDecl, RttiId, ModuleInfo, Init, SubDefns) :- MethodIds = [], MethodIdDefns = [], MethodIdsInit = gen_init_null_pointer( - mlds__rtti_type(item_type(MethodIdsRttiId))) + mlds_rtti_type(item_type(MethodIdsRttiId))) ; MethodIds = [_ | _], gen_tc_id_method_ids(MethodIdsRttiId, TCName, MethodIds, MethodIdDefn), @@ -308,9 +308,9 @@ gen_type_class_decl_defn(TCDecl, RttiId, ModuleInfo, Init, SubDefns) :- ), TCIdRttiId = tc_rtti_id(TCName, type_class_id), sym_name_to_string(ModuleSymName, ModuleSymNameStr), - list__length(TVarNames, NumTVars), - list__length(MethodIds, NumMethods), - TCIdInit = init_struct(mlds__rtti_type(item_type(TCIdRttiId)), [ + list.length(TVarNames, NumTVars), + list.length(MethodIds, NumMethods), + TCIdInit = init_struct(mlds_rtti_type(item_type(TCIdRttiId)), [ gen_init_string(ModuleSymNameStr), gen_init_string(ClassName), gen_init_int(Arity), @@ -324,31 +324,30 @@ gen_type_class_decl_defn(TCDecl, RttiId, ModuleInfo, Init, SubDefns) :- Supers = [], SuperDefns = [], SupersInit = gen_init_null_pointer( - mlds__rtti_type(item_type(MethodIdsRttiId))) + mlds_rtti_type(item_type(MethodIdsRttiId))) ; Supers = [_ | _], - list__map_foldl2(gen_tc_constraint(ModuleInfo, + list.map_foldl2(gen_tc_constraint(ModuleInfo, make_decl_super_id(TCName)), Supers, SuperRttiIds, - counter__init(1), _, [], SuperConstrDefns), + counter.init(1), _, [], SuperConstrDefns), SuperArrayRttiName = type_class_decl_supers, SuperArrayRttiId = tc_rtti_id(TCName, SuperArrayRttiName), - ElementType = mlds__rtti_type(element_type(SuperArrayRttiId)), + ElementType = mlds_rtti_type(element_type(SuperArrayRttiId)), SuperArrayInit = gen_init_array( gen_init_cast_rtti_id(ElementType, ModuleName), SuperRttiIds), rtti_id_and_init_to_defn(SuperArrayRttiId, SuperArrayInit, SuperDefn), - list__append(SuperConstrDefns, [SuperDefn], SuperDefns), + SuperDefns = SuperConstrDefns ++ [SuperDefn], SupersInit = gen_init_null_pointer( - mlds__rtti_type(item_type(MethodIdsRttiId))) + mlds_rtti_type(item_type(MethodIdsRttiId))) ), - list__length(Supers, NumSupers), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + list.length(Supers, NumSupers), + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_rtti_id(ModuleName, TCIdRttiId), gen_init_int(Version), gen_init_int(NumSupers), SupersInit ]), - list__condense([TVarNameDefns, MethodIdDefns, [TCIdDefn], SuperDefns], - SubDefns). + SubDefns = TVarNameDefns ++ MethodIdDefns ++ [TCIdDefn] ++ SuperDefns. :- pred make_decl_super_id(tc_name::in, int::in, int::in, rtti_id::out) is det. @@ -357,7 +356,7 @@ make_decl_super_id(TCName, TCNum, Arity, RttiId) :- TCRttiName = type_class_decl_super(TCNum, Arity), RttiId = tc_rtti_id(TCName, TCRttiName). -:- pred gen_tc_id_var_names(rtti_id::in, list(string)::in, mlds__defn::out) +:- pred gen_tc_id_var_names(rtti_id::in, list(string)::in, mlds_defn::out) is det. gen_tc_id_var_names(RttiId, Names, MLDS_Defn) :- @@ -365,18 +364,18 @@ gen_tc_id_var_names(RttiId, Names, MLDS_Defn) :- rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn). :- pred gen_tc_id_method_ids(rtti_id::in, tc_name::in, list(tc_method_id)::in, - mlds__defn::out) is det. + mlds_defn::out) is det. gen_tc_id_method_ids(RttiId, TCName, MethodIds, Defn) :- Init = gen_init_array(gen_tc_id_method_id(TCName), MethodIds), rtti_id_and_init_to_defn(RttiId, Init, Defn). -:- func gen_tc_id_method_id(tc_name, tc_method_id) = mlds__initializer. +:- func gen_tc_id_method_id(tc_name, tc_method_id) = mlds_initializer. gen_tc_id_method_id(TCName, MethodId) = Init :- MethodId = tc_method_id(MethodName, MethodArity, PredOrFunc), RttiId = tc_rtti_id(TCName, type_class_id_method_ids), - Init = init_struct(mlds__rtti_type(element_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(element_type(RttiId)), [ gen_init_string(MethodName), gen_init_int(MethodArity), gen_init_pred_or_func(PredOrFunc) @@ -385,43 +384,43 @@ gen_tc_id_method_id(TCName, MethodId) = Init :- %-----------------------------------------------------------------------------% :- pred gen_type_class_instance_defn(tc_instance::in, rtti_id::in, - module_info::in, mlds__initializer::out, list(mlds__defn)::out) is det. + module_info::in, mlds_initializer::out, list(mlds_defn)::out) is det. gen_type_class_instance_defn(Instance, RttiId, ModuleInfo, Init, SubDefns) :- Instance = tc_instance(TCName, Types, NumTypeVars, InstanceConstraints, _Methods), TCDeclRttiId = tc_rtti_id(TCName, type_class_decl), - list__length(InstanceConstraints, NumInstanceConstraints), + list.length(InstanceConstraints, NumInstanceConstraints), InstanceTypesTCRttiName = type_class_instance_tc_type_vector(Types), InstanceTypesRttiId = tc_rtti_id(TCName, InstanceTypesTCRttiName), InstanceConstrsTCRttiName = type_class_instance_constraints(Types), InstanceConstrsRttiId = tc_rtti_id(TCName, InstanceConstrsTCRttiName), module_info_get_name(ModuleInfo, ModuleName), - TypeRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, Types), + TypeRttiDatas = list.map(maybe_pseudo_type_info_to_rtti_data, Types), gen_pseudo_type_info_array(ModuleInfo, TypeRttiDatas, TypesInit, TypesDefns), rtti_id_and_init_to_defn(InstanceTypesRttiId, TypesInit, TypesDefn), - list__map_foldl2(gen_tc_constraint(ModuleInfo, + list.map_foldl2(gen_tc_constraint(ModuleInfo, make_instance_constr_id(TCName, Types)), - InstanceConstraints, TCConstrIds, counter__init(1), _, + InstanceConstraints, TCConstrIds, counter.init(1), _, [], TCConstrDefns), - ElementType = mlds__rtti_type(element_type(InstanceConstrsRttiId)), + ElementType = mlds_rtti_type(element_type(InstanceConstrsRttiId)), InstanceConstrsInit = gen_init_array( gen_init_cast_rtti_id(ElementType, ModuleName), TCConstrIds), rtti_id_and_init_to_defn(InstanceConstrsRttiId, InstanceConstrsInit, InstanceConstrsDefn), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_rtti_id(ModuleName, TCDeclRttiId), gen_init_int(NumTypeVars), gen_init_int(NumInstanceConstraints), gen_init_rtti_id(ModuleName, InstanceTypesRttiId), gen_init_rtti_id(ModuleName, InstanceConstrsRttiId) ]), - list__condense([TypesDefns, [TypesDefn], TCConstrDefns, - [InstanceConstrsDefn]], SubDefns). + SubDefns = TypesDefns ++ [TypesDefn] ++ TCConstrDefns ++ + [InstanceConstrsDefn]. :- pred make_instance_constr_id(tc_name::in, list(tc_type)::in, int::in, int::in, rtti_id::out) is det. @@ -433,39 +432,39 @@ make_instance_constr_id(TCName, Types, TCNum, Arity, RttiId) :- %-----------------------------------------------------------------------------% :- pred gen_type_info_defn(module_info::in, rtti_type_info::in, rtti_id::in, - mlds__initializer::out, list(mlds__defn)::out) is det. + mlds_initializer::out, list(mlds_defn)::out) is det. gen_type_info_defn(_, plain_arity_zero_type_info(_), _, _, _) :- unexpected(this_file, "gen_type_info_defn: plain_arity_zero_type_info"). gen_type_info_defn(ModuleInfo, plain_type_info(RttiTypeCtor, ArgTypes), RttiId, Init, SubDefns) :- - ArgRttiDatas = list__map(type_info_to_rtti_data, ArgTypes), - RealRttiDatas = list__filter(real_rtti_data, ArgRttiDatas), - SubDefnLists = list__map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), - SubDefns = list__condense(SubDefnLists), + ArgRttiDatas = list.map(type_info_to_rtti_data, ArgTypes), + RealRttiDatas = list.filter(real_rtti_data, ArgRttiDatas), + SubDefnLists = list.map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), + SubDefns = list.condense(SubDefnLists), module_info_get_name(ModuleInfo, ModuleName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_rtti_name(ModuleName, RttiTypeCtor, type_ctor_info), - gen_init_cast_rtti_datas_array(mlds__type_info_type, + gen_init_cast_rtti_datas_array(mlds_type_info_type, ModuleName, ArgRttiDatas) ]). gen_type_info_defn(ModuleInfo, var_arity_type_info(VarArityId, ArgTypes), RttiId, Init, SubDefns) :- - ArgRttiDatas = list__map(type_info_to_rtti_data, ArgTypes), - RealRttiDatas = list__filter(real_rtti_data, ArgRttiDatas), - SubDefnLists = list__map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), - SubDefns = list__condense(SubDefnLists), + ArgRttiDatas = list.map(type_info_to_rtti_data, ArgTypes), + RealRttiDatas = list.filter(real_rtti_data, ArgRttiDatas), + SubDefnLists = list.map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), + SubDefns = list.condense(SubDefnLists), RttiTypeCtor = var_arity_id_to_rtti_type_ctor(VarArityId), module_info_get_name(ModuleInfo, ModuleName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_rtti_name(ModuleName, RttiTypeCtor, type_ctor_info), - gen_init_int(list__length(ArgTypes)), - gen_init_cast_rtti_datas_array(mlds__type_info_type, + gen_init_int(list.length(ArgTypes)), + gen_init_cast_rtti_datas_array(mlds_type_info_type, ModuleName, ArgRttiDatas) ]). :- pred gen_pseudo_type_info_defn(module_info::in, rtti_pseudo_type_info::in, - rtti_id::in, mlds__initializer::out, list(mlds__defn)::out) is det. + rtti_id::in, mlds_initializer::out, list(mlds_defn)::out) is det. gen_pseudo_type_info_defn(_, plain_arity_zero_pseudo_type_info(_), _, _, _) :- unexpected(this_file, @@ -473,29 +472,29 @@ gen_pseudo_type_info_defn(_, plain_arity_zero_pseudo_type_info(_), _, _, _) :- gen_pseudo_type_info_defn(ModuleInfo, PseudoTypeInfo, RttiId, Init, SubDefns) :- PseudoTypeInfo = plain_pseudo_type_info(RttiTypeCtor, ArgTypes), - ArgRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, ArgTypes), - RealRttiDatas = list__filter(real_rtti_data, ArgRttiDatas), - SubDefnLists = list__map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), - SubDefns = list__condense(SubDefnLists), + ArgRttiDatas = list.map(maybe_pseudo_type_info_to_rtti_data, ArgTypes), + RealRttiDatas = list.filter(real_rtti_data, ArgRttiDatas), + SubDefnLists = list.map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), + SubDefns = list.condense(SubDefnLists), module_info_get_name(ModuleInfo, ModuleName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_rtti_name(ModuleName, RttiTypeCtor, type_ctor_info), - gen_init_cast_rtti_datas_array(mlds__pseudo_type_info_type, + gen_init_cast_rtti_datas_array(mlds_pseudo_type_info_type, ModuleName, ArgRttiDatas) ]). gen_pseudo_type_info_defn(ModuleInfo, PseudoTypeInfo, RttiId, Init, SubDefns) :- PseudoTypeInfo = var_arity_pseudo_type_info(VarArityId, ArgTypes), - ArgRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, ArgTypes), - RealRttiDatas = list__filter(real_rtti_data, ArgRttiDatas), - SubDefnLists = list__map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), - SubDefns = list__condense(SubDefnLists), + ArgRttiDatas = list.map(maybe_pseudo_type_info_to_rtti_data, ArgTypes), + RealRttiDatas = list.filter(real_rtti_data, ArgRttiDatas), + SubDefnLists = list.map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), + SubDefns = list.condense(SubDefnLists), RttiTypeCtor = var_arity_id_to_rtti_type_ctor(VarArityId), module_info_get_name(ModuleInfo, ModuleName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_rtti_name(ModuleName, RttiTypeCtor, type_ctor_info), - gen_init_int(list__length(ArgTypes)), - gen_init_cast_rtti_datas_array(mlds__pseudo_type_info_type, + gen_init_int(list.length(ArgTypes)), + gen_init_cast_rtti_datas_array(mlds_pseudo_type_info_type, ModuleName, ArgRttiDatas) ]). gen_pseudo_type_info_defn(_, type_var(_), _, _, _) :- @@ -504,8 +503,8 @@ gen_pseudo_type_info_defn(_, type_var(_), _, _, _) :- %-----------------------------------------------------------------------------% :- pred gen_functors_layout_info(module_info::in, rtti_type_ctor::in, - type_ctor_details::in, mlds__initializer::out, mlds__initializer::out, - list(mlds__defn)::out) is det. + type_ctor_details::in, mlds_initializer::out, mlds_initializer::out, + list(mlds_defn)::out) is det. gen_functors_layout_info(ModuleInfo, RttiTypeCtor, TypeCtorDetails, FunctorInit, LayoutInit, Defns) :- @@ -513,7 +512,7 @@ gen_functors_layout_info(ModuleInfo, RttiTypeCtor, TypeCtorDetails, ( TypeCtorDetails = enum(_, EnumFunctors, EnumByValue, EnumByName, _IsDummy), - EnumFunctorDescs = list__map( + EnumFunctorDescs = list.map( gen_enum_functor_desc(ModuleInfo, RttiTypeCtor), EnumFunctors), ByValueDefn = gen_enum_value_ordered_table(ModuleInfo, RttiTypeCtor, EnumByValue), @@ -526,9 +525,9 @@ gen_functors_layout_info(ModuleInfo, RttiTypeCtor, TypeCtorDetails, Defns = EnumFunctorDescs ++ [ByValueDefn, ByNameDefn] ; TypeCtorDetails = du(_, DuFunctors, DuByPtag, DuByName), - DuFunctorDefnLists = list__map( + DuFunctorDefnLists = list.map( gen_du_functor_desc(ModuleInfo, RttiTypeCtor), DuFunctors), - DuFunctorDefns = list__condense(DuFunctorDefnLists), + DuFunctorDefns = list.condense(DuFunctorDefnLists), ByPtagDefns = gen_du_ptag_ordered_table(ModuleInfo, RttiTypeCtor, DuByPtag), ByNameDefn = gen_du_name_ordered_table(ModuleInfo, @@ -541,10 +540,10 @@ gen_functors_layout_info(ModuleInfo, RttiTypeCtor, TypeCtorDetails, ; TypeCtorDetails = reserved(_, MaybeResFunctors, ResFunctors, DuByPtag, MaybeResByName), - MaybeResFunctorDefnLists = list__map( + MaybeResFunctorDefnLists = list.map( gen_maybe_res_functor_desc(ModuleInfo, RttiTypeCtor), MaybeResFunctors), - MaybeResFunctorDefns = list__condense(MaybeResFunctorDefnLists), + MaybeResFunctorDefns = list.condense(MaybeResFunctorDefnLists), ByValueDefns = gen_maybe_res_value_ordered_table(ModuleInfo, RttiTypeCtor, ResFunctors, DuByPtag), ByNameDefn = gen_maybe_res_name_ordered_table(ModuleInfo, @@ -566,41 +565,41 @@ gen_functors_layout_info(ModuleInfo, RttiTypeCtor, TypeCtorDetails, TypeRttiData = maybe_pseudo_type_info_to_rtti_data(EqvType), gen_pseudo_type_info(ModuleInfo, TypeRttiData, LayoutInit, Defns), % The type is a lie, but a safe one. - FunctorInit = gen_init_null_pointer(mlds__generic_type) + FunctorInit = gen_init_null_pointer(mlds_generic_type) ; TypeCtorDetails = builtin(_), Defns = [], - LayoutInit = gen_init_null_pointer(mlds__generic_type), - FunctorInit = gen_init_null_pointer(mlds__generic_type) + LayoutInit = gen_init_null_pointer(mlds_generic_type), + FunctorInit = gen_init_null_pointer(mlds_generic_type) ; TypeCtorDetails = impl_artifact(_), Defns = [], - LayoutInit = gen_init_null_pointer(mlds__generic_type), - FunctorInit = gen_init_null_pointer(mlds__generic_type) + LayoutInit = gen_init_null_pointer(mlds_generic_type), + FunctorInit = gen_init_null_pointer(mlds_generic_type) ; TypeCtorDetails = foreign(_), Defns = [], - LayoutInit = gen_init_null_pointer(mlds__generic_type), - FunctorInit = gen_init_null_pointer(mlds__generic_type) + LayoutInit = gen_init_null_pointer(mlds_generic_type), + FunctorInit = gen_init_null_pointer(mlds_generic_type) ). %-----------------------------------------------------------------------------% :- func gen_enum_functor_desc(module_info, rtti_type_ctor, enum_functor) - = mlds__defn. + = mlds_defn. gen_enum_functor_desc(_ModuleInfo, RttiTypeCtor, EnumFunctor) = MLDS_Defn :- EnumFunctor = enum_functor(FunctorName, Ordinal), RttiName = enum_functor_desc(Ordinal), RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_string(FunctorName), gen_init_int(Ordinal) ]), rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn). :- func gen_notag_functor_desc(module_info, rtti_type_ctor, notag_functor) - = list(mlds__defn). + = list(mlds_defn). gen_notag_functor_desc(ModuleInfo, RttiTypeCtor, NotagFunctorDesc) = MLDS_Defns :- @@ -609,23 +608,23 @@ gen_notag_functor_desc(ModuleInfo, RttiTypeCtor, NotagFunctorDesc) gen_pseudo_type_info(ModuleInfo, ArgTypeRttiData, PTIInit, SubDefns), RttiName = notag_functor_desc, RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_string(FunctorName), PTIInit, gen_init_maybe(ml_string_type, gen_init_string, MaybeArgName) ]), rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn), - MLDS_Defns = list__append(SubDefns, [MLDS_Defn]). + MLDS_Defns = SubDefns ++ [MLDS_Defn]. :- func gen_du_functor_desc(module_info, rtti_type_ctor, du_functor) - = list(mlds__defn). + = list(mlds_defn). gen_du_functor_desc(ModuleInfo, RttiTypeCtor, DuFunctor) = MLDS_Defns :- DuFunctor = du_functor(FunctorName, Arity, Ordinal, Rep, ArgInfos, MaybeExistInfo), - ArgTypes = list__map(du_arg_info_type, ArgInfos), - MaybeArgNames = list__map(du_arg_info_name, ArgInfos), - ArgNames = list__filter_map(project_yes, MaybeArgNames), + ArgTypes = list.map(du_arg_info_type, ArgInfos), + MaybeArgNames = list.map(du_arg_info_name, ArgInfos), + ArgNames = list.filter_map(project_yes, MaybeArgNames), ContainsVarBitVector = compute_contains_var_bit_vector(ArgTypes), module_info_get_name(ModuleInfo, ModuleName), ( @@ -638,7 +637,7 @@ gen_du_functor_desc(ModuleInfo, RttiTypeCtor, DuFunctor) = MLDS_Defns :- ArgInfos = [], ArgTypeDefns = [], ArgTypeInit = gen_init_null_pointer( - mlds__rtti_type(item_type( + mlds_rtti_type(item_type( ctor_rtti_id(RttiTypeCtor, field_types(0))))) ), ( @@ -652,7 +651,7 @@ gen_du_functor_desc(ModuleInfo, RttiTypeCtor, DuFunctor) = MLDS_Defns :- ArgNames = [], ArgNameDefns = [], ArgNameInit = gen_init_null_pointer( - mlds__rtti_type(item_type( + mlds_rtti_type(item_type( ctor_rtti_id(RttiTypeCtor, field_names(0))))) ), ( @@ -665,7 +664,7 @@ gen_du_functor_desc(ModuleInfo, RttiTypeCtor, DuFunctor) = MLDS_Defns :- MaybeExistInfo = no, ExistInfoDefns = [], ExistInfoInit = gen_init_null_pointer( - mlds__rtti_type(item_type( + mlds_rtti_type(item_type( ctor_rtti_id(RttiTypeCtor, exist_info(0))))) ), SubDefns = ArgTypeDefns ++ ArgNameDefns ++ ExistInfoDefns, @@ -688,7 +687,7 @@ gen_du_functor_desc(ModuleInfo, RttiTypeCtor, DuFunctor) = MLDS_Defns :- ), RttiName = du_functor_desc(Ordinal), RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_string(FunctorName), gen_init_int(Arity), gen_init_int(ContainsVarBitVector), @@ -701,16 +700,16 @@ gen_du_functor_desc(ModuleInfo, RttiTypeCtor, DuFunctor) = MLDS_Defns :- ExistInfoInit ]), rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn), - MLDS_Defns = list__append(SubDefns, [MLDS_Defn]). + MLDS_Defns = SubDefns ++ [MLDS_Defn]. :- func gen_res_addr_functor_desc(module_info, rtti_type_ctor, - reserved_functor) = mlds__defn. + reserved_functor) = mlds_defn. gen_res_addr_functor_desc(ModuleInfo, RttiTypeCtor, ResFunctor) = MLDS_Defn :- ResFunctor = reserved_functor(FunctorName, Ordinal, ReservedAddress), RttiName = res_functor_desc(Ordinal), RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_string(FunctorName), gen_init_int(Ordinal), gen_init_reserved_address(ModuleInfo, ReservedAddress) @@ -718,7 +717,7 @@ gen_res_addr_functor_desc(ModuleInfo, RttiTypeCtor, ResFunctor) = MLDS_Defn :- rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn). :- func gen_maybe_res_functor_desc(module_info, rtti_type_ctor, - maybe_reserved_functor) = list(mlds__defn). + maybe_reserved_functor) = list(mlds_defn). gen_maybe_res_functor_desc(ModuleInfo, RttiTypeCtor, MaybeResFunctor) = MLDS_Defns :- @@ -735,7 +734,7 @@ gen_maybe_res_functor_desc(ModuleInfo, RttiTypeCtor, MaybeResFunctor) %-----------------------------------------------------------------------------% :- func gen_init_exist_locn(rtti_type_ctor, exist_typeinfo_locn) = - mlds__initializer. + mlds_initializer. gen_init_exist_locn(RttiTypeCtor, ExistTypeInfoLocn) = Init :- ( @@ -745,13 +744,13 @@ gen_init_exist_locn(RttiTypeCtor, ExistTypeInfoLocn) = Init :- SlotInTci = -1 ), RttiId = ctor_rtti_id(RttiTypeCtor, exist_locn), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_int(SlotInCell), gen_init_int(SlotInTci) ]). :- func gen_exist_locns_array(module_info, rtti_type_ctor, int, - list(exist_typeinfo_locn)) = mlds__defn. + list(exist_typeinfo_locn)) = mlds_defn. gen_exist_locns_array(_ModuleInfo, RttiTypeCtor, Ordinal, Locns) = MLDS_Defn :- Init = gen_init_array(gen_init_exist_locn(RttiTypeCtor), Locns), @@ -761,25 +760,24 @@ gen_exist_locns_array(_ModuleInfo, RttiTypeCtor, Ordinal, Locns) = MLDS_Defn :- :- pred gen_tc_constraint(module_info::in, pred(int, int, rtti_id)::in(pred(in, in, out) is det), tc_constraint::in, rtti_id::out, counter::in, counter::out, - list(mlds__defn)::in, list(mlds__defn)::out) is det. + list(mlds_defn)::in, list(mlds_defn)::out) is det. gen_tc_constraint(ModuleInfo, MakeRttiId, Constraint, RttiId, !Counter, !Defns) :- Constraint = tc_constraint(TCName, Types), - list__length(Types, Arity), - counter__allocate(TCNum, !Counter), + list.length(Types, Arity), + counter.allocate(TCNum, !Counter), MakeRttiId(TCNum, Arity, RttiId), TCDeclRttiName = type_class_decl, module_info_get_name(ModuleInfo, ModuleName), - TypeRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, Types), + TypeRttiDatas = list.map(maybe_pseudo_type_info_to_rtti_data, Types), gen_pseudo_type_info_array(ModuleInfo, TypeRttiDatas, PTIInits, PTIDefns), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_tc_rtti_name(ModuleName, TCName, TCDeclRttiName), PTIInits ]), rtti_id_and_init_to_defn(RttiId, Init, ConstrDefn), - list__append(PTIDefns, [ConstrDefn], NewDefns), - list__append(!.Defns, NewDefns, !:Defns). + !:Defns = !.Defns ++ PTIDefns ++ [ConstrDefn]. :- pred make_exist_tc_constr_id(rtti_type_ctor::in, int::in, int::in, int::in, rtti_id::out) is det. @@ -789,39 +787,39 @@ make_exist_tc_constr_id(RttiTypeCtor, Ordinal, TCNum, Arity, RttiId) :- RttiId = ctor_rtti_id(RttiTypeCtor, RttiName). :- func gen_exist_info(module_info, rtti_type_ctor, int, exist_info) - = list(mlds__defn). + = list(mlds_defn). gen_exist_info(ModuleInfo, RttiTypeCtor, Ordinal, ExistInfo) = MLDS_Defns :- ExistInfo = exist_info(Plain, InTci, Constraints, Locns), module_info_get_name(ModuleInfo, ModuleName), RttiName = exist_info(Ordinal), RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), - list__length(Constraints, Tci), + list.length(Constraints, Tci), ( Constraints = [], ConstrInit = gen_init_null_pointer( - mlds__rtti_type(item_type(ctor_rtti_id(RttiTypeCtor, + mlds_rtti_type(item_type(ctor_rtti_id(RttiTypeCtor, exist_tc_constrs(Ordinal))))), ConstrDefns = [] ; Constraints = [_ | _], ConstrInit = gen_init_rtti_name(ModuleName, RttiTypeCtor, exist_tc_constrs(Ordinal)), - list__map_foldl2(gen_tc_constraint(ModuleInfo, + list.map_foldl2(gen_tc_constraint(ModuleInfo, make_exist_tc_constr_id(RttiTypeCtor, Ordinal)), - Constraints, TCConstrIds, counter__init(1), _, + Constraints, TCConstrIds, counter.init(1), _, [], TCConstrDefns), TCConstrArrayRttiName = exist_tc_constrs(Ordinal), TCConstrArrayRttiId = ctor_rtti_id(RttiTypeCtor, TCConstrArrayRttiName), - ElementType = mlds__rtti_type(element_type(TCConstrArrayRttiId)), + ElementType = mlds_rtti_type(element_type(TCConstrArrayRttiId)), TCConstrArrayInit = gen_init_array( gen_init_cast_rtti_id(ElementType, ModuleName), TCConstrIds), rtti_name_and_init_to_defn(RttiTypeCtor, TCConstrArrayRttiName, TCConstrArrayInit, TCConstrArrayDefn), - list__append(TCConstrDefns, [TCConstrArrayDefn], ConstrDefns) + ConstrDefns = TCConstrDefns ++ [TCConstrArrayDefn] ), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_int(Plain), gen_init_int(InTci), gen_init_int(Tci), @@ -834,7 +832,7 @@ gen_exist_info(ModuleInfo, RttiTypeCtor, Ordinal, ExistInfo) = MLDS_Defns :- MLDS_Defns = [MLDS_Defn, LocnsDefn | ConstrDefns]. :- func gen_field_names(module_info, rtti_type_ctor, int, list(maybe(string))) - = mlds__defn. + = mlds_defn. gen_field_names(_ModuleInfo, RttiTypeCtor, Ordinal, MaybeNames) = MLDS_Defn :- StrType = builtin(string), @@ -845,51 +843,51 @@ gen_field_names(_ModuleInfo, RttiTypeCtor, Ordinal, MaybeNames) = MLDS_Defn :- rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn). :- func gen_field_types(module_info, rtti_type_ctor, int, - list(rtti_maybe_pseudo_type_info_or_self)) = list(mlds__defn). + list(rtti_maybe_pseudo_type_info_or_self)) = list(mlds_defn). gen_field_types(ModuleInfo, RttiTypeCtor, Ordinal, Types) = MLDS_Defns :- - TypeRttiDatas = list__map(maybe_pseudo_type_info_or_self_to_rtti_data, + TypeRttiDatas = list.map(maybe_pseudo_type_info_or_self_to_rtti_data, Types), gen_pseudo_type_info_array(ModuleInfo, TypeRttiDatas, Init, SubDefns), RttiName = field_types(Ordinal), rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn), - MLDS_Defns = list__append(SubDefns, [MLDS_Defn]). + MLDS_Defns = SubDefns ++ [MLDS_Defn]. %-----------------------------------------------------------------------------% :- func gen_enum_value_ordered_table(module_info, rtti_type_ctor, - map(int, enum_functor)) = mlds__defn. + map(int, enum_functor)) = mlds_defn. gen_enum_value_ordered_table(ModuleInfo, RttiTypeCtor, EnumByValue) = MLDS_Defn :- - map__values(EnumByValue, Functors), + map.values(EnumByValue, Functors), module_info_get_name(ModuleInfo, ModuleName), - FunctorRttiNames = list__map(enum_functor_rtti_name, Functors), + FunctorRttiNames = list.map(enum_functor_rtti_name, Functors), Init = gen_init_rtti_names_array(ModuleName, RttiTypeCtor, FunctorRttiNames), RttiName = enum_value_ordered_table, rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn). :- func gen_enum_name_ordered_table(module_info, rtti_type_ctor, - map(string, enum_functor)) = mlds__defn. + map(string, enum_functor)) = mlds_defn. gen_enum_name_ordered_table(ModuleInfo, RttiTypeCtor, EnumByName) = MLDS_Defn :- - map__values(EnumByName, Functors), + map.values(EnumByName, Functors), module_info_get_name(ModuleInfo, ModuleName), - FunctorRttiNames = list__map(enum_functor_rtti_name, Functors), + FunctorRttiNames = list.map(enum_functor_rtti_name, Functors), Init = gen_init_rtti_names_array(ModuleName, RttiTypeCtor, FunctorRttiNames), RttiName = enum_name_ordered_table, rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn). :- func gen_du_ptag_ordered_table(module_info, rtti_type_ctor, - map(int, sectag_table)) = list(mlds__defn). + map(int, sectag_table)) = list(mlds_defn). gen_du_ptag_ordered_table(ModuleInfo, RttiTypeCtor, PtagMap) = MLDS_Defns :- module_info_get_name(ModuleInfo, ModuleName), - map__to_assoc_list(PtagMap, PtagList), - SubDefns = list__map(gen_du_stag_ordered_table(ModuleName, RttiTypeCtor), + map.to_assoc_list(PtagMap, PtagList), + SubDefns = list.map(gen_du_stag_ordered_table(ModuleName, RttiTypeCtor), PtagList), ( PtagList = [1 - _ | _] -> % Output a dummy ptag definition for the @@ -897,11 +895,11 @@ gen_du_ptag_ordered_table(ModuleInfo, RttiTypeCtor, PtagMap) = MLDS_Defns :- RttiElemName = du_ptag_layout(0), RttiElemId = ctor_rtti_id(RttiTypeCtor, RttiElemName), PtagInitPrefix = [ - init_struct(mlds__rtti_type(item_type(RttiElemId)), + init_struct(mlds_rtti_type(item_type(RttiElemId)), [gen_init_int(0), gen_init_builtin_const("MR_SECTAG_VARIABLE"), gen_init_null_pointer( - mlds__rtti_type(item_type( + mlds_rtti_type(item_type( ctor_rtti_id(RttiTypeCtor, du_stag_ordered_table(0)))))] )], FirstPtag = 1 @@ -917,12 +915,12 @@ gen_du_ptag_ordered_table(ModuleInfo, RttiTypeCtor, PtagMap) = MLDS_Defns :- PtagInits = gen_du_ptag_ordered_table_body(ModuleName, RttiTypeCtor, PtagList, FirstPtag), RttiName = du_ptag_ordered_table, - Init = init_array(list__append(PtagInitPrefix, PtagInits)), + Init = init_array(PtagInitPrefix ++ PtagInits), rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn), - MLDS_Defns = list__append(SubDefns, [MLDS_Defn]). + MLDS_Defns = SubDefns ++ [MLDS_Defn]. :- func gen_du_ptag_ordered_table_body(module_name, rtti_type_ctor, - assoc_list(int, sectag_table), int) = list(mlds__initializer). + assoc_list(int, sectag_table), int) = list(mlds_initializer). gen_du_ptag_ordered_table_body(_, _, [], _) = []. gen_du_ptag_ordered_table_body(ModuleName, RttiTypeCtor, @@ -932,7 +930,7 @@ gen_du_ptag_ordered_table_body(ModuleName, RttiTypeCtor, SectagTable = sectag_table(SectagLocn, NumSharers, _SectagMap), RttiName = du_ptag_layout(Ptag), RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_int(NumSharers), gen_init_sectag_locn(SectagLocn), gen_init_rtti_name(ModuleName, RttiTypeCtor, @@ -942,59 +940,59 @@ gen_du_ptag_ordered_table_body(ModuleName, RttiTypeCtor, PtagTail, CurPtag + 1). :- func gen_du_stag_ordered_table(module_name, rtti_type_ctor, - pair(int, sectag_table)) = mlds__defn. + pair(int, sectag_table)) = mlds_defn. gen_du_stag_ordered_table(ModuleName, RttiTypeCtor, Ptag - SectagTable) = MLDS_Defn :- SectagTable = sectag_table(_SectagLocn, _NumSharers, SectagMap), - map__values(SectagMap, SectagFunctors), - FunctorRttiNames = list__map(du_functor_rtti_name, SectagFunctors), + map.values(SectagMap, SectagFunctors), + FunctorRttiNames = list.map(du_functor_rtti_name, SectagFunctors), Init = gen_init_rtti_names_array(ModuleName, RttiTypeCtor, FunctorRttiNames), RttiName = du_stag_ordered_table(Ptag), rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn). :- func gen_du_name_ordered_table(module_info, rtti_type_ctor, - map(string, map(int, du_functor))) = mlds__defn. + map(string, map(int, du_functor))) = mlds_defn. gen_du_name_ordered_table(ModuleInfo, RttiTypeCtor, NameArityMap) = MLDS_Defn :- - map__values(NameArityMap, ArityMaps), - list__map(map__values, ArityMaps, FunctorLists), - list__condense(FunctorLists, Functors), + map.values(NameArityMap, ArityMaps), + list.map(map.values, ArityMaps, FunctorLists), + list.condense(FunctorLists, Functors), module_info_get_name(ModuleInfo, ModuleName), - FunctorRttiNames = list__map(du_functor_rtti_name, Functors), + FunctorRttiNames = list.map(du_functor_rtti_name, Functors), Init = gen_init_rtti_names_array(ModuleName, RttiTypeCtor, FunctorRttiNames), RttiName = du_name_ordered_table, rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn). :- func gen_maybe_res_value_ordered_table(module_info, rtti_type_ctor, - list(reserved_functor), map(int, sectag_table)) = list(mlds__defn). + list(reserved_functor), map(int, sectag_table)) = list(mlds_defn). gen_maybe_res_value_ordered_table(ModuleInfo, RttiTypeCtor, ResFunctors, DuByPtag) = MLDS_Defns :- - ResFunctorReps = list__map(res_addr_rep, ResFunctors), - list__filter(res_addr_is_numeric, ResFunctorReps, + ResFunctorReps = list.map(res_addr_rep, ResFunctors), + list.filter(res_addr_is_numeric, ResFunctorReps, NumericResFunctorReps, SymbolicResFunctorReps), - list__length(NumericResFunctorReps, NumNumericResFunctorReps), - list__length(SymbolicResFunctorReps, NumSymbolicResFunctorReps), + list.length(NumericResFunctorReps, NumNumericResFunctorReps), + list.length(SymbolicResFunctorReps, NumSymbolicResFunctorReps), module_info_get_name(ModuleInfo, ModuleName), ResDefns = [gen_res_addr_functor_table(ModuleName, RttiTypeCtor, ResFunctors)], ( NumSymbolicResFunctorReps = 0 -> ResAddrDefns = [], - ResAddrInit = gen_init_null_pointer(mlds__generic_type) + ResAddrInit = gen_init_null_pointer(mlds_generic_type) ; ResAddrDefns = [gen_res_addrs_list(ModuleInfo, RttiTypeCtor, SymbolicResFunctorReps)], ResAddrInit = gen_init_rtti_name(ModuleName, RttiTypeCtor, res_addrs) ), DuDefns = gen_du_ptag_ordered_table(ModuleInfo, RttiTypeCtor, DuByPtag), - SubDefns = list__condense([ResDefns, ResAddrDefns, DuDefns]), + SubDefns = ResDefns ++ ResAddrDefns ++ DuDefns, RttiName = res_value_ordered_table, RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), - Init = init_struct(mlds__rtti_type(item_type(RttiId)), [ + Init = init_struct(mlds_rtti_type(item_type(RttiId)), [ gen_init_int(NumNumericResFunctorReps), gen_init_int(NumSymbolicResFunctorReps), ResAddrInit, @@ -1002,21 +1000,21 @@ gen_maybe_res_value_ordered_table(ModuleInfo, RttiTypeCtor, ResFunctors, gen_init_rtti_name(ModuleName, RttiTypeCtor, du_ptag_ordered_table) ]), rtti_id_and_init_to_defn(RttiId, Init, MLDS_Defn), - MLDS_Defns = list__append(SubDefns, [MLDS_Defn]). + MLDS_Defns = SubDefns ++ [MLDS_Defn]. :- func gen_res_addr_functor_table(module_name, rtti_type_ctor, - list(reserved_functor)) = mlds__defn. + list(reserved_functor)) = mlds_defn. gen_res_addr_functor_table(ModuleName, RttiTypeCtor, ResFunctors) = MLDS_Defn :- - FunctorRttiNames = list__map(res_functor_rtti_name, ResFunctors), + FunctorRttiNames = list.map(res_functor_rtti_name, ResFunctors), Init = gen_init_rtti_names_array(ModuleName, RttiTypeCtor, FunctorRttiNames), RttiName = res_addr_functors, rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn). :- func gen_res_addrs_list(module_info, rtti_type_ctor, list(reserved_address)) - = mlds__defn. + = mlds_defn. gen_res_addrs_list(ModuleInfo, RttiTypeCtor, ResAddrs) = MLDS_Defn :- Init = gen_init_array(gen_init_reserved_address(ModuleInfo), ResAddrs), @@ -1024,13 +1022,13 @@ gen_res_addrs_list(ModuleInfo, RttiTypeCtor, ResAddrs) = MLDS_Defn :- rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn). :- func gen_maybe_res_name_ordered_table(module_info, rtti_type_ctor, - map(string, map(int, maybe_reserved_functor))) = mlds__defn. + map(string, map(int, maybe_reserved_functor))) = mlds_defn. gen_maybe_res_name_ordered_table(ModuleInfo, RttiTypeCtor, NameArityMap) = MLDS_Defn :- - map__values(NameArityMap, ArityMaps), - list__map(map__values, ArityMaps, FunctorLists), - list__condense(FunctorLists, Functors), + map.values(NameArityMap, ArityMaps), + list.map(map.values, ArityMaps, FunctorLists), + list.condense(FunctorLists, Functors), module_info_get_name(ModuleInfo, ModuleName), Init = gen_init_array( gen_maybe_res_name_ordered_table_element(ModuleName, RttiTypeCtor), @@ -1039,13 +1037,13 @@ gen_maybe_res_name_ordered_table(ModuleInfo, RttiTypeCtor, NameArityMap) rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Init, MLDS_Defn). :- func gen_maybe_res_name_ordered_table_element(module_name, rtti_type_ctor, - maybe_reserved_functor) = mlds__initializer. + maybe_reserved_functor) = mlds_initializer. gen_maybe_res_name_ordered_table_element(ModuleName, RttiTypeCtor, MaybeResFunctor) = Init :- RttiName = maybe_res_addr_functor_desc, RttiId = ctor_rtti_id(RttiTypeCtor, RttiName), - Type = mlds__rtti_type(item_type(RttiId)), + Type = mlds_rtti_type(item_type(RttiId)), ( MaybeResFunctor = res_func(ResFunctor), Name = ResFunctor ^ res_name, @@ -1071,43 +1069,43 @@ gen_maybe_res_name_ordered_table_element(ModuleName, RttiTypeCtor, %-----------------------------------------------------------------------------% :- func gen_init_rtti_names_array(module_name, rtti_type_ctor, - list(ctor_rtti_name)) = mlds__initializer. + list(ctor_rtti_name)) = mlds_initializer. gen_init_rtti_names_array(ModuleName, RttiTypeCtor, RttiNames) = gen_init_array(gen_init_rtti_name(ModuleName, RttiTypeCtor), RttiNames). :- func gen_init_rtti_datas_array(module_name, list(rtti_data)) = - mlds__initializer. + mlds_initializer. gen_init_rtti_datas_array(ModuleName, RttiDatas) = gen_init_array(gen_init_rtti_data(ModuleName), RttiDatas). :- func gen_init_cast_rtti_datas_array(mlds_type, module_name, - list(rtti_data)) = mlds__initializer. + list(rtti_data)) = mlds_initializer. gen_init_cast_rtti_datas_array(Type, ModuleName, RttiDatas) = gen_init_array(gen_init_cast_rtti_data(Type, ModuleName), RttiDatas). % Generate the MLDS initializer comprising the rtti_name - % for a given rtti_data, converted to mlds__generic_type. + % for a given rtti_data, converted to mlds_generic_type. % XXX We don't need to pass the module_name down to here. % :- func gen_init_cast_rtti_data(mlds_type, module_name, rtti_data) = - mlds__initializer. + mlds_initializer. gen_init_cast_rtti_data(DestType, ModuleName, RttiData) = Initializer :- ( RttiData = pseudo_type_info(type_var(VarNum)) -> % rtti_data_to_name/3 does not handle this case - SrcType = mlds__native_int_type, + SrcType = mlds_native_int_type, Initializer = init_obj(unop(gen_cast(SrcType, DestType), const(int_const(VarNum)))) ; RttiData = base_typeclass_info(TCName, InstanceModuleName, InstanceString, _) -> - SrcType = rtti_type(item_type(tc_rtti_id(TCName, + SrcType = mlds_rtti_type(item_type(tc_rtti_id(TCName, base_typeclass_info(InstanceModuleName, InstanceString)))), MLDS_ModuleName = mercury_module_name_to_mlds(InstanceModuleName), MLDS_DataName = rtti(tc_rtti_id(TCName, @@ -1129,7 +1127,7 @@ gen_cast(_SrcType, DestType) = cast(DestType). % Generate the MLDS initializer comprising the rtti_name % for a given rtti_data. % -:- func gen_init_rtti_data(module_name, rtti_data) = mlds__initializer. +:- func gen_init_rtti_data(module_name, rtti_data) = mlds_initializer. gen_init_rtti_data(ModuleName, RttiData) = Initializer :- rtti_data_to_id(RttiData, RttiId), @@ -1138,7 +1136,7 @@ gen_init_rtti_data(ModuleName, RttiData) = Initializer :- % Generate an MLDS initializer comprising just the % the rval for a given rtti_id. % -:- func gen_init_rtti_id(module_name, rtti_id) = mlds__initializer. +:- func gen_init_rtti_id(module_name, rtti_id) = mlds_initializer. gen_init_rtti_id(ModuleName, ctor_rtti_id(RttiTypeCtor, RttiName)) = gen_init_rtti_name(ModuleName, RttiTypeCtor, RttiName). @@ -1149,7 +1147,7 @@ gen_init_rtti_id(ModuleName, tc_rtti_id(TCName, TCRttiName)) = % the rval for a given rtti_name. % :- func gen_init_rtti_name(module_name, rtti_type_ctor, ctor_rtti_name) = - mlds__initializer. + mlds_initializer. gen_init_rtti_name(ModuleName, RttiTypeCtor, RttiName) = init_obj(gen_rtti_name(ModuleName, RttiTypeCtor, RttiName)). @@ -1158,7 +1156,7 @@ gen_init_rtti_name(ModuleName, RttiTypeCtor, RttiName) = % the rval for a given tc_rtti_name. % :- func gen_init_tc_rtti_name(module_name, tc_name, tc_rtti_name) = - mlds__initializer. + mlds_initializer. gen_init_tc_rtti_name(ModuleName, TCName, TCRttiName) = init_obj(gen_tc_rtti_name(ModuleName, TCName, TCRttiName)). @@ -1167,10 +1165,10 @@ gen_init_tc_rtti_name(ModuleName, TCName, TCRttiName) = % for a given rtti_name, converted to the given type. % :- func gen_init_cast_rtti_id(mlds_type, module_name, rtti_id) - = mlds__initializer. + = mlds_initializer. gen_init_cast_rtti_id(DestType, ModuleName, RttiId) = Initializer :- - SrcType = rtti_type(item_type(RttiId)), + SrcType = mlds_rtti_type(item_type(RttiId)), Initializer = init_obj(unop(gen_cast(SrcType, DestType), gen_rtti_id(ModuleName, RttiId))). @@ -1280,43 +1278,43 @@ mlds_module_name_from_tc_name(TCName) = MLDS_ModuleName :- %-----------------------------------------------------------------------------% :- pred gen_pseudo_type_info(module_info::in, rtti_data::in, - mlds__initializer::out, list(mlds__defn)::out) is det. + mlds_initializer::out, list(mlds_defn)::out) is det. gen_pseudo_type_info(ModuleInfo, PTIRttiData, Init, Defns) :- - RealRttiDatas = list__filter(real_rtti_data, [PTIRttiData]), - DefnLists = list__map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), - Defns = list__condense(DefnLists), + RealRttiDatas = list.filter(real_rtti_data, [PTIRttiData]), + DefnLists = list.map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), + Defns = list.condense(DefnLists), module_info_get_name(ModuleInfo, ModuleName), - Init = gen_init_cast_rtti_data(mlds__pseudo_type_info_type, + Init = gen_init_cast_rtti_data(mlds_pseudo_type_info_type, ModuleName, PTIRttiData). :- pred gen_pseudo_type_info_array(module_info::in, list(rtti_data)::in, - mlds__initializer::out, list(mlds__defn)::out) is det. + mlds_initializer::out, list(mlds_defn)::out) is det. gen_pseudo_type_info_array(ModuleInfo, PTIRttiDatas, Init, Defns) :- - RealRttiDatas = list__filter(real_rtti_data, PTIRttiDatas), - DefnLists = list__map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), - Defns = list__condense(DefnLists), + RealRttiDatas = list.filter(real_rtti_data, PTIRttiDatas), + DefnLists = list.map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), + Defns = list.condense(DefnLists), module_info_get_name(ModuleInfo, ModuleName), - Init = gen_init_cast_rtti_datas_array(mlds__pseudo_type_info_type, + Init = gen_init_cast_rtti_datas_array(mlds_pseudo_type_info_type, ModuleName, PTIRttiDatas). :- pred gen_pseudo_type_info_list(module_info::in, list(rtti_data)::in, - list(mlds__initializer)::out, list(mlds__defn)::out) is det. + list(mlds_initializer)::out, list(mlds_defn)::out) is det. gen_pseudo_type_info_list(ModuleInfo, PTIRttiDatas, Inits, Defns) :- - RealRttiDatas = list__filter(real_rtti_data, PTIRttiDatas), - DefnLists = list__map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), - Defns = list__condense(DefnLists), + RealRttiDatas = list.filter(real_rtti_data, PTIRttiDatas), + DefnLists = list.map(rtti_data_to_mlds(ModuleInfo), RealRttiDatas), + Defns = list.condense(DefnLists), module_info_get_name(ModuleInfo, ModuleName), - Inits = list__map( - gen_init_cast_rtti_data(mlds__pseudo_type_info_type, ModuleName), + Inits = list.map( + gen_init_cast_rtti_data(mlds_pseudo_type_info_type, ModuleName), PTIRttiDatas). %-----------------------------------------------------------------------------% :- pred gen_init_method(module_info::in, int::in, rtti_proc_label::in, - mlds__initializer::out, list(mlds__defn)::in, list(mlds__defn)::out) + mlds_initializer::out, list(mlds_defn)::in, list(mlds_defn)::out) is det. gen_init_method(ModuleInfo, NumExtra, RttiProcLabel, Init, !ExtraDefns) :- @@ -1336,7 +1334,7 @@ gen_init_method(ModuleInfo, NumExtra, RttiProcLabel, Init, !ExtraDefns) :- typeclass_info_closure, Init, !ExtraDefns). :- pred gen_init_special_pred(module_info::in, univ::in, - mlds__initializer::out, list(mlds__defn)::in, list(mlds__defn)::out) + mlds_initializer::out, list(mlds_defn)::in, list(mlds_defn)::out) is det. gen_init_special_pred(ModuleInfo, RttiProcIdUniv, Init, !ExtraDefns) :- @@ -1364,11 +1362,11 @@ gen_init_special_pred(ModuleInfo, RttiProcIdUniv, Init, !ExtraDefns) :- ). :- pred gen_wrapper_func_and_initializer(module_info::in, int::in, - rtti_proc_label::in, closure_kind::in, mlds__initializer::out, - list(mlds__defn)::in, list(mlds__defn)::out) is det. + rtti_proc_label::in, closure_kind::in, mlds_initializer::out, + list(mlds_defn)::in, list(mlds_defn)::out) is det. gen_wrapper_func_and_initializer(ModuleInfo, NumExtra, RttiProcId, - ClosureKind, Init, ExtraDefns0, ExtraDefns) :- + ClosureKind, Init, !ExtraDefns) :- % We start off by creating a fresh MLGenInfo here, using the pred_id and % proc_id of the wrapped procedure. This requires considerable care. % We need to call ml_gen_info_bump_counters to ensure that the function @@ -1381,17 +1379,17 @@ gen_wrapper_func_and_initializer(ModuleInfo, NumExtra, RttiProcId, ml_gen_info_bump_counters(MLGenInfo0, MLGenInfo1), % Now we can safely go ahead and generate the wrapper function. - term__context_init(Context), + term.context_init(Context), ml_gen_closure_wrapper(PredId, ProcId, ClosureKind, NumExtra, Context, WrapperFuncRval, WrapperFuncType, MLGenInfo1, MLGenInfo), - ml_gen_info_get_extra_defns(MLGenInfo, ExtraDefns1), - ExtraDefns = list__append(ExtraDefns1, ExtraDefns0), + ml_gen_info_get_extra_defns(MLGenInfo, ExtraDefns), + !:ExtraDefns = ExtraDefns ++ !.ExtraDefns, % The initializer for the wrapper is just the wrapper function's address, - % converted to mlds__generic_type (by boxing). + % converted to mlds_generic_type (by boxing). Init = init_obj(unop(box(WrapperFuncType), WrapperFuncRval)). -:- func gen_init_proc_id(module_info, rtti_proc_label) = mlds__initializer. +:- func gen_init_proc_id(module_info, rtti_proc_label) = mlds_initializer. gen_init_proc_id(ModuleInfo, RttiProcId) = Init :- % Construct an rval for the address of this procedure @@ -1400,18 +1398,18 @@ gen_init_proc_id(ModuleInfo, RttiProcId) = Init :- ProcId = RttiProcId ^ proc_id, QualifiedProcLabel = qual(PredModule, module_qual, PredLabel - ProcId), Params = ml_gen_proc_params_from_rtti(ModuleInfo, RttiProcId), - Signature = mlds__get_func_signature(Params), + Signature = mlds_get_func_signature(Params), ProcAddrRval = const(code_addr_const(proc(QualifiedProcLabel, Signature))), % Convert the procedure address to a generic type. We need to use a % generic type because since the actual type for the procedure will % depend on how many type_info parameters it takes, which will depend % on the type's arity. - ProcAddrArg = unop(box(mlds__func_type(Params)), ProcAddrRval), + ProcAddrArg = unop(box(mlds_func_type(Params)), ProcAddrRval), Init = init_obj(ProcAddrArg). :- func gen_init_proc_id_from_univ(module_info, univ) = - mlds__initializer. + mlds_initializer. gen_init_proc_id_from_univ(ModuleInfo, ProcLabelUniv) = Init :- ( univ_to_type(ProcLabelUniv, ProcLabel) -> @@ -1422,7 +1420,7 @@ gen_init_proc_id_from_univ(ModuleInfo, ProcLabelUniv) = Init :- ). % Succeed iff the specified rtti_data is one that requires an - % explicit mlds__defn to define it. + % explicit mlds_defn to define it. % :- pred real_rtti_data(rtti_data::in) is semidet. @@ -1447,31 +1445,32 @@ real_rtti_data(RttiData) :- % named constants in the private_builtin module, which the Mercury runtime % is expected to define. -:- func gen_init_pred_or_func(pred_or_func) = mlds__initializer. +:- func gen_init_pred_or_func(pred_or_func) = mlds_initializer. gen_init_pred_or_func(PredOrFunc) = gen_init_builtin_const(Name) :- - rtti__pred_or_func_to_string(PredOrFunc, Name). + rtti.pred_or_func_to_string(PredOrFunc, Name). -:- func gen_init_sectag_locn(sectag_locn) = mlds__initializer. +:- func gen_init_sectag_locn(sectag_locn) = mlds_initializer. gen_init_sectag_locn(Locn) = gen_init_builtin_const(Name) :- - rtti__sectag_locn_to_string(Locn, Name). + rtti.sectag_locn_to_string(Locn, Name). -:- func gen_init_type_ctor_rep(type_ctor_data) = mlds__initializer. +:- func gen_init_type_ctor_rep(type_ctor_data) = mlds_initializer. gen_init_type_ctor_rep(TypeCtorData) = gen_init_builtin_const(Name) :- - rtti__type_ctor_rep_to_string(TypeCtorData, Name). + rtti.type_ctor_rep_to_string(TypeCtorData, Name). -:- func gen_init_builtin_const(string) = mlds__initializer. +:- func gen_init_builtin_const(string) = mlds_initializer. gen_init_builtin_const(Name) = init_obj(Rval) :- mercury_private_builtin_module(PrivateBuiltin), MLDS_Module = mercury_module_name_to_mlds(PrivateBuiltin), % XXX These are actually enumeration constants. % Perhaps we should be using an enumeration type here, - % rather than `mlds__native_int_type'. - Type = mlds__native_int_type, - Rval = lval(var(qual(MLDS_Module, module_qual, var_name(Name, no)), Type)). + % rather than `mlds_native_int_type'. + Type = mlds_native_int_type, + Rval = lval(var(qual(MLDS_Module, module_qual, mlds_var_name(Name, no)), + Type)). %-----------------------------------------------------------------------------% % @@ -1479,46 +1478,46 @@ gen_init_builtin_const(Name) = init_obj(Rval) :- % % This handles arrays, maybe, null pointers, strings, and ints. -:- func gen_init_array(func(T) = mlds__initializer, list(T)) = - mlds__initializer. +:- func gen_init_array(func(T) = mlds_initializer, list(T)) = + mlds_initializer. -gen_init_array(Conv, List) = init_array(list__map(Conv, List)). +gen_init_array(Conv, List) = init_array(list.map(Conv, List)). -:- func gen_init_maybe(mlds_type, func(T) = mlds__initializer, maybe(T)) = - mlds__initializer. +:- func gen_init_maybe(mlds_type, func(T) = mlds_initializer, maybe(T)) = + mlds_initializer. gen_init_maybe(_Type, Conv, yes(X)) = Conv(X). gen_init_maybe(Type, _Conv, no) = gen_init_null_pointer(Type). -:- func gen_init_null_pointer(mlds_type) = mlds__initializer. +:- func gen_init_null_pointer(mlds_type) = mlds_initializer. gen_init_null_pointer(Type) = init_obj(const(null(Type))). -:- func gen_init_string(string) = mlds__initializer. +:- func gen_init_string(string) = mlds_initializer. gen_init_string(String) = init_obj(const(string_const(String))). -:- func gen_init_int(int) = mlds__initializer. +:- func gen_init_int(int) = mlds_initializer. gen_init_int(Int) = init_obj(const(int_const(Int))). -:- func gen_init_bool(bool) = mlds__initializer. +:- func gen_init_bool(bool) = mlds_initializer. gen_init_bool(no) = init_obj(const(false)). gen_init_bool(yes) = init_obj(const(true)). -:- func gen_init_boxed_int(int) = mlds__initializer. +:- func gen_init_boxed_int(int) = mlds_initializer. gen_init_boxed_int(Int) = - init_obj(unop(box(mlds__native_int_type), const(int_const(Int)))). + init_obj(unop(box(mlds_native_int_type), const(int_const(Int)))). :- func gen_init_reserved_address(module_info, reserved_address) = - mlds__initializer. + mlds_initializer. gen_init_reserved_address(ModuleInfo, ReservedAddress) = - % XXX using `mlds__generic_type' here is probably wrong + % XXX using `mlds_generic_type' here is probably wrong init_obj(ml_gen_reserved_address(ModuleInfo, ReservedAddress, - mlds__generic_type)). + mlds_generic_type)). %-----------------------------------------------------------------------------% diff --git a/compiler/saved_vars.m b/compiler/saved_vars.m index 185ed87b4..bf78fba3c 100644 --- a/compiler/saved_vars.m +++ b/compiler/saved_vars.m @@ -24,7 +24,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__saved_vars. +:- module ll_backend.saved_vars. :- interface. :- import_module hlds.hlds_module. @@ -85,7 +85,7 @@ saved_vars_proc_no_io(TypeInfoLiveness, !ProcInfo, !ModuleInfo) :- final_slot_info(Varset1, VarTypes1, RttiVarMaps, SlotInfo), proc_info_headvars(!.ProcInfo, HeadVars), - % hlds_out__write_goal(Goal1, !.ModuleInfo, Varset1, 0, "\n"), + % hlds_out.write_goal(Goal1, !.ModuleInfo, Varset1, 0, "\n"), % Recompute the nonlocals for each goal. implicitly_quantify_clause_body(HeadVars, _Warnings, Goal1, Goal2, @@ -95,7 +95,7 @@ saved_vars_proc_no_io(TypeInfoLiveness, !ProcInfo, !ModuleInfo) :- recompute_instmap_delta(no, Goal2, Goal, VarTypes, InstVarSet, InstMap0, !ModuleInfo), - % hlds_out__write_goal(Goal, !.ModuleInfo, Varset, 0, "\n"), + % hlds_out.write_goal(Goal, !.ModuleInfo, Varset, 0, "\n"), proc_info_set_goal(Goal, !ProcInfo), proc_info_set_varset(Varset, !ProcInfo), @@ -184,7 +184,7 @@ saved_vars_in_conj([Goal0 | Goals0], Goals, NonLocals, !SlotInfo) :- goal_info_get_features(GoalInfo, Features), ( all [Feature] ( - set__member(Feature, Features) + set.member(Feature, Features) => ok_to_duplicate(Feature) = yes ) @@ -194,10 +194,10 @@ saved_vars_in_conj([Goal0 | Goals0], Goals, NonLocals, !SlotInfo) :- OtherGoals = [First | _Rest], can_push(Var, First) -> - set__is_member(Var, NonLocals, IsNonLocal), + set.is_member(Var, NonLocals, IsNonLocal), saved_vars_delay_goal(OtherGoals, Goals1, Goal0, Var, IsNonLocal, !SlotInfo), - list__append(Constants, Goals1, Goals2), + list.append(Constants, Goals1, Goals2), saved_vars_in_conj(Goals2, Goals, NonLocals, !SlotInfo) ; saved_vars_in_goal(Goal0, Goal1, !SlotInfo), @@ -260,7 +260,7 @@ skip_constant_constructs([Goal0 | Goals0], Constants, Others) :- can_push(Var, First) :- First = FirstExpr - FirstInfo, goal_info_get_nonlocals(FirstInfo, FirstNonLocals), - ( set__member(Var, FirstNonLocals) -> + ( set.member(Var, FirstNonLocals) -> ( FirstExpr = conj(plain_conj, _) ; @@ -311,36 +311,36 @@ saved_vars_delay_goal([Goal0 | Goals0], Goals, Construct, Var, IsNonLocal, !SlotInfo) :- Goal0 = Goal0Expr - Goal0Info, goal_info_get_nonlocals(Goal0Info, Goal0NonLocals), - ( set__member(Var, Goal0NonLocals) -> + ( set.member(Var, Goal0NonLocals) -> ( Goal0Expr = unify(_, _, _, _, _), rename_var(Var, _NewVar, Subst, !SlotInfo), - goal_util__rename_vars_in_goal(Subst, Construct, NewConstruct), - goal_util__rename_vars_in_goal(Subst, Goal0, Goal1), + goal_util.rename_vars_in_goal(Subst, Construct, NewConstruct), + goal_util.rename_vars_in_goal(Subst, Goal0, Goal1), saved_vars_delay_goal(Goals0, Goals1, Construct, Var, IsNonLocal, !SlotInfo), Goals = [NewConstruct, Goal1 | Goals1] ; Goal0Expr = call(_, _, _, _, _, _), rename_var(Var, _NewVar, Subst, !SlotInfo), - goal_util__rename_vars_in_goal(Subst, Construct, NewConstruct), - goal_util__rename_vars_in_goal(Subst, Goal0, Goal1), + goal_util.rename_vars_in_goal(Subst, Construct, NewConstruct), + goal_util.rename_vars_in_goal(Subst, Goal0, Goal1), saved_vars_delay_goal(Goals0, Goals1, Construct, Var, IsNonLocal, !SlotInfo), Goals = [NewConstruct, Goal1 | Goals1] ; Goal0Expr = generic_call(_, _, _, _), rename_var(Var, _NewVar, Subst, !SlotInfo), - goal_util__rename_vars_in_goal(Subst, Construct, NewConstruct), - goal_util__rename_vars_in_goal(Subst, Goal0, Goal1), + goal_util.rename_vars_in_goal(Subst, Construct, NewConstruct), + goal_util.rename_vars_in_goal(Subst, Goal0, Goal1), saved_vars_delay_goal(Goals0, Goals1, Construct, Var, IsNonLocal, !SlotInfo), Goals = [NewConstruct, Goal1 | Goals1] ; Goal0Expr = foreign_proc(_, _, _, _, _, _), rename_var(Var, _NewVar, Subst, !SlotInfo), - goal_util__rename_vars_in_goal(Subst, Construct, NewConstruct), - goal_util__rename_vars_in_goal(Subst, Goal0, Goal1), + goal_util.rename_vars_in_goal(Subst, Construct, NewConstruct), + goal_util.rename_vars_in_goal(Subst, Goal0, Goal1), saved_vars_delay_goal(Goals0, Goals1, Construct, Var, IsNonLocal, !SlotInfo), Goals = [NewConstruct, Goal1 | Goals1] @@ -360,8 +360,8 @@ saved_vars_delay_goal([Goal0 | Goals0], Goals, Construct, Var, IsNonLocal, ; Goal0Expr = scope(Reason, SomeGoal0), rename_var(Var, NewVar, Subst, !SlotInfo), - goal_util__rename_vars_in_goal(Subst, Construct, NewConstruct), - goal_util__rename_vars_in_goal(Subst, SomeGoal0, SomeGoal1), + goal_util.rename_vars_in_goal(Subst, Construct, NewConstruct), + goal_util.rename_vars_in_goal(Subst, SomeGoal0, SomeGoal1), push_into_goal(SomeGoal1, SomeGoal, NewConstruct, NewVar, !SlotInfo), Goal1 = scope(Reason, SomeGoal) - Goal0Info, @@ -371,8 +371,8 @@ saved_vars_delay_goal([Goal0 | Goals0], Goals, Construct, Var, IsNonLocal, ; Goal0Expr = not(NegGoal0), rename_var(Var, NewVar, Subst, !SlotInfo), - goal_util__rename_vars_in_goal(Subst, Construct, NewConstruct), - goal_util__rename_vars_in_goal(Subst, NegGoal0, NegGoal1), + goal_util.rename_vars_in_goal(Subst, Construct, NewConstruct), + goal_util.rename_vars_in_goal(Subst, NegGoal0, NegGoal1), push_into_goal(NegGoal1, NegGoal, NewConstruct, NewVar, !SlotInfo), Goal1 = not(NegGoal) - Goal0Info, @@ -446,10 +446,10 @@ push_into_goal(Goal0, Goal, Construct, Var, !SlotInfo) :- push_into_goal_rename(Goal0, Goal, Construct, Var, !SlotInfo) :- Goal0 = _ - GoalInfo0, goal_info_get_nonlocals(GoalInfo0, NonLocals), - ( set__member(Var, NonLocals) -> + ( set.member(Var, NonLocals) -> rename_var(Var, NewVar, Subst, !SlotInfo), - goal_util__rename_vars_in_goal(Subst, Construct, NewConstruct), - goal_util__rename_vars_in_goal(Subst, Goal0, Goal1), + goal_util.rename_vars_in_goal(Subst, Construct, NewConstruct), + goal_util.rename_vars_in_goal(Subst, Goal0, Goal1), push_into_goal(Goal1, Goal, NewConstruct, NewVar, !SlotInfo) ; saved_vars_in_goal(Goal0, Goal, !SlotInfo) @@ -530,10 +530,10 @@ final_slot_info(Varset, VarTypes, RttiVarMaps, SlotInfo) :- rename_var(Var, NewVar, Substitution, !SlotInfo) :- !.SlotInfo = slot_info(Varset0, VarTypes0, RttiVarMaps0, TypeInfoLiveness), - varset__new_var(Varset0, NewVar, Varset), - map__from_assoc_list([Var - NewVar], Substitution), - map__lookup(VarTypes0, Var, Type), - map__det_insert(VarTypes0, NewVar, Type, VarTypes), + varset.new_var(Varset0, NewVar, Varset), + map.from_assoc_list([Var - NewVar], Substitution), + map.lookup(VarTypes0, Var, Type), + map.det_insert(VarTypes0, NewVar, Type, VarTypes), rtti_var_info_duplicate(Var, NewVar, RttiVarMaps0, RttiVarMaps), !:SlotInfo = slot_info(Varset, VarTypes, RttiVarMaps, TypeInfoLiveness). @@ -553,8 +553,8 @@ rename_var(Var, NewVar, Substitution, !SlotInfo) :- slot_info_do_not_duplicate_var(SlotInfo, Var) :- SlotInfo = slot_info(_, VarTypes, _, TypeInfoLiveness), TypeInfoLiveness = yes, - map__lookup(VarTypes, Var, Type), - polymorphism__type_is_type_info_or_ctor_type(Type). + map.lookup(VarTypes, Var, Type), + polymorphism.type_is_type_info_or_ctor_type(Type). %-----------------------------------------------------------------------------% diff --git a/compiler/simplify.m b/compiler/simplify.m index 666072db3..96ca3b87f 100644 --- a/compiler/simplify.m +++ b/compiler/simplify.m @@ -28,7 +28,7 @@ % %-----------------------------------------------------------------------------% -:- module check_hlds__simplify. +:- module check_hlds.simplify. :- interface. :- import_module check_hlds.common. @@ -136,10 +136,10 @@ simplify_pred(Simplifications0, PredId, !ModuleInfo, !PredInfo, ProcIds = pred_info_non_imported_procids(!.PredInfo), ( % Don't warn for compiler-generated procedures. - list__member(warn_simple_code, Simplifications0), + list.member(warn_simple_code, Simplifications0), is_unify_or_compare_pred(!.PredInfo) -> - list__delete_all(Simplifications0, warn_simple_code, Simplifications) + list.delete_all(Simplifications0, warn_simple_code, Simplifications) ; Simplifications = Simplifications0 ), @@ -148,15 +148,15 @@ simplify_pred(Simplifications0, PredId, !ModuleInfo, !PredInfo, MaybeMsgs0, MaybeMsgs, !IO), ( MaybeMsgs = yes(Msgs0 - Msgs1), - set__union(Msgs0, Msgs1, Msgs2), - set__to_sorted_list(Msgs2, Msgs), + set.union(Msgs0, Msgs1, Msgs2), + set.to_sorted_list(Msgs2, Msgs), det_report_msgs(Msgs, !.ModuleInfo, WarnCnt, ErrCnt, !IO) ; MaybeMsgs = no, WarnCnt = 0, ErrCnt = 0 ), - globals__io_lookup_bool_option(detailed_statistics, Statistics, !IO), + globals.io_lookup_bool_option(detailed_statistics, Statistics, !IO), maybe_report_stats(Statistics, !IO). :- pred simplify_procs(list(simplification)::in, pred_id::in, @@ -170,21 +170,21 @@ simplify_procs(_, _, [], !ModuleInfo, !PredInfo, !Msgs, !IO). simplify_procs(Simplifications, PredId, [ProcId | ProcIds], !ModuleInfo, !PredInfo, !MaybeMsgs, !IO) :- pred_info_procedures(!.PredInfo, Procs0), - map__lookup(Procs0, ProcId, Proc0), + map.lookup(Procs0, ProcId, Proc0), simplify_proc_return_msgs(Simplifications, PredId, ProcId, !ModuleInfo, Proc0, Proc, ProcMsgSet, !IO), - map__det_update(Procs0, ProcId, Proc, Procs), + map.det_update(Procs0, ProcId, Proc, Procs), pred_info_set_procedures(Procs, !PredInfo), - set__to_sorted_list(ProcMsgSet, ProcMsgs), - list__filter((pred(context_det_msg(_, Msg)::in) is semidet :- + set.to_sorted_list(ProcMsgSet, ProcMsgs), + list.filter((pred(context_det_msg(_, Msg)::in) is semidet :- det_msg_is_any_mode_msg(Msg, any_mode) ), ProcMsgs, ProcAnyModeMsgs, ProcAllModeMsgs), - set__sorted_list_to_set(ProcAnyModeMsgs, ProcAnyModeMsgSet), - set__sorted_list_to_set(ProcAllModeMsgs, ProcAllModeMsgSet), + set.sorted_list_to_set(ProcAnyModeMsgs, ProcAnyModeMsgSet), + set.sorted_list_to_set(ProcAllModeMsgs, ProcAllModeMsgSet), ( !.MaybeMsgs = yes(AnyModeMsgSet0 - AllModeMsgSet0), - set__union(AnyModeMsgSet0, ProcAnyModeMsgSet, AnyModeMsgSet), - set__intersect(AllModeMsgSet0, ProcAllModeMsgSet, AllModeMsgSet), + set.union(AnyModeMsgSet0, ProcAnyModeMsgSet, AnyModeMsgSet), + set.intersect(AllModeMsgSet0, ProcAllModeMsgSet, AllModeMsgSet), !:MaybeMsgs = yes(AllModeMsgSet - AnyModeMsgSet) ; !.MaybeMsgs = no, @@ -278,14 +278,14 @@ process_goal(Goal0, Goal, !Info, !IO) :- % On the first pass do common structure and call elimination. NotOnFirstPass = [do_once, excess_assigns], - set__delete_list(Simplifications0, NotOnFirstPass, Simplifications1), + set.delete_list(Simplifications0, NotOnFirstPass, Simplifications1), simplify_info_set_simplifications(Simplifications1, !Info), do_process_goal(Goal0, Goal1, !Info, !IO), NotOnSecondPass = [warn_simple_code, warn_duplicate_calls, common_struct, duplicate_calls], - set__delete_list(Simplifications0, NotOnSecondPass, Simplifications2), + set.delete_list(Simplifications0, NotOnSecondPass, Simplifications2), simplify_info_reinit(Simplifications2, InstMap0, !Info) ; Goal1 = Goal0 @@ -384,7 +384,7 @@ find_simplifications_2(WarnThisPass, Globals, !Simps) :- list(simplification)::in, list(simplification)::out) is det. set_by_option(Globals, Option, Simplification, !Simplifications) :- - globals__lookup_bool_option(Globals, Option, Result), + globals.lookup_bool_option(Globals, Option, Result), ( Result = yes, !:Simplifications = [Simplification | !.Simplifications] @@ -439,12 +439,12 @@ simplify_goal(Goal0, Goal - GoalInfo, !Info, !IO) :- % If the goal had any non-locals we should requantify. goal_info_get_nonlocals(GoalInfo0, NonLocals0), - ( set__empty(NonLocals0) -> + ( set.empty(NonLocals0) -> true ; simplify_info_set_requantify(!Info) ), - pd_cost__goal(Goal0, CostDelta), + goal_cost(Goal0, CostDelta), simplify_info_incr_cost_delta(CostDelta, !Info), Goal1 = fail_goal_with_context(Context) ; @@ -505,12 +505,12 @@ simplify_goal(Goal0, Goal - GoalInfo, !Info, !IO) :- % If the goal had any non-locals we should requantify. goal_info_get_nonlocals(GoalInfo0, NonLocals0), - ( set__empty(NonLocals0) -> + ( set.empty(NonLocals0) -> true ; simplify_info_set_requantify(!Info) ), - pd_cost__goal(Goal0, CostDelta), + goal_cost(Goal0, CostDelta), simplify_info_incr_cost_delta(CostDelta, !Info), goal_info_get_context(GoalInfo0, Context), Goal1 = true_goal_with_context(Context) @@ -662,8 +662,8 @@ simplify_goal_2(disj(Disjuncts0), Goal, GoalInfo0, GoalInfo, !Info, !IO) :- goal_info_set_instmap_delta(NewDelta, GoalInfo0, GoalInfo) ) ), - list__length(Disjuncts, DisjunctsLength), - list__length(Disjuncts0, Disjuncts0Length), + list.length(Disjuncts, DisjunctsLength), + list.length(Disjuncts0, Disjuncts0Length), ( DisjunctsLength \= Disjuncts0Length -> % % If we pruned some disjuncts, variables used by those disjuncts @@ -684,10 +684,10 @@ simplify_goal_2(switch(Var, SwitchCanFail0, Cases0), Goal, GoalInfo0, GoalInfo, !Info, !IO) :- simplify_info_get_instmap(!.Info, InstMap0), simplify_info_get_module_info(!.Info, ModuleInfo0), - instmap__lookup_var(InstMap0, Var, VarInst), + instmap.lookup_var(InstMap0, Var, VarInst), ( inst_is_bound_to_functors(ModuleInfo0, VarInst, Functors) -> functors_to_cons_ids(Functors, ConsIds0), - list__sort(ConsIds0, ConsIds), + list.sort(ConsIds0, ConsIds), delete_unreachable_cases(Cases0, ConsIds, Cases1), MaybeConsIds = yes(ConsIds) ; @@ -699,8 +699,7 @@ simplify_goal_2(switch(Var, SwitchCanFail0, Cases0), Goal, ( Cases = [], % An empty switch always fails. - pd_cost__eliminate_switch(CostDelta), - simplify_info_incr_cost_delta(CostDelta, !Info), + simplify_info_incr_cost_delta(cost_of_eliminate_switch, !Info), goal_info_get_context(GoalInfo0, Context), Goal - GoalInfo = fail_goal_with_context(Context) ; @@ -718,9 +717,9 @@ simplify_goal_2(switch(Var, SwitchCanFail0, Cases0), Goal, % arguments or their typeinfos. simplify_info_get_var_types(!.Info, VarTypes1), - map__lookup(VarTypes1, Var, Type), + map.lookup(VarTypes1, Var, Type), simplify_info_get_module_info(!.Info, ModuleInfo1), - ( type_util__is_existq_cons(ModuleInfo1, Type, ConsId) -> + ( type_util.is_existq_cons(ModuleInfo1, Type, ConsId) -> Goal = switch(Var, SwitchCanFail, Cases), goal_info_get_nonlocals(GoalInfo0, NonLocals), simplify_info_get_var_types(!.Info, VarTypes), @@ -738,7 +737,7 @@ simplify_goal_2(switch(Var, SwitchCanFail0, Cases0), Goal, % Work out the nonlocals, instmap_delta % and determinism of the entire conjunction. goal_info_get_nonlocals(GoalInfo0, NonLocals0), - set__insert(NonLocals0, Var, NonLocals), + set.insert(NonLocals0, Var, NonLocals), goal_info_get_instmap_delta(GoalInfo0, InstMapDelta0), simplify_info_get_instmap(!.Info, InstMap), instmap_delta_bind_var_to_functor(Var, Type, ConsId, @@ -756,12 +755,11 @@ simplify_goal_2(switch(Var, SwitchCanFail0, Cases0), Goal, GoalInfo = CombinedGoalInfo ) ; - % The var can only be bound to this cons_id, so - % a test is unnecessary. + % The var can only be bound to this cons_id, so a test + % is unnecessary. SingleGoal = Goal - GoalInfo ), - pd_cost__eliminate_switch(CostDelta), - simplify_info_incr_cost_delta(CostDelta, !Info) + simplify_info_incr_cost_delta(cost_of_eliminate_switch, !Info) ; Cases = [_, _ | _], Goal = switch(Var, SwitchCanFail, Cases), @@ -779,20 +777,16 @@ simplify_goal_2(switch(Var, SwitchCanFail0, Cases0), Goal, goal_info_set_instmap_delta(NewDelta, GoalInfo0, GoalInfo) ) ), - list__length(Cases0, Cases0Length), - list__length(Cases, CasesLength), + list.length(Cases0, Cases0Length), + list.length(Cases, CasesLength), ( CasesLength \= Cases0Length -> - % - % If we pruned some cases, variables used by those - % cases may no longer be non-local to the switch. - % Also, the determinism may have changed (especially - % if we pruned all the cases). - % If the switch now can't succeed, it is necessary - % to recompute instmap_deltas and rerun determinism - % analysis to avoid aborts in the code generator - % because the switch now cannot produce variables it - % did before. - % + % If we pruned some cases, variables used by those cases may no longer + % be non-local to the switch. Also, the determinism may have changed + % (especially if we pruned all the cases). If the switch now can't + % succeed, it is necessary to recompute instmap_deltas and rerun + % determinism analysis to avoid aborts in the code generator because + % the switch now cannot produce variables it did before. + simplify_info_set_requantify(!Info), simplify_info_set_rerun_det(!Info) ; @@ -809,7 +803,7 @@ simplify_goal_2(Goal0, Goal, GoalInfo, GoalInfo, !Info, !IO) :- % XXX Should we handle semipure higher-order calls too? Purity = purity_pure -> - common__optimise_higher_order_call(Closure, Args, Modes, Det, + common.optimise_higher_order_call(Closure, Args, Modes, Det, GoalInfo, Goal0, Goal, !Info) ; simplify_do_warn_calls(!.Info), @@ -819,7 +813,7 @@ simplify_goal_2(Goal0, Goal, GoalInfo, GoalInfo, !Info, !IO) :- -> % We need to do the pass, for the warnings, but we ignore % the optimized goal and instead use the original one. - common__optimise_higher_order_call(Closure, Args, Modes, Det, + common.optimise_higher_order_call(Closure, Args, Modes, Det, GoalInfo, Goal0, _Goal1, !Info), Goal = Goal0 ; @@ -830,8 +824,8 @@ simplify_goal_2(Goal0, Goal, GoalInfo0, GoalInfo, !Info, !IO) :- Goal0 = call(PredId, ProcId, Args, IsBuiltin, _, _), simplify_info_get_module_info(!.Info, ModuleInfo), module_info_pred_info(ModuleInfo, PredId, PredInfo), - ModuleName = hlds_pred__pred_info_module(PredInfo), - Name = hlds_pred__pred_info_name(PredInfo), + ModuleName = hlds_pred.pred_info_module(PredInfo), + Name = hlds_pred.pred_info_name(PredInfo), ( is_format_call(ModuleName, Name, Args, _, _) -> simplify_info_set_format_calls(yes, !Info) ; @@ -839,7 +833,7 @@ simplify_goal_2(Goal0, Goal, GoalInfo0, GoalInfo, !Info, !IO) :- ), % % Convert calls to builtin @=<, @<, @>=, @> into the corresponding - % calls to builtin__compare/3. + % calls to builtin.compare/3. % ( Args = [TI, X, Y], @@ -905,7 +899,7 @@ simplify_goal_2(Goal0, Goal, GoalInfo0, GoalInfo, !Info, !IO) :- ; simplify_do_common(!.Info) -> - common__optimise_unification(U0, LT0, RT0, M, C, + common.optimise_unification(U0, LT0, RT0, M, C, Goal0, Goal, GoalInfo0, GoalInfo, !Info) ; ( simplify_do_calls(!.Info) @@ -917,7 +911,7 @@ simplify_goal_2(Goal0, Goal, GoalInfo0, GoalInfo, !Info, !IO) :- % duplicate calls. But we don't want to perform % the optimization, so we disregard the optimized goal % and instead use the original one. - common__optimise_unification(U0, LT0, RT0, M, C, + common.optimise_unification(U0, LT0, RT0, M, C, Goal0, _Goal1, GoalInfo0, _GoalInfo1, !Info), Goal = Goal0, GoalInfo = GoalInfo0 @@ -959,7 +953,7 @@ simplify_goal_2(if_then_else(Vars, Cond0, Then0, Else0), Goal, ( CondCanFail0 = cannot_fail -> goal_to_conj_list(Cond0, CondList), goal_to_conj_list(Then0, ThenList), - list__append(CondList, ThenList, List), + list.append(CondList, ThenList, List), simplify_goal(conj(plain_conj, List) - GoalInfo0, Goal - GoalInfo, !Info, !IO), goal_info_get_context(GoalInfo0, Context), @@ -1016,7 +1010,7 @@ simplify_goal_2(if_then_else(Vars, Cond0, Then0, Else0), Goal, % (A -> C ; fail) is equivalent to (A, C) goal_to_conj_list(Cond0, CondList), goal_to_conj_list(Then0, ThenList), - list__append(CondList, ThenList, List), + list.append(CondList, ThenList, List), simplify_goal(conj(plain_conj, List) - GoalInfo0, Goal - GoalInfo, !Info, !IO), simplify_info_set_requantify(!Info), @@ -1209,8 +1203,8 @@ simplify_goal_2(Goal0, Goal, GoalInfo, GoalInfo, !Info, !IO) :- goal_info_is_pure(GoalInfo), ExtraArgs = [] -> - ArgVars = list__map(foreign_arg_var, Args), - common__optimise_call(PredId, ProcId, ArgVars, GoalInfo, Goal1, Goal, + ArgVars = list.map(foreign_arg_var, Args), + common.optimise_call(PredId, ProcId, ArgVars, GoalInfo, Goal1, Goal, !Info) ; Goal = Goal1 @@ -1235,7 +1229,7 @@ inequality_goal(TI, X, Y, Inequality, Invert, GoalInfo, GoalExpr, GoalInfo, % Construct the variable to hold the comparison result. VarSet0 = !.Info ^ varset, - varset__new_var(VarSet0, R, VarSet), + varset.new_var(VarSet0, R, VarSet), !:Info = !.Info ^ varset := VarSet, % We have to add the type of R to the var_types. @@ -1245,12 +1239,12 @@ inequality_goal(TI, X, Y, Inequality, Invert, GoalInfo, GoalExpr, GoalInfo, % Construct the call to compare/3. mercury_public_builtin_module(BuiltinModule), - hlds_goal__goal_info_get_context(GoalInfo, Context), + hlds_goal.goal_info_get_context(GoalInfo, Context), Args = [TI, R, X, Y], simplify_info_get_instmap(!.Info, InstMap), - instmap__lookup_var(InstMap, X, XInst), - instmap__lookup_var(InstMap, Y, YInst), + instmap.lookup_var(InstMap, X, XInst), + instmap.lookup_var(InstMap, Y, YInst), simplify_info_get_module_info(!.Info, ModuleInfo), ModeNo = ( if inst_is_unique(ModuleInfo, XInst) then @@ -1261,7 +1255,7 @@ inequality_goal(TI, X, Y, Inequality, Invert, GoalInfo, GoalExpr, GoalInfo, Unique = ground(unique, none), ArgInsts = [R - Unique], - goal_util__generate_simple_call(BuiltinModule, "compare", predicate, + goal_util.generate_simple_call(BuiltinModule, "compare", predicate, mode_no(ModeNo), det, Args, [], ArgInsts, ModuleInfo, Context, CmpGoal0), CmpGoal0 = CmpExpr - CmpInfo0, @@ -1369,8 +1363,10 @@ call_goal(PredId, ProcId, Args, IsBuiltin, Goal0, Goal, GoalInfo0, GoalInfo, % warnings about possible nontermination should only be given % if the termination analysis pass is enabled. all [ArgMode] ( - (list__member(ArgMode, ArgModes), - mode_is_input(ModuleInfo1, ArgMode)) + ( + list.member(ArgMode, ArgModes), + mode_is_input(ModuleInfo1, ArgMode) + ) => mode_is_fully_input(ModuleInfo1, ArgMode) ), @@ -1397,7 +1393,7 @@ call_goal(PredId, ProcId, Args, IsBuiltin, Goal0, Goal, GoalInfo0, GoalInfo, simplify_do_calls(!.Info), goal_info_is_pure(GoalInfo0) -> - common__optimise_call(PredId, ProcId, Args, GoalInfo0, Goal0, Goal1, + common.optimise_call(PredId, ProcId, Args, GoalInfo0, Goal0, Goal1, !Info) ; simplify_do_warn_calls(!.Info), @@ -1405,7 +1401,7 @@ call_goal(PredId, ProcId, Args, IsBuiltin, Goal0, Goal, GoalInfo0, GoalInfo, -> % we need to do the pass, for the warnings, but we ignore % the optimized goal and instead use the original one - common__optimise_call(PredId, ProcId, Args, GoalInfo0, Goal0, _Goal1, + common.optimise_call(PredId, ProcId, Args, GoalInfo0, Goal0, _Goal1, !Info), Goal1 = Goal0 ; @@ -1446,7 +1442,7 @@ process_compl_unify(XVar, YVar, UniMode, CanFail, _OldTypeInfoVars, Context, GoalInfo0, Goal, !Info, !IO) :- simplify_info_get_module_info(!.Info, ModuleInfo), simplify_info_get_var_types(!.Info, VarTypes), - map__lookup(VarTypes, XVar, Type), + map.lookup(VarTypes, XVar, Type), ( Type = variable(TypeVar, Kind) -> % % Convert polymorphic unifications into calls to `unify/2', @@ -1477,12 +1473,12 @@ process_compl_unify(XVar, YVar, UniMode, CanFail, _OldTypeInfoVars, Context, unexpected(this_file, "type_to_ctor_and_args failed") ), determinism_components(Det, CanFail, at_most_one), - unify_proc__lookup_mode_num(ModuleInfo, TypeCtor, UniMode, Det, + unify_proc.lookup_mode_num(ModuleInfo, TypeCtor, UniMode, Det, ProcId), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, special_preds, SpecialPreds), + globals.lookup_bool_option(Globals, special_preds, SpecialPreds), ( - hlds_pred__in_in_unification_proc_id(ProcId), + hlds_pred.in_in_unification_proc_id(ProcId), ( SpecialPreds = no ; @@ -1517,7 +1513,7 @@ process_compl_unify(XVar, YVar, UniMode, CanFail, _OldTypeInfoVars, Context, Call = Call1 - CallGoalInfo1 ) ), - list__append(ExtraGoals, [Call], ConjList), + list.append(ExtraGoals, [Call], ConjList), conj_list_to_goal(ConjList, GoalInfo0, Goal). :- pred call_generic_unify(prog_var::in, prog_var::in, prog_var::in, @@ -1528,7 +1524,7 @@ call_generic_unify(TypeInfoVar, XVar, YVar, ModuleInfo, _, _, GoalInfo, Call) :- ArgVars = [TypeInfoVar, XVar, YVar], goal_info_get_context(GoalInfo, Context), - goal_util__generate_simple_call(mercury_public_builtin_module, + goal_util.generate_simple_call(mercury_public_builtin_module, "unify", predicate, mode_no(0), semidet, ArgVars, [], [], ModuleInfo, Context, Call). @@ -1540,9 +1536,9 @@ call_generic_unify(TypeInfoVar, XVar, YVar, ModuleInfo, _, _, GoalInfo, call_specific_unify(TypeCtor, TypeInfoVars, XVar, YVar, ProcId, ModuleInfo, Context, GoalInfo0, CallExpr, CallGoalInfo) :- % Create the new call goal. - list__append(TypeInfoVars, [XVar, YVar], ArgVars), + list.append(TypeInfoVars, [XVar, YVar], ArgVars), module_info_get_special_pred_map(ModuleInfo, SpecialPredMap), - map__lookup(SpecialPredMap, spec_pred_unify - TypeCtor, PredId), + map.lookup(SpecialPredMap, spec_pred_unify - TypeCtor, PredId), module_info_pred_info(ModuleInfo, PredId, PredInfo), ModuleName = pred_info_module(PredInfo), PredName = pred_info_name(PredInfo), @@ -1553,7 +1549,7 @@ call_specific_unify(TypeCtor, TypeInfoVars, XVar, YVar, ProcId, ModuleInfo, % Add the extra type_info vars to the nonlocals for the call. goal_info_get_nonlocals(GoalInfo0, NonLocals0), - set__insert_list(NonLocals0, TypeInfoVars, NonLocals), + set.insert_list(NonLocals0, TypeInfoVars, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, CallGoalInfo). :- pred make_type_info_vars(list(mer_type)::in, list(prog_var)::out, @@ -1589,8 +1585,8 @@ make_type_info_vars(Types, TypeInfoVars, TypeInfoGoals, !Info) :- % Call polymorphism.m to create the type_infos. create_poly_info(ModuleInfo0, !.PredInfo, !.ProcInfo, !:PolyInfo), - term__context_init(Context), - polymorphism__make_type_info_vars(Types, Context, + term.context_init(Context), + polymorphism.make_type_info_vars(Types, Context, TypeInfoVars, TypeInfoGoals, !PolyInfo), poly_info_extract(!.PolyInfo, !PredInfo, !ProcInfo, ModuleInfo1), @@ -1636,7 +1632,7 @@ extract_type_info(TypeVar, Kind, TypeClassInfoVar, Index, Goals, TypeInfoVar, simplify_info_get_var_types(!.Info, VarTypes0), simplify_info_get_rtti_varmaps(!.Info, RttiVarMaps0), - polymorphism__gen_extract_type_info(TypeVar, Kind, TypeClassInfoVar, Index, + polymorphism.gen_extract_type_info(TypeVar, Kind, TypeClassInfoVar, Index, ModuleInfo, Goals, TypeInfoVar, VarSet0, VarSet, VarTypes0, VarTypes, RttiVarMaps0, RttiVarMaps), @@ -1660,7 +1656,7 @@ input_args_are_equiv([], [], _, _, _). input_args_are_equiv([Arg | Args], [HeadVar | HeadVars], [Mode | Modes], CommonInfo, ModuleInfo) :- ( mode_is_input(ModuleInfo, Mode) -> - common__vars_are_equivalent(Arg, HeadVar, CommonInfo) + common.vars_are_equivalent(Arg, HeadVar, CommonInfo) ; true ), @@ -1697,7 +1693,7 @@ nested_scopes_2(Reason0, Reason, Goal0, Goal) :- Reason0 = exist_quant(Vars0), Reason1 = exist_quant(Vars1) -> - list__append(Vars0, Vars1, Vars2), + list.append(Vars0, Vars1, Vars2), Reason2 = exist_quant(Vars2) ; Reason0 = from_ground_term(_) @@ -1776,12 +1772,12 @@ maybe_wrap_goal(OuterGoalInfo, InnerGoalInfo, Goal1, Goal, GoalInfo, !Info) :- simplify_info::in, simplify_info::out, io::di, io::uo) is det. simplify_conj([], RevGoals, Goals, _, !Info, !IO) :- - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). simplify_conj([Goal0 | Goals0], !.RevGoals, Goals, ConjInfo, !Info, !IO) :- Info0 = !.Info, % Flatten conjunctions. ( Goal0 = conj(plain_conj, SubGoals) - _ -> - list__append(SubGoals, Goals0, Goals1), + list.append(SubGoals, Goals0, Goals1), simplify_conj(Goals1, !.RevGoals, Goals, ConjInfo, !Info, !IO) ; simplify_goal(Goal0, Goal1, !Info, !IO), @@ -1790,13 +1786,13 @@ simplify_conj([Goal0 | Goals0], !.RevGoals, Goals, ConjInfo, !Info, !IO) :- Goal1 = conj(plain_conj, SubGoals1) - _ -> simplify_info_undo_goal_updates(Info0, !Info), - list__append(SubGoals1, Goals0, Goals1), + list.append(SubGoals1, Goals0, Goals1), simplify_conj(Goals1, !.RevGoals, Goals, ConjInfo, !Info, !IO) ; % Delete unreachable goals. ( simplify_info_get_instmap(!.Info, InstMap1), - instmap__is_unreachable(InstMap1) + instmap.is_unreachable(InstMap1) ; Goal1 = _ - GoalInfo1, goal_info_get_determinism(GoalInfo1, Detism1), @@ -1824,7 +1820,7 @@ simplify_conj([Goal0 | Goals0], !.RevGoals, Goals, ConjInfo, !Info, !IO) :- FailGoal = fail_goal_with_context(Context), conjoin_goal_and_rev_goal_list(FailGoal, !RevGoals) ), - list__reverse(!.RevGoals, Goals) + list.reverse(!.RevGoals, Goals) ; conjoin_goal_and_rev_goal_list(Goal1, !RevGoals), simplify_info_update_instmap(Goal1, !Info), @@ -1837,8 +1833,8 @@ simplify_conj([Goal0 | Goals0], !.RevGoals, Goals, ConjInfo, !Info, !IO) :- conjoin_goal_and_rev_goal_list(Goal, RevGoals0, RevGoals) :- ( Goal = conj(plain_conj, Goals) - _ -> - list__reverse(Goals, Goals1), - list__append(Goals1, RevGoals0, RevGoals) + list.reverse(Goals, Goals1), + list.append(Goals1, RevGoals0, RevGoals) ; RevGoals = [Goal | RevGoals0] ). @@ -1864,26 +1860,26 @@ simplify_par_conj([Goal0 |Goals0], [Goal | Goals], Info0, !Info, !IO) :- excess_assigns_in_conj(ConjInfo, Goals0, Goals, !Info) :- ( simplify_do_excess_assigns(!.Info) -> goal_info_get_nonlocals(ConjInfo, ConjNonLocals), - map__init(Subn0), + map.init(Subn0), simplify_info_get_module_info(!.Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__get_trace_level(Globals, TraceLevel), - globals__lookup_bool_option(Globals, trace_optimized, TraceOptimized), + globals.get_trace_level(Globals, TraceLevel), + globals.lookup_bool_option(Globals, trace_optimized, TraceOptimized), simplify_info_get_varset(!.Info, VarSet0), find_excess_assigns_in_conj(TraceLevel, TraceOptimized, VarSet0, ConjNonLocals, Goals0, [], RevGoals, Subn0, Subn1), - ( map__is_empty(Subn1) -> + ( map.is_empty(Subn1) -> Goals = Goals0 ; renaming_transitive_closure(Subn1, Subn), - list__reverse(RevGoals, Goals1), + list.reverse(RevGoals, Goals1), MustSub = no, - goal_util__rename_vars_in_goals(MustSub, Subn, Goals1, Goals), - map__keys(Subn0, RemovedVars), - varset__delete_vars(VarSet0, RemovedVars, VarSet), + goal_util.rename_vars_in_goals(MustSub, Subn, Goals1, Goals), + map.keys(Subn0, RemovedVars), + varset.delete_vars(VarSet0, RemovedVars, VarSet), simplify_info_set_varset(VarSet, !Info), simplify_info_get_rtti_varmaps(!.Info, RttiVarMaps0), - apply_substitutions_to_rtti_varmaps(map__init, map__init, Subn, + apply_substitutions_to_rtti_varmaps(map.init, map.init, Subn, RttiVarMaps0, RttiVarMaps), simplify_info_set_rtti_varmaps(RttiVarMaps, !Info) ) @@ -1925,8 +1921,8 @@ goal_is_excess_assign(Trace, TraceOptimized, VarSet, ConjNonLocals, Goal0, find_renamed_var(!.Subn, LeftVar0, LeftVar), find_renamed_var(!.Subn, RightVar0, RightVar), - CanElimLeft = ( set__member(LeftVar, ConjNonLocals) -> no ; yes ), - CanElimRight = ( set__member(RightVar, ConjNonLocals) -> no ; yes ), + CanElimLeft = ( set.member(LeftVar, ConjNonLocals) -> no ; yes ), + CanElimRight = ( set.member(RightVar, ConjNonLocals) -> no ; yes ), % If we have a choice, eliminate an unnamed variable. ( CanElimLeft = yes, CanElimRight = yes -> @@ -1946,7 +1942,7 @@ goal_is_excess_assign(Trace, TraceOptimized, VarSet, ConjNonLocals, Goal0, ; fail ), - map__det_insert(!.Subn, ElimVar, ReplacementVar, !:Subn), + map.det_insert(!.Subn, ElimVar, ReplacementVar, !:Subn), % If the module is being compiled with `--trace deep' and % `--no-trace-optimized' don't replace a meaningful variable name @@ -1961,16 +1957,16 @@ goal_is_excess_assign(Trace, TraceOptimized, VarSet, ConjNonLocals, Goal0, :- pred var_is_named(prog_varset::in, prog_var::in) is semidet. var_is_named(VarSet, Var) :- - varset__search_name(VarSet, Var, Name), + varset.search_name(VarSet, Var, Name), \+ ( - string__append("HeadVar__", Suffix, Name), - string__to_int(Suffix, _) + string.append("HeadVar__", Suffix, Name), + string.to_int(Suffix, _) ). :- pred find_renamed_var(var_renaming::in, prog_var::in, prog_var::out) is det. find_renamed_var(Subn, Var0, Var) :- - ( map__search(Subn, Var0, Var1) -> + ( map.search(Subn, Var0, Var1) -> find_renamed_var(Subn, Var1, Var) ; Var = Var0 @@ -1982,7 +1978,7 @@ find_renamed_var(Subn, Var0, Var) :- is det. renaming_transitive_closure(VarRenaming0, VarRenaming) :- - map__map_values( + map.map_values( (pred(_::in, Value0::in, Value::out) is det :- find_renamed_var(VarRenaming0, Value0, Value) ), VarRenaming0, VarRenaming). @@ -1995,15 +1991,15 @@ renaming_transitive_closure(VarRenaming0, VarRenaming) :- simplify_info::in, simplify_info::out, io::di, io::uo) is det. simplify_switch(_, [], RevCases, Cases, !InstMaps, !CanFail, _, !Info, !IO) :- - list__reverse(RevCases, Cases). + list.reverse(RevCases, Cases). simplify_switch(Var, [Case0 | Cases0], RevCases0, Cases, !InstMaps, !CanFail, Info0, !Info, !IO) :- simplify_info_get_instmap(Info0, InstMap0), Case0 = case(ConsId, Goal0), simplify_info_get_module_info(!.Info, ModuleInfo0), simplify_info_get_var_types(!.Info, VarTypes), - map__lookup(VarTypes, Var, Type), - instmap__bind_var_to_functor(Var, Type, ConsId, InstMap0, InstMap1, + map.lookup(VarTypes, Var, Type), + instmap.bind_var_to_functor(Var, Type, ConsId, InstMap0, InstMap1, ModuleInfo0, ModuleInfo1), simplify_info_set_module_info(ModuleInfo1, !Info), simplify_info_set_instmap(InstMap1, !Info), @@ -2049,17 +2045,16 @@ create_test_unification(Var, ConsId, ConsArity, ExtraGoal - ExtraGoalInfo, !Info) :- simplify_info_get_varset(!.Info, VarSet0), simplify_info_get_var_types(!.Info, VarTypes0), - varset__new_vars(VarSet0, ConsArity, ArgVars, VarSet), - map__lookup(VarTypes0, Var, VarType), + varset.new_vars(VarSet0, ConsArity, ArgVars, VarSet), + map.lookup(VarTypes0, Var, VarType), simplify_info_get_module_info(!.Info, ModuleInfo), - type_util__get_cons_id_arg_types(ModuleInfo, - VarType, ConsId, ArgTypes), - map__det_insert_from_corresponding_lists(VarTypes0, ArgVars, + type_util.get_cons_id_arg_types(ModuleInfo, VarType, ConsId, ArgTypes), + map.det_insert_from_corresponding_lists(VarTypes0, ArgVars, ArgTypes, VarTypes), simplify_info_set_varset(VarSet, !Info), simplify_info_set_var_types(VarTypes, !Info), simplify_info_get_instmap(!.Info, InstMap), - instmap__lookup_var(InstMap, Var, Inst0), + instmap.lookup_var(InstMap, Var, Inst0), ( inst_expand(ModuleInfo, Inst0, Inst1), get_arg_insts(Inst1, ConsId, ConsArity, ArgInsts1) @@ -2072,14 +2067,14 @@ create_test_unification(Var, ConsId, ConsArity, ExtraGoal - ExtraGoalInfo, (pred(ArgInst::in, ArgUniMode::out) is det :- ArgUniMode = ((ArgInst - free) -> (ArgInst - ArgInst)) ), - list__map(InstToUniMode, ArgInsts, UniModes), + list.map(InstToUniMode, ArgInsts, UniModes), UniMode = (Inst0 -> Inst0) - (Inst0 -> Inst0), UnifyContext = unify_context(explicit, []), Unification = deconstruct(Var, ConsId, ArgVars, UniModes, can_fail, cannot_cgc), ExtraGoal = unify(Var, functor(ConsId, no, ArgVars), UniMode, Unification, UnifyContext), - set__singleton_set(NonLocals, Var), + set.singleton_set(NonLocals, Var), % The test can't bind any variables, so the InstMapDelta should be empty. instmap_delta_init_reachable(InstMapDelta), @@ -2095,7 +2090,7 @@ create_test_unification(Var, ConsId, ConsArity, ExtraGoal - ExtraGoalInfo, io::di, io::uo) is det. simplify_disj([], RevGoals, Goals, !PostBranchInstMaps, _, !Info, !IO) :- - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). simplify_disj([Goal0 | Goals0], RevGoals0, Goals, !PostBranchInstMaps, Info0, !Info, !IO) :- simplify_goal(Goal0, Goal, !Info, !IO), @@ -2225,7 +2220,7 @@ det_disj_to_ite([Disjunct | Disjuncts], GoalInfo, Goal) :- goal_info_get_nonlocals(CondGoalInfo, CondNonLocals), goal_info_get_nonlocals(RestGoalInfo, RestNonLocals), - set__union(CondNonLocals, RestNonLocals, NonLocals), + set.union(CondNonLocals, RestNonLocals, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo, NewGoalInfo0), goal_info_get_instmap_delta(GoalInfo, InstMapDelta0), @@ -2254,7 +2249,7 @@ det_disj_to_ite([Disjunct | Disjuncts], GoalInfo, Goal) :- :- pred contains_multisoln_goal(list(hlds_goal)::in) is semidet. contains_multisoln_goal(Goals) :- - list__member(_Goal - GoalInfo, Goals), + list.member(_Goal - GoalInfo, Goals), goal_info_get_determinism(GoalInfo, Detism), determinism_components(Detism, _, at_most_many). @@ -2296,8 +2291,8 @@ simplify_info_init(DetInfo, Simplifications, InstMap, ProcInfo, Info) :- proc_info_varset(ProcInfo, VarSet), proc_info_inst_varset(ProcInfo, InstVarSet), proc_info_rtti_varmaps(ProcInfo, RttiVarMaps), - set__init(Msgs), - set__list_to_set(Simplifications, SimplificationsSet), + set.init(Msgs), + set.list_to_set(Simplifications, SimplificationsSet), Info = simplify_info(DetInfo, Msgs, SimplificationsSet, common_info_init, InstMap, VarSet, InstVarSet, no, no, no, 0, 0, RttiVarMaps, no). @@ -2453,7 +2448,7 @@ simplify_info_add_det_msg(Msg, !Info) :- simplify_info_do_add_det_msg(Msg, !Info) :- simplify_info_get_det_msgs(!.Info, Msgs0), - set__insert(Msgs0, Msg, Msgs), + set.insert(Msgs0, Msg, Msgs), simplify_info_set_det_msgs(Msgs, !Info). simplify_info_enter_lambda(Info, Info ^ lambdas := Info ^ lambdas + 1). @@ -2479,8 +2474,8 @@ simplify_info_apply_type_substitution(TSubst, !Info) :- ApplyTSubst = (pred(_::in, T0::in, T::out) is det :- apply_rec_subst_to_type(TSubst, T0, T) ), - map__map_values(ApplyTSubst, VarTypes0, VarTypes), - apply_substitutions_to_rtti_varmaps(map__init, TSubst, map__init, + map.map_values(ApplyTSubst, VarTypes0, VarTypes), + apply_substitutions_to_rtti_varmaps(map.init, TSubst, map.init, RttiVarMaps0, RttiVarMaps), simplify_info_set_var_types(VarTypes, !Info), simplify_info_set_rtti_varmaps(RttiVarMaps, !Info). @@ -2500,28 +2495,28 @@ simplify_info_apply_type_substitution(TSubst, !Info) :- simplify_do_warn(Info) :- simplify_info_get_simplifications(Info, Simplifications), - set__member(warn_simple_code, Simplifications). + set.member(warn_simple_code, Simplifications). simplify_do_warn_calls(Info) :- simplify_info_get_simplifications(Info, Simplifications), - set__member(warn_duplicate_calls, Simplifications). + set.member(warn_duplicate_calls, Simplifications). simplify_do_once(Info) :- simplify_info_get_simplifications(Info, Simplifications), - set__member(do_once, Simplifications). + set.member(do_once, Simplifications). simplify_do_common(Info) :- simplify_info_get_simplifications(Info, Simplifications), - set__member(common_struct, Simplifications). + set.member(common_struct, Simplifications). simplify_do_excess_assigns(Info) :- simplify_info_get_simplifications(Info, Simplifications), - set__member(excess_assigns, Simplifications). + set.member(excess_assigns, Simplifications). simplify_do_calls(Info) :- simplify_info_get_simplifications(Info, Simplifications), - set__member(duplicate_calls, Simplifications). + set.member(duplicate_calls, Simplifications). simplify_do_const_prop(Info) :- simplify_info_get_simplifications(Info, Simplifications), - set__member(constant_prop, Simplifications). + set.member(constant_prop, Simplifications). simplify_do_more_common(Info) :- simplify_info_get_simplifications(Info, Simplifications), - set__member(extra_common_struct, Simplifications). + set.member(extra_common_struct, Simplifications). :- pred simplify_info_update_instmap(hlds_goal::in, simplify_info::in, simplify_info::out) is det. diff --git a/compiler/size_prof.m b/compiler/size_prof.m index e9cb4c6ad..70cf30679 100644 --- a/compiler/size_prof.m +++ b/compiler/size_prof.m @@ -80,7 +80,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__size_prof. +:- module transform_hlds.size_prof. :- interface. :- import_module hlds.hlds_module. @@ -197,7 +197,7 @@ :- type rev_type_ctor_map == map(prog_var, type_ctor). :- type known_size_map == map(prog_var, int). -:- type size_prof__info +:- type size_prof.info ---> size_prof_info( type_ctor_map :: type_ctor_map, type_info_map :: type_info_map, @@ -214,15 +214,15 @@ process_proc_msg(Transform, PredId, ProcId, ProcInfo0, ProcInfo, !ModuleInfo, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string("% Adding typeinfos in ", !IO), - hlds_out__write_pred_proc_id(!.ModuleInfo, PredId, ProcId, !IO), - io__write_string(": ", !IO), + io.write_string("% Adding typeinfos in ", !IO), + hlds_out.write_pred_proc_id(!.ModuleInfo, PredId, ProcId, !IO), + io.write_string(": ", !IO), process_proc(Transform, PredId, ProcId, ProcInfo0, ProcInfo, !ModuleInfo, !IO), - io__write_string("done.\n", !IO) + io.write_string("done.\n", !IO) ; VeryVerbose = no, process_proc(Transform, PredId, ProcId, ProcInfo0, ProcInfo, @@ -245,18 +245,18 @@ process_proc(Transform, PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :- proc_info_rtti_varmaps(!.ProcInfo, RttiVarMaps), % The with_types are needed to avoid a combinatorial explosion % of ambiguity in the type checker. - TypeCtorMap0 = map__init `with_type` type_ctor_map, - TypeInfoMap0 = map__init `with_type` type_info_map, - RevTypeCtorMap0 = map__init `with_type` rev_type_ctor_map, - RevTypeInfoMap0 = map__init `with_type` rev_type_info_map, - TargetTypeInfoMap0 = map__init `with_type` type_info_map, - KnownSizeMap0 = map__init `with_type` known_size_map, + TypeCtorMap0 = map.init `with_type` type_ctor_map, + TypeInfoMap0 = map.init `with_type` type_info_map, + RevTypeCtorMap0 = map.init `with_type` rev_type_ctor_map, + RevTypeInfoMap0 = map.init `with_type` rev_type_info_map, + TargetTypeInfoMap0 = map.init `with_type` type_info_map, + KnownSizeMap0 = map.init `with_type` known_size_map, Info0 = size_prof_info(TypeCtorMap0, TypeInfoMap0, RevTypeCtorMap0, RevTypeInfoMap0, TargetTypeInfoMap0, KnownSizeMap0, VarSet0, VarTypes0, Transform, RttiVarMaps, !.ModuleInfo), rtti_varmaps_tvars(RttiVarMaps, TVars), - list__foldl(record_typeinfo_in_type_info_varmap(RttiVarMaps), TVars, + list.foldl(record_typeinfo_in_type_info_varmap(RttiVarMaps), TVars, Info0, Info1), process_goal(Goal0, Goal1, Info1, Info), @@ -291,7 +291,7 @@ process_goal(Goal0, Goal, !Info) :- % BindingArgModes = [], which is almost 100% likely, % then process_deconstruct would return GoalExpr0 as % GoalExpr anyway, but would take longer. - list__filter(binds_arg_in_cell(!.Info), ArgModes, BindingArgModes), + list.filter(binds_arg_in_cell(!.Info), ArgModes, BindingArgModes), BindingArgModes \= [] -> process_deconstruct(Var, ConsId, Args, ArgModes, @@ -304,16 +304,16 @@ process_goal(Goal0, Goal, !Info) :- % We don't want to save type_ctor_info variables across calls, % because saving/restoring them is more expensive than defining % them again. - !:Info = !.Info ^ type_ctor_map := map__init, - !:Info = !.Info ^ rev_type_ctor_map := map__init, + !:Info = !.Info ^ type_ctor_map := map.init, + !:Info = !.Info ^ rev_type_ctor_map := map.init, GoalExpr = GoalExpr0 ; GoalExpr0 = generic_call(_, _, _, _), % We don't want to save type_ctor_info variables across calls, % because saving/restoring them is more expensive than defining % them again. - !:Info = !.Info ^ type_ctor_map := map__init, - !:Info = !.Info ^ rev_type_ctor_map := map__init, + !:Info = !.Info ^ type_ctor_map := map.init, + !:Info = !.Info ^ rev_type_ctor_map := map.init, GoalExpr = GoalExpr0 ; GoalExpr0 = foreign_proc(_, _, _, _, _, _), @@ -339,8 +339,8 @@ process_goal(Goal0, Goal, !Info) :- !:Info = !.Info ^ target_type_info_map := TargetTypeInfoMap0, !:Info = !.Info ^ type_info_map := TypeInfoMap0, !:Info = !.Info ^ rev_type_info_map := RevTypeInfoMap0, - !:Info = !.Info ^ type_ctor_map := map__init, - !:Info = !.Info ^ rev_type_ctor_map := map__init, + !:Info = !.Info ^ type_ctor_map := map.init, + !:Info = !.Info ^ rev_type_ctor_map := map.init, !:Info = !.Info ^ known_size_map := KnownSizeMap0 ), GoalExpr = conj(ConjType, Goals) @@ -362,13 +362,13 @@ process_goal(Goal0, Goal, !Info) :- !:Info = !.Info ^ type_info_map := TypeInfoMap, % The rev_type_info_map field is updated by % the call to update_rev_maps below. - !:Info = !.Info ^ type_ctor_map := map__init, - !:Info = !.Info ^ rev_type_ctor_map := map__init, + !:Info = !.Info ^ type_ctor_map := map.init, + !:Info = !.Info ^ rev_type_ctor_map := map.init, !:Info = !.Info ^ known_size_map := KnownSizeMap, Cases = [First | Later] ; Cases0 = [], - unexpected(this_file, "size_prof__process_goal: empty switch") + unexpected(this_file, "size_prof.process_goal: empty switch") ), update_rev_maps(!Info), update_target_map(!Info), @@ -391,17 +391,17 @@ process_goal(Goal0, Goal, !Info) :- !:Info = !.Info ^ type_info_map := TypeInfoMap, % The rev_type_info_map field is updated by % the call to update_rev_maps below. - !:Info = !.Info ^ type_ctor_map := map__init, - !:Info = !.Info ^ rev_type_ctor_map := map__init, + !:Info = !.Info ^ type_ctor_map := map.init, + !:Info = !.Info ^ rev_type_ctor_map := map.init, !:Info = !.Info ^ known_size_map := KnownSizeMap, Disjuncts = [First | Later] ; Disjuncts0 = [], % An empty disj represents `fail'. - !:Info = !.Info ^ type_info_map := map__init, - !:Info = !.Info ^ rev_type_ctor_map := map__init, - !:Info = !.Info ^ type_info_map := map__init, - !:Info = !.Info ^ rev_type_ctor_map := map__init, + !:Info = !.Info ^ type_info_map := map.init, + !:Info = !.Info ^ rev_type_ctor_map := map.init, + !:Info = !.Info ^ type_info_map := map.init, + !:Info = !.Info ^ rev_type_ctor_map := map.init, Disjuncts = [] ), update_rev_maps(!Info), @@ -416,7 +416,7 @@ process_goal(Goal0, Goal, !Info) :- RevTypeCtorMap0 = !.Info ^ rev_type_ctor_map, KnownSizeMap0 = !.Info ^ known_size_map, - !:Info = !.Info ^ target_type_info_map := map__init, + !:Info = !.Info ^ target_type_info_map := map.init, process_goal(Cond0, Cond, !Info), !:Info = !.Info ^ target_type_info_map := TargetTypeInfoMap0, process_goal(Then0, Then, !Info), @@ -424,7 +424,7 @@ process_goal(Goal0, Goal, !Info) :- TypeInfoMapThen = !.Info ^ type_info_map, KnownSizeMapThen = !.Info ^ known_size_map, - map__union(select_first, TargetTypeInfoMapThen, + map.union(select_first, TargetTypeInfoMapThen, TargetTypeInfoMap0, ElseTargetTypeInfoMap), !:Info = !.Info ^ target_type_info_map := ElseTargetTypeInfoMap, @@ -437,10 +437,10 @@ process_goal(Goal0, Goal, !Info) :- TypeInfoMapElse = !.Info ^ type_info_map, KnownSizeMapElse = !.Info ^ known_size_map, - TypeInfoMap = map__common_subset(TypeInfoMapThen, TypeInfoMapElse), - KnownSizeMap = map__common_subset(KnownSizeMapThen, KnownSizeMapElse), + TypeInfoMap = map.common_subset(TypeInfoMapThen, TypeInfoMapElse), + KnownSizeMap = map.common_subset(KnownSizeMapThen, KnownSizeMapElse), !:Info = !.Info ^ type_info_map := TypeInfoMap, - !:Info = !.Info ^ type_ctor_map := map__init, + !:Info = !.Info ^ type_ctor_map := map.init, !:Info = !.Info ^ known_size_map := KnownSizeMap, update_rev_maps(!Info), update_target_map(!Info), @@ -470,7 +470,7 @@ process_goal(Goal0, Goal, !Info) :- GoalExpr = scope(Reason, SomeGoal) ; GoalExpr0 = shorthand(_), - unexpected(this_file, "size_prof__process_goal: shorthand") + unexpected(this_file, "size_prof.process_goal: shorthand") ), Goal = GoalExpr - GoalInfo0. @@ -488,7 +488,7 @@ process_conj([Goal0 | Goals0], Conj, !Info) :- % We never create conjunctions more than one level deep, % so this single test is sufficient to ensure that we never % leave conjunctions nested more deeply than the input goal. - Conj = list__append(SubConj, Goals) + Conj = list.append(SubConj, Goals) ; Conj = [Goal | Goals] ). @@ -531,14 +531,14 @@ process_disj(First0, First, Later0, Later, !Info, TargetTypeInfoMap, KnownSizeMapFirst = !.Info ^ known_size_map, ( Later0 = [Head0 | Tail0], - map__union(select_first, TypeInfoMapFirst, + map.union(select_first, TypeInfoMapFirst, TargetTypeInfoMap, LaterTargetTypeInfoMap), !:Info = !.Info ^ target_type_info_map := LaterTargetTypeInfoMap, process_disj(Head0, Head, Tail0, Tail, !Info, TargetTypeInfoMap, TypeInfoMap0, RevTypeInfoMap0, TypeCtorMap0, RevTypeCtorMap0, TypeInfoMapLater, KnownSizeMap0, KnownSizeMapLater), - TypeInfoMap = map__common_subset(TypeInfoMapFirst, TypeInfoMapLater), - KnownSizeMap = map__common_subset(KnownSizeMapFirst, + TypeInfoMap = map.common_subset(TypeInfoMapFirst, TypeInfoMapLater), + KnownSizeMap = map.common_subset(KnownSizeMapFirst, KnownSizeMapLater), Later = [Head | Tail] ; @@ -571,14 +571,14 @@ process_switch(First0, First, Later0, Later, !Info, TargetTypeInfoMap, First = case(FirstConsId, FirstGoal), ( Later0 = [Head0 | Tail0], - map__union(select_first, TargetTypeInfoMap, + map.union(select_first, TargetTypeInfoMap, TypeInfoMapFirst, LaterTargetTypeInfoMap), !:Info = !.Info ^ target_type_info_map := LaterTargetTypeInfoMap, process_switch(Head0, Head, Tail0, Tail, !Info, TargetTypeInfoMap, TypeInfoMap0, RevTypeInfoMap0, TypeCtorMap0, RevTypeCtorMap0, TypeInfoMapLater, KnownSizeMap0, KnownSizeMapLater), - TypeInfoMap = map__common_subset(TypeInfoMapFirst, TypeInfoMapLater), - KnownSizeMap = map__common_subset(KnownSizeMapFirst, + TypeInfoMap = map.common_subset(TypeInfoMapFirst, TypeInfoMapLater), + KnownSizeMap = map.common_subset(KnownSizeMapFirst, KnownSizeMapLater), Later = [Head | Tail] ; @@ -597,12 +597,12 @@ process_switch(First0, First, Later0, Later, !Info, TargetTypeInfoMap, process_construct(LHS, RHS, UniMode, UnifyContext, Var, ConsId, Args, ArgModes, How, Unique, GoalInfo, GoalExpr, !Info) :- - map__lookup(!.Info ^ vartypes, Var, VarType), + map.lookup(!.Info ^ vartypes, Var, VarType), ( type_to_ctor_and_args(VarType, VarTypeCtorPrime, _VarTypeArgs) -> VarTypeCtor = VarTypeCtorPrime ; unexpected(this_file, - "size_prof__process_construct: constructing term of variable type") + "size_prof.process_construct: constructing term of variable type") ), type_ctor_module(!.Info ^ module_info, VarTypeCtor, VarTypeCtorModule), type_ctor_name(!.Info ^ module_info, VarTypeCtor, VarTypeCtorName), @@ -660,7 +660,7 @@ process_construct(LHS, RHS, UniMode, UnifyContext, Var, ConsId, Args, ArgModes, info::in, info::out) is det. process_deconstruct(Var, ConsId, Args, ArgModes, Goal0, GoalExpr, !Info) :- - map__lookup(!.Info ^ vartypes, Var, VarType), + map.lookup(!.Info ^ vartypes, Var, VarType), ( type_to_ctor_and_args(VarType, VarTypeCtorPrime, _VarTypeArgs) -> VarTypeCtor = VarTypeCtorPrime ; @@ -724,10 +724,10 @@ process_cons_construct(LHS, RHS, UniMode, UnifyContext, Var, _Type, ConsId, construct_sub_info(no, yes(dynamic_size(SizeVar)))), UnifyExpr = unify(LHS, RHS, UniMode, Unification, UnifyContext), goal_info_get_nonlocals(GoalInfo0, NonLocals0), - set__insert(NonLocals0, SizeVar, NonLocals), + set.insert(NonLocals0, SizeVar, NonLocals), goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo), UnifyGoal = UnifyExpr - GoalInfo, - Goals = list__condense([ArgGoals, SizeGoals, [UnifyGoal]]), + Goals = list.condense([ArgGoals, SizeGoals, [UnifyGoal]]), GoalExpr = conj(plain_conj, Goals) ). @@ -755,7 +755,7 @@ process_cons_deconstruct(Var, Args, ArgModes, UnifyGoal, GoalExpr, !Info) :- % The increment_size primitive doesn't need Var's type_info, % so we make it a no_type_info_builtin. TermSizeProfBuiltin = mercury_term_size_prof_builtin_module, - goal_util__generate_simple_call(TermSizeProfBuiltin, + goal_util.generate_simple_call(TermSizeProfBuiltin, "increment_size", predicate, only_mode, det, [Var, SizeVar], [impure_goal], [], !.Info ^ module_info, Context, UpdateGoal), @@ -781,8 +781,8 @@ process_cons_deconstruct(Var, Args, ArgModes, UnifyGoal, GoalExpr, !Info) :- process_args([], !KnownSize, !MaybeSizeVar, _, [], !Info). process_args([Arg | Args], !KnownSize, !MaybeSizeVar, Context, Goals, !Info) :- - map__lookup(!.Info ^ vartypes, Arg, Type), - ( map__search(!.Info ^ known_size_map, Arg, ArgSize) -> + map.lookup(!.Info ^ vartypes, Arg, Type), + ( map.search(!.Info ^ known_size_map, Arg, ArgSize) -> !:KnownSize = !.KnownSize + ArgSize, ArgGoals = [] ; zero_size_type(Type, !.Info ^ module_info) -> @@ -791,10 +791,10 @@ process_args([Arg | Args], !KnownSize, !MaybeSizeVar, Context, Goals, !Info) :- make_type_info(Context, Type, TypeInfoVar, TypeInfoGoals, !Info), make_size_goal(TypeInfoVar, Arg, Context, SizeGoal, !MaybeSizeVar, !Info), - list__append(TypeInfoGoals, [SizeGoal], ArgGoals) + list.append(TypeInfoGoals, [SizeGoal], ArgGoals) ), process_args(Args, !KnownSize, !MaybeSizeVar, Context, LaterGoals, !Info), - list__append(ArgGoals, LaterGoals, Goals). + list.append(ArgGoals, LaterGoals, Goals). %-----------------------------------------------------------------------------% @@ -820,7 +820,7 @@ generate_size_var(SizeVar0, KnownSize, Context, SizeVar, Goals, !Info) :- !:Info = !.Info ^ vartypes := VarTypes1, get_new_var(int_type, "FinalSizeVar", SizeVar, !Info), TermSizeProfModule = mercury_term_size_prof_builtin_module, - goal_util__generate_simple_call(TermSizeProfModule, + goal_util.generate_simple_call(TermSizeProfModule, "term_size_plus", function, mode_no(0), det, [SizeVar0, KnownSizeVar, SizeVar], [], [SizeVar - ground(shared, none)], @@ -839,7 +839,7 @@ generate_size_var(SizeVar0, KnownSize, Context, SizeVar, Goals, !Info) :- list(hlds_goal)::out, info::in, info::out) is det. make_type_info(Context, Type, TypeInfoVar, TypeInfoGoals, !Info) :- - ( map__search(!.Info ^ type_info_map, Type, TypeInfoVarPrime) -> + ( map.search(!.Info ^ type_info_map, Type, TypeInfoVarPrime) -> TypeInfoVar = TypeInfoVarPrime, TypeInfoGoals = [] ; type_has_variable_arity_ctor(Type, TypeCtor, ArgTypes) -> @@ -867,13 +867,13 @@ make_type_info(Context, Type, TypeInfoVar, TypeInfoGoals, !Info) :- TargetTypeInfoMap = !.Info ^ target_type_info_map, VarSet0 = !.Info ^ varset, VarTypes0 = !.Info ^ vartypes, - ( map__search(TargetTypeInfoMap, Type, TargetVar) -> + ( map.search(TargetTypeInfoMap, Type, TargetVar) -> TypeInfoVar = TargetVar, VarSet1 = VarSet0, VarTypes1 = VarTypes0 ; RttiVarMaps0 = !.Info ^ rtti_varmaps, - polymorphism__new_type_info_var_raw(Type, type_info, + polymorphism.new_type_info_var_raw(Type, type_info, TypeInfoVar, VarSet0, VarSet1, VarTypes0, VarTypes1, RttiVarMaps0, RttiVarMaps), !:Info = !.Info ^ rtti_varmaps := RttiVarMaps @@ -883,7 +883,7 @@ make_type_info(Context, Type, TypeInfoVar, TypeInfoGoals, !Info) :- !:Info = !.Info ^ varset := VarSet, !:Info = !.Info ^ vartypes := VarTypes, PrivateBuiltin = mercury_private_builtin_module, - goal_util__generate_simple_call(PrivateBuiltin, + goal_util.generate_simple_call(PrivateBuiltin, "type_info_from_typeclass_info", predicate, only_mode, det, [TypeClassInfoVar, SlotVar, TypeInfoVar], [], [TypeInfoVar - ground(shared, none)], @@ -895,7 +895,7 @@ make_type_info(Context, Type, TypeInfoVar, TypeInfoGoals, !Info) :- % Type_to_ctor_and_args can fail only if Type is a type variable, % or acts like one. The tests in our callers should have filtered % out both cases. - unexpected(this_file, "size_prof__make_type_info: cannot happen") + unexpected(this_file, "size_prof.make_type_info: cannot happen") ). % Construct a type_info for Type = TypeCtor(ArgTypes), given that we know @@ -909,20 +909,20 @@ make_type_info(Context, Type, TypeInfoVar, TypeInfoGoals, !Info) :- construct_type_info(Context, Type, TypeCtor, ArgTypes, CtorIsVarArity, TypeInfoVar, TypeInfoGoals, !Info) :- - list__map2_foldl(make_type_info(Context), ArgTypes, + list.map2_foldl(make_type_info(Context), ArgTypes, ArgTypeInfoVars, ArgTypeInfoGoalLists, !Info), - ArgTypeInfoGoals = list__condense(ArgTypeInfoGoalLists), + ArgTypeInfoGoals = list.condense(ArgTypeInfoGoalLists), make_type_ctor_info(TypeCtor, ArgTypes, TypeCtorVar, TypeCtorGoals, !Info), ( CtorIsVarArity = yes, - list__length(ArgTypes, Arity), + list.length(ArgTypes, Arity), VarSet0 = !.Info ^ varset, VarTypes0 = !.Info ^ vartypes, make_int_const_construction_alloc(Arity, yes("TupleArity"), ArityGoal, ArityVar, VarTypes0, VarTypes1, VarSet0, VarSet1), !:Info = !.Info ^ varset := VarSet1, !:Info = !.Info ^ vartypes := VarTypes1, - FrontGoals = list__append(TypeCtorGoals, [ArityGoal]), + FrontGoals = list.append(TypeCtorGoals, [ArityGoal]), ArgVars = [TypeCtorVar, ArityVar | ArgTypeInfoVars] ; CtorIsVarArity = no, @@ -933,18 +933,18 @@ construct_type_info(Context, Type, TypeCtor, ArgTypes, CtorIsVarArity, VarTypes2 = !.Info ^ vartypes, RttiVarMaps0 = !.Info ^ rtti_varmaps, TargetTypeInfoMap = !.Info ^ target_type_info_map, - ( map__search(TargetTypeInfoMap, Type, PrefTIVar) -> + ( map.search(TargetTypeInfoMap, Type, PrefTIVar) -> MaybePreferredVar = yes(PrefTIVar) ; MaybePreferredVar = no ), - polymorphism__init_type_info_var(Type, ArgVars, MaybePreferredVar, + polymorphism.init_type_info_var(Type, ArgVars, MaybePreferredVar, TypeInfoVar, TypeInfoGoal, VarSet2, VarSet, VarTypes2, VarTypes, RttiVarMaps0, RttiVarMaps), !:Info = !.Info ^ varset := VarSet, !:Info = !.Info ^ vartypes := VarTypes, !:Info = !.Info ^ rtti_varmaps := RttiVarMaps, - TypeInfoGoals = list__condense([ArgTypeInfoGoals, FrontGoals, + TypeInfoGoals = list.condense([ArgTypeInfoGoals, FrontGoals, [TypeInfoGoal]]). % Create a type_ctor_info for a given type constructor as cheaply as @@ -956,7 +956,7 @@ construct_type_info(Context, Type, TypeCtor, ArgTypes, CtorIsVarArity, list(hlds_goal)::out, info::in, info::out) is det. make_type_ctor_info(TypeCtor, TypeArgs, TypeCtorVar, TypeCtorGoals, !Info) :- - ( map__search(!.Info ^ type_ctor_map, TypeCtor, TypeCtorVarPrime) -> + ( map.search(!.Info ^ type_ctor_map, TypeCtor, TypeCtorVarPrime) -> TypeCtorVar = TypeCtorVarPrime, TypeCtorGoals = [] ; @@ -971,7 +971,7 @@ make_type_ctor_info(TypeCtor, TypeArgs, TypeCtorVar, TypeCtorGoals, !Info) :- VarSet0 = !.Info ^ varset, VarTypes0 = !.Info ^ vartypes, RttiVarMaps0 = !.Info ^ rtti_varmaps, - polymorphism__init_const_type_ctor_info_var(Type, TypeCtor, + polymorphism.init_const_type_ctor_info_var(Type, TypeCtor, TypeCtorVar, TypeCtorGoal, !.Info ^ module_info, VarSet0, VarSet, VarTypes0, VarTypes, RttiVarMaps0, RttiVarMaps), @@ -1009,7 +1009,7 @@ make_size_goal(TypeInfoVar, Arg, Context, SizeGoal, Args = [TypeInfoVar, Arg, SizeVar] ), TermSizeProfBuiltin = mercury_term_size_prof_builtin_module, - goal_util__generate_simple_call(TermSizeProfBuiltin, Pred, predicate, + goal_util.generate_simple_call(TermSizeProfBuiltin, Pred, predicate, only_mode, det, Args, [], [SizeVar - ground(shared, none)], !.Info ^ module_info, Context, SizeGoal), MaybeSizeVar = yes(SizeVar). @@ -1025,12 +1025,12 @@ make_size_goal(TypeInfoVar, Arg, Context, SizeGoal, get_new_var(Type, Prefix, Var, !Info) :- VarSet0 = !.Info ^ varset, VarTypes0 = !.Info ^ vartypes, - varset__new_var(VarSet0, Var, VarSet1), - term__var_to_int(Var, VarNum), - string__int_to_string(VarNum, VarNumStr), - string__append(Prefix, VarNumStr, Name), - varset__name_var(VarSet1, Var, Name, VarSet), - map__set(VarTypes0, Var, Type, VarTypes), + varset.new_var(VarSet0, Var, VarSet1), + term.var_to_int(Var, VarNum), + string.int_to_string(VarNum, VarNumStr), + string.append(Prefix, VarNumStr, Name), + varset.name_var(VarSet1, Var, Name, VarSet), + map.set(VarTypes0, Var, Type, VarTypes), !:Info = !.Info ^ varset := VarSet, !:Info = !.Info ^ vartypes := VarTypes. @@ -1040,8 +1040,8 @@ get_new_var(Type, Prefix, Var, !Info) :- % either there originally or was made true by our transformation) for later % use in optimizating the transformation of the rest of the procedure body. % - % The reason why the implementation uses map__set instead of - % map__det_insert is that it is possible for Var to already exist in the + % The reason why the implementation uses map.set instead of + % map.det_insert is that it is possible for Var to already exist in the % maps. This can happen e.g. when each branch of a branched structure % generates a value of an existential type, and thus also generates % the type_info describing that type. The first branch will insert the @@ -1062,8 +1062,8 @@ record_known_type_ctor_info(Var, TypeCtorModule, TypeCtorName, TypeCtorArity, TypeCtor = qualified(TypeCtorModule, TypeCtorName) - TypeCtorArity, TypeCtorMap0 = !.Info ^ type_ctor_map, RevTypeCtorMap0 = !.Info ^ rev_type_ctor_map, - map__set(TypeCtorMap0, TypeCtor, Var, TypeCtorMap), - map__set(RevTypeCtorMap0, Var, TypeCtor, RevTypeCtorMap), + map.set(TypeCtorMap0, TypeCtor, Var, TypeCtorMap), + map.set(RevTypeCtorMap0, Var, TypeCtor, RevTypeCtorMap), !:Info = !.Info ^ type_ctor_map := TypeCtorMap, !:Info = !.Info ^ rev_type_ctor_map := RevTypeCtorMap. @@ -1072,10 +1072,10 @@ record_known_type_ctor_info(Var, TypeCtorModule, TypeCtorName, TypeCtorArity, record_known_type_info(Var, TypeCtorInfoVar, ArgTypeInfoVars, !Info) :- RevTypeCtorMap0 = !.Info ^ rev_type_ctor_map, - ( map__search(RevTypeCtorMap0, TypeCtorInfoVar, TypeCtor0) -> + ( map.search(RevTypeCtorMap0, TypeCtorInfoVar, TypeCtor0) -> RevTypeInfoMap0 = !.Info ^ rev_type_info_map, - ( list__map(map__search(RevTypeInfoMap0), ArgTypeInfoVars, ArgTypes) -> - list__length(ArgTypes, Arity), + ( list.map(map.search(RevTypeInfoMap0), ArgTypeInfoVars, ArgTypes) -> + list.length(ArgTypes, Arity), % Just in case TypeCtorInfo0 has fake arity, e.g. if it is a tuple. TypeCtor0 = SymName - _DeclArity, TypeCtor1 = SymName - Arity, @@ -1100,8 +1100,8 @@ record_known_type_info(Var, TypeCtorInfoVar, ArgTypeInfoVars, !Info) :- record_type_info_var(Type, Var, !Info) :- RevTypeInfoMap0 = !.Info ^ rev_type_info_map, TypeInfoMap0 = !.Info ^ type_info_map, - map__set(TypeInfoMap0, Type, Var, TypeInfoMap), - ( map__insert(RevTypeInfoMap0, Var, Type, RevTypeInfoMap1) -> + map.set(TypeInfoMap0, Type, Var, TypeInfoMap), + ( map.insert(RevTypeInfoMap0, Var, Type, RevTypeInfoMap1) -> RevTypeInfoMap = RevTypeInfoMap1 ; % This can happen because inlining XXX can leave a @@ -1116,7 +1116,7 @@ record_type_info_var(Type, Var, !Info) :- record_known_size(Var, KnownSize, !Info) :- KnownSizeMap0 = !.Info ^ known_size_map, - map__det_insert(KnownSizeMap0, Var, KnownSize, KnownSizeMap), + map.det_insert(KnownSizeMap0, Var, KnownSize, KnownSizeMap), !:Info = !.Info ^ known_size_map := KnownSizeMap. :- pred record_typeinfo_in_type_info_varmap(rtti_varmaps::in, tvar::in, @@ -1136,7 +1136,7 @@ record_typeinfo_in_type_info_varmap(RttiVarMaps, TVar, !Info) :- % extract typeinfos from typeclass_infos, but code that does % that is rare enough that it is not worth optimizing. % TypeClassInfoMap0 = !.Info ^ type_class_info_map, - % map__det_insert(TypeClassInfoMap0, + % map.det_insert(TypeClassInfoMap0, % TypeClassInfoVar - Offset, Type, TypeClassInfoMap), % !:Info = !.Info ^ type_class_info_map := TypeClassInfoMap ). @@ -1159,13 +1159,13 @@ record_typeinfo_in_type_info_varmap(RttiVarMaps, TVar, !Info) :- :- pred update_rev_maps(info::in, info::out) is det. update_rev_maps(!Info) :- - map__to_sorted_assoc_list(!.Info ^ type_info_map, TypeInfoList), - map__to_sorted_assoc_list(!.Info ^ type_ctor_map, TypeCtorList), - map__init(VarCounts0), + map.to_sorted_assoc_list(!.Info ^ type_info_map, TypeInfoList), + map.to_sorted_assoc_list(!.Info ^ type_ctor_map, TypeCtorList), + map.init(VarCounts0), count_appearances(TypeInfoList, VarCounts0, VarCounts1), count_appearances(TypeCtorList, VarCounts1, VarCounts), - construct_rev_map(TypeInfoList, VarCounts, map__init, RevTypeInfoMap), - construct_rev_map(TypeCtorList, VarCounts, map__init, RevTypeCtorMap), + construct_rev_map(TypeInfoList, VarCounts, map.init, RevTypeInfoMap), + construct_rev_map(TypeCtorList, VarCounts, map.init, RevTypeCtorMap), !:Info = !.Info ^ rev_type_info_map := RevTypeInfoMap, !:Info = !.Info ^ rev_type_ctor_map := RevTypeCtorMap. @@ -1174,10 +1174,10 @@ update_rev_maps(!Info) :- count_appearances([], VarCounts, VarCounts). count_appearances([_ - Var | AssocList], VarCounts0, VarCounts) :- - ( map__search(VarCounts0, Var, Count) -> - map__det_update(VarCounts0, Var, Count + 1, VarCounts1) + ( map.search(VarCounts0, Var, Count) -> + map.det_update(VarCounts0, Var, Count + 1, VarCounts1) ; - map__det_insert(VarCounts0, Var, 1, VarCounts1) + map.det_insert(VarCounts0, Var, 1, VarCounts1) ), count_appearances(AssocList, VarCounts1, VarCounts). @@ -1187,9 +1187,9 @@ count_appearances([_ - Var | AssocList], VarCounts0, VarCounts) :- construct_rev_map([], _, RevMap, RevMap). construct_rev_map([T - Var | AssocList], VarCounts, RevMap0, RevMap) :- - map__lookup(VarCounts, Var, Count), + map.lookup(VarCounts, Var, Count), ( Count = 1 -> - map__det_insert(RevMap0, Var, T, RevMap1) + map.det_insert(RevMap0, Var, T, RevMap1) ; RevMap1 = RevMap0 ), @@ -1213,17 +1213,17 @@ construct_rev_map([T - Var | AssocList], VarCounts, RevMap0, RevMap) :- update_target_map(!Info) :- TargetTypeInfoMap0 = !.Info ^ target_type_info_map, TypeInfoMap = !.Info ^ type_info_map, - map__to_sorted_assoc_list(TargetTypeInfoMap0, TargetTypeInfoList), - list__foldl(include_in_target_map(TypeInfoMap), TargetTypeInfoList, - map__init, TargetTypeInfoMap), + map.to_sorted_assoc_list(TargetTypeInfoMap0, TargetTypeInfoList), + list.foldl(include_in_target_map(TypeInfoMap), TargetTypeInfoList, + map.init, TargetTypeInfoMap), !:Info = !.Info ^ target_type_info_map := TargetTypeInfoMap. :- pred include_in_target_map(type_info_map::in, pair(mer_type, prog_var)::in, type_info_map::in, type_info_map::out) is det. include_in_target_map(TypeInfoMap, Type - TypeInfoVar, !TargetTypeInfoMap) :- - ( map__search(TypeInfoMap, Type, TypeInfoVar) -> - svmap__det_insert(Type, TypeInfoVar, !TargetTypeInfoMap) + ( map.search(TypeInfoMap, Type, TypeInfoVar) -> + svmap.det_insert(Type, TypeInfoVar, !TargetTypeInfoMap) ; true ). @@ -1239,7 +1239,7 @@ compute_functor_size(Args, Info) = FunctorSize :- FunctorSize = 1 ; TransformOp = term_words, - FunctorSize = list__length(Args) + FunctorSize = list.length(Args) ). :- pred find_defined_args(list(prog_var)::in, list(uni_mode)::in, @@ -1254,11 +1254,11 @@ find_defined_args(Args, Modes, DefinedArgs, NonDefinedArgs, Info) :- ; Args = [], Modes = [_ | _], - unexpected(this_file, "size_prof__find_defined_args: length mismatch") + unexpected(this_file, "size_prof.find_defined_args: length mismatch") ; Args = [_ | _], Modes = [], - unexpected(this_file, "size_prof__find_defined_args: length mismatch") + unexpected(this_file, "size_prof.find_defined_args: length mismatch") ; Args = [FirstArg | LaterArgs], Modes = [FirstMode | LaterModes], diff --git a/compiler/source_file_map.m b/compiler/source_file_map.m index b728634ab..301567bcd 100644 --- a/compiler/source_file_map.m +++ b/compiler/source_file_map.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2002-2005 The University of Melbourne. +% Copyright (C) 2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -11,7 +11,7 @@ % Maintain a mapping from module name to source file name. %-----------------------------------------------------------------------------% -:- module parse_tree__source_file_map. +:- module parse_tree.source_file_map. :- interface. @@ -57,20 +57,23 @@ lookup_module_source_file(ModuleName, FileName, !IO) :- get_source_file_map(SourceFileMap, !IO), - ( map__search(SourceFileMap, ModuleName, FileName0) -> + ( map.search(SourceFileMap, ModuleName, FileName0) -> FileName = FileName0 ; FileName = default_source_file(ModuleName) ). default_source_file(ModuleName) = BaseFileName ++ ".m" :- - mdbcomp__prim_data__sym_name_to_string(ModuleName, ".", BaseFileName). + sym_name_to_string(ModuleName, ".", BaseFileName). have_source_file_map(HaveMap, !IO) :- get_source_file_map(_, !IO), - globals__io_get_globals(Globals, !IO), - globals__get_source_file_map(Globals, MaybeSourceFileMap), - ( MaybeSourceFileMap = yes(Map), \+ map__is_empty(Map) -> + globals.io_get_globals(Globals, !IO), + globals.get_source_file_map(Globals, MaybeSourceFileMap), + ( + MaybeSourceFileMap = yes(Map), + \+ map.is_empty(Map) + -> HaveMap = yes ; HaveMap = no @@ -82,29 +85,29 @@ have_source_file_map(HaveMap, !IO) :- :- pred get_source_file_map(source_file_map::out, io::di, io::uo) is det. get_source_file_map(SourceFileMap, !IO) :- - globals__io_get_globals(Globals0, !IO), - globals__get_source_file_map(Globals0, MaybeSourceFileMap0), + globals.io_get_globals(Globals0, !IO), + globals.get_source_file_map(Globals0, MaybeSourceFileMap0), ( MaybeSourceFileMap0 = yes(SourceFileMap0), SourceFileMap = SourceFileMap0 ; MaybeSourceFileMap0 = no, - io__open_input(modules_file_name, OpenRes, !IO), + io.open_input(modules_file_name, OpenRes, !IO), ( OpenRes = ok(Stream), - io__set_input_stream(Stream, OldStream, !IO), - read_source_file_map([], map__init, SourceFileMap, !IO), - io__set_input_stream(OldStream, _, !IO), - io__close_input(Stream, !IO) + io.set_input_stream(Stream, OldStream, !IO), + read_source_file_map([], map.init, SourceFileMap, !IO), + io.set_input_stream(OldStream, _, !IO), + io.close_input(Stream, !IO) ; OpenRes = error(_), % If the file doesn't exist, then the mapping is empty. - SourceFileMap = map__init + SourceFileMap = map.init ), - globals__io_get_globals(Globals1, !IO), - globals__set_source_file_map(yes(SourceFileMap), Globals1, Globals2), + globals.io_get_globals(Globals1, !IO), + globals.set_source_file_map(yes(SourceFileMap), Globals1, Globals2), unsafe_promise_unique(Globals2, Globals), - globals__io_set_globals(Globals, !IO) + globals.io_set_globals(Globals, !IO) ). :- pred read_source_file_map(list(char)::in, @@ -114,43 +117,43 @@ read_source_file_map(ModuleChars, !Map, !IO) :- read_until_char('\t', [], ModuleCharsResult, !IO), ( ModuleCharsResult = ok(RevModuleChars), - string__from_rev_char_list(RevModuleChars, ModuleStr), + string.from_rev_char_list(RevModuleChars, ModuleStr), string_to_sym_name(ModuleStr, ".", ModuleName), read_until_char('\n', [], FileNameCharsResult, !IO), ( FileNameCharsResult = ok(FileNameChars), - string__from_rev_char_list(FileNameChars, FileName), - map__set(!.Map, ModuleName, FileName, !:Map), + string.from_rev_char_list(FileNameChars, FileName), + map.set(!.Map, ModuleName, FileName, !:Map), read_source_file_map(ModuleChars, !Map, !IO) ; FileNameCharsResult = eof, - io__set_exit_status(1, !IO), - io__write_string("mercury_compile: unexpected end " ++ + io.set_exit_status(1, !IO), + io.write_string("mercury_compile: unexpected end " ++ "of file in Mercury.modules file.\n", !IO) ; FileNameCharsResult = error(Error), - io__set_exit_status(1, !IO), - io__write_string("mercury_compile: error in " ++ + io.set_exit_status(1, !IO), + io.write_string("mercury_compile: error in " ++ "Mercury.modules file: ", !IO), - io__write_string(io__error_message(Error), !IO), - io__nl(!IO) + io.write_string(io.error_message(Error), !IO), + io.nl(!IO) ) ; ModuleCharsResult = eof ; ModuleCharsResult = error(Error), - io__set_exit_status(1, !IO), - io__write_string("mercury_compile: error in " ++ + io.set_exit_status(1, !IO), + io.write_string("mercury_compile: error in " ++ "Mercury.modules file: ", !IO), - io__write_string(io__error_message(Error), !IO), - io__nl(!IO) + io.write_string(io.error_message(Error), !IO), + io.nl(!IO) ). -:- pred read_until_char(char::in, list(char)::in, io__result(list(char))::out, +:- pred read_until_char(char::in, list(char)::in, io.result(list(char))::out, io::di, io::uo) is det. read_until_char(EndChar, Chars0, Result, !IO) :- - io__read_char(CharRes, !IO), + io.read_char(CharRes, !IO), ( CharRes = ok(Char), ( Char = EndChar -> @@ -168,48 +171,48 @@ read_until_char(EndChar, Chars0, Result, !IO) :- write_source_file_map(FileNames, !IO) :- ModulesFileName = modules_file_name, - io__open_output(ModulesFileName, OpenRes, !IO), + io.open_output(ModulesFileName, OpenRes, !IO), ( OpenRes = ok(Stream), - list__foldl(write_source_file_map_2(Stream), FileNames, !IO), - io__close_output(Stream, !IO) + list.foldl(write_source_file_map_2(Stream), FileNames, !IO), + io.close_output(Stream, !IO) ; OpenRes = error(Error), - io__set_exit_status(1, !IO), - io__write_string("mercury_compile: error opening `", !IO), - io__write_string(ModulesFileName, !IO), - io__write_string("' for output: ", !IO), - io__write_string(io__error_message(Error), !IO) + io.set_exit_status(1, !IO), + io.write_string("mercury_compile: error opening `", !IO), + io.write_string(ModulesFileName, !IO), + io.write_string("' for output: ", !IO), + io.write_string(io.error_message(Error), !IO) ). -:- pred write_source_file_map_2(io__output_stream::in, file_name::in, +:- pred write_source_file_map_2(io.output_stream::in, file_name::in, io::di, io::uo) is det. write_source_file_map_2(MapStream, FileName, !IO) :- find_module_name(FileName, MaybeModuleName, !IO), ( MaybeModuleName = yes(ModuleName), - ( string__remove_suffix(FileName, ".m", PartialFileName0) -> + ( string.remove_suffix(FileName, ".m", PartialFileName0) -> PartialFileName = PartialFileName0 ; PartialFileName = FileName ), - file_name_to_module_name(dir__basename_det(PartialFileName), + file_name_to_module_name(dir.basename_det(PartialFileName), DefaultModuleName), ( % Only include a module in the mapping if the name doesn't match % the default. - dir__dirname(PartialFileName) = dir__this_directory : string, + dir.dirname(PartialFileName) = dir.this_directory : string, ModuleName = DefaultModuleName -> true ; - io__set_output_stream(MapStream, OldStream, !IO), - prog_out__write_sym_name(ModuleName, !IO), - io__write_string("\t", !IO), - io__write_string(FileName, !IO), - io__nl(!IO), - io__set_output_stream(OldStream, _, !IO) + io.set_output_stream(MapStream, OldStream, !IO), + prog_out.write_sym_name(ModuleName, !IO), + io.write_string("\t", !IO), + io.write_string(FileName, !IO), + io.nl(!IO), + io.set_output_stream(OldStream, _, !IO) ) ; MaybeModuleName = no diff --git a/compiler/special_pred.m b/compiler/special_pred.m index 870ad5c2b..0cf3bb561 100644 --- a/compiler/special_pred.m +++ b/compiler/special_pred.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1995-2000,2002-2005 The University of Melbourne. +% Copyright (C) 1995-2000,2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__special_pred. +:- module hlds.special_pred. :- interface. :- import_module hlds.hlds_data. @@ -53,7 +53,7 @@ % argument specifies the type that this special predicate is for. Note that % this gets called after the polymorphism.m pass, so type_info arguments % may have been inserted at the start; hence we find the type at a known - % position from the end of the list (by using list__reverse). + % position from the end of the list (by using list.reverse). % % Currently for most of the special predicates the type variable can be % found in the last type argument, except for index, for which it is the @@ -164,13 +164,13 @@ special_pred_interface(spec_pred_init, Type, [Type], [InAny], det) :- InAny = out_any_mode. special_pred_get_type(spec_pred_unify, Types, T) :- - list__reverse(Types, [T | _]). + list.reverse(Types, [T | _]). special_pred_get_type(spec_pred_index, Types, T) :- - list__reverse(Types, [_, T | _]). + list.reverse(Types, [_, T | _]). special_pred_get_type(spec_pred_compare, Types, T) :- - list__reverse(Types, [T | _]). + list.reverse(Types, [T | _]). special_pred_get_type(spec_pred_init, Types, T) :- - list__reverse(Types, [T | _]). + list.reverse(Types, [T | _]). special_pred_get_type_det(SpecialId, ArgTypes, Type) :- ( special_pred_get_type(SpecialId, ArgTypes, TypePrime) -> @@ -195,9 +195,9 @@ special_pred_is_generated_lazily(ModuleInfo, TypeCtor) :- ; is_introduced_type_info_type_category(TypeCategory) = yes ), module_info_get_type_table(ModuleInfo, Types), - map__search(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, Body), - hlds_data__get_type_defn_status(TypeDefn, Status), + map.search(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, Body), + hlds_data.get_type_defn_status(TypeDefn, Status), special_pred_is_generated_lazily_2(ModuleInfo, TypeCtor, Body, Status) ). @@ -229,13 +229,13 @@ special_pred_is_generated_lazily_2(ModuleInfo, _TypeCtor, Body, Status) :- status_defined_in_this_module(Status, no) ; module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, special_preds, no) + globals.lookup_bool_option(Globals, special_preds, no) ), % We can't generate clauses for unification predicates for foreign types % lazily because they call the polymorphic procedure - % private_builtin__nyi_foreign_type_unify. - % polymorphism__process_generated_pred can't handle calls to polymorphic + % private_builtin.nyi_foreign_type_unify. + % polymorphism.process_generated_pred can't handle calls to polymorphic % procedures after the initial polymorphism pass. % Body \= foreign_type(_), @@ -258,7 +258,7 @@ special_pred_for_type_needs_typecheck(ModuleInfo, SpecialPredId, Body) :- ; SpecialPredId \= spec_pred_init, Ctors = Body ^ du_type_ctors, - list__member(Ctor, Ctors), + list.member(Ctor, Ctors), Ctor = ctor(ExistQTVars, _, _, _), ExistQTVars \= [] ; @@ -298,7 +298,7 @@ is_builtin_types_special_preds_defined_in_mercury(TypeCtor, TypeName) :- % compiler_generated_rtti_for_builtins(ModuleInfo) :- module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( Target = il ; Target = java ). %-----------------------------------------------------------------------------% diff --git a/compiler/stack_alloc.m b/compiler/stack_alloc.m index 3129786cd..2c5a28d89 100644 --- a/compiler/stack_alloc.m +++ b/compiler/stack_alloc.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2002-2005 The University of Melbourne. +% Copyright (C) 2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -22,7 +22,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__stack_alloc. +:- module ll_backend.stack_alloc. :- interface. :- import_module hlds.hlds_module. @@ -72,22 +72,22 @@ allocate_stack_slots_in_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :- initial_liveness(!.ProcInfo, PredId, ModuleInfo, Liveness0), module_info_pred_info(ModuleInfo, PredId, PredInfo), module_info_get_globals(ModuleInfo, Globals), - globals__get_trace_level(Globals, TraceLevel), + globals.get_trace_level(Globals, TraceLevel), ( eff_trace_level_needs_input_vars(PredInfo, !.ProcInfo, TraceLevel) = yes -> - trace__fail_vars(ModuleInfo, !.ProcInfo, FailVars) + trace.fail_vars(ModuleInfo, !.ProcInfo, FailVars) ; - set__init(FailVars) + set.init(FailVars) ), body_should_use_typeinfo_liveness(PredInfo, Globals, TypeInfoLiveness), - globals__lookup_bool_option(Globals, opt_no_return_calls, + globals.lookup_bool_option(Globals, opt_no_return_calls, OptNoReturnCalls), AllocData = alloc_data(ModuleInfo, !.ProcInfo, TypeInfoLiveness, OptNoReturnCalls), - set__init(NondetLiveness0), - SimpleStackAlloc0 = stack_alloc(set__make_singleton_set(FailVars)), + set.init(NondetLiveness0), + SimpleStackAlloc0 = stack_alloc(set.make_singleton_set(FailVars)), proc_info_goal(!.ProcInfo, Goal0), build_live_sets_in_goal(Goal0, Goal, FailVars, AllocData, SimpleStackAlloc0, SimpleStackAlloc, Liveness0, _Liveness, @@ -95,13 +95,13 @@ allocate_stack_slots_in_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :- proc_info_set_goal(Goal, !ProcInfo), SimpleStackAlloc = stack_alloc(LiveSets0), - trace__do_we_need_maxfr_slot(Globals, PredInfo, !ProcInfo), - trace__reserved_slots(ModuleInfo, PredInfo, !.ProcInfo, Globals, + trace.do_we_need_maxfr_slot(Globals, PredInfo, !ProcInfo), + trace.reserved_slots(ModuleInfo, PredInfo, !.ProcInfo, Globals, NumReservedSlots, MaybeReservedVarInfo), ( MaybeReservedVarInfo = yes(ResVar - _), - set__singleton_set(ResVarSet, ResVar), - set__insert(LiveSets0, ResVarSet, LiveSets1) + set.singleton_set(ResVarSet, ResVar), + set.insert(LiveSets0, ResVarSet, LiveSets1) ; MaybeReservedVarInfo = no, LiveSets1 = LiveSets0 @@ -109,8 +109,8 @@ allocate_stack_slots_in_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :- proc_info_vartypes(!.ProcInfo, VarTypes), filter_out_dummy_values(ModuleInfo, VarTypes, LiveSets1, LiveSets, DummyVars), - graph_colour__group_elements(LiveSets, ColourSets), - set__to_sorted_list(ColourSets, ColourList), + graph_colour.group_elements(LiveSets, ColourSets), + set.to_sorted_list(ColourSets, ColourList), proc_info_interface_code_model(!.ProcInfo, CodeModel), allocate_stack_slots(ColourList, CodeModel, NumReservedSlots, MaybeReservedVarInfo, StackSlots1), @@ -123,11 +123,11 @@ allocate_stack_slots_in_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :- list(prog_var)::out) is det. filter_out_dummy_values(ModuleInfo, VarTypes, LiveSet0, LiveSet, DummyVars) :- - set__to_sorted_list(LiveSet0, LiveList0), + set.to_sorted_list(LiveSet0, LiveList0), filter_out_dummy_values_2(ModuleInfo, VarTypes, LiveList0, LiveList, - set__init, Dummies), - set__list_to_set(LiveList, LiveSet), - set__to_sorted_list(Dummies, DummyVars). + set.init, Dummies), + set.list_to_set(LiveList, LiveSet), + set.to_sorted_list(Dummies, DummyVars). :- pred filter_out_dummy_values_2(module_info::in, vartypes::in, list(set(prog_var))::in, list(set(prog_var))::out, @@ -138,10 +138,10 @@ filter_out_dummy_values_2(ModuleInfo, VarTypes, [LiveSet0 | LiveSets0], LiveSets, !Dummies) :- filter_out_dummy_values_2(ModuleInfo, VarTypes, LiveSets0, LiveSets1, !Dummies), - set__to_sorted_list(LiveSet0, LiveList0), - list__filter(var_is_of_dummy_type(ModuleInfo, VarTypes), LiveList0, + set.to_sorted_list(LiveSet0, LiveList0), + list.filter(var_is_of_dummy_type(ModuleInfo, VarTypes), LiveList0, DummyVars, NonDummyVars), - set__insert_list(!.Dummies, DummyVars, !:Dummies), + set.insert_list(!.Dummies, DummyVars, !:Dummies), ( NonDummyVars = [], LiveSets = LiveSets1 @@ -170,9 +170,9 @@ filter_out_dummy_values_2(ModuleInfo, VarTypes, alloc_at_call_site(NeedAtCall, _GoalInfo, StackAlloc0, StackAlloc) :- NeedAtCall = need_across_call(ForwardVars, ResumeVars, NondetLiveVars), - LiveSet = set__union_list([ForwardVars, ResumeVars, NondetLiveVars]), + LiveSet = set.union_list([ForwardVars, ResumeVars, NondetLiveVars]), StackAlloc0 = stack_alloc(LiveSets0), - LiveSets = set__insert(LiveSets0, LiveSet), + LiveSets = set.insert(LiveSets0, LiveSet), StackAlloc = stack_alloc(LiveSets). :- pred alloc_at_resume_site(need_in_resume::in, hlds_goal_info::in, @@ -185,9 +185,9 @@ alloc_at_resume_site(NeedAtResume, _GoalInfo, StackAlloc0, StackAlloc) :- StackAlloc = StackAlloc0 ; ResumeOnStack = yes, - LiveSet = set__union(ResumeVars, NondetLiveVars), + LiveSet = set.union(ResumeVars, NondetLiveVars), StackAlloc0 = stack_alloc(LiveSets0), - LiveSets = set__insert(LiveSets0, LiveSet), + LiveSets = set.insert(LiveSets0, LiveSet), StackAlloc = stack_alloc(LiveSets) ). @@ -197,7 +197,7 @@ alloc_at_resume_site(NeedAtResume, _GoalInfo, StackAlloc0, StackAlloc) :- alloc_at_par_conj(NeedParConj, _GoalInfo, StackAlloc0, StackAlloc) :- NeedParConj = need_in_par_conj(StackVars), StackAlloc0 = stack_alloc(LiveSets0), - LiveSets = set__insert(LiveSets0, StackVars), + LiveSets = set.insert(LiveSets0, StackVars), StackAlloc = stack_alloc(LiveSets). %-----------------------------------------------------------------------------% @@ -209,10 +209,10 @@ alloc_at_par_conj(NeedParConj, _GoalInfo, StackAlloc0, StackAlloc) :- allocate_stack_slots(ColourList, CodeModel, NumReservedSlots, MaybeReservedVarInfo, StackSlots) :- % The reserved slots are referred to by fixed number - % (e.g. framevar(1)) in trace__setup. + % (e.g. framevar(1)) in trace.setup. FirstVarSlot = NumReservedSlots + 1, allocate_stack_slots_2(ColourList, CodeModel, FirstVarSlot, - MaybeReservedVarInfo, map__init, StackSlots). + MaybeReservedVarInfo, map.init, StackSlots). :- pred allocate_stack_slots_2(list(set(prog_var))::in, code_model::in, int::in, maybe(pair(prog_var, int))::in, @@ -223,7 +223,7 @@ allocate_stack_slots_2([Vars | VarSets], CodeModel, N0, MaybeReservedVarInfo, !StackSlots) :- ( MaybeReservedVarInfo = yes(ResVar - ResSlotNum), - set__member(ResVar, Vars) + set.member(ResVar, Vars) -> SlotNum = ResSlotNum, N1 = N0 @@ -231,7 +231,7 @@ allocate_stack_slots_2([Vars | VarSets], CodeModel, N0, MaybeReservedVarInfo, SlotNum = N0, N1 = N0 + 1 ), - set__to_sorted_list(Vars, VarList), + set.to_sorted_list(Vars, VarList), allocate_same_stack_slot(VarList, CodeModel, SlotNum, !StackSlots), allocate_stack_slots_2(VarSets, CodeModel, N1, MaybeReservedVarInfo, !StackSlots). @@ -246,7 +246,7 @@ allocate_same_stack_slot([Var | Vars], CodeModel, Slot, !StackSlots) :- ; Locn = det_slot(Slot) ), - svmap__det_insert(Var, Locn, !StackSlots), + svmap.det_insert(Var, Locn, !StackSlots), allocate_same_stack_slot(Vars, CodeModel, Slot, !StackSlots). % We must not allocate the same stack slot to dummy variables. If we do, diff --git a/compiler/stack_layout.m b/compiler/stack_layout.m index 59ef0e637..0526c311b 100644 --- a/compiler/stack_layout.m +++ b/compiler/stack_layout.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 1997-2005 University of Melbourne. +% Copyright (C) 1997-2006 University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -25,7 +25,7 @@ %---------------------------------------------------------------------------% -:- module ll_backend__stack_layout. +:- module ll_backend.stack_layout. :- interface. :- import_module hlds.hlds_module. @@ -113,20 +113,20 @@ generate_llds(ModuleInfo0, !GlobalData, Layouts, LayoutLabels) :- global_data_get_all_proc_layouts(!.GlobalData, ProcLayoutList), module_info_get_globals(ModuleInfo0, Globals), - globals__lookup_bool_option(Globals, agc_stack_layout, AgcLayout), - globals__lookup_bool_option(Globals, trace_stack_layout, TraceLayout), - globals__lookup_bool_option(Globals, procid_stack_layout, + globals.lookup_bool_option(Globals, agc_stack_layout, AgcLayout), + globals.lookup_bool_option(Globals, trace_stack_layout, TraceLayout), + globals.lookup_bool_option(Globals, procid_stack_layout, ProcIdLayout), - globals__get_trace_level(Globals, TraceLevel), - globals__get_trace_suppress(Globals, TraceSuppress), - globals__have_static_code_addresses(Globals, StaticCodeAddr), - map__init(LayoutLabels0), + globals.get_trace_level(Globals, TraceLevel), + globals.get_trace_suppress(Globals, TraceSuppress), + globals.have_static_code_addresses(Globals, StaticCodeAddr), + map.init(LayoutLabels0), - map__init(StringMap0), - map__init(LabelTables0), + map.init(StringMap0), + map.init(LabelTables0), StringTable0 = string_table(StringMap0, [], 0), global_data_get_static_cell_info(!.GlobalData, StaticCellInfo0), - counter__init(1, LabelCounter0), + counter.init(1, LabelCounter0), LayoutInfo0 = stack_layout_info(ModuleInfo0, AgcLayout, TraceLayout, ProcIdLayout, StaticCodeAddr, LabelCounter0, [], [], [], LayoutLabels0, [], @@ -134,9 +134,9 @@ generate_llds(ModuleInfo0, !GlobalData, Layouts, LayoutLabels) :- lookup_string_in_table("", _, LayoutInfo0, LayoutInfo1), lookup_string_in_table("", _, LayoutInfo1, LayoutInfo2), - list__foldl(construct_layouts, ProcLayoutList, LayoutInfo2, LayoutInfo), + list.foldl(construct_layouts, ProcLayoutList, LayoutInfo2, LayoutInfo), LabelsCounter = LayoutInfo ^ label_counter, - counter__allocate(NumLabels, LabelsCounter, _), + counter.allocate(NumLabels, LabelsCounter, _), TableIoDecls = LayoutInfo ^ table_infos, ProcLayouts = LayoutInfo ^ proc_layouts, InternalLayouts = LayoutInfo ^ internal_layouts, @@ -147,20 +147,20 @@ generate_llds(ModuleInfo0, !GlobalData, Layouts, LayoutLabels) :- global_data_set_static_cell_info(LayoutInfo ^ static_cell_info, !GlobalData), StringTable = string_table(_, RevStringList, StringOffset), - list__reverse(RevStringList, StringList), + list.reverse(RevStringList, StringList), concat_string_list(StringList, StringOffset, ConcatStrings), - list__condense([TableIoDecls, ProcLayouts, InternalLayouts], Layouts0), + list.condense([TableIoDecls, ProcLayouts, InternalLayouts], Layouts0), ( TraceLayout = yes, module_info_get_name(ModuleInfo0, ModuleName), - globals__lookup_bool_option(Globals, rtti_line_numbers, LineNumbers), + globals.lookup_bool_option(Globals, rtti_line_numbers, LineNumbers), ( LineNumbers = yes, EffLabelTables = LabelTables ; LineNumbers = no, - map__init(EffLabelTables) + map.init(EffLabelTables) ), format_label_tables(EffLabelTables, SourceFileLayouts), SuppressedEvents = encode_suppressed_events(TraceSuppress), @@ -241,13 +241,13 @@ concat_string_list(Strings, Len, string_with_0s(Result)) :- % So we check that. concat_string_list_2(StringsList, _Len, StringWithNulls) :- ( - char__to_int(NullChar, 0), - NullCharString = string__char_to_string(NullChar), - string__length(NullCharString, 1) + char.to_int(NullChar, 0), + NullCharString = string.char_to_string(NullChar), + string.length(NullCharString, 1) -> - StringsWithNullsList = list__map(func(S) = S ++ NullCharString, + StringsWithNullsList = list.map(func(S) = S ++ NullCharString, StringsList), - StringWithNulls = string__append_list(StringsWithNullsList) + StringWithNulls = string.append_list(StringsWithNullsList) ; % the Mercury implementation's string representation % doesn't support strings containing null characters @@ -260,8 +260,8 @@ concat_string_list_2(StringsList, _Len, StringWithNulls) :- list(file_layout_data)::out) is det. format_label_tables(LabelTableMap, SourceFileLayouts) :- - map__to_assoc_list(LabelTableMap, LabelTableList), - list__map(format_label_table, LabelTableList, SourceFileLayouts). + map.to_assoc_list(LabelTableMap, LabelTableList), + list.map(format_label_table, LabelTableList, SourceFileLayouts). :- pred format_label_table(pair(string, label_table)::in, file_layout_data::out) is det. @@ -269,23 +269,23 @@ format_label_tables(LabelTableMap, SourceFileLayouts) :- format_label_table(FileName - LineNoMap, file_layout_data(FileName, FilteredList)) :- % This step should produce a list ordered on line numbers. - map__to_assoc_list(LineNoMap, LineNoList), + map.to_assoc_list(LineNoMap, LineNoList), % And this step should preserve that order. flatten_label_table(LineNoList, [], FlatLineNoList), Filter = (pred(LineNoInfo::in, FilteredLineNoInfo::out) is det :- LineNoInfo = LineNo - (Label - _IsReturn), FilteredLineNoInfo = LineNo - Label ), - list__map(Filter, FlatLineNoList, FilteredList). + list.map(Filter, FlatLineNoList, FilteredList). :- pred flatten_label_table(assoc_list(int, list(line_no_info))::in, assoc_list(int, line_no_info)::in, assoc_list(int, line_no_info)::out) is det. flatten_label_table([], RevList, List) :- - list__reverse(RevList, List). + list.reverse(RevList, List). flatten_label_table([LineNo - LinesInfos | Lines], RevList0, List) :- - list__foldl(add_line_no(LineNo), LinesInfos, RevList0, RevList1), + list.foldl(add_line_no(LineNo), LinesInfos, RevList0, RevList1), flatten_label_table(Lines, RevList1, List). :- pred add_line_no(int::in, line_no_info::in, @@ -328,12 +328,12 @@ construct_layouts(ProcLayoutInfo, !Info) :- MaybeTableIoDecl, _NeedsAllNames, _MaybeDeepProfInfo), - map__to_assoc_list(InternalMap, Internals), + map.to_assoc_list(InternalMap, Internals), compute_var_number_map(HeadVars, VarSet, Internals, Goal, VarNumMap), ProcLabel = get_proc_label(EntryLabel), get_procid_stack_layout(!.Info, ProcIdLayout0), - bool__or(ProcIdLayout0, ForceProcIdLayout, ProcIdLayout), + bool.or(ProcIdLayout0, ForceProcIdLayout, ProcIdLayout), ( ( ProcIdLayout = yes ; MaybeTableIoDecl = yes(_) @@ -350,14 +350,14 @@ construct_layouts(ProcLayoutInfo, !Info) :- ), valid_proc_layout(ProcLayoutInfo) -> - list__map_foldl( + list.map_foldl( construct_internal_layout(ProcLabel, ProcLayoutName, VarNumMap), Internals, InternalLayouts, !Info) ; InternalLayouts = [] ), get_label_tables(!.Info, LabelTables0), - list__foldl(update_label_table, InternalLayouts, + list.foldl(update_label_table, InternalLayouts, LabelTables0, LabelTables), set_label_tables(LabelTables, !Info), construct_proc_layout(ProcLayoutInfo, Kind, VarNumMap, !Info). @@ -400,25 +400,25 @@ update_label_table({ProcLabel, LabelNum, LabelVars, InternalInfo}, update_label_table_2(ProcLabel, LabelNum, LabelVars, Context, IsReturn, !LabelTables) :- - term__context_file(Context, File), - term__context_line(Context, Line), - ( map__search(!.LabelTables, File, LabelTable0) -> + term.context_file(Context, File), + term.context_line(Context, Line), + ( map.search(!.LabelTables, File, LabelTable0) -> LabelLayout = label_layout(ProcLabel, LabelNum, LabelVars), - ( map__search(LabelTable0, Line, LineInfo0) -> + ( map.search(LabelTable0, Line, LineInfo0) -> LineInfo = [LabelLayout - IsReturn | LineInfo0], - map__det_update(LabelTable0, Line, LineInfo, LabelTable), - svmap__det_update(File, LabelTable, !LabelTables) + map.det_update(LabelTable0, Line, LineInfo, LabelTable), + svmap.det_update(File, LabelTable, !LabelTables) ; LineInfo = [LabelLayout - IsReturn], - map__det_insert(LabelTable0, Line, LineInfo, LabelTable), - svmap__det_update(File, LabelTable, !LabelTables) + map.det_insert(LabelTable0, Line, LineInfo, LabelTable), + svmap.det_update(File, LabelTable, !LabelTables) ) ; context_is_valid(Context) -> - map__init(LabelTable0), + map.init(LabelTable0), LabelLayout = label_layout(ProcLabel, LabelNum, LabelVars), LineInfo = [LabelLayout - IsReturn], - map__det_insert(LabelTable0, Line, LineInfo, LabelTable), - svmap__det_insert(File, LabelTable, !LabelTables) + map.det_insert(LabelTable0, Line, LineInfo, LabelTable), + svmap.det_insert(File, LabelTable, !LabelTables) ; % We don't have a valid context for this label, % so we don't enter it into any tables. @@ -445,8 +445,8 @@ find_valid_return_context([TargetContext | TargetContexts], :- pred context_is_valid(prog_context::in) is semidet. context_is_valid(Context) :- - term__context_file(Context, File), - term__context_line(Context, Line), + term.context_file(Context, File), + term.context_line(Context, Line), File \= "", Line > 0. @@ -584,14 +584,14 @@ construct_trace_layout(RttiProcLabel, EvalMethod, EffTraceLevel, MaybeTableInfo, NeedsAllNames, VarNumMap, ExecTrace, !Info) :- construct_var_name_vector(VarNumMap, NeedsAllNames, MaxVarNum, VarNameVector, !Info), - list__map(convert_var_to_int(VarNumMap), HeadVars, HeadVarNumVector), + list.map(convert_var_to_int(VarNumMap), HeadVars, HeadVarNumVector), ModuleInfo = !.Info ^ module_info, ( NeedGoalRep = no, ProcBytes = [] ; NeedGoalRep = yes, - prog_rep__represent_proc(HeadVars, Goal, InstMap, VarTypes, VarNumMap, + prog_rep.represent_proc(HeadVars, Goal, InstMap, VarTypes, VarNumMap, ModuleInfo, !Info, ProcBytes) ), ( @@ -654,15 +654,15 @@ encode_exec_trace_flags(ModuleInfo, HeadVars, ArgModes, VarTypes, !Flags) :- construct_var_name_vector(VarNumMap, NeedsAllNames, MaxVarNum, Offsets, !Info) :- - map__values(VarNumMap, VarNames0), + map.values(VarNumMap, VarNames0), ( NeedsAllNames = yes, VarNames = VarNames0 ; NeedsAllNames = no, - list__filter(var_has_name, VarNames0, VarNames) + list.filter(var_has_name, VarNames0, VarNames) ), - list__sort(VarNames, SortedVarNames), + list.sort(VarNames, SortedVarNames), ( SortedVarNames = [FirstVarNum - _ | _] -> MaxVarNum0 = FirstVarNum, construct_var_name_rvals(SortedVarNames, 1, MaxVarNum0, MaxVarNum, @@ -705,15 +705,15 @@ construct_var_name_rvals([Var - Name | VarNamesTail], CurNum, compute_var_number_map(HeadVars, VarSet, Internals, Goal, VarNumMap) :- some [!VarNumMap, !Counter] ( - !:VarNumMap = map__init, - !:Counter = counter__init(1), % to match term__var_supply_init - goal_util__goal_vars(Goal, GoalVarSet), - set__to_sorted_list(GoalVarSet, GoalVars), - list__foldl2(add_var_to_var_number_map(VarSet), GoalVars, + !:VarNumMap = map.init, + !:Counter = counter.init(1), % to match term.var_supply_init + goal_util.goal_vars(Goal, GoalVarSet), + set.to_sorted_list(GoalVarSet, GoalVars), + list.foldl2(add_var_to_var_number_map(VarSet), GoalVars, !VarNumMap, !Counter), - list__foldl2(add_var_to_var_number_map(VarSet), HeadVars, + list.foldl2(add_var_to_var_number_map(VarSet), HeadVars, !VarNumMap, !Counter), - list__foldl2(internal_var_number_map, Internals, !VarNumMap, + list.foldl2(internal_var_number_map, Internals, !VarNumMap, !.Counter, _), VarNumMap = !.VarNumMap ). @@ -749,20 +749,20 @@ internal_var_number_map(_Label - Internal, !VarNumMap, !Counter) :- label_layout_var_number_map(LabelLayout, !VarNumMap, !Counter) :- LabelLayout = layout_label_info(VarInfoSet, _), - VarInfos = set__to_sorted_list(VarInfoSet), + VarInfos = set.to_sorted_list(VarInfoSet), FindVar = (pred(VarInfo::in, Var - Name::out) is semidet :- VarInfo = layout_var_info(_, LiveValueType, _), LiveValueType = var(Var, Name, _, _) ), - list__filter_map(FindVar, VarInfos, VarsNames), - list__foldl2(add_named_var_to_var_number_map, VarsNames, + list.filter_map(FindVar, VarInfos, VarsNames), + list.foldl2(add_named_var_to_var_number_map, VarsNames, !VarNumMap, !Counter). :- pred add_var_to_var_number_map(prog_varset::in, prog_var::in, var_num_map::in, var_num_map::out, counter::in, counter::out) is det. add_var_to_var_number_map(VarSet, Var, !VarNumMap, !Counter) :- - ( varset__search_name(VarSet, Var, VarName) -> + ( varset.search_name(VarSet, Var, VarName) -> Name = VarName ; Name = "" @@ -773,12 +773,12 @@ add_var_to_var_number_map(VarSet, Var, !VarNumMap, !Counter) :- var_num_map::in, var_num_map::out, counter::in, counter::out) is det. add_named_var_to_var_number_map(Var - Name, !VarNumMap, !Counter) :- - ( map__search(!.VarNumMap, Var, _) -> + ( map.search(!.VarNumMap, Var, _) -> % Name shouldn't differ from the name recorded in !.VarNumMap. true ; - counter__allocate(VarNum, !Counter), - map__det_insert(!.VarNumMap, Var, VarNum - Name, !:VarNumMap) + counter.allocate(VarNum, !Counter), + map.det_insert(!.VarNumMap, Var, VarNum - Name, !:VarNumMap) ). %---------------------------------------------------------------------------% @@ -796,16 +796,16 @@ construct_internal_layout(ProcLabel, ProcLayoutName, VarNumMap, Internal = internal_layout_info(Trace, Resume, Return), ( Trace = no, - set__init(TraceLiveVarSet), - map__init(TraceTypeVarMap) + set.init(TraceLiveVarSet), + map.init(TraceTypeVarMap) ; Trace = yes(trace_port_layout_info(_,_,_,_, TraceLayout)), TraceLayout = layout_label_info(TraceLiveVarSet, TraceTypeVarMap) ), ( Resume = no, - set__init(ResumeLiveVarSet), - map__init(ResumeTypeVarMap) + set.init(ResumeLiveVarSet), + map.init(ResumeTypeVarMap) ; Resume = yes(ResumeLayout), ResumeLayout = layout_label_info(ResumeLiveVarSet, ResumeTypeVarMap) @@ -857,8 +857,8 @@ construct_internal_layout(ProcLabel, ProcLayoutName, VarNumMap, get_agc_stack_layout(!.Info, AgcStackLayout), ( Return = no, - set__init(ReturnLiveVarSet), - map__init(ReturnTypeVarMap) + set.init(ReturnLiveVarSet), + map.init(ReturnTypeVarMap) ; Return = yes(return_layout_info(_, ReturnLayout)), ReturnLayout = layout_label_info(ReturnLiveVarSet0, ReturnTypeVarMap0), @@ -872,11 +872,11 @@ construct_internal_layout(ProcLabel, ProcLayoutName, VarNumMap, % tracing, so we are interested only in (a) variables, not % temporaries, (b) only named variables, and (c) only those % on the stack, not the return values. - set__to_sorted_list(ReturnLiveVarSet0, ReturnLiveVarList0), + set.to_sorted_list(ReturnLiveVarSet0, ReturnLiveVarList0), select_trace_return( ReturnLiveVarList0, ReturnTypeVarMap0, ReturnLiveVarList, ReturnTypeVarMap), - set__list_to_set(ReturnLiveVarList, ReturnLiveVarSet) + set.list_to_set(ReturnLiveVarList, ReturnLiveVarSet) ) ), ( @@ -888,11 +888,11 @@ construct_internal_layout(ProcLabel, ProcLayoutName, VarNumMap, LabelVars = label_has_no_var_info ; % XXX Ignore differences in insts inside layout_var_infos. - set__union(TraceLiveVarSet, ResumeLiveVarSet, LiveVarSet0), - set__union(LiveVarSet0, ReturnLiveVarSet, LiveVarSet), - map__union(set__intersect, TraceTypeVarMap, ResumeTypeVarMap, + set.union(TraceLiveVarSet, ResumeLiveVarSet, LiveVarSet0), + set.union(LiveVarSet0, ReturnLiveVarSet, LiveVarSet), + map.union(set.intersect, TraceTypeVarMap, ResumeTypeVarMap, TypeVarMap0), - map__union(set__intersect, TypeVarMap0, ReturnTypeVarMap, TypeVarMap), + map.union(set.intersect, TypeVarMap0, ReturnTypeVarMap, TypeVarMap), construct_livelval_rvals(LiveVarSet, VarNumMap, TypeVarMap, EncodedLength, LiveValRval, NamesRval, TypeParamRval, !Info), VarInfo = label_var_info(EncodedLength, LiveValRval, NamesRval, @@ -933,7 +933,7 @@ construct_internal_layout(ProcLabel, ProcLayoutName, VarNumMap, construct_livelval_rvals(LiveLvalSet, VarNumMap, TVarLocnMap, EncodedLength, LiveValRval, NamesRval, TypeParamRval, !Info) :- - set__to_sorted_list(LiveLvalSet, LiveLvals), + set.to_sorted_list(LiveLvalSet, LiveLvals), sort_livevals(LiveLvals, SortedLiveLvals), construct_liveval_arrays(SortedLiveLvals, VarNumMap, EncodedLength, LiveValRval, NamesRval, !Info), @@ -946,7 +946,7 @@ construct_livelval_rvals(LiveLvalSet, VarNumMap, TVarLocnMap, rval::out, static_cell_info::in, static_cell_info::out) is det. construct_tvar_vector(TVarLocnMap, TypeParamRval, !StaticCellInfo) :- - ( map__is_empty(TVarLocnMap) -> + ( map.is_empty(TVarLocnMap) -> TypeParamRval = const(int_const(0)) ; construct_tvar_rvals(TVarLocnMap, Vector), @@ -958,9 +958,9 @@ construct_tvar_vector(TVarLocnMap, TypeParamRval, !StaticCellInfo) :- assoc_list(rval, llds_type)::out) is det. construct_tvar_rvals(TVarLocnMap, Vector) :- - map__to_assoc_list(TVarLocnMap, TVarLocns), + map.to_assoc_list(TVarLocnMap, TVarLocns), construct_type_param_locn_vector(TVarLocns, 1, TypeParamLocs), - list__length(TypeParamLocs, TypeParamsLength), + list.length(TypeParamLocs, TypeParamsLength), LengthRval = const(int_const(TypeParamsLength)), Vector = [LengthRval - uint_least32 | TypeParamLocs]. @@ -985,7 +985,7 @@ select_trace_return(Infos, TVars, TraceReturnInfos, TVars) :- ( Locn = direct(Lval) ; Locn = indirect(Lval, _)), ( Lval = stackvar(_) ; Lval = framevar(_) ) ), - list__filter(IsNamedReturnVar, Infos, TraceReturnInfos). + list.filter(IsNamedReturnVar, Infos, TraceReturnInfos). % Given a list of layout_var_infos, put the ones that tracing can be % interested in (whether at an internal port or for uplevel printing) @@ -1005,7 +1005,7 @@ sort_livevals(OrigInfos, FinalInfos) :- LvalType = var(_, Name, _, _), Name \= "" ), - list__filter(IsNamedVar, OrigInfos, NamedVarInfos0, OtherInfos0), + list.filter(IsNamedVar, OrigInfos, NamedVarInfos0, OtherInfos0), CompareVarInfos = (pred(Var1::in, Var2::in, Result::out) is det :- Var1 = layout_var_info(Lval1, LiveType1, _), Var2 = layout_var_info(Lval2, LiveType2, _), @@ -1018,9 +1018,9 @@ sort_livevals(OrigInfos, FinalInfos) :- Result = NameResult ) ), - list__sort(CompareVarInfos, NamedVarInfos0, NamedVarInfos), - list__sort(CompareVarInfos, OtherInfos0, OtherInfos), - list__append(NamedVarInfos, OtherInfos, FinalInfos). + list.sort(CompareVarInfos, NamedVarInfos0, NamedVarInfos), + list.sort(CompareVarInfos, OtherInfos0, OtherInfos), + list.append(NamedVarInfos, OtherInfos, FinalInfos). :- pred get_name_from_live_value_type(live_value_type::in, string::out) is det. @@ -1046,10 +1046,10 @@ get_name_from_live_value_type(LiveType, Name) :- construct_type_param_locn_vector([], _, []). construct_type_param_locn_vector([TVar - Locns | TVarLocns], CurSlot, Vector) :- - term__var_to_int(TVar, TVarNum), + term.var_to_int(TVar, TVarNum), NextSlot = CurSlot + 1, ( TVarNum = CurSlot -> - ( set__remove_least(Locns, LeastLocn, _) -> + ( set.remove_least(Locns, LeastLocn, _) -> Locn = LeastLocn ; unexpected(this_file, "tvar has empty set of locations") @@ -1094,13 +1094,13 @@ construct_type_param_locn_vector([TVar - Locns | TVarLocns], CurSlot, construct_liveval_arrays(VarInfos, VarNumMap, EncodedLength, TypeLocnVector, NumVector, !Info) :- - int__pow(2, short_count_bits, BytesLimit), + int.pow(2, short_count_bits, BytesLimit), construct_liveval_array_infos(VarInfos, VarNumMap, 0, BytesLimit, IntArrayInfo, ByteArrayInfo, !Info), - list__length(IntArrayInfo, IntArrayLength), - list__length(ByteArrayInfo, ByteArrayLength), - list__append(IntArrayInfo, ByteArrayInfo, AllArrayInfo), + list.length(IntArrayInfo, IntArrayLength), + list.length(ByteArrayInfo, ByteArrayLength), + list.append(IntArrayInfo, ByteArrayInfo, AllArrayInfo), EncodedLength = IntArrayLength << short_count_bits + ByteArrayLength, @@ -1115,13 +1115,13 @@ construct_liveval_arrays(VarInfos, VarNumMap, EncodedLength, NumRvals = [NumRval | NumRvals0] ), - list__map(SelectTypes, AllArrayInfo, AllTypeRvalsTypes), - list__map(SelectLocns, IntArrayInfo, IntLocns), - list__map(associate_type(uint_least32), IntLocns, IntLocnsTypes), - list__map(SelectLocns, ByteArrayInfo, ByteLocns), - list__map(associate_type(uint_least8), ByteLocns, ByteLocnsTypes), - list__append(IntLocnsTypes, ByteLocnsTypes, AllLocnsTypes), - list__append(AllTypeRvalsTypes, AllLocnsTypes, TypeLocnVectorRvalsTypes), + list.map(SelectTypes, AllArrayInfo, AllTypeRvalsTypes), + list.map(SelectLocns, IntArrayInfo, IntLocns), + list.map(associate_type(uint_least32), IntLocns, IntLocnsTypes), + list.map(SelectLocns, ByteArrayInfo, ByteLocns), + list.map(associate_type(uint_least8), ByteLocns, ByteLocnsTypes), + list.append(IntLocnsTypes, ByteLocnsTypes, AllLocnsTypes), + list.append(AllTypeRvalsTypes, AllLocnsTypes, TypeLocnVectorRvalsTypes), get_static_cell_info(!.Info, StaticCellInfo0), add_static_cell(TypeLocnVectorRvalsTypes, TypeLocnVectorAddr, StaticCellInfo0, StaticCellInfo1), @@ -1131,9 +1131,9 @@ construct_liveval_arrays(VarInfos, VarNumMap, EncodedLength, get_trace_stack_layout(!.Info, TraceStackLayout), ( TraceStackLayout = yes, - list__foldl(AddRevNums, AllArrayInfo, [], RevVarNumRvals), - list__reverse(RevVarNumRvals, VarNumRvals), - list__map(associate_type(uint_least16), VarNumRvals, VarNumRvalsTypes), + list.foldl(AddRevNums, AllArrayInfo, [], RevVarNumRvals), + list.reverse(RevVarNumRvals, VarNumRvals), + list.map(associate_type(uint_least16), VarNumRvals, VarNumRvalsTypes), get_static_cell_info(!.Info, StaticCellInfo2), add_static_cell(VarNumRvalsTypes, NumVectorAddr, StaticCellInfo2, StaticCellInfo), @@ -1205,13 +1205,13 @@ construct_liveval_num_rval(VarNumMap, int::out) is det. convert_var_to_int(VarNumMap, Var, VarNum) :- - map__lookup(VarNumMap, Var, VarNum0 - _), + map.lookup(VarNumMap, Var, VarNum0 - _), % The variable number has to fit into two bytes. We reserve the largest % such number (Limit) to mean that the variable number is too large % to be represented. This ought not to happen, since compilation % would be glacial at best for procedures with that many variables. Limit = (1 << (2 * byte_bits)) - 1, - int__min(VarNum0, Limit, VarNum). + int.min(VarNum0, Limit, VarNum). %---------------------------------------------------------------------------% @@ -1242,9 +1242,9 @@ construct_closure_layout(CallerProcLabel, SeqNo, construct_closure_arg_rvals(ClosureArgs, ClosureArgRvalsTypes, !StaticCellInfo) :- - list__map_foldl(construct_closure_arg_rval, ClosureArgs, ArgRvalsTypes, + list.map_foldl(construct_closure_arg_rval, ClosureArgs, ArgRvalsTypes, !StaticCellInfo), - list__length(ArgRvalsTypes, Length), + list.length(ArgRvalsTypes, Length), ClosureArgRvalsTypes = [const(int_const(Length)) - integer | ArgRvalsTypes]. @@ -1261,7 +1261,7 @@ construct_closure_arg_rval(ClosureArg, ArgRval - ArgRvalType, % we can take the variable number directly from the procedure's tvar set. ExistQTvars = [], NumUnivQTvars = -1, - ll_pseudo_type_info__construct_typed_llds_pseudo_type_info(Type, + ll_pseudo_type_info.construct_typed_llds_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, !StaticCellInfo, ArgRval, ArgRvalType). %---------------------------------------------------------------------------% @@ -1297,12 +1297,12 @@ make_table_data(RttiProcLabel, Kind, TableInfo, TableData, convert_table_arg_info(TableArgInfos, NumPTIs, PTIVectorRval, TVarVectorRval, !StaticCellInfo) :- TableArgInfos = table_arg_infos(Args, TVarSlotMap), - list__length(Args, NumPTIs), - list__map_foldl(construct_table_arg_pti_rval, Args, PTIRvalsTypes, + list.length(Args, NumPTIs), + list.map_foldl(construct_table_arg_pti_rval, Args, PTIRvalsTypes, !StaticCellInfo), add_static_cell(PTIRvalsTypes, PTIVectorAddr, !StaticCellInfo), PTIVectorRval = const(data_addr_const(PTIVectorAddr, no)), - map__map_values(convert_slot_to_locn_map, TVarSlotMap, TVarLocnMap), + map.map_values(convert_slot_to_locn_map, TVarSlotMap, TVarLocnMap), construct_tvar_vector(TVarLocnMap, TVarVectorRval, !StaticCellInfo). :- pred convert_slot_to_locn_map(tvar::in, table_locn::in, @@ -1316,7 +1316,7 @@ convert_slot_to_locn_map(_TVar, SlotLocn, LvalLocns) :- SlotLocn = indirect(SlotNum, Offset), LvalLocn = indirect(reg(r, SlotNum), Offset) ), - LvalLocns = set__make_singleton_set(LvalLocn). + LvalLocns = set.make_singleton_set(LvalLocn). :- pred construct_table_arg_pti_rval( table_arg_info::in, pair(rval, llds_type)::out, @@ -1327,7 +1327,7 @@ construct_table_arg_pti_rval(ClosureArg, ArgRval - ArgRvalType, ClosureArg = table_arg_info(_, _, Type), ExistQTvars = [], NumUnivQTvars = -1, - ll_pseudo_type_info__construct_typed_llds_pseudo_type_info(Type, + ll_pseudo_type_info.construct_typed_llds_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, !StaticCellInfo, ArgRval, ArgRvalType). %---------------------------------------------------------------------------% @@ -1371,7 +1371,7 @@ represent_live_value_type(var(_, _, Type, _), Rval, LldsType, !Info) :- ExistQTvars = [], NumUnivQTvars = -1, get_static_cell_info(!.Info, StaticCellInfo0), - ll_pseudo_type_info__construct_typed_llds_pseudo_type_info(Type, + ll_pseudo_type_info.construct_typed_llds_pseudo_type_info(Type, NumUnivQTvars, ExistQTvars, StaticCellInfo0, StaticCellInfo, Rval, LldsType), set_static_cell_info(StaticCellInfo, !Info). @@ -1575,7 +1575,7 @@ byte_bits = 8. %---------------------------------------------------------------------------% represent_determinism_rval(Detism, - const(int_const(code_model__represent_determinism(Detism)))). + const(int_const(code_model.represent_determinism(Detism)))). %---------------------------------------------------------------------------% @@ -1664,7 +1664,7 @@ get_static_cell_info(LI, LI ^ static_cell_info). allocate_label_number(LabelNum, !LI) :- Counter0 = !.LI ^ label_counter, - counter__allocate(LabelNum, Counter0, Counter), + counter.allocate(LabelNum, Counter0, Counter), !:LI = !.LI ^ label_counter := Counter. :- pred add_table_data(layout_data::in, @@ -1683,7 +1683,7 @@ add_proc_layout_data(ProcLayout, ProcLayoutName, Label, !LI) :- ProcLayouts0 = !.LI ^ proc_layouts, ProcLayouts = [ProcLayout | ProcLayouts0], LabelSet0 = !.LI ^ label_set, - map__det_insert(LabelSet0, Label, layout_addr(ProcLayoutName), LabelSet), + map.det_insert(LabelSet0, Label, layout_addr(ProcLayoutName), LabelSet), ProcLayoutNames0 = !.LI ^ proc_layout_name_list, ProcLayoutNames = [ProcLayoutName | ProcLayoutNames0], !:LI = !.LI ^ proc_layouts := ProcLayouts, @@ -1699,7 +1699,7 @@ add_internal_layout_data(InternalLayout, Label, LayoutName, InternalLayouts0 = !.LI ^ internal_layouts, InternalLayouts = [InternalLayout | InternalLayouts0], LabelSet0 = !.LI ^ label_set, - map__det_insert(LabelSet0, Label, layout_addr(LayoutName), LabelSet), + map.det_insert(LabelSet0, Label, layout_addr(LayoutName), LabelSet), !:LI = !.LI ^ internal_layouts := InternalLayouts, !:LI = !.LI ^ label_set := LabelSet. @@ -1732,10 +1732,10 @@ set_static_cell_info(SCI, LI, LI ^ static_cell_info := SCI). lookup_string_in_table(String, Offset, !Info) :- StringTable0 = !.Info ^ string_table, StringTable0 = string_table(TableMap0, TableList0, TableOffset0), - ( map__search(TableMap0, String, OldOffset) -> + ( map.search(TableMap0, String, OldOffset) -> Offset = OldOffset ; - string__length(String, Length), + string.length(String, Length), TableOffset = TableOffset0 + Length + 1, % We use a 32 bit unsigned integer to represent the offset. % Computing that limit exactly without getting an overflow @@ -1750,7 +1750,7 @@ lookup_string_in_table(String, Offset, !Info) :- TableOffset < (1 << ((4 * byte_bits) - 2)) -> Offset = TableOffset0, - map__det_insert(TableMap0, String, TableOffset0, TableMap), + map.det_insert(TableMap0, String, TableOffset0, TableMap), TableList = [String | TableList0], StringTable = string_table(TableMap, TableList, TableOffset), set_string_table(StringTable, !Info) diff --git a/compiler/stack_opt.m b/compiler/stack_opt.m index bf7f0ad28..e5689c06f 100644 --- a/compiler/stack_opt.m +++ b/compiler/stack_opt.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2002-2005 The University of Melbourne. +% Copyright (C) 2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -68,7 +68,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__stack_opt. +:- module ll_backend.stack_opt. :- interface. :- import_module hlds.hlds_module. @@ -180,21 +180,21 @@ stack_opt_cell(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :- module_info_get_globals(!.ModuleInfo, Globals), module_info_pred_info(!.ModuleInfo, PredId, PredInfo), body_should_use_typeinfo_liveness(PredInfo, Globals, TypeInfoLiveness), - globals__lookup_bool_option(Globals, opt_no_return_calls, + globals.lookup_bool_option(Globals, opt_no_return_calls, OptNoReturnCalls), AllocData = alloc_data(!.ModuleInfo, !.ProcInfo, TypeInfoLiveness, OptNoReturnCalls), - goal_path__fill_slots(!.ModuleInfo, !ProcInfo), + fill_goal_path_slots(!.ModuleInfo, !ProcInfo), proc_info_goal(!.ProcInfo, Goal2), OptStackAlloc0 = init_opt_stack_alloc, - set__init(FailVars), - set__init(NondetLiveness0), + set.init(FailVars), + set.init(NondetLiveness0), build_live_sets_in_goal(Goal2, Goal, FailVars, AllocData, OptStackAlloc0, OptStackAlloc, Liveness0, _Liveness, NondetLiveness0, _NondetLiveness), proc_info_set_goal(Goal, !ProcInfo), allocate_store_maps(for_stack_opt, PredId, !.ModuleInfo, !ProcInfo), - globals__lookup_int_option(Globals, debug_stack_opt, DebugStackOpt), + globals.lookup_int_option(Globals, debug_stack_opt, DebugStackOpt), pred_id_to_int(PredId, PredIdInt), maybe_write_progress_message("\nbefore stack opt cell", DebugStackOpt, PredIdInt, !.ProcInfo, !.ModuleInfo, !IO), @@ -216,7 +216,7 @@ stack_opt_cell(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :- :- func init_opt_stack_alloc = opt_stack_alloc. -init_opt_stack_alloc = opt_stack_alloc(set__init). +init_opt_stack_alloc = opt_stack_alloc(set.init). :- pred optimize_live_sets(module_info::in, opt_stack_alloc::in, proc_info::in, proc_info::out, bool::out, int::in, int::in, @@ -228,61 +228,61 @@ optimize_live_sets(ModuleInfo, OptAlloc, !ProcInfo, Changed, DebugStackOpt, proc_info_vartypes(!.ProcInfo, VarTypes0), proc_info_varset(!.ProcInfo, VarSet0), OptAlloc = opt_stack_alloc(ParConjOwnSlot), - arg_info__partition_proc_args(!.ProcInfo, ModuleInfo, + arg_info.partition_proc_args(!.ProcInfo, ModuleInfo, InputArgs, OutputArgs, UnusedArgs), - HeadVars = set__union_list([InputArgs, OutputArgs, UnusedArgs]), + HeadVars = set.union_list([InputArgs, OutputArgs, UnusedArgs]), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, optimize_saved_vars_cell_candidate_headvars, CandHeadvars), ( CandHeadvars = no, - set__union(HeadVars, ParConjOwnSlot, NonCandidateVars) + set.union(HeadVars, ParConjOwnSlot, NonCandidateVars) ; CandHeadvars = yes, NonCandidateVars = ParConjOwnSlot ), - Counter0 = counter__init(1), - counter__allocate(CurInterval, Counter0, Counter1), + Counter0 = counter.init(1), + counter.allocate(CurInterval, Counter0, Counter1), CurIntervalId = interval_id(CurInterval), - EndMap0 = map__det_insert(map__init, CurIntervalId, proc_end), - InsertMap0 = map__init, - StartMap0 = map__init, - SuccMap0 = map__det_insert(map__init, CurIntervalId, []), - VarsMap0 = map__det_insert(map__init, CurIntervalId, OutputArgs), - globals__lookup_int_option(Globals, + EndMap0 = map.det_insert(map.init, CurIntervalId, proc_end), + InsertMap0 = map.init, + StartMap0 = map.init, + SuccMap0 = map.det_insert(map.init, CurIntervalId, []), + VarsMap0 = map.det_insert(map.init, CurIntervalId, OutputArgs), + globals.lookup_int_option(Globals, optimize_saved_vars_cell_cv_store_cost, CellVarStoreCost), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_cv_load_cost, CellVarLoadCost), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_fv_store_cost, FieldVarStoreCost), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_fv_load_cost, FieldVarLoadCost), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_op_ratio, OpRatio), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_node_ratio, NodeRatio), - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, optimize_saved_vars_cell_include_all_candidates, InclAllCand), MatchingParams = matching_params(CellVarStoreCost, CellVarLoadCost, FieldVarStoreCost, FieldVarLoadCost, OpRatio, NodeRatio, InclAllCand), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_all_path_node_ratio, AllPathNodeRatio), - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, optimize_saved_vars_cell_loop, FixpointLoop), - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, optimize_saved_vars_cell_full_path, FullPath), - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, optimize_saved_vars_cell_on_stack, OnStack), - globals__lookup_bool_option(Globals, + globals.lookup_bool_option(Globals, opt_no_return_calls, OptNoReturnCalls), IntParams = interval_params(ModuleInfo, VarTypes0, OptNoReturnCalls), - IntervalInfo0 = interval_info(IntParams, set__init, OutputArgs, - map__init, map__init, map__init, CurIntervalId, Counter1, - set__make_singleton_set(CurIntervalId), - map__init, set__init, StartMap0, EndMap0, - SuccMap0, VarsMap0, map__init), + IntervalInfo0 = interval_info(IntParams, set.init, OutputArgs, + map.init, map.init, map.init, CurIntervalId, Counter1, + set.make_singleton_set(CurIntervalId), + map.init, set.init, StartMap0, EndMap0, + SuccMap0, VarsMap0, map.init), StackOptParams = stack_opt_params(MatchingParams, AllPathNodeRatio, FixpointLoop, FullPath, OnStack, NonCandidateVars), StackOptInfo0 = stack_opt_info(StackOptParams, InsertMap0, []), @@ -295,11 +295,11 @@ optimize_live_sets(ModuleInfo, OptAlloc, !ProcInfo, Changed, DebugStackOpt, true ), InsertMap = StackOptInfo ^ left_anchor_inserts, - ( map__is_empty(InsertMap) -> + ( map.is_empty(InsertMap) -> Changed = no ; record_decisions_in_goal(Goal0, Goal1, VarSet0, VarSet, - VarTypes0, VarTypes, map__init, RenameMap, + VarTypes0, VarTypes, map.init, RenameMap, InsertMap, yes(stack_opt)), apply_headvar_correction(HeadVars, RenameMap, Goal1, Goal), proc_info_set_goal(Goal, !ProcInfo), @@ -333,14 +333,14 @@ opt_at_resume_site(_NeedAtResume, _GoalInfo, StackAlloc, StackAlloc). opt_at_par_conj(NeedParConj, _GoalInfo, StackAlloc0, StackAlloc) :- NeedParConj = need_in_par_conj(StackVars), ParConjOwnSlots0 = StackAlloc0 ^ par_conj_own_slots, - ParConjOwnSlots = set__union(StackVars, ParConjOwnSlots0), + ParConjOwnSlots = set.union(StackVars, ParConjOwnSlots0), StackAlloc = StackAlloc0 ^ par_conj_own_slots := ParConjOwnSlots. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% :- instance build_interval_info_acc(stack_opt_info) where [ - pred(use_cell/8) is stack_opt__use_cell + pred(use_cell/8) is stack_opt.use_cell ]. :- type match_path_info @@ -377,19 +377,19 @@ use_cell(CellVar, FieldVarList, ConsId, Goal, !IntervalInfo, !StackOptInfo) :- FlushedLater = !.IntervalInfo ^ flushed_later, StackOptParams = !.StackOptInfo ^ stack_opt_params, NonCandidateVars = StackOptParams ^ non_candidate_vars, - set__list_to_set(FieldVarList, FieldVars), - set__intersect(FieldVars, FlushedLater, FlushedLaterFieldVars), - set__difference(FlushedLaterFieldVars, NonCandidateVars, + set.list_to_set(FieldVarList, FieldVars), + set.intersect(FieldVars, FlushedLater, FlushedLaterFieldVars), + set.difference(FlushedLaterFieldVars, NonCandidateVars, CandidateArgVars0), ( - set__empty(CandidateArgVars0) + set.empty(CandidateArgVars0) -> true ; ConsId = cons(_Name, _Arity), IntParams = !.IntervalInfo ^ interval_params, VarTypes = IntParams ^ var_types, - map__lookup(VarTypes, CellVar, Type), + map.lookup(VarTypes, CellVar, Type), ( type_is_tuple(Type, _) -> @@ -398,11 +398,11 @@ use_cell(CellVar, FieldVarList, ConsId, Goal, !IntervalInfo, !StackOptInfo) :- type_to_ctor_and_args(Type, TypeCtor, _), ModuleInfo = IntParams ^ module_info, module_info_get_type_table(ModuleInfo, TypeTable), - map__lookup(TypeTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.lookup(TypeTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), ConsTable = TypeBody ^ du_type_cons_tag_values -> - map__lookup(ConsTable, ConsId, ConsTag), + map.lookup(ConsTable, ConsId, ConsTag), ( ConsTag = no_tag -> FreeOfCost = yes ; @@ -412,14 +412,14 @@ use_cell(CellVar, FieldVarList, ConsId, Goal, !IntervalInfo, !StackOptInfo) :- fail ) -> - RelevantVars = set__insert(FieldVars, CellVar), + RelevantVars = set.insert(FieldVars, CellVar), find_all_branches_from_cur_interval(RelevantVars, MatchInfo, !.IntervalInfo, !.StackOptInfo), MatchInfo = match_info(PathsInfo, RelevantAfterVars, AfterModelNon, InsertAnchors, InsertIntervals), ( FreeOfCost = yes, - set__difference(CandidateArgVars0, RelevantAfterVars, ViaCellVars), + set.difference(CandidateArgVars0, RelevantAfterVars, ViaCellVars), record_matching_result(CellVar, ConsId, FieldVarList, ViaCellVars, Goal, InsertAnchors, InsertIntervals, !IntervalInfo, !StackOptInfo) @@ -428,11 +428,11 @@ use_cell(CellVar, FieldVarList, ConsId, Goal, !IntervalInfo, !StackOptInfo) :- ( AfterModelNon = no, OnStack = StackOptParams ^ on_stack, - set__difference(CandidateArgVars0, RelevantAfterVars, + set.difference(CandidateArgVars0, RelevantAfterVars, CandidateArgVars), ( OnStack = yes, - ( set__member(CellVar, FlushedLater) -> + ( set.member(CellVar, FlushedLater) -> CellVarFlushedLater = yes ; CellVarFlushedLater = no @@ -440,10 +440,10 @@ use_cell(CellVar, FieldVarList, ConsId, Goal, !IntervalInfo, !StackOptInfo) :- ; OnStack = no, ( - list__member(PathInfo, PathsInfo), + list.member(PathInfo, PathsInfo), PathInfo = match_path_info(_, Segments), - list__member(Segment, Segments), - set__member(CellVar, Segment) + list.member(Segment, Segments), + set.member(CellVar, Segment) -> CellVarFlushedLater = yes ; @@ -472,15 +472,15 @@ apply_matching(CellVar, CellVarFlushedLater, IntParams, StackOptParams, apply_matching_loop(CellVar, CellVarFlushedLater, IntParams, StackOptParams, PathInfos, CandidateArgVars0, BenefitNodeSets, CostNodeSets, ViaCellVars0), - BenefitNodes = set__union_list(BenefitNodeSets), - CostNodes = set__union_list(CostNodeSets), - set__count(BenefitNodes, NumBenefitNodes), - set__count(CostNodes, NumCostNodes), + BenefitNodes = set.union_list(BenefitNodeSets), + CostNodes = set.union_list(CostNodeSets), + set.count(BenefitNodes, NumBenefitNodes), + set.count(CostNodes, NumCostNodes), AllPathNodeRatio = StackOptParams ^ all_path_node_ratio, ( NumBenefitNodes * 100 >= NumCostNodes * AllPathNodeRatio -> ViaCellVars = ViaCellVars0 ; - ViaCellVars = set__init + ViaCellVars = set.init ). :- pred apply_matching_loop(prog_var::in, bool::in, interval_params::in, @@ -491,19 +491,19 @@ apply_matching(CellVar, CellVarFlushedLater, IntParams, StackOptParams, apply_matching_loop(CellVar, CellVarFlushedLater, IntParams, StackOptParams, PathInfos, CandidateArgVars0, BenefitNodeSets, CostNodeSets, ViaCellVars) :- - list__map3(apply_matching_for_path(CellVar, CellVarFlushedLater, + list.map3(apply_matching_for_path(CellVar, CellVarFlushedLater, StackOptParams, CandidateArgVars0), PathInfos, BenefitNodeSets0, CostNodeSets0, PathViaCellVars), - ( list__all_same(PathViaCellVars) -> + ( list.all_same(PathViaCellVars) -> BenefitNodeSets = BenefitNodeSets0, CostNodeSets = CostNodeSets0, ( PathViaCellVars = [ViaCellVarsPrime | _] -> ViaCellVars = ViaCellVarsPrime ; - ViaCellVars = set__init + ViaCellVars = set.init ) ; - CandidateArgVars1 = set__intersect_list(PathViaCellVars), + CandidateArgVars1 = set.intersect_list(PathViaCellVars), FixpointLoop = StackOptParams ^ fixpoint_loop, ( FixpointLoop = no, @@ -524,10 +524,10 @@ apply_matching_loop(CellVar, CellVarFlushedLater, IntParams, StackOptParams, apply_matching_for_path(CellVar, CellVarFlushedLater, StackOptParams, CandidateArgVars, PathInfo, BenefitNodes, CostNodes, ViaCellVars) :- - ( set__empty(CandidateArgVars) -> - BenefitNodes = set__init, - CostNodes = set__init, - ViaCellVars = set__init + ( set.empty(CandidateArgVars) -> + BenefitNodes = set.init, + CostNodes = set.init, + ViaCellVars = set.init ; PathInfo = match_path_info(FirstSegment, LaterSegments), MatchingParams = StackOptParams ^ matching_params, @@ -543,17 +543,17 @@ apply_matching_for_path(CellVar, CellVarFlushedLater, StackOptParams, record_matching_result(CellVar, ConsId, ArgVars, ViaCellVars, Goal, PotentialAnchors, PotentialIntervals, !IntervalInfo, !StackOptInfo) :- - ( set__empty(ViaCellVars) -> + ( set.empty(ViaCellVars) -> true ; - set__to_sorted_list(PotentialIntervals, PotentialIntervalList), - set__to_sorted_list(PotentialAnchors, PotentialAnchorList), - list__foldl3(record_cell_var_for_interval(CellVar, ViaCellVars), + set.to_sorted_list(PotentialIntervals, PotentialIntervalList), + set.to_sorted_list(PotentialAnchors, PotentialAnchorList), + list.foldl3(record_cell_var_for_interval(CellVar, ViaCellVars), PotentialIntervalList, !IntervalInfo, !StackOptInfo, - set__init, InsertIntervals), - list__foldl3(add_anchor_inserts(Goal, ViaCellVars, InsertIntervals), + set.init, InsertIntervals), + list.foldl3(add_anchor_inserts(Goal, ViaCellVars, InsertIntervals), PotentialAnchorList, !IntervalInfo, !StackOptInfo, - set__init, InsertAnchors), + set.init, InsertAnchors), Goal = _ - GoalInfo, goal_info_get_goal_path(GoalInfo, GoalPath), MatchingResult = matching_result(CellVar, ConsId, @@ -574,8 +574,8 @@ record_cell_var_for_interval(CellVar, ViaCellVars, IntervalId, !IntervalInfo, !StackOptInfo, !InsertIntervals) :- record_interval_vars(IntervalId, [CellVar], !IntervalInfo), delete_interval_vars(IntervalId, ViaCellVars, DeletedVars, !IntervalInfo), - ( set__non_empty(DeletedVars) -> - svset__insert(IntervalId, !InsertIntervals) + ( set.non_empty(DeletedVars) -> + svset.insert(IntervalId, !InsertIntervals) ; true ). @@ -587,22 +587,22 @@ record_cell_var_for_interval(CellVar, ViaCellVars, IntervalId, add_anchor_inserts(Goal, ArgVarsViaCellVar, InsertIntervals, Anchor, !IntervalInfo, !StackOptInfo, !InsertAnchors) :- - map__lookup(!.IntervalInfo ^ anchor_follow_map, Anchor, AnchorFollow), + map.lookup(!.IntervalInfo ^ anchor_follow_map, Anchor, AnchorFollow), AnchorFollow = _ - AnchorIntervals, - set__intersect(AnchorIntervals, InsertIntervals, + set.intersect(AnchorIntervals, InsertIntervals, AnchorInsertIntervals), - ( set__non_empty(AnchorInsertIntervals) -> + ( set.non_empty(AnchorInsertIntervals) -> Insert = insert_spec(Goal, ArgVarsViaCellVar), InsertMap0 = !.StackOptInfo ^ left_anchor_inserts, - ( map__search(InsertMap0, Anchor, Inserts0) -> + ( map.search(InsertMap0, Anchor, Inserts0) -> Inserts = [Insert | Inserts0], - svmap__det_update(Anchor, Inserts, InsertMap0, InsertMap) + svmap.det_update(Anchor, Inserts, InsertMap0, InsertMap) ; Inserts = [Insert], - svmap__det_insert(Anchor, Inserts, InsertMap0, InsertMap) + svmap.det_insert(Anchor, Inserts, InsertMap0, InsertMap) ), !:StackOptInfo = !.StackOptInfo ^ left_anchor_inserts := InsertMap, - svset__insert(Anchor, !InsertAnchors) + svset.insert(Anchor, !InsertAnchors) ; true ). @@ -654,30 +654,30 @@ close_path(Path0) = Path :- Path0 = path(FlushState, CurSegment, FirstSegment0, OtherSegments0, FlushAnchors, IntervalIds), ( FlushState = current_is_before_first_flush -> - expect(set__empty(FirstSegment0), this_file, + expect(set.empty(FirstSegment0), this_file, "close_path: FirstSegment0 not empty"), FirstSegment = CurSegment, OtherSegments = OtherSegments0 - ; set__empty(CurSegment) -> + ; set.empty(CurSegment) -> FirstSegment = FirstSegment0, OtherSegments = OtherSegments0 ; FirstSegment = FirstSegment0, OtherSegments = [CurSegment | OtherSegments0] ), - Path = path(current_is_after_first_flush, set__init, + Path = path(current_is_after_first_flush, set.init, FirstSegment, OtherSegments, FlushAnchors, IntervalIds). :- func add_interval_to_path(interval_id, set(prog_var), path) = path. add_interval_to_path(IntervalId, Vars, !.Path) = !:Path :- - ( set__empty(Vars) -> + ( set.empty(Vars) -> true ; CurSegment0 = !.Path ^ current_segment, - CurSegment = set__union(Vars, CurSegment0), + CurSegment = set.union(Vars, CurSegment0), OccurringIntervals0 = !.Path ^ occurring_intervals, - svset__insert(IntervalId, OccurringIntervals0, OccurringIntervals), + svset.insert(IntervalId, OccurringIntervals0, OccurringIntervals), !:Path = !.Path ^ current_segment := CurSegment, !:Path = !.Path ^ occurring_intervals := OccurringIntervals ). @@ -686,7 +686,7 @@ add_interval_to_path(IntervalId, Vars, !.Path) = !:Path :- add_anchor_to_path(Anchor, !.Path) = !:Path :- Anchors0 = !.Path ^ flush_anchors, - svset__insert(Anchor, Anchors0, Anchors), + svset.insert(Anchor, Anchors0, Anchors), !:Path = !.Path ^ flush_anchors := Anchors. :- func anchor_requires_close(interval_info, anchor) = bool. @@ -695,7 +695,7 @@ anchor_requires_close(_, proc_start) = no. anchor_requires_close(_, proc_end) = yes. anchor_requires_close(IntervalInfo, branch_start(_, GoalPath)) = resume_save_status_requires_close(ResumeSaveStatus) :- - map__lookup(IntervalInfo ^ branch_resume_map, GoalPath, ResumeSaveStatus). + map.lookup(IntervalInfo ^ branch_resume_map, GoalPath, ResumeSaveStatus). anchor_requires_close(_, cond_then(_)) = no. anchor_requires_close(_, branch_end(BranchConstruct, _)) = ( BranchConstruct = neg -> @@ -765,19 +765,19 @@ may_have_more_successors(call_site(_), no). find_all_branches_from_cur_interval(RelevantVars, MatchInfo, IntervalInfo, StackOptInfo) :- IntervalId = IntervalInfo ^ cur_interval, - map__lookup(IntervalInfo ^ interval_vars, IntervalId, IntervalVars), - IntervalRelevantVars = set__intersect(RelevantVars, IntervalVars), + map.lookup(IntervalInfo ^ interval_vars, IntervalId, IntervalVars), + IntervalRelevantVars = set.intersect(RelevantVars, IntervalVars), Path0 = path(current_is_before_first_flush, IntervalRelevantVars, - set__init, [], set__init, set__init), - AllPaths0 = all_paths(set__make_singleton_set(Path0), no, set__init), + set.init, [], set.init, set.init), + AllPaths0 = all_paths(set.make_singleton_set(Path0), no, set.init), find_all_branches(RelevantVars, IntervalId, no, IntervalInfo, StackOptInfo, AllPaths0, AllPaths), AllPaths = all_paths(Paths, AfterModelNon, RelevantAfter), - set__to_sorted_list(Paths, PathList), - list__map3(extract_match_and_save_info, PathList, + set.to_sorted_list(Paths, PathList), + list.map3(extract_match_and_save_info, PathList, MatchInputs, FlushAnchorSets, OccurringIntervalSets), - FlushAnchors = set__union_list(FlushAnchorSets), - OccurringIntervals = set__union_list(OccurringIntervalSets), + FlushAnchors = set.union_list(FlushAnchorSets), + OccurringIntervals = set.union_list(OccurringIntervalSets), MatchInfo = match_info(MatchInputs, RelevantAfter, AfterModelNon, FlushAnchors, OccurringIntervals). @@ -787,8 +787,8 @@ find_all_branches_from_cur_interval(RelevantVars, MatchInfo, IntervalInfo, find_all_branches(RelevantVars, IntervalId, MaybeSearchAnchor0, IntervalInfo, StackOptInfo, !AllPaths) :- - map__lookup(IntervalInfo ^ interval_end, IntervalId, End), - map__lookup(IntervalInfo ^ interval_succ, IntervalId, SuccessorIds), + map.lookup(IntervalInfo ^ interval_end, IntervalId, End), + map.lookup(IntervalInfo ^ interval_succ, IntervalId, SuccessorIds), ( SuccessorIds = [], expect(may_have_no_successor(End), this_file, @@ -811,17 +811,17 @@ find_all_branches(RelevantVars, IntervalId, MaybeSearchAnchor0, MaybeSearchAnchor0 = yes(SearchAnchor0), End = SearchAnchor0 -> - !:AllPaths = !.AllPaths ^ used_after_scope := set__init + !:AllPaths = !.AllPaths ^ used_after_scope := set.init ; End = branch_end(_, EndGoalPath), - map__lookup(IntervalInfo ^ branch_end_map, EndGoalPath, + map.lookup(IntervalInfo ^ branch_end_map, EndGoalPath, BranchEndInfo), OnStackAfterBranch = BranchEndInfo ^ flushed_after_branch, AccessedAfterBranch = BranchEndInfo ^ accessed_after_branch, - NeededAfterBranch = set__union(OnStackAfterBranch, + NeededAfterBranch = set.union(OnStackAfterBranch, AccessedAfterBranch), - RelevantAfter = set__intersect(RelevantVars, NeededAfterBranch), - set__non_empty(RelevantAfter) + RelevantAfter = set.intersect(RelevantVars, NeededAfterBranch), + set.non_empty(RelevantAfter) -> !:AllPaths = !.AllPaths ^ used_after_scope := RelevantAfter ; @@ -839,7 +839,7 @@ find_all_branches_from(End, RelevantVars, MaybeSearchAnchor0, IntervalInfo, StackOptInfo, SuccessorIds, !AllPaths) :- ( anchor_requires_close(IntervalInfo, End) = yes -> Paths0 = !.AllPaths ^ paths_so_far, - Paths1 = set__map(close_path, Paths0), + Paths1 = set.map(close_path, Paths0), !:AllPaths = !.AllPaths ^ paths_so_far := Paths1 ; true @@ -853,7 +853,7 @@ find_all_branches_from(End, RelevantVars, MaybeSearchAnchor0, IntervalInfo, MaybeSearchAnchor1 = yes(branch_end(disj, EndGoalPath)), one_after_another(RelevantVars, MaybeSearchAnchor1, IntervalInfo, StackOptInfo, SuccessorIds, !AllPaths), - map__lookup(IntervalInfo ^ branch_end_map, EndGoalPath, + map.lookup(IntervalInfo ^ branch_end_map, EndGoalPath, BranchEndInfo), ContinueId = BranchEndInfo ^ interval_after_branch, apply_interval_find_all_branches(RelevantVars, @@ -876,11 +876,11 @@ find_all_branches_from(End, RelevantVars, MaybeSearchAnchor0, IntervalInfo, CondStartId, !AllPaths), MaybeSearchAnchorEnd = yes(branch_end(ite, EndGoalPath)), CondEndMap = IntervalInfo ^ cond_end_map, - map__lookup(CondEndMap, EndGoalPath, ThenStartId), + map.lookup(CondEndMap, EndGoalPath, ThenStartId), one_after_another(RelevantVars, MaybeSearchAnchorEnd, IntervalInfo, StackOptInfo, [ThenStartId, ElseStartId], !AllPaths), - map__lookup(IntervalInfo ^ branch_end_map, EndGoalPath, + map.lookup(IntervalInfo ^ branch_end_map, EndGoalPath, BranchEndInfo), ContinueId = BranchEndInfo ^ interval_after_branch, apply_interval_find_all_branches(RelevantVars, @@ -890,11 +890,11 @@ find_all_branches_from(End, RelevantVars, MaybeSearchAnchor0, IntervalInfo, End = branch_start(BranchType, EndGoalPath) -> MaybeSearchAnchor1 = yes(branch_end(BranchType, EndGoalPath)), - list__map(apply_interval_find_all_branches_map(RelevantVars, + list.map(apply_interval_find_all_branches_map(RelevantVars, MaybeSearchAnchor1, IntervalInfo, StackOptInfo, !.AllPaths), SuccessorIds, AllPathsList), consolidate_after_join(AllPathsList, !:AllPaths), - map__lookup(IntervalInfo ^ branch_end_map, EndGoalPath, BranchEndInfo), + map.lookup(IntervalInfo ^ branch_end_map, EndGoalPath, BranchEndInfo), ContinueId = BranchEndInfo ^ interval_after_branch, apply_interval_find_all_branches(RelevantVars, MaybeSearchAnchor0, IntervalInfo, StackOptInfo, @@ -941,28 +941,28 @@ apply_interval_find_all_branches_map(RelevantVars, MaybeSearchAnchor0, apply_interval_find_all_branches(RelevantVars, MaybeSearchAnchor0, IntervalInfo, StackOptInfo, IntervalId, !AllPaths) :- - map__lookup(IntervalInfo ^ interval_vars, IntervalId, IntervalVars), - RelevantIntervalVars = set__intersect(RelevantVars, IntervalVars), + map.lookup(IntervalInfo ^ interval_vars, IntervalId, IntervalVars), + RelevantIntervalVars = set.intersect(RelevantVars, IntervalVars), !.AllPaths = all_paths(Paths0, AfterModelNon0, RelevantAfter), - Paths1 = set__map(add_interval_to_path(IntervalId, RelevantIntervalVars), + Paths1 = set.map(add_interval_to_path(IntervalId, RelevantIntervalVars), Paths0), - map__lookup(IntervalInfo ^ interval_start, IntervalId, Start), + map.lookup(IntervalInfo ^ interval_start, IntervalId, Start), ( % Check if intervals starting at Start use any RelevantVars. ( Start = call_site(_) ; Start = branch_end(_, _) ; Start = branch_start(_, _) ), - map__search(IntervalInfo ^ anchor_follow_map, Start, StartInfo), + map.search(IntervalInfo ^ anchor_follow_map, Start, StartInfo), StartInfo = AnchorFollowVars - _, - set__intersect(RelevantVars, AnchorFollowVars, NeededVars), - set__non_empty(NeededVars) + set.intersect(RelevantVars, AnchorFollowVars, NeededVars), + set.non_empty(NeededVars) -> - Paths2 = set__map(add_anchor_to_path(Start), Paths1) + Paths2 = set.map(add_anchor_to_path(Start), Paths1) ; Paths2 = Paths1 ), - ( set__member(Start, IntervalInfo ^ model_non_anchors) -> + ( set.member(Start, IntervalInfo ^ model_non_anchors) -> AfterModelNon = yes ; AfterModelNon = AfterModelNon0 @@ -976,13 +976,13 @@ apply_interval_find_all_branches(RelevantVars, MaybeSearchAnchor0, consolidate_after_join([], _) :- unexpected(this_file, "consolidate_after_join: no paths to join"). consolidate_after_join([First | Rest], AllPaths) :- - PathsList = list__map(project_paths_from_all_paths, [First | Rest]), - Paths0 = set__union_list(PathsList), + PathsList = list.map(project_paths_from_all_paths, [First | Rest]), + Paths0 = set.union_list(PathsList), Paths = compress_paths(Paths0), - AfterModelNonList = list__map(project_after_model_non_from_all_paths, + AfterModelNonList = list.map(project_after_model_non_from_all_paths, [First | Rest]), - bool__or_list(AfterModelNonList, AfterModelNon), - AllPaths = all_paths(Paths, AfterModelNon, set__init). + bool.or_list(AfterModelNonList, AfterModelNon), + AllPaths = all_paths(Paths, AfterModelNon, set.init). :- func project_paths_from_all_paths(all_paths) = set(path). @@ -1009,12 +1009,12 @@ compress_paths(Paths) = Paths. maybe_write_progress_message(Message, DebugStackOpt, PredIdInt, ProcInfo, ModuleInfo, !IO) :- ( DebugStackOpt = PredIdInt -> - io__write_string(Message, !IO), - io__write_string(":\n", !IO), + io.write_string(Message, !IO), + io.write_string(":\n", !IO), proc_info_goal(ProcInfo, Goal), proc_info_varset(ProcInfo, VarSet), - hlds_out__write_goal(Goal, ModuleInfo, VarSet, yes, 0, "\n", !IO), - io__write_string("\n", !IO) + hlds_out.write_goal(Goal, ModuleInfo, VarSet, yes, 0, "\n", !IO), + io.write_string("\n", !IO) ; true ). @@ -1027,44 +1027,44 @@ maybe_write_progress_message(Message, DebugStackOpt, PredIdInt, ProcInfo, :- pred dump_stack_opt_info(stack_opt_info::in, io::di, io::uo) is det. dump_stack_opt_info(StackOptInfo, !IO) :- - map__to_assoc_list(StackOptInfo ^ left_anchor_inserts, Inserts), - io__write_string("\nANCHOR INSERT:\n", !IO), - list__foldl(dump_anchor_inserts, Inserts, !IO), + map.to_assoc_list(StackOptInfo ^ left_anchor_inserts, Inserts), + io.write_string("\nANCHOR INSERT:\n", !IO), + list.foldl(dump_anchor_inserts, Inserts, !IO), - io__write_string("\nMATCHING RESULTS:\n", !IO), - list__foldl(dump_matching_result, StackOptInfo ^ matching_results, !IO), - io__write_string("\n", !IO). + io.write_string("\nMATCHING RESULTS:\n", !IO), + list.foldl(dump_matching_result, StackOptInfo ^ matching_results, !IO), + io.write_string("\n", !IO). :- pred dump_anchor_inserts(pair(anchor, list(insert_spec))::in, io::di, io::uo) is det. dump_anchor_inserts(Anchor - InsertSpecs, !IO) :- - io__write_string("\ninsertions after ", !IO), - io__write(Anchor, !IO), - io__write_string(":\n", !IO), - list__foldl(dump_insert, InsertSpecs, !IO). + io.write_string("\ninsertions after ", !IO), + io.write(Anchor, !IO), + io.write_string(":\n", !IO), + list.foldl(dump_insert, InsertSpecs, !IO). :- pred dump_insert(insert_spec::in, io::di, io::uo) is det. dump_insert(insert_spec(Goal, Vars), !IO) :- - list__map(term__var_to_int, set__to_sorted_list(Vars), VarNums), - io__write_string("vars [", !IO), + list.map(term.var_to_int, set.to_sorted_list(Vars), VarNums), + io.write_string("vars [", !IO), write_int_list(VarNums, !IO), - io__write_string("]: ", !IO), + io.write_string("]: ", !IO), ( Goal = unify(_, _, _, Unification, _) - _, Unification = deconstruct(CellVar, ConsId, ArgVars, _,_,_) -> - term__var_to_int(CellVar, CellVarNum), - io__write_int(CellVarNum, !IO), - io__write_string(" => ", !IO), + term.var_to_int(CellVar, CellVarNum), + io.write_int(CellVarNum, !IO), + io.write_string(" => ", !IO), mercury_output_cons_id(ConsId, does_not_need_brackets, !IO), - io__write_string("(", !IO), - list__map(term__var_to_int, ArgVars, ArgVarNums), + io.write_string("(", !IO), + list.map(term.var_to_int, ArgVars, ArgVarNums), write_int_list(ArgVarNums, !IO), - io__write_string(")\n", !IO) + io.write_string(")\n", !IO) ; - io__write_string("BAD INSERT GOAL\n", !IO) + io.write_string("BAD INSERT GOAL\n", !IO) ). :- pred dump_matching_result(matching_result::in, @@ -1074,39 +1074,39 @@ dump_matching_result(MatchingResult, !IO) :- MatchingResult = matching_result(CellVar, ConsId, ArgVars, ViaCellVars, GoalPath, PotentialIntervals, InsertIntervals, PotentialAnchors, InsertAnchors), - io__write_string("\nmatching result at ", !IO), - io__write(GoalPath, !IO), - io__write_string("\n", !IO), - term__var_to_int(CellVar, CellVarNum), - list__map(term__var_to_int, ArgVars, ArgVarNums), - list__map(term__var_to_int, set__to_sorted_list(ViaCellVars), + io.write_string("\nmatching result at ", !IO), + io.write(GoalPath, !IO), + io.write_string("\n", !IO), + term.var_to_int(CellVar, CellVarNum), + list.map(term.var_to_int, ArgVars, ArgVarNums), + list.map(term.var_to_int, set.to_sorted_list(ViaCellVars), ViaCellVarNums), - io__write_int(CellVarNum, !IO), - io__write_string(" => ", !IO), + io.write_int(CellVarNum, !IO), + io.write_string(" => ", !IO), mercury_output_cons_id(ConsId, does_not_need_brackets, !IO), - io__write_string("(", !IO), + io.write_string("(", !IO), write_int_list(ArgVarNums, !IO), - io__write_string("): via cell ", !IO), + io.write_string("): via cell ", !IO), write_int_list(ViaCellVarNums, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), - io__write_string("potential intervals: ", !IO), - PotentialIntervalNums = list__map(interval_id_to_int, - set__to_sorted_list(PotentialIntervals)), + io.write_string("potential intervals: ", !IO), + PotentialIntervalNums = list.map(interval_id_to_int, + set.to_sorted_list(PotentialIntervals)), write_int_list(PotentialIntervalNums, !IO), - io__write_string("\n", !IO), - io__write_string("insert intervals: ", !IO), - InsertIntervalNums = list__map(interval_id_to_int, - set__to_sorted_list(InsertIntervals)), + io.write_string("\n", !IO), + io.write_string("insert intervals: ", !IO), + InsertIntervalNums = list.map(interval_id_to_int, + set.to_sorted_list(InsertIntervals)), write_int_list(InsertIntervalNums, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), - io__write_string("potential anchors: ", !IO), - io__write_list(set__to_sorted_list(PotentialAnchors), " ", io__write, !IO), - io__write_string("\n", !IO), - io__write_string("insert anchors: ", !IO), - io__write_list(set__to_sorted_list(InsertAnchors), " ", io__write, !IO), - io__write_string("\n", !IO). + io.write_string("potential anchors: ", !IO), + io.write_list(set.to_sorted_list(PotentialAnchors), " ", io.write, !IO), + io.write_string("\n", !IO), + io.write_string("insert anchors: ", !IO), + io.write_list(set.to_sorted_list(InsertAnchors), " ", io.write, !IO), + io.write_string("\n", !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/state_var.m b/compiler/state_var.m index 07a472c7f..892588491 100644 --- a/compiler/state_var.m +++ b/compiler/state_var.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2005 The University of Melbourne. +% Copyright (C) 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -9,7 +9,7 @@ % File: state_var.m. % Main author: rafe. -:- module hlds__make_hlds__state_var. +:- module hlds.make_hlds.state_var. :- interface. :- import_module hlds.hlds_goal. @@ -306,7 +306,7 @@ :- import_module term. :- import_module varset. -new_svar_info = svar_info(in_head, 0, map__init, map__init, map__init). +new_svar_info = svar_info(in_head, 0, map.init, map.init, map.init). :- pred svar_info `has_svar_colon_mapping_for` svar. :- mode in `has_svar_colon_mapping_for` in is semidet. @@ -321,7 +321,7 @@ SInfo `has_svar_colon_mapping_for` StateVar :- SInfo `with_updated_svar` StateVar = ( SInfo ^ ctxt = in_atom(UpdatedStateVars, ParentSInfo) -> - SInfo ^ ctxt := in_atom(set__insert(UpdatedStateVars, StateVar), + SInfo ^ ctxt := in_atom(set.insert(UpdatedStateVars, StateVar), ParentSInfo) ; SInfo @@ -382,8 +382,7 @@ colon(Context, StateVar, Var, !VarSet, !SInfo, !IO) :- % Construct the initial and final mappings for a state variable. % :- pred new_local_state_var(svar::in, prog_var::out, prog_var::out, - prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) - is det. + prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det. new_local_state_var(StateVar, VarD, VarC, !VarSet, !SInfo) :- new_dot_state_var(StateVar, VarD, !VarSet, !SInfo), @@ -392,35 +391,32 @@ new_local_state_var(StateVar, VarD, VarC, !VarSet, !SInfo) :- % Construct the initial and final mappings for a state variable. % :- pred new_dot_state_var(svar::in, prog_var::out, - prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) - is det. + prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det. new_dot_state_var(StateVar, VarD, !VarSet, !SInfo) :- N = !.SInfo ^ num, - Name = varset__lookup_name(!.VarSet, StateVar), - NameD = string__format("STATE_VARIABLE_%s_%d", [s(Name), i(N)]), - varset__new_named_var(!.VarSet, NameD, VarD, !:VarSet), + Name = varset.lookup_name(!.VarSet, StateVar), + NameD = string.format("STATE_VARIABLE_%s_%d", [s(Name), i(N)]), + varset.new_named_var(!.VarSet, NameD, VarD, !:VarSet), !:SInfo = ( !.SInfo ^ dot ^ elem(StateVar) := VarD ). :- pred new_colon_state_var(svar::in, prog_var::out, - prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) - is det. + prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det. new_colon_state_var(StateVar, VarC, !VarSet, !SInfo) :- N = !.SInfo ^ num, - Name = varset__lookup_name(!.VarSet, StateVar), - NameC = string__format("STATE_VARIABLE_%s_%d", [s(Name), i(N)]), - varset__new_named_var(!.VarSet, NameC, VarC, !:VarSet), + Name = varset.lookup_name(!.VarSet, StateVar), + NameC = string.format("STATE_VARIABLE_%s_%d", [s(Name), i(N)]), + varset.new_named_var(!.VarSet, NameC, VarC, !:VarSet), !:SInfo = ( !.SInfo ^ colon ^ elem(StateVar) := VarC ). :- pred new_final_state_var(svar::in, prog_var::out, - prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) - is det. + prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det. new_final_state_var(StateVar, VarC, !VarSet, !SInfo) :- - Name = varset__lookup_name(!.VarSet, StateVar), - NameC = string__format("STATE_VARIABLE_%s", [s(Name)]), - varset__new_named_var(!.VarSet, NameC, VarC, !:VarSet), + Name = varset.lookup_name(!.VarSet, StateVar), + NameC = string.format("STATE_VARIABLE_%s", [s(Name)]), + varset.new_named_var(!.VarSet, NameC, VarC, !:VarSet), !:SInfo = ( !.SInfo ^ colon ^ elem(StateVar) := VarC ). %-----------------------------------------------------------------------------% @@ -437,8 +433,8 @@ prepare_for_lambda(!SInfo) :- prepare_for_body(FinalMap, !VarSet, !SInfo) :- FinalMap = !.SInfo ^ colon, N = !.SInfo ^ num + 1, - StateVars = list__merge_and_remove_dups(map__keys(!.SInfo ^ colon), - map__keys(!.SInfo ^ dot)), + StateVars = list.merge_and_remove_dups(map.keys(!.SInfo ^ colon), + map.keys(!.SInfo ^ dot)), next_svar_mappings(N, StateVars, !VarSet, Colon), !:SInfo = !.SInfo ^ ctxt := in_body, !:SInfo = !.SInfo ^ num := N, @@ -459,7 +455,7 @@ finish_goals(Context, FinalSVarMap, Goals0, Goal, SInfo) :- = hlds_goals. svar_unifiers(MaybeFeature, Context, LHSMap, RHSMap) = - map__foldl(add_svar_unifier(MaybeFeature, RHSMap, Context), LHSMap, []). + map.foldl(add_svar_unifier(MaybeFeature, RHSMap, Context), LHSMap, []). :- func add_svar_unifier(maybe(goal_feature), svar_map, prog_context, svar, prog_var, hlds_goals) = hlds_goals. @@ -492,7 +488,7 @@ svar_unification(MaybeFeature, Context, SVar, Var) = Unification :- %-----------------------------------------------------------------------------% prepare_for_local_state_vars(StateVars, !VarSet, !SInfo) :- - list__foldl2(add_new_local_state_var, StateVars, !VarSet, !SInfo). + list.foldl2(add_new_local_state_var, StateVars, !VarSet, !SInfo). :- pred add_new_local_state_var(svar::in, prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det. @@ -507,7 +503,7 @@ finish_local_state_vars(StateVars, Vars, SInfoBefore, !SInfo) :- InitColon = !.SInfo ^ colon, Dots = svar_mappings(InitDot, StateVars), Colons = svar_mappings(InitColon, StateVars), - Vars = list__sort_and_remove_dups(Dots ++ Colons), + Vars = list.sort_and_remove_dups(Dots ++ Colons), !:SInfo = !.SInfo ^ dot := del_locals(StateVars, SInfoBefore ^ dot, InitDot), !:SInfo = !.SInfo ^ colon := @@ -526,11 +522,11 @@ svar_mappings(Map, [StateVar | StateVars]) = :- func del_locals(svars, svar_map, svar_map) = svar_map. del_locals(StateVars, MapBefore, Map) = - list__foldl( + list.foldl( func(K, M) = ( if MapBefore ^ elem(K) = V then M ^ elem(K) := V - else map__delete(M, K) + else map.delete(M, K) ), StateVars, Map @@ -546,8 +542,8 @@ finish_if_then_else(Context, Then0, Then, Else0, Else, % Them arm itself. This is because the new mappings % appear only in a negated context. % - StateVars = list__merge_and_remove_dups(map__keys(SInfoT0 ^ dot), - map__keys(SInfoE ^ dot)), + StateVars = list.merge_and_remove_dups(map.keys(SInfoT0 ^ dot), + map.keys(SInfoE ^ dot)), Then0 = _ - GoalInfo, goal_to_conj_list(Then0, Thens0), add_then_arm_specific_unifiers(Context, StateVars, @@ -592,7 +588,7 @@ add_then_arm_specific_unifiers(Context, [StateVar | StateVars], new_colon_state_var(StateVar, Dot, !VarSet, !SInfoT), !:Thens = [svar_unification(yes(dont_warn_singleton), Context, Dot, Dot0) | !.Thens], - prepare_for_next_conjunct(set__make_singleton_set(StateVar), + prepare_for_next_conjunct(set.make_singleton_set(StateVar), !VarSet, !SInfoT) ; true @@ -606,7 +602,7 @@ add_then_arm_specific_unifiers(Context, [StateVar | StateVars], prog_varset::in, prog_varset::out, svar_map::out) is det. next_svar_mappings(N, StateVars, VarSet0, VarSet, Map) :- - next_svar_mappings_2(N, StateVars, VarSet0, VarSet, map__init, Map). + next_svar_mappings_2(N, StateVars, VarSet0, VarSet, map.init, Map). :- pred next_svar_mappings_2(int::in, svars::in, prog_varset::in, prog_varset::out, svar_map::in, svar_map::out) is det. @@ -626,8 +622,8 @@ finish_negation(SInfoBefore, SInfoNeg, SInfo) :- finish_disjunction(Context, VarSet, DisjSInfos, Disjs, SInfo) :- SInfo = reconciled_disj_svar_info(VarSet, DisjSInfos), - StateVars = map__keys(SInfo ^ dot), - Disjs = list__map( add_disj_unifiers(Context, SInfo, StateVars), + StateVars = map.keys(SInfo ^ dot), + Disjs = list.map( add_disj_unifiers(Context, SInfo, StateVars), DisjSInfos). % Each arm of a disjunction may have a different mapping for @@ -648,15 +644,15 @@ reconciled_disj_svar_info(VarSet, [{_, SInfo0} | DisjSInfos]) = SInfo :- % over the whole disjunction (not all arms will necessarily % include !. and !: mappings for all state variables). % - Dots0 = set__sorted_list_to_set(map__keys(SInfo0 ^ dot)), - Colons0 = set__sorted_list_to_set(map__keys(SInfo0 ^ colon)), + Dots0 = set.sorted_list_to_set(map.keys(SInfo0 ^ dot)), + Colons0 = set.sorted_list_to_set(map.keys(SInfo0 ^ colon)), Dots = union_dot_svars(Dots0, DisjSInfos), Colons = union_colon_svars(Colons0, DisjSInfos), % Then we update SInfo0 to take the highest numbered % !. and !: mapping for each state variable. % - SInfo = list__foldl(reconciled_svar_infos(VarSet, Dots, Colons), + SInfo = list.foldl(reconciled_svar_infos(VarSet, Dots, Colons), DisjSInfos, SInfo0). :- func union_dot_svars(svar_set, hlds_goal_svar_infos) = svar_set. @@ -664,7 +660,7 @@ reconciled_disj_svar_info(VarSet, [{_, SInfo0} | DisjSInfos]) = SInfo :- union_dot_svars(Dots, [] ) = Dots. union_dot_svars(Dots, [{_, SInfo} | DisjSInfos]) = union_dot_svars( - Dots `union` set__sorted_list_to_set(map__keys(SInfo ^ dot)), + Dots `union` set.sorted_list_to_set(map.keys(SInfo ^ dot)), DisjSInfos ). @@ -673,7 +669,7 @@ union_dot_svars(Dots, [{_, SInfo} | DisjSInfos]) = union_colon_svars(Colons, [] ) = Colons. union_colon_svars(Colons, [{_, SInfo} | DisjSInfos]) = union_colon_svars( - Colons `union` set__sorted_list_to_set(map__keys(SInfo ^ colon)), + Colons `union` set.sorted_list_to_set(map.keys(SInfo ^ colon)), DisjSInfos ). @@ -682,9 +678,9 @@ union_colon_svars(Colons, [{_, SInfo} | DisjSInfos]) = reconciled_svar_infos(VarSet, Dots, Colons, {_, SInfoX}, SInfo0) = SInfo :- - SInfo1 = set__fold(reconciled_svar_infos_dots(VarSet, SInfoX), + SInfo1 = set.fold(reconciled_svar_infos_dots(VarSet, SInfoX), Dots, SInfo0), - SInfo2 = set__fold(reconciled_svar_infos_colons(VarSet, SInfoX), + SInfo2 = set.fold(reconciled_svar_infos_colons(VarSet, SInfoX), Colons, SInfo1), SInfo = ( SInfo2 ^ num := max(SInfo0 ^ num, SInfoX ^ num) ). @@ -696,8 +692,8 @@ reconciled_svar_infos_dots(VarSet, SInfoX, StateVar, SInfo0) = SInfo :- DotX = SInfoX ^ dot ^ elem(StateVar), Dot0 = SInfo0 ^ dot ^ elem(StateVar) -> - NameX = varset__lookup_name(VarSet, DotX) `with_type` string, - Name0 = varset__lookup_name(VarSet, Dot0) `with_type` string, + NameX = varset.lookup_name(VarSet, DotX) `with_type` string, + Name0 = varset.lookup_name(VarSet, Dot0) `with_type` string, compare_svar_names(RDot, NameX, Name0), ( RDot = (<), @@ -721,8 +717,8 @@ reconciled_svar_infos_colons(VarSet, SInfoX, StateVar, SInfo0) = SInfo :- ColonX = SInfoX ^ colon ^ elem(StateVar), Colon0 = SInfo0 ^ colon ^ elem(StateVar) -> - NameX = varset__lookup_name(VarSet, ColonX) `with_type` string, - Name0 = varset__lookup_name(VarSet, Colon0) `with_type` string, + NameX = varset.lookup_name(VarSet, ColonX) `with_type` string, + Name0 = varset.lookup_name(VarSet, Colon0) `with_type` string, compare_svar_names(RColon, NameX, Name0), ( RColon = (<), @@ -742,7 +738,7 @@ reconciled_svar_infos_colons(VarSet, SInfoX, StateVar, SInfo0) = SInfo :- = hlds_goal. add_disj_unifiers(Context, SInfo, StateVars, {GoalX, SInfoX}) = Goal :- - Unifiers = list__foldl(add_disj_unifier(Context, SInfo, SInfoX), + Unifiers = list.foldl(add_disj_unifier(Context, SInfo, SInfoX), StateVars, []), GoalX = _ - GoalInfo, goal_to_conj_list(GoalX, GoalsX), @@ -812,7 +808,7 @@ prepare_for_call(ParentSInfo, SInfo) :- ( ParentSInfo ^ ctxt = in_atom(UpdatedStateVars, _GrandparentSInfo) -> Ctxt = in_atom(UpdatedStateVars, ParentSInfo) ; - Ctxt = in_atom(set__init, ParentSInfo) + Ctxt = in_atom(set.init, ParentSInfo) ), SInfo = ParentSInfo ^ ctxt := Ctxt. @@ -878,10 +874,10 @@ prepare_for_next_conjunct(UpdatedStateVars, !VarSet, !SInfo) :- Dot0 = !.SInfo ^ dot, Colon0 = !.SInfo ^ colon, N = !.SInfo ^ num + 1, - map__init(Nil), - map__foldl(next_dot_mapping(UpdatedStateVars, Dot0, Colon0), Colon0, + map.init(Nil), + map.foldl(next_dot_mapping(UpdatedStateVars, Dot0, Colon0), Colon0, Nil, Dot), - map__foldl2(next_colon_mapping(UpdatedStateVars, Colon0, N), Colon0, + map.foldl2(next_colon_mapping(UpdatedStateVars, Colon0, N), Colon0, !VarSet, Nil, Colon), !:SInfo = !.SInfo ^ ctxt := in_body, !:SInfo = !.SInfo ^ num := N, @@ -929,15 +925,15 @@ next_colon_mapping(UpdatedStateVars, OldColon, N, StateVar, _, prog_varset::in, prog_varset::out, svar_map::in, svar_map::out) is det. next_svar_mapping(N, StateVar, Var, !VarSet, !Map) :- - Name = string__format("STATE_VARIABLE_%s_%d", - [s(varset__lookup_name(!.VarSet, StateVar)), i(N)]), - varset__new_named_var(!.VarSet, Name, Var, !:VarSet), + Name = string.format("STATE_VARIABLE_%s_%d", + [s(varset.lookup_name(!.VarSet, StateVar)), i(N)]), + varset.new_named_var(!.VarSet, Name, Var, !:VarSet), !:Map = ( !.Map ^ elem(StateVar) := Var ). %-----------------------------------------------------------------------------% expand_bang_state_var_args(Args) = - list__foldr(expand_bang_state_var, Args, []). + list.foldr(expand_bang_state_var, Args, []). :- func expand_bang_state_var(prog_term, list(prog_term)) = list(prog_term). @@ -958,7 +954,7 @@ expand_bang_state_var(T @ functor(Const, Args, Ctxt), Ts) = expand_bang_state_var_args_in_instance_method_heads(abstract) = abstract. expand_bang_state_var_args_in_instance_method_heads(concrete(Methods)) = - concrete(list__map(expand_method_bsvs, Methods)). + concrete(list.map(expand_method_bsvs, Methods)). :- func expand_method_bsvs(instance_method) = instance_method. @@ -967,11 +963,11 @@ expand_method_bsvs(IM) = IM :- expand_method_bsvs(IM0) = IM :- IM0 = instance_method(PredOrFunc, Method, clauses(Cs0), Arity0, Ctxt), - Cs = list__map(expand_item_bsvs, Cs0), + Cs = list.map(expand_item_bsvs, Cs0), % Note that the condition should always succeed... % ( Cs = [clause(_, _, _, _, Args, _) | _] -> - adjust_func_arity(PredOrFunc, Arity, list__length(Args)) + adjust_func_arity(PredOrFunc, Arity, list.length(Args)) ; Arity = Arity0 ), @@ -1015,7 +1011,7 @@ substitute_state_var_mapping(Arg0, Arg, !VarSet, !SInfo, !IO) :- %-----------------------------------------------------------------------------% illegal_state_var_func_result(function, Args, StateVar) :- - list__last(Args, functor(atom("!"), [variable(StateVar)], _Ctxt)). + list.last(Args, functor(atom("!"), [variable(StateVar)], _Ctxt)). %-----------------------------------------------------------------------------% @@ -1029,12 +1025,12 @@ lambda_args_contain_bang_state_var([Arg | Args], StateVar) :- %-----------------------------------------------------------------------------% report_illegal_state_var_update(Context, VarSet, StateVar, !IO) :- - Name = varset__lookup_name(VarSet, StateVar), + Name = varset.lookup_name(VarSet, StateVar), Pieces = [words("Error: cannot use"), fixed("!:" ++ Name), words("in this context;"), nl, words("however"), fixed("!." ++ Name), words("may be used here.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% @@ -1042,11 +1038,11 @@ report_illegal_state_var_update(Context, VarSet, StateVar, !IO) :- prog_varset::in, svar::in, io::di, io::uo) is det. report_non_visible_state_var(DorC, Context, VarSet, StateVar, !IO) :- - Name = varset__lookup_name(VarSet, StateVar), + Name = varset.lookup_name(VarSet, StateVar), Pieces = [words("Error: state variable"), fixed("!" ++ DorC ++ Name), words("is not visible in this context.")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% @@ -1054,7 +1050,7 @@ report_non_visible_state_var(DorC, Context, VarSet, StateVar, !IO) :- svar::in, io::di, io::uo) is det. report_unitialized_state_var(Context, VarSet, StateVar, !IO) :- - Name = varset__lookup_name(VarSet, StateVar), + Name = varset.lookup_name(VarSet, StateVar), Pieces = [words("Warning: reference to unitialized state variable"), fixed("!." ++ Name), suffix("."), nl], write_error_pieces(Context, 0, Pieces, !IO), @@ -1063,24 +1059,24 @@ report_unitialized_state_var(Context, VarSet, StateVar, !IO) :- %-----------------------------------------------------------------------------% report_illegal_func_svar_result(Context, VarSet, StateVar, !IO) :- - Name = varset__lookup_name(VarSet, StateVar), + Name = varset.lookup_name(VarSet, StateVar), Pieces = [words("Error:"), fixed("!" ++ Name), words("cannot be a function result."), nl, words("You probably meant"), fixed("!." ++ Name), words("or"), fixed("!:" ++ Name), suffix("."), nl], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% report_illegal_bang_svar_lambda_arg(Context, VarSet, StateVar, !IO) :- - Name = varset__lookup_name(VarSet, StateVar), + Name = varset.lookup_name(VarSet, StateVar), Pieces = [words("Error:"), fixed("!" ++ Name), words("cannot be a lambda argument."), nl, words("Perhaps you meant"), fixed("!." ++ Name), words("or"), fixed("!:" ++ Name), suffix("."), nl], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/store_alloc.m b/compiler/store_alloc.m index 82244f766..54bcd71c3 100644 --- a/compiler/store_alloc.m +++ b/compiler/store_alloc.m @@ -25,7 +25,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__store_alloc. +:- module ll_backend.store_alloc. :- interface. :- import_module hlds.hlds_module. @@ -86,12 +86,12 @@ allocate_store_maps(RunType, PredId, ModuleInfo, !ProcInfo) :- proc_info_goal(!.ProcInfo, Goal2) ), initial_liveness(!.ProcInfo, PredId, ModuleInfo, Liveness0), - globals__get_trace_level(Globals, TraceLevel), + globals.get_trace_level(Globals, TraceLevel), module_info_pred_info(ModuleInfo, PredId, PredInfo), ( eff_trace_level_is_none(PredInfo, !.ProcInfo, TraceLevel) = no -> - trace__fail_vars(ModuleInfo, !.ProcInfo, ResumeVars0) + trace.fail_vars(ModuleInfo, !.ProcInfo, ResumeVars0) ; - set__init(ResumeVars0) + set.init(ResumeVars0) ), build_input_arg_list(!.ProcInfo, InputArgLvals), LastLocns0 = initial_last_locns(InputArgLvals), @@ -103,10 +103,10 @@ allocate_store_maps(RunType, PredId, ModuleInfo, !ProcInfo) :- :- func initial_last_locns(assoc_list(prog_var, lval)) = last_locns. -initial_last_locns([]) = map__init. +initial_last_locns([]) = map.init. initial_last_locns([Var - Lval | VarLvals]) = - map__det_insert(initial_last_locns(VarLvals), Var, - set__make_singleton_set(Lval)). + map.det_insert(initial_last_locns(VarLvals), Var, + set.make_singleton_set(Lval)). %-----------------------------------------------------------------------------% @@ -134,25 +134,25 @@ store_alloc_in_goal(Goal0 - GoalInfo0, Goal - GoalInfo, Liveness0, Liveness, goal_info_get_post_deaths(GoalInfo0, PostDeaths), goal_info_get_post_births(GoalInfo0, PostBirths), - set__difference(Liveness0, PreDeaths, Liveness1), - set__union(Liveness1, PreBirths, Liveness2), + set.difference(Liveness0, PreDeaths, Liveness1), + set.union(Liveness1, PreBirths, Liveness2), store_alloc_in_goal_2(Goal0, Goal, Liveness2, Liveness3, !LastLocns, ResumeVars0, PostDeaths, StoreAllocInfo), - set__difference(Liveness3, PostDeaths, Liveness4), + set.difference(Liveness3, PostDeaths, Liveness4), % If any variables magically become live in the PostBirths, % then they have to mundanely become live in a parallel goal, % so we don't need to allocate anything for them here. - set__union(Liveness4, PostBirths, Liveness), - ( goal_util__goal_is_branched(Goal) -> + set.union(Liveness4, PostBirths, Liveness), + ( goal_util.goal_is_branched(Goal) -> % Any variables that become magically live at the % end of the goal should not be included in the store map. % That is why we use Liveness4 instead of Liveness here. - set__union(Liveness4, ResumeVars0, MappedSet), - set__to_sorted_list(MappedSet, MappedVars), + set.union(Liveness4, ResumeVars0, MappedSet), + set.to_sorted_list(MappedSet, MappedVars), ( goal_info_maybe_get_store_map(GoalInfo0, StoreMapPrime) -> AdvisoryStoreMap = StoreMapPrime ; - AdvisoryStoreMap = map__init + AdvisoryStoreMap = map.init ), store_alloc_allocate_storage(MappedVars, StoreAllocInfo, AdvisoryStoreMap, StoreMap), @@ -328,7 +328,7 @@ merge_last_locations(LastLocnsList, LastLocns) :- ( LastLocnsList = [LastLocnsPrime | _] -> LastLocns = LastLocnsPrime ; - LastLocns = map__init + LastLocns = map.init ). %-----------------------------------------------------------------------------% @@ -354,12 +354,12 @@ store_alloc_allocate_storage(LiveVars, StoreAllocInfo, FollowVars, !:StoreMap) :- % This addresses point 1 - map__keys(FollowVars, FollowKeys), + map.keys(FollowVars, FollowKeys), store_alloc_remove_nonlive(FollowKeys, LiveVars, FollowVars, !:StoreMap), % This addresses points 3 and 4 - map__keys(!.StoreMap, StoreVars), - set__init(SeenLvals0), + map.keys(!.StoreMap, StoreVars), + set.init(SeenLvals0), store_alloc_handle_conflicts_and_nonreal(StoreVars, 1, N, SeenLvals0, SeenLvals, !StoreMap), @@ -372,10 +372,10 @@ store_alloc_allocate_storage(LiveVars, StoreAllocInfo, FollowVars, store_alloc_remove_nonlive([], _LiveVars, !StoreMap). store_alloc_remove_nonlive([Var | Vars], LiveVars, !StoreMap) :- - ( list__member(Var, LiveVars) -> + ( list.member(Var, LiveVars) -> true ; - map__delete(!.StoreMap, Var, !:StoreMap) + map.delete(!.StoreMap, Var, !:StoreMap) ), store_alloc_remove_nonlive(Vars, LiveVars, !StoreMap). @@ -386,19 +386,19 @@ store_alloc_remove_nonlive([Var | Vars], LiveVars, !StoreMap) :- store_alloc_handle_conflicts_and_nonreal([], !N, !SeenLocns, !StoreMap). store_alloc_handle_conflicts_and_nonreal([Var | Vars], !N, !SeenLocns, !StoreMap) :- - map__lookup(!.StoreMap, Var, Locn), + map.lookup(!.StoreMap, Var, Locn), ( ( Locn = any_reg - ; set__member(Locn, !.SeenLocns) + ; set.member(Locn, !.SeenLocns) ) -> next_free_reg(!.SeenLocns, !N), FinalLocn = abs_reg(!.N), - map__det_update(!.StoreMap, Var, FinalLocn, !:StoreMap) + map.det_update(!.StoreMap, Var, FinalLocn, !:StoreMap) ; FinalLocn = Locn ), - set__insert(!.SeenLocns, FinalLocn, !:SeenLocns), + set.insert(!.SeenLocns, FinalLocn, !:SeenLocns), store_alloc_handle_conflicts_and_nonreal(Vars, !N, !SeenLocns, !StoreMap). @@ -409,7 +409,7 @@ store_alloc_handle_conflicts_and_nonreal([Var | Vars], !N, !SeenLocns, store_alloc_allocate_extras([], _, _, _, !StoreMap). store_alloc_allocate_extras([Var | Vars], !.N, !.SeenLocns, StoreAllocInfo, !StoreMap) :- - ( map__contains(!.StoreMap, Var) -> + ( map.contains(!.StoreMap, Var) -> % We have already allocated a slot for this variable. true ; @@ -417,9 +417,9 @@ store_alloc_allocate_extras([Var | Vars], !.N, !.SeenLocns, StoreAllocInfo, % which means it is not in the follow vars (if any). StoreAllocInfo = store_alloc_info(_, StackSlots), ( - map__search(StackSlots, Var, StackSlot), + map.search(StackSlots, Var, StackSlot), StackSlotLocn = stack_slot_to_abs_locn(StackSlot), - \+ set__member(StackSlotLocn, !.SeenLocns) + \+ set.member(StackSlotLocn, !.SeenLocns) % Follow_vars was run, so the only reason why a var would not be % in the follow_vars set is if it was supposed to be in its stack % slot. @@ -429,8 +429,8 @@ store_alloc_allocate_extras([Var | Vars], !.N, !.SeenLocns, StoreAllocInfo, next_free_reg(!.SeenLocns, !N), Locn = abs_reg(!.N) ), - map__det_insert(!.StoreMap, Var, Locn, !:StoreMap), - set__insert(!.SeenLocns, Locn, !:SeenLocns) + map.det_insert(!.StoreMap, Var, Locn, !:StoreMap), + set.insert(!.SeenLocns, Locn, !:SeenLocns) ), store_alloc_allocate_extras(Vars, !.N, !.SeenLocns, StoreAllocInfo, !StoreMap). @@ -440,7 +440,7 @@ store_alloc_allocate_extras([Var | Vars], !.N, !.SeenLocns, StoreAllocInfo, :- pred next_free_reg(set(abs_locn)::in, int::in, int::out) is det. next_free_reg(Values, N0, N) :- - ( set__member(abs_reg(N0), Values) -> + ( set.member(abs_reg(N0), Values) -> N1 = N0 + 1, next_free_reg(Values, N1, N) ; diff --git a/compiler/stratify.m b/compiler/stratify.m index 4dd1e8266..e9b5e4855 100644 --- a/compiler/stratify.m +++ b/compiler/stratify.m @@ -28,7 +28,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__stratify. +:- module check_hlds.stratify. :- interface. :- import_module hlds.hlds_module. @@ -75,14 +75,14 @@ :- import_module std_util. :- import_module string. -stratify__check_stratification(!ModuleInfo, !IO) :- +check_stratification(!ModuleInfo, !IO) :- module_info_ensure_dependency_info(!ModuleInfo), module_info_dependency_info(!.ModuleInfo, DepInfo), hlds_dependency_info_get_dependency_graph(DepInfo, DepGraph0), - relation__atsort(DepGraph0, FOSCCs1), + relation.atsort(DepGraph0, FOSCCs1), dep_sets_to_lists_and_sets(FOSCCs1, [], FOSCCs), - globals__io_lookup_bool_option(warn_non_stratification, Warn, !IO), + globals.io_lookup_bool_option(warn_non_stratification, Warn, !IO), module_info_get_stratified_preds(!.ModuleInfo, StratifiedPreds), first_order_check_sccs(FOSCCs, StratifiedPreds, Warn, !ModuleInfo, !IO). @@ -92,7 +92,7 @@ stratify__check_stratification(!ModuleInfo, !IO) :- % higher order proc is hidden in some complex data structure % % gen_conservative_graph(Module2, DepGraph0, DepGraph, HOInfo), - % relation__atsort(DepGraph, HOSCCs1), + % relation.atsort(DepGraph, HOSCCs1), % dep_sets_to_lists_and_sets(HOSCCs1, [], HOSCCs), % higher_order_check_sccs(HOSCCs, HOInfo, !ModuleInfo, !IO). @@ -104,9 +104,9 @@ stratify__check_stratification(!ModuleInfo, !IO) :- dep_sets_to_lists_and_sets([], !DepList). dep_sets_to_lists_and_sets([PredProcSet | PredProcSets], !DepList) :- - set__to_sorted_list(PredProcSet, PredProcList), - list__map(get_proc_id, PredProcList, ProcList), - set__list_to_set(ProcList, ProcSet), + set.to_sorted_list(PredProcSet, PredProcList), + list.map(get_proc_id, PredProcList, ProcList), + set.list_to_set(ProcList, ProcSet), !:DepList = [PredProcList - ProcSet | !.DepList], dep_sets_to_lists_and_sets(PredProcSets, !DepList). @@ -125,8 +125,8 @@ first_order_check_sccs([], _, _, !ModuleInfo, !IO). first_order_check_sccs([SCCl - SCCs | Rest], StratifiedPreds, Warn0, !ModuleInfo, !IO) :- ( - set__intersect(SCCs, StratifiedPreds, Intersection), - set__empty(Intersection) + set.intersect(SCCs, StratifiedPreds, Intersection), + set.empty(Intersection) -> Warn = Warn0 ; @@ -155,7 +155,7 @@ first_order_check_scc_2([PredProcId | Remaining], WholeScc, Error, !ModuleInfo, PredProcId = proc(PredId, ProcId), module_info_pred_info(!.ModuleInfo, PredId, PredInfo), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, Proc), + map.lookup(ProcTable, ProcId, Proc), proc_info_goal(Proc, Goal - GoalInfo), first_order_check_goal(Goal, GoalInfo, no, WholeScc, PredProcId, Error, !ModuleInfo, !IO), @@ -199,7 +199,7 @@ first_order_check_goal(foreign_proc(_Attributes, CPred, CProc, _, _, _), !ModuleInfo, !IO) :- ( Negated = yes, - list__member(proc(CPred, CProc), WholeScc) + list.member(proc(CPred, CProc), WholeScc) -> goal_info_get_context(GoalInfo, Context), emit_message(ThisPredProcId, Context, @@ -214,7 +214,7 @@ first_order_check_goal(call(CPred, CProc, _Args, _BuiltinState, _Contex, _Sym), Callee = proc(CPred, CProc), ( Negated = yes, - list__member(Callee, WholeScc) + list.member(Callee, WholeScc) -> goal_info_get_context(GInfo, Context), emit_message(ThisPredProcId, Context, @@ -277,21 +277,21 @@ higher_order_check_scc([PredProcId | Remaining], WholeScc, HOInfo, !ModuleInfo, !IO) :- PredProcId = proc(PredId, ProcId), module_info_pred_info(!.ModuleInfo, PredId, PredInfo), - globals__io_lookup_bool_option(warn_non_stratification, Warn, !IO), + globals.io_lookup_bool_option(warn_non_stratification, Warn, !IO), Error = no, ( Warn = yes, - map__search(HOInfo, PredProcId, HigherOrderInfo) + map.search(HOInfo, PredProcId, HigherOrderInfo) -> HigherOrderInfo = info(HOCalls, _), - set__intersect(HOCalls, WholeScc, HOLoops), - ( set__empty(HOLoops) -> + set.intersect(HOCalls, WholeScc, HOLoops), + ( set.empty(HOLoops) -> HighOrderLoops = no ; HighOrderLoops = yes ), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, Proc), + map.lookup(ProcTable, ProcId, Proc), proc_info_goal(Proc, Goal - GoalInfo), higher_order_check_goal(Goal, GoalInfo, no, WholeScc, PredProcId, HighOrderLoops, Error, !ModuleInfo, !IO) @@ -439,9 +439,9 @@ higher_order_check_case_list([Case | Goals], Negated, WholeScc, ThisPredProcId, gen_conservative_graph(ModuleInfo, !DepGraph, HOInfo) :- get_call_info(ModuleInfo, ProcCalls, HOInfo0, CallsHO), - map__keys(ProcCalls, Callers), + map.keys(ProcCalls, Callers), iterate_solution(Callers, ProcCalls, CallsHO, HOInfo0, HOInfo), - map__to_assoc_list(HOInfo, HOInfoL), + map.to_assoc_list(HOInfo, HOInfoL), add_new_arcs(HOInfoL, CallsHO, !DepGraph). % For a given module, collects for each non imported procedure @@ -453,9 +453,9 @@ gen_conservative_graph(ModuleInfo, !DepGraph, HOInfo) :- set(pred_proc_id)::out) is det. get_call_info(ModuleInfo, !:ProcCalls, !:HOInfo, !:CallsHO) :- - map__init(!:ProcCalls), - map__init(!:HOInfo), - set__init(!:CallsHO), + map.init(!:ProcCalls), + map.init(!:HOInfo), + set.init(!:CallsHO), module_info_predids(ModuleInfo, PredIds), expand_predids(PredIds, ModuleInfo, !ProcCalls, !HOInfo, !CallsHO). @@ -483,8 +483,8 @@ iterate_solution(PredProcs, ProcCalls, CallsHO, !HOInfo) :- tc([], _, _, !HOInfo, !Changed). tc([PredProcId | PredProcIds], ProcCalls, CallsHO, !HOInfo, !Changed) :- - map__lookup(ProcCalls, PredProcId, PCalls), - set__to_sorted_list(PCalls, PCallsL), + map.lookup(ProcCalls, PredProcId, PCalls), + set.to_sorted_list(PCalls, PCallsL), merge_calls(PCallsL, PredProcId, CallsHO, yes, !HOInfo, !Changed), tc(PredProcIds, ProcCalls, CallsHO, !HOInfo, !Changed). @@ -498,8 +498,8 @@ tc([PredProcId | PredProcIds], ProcCalls, CallsHO, !HOInfo, !Changed) :- merge_calls([], _, _, _, !HOInfo, !Changed). merge_calls([C | Cs], P, CallsHO, DoingFirstOrder, !HOInfo, !Changed) :- - ( map__search(!.HOInfo, C, CInfo) -> - map__lookup(!.HOInfo, P, PInfo), + ( map.search(!.HOInfo, C, CInfo) -> + map.lookup(!.HOInfo, P, PInfo), CInfo = info(CHaveAT0, CHOInOut), PInfo = info(PHaveAT0, PHOInOut), % First merge the first order info, if we need to. @@ -508,19 +508,19 @@ merge_calls([C | Cs], P, CallsHO, DoingFirstOrder, !HOInfo, !Changed) :- ; ( CHOInOut = ho_in, - ( set__subset(PHaveAT0, CHaveAT0) -> + ( set.subset(PHaveAT0, CHaveAT0) -> CHaveAT = CHaveAT0 ; - set__union(PHaveAT0, CHaveAT0, CHaveAT), + set.union(PHaveAT0, CHaveAT0, CHaveAT), !:Changed = yes ), PHaveAT = PHaveAT0 ; CHOInOut = ho_out, - ( set__subset(CHaveAT0, PHaveAT0) -> + ( set.subset(CHaveAT0, PHaveAT0) -> PHaveAT = PHaveAT0 ; - set__union(CHaveAT0, PHaveAT0, PHaveAT), + set.union(CHaveAT0, PHaveAT0, PHaveAT), !:Changed = yes ), CHaveAT = CHaveAT0 @@ -530,7 +530,7 @@ merge_calls([C | Cs], P, CallsHO, DoingFirstOrder, !HOInfo, !Changed) :- CHaveAT = CHaveAT0, PHaveAT = PHaveAT0 ; - set__union(CHaveAT0, PHaveAT0, NewHaveAT), + set.union(CHaveAT0, PHaveAT0, NewHaveAT), CHaveAT = NewHaveAT, PHaveAT = NewHaveAT, !:Changed = yes @@ -542,17 +542,17 @@ merge_calls([C | Cs], P, CallsHO, DoingFirstOrder, !HOInfo, !Changed) :- ), NewCInfo = info(CHaveAT, CHOInOut), NewPInfo = info(PHaveAT, PHOInOut), - map__det_update(!.HOInfo, C, NewCInfo, !:HOInfo), - map__det_update(!.HOInfo, P, NewPInfo, !:HOInfo) + map.det_update(!.HOInfo, C, NewCInfo, !:HOInfo), + map.det_update(!.HOInfo, P, NewPInfo, !:HOInfo) ), % Then, if we need to, merge the higher order info. ( DoingFirstOrder = yes, - set__member(P, CallsHO) + set.member(P, CallsHO) -> - map__lookup(!.HOInfo, P, PHOInfo), + map.lookup(!.HOInfo, P, PHOInfo), PHOInfo = info(PossibleCalls, _), - set__to_sorted_list(PossibleCalls, PossibleCallsL), + set.to_sorted_list(PossibleCalls, PossibleCallsL), merge_calls(PossibleCallsL, P, CallsHO, no, !HOInfo, !Changed) ; true @@ -572,10 +572,10 @@ merge_calls([C | Cs], P, CallsHO, DoingFirstOrder, !HOInfo, !Changed) :- add_new_arcs([], _, !DepGraph). add_new_arcs([Caller - CallerInfo | Cs], CallsHO, !DepGraph) :- % Only add arcs for callers who call higher order procs. - ( set__member(Caller, CallsHO) -> + ( set.member(Caller, CallsHO) -> CallerInfo = info(PossibleCallees0, _), - set__to_sorted_list(PossibleCallees0, PossibleCallees), - relation__lookup_element(!.DepGraph, Caller, CallerKey), + set.to_sorted_list(PossibleCallees0, PossibleCallees), + relation.lookup_element(!.DepGraph, Caller, CallerKey), add_new_arcs2(PossibleCallees, CallerKey, !DepGraph) ; true @@ -587,8 +587,8 @@ add_new_arcs([Caller - CallerInfo | Cs], CallsHO, !DepGraph) :- add_new_arcs2([], _, !DepGraph). add_new_arcs2([Callee | Cs], CallerKey, !DepGraph) :- - relation__lookup_element(!.DepGraph, Callee, CalleeKey), - relation__add(!.DepGraph, CallerKey, CalleeKey, !:DepGraph), + relation.lookup_element(!.DepGraph, Callee, CalleeKey), + relation.add(!.DepGraph, CallerKey, CalleeKey, !:DepGraph), add_new_arcs2(Cs, CallerKey, !DepGraph). % For each given pred id, pass all non imported procs onto the @@ -620,17 +620,17 @@ expand_predids([PredId | PredIds], ModuleInfo, !ProcCalls, !HOInfo, process_procs([], _, _, _, _, !ProcCalls, !HOInfo, !CallsHO). process_procs([ProcId | Procs], ModuleInfo, PredId, ArgTypes, ProcTable, !ProcCalls, !HOInfo, !CallsHO) :- - map__lookup(ProcTable, ProcId, ProcInfo), + map.lookup(ProcTable, ProcId, ProcInfo), proc_info_argmodes(ProcInfo, ArgModes), proc_info_goal(ProcInfo, Goal - _GoalInfo), PredProcId = proc(PredId, ProcId), check_goal(Goal, Calls, HaveAT, CallsHigherOrder), - map__det_insert(!.ProcCalls, PredProcId, Calls, !:ProcCalls), + map.det_insert(!.ProcCalls, PredProcId, Calls, !:ProcCalls), higherorder_in_out(ArgTypes, ArgModes, ModuleInfo, HOInOut), - map__det_insert(!.HOInfo, PredProcId, info(HaveAT, HOInOut), !:HOInfo), + map.det_insert(!.HOInfo, PredProcId, info(HaveAT, HOInOut), !:HOInfo), ( CallsHigherOrder = yes, - set__insert(!.CallsHO, PredProcId, !:CallsHO) + set.insert(!.CallsHO, PredProcId, !:CallsHO) ; CallsHigherOrder = no ), @@ -689,8 +689,8 @@ higherorder_in_out1([Type | Types], [Mode | Modes], ModuleInfo, set(pred_proc_id)::out, bool::out) is det. check_goal(Goal, Calls, TakenAddrs, CallsHO) :- - set__init(Calls0), - set__init(TakenAddrs0), + set.init(Calls0), + set.init(TakenAddrs0), check_goal1(Goal, Calls0, Calls, TakenAddrs0, TakenAddrs, no, CallsHO). :- pred check_goal1(hlds_goal_expr::in, @@ -709,7 +709,7 @@ check_goal1(unify(_Var, RHS, _Mode, Unification, _Context), !Calls, _Modes, _Determinism, Goal - _GoalInfo) -> get_called_procs(Goal, [], CalledProcs), - set__insert_list(!.HasAT, CalledProcs, !:HasAT) + set.insert_list(!.HasAT, CalledProcs, !:HasAT) ; % Currently when this pass is run the construct/4 case will not happen % as higher order constants have been transformed to lambda goals. @@ -718,7 +718,7 @@ check_goal1(unify(_Var, RHS, _Mode, Unification, _Context), !Calls, -> ( ConsId = pred_const(ShroudedPredProcId, _) -> PredProcId = unshroud_pred_proc_id(ShroudedPredProcId), - set__insert(!.HasAT, PredProcId, !:HasAT) + set.insert(!.HasAT, PredProcId, !:HasAT) ; true ) @@ -728,7 +728,7 @@ check_goal1(unify(_Var, RHS, _Mode, Unification, _Context), !Calls, check_goal1(call(CPred, CProc, _Args, _Builtin, _Contex, _Sym), !Calls, !HasAT, !CallsHO) :- % Add this call to the call list. - set__insert(!.Calls, proc(CPred, CProc), !:Calls). + set.insert(!.Calls, proc(CPred, CProc), !:Calls). check_goal1(generic_call(_Var, _Vars, _Modes, _Det), !Calls, !HasAT, _, yes). % Record that the higher order call was made. check_goal1(conj(_ConjType, Goals), !Calls, !HasAT, !CallsHO) :- @@ -867,7 +867,7 @@ emit_message(PPId, Context, Message, Error, !ModuleInfo, !IO) :- ErrOrWarnMsg = words("error:") ), ErrMsgMiddle = [ ErrOrWarnMsg, words(Message) ], - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, ErrMsgFinal = [ nl, diff --git a/compiler/string_switch.m b/compiler/string_switch.m index 6acdfd170..515f6dcf5 100644 --- a/compiler/string_switch.m +++ b/compiler/string_switch.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__string_switch. +:- module ll_backend.string_switch. :- interface. :- import_module backend_libs.switch_util. @@ -53,27 +53,27 @@ generate_string_switch(Cases, Var, CodeModel, _CanFail, SwitchGoalInfo, EndLabel, !MaybeEnd, Code, !CI) :- - code_info__produce_variable(Var, VarCode, VarRval, !CI), - code_info__acquire_reg(r, SlotReg, !CI), - code_info__acquire_reg(r, StringReg, !CI), - code_info__get_next_label(LoopLabel, !CI), - code_info__get_next_label(FailLabel, !CI), - code_info__get_next_label(JumpLabel, !CI), + code_info.produce_variable(Var, VarCode, VarRval, !CI), + code_info.acquire_reg(r, SlotReg, !CI), + code_info.acquire_reg(r, StringReg, !CI), + code_info.get_next_label(LoopLabel, !CI), + code_info.get_next_label(FailLabel, !CI), + code_info.get_next_label(JumpLabel, !CI), % Determine how big to make the hash table. Currently we round the number % of cases up to the nearest power of two, and then double it. % This should hopefully ensure that we don't get too many hash collisions. - list__length(Cases, NumCases), - int__log2(NumCases, LogNumCases), - int__pow(2, LogNumCases, RoundedNumCases), + list.length(Cases, NumCases), + int.log2(NumCases, LogNumCases), + int.pow(2, LogNumCases, RoundedNumCases), TableSize = 2 * RoundedNumCases, HashMask = TableSize - 1, % Compute the hash table. - switch_util__string_hash_cases(Cases, HashMask, HashValsMap), - map__to_assoc_list(HashValsMap, HashValsList), - switch_util__calc_hash_slots(HashValsList, HashValsMap, HashSlotsMap), + switch_util.string_hash_cases(Cases, HashMask, HashValsMap), + map.to_assoc_list(HashValsMap, HashValsList), + switch_util.calc_hash_slots(HashValsList, HashValsMap, HashSlotsMap), % Note that it is safe to release the registers now, even though we haven't % yet generated all the code which uses them, because that code will be @@ -81,13 +81,13 @@ generate_string_switch(Cases, Var, CodeModel, _CanFail, SwitchGoalInfo, % registers), and because that code is generated manually (below) % so we don't need the reg info to be valid when we generate it. - code_info__release_reg(SlotReg, !CI), - code_info__release_reg(StringReg, !CI), + code_info.release_reg(SlotReg, !CI), + code_info.release_reg(StringReg, !CI), % Generate the code for when the hash lookup fails. This must be done % before gen_hash_slots, since we want to use the exprn_info corresponding % to the start of the switch, not to the end of the last case. - code_info__generate_failure(FailCode, !CI), + code_info.generate_failure(FailCode, !CI), % Generate the code etc. for the hash table. gen_hash_slots(0, TableSize, HashSlotsMap, CodeModel, SwitchGoalInfo, @@ -165,7 +165,7 @@ gen_hash_slots(Slot, TableSize, HashSlotMap, CodeModel, SwitchGoalInfo, gen_hash_slot(Slot, TblSize, HashSlotMap, CodeModel, SwitchGoalInfo, FailLabel, EndLabel, !MaybeEnd, StringRval, Label, NextSlotRval, Code, !CI) :- - ( map__search(HashSlotMap, Slot, hash_slot(Case, Next)) -> + ( map.search(HashSlotMap, Slot, hash_slot(Case, Next)) -> NextSlotRval = const(int_const(Next)), Case = case(_, ConsTag, _, Goal), ( ConsTag = string_constant(String0) -> @@ -174,19 +174,19 @@ gen_hash_slot(Slot, TblSize, HashSlotMap, CodeModel, SwitchGoalInfo, FailLabel, unexpected(this_file, "gen_hash_slots: string expected") ), StringRval = const(string_const(String)), - code_info__get_next_label(Label, !CI), - string__append_list(["case """, String, """"], Comment), + code_info.get_next_label(Label, !CI), + string.append_list(["case """, String, """"], Comment), LabelCode = node([label(Label) - Comment]), - code_info__remember_position(!.CI, BranchStart), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + code_info.remember_position(!.CI, BranchStart), + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), goal_info_get_store_map(SwitchGoalInfo, StoreMap), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), ( this_is_last_case(Slot, TblSize, HashSlotMap) -> true ; - code_info__reset_to_position(BranchStart, !CI) + code_info.reset_to_position(BranchStart, !CI) ), FinishCode = node([goto(label(EndLabel)) - "jump to end of switch"]), Code = tree_list([LabelCode, TraceCode, GoalCode, SaveCode, @@ -206,7 +206,7 @@ this_is_last_case(Slot, TableSize, Table) :- ( Slot1 >= TableSize -> true ; - \+ map__contains(Table, Slot1), + \+ map.contains(Table, Slot1), this_is_last_case(Slot1, TableSize, Table) ). diff --git a/compiler/superhomogeneous.m b/compiler/superhomogeneous.m index ab76dba3e..deb38c69d 100644 --- a/compiler/superhomogeneous.m +++ b/compiler/superhomogeneous.m @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module hlds__make_hlds__superhomogeneous. +:- module hlds.make_hlds.superhomogeneous. :- interface. :- import_module hlds.hlds_goal. @@ -182,7 +182,7 @@ insert_arg_unifications_2([Var | Vars], [Arg | Args], Context, ArgContext, ArgUnifyConj = [_ | _], insert_arg_unifications_2(Vars, Args, Context, ArgContext, N1, !Goals, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), - list__append(ArgUnifyConj, !.Goals, !:Goals) + list.append(ArgUnifyConj, !.Goals, !:Goals) ). insert_arg_unifications_with_supplied_contexts(ArgVars, ArgTerms0, ArgContexts, @@ -227,7 +227,7 @@ insert_arg_unifications_with_supplied_contexts_2(Vars, Terms, ArgContexts, insert_arg_unifications_with_supplied_contexts_2(VarsTail, TermsTail, ArgContextsTail, Context, !Goals, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), - list__append(UnifyConj, !.Goals, !:Goals) + list.append(UnifyConj, !.Goals, !:Goals) ; unexpected(this_file, "insert_arg_unifications_with_supplied_contexts") ). @@ -240,13 +240,13 @@ insert_arg_unifications_with_supplied_contexts_2(Vars, Terms, ArgContexts, insert_arg_unification(Var, Arg, Context, ArgContext, N1, !VarSet, ArgUnifyConj, !ModuleInfo, !QualInfo, !SInfo, !IO) :- - ( Arg = term__variable(Var) -> + ( Arg = term.variable(Var) -> % Skip unifications of the form `X = X' ArgUnifyConj = [] ; arg_context_to_unify_context(ArgContext, N1, UnifyMainContext, UnifySubContext), - unravel_unification(term__variable(Var), Arg, Context, + unravel_unification(term.variable(Var), Arg, Context, UnifyMainContext, UnifySubContext, purity_pure, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), goal_to_conj_list(Goal, ArgUnifyConj) @@ -287,7 +287,7 @@ append_arg_unifications_2([Var|Vars], [Arg|Args], Context, ArgContext, N1 = N0 + 1, append_arg_unification(Var, Arg, Context, ArgContext, N1, ConjList, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), - list__append(!.List, ConjList, !:List), + list.append(!.List, ConjList, !:List), append_arg_unifications_2(Vars, Args, Context, ArgContext, N1, !List, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO). @@ -299,13 +299,13 @@ append_arg_unifications_2([Var|Vars], [Arg|Args], Context, ArgContext, append_arg_unification(Var, Arg, Context, ArgContext, N1, ConjList, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) :- - ( Arg = term__variable(Var) -> + ( Arg = term.variable(Var) -> % skip unifications of the form `X = X' ConjList = [] ; arg_context_to_unify_context(ArgContext, N1, UnifyMainContext, UnifySubContext), - unravel_unification(term__variable(Var), Arg, Context, + unravel_unification(term.variable(Var), Arg, Context, UnifyMainContext, UnifySubContext, purity_pure, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), goal_to_conj_list(Goal, ConjList) @@ -331,7 +331,7 @@ arg_context_to_unify_context(functor(ConsId, MainContext, SubContexts), ArgNum, make_fresh_arg_vars(Args, Vars, !VarSet, !SInfo, !IO) :- make_fresh_arg_vars_2(Args, [], Vars1, !VarSet, !SInfo, !IO), - list__reverse(Vars1, Vars). + list.reverse(Vars1, Vars). :- pred make_fresh_arg_vars_2(list(prog_term)::in, list(prog_var)::in, list(prog_var)::out, prog_varset::in,prog_varset::out, @@ -345,12 +345,12 @@ make_fresh_arg_vars_2([Arg | Args], Vars0, Vars, !VarSet, !SInfo, !IO) :- make_fresh_arg_var(Arg0, Var, Vars0, !VarSet, !SInfo, !IO) :- substitute_state_var_mapping(Arg0, Arg, !VarSet, !SInfo, !IO), ( - Arg = term__variable(ArgVar), - \+ list__member(ArgVar, Vars0) + Arg = term.variable(ArgVar), + \+ list.member(ArgVar, Vars0) -> Var = ArgVar ; - varset__new_var(!.VarSet, Var, !:VarSet) + varset.new_var(!.VarSet, Var, !:VarSet) ). %-----------------------------------------------------------------------------% @@ -375,7 +375,7 @@ unravel_unification(LHS0, RHS0, Context, MainContext, SubContext, % `X = Y' needs no unravelling. -unravel_unification_2(term__variable(X), term__variable(Y), Context, +unravel_unification_2(term.variable(X), term.variable(Y), Context, MainContext, SubContext, Purity, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) :- make_atomic_unification(X, var(Y), Context, MainContext, SubContext, @@ -390,33 +390,33 @@ unravel_unification_2(term__variable(X), term__variable(Y), Context, % NewVar3 = A3. % In the trivial case `X = c', no unravelling occurs. -unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, +unravel_unification_2(term.variable(X), RHS, Context, MainContext, SubContext, Purity, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) :- - RHS = term__functor(F, Args1, FunctorContext), + RHS = term.functor(F, Args1, FunctorContext), substitute_state_var_mappings(Args1, Args, !VarSet, !SInfo, !IO), ( % Handle explicit type qualification. ( - F = term__atom("with_type") + F = term.atom("with_type") ; - F = term__atom(":") + F = term.atom(":") ), Args = [RVal, DeclType0] -> % DeclType0 is a prog_term, but it is really a type so we coerce it % to a generic term before parsing it. - term__coerce(DeclType0, DeclType1), + term.coerce(DeclType0, DeclType1), parse_type(DeclType1, DeclTypeResult), ( DeclTypeResult = ok(DeclType), - varset__coerce(!.VarSet, DeclVarSet), + varset.coerce(!.VarSet, DeclVarSet), process_type_qualification(X, DeclType, DeclVarSet, Context, !ModuleInfo, !QualInfo, !IO) ; DeclTypeResult = error(Msg, ErrorTerm), % The varset is a prog_varset even though it contains the names % of type variables in ErrorTerm, which is a generic term. - GenericVarSet = varset__coerce(!.VarSet), + GenericVarSet = varset.coerce(!.VarSet), TermStr = mercury_term_to_string(ErrorTerm, GenericVarSet, no), Pieces = [words("In explicit type qualification:"), words(Msg), @@ -425,29 +425,29 @@ unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, write_error_pieces(Context, 0, Pieces, !IO), io.set_exit_status(1, !IO) ), - unravel_unification(term__variable(X), RVal, Context, MainContext, + unravel_unification(term.variable(X), RVal, Context, MainContext, SubContext, Purity, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) ; % Handle unification expressions. - F = term__atom("@"), + F = term.atom("@"), Args = [LVal, RVal] -> - unravel_unification(term__variable(X), LVal, Context, + unravel_unification(term.variable(X), LVal, Context, MainContext, SubContext, Purity, Goal1, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), - unravel_unification(term__variable(X), RVal, Context, + unravel_unification(term.variable(X), RVal, Context, MainContext, SubContext, Purity, Goal2, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), goal_info_init(GoalInfo), goal_to_conj_list(Goal1, ConjList1), goal_to_conj_list(Goal2, ConjList2), - list__append(ConjList1, ConjList2, ConjList), + list.append(ConjList1, ConjList2, ConjList), conj_list_to_goal(ConjList, GoalInfo, Goal) ; % Handle higher-order pred and func expressions. parse_rule_term(Context, RHS, HeadTerm0, GoalTerm1), - term__coerce(HeadTerm0, HeadTerm1), + term.coerce(HeadTerm0, HeadTerm1), parse_purity_annotation(HeadTerm1, LambdaPurity, HeadTerm), ( parse_pred_expression(HeadTerm, EvalMethod0, Vars0, Modes0, Det0) @@ -462,10 +462,10 @@ unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, PredOrFunc = function ) -> - add_clause__qualify_lambda_mode_list(Modes1, Modes, Context, + add_clause.qualify_lambda_mode_list(Modes1, Modes, Context, !QualInfo, !IO), Det = Det1, - term__coerce(GoalTerm1, GoalTerm), + term.coerce(GoalTerm1, GoalTerm), parse_goal(GoalTerm, ParsedGoal, !VarSet), build_lambda_expression(X, Purity, LambdaPurity, PredOrFunc, EvalMethod, Vars1, Modes, Det, ParsedGoal, Context, MainContext, @@ -475,17 +475,17 @@ unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, % same semantics as higher-order pred expressions, % but has two extra arguments, and the goal is expanded % as a DCG goal. - F = term__atom("-->"), + F = term.atom("-->"), Args = [PredTerm0, GoalTerm0], - term__coerce(PredTerm0, PredTerm1), + term.coerce(PredTerm0, PredTerm1), parse_purity_annotation(PredTerm1, DCGLambdaPurity, PredTerm), parse_dcg_pred_expression(PredTerm, EvalMethod, Vars0, Modes0, Det) -> - add_clause__qualify_lambda_mode_list(Modes0, Modes, Context, !QualInfo, + add_clause.qualify_lambda_mode_list(Modes0, Modes, Context, !QualInfo, !IO), - term__coerce(GoalTerm0, GoalTerm), + term.coerce(GoalTerm0, GoalTerm), parse_dcg_pred_goal(GoalTerm, ParsedGoal, DCG0, DCGn, !VarSet), - list__append(Vars0, [term__variable(DCG0), term__variable(DCGn)], + list.append(Vars0, [term.variable(DCG0), term.variable(DCGn)], Vars1), build_lambda_expression(X, Purity, DCGLambdaPurity, predicate, EvalMethod, Vars1, Modes, Det, ParsedGoal, Context, MainContext, @@ -496,36 +496,36 @@ unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, ; % handle if-then-else expressions ( - F = term__atom("else"), - IfThenTerm = term__functor( - term__atom("if"), - [term__functor(term__atom("then"), [IfTerm0, ThenTerm], _)], + F = term.atom("else"), + IfThenTerm = term.functor( + term.atom("if"), + [term.functor(term.atom("then"), [IfTerm0, ThenTerm], _)], _), Args = [IfThenTerm, ElseTerm] ; - F = term__atom(";"), - Args = [term__functor(term__atom("->"), [IfTerm0, ThenTerm], _), + F = term.atom(";"), + Args = [term.functor(term.atom("->"), [IfTerm0, ThenTerm], _), ElseTerm] ), - term__coerce(IfTerm0, IfTerm), + term.coerce(IfTerm0, IfTerm), parse_some_vars_goal(IfTerm, Vars, StateVars, IfParseTree, !VarSet) -> BeforeSInfo = !.SInfo, prepare_for_if_then_else_expr(StateVars, !VarSet, !SInfo), - map__init(EmptySubst), + map.init(EmptySubst), transform_goal(IfParseTree, EmptySubst, IfGoal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), finish_if_then_else_expr_condition(BeforeSInfo, !SInfo), - unravel_unification(term__variable(X), ThenTerm, + unravel_unification(term.variable(X), ThenTerm, Context, MainContext, SubContext, Purity, ThenGoal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), finish_if_then_else_expr_then_goal(StateVars, BeforeSInfo, !SInfo), - unravel_unification(term__variable(X), ElseTerm, + unravel_unification(term.variable(X), ElseTerm, Context, MainContext, SubContext, Purity, ElseGoal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), @@ -535,7 +535,7 @@ unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, Goal = IfThenElse - GoalInfo ; % handle field extraction expressions - F = term__atom("^"), + F = term.atom("^"), Args = [InputTerm, FieldNameTerm], parse_field_list(FieldNameTerm, FieldNameResult), FieldNameResult = ok(FieldNames) @@ -551,9 +551,9 @@ unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) ; % handle field update expressions - F = term__atom(":="), + F = term.atom(":="), Args = [FieldDescrTerm, FieldValueTerm], - FieldDescrTerm = term__functor(term__atom("^"), + FieldDescrTerm = term.functor(term.atom("^"), [InputTerm, FieldNameTerm], _), parse_field_list(FieldNameTerm, FieldNameResult), FieldNameResult = ok(FieldNames) @@ -582,13 +582,13 @@ unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, parse_qualified_term(RHS, RHS, "", MaybeFunctor), ( MaybeFunctor = ok(FunctorName, FunctorArgs), - list__length(FunctorArgs, Arity), + list.length(FunctorArgs, Arity), ConsId = cons(FunctorName, Arity) ; % float, int or string constant % - any errors will be caught by typechecking MaybeFunctor = error(_, _), - list__length(Args, Arity), + list.length(Args, Arity), ConsId = make_functor_cons_id(F, Arity), FunctorArgs = Args ), @@ -648,9 +648,9 @@ unravel_unification_2(term__variable(X), RHS, Context, MainContext, SubContext, % Handle `f(...) = X' in the same way as `X = f(...)'. -unravel_unification_2(term__functor(F, As, FC), term__variable(Y), C, MC, SC, +unravel_unification_2(term.functor(F, As, FC), term.variable(Y), C, MC, SC, Purity, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) :- - unravel_unification(term__variable(Y), term__functor(F, As, FC), C, MC, SC, + unravel_unification(term.variable(Y), term.functor(F, As, FC), C, MC, SC, Purity, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO). % If we find a unification of the form `f1(...) = f2(...)', @@ -659,28 +659,28 @@ unravel_unification_2(term__functor(F, As, FC), term__variable(Y), C, MC, SC, % Note that we can't simplify it yet, because we might simplify % away type errors. -unravel_unification_2(term__functor(LeftF, LeftAs, LeftC), - term__functor(RightF, RightAs, RightC), +unravel_unification_2(term.functor(LeftF, LeftAs, LeftC), + term.functor(RightF, RightAs, RightC), Context, MainContext, SubContext, Purity, Goal, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO) :- - varset__new_var(!.VarSet, TmpVar, !:VarSet), - unravel_unification(term__variable(TmpVar), - term__functor(LeftF, LeftAs, LeftC), + varset.new_var(!.VarSet, TmpVar, !:VarSet), + unravel_unification(term.variable(TmpVar), + term.functor(LeftF, LeftAs, LeftC), Context, MainContext, SubContext, Purity, Goal0, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), - unravel_unification(term__variable(TmpVar), - term__functor(RightF, RightAs, RightC), + unravel_unification(term.variable(TmpVar), + term.functor(RightF, RightAs, RightC), Context, MainContext, SubContext, Purity, Goal1, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO), goal_info_init(GoalInfo), goal_to_conj_list(Goal0, ConjList0), goal_to_conj_list(Goal1, ConjList1), - list__append(ConjList0, ConjList1, ConjList), + list.append(ConjList0, ConjList1, ConjList), conj_list_to_goal(ConjList, GoalInfo, Goal). :- pred ground_term(term(T)::in) is semidet. -ground_term(term__functor(_, Terms, _)) :- +ground_term(term.functor(_, Terms, _)) :- ground_terms(Terms). :- pred ground_terms(list(term(T))::in) is semidet. diff --git a/compiler/switch_detection.m b/compiler/switch_detection.m index 7eae549f9..f0e3b35a0 100644 --- a/compiler/switch_detection.m +++ b/compiler/switch_detection.m @@ -15,7 +15,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__switch_detection. +:- module check_hlds.switch_detection. :- interface. :- import_module hlds.hlds_goal. @@ -93,7 +93,7 @@ detect_switches(!ModuleInfo, !IO) :- detect_switches_in_preds([], !ModuleInfo, !IO). detect_switches_in_preds([PredId | PredIds], !ModuleInfo, !IO) :- module_info_preds(!.ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), detect_switches_in_pred(PredId, PredInfo, !ModuleInfo, !IO), detect_switches_in_preds(PredIds, !ModuleInfo, !IO). @@ -121,9 +121,9 @@ detect_switches_in_procs([ProcId | ProcIds], PredId, !ModuleInfo) :- detect_switches_in_proc(ProcId, PredId, !ModuleInfo) :- module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo0), + map.lookup(PredTable0, PredId, PredInfo0), pred_info_procedures(PredInfo0, ProcTable0), - map__lookup(ProcTable0, ProcId, ProcInfo0), + map.lookup(ProcTable0, ProcId, ProcInfo0), % To process each ProcInfo, we get the goal, initialize the instmap % based on the modes of the head vars, and pass these to @@ -142,9 +142,9 @@ detect_switches_in_proc(ProcId, PredId, !ModuleInfo) :- Requant = no, ProcInfo = ProcInfo1 ), - map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable), + map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, PredInfo0, PredInfo), - map__det_update(PredTable0, PredId, PredInfo, PredTable), + map.det_update(PredTable0, PredId, PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo). %-----------------------------------------------------------------------------% @@ -189,7 +189,7 @@ detect_switches_in_goal_2(ModuleInfo, VarTypes, InstMap0, GoalInfo, ; Goals0 = [_ | _], goal_info_get_nonlocals(GoalInfo, NonLocals), - set__to_sorted_list(NonLocals, NonLocalsList), + set.to_sorted_list(NonLocals, NonLocalsList), detect_switches_in_disj(NonLocalsList, Goals0, GoalInfo, InstMap0, VarTypes, NonLocalsList, ModuleInfo, [], Goal, !Requant) ) @@ -234,7 +234,7 @@ detect_switches_in_goal_2(ModuleInfo, VarTypes, InstMap0, GoalInfo, ( RHS0 = lambda_goal(_, _, _, _, Vars, Modes, _, LambdaGoal0) -> % We need to insert the initial insts for the lambda variables % in the instmap before processing the lambda goal. - instmap__pre_lambda_update(ModuleInfo, Vars, Modes, + instmap.pre_lambda_update(ModuleInfo, Vars, Modes, InstMap0, InstMap1), detect_switches_in_goal(ModuleInfo, VarTypes, InstMap1, LambdaGoal0, LambdaGoal, !Requant), @@ -266,7 +266,8 @@ detect_switches_in_goal_2(ModuleInfo, VarTypes, InstMap0, GoalInfo, % the sorted_case_list should always be sorted on cons_id - % `delete_unreachable_cases' relies on this. -:- type again ---> again(prog_var, list(hlds_goal), sorted_case_list). +:- type again + ---> again(prog_var, list(hlds_goal), sorted_case_list). % This is the interesting bit - we've found a non-empty disjunction, % and we've got a list of the non-local variables of that disjunction. @@ -283,7 +284,7 @@ detect_switches_in_disj([Var | Vars], Goals0, GoalInfo, InstMap, VarTypes, AllVars, ModuleInfo, Again0, Goal, !Requant) :- % Can we do at least a partial switch on this variable? ( - instmap__lookup_var(InstMap, Var, VarInst0), + instmap.lookup_var(InstMap, Var, VarInst0), inst_is_bound(ModuleInfo, VarInst0), partition_disj(Goals0, Var, GoalInfo, Left, CasesList, !Requant) -> @@ -348,8 +349,8 @@ select_best_switch([Again | AgainList], BestAgain0, BestAgain) :- ( Again = again(_, _, CasesList), BestAgain0 = again(_, _, BestCasesList), - list__length(CasesList, Length), - list__length(BestCasesList, BestLength), + list.length(CasesList, Length), + list.length(BestCasesList, BestLength), Length < BestLength -> BestAgain1 = BestAgain0 @@ -425,9 +426,9 @@ detect_switches_in_conj(ModuleInfo, VarTypes, InstMap0, is semidet. partition_disj(Goals0, Var, GoalInfo, Left, CasesList, !Requant) :- - map__init(Cases0), + map.init(Cases0), partition_disj_trial(Goals0, Var, [], Left1, Cases0, Cases1), - map__to_assoc_list(Cases1, CasesAssocList1), + map.to_assoc_list(Cases1, CasesAssocList1), CasesAssocList1 = [_ | _], % There must be at least one case. ( Left1 = [], @@ -437,7 +438,7 @@ partition_disj(Goals0, Var, GoalInfo, Left, CasesList, !Requant) :- Left1 = [_ | _], ( expand_sub_disjs(Var, Left1, Cases1, Cases) -> Left = [], - map__to_assoc_list(Cases, CasesAssocList), + map.to_assoc_list(Cases, CasesAssocList), CasesAssocList = [_ | _], % There must be at least one case. fix_case_list(CasesAssocList, GoalInfo, CasesList), !:Requant = yes @@ -487,8 +488,8 @@ expand_sub_disj_process_conj(Var, ConjGoals, !.RevUnifies, GoalInfo, GoalInfo, !Cases) ; FirstGoalExpr = disj(Disjuncts) -> Disjuncts = [_ | _], - list__reverse(!.RevUnifies, Unifies), - list__map( + list.reverse(!.RevUnifies, Unifies), + list.map( create_expanded_conjunction(Unifies, RestGoals, GoalInfo), Disjuncts, ExpandedConjunctions), partition_disj_trial(ExpandedConjunctions, Var, [], Left, !Cases), @@ -521,12 +522,12 @@ partition_disj_trial([Goal0 | Goals], Var, !Left, !Cases) :- no, MaybeFunctor, unit, _, _), ( MaybeFunctor = yes(Functor), - ( map__search(!.Cases, Functor, DisjList0) -> + ( map.search(!.Cases, Functor, DisjList0) -> DisjList = [Goal | DisjList0], - map__det_update(!.Cases, Functor, DisjList, !:Cases) + map.det_update(!.Cases, Functor, DisjList, !:Cases) ; DisjList = [Goal], - map__det_insert(!.Cases, Functor, DisjList, !:Cases) + map.det_insert(!.Cases, Functor, DisjList, !:Cases) ) ; MaybeFunctor = no, @@ -559,7 +560,7 @@ find_bind_var_for_switch_in_deconstruct(_UnifyVar, Goal0, Goals, %-----------------------------------------------------------------------------% find_bind_var(Var, ProcessUnify, !Goal, !Result, !Info, FoundDeconstruct) :- - map__init(Subst), + map.init(Subst), find_bind_var_2(Var, ProcessUnify, !Goal, Subst, _, !Result, !Info, DeconstructSearch), ( @@ -613,10 +614,10 @@ find_bind_var_2(Var, ProcessUnify, Goal0 - GoalInfo, Goal, !Subst, !Result, % Check whether the unification is a deconstruction unification % on either Var or on a variable aliased to Var. UnifyInfo0 = deconstruct(UnifyVar, _, _, _, _, _), - term__apply_rec_substitution(term__variable(Var), - !.Subst, term__variable(SubstVar)), - term__apply_rec_substitution(term__variable(UnifyVar), - !.Subst, term__variable(SubstUnifyVar)), + term.apply_rec_substitution(term.variable(Var), + !.Subst, term.variable(SubstVar)), + term.apply_rec_substitution(term.variable(UnifyVar), + !.Subst, term.variable(SubstUnifyVar)), SubstVar = SubstUnifyVar -> call(ProcessUnify, Var, Goal0 - GoalInfo, Goals, !Result, !Info), @@ -670,18 +671,18 @@ conj_find_bind_var(Var, ProcessUnify, [Goal0 | Goals0], [Goal | Goals], cases_to_switch(CasesList, Var, VarTypes, _GoalInfo, InstMap, ModuleInfo, Goal, !Requant) :- - instmap__lookup_var(InstMap, Var, VarInst), + instmap.lookup_var(InstMap, Var, VarInst), ( inst_is_bound_to_functors(ModuleInfo, VarInst, Functors) -> functors_to_cons_ids(Functors, ConsIds0), - list__sort(ConsIds0, ConsIds), + list.sort(ConsIds0, ConsIds), delete_unreachable_cases(CasesList, ConsIds, CasesList1), - ( list__same_length(Functors, CasesList1) -> + ( list.same_length(Functors, CasesList1) -> CanFail = cannot_fail ; CanFail = can_fail ) ; - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), CasesList1 = CasesList, ( switch_covers_all_cases(ModuleInfo, Type, CasesList1) -> CanFail = cannot_fail @@ -713,8 +714,8 @@ cases_to_switch(CasesList, Var, VarTypes, _GoalInfo, InstMap, ModuleInfo, sorted_case_list::in) is semidet. switch_covers_all_cases(ModuleInfo, Type, CasesList) :- - type_util__switch_type_num_functors(ModuleInfo, Type, NumFunctors), - list__length(CasesList, NumCases), + type_util.switch_type_num_functors(ModuleInfo, Type, NumFunctors), + list.length(CasesList, NumCases), NumCases = NumFunctors. % Convert the assoc_list(cons_id, list(hlds_goal)) back into a plain @@ -727,7 +728,7 @@ fix_case_list([], _, []). fix_case_list([Functor - DisjList0 | Cases0], GoalInfo, [case(Functor, Goal) | Cases]) :- % We need to put the list back the right way around. - list__reverse(DisjList0, DisjList), + list.reverse(DisjList0, DisjList), disj_list_to_goal(DisjList, GoalInfo, Goal), fix_case_list(Cases0, GoalInfo, Cases). diff --git a/compiler/switch_gen.m b/compiler/switch_gen.m index 6d46b4698..6c26c5c85 100644 --- a/compiler/switch_gen.m +++ b/compiler/switch_gen.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -43,7 +43,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__switch_gen. +:- module ll_backend.switch_gen. :- interface. :- import_module hlds.code_model. @@ -92,15 +92,15 @@ generate_switch(CodeModel, CaseVar, CanFail, Cases, GoalInfo, Code, !CI) :- goal_info_get_store_map(GoalInfo, StoreMap), SwitchCategory = determine_category(!.CI, CaseVar), - code_info__get_next_label(EndLabel, !CI), + code_info.get_next_label(EndLabel, !CI), lookup_tags(!.CI, Cases, CaseVar, TaggedCases0), - list__sort_and_remove_dups(TaggedCases0, TaggedCases), - code_info__get_globals(!.CI, Globals), - globals__lookup_bool_option(Globals, smart_indexing, Indexing), + list.sort_and_remove_dups(TaggedCases0, TaggedCases), + code_info.get_globals(!.CI, Globals), + globals.lookup_bool_option(Globals, smart_indexing, Indexing), ( % Check for a switch on a type whose representation % uses reserved addresses. - list__member(Case, TaggedCases), + list.member(Case, TaggedCases), Case = case(_Priority, Tag, _ConsId, _Goal), ( Tag = reserved_address(_) @@ -114,12 +114,12 @@ generate_switch(CodeModel, CaseVar, CanFail, Cases, GoalInfo, Code, !CI) :- ; Indexing = yes, SwitchCategory = atomic_switch, - code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo), + code_info.get_maybe_trace_info(!.CI, MaybeTraceInfo), MaybeTraceInfo = no, - list__length(TaggedCases, NumCases), - globals__lookup_int_option(Globals, lookup_switch_size, LookupSize), + list.length(TaggedCases, NumCases), + globals.lookup_int_option(Globals, lookup_switch_size, LookupSize), NumCases >= LookupSize, - globals__lookup_int_option(Globals, lookup_switch_req_density, + globals.lookup_int_option(Globals, lookup_switch_req_density, ReqDensity), is_lookup_switch(CaseVar, TaggedCases, GoalInfo, CanFail, ReqDensity, StoreMap, no, MaybeEndPrime, CodeModel, FirstVal, LastVal, @@ -132,12 +132,12 @@ generate_switch(CodeModel, CaseVar, CanFail, Cases, GoalInfo, Code, !CI) :- ; Indexing = yes, SwitchCategory = atomic_switch, - list__length(TaggedCases, NumCases), - globals__lookup_int_option(Globals, dense_switch_size, DenseSize), + list.length(TaggedCases, NumCases), + globals.lookup_int_option(Globals, dense_switch_size, DenseSize), NumCases >= DenseSize, - globals__lookup_int_option(Globals, dense_switch_req_density, + globals.lookup_int_option(Globals, dense_switch_req_density, ReqDensity), - dense_switch__is_dense_switch(!.CI, CaseVar, TaggedCases, + dense_switch.is_dense_switch(!.CI, CaseVar, TaggedCases, CanFail, ReqDensity, FirstVal, LastVal, CanFail1) -> generate_dense_switch(TaggedCases, FirstVal, LastVal, CaseVar, @@ -145,8 +145,8 @@ generate_switch(CodeModel, CaseVar, CanFail, Cases, GoalInfo, Code, !CI) :- ; Indexing = yes, SwitchCategory = string_switch, - list__length(TaggedCases, NumCases), - globals__lookup_int_option(Globals, string_switch_size, StringSize), + list.length(TaggedCases, NumCases), + globals.lookup_int_option(Globals, string_switch_size, StringSize), NumCases >= StringSize -> generate_string_switch(TaggedCases, CaseVar, CodeModel, CanFail, @@ -154,8 +154,8 @@ generate_switch(CodeModel, CaseVar, CanFail, Cases, GoalInfo, Code, !CI) :- ; Indexing = yes, SwitchCategory = tag_switch, - list__length(TaggedCases, NumCases), - globals__lookup_int_option(Globals, tag_switch_size, TagSize), + list.length(TaggedCases, NumCases), + globals.lookup_int_option(Globals, tag_switch_size, TagSize), NumCases >= TagSize -> generate_tag_switch(TaggedCases, CaseVar, CodeModel, CanFail, @@ -166,7 +166,7 @@ generate_switch(CodeModel, CaseVar, CanFail, Cases, GoalInfo, Code, !CI) :- generate_all_cases(TaggedCases, CaseVar, CodeModel, CanFail, GoalInfo, EndLabel, no, MaybeEnd, Code, !CI) ), - code_info__after_all_branches(StoreMap, MaybeEnd, !CI). + code_info.after_all_branches(StoreMap, MaybeEnd, !CI). %-----------------------------------------------------------------------------% @@ -176,10 +176,10 @@ generate_switch(CodeModel, CaseVar, CanFail, Cases, GoalInfo, Code, !CI) :- :- func determine_category(code_info, prog_var) = switch_category. determine_category(CI, CaseVar) = SwitchCategory :- - Type = code_info__variable_type(CI, CaseVar), - code_info__get_module_info(CI, ModuleInfo), + Type = code_info.variable_type(CI, CaseVar), + code_info.get_module_info(CI, ModuleInfo), classify_type(ModuleInfo, Type) = TypeCategory, - SwitchCategory = switch_util__type_cat_to_switch_cat(TypeCategory). + SwitchCategory = switch_util.type_cat_to_switch_cat(TypeCategory). %-----------------------------------------------------------------------------% @@ -189,8 +189,8 @@ determine_category(CI, CaseVar) = SwitchCategory :- lookup_tags(_, [], _, []). lookup_tags(CI, [Case | Cases], Var, [TaggedCase | TaggedCases]) :- Case = case(ConsId, Goal), - Tag = code_info__cons_id_to_tag(CI, Var, ConsId), - Priority = switch_util__switch_priority(Tag), + Tag = code_info.cons_id_to_tag(CI, Var, ConsId), + Priority = switch_util.switch_priority(Tag), TaggedCase = case(Priority, Tag, ConsId, Goal), lookup_tags(CI, Cases, Var, TaggedCases). @@ -230,7 +230,7 @@ lookup_tags(CI, [Case | Cases], Var, [TaggedCase | TaggedCases]) :- generate_all_cases(Cases0, Var, CodeModel, CanFail, GoalInfo, EndLabel, !MaybeEnd, Code, !CI) :- - code_info__produce_variable(Var, VarCode, _Rval, !CI), + code_info.produce_variable(Var, VarCode, _Rval, !CI), ( CodeModel = model_det, CanFail = cannot_fail, @@ -238,8 +238,8 @@ generate_all_cases(Cases0, Var, CodeModel, CanFail, GoalInfo, EndLabel, Case1 = case(_, _, _, Goal1), Case2 = case(_, _, _, Goal2) -> - code_info__get_pred_id(!.CI, PredId), - code_info__get_proc_id(!.CI, ProcId), + code_info.get_pred_id(!.CI, PredId), + code_info.get_proc_id(!.CI, ProcId), count_recursive_calls(Goal1, PredId, ProcId, Min1, Max1), count_recursive_calls(Goal2, PredId, ProcId, Min2, Max2), ( @@ -274,7 +274,7 @@ generate_cases([], _Var, _CodeModel, CanFail, _GoalInfo, EndLabel, !MaybeEnd, % At the end of a locally semidet switch, we fail because we came % across a tag which was not covered by one of the cases. It is % followed by the end of switch label to which the cases branch. - code_info__generate_failure(FailCode, !CI) + code_info.generate_failure(FailCode, !CI) ; CanFail = cannot_fail, FailCode = empty @@ -284,19 +284,19 @@ generate_cases([], _Var, _CodeModel, CanFail, _GoalInfo, EndLabel, !MaybeEnd, generate_cases([case(_, _, Cons, Goal) | Cases], Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, !MaybeEnd, CasesCode, !CI) :- - code_info__remember_position(!.CI, BranchStart), + code_info.remember_position(!.CI, BranchStart), goal_info_get_store_map(SwitchGoalInfo, StoreMap), ( ( Cases = [_|_] ; CanFail = can_fail ) -> - unify_gen__generate_tag_test(Var, Cons, branch_on_failure, NextLabel, + unify_gen.generate_tag_test(Var, Cons, branch_on_failure, NextLabel, TestCode, !CI), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), ElseCode = node([ goto(label(EndLabel)) - "skip to the end of the switch", label(NextLabel) - "next case" @@ -304,13 +304,13 @@ generate_cases([case(_, _, Cons, Goal) | Cases], Var, CodeModel, CanFail, ThisCaseCode = tree_list([TestCode, TraceCode, GoalCode, SaveCode, ElseCode]) ; - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), ThisCaseCode = tree_list([TraceCode, GoalCode, SaveCode]) ), - code_info__reset_to_position(BranchStart, !CI), + code_info.reset_to_position(BranchStart, !CI), generate_cases(Cases, Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, !MaybeEnd, OtherCasesCode, !CI), CasesCode = tree(ThisCaseCode, OtherCasesCode). diff --git a/compiler/switch_util.m b/compiler/switch_util.m index 7d0e3c16c..34dab5abc 100644 --- a/compiler/switch_util.m +++ b/compiler/switch_util.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2000-2005 The University of Melbourne. +% Copyright (C) 2000-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -14,7 +14,7 @@ %-----------------------------------------------------------------------------% -:- module backend_libs__switch_util. +:- module backend_libs.switch_util. :- interface. :- import_module hlds.hlds_data. @@ -158,7 +158,7 @@ %-----------------------------------------------------------------------------% string_hash_cases([], _, Map) :- - map__init(Map). + map.init(Map). string_hash_cases([Case | Cases], HashMask, Map) :- string_hash_cases(Cases, HashMask, Map0), ( Case = case(_, string_constant(String0), _, _) -> @@ -166,16 +166,16 @@ string_hash_cases([Case | Cases], HashMask, Map) :- ; unexpected(this_file, "string_hash_cases: non-string case?") ), - string__hash(String, HashVal0), + string.hash(String, HashVal0), HashVal = HashVal0 /\ HashMask, - ( map__search(Map0, HashVal, CaseList0) -> - map__det_update(Map0, HashVal, [Case | CaseList0], Map) + ( map.search(Map0, HashVal, CaseList0) -> + map.det_update(Map0, HashVal, [Case | CaseList0], Map) ; - map__det_insert(Map0, HashVal, [Case], Map) + map.det_insert(Map0, HashVal, [Case], Map) ). calc_hash_slots(HashValList, HashMap, Map) :- - calc_hash_slots_1(HashValList, HashMap, map__init, Map, 0, _). + calc_hash_slots_1(HashValList, HashMap, map.init, Map, 0, _). :- pred calc_hash_slots_1(assoc_list(int, cases_list)::in, map(int, cases_list)::in, @@ -196,23 +196,23 @@ calc_hash_slots_1([HashVal - Cases | Rest], HashMap, calc_hash_slots_2([], _HashVal, _HashMap, !Map, !LastUsed). calc_hash_slots_2([Case | Cases], HashVal, HashMap, !Map, !LastUsed) :- calc_hash_slots_2(Cases, HashVal, HashMap, !Map, !LastUsed), - ( map__contains(!.Map, HashVal) -> + ( map.contains(!.Map, HashVal) -> follow_hash_chain(!.Map, HashVal, ChainEnd), next_free_hash_slot(!.Map, HashMap, !LastUsed), - map__lookup(!.Map, ChainEnd, hash_slot(PrevCase, _)), - svmap__det_update(ChainEnd, hash_slot(PrevCase, !.LastUsed), !Map), - svmap__det_insert(!.LastUsed, hash_slot(Case, -1), !Map) + map.lookup(!.Map, ChainEnd, hash_slot(PrevCase, _)), + svmap.det_update(ChainEnd, hash_slot(PrevCase, !.LastUsed), !Map), + svmap.det_insert(!.LastUsed, hash_slot(Case, -1), !Map) ; - svmap__det_insert(HashVal, hash_slot(Case, -1), !Map) + svmap.det_insert(HashVal, hash_slot(Case, -1), !Map) ). :- pred follow_hash_chain(map(int, hash_slot)::in, int::in, int::out) is det. follow_hash_chain(Map, Slot, LastSlot) :- - map__lookup(Map, Slot, hash_slot(_, NextSlot)), + map.lookup(Map, Slot, hash_slot(_, NextSlot)), ( NextSlot >= 0, - map__contains(Map, NextSlot) + map.contains(Map, NextSlot) -> follow_hash_chain(Map, NextSlot, LastSlot) ; @@ -231,8 +231,8 @@ follow_hash_chain(Map, Slot, LastSlot) :- next_free_hash_slot(Map, H_Map, LastUsed, FreeSlot) :- NextSlot = LastUsed + 1, ( - \+ map__contains(Map, NextSlot), - \+ map__contains(H_Map, NextSlot) + \+ map.contains(Map, NextSlot), + \+ map.contains(H_Map, NextSlot) -> FreeSlot = NextSlot ; @@ -277,7 +277,7 @@ switch_priority(float_constant(_)) = 3. switch_priority(shared_remote_tag(_, _)) = 4. switch_priority(string_constant(_)) = 5. switch_priority(shared_with_reserved_addresses(RAs, Tag)) = - switch_priority(Tag) + list__length(RAs). + switch_priority(Tag) + list.length(RAs). % The following tags should all never occur in switches. switch_priority(pred_closure_tag(_, _, _)) = 6. switch_priority(type_ctor_info_constant(_, _, _)) = 6. @@ -291,20 +291,20 @@ type_range(type_cat_char, _, _, MinChar, MaxChar) :- % not the target's, so it won't work if cross-compiling % to a machine with a different character size. % Note also that the code in dense_switch.m and the code - % in lookup_switch.m assume that char__min_char_value is 0. - char__min_char_value(MinChar), - char__max_char_value(MaxChar). + % in lookup_switch.m assume that char.min_char_value is 0. + char.min_char_value(MinChar), + char.max_char_value(MaxChar). type_range(type_cat_enum, Type, ModuleInfo, 0, MaxEnum) :- ( type_to_ctor_and_args(Type, TypeCtorPrime, _) -> TypeCtor = TypeCtorPrime ; - unexpected(this_file, "dense_switch__type_range: invalid enum type?") + unexpected(this_file, "dense_switch.type_range: invalid enum type?") ), module_info_get_type_table(ModuleInfo, TypeTable), - map__lookup(TypeTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.lookup(TypeTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), ( ConsTable = TypeBody ^ du_type_cons_tag_values -> - map__count(ConsTable, TypeRange), + map.count(ConsTable, TypeRange), MaxEnum = TypeRange - 1 ; unexpected(this_file, "type_range: enum type is not d.u. type?") @@ -319,15 +319,15 @@ get_ptag_counts(Type, ModuleInfo, MaxPrimary, PtagCountMap) :- unexpected(this_file, "unknown type in get_ptag_counts") ), module_info_get_type_table(ModuleInfo, TypeTable), - map__lookup(TypeTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, Body), + map.lookup(TypeTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, Body), ( ConsTable = Body ^ du_type_cons_tag_values -> - map__to_assoc_list(ConsTable, ConsList), - assoc_list__values(ConsList, TagList) + map.to_assoc_list(ConsTable, ConsList), + assoc_list.values(ConsList, TagList) ; unexpected(this_file, "non-du type in get_ptag_counts") ), - map__init(PtagCountMap0), + map.init(PtagCountMap0), get_ptag_counts_2(TagList, -1, MaxPrimary, PtagCountMap0, PtagCountMap). :- pred get_ptag_counts_2(list(cons_tag)::in, int::in, int::out, @@ -340,43 +340,43 @@ get_ptag_counts_2([ConsTag | TagList], !MaxPrimary, !PtagCountMap) :- ; ConsTag = unshared_tag(Primary) ) -> - int__max(Primary, !MaxPrimary), - ( map__search(!.PtagCountMap, Primary, _) -> + int.max(Primary, !MaxPrimary), + ( map.search(!.PtagCountMap, Primary, _) -> unexpected(this_file, "unshared tag is shared") ; - map__det_insert(!.PtagCountMap, Primary, none - (-1), + map.det_insert(!.PtagCountMap, Primary, none - (-1), !:PtagCountMap) ) ; ConsTag = shared_remote_tag(Primary, Secondary) -> - int__max(Primary, !MaxPrimary), - ( map__search(!.PtagCountMap, Primary, Target) -> + int.max(Primary, !MaxPrimary), + ( map.search(!.PtagCountMap, Primary, Target) -> Target = TagType - MaxSoFar, ( TagType = remote -> true ; unexpected(this_file, "remote tag is shared with non-remote") ), - int__max(Secondary, MaxSoFar, Max), - map__det_update(!.PtagCountMap, Primary, remote - Max, + int.max(Secondary, MaxSoFar, Max), + map.det_update(!.PtagCountMap, Primary, remote - Max, !:PtagCountMap) ; - map__det_insert(!.PtagCountMap, Primary, + map.det_insert(!.PtagCountMap, Primary, remote - Secondary, !:PtagCountMap) ) ; ConsTag = shared_local_tag(Primary, Secondary) -> - int__max(Primary, !MaxPrimary), - ( map__search(!.PtagCountMap, Primary, Target) -> + int.max(Primary, !MaxPrimary), + ( map.search(!.PtagCountMap, Primary, Target) -> Target = TagType - MaxSoFar, ( TagType = local -> true ; unexpected(this_file, "local tag is shared with non-local") ), - int__max(Secondary, MaxSoFar, Max), - map__det_update(!.PtagCountMap, Primary, local - Max, + int.max(Secondary, MaxSoFar, Max), + map.det_update(!.PtagCountMap, Primary, local - Max, !:PtagCountMap) ; - map__det_insert(!.PtagCountMap, Primary, + map.det_insert(!.PtagCountMap, Primary, local - Secondary, !:PtagCountMap) ) ; @@ -398,40 +398,40 @@ group_cases_by_ptag([Case0 | Cases0], !PtagCaseMap) :- ; Tag = unshared_tag(Primary) ) -> - ( map__search(!.PtagCaseMap, Primary, _Group) -> + ( map.search(!.PtagCaseMap, Primary, _Group) -> unexpected(this_file, "unshared tag is shared") ; - map__init(StagGoalMap0), - map__det_insert(StagGoalMap0, -1, ConsIdGoal, StagGoalMap), - svmap__det_insert(Primary, ptag_case(none, StagGoalMap), + map.init(StagGoalMap0), + map.det_insert(StagGoalMap0, -1, ConsIdGoal, StagGoalMap), + svmap.det_insert(Primary, ptag_case(none, StagGoalMap), !PtagCaseMap) ) ; Tag = shared_remote_tag(Primary, Secondary) -> - ( map__search(!.PtagCaseMap, Primary, Group) -> + ( map.search(!.PtagCaseMap, Primary, Group) -> Group = ptag_case(StagLoc, StagGoalMap0), expect(unify(StagLoc, remote), this_file, "remote tag is shared with non-remote"), - map__det_insert(StagGoalMap0, Secondary, ConsIdGoal, StagGoalMap), - svmap__det_update(Primary, ptag_case(remote, StagGoalMap), + map.det_insert(StagGoalMap0, Secondary, ConsIdGoal, StagGoalMap), + svmap.det_update(Primary, ptag_case(remote, StagGoalMap), !PtagCaseMap) ; - map__init(StagGoalMap0), - map__det_insert(StagGoalMap0, Secondary, ConsIdGoal, StagGoalMap), - svmap__det_insert(Primary, ptag_case(remote, StagGoalMap), + map.init(StagGoalMap0), + map.det_insert(StagGoalMap0, Secondary, ConsIdGoal, StagGoalMap), + svmap.det_insert(Primary, ptag_case(remote, StagGoalMap), !PtagCaseMap) ) ; Tag = shared_local_tag(Primary, Secondary) -> - ( map__search(!.PtagCaseMap, Primary, Group) -> + ( map.search(!.PtagCaseMap, Primary, Group) -> Group = ptag_case(StagLoc, StagGoalMap0), expect(unify(StagLoc, local), this_file, "local tag is shared with non-local"), - map__det_insert(StagGoalMap0, Secondary, ConsIdGoal, StagGoalMap), - svmap__det_update(Primary, ptag_case(local, StagGoalMap), + map.det_insert(StagGoalMap0, Secondary, ConsIdGoal, StagGoalMap), + svmap.det_update(Primary, ptag_case(local, StagGoalMap), !PtagCaseMap) ; - map__init(StagGoalMap0), - map__det_insert(StagGoalMap0, Secondary, ConsIdGoal, StagGoalMap), - svmap__det_insert(Primary, ptag_case(local, StagGoalMap), + map.init(StagGoalMap0), + map.det_insert(StagGoalMap0, Secondary, ConsIdGoal, StagGoalMap), + svmap.det_insert(Primary, ptag_case(local, StagGoalMap), !PtagCaseMap) ) ; @@ -453,15 +453,15 @@ group_cases_by_ptag([Case0 | Cases0], !PtagCaseMap) :- order_ptags_by_count(PtagCountList0, PtagCaseMap0, PtagCaseList) :- ( select_frequent_ptag(PtagCountList0, Primary, _, PtagCountList1) -> - ( map__search(PtagCaseMap0, Primary, PtagCase) -> - map__delete(PtagCaseMap0, Primary, PtagCaseMap1), + ( map.search(PtagCaseMap0, Primary, PtagCase) -> + map.delete(PtagCaseMap0, Primary, PtagCaseMap1), order_ptags_by_count(PtagCountList1, PtagCaseMap1, PtagCaseList1), PtagCaseList = [Primary - PtagCase | PtagCaseList1] ; order_ptags_by_count(PtagCountList1, PtagCaseMap0, PtagCaseList) ) ; - ( map__is_empty(PtagCaseMap0) -> + ( map.is_empty(PtagCaseMap0) -> PtagCaseList = [] ; unexpected(this_file, @@ -501,8 +501,8 @@ select_frequent_ptag([PtagCount0 | PtagCountList1], Primary, order_ptags_by_value(Ptag, MaxPtag, PtagCaseMap0, PtagCaseList) :- ( MaxPtag >= Ptag -> NextPtag = Ptag + 1, - ( map__search(PtagCaseMap0, Ptag, PtagCase) -> - map__delete(PtagCaseMap0, Ptag, PtagCaseMap1), + ( map.search(PtagCaseMap0, Ptag, PtagCase) -> + map.delete(PtagCaseMap0, Ptag, PtagCaseMap1), order_ptags_by_value(NextPtag, MaxPtag, PtagCaseMap1, PtagCaseList1), PtagCaseList = [Ptag - PtagCase | PtagCaseList1] @@ -510,7 +510,7 @@ order_ptags_by_value(Ptag, MaxPtag, PtagCaseMap0, PtagCaseList) :- order_ptags_by_value(NextPtag, MaxPtag, PtagCaseMap0, PtagCaseList) ) ; - ( map__is_empty(PtagCaseMap0) -> + ( map.is_empty(PtagCaseMap0) -> PtagCaseList = [] ; unexpected(this_file, diff --git a/compiler/table_gen.m b/compiler/table_gen.m index e24053561..b9895986c 100644 --- a/compiler/table_gen.m +++ b/compiler/table_gen.m @@ -36,7 +36,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__table_gen. +:- module transform_hlds.table_gen. :- interface. :- import_module hlds.hlds_module. @@ -45,7 +45,7 @@ %-----------------------------------------------------------------------------% -:- pred table_gen__process_module(module_info::in, module_info::out, +:- pred table_gen.process_module(module_info::in, module_info::out, io::di, io::uo) is det. %-----------------------------------------------------------------------------% @@ -110,57 +110,57 @@ % of this code that is able to handle passing a module_info to % polymorphism and getting an updated module_info back. % -table_gen__process_module(!ModuleInfo, !IO) :- +table_gen.process_module(!ModuleInfo, !IO) :- module_info_preds(!.ModuleInfo, Preds0), - map__keys(Preds0, PredIds), - map__init(GenMap0), - table_gen__process_preds(PredIds, !ModuleInfo, GenMap0, _, !IO). + map.keys(Preds0, PredIds), + map.init(GenMap0), + table_gen.process_preds(PredIds, !ModuleInfo, GenMap0, _, !IO). -:- pred table_gen__process_preds(list(pred_id)::in, +:- pred table_gen.process_preds(list(pred_id)::in, module_info::in, module_info::out, generator_map::in, generator_map::out, io::di, io::uo) is det. -table_gen__process_preds([], !ModuleInfo, !GenMap, !IO). -table_gen__process_preds([PredId | PredIds], !ModuleInfo, !GenMap, !IO) :- - table_gen__process_pred(PredId, !ModuleInfo, !GenMap, !IO), - table_gen__process_preds(PredIds, !ModuleInfo, !GenMap, !IO). +table_gen.process_preds([], !ModuleInfo, !GenMap, !IO). +table_gen.process_preds([PredId | PredIds], !ModuleInfo, !GenMap, !IO) :- + table_gen.process_pred(PredId, !ModuleInfo, !GenMap, !IO), + table_gen.process_preds(PredIds, !ModuleInfo, !GenMap, !IO). -:- pred table_gen__process_pred(pred_id::in, module_info::in, module_info::out, +:- pred table_gen.process_pred(pred_id::in, module_info::in, module_info::out, generator_map::in, generator_map::out, io::di, io::uo) is det. -table_gen__process_pred(PredId, !ModuleInfo, !GenMap, !IO) :- +table_gen.process_pred(PredId, !ModuleInfo, !GenMap, !IO) :- module_info_pred_info(!.ModuleInfo, PredId, PredInfo), ProcIds = pred_info_procids(PredInfo), - table_gen__process_procs(PredId, ProcIds, !ModuleInfo, !GenMap, !IO). + table_gen.process_procs(PredId, ProcIds, !ModuleInfo, !GenMap, !IO). -:- pred table_gen__process_procs(pred_id::in, list(proc_id)::in, +:- pred table_gen.process_procs(pred_id::in, list(proc_id)::in, module_info::in, module_info::out, generator_map::in, generator_map::out, io::di, io::uo) is det. -table_gen__process_procs(_PredId, [], !ModuleInfo, !GenMap, !IO). -table_gen__process_procs(PredId, [ProcId | ProcIds], !ModuleInfo, !GenMap, +table_gen.process_procs(_PredId, [], !ModuleInfo, !GenMap, !IO). +table_gen.process_procs(PredId, [ProcId | ProcIds], !ModuleInfo, !GenMap, !IO) :- module_info_preds(!.ModuleInfo, PredTable), - map__lookup(PredTable, PredId, PredInfo), + map.lookup(PredTable, PredId, PredInfo), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, ProcInfo0), - table_gen__process_proc(PredId, ProcId, ProcInfo0, PredInfo, + map.lookup(ProcTable, ProcId, ProcInfo0), + table_gen.process_proc(PredId, ProcId, ProcInfo0, PredInfo, !ModuleInfo, !GenMap, !IO), - table_gen__process_procs(PredId, ProcIds, !ModuleInfo, !GenMap, !IO). + table_gen.process_procs(PredId, ProcIds, !ModuleInfo, !GenMap, !IO). -:- pred table_gen__process_proc(pred_id::in, proc_id::in, proc_info::in, +:- pred table_gen.process_proc(pred_id::in, proc_id::in, proc_info::in, pred_info::in, module_info::in, module_info::out, generator_map::in, generator_map::out, io::di, io::uo) is det. -table_gen__process_proc(PredId, ProcId, ProcInfo0, PredInfo0, !ModuleInfo, +table_gen.process_proc(PredId, ProcId, ProcInfo0, PredInfo0, !ModuleInfo, !GenMap, !IO) :- proc_info_eval_method(ProcInfo0, EvalMethod), ( eval_method_requires_tabling_transform(EvalMethod) = yes -> - table_gen__transform_proc_if_possible(EvalMethod, PredId, + table_gen.transform_proc_if_possible(EvalMethod, PredId, ProcId, ProcInfo0, _, PredInfo0, _, !ModuleInfo, !GenMap, !IO) ; module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, trace_table_io, yes), + globals.lookup_bool_option(Globals, trace_table_io, yes), proc_info_has_io_state_pair(!.ModuleInfo, ProcInfo0, _InArgNum, _OutArgNum) -> @@ -169,12 +169,12 @@ table_gen__process_proc(PredId, ProcId, ProcInfo0, PredInfo0, !ModuleInfo, true ; pred_id_to_int(PredId, PredIdInt), - Msg = string__format("I/O procedure pred id %d not model_det", + Msg = string.format("I/O procedure pred id %d not model_det", [i(PredIdInt)]), unexpected(this_file, Msg) ), - globals__lookup_bool_option(Globals, trace_table_io_all, TransformAll), - globals__lookup_bool_option(Globals, trace_table_io_require, Require), + globals.lookup_bool_option(Globals, trace_table_io_all, TransformAll), + globals.lookup_bool_option(Globals, trace_table_io_require, Require), proc_info_goal(ProcInfo0, BodyGoal), predicate_module(!.ModuleInfo, PredId, PredModuleName), should_io_procedure_be_transformed(TransformAll, Require, BodyGoal, @@ -191,7 +191,7 @@ table_gen__process_proc(PredId, ProcId, ProcInfo0, PredInfo0, !ModuleInfo, TransformPrimitive = no ; TransformPrimitive = yes(Unitize), - globals__lookup_bool_option(Globals, trace_table_io_only_retry, + globals.lookup_bool_option(Globals, trace_table_io_only_retry, TraceTableIoOnlyRetry), ( TraceTableIoOnlyRetry = no, @@ -202,7 +202,7 @@ table_gen__process_proc(PredId, ProcId, ProcInfo0, PredInfo0, !ModuleInfo, ), TableIoMethod = eval_table_io(Decl, Unitize), proc_info_set_eval_method(TableIoMethod, ProcInfo0, ProcInfo1), - table_gen__transform_proc_if_possible(TableIoMethod, + table_gen.transform_proc_if_possible(TableIoMethod, PredId, ProcId, ProcInfo1, _, PredInfo0, _, !ModuleInfo, !GenMap, !IO) ) @@ -312,7 +312,7 @@ report_missing_tabled_for_io(ModuleInfo, PredInfo, PredId, ProcId, !IO) :- ProcPieces = describe_one_proc_name(ModuleInfo, should_module_qualify, proc(PredId, ProcId)), Msg = ProcPieces ++ [words("contains untabled I/O primitive.")], - error_util__write_error_pieces(Context, 0, Msg, !IO). + error_util.write_error_pieces(Context, 0, Msg, !IO). :- pred report_bad_mode_for_tabling(module_info::in, pred_info::in, pred_id::in, proc_id::in, prog_varset::in, list(prog_var)::in, @@ -327,14 +327,14 @@ report_bad_mode_for_tabling(ModuleInfo, PredInfo, PredId, ProcId, VarSet, Vars, Msg = ProcPieces ++ [words("contains arguments"), words("whose mode is incompatible with tabling;"), nl, words("these arguments are"), words(VarNames)], - error_util__write_error_pieces(Context, 0, Msg, !IO). + error_util.write_error_pieces(Context, 0, Msg, !IO). :- pred lookup_var_names(prog_varset::in, list(prog_var)::in, string::out) is det. lookup_var_names(_, [], ""). lookup_var_names(VarSet, [Var | Vars], Description) :- - varset__lookup_name(VarSet, Var, Name), + varset.lookup_name(VarSet, Var, Name), ( Vars = [], Description = Name @@ -346,17 +346,17 @@ lookup_var_names(VarSet, [Var | Vars], Description) :- %-----------------------------------------------------------------------------% -:- pred table_gen__transform_proc_if_possible(eval_method::in, +:- pred table_gen.transform_proc_if_possible(eval_method::in, pred_id::in, proc_id::in, proc_info::in, proc_info::out, pred_info::in, pred_info::out, module_info::in, module_info::out, generator_map::in, generator_map::out, io::di, io::uo) is det. -table_gen__transform_proc_if_possible(EvalMethod, PredId, ProcId, +table_gen.transform_proc_if_possible(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, !ModuleInfo, !GenMap, !IO) :- - globals__io_get_target(Target, !IO), - globals__io_get_gc_method(GC_Method, !IO), + globals.io_get_target(Target, !IO), + globals.io_get_gc_method(GC_Method, !IO), ( Target = c, GC_Method \= accurate -> - table_gen__transform_proc(EvalMethod, PredId, ProcId, + table_gen.transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, !ModuleInfo, !GenMap, !IO) ; % We don't want to increment the error count, since that @@ -370,7 +370,7 @@ table_gen__transform_proc_if_possible(EvalMethod, PredId, ProcId, Msg = [words("Ignoring the pragma"), fixed(EvalMethodStr), words("for")] ++ ProcPieces ++ [words("due to lack of support on this back end."), nl], - error_util__write_error_pieces(Context, 0, Msg, !IO), + error_util.write_error_pieces(Context, 0, Msg, !IO), % % XXX We set the evaluation method to eval_normal here to prevent % problems in the ml code generator if we are compiling in a grade @@ -386,12 +386,12 @@ table_gen__transform_proc_if_possible(EvalMethod, PredId, ProcId, !.ProcInfo, !ModuleInfo) ). -:- pred table_gen__transform_proc(eval_method::in, pred_id::in, proc_id::in, +:- pred table_gen.transform_proc(eval_method::in, pred_id::in, proc_id::in, proc_info::in, proc_info::out, pred_info::in, pred_info::out, module_info::in, module_info::out, generator_map::in, generator_map::out, io::di, io::uo) is det. -table_gen__transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, +table_gen.transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, !ModuleInfo, !GenMap, !IO) :- table_info_init(!.ModuleInfo, !.PredInfo, !.ProcInfo, TableInfo0), @@ -407,7 +407,7 @@ table_gen__transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, ( EvalMethod = eval_normal, % This should have been caught by our caller. - unexpected(this_file, "table_gen__transform_proc: eval_normal") + unexpected(this_file, "table_gen.transform_proc: eval_normal") ; EvalMethod = eval_table_io(_, _), % Since we don't actually create a call table for I/O tabled @@ -441,10 +441,10 @@ table_gen__transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, ( EvalMethod = eval_table_io(Decl, Unitize), module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, trace_table_io_states, + globals.lookup_bool_option(Globals, trace_table_io_states, TableIoStates), - assoc_list__from_corresponding_lists(HeadVars, ArgModes, HeadVarModes), - table_gen__create_new_io_goal(OrigGoal, Decl, Unitize, + assoc_list.from_corresponding_lists(HeadVars, ArgModes, HeadVarModes), + table_gen.create_new_io_goal(OrigGoal, Decl, Unitize, TableIoStates, PredId, ProcId, TablingViaExtraArgs, HeadVarModes, NumberedInputVars, NumberedOutputVars, VarTypes0, VarTypes, VarSet0, VarSet, @@ -452,7 +452,7 @@ table_gen__transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, MaybeCallTableTip = no ; EvalMethod = eval_loop_check, - table_gen__create_new_loop_goal(Detism, OrigGoal, PredId, ProcId, + table_gen.create_new_loop_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, HeadVars, NumberedInputVars, NumberedOutputVars, VarTypes0, VarTypes, VarSet0, VarSet, @@ -464,13 +464,13 @@ table_gen__transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, ; EvalMethod = eval_memo(_CallStrictness), ( CodeModel = model_non -> - table_gen__create_new_memo_non_goal(Detism, + table_gen.create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, HeadVars, NumberedInputVars, NumberedOutputVars, VarTypes0, VarTypes, VarSet0, VarSet, TableInfo0, TableInfo, CallTableTip, Goal, Steps) ; - table_gen__create_new_memo_goal(Detism, + table_gen.create_new_memo_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, HeadVars, NumberedInputVars, NumberedOutputVars, VarTypes0, VarTypes, VarSet0, VarSet, @@ -484,14 +484,14 @@ table_gen__transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, EvalMethod = eval_minimal(MinimalMethod), ( CodeModel = model_det, - unexpected(this_file, "table_gen__transform_proc: minimal det") + unexpected(this_file, "table_gen.transform_proc: minimal det") ; CodeModel = model_semi, - unexpected(this_file, "table_gen__transform_proc: minimal semi") + unexpected(this_file, "table_gen.transform_proc: minimal semi") ; CodeModel = model_non, MinimalMethod = stack_copy, - table_gen__create_new_mm_goal(Detism, OrigGoal, + table_gen.create_new_mm_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, HeadVars, NumberedInputVars, NumberedOutputVars, VarTypes0, VarTypes, VarSet0, VarSet, @@ -500,7 +500,7 @@ table_gen__transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, ; CodeModel = model_non, MinimalMethod = own_stacks, - table_gen__do_own_stack_transform(Detism, OrigGoal, + table_gen.do_own_stack_transform(Detism, OrigGoal, PredId, ProcId, !.PredInfo, !.ProcInfo, HeadVars, NumberedInputVars, NumberedOutputVars, VarTypes0, VarTypes, VarSet0, VarSet, @@ -529,14 +529,14 @@ table_gen__transform_proc(EvalMethod, PredId, ProcId, !ProcInfo, !PredInfo, recompute_instmap_delta_proc(RecomputeAtomic, !ProcInfo, !ModuleInfo), pred_info_procedures(!.PredInfo, ProcTable1), - map__det_update(ProcTable1, ProcId, !.ProcInfo, ProcTable), + map.det_update(ProcTable1, ProcId, !.ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, !PredInfo), % The transformation doesn't pay attention to the purity % of compound goals, so recompute the purity here. repuritycheck_proc(!.ModuleInfo, proc(PredId, ProcId), !PredInfo), module_info_preds(!.ModuleInfo, PredTable1), - map__det_update(PredTable1, PredId, !.PredInfo, PredTable), + map.det_update(PredTable1, PredId, !.PredInfo, PredTable), module_info_set_preds(PredTable, !ModuleInfo). %-----------------------------------------------------------------------------% @@ -639,7 +639,7 @@ create_new_loop_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, % the code generated by the tabling transformation does, % so we need to compute the nonlocals from the headvars rather % than getting it from the nonlocals field in the original goal. - set__list_to_set(HeadVars, OrigNonLocals), + set.list_to_set(HeadVars, OrigNonLocals), OrigGoal = _ - OrigGoalInfo, goal_info_get_instmap_delta(OrigGoalInfo, OrigInstMapDelta), goal_info_get_context(OrigGoalInfo, Context), @@ -690,8 +690,8 @@ create_new_loop_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, ), determinism_to_code_model(Detism, CodeModel), - set__list_to_set([TableTipVar | HeadVars], InactiveNonLocals), - OutputVars = list__map(project_var, NumberedOutputVars), + set.list_to_set([TableTipVar | HeadVars], InactiveNonLocals), + OutputVars = list.map(project_var, NumberedOutputVars), InactiveInstmapDelta = bind_vars(OutputVars), ( CodeModel = model_det, @@ -705,7 +705,7 @@ create_new_loop_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, ThenGoalExpr = conj(plain_conj, Unifies ++ [MarkInactiveGoal]), ThenVars = [TableTipVar | OutputVars] ++ NewVars, - set__list_to_set(ThenVars, ThenNonLocals), + set.list_to_set(ThenVars, ThenNonLocals), goal_info_init_hide(ThenNonLocals, InactiveInstmapDelta, Detism, purity_impure, Context, ThenGoalInfo), ThenGoal = ThenGoalExpr - ThenGoalInfo, @@ -716,13 +716,13 @@ create_new_loop_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, CodeModel = model_non, AfterGoalExpr = disj([MarkInactiveGoal, MarkActiveFailGoal]), instmap_delta_init_reachable(AfterInstMapDelta), - goal_info_init_hide(set__make_singleton_set(TableTipVar), + goal_info_init_hide(set.make_singleton_set(TableTipVar), AfterInstMapDelta, multidet, purity_impure, Context, AfterGoalInfo), AfterGoal = AfterGoalExpr - AfterGoalInfo, FirstGoalExpr = conj(plain_conj, [OrigGoal, AfterGoal]), goal_info_get_nonlocals(OrigGoalInfo, OrigGINonLocals), - set__insert(OrigGINonLocals, TableTipVar, FirstNonlocals), + set.insert(OrigGINonLocals, TableTipVar, FirstNonlocals), goal_info_set_nonlocals(FirstNonlocals, OrigGoalInfo, FirstGoalInfo), FirstGoal = FirstGoalExpr - FirstGoalInfo, InactiveGoalExpr = disj([FirstGoal, MarkInactiveFailGoal]) @@ -737,7 +737,7 @@ create_new_loop_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, case(cons(qualified(TB, "loop_inactive"), 0), InactiveGoal) ], SwitchExpr = switch(StatusVar, cannot_fail, SwitchArms), - set__insert_list(InactiveNonLocals, [StatusVar, TableTipVar], + set.insert_list(InactiveNonLocals, [StatusVar, TableTipVar], SwitchNonLocals), goal_info_init_hide(SwitchNonLocals, InactiveInstmapDelta, Detism, purity_impure, Context, SwitchGoalInfo), @@ -882,7 +882,7 @@ create_new_memo_goal(Detism, OrigGoal, PredId, ProcId, % the code generated by the tabling transformation does, % so we need to compute the nonlocals from the headvars rather % than getting it from the nonlocals field in the original goal. - set__list_to_set(HeadVars, OrigNonLocals), + set.list_to_set(HeadVars, OrigNonLocals), OrigGoal = _ - OrigGoalInfo, goal_info_get_instmap_delta(OrigGoalInfo, OrigInstMapDelta), goal_info_get_context(OrigGoalInfo, Context), @@ -909,7 +909,7 @@ create_new_memo_goal(Detism, OrigGoal, PredId, ProcId, generate_error_goal(!.TableInfo, Context, infinite_recursion_msg, !VarTypes, !VarSet, ActiveGoal), - list__length(NumberedOutputVars, BlockSize), + list.length(NumberedOutputVars, BlockSize), generate_memo_save_goals(NumberedOutputVars, TableTipVar, BlockSize, TablingViaExtraArgs, Context, !VarTypes, !VarSet, !TableInfo, SaveAnswerGoals), @@ -918,8 +918,8 @@ create_new_memo_goal(Detism, OrigGoal, PredId, ProcId, !VarTypes, !VarSet, RestoreAnswerGoal), SucceededGoal = RestoreAnswerGoal, - set__list_to_set([TableTipVar | HeadVars], InactiveNonLocals), - OutputVars = list__map(project_var, NumberedOutputVars), + set.list_to_set([TableTipVar | HeadVars], InactiveNonLocals), + OutputVars = list.map(project_var, NumberedOutputVars), InactiveInstmapDelta = bind_vars(OutputVars), % The case CodeModel = model_non was caught by the code above. @@ -943,8 +943,8 @@ create_new_memo_goal(Detism, OrigGoal, PredId, ProcId, rename_vars_in_goal(Renaming, OrigGoal, RenamedOrigGoal), ThenGoalExpr = conj(plain_conj, Unifies ++ SaveAnswerGoals), - list__append([TableTipVar | OutputVars], NewVars, ThenVars), - set__list_to_set(ThenVars, ThenNonLocals), + list.append([TableTipVar | OutputVars], NewVars, ThenVars), + set.list_to_set(ThenVars, ThenNonLocals), goal_info_init_hide(ThenNonLocals, InactiveInstmapDelta, det, purity_impure, Context, ThenGoalInfo), ThenGoal = ThenGoalExpr - ThenGoalInfo, @@ -983,7 +983,7 @@ create_new_memo_goal(Detism, OrigGoal, PredId, ProcId, ), SwitchExpr = switch(StatusVar, cannot_fail, SwitchArms), - set__insert(InactiveNonLocals, StatusVar, SwitchNonLocals), + set.insert(InactiveNonLocals, StatusVar, SwitchNonLocals), goal_info_init_hide(SwitchNonLocals, InactiveInstmapDelta, Detism, purity_impure, Context, SwitchGoalInfo), SwitchGoal = SwitchExpr - SwitchGoalInfo, @@ -1007,13 +1007,13 @@ create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, % the code generated by the tabling transformation does, % so we need to compute the nonlocals from the headvars rather % than getting it from the nonlocals field in the original goal. - set__list_to_set(HeadVars, OrigNonLocals), + set.list_to_set(HeadVars, OrigNonLocals), OrigGoal = _ - OrigGoalInfo, goal_info_get_instmap_delta(OrigGoalInfo, OrigInstMapDelta), goal_info_get_context(OrigGoalInfo, Context), ModuleInfo = !.TableInfo ^ table_module_info, - list__length(NumberedOutputVars, BlockSize), + list.length(NumberedOutputVars, BlockSize), generate_error_goal(!.TableInfo, Context, infinite_recursion_msg, !VarTypes, !VarSet, InfiniteRecursionGoal), @@ -1057,7 +1057,7 @@ create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, ModuleInfo, Context, MarkCompleteGoal), OrigSaveExpr = conj(plain_conj, [OrigGoal | SaveAnswerGoals]), - set__insert(OrigNonLocals, RecordVar, OrigSaveNonLocals), + set.insert(OrigNonLocals, RecordVar, OrigSaveNonLocals), create_instmap_delta([OrigGoal | SaveAnswerGoals], OrigSaveIMD0), instmap_delta_restrict(OrigSaveNonLocals, OrigSaveIMD0, OrigSaveIMD), goal_info_init_hide(OrigSaveNonLocals, OrigSaveIMD, nondet, purity_impure, @@ -1065,7 +1065,7 @@ create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, OrigSaveGoal = OrigSaveExpr - OrigSaveGoalInfo, AfterExpr = disj([MarkIncompleteGoal, MarkActiveGoal]), - AfterNonLocals = set__make_singleton_set(RecordVar), + AfterNonLocals = set.make_singleton_set(RecordVar), create_instmap_delta([], AfterInstMapDelta), goal_info_init_hide(AfterNonLocals, AfterInstMapDelta, nondet, purity_impure, Context, AfterGoalInfo), @@ -1077,8 +1077,8 @@ create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, InactiveExpr = disj([OrigSaveAfterGoal, MarkCompleteGoal]), InactiveGoal = InactiveExpr - OrigSaveGoalInfo, - set__list_to_set([RecordVar | HeadVars], InactiveNonLocals), - OutputVars = list__map(project_var, NumberedOutputVars), + set.list_to_set([RecordVar | HeadVars], InactiveNonLocals), + OutputVars = list.map(project_var, NumberedOutputVars), InactiveInstmapDelta = bind_vars(OutputVars), mercury_table_builtin_module(TB), @@ -1090,7 +1090,7 @@ create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, ], SwitchExpr = switch(StatusVar, cannot_fail, SwitchArms), - set__insert(InactiveNonLocals, StatusVar, SwitchNonLocals), + set.insert(InactiveNonLocals, StatusVar, SwitchNonLocals), goal_info_init_hide(SwitchNonLocals, InactiveInstmapDelta, Detism, purity_impure, Context, SwitchGoalInfo), SwitchGoal = SwitchExpr - SwitchGoalInfo, @@ -1141,7 +1141,7 @@ create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, % ). % % Note that copying the I/O state works only because variables of type -% io__state don't actually contain any information; the information is actually +% io.state don't actually contain any information; the information is actually % stored in global variables. However, if this ever changes, the transformation % can be fixed simply by changing the value of --trace-table-io-states to yes, % which will cause such values to be tabled along with the other output @@ -1169,7 +1169,7 @@ create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, % generate will fill in the slots containing this extra information before % it executes the original goal. -:- pred table_gen__create_new_io_goal(hlds_goal::in, table_io_is_decl::in, +:- pred table_gen.create_new_io_goal(hlds_goal::in, table_io_is_decl::in, table_io_is_unitize::in, bool::in, pred_id::in, proc_id::in, bool::in, assoc_list(prog_var, mer_mode)::in, list(var_mode_pos_method)::in, list(var_mode_pos_method)::in, @@ -1177,7 +1177,7 @@ create_new_memo_non_goal(Detism, OrigGoal, PredId, ProcId, table_info::in, table_info::out, hlds_goal::out, maybe(proc_table_info)::out) is det. -table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, +table_gen.create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, PredId, ProcId, TablingViaExtraArgs, HeadVarModes, OrigInputVars, OrigOutputVars, !VarTypes, !VarSet, !TableInfo, Goal, MaybeProcTableInfo) :- @@ -1214,13 +1214,13 @@ table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, SavedHeadVars = HeadVarModes ; TableIoStates = no, - list__filter(table_gen__var_mode_pos_is_io_state(!.VarTypes), + list.filter(table_gen.var_mode_pos_is_io_state(!.VarTypes), OrigOutputVars, IoStateAssignToVars, MisNumberedSavedOutputVars), reallocate_slot_numbers(MisNumberedSavedOutputVars, 0, SavedOutputVars), - list__filter(table_gen__var_mode_pos_is_io_state(!.VarTypes), + list.filter(table_gen.var_mode_pos_is_io_state(!.VarTypes), OrigInputVars, IoStateAssignFromVars, _MisNumberedSavedInputVars), - list__filter(table_gen__var_mode_is_io_state(!.VarTypes), + list.filter(table_gen.var_mode_is_io_state(!.VarTypes), HeadVarModes, _, SavedHeadVars) ), generate_new_table_var("TableVar", trie_node_type, !VarTypes, !VarSet, @@ -1251,14 +1251,14 @@ table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, NumberedSaveVars = [ var_mode_pos_method(TableIoDeclPtrVar, in_mode, 0, unit) | NumberedSavedHeadVars], - UnnumberedSavedOutputVars = list__map(project_var, SavedOutputVars), - list__filter(var_belong_to_list(UnnumberedSavedOutputVars), + UnnumberedSavedOutputVars = list.map(project_var, SavedOutputVars), + list.filter(var_belong_to_list(UnnumberedSavedOutputVars), NumberedSaveVars, NumberedSavedOutputVars), NumberedRestoreVars = NumberedSavedOutputVars, ProcInfo0 = !.TableInfo ^ table_cur_proc_info, - continuation_info__generate_table_arg_type_info(ProcInfo0, - list__map(project_var_pos, NumberedSavedHeadVars), + continuation_info.generate_table_arg_type_info(ProcInfo0, + list.map(project_var_pos, NumberedSavedHeadVars), TableArgTypeInfo), ProcTableInfo = table_io_decl_info(TableArgTypeInfo), MaybeProcTableInfo = yes(ProcTableInfo) @@ -1266,11 +1266,11 @@ table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, TableDecl = table_io_proc, TableIoDeclGoal = true_goal, NumberedRestoreVars = - list__map(project_out_arg_method, SavedOutputVars), - NumberedSaveVars = list__map(project_out_arg_method, SavedOutputVars), + list.map(project_out_arg_method, SavedOutputVars), + NumberedSaveVars = list.map(project_out_arg_method, SavedOutputVars), MaybeProcTableInfo = no ), - list__length(NumberedSaveVars, BlockSize), + list.length(NumberedSaveVars, BlockSize), goal_info_get_instmap_delta(OrigGoalInfo, OrigInstMapDelta), generate_memo_restore_goal(NumberedRestoreVars, OrigInstMapDelta, TipVar, ModuleInfo, TablingViaExtraArgs, Context, !VarTypes, !VarSet, @@ -1304,7 +1304,7 @@ table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, RestoreAnswerGoal0 = _ - RestoreAnswerGoal0Info, goal_info_get_nonlocals(RestoreAnswerGoal0Info, RestoreAnswer0NonLocals), - set__insert_list(RestoreAnswer0NonLocals, + set.insert_list(RestoreAnswer0NonLocals, [IoStateAssignFromVar, IoStateAssignToVar], RestoreAnswerNonLocals), instmap_delta_restrict(RestoreAnswerNonLocals, @@ -1336,7 +1336,7 @@ table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, ), CallSaveAnswerGoalExpr = conj(plain_conj, CallSaveAnswerGoalList), create_instmap_delta(CallSaveAnswerGoalList, CallSaveAnswerInstMapDelta0), - set__insert(OrigNonLocals, TipVar, CallSaveAnswerNonLocals), + set.insert(OrigNonLocals, TipVar, CallSaveAnswerNonLocals), instmap_delta_restrict(CallSaveAnswerNonLocals, CallSaveAnswerInstMapDelta0, CallSaveAnswerInstMapDelta), goal_info_init_hide(CallSaveAnswerNonLocals, CallSaveAnswerInstMapDelta, @@ -1349,7 +1349,7 @@ table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, RestoreAnswerGoal, CallSaveAnswerGoal), create_instmap_delta([OccurredGoal, RestoreAnswerGoal, CallSaveAnswerGoal], GenIfNecInstMapDelta0), - set__insert(OrigNonLocals, TipVar, GenIfNecNonLocals), + set.insert(OrigNonLocals, TipVar, GenIfNecNonLocals), instmap_delta_restrict(GenIfNecNonLocals, GenIfNecInstMapDelta0, GenIfNecInstMapDelta), goal_info_init_hide(GenIfNecNonLocals, GenIfNecInstMapDelta, det, @@ -1359,7 +1359,7 @@ table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, CheckAndGenAnswerGoalExpr = conj(plain_conj, [LookupGoal, GenIfNecGoal]), create_instmap_delta([LookupGoal, GenIfNecGoal], CheckAndGenAnswerInstMapDelta0), - set__insert_list(OrigNonLocals, [TableVar, CounterVar, StartVar], + set.insert_list(OrigNonLocals, [TableVar, CounterVar, StartVar], CheckAndGenAnswerNonLocals), instmap_delta_restrict(CheckAndGenAnswerNonLocals, CheckAndGenAnswerInstMapDelta0, CheckAndGenAnswerInstMapDelta), @@ -1431,27 +1431,27 @@ table_gen__create_new_io_goal(OrigGoal, TableDecl, Unitize, TableIoStates, % ) % ). -:- pred table_gen__create_new_mm_goal(determinism::in, +:- pred table_gen.create_new_mm_goal(determinism::in, hlds_goal::in, pred_id::in, proc_id::in, bool::in, list(prog_var)::in, list(var_mode_pos_method)::in, list(var_mode_pos_method)::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, prog_var::out, hlds_goal::out, list(table_trie_step)::out) is det. -table_gen__create_new_mm_goal(Detism, OrigGoal, PredId, ProcId, +table_gen.create_new_mm_goal(Detism, OrigGoal, PredId, ProcId, TablingViaExtraArgs, HeadVars, NumberedInputVars, NumberedOutputVars, !VarTypes, !VarSet, !TableInfo, SubgoalVar, Goal, Steps) :- % Even if the original goal doesn't use all of the headvars, % the code generated by the tabling transformation does, % so we need to compute the nonlocals from the headvars rather % than getting it from the nonlocals field in the original goal. - set__list_to_set(HeadVars, OrigNonLocals), + set.list_to_set(HeadVars, OrigNonLocals), OrigGoal = _ - OrigGoalInfo, goal_info_get_instmap_delta(OrigGoalInfo, OrigInstMapDelta), goal_info_get_context(OrigGoalInfo, Context), ModuleInfo = !.TableInfo ^ table_module_info, - list__length(NumberedOutputVars, BlockSize), + list.length(NumberedOutputVars, BlockSize), generate_mm_call_table_lookup_goal(NumberedInputVars, PredId, ProcId, TablingViaExtraArgs, Context, !VarTypes, !VarSet, !TableInfo, SubgoalVar, StatusVar, LookUpGoal, Steps), @@ -1466,7 +1466,7 @@ table_gen__create_new_mm_goal(Detism, OrigGoal, PredId, ProcId, !VarTypes, !VarSet, SuspendGoal), MainExpr = conj(plain_conj, [OrigGoal | SaveAnswerGoals]), - set__insert_list(OrigNonLocals, [SubgoalVar, StatusVar], MainNonLocals), + set.insert_list(OrigNonLocals, [SubgoalVar, StatusVar], MainNonLocals), create_instmap_delta([OrigGoal | SaveAnswerGoals], MainIMD0), instmap_delta_restrict(MainNonLocals, MainIMD0, MainIMD), goal_info_init_hide(MainNonLocals, MainIMD, nondet, purity_impure, Context, @@ -1540,35 +1540,35 @@ table_gen__create_new_mm_goal(Detism, OrigGoal, PredId, ProcId, % impure table_mmos_consume_next_answer_nondet(Consumer, AnswerBlock), % impure table_restore_int_ans(AnswerBlock, 0, B). -:- pred table_gen__do_own_stack_transform(determinism::in, hlds_goal::in, +:- pred table_gen.do_own_stack_transform(determinism::in, hlds_goal::in, pred_id::in, proc_id::in, pred_info::in, proc_info::in, list(prog_var)::in, list(var_mode_pos_method)::in, list(var_mode_pos_method)::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, generator_map::in, generator_map::out, hlds_goal::out, list(table_trie_step)::out) is det. -table_gen__do_own_stack_transform(Detism, OrigGoal, PredId, ProcId, +table_gen.do_own_stack_transform(Detism, OrigGoal, PredId, ProcId, PredInfo0, ProcInfo0, HeadVars, NumberedInputVars, NumberedOutputVars, !VarTypes, !VarSet, !TableInfo, !GenMap, Goal, Steps) :- PredName = pred_info_name(PredInfo0), - ( map__search(!.GenMap, PredId, GeneratorPredIdPrime) -> + ( map.search(!.GenMap, PredId, GeneratorPredIdPrime) -> GeneratorPredId = GeneratorPredIdPrime ; clone_pred_info(PredId, PredInfo0, HeadVars, NumberedOutputVars, GeneratorPredId, !TableInfo), - map__det_insert(!.GenMap, PredId, GeneratorPredId, !:GenMap) + map.det_insert(!.GenMap, PredId, GeneratorPredId, !:GenMap) ), % Even if the original goal doesn't use all of the headvars, % the code generated by the tabling transformation does, % so we need to compute the nonlocals from the headvars rather % than getting it from the nonlocals field in the original goal. - set__list_to_set(HeadVars, OrigNonLocals), + set.list_to_set(HeadVars, OrigNonLocals), OrigGoal = _ - OrigGoalInfo, goal_info_get_instmap_delta(OrigGoalInfo, OrigInstMapDelta), goal_info_get_context(OrigGoalInfo, Context), - list__length(NumberedInputVars, NumInputVars), + list.length(NumberedInputVars, NumInputVars), ModuleInfo = !.TableInfo ^ table_module_info, % The type is a lie, but a safe one: the variable we create @@ -1591,8 +1591,8 @@ table_gen__do_own_stack_transform(Detism, OrigGoal, PredId, ProcId, _LookupGoals, Steps, PredTableVar, LookupForeignArgs, LookupPrefixGoals, LookupCodeStr), - InputVarModes = list__map(project_mode, NumberedInputVars), - assoc_list__from_corresponding_lists(LookupForeignArgs, InputVarModes, + InputVarModes = list.map(project_mode, NumberedInputVars), + assoc_list.from_corresponding_lists(LookupForeignArgs, InputVarModes, LookupForeignArgModes), generate_save_input_vars_code(LookupForeignArgModes, ModuleInfo, 0, PickupForeignArgs, SaveInputVarCode, PickupInputVarCode), @@ -1714,7 +1714,7 @@ generate_save_input_vars_code([InputArg - Mode | InputArgModes], ModuleInfo, PickupArgs, SaveVarCodes, PickupVarCodes). :- pred do_own_stack_create_generator(pred_id::in, proc_id::in, - pred_info::in, proc_info::in, term__context::in, prog_var::in, string::in, + pred_info::in, proc_info::in, term.context::in, prog_var::in, string::in, list(foreign_arg)::in, list(var_mode_pos_method)::in, list(var_mode_pos_method)::in, set(prog_var)::in, instmap_delta::in, @@ -1726,11 +1726,11 @@ do_own_stack_create_generator(PredId, ProcId, !.PredInfo, !.ProcInfo, Context, OrigNonLocals, OrigInstMapDelta, !.VarTypes, !.VarSet, !TableInfo) :- ModuleInfo0 = !.TableInfo ^ table_module_info, - proc_info_set_headvars(list__map(project_var, NumberedOutputVars), + proc_info_set_headvars(list.map(project_var, NumberedOutputVars), !ProcInfo), - proc_info_set_argmodes(list__map(project_mode, NumberedOutputVars), + proc_info_set_argmodes(list.map(project_mode, NumberedOutputVars), !ProcInfo), - PickupInstMapDeltaSrc0 = list__map(project_var_init_inst(ModuleInfo0), + PickupInstMapDeltaSrc0 = list.map(project_var_init_inst(ModuleInfo0), NumberedInputVars), PickupInstMapDeltaSrc = [pair_with_ground(GeneratorVar) | PickupInstMapDeltaSrc0], @@ -1743,7 +1743,7 @@ do_own_stack_create_generator(PredId, ProcId, !.PredInfo, !.ProcInfo, Context, "", PickupGeneratorCode, PickupVarCode, semipure_code, PickupInstMapDeltaSrc, ModuleInfo0, Context, PickupGoal), - list__length(NumberedOutputVars, BlockSize), + list.length(NumberedOutputVars, BlockSize), generate_own_stack_save_goal(NumberedOutputVars, GeneratorVar, BlockSize, Context, !VarTypes, !VarSet, !TableInfo, SaveAnswerGoals), @@ -1751,7 +1751,7 @@ do_own_stack_create_generator(PredId, ProcId, !.PredInfo, !.ProcInfo, Context, GoalExpr = conj(plain_conj, [PickupGoal, OrigGoal | SaveAnswerGoals]), OrigGoal = _ - OrigGoalInfo, goal_info_get_determinism(OrigGoalInfo, Detism), - set__insert(OrigNonLocals, GeneratorVar, NonLocals), + set.insert(OrigNonLocals, GeneratorVar, NonLocals), goal_info_init(NonLocals, OrigInstMapDelta, Detism, purity_impure, Context, GoalInfo0), goal_info_add_feature(hide_debug_event, GoalInfo0, GoalInfo), @@ -1761,11 +1761,11 @@ do_own_stack_create_generator(PredId, ProcId, !.PredInfo, !.ProcInfo, Context, proc_info_set_vartypes(!.VarTypes, !ProcInfo), proc_info_set_varset(!.VarSet, !ProcInfo), pred_info_procedures(!.PredInfo, ProcTable0), - map__det_insert(ProcTable0, ProcId, !.ProcInfo, ProcTable), + map.det_insert(ProcTable0, ProcId, !.ProcInfo, ProcTable), pred_info_set_procedures(ProcTable, !PredInfo), module_info_preds(ModuleInfo0, PredTable0), - map__det_update(PredTable0, PredId, !.PredInfo, PredTable), + map.det_update(PredTable0, PredId, !.PredInfo, PredTable), module_info_set_preds(PredTable, ModuleInfo0, ModuleInfo), !:TableInfo = !.TableInfo ^ table_module_info := ModuleInfo. @@ -1796,12 +1796,12 @@ clone_pred_info(OrigPredId, PredInfo0, HeadVars, NumberedOutputVars, pred_info_clauses_info(PredInfo0, ClausesInfo), PredName = qualified(ModuleName, "GeneratorFor_" ++ PredName0), - assoc_list__from_corresponding_lists(HeadVars, ArgTypes0, HeadVarTypes), + assoc_list.from_corresponding_lists(HeadVars, ArgTypes0, HeadVarTypes), keep_only_output_arg_types(HeadVarTypes, NumberedOutputVars, ArgTypes), - Arity = list__length(ArgTypes), + Arity = list.length(ArgTypes), markers_to_marker_list(Markers0, MarkerList0), - list__filter(filter_marker, MarkerList0, MarkerList), + list.filter(filter_marker, MarkerList0, MarkerList), marker_list_to_markers(MarkerList, Markers), Origin = transformed(table_generator, OrigOrigin, OrigPredId), @@ -1914,13 +1914,13 @@ keep_marker(mode_check_clauses) = yes. generate_gen_proc_table_info(TableInfo, Steps, InputVars, OutputVars, ProcTableInfo) :- ProcInfo = TableInfo ^ table_cur_proc_info, - list__append(InputVars, OutputVars, InOutHeadVars), + list.append(InputVars, OutputVars, InOutHeadVars), allocate_slot_numbers(InOutHeadVars, 1, NumberedInOutHeadVars), - ArgInfos = list__map(project_var_pos, NumberedInOutHeadVars), - continuation_info__generate_table_arg_type_info(ProcInfo, ArgInfos, + ArgInfos = list.map(project_var_pos, NumberedInOutHeadVars), + continuation_info.generate_table_arg_type_info(ProcInfo, ArgInfos, TableArgTypeInfo), - NumInputs = list__length(InputVars), - NumOutputs = list__length(OutputVars), + NumInputs = list.length(InputVars), + NumOutputs = list.length(OutputVars), ProcTableInfo = table_gen_info(NumInputs, NumOutputs, Steps, TableArgTypeInfo). @@ -1931,7 +1931,7 @@ generate_gen_proc_table_info(TableInfo, Steps, InputVars, OutputVars, % :- pred generate_simple_call_table_lookup_goal(mer_type::in, string::in, list(var_mode_pos_method)::in, pred_id::in, proc_id::in, bool::in, - term__context::in, + term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, prog_var::out, prog_var::out, hlds_goal::out, list(table_trie_step)::out) is det. @@ -1990,18 +1990,18 @@ generate_simple_call_table_lookup_goal(StatusType, SetupPred, PredCodeStr, "", impure_code, ground_vars(BoundVars), ModuleInfo, Context, SetupGoal0), attach_call_table_tip(SetupGoal0, SetupGoal), - list__append(LookupPrefixGoals, [SetupGoal], LookupSetupGoals) + list.append(LookupPrefixGoals, [SetupGoal], LookupSetupGoals) ; TablingViaExtraArgs = no, generate_call(SetupPred, det, [TableTipVar, StatusVar], impure_code, ground_vars([StatusVar]), ModuleInfo, Context, SetupGoal0), attach_call_table_tip(SetupGoal0, SetupGoal), - list__append(LookupGoals, [SetupGoal], LookupSetupGoals) + list.append(LookupGoals, [SetupGoal], LookupSetupGoals) ), GoalExpr = conj(plain_conj, LookupSetupGoals), - Vars = list__map(project_var, NumberedVars), - set__list_to_set([StatusVar, TableTipVar | Vars], NonLocals), + Vars = list.map(project_var, NumberedVars), + set.list_to_set([StatusVar, TableTipVar | Vars], NonLocals), goal_info_init_hide(NonLocals, bind_vars([TableTipVar, StatusVar]), det, purity_impure, Context, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -2010,7 +2010,7 @@ generate_simple_call_table_lookup_goal(StatusType, SetupPred, % model_non memo predicates. % :- pred generate_memo_non_call_table_lookup_goal(list(var_mode_pos_method)::in, - pred_id::in, proc_id::in, term__context::in, + pred_id::in, proc_id::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, prog_var::out, prog_var::out, hlds_goal::out, list(table_trie_step)::out) is det. @@ -2052,11 +2052,11 @@ generate_memo_non_call_table_lookup_goal(NumberedVars, LookupForeignArgs, LookupDeclCodeStr, PredCodeStr, "", impure_code, ground_vars(BoundVars), ModuleInfo, Context, SetupGoal0), attach_call_table_tip(SetupGoal0, SetupGoal), - list__append(LookupPrefixGoals, [SetupGoal], LookupSetupGoals), + list.append(LookupPrefixGoals, [SetupGoal], LookupSetupGoals), GoalExpr = conj(plain_conj, LookupSetupGoals), - Vars = list__map(project_var, NumberedVars), - set__list_to_set([StatusVar, RecordVar | Vars], NonLocals), + Vars = list.map(project_var, NumberedVars), + set.list_to_set([StatusVar, RecordVar | Vars], NonLocals), goal_info_init_hide(NonLocals, bind_vars([RecordVar, StatusVar]), det, purity_impure, Context, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -2065,7 +2065,7 @@ generate_memo_non_call_table_lookup_goal(NumberedVars, % minimal model predicates. % :- pred generate_mm_call_table_lookup_goal(list(var_mode_pos_method)::in, - pred_id::in, proc_id::in, bool::in, term__context::in, + pred_id::in, proc_id::in, bool::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, prog_var::out, prog_var::out, hlds_goal::out, list(table_trie_step)::out) is det. @@ -2111,18 +2111,18 @@ generate_mm_call_table_lookup_goal(NumberedVars, PredId, ProcId, PredCodeStr, "", impure_code, ground_vars(BoundVars), ModuleInfo, Context, SetupGoal0), attach_call_table_tip(SetupGoal0, SetupGoal), - list__append(LookupPrefixGoals, [SetupGoal], LookupSetupGoals) + list.append(LookupPrefixGoals, [SetupGoal], LookupSetupGoals) ; TablingViaExtraArgs = no, generate_call(SetupPred, det, [TableTipVar, SubgoalVar, StatusVar], impure_code, ground_vars(BoundVars), ModuleInfo, Context, SetupGoal0), attach_call_table_tip(SetupGoal0, SetupGoal), - list__append(LookupGoals, [SetupGoal], LookupSetupGoals) + list.append(LookupGoals, [SetupGoal], LookupSetupGoals) ), GoalExpr = conj(plain_conj, LookupSetupGoals), - Vars = list__map(project_var, NumberedVars), - set__list_to_set([StatusVar, SubgoalVar | Vars], NonLocals), + Vars = list.map(project_var, NumberedVars), + set.list_to_set([StatusVar, SubgoalVar | Vars], NonLocals), goal_info_init_hide(NonLocals, bind_vars([SubgoalVar, StatusVar]), det, purity_impure, Context, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -2132,7 +2132,7 @@ generate_mm_call_table_lookup_goal(NumberedVars, PredId, ProcId, % Utility predicates used when creating call table lookup goals. :- pred generate_call_table_lookup_goals(list(var_mode_pos_method)::in, - pred_id::in, proc_id::in, term__context::in, + pred_id::in, proc_id::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, prog_var::out, list(hlds_goal)::out, list(table_trie_step)::out, prog_var::out, @@ -2167,7 +2167,7 @@ generate_get_table_goal(PredId, ProcId, !VarTypes, !VarSet, PredTableVar, attach_call_table_tip(GoalExpr - GoalInfo0, GoalExpr - GoalInfo) :- goal_info_get_features(GoalInfo0, Features0), - set__insert(Features0, call_table_gen, Features), + set.insert(Features0, call_table_gen, Features), goal_info_set_features(Features, GoalInfo0, GoalInfo). %-----------------------------------------------------------------------------% @@ -2177,7 +2177,7 @@ attach_call_table_tip(GoalExpr - GoalInfo0, GoalExpr - GoalInfo) :- % and answer tables. % :- pred generate_table_lookup_goals(list(var_mode_pos_method)::in, string::in, - term__context::in, prog_var::in, prog_var::out, + term.context::in, prog_var::in, prog_var::out, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(hlds_goal)::out, list(table_trie_step)::out, list(foreign_arg)::out, @@ -2191,7 +2191,7 @@ generate_table_lookup_goals([VarModePos | NumberedVars], PrefixGoals ++ RestPrefixGoals, CodeStr ++ RestCodeStr) :- VarModePos = var_mode_pos_method(Var, _, VarSeqNum, ArgMethod), ModuleInfo = !.TableInfo ^ table_module_info, - map__lookup(!.VarTypes, Var, VarType), + map.lookup(!.VarTypes, Var, VarType), classify_type(ModuleInfo, VarType) = TypeCat, ( ArgMethod = arg_promise_implied, @@ -2216,7 +2216,7 @@ generate_table_lookup_goals([VarModePos | NumberedVars], RestForeignArgs, RestPrefixGoals, RestCodeStr). :- pred gen_lookup_call_for_type(arg_tabling_method::in, type_category::in, - mer_type::in, prog_var::in, string::in, int::in, term__context::in, + mer_type::in, prog_var::in, string::in, int::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, prog_var::in, prog_var::out, list(hlds_goal)::out, table_trie_step::out, @@ -2236,14 +2236,14 @@ gen_lookup_call_for_type(ArgTablingMethod, TypeCat, Type, ArgVar, Prefix, ( TypeCat = type_cat_enum -> ( type_to_ctor_and_args(Type, TypeCtor, _) -> module_info_get_type_table(ModuleInfo, TypeDefnTable), - map__lookup(TypeDefnTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.lookup(TypeDefnTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), ( Ctors = TypeBody ^ du_type_ctors, TypeBody ^ du_type_is_enum = is_enum, TypeBody ^ du_type_usereq = no -> - list__length(Ctors, EnumRange) + list.length(Ctors, EnumRange) ; unexpected(this_file, "gen_lookup_call_for_type: enum type is not du_type?") @@ -2279,7 +2279,7 @@ gen_lookup_call_for_type(ArgTablingMethod, TypeCat, Type, ArgVar, Prefix, lookup_tabling_category(TypeCat, MaybeCatStringStep), ( MaybeCatStringStep = no, - prog_type__vars(Type, TypeVars), + prog_type.vars(Type, TypeVars), ( ArgTablingMethod = arg_value, ( @@ -2315,7 +2315,7 @@ gen_lookup_call_for_type(ArgTablingMethod, TypeCat, Type, ArgVar, Prefix, Goals = ExtraGoals ++ [CallGoal], PrefixGoals = ExtraGoals, TypeInfoArgName = "input_typeinfo" ++ int_to_string(VarSeqNum), - map__lookup(!.VarTypes, TypeInfoVar, TypeInfoType), + map.lookup(!.VarTypes, TypeInfoVar, TypeInfoType), ForeignTypeInfoArg = foreign_arg(TypeInfoVar, yes(TypeInfoArgName - in_mode), TypeInfoType, native_if_possible), @@ -2346,7 +2346,7 @@ gen_lookup_call_for_type(ArgTablingMethod, TypeCat, Type, ArgVar, Prefix, % in memo predicates. % :- pred generate_memo_save_goals(list(var_mode_pos_method(T))::in, - prog_var::in, int::in, bool::in, term__context::in, + prog_var::in, int::in, bool::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(hlds_goal)::out) is det. @@ -2385,7 +2385,7 @@ generate_memo_save_goals(NumberedSaveVars, TableTipVar, BlockSize, % in model_non memo predicates. % :- pred generate_memo_non_save_goals(list(var_mode_pos_method)::in, - prog_var::in, int::in, term__context::in, + prog_var::in, int::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(hlds_goal)::out) is det. @@ -2452,7 +2452,7 @@ generate_memo_non_save_goals(NumberedSaveVars, RecordVar, % in minimal model predicates. % :- pred generate_mm_save_goals(list(var_mode_pos_method)::in, - prog_var::in, int::in, bool::in, term__context::in, + prog_var::in, int::in, bool::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(hlds_goal)::out) is det. @@ -2507,21 +2507,21 @@ generate_mm_save_goals(NumberedSaveVars, SubgoalVar, BlockSize, tabling_c_attributes, Args, LookupForeignArgs, PreStr, DuplCheckCodeStr, PostStr, impure_code, [], ModuleInfo, Context, DuplicateCheckSaveGoal), - list__append(LookupPrefixGoals, [DuplicateCheckSaveGoal], Goals) + list.append(LookupPrefixGoals, [DuplicateCheckSaveGoal], Goals) ; TablingViaExtraArgs = no, generate_call(DuplCheckPredName, semidet, [AnswerTableTipVar], impure_code, [], ModuleInfo, Context, DuplicateCheckGoal), - list__append([GetAnswerTableGoal | LookupAnswerGoals], + list.append([GetAnswerTableGoal | LookupAnswerGoals], [DuplicateCheckGoal], LookupCheckGoals), - list__append(LookupCheckGoals, SaveGoals, Goals) + list.append(LookupCheckGoals, SaveGoals, Goals) ). % Generate a save goal for the given variables. % :- pred generate_all_save_goals(list(var_mode_pos_method(T))::in, prog_var::in, mer_type::in, string::in, int::in, string::in, string::in, - bool::in, term__context::in, vartypes::in, vartypes::out, + bool::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(hlds_goal)::out, string::out, string::out) is det. @@ -2551,7 +2551,7 @@ generate_all_save_goals(NumberedSaveVars, BaseVar, BaseVarType, BaseVarName, tabling_c_attributes, Args, SaveArgs, SaveDeclCodeStr ++ CreateSaveCodeStr, ShortcutStr, "", impure_code, [], ModuleInfo, Context, ShortcutGoal), - list__append(SavePrefixGoals, [ShortcutGoal], Goals) + list.append(SavePrefixGoals, [ShortcutGoal], Goals) ; TablingViaExtraArgs = no, gen_int_construction("BlockSize", BlockSize, !VarTypes, @@ -2570,7 +2570,7 @@ generate_all_save_goals(NumberedSaveVars, BaseVar, BaseVarType, BaseVarName, % Generate a sequence of save goals for the given variables. % :- pred generate_own_stack_save_goal(list(var_mode_pos_method)::in, - prog_var::in, int::in, term__context::in, + prog_var::in, int::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(hlds_goal)::out) is det. @@ -2627,7 +2627,7 @@ generate_own_stack_save_goal(NumberedOutputVars, GeneratorVar, BlockSize, Goals = LookupPrefixGoals ++ SavePrefixGoals ++ [DuplicateCheckSaveGoal]. :- pred generate_save_goals(list(var_mode_pos_method(T))::in, prog_var::in, - term__context::in, vartypes::in, vartypes::out, + term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(hlds_goal)::out, list(foreign_arg)::out, list(hlds_goal)::out, string::out) is det. @@ -2641,7 +2641,7 @@ generate_save_goals([NumberedVar | NumberedRest], TableVar, Context, gen_int_construction("OffsetVar", Offset, !VarTypes, !VarSet, OffsetVar, OffsetUnifyGoal), ModuleInfo = !.TableInfo ^ table_module_info, - map__lookup(!.VarTypes, Var, VarType), + map.lookup(!.VarTypes, Var, VarType), classify_type(ModuleInfo, VarType) = TypeCat, gen_save_call_for_type(TypeCat, VarType, TableVar, Var, Offset, OffsetVar, Context, !VarTypes, !VarSet, !TableInfo, @@ -2652,7 +2652,7 @@ generate_save_goals([NumberedVar | NumberedRest], TableVar, Context, Goals = [OffsetUnifyGoal | SaveGoals ++ RestGoals]. :- pred gen_save_call_for_type(type_category::in, mer_type::in, - prog_var::in, prog_var::in, int::in, prog_var::in, term__context::in, + prog_var::in, prog_var::in, int::in, prog_var::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(hlds_goal)::out, list(foreign_arg)::out, list(hlds_goal)::out, string::out) is det. @@ -2682,7 +2682,7 @@ gen_save_call_for_type(TypeCat, Type, TableVar, Var, Offset, OffsetVar, make_type_info_var(Type, Context, !VarTypes, !VarSet, !TableInfo, TypeInfoVar, ExtraGoals), TypeInfoName = "save_arg_typeinfo" ++ int_to_string(Offset), - map__lookup(!.VarTypes, TypeInfoVar, TypeInfoType), + map.lookup(!.VarTypes, TypeInfoVar, TypeInfoType), TypeInfoForeignArg = foreign_arg(TypeInfoVar, yes(TypeInfoName - in_mode), TypeInfoType, native_if_possible), SavePredName = "table_save_any_answer", @@ -2715,14 +2715,14 @@ gen_save_call_for_type(TypeCat, Type, TableVar, Var, Offset, OffsetVar, % :- pred generate_memo_restore_goal(list(var_mode_pos_method(T))::in, instmap_delta::in, prog_var::in, module_info::in, bool::in, - term__context::in, vartypes::in, vartypes::out, + term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, hlds_goal::out) is det. generate_memo_restore_goal(NumberedOutputVars, OrigInstMapDelta, TipVar, ModuleInfo, TablingViaExtraArgs, Context, !VarTypes, !VarSet, Goal) :- ( NumberedOutputVars = [_ | _], - OutputVars = list__map(project_var, NumberedOutputVars), + OutputVars = list.map(project_var, NumberedOutputVars), GetPredName = "table_memo_get_answer_block", generate_new_table_var("RestoreBlockVar", answer_block_type, !VarTypes, !VarSet, RestoreBlockVar), @@ -2753,7 +2753,7 @@ generate_memo_restore_goal(NumberedOutputVars, OrigInstMapDelta, TipVar, semipure_code, ground_vars([RestoreBlockVar]), ModuleInfo, Context, GetBlockGoal), GoalExpr = conj(plain_conj, [GetBlockGoal | RestoreGoals]), - set__list_to_set([TipVar | OutputVars], NonLocals), + set.list_to_set([TipVar | OutputVars], NonLocals), goal_info_init_hide(NonLocals, OrigInstMapDelta, det, purity_semipure, Context, GoalInfo), Goal = GoalExpr - GoalInfo @@ -2768,7 +2768,7 @@ generate_memo_restore_goal(NumberedOutputVars, OrigInstMapDelta, TipVar, % :- pred generate_memo_non_restore_goal(determinism::in, list(var_mode_pos_method)::in, instmap_delta::in, prog_var::in, - module_info::in, term__context::in, vartypes::in, vartypes::out, + module_info::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, hlds_goal::out) is det. generate_memo_non_restore_goal(Detism, NumberedOutputVars, OrigInstMapDelta, @@ -2788,7 +2788,7 @@ generate_memo_non_restore_goal(Detism, NumberedOutputVars, OrigInstMapDelta, generate_restore_goals(NumberedOutputVars, OrigInstMapDelta, AnswerBlockVar, ModuleInfo, Context, !VarTypes, !VarSet, _RestoreGoals, RestoreInstMapDeltaSrc, RestoreArgs, RestoreCodeStr), - OutputVars = list__map(project_var, NumberedOutputVars), + OutputVars = list.map(project_var, NumberedOutputVars), Arg = foreign_arg(AnswerBlockVar, yes(answer_block_name - in_mode), answer_block_type, native_if_possible), Args = [Arg], @@ -2800,7 +2800,7 @@ generate_memo_non_restore_goal(Detism, NumberedOutputVars, OrigInstMapDelta, RestoreInstMapDeltaSrc, ModuleInfo, Context, ShortcutGoal), GoalExpr = conj(plain_conj, [ReturnAnswerBlocksGoal, ShortcutGoal]), - set__list_to_set([RecordVar | OutputVars], NonLocals), + set.list_to_set([RecordVar | OutputVars], NonLocals), goal_info_init_hide(NonLocals, OrigInstMapDelta, Detism, purity_semipure, Context, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -2810,7 +2810,7 @@ generate_memo_non_restore_goal(Detism, NumberedOutputVars, OrigInstMapDelta, % :- pred generate_mm_restore_goal(determinism::in, list(var_mode_pos_method)::in, instmap_delta::in, prog_var::in, - module_info::in, bool::in, term__context::in, + module_info::in, bool::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, hlds_goal::out) is det. @@ -2833,7 +2833,7 @@ generate_mm_restore_goal(Detism, NumberedOutputVars, OrigInstMapDelta, % :- pred generate_mm_suspend_goal(list(var_mode_pos_method)::in, instmap_delta::in, prog_var::in, module_info::in, - bool::in, term__context::in, + bool::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, hlds_goal::out) is det. @@ -2850,7 +2850,7 @@ generate_mm_suspend_goal(NumberedOutputVars, OrigInstMapDelta, SubgoalVar, % :- pred generate_mm_restore_or_suspend_goal(string::in, determinism::in, purity::in, list(var_mode_pos_method)::in, instmap_delta::in, - prog_var::in, module_info::in, bool::in, term__context::in, + prog_var::in, module_info::in, bool::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, hlds_goal::out) is det. @@ -2865,7 +2865,7 @@ generate_mm_restore_or_suspend_goal(PredName, Detism, Purity, generate_restore_goals(NumberedOutputVars, OrigInstMapDelta, AnswerBlockVar, ModuleInfo, Context, !VarTypes, !VarSet, RestoreGoals, RestoreInstMapDeltaSrc, RestoreArgs, RestoreCodeStr), - OutputVars = list__map(project_var, NumberedOutputVars), + OutputVars = list.map(project_var, NumberedOutputVars), ( TablingViaExtraArgs = yes, Arg = foreign_arg(AnswerBlockVar, @@ -2884,7 +2884,7 @@ generate_mm_restore_or_suspend_goal(PredName, Detism, Purity, TablingViaExtraArgs = no, GoalExpr = conj(plain_conj, [ReturnAnswerBlocksGoal | RestoreGoals]) ), - set__list_to_set([SubgoalVar | OutputVars], NonLocals), + set.list_to_set([SubgoalVar | OutputVars], NonLocals), goal_info_init_hide(NonLocals, OrigInstMapDelta, Detism, Purity, Context, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -2894,7 +2894,7 @@ generate_mm_restore_or_suspend_goal(PredName, Detism, Purity, % Generate a sequence of restore goals for the given variables. % :- pred generate_restore_goals(list(var_mode_pos_method(T))::in, - instmap_delta::in, prog_var::in, module_info::in, term__context::in, + instmap_delta::in, prog_var::in, module_info::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, list(hlds_goal)::out, assoc_list(prog_var, mer_inst)::out, list(foreign_arg)::out, string::out) is det. @@ -2907,7 +2907,7 @@ generate_restore_goals([NumberedVar | NumberedRest], OrigInstmapDelta, NumberedVar = var_mode_pos_method(Var, _Mode, Offset, _), gen_int_construction("OffsetVar", Offset, !VarTypes, !VarSet, OffsetVar, OffsetUnifyGoal), - map__lookup(!.VarTypes, Var, VarType), + map.lookup(!.VarTypes, Var, VarType), classify_type(ModuleInfo, VarType) = TypeCat, gen_restore_call_for_type(TypeCat, VarType, OrigInstmapDelta, AnswerBlockVar, Var, Offset, OffsetVar, ModuleInfo, Context, @@ -2918,7 +2918,7 @@ generate_restore_goals([NumberedVar | NumberedRest], OrigInstmapDelta, :- pred gen_restore_call_for_type(type_category::in, mer_type::in, instmap_delta::in, prog_var::in, prog_var::in, int::in, prog_var::in, - module_info::in, term__context::in, hlds_goal::out, + module_info::in, term.context::in, hlds_goal::out, pair(prog_var, mer_inst)::out, foreign_arg::out, string::out) is det. gen_restore_call_for_type(TypeCat, Type, OrigInstmapDelta, TableVar, Var, @@ -2958,7 +2958,7 @@ infinite_recursion_msg = "detected infinite recursion". need_minimal_model_msg = "detected need for minimal model". -:- pred generate_error_goal(table_info::in, term__context::in, +:- pred generate_error_goal(table_info::in, term.context::in, string::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, hlds_goal::out) is det. @@ -2972,7 +2972,7 @@ generate_error_goal(TableInfo, Context, Msg, !VarTypes, !VarSet, Goal) :- PredOrFunc = pred_info_is_pred_or_func(PredInfo), PredOrFuncStr = pred_or_func_to_str(PredOrFunc), sym_name_to_string(qualified(Module, Name), NameStr), - string__int_to_string(Arity, ArityStr), + string.int_to_string(Arity, ArityStr), Message = Msg ++ " in " ++ PredOrFuncStr ++ " " ++ NameStr ++ "/" ++ ArityStr, @@ -2982,7 +2982,7 @@ generate_error_goal(TableInfo, Context, Msg, !VarTypes, !VarSet, Goal) :- ModuleInfo, Context, CallGoal), GoalExpr = conj(plain_conj, [MessageStrGoal, CallGoal]), - goal_info_init_hide(set__init, bind_vars([]), erroneous, purity_impure, + goal_info_init_hide(set.init, bind_vars([]), erroneous, purity_impure, Context, GoalInfo), Goal = GoalExpr - GoalInfo. @@ -2993,8 +2993,8 @@ generate_error_goal(TableInfo, Context, Msg, !VarTypes, !VarSet, Goal) :- prog_var::out) is det. generate_new_table_var(Name, Type, !VarTypes, !VarSet, Var) :- - varset__new_named_var(!.VarSet, Name, Var, !:VarSet), - map__set(!.VarTypes, Var, Type, !:VarTypes). + varset.new_named_var(!.VarSet, Name, Var, !:VarSet), + map.set(!.VarTypes, Var, Type, !:VarTypes). :- type impure_or_semipure ---> impure_code @@ -3012,7 +3012,7 @@ impure_or_semipure_to_features(pure_code) = []. :- pred generate_call(string::in, determinism::in, list(prog_var)::in, impure_or_semipure::in, assoc_list(prog_var, mer_inst)::in, - module_info::in, term__context::in, hlds_goal::out) is det. + module_info::in, term.context::in, hlds_goal::out) is det. generate_call(PredName, Detism, Args, Purity, InstMapSrc, ModuleInfo, Context, Goal) :- @@ -3023,7 +3023,7 @@ generate_call(PredName, Detism, Args, Purity, InstMapSrc, ; Features = Features0 ), - goal_util__generate_simple_call(BuiltinModule, PredName, predicate, + goal_util.generate_simple_call(BuiltinModule, PredName, predicate, only_mode, Detism, Args, Features, InstMapSrc, ModuleInfo, Context, Goal). @@ -3031,7 +3031,7 @@ generate_call(PredName, Detism, Args, Purity, InstMapSrc, pragma_foreign_proc_attributes::in, list(foreign_arg)::in, list(foreign_arg)::in, string::in, string::in, string::in, impure_or_semipure::in, assoc_list(prog_var, mer_inst)::in, - module_info::in, term__context::in, hlds_goal::out) is det. + module_info::in, term.context::in, hlds_goal::out) is det. table_generate_foreign_proc(PredName, Detism, Attributes, Args, ExtraArgs, PrefixCode, Code, SuffixCode, Purity, InstMapSrc, @@ -3043,7 +3043,7 @@ table_generate_foreign_proc(PredName, Detism, Attributes, Args, ExtraArgs, ; Features = Features0 ), - goal_util__generate_foreign_proc(BuiltinModule, PredName, predicate, + goal_util.generate_foreign_proc(BuiltinModule, PredName, predicate, only_mode, Detism, Attributes, Args, ExtraArgs, PrefixCode, Code, SuffixCode, Features, InstMapSrc, ModuleInfo, Context, Goal). @@ -3158,7 +3158,7 @@ get_input_output_vars([Var | Vars], [Mode | Modes], ModuleInfo, ; !.MaybeSpecMethod = specified(MaybeArgMethods0), ( - list__split_last(MaybeArgMethods0, MaybeArgMethods, + list.split_last(MaybeArgMethods0, MaybeArgMethods, LastMaybeArgMethod) -> ( @@ -3189,7 +3189,7 @@ get_input_output_vars([Var | Vars], [Mode | Modes], ModuleInfo, ; !.MaybeSpecMethod = specified(MaybeArgMethods0), ( - list__split_last(MaybeArgMethods0, MaybeArgMethods, + list.split_last(MaybeArgMethods0, MaybeArgMethods, LastMaybeArgMethod) -> expect(unify(LastMaybeArgMethod, no), this_file, @@ -3316,7 +3316,7 @@ reallocate_slot_numbers([VarModePos0 | VarModes], Offset0, is semidet. var_belong_to_list(List, var_mode_pos_method(Var, _, _, _)) :- - list__member(Var, List). + list.member(Var, List). :- func bind_vars(list(prog_var)) = instmap_delta. @@ -3327,7 +3327,7 @@ bind_vars(Vars) = InstMapDelta :- :- func ground_vars(list(prog_var)) = assoc_list(prog_var, mer_inst). ground_vars(Vars) = VarsAndGround :- - VarsAndGround = list__map(pair_with_ground, Vars). + VarsAndGround = list.map(pair_with_ground, Vars). :- func pair_with_ground(prog_var) = pair(prog_var, mer_inst). @@ -3434,28 +3434,28 @@ type_save_category(type_cat_base_typeclass_info, _) :- %-----------------------------------------------------------------------------% -:- pred table_gen__make_type_info_var(mer_type::in, term__context::in, +:- pred table_gen.make_type_info_var(mer_type::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, prog_var::out, list(hlds_goal)::out) is det. -table_gen__make_type_info_var(Type, Context, !VarTypes, !VarSet, !TableInfo, +table_gen.make_type_info_var(Type, Context, !VarTypes, !VarSet, !TableInfo, TypeInfoVar, TypeInfoGoals) :- - table_gen__make_type_info_vars([Type], Context, !VarTypes, !VarSet, + table_gen.make_type_info_vars([Type], Context, !VarTypes, !VarSet, !TableInfo, TypeInfoVars, TypeInfoGoals), ( TypeInfoVars = [TypeInfoVar0] -> TypeInfoVar = TypeInfoVar0 ; unexpected(this_file, - "table_gen__make_type_info_var: list length != 1") + "table_gen.make_type_info_var: list length != 1") ). -:- pred table_gen__make_type_info_vars(list(mer_type)::in, term__context::in, +:- pred table_gen.make_type_info_vars(list(mer_type)::in, term.context::in, vartypes::in, vartypes::out, prog_varset::in, prog_varset::out, table_info::in, table_info::out, list(prog_var)::out, list(hlds_goal)::out) is det. -table_gen__make_type_info_vars(Types, Context, !VarTypes, !VarSet, !TableInfo, +table_gen.make_type_info_vars(Types, Context, !VarTypes, !VarSet, !TableInfo, TypeInfoVars, TypeInfoGoals) :- % Extract the information from table_info. table_info_extract(!.TableInfo, ModuleInfo0, PredInfo0, ProcInfo0), @@ -3467,7 +3467,7 @@ table_gen__make_type_info_vars(Types, Context, !VarTypes, !VarSet, !TableInfo, % Call polymorphism.m to create the type_infos. create_poly_info(ModuleInfo0, PredInfo0, ProcInfo2, PolyInfo0), - polymorphism__make_type_info_vars(Types, Context, + polymorphism.make_type_info_vars(Types, Context, TypeInfoVars, TypeInfoGoals, PolyInfo0, PolyInfo), poly_info_extract(PolyInfo, PredInfo0, PredInfo, ProcInfo0, ProcInfo, ModuleInfo), @@ -3482,22 +3482,22 @@ table_gen__make_type_info_vars(Types, Context, !VarTypes, !VarSet, !TableInfo, %-----------------------------------------------------------------------------% -:- pred table_gen__var_mode_pos_is_io_state(vartypes::in, +:- pred table_gen.var_mode_pos_is_io_state(vartypes::in, var_mode_pos_method::in) is semidet. -table_gen__var_mode_pos_is_io_state(VarTypes, VarModePosMethod) :- - table_gen__var_is_io_state(VarTypes, project_var(VarModePosMethod)). +table_gen.var_mode_pos_is_io_state(VarTypes, VarModePosMethod) :- + table_gen.var_is_io_state(VarTypes, project_var(VarModePosMethod)). -:- pred table_gen__var_mode_is_io_state(vartypes::in, +:- pred table_gen.var_mode_is_io_state(vartypes::in, pair(prog_var, mer_mode)::in) is semidet. -table_gen__var_mode_is_io_state(VarTypes, Var - _) :- - table_gen__var_is_io_state(VarTypes, Var). +table_gen.var_mode_is_io_state(VarTypes, Var - _) :- + table_gen.var_is_io_state(VarTypes, Var). -:- pred table_gen__var_is_io_state(vartypes::in, prog_var::in) is semidet. +:- pred table_gen.var_is_io_state(vartypes::in, prog_var::in) is semidet. -table_gen__var_is_io_state(VarTypes, Var) :- - map__lookup(VarTypes, Var, VarType), +table_gen.var_is_io_state(VarTypes, Var) :- + map.lookup(VarTypes, Var, VarType), type_is_io_state(VarType). %-----------------------------------------------------------------------------% @@ -3506,7 +3506,7 @@ table_gen__var_is_io_state(VarTypes, Var) :- tabling_via_extra_args(ModuleInfo, TablingViaExtraArgs) :- module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, tabling_via_extra_args, + globals.lookup_bool_option(Globals, tabling_via_extra_args, TablingViaExtraArgs). :- func tabling_c_attributes = pragma_foreign_proc_attributes. @@ -3524,8 +3524,8 @@ make_generator_c_attributes = Attrs :- :- func dummy_type_var = mer_type. dummy_type_var = Type :- - varset__init(DummyTVarSet0), - varset__new_var(DummyTVarSet0, DummyTVar, _), + varset.init(DummyTVarSet0), + varset.new_var(DummyTVarSet0, DummyTVar, _), Type = variable(DummyTVar, star). %-----------------------------------------------------------------------------% diff --git a/compiler/tag_switch.m b/compiler/tag_switch.m index 5739532c0..ee42d24c9 100644 --- a/compiler/tag_switch.m +++ b/compiler/tag_switch.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2000,2002-2005 The University of Melbourne. +% Copyright (C) 1994-2000,2002-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -13,7 +13,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__tag_switch. +:- module ll_backend.tag_switch. :- interface. :- import_module backend_libs.switch_util. @@ -197,23 +197,23 @@ generate_tag_switch(Cases, Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, % Group the cases based on primary tag value and find out how many % constructors share each primary tag value. - code_info__get_module_info(!.CI, ModuleInfo), - code_info__get_proc_info(!.CI, ProcInfo), + code_info.get_module_info(!.CI, ModuleInfo), + code_info.get_proc_info(!.CI, ProcInfo), proc_info_vartypes(ProcInfo, VarTypes), - map__lookup(VarTypes, Var, Type), - switch_util__get_ptag_counts(Type, ModuleInfo, + map.lookup(VarTypes, Var, Type), + switch_util.get_ptag_counts(Type, ModuleInfo, MaxPrimary, PtagCountMap), - map__to_assoc_list(PtagCountMap, PtagCountList), - map__init(PtagCaseMap0), - switch_util__group_cases_by_ptag(Cases, PtagCaseMap0, PtagCaseMap), + map.to_assoc_list(PtagCountMap, PtagCountList), + map.init(PtagCaseMap0), + switch_util.group_cases_by_ptag(Cases, PtagCaseMap0, PtagCaseMap), - map__count(PtagCaseMap, PtagsUsed), - code_info__get_globals(!.CI, Globals), - globals__lookup_int_option(Globals, dense_switch_size, + map.count(PtagCaseMap, PtagsUsed), + code_info.get_globals(!.CI, Globals), + globals.lookup_int_option(Globals, dense_switch_size, DenseSwitchSize), - globals__lookup_int_option(Globals, try_switch_size, + globals.lookup_int_option(Globals, try_switch_size, TrySwitchSize), - globals__lookup_int_option(Globals, binary_switch_size, + globals.lookup_int_option(Globals, binary_switch_size, BinarySwitchSize), ( PtagsUsed >= DenseSwitchSize -> PrimaryMethod = jump_table @@ -234,14 +234,14 @@ generate_tag_switch(Cases, Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, % or if the "register" we get is likely to be slower than % recomputing the tag from scratch. - code_info__produce_variable_in_reg(Var, VarCode, VarLval, !CI), + code_info.produce_variable_in_reg(Var, VarCode, VarLval, !CI), VarRval = lval(VarLval), - code_info__acquire_reg(r, PtagReg, !CI), - code_info__release_reg(PtagReg, !CI), + code_info.acquire_reg(r, PtagReg, !CI), + code_info.release_reg(PtagReg, !CI), ( PrimaryMethod \= jump_table, PtagsUsed >= 2, - globals__lookup_int_option(Globals, num_real_r_regs, NumRealRegs), + globals.lookup_int_option(Globals, num_real_r_regs, NumRealRegs), ( NumRealRegs = 0 ; @@ -264,14 +264,14 @@ generate_tag_switch(Cases, Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, % We generate FailCode and EndCode here because the last case within % a primary tag may not be the last case overall. - code_info__get_next_label(FailLabel, !CI), + code_info.get_next_label(FailLabel, !CI), FailLabelCode = node([label(FailLabel) - "switch has failed"]), ( CanFail = cannot_fail, FailCode = node([goto(do_not_reached) - "oh-oh, det switch failed"]) ; CanFail = can_fail, - code_info__generate_failure(FailCode, !CI) + code_info.generate_failure(FailCode, !CI) ), LabelledFailCode = tree(FailLabelCode, FailCode), @@ -279,14 +279,14 @@ generate_tag_switch(Cases, Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, ( PrimaryMethod = binary_search, - switch_util__order_ptags_by_value(0, MaxPrimary, PtagCaseMap, + switch_util.order_ptags_by_value(0, MaxPrimary, PtagCaseMap, PtagCaseList), generate_primary_binary_search(PtagCaseList, 0, MaxPrimary, PtagRval, VarRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, PtagCountMap, !MaybeEnd, CasesCode, !CI) ; PrimaryMethod = jump_table, - switch_util__order_ptags_by_value(0, MaxPrimary, PtagCaseMap, + switch_util.order_ptags_by_value(0, MaxPrimary, PtagCaseMap, PtagCaseList), generate_primary_jump_table(PtagCaseList, 0, MaxPrimary, VarRval, CodeModel, SwitchGoalInfo, EndLabel, FailLabel, PtagCountMap, @@ -297,13 +297,13 @@ generate_tag_switch(Cases, Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, CasesCode = tree(SwitchCode, TableCode) ; PrimaryMethod = try_chain, - switch_util__order_ptags_by_count(PtagCountList, PtagCaseMap, + switch_util.order_ptags_by_count(PtagCountList, PtagCaseMap, PtagCaseList0), ( CanFail = cannot_fail, PtagCaseList0 = [MostFreqCase | OtherCases] -> - list__append(OtherCases, [MostFreqCase], PtagCaseList) + list.append(OtherCases, [MostFreqCase], PtagCaseList) ; PtagCaseList = PtagCaseList0 ), @@ -312,7 +312,7 @@ generate_tag_switch(Cases, Var, CodeModel, CanFail, SwitchGoalInfo, EndLabel, empty, empty, !MaybeEnd, CasesCode, !CI) ; PrimaryMethod = try_me_else_chain, - switch_util__order_ptags_by_count(PtagCountList, PtagCaseMap, + switch_util.order_ptags_by_count(PtagCountList, PtagCaseMap, PtagCaseList), generate_primary_try_me_else_chain(PtagCaseList, PtagRval, VarRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, @@ -337,7 +337,7 @@ generate_primary_try_me_else_chain([PtagGroup | PtagGroups], TagRval, VarRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, PtagCountMap, !MaybeEnd, Code, !CI) :- PtagGroup = Primary - ptag_case(StagLoc, StagGoalMap), - map__lookup(PtagCountMap, Primary, CountInfo), + map.lookup(PtagCountMap, Primary, CountInfo), CountInfo = StagLoc1 - MaxSecondary, expect(unify(StagLoc, StagLoc1), this_file, "generate_primary_try_me_else_chain: secondary tag locations differ"), @@ -346,8 +346,8 @@ generate_primary_try_me_else_chain([PtagGroup | PtagGroups], TagRval, VarRval, ; CanFail = can_fail ) -> - code_info__remember_position(!.CI, BranchStart), - code_info__get_next_label(ElseLabel, !CI), + code_info.remember_position(!.CI, BranchStart), + code_info.get_next_label(ElseLabel, !CI), TestRval = binop(ne, TagRval, unop(mktag, const(int_const(Primary)))), TestCode = node([ @@ -360,7 +360,7 @@ generate_primary_try_me_else_chain([PtagGroup | PtagGroups], TagRval, VarRval, ThisTagCode = tree_list([TestCode, TagCode, ElseCode]), ( PtagGroups = [_ | _], - code_info__reset_to_position(BranchStart, !CI), + code_info.reset_to_position(BranchStart, !CI), generate_primary_try_me_else_chain(PtagGroups, TagRval, VarRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, PtagCountMap, !MaybeEnd, OtherTagsCode, !CI), @@ -398,7 +398,7 @@ generate_primary_try_chain([PtagGroup | PtagGroups], TagRval, VarRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, PtagCountMap, PrevTests0, PrevCases0, !MaybeEnd, Code, !CI) :- PtagGroup = Primary - ptag_case(StagLoc, StagGoalMap), - map__lookup(PtagCountMap, Primary, CountInfo), + map.lookup(PtagCountMap, Primary, CountInfo), CountInfo = StagLoc1 - MaxSecondary, expect(unify(StagLoc, StagLoc1), this_file, "secondary tag locations differ in generate_primary_try_chain"), @@ -407,8 +407,8 @@ generate_primary_try_chain([PtagGroup | PtagGroups], TagRval, VarRval, ; CanFail = can_fail ) -> - code_info__remember_position(!.CI, BranchStart), - code_info__get_next_label(ThisPtagLabel, !CI), + code_info.remember_position(!.CI, BranchStart), + code_info.get_next_label(ThisPtagLabel, !CI), TestRval = binop(eq, TagRval, unop(mktag, const(int_const(Primary)))), TestCode = node([ @@ -422,7 +422,7 @@ generate_primary_try_chain([PtagGroup | PtagGroups], TagRval, VarRval, PrevCases = tree(tree(LabelCode, TagCode), PrevCases0), ( PtagGroups = [_ | _], - code_info__reset_to_position(BranchStart, !CI), + code_info.reset_to_position(BranchStart, !CI), generate_primary_try_chain(PtagGroups, TagRval, VarRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, PtagCountMap, PrevTests, PrevCases, !MaybeEnd, Code, !CI) @@ -471,12 +471,12 @@ generate_primary_jump_table(PtagGroups, CurPrimary, MaxPrimary, VarRval, NextPrimary = CurPrimary + 1, ( PtagGroups = [CurPrimary - PrimaryInfo | PtagGroups1] -> PrimaryInfo = ptag_case(StagLoc, StagGoalMap), - map__lookup(PtagCountMap, CurPrimary, CountInfo), + map.lookup(PtagCountMap, CurPrimary, CountInfo), CountInfo = StagLoc1 - MaxSecondary, expect(unify(StagLoc, StagLoc1), this_file, "secondary tag locations differ " ++ "in generate_primary_jump_table"), - code_info__get_next_label(NewLabel, !CI), + code_info.get_next_label(NewLabel, !CI), LabelCode = node([ label(NewLabel) - "start of a case in primary tag switch" ]), @@ -487,11 +487,11 @@ generate_primary_jump_table(PtagGroups, CurPrimary, MaxPrimary, VarRval, EndLabel, FailLabel, !MaybeEnd, ThisTagCode, !CI) ; PtagGroups1 = [_ | _], - code_info__remember_position(!.CI, BranchStart), + code_info.remember_position(!.CI, BranchStart), generate_primary_tag_code(StagGoalMap, CurPrimary, MaxSecondary, StagLoc, VarRval, CodeModel, SwitchGoalInfo, EndLabel, FailLabel, !MaybeEnd, ThisTagCode, !CI), - code_info__reset_to_position(BranchStart, !CI) + code_info.reset_to_position(BranchStart, !CI) ), generate_primary_jump_table(PtagGroups1, NextPrimary, MaxPrimary, VarRval, CodeModel, SwitchGoalInfo, EndLabel, FailLabel, @@ -528,8 +528,8 @@ generate_primary_binary_search(PtagGroups, MinPtag, MaxPtag, PtagRval, VarRval, % There is no code for this tag. ( CanFail = can_fail, - string__int_to_string(CurPrimary, PtagStr), - string__append("no code for ptag ", PtagStr, Comment), + string.int_to_string(CurPrimary, PtagStr), + string.append("no code for ptag ", PtagStr, Comment), Code = node([goto(label(FailLabel)) - Comment]) ; CanFail = cannot_fail, @@ -540,7 +540,7 @@ generate_primary_binary_search(PtagGroups, MinPtag, MaxPtag, PtagRval, VarRval, expect(unify(CurPrimary, CurPrimaryPrime), this_file, "generate_primary_binary_search: cur_primary mismatch"), PrimaryInfo = ptag_case(StagLoc, StagGoalMap), - map__lookup(PtagCountMap, CurPrimary, CountInfo), + map.lookup(PtagCountMap, CurPrimary, CountInfo), CountInfo = StagLoc1 - MaxSecondary, expect(unify(StagLoc, StagLoc1), this_file, "secondary tag locations differ " ++ @@ -560,26 +560,26 @@ generate_primary_binary_search(PtagGroups, MinPtag, MaxPtag, PtagRval, VarRval, PtagGroup = Ptag - _, Ptag =< LowRangeEnd ), - list__filter(InLowGroup, PtagGroups, LowGroups, HighGroups), - code_info__get_next_label(NewLabel, !CI), - string__int_to_string(MinPtag, LowStartStr), - string__int_to_string(LowRangeEnd, LowEndStr), - string__int_to_string(HighRangeStart, HighStartStr), - string__int_to_string(MaxPtag, HighEndStr), - string__append_list(["fallthrough for ptags ", + list.filter(InLowGroup, PtagGroups, LowGroups, HighGroups), + code_info.get_next_label(NewLabel, !CI), + string.int_to_string(MinPtag, LowStartStr), + string.int_to_string(LowRangeEnd, LowEndStr), + string.int_to_string(HighRangeStart, HighStartStr), + string.int_to_string(MaxPtag, HighEndStr), + string.append_list(["fallthrough for ptags ", LowStartStr, " to ", LowEndStr], IfComment), - string__append_list(["code for ptags ", HighStartStr, + string.append_list(["code for ptags ", HighStartStr, " to ", HighEndStr], LabelComment), LowRangeEndConst = const(int_const(LowRangeEnd)), TestRval = binop(int_gt, PtagRval, LowRangeEndConst), IfCode = node([if_val(TestRval, label(NewLabel)) - IfComment]), LabelCode = node([label(NewLabel) - LabelComment]), - code_info__remember_position(!.CI, BranchStart), + code_info.remember_position(!.CI, BranchStart), generate_primary_binary_search(LowGroups, MinPtag, LowRangeEnd, PtagRval, VarRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, PtagCountMap, !MaybeEnd, LowRangeCode, !CI), - code_info__reset_to_position(BranchStart, !CI), + code_info.reset_to_position(BranchStart, !CI), generate_primary_binary_search(HighGroups, HighRangeStart, MaxPtag, PtagRval, VarRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, PtagCountMap, !MaybeEnd, HighRangeCode, !CI), @@ -601,7 +601,7 @@ generate_primary_binary_search(PtagGroups, MinPtag, MaxPtag, PtagRval, VarRval, generate_primary_tag_code(GoalMap, Primary, MaxSecondary, StagLoc, Rval, CodeModel, SwitchGoalInfo, EndLabel, FailLabel, !MaybeEnd, Code, !CI) :- - map__to_assoc_list(GoalMap, GoalList), + map.to_assoc_list(GoalMap, GoalList), ( StagLoc = none -> @@ -609,11 +609,11 @@ generate_primary_tag_code(GoalMap, Primary, MaxSecondary, StagLoc, Rval, ( GoalList = [-1 - stag_goal(ConsId, Goal)] -> Comment = "case " ++ cons_id_to_string(ConsId), CommentCode = node([comment(Comment) - ""]), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), goal_info_get_store_map(SwitchGoalInfo, StoreMap), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), GotoCode = node([ goto(label(EndLabel)) - "skip to end of primary tag switch" ]), @@ -626,12 +626,12 @@ generate_primary_tag_code(GoalMap, Primary, MaxSecondary, StagLoc, Rval, ) ; % There is a secondary tag, so figure out how to switch on it - code_info__get_globals(!.CI, Globals), - globals__lookup_int_option(Globals, dense_switch_size, + code_info.get_globals(!.CI, Globals), + globals.lookup_int_option(Globals, dense_switch_size, DenseSwitchSize), - globals__lookup_int_option(Globals, binary_switch_size, + globals.lookup_int_option(Globals, binary_switch_size, BinarySwitchSize), - globals__lookup_int_option(Globals, try_switch_size, TrySwitchSize), + globals.lookup_int_option(Globals, try_switch_size, TrySwitchSize), ( MaxSecondary >= DenseSwitchSize -> SecondaryMethod = jump_table ; MaxSecondary >= BinarySwitchSize -> @@ -651,12 +651,12 @@ generate_primary_tag_code(GoalMap, Primary, MaxSecondary, StagLoc, Rval, Comment = "compute local sec tag to switch on" ), - code_info__acquire_reg(r, StagReg, !CI), - code_info__release_reg(StagReg, !CI), + code_info.acquire_reg(r, StagReg, !CI), + code_info.release_reg(StagReg, !CI), ( SecondaryMethod \= jump_table, MaxSecondary >= 2, - globals__lookup_int_option(Globals, num_real_r_regs, NumRealRegs), + globals.lookup_int_option(Globals, num_real_r_regs, NumRealRegs), ( NumRealRegs = 0 ; @@ -674,7 +674,7 @@ generate_primary_tag_code(GoalMap, Primary, MaxSecondary, StagLoc, Rval, StagRval = OrigStagRval ), ( - list__length(GoalList, GoalCount), + list.length(GoalList, GoalCount), FullGoalCount = MaxSecondary + 1, FullGoalCount = GoalCount -> @@ -735,17 +735,17 @@ generate_secondary_try_me_else_chain([Case0 | Cases0], StagRval, CodeModel, ; CanFail = can_fail ) -> - code_info__remember_position(!.CI, BranchStart), - code_info__get_next_label(ElseLabel, !CI), + code_info.remember_position(!.CI, BranchStart), + code_info.get_next_label(ElseLabel, !CI), TestCode = node([ if_val(binop(ne, StagRval, const(int_const(Secondary))), label(ElseLabel)) - "test remote sec tag only" ]), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), - code_info__generate_branch_end(StoreMap, !MaybeEnd, + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), GotoLabelCode = node([ goto(label(EndLabel)) - "skip to end of secondary tag switch", @@ -755,7 +755,7 @@ generate_secondary_try_me_else_chain([Case0 | Cases0], StagRval, CodeModel, SaveCode, GotoLabelCode]), ( Cases0 = [_ | _], - code_info__reset_to_position(BranchStart, !CI), + code_info.reset_to_position(BranchStart, !CI), generate_secondary_try_me_else_chain(Cases0, StagRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, !MaybeEnd, OtherCode, !CI), @@ -768,10 +768,10 @@ generate_secondary_try_me_else_chain([Case0 | Cases0], StagRval, CodeModel, Code = tree(ThisCode, FailCode) ) ; - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), GotoCode = node([ goto(label(EndLabel)) - "skip to end of secondary tag switch" ]), @@ -801,8 +801,8 @@ generate_secondary_try_chain([Case0 | Cases0], StagRval, CodeModel, CanFail, ; CanFail = can_fail ) -> - code_info__remember_position(!.CI, BranchStart), - code_info__get_next_label(ThisStagLabel, !CI), + code_info.remember_position(!.CI, BranchStart), + code_info.get_next_label(ThisStagLabel, !CI), TestCode = node([ if_val(binop(eq, StagRval, const(int_const(Secondary))), label(ThisStagLabel)) @@ -812,10 +812,10 @@ generate_secondary_try_chain([Case0 | Cases0], StagRval, CodeModel, CanFail, label(ThisStagLabel) - ("handle next secondary tag for " ++ Comment) ]), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), GotoCode = node([ goto(label(EndLabel)) - "skip to end of secondary tag switch" ]), @@ -825,7 +825,7 @@ generate_secondary_try_chain([Case0 | Cases0], StagRval, CodeModel, CanFail, PrevCases = tree(ThisCode, PrevCases0), ( Cases0 = [_ | _], - code_info__reset_to_position(BranchStart, !CI), + code_info.reset_to_position(BranchStart, !CI), generate_secondary_try_chain(Cases0, StagRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, PrevTests, PrevCases, !MaybeEnd, Code, !CI) @@ -839,10 +839,10 @@ generate_secondary_try_chain([Case0 | Cases0], StagRval, CodeModel, CanFail, ) ; CommentCode = node([comment(Comment) - ""]), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), GotoCode = node([ goto(label(EndLabel)) - "skip to end of secondary tag switch" ]), @@ -871,22 +871,22 @@ generate_secondary_jump_table(CaseList, CurSecondary, MaxSecondary, CodeModel, NextSecondary = CurSecondary + 1, ( CaseList = [CurSecondary - stag_goal(ConsId, Goal) | CaseList1] -> Comment = "case " ++ cons_id_to_string(ConsId), - code_info__get_next_label(NewLabel, !CI), + code_info.get_next_label(NewLabel, !CI), LabelCode = node([ label(NewLabel) - ("start of " ++ Comment ++ " in secondary tag switch") ]), - code_info__remember_position(!.CI, BranchStart), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + code_info.remember_position(!.CI, BranchStart), + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), goal_info_get_store_map(SwitchGoalInfo, StoreMap), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), ( CaseList1 = [] ; CaseList1 = [_ | _], - code_info__reset_to_position(BranchStart, !CI) + code_info.reset_to_position(BranchStart, !CI) ), GotoCode = node([ goto(label(EndLabel)) - "branch to end of tag switch" @@ -927,8 +927,8 @@ generate_secondary_binary_search(StagGoals, MinStag, MaxStag, StagRval, % There is no code for this tag. ( CanFail = can_fail, - string__int_to_string(CurSec, StagStr), - string__append("no code for ptag ", StagStr, Comment), + string.int_to_string(CurSec, StagStr), + string.append("no code for ptag ", StagStr, Comment), Code = node([goto(label(FailLabel)) - Comment]) ; CanFail = cannot_fail, @@ -940,11 +940,11 @@ generate_secondary_binary_search(StagGoals, MinStag, MaxStag, StagRval, CommentCode = node([comment(Comment) - ""]), expect(unify(CurSec, CurSecPrime), this_file, "generate_secondary_binary_search: cur_secondary mismatch"), - trace__maybe_generate_internal_event_code(Goal, SwitchGoalInfo, + trace.maybe_generate_internal_event_code(Goal, SwitchGoalInfo, TraceCode, !CI), - code_gen__generate_goal(CodeModel, Goal, GoalCode, !CI), + code_gen.generate_goal(CodeModel, Goal, GoalCode, !CI), goal_info_get_store_map(SwitchGoalInfo, StoreMap), - code_info__generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), + code_info.generate_branch_end(StoreMap, !MaybeEnd, SaveCode, !CI), Code = tree_list([CommentCode, TraceCode, GoalCode, SaveCode]) ; StagGoals = [_, _ | _], @@ -959,26 +959,26 @@ generate_secondary_binary_search(StagGoals, MinStag, MaxStag, StagRval, StagGoal = Stag - _, Stag =< LowRangeEnd ), - list__filter(InLowGroup, StagGoals, LowGoals, HighGoals), - code_info__get_next_label(NewLabel, !CI), - string__int_to_string(MinStag, LowStartStr), - string__int_to_string(LowRangeEnd, LowEndStr), - string__int_to_string(HighRangeStart, HighStartStr), - string__int_to_string(MaxStag, HighEndStr), - string__append_list(["fallthrough for stags ", + list.filter(InLowGroup, StagGoals, LowGoals, HighGoals), + code_info.get_next_label(NewLabel, !CI), + string.int_to_string(MinStag, LowStartStr), + string.int_to_string(LowRangeEnd, LowEndStr), + string.int_to_string(HighRangeStart, HighStartStr), + string.int_to_string(MaxStag, HighEndStr), + string.append_list(["fallthrough for stags ", LowStartStr, " to ", LowEndStr], IfComment), - string__append_list(["code for stags ", HighStartStr, + string.append_list(["code for stags ", HighStartStr, " to ", HighEndStr], LabelComment), LowRangeEndConst = const(int_const(LowRangeEnd)), TestRval = binop(int_gt, StagRval, LowRangeEndConst), IfCode = node([if_val(TestRval, label(NewLabel)) - IfComment]), LabelCode = node([label(NewLabel) - LabelComment ]), - code_info__remember_position(!.CI, BranchStart), + code_info.remember_position(!.CI, BranchStart), generate_secondary_binary_search(LowGoals, MinStag, LowRangeEnd, StagRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, !MaybeEnd, LowRangeCode, !CI), - code_info__reset_to_position(BranchStart, !CI), + code_info.reset_to_position(BranchStart, !CI), generate_secondary_binary_search(HighGoals, HighRangeStart, MaxStag, StagRval, CodeModel, CanFail, SwitchGoalInfo, EndLabel, FailLabel, !MaybeEnd, HighRangeCode, !CI), diff --git a/compiler/termination.m b/compiler/termination.m index 3d352320e..72a479ea3 100644 --- a/compiler/termination.m +++ b/compiler/termination.m @@ -440,16 +440,16 @@ set_finite_arg_size_infos([Soln | Solns], OutputSupplierMap, !ModuleInfo) :- Soln = PPId - Gamma, PPId = proc(PredId, ProcId), module_info_preds(!.ModuleInfo, PredTable0), - map__lookup(PredTable0, PredId, PredInfo), + map.lookup(PredTable0, PredId, PredInfo), pred_info_procedures(PredInfo, ProcTable), - map__lookup(ProcTable, ProcId, ProcInfo), - map__lookup(OutputSupplierMap, PPId, OutputSuppliers), + map.lookup(ProcTable, ProcId, ProcInfo), + map.lookup(OutputSupplierMap, PPId, OutputSuppliers), ArgSizeInfo = finite(Gamma, OutputSuppliers), % XXX intermod proc_info_set_maybe_arg_size_info(yes(ArgSizeInfo), ProcInfo, ProcInfo1), - map__set(ProcTable, ProcId, ProcInfo1, ProcTable1), + map.set(ProcTable, ProcId, ProcInfo1, ProcTable1), pred_info_set_procedures(ProcTable1, PredInfo, PredInfo1), - map__set(PredTable0, PredId, PredInfo1, PredTable), + map.set(PredTable0, PredId, PredInfo1, PredTable), module_info_set_preds(PredTable, !ModuleInfo), set_finite_arg_size_infos(Solns, OutputSupplierMap, !ModuleInfo). diff --git a/compiler/timestamp.m b/compiler/timestamp.m index 134636fe5..49fa193ea 100644 --- a/compiler/timestamp.m +++ b/compiler/timestamp.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2001-2002, 2004-2005 The University of Melbourne. +% Copyright (C) 2001-2002, 2004-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -11,7 +11,7 @@ % Timestamp representation for smart recompilation. %-----------------------------------------------------------------------------% -:- module libs__timestamp. +:- module libs.timestamp. :- interface. @@ -67,7 +67,7 @@ oldest_timestamp = timestamp("0000-00-00 00:00:00"). newest_timestamp = timestamp("9999-99-99 99:99:99"). -time_t_to_timestamp(Time) = gmtime_to_timestamp(time__gmtime(Time)). +time_t_to_timestamp(Time) = gmtime_to_timestamp(time.gmtime(Time)). :- func gmtime_to_timestamp(tm) = timestamp. @@ -136,37 +136,37 @@ string_to_timestamp(Timestamp) = timestamp(Timestamp) :- % we need to ensure that the length check occurs before the % calls to unsafe_undex to avoid dereferencing invalid pointers. ( - string__length(Timestamp) : int = string__length("yyyy-mm-dd hh:mm:ss") + string.length(Timestamp) : int = string.length("yyyy-mm-dd hh:mm:ss") -> - string__to_int(string__unsafe_substring(Timestamp, 0, 4), _), + string.to_int(string.unsafe_substring(Timestamp, 0, 4), _), - string__unsafe_index(Timestamp, 4, '-'), + string.unsafe_index(Timestamp, 4, '-'), - string__to_int(string__unsafe_substring(Timestamp, 5, 2), Month), + string.to_int(string.unsafe_substring(Timestamp, 5, 2), Month), Month >= 1, Month =< 12, - string__unsafe_index(Timestamp, 7, '-'), + string.unsafe_index(Timestamp, 7, '-'), - string__to_int(string__unsafe_substring(Timestamp, 8, 2), Day), + string.to_int(string.unsafe_substring(Timestamp, 8, 2), Day), Day >= 1, Day =< 31, - string__unsafe_index(Timestamp, 10, ' '), + string.unsafe_index(Timestamp, 10, ' '), - string__to_int(string__unsafe_substring(Timestamp, 11, 2), Hour), + string.to_int(string.unsafe_substring(Timestamp, 11, 2), Hour), Hour >= 0, Hour =< 23, - string__unsafe_index(Timestamp, 13, ':'), + string.unsafe_index(Timestamp, 13, ':'), - string__to_int(string__unsafe_substring(Timestamp, 14, 2), Minute), + string.to_int(string.unsafe_substring(Timestamp, 14, 2), Minute), Minute >= 0, Minute =< 59, - string__unsafe_index(Timestamp, 16, ':'), + string.unsafe_index(Timestamp, 16, ':'), - string__to_int(string__unsafe_substring(Timestamp, 17, 2), Second), + string.to_int(string.unsafe_substring(Timestamp, 17, 2), Second), Second >= 0, Second =< 61 % Seconds 60 and 61 are for leap seconds. ; diff --git a/compiler/trace.m b/compiler/trace.m index e307e2dcb..985689757 100644 --- a/compiler/trace.m +++ b/compiler/trace.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1997-2005 The University of Melbourne. +% Copyright (C) 1997-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -45,7 +45,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__trace. +:- module ll_backend.trace. :- interface. :- import_module hlds.hlds_goal. @@ -136,13 +136,13 @@ % although to handle them properly we need to record insts in stack % layouts), and those of dummy types. % -:- pred trace__fail_vars(module_info::in, proc_info::in, +:- pred fail_vars(module_info::in, proc_info::in, set(prog_var)::out) is det. % Figure out whether we need a slot for storing the value of maxfr % on entry, and record the result in the proc info. % -:- pred trace__do_we_need_maxfr_slot(globals::in, pred_info::in, proc_info::in, +:- pred do_we_need_maxfr_slot(globals::in, pred_info::in, proc_info::in, proc_info::out) is det. % Return the number of slots reserved for tracing information. @@ -152,7 +152,7 @@ % If so, the variable and its slot number are returned in the last % argument. % -:- pred trace__reserved_slots(module_info::in, pred_info::in, proc_info::in, +:- pred reserved_slots(module_info::in, pred_info::in, proc_info::in, globals::in, int::out, maybe(pair(prog_var, int))::out) is det. % Construct and return an abstract struct that represents the @@ -160,37 +160,37 @@ % info about the non-fixed slots used by the tracing system, % for eventual use in the constructing the procedure's layout structure. % -:- pred trace__setup(module_info::in, pred_info::in, proc_info::in, +:- pred setup(module_info::in, pred_info::in, proc_info::in, globals::in, trace_slot_info::out, trace_info::out, code_info::in, code_info::out) is det. % Generate code to fill in the reserved stack slots. % -:- pred trace__generate_slot_fill_code(code_info::in, trace_info::in, +:- pred generate_slot_fill_code(code_info::in, trace_info::in, code_tree::out) is det. % If we are doing execution tracing, generate code to prepare for a call. % -:- pred trace__prepare_for_call(code_info::in, code_tree::out) is det. +:- pred prepare_for_call(code_info::in, code_tree::out) is det. % If we are doing execution tracing, generate code for an internal % trace event. This predicate must be called just before generating code % for the given goal. % -:- pred trace__maybe_generate_internal_event_code(hlds_goal::in, +:- pred maybe_generate_internal_event_code(hlds_goal::in, hlds_goal_info::in, code_tree::out, code_info::in, code_info::out) is det. % If we are doing execution tracing, generate code for an trace event % that represents leaving a negated goal (via success or failure). % -:- pred trace__maybe_generate_negated_event_code(hlds_goal::in, +:- pred maybe_generate_negated_event_code(hlds_goal::in, hlds_goal_info::in, negation_end_port::in, code_tree::out, code_info::in, code_info::out) is det. % If we are doing execution tracing, generate code for a nondet % pragma C code trace event. % -:- pred trace__maybe_generate_pragma_event_code(nondet_pragma_trace_port::in, +:- pred maybe_generate_pragma_event_code(nondet_pragma_trace_port::in, prog_context::in, code_tree::out, code_info::in, code_info::out) is det. :- type external_event_info @@ -213,7 +213,7 @@ % liveness information, since some of our callers also need this % information. % -:- pred trace__generate_external_event_code(external_trace_port::in, +:- pred generate_external_event_code(external_trace_port::in, trace_info::in, prog_context::in, maybe(external_event_info)::out, code_info::in, code_info::out) is det. @@ -222,7 +222,7 @@ % address of one of the labels in the runtime that calls MR_trace % for a redo event. Otherwise, generate empty code. % -:- pred trace__maybe_setup_redo_event(trace_info::in, code_tree::out) is det. +:- pred maybe_setup_redo_event(trace_info::in, code_tree::out) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -273,29 +273,29 @@ ) ; nondet_pragma. -trace__fail_vars(ModuleInfo, ProcInfo, FailVars) :- +fail_vars(ModuleInfo, ProcInfo, FailVars) :- proc_info_headvars(ProcInfo, HeadVars), proc_info_argmodes(ProcInfo, Modes), proc_info_arg_info(ProcInfo, ArgInfos), proc_info_vartypes(ProcInfo, VarTypes), mode_list_get_final_insts(ModuleInfo, Modes, Insts), ( - trace__build_fail_vars(HeadVars, Insts, ArgInfos, + build_fail_vars(HeadVars, Insts, ArgInfos, ModuleInfo, VarTypes, FailVarsList) -> - set__list_to_set(FailVarsList, FailVars) + set.list_to_set(FailVarsList, FailVars) ; - unexpected(this_file, "length mismatch in trace__fail_vars") + unexpected(this_file, "length mismatch in trace.fail_vars") ). -trace__do_we_need_maxfr_slot(Globals, PredInfo0, !ProcInfo) :- - globals__get_trace_level(Globals, TraceLevel), +do_we_need_maxfr_slot(Globals, PredInfo0, !ProcInfo) :- + globals.get_trace_level(Globals, TraceLevel), proc_info_interface_code_model(!.ProcInfo, CodeModel), ( eff_trace_level_is_none(PredInfo0, !.ProcInfo, TraceLevel) = no, CodeModel \= model_non, proc_info_goal(!.ProcInfo, Goal), - code_util__goal_may_alloc_temp_frame(Goal) + code_util.goal_may_alloc_temp_frame(Goal) -> MaxfrFlag = yes ; @@ -303,9 +303,8 @@ trace__do_we_need_maxfr_slot(Globals, PredInfo0, !ProcInfo) :- ), proc_info_set_need_maxfr_slot(MaxfrFlag, !ProcInfo). - % trace__reserved_slots and trace__setup cooperate in the allocation - % of stack slots for tracing purposes. The allocation is done in the - % following stages. + % reserved_slots and setup cooperate in the allocation of stack slots + % for tracing purposes. The allocation is done in the following stages. % % stage 1: Allocate the fixed slots, slots 1, 2 and 3, to hold % the event number of call, the call sequence number @@ -374,15 +373,14 @@ trace__do_we_need_maxfr_slot(Globals, PredInfo0, !ProcInfo) :- % by the runtime system if they are guaranteed to exist. The runtime % system may of course also need to refer to slots allocated by later % stages, but before it does so, it needs to know whether those slots - % exist or not. This is why trace__setup returns TraceSlotInfo, - % which answers such questions, for later inclusion in the - % procedure's layout structure. + % exist or not. This is why setup returns TraceSlotInfo, which answers + % such questions, for later inclusion in the procedure's layout structure. -trace__reserved_slots(_ModuleInfo, PredInfo, ProcInfo, Globals, ReservedSlots, +reserved_slots(_ModuleInfo, PredInfo, ProcInfo, Globals, ReservedSlots, MaybeTableVarInfo) :- - globals__get_trace_level(Globals, TraceLevel), - globals__get_trace_suppress(Globals, TraceSuppress), - globals__lookup_bool_option(Globals, trace_table_io, TraceTableIo), + globals.get_trace_level(Globals, TraceLevel), + globals.get_trace_suppress(Globals, TraceSuppress), + globals.lookup_bool_option(Globals, trace_table_io, TraceTableIo), FixedSlots = eff_trace_level_needs_fixed_slots(PredInfo, ProcInfo, TraceLevel), ( @@ -416,7 +414,7 @@ trace__reserved_slots(_ModuleInfo, PredInfo, ProcInfo, Globals, ReservedSlots, TraceTableIo = no, IoSeq = 0 ), - globals__lookup_bool_option(Globals, use_trail, UseTrail), + globals.lookup_bool_option(Globals, use_trail, UseTrail), ( UseTrail = yes, Trail = 2 @@ -445,19 +443,19 @@ trace__reserved_slots(_ModuleInfo, PredInfo, ProcInfo, Globals, ReservedSlots, ) ). -trace__setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, - TraceInfo, !CI) :- - CodeModel = code_info__get_proc_model(!.CI), - globals__get_trace_level(Globals, TraceLevel), - globals__get_trace_suppress(Globals, TraceSuppress), - globals__lookup_bool_option(Globals, trace_table_io, TraceTableIo), +setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, TraceInfo, + !CI) :- + CodeModel = code_info.get_proc_model(!.CI), + globals.get_trace_level(Globals, TraceLevel), + globals.get_trace_suppress(Globals, TraceSuppress), + globals.lookup_bool_option(Globals, trace_table_io, TraceTableIo), TraceRedo = eff_trace_needs_port(PredInfo, ProcInfo, TraceLevel, TraceSuppress, redo), ( TraceRedo = yes, CodeModel = model_non -> - code_info__get_next_label(RedoLayoutLabel, !CI), + code_info.get_next_label(RedoLayoutLabel, !CI), MaybeRedoLayoutLabel = yes(RedoLayoutLabel), NextSlotAfterRedoLayout = 5 ; @@ -474,7 +472,7 @@ trace__setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, ; FromFullSlot = yes, MaybeFromFullSlot = yes(NextSlotAfterRedoLayout), - CallFromFullSlot = llds__stack_slot_num_to_lval( + CallFromFullSlot = llds.stack_slot_num_to_lval( CodeModel, NextSlotAfterRedoLayout), MaybeFromFullSlotLval = yes(CallFromFullSlot), NextSlotAfterFromFull = NextSlotAfterRedoLayout + 1 @@ -482,7 +480,7 @@ trace__setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, ( TraceTableIo = yes, MaybeIoSeqSlot = yes(NextSlotAfterFromFull), - IoSeqLval = llds__stack_slot_num_to_lval(CodeModel, + IoSeqLval = llds.stack_slot_num_to_lval(CodeModel, NextSlotAfterFromFull), MaybeIoSeqLval = yes(IoSeqLval), NextSlotAfterIoSeq = NextSlotAfterFromFull + 1 @@ -492,13 +490,13 @@ trace__setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, MaybeIoSeqLval = no, NextSlotAfterIoSeq = NextSlotAfterFromFull ), - globals__lookup_bool_option(Globals, use_trail, UseTrail), + globals.lookup_bool_option(Globals, use_trail, UseTrail), ( UseTrail = yes, MaybeTrailSlot = yes(NextSlotAfterIoSeq), - TrailLval = llds__stack_slot_num_to_lval(CodeModel, + TrailLval = llds.stack_slot_num_to_lval(CodeModel, NextSlotAfterIoSeq), - TicketLval = llds__stack_slot_num_to_lval(CodeModel, + TicketLval = llds.stack_slot_num_to_lval(CodeModel, NextSlotAfterIoSeq + 1), MaybeTrailLvals = yes(TrailLval - TicketLval), NextSlotAfterTrail = NextSlotAfterIoSeq + 2 @@ -512,7 +510,7 @@ trace__setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, ( NeedMaxfr = yes, MaybeMaxfrSlot = yes(NextSlotAfterTrail), - MaxfrLval = llds__stack_slot_num_to_lval(CodeModel, + MaxfrLval = llds.stack_slot_num_to_lval(CodeModel, NextSlotAfterTrail), MaybeMaxfrLval = yes(MaxfrLval), NextSlotAfterMaxfr = NextSlotAfterTrail + 1 @@ -524,7 +522,7 @@ trace__setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, ), ( proc_info_get_call_table_tip(ProcInfo, yes(_)) -> MaybeCallTableSlot = yes(NextSlotAfterMaxfr), - CallTableLval = llds__stack_slot_num_to_lval(CodeModel, + CallTableLval = llds.stack_slot_num_to_lval(CodeModel, NextSlotAfterMaxfr), MaybeCallTableLval = yes(CallTableLval) ; @@ -537,27 +535,27 @@ trace__setup(_ModuleInfo, PredInfo, ProcInfo, Globals, TraceSlotInfo, MaybeFromFullSlotLval, MaybeIoSeqLval, MaybeTrailLvals, MaybeMaxfrLval, MaybeCallTableLval, MaybeRedoLayoutLabel). -trace__generate_slot_fill_code(CI, TraceInfo, TraceCode) :- - CodeModel = code_info__get_proc_model(CI), +generate_slot_fill_code(CI, TraceInfo, TraceCode) :- + CodeModel = code_info.get_proc_model(CI), MaybeFromFullSlot = TraceInfo ^ from_full_lval, MaybeIoSeqSlot = TraceInfo ^ io_seq_lval, MaybeTrailLvals = TraceInfo ^ trail_lvals, MaybeMaxfrLval = TraceInfo ^ maxfr_lval, MaybeCallTableLval = TraceInfo ^ call_table_tip_lval, MaybeRedoLabel = TraceInfo ^ redo_label, - trace__event_num_slot(CodeModel, EventNumLval), - trace__call_num_slot(CodeModel, CallNumLval), - trace__call_depth_slot(CodeModel, CallDepthLval), - trace__stackref_to_string(EventNumLval, EventNumStr), - trace__stackref_to_string(CallNumLval, CallNumStr), - trace__stackref_to_string(CallDepthLval, CallDepthStr), - string__append_list(["\t\tMR_trace_fill_std_slots(", + event_num_slot(CodeModel, EventNumLval), + call_num_slot(CodeModel, CallNumLval), + call_depth_slot(CodeModel, CallDepthLval), + stackref_to_string(EventNumLval, EventNumStr), + stackref_to_string(CallNumLval, CallNumStr), + stackref_to_string(CallDepthLval, CallDepthStr), + string.append_list(["\t\tMR_trace_fill_std_slots(", EventNumStr, ", ", CallNumStr, ", ", CallDepthStr, ");\n" ], FillThreeSlots), ( MaybeIoSeqSlot = yes(IoSeqLval), - trace__stackref_to_string(IoSeqLval, IoSeqStr), - string__append_list([ + stackref_to_string(IoSeqLval, IoSeqStr), + string.append_list([ FillThreeSlots, "\t\t", IoSeqStr, " = MR_io_tabling_counter;\n" ], FillSlotsUptoIoSeq) @@ -567,11 +565,11 @@ trace__generate_slot_fill_code(CI, TraceInfo, TraceCode) :- ), ( MaybeRedoLabel = yes(RedoLayoutLabel), - trace__redo_layout_slot(CodeModel, RedoLayoutLval), - trace__stackref_to_string(RedoLayoutLval, RedoLayoutStr), + redo_layout_slot(CodeModel, RedoLayoutLval), + stackref_to_string(RedoLayoutLval, RedoLayoutStr), LayoutAddrStr = - layout_out__make_label_layout_name(RedoLayoutLabel), - string__append_list([ + layout_out.make_label_layout_name(RedoLayoutLabel), + string.append_list([ FillSlotsUptoIoSeq, "\t\t", RedoLayoutStr, " = (MR_Word) (const MR_Word *) &", LayoutAddrStr, ";\n" @@ -588,9 +586,9 @@ trace__generate_slot_fill_code(CI, TraceInfo, TraceCode) :- % only when the caller is deep traced, and everything inside % that test must be in C code. MaybeTrailLvals = yes(TrailLval - TicketLval), - trace__stackref_to_string(TrailLval, TrailLvalStr), - trace__stackref_to_string(TicketLval, TicketLvalStr), - string__append_list([ + stackref_to_string(TrailLval, TrailLvalStr), + stackref_to_string(TicketLval, TicketLvalStr), + string.append_list([ FillSlotsUptoRedo, "\t\tMR_mark_ticket_stack(", TicketLvalStr, ");\n", "\t\tMR_store_ticket(", TrailLvalStr, ");\n" @@ -601,7 +599,7 @@ trace__generate_slot_fill_code(CI, TraceInfo, TraceCode) :- ), ( MaybeFromFullSlot = yes(CallFromFullSlot), - trace__stackref_to_string(CallFromFullSlot, + stackref_to_string(CallFromFullSlot, CallFromFullSlotStr), TraceStmt1 = "\t\t" ++ CallFromFullSlotStr ++ " = MR_trace_from_full;\n" ++ @@ -616,7 +614,7 @@ trace__generate_slot_fill_code(CI, TraceInfo, TraceCode) :- ), TraceCode1 = node([ pragma_c([], [pragma_c_raw_code(TraceStmt1, cannot_branch_away, - live_lvals_info(set__init))], will_not_call_mercury, + live_lvals_info(set.init))], will_not_call_mercury, no, no, MaybeLayoutLabel, no, yes, no) - "" ]), @@ -631,11 +629,11 @@ trace__generate_slot_fill_code(CI, TraceInfo, TraceCode) :- ), ( MaybeCallTableLval = yes(CallTableLval), - trace__stackref_to_string(CallTableLval, CallTableLvalStr), + stackref_to_string(CallTableLval, CallTableLvalStr), TraceStmt3 = "\t\t" ++ CallTableLvalStr ++ " = 0;\n", TraceCode3 = node([ pragma_c([], [pragma_c_raw_code(TraceStmt3, cannot_branch_away, - live_lvals_info(set__init))], + live_lvals_info(set.init))], will_not_call_mercury, no, no, no, no, yes, no) - "" ]) ; @@ -644,14 +642,14 @@ trace__generate_slot_fill_code(CI, TraceInfo, TraceCode) :- ), TraceCode = tree(TraceCode1, tree(TraceCode2, TraceCode3)). -trace__prepare_for_call(CI, TraceCode) :- - code_info__get_maybe_trace_info(CI, MaybeTraceInfo), - CodeModel = code_info__get_proc_model(CI), +prepare_for_call(CI, TraceCode) :- + code_info.get_maybe_trace_info(CI, MaybeTraceInfo), + CodeModel = code_info.get_proc_model(CI), ( MaybeTraceInfo = yes(TraceInfo), MaybeFromFullSlot = TraceInfo ^ from_full_lval, - trace__call_depth_slot(CodeModel, CallDepthLval), - trace__stackref_to_string(CallDepthLval, CallDepthStr), + call_depth_slot(CodeModel, CallDepthLval), + stackref_to_string(CallDepthLval, CallDepthStr), ( MaybeFromFullSlot = yes(_), MacroStr = "MR_trace_reset_depth_from_shallow" @@ -661,15 +659,15 @@ trace__prepare_for_call(CI, TraceCode) :- ), ResetStmt = MacroStr ++ "(" ++ CallDepthStr ++ ");\n", TraceCode = node([ - c_code(ResetStmt, live_lvals_info(set__init)) - "" + c_code(ResetStmt, live_lvals_info(set.init)) - "" ]) ; MaybeTraceInfo = no, TraceCode = empty ). -trace__maybe_generate_internal_event_code(Goal, OutsideGoalInfo, Code, !CI) :- - code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo), +maybe_generate_internal_event_code(Goal, OutsideGoalInfo, Code, !CI) :- + code_info.get_maybe_trace_info(!.CI, MaybeTraceInfo), ( MaybeTraceInfo = yes(TraceInfo), Goal = _ - GoalInfo, @@ -701,8 +699,8 @@ trace__maybe_generate_internal_event_code(Goal, OutsideGoalInfo, Code, !CI) :- unexpected(this_file, "generate_internal_event_code: bad path") ), ( - code_info__get_pred_info(!.CI, PredInfo), - code_info__get_proc_info(!.CI, ProcInfo), + code_info.get_pred_info(!.CI, PredInfo), + code_info.get_proc_info(!.CI, ProcInfo), eff_trace_needs_port(PredInfo, ProcInfo, TraceInfo ^ trace_level, TraceInfo ^ trace_suppress_items, Port) = yes @@ -714,7 +712,7 @@ trace__maybe_generate_internal_event_code(Goal, OutsideGoalInfo, Code, !CI) :- ; HideEvent = no ), - trace__generate_event_code(Port, internal(Path, PreDeaths), + generate_event_code(Port, internal(Path, PreDeaths), TraceInfo, Context, HideEvent, _, _, Code, !CI) ; Code = empty @@ -724,9 +722,8 @@ trace__maybe_generate_internal_event_code(Goal, OutsideGoalInfo, Code, !CI) :- Code = empty ). -trace__maybe_generate_negated_event_code(Goal, OutsideGoalInfo, NegPort, Code, - !CI) :- - code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo), +maybe_generate_negated_event_code(Goal, OutsideGoalInfo, NegPort, Code, !CI) :- + code_info.get_maybe_trace_info(!.CI, MaybeTraceInfo), ( MaybeTraceInfo = yes(TraceInfo), ( @@ -736,8 +733,8 @@ trace__maybe_generate_negated_event_code(Goal, OutsideGoalInfo, NegPort, Code, NegPort = neg_success, Port = neg_success ), - code_info__get_pred_info(!.CI, PredInfo), - code_info__get_proc_info(!.CI, ProcInfo), + code_info.get_pred_info(!.CI, PredInfo), + code_info.get_proc_info(!.CI, ProcInfo), eff_trace_needs_port(PredInfo, ProcInfo, TraceInfo ^ trace_level, TraceInfo ^ trace_suppress_items, Port) = yes @@ -750,66 +747,66 @@ trace__maybe_generate_negated_event_code(Goal, OutsideGoalInfo, NegPort, Code, ; HideEvent = no ), - trace__generate_event_code(Port, negation_end(Path), - TraceInfo, Context, HideEvent, _, _, Code, !CI) + generate_event_code(Port, negation_end(Path), TraceInfo, Context, + HideEvent, _, _, Code, !CI) ; Code = empty ). -trace__maybe_generate_pragma_event_code(PragmaPort, Context, Code, !CI) :- - code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo), +maybe_generate_pragma_event_code(PragmaPort, Context, Code, !CI) :- + code_info.get_maybe_trace_info(!.CI, MaybeTraceInfo), ( MaybeTraceInfo = yes(TraceInfo), - trace__convert_nondet_pragma_port_type(PragmaPort, Port), - code_info__get_pred_info(!.CI, PredInfo), - code_info__get_proc_info(!.CI, ProcInfo), + Port = convert_nondet_pragma_port_type(PragmaPort), + code_info.get_pred_info(!.CI, PredInfo), + code_info.get_proc_info(!.CI, ProcInfo), eff_trace_needs_port(PredInfo, ProcInfo, TraceInfo ^ trace_level, TraceInfo ^ trace_suppress_items, Port) = yes -> - trace__generate_event_code(Port, nondet_pragma, TraceInfo, - Context, no, _, _, Code, !CI) + generate_event_code(Port, nondet_pragma, TraceInfo, Context, no, _, _, + Code, !CI) ; Code = empty ). -trace__generate_external_event_code(ExternalPort, TraceInfo, Context, +generate_external_event_code(ExternalPort, TraceInfo, Context, MaybeExternalInfo, !CI) :- - trace__convert_external_port_type(ExternalPort, Port), + Port = convert_external_port_type(ExternalPort), ( - code_info__get_pred_info(!.CI, PredInfo), - code_info__get_proc_info(!.CI, ProcInfo), + code_info.get_pred_info(!.CI, PredInfo), + code_info.get_proc_info(!.CI, ProcInfo), eff_trace_needs_port(PredInfo, ProcInfo, TraceInfo ^ trace_level, TraceInfo ^ trace_suppress_items, Port) = yes -> - trace__generate_event_code(Port, external, TraceInfo, - Context, no, Label, TvarDataMap, Code, !CI), + generate_event_code(Port, external, TraceInfo, Context, no, Label, + TvarDataMap, Code, !CI), MaybeExternalInfo = yes(external_event_info(Label, TvarDataMap, Code)) ; MaybeExternalInfo = no ). -:- pred trace__generate_event_code(trace_port::in, trace_port_info::in, +:- pred generate_event_code(trace_port::in, trace_port_info::in, trace_info::in, prog_context::in, bool::in, label::out, map(tvar, set(layout_locn))::out, code_tree::out, code_info::in, code_info::out) is det. -trace__generate_event_code(Port, PortInfo, TraceInfo, Context, HideEvent, - Label, TvarDataMap, Code, !CI) :- - code_info__get_next_label(Label, !CI), - code_info__get_known_variables(!.CI, LiveVars0), +generate_event_code(Port, PortInfo, TraceInfo, Context, HideEvent, Label, + TvarDataMap, Code, !CI) :- + code_info.get_next_label(Label, !CI), + code_info.get_known_variables(!.CI, LiveVars0), ( PortInfo = external, LiveVars = LiveVars0, Path = [] ; PortInfo = internal(Path, PreDeaths), - ResumeVars = code_info__current_resume_point_vars(!.CI), - set__difference(PreDeaths, ResumeVars, RealPreDeaths), - set__to_sorted_list(RealPreDeaths, RealPreDeathList), - list__delete_elems(LiveVars0, RealPreDeathList, LiveVars) + ResumeVars = code_info.current_resume_point_vars(!.CI), + set.difference(PreDeaths, ResumeVars, RealPreDeaths), + set.to_sorted_list(RealPreDeaths, RealPreDeathList), + list.delete_elems(LiveVars0, RealPreDeathList, LiveVars) ; PortInfo = negation_end(Path), LiveVars = LiveVars0 @@ -825,38 +822,38 @@ trace__generate_event_code(Port, PortInfo, TraceInfo, Context, HideEvent, "bad nondet pragma port") ) ), - VarTypes = code_info__get_var_types(!.CI), - code_info__get_varset(!.CI, VarSet), - code_info__get_instmap(!.CI, InstMap), - trace__produce_vars(LiveVars, VarSet, VarTypes, InstMap, Port, - set__init, TvarSet, [], VarInfoList, ProduceCode, !CI), - code_info__max_reg_in_use(!.CI, MaxReg), - code_info__get_max_reg_in_use_at_trace(!.CI, MaxTraceReg0), + VarTypes = code_info.get_var_types(!.CI), + code_info.get_varset(!.CI, VarSet), + code_info.get_instmap(!.CI, InstMap), + trace_produce_vars(LiveVars, VarSet, VarTypes, InstMap, Port, + set.init, TvarSet, [], VarInfoList, ProduceCode, !CI), + code_info.max_reg_in_use(!.CI, MaxReg), + code_info.get_max_reg_in_use_at_trace(!.CI, MaxTraceReg0), ( MaxTraceReg0 < MaxReg -> - code_info__set_max_reg_in_use_at_trace(MaxReg, !CI) + code_info.set_max_reg_in_use_at_trace(MaxReg, !CI) ; true ), - code_info__variable_locations(!.CI, VarLocs), - code_info__get_proc_info(!.CI, ProcInfo), - set__to_sorted_list(TvarSet, TvarList), - continuation_info__find_typeinfos_for_tvars(TvarList, + code_info.variable_locations(!.CI, VarLocs), + code_info.get_proc_info(!.CI, ProcInfo), + set.to_sorted_list(TvarSet, TvarList), + continuation_info.find_typeinfos_for_tvars(TvarList, VarLocs, ProcInfo, TvarDataMap), % compute the set of live lvals at the event - VarLvals = list__map(find_lval_in_var_info, VarInfoList), - map__values(TvarDataMap, TvarLocnSets), - TvarLocnSet = set__union_list(TvarLocnSets), - set__to_sorted_list(TvarLocnSet, TvarLocns), - TvarLvals = list__map(find_lval_in_layout_locn, TvarLocns), - list__append(VarLvals, TvarLvals, LiveLvals), - LiveLvalSet = set__list_to_set(LiveLvals), + VarLvals = list.map(find_lval_in_var_info, VarInfoList), + map.values(TvarDataMap, TvarLocnSets), + TvarLocnSet = set.union_list(TvarLocnSets), + set.to_sorted_list(TvarLocnSet, TvarLocns), + TvarLvals = list.map(find_lval_in_layout_locn, TvarLocns), + list.append(VarLvals, TvarLvals, LiveLvals), + LiveLvalSet = set.list_to_set(LiveLvals), - set__list_to_set(VarInfoList, VarInfoSet), + set.list_to_set(VarInfoList, VarInfoSet), LayoutLabelInfo = layout_label_info(VarInfoSet, TvarDataMap), - LabelStr = llds_out__label_to_c_string(Label, no), - string__append_list(["\t\tMR_EVENT(", LabelStr, ")\n"], TraceStmt), - code_info__add_trace_layout_for_label(Label, Context, Port, HideEvent, + LabelStr = llds_out.label_to_c_string(Label, no), + string.append_list(["\t\tMR_EVENT(", LabelStr, ")\n"], TraceStmt), + code_info.add_trace_layout_for_label(Label, Context, Port, HideEvent, Path, LayoutLabelInfo, !CI), ( Port = fail, @@ -869,10 +866,10 @@ trace__generate_event_code(Port, PortInfo, TraceInfo, Context, HideEvent, % generating it for the redo event would be much harder. % On the other hand, the address of the layout structure % for the redo event should be put into its fixed stack slot - % at procedure entry. Therefore trace__setup reserves a label + % at procedure entry. Therefore setup reserves a label % for the redo event, whose layout information is filled in % when we get to the fail event. - code_info__add_trace_layout_for_label(RedoLabel, Context, redo, + code_info.add_trace_layout_for_label(RedoLabel, Context, redo, HideEvent, Path, LayoutLabelInfo, !CI) ; true @@ -904,7 +901,7 @@ find_lval_in_var_info(layout_var_info(LayoutLocn, _, _)) = find_lval_in_layout_locn(direct(Lval)) = Lval. find_lval_in_layout_locn(indirect(Lval, _)) = Lval. -trace__maybe_setup_redo_event(TraceInfo, Code) :- +maybe_setup_redo_event(TraceInfo, Code) :- TraceRedoLabel = TraceInfo ^ redo_label, ( TraceRedoLabel = yes(_), @@ -912,7 +909,7 @@ trace__maybe_setup_redo_event(TraceInfo, Code) :- ( MaybeFromFullSlot = yes(Lval), % The code in the runtime looks for the from-full flag in - % framevar 5; see the comment before trace__reserved_slots. + % framevar 5; see the comment before reserved_slots. expect(unify(Lval, framevar(5)), this_file, "from-full flag not stored in expected slot"), Code = node([ @@ -933,66 +930,64 @@ trace__maybe_setup_redo_event(TraceInfo, Code) :- Code = empty ). -:- pred trace__produce_vars(list(prog_var)::in, prog_varset::in, vartypes::in, +:- pred trace_produce_vars(list(prog_var)::in, prog_varset::in, vartypes::in, instmap::in, trace_port::in, set(tvar)::in, set(tvar)::out, list(layout_var_info)::in, list(layout_var_info)::out, code_tree::out, code_info::in, code_info::out) is det. -trace__produce_vars([], _, _, _, _, !TVars, !VarInfos, empty, !CI). -trace__produce_vars([Var | Vars], VarSet, VarTypes, InstMap, Port, +trace_produce_vars([], _, _, _, _, !TVars, !VarInfos, empty, !CI). +trace_produce_vars([Var | Vars], VarSet, VarTypes, InstMap, Port, !TVars, !VarInfos, tree(VarCode, VarsCode), !CI) :- - map__lookup(VarTypes, Var, Type), - code_info__get_module_info(!.CI, ModuleInfo), + map.lookup(VarTypes, Var, Type), + code_info.get_module_info(!.CI, ModuleInfo), ( is_dummy_argument_type(ModuleInfo, Type) -> VarCode = empty ; - trace__produce_var(Var, VarSet, InstMap, !TVars, - VarInfo, VarCode, !CI), + trace_produce_var(Var, VarSet, InstMap, !TVars, VarInfo, VarCode, !CI), !:VarInfos = [VarInfo | !.VarInfos] ), - trace__produce_vars(Vars, VarSet, VarTypes, InstMap, Port, !TVars, + trace_produce_vars(Vars, VarSet, VarTypes, InstMap, Port, !TVars, !VarInfos, VarsCode, !CI). -:- pred trace__produce_var(prog_var::in, prog_varset::in, instmap::in, +:- pred trace_produce_var(prog_var::in, prog_varset::in, instmap::in, set(tvar)::in, set(tvar)::out, layout_var_info::out, code_tree::out, code_info::in, code_info::out) is det. -trace__produce_var(Var, VarSet, InstMap, !Tvars, VarInfo, VarCode, !CI) :- - code_info__produce_variable_in_reg_or_stack(Var, VarCode, Lval, !CI), - Type = code_info__variable_type(!.CI, Var), - code_info__get_module_info(!.CI, ModuleInfo), - ( varset__search_name(VarSet, Var, SearchName) -> +trace_produce_var(Var, VarSet, InstMap, !Tvars, VarInfo, VarCode, !CI) :- + code_info.produce_variable_in_reg_or_stack(Var, VarCode, Lval, !CI), + Type = code_info.variable_type(!.CI, Var), + code_info.get_module_info(!.CI, ModuleInfo), + ( varset.search_name(VarSet, Var, SearchName) -> Name = SearchName ; Name = "" ), - instmap__lookup_var(InstMap, Var, Inst), - ( inst_match__inst_is_ground(ModuleInfo, Inst) -> + instmap.lookup_var(InstMap, Var, Inst), + ( inst_match.inst_is_ground(ModuleInfo, Inst) -> LldsInst = ground ; LldsInst = partial(Inst) ), LiveType = var(Var, Name, Type, LldsInst), VarInfo = layout_var_info(direct(Lval), LiveType, "trace"), - prog_type__vars(Type, TypeVars), - set__insert_list(!.Tvars, TypeVars, !:Tvars). + prog_type.vars(Type, TypeVars), + set.insert_list(!.Tvars, TypeVars, !:Tvars). %-----------------------------------------------------------------------------% -:- pred trace__build_fail_vars(list(prog_var)::in, list(mer_inst)::in, +:- pred build_fail_vars(list(prog_var)::in, list(mer_inst)::in, list(arg_info)::in, module_info::in, vartypes::in, list(prog_var)::out) is semidet. -trace__build_fail_vars([], [], [], _, _, []). -trace__build_fail_vars([Var | Vars], [Inst | Insts], [Info | Infos], - ModuleInfo, VarTypes, FailVars) :- - trace__build_fail_vars(Vars, Insts, Infos, ModuleInfo, VarTypes, - FailVars0), +build_fail_vars([], [], [], _, _, []). +build_fail_vars([Var | Vars], [Inst | Insts], [Info | Infos], ModuleInfo, + VarTypes, FailVars) :- + build_fail_vars(Vars, Insts, Infos, ModuleInfo, VarTypes, FailVars0), Info = arg_info(_Loc, ArgMode), ( ArgMode = top_in, \+ inst_is_clobbered(ModuleInfo, Inst), - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), \+ is_dummy_argument_type(ModuleInfo, Type) -> FailVars = [Var | FailVars0] @@ -1002,20 +997,20 @@ trace__build_fail_vars([Var | Vars], [Inst | Insts], [Info | Infos], %-----------------------------------------------------------------------------% -:- pred trace__code_model_to_string(code_model::in, string::out) is det. +:- func trace_code_model_to_string(code_model) = string. -trace__code_model_to_string(model_det, "MR_MODEL_DET"). -trace__code_model_to_string(model_semi, "MR_MODEL_SEMI"). -trace__code_model_to_string(model_non, "MR_MODEL_NON"). +trace_code_model_to_string(model_det) = "MR_MODEL_DET". +trace_code_model_to_string(model_semi) = "MR_MODEL_SEMI". +trace_code_model_to_string(model_non) = "MR_MODEL_NON". -:- pred trace__stackref_to_string(lval::in, string::out) is det. +:- pred stackref_to_string(lval::in, string::out) is det. -trace__stackref_to_string(Lval, LvalStr) :- +stackref_to_string(Lval, LvalStr) :- ( Lval = stackvar(Slot) -> - string__int_to_string(Slot, SlotString), + string.int_to_string(Slot, SlotString), LvalStr = "MR_sv(" ++ SlotString ++ ")" ; Lval = framevar(Slot) -> - string__int_to_string(Slot, SlotString), + string.int_to_string(Slot, SlotString), LvalStr = "MR_fv(" ++ SlotString ++ ")" ; unexpected(this_file, "non-stack lval in stackref_to_string") @@ -1023,50 +1018,46 @@ trace__stackref_to_string(Lval, LvalStr) :- %-----------------------------------------------------------------------------% -:- pred trace__convert_external_port_type(external_trace_port::in, - trace_port::out) is det. +:- func convert_external_port_type(external_trace_port) = trace_port. -trace__convert_external_port_type(call, call). -trace__convert_external_port_type(exit, exit). -trace__convert_external_port_type(fail, fail). +convert_external_port_type(call) = call. +convert_external_port_type(exit) = exit. +convert_external_port_type(fail) = fail. -:- pred trace__convert_nondet_pragma_port_type(nondet_pragma_trace_port::in, - trace_port::out) is det. +:- func convert_nondet_pragma_port_type(nondet_pragma_trace_port) = trace_port. -trace__convert_nondet_pragma_port_type(nondet_pragma_first, - nondet_pragma_first). -trace__convert_nondet_pragma_port_type(nondet_pragma_later, - nondet_pragma_later). +convert_nondet_pragma_port_type(nondet_pragma_first) = nondet_pragma_first. +convert_nondet_pragma_port_type(nondet_pragma_later) = nondet_pragma_later. %-----------------------------------------------------------------------------% -:- pred trace__event_num_slot(code_model::in, lval::out) is det. -:- pred trace__call_num_slot(code_model::in, lval::out) is det. -:- pred trace__call_depth_slot(code_model::in, lval::out) is det. -:- pred trace__redo_layout_slot(code_model::in, lval::out) is det. +:- pred event_num_slot(code_model::in, lval::out) is det. +:- pred call_num_slot(code_model::in, lval::out) is det. +:- pred call_depth_slot(code_model::in, lval::out) is det. +:- pred redo_layout_slot(code_model::in, lval::out) is det. -trace__event_num_slot(CodeModel, EventNumSlot) :- +event_num_slot(CodeModel, EventNumSlot) :- ( CodeModel = model_non -> EventNumSlot = framevar(1) ; EventNumSlot = stackvar(1) ). -trace__call_num_slot(CodeModel, CallNumSlot) :- +call_num_slot(CodeModel, CallNumSlot) :- ( CodeModel = model_non -> CallNumSlot = framevar(2) ; CallNumSlot = stackvar(2) ). -trace__call_depth_slot(CodeModel, CallDepthSlot) :- +call_depth_slot(CodeModel, CallDepthSlot) :- ( CodeModel = model_non -> CallDepthSlot = framevar(3) ; CallDepthSlot = stackvar(3) ). -trace__redo_layout_slot(CodeModel, RedoLayoutSlot) :- +redo_layout_slot(CodeModel, RedoLayoutSlot) :- ( CodeModel = model_non -> RedoLayoutSlot = framevar(4) ; diff --git a/compiler/trace_params.m b/compiler/trace_params.m index b3df4a0f2..56b087868 100644 --- a/compiler/trace_params.m +++ b/compiler/trace_params.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2000-2005 The University of Melbourne. +% Copyright (C) 2000-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -33,7 +33,7 @@ %-----------------------------------------------------------------------------% -:- module libs__trace_params. +:- module libs.trace_params. :- interface. @@ -272,7 +272,7 @@ trace_level_needs_meaningful_var_names(decl_rep) = yes. trace_needs_return_info(TraceLevel, TraceSuppressItems) = Need :- ( trace_level_has_return_info(TraceLevel) = yes, - \+ set__member(return_info, TraceSuppressItems) + \+ set.member(return_info, TraceSuppressItems) -> Need = yes ; @@ -282,7 +282,7 @@ trace_needs_return_info(TraceLevel, TraceSuppressItems) = Need :- trace_needs_all_var_names(TraceLevel, TraceSuppressItems) = Need :- ( trace_level_has_all_var_names(TraceLevel) = yes, - \+ set__member(all_var_names, TraceSuppressItems) + \+ set.member(all_var_names, TraceSuppressItems) -> Need = yes ; @@ -292,7 +292,7 @@ trace_needs_all_var_names(TraceLevel, TraceSuppressItems) = Need :- trace_needs_proc_body_reps(TraceLevel, TraceSuppressItems) = Need :- ( trace_level_has_proc_body_reps(TraceLevel) = yes, - \+ set__member(proc_body_reps, TraceSuppressItems) + \+ set.member(proc_body_reps, TraceSuppressItems) -> Need = yes ; @@ -319,16 +319,16 @@ trace_level_has_proc_body_reps(deep) = no. trace_level_has_proc_body_reps(decl_rep) = yes. convert_trace_suppress(SuppressString, SuppressItemSet) :- - SuppressWords = string__words(char_is_comma, SuppressString), - list__map(convert_item_name, SuppressWords, SuppressItemLists), - list__condense(SuppressItemLists, SuppressItems), - set__list_to_set(SuppressItems, SuppressItemSet). + SuppressWords = string.words(char_is_comma, SuppressString), + list.map(convert_item_name, SuppressWords, SuppressItemLists), + list.condense(SuppressItemLists, SuppressItems), + set.list_to_set(SuppressItems, SuppressItemSet). :- pred char_is_comma(char::in) is semidet. char_is_comma(','). -default_trace_suppress = set__init. +default_trace_suppress = set.init. :- func convert_port_name(string) = trace_port is semidet. @@ -389,7 +389,7 @@ convert_item_name(String, Names) :- ( convert_port_name(String) = PortName -> Names = [port(PortName)] ; convert_port_class_name(String) = PortNames -> - list__map(wrap_port, PortNames, Names) + list.map(wrap_port, PortNames, Names) ; convert_other_name(String) = OtherName -> Names = [OtherName] ; @@ -453,10 +453,10 @@ trace_level_allows_port_suppression(decl_rep) = no. trace_needs_port(TraceLevel, TraceSuppressItems, Port) = NeedsPort :- ( trace_port_category(Port) = Category, - list__member(Category, trace_level_port_categories(TraceLevel)), + list.member(Category, trace_level_port_categories(TraceLevel)), \+ ( trace_level_allows_port_suppression(TraceLevel) = yes, - set__member(port(Port), TraceSuppressItems) + set.member(port(Port), TraceSuppressItems) ) -> NeedsPort = yes @@ -465,7 +465,7 @@ trace_needs_port(TraceLevel, TraceSuppressItems, Port) = NeedsPort :- ). encode_suppressed_events(SuppressedEvents) = SuppressedEventsInt :- - set__fold(maybe_add_suppressed_event, SuppressedEvents, + set.fold(maybe_add_suppressed_event, SuppressedEvents, 0, SuppressedEventsInt). :- pred maybe_add_suppressed_event(trace_suppress_item::in, int::in, int::out) diff --git a/compiler/trans_opt.m b/compiler/trans_opt.m index cea7ab507..329b0130f 100644 --- a/compiler/trans_opt.m +++ b/compiler/trans_opt.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1997-2005 The University of Melbourne. +% Copyright (C) 1997-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -50,7 +50,7 @@ % %-----------------------------------------------------------------------------% -:- module transform_hlds__trans_opt. +:- module transform_hlds.trans_opt. :- interface. @@ -67,14 +67,14 @@ % Open the file ".trans_opt.tmp", and write out the % declarations. % -:- pred trans_opt__write_optfile(module_info::in, io::di, io::uo) is det. +:- pred write_optfile(module_info::in, io::di, io::uo) is det. - % trans_opt__grab_optfiles(ModuleList, !ModuleImports, Error, !IO): + % grab_optfiles(ModuleList, !ModuleImports, Error, !IO): % % Add the items from each of the modules in ModuleList.trans_opt to % the items in ModuleImports. % -:- pred trans_opt__grab_optfiles(list(module_name)::in, +:- pred grab_optfiles(list(module_name)::in, module_imports::in, module_imports::out, bool::out, io::di, io::uo) is det. %-----------------------------------------------------------------------------% @@ -111,56 +111,56 @@ %-----------------------------------------------------------------------------% -trans_opt__write_optfile(Module, !IO) :- +write_optfile(Module, !IO) :- module_info_get_name(Module, ModuleName), module_name_to_file_name(ModuleName, ".trans_opt.tmp", yes, TmpOptName, !IO), - io__open_output(TmpOptName, Result, !IO), + io.open_output(TmpOptName, Result, !IO), ( Result = error(Error), - io__error_message(Error, Msg), - io__progname_base("trans_opt.m", ProgName, !IO), - io__write_string(ProgName, !IO), - io__write_string( + io.error_message(Error, Msg), + io.progname_base("trans_opt.m", ProgName, !IO), + io.write_string(ProgName, !IO), + io.write_string( ": cannot open transitive optimisation file `", !IO), - io__write_string(TmpOptName, !IO), - io__write_string("' \n", !IO), - io__write_string(ProgName, !IO), - io__write_string(": for output: ", !IO), - io__write_string(Msg, !IO), - io__nl(!IO), - io__set_exit_status(1, !IO) + io.write_string(TmpOptName, !IO), + io.write_string("' \n", !IO), + io.write_string(ProgName, !IO), + io.write_string(": for output: ", !IO), + io.write_string(Msg, !IO), + io.nl(!IO), + io.set_exit_status(1, !IO) ; Result = ok(Stream), - io__set_output_stream(Stream, OldStream, !IO), + io.set_output_stream(Stream, OldStream, !IO), module_info_get_name(Module, ModName), - io__write_string(":- module ", !IO), + io.write_string(":- module ", !IO), mercury_output_bracketed_sym_name(ModName, !IO), - io__write_string(".\n", !IO), + io.write_string(".\n", !IO), % All predicates to write global items into the .trans_opt % file should go here. module_info_predids(Module, PredIds), - list__foldl(termination__write_pred_termination_info(Module), + list.foldl(termination.write_pred_termination_info(Module), PredIds, !IO), - list__foldl(term_constr_main.output_pred_termination2_info(Module), + list.foldl(term_constr_main.output_pred_termination2_info(Module), PredIds, !IO), - list__foldl(structure_sharing.analysis.write_pred_sharing_info(Module), + list.foldl(structure_sharing.analysis.write_pred_sharing_info(Module), PredIds, !IO), module_info_get_exception_info(Module, ExceptionInfo), - list__foldl( - exception_analysis__write_pragma_exceptions(Module, ExceptionInfo), + list.foldl( + exception_analysis.write_pragma_exceptions(Module, ExceptionInfo), PredIds, !IO), module_info_get_trailing_info(Module, TrailingInfo), - list__foldl( + list.foldl( write_pragma_trailing_info(Module, TrailingInfo), PredIds, !IO), - io__set_output_stream(OldStream, _, !IO), - io__close_output(Stream, !IO), + io.set_output_stream(OldStream, _, !IO), + io.close_output(Stream, !IO), module_name_to_file_name(ModuleName, ".trans_opt", no, OptName, !IO), update_interface(OptName, !IO), @@ -172,8 +172,8 @@ trans_opt__write_optfile(Module, !IO) :- % Read and process the transitive optimization interfaces. % -trans_opt__grab_optfiles(TransOptDeps, !Module, FoundError, !IO) :- - globals__io_lookup_bool_option(verbose, Verbose, !IO), +grab_optfiles(TransOptDeps, !Module, FoundError, !IO) :- + globals.io_lookup_bool_option(verbose, Verbose, !IO), maybe_write_string(Verbose, "% Reading .trans_opt files..\n", !IO), maybe_flush_output(Verbose, !IO), @@ -181,7 +181,7 @@ trans_opt__grab_optfiles(TransOptDeps, !Module, FoundError, !IO) :- append_pseudo_decl(opt_imported, !Module), module_imports_get_items(!.Module, Items0), - list__append(Items0, OptItems, Items), + list.append(Items0, OptItems, Items), module_imports_set_items(Items, !Module), module_imports_set_error(no_module_errors, !Module), @@ -192,24 +192,24 @@ trans_opt__grab_optfiles(TransOptDeps, !Module, FoundError, !IO) :- read_trans_opt_files([], !Items, !Error, !IO). read_trans_opt_files([Import | Imports], !Items, !Error, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), maybe_write_string(VeryVerbose, "% Reading transitive optimization interface for module", !IO), maybe_write_string(VeryVerbose, " `", !IO), - mdbcomp__prim_data__sym_name_to_string(Import, ImportString), + sym_name_to_string(Import, ImportString), maybe_write_string(VeryVerbose, ImportString, !IO), maybe_write_string(VeryVerbose, "'... ", !IO), maybe_flush_output(VeryVerbose, !IO), module_name_to_search_file_name(Import, ".trans_opt", FileName, !IO), - prog_io__read_opt_file(FileName, Import, + prog_io.read_opt_file(FileName, Import, ModuleError, Messages, NewItems, !IO), maybe_write_string(VeryVerbose, " done.\n", !IO), - intermod__update_error_status(trans_opt, FileName, ModuleError, + intermod.update_error_status(trans_opt, FileName, ModuleError, Messages, !Error, !IO), - list__append(!.Items, NewItems, !:Items), + list.append(!.Items, NewItems, !:Items), read_trans_opt_files(Imports, !Items, !Error, !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/transform.m b/compiler/transform.m index 4779c53d8..56b05adb8 100644 --- a/compiler/transform.m +++ b/compiler/transform.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1995-1998, 2003-2005 The University of Melbourne. +% Copyright (C) 1995-1998, 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -31,7 +31,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__transform. +:- module transform_hlds.transform. :- interface. :- import_module check_hlds.mode_info. @@ -67,17 +67,17 @@ reschedule_conj([Goal0 | Goals0], Goals, !ModeInfo) :- mode_info_get_instmap(!.ModeInfo, InstMap0), mode_info_get_delay_info(!.ModeInfo, DelayInfo0), - delay_info__wakeup_goals(WokenGoals, DelayInfo0, DelayInfo1), + delay_info_wakeup_goals(WokenGoals, DelayInfo0, DelayInfo1), mode_info_set_delay_info(DelayInfo1, !ModeInfo), ( WokenGoals = [_ | _], - list__append(WokenGoals, [Goal0 | Goals0], Goals1), + list.append(WokenGoals, [Goal0 | Goals0], Goals1), reschedule_conj(Goals1, Goals, !ModeInfo) ; WokenGoals = [], Goal0 = _Goal0Goal - Goal0Info, goal_info_get_instmap_delta(Goal0Info, InstMapDelta), - instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap1), + instmap.apply_instmap_delta(InstMap0, InstMapDelta, InstMap1), mode_info_set_instmap(InstMap1, !ModeInfo), reschedule_conj(Goals0, Goals1, !ModeInfo), Goals = [Goal0 | Goals1] diff --git a/compiler/transform_llds.m b/compiler/transform_llds.m index 1e1f0223b..ac5a30564 100644 --- a/compiler/transform_llds.m +++ b/compiler/transform_llds.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1998-2001,2003-2005 The University of Melbourne. +% Copyright (C) 1998-2001,2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -10,17 +10,17 @@ % Main authors: petdr. % This module does source to source transformations of the llds data -% structure. This is sometimes necessary to avoid limits in some compilers. +% structure. This is sometimes necessary to avoid limits in some compilers. % % This module currently transforms computed gotos into a binary search down to -% smaller computed gotos. This avoids a limitation in the lcc compiler. +% smaller computed gotos. This avoids a limitation in the lcc compiler. % % If accurate GC is enabled, we also append a module containing an end label % to the list of comp_gen_c_modules. %-----------------------------------------------------------------------------% -:- module ll_backend__transform_llds. +:- module ll_backend.transform_llds. :- interface. :- import_module ll_backend.llds. @@ -53,7 +53,7 @@ %-----------------------------------------------------------------------------% transform_llds(!LLDS, !IO) :- - globals__io_get_globals(Globals, !IO), + globals.io_get_globals(Globals, !IO), transform_c_file(!LLDS, Globals). %-----------------------------------------------------------------------------% @@ -63,16 +63,19 @@ transform_llds(!LLDS, !IO) :- transform_c_file(CFile0, CFile, Globals) :- CFile0 = c_file(ModuleName, _, _, _, _, _, Modules0, _, _), % split up large computed gotos - globals__lookup_int_option(Globals, max_jump_table_size, MaxSize), + globals.lookup_int_option(Globals, max_jump_table_size, MaxSize), ( MaxSize = 0 -> Modules1 = Modules0 ; transform_c_module_list(Modules0, Modules1, MaxSize) ), % append an end label for accurate GC - globals__get_gc_method(Globals, GC), - ( GC = accurate, Modules1 \= [] -> - list__last_det(Modules1, LastModule), + globals.get_gc_method(Globals, GC), + ( + GC = accurate, + Modules1 = [_ | _] + -> + list.last_det(Modules1, LastModule), LastModule = comp_gen_c_module(LastModuleName, _), Modules = Modules1 ++ [gen_end_label_module(ModuleName, LastModuleName)] @@ -81,42 +84,40 @@ transform_c_file(CFile0, CFile, Globals) :- ), CFile = CFile0 ^ cfile_code := Modules. -% -% For LLDS native GC, we need to add a dummy comp_gen_c_module at the end of -% the list. This dummy module contains only a single dummy procedure which -% in turn contains only a single label, for which there is no stack layout -% structure. The point of this is to ensure that the address of this label -% gets inserted into the entry table, so that we know where the preceding -% procedure finishes when mapping from instruction pointer values to stack -% layout entries. -% -% Without this, we might think that the following C function was -% actually part of the last Mercury procedure in the preceding module, -% and then incorrectly use the stack layout of the Mercury procedure -% if we happened to get a heap overflow signal (SIGSEGV) while in that -% C function. -% -% Note that it is not sufficient to generate a label at end of the module, -% because GCC (e.g. GCC 3.2) sometimes reorders code within a single C -% function, so that a label declared at the end of the module might not -% be actually have highest address. So we generate a new module (which -% corresponds to a new C function). XXX Hopefully GCC won't mess with the -% order of the functions... -% - + % For LLDS native GC, we need to add a dummy comp_gen_c_module at the end + % of the list. This dummy module contains only a single dummy procedure + % which in turn contains only a single label, for which there is no + % stack layout structure. The point of this is to ensure that the + % address of this label gets inserted into the entry table, so that + % we know where the preceding procedure finishes when mapping from + % instruction pointer values to stack layout entries. + % + % Without this, we might think that the following C function was + % actually part of the last Mercury procedure in the preceding module, + % and then incorrectly use the stack layout of the Mercury procedure + % if we happened to get a heap overflow signal (SIGSEGV) while in that + % C function. + % + % Note that it is not sufficient to generate a label at end of the module, + % because GCC (e.g. GCC 3.2) sometimes reorders code within a single C + % function, so that a label declared at the end of the module might not + % be actually have highest address. So we generate a new module (which + % corresponds to a new C function). XXX Hopefully GCC won't mess with the + % order of the functions... + % :- func gen_end_label_module(module_name, string) = comp_gen_c_module. gen_end_label_module(ModuleName, LastModule) = EndLabelModule :- Arity = 0, - ProcId = hlds_pred__initial_proc_id, - PredId = hlds_pred__initial_pred_id, + ProcId = hlds_pred.initial_proc_id, + PredId = hlds_pred.initial_pred_id, PredName = "ACCURATE_GC_END_LABEL", ProcLabel = proc(ModuleName, predicate, ModuleName, PredName, Arity, proc_id_to_int(ProcId)), Instrs = [label(entry(local, ProcLabel)) - "label to indicate end of previous procedure"], DummyProc = c_procedure(PredName, Arity, proc(PredId, ProcId), - Instrs, ProcLabel, counter__init(0), must_not_alter_rtti), + Instrs, ProcLabel, counter.init(0), must_not_alter_rtti), EndLabelModule = comp_gen_c_module(LastModule ++ "_END", [DummyProc]). %-----------------------------------------------------------------------------% @@ -134,9 +135,10 @@ transform_c_module_list([Module0 | Module0s], [Module | Modules], MaxSize) :- :- pred transform_c_module(comp_gen_c_module::in, comp_gen_c_module::out, int::in) is det. -transform_c_module(comp_gen_c_module(Name, Procedures0), - comp_gen_c_module(Name, Procedures), MaxSize) :- - transform_c_procedure_list(Procedures0, Procedures, MaxSize). +transform_c_module(Module0, Module, MaxSize) :- + Module0 = comp_gen_c_module(Name, Procedures0), + transform_c_procedure_list(Procedures0, Procedures, MaxSize), + Module = comp_gen_c_module(Name, Procedures). %-----------------------------------------------------------------------------% @@ -153,10 +155,11 @@ transform_c_procedure_list([Proc0 | Proc0s], [Proc | Procs], MaxSize) :- :- pred transform_c_procedure(c_procedure::in, c_procedure::out, int::in) is det. -transform_c_procedure(Proc0, Proc, MaxSize) :- - Proc0 = c_procedure(_, _, _, Instrs0, ProcLabel, C0, _), +transform_c_procedure(!Proc, MaxSize) :- + !.Proc = c_procedure(_, _, _, Instrs0, ProcLabel, C0, _), transform_instructions(Instrs0, Instrs, C0, C, ProcLabel, MaxSize), - Proc = (Proc0 ^ cproc_code := Instrs) ^ cproc_label_nums := C. + !:Proc = !.Proc ^ cproc_code := Instrs, + !:Proc = !.Proc ^ cproc_label_nums := C. :- pred transform_instructions(list(instruction)::in, list(instruction)::out, counter::in, counter::out, proc_label::in, int::in) is det. @@ -166,12 +169,12 @@ transform_instructions([Instr0 | Instrs0], Instrs, !C, ProcLabel, MaxSize) :- transform_instructions(Instrs0, InstrsTail, !C, ProcLabel, MaxSize), ( Instr0 = computed_goto(Rval, Labels) - Comment, - list__length(Labels, NumLabels), + list.length(Labels, NumLabels), NumLabels > MaxSize -> split_computed_goto(Rval, Labels, Comment, InstrsHead, !C, MaxSize, NumLabels, ProcLabel), - list__append(InstrsHead, InstrsTail, Instrs) + list.append(InstrsHead, InstrsTail, Instrs) ; Instrs = [Instr0 | InstrsTail] ). @@ -191,13 +194,13 @@ split_computed_goto(Rval, Labels, Comment, Instrs, !C, MaxSize, NumLabels, ( NumLabels =< MaxSize -> Instrs = [computed_goto(Rval, Labels) - Comment] ; - counter__allocate(LabelNum, !C), + counter.allocate(LabelNum, !C), Mid = NumLabels // 2, - ( list__split_list(Mid, Labels, StartPrime, EndPrime) -> + ( list.split_list(Mid, Labels, StartPrime, EndPrime) -> Start = StartPrime, End = EndPrime ; - unexpected(this_file, "split_computed_goto: list__split_list") + unexpected(this_file, "split_computed_goto: list.split_list") ), Index = binop(int_sub, Rval, const(int_const(Mid))), @@ -211,8 +214,7 @@ split_computed_goto(Rval, Labels, Comment, Instrs, !C, MaxSize, NumLabels, split_computed_goto(Index, End, Comment ++ " else", ElseInstrs, !C, MaxSize, NumLabels - Mid, ProcLabel), - list__append([IfInstr | ThenInstrs], [ElseInstr | ElseInstrs], - Instrs) + Instrs = [IfInstr | ThenInstrs] ++ [ElseInstr | ElseInstrs] ). %-----------------------------------------------------------------------------% diff --git a/compiler/tupling.m b/compiler/tupling.m index 3c2a5bff2..3958e0b6e 100644 --- a/compiler/tupling.m +++ b/compiler/tupling.m @@ -81,7 +81,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__tupling. +:- module transform_hlds.tupling. :- interface. :- import_module hlds.hlds_module. @@ -151,7 +151,7 @@ tuple_arguments(!ModuleInfo, !IO) :- module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_string_option(Globals, + globals.lookup_string_option(Globals, tuple_trace_counts_file, TraceCountsFile), ( TraceCountsFile = "" -> report_warning("Warning: --tuple requires " ++ @@ -174,16 +174,16 @@ tuple_arguments(!ModuleInfo, !IO) :- tuple_arguments_2(!ModuleInfo, TraceCounts0, !IO) :- module_info_get_globals(!.ModuleInfo, Globals), % We use the same cost options as for the stack optimisation. - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_cv_load_cost, CellVarLoadCost), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_cv_store_cost, CellVarStoreCost), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_fv_load_cost, FieldVarLoadCost), - globals__lookup_int_option(Globals, + globals.lookup_int_option(Globals, optimize_saved_vars_cell_fv_store_cost, FieldVarStoreCost), - globals__lookup_int_option(Globals, tuple_costs_ratio, CostsRatio), - globals__lookup_int_option(Globals, tuple_min_args, MinArgsToTuple), + globals.lookup_int_option(Globals, tuple_costs_ratio, CostsRatio), + globals.lookup_int_option(Globals, tuple_min_args, MinArgsToTuple), % These are the costs for untupled variables. We just assume it is % the lesser of the cell and field variable costs (usually the field % variable costs should be smaller). @@ -205,20 +205,20 @@ tuple_arguments_2(!ModuleInfo, TraceCounts0, !IO) :- % Add transformed versions of procedures that we think would be % beneficial. - list__foldl4(maybe_tuple_scc(TraceCounts, TuningParams, DepGraph), - SCCs, !ModuleInfo, counter__init(0), _, - map__init, TransformMap, !IO), + list.foldl4(maybe_tuple_scc(TraceCounts, TuningParams, DepGraph), + SCCs, !ModuleInfo, counter.init(0), _, + map.init, TransformMap, !IO), % Update the callers of the original procedures to call their % transformed versions instead. Do the same for the transformed % procedures themselves. - list__foldl(fix_calls_in_procs(TransformMap), SCCs, !ModuleInfo), + list.foldl(fix_calls_in_procs(TransformMap), SCCs, !ModuleInfo), fix_calls_in_transformed_procs(TransformMap, !ModuleInfo). :- pred warn_trace_counts_error(string::in, string::in, io::di, io::uo) is det. warn_trace_counts_error(TraceCountsFile, Reason, !IO) :- - string__format( + string.format( "Warning: unable to read trace count summary from %s (%s)\n", [s(TraceCountsFile), s(Reason)], Message), report_warning(Message, !IO). @@ -252,13 +252,13 @@ maybe_tuple_scc_individual_procs(TraceCounts, TuningParams, DepGraph, maybe_tuple_scc(TraceCounts, TuningParams, DepGraph, SCC, !ModuleInfo, !Counter, !TransformMap, !IO) :- module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, very_verbose, VeryVerbose), + globals.lookup_bool_option(Globals, very_verbose, VeryVerbose), ( VeryVerbose = yes, io.write_string("% Considering tupling in ", !IO), - list__foldl((pred(PredProcId::in, IO0::di, IO::uo) is det :- + list.foldl((pred(PredProcId::in, IO0::di, IO::uo) is det :- PredProcId = proc(PredId, ProcId), - hlds_out__write_pred_proc_id(!.ModuleInfo, + hlds_out.write_pred_proc_id(!.ModuleInfo, PredId, ProcId, IO0, IO)), SCC, !IO), io.write_string("\n", !IO) @@ -274,10 +274,10 @@ maybe_tuple_scc(TraceCounts, TuningParams, DepGraph, SCC, CandidateHeadVars) ), MinArgsToTuple = TuningParams ^ min_args_to_tuple, - ( list__length(CandidateHeadVars) < MinArgsToTuple -> + ( list.length(CandidateHeadVars) < MinArgsToTuple -> ( VeryVerbose = yes, - io__write_string("% Too few candidate headvars\n", !IO) + io.write_string("% Too few candidate headvars\n", !IO) ; VeryVerbose = no ) @@ -294,7 +294,7 @@ maybe_tuple_scc(TraceCounts, TuningParams, DepGraph, SCC, % to look at it, for intermodule tupling. ( VeryVerbose = yes, - io__write_string("% SCC has no local callers\n", !IO) + io.write_string("% SCC has no local callers\n", !IO) ; VeryVerbose = no ) @@ -313,9 +313,9 @@ scc_has_local_callers(CalleeProcs, DepGraph) :- is semidet. proc_has_local_callers(CalleeProc, DepGraph) :- - relation__lookup_element(DepGraph, CalleeProc, CalleeKey), - relation__lookup_to(DepGraph, CalleeKey, CallingKeys), - not set__empty(CallingKeys). + relation.lookup_element(DepGraph, CalleeProc, CalleeKey), + relation.lookup_to(DepGraph, CalleeKey, CallingKeys), + not set.empty(CallingKeys). %-----------------------------------------------------------------------------% @@ -326,10 +326,10 @@ proc_has_local_callers(CalleeProc, DepGraph) :- maybe_tuple_scc_2(TraceCounts, TuningParams, PredProcIds, CandidateHeadVars, !ModuleInfo, !Counter, !TransformMap, !IO, VeryVerbose) :- - list__foldl2(prepare_proc_for_counting, PredProcIds, !ModuleInfo, !IO), + list.foldl2(prepare_proc_for_counting, PredProcIds, !ModuleInfo, !IO), % Count the average number of loads/stores without any transformation. count_load_stores_for_scc(TraceCounts, TuningParams, !.ModuleInfo, - map__init, PredProcIds, CostsWithoutTupling), + map.init, PredProcIds, CostsWithoutTupling), ( VeryVerbose = yes, CostsWithoutTupling = costs(LoadsWoTupling, StoresWoTupling), @@ -433,7 +433,7 @@ candidate_headvars_of_proc(ModuleInfo, PredProcId @ proc(PredId, ProcId), proc_info_vartypes(ProcInfo, VarTypes), proc_info_headvars(ProcInfo, HeadVars), proc_info_argmodes(ProcInfo, ArgModes), - CandidateHeadVars = list__filter_map_corresponding( + CandidateHeadVars = list.filter_map_corresponding( candidate_headvars_of_proc_2(PredProcId, VarSet, VarTypes, ModuleInfo), HeadVars, ArgModes). @@ -446,21 +446,21 @@ candidate_headvars_of_proc_2(PredProcId, VarSet, VarTypes, ModuleInfo, % We only tuple input arguments. mode_is_input(ModuleInfo, ArgMode), % Don't touch introduced typeinfo arguments. - map__lookup(VarTypes, HeadVar, Type), + map.lookup(VarTypes, HeadVar, Type), not is_introduced_type_info_type(Type), - varset__search_name(VarSet, HeadVar, Name), - map__det_insert(map__init, PredProcId, HeadVar, Origins). + varset.search_name(VarSet, HeadVar, Name), + map.det_insert(map.init, PredProcId, HeadVar, Origins). :- pred common_candidate_headvars_of_procs(module_info::in, list(pred_proc_id)::in, candidate_headvars::out) is det. common_candidate_headvars_of_procs(ModuleInfo, PredProcIds, CandidateHeadVars) :- - list__map(candidate_headvars_of_proc(ModuleInfo), + list.map(candidate_headvars_of_proc(ModuleInfo), PredProcIds, ListsOfCandidates), - list__condense(ListsOfCandidates, FlatListOfCandidates), - multi_map__from_flat_assoc_list(FlatListOfCandidates, CandidatesMultiMap), - map__foldl(common_candidate_headvars_of_procs_2, CandidatesMultiMap, + list.condense(ListsOfCandidates, FlatListOfCandidates), + multi_map.from_flat_assoc_list(FlatListOfCandidates, CandidatesMultiMap), + map.foldl(common_candidate_headvars_of_procs_2, CandidatesMultiMap, [], CandidateHeadVars). :- pred common_candidate_headvars_of_procs_2( @@ -472,7 +472,7 @@ common_candidate_headvars_of_procs_2(HeadVarName, ListOfOrigins, % Only include this variable in the list of candidates if there are two % or more procedures in the SCC with head variables having the same name. ( ListOfOrigins = [_, _ | _] -> - list__foldl(map__merge, ListOfOrigins, map__init, Origins), + list.foldl(map.merge, ListOfOrigins, map.init, Origins), CandidateHeadVars = CandidateHeadVars0 ++ [HeadVarName - Origins] ; CandidateHeadVars = CandidateHeadVars0 @@ -515,10 +515,10 @@ find_best_tupling_scheme_2(TraceCounts, TuningParams, ModuleInfo, PredProcIds, CandidateHeadVars, MaybeBestScheme0, MaybeBestScheme) :- MinArgsToTuple = TuningParams ^ min_args_to_tuple, - list__map( + list.map( make_tupling_proposal(ModuleInfo, CandidateHeadVars, MinArgsToTuple), PredProcIds, TuplingProposals), - map__from_corresponding_lists(PredProcIds, TuplingProposals, + map.from_corresponding_lists(PredProcIds, TuplingProposals, TuplingScheme), count_load_stores_for_scc(TraceCounts, TuningParams, ModuleInfo, TuplingScheme, PredProcIds, Costs), @@ -543,19 +543,19 @@ make_tupling_proposal(ModuleInfo, CandidateHeadVars, MinArgsToTuple, module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo), proc_info_varset(ProcInfo, VarSet), proc_info_headvars(ProcInfo, HeadVars), - FieldVarArgPos = list__filter_map( + FieldVarArgPos = list.filter_map( (func(_ - Annotation) = (Var - Pos) is semidet :- - map__search(Annotation, PredProcId, Var), - list__nth_member_search(HeadVars, Var, Pos)), + map.search(Annotation, PredProcId, Var), + list.nth_member_search(HeadVars, Var, Pos)), CandidateHeadVars), - ( list__length(FieldVarArgPos) < MinArgsToTuple -> + ( list.length(FieldVarArgPos) < MinArgsToTuple -> TuplingProposal = no_tupling ; % We need a new variable to act as the cell variable while % counting loads/stores for a proposed tupling, but we don't % add that variable to the varset permanently. - varset__new_named_var(VarSet, "DummyCellVar", DummyCellVar, _), - FieldVars = assoc_list__keys(FieldVarArgPos), + varset.new_named_var(VarSet, "DummyCellVar", DummyCellVar, _), + FieldVars = assoc_list.keys(FieldVarArgPos), TuplingProposal = tupling(DummyCellVar, FieldVars, FieldVarArgPos) ). @@ -586,7 +586,7 @@ fold_over_list_runs(Pred, List @ [_ | Tail], MinLength, !Acc) :- list(L)::in, int::in, A::in, A::out) is det. fold_over_list_runs_2(Pred, List, Length, !Acc) :- - ( list__take(Length, List, Front) -> + ( list.take(Length, List, Front) -> Pred(Front, !Acc), fold_over_list_runs_2(Pred, List, Length+1, !Acc) ; @@ -603,7 +603,7 @@ fold_over_list_runs_2(Pred, List, Length, !Acc) :- transform_map::out) is det. add_transformed_procs(TuplingScheme, !ModuleInfo, !Counter, !TransformMap) :- - map__foldl3(add_transformed_proc, TuplingScheme, + map.foldl3(add_transformed_proc, TuplingScheme, !ModuleInfo, !Counter, !TransformMap). :- pred add_transformed_proc(pred_proc_id::in, tupling_proposal::in, @@ -622,9 +622,9 @@ add_transformed_proc(PredProcId, tupling(_, FieldVars, _), build_interval_info(!.ModuleInfo, !.ProcInfo, IntervalInfo), % Create the cell variable. - list__length(FieldVars, TupleArity), + list.length(FieldVars, TupleArity), proc_info_vartypes(!.ProcInfo, VarTypes), - list__map(map__lookup(VarTypes), FieldVars, TupleArgTypes), + list.map(map.lookup(VarTypes), FieldVars, TupleArgTypes), construct_type(unqualified("{}") - TupleArity, TupleArgTypes, TupleConsType), proc_info_create_var_from_type(TupleConsType, @@ -632,7 +632,7 @@ add_transformed_proc(PredProcId, tupling(_, FieldVars, _), % Get the argument positions of the parameters to be tupled. proc_info_headvars(!.ProcInfo, HeadVars), - list__map(nth_member_lookup(HeadVars), FieldVars, ArgsToTuple), + list.map(nth_member_lookup(HeadVars), FieldVars, ArgsToTuple), % Build an insertion map of where the deconstruction % unifications are needed. @@ -642,14 +642,14 @@ add_transformed_proc(PredProcId, tupling(_, FieldVars, _), % the module. make_transformed_proc(CellVar, FieldVars, InsertMap, !ProcInfo), recompute_instmap_delta_proc(yes, !ProcInfo, !ModuleInfo), - counter__allocate(Num, !Counter), + counter.allocate(Num, !Counter), create_aux_pred(PredId, ProcId, PredInfo, !.ProcInfo, Num, AuxPredProcId, CallAux, !ModuleInfo), % Add an entry to the transform map for the new procedure. TransformedProc = transformed_proc(AuxPredProcId, TupleConsType, ArgsToTuple, CallAux), - svmap__det_insert(PredProcId, TransformedProc, !TransformMap) + svmap.det_insert(PredProcId, TransformedProc, !TransformMap) ). add_transformed_proc(_, no_tupling, !ModuleInfo, !TransformMap, !Counter). @@ -663,11 +663,11 @@ make_transformed_proc(CellVar, FieldVarsList, InsertMap, !ProcInfo) :- % Modify the procedure's formal parameters. proc_info_headvars(!.ProcInfo, HeadVars0), proc_info_argmodes(!.ProcInfo, ArgModes0), - HeadVarsAndModes = list__filter_map_corresponding( + HeadVarsAndModes = list.filter_map_corresponding( (func(Var, Mode) = (Var - Mode) is semidet :- not Var `list.member` FieldVarsList), HeadVars0, ArgModes0), - assoc_list__keys_and_values(HeadVarsAndModes, HeadVars, ArgModes), + assoc_list.keys_and_values(HeadVarsAndModes, HeadVars, ArgModes), proc_info_set_headvars(HeadVars ++ [CellVar], !ProcInfo), proc_info_set_argmodes(ArgModes ++ [in_mode], !ProcInfo), @@ -678,7 +678,7 @@ make_transformed_proc(CellVar, FieldVarsList, InsertMap, !ProcInfo) :- % XXX: I haven't checked if adding this feature has any effect. MaybeGoalFeature = yes(tuple_opt), record_decisions_in_goal(Goal0, Goal1, VarSet0, VarSet1, - VarTypes0, VarTypes1, map__init, RenameMapA, InsertMap, + VarTypes0, VarTypes1, map.init, RenameMapA, InsertMap, MaybeGoalFeature), % In some cases some of the field variables need to be available at @@ -693,14 +693,14 @@ make_transformed_proc(CellVar, FieldVarsList, InsertMap, !ProcInfo) :- % deconstruct_tuple(CellVar, FieldVarsList, ProcStartDeconstruct), ProcStartInsert = insert_spec(ProcStartDeconstruct, - set__from_list(FieldVarsList)), + set.from_list(FieldVarsList)), insert_proc_start_deconstruction(Goal1, Goal2, VarSet1, VarSet, VarTypes1, VarTypes, RenameMapB, ProcStartInsert), rename_vars_in_goal(RenameMapB, Goal2, Goal3), - map__merge(RenameMapA, RenameMapB, RenameMap), - apply_headvar_correction(set__from_list(HeadVars), RenameMap, Goal3, Goal), + map.merge(RenameMapA, RenameMapB, RenameMap), + apply_headvar_correction(set.from_list(HeadVars), RenameMap, Goal3, Goal), proc_info_set_goal(Goal, !ProcInfo), proc_info_set_varset(VarSet, !ProcInfo), proc_info_set_vartypes(VarTypes, !ProcInfo), @@ -714,7 +714,7 @@ insert_proc_start_deconstruction(Goal0, Goal, !VarSet, !VarTypes, VarRename, Insert) :- % The tuple_opt feature is not used for this goal as we do want % other transformations to remove it if possible. - make_inserted_goal(!VarSet, !VarTypes, map__init, VarRename, + make_inserted_goal(!VarSet, !VarTypes, map.init, VarRename, Insert, no, InsertGoal), Goal0 = _ - GoalInfo, conj_list_to_goal([InsertGoal, Goal0], GoalInfo, Goal). @@ -755,9 +755,9 @@ create_aux_pred(PredId, ProcId, PredInfo, ProcInfo, Counter, PredName = pred_info_name(PredInfo), PredOrFunc = pred_info_is_pred_or_func(PredInfo), goal_info_get_context(GoalInfo, Context), - term__context_line(Context, Line), + term.context_line(Context, Line), proc_id_to_int(ProcId, ProcNo), - AuxNamePrefix = string__format("tupling_%d", [i(ProcNo)]), + AuxNamePrefix = string.format("tupling_%d", [i(ProcNo)]), make_pred_name_with_context(ModuleName, AuxNamePrefix, PredOrFunc, PredName, Line, Counter, AuxPredSymName), ( @@ -767,7 +767,7 @@ create_aux_pred(PredId, ProcId, PredInfo, ProcInfo, Counter, ), Origin = transformed(tuple(ProcNo), OrigOrigin, PredId), - hlds_pred__define_new_pred( + hlds_pred.define_new_pred( Origin, % in Goal, % in CallAux, % out @@ -834,7 +834,7 @@ create_aux_pred(PredId, ProcId, PredInfo, ProcInfo, Counter, is det. get_tupling_proposal(CountInfo, PredProcId) = TuplingProposal :- - ( map__search(CountInfo ^ tupling_scheme, PredProcId, Probe) -> + ( map.search(CountInfo ^ tupling_scheme, PredProcId, Probe) -> TuplingProposal = Probe ; TuplingProposal = no_tupling @@ -864,24 +864,23 @@ prepare_proc_for_counting(PredProcId, !ModuleInfo, !IO) :- detect_liveness_proc(PredId, ProcId, !.ModuleInfo, !ProcInfo, !IO), initial_liveness(!.ProcInfo, PredId, !.ModuleInfo, Liveness0), module_info_get_globals(!.ModuleInfo, Globals), - body_should_use_typeinfo_liveness(PredInfo, Globals, - TypeInfoLiveness), - globals__lookup_bool_option(Globals, + body_should_use_typeinfo_liveness(PredInfo, Globals, TypeInfoLiveness), + globals.lookup_bool_option(Globals, opt_no_return_calls, OptNoReturnCalls), AllocData = alloc_data(!.ModuleInfo, !.ProcInfo, TypeInfoLiveness, OptNoReturnCalls), - goal_path__fill_slots(!.ModuleInfo, !ProcInfo), + fill_goal_path_slots(!.ModuleInfo, !ProcInfo), proc_info_goal(!.ProcInfo, Goal0), OptTupleAlloc0 = opt_tuple_alloc, - set__init(FailVars), - set__init(NondetLiveness0), + set.init(FailVars), + set.init(NondetLiveness0), build_live_sets_in_goal(Goal0, Goal, FailVars, AllocData, OptTupleAlloc0, _OptTupleAlloc, Liveness0, _Liveness, NondetLiveness0, _NondetLiveness), proc_info_set_goal(Goal, !ProcInfo), - module_info_set_pred_proc_info(PredId, ProcId, - PredInfo, !.ProcInfo, !ModuleInfo) + module_info_set_pred_proc_info(PredId, ProcId, PredInfo, !.ProcInfo, + !ModuleInfo) ). %-----------------------------------------------------------------------------% @@ -921,8 +920,9 @@ opt_at_par_conj(_NeedParConj, _GoalInfo, StackAlloc, StackAlloc). count_load_stores_for_scc(TraceCounts, TuningParams, ModuleInfo, TuplingScheme, PredProcIds, costs(Loads, Stores)) :- - list__foldl2(count_load_stores_for_scc_2(TraceCounts, - TuningParams, ModuleInfo, TuplingScheme), + list.foldl2( + count_load_stores_for_scc_2(TraceCounts, TuningParams, ModuleInfo, + TuplingScheme), PredProcIds, 0.0, Loads, 0.0, Stores). :- pred count_load_stores_for_scc_2(trace_counts::in, tuning_params::in, @@ -936,11 +936,11 @@ count_load_stores_for_scc_2(TraceCounts, TuningParams, ModuleInfo, PredInfo, ProcInfo), % XXX: Different declaring vs defining modules not handled. ProcLabel = proc(pred_info_module(PredInfo), - pred_info_is_pred_or_func(PredInfo), - pred_info_module(PredInfo), - pred_info_name(PredInfo), - pred_info_orig_arity(PredInfo), - proc_id_to_int(ProcId)), + pred_info_is_pred_or_func(PredInfo), + pred_info_module(PredInfo), + pred_info_name(PredInfo), + pred_info_orig_arity(PredInfo), + proc_id_to_int(ProcId)), pred_info_context(PredInfo, Context), Context = context(FileName, _), ProcLabelAndFile = proc_label_and_filename(ProcLabel, FileName), @@ -972,17 +972,17 @@ count_load_stores_in_proc(CountInfo, Loads, Stores) :- ProcInfo = CountInfo ^ count_info_proc, ModuleInfo = CountInfo ^ count_info_module, initial_liveness(ProcInfo, PredId, ModuleInfo, InitialLiveness), - CountState0 = count_state(InitialLiveness, set__init, 0.0, 0.0), + CountState0 = count_state(InitialLiveness, set.init, 0.0, 0.0), proc_info_goal(ProcInfo, Goal), count_load_stores_in_goal(Goal, CountInfo, CountState0, CountState1), - arg_info__partition_proc_args(ProcInfo, ModuleInfo, _, OutputArgs, _), - cls_require_in_regs(CountInfo, set__to_sorted_list(OutputArgs), + arg_info.partition_proc_args(ProcInfo, ModuleInfo, _, OutputArgs, _), + cls_require_in_regs(CountInfo, set.to_sorted_list(OutputArgs), CountState1, CountState), CountState = count_state(_, _, Loads, Stores). %-----------------------------------------------------------------------------% - % This code is based on interval__build_interval_info_in_goal. + % This code is based on interval.build_interval_info_in_goal. :- pred count_load_stores_in_goal(hlds_goal::in, count_info::in, count_state::in, count_state::out) is det. @@ -993,14 +993,14 @@ count_load_stores_in_goal(Goal - GoalInfo, CountInfo, !CountState) :- ModuleInfo = CountInfo ^ count_info_module, module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _PredInfo, ProcInfo), - ArgVars = list__map(foreign_arg_var, Args), - ExtraVars = list__map(foreign_arg_var, ExtraArgs), + ArgVars = list.map(foreign_arg_var, Args), + ExtraVars = list.map(foreign_arg_var, ExtraArgs), CallingProcInfo = CountInfo ^ count_info_proc, proc_info_vartypes(CallingProcInfo, VarTypes), - arg_info__partition_proc_call_args(ProcInfo, VarTypes, + arg_info.partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, ArgVars, InputArgVarSet, OutputArgVarSet, _), - set__to_sorted_list(InputArgVarSet, InputArgVars), - list__append(InputArgVars, ExtraVars, InputVars), + set.to_sorted_list(InputArgVarSet, InputArgVars), + list.append(InputArgVars, ExtraVars, InputVars), ( goal_info_maybe_get_maybe_need_across_call(GoalInfo, MaybeNeedAcrossCall), @@ -1019,8 +1019,8 @@ count_load_stores_in_goal(Goal - GoalInfo, CountInfo, !CountState) :- ModuleInfo = CountInfo ^ count_info_module, goal_info_get_maybe_need_across_call(GoalInfo, MaybeNeedAcrossCall), proc_info_vartypes(ProcInfo, VarTypes), - list__map(map__lookup(VarTypes), ArgVars, ArgTypes), - arg_info__compute_in_and_out_vars(ModuleInfo, ArgVars, + list.map(map.lookup(VarTypes), ArgVars, ArgTypes), + arg_info.compute_in_and_out_vars(ModuleInfo, ArgVars, ArgModes, ArgTypes, InputArgs, OutputArgs), % Casts are generated inline. @@ -1029,11 +1029,11 @@ count_load_stores_in_goal(Goal - GoalInfo, CountInfo, !CountState) :- cls_put_in_regs(OutputArgs, !CountState) ; module_info_get_globals(ModuleInfo, Globals), - call_gen__generic_call_info(Globals, GenericCall, + call_gen.generic_call_info(Globals, GenericCall, length(InputArgs), _, GenericVarsArgInfos, _, _), - assoc_list__keys(GenericVarsArgInfos, GenericVars), - list__append(GenericVars, InputArgs, Inputs), - set__list_to_set(OutputArgs, Outputs), + assoc_list.keys(GenericVarsArgInfos, GenericVars), + list.append(GenericVars, InputArgs, Inputs), + set.list_to_set(OutputArgs, Outputs), count_load_stores_for_call(CountInfo, Inputs, Outputs, MaybeNeedAcrossCall, GoalInfo, !CountState) ). @@ -1163,7 +1163,7 @@ count_load_stores_in_call_to_tupled(Goal - GoalInfo, CountInfo, _, CalleeProcInfo), CallingProcInfo = CountInfo ^ count_info_proc, proc_info_vartypes(CallingProcInfo, VarTypes), - arg_info__partition_proc_call_args(CalleeProcInfo, VarTypes, + arg_info.partition_proc_call_args(CalleeProcInfo, VarTypes, ModuleInfo, ArgVars, InputArgs0, Outputs, _), ( % If the caller is a tupled procedure, and every field variable @@ -1177,14 +1177,14 @@ count_load_stores_in_call_to_tupled(Goal - GoalInfo, CountInfo, get_own_tupling_proposal(CountInfo) = tupling(_, _, _), all [Var] Var `list.member` FieldVars => ( Var `set.member` InputArgs0, - assoc_list__search(FieldVarArgPos, Var, Pos), - list__nth_member_search(ArgVars, Var, Pos) + assoc_list.search(FieldVarArgPos, Var, Pos), + list.nth_member_search(ArgVars, Var, Pos) ) -> % In this case, the cell var is not being used to access field % variables, so it should not incur the cell var cost. cls_require_normal_var_in_reg(CountInfo, CellVar, !CountState), - set__delete_list(InputArgs0, FieldVars, InputArgs) + set.delete_list(InputArgs0, FieldVars, InputArgs) ; % The cell var cannot be used for the callee, so we must add % the cost of constructing a new tuple. @@ -1194,7 +1194,7 @@ count_load_stores_in_call_to_tupled(Goal - GoalInfo, CountInfo, (!.CountState ^ store_costs + CellVarStoreCost)), InputArgs = InputArgs0 ), - set__to_sorted_list(InputArgs, Inputs), + set.to_sorted_list(InputArgs, Inputs), goal_info_get_maybe_need_across_call(GoalInfo, MaybeNeedAcrossCall), count_load_stores_for_call(CountInfo, Inputs, Outputs, MaybeNeedAcrossCall, GoalInfo, !CountState). @@ -1210,12 +1210,12 @@ count_load_stores_in_call_to_not_tupled(Goal - GoalInfo, CountInfo, _PredInfo, CalleeProcInfo), ProcInfo = CountInfo ^ count_info_proc, proc_info_vartypes(ProcInfo, VarTypes), - arg_info__partition_proc_call_args(CalleeProcInfo, VarTypes, + arg_info.partition_proc_call_args(CalleeProcInfo, VarTypes, ModuleInfo, ArgVars, InputArgs, Outputs, _), - set__to_sorted_list(InputArgs, Inputs), + set.to_sorted_list(InputArgs, Inputs), ( Builtin = inline_builtin -> cls_require_in_regs(CountInfo, Inputs, !CountState), - cls_put_in_regs(set__to_sorted_list(Outputs), !CountState) + cls_put_in_regs(set.to_sorted_list(Outputs), !CountState) ; goal_info_get_maybe_need_across_call(GoalInfo, MaybeNeedAcrossCall), @@ -1234,7 +1234,7 @@ count_load_stores_for_call(CountInfo, Inputs, Outputs, MaybeNeedAcrossCall, MaybeNeedAcrossCall = yes(NeedAcrossCall), NeedAcrossCall = need_across_call(ForwardVars, ResumeVars, NondetLiveVars), - AllVars = set__union_list([ForwardVars, ResumeVars, NondetLiveVars]), + AllVars = set.union_list([ForwardVars, ResumeVars, NondetLiveVars]), cls_require_flushed(CountInfo, AllVars, !CountState), cls_clobber_regs(Outputs, !CountState) ; @@ -1306,7 +1306,7 @@ count_load_stores_in_cases([Case | Cases], CountInfo, !CountState) :- count_state::out) is det. cls_require_in_regs(CountInfo, Vars, !CountState) :- - list__foldl(cls_require_in_reg(CountInfo), Vars, !CountState). + list.foldl(cls_require_in_reg(CountInfo), Vars, !CountState). :- pred cls_require_in_reg(count_info::in, prog_var::in, count_state::in, count_state::out) is det. @@ -1390,17 +1390,17 @@ cls_put_in_regs_via_deconstruct(CountInfo, TuplingProposal = no_tupling, cls_require_var_in_reg_with_cost(CvLoadCost, DeconstructCellVar, !State), - list__foldl(cls_require_var_in_reg_with_cost(FvLoadCost), + list.foldl(cls_require_var_in_reg_with_cost(FvLoadCost), DeconstructFieldVars, !State) ; TuplingProposal = tupling(_, TupleFieldVars, _), - VarsToLoad = set__difference( - set__from_list(DeconstructFieldVars), - set__from_list(TupleFieldVars)), - ( set__non_empty(VarsToLoad) -> + VarsToLoad = set.difference( + set.from_list(DeconstructFieldVars), + set.from_list(TupleFieldVars)), + ( set.non_empty(VarsToLoad) -> cls_require_var_in_reg_with_cost(CvLoadCost, DeconstructCellVar, !State), - set__fold(cls_require_var_in_reg_with_cost(FvLoadCost), VarsToLoad, + set.fold(cls_require_var_in_reg_with_cost(FvLoadCost), VarsToLoad, !State) ; % All the variables generated by this deconstruction can be @@ -1422,7 +1422,7 @@ cls_put_in_regs_via_deconstruct(CountInfo, cls_require_flushed(CountInfo, Vars, !CountState) :- TuplingProposal = get_own_tupling_proposal(CountInfo), TuningParams = CountInfo ^ count_info_params, - set__fold(cls_require_flushed_2(TuplingProposal, TuningParams), + set.fold(cls_require_flushed_2(TuplingProposal, TuningParams), Vars, !CountState). :- pred cls_require_flushed_2(tupling_proposal::in, tuning_params::in, @@ -1496,28 +1496,28 @@ add_branch_costs(BranchState, Weight, !CountState) :- build_interval_info(ModuleInfo, ProcInfo, IntervalInfo) :- proc_info_goal(ProcInfo, Goal), proc_info_vartypes(ProcInfo, VarTypes), - arg_info__partition_proc_args(ProcInfo, ModuleInfo, + arg_info.partition_proc_args(ProcInfo, ModuleInfo, _InputArgs, OutputArgs, _UnusedArgs), - Counter0 = counter__init(1), - counter__allocate(CurInterval, Counter0, Counter), + Counter0 = counter.init(1), + counter.allocate(CurInterval, Counter0, Counter), CurIntervalId = interval_id(CurInterval), - EndMap = map__det_insert(map__init, CurIntervalId, proc_end), - StartMap = map__init, - SuccMap = map__det_insert(map__init, CurIntervalId, []), - VarsMap = map__det_insert(map__init, CurIntervalId, OutputArgs), + EndMap = map.det_insert(map.init, CurIntervalId, proc_end), + StartMap = map.init, + SuccMap = map.det_insert(map.init, CurIntervalId, []), + VarsMap = map.det_insert(map.init, CurIntervalId, OutputArgs), IntParams = interval_params(ModuleInfo, VarTypes, no), - IntervalInfo0 = interval_info(IntParams, set__init, - OutputArgs, map__init, map__init, map__init, + IntervalInfo0 = interval_info(IntParams, set.init, + OutputArgs, map.init, map.init, map.init, CurIntervalId, Counter, - set__make_singleton_set(CurIntervalId), - map__init, set__init, StartMap, EndMap, - SuccMap, VarsMap, map__init), + set.make_singleton_set(CurIntervalId), + map.init, set.init, StartMap, EndMap, + SuccMap, VarsMap, map.init), build_interval_info_in_goal(Goal, IntervalInfo0, IntervalInfo, unit, _). % This is needed only to satisfy the interface of interval.m % :- instance build_interval_info_acc(unit) where [ - pred(use_cell/8) is tupling__use_cell + pred(use_cell/8) is tupling.use_cell ]. :- pred use_cell(prog_var::in, list(prog_var)::in, cons_id::in, hlds_goal::in, @@ -1536,9 +1536,9 @@ use_cell(_CellVar, _FieldVarList, _ConsId, _Goal, !IntervalInfo, !Unit). insert_map::out) is det. build_insert_map(CellVar, FieldVars, IntervalInfo, InsertMap) :- - FieldVarsSet = set__from_list(FieldVars), - map__foldl(build_insert_map_2(CellVar, FieldVars, FieldVarsSet), - IntervalInfo ^ anchor_follow_map, map__init, InsertMap). + FieldVarsSet = set.from_list(FieldVars), + map.foldl(build_insert_map_2(CellVar, FieldVars, FieldVarsSet), + IntervalInfo ^ anchor_follow_map, map.init, InsertMap). :- pred build_insert_map_2(prog_var::in, list(prog_var)::in, set(prog_var)::in, anchor::in, anchor_follow_info::in, insert_map::in, insert_map::out) @@ -1546,8 +1546,8 @@ build_insert_map(CellVar, FieldVars, IntervalInfo, InsertMap) :- build_insert_map_2(CellVar, FieldVars, FieldVarsSet, Anchor, FollowVars - _, !InsertMap) :- - NeededFieldVars = FieldVarsSet `set__intersect` FollowVars, - ( set__empty(NeededFieldVars) -> + NeededFieldVars = FieldVarsSet `set.intersect` FollowVars, + ( set.empty(NeededFieldVars) -> true ; deconstruct_tuple(CellVar, FieldVars, Goal), @@ -1559,11 +1559,11 @@ build_insert_map_2(CellVar, FieldVars, FieldVarsSet, Anchor, FollowVars - _, insert_map::out) is det. add_insert_spec(Anchor, InsertSpec, !InsertMap) :- - ( map__search(!.InsertMap, Anchor, InsertSpecs0) -> + ( map.search(!.InsertMap, Anchor, InsertSpecs0) -> combine_inserts(InsertSpec, InsertSpecs0, InsertSpecs), - svmap__det_update(Anchor, InsertSpecs, !InsertMap) + svmap.det_update(Anchor, InsertSpecs, !InsertMap) ; - svmap__det_insert(Anchor, [InsertSpec], !InsertMap) + svmap.det_insert(Anchor, [InsertSpec], !InsertMap) ). :- pred combine_inserts(insert_spec::in, list(insert_spec)::in, @@ -1575,7 +1575,7 @@ combine_inserts(A, [B | Bs], [C | Cs]) :- A = insert_spec(Goal, ASet), B = insert_spec(Goal, BSet) -> - C = insert_spec(Goal, ASet `set__union` BSet), + C = insert_spec(Goal, ASet `set.union` BSet), Cs = Bs ; C = B, @@ -1616,13 +1616,13 @@ combine_inserts(A, [B | Bs], [C | Cs]) :- module_info::in, module_info::out) is det. fix_calls_in_procs(TransformMap, PredProcIds, !ModuleInfo) :- - list__foldl(fix_calls_in_proc(TransformMap), PredProcIds, !ModuleInfo). + list.foldl(fix_calls_in_proc(TransformMap), PredProcIds, !ModuleInfo). :- pred fix_calls_in_transformed_procs(transform_map::in, module_info::in, module_info::out) is det. fix_calls_in_transformed_procs(TransformMap, !ModuleInfo) :- - map__foldl(fix_calls_in_transformed_procs_2(TransformMap), TransformMap, + map.foldl(fix_calls_in_transformed_procs_2(TransformMap), TransformMap, !ModuleInfo). :- pred fix_calls_in_transformed_procs_2(transform_map::in, pred_proc_id::in, @@ -1679,13 +1679,13 @@ fix_calls_in_goal(Goal0 - GoalInfo0, Goal, !VarSet, !VarTypes, TransformMap) :- _Context, _SymName), ( Builtin = not_builtin, - map__search(TransformMap, proc(CalledPredId0, CalledProcId0), + map.search(TransformMap, proc(CalledPredId0, CalledProcId0), TransformedProc), TransformedProc = transformed_proc(_, TupleConsType, ArgsToTuple, CallAux0 - CallAuxInfo) -> - svvarset__new_named_var("TuplingCellVarForCall", CellVar, !VarSet), - svmap__det_insert(CellVar, TupleConsType, !VarTypes), + svvarset.new_named_var("TuplingCellVarForCall", CellVar, !VarSet), + svmap.det_insert(CellVar, TupleConsType, !VarTypes), extract_tupled_args_from_list(Args0, ArgsToTuple, TupledArgs, UntupledArgs), construct_tuple(CellVar, TupledArgs, ConstructGoal), @@ -1698,7 +1698,7 @@ fix_calls_in_goal(Goal0 - GoalInfo0, Goal, !VarSet, !VarTypes, TransformMap) :- unexpected(this_file, "fix_calls_in_goal: not a call template") ), conj_list_to_goal([ConstructGoal, CallGoal], GoalInfo0, Goal1), - RequantifyVars = set__from_list([CellVar | Args0]), + RequantifyVars = set.from_list([CellVar | Args0]), implicitly_quantify_goal(RequantifyVars, _, Goal1, Goal, !VarSet, !VarTypes) ; @@ -1805,7 +1805,7 @@ fix_calls_in_cases([Case0 | Cases0], [Case | Cases], !VarSet, !VarTypes, prog_vars::out, prog_vars::out) is det. extract_tupled_args_from_list(ArgList, Indices, Selected, NotSelected) :- - list__map(list__index1_det(ArgList), Indices, Selected), + list.map(list.index1_det(ArgList), Indices, Selected), extract_tupled_args_from_list_2(ArgList, 1, Indices, NotSelected). :- pred extract_tupled_args_from_list_2(prog_vars::in, int::in, list(int)::in, @@ -1826,15 +1826,15 @@ extract_tupled_args_from_list_2([H | T], Num, Indices, NotSelected) :- % :- type mdbcomp_goal_path_step - == mdbcomp__program_representation__goal_path_step. + == mdbcomp.program_representation.goal_path_step. :- type mdbcomp_goal_path - == mdbcomp__program_representation__goal_path. + == mdbcomp.program_representation.goal_path. :- pred get_proc_counts(trace_counts::in, proc_label_and_filename::in, maybe(proc_trace_counts)::out) is det. get_proc_counts(TraceCounts, ProcLabelAndFile, MaybeProcCounts) :- - ( map__search(TraceCounts, ProcLabelAndFile, ProcCounts) -> + ( map.search(TraceCounts, ProcLabelAndFile, ProcCounts) -> MaybeProcCounts = yes(ProcCounts) ; MaybeProcCounts = no @@ -1843,7 +1843,7 @@ get_proc_counts(TraceCounts, ProcLabelAndFile, MaybeProcCounts) :- :- pred get_proc_calls(proc_trace_counts::in, int::out) is det. get_proc_calls(ProcCounts, Count) :- - map__lookup(ProcCounts, port_only(call), ContextCount), + map.lookup(ProcCounts, port_only(call), ContextCount), Count = ContextCount ^ exec_count. :- pred get_path_only_count(proc_trace_counts::in, mdbcomp_goal_path::in, @@ -1851,7 +1851,7 @@ get_proc_calls(ProcCounts, Count) :- get_path_only_count(ProcCounts, GoalPath, Count) :- PathPort = path_only(GoalPath), - ( map__search(ProcCounts, PathPort, ContextCount) -> + ( map.search(ProcCounts, PathPort, ContextCount) -> Count = ContextCount ^ exec_count ; Count = 0 @@ -1882,10 +1882,10 @@ get_disjunct_relative_frequency(ProcCounts, GoalPath, RelFreq) :- ( GoalPath = [disj(Num) | GoalPathRest] -> goal_path_to_mdbcomp_goal_path(GoalPathRest, MdbGoalPathRest), get_path_only_count(ProcCounts, - [mdbcomp__program_representation__disj(Num) | + [mdbcomp.program_representation.disj(Num) | MdbGoalPathRest], DisjCount), get_path_only_count(ProcCounts, - [mdbcomp__program_representation__disj(1) | + [mdbcomp.program_representation.disj(1) | MdbGoalPathRest], FirstDisjCount), ( FirstDisjCount = 0 -> RelFreq = 0.0 @@ -1915,8 +1915,7 @@ get_case_relative_frequency(ProcCounts, GoalPath, RelFreq) :- int::out) is det. get_switch_total_count(ProcCounts, MdbGoalPath, Total) :- - map__foldl(get_switch_total_count_2(MdbGoalPath), - ProcCounts, 0, Total). + map.foldl(get_switch_total_count_2(MdbGoalPath), ProcCounts, 0, Total). :- pred get_switch_total_count_2(mdbcomp_goal_path::in, path_port::in, line_no_and_count::in, int::in, int::out) is det. @@ -1944,8 +1943,7 @@ case_in_switch([mdbcomp.program_representation.switch(_) | Prefix], is det. goal_path_to_mdbcomp_goal_path(GoalPath, MdbGoalPath) :- - list__map(goal_path_step_to_mdbcomp_goal_path_step, - GoalPath, MdbGoalPath). + list.map(goal_path_step_to_mdbcomp_goal_path_step, GoalPath, MdbGoalPath). :- pred goal_path_step_to_mdbcomp_goal_path_step(goal_path_step::in, mdbcomp_goal_path_step::out) is det. diff --git a/compiler/type_class_info.m b/compiler/type_class_info.m index b3ed4498e..f28bfce5c 100644 --- a/compiler/type_class_info.m +++ b/compiler/type_class_info.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 2003-2005 The University of Melbourne. +% Copyright (C) 2003-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -19,7 +19,7 @@ %---------------------------------------------------------------------------% -:- module backend_libs__type_class_info. +:- module backend_libs.type_class_info. :- interface. :- import_module backend_libs.rtti. @@ -31,7 +31,7 @@ %---------------------------------------------------------------------------% -:- pred type_class_info__generate_rtti(module_info::in, bool::in, +:- pred generate_type_class_info_rtti(module_info::in, bool::in, list(rtti_data)::out) is det. :- func generate_class_constraint(prog_constraint) = tc_constraint. @@ -71,15 +71,15 @@ % typed arguments. We generate descriptors for type class instances only if % requested to generate all the descriptors we can. -generate_rtti(ModuleInfo, GenerateAll, !:RttiDatas) :- +generate_type_class_info_rtti(ModuleInfo, GenerateAll, !:RttiDatas) :- module_info_get_class_table(ModuleInfo, ClassTable), - map__to_assoc_list(ClassTable, Classes), - list__foldl(generate_class_decl(ModuleInfo), Classes, [], !:RttiDatas), + map.to_assoc_list(ClassTable, Classes), + list.foldl(generate_class_decl(ModuleInfo), Classes, [], !:RttiDatas), ( GenerateAll = yes, module_info_get_instance_table(ModuleInfo, InstanceTable), - map__to_assoc_list(InstanceTable, Instances), - list__foldl(generate_instance_decls(ModuleInfo), Instances, !RttiDatas) + map.to_assoc_list(InstanceTable, Instances), + list.foldl(generate_instance_decls(ModuleInfo), Instances, !RttiDatas) ; GenerateAll = no ). @@ -95,7 +95,7 @@ generate_class_decl(ModuleInfo, ClassId - ClassDefn, !RttiDatas) :- ( status_defined_in_this_module(ImportStatus, yes) -> TCId = generate_class_id(ModuleInfo, ClassId, ClassDefn), Supers = ClassDefn ^ class_supers, - TCSupers = list__map(generate_class_constraint, Supers), + TCSupers = list.map(generate_class_constraint, Supers), TCVersion = type_class_info_rtti_version, RttiData = type_class_decl(tc_decl(TCId, TCVersion, TCSupers)), !:RttiDatas = [RttiData | !.RttiDatas] @@ -109,9 +109,9 @@ generate_class_id(ModuleInfo, ClassId, ClassDefn) = TCId :- TCName = generate_class_name(ClassId), ClassVars = ClassDefn ^ class_vars, ClassVarSet = ClassDefn ^ class_tvarset, - list__map(varset__lookup_name(ClassVarSet), ClassVars, VarNames), + list.map(varset.lookup_name(ClassVarSet), ClassVars, VarNames), Interface = ClassDefn ^ class_hlds_interface, - MethodIds = list__map(generate_method_id(ModuleInfo), Interface), + MethodIds = list.map(generate_method_id(ModuleInfo), Interface), TCId = tc_id(TCName, VarNames, MethodIds). :- func generate_method_id(module_info, hlds_class_proc) = tc_method_id. @@ -131,7 +131,7 @@ generate_method_id(ModuleInfo, ClassProc) = MethodId :- list(rtti_data)::in, list(rtti_data)::out) is det. generate_instance_decls(ModuleInfo, ClassId - Instances, !RttiDatas) :- - list__foldl(generate_maybe_instance_decl(ModuleInfo, ClassId), + list.foldl(generate_maybe_instance_decl(ModuleInfo, ClassId), Instances, !RttiDatas). :- pred generate_maybe_instance_decl(module_info::in, @@ -160,12 +160,12 @@ generate_maybe_instance_decl(ModuleInfo, ClassId, InstanceDefn, !RttiDatas) :- generate_instance_decl(ModuleInfo, ClassId, Instance) = RttiData :- TCName = generate_class_name(ClassId), InstanceTypes = Instance ^ instance_types, - InstanceTCTypes = list__map(generate_tc_type, InstanceTypes), + InstanceTCTypes = list.map(generate_tc_type, InstanceTypes), TVarSet = Instance ^ instance_tvarset, - varset__vars(TVarSet, TVars), - TVarNums = list__map(term__var_to_int, TVars), - TVarLength = list__length(TVarNums), - ( list__last(TVarNums, LastTVarNum) -> + varset.vars(TVarSet, TVars), + TVarNums = list.map(term.var_to_int, TVars), + TVarLength = list.length(TVarNums), + ( list.last(TVarNums, LastTVarNum) -> expect(unify(TVarLength, LastTVarNum), this_file, "generate_instance_decl: tvar num mismatch"), NumTypeVars = TVarLength @@ -173,11 +173,11 @@ generate_instance_decl(ModuleInfo, ClassId, Instance) = RttiData :- NumTypeVars = 0 ), Constraints = Instance ^ instance_constraints, - TCConstraints = list__map(generate_class_constraint, Constraints), + TCConstraints = list.map(generate_class_constraint, Constraints), MaybeInterface = Instance ^ instance_hlds_interface, ( MaybeInterface = yes(Interface), - MethodProcLabels = list__map(generate_method_proc_label(ModuleInfo), + MethodProcLabels = list.map(generate_method_proc_label(ModuleInfo), Interface) ; MaybeInterface = no, @@ -205,16 +205,16 @@ generate_class_name(class_id(SymName, Arity)) = TCName :- TCName = tc_name(ModuleName, ClassName, Arity). generate_class_constraint(constraint(ClassName, Types)) = TCConstr :- - Arity = list__length(Types), + Arity = list.length(Types), ClassId = class_id(ClassName, Arity), TCClassName = generate_class_name(ClassId), - ClassTypes = list__map(generate_tc_type, Types), + ClassTypes = list.map(generate_tc_type, Types), TCConstr = tc_constraint(TCClassName, ClassTypes). :- func generate_tc_type(mer_type) = tc_type. generate_tc_type(Type) = TCType :- - pseudo_type_info__construct_maybe_pseudo_type_info(Type, -1, [], TCType). + pseudo_type_info.construct_maybe_pseudo_type_info(Type, -1, [], TCType). %---------------------------------------------------------------------------% diff --git a/compiler/type_ctor_info.m b/compiler/type_ctor_info.m index 338d7cfbf..3a0654c33 100644 --- a/compiler/type_ctor_info.m +++ b/compiler/type_ctor_info.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 1996-2005 The University of Melbourne. +% Copyright (C) 1996-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -33,7 +33,7 @@ % %---------------------------------------------------------------------------% -:- module backend_libs__type_ctor_info. +:- module backend_libs.type_ctor_info. :- interface. :- import_module backend_libs.rtti. @@ -102,7 +102,7 @@ generate_hlds(!ModuleInfo) :- module_info_get_name(!.ModuleInfo, ModuleName), module_info_get_type_table(!.ModuleInfo, TypeTable), - map__keys(TypeTable, TypeCtors0), + map.keys(TypeTable, TypeCtors0), ( ModuleName = mercury_public_builtin_module, compiler_generated_rtti_for_builtins(!.ModuleInfo) @@ -167,15 +167,15 @@ gen_type_ctor_gen_infos([TypeCtor | TypeCtors], TypeTable, ModuleName, create_type_ctor_gen(ModuleInfo, TypeTable, TypeCtor, TypeModuleName, TypeName, TypeArity, TypeDefn) :- - ( list__member(TypeCtor, builtin_type_ctors_with_no_hlds_type_defn) -> + ( list.member(TypeCtor, builtin_type_ctors_with_no_hlds_type_defn) -> % The builtin types with no type definition. compiler_generated_rtti_for_builtins(ModuleInfo), TypeModuleName = unqualified(ModuleNameString), builtin_type_ctor(ModuleNameString, TypeName, TypeArity, _), TypeDefn = builtin_type_defn ; - map__lookup(TypeTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.lookup(TypeTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), ( ( TypeBody = abstract_type(_) ; type_ctor_has_hand_defined_rtti(TypeCtor, TypeBody) @@ -206,14 +206,14 @@ create_type_ctor_gen(ModuleInfo, TypeTable, TypeCtor, TypeModuleName, :- func builtin_type_defn = hlds_type_defn. builtin_type_defn = TypeDefn :- - varset__init(TVarSet), + varset.init(TVarSet), Params = [], - map__init(Kinds), + map.init(Kinds), Body = abstract_type(non_solver_type), ImportStatus = local, NeedQualifier = may_be_unqualified, - term__context_init(Context), - hlds_data__set_type_defn(TVarSet, Params, Kinds, Body, ImportStatus, no, + term.context_init(Context), + hlds_data.set_type_defn(TVarSet, Params, Kinds, Body, ImportStatus, no, NeedQualifier, Context, TypeDefn). :- pred gen_type_ctor_gen_info(type_ctor::in, string::in, int::in, @@ -222,25 +222,25 @@ builtin_type_defn = TypeDefn :- gen_type_ctor_gen_info(TypeCtor, TypeName, TypeArity, TypeDefn, ModuleName, ModuleInfo, TypeCtorGenInfo) :- - hlds_data__get_type_defn_status(TypeDefn, Status), + hlds_data.get_type_defn_status(TypeDefn, Status), module_info_get_globals(ModuleInfo, Globals), module_info_get_special_pred_map(ModuleInfo, SpecMap), - globals__lookup_bool_option(Globals, special_preds, SpecialPreds), + globals.lookup_bool_option(Globals, special_preds, SpecialPreds), ( ( SpecialPreds = yes ; SpecialPreds = no, - hlds_data__get_type_defn_body(TypeDefn, Body), + hlds_data.get_type_defn_body(TypeDefn, Body), Body ^ du_type_usereq = yes(_UserDefinedEquality) ) -> - map__lookup(SpecMap, spec_pred_unify - TypeCtor, UnifyPredId), + map.lookup(SpecMap, spec_pred_unify - TypeCtor, UnifyPredId), special_pred_mode_num(spec_pred_unify, UnifyProcInt), proc_id_to_int(UnifyProcId, UnifyProcInt), Unify = proc(UnifyPredId, UnifyProcId), - map__lookup(SpecMap, spec_pred_compare - TypeCtor, ComparePredId), + map.lookup(SpecMap, spec_pred_compare - TypeCtor, ComparePredId), special_pred_mode_num(spec_pred_compare, CompareProcInt), proc_id_to_int(CompareProcId, CompareProcInt), Compare = proc(ComparePredId, CompareProcId) @@ -263,8 +263,8 @@ generate_rtti(ModuleInfo, Tables) :- % The same pseudo_type_info may be generated in several places; we need % to eliminate duplicates here, to avoid duplicate definition errors % in the generated C code. - Static = list__remove_dups(Static0), - list__append(Dynamic, Static, Tables). + Static = list.remove_dups(Static0), + list.append(Dynamic, Static, Tables). :- pred construct_type_ctor_infos(list(type_ctor_gen_info)::in, module_info::in, @@ -291,7 +291,7 @@ construct_type_ctor_info(TypeCtorGenInfo, ModuleInfo, RttiData) :- type_to_univ(UnifyProcLabel, UnifyUniv), type_to_univ(CompareProcLabel, CompareUniv), module_info_get_globals(ModuleInfo, Globals), - hlds_data__get_type_defn_body(HldsDefn, TypeBody), + hlds_data.get_type_defn_body(HldsDefn, TypeBody), Version = type_ctor_info_rtti_version, % It is an error for a type body to be an abstract type unless @@ -331,7 +331,7 @@ construct_type_ctor_info(TypeCtorGenInfo, ModuleInfo, RttiData) :- % There can be no existentially typed args to an equivalence. UnivTvars = TypeArity, ExistTvars = [], - pseudo_type_info__construct_maybe_pseudo_type_info(RepnType, + pseudo_type_info.construct_maybe_pseudo_type_info(RepnType, UnivTvars, ExistTvars, MaybePseudoTypeInfo), Details = eqv(MaybePseudoTypeInfo) ; @@ -339,8 +339,8 @@ construct_type_ctor_info(TypeCtorGenInfo, ModuleInfo, RttiData) :- foreign_type_body_to_exported_type(ModuleInfo, ForeignBody, _, _, Assertions), ( - list__member(can_pass_as_mercury_type, Assertions), - list__member(stable, Assertions) + list.member(can_pass_as_mercury_type, Assertions), + list.member(stable, Assertions) -> IsStable = is_stable ; @@ -352,7 +352,7 @@ construct_type_ctor_info(TypeCtorGenInfo, ModuleInfo, RttiData) :- % There can be no existentially typed args to an equivalence. UnivTvars = TypeArity, ExistTvars = [], - pseudo_type_info__construct_maybe_pseudo_type_info(Type, + pseudo_type_info.construct_maybe_pseudo_type_info(Type, UnivTvars, ExistTvars, MaybePseudoTypeInfo), Details = eqv(MaybePseudoTypeInfo) ; @@ -390,11 +390,11 @@ construct_type_ctor_info(TypeCtorGenInfo, ModuleInfo, RttiData) :- ) ), some [!Flags] ( - !:Flags = set__init, + !:Flags = set.init, ( TypeBody = du_type(_, _, _, _, _, _) -> - svset__insert(kind_of_du_flag, !Flags), + svset.insert(kind_of_du_flag, !Flags), ( TypeBody ^ du_type_reserved_tag = yes -> - svset__insert(reserve_tag_flag, !Flags) + svset.insert(reserve_tag_flag, !Flags) ; true ) @@ -446,7 +446,7 @@ impl_type_ctor("table_builtin", "ml_subgoal", 0, subgoal). make_rtti_proc_label(PredProcId, ModuleInfo, ProcLabel) :- PredProcId = proc(PredId, ProcId), - ProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId). + ProcLabel = rtti.make_rtti_proc_label(ModuleInfo, PredId, ProcId). %---------------------------------------------------------------------------% @@ -476,7 +476,7 @@ type_ctor_info_rtti_version = 9. make_pseudo_type_info_and_tables(Type, UnivTvars, ExistTvars, RttiData, !Tables) :- - pseudo_type_info__construct_pseudo_type_info(Type, UnivTvars, ExistTvars, + pseudo_type_info.construct_pseudo_type_info(Type, UnivTvars, ExistTvars, PseudoTypeInfo), RttiData = pseudo_type_info(PseudoTypeInfo), make_pseudo_type_info_tables(PseudoTypeInfo, !Tables). @@ -492,11 +492,11 @@ make_type_info_tables(plain_arity_zero_type_info(_), !Tables). make_type_info_tables(PseudoTypeInfo, !Tables) :- PseudoTypeInfo = plain_type_info(_, Args), !:Tables = [type_info(PseudoTypeInfo) | !.Tables], - list__foldl(make_type_info_tables, Args, !Tables). + list.foldl(make_type_info_tables, Args, !Tables). make_type_info_tables(PseudoTypeInfo, !Tables) :- PseudoTypeInfo = var_arity_type_info(_, Args), !:Tables = [type_info(PseudoTypeInfo) | !.Tables], - list__foldl(make_type_info_tables, Args, !Tables). + list.foldl(make_type_info_tables, Args, !Tables). :- pred make_pseudo_type_info_tables(rtti_pseudo_type_info::in, list(rtti_data)::in, list(rtti_data)::out) is det. @@ -505,12 +505,12 @@ make_pseudo_type_info_tables(plain_arity_zero_pseudo_type_info(_), !Tables). make_pseudo_type_info_tables(PseudoTypeInfo, !Tables) :- PseudoTypeInfo = plain_pseudo_type_info(_, Args), !:Tables = [pseudo_type_info(PseudoTypeInfo) | !.Tables], - list__foldl(make_maybe_pseudo_type_info_tables, Args, + list.foldl(make_maybe_pseudo_type_info_tables, Args, !Tables). make_pseudo_type_info_tables(PseudoTypeInfo, !Tables) :- PseudoTypeInfo = var_arity_pseudo_type_info(_, Args), !:Tables = [pseudo_type_info(PseudoTypeInfo) | !.Tables], - list__foldl(make_maybe_pseudo_type_info_tables, Args, !Tables). + list.foldl(make_maybe_pseudo_type_info_tables, Args, !Tables). make_pseudo_type_info_tables(type_var(_), !Tables). :- pred make_maybe_pseudo_type_info_tables(rtti_maybe_pseudo_type_info::in, @@ -544,7 +544,7 @@ make_notag_details(TypeArity, SymName, ArgType, MaybeArgName, EqualityAxioms, NumUnivTvars = TypeArity, % There can be no existentially typed args to the functor in a notag type. ExistTvars = [], - pseudo_type_info__construct_maybe_pseudo_type_info(ArgType, + pseudo_type_info.construct_maybe_pseudo_type_info(ArgType, NumUnivTvars, ExistTvars, MaybePseudoTypeInfo), Functor = notag_functor(FunctorName, MaybePseudoTypeInfo, MaybeArgName), Details = notag(EqualityAxioms, Functor). @@ -566,9 +566,9 @@ make_enum_details(Ctors, ConsTagMap, ReserveTag, EqualityAxioms, Details) :- ReserveTag = no ), make_enum_functors(Ctors, 0, ConsTagMap, EnumFunctors), - ValueMap0 = map__init, - NameMap0 = map__init, - list__foldl2(make_enum_maps, EnumFunctors, + ValueMap0 = map.init, + NameMap0 = map.init, + list.foldl2(make_enum_maps, EnumFunctors, ValueMap0, ValueMap, NameMap0, NameMap), ( Ctors = [_] -> IsDummy = yes @@ -596,11 +596,11 @@ make_enum_functors([Functor | Functors], NextOrdinal0, ConsTagMap, "existential arguments in functor in enum"), expect(unify(Constraints, []), this_file, "class constraints on functor in enum"), - list__length(FunctorArgs, Arity), + list.length(FunctorArgs, Arity), expect(unify(Arity, 0), this_file, "functor in enum has nonzero arity"), ConsId = make_cons_id_from_qualified_sym_name(SymName, FunctorArgs), - map__lookup(ConsTagMap, ConsId, ConsTag), + map.lookup(ConsTagMap, ConsId, ConsTag), expect(unify(ConsTag, int_constant(NextOrdinal0)), this_file, "mismatch on constant assigned to functor in enum"), unqualify_name(SymName, FunctorName), @@ -613,8 +613,8 @@ make_enum_functors([Functor | Functors], NextOrdinal0, ConsTagMap, make_enum_maps(EnumFunctor, !ValueMap, !NameMap) :- EnumFunctor = enum_functor(FunctorName, Ordinal), - svmap__det_insert(Ordinal, EnumFunctor, !ValueMap), - svmap__det_insert(FunctorName, EnumFunctor, !NameMap). + svmap.det_insert(Ordinal, EnumFunctor, !ValueMap), + svmap.det_insert(FunctorName, EnumFunctor, !NameMap). %---------------------------------------------------------------------------% @@ -645,19 +645,19 @@ make_du_details(Ctors, ConsTagMap, TypeArity, EqualityAxioms, ModuleInfo, Details) :- make_maybe_res_functors(Ctors, 0, ConsTagMap, TypeArity, ModuleInfo, MaybeResFunctors), - DuFunctors = list__filter_map(is_du_functor, MaybeResFunctors), - ResFunctors = list__filter_map(is_reserved_functor, MaybeResFunctors), - list__foldl(make_du_ptag_ordered_table, DuFunctors, - map__init, DuPtagTable), + DuFunctors = list.filter_map(is_du_functor, MaybeResFunctors), + ResFunctors = list.filter_map(is_reserved_functor, MaybeResFunctors), + list.foldl(make_du_ptag_ordered_table, DuFunctors, + map.init, DuPtagTable), ( ResFunctors = [], - list__foldl(make_du_name_ordered_table, DuFunctors, - map__init, DuNameOrderedMap), + list.foldl(make_du_name_ordered_table, DuFunctors, + map.init, DuNameOrderedMap), Details = du(EqualityAxioms, DuFunctors, DuPtagTable, DuNameOrderedMap) ; ResFunctors = [_ | _], - list__foldl(make_res_name_ordered_table, MaybeResFunctors, - map__init, ResNameOrderedMap), + list.foldl(make_res_name_ordered_table, MaybeResFunctors, + map.init, ResNameOrderedMap), Details = reserved(EqualityAxioms, MaybeResFunctors, ResFunctors, DuPtagTable, ResNameOrderedMap) ). @@ -686,12 +686,12 @@ make_maybe_res_functors([], _, _, _, _, []). make_maybe_res_functors([Functor | Functors], NextOrdinal, ConsTagMap, TypeArity, ModuleInfo, [MaybeResFunctor | MaybeResFunctors]) :- Functor = ctor(ExistTvars, Constraints, SymName, ConstructorArgs), - list__length(ConstructorArgs, Arity), + list.length(ConstructorArgs, Arity), unqualify_name(SymName, FunctorName), ConsId = make_cons_id_from_qualified_sym_name(SymName, ConstructorArgs), - map__lookup(ConsTagMap, ConsId, ConsTag), + map.lookup(ConsTagMap, ConsId, ConsTag), process_cons_tag(ConsTag, ConsRep), - list__map(generate_du_arg_info(TypeArity, ExistTvars), + list.map(generate_du_arg_info(TypeArity, ExistTvars), ConstructorArgs, ArgInfos), ( ExistTvars = [], @@ -775,7 +775,7 @@ generate_du_arg_info(NumUnivTvars, ExistTvars, ConstructorArg, ArgInfo) :- ), % The C runtime cannot yet handle the "self" type representation, % so we do not generate it here. - pseudo_type_info__construct_maybe_pseudo_type_info(ArgType, + pseudo_type_info.construct_maybe_pseudo_type_info(ArgType, NumUnivTvars, ExistTvars, MaybePseudoTypeInfo), ( MaybePseudoTypeInfo = plain(TypeInfo), @@ -801,26 +801,26 @@ contains_var_bit_vector_size = 16. class_table::in, exist_info::out) is det. generate_exist_into(ExistTvars, Constraints, ClassTable, ExistInfo) :- - list__map((pred(C::in, Ts::out) is det :- C = constraint(_, Ts)), + list.map((pred(C::in, Ts::out) is det :- C = constraint(_, Ts)), Constraints, ConstrainedTvars0), - list__condense(ConstrainedTvars0, ConstrainedTvars1), - prog_type__vars_list(ConstrainedTvars1, ConstrainedTvars2), - list__delete_elems(ExistTvars, ConstrainedTvars2, UnconstrainedTvars), + list.condense(ConstrainedTvars0, ConstrainedTvars1), + prog_type.vars_list(ConstrainedTvars1, ConstrainedTvars2), + list.delete_elems(ExistTvars, ConstrainedTvars2, UnconstrainedTvars), % We do this to maintain the ordering of the type variables. - list__delete_elems(ExistTvars, UnconstrainedTvars, ConstrainedTvars), - map__init(LocnMap0), - list__foldl2((pred(T::in, N0::in, N::out, Lm0::in, Lm::out) is det :- + list.delete_elems(ExistTvars, UnconstrainedTvars, ConstrainedTvars), + map.init(LocnMap0), + list.foldl2((pred(T::in, N0::in, N::out, Lm0::in, Lm::out) is det :- Locn = plain_typeinfo(N0), - map__det_insert(Lm0, T, Locn, Lm), + map.det_insert(Lm0, T, Locn, Lm), N = N0 + 1 ), UnconstrainedTvars, 0, TIsPlain, LocnMap0, LocnMap1), - list__length(ExistTvars, AllTIs), + list.length(ExistTvars, AllTIs), TIsInTCIs = AllTIs - TIsPlain, - list__foldl(find_type_info_index(Constraints, ClassTable, TIsPlain), + list.foldl(find_type_info_index(Constraints, ClassTable, TIsPlain), ConstrainedTvars, LocnMap1, LocnMap), - TCConstraints = list__map(generate_class_constraint, Constraints), - list__map((pred(Tvar::in, Locn::out) is det :- - map__lookup(LocnMap, Tvar, Locn)), + TCConstraints = list.map(generate_class_constraint, Constraints), + list.map((pred(Tvar::in, Locn::out) is det :- + map.lookup(LocnMap, Tvar, Locn)), ExistTvars, ExistLocns), ExistInfo = exist_info(TIsPlain, TIsInTCIs, TCConstraints, ExistLocns). @@ -832,12 +832,12 @@ find_type_info_index(Constraints, ClassTable, StartSlot, Tvar, !LocnMap) :- first_matching_type_class_info(Constraints, Tvar, FirstConstraint, StartSlot, Slot, TypeInfoIndex), FirstConstraint = constraint(ClassName, Args), - list__length(Args, ClassArity), - map__lookup(ClassTable, class_id(ClassName, ClassArity), ClassDefn), - list__length(ClassDefn ^ class_supers, NumSuperClasses), + list.length(Args, ClassArity), + map.lookup(ClassTable, class_id(ClassName, ClassArity), ClassDefn), + list.length(ClassDefn ^ class_supers, NumSuperClasses), RealTypeInfoIndex = TypeInfoIndex + NumSuperClasses, Locn = typeinfo_in_tci(Slot, RealTypeInfoIndex), - svmap__det_insert(Tvar, Locn, !LocnMap). + svmap.det_insert(Tvar, Locn, !LocnMap). :- pred first_matching_type_class_info(list(prog_constraint)::in, tvar::in, prog_constraint::out, int::in, int::out, int::out) is det. @@ -847,8 +847,8 @@ first_matching_type_class_info([], _, _, !N, _) :- first_matching_type_class_info([C | Cs], Tvar, MatchingConstraint, !N, TypeInfoIndex) :- C = constraint(_, Ts), - prog_type__vars_list(Ts, TVs), - ( list__nth_member_search(TVs, Tvar, Index) -> + prog_type.vars_list(Ts, TVs), + ( list.nth_member_search(TVs, Tvar, Index) -> MatchingConstraint = C, TypeInfoIndex = Index ; @@ -877,19 +877,19 @@ make_du_ptag_ordered_table(DuFunctor, !PtagTable) :- SectagAndLocn = sectag_remote(Sectag), SectagLocn = sectag_remote ), - ( map__search(!.PtagTable, Ptag, SectagTable0) -> + ( map.search(!.PtagTable, Ptag, SectagTable0) -> SectagTable0 = sectag_table(Locn0, NumSharers0, SectagMap0), expect(unify(SectagLocn, Locn0), this_file, "make_du_ptag_ordered_table: " ++ "sectag locn disagreement"), - map__det_insert(SectagMap0, Sectag, DuFunctor, SectagMap), + map.det_insert(SectagMap0, Sectag, DuFunctor, SectagMap), SectagTable = sectag_table(Locn0, NumSharers0 + 1, SectagMap), - svmap__det_update(Ptag, SectagTable, !PtagTable) + svmap.det_update(Ptag, SectagTable, !PtagTable) ; - SectagMap0 = map__init, - map__det_insert(SectagMap0, Sectag, DuFunctor, SectagMap), + SectagMap0 = map.init, + map.det_insert(SectagMap0, Sectag, DuFunctor, SectagMap), SectagTable = sectag_table(SectagLocn, 1, SectagMap), - svmap__det_insert(Ptag, SectagTable, !PtagTable) + svmap.det_insert(Ptag, SectagTable, !PtagTable) ) ; DuRep = du_hl_rep(_), @@ -903,12 +903,12 @@ make_du_ptag_ordered_table(DuFunctor, !PtagTable) :- make_du_name_ordered_table(DuFunctor, !NameTable) :- Name = DuFunctor ^ du_name, Arity = DuFunctor ^ du_orig_arity, - ( map__search(!.NameTable, Name, NameMap0) -> - map__det_insert(NameMap0, Arity, DuFunctor, NameMap), - svmap__det_update(Name, NameMap, !NameTable) + ( map.search(!.NameTable, Name, NameMap0) -> + map.det_insert(NameMap0, Arity, DuFunctor, NameMap), + svmap.det_update(Name, NameMap, !NameTable) ; - map__det_insert(map__init, Arity, DuFunctor, NameMap), - svmap__det_insert(Name, NameMap, !NameTable) + map.det_insert(map.init, Arity, DuFunctor, NameMap), + svmap.det_insert(Name, NameMap, !NameTable) ). :- pred make_res_name_ordered_table(maybe_reserved_functor::in, @@ -925,12 +925,12 @@ make_res_name_ordered_table(MaybeResFunctor, !NameTable) :- Name = ResFunctor ^ res_name, Arity = 0 ), - ( map__search(!.NameTable, Name, NameMap0) -> - map__det_insert(NameMap0, Arity, MaybeResFunctor, NameMap), - svmap__det_update(Name, NameMap, !NameTable) + ( map.search(!.NameTable, Name, NameMap0) -> + map.det_insert(NameMap0, Arity, MaybeResFunctor, NameMap), + svmap.det_update(Name, NameMap, !NameTable) ; - NameMap = map__det_insert(map__init, Arity, MaybeResFunctor), - svmap__det_insert(Name, NameMap, !NameTable) + NameMap = map.det_insert(map.init, Arity, MaybeResFunctor), + svmap.det_insert(Name, NameMap, !NameTable) ). %---------------------------------------------------------------------------% diff --git a/compiler/type_util.m b/compiler/type_util.m index 245f903eb..8d344a45a 100644 --- a/compiler/type_util.m +++ b/compiler/type_util.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 1994-2005 The University of Melbourne. +% Copyright (C) 1994-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -16,7 +16,7 @@ %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- module check_hlds__type_util. +:- module check_hlds.type_util. :- interface. :- import_module hlds.hlds_data. @@ -399,7 +399,7 @@ type_has_user_defined_equality_pred(ModuleInfo, Type, UserEqComp) :- type_body_has_user_defined_equality_pred(ModuleInfo, TypeBody, UserEqComp) :- module_info_get_globals(ModuleInfo, Globals), - globals__get_target(Globals, Target), + globals.get_target(Globals, Target), ( TypeBody = du_type(_, _, _, _, _, _), ( @@ -444,11 +444,11 @@ type_body_has_solver_type_details( ModuleInfo, type_to_type_defn(ModuleInfo, Type, TypeDefn) :- module_info_get_type_table(ModuleInfo, TypeTable), type_to_ctor_and_args(Type, TypeCtor, _TypeArgs), - map__search(TypeTable, TypeCtor, TypeDefn). + map.search(TypeTable, TypeCtor, TypeDefn). type_to_type_defn_body(ModuleInfo, Type, TypeBody) :- type_to_type_defn(ModuleInfo, Type, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody). + hlds_data.get_type_defn_body(TypeDefn, TypeBody). % XXX We can't assume that type variables refer to solver types % because otherwise the compiler will try to construct initialisation @@ -495,7 +495,7 @@ is_dummy_argument_type(ModuleInfo, Type) :- module_info_get_type_table(ModuleInfo, TypeTable), % This can fail for some builtin type constructors such as func, % pred, and tuple, none of which are dummy types. - map__search(TypeTable, TypeCtor, TypeDefn), + map.search(TypeTable, TypeCtor, TypeDefn), get_type_defn_body(TypeDefn, TypeBody), Ctors = TypeBody ^ du_type_ctors, UserEqCmp = TypeBody ^ du_type_usereq, @@ -509,8 +509,8 @@ is_dummy_argument_type(ModuleInfo, Type) :- type_ctor_is_enumeration(TypeCtor, ModuleInfo) :- module_info_get_type_table(ModuleInfo, TypeDefnTable), - map__search(TypeDefnTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.search(TypeDefnTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), TypeBody ^ du_type_is_enum = is_enum. %-----------------------------------------------------------------------------% @@ -523,14 +523,14 @@ type_constructors(Type, ModuleInfo, Constructors) :- % Tuples are never existentially typed. ExistQVars = [], ClassConstraints = [], - CtorArgs = list__map((func(ArgType) = no - ArgType), TypeArgs), + CtorArgs = list.map((func(ArgType) = no - ArgType), TypeArgs), Constructors = [ctor(ExistQVars, ClassConstraints, unqualified("{}"), CtorArgs)] ; module_info_get_type_table(ModuleInfo, TypeTable), - map__search(TypeTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_tparams(TypeDefn, TypeParams), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.search(TypeTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_tparams(TypeDefn, TypeParams), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), substitute_type_args(TypeParams, TypeArgs, TypeBody ^ du_type_ctors, Constructors) ). @@ -543,16 +543,16 @@ switch_type_num_functors(ModuleInfo, Type, NumFunctors) :- % XXX The following code uses the source machine's character size, % not the target's, so it won't work if cross-compiling to a machine % with a different size character. - char__max_char_value(MaxChar), - char__min_char_value(MinChar), + char.max_char_value(MaxChar), + char.min_char_value(MinChar), NumFunctors = MaxChar - MinChar + 1 ; type_ctor_is_tuple(TypeCtor) -> NumFunctors = 1 ; module_info_get_type_table(ModuleInfo, TypeTable), - map__search(TypeTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), - map__count(TypeBody ^ du_type_cons_tag_values, NumFunctors) + map.search(TypeTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), + map.count(TypeBody ^ du_type_cons_tag_values, NumFunctors) ). %-----------------------------------------------------------------------------% @@ -590,7 +590,7 @@ get_cons_id_arg_types_2(EQVarAction, ModuleInfo, VarType, ConsId, ArgTypes) :- ConsDefn = hlds_cons_defn(ExistQVars0, _Constraints0, Args, _, _), Args = [_ | _] -> - hlds_data__get_type_defn_tparams(TypeDefn, TypeParams), + hlds_data.get_type_defn_tparams(TypeDefn, TypeParams), % XXX handle ExistQVars ( @@ -607,8 +607,8 @@ get_cons_id_arg_types_2(EQVarAction, ModuleInfo, VarType, ConsId, ArgTypes) :- ) ), - map__from_corresponding_lists(TypeParams, TypeArgs, TSubst), - assoc_list__values(Args, ArgTypes0), + map.from_corresponding_lists(TypeParams, TypeArgs, TSubst), + assoc_list.values(Args, ArgTypes0), apply_subst_to_type_list(TSubst, ArgTypes0, ArgTypes) ; ArgTypes = [] @@ -620,23 +620,23 @@ get_cons_id_arg_types_2(EQVarAction, ModuleInfo, VarType, ConsId, ArgTypes) :- cons_id_arg_types(ModuleInfo, VarType, ConsId, ArgTypes) :- type_to_ctor_and_args(VarType, TypeCtor, TypeArgs), module_info_get_type_table(ModuleInfo, Types), - map__search(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeDefnBody), - map__member(TypeDefnBody ^ du_type_cons_tag_values, ConsId, _), + map.search(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeDefnBody), + map.member(TypeDefnBody ^ du_type_cons_tag_values, ConsId, _), module_info_get_cons_table(ModuleInfo, Ctors), - map__lookup(Ctors, ConsId, ConsDefns), - list__member(ConsDefn, ConsDefns), + map.lookup(Ctors, ConsId, ConsDefns), + list.member(ConsDefn, ConsDefns), ConsDefn = hlds_cons_defn(ExistQVars0, _, Args, TypeCtor, _), % XXX handle ExistQVars ExistQVars0 = [], - hlds_data__get_type_defn_tparams(TypeDefn, TypeParams), + hlds_data.get_type_defn_tparams(TypeDefn, TypeParams), - map__from_corresponding_lists(TypeParams, TypeArgs, TSubst), - assoc_list__values(Args, ArgTypes0), + map.from_corresponding_lists(TypeParams, TypeArgs, TSubst), + assoc_list.values(Args, ArgTypes0), apply_subst_to_type_list(TSubst, ArgTypes0, ArgTypes). is_existq_cons(ModuleInfo, VarType, ConsId) :- @@ -656,13 +656,13 @@ is_existq_cons(ModuleInfo, VarType, ConsId, ConsDefn) :- get_existq_cons_defn(ModuleInfo, VarType, ConsId, CtorDefn) :- is_existq_cons(ModuleInfo, VarType, ConsId, ConsDefn), ConsDefn = hlds_cons_defn(ExistQVars, Constraints, Args, _, _), - assoc_list__values(Args, ArgTypes), + assoc_list.values(Args, ArgTypes), module_info_get_type_table(ModuleInfo, Types), type_to_ctor_and_args(VarType, TypeCtor, _), - map__lookup(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_tvarset(TypeDefn, TypeVarSet), - hlds_data__get_type_defn_tparams(TypeDefn, TypeParams), - hlds_data__get_type_defn_kind_map(TypeDefn, KindMap), + map.lookup(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_tvarset(TypeDefn, TypeVarSet), + hlds_data.get_type_defn_tparams(TypeDefn, TypeParams), + hlds_data.get_type_defn_kind_map(TypeDefn, KindMap), prog_type.var_list_to_type_list(KindMap, TypeParams, TypeCtorArgs), type_to_ctor_and_args(VarType, TypeCtor, _), construct_type(TypeCtor, TypeCtorArgs, RetType), @@ -687,30 +687,31 @@ get_type_and_cons_defn(ModuleInfo, Type, ConsId, TypeDefn, ConsDefn) :- do_get_type_and_cons_defn(ModuleInfo, TypeCtor, ConsId, TypeDefn, ConsDefn) :- get_cons_defn(ModuleInfo, TypeCtor, ConsId, ConsDefn), module_info_get_type_table(ModuleInfo, Types), - map__lookup(Types, TypeCtor, TypeDefn). + map.lookup(Types, TypeCtor, TypeDefn). get_cons_defn(ModuleInfo, TypeCtor, ConsId, ConsDefn) :- module_info_get_cons_table(ModuleInfo, Ctors), % will fail for builtin cons_ids. - map__search(Ctors, ConsId, ConsDefns), - MatchingCons = (pred(ThisConsDefn::in) is semidet :- + map.search(Ctors, ConsId, ConsDefns), + MatchingCons = + (pred(ThisConsDefn::in) is semidet :- ThisConsDefn = hlds_cons_defn(_, _, _, TypeCtor, _) ), - list__filter(MatchingCons, ConsDefns, [ConsDefn]). + list.filter(MatchingCons, ConsDefns, [ConsDefn]). %-----------------------------------------------------------------------------% type_is_no_tag_type(ModuleInfo, Type, Ctor, ArgType) :- type_to_ctor_and_args(Type, TypeCtor, TypeArgs), module_info_get_no_tag_types(ModuleInfo, NoTagTypes), - map__search(NoTagTypes, TypeCtor, NoTagType), + map.search(NoTagTypes, TypeCtor, NoTagType), NoTagType = no_tag_type(TypeParams, Ctor, ArgType0), ( TypeParams = [], ArgType = ArgType0 ; TypeParams = [_ | _], - map__from_corresponding_lists(TypeParams, TypeArgs, Subn), + map.from_corresponding_lists(TypeParams, TypeArgs, Subn), apply_subst_to_type(Subn, ArgType0, ArgType) ). @@ -728,7 +729,7 @@ substitute_type_args(TypeParams, TypeArgs, Constructors0, Constructors) :- Constructors = Constructors0 ; TypeParams = [_ | _], - map__from_corresponding_lists(TypeParams, TypeArgs, Subst), + map.from_corresponding_lists(TypeParams, TypeArgs, Subst), substitute_type_args_2(Subst, Constructors0, Constructors) ). @@ -764,11 +765,11 @@ cons_id_adjusted_arity(ModuleInfo, Type, ConsId) = AdjustedArity :- ( get_existq_cons_defn(ModuleInfo, Type, ConsId, ConsDefn) -> ConsDefn = ctor_defn(_TVarSet, ExistQTVars, _KindMap, Constraints, _ArgTypes, _ResultType), - list__length(Constraints, NumTypeClassInfos), + list.length(Constraints, NumTypeClassInfos), constraint_list_get_tvars(Constraints, ConstrainedTVars), - list__delete_elems(ExistQTVars, ConstrainedTVars, + list.delete_elems(ExistQTVars, ConstrainedTVars, UnconstrainedExistQTVars), - list__length(UnconstrainedExistQTVars, NumTypeInfos), + list.length(UnconstrainedExistQTVars, NumTypeInfos), AdjustedArity = ConsArity + NumTypeClassInfos + NumTypeInfos ; AdjustedArity = ConsArity @@ -787,11 +788,11 @@ maybe_get_cons_id_arg_types(ModuleInfo, MaybeType, ConsId0, Arity, % for ConsIds with existentially typed arguments. get_cons_id_non_existential_arg_types(ModuleInfo, Type, ConsId, Types), - list__length(Types, Arity) + list.length(Types, Arity) -> - MaybeTypes = list__map(func(T) = yes(T), Types) + MaybeTypes = list.map(func(T) = yes(T), Types) ; - list__duplicate(Arity, no, MaybeTypes) + list.duplicate(Arity, no, MaybeTypes) ) ; MaybeTypes = [] @@ -802,9 +803,9 @@ maybe_get_higher_order_arg_types(MaybeType, Arity, MaybeTypes) :- MaybeType = yes(Type), type_is_higher_order(Type, _, _, _, Types) -> - MaybeTypes = list__map(func(T) = yes(T), Types) + MaybeTypes = list.map(func(T) = yes(T), Types) ; - list__duplicate(Arity, no, MaybeTypes) + list.duplicate(Arity, no, MaybeTypes) ). %-----------------------------------------------------------------------------% @@ -828,13 +829,13 @@ apply_rec_subst_to_constraint(Subst, !Constraint) :- %-----------------------------------------------------------------------------% apply_variable_renaming_to_constraint_list(Renaming, !Constraints) :- - list__map(apply_variable_renaming_to_constraint(Renaming), !Constraints). + list.map(apply_variable_renaming_to_constraint(Renaming), !Constraints). apply_subst_to_constraint_list(Subst, !Constraints) :- - list__map(apply_subst_to_constraint(Subst), !Constraints). + list.map(apply_subst_to_constraint(Subst), !Constraints). apply_rec_subst_to_constraint_list(Subst, !Constraints) :- - list__map(apply_rec_subst_to_constraint(Subst), !Constraints). + list.map(apply_rec_subst_to_constraint(Subst), !Constraints). %-----------------------------------------------------------------------------% @@ -871,15 +872,15 @@ apply_rec_subst_to_constraints(Subst, !Constraints) :- %-----------------------------------------------------------------------------% apply_variable_renaming_to_constraint_proofs(Renaming, Proofs0, Proofs) :- - ( map__is_empty(Proofs0) -> + ( map.is_empty(Proofs0) -> % Optimize the simple case. Proofs = Proofs0 ; - map__keys(Proofs0, Keys0), - map__values(Proofs0, Values0), + map.keys(Proofs0, Keys0), + map.values(Proofs0, Values0), apply_variable_renaming_to_prog_constraint_list(Renaming, Keys0, Keys), - list__map(rename_constraint_proof(Renaming), Values0, Values), - map__from_corresponding_lists(Keys, Values, Proofs) + list.map(rename_constraint_proof(Renaming), Values0, Values), + map.from_corresponding_lists(Keys, Values, Proofs) ). % Apply a type variable renaming to a class constraint proof. @@ -894,8 +895,8 @@ rename_constraint_proof(TSubst, superclass(ClassConstraint0), ClassConstraint). apply_subst_to_constraint_proofs(Subst, Proofs0, Proofs) :- - map__foldl(apply_subst_to_constraint_proofs_2(Subst), Proofs0, - map__init, Proofs). + map.foldl(apply_subst_to_constraint_proofs_2(Subst), Proofs0, + map.init, Proofs). :- pred apply_subst_to_constraint_proofs_2(tsubst::in, prog_constraint::in, constraint_proof::in, @@ -911,11 +912,11 @@ apply_subst_to_constraint_proofs_2(Subst, Constraint0, Proof0, Map0, Map) :- apply_subst_to_prog_constraint(Subst, Super0, Super), Proof = superclass(Super) ), - map__set(Map0, Constraint, Proof, Map). + map.set(Map0, Constraint, Proof, Map). apply_rec_subst_to_constraint_proofs(Subst, Proofs0, Proofs) :- - map__foldl(apply_rec_subst_to_constraint_proofs_2(Subst), Proofs0, - map__init, Proofs). + map.foldl(apply_rec_subst_to_constraint_proofs_2(Subst), Proofs0, + map.init, Proofs). :- pred apply_rec_subst_to_constraint_proofs_2(tsubst::in, prog_constraint::in, constraint_proof::in, @@ -931,12 +932,12 @@ apply_rec_subst_to_constraint_proofs_2(Subst, Constraint0, Proof0, !Map) :- apply_rec_subst_to_prog_constraint(Subst, Super0, Super), Proof = superclass(Super) ), - map__set(!.Map, Constraint, Proof, !:Map). + map.set(!.Map, Constraint, Proof, !:Map). %-----------------------------------------------------------------------------% apply_variable_renaming_to_constraint_map(Renaming, !ConstraintMap) :- - map__map_values(apply_variable_renaming_to_constraint_map_2(Renaming), + map.map_values(apply_variable_renaming_to_constraint_map_2(Renaming), !ConstraintMap). :- pred apply_variable_renaming_to_constraint_map_2(tvar_renaming::in, @@ -946,7 +947,7 @@ apply_variable_renaming_to_constraint_map_2(Renaming, _Key, !Value) :- apply_variable_renaming_to_prog_constraint(Renaming, !Value). apply_subst_to_constraint_map(Subst, !ConstraintMap) :- - map__map_values(apply_subst_to_constraint_map_2(Subst), !ConstraintMap). + map.map_values(apply_subst_to_constraint_map_2(Subst), !ConstraintMap). :- pred apply_subst_to_constraint_map_2(tsubst::in, constraint_id::in, prog_constraint::in, prog_constraint::out) is det. @@ -955,7 +956,7 @@ apply_subst_to_constraint_map_2(Subst, _Key, !Value) :- apply_subst_to_prog_constraint(Subst, !Value). apply_rec_subst_to_constraint_map(Subst, !ConstraintMap) :- - map__map_values(apply_rec_subst_to_constraint_map_2(Subst), + map.map_values(apply_rec_subst_to_constraint_map_2(Subst), !ConstraintMap). :- pred apply_rec_subst_to_constraint_map_2(tsubst::in, constraint_id::in, diff --git a/compiler/typecheck.m b/compiler/typecheck.m index 4e3589956..fa69c4b7e 100644 --- a/compiler/typecheck.m +++ b/compiler/typecheck.m @@ -324,7 +324,7 @@ typecheck_pred(Iteration, PredId, !PredInfo, !ModuleInfo, Error, Changed, globals__io_get_globals(Globals, !IO), ( Iteration = 1 -> % Goal paths are used to identify typeclass constraints. - goal_path__fill_slots_in_clauses(!.ModuleInfo, no, !PredInfo), + fill_goal_path_slots_in_clauses(!.ModuleInfo, no, !PredInfo), maybe_add_field_access_function_clause(!.ModuleInfo, !PredInfo), maybe_improve_headvar_names(Globals, !PredInfo), diff --git a/compiler/typecheck_errors.m b/compiler/typecheck_errors.m index 399d66e8a..d277ec5af 100644 --- a/compiler/typecheck_errors.m +++ b/compiler/typecheck_errors.m @@ -163,7 +163,7 @@ report_pred_call_error(PredCallId, !Info, !IO) :- typecheck_find_arities(_, [], []). typecheck_find_arities(Preds, [PredId | PredIds], [Arity | Arities]) :- - map__lookup(Preds, PredId, PredInfo), + map.lookup(Preds, PredId, PredInfo), Arity = pred_info_orig_arity(PredInfo), typecheck_find_arities(Preds, PredIds, Arities). @@ -173,16 +173,16 @@ typecheck_find_arities(Preds, [PredId | PredIds], [Arity | Arities]) :- report_error_pred_num_args(Info, PredOrFunc - SymName/Arity, Arities, !IO) :- write_context_and_pred_id(Info, !IO), typecheck_info_get_context(Info, Context), - prog_out__write_context(Context, !IO), - io__write_string(" error: ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" error: ", !IO), report_error_num_args(yes(PredOrFunc), Arity, Arities, !IO), - io__nl(!IO), - prog_out__write_context(Context, !IO), - io__write_string(" in call to ", !IO), - prog_out__write_pred_or_func(PredOrFunc, !IO), - io__write_string(" `", !IO), - prog_out__write_sym_name(SymName, !IO), - io__write_string("'.\n", !IO). + io.nl(!IO), + prog_out.write_context(Context, !IO), + io.write_string(" in call to ", !IO), + prog_out.write_pred_or_func(PredOrFunc, !IO), + io.write_string(" `", !IO), + prog_out.write_sym_name(SymName, !IO), + io.write_string("'.\n", !IO). :- pred report_error_func_instead_of_pred(typecheck_info::in, pred_or_func::in, simple_call_id::in, io::di, io::uo) is det. @@ -215,51 +215,43 @@ report_error_undef_pred(Info, PredOrFunc - PredCallId, !IO) :- PredName = unqualified("->"), ( Arity = 2 ; Arity = 4 ) -> - io__write_string(" error: `->' without `;'.\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, - !IO), + io.write_string(" error: `->' without `;'.\n", !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string( - " Note: the else part is not optional.\n", - !IO), - prog_out__write_context(Context, !IO), - io__write_string(" Every if-then must have an else.\n", !IO) + prog_out.write_context(Context, !IO), + io.write_string(" Note: the else part is not optional.\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" Every if-then must have an else.\n", !IO) ; VerboseErrors = no, - globals__io_set_extra_error_info(yes, !IO) + globals.io_set_extra_error_info(yes, !IO) ) ; PredName = unqualified("else"), ( Arity = 2 ; Arity = 4 ) -> - io__write_string(" error: unmatched `else'.\n", !IO) + io.write_string(" error: unmatched `else'.\n", !IO) ; PredName = unqualified("if"), ( Arity = 2 ; Arity = 4 ) -> - io__write_string(" error: `if' without `then' or `else'.\n", - !IO) + io.write_string(" error: `if' without `then' or `else'.\n", !IO) ; PredName = unqualified("then"), ( Arity = 2 ; Arity = 4 ) -> - io__write_string(" error: `then' without `if' or `else'.\n", - !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, - !IO), + io.write_string(" error: `then' without `if' or `else'.\n", !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string(" Note: the `else' part is not optional.\n", - !IO), - prog_out__write_context(Context, !IO), - io__write_string( - " Every if-then must have an `else'.\n", !IO) + prog_out.write_context(Context, !IO), + io.write_string(" Note: the `else' part is not optional.\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" Every if-then must have an `else'.\n", !IO) ; VerboseErrors = no, - globals__io_set_extra_error_info(yes, !IO) + globals.io_set_extra_error_info(yes, !IO) ) ; PredName = unqualified("apply"), @@ -271,36 +263,35 @@ report_error_undef_pred(Info, PredOrFunc - PredCallId, !IO) :- Arity = 1, ( PurityString = "impure" ; PurityString = "semipure" ) -> - io__write_string(" error: `", !IO), - io__write_string(PurityString, !IO), - io__write_string("' marker in an inappropriate place.\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, - !IO), + io.write_string(" error: `", !IO), + io.write_string(PurityString, !IO), + io.write_string("' marker in an inappropriate place.\n", !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string(" Such markers only belong " ++ + prog_out.write_context(Context, !IO), + io.write_string(" Such markers only belong " ++ "before predicate calls.\n", !IO) ; VerboseErrors = no, - globals__io_set_extra_error_info(yes, !IO) + globals.io_set_extra_error_info(yes, !IO) ) ; PredName = unqualified("some"), Arity = 2 -> - io__write_string(" syntax error in existential " ++ + io.write_string(" syntax error in existential " ++ "quantification: first\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" argument of `some' should be " ++ + prog_out.write_context(Context, !IO), + io.write_string(" argument of `some' should be " ++ "a list of variables.\n", !IO) ; - io__write_string(" error: undefined ", !IO), + io.write_string(" error: undefined ", !IO), write_simple_call_id(PredOrFunc - PredCallId, !IO), ( PredName = qualified(ModuleQualifier, _) -> maybe_report_missing_import(Info, ModuleQualifier, !IO) ; - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ) ). @@ -311,7 +302,7 @@ report_error_apply_instead_of_pred(Info, !IO) :- typecheck_info_get_context(Info, Context), Pieces1 = [words("error: the language construct `apply'"), words("should be used as an expression, not as a goal."), nl], - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, Pieces2 = [words("Perhaps you forgot to add"), @@ -331,7 +322,7 @@ report_error_apply_instead_of_pred(Info, !IO) :- fixed("`my_apply(Func, X, Y) :- apply(Func, X, Y).'")] ; VerboseErrors = no, - globals__io_set_extra_error_info(yes, !IO), + globals.io_set_extra_error_info(yes, !IO), Pieces2 = [] ), write_error_pieces_not_first_line(Context, 0, Pieces1 ++ Pieces2, !IO). @@ -344,7 +335,7 @@ report_no_clauses(MessageKind, PredId, PredInfo, ModuleInfo, !IO) :- should_not_module_qualify, PredId), ErrorMsg = [words(MessageKind ++ ": no clauses for ") | PredPieces] ++ [suffix(".")], - error_util__write_error_pieces(Context, 0, ErrorMsg, !IO). + error_util.write_error_pieces(Context, 0, ErrorMsg, !IO). %-----------------------------------------------------------------------------% @@ -353,20 +344,20 @@ report_warning_too_much_overloading(Info, !IO) :- make_pred_id_preamble(Info, Preamble), SmallWarning = [fixed(Preamble), words("warning: highly ambiguous overloading.") ], - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, VerboseWarning = [ words("This may cause type-checking to be very"), words("slow. It may also make your code"), words("difficult to understand.") ], - list__append(SmallWarning, VerboseWarning, Warning) + list.append(SmallWarning, VerboseWarning, Warning) ; VerboseErrors = no, - globals__io_set_extra_error_info(yes, !IO), + globals.io_set_extra_error_info(yes, !IO), Warning = SmallWarning ), - error_util__report_warning(Context, 0, Warning, !IO). + error_util.report_warning(Context, 0, Warning, !IO). %-----------------------------------------------------------------------------% @@ -376,30 +367,30 @@ report_error_unif_var_var(Info, X, Y, TypeAssignSet, !IO) :- typecheck_info_get_unify_context(Info, UnifyContext), write_context_and_pred_id(Info, !IO), - hlds_out__write_unify_context(UnifyContext, Context, !IO), + hlds_out.write_unify_context(UnifyContext, Context, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" type error in unification of variable `", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" type error in unification of variable `", !IO), mercury_output_var(X, VarSet, no, !IO), - io__write_string("'\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" and variable `", !IO), + io.write_string("'\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" and variable `", !IO), mercury_output_var(Y, VarSet, no, !IO), - io__write_string("'.\n", !IO), + io.write_string("'.\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" `", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" `", !IO), mercury_output_var(X, VarSet, no, !IO), - io__write_string("'", !IO), + io.write_string("'", !IO), write_type_of_var(Info, Context, TypeAssignSet, X, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" `", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" `", !IO), mercury_output_var(Y, VarSet, no, !IO), - io__write_string("'", !IO), + io.write_string("'", !IO), write_type_of_var(Info, Context, TypeAssignSet, Y, !IO), - io__write_string(".\n", !IO), + io.write_string(".\n", !IO), write_type_assign_set_msg(TypeAssignSet, VarSet, !IO). @@ -410,69 +401,69 @@ report_error_lambda_var(Info, PredOrFunc, _EvalMethod, Var, ArgVars, typecheck_info_get_unify_context(Info, UnifyContext), write_context_and_pred_id(Info, !IO), - hlds_out__write_unify_context(UnifyContext, Context, !IO), + hlds_out.write_unify_context(UnifyContext, Context, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" type error in unification of ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" type error in unification of ", !IO), write_argument_name(VarSet, Var, !IO), - io__write_string("\n", !IO), - prog_out__write_context(Context, !IO), + io.write_string("\n", !IO), + prog_out.write_context(Context, !IO), ( PredOrFunc = predicate, - io__write_string(" and `", !IO), - io__write_string("pred(", !IO), + io.write_string(" and `", !IO), + io.write_string("pred(", !IO), mercury_output_vars(ArgVars, VarSet, no, !IO), - io__write_string(") :- ...':\n", !IO) + io.write_string(") :- ...':\n", !IO) ; PredOrFunc = function, pred_args_to_func_args(ArgVars, FuncArgs, RetVar), - io__write_string(" and `", !IO), - io__write_string("func(", !IO), + io.write_string(" and `", !IO), + io.write_string("func(", !IO), mercury_output_vars(FuncArgs, VarSet, no, !IO), - io__write_string(") = ", !IO), + io.write_string(") = ", !IO), mercury_output_var(RetVar, VarSet, no, !IO), - io__write_string(" :- ...':\n", !IO) + io.write_string(" :- ...':\n", !IO) ), - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), write_argument_name(VarSet, Var, !IO), write_type_of_var(Info, Context, TypeAssignSet, Var, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" lambda expression has type `", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" lambda expression has type `", !IO), ( PredOrFunc = predicate, - io__write_string("pred", !IO), + io.write_string("pred", !IO), ( ArgVars = [] -> true ; - io__write_string("(_", !IO), - list__length(ArgVars, NumArgVars), + io.write_string("(_", !IO), + list.length(ArgVars, NumArgVars), NumArgVars1 = NumArgVars - 1, - list__duplicate(NumArgVars1, ", _", Strings), - io__write_strings(Strings, !IO), - io__write_string(")", !IO) + list.duplicate(NumArgVars1, ", _", Strings), + io.write_strings(Strings, !IO), + io.write_string(")", !IO) ) ; PredOrFunc = function, - io__write_string("func", !IO), + io.write_string("func", !IO), pred_args_to_func_args(ArgVars, FuncArgs2, _), ( FuncArgs2 = [] -> true ; - io__write_string("(_", !IO), - list__length(FuncArgs2, NumArgVars), + io.write_string("(_", !IO), + list.length(FuncArgs2, NumArgVars), NumArgVars1 = NumArgVars - 1, - list__duplicate(NumArgVars1, ", _", Strings), - io__write_strings(Strings, !IO), - io__write_string(")", !IO) + list.duplicate(NumArgVars1, ", _", Strings), + io.write_strings(Strings, !IO), + io.write_string(")", !IO) ), - io__write_string(" = _", !IO) + io.write_string(" = _", !IO) ), - io__write_string("'.\n", !IO), + io.write_string("'.\n", !IO), write_type_assign_set_msg(TypeAssignSet, VarSet, !IO). report_error_functor_type(Info, Var, ConsDefnList, Functor, Arity, @@ -482,28 +473,28 @@ report_error_functor_type(Info, Var, ConsDefnList, Functor, Arity, typecheck_info_get_unify_context(Info, UnifyContext), write_context_and_pred_id(Info, !IO), - hlds_out__write_unify_context(UnifyContext, Context, !IO), + hlds_out.write_unify_context(UnifyContext, Context, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" type error in unification of ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" type error in unification of ", !IO), write_argument_name(VarSet, Var, !IO), - io__write_string("\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" and ", !IO), + io.write_string("\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" and ", !IO), write_functor_name(Functor, Arity, !IO), - io__write_string(".\n", !IO), + io.write_string(".\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), write_argument_name(VarSet, Var, !IO), write_type_of_var(Info, Context, TypeAssignSet, Var, !IO), - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), write_functor_name(Functor, Arity, !IO), write_type_of_functor(Functor, Arity, Context, ConsDefnList, !IO), - io__write_string(".\n", !IO), + io.write_string(".\n", !IO), write_type_assign_set_msg(TypeAssignSet, VarSet, !IO). @@ -513,40 +504,40 @@ report_error_functor_arg_types(Info, Var, ConsDefnList, Functor, Args, typecheck_info_get_varset(Info, VarSet), typecheck_info_get_unify_context(Info, UnifyContext), typecheck_info_get_module_info(Info, ModuleInfo), - list__length(Args, Arity), + list.length(Args, Arity), write_context_and_pred_id(Info, !IO), - hlds_out__write_unify_context(UnifyContext, Context, !IO), + hlds_out.write_unify_context(UnifyContext, Context, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" in unification of ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" in unification of ", !IO), write_argument_name(VarSet, Var, !IO), - io__write_string("\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" and term `", !IO), + io.write_string("\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" and term `", !IO), strip_builtin_qualifier_from_cons_id(Functor, StrippedFunctor), - hlds_out__write_functor_cons_id(StrippedFunctor, Args, VarSet, + hlds_out.write_functor_cons_id(StrippedFunctor, Args, VarSet, ModuleInfo, no, !IO), - io__write_string("':\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" type error in argument(s) of ", !IO), + io.write_string("':\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" type error in argument(s) of ", !IO), write_functor_name(StrippedFunctor, Arity, !IO), - io__write_string(".\n", !IO), + io.write_string(".\n", !IO), - ConsArgTypesSet = list__map(get_callee_arg_types, ArgsTypeAssignSet), + ConsArgTypesSet = list.map(get_callee_arg_types, ArgsTypeAssignSet), % If we know the type of the function symbol, and each argument % also has at most one possible type, then we prefer to print an % error message that mentions the actual and expected types of the % arguments only for the arguments in which the two types differ. ( - list__all_same(ConsArgTypesSet), + list.all_same(ConsArgTypesSet), ConsArgTypesSet = [ConsArgTypes | _], - assoc_list__from_corresponding_lists(Args, ConsArgTypes, ArgExpTypes), - TypeAssigns = list__map(get_caller_arg_assign, ArgsTypeAssignSet), + assoc_list.from_corresponding_lists(Args, ConsArgTypes, ArgExpTypes), + TypeAssigns = list.map(get_caller_arg_assign, ArgsTypeAssignSet), find_mismatched_args(ArgExpTypes, TypeAssigns, 1, SimpleMismatches, ComplexMismatches, AllMismatches), - expect(list__is_not_empty(AllMismatches), this_file, + expect(list.is_not_empty(AllMismatches), this_file, "report_error_functor_arg_types: no mismatches"), ComplexMismatches = [] -> @@ -565,22 +556,22 @@ report_error_functor_arg_types(Info, Var, ConsDefnList, Functor, Args, % ( % could the type of the functor be polymorphic? - list__member(ConsDefn, ConsDefnList), + list.member(ConsDefn, ConsDefnList), ConsDefn = cons_type_info(_, _, _, ConsArgTypes, _), ConsArgTypes \= [] -> % if so, print out the type of `Var' - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), write_argument_name(VarSet, Var, !IO), write_type_of_var(Info, Context, TypeAssignSet, Var, !IO), - io__write_string(",\n", !IO) + io.write_string(",\n", !IO) ; true ), - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), write_functor_name(Functor, Arity, !IO), write_type_of_functor(Functor, Arity, Context, ConsDefnList, !IO), write_types_of_vars(Args, VarSet, Context, Info, TypeAssignSet, !IO), @@ -616,9 +607,9 @@ find_mismatched_args([Arg - ExpType | ArgExpTypes], TypeAssignSet, ArgNum0, SimpleMismatchesTail, ComplexMismatchesTail, AllMismatchesTail), get_type_stuff(TypeAssignSet, Arg, TypeStuffList), - list__filter_map(substitute_types_check_match(ExpType), TypeStuffList, + list.filter_map(substitute_types_check_match(ExpType), TypeStuffList, TypeMismatches0), - list__sort_and_remove_dups(TypeMismatches0, TypeMismatches), + list.sort_and_remove_dups(TypeMismatches0, TypeMismatches), ( TypeMismatches = [], SimpleMismatches = SimpleMismatchesTail, @@ -675,7 +666,7 @@ report_mismatched_args([Mismatch | Mismatches], First, VarSet, Functor, unexpected(this_file, "report_mismatched_args: more than one type mismatch") ), - prog_out__write_context(Context, !IO), + prog_out.write_context(Context, !IO), ( % Handle higher-order syntax such as ''(F, A) specially: % output @@ -689,41 +680,41 @@ report_mismatched_args([Mismatch | Mismatches], First, VarSet, Functor, -> ( First = yes, - io__write_string(" Functor", !IO) + io.write_string(" Functor", !IO) ; First = no, - io__write_string(" argument ", !IO), - io__write_int(ArgNum - 1, !IO) + io.write_string(" argument ", !IO), + io.write_int(ArgNum - 1, !IO) ) ; ( First = yes, - io__write_string(" Argument ", !IO) + io.write_string(" Argument ", !IO) ; First = no, - io__write_string(" argument ", !IO) + io.write_string(" argument ", !IO) ), - io__write_int(ArgNum, !IO) + io.write_int(ArgNum, !IO) ), - ( varset__search_name(VarSet, Var, _) -> - io__write_string(" (", !IO), + ( varset.search_name(VarSet, Var, _) -> + io.write_string(" (", !IO), mercury_output_var(Var, VarSet, no, !IO), - io__write_string(")", !IO) + io.write_string(")", !IO) ; true ), - io__write_string(" has type `", !IO), + io.write_string(" has type `", !IO), output_type(ActType, TVarSet, HeadTypeParams, !IO), - io__write_string("',\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" expected type was `", !IO), + io.write_string("',\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" expected type was `", !IO), output_type(ExpType, TVarSet, HeadTypeParams, !IO), ( Mismatches = [], - io__write_string("'.\n", !IO) + io.write_string("'.\n", !IO) ; Mismatches = [_ | _], - io__write_string("';\n", !IO), + io.write_string("';\n", !IO), report_mismatched_args(Mismatches, no, VarSet, Functor, Context, !IO) ). @@ -741,33 +732,33 @@ report_error_var(Info, Var, Type, TypeAssignSet0, !IO) :- write_context_and_pred_id(Info, !IO), write_call_context(Context, PredMarkers, CalledPredId, ArgNum, UnifyContext, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" type error: ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" type error: ", !IO), ( TypeStuffList = [SingleTypeStuff] -> write_argument_name(VarSet, Var, !IO), SingleTypeStuff = type_stuff(VType, TVarSet, TBinding, HeadTypeParams), - io__write_string(" has type `", !IO), + io.write_string(" has type `", !IO), write_type_b(VType, TVarSet, TBinding, HeadTypeParams, !IO), - io__write_string("',\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" expected type was `", !IO), + io.write_string("',\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" expected type was `", !IO), write_type_b(Type, TVarSet, TBinding, HeadTypeParams, !IO), - io__write_string("'.\n", !IO) + io.write_string("'.\n", !IO) ; - io__write_string("type of ", !IO), + io.write_string("type of ", !IO), write_argument_name(VarSet, Var, !IO), - io__write_string(" does not match its expected type;\n", !IO), + io.write_string(" does not match its expected type;\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), write_argument_name(VarSet, Var, !IO), - io__write_string(" has overloaded actual/expected types {\n", !IO), + io.write_string(" has overloaded actual/expected types {\n", !IO), write_var_type_stuff_list(Context, TypeStuffList, Type, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" }.\n", !IO) + prog_out.write_context(Context, !IO), + io.write_string(" }.\n", !IO) ), write_type_assign_set_msg(TypeAssignSet0, VarSet, !IO). @@ -782,34 +773,34 @@ report_error_arg_var(Info, Var, ArgTypeAssignSet0) --> write_context_and_pred_id(Info), write_call_context(Context, PredMarkers, CalledPredId, ArgNum, UnifyContext), - prog_out__write_context(Context), - io__write_string(" type error: "), + prog_out.write_context(Context), + io.write_string(" type error: "), ( { ArgTypeStuffList = [SingleArgTypeStuff] } -> write_argument_name(VarSet, Var), { SingleArgTypeStuff = arg_type_stuff(Type0, VType0, TVarSet, HeadTypeParams) }, - io__write_string(" has type `"), + io.write_string(" has type `"), output_type(VType0, TVarSet, HeadTypeParams), - io__write_string("',\n"), - prog_out__write_context(Context), - io__write_string(" expected type was `"), + io.write_string("',\n"), + prog_out.write_context(Context), + io.write_string(" expected type was `"), output_type(Type0, TVarSet, HeadTypeParams), - io__write_string("'.\n") + io.write_string("'.\n") ; - io__write_string("type of "), + io.write_string("type of "), write_argument_name(VarSet, Var), - io__write_string(" does not match its expected type;\n"), + io.write_string(" does not match its expected type;\n"), - prog_out__write_context(Context), - io__write_string(" "), + prog_out.write_context(Context), + io.write_string(" "), write_argument_name(VarSet, Var), - io__write_string(" has overloaded actual/expected types {\n"), + io.write_string(" has overloaded actual/expected types {\n"), write_arg_type_stuff_list(Context, ArgTypeStuffList), - io__write_string("\n"), + io.write_string("\n"), - prog_out__write_context(Context), - io__write_string(" }.\n") + prog_out.write_context(Context), + io.write_string(" }.\n") ), write_args_type_assign_set_msg(ArgTypeAssignSet0, VarSet). @@ -824,7 +815,7 @@ report_error_undef_cons(Info, ConsErrors, Functor, Arity, !IO) :- write_context_and_pred_id(Info, !IO), write_call_context(Context, PredMarkers, CalledPredId, ArgNum, UnifyContext, !IO), - prog_out__write_context(Context, !IO), + prog_out.write_context(Context, !IO), % % Check for some special cases, so that we can give % clearer error messages. @@ -833,53 +824,53 @@ report_error_undef_cons(Info, ConsErrors, Functor, Arity, !IO) :- Functor = cons(unqualified(Name), _), language_builtin(Name, Arity) -> - io__write_string(" error: the language construct ", !IO), - hlds_out__write_cons_id(Functor, !IO), - io__write_string(" should be\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" used as a goal, not as an expression.\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + io.write_string(" error: the language construct ", !IO), + hlds_out.write_cons_id(Functor, !IO), + io.write_string(" should be\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" used as a goal, not as an expression.\n", !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " If you are trying to use a goal as a boolean function,\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " you should write `if then yes else no' instead.\n", !IO), ( Name = "call" -> - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " If you are trying to invoke a higher-order\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " function, you should use `apply', not `call'.\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " If you're trying to curry a higher-order predicate,\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " see the ""Creating higher-order terms"" section of the\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " Mercury Language Reference Manual.\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " If you really are trying to use `call' as an expression\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " and not as an application of the language builtin\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " call/N, make sure that you have the arity correct, and\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " that the functor `call' is actually defined (if it is\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " defined in a separate module, check that the module is\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " correctly imported).\n", !IO) ; true @@ -888,81 +879,81 @@ report_error_undef_cons(Info, ConsErrors, Functor, Arity, !IO) :- VerboseErrors = no ) ; Functor = cons(unqualified("else"), 2) -> - io__write_string(" error: unmatched `else'.\n", !IO) + io.write_string(" error: unmatched `else'.\n", !IO) ; Functor = cons(unqualified("if"), 2) -> - io__write_string(" error: `if' without `then' or `else'.\n", !IO) + io.write_string(" error: `if' without `then' or `else'.\n", !IO) ; Functor = cons(unqualified("then"), 2) -> - io__write_string(" error: `then' without `if' or `else'.\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + io.write_string(" error: `then' without `if' or `else'.\n", !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " Note: the `else' part is not optional.\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " Every if-then must have an `else'.\n", !IO) ; VerboseErrors = no ) ; Functor = cons(unqualified("->"), 2) -> - io__write_string(" error: `->' without `;'.\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + io.write_string(" error: `->' without `;'.\n", !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " Note: the else part is not optional.\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string( + prog_out.write_context(Context, !IO), + io.write_string( " Every if-then must have an else.\n", !IO) ; VerboseErrors = no ) ; Functor = cons(unqualified("^"), 2) -> - io__write_string(" error: invalid use of field selection " ++ + io.write_string(" error: invalid use of field selection " ++ "operator (`^').\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string(" This is probably some kind " ++ + prog_out.write_context(Context, !IO), + io.write_string(" This is probably some kind " ++ "of syntax error.\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" The field name must be an " ++ + prog_out.write_context(Context, !IO), + io.write_string(" The field name must be an " ++ "atom, not a variable or other term.\n", !IO) ; VerboseErrors = no ) ; Functor = cons(unqualified(":="), 2) -> - io__write_string(" error: invalid use of field update " ++ + io.write_string(" error: invalid use of field update " ++ "operator (`:=').\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string(" This is probably some kind " ++ + prog_out.write_context(Context, !IO), + io.write_string(" This is probably some kind " ++ "of syntax error.\n", !IO) ; VerboseErrors = no ) ; Functor = cons(unqualified(":-"), 2) -> - io__write_string(" syntax error in lambda expression " ++ + io.write_string(" syntax error in lambda expression " ++ "(`:-').\n", !IO) ; Functor = cons(unqualified("-->"), 2) -> - io__write_string(" syntax error in DCG lambda expression " ++ + io.write_string(" syntax error in DCG lambda expression " ++ "(`-->').\n", !IO) ; Functor = cons(unqualified("."), 2) -> - io__write_string(" error: the list constructor is " ++ + io.write_string(" error: the list constructor is " ++ "now `[|]/2', not `./2'.\n", !IO) ; Functor = cons(unqualified("!"), 1) -> - io__write_string(" error: invalid use of `!' " ++ + io.write_string(" error: invalid use of `!' " ++ "state variable operator.\n", !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, - prog_out__write_context(Context, !IO), - io__write_string(" You probably meant to use " ++ + prog_out.write_context(Context, !IO), + io.write_string(" You probably meant to use " ++ "`!.' or `!:'.\n", !IO) ; VerboseErrors = no @@ -973,7 +964,7 @@ report_error_undef_cons(Info, ConsErrors, Functor, Arity, !IO) :- typecheck_info_get_ctors(Info, ConsTable), solutions( (pred(N::out) is nondet :- - map__member(ConsTable, cons(Constructor, N), _), + map.member(ConsTable, cons(Constructor, N), _), N \= Arity ), ActualArities), ActualArities \= [] @@ -981,10 +972,10 @@ report_error_undef_cons(Info, ConsErrors, Functor, Arity, !IO) :- report_wrong_arity_constructor(Constructor, Arity, ActualArities, Context, !IO) ; - io__write_string(" error: undefined symbol `", !IO), + io.write_string(" error: undefined symbol `", !IO), strip_builtin_qualifier_from_cons_id(Functor, StrippedFunctor), - hlds_out__write_cons_id(StrippedFunctor, !IO), - io__write_string("'", !IO), + hlds_out.write_cons_id(StrippedFunctor, !IO), + io.write_string("'", !IO), ( Functor = cons(Constructor, _), Constructor = qualified(ModQual, _) @@ -995,12 +986,12 @@ report_error_undef_cons(Info, ConsErrors, Functor, Arity, !IO) :- -> maybe_report_missing_import(Info, unqualified("list"), !IO) ; - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ) ), ( ConsErrors = [_|_], - list__foldl(report_cons_error(Context), ConsErrors, !IO) + list.foldl(report_cons_error(Context), ConsErrors, !IO) ; ConsErrors = [] ) @@ -1031,14 +1022,14 @@ language_builtin("some", 2). prog_context::in, io::di, io::uo) is det. report_wrong_arity_constructor(Name, Arity, ActualArities, Context, !IO) :- - io__write_string(" error: ", !IO), + io.write_string(" error: ", !IO), MaybePredOrFunc = no, report_error_num_args(MaybePredOrFunc, Arity, ActualArities, !IO), - io__nl(!IO), - prog_out__write_context(Context, !IO), - io__write_string(" in use of constructor `", !IO), - prog_out__write_sym_name(Name, !IO), - io__write_string("'.\n", !IO). + io.nl(!IO), + prog_out.write_context(Context, !IO), + io.write_string(" in use of constructor `", !IO), + prog_out.write_sym_name(Name, !IO), + io.write_string("'.\n", !IO). :- pred report_cons_error(prog_context::in, cons_error::in, io::di, io::uo) is det. @@ -1107,27 +1098,27 @@ report_cons_error(Context, ConsError, !IO) :- report_ambiguity_error(Info, TypeAssign1, TypeAssign2, !IO) :- write_typecheck_info_context(Info, !IO), - io__write_string( + io.write_string( " error: ambiguous overloading causes type ambiguity.\n", !IO), typecheck_info_get_varset(Info, VarSet), type_assign_get_var_types(TypeAssign1, VarTypes1), - map__keys(VarTypes1, Vars1), + map.keys(VarTypes1, Vars1), report_ambiguity_error_2(Vars1, VarSet, Info, TypeAssign1, TypeAssign2, no, Found, !IO), - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), typecheck_info_get_context(Info, Context), ( Found = no -> - prog_out__write_context(Context, !IO), - io__write_string(" One or more of the predicates or " ++ + prog_out.write_context(Context, !IO), + io.write_string(" One or more of the predicates or " ++ "functions called\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" is declared in more than one module.\n", + prog_out.write_context(Context, !IO), + io.write_string(" is declared in more than one module.\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" Try adding explicit module qualifiers.\n", + prog_out.write_context(Context, !IO), + io.write_string(" Try adding explicit module qualifiers.\n", !IO) ; VerboseErrors = yes -> - io__write_strings([ + io.write_strings([ "\tYou will need to add an explicit type qualification to resolve the\n", "\ttype ambiguity.\n", "\tThe way to add an explicit type qualification is to use ""with_type"".\n", @@ -1154,8 +1145,8 @@ report_ambiguity_error_2([V | Vs], VarSet, Info, TypeAssign1, type_assign_get_head_type_params(TypeAssign1, HeadTypeParams1), type_assign_get_head_type_params(TypeAssign2, HeadTypeParams2), ( - map__search(VarTypes1, V, Type1), - map__search(VarTypes2, V, Type2), + map.search(VarTypes1, V, Type1), + map.search(VarTypes2, V, Type2), apply_rec_subst_to_type(TypeBindings1, Type1, T1), apply_rec_subst_to_type(TypeBindings2, Type2, T2), \+ identical_types(T1, T2) @@ -1163,21 +1154,21 @@ report_ambiguity_error_2([V | Vs], VarSet, Info, TypeAssign1, typecheck_info_get_context(Info, Context), ( !.Found = no, - prog_out__write_context(Context, !IO), - io__write_string(" Possible type assignments include:\n", !IO) + prog_out.write_context(Context, !IO), + io.write_string(" Possible type assignments include:\n", !IO) ; !.Found = yes ), !:Found = yes, - prog_out__write_context(Context, !IO), + prog_out.write_context(Context, !IO), mercury_output_var(V, VarSet, no, !IO), - io__write_string(": ", !IO), + io.write_string(": ", !IO), type_assign_get_typevarset(TypeAssign1, TVarSet1), output_type(T1, TVarSet1, HeadTypeParams1, !IO), - io__write_string(" or ", !IO), + io.write_string(" or ", !IO), type_assign_get_typevarset(TypeAssign2, TVarSet2), output_type(T2, TVarSet2, HeadTypeParams2, !IO), - io__write_string("\n", !IO) + io.write_string("\n", !IO) ; true ), @@ -1189,12 +1180,12 @@ report_ambiguity_error_2([V | Vs], VarSet, Info, TypeAssign1, report_unsatisfiable_constraints(TypeAssignSet, !Info, !IO) :- typecheck_info_get_context(!.Info, Context), write_context_and_pred_id(!.Info, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" unsatisfiable typeclass constraint(s):\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" unsatisfiable typeclass constraint(s):\n", !IO), % XXX this won't be very pretty when there are % XXX multiple type_assigns. - io__write_list(TypeAssignSet, "\n", write_constraints(Context), !IO), + io.write_list(TypeAssignSet, "\n", write_constraints(Context), !IO), typecheck_info_set_found_error(yes, !Info). :- pred write_constraints(prog_context::in, type_assign::in, io::di, io::uo) @@ -1210,14 +1201,14 @@ write_constraints(Context, TypeAssign, !IO) :- type_assign_get_type_bindings(TypeAssign, Bindings), apply_rec_subst_to_prog_constraint_list(Bindings, UnprovenProgConstraints0, UnprovenProgConstraints1), - list__sort_and_remove_dups(UnprovenProgConstraints1, + list.sort_and_remove_dups(UnprovenProgConstraints1, UnprovenProgConstraints), - prog_out__write_context(Context, !IO), - io__write_string(" `", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" `", !IO), AppendVarnums = no, - io__write_list(UnprovenProgConstraints, "', `", + io.write_list(UnprovenProgConstraints, "', `", mercury_output_constraint(VarSet, AppendVarnums), !IO), - io__write_string("'.\n", !IO). + io.write_string("'.\n", !IO). %-----------------------------------------------------------------------------% @@ -1231,7 +1222,7 @@ report_missing_tvar_in_foreign_code(Info, VarName, !IO) :- [words("should define the variable"), fixed(add_quotes(VarName)), suffix(".")], write_error_pieces(Context, 0, Pieces, !IO), - io__set_exit_status(1, !IO). + io.set_exit_status(1, !IO). %-----------------------------------------------------------------------------% @@ -1240,11 +1231,11 @@ report_missing_tvar_in_foreign_code(Info, VarName, !IO) :- io::di, io::uo) is det. write_types_of_vars([], _, _, _, _, !IO) :- - io__write_string(".\n", !IO). + io.write_string(".\n", !IO). write_types_of_vars([Var | Vars], VarSet, Context, Info, TypeAssignSet, !IO) :- - io__write_string(",\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), + io.write_string(",\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), write_argument_name(VarSet, Var, !IO), write_type_of_var(Info, Context, TypeAssignSet, Var, !IO), write_types_of_vars(Vars, VarSet, Context, Info, TypeAssignSet, !IO). @@ -1253,12 +1244,12 @@ write_types_of_vars([Var | Vars], VarSet, Context, Info, TypeAssignSet, !IO) :- is det. write_argument_name(VarSet, Var, !IO) :- - ( varset__search_name(VarSet, Var, _) -> - io__write_string("variable `", !IO), + ( varset.search_name(VarSet, Var, _) -> + io.write_string("variable `", !IO), mercury_output_var(Var, VarSet, no, !IO), - io__write_string("'", !IO) + io.write_string("'", !IO) ; - io__write_string("argument", !IO) + io.write_string("argument", !IO) ). :- pred write_functor_name(cons_id::in, int::in, io::di, io::uo) is det. @@ -1266,21 +1257,21 @@ write_argument_name(VarSet, Var, !IO) :- write_functor_name(Functor, Arity, !IO) :- strip_builtin_qualifier_from_cons_id(Functor, StrippedFunctor), ( Arity = 0 -> - io__write_string("constant `", !IO), + io.write_string("constant `", !IO), ( Functor = cons(Name, _) -> - prog_out__write_sym_name(Name, !IO) + prog_out.write_sym_name(Name, !IO) ; - hlds_out__write_cons_id(StrippedFunctor, !IO) + hlds_out.write_cons_id(StrippedFunctor, !IO) ), - io__write_string("'", !IO) + io.write_string("'", !IO) ; Functor = cons(unqualified(""), _) -> - io__write_string("higher-order term (with arity ", !IO), - io__write_int(Arity - 1, !IO), - io__write_string(")", !IO) + io.write_string("higher-order term (with arity ", !IO), + io.write_int(Arity - 1, !IO), + io.write_string(")", !IO) ; - io__write_string("functor `", !IO), - hlds_out__write_cons_id(StrippedFunctor, !IO), - io__write_string("'", !IO) + io.write_string("functor `", !IO), + hlds_out.write_cons_id(StrippedFunctor, !IO), + io.write_string("'", !IO) ). :- pred write_type_of_var(typecheck_info::in, prog_context::in, @@ -1288,17 +1279,17 @@ write_functor_name(Functor, Arity, !IO) :- write_type_of_var(_Info, Context, TypeAssignSet, Var, !IO) :- get_type_stuff(TypeAssignSet, Var, TypeStuffList), - TypeStrs0 = list__map(typestuff_to_typestr, TypeStuffList), - list__sort_and_remove_dups(TypeStrs0, TypeStrs), + TypeStrs0 = list.map(typestuff_to_typestr, TypeStuffList), + list.sort_and_remove_dups(TypeStrs0, TypeStrs), ( TypeStrs = [TypeStr] -> - io__write_string(" has type `", !IO), - io__write_string(TypeStr, !IO), - io__write_string("'", !IO) + io.write_string(" has type `", !IO), + io.write_string(TypeStr, !IO), + io.write_string("'", !IO) ; - io__write_string(" has overloaded type {\n", !IO), + io.write_string(" has overloaded type {\n", !IO), write_types_list(Context, TypeStrs, !IO), - prog_out__write_context(Context, !IO), - io__write_string(" }", !IO) + prog_out.write_context(Context, !IO), + io.write_string(" }", !IO) ). :- pred write_type_of_functor(cons_id::in, int::in, prog_context::in, @@ -1306,22 +1297,22 @@ write_type_of_var(_Info, Context, TypeAssignSet, Var, !IO) :- write_type_of_functor(Functor, Arity, Context, ConsDefnList, !IO) :- ( ConsDefnList = [SingleDefn] -> - io__write_string(" has type ", !IO), + io.write_string(" has type ", !IO), ( Arity \= 0 -> - io__write_string("\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" `", !IO) + io.write_string("\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" `", !IO) ; - io__write_string("`", !IO) + io.write_string("`", !IO) ), write_cons_type(SingleDefn, Functor, Context, !IO), - io__write_string("'", !IO) + io.write_string("'", !IO) ; - io__write_string(" has overloaded type\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" { ", !IO), + io.write_string(" has overloaded type\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" { ", !IO), write_cons_type_list(ConsDefnList, Functor, Arity, Context, !IO), - io__write_string(" }", !IO) + io.write_string(" }", !IO) ). :- pred write_cons_type(cons_type_info::in, cons_id::in, prog_context::in, @@ -1340,7 +1331,7 @@ write_cons_type(cons_type_info(TVarSet, ExistQVars, ConsType, ArgTypes, _), ; unexpected(this_file, "write_cons_type: invalid cons_id") ), - io__write_string(": ", !IO) + io.write_string(": ", !IO) ; ArgTypes = [] ), @@ -1357,11 +1348,11 @@ write_cons_type_list([ConsDefn | ConsDefns], Functor, Arity, Context, !IO) :- ; ConsDefns = [_ | _], ( Arity = 0 -> - io__write_string(", ", !IO) + io.write_string(", ", !IO) ; - io__write_string(",\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO) + io.write_string(",\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO) ), write_cons_type_list(ConsDefns, Functor, Arity, Context, !IO) ). @@ -1370,40 +1361,40 @@ write_cons_type_list([ConsDefn | ConsDefns], Functor, Arity, Context, !IO) :- io::di, io::uo) is det. write_type_assign_set_msg(TypeAssignSet, VarSet, !IO) :- - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, ( TypeAssignSet = [_] -> - io__write_string( + io.write_string( "\tThe partial type assignment was:\n", !IO) ; - io__write_string("\tThe possible partial type " ++ + io.write_string("\tThe possible partial type " ++ "assignments were:\n", !IO) ), write_type_assign_set(TypeAssignSet, VarSet, !IO) ; VerboseErrors = no, - globals__io_set_extra_error_info(yes, !IO) + globals.io_set_extra_error_info(yes, !IO) ). :- pred write_args_type_assign_set_msg(args_type_assign_set::in, prog_varset::in, io::di, io::uo) is det. write_args_type_assign_set_msg(ArgTypeAssignSet, VarSet, !IO) :- - globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), + globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO), ( VerboseErrors = yes, ( ArgTypeAssignSet = [_] -> - io__write_string( + io.write_string( "\tThe partial type assignment was:\n", !IO) ; - io__write_string("\tThe possible partial type " ++ + io.write_string("\tThe possible partial type " ++ "assignments were:\n", !IO) ), write_args_type_assign_set(ArgTypeAssignSet, VarSet, !IO) ; VerboseErrors = no, - globals__io_set_extra_error_info(yes, !IO) + globals.io_set_extra_error_info(yes, !IO) ). :- pred output_type(mer_type::in, tvarset::in, head_type_params::in, @@ -1412,9 +1403,9 @@ write_args_type_assign_set_msg(ArgTypeAssignSet, VarSet, !IO) :- output_type(Type0, TVarSet, HeadTypeParams, !IO) :- strip_builtin_qualifiers_from_type(Type0, Type), unparse_type(Type, Term0), - list__map(term__coerce_var, HeadTypeParams, ExistQVars), + list.map(term.coerce_var, HeadTypeParams, ExistQVars), maybe_add_existential_quantifier(ExistQVars, Term0, Term), - varset__coerce(TVarSet, VarSet), + varset.coerce(TVarSet, VarSet), mercury_output_term(Term, VarSet, no, !IO). :- pred write_types_list(prog_context::in, list(string)::in, @@ -1422,15 +1413,15 @@ output_type(Type0, TVarSet, HeadTypeParams, !IO) :- write_types_list(_Context, [], !IO). write_types_list(Context, [Type | Types], !IO) :- - prog_out__write_context(Context, !IO), - io__write_string(" ", !IO), - io__write_string(Type, !IO), + prog_out.write_context(Context, !IO), + io.write_string(" ", !IO), + io.write_string(Type, !IO), ( Types = [], - io__write_string("\n", !IO) + io.write_string("\n", !IO) ; Types = [_ | _], - io__write_string(",\n", !IO), + io.write_string(",\n", !IO), write_types_list(Context, Types, !IO) ). @@ -1444,7 +1435,7 @@ write_type_stuff(type_stuff(Type, TVarSet, TypeBinding, HeadTypeParams), mer_type::in, io::di, io::uo) is det. write_var_type_stuff_list(Context, TypeStuffs, Type, !IO) :- - io__write_list(TypeStuffs, ",\n", write_var_type_stuff(Context, Type), + io.write_list(TypeStuffs, ",\n", write_var_type_stuff(Context, Type), !IO). :- pred write_var_type_stuff(prog_context::in, mer_type::in, type_stuff::in, @@ -1452,12 +1443,12 @@ write_var_type_stuff_list(Context, TypeStuffs, Type, !IO) :- write_var_type_stuff(Context, Type, VarTypeStuff, !IO) :- VarTypeStuff = type_stuff(VarType, TVarSet, TypeBinding, HeadTypeParams), - prog_out__write_context(Context, !IO), - io__write_string(" (inferred) ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" (inferred) ", !IO), write_type_b(VarType, TVarSet, TypeBinding, HeadTypeParams, !IO), - io__write_string(",\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" (expected) ", !IO), + io.write_string(",\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" (expected) ", !IO), write_type_b(Type, TVarSet, TypeBinding, HeadTypeParams, !IO). :- pred write_type_b(mer_type::in, tvarset::in, tsubst::in, @@ -1471,19 +1462,19 @@ write_type_b(Type0, TypeVarSet, TypeBindings, HeadTypeParams, !IO) :- io::di, io::uo) is det. write_arg_type_stuff_list(Context, TypeStuffs, !IO) :- - io__write_list(TypeStuffs, ",\n", write_arg_type_stuff(Context), !IO). + io.write_list(TypeStuffs, ",\n", write_arg_type_stuff(Context), !IO). :- pred write_arg_type_stuff(prog_context::in, arg_type_stuff::in, io::di, io::uo) is det. write_arg_type_stuff(Context, ArgTypeStuff, !IO) :- ArgTypeStuff = arg_type_stuff(Type, VarType, TVarSet, HeadTypeParams), - prog_out__write_context(Context, !IO), - io__write_string(" (inferred) ", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" (inferred) ", !IO), output_type(VarType, TVarSet, HeadTypeParams, !IO), - io__write_string(",\n", !IO), - prog_out__write_context(Context, !IO), - io__write_string(" (expected) ", !IO), + io.write_string(",\n", !IO), + prog_out.write_context(Context, !IO), + io.write_string(" (expected) ", !IO), output_type(Type, TVarSet, HeadTypeParams, !IO). %-----------------------------------------------------------------------------% @@ -1506,10 +1497,10 @@ maybe_report_missing_import(Info, ModuleQualifier, !IO) :- match_sym_name(ModuleQualifier, VisibleModule) ) -> - io__write_string("\n", !IO), - error_util__write_error_pieces(Context, 2, + io.write_string("\n", !IO), + error_util.write_error_pieces(Context, 2, [words("(the module "), - fixed(error_util__describe_sym_name(ModuleQualifier)), + fixed(error_util.describe_sym_name(ModuleQualifier)), words("has not been imported).")], !IO) ; % The module qualifier matches one or more of the @@ -1519,10 +1510,10 @@ maybe_report_missing_import(Info, ModuleQualifier, !IO) :- ModuleInfo), UnimportedParents), UnimportedParents \= [] -> - io__write_string("\n", !IO), + io.write_string("\n", !IO), report_unimported_parents(Context, UnimportedParents, !IO) ; - io__write_string(".\n", !IO) + io.write_string(".\n", !IO) ). % Nondeterministically return all the possible parent modules which could @@ -1536,16 +1527,16 @@ get_unimported_parent(ModuleQualifier, ModuleInfo, UnimportedParent) :- visible_module(ModuleName, ModuleInfo), match_sym_name(ModuleQualifier, ModuleName), ParentModules = get_ancestors(ModuleName), - list__member(UnimportedParent, ParentModules), + list.member(UnimportedParent, ParentModules), \+ visible_module(UnimportedParent, ModuleInfo). :- pred report_unimported_parents(prog_context::in, list(module_name)::in, io::di, io::uo) is det. report_unimported_parents(Context, UnimportedParents, !IO) :- - UnimportedParentDescs = list__map(describe_sym_name, UnimportedParents), + UnimportedParentDescs = list.map(describe_sym_name, UnimportedParents), AllUnimportedParents = list_to_pieces(UnimportedParentDescs), - error_util__write_error_pieces(Context, 2, + error_util.write_error_pieces(Context, 2, ( AllUnimportedParents = [_] -> [words("(the possible parent module ")] ++ AllUnimportedParents @@ -1563,12 +1554,12 @@ report_unimported_parents(Context, UnimportedParents, !IO) :- write_call_context(Context, PredMarkers, CallId, ArgNum, UnifyContext) --> ( { ArgNum = 0 } -> - hlds_out__write_unify_context(UnifyContext, Context) + hlds_out.write_unify_context(UnifyContext, Context) ; - prog_out__write_context(Context), - io__write_string(" in "), - hlds_out__write_call_arg_id(CallId, ArgNum, PredMarkers), - io__write_string(":\n") + prog_out.write_context(Context), + io.write_string(" in "), + hlds_out.write_call_arg_id(CallId, ArgNum, PredMarkers), + io.write_string(":\n") ). :- pred write_typecheck_info_context(typecheck_info::in, io::di, io::uo) @@ -1577,7 +1568,7 @@ write_call_context(Context, PredMarkers, CallId, ArgNum, UnifyContext) --> write_typecheck_info_context(Info, !IO) :- write_context_and_pred_id(Info, !IO), typecheck_info_get_context(Info, Context), - prog_out__write_context(Context, !IO). + prog_out.write_context(Context, !IO). :- pred write_context_and_pred_id(typecheck_info::in, io::di, io::uo) is det. @@ -1585,10 +1576,10 @@ write_context_and_pred_id(Info, !IO) :- typecheck_info_get_module_info(Info, ModuleInfo), typecheck_info_get_context(Info, Context), typecheck_info_get_predid(Info, PredId), - prog_out__write_context(Context, !IO), - io__write_string("In clause for ", !IO), - hlds_out__write_pred_id(ModuleInfo, PredId, !IO), - io__write_string(":\n", !IO). + prog_out.write_context(Context, !IO), + io.write_string("In clause for ", !IO), + hlds_out.write_pred_id(ModuleInfo, PredId, !IO), + io.write_string(":\n", !IO). % This is intended to supercede the above predicate - It performs the % same action, but instead of just writing to the output straight away @@ -1616,7 +1607,7 @@ make_pred_id_preamble(Info, Preamble) :- :- pred identical_types(mer_type::in, mer_type::in) is semidet. identical_types(Type1, Type2) :- - map__init(TypeSubst0), + map.init(TypeSubst0), type_unify(Type1, Type2, [], TypeSubst0, TypeSubst), TypeSubst = TypeSubst0. @@ -1643,7 +1634,7 @@ get_type_stuff([TypeAssign | TypeAssigns], Var, TypeStuffs) :- type_assign_get_type_bindings(TypeAssign, TypeBindings), type_assign_get_typevarset(TypeAssign, TVarSet), type_assign_get_var_types(TypeAssign, VarTypes), - ( map__search(VarTypes, Var, Type0) -> + ( map.search(VarTypes, Var, Type0) -> Type = Type0 ; % This shouldn't happen - how can a variable which has @@ -1652,7 +1643,7 @@ get_type_stuff([TypeAssign | TypeAssigns], Var, TypeStuffs) :- Type = defined(unqualified(""), [], star) ), TypeStuff = type_stuff(Type, TVarSet, TypeBindings, HeadTypeParams), - ( list__member(TypeStuff, TailTypeStuffs) -> + ( list.member(TypeStuff, TailTypeStuffs) -> TypeStuffs = TailTypeStuffs ; TypeStuffs = [TypeStuff | TailTypeStuffs] @@ -1665,9 +1656,9 @@ typestuff_to_typestr(TypeStuff) = TypeStr :- apply_rec_subst_to_type(TypeBindings, Type0, Type1), strip_builtin_qualifiers_from_type(Type1, Type), unparse_type(Type, Term0), - list__map(term__coerce_var, HeadTypeParams, ExistQVars), + list.map(term.coerce_var, HeadTypeParams, ExistQVars), maybe_add_existential_quantifier(ExistQVars, Term0, Term), - varset__coerce(TypeVarSet, VarSet), + varset.coerce(TypeVarSet, VarSet), TypeStr = mercury_term_to_string(Term, VarSet, no). % Given an arg type assignment set and a variable id, return the list of @@ -1692,7 +1683,7 @@ get_arg_type_stuff([ArgTypeAssign | ArgTypeAssigns], Var, ArgTypeStuffs) :- type_assign_get_type_bindings(TypeAssign, TypeBindings), type_assign_get_typevarset(TypeAssign, TVarSet), type_assign_get_var_types(TypeAssign, VarTypes), - ( map__search(VarTypes, Var, VarType0) -> + ( map.search(VarTypes, Var, VarType0) -> VarType = VarType0 ; % This shouldn't happen - how can a variable which has @@ -1700,12 +1691,12 @@ get_arg_type_stuff([ArgTypeAssign | ArgTypeAssigns], Var, ArgTypeStuffs) :- % the correct type? VarType = defined(unqualified(""), [], star) ), - list__index0_det(ArgTypes, 0, ArgType), + list.index0_det(ArgTypes, 0, ArgType), apply_rec_subst_to_type(TypeBindings, ArgType, ArgType2), apply_rec_subst_to_type(TypeBindings, VarType, VarType2), ArgTypeStuff = arg_type_stuff(ArgType2, VarType2, TVarSet, HeadTypeParams), - ( list__member(ArgTypeStuff, TailArgTypeStuffs) -> + ( list.member(ArgTypeStuff, TailArgTypeStuffs) -> ArgTypeStuffs = TailArgTypeStuffs ; ArgTypeStuffs = [ArgTypeStuff | TailArgTypeStuffs] @@ -1720,23 +1711,23 @@ get_arg_type_stuff([ArgTypeAssign | ArgTypeAssigns], Var, ArgTypeStuffs) :- is det. maybe_add_existential_quantifier(HeadTypeParams, !Term) :- - term__vars(!.Term, Vars), - ExistQVars = set__to_sorted_list(set__intersect( - set__list_to_set(HeadTypeParams), set__list_to_set(Vars))), + term.vars(!.Term, Vars), + ExistQVars = set.to_sorted_list(set.intersect( + set.list_to_set(HeadTypeParams), set.list_to_set(Vars))), ( ExistQVars = [] ; ExistQVars = [_ | _], QTerm = make_list_term(ExistQVars), - !:Term = term__functor(term__atom("some"), [QTerm, !.Term], - term__context_init) + !:Term = term.functor(term.atom("some"), [QTerm, !.Term], + term.context_init) ). :- func make_list_term(list(var)) = term. -make_list_term([]) = term__functor(term__atom("[]"), [], term__context_init). -make_list_term([Var | Vars]) = term__functor(term__atom("[|]"), - [term__variable(Var), make_list_term(Vars)], term__context_init). +make_list_term([]) = term.functor(term.atom("[]"), [], term.context_init). +make_list_term([Var | Vars]) = term.functor(term.atom("[|]"), + [term.variable(Var), make_list_term(Vars)], term.context_init). %-----------------------------------------------------------------------------% @@ -1747,7 +1738,7 @@ write_inference_messages([PredId | PredIds], ModuleInfo, !IO) :- ( check_marker(Markers, infer_type), module_info_predids(ModuleInfo, ValidPredIds), - list__member(PredId, ValidPredIds), + list.member(PredId, ValidPredIds), \+ pred_info_get_goal_type(PredInfo, promise(_)) -> write_inference_message(PredInfo, !IO) @@ -1771,26 +1762,24 @@ write_inference_message(PredInfo, !IO) :- pred_info_get_class_context(PredInfo, ClassContext), pred_info_get_purity(PredInfo, Purity), MaybeDet = no, - prog_out__write_context(Context, !IO), - io__write_string("Inferred ", !IO), + prog_out.write_context(Context, !IO), + io.write_string("Inferred ", !IO), AppendVarNums = no, ( PredOrFunc = predicate, mercury_output_pred_type(VarSet, ExistQVars, Name, Types, - MaybeDet, Purity, ClassContext, Context, AppendVarNums, - !IO) + MaybeDet, Purity, ClassContext, Context, AppendVarNums, !IO) ; PredOrFunc = function, pred_args_to_func_args(Types, ArgTypes, RetType), - mercury_output_func_type(VarSet, ExistQVars, Name, ArgTypes, - RetType, MaybeDet, Purity, ClassContext, Context, - AppendVarNums, !IO) + mercury_output_func_type(VarSet, ExistQVars, Name, ArgTypes, RetType, + MaybeDet, Purity, ClassContext, Context, AppendVarNums, !IO) ). checkpoint(Msg, !Info, !IO) :- typecheck_info_get_module_info(!.Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, debug_types, DoCheckPoint), + globals.lookup_bool_option(Globals, debug_types, DoCheckPoint), ( DoCheckPoint = yes, checkpoint_2(Msg, !.Info, !IO) @@ -1801,12 +1790,12 @@ checkpoint(Msg, !Info, !IO) :- :- pred checkpoint_2(string::in, typecheck_info::in, io::di, io::uo) is det. checkpoint_2(Msg, T0, !IO) :- - io__write_string("At ", !IO), - io__write_string(Msg, !IO), - io__write_string(": ", !IO), - globals__io_lookup_bool_option(detailed_statistics, Statistics, !IO), + io.write_string("At ", !IO), + io.write_string(Msg, !IO), + io.write_string(": ", !IO), + globals.io_lookup_bool_option(detailed_statistics, Statistics, !IO), maybe_report_stats(Statistics, !IO), - io__write_string("\n", !IO), + io.write_string("\n", !IO), typecheck_info_get_type_assign_set(T0, TypeAssignSet), ( Statistics = yes, @@ -1815,8 +1804,7 @@ checkpoint_2(Msg, T0, !IO) :- type_assign_get_var_types(TypeAssign, VarTypes), checkpoint_tree_stats("\t`var -> type' map", VarTypes, !IO), type_assign_get_type_bindings(TypeAssign, TypeBindings), - checkpoint_tree_stats("\t`type var -> type' map", TypeBindings, - !IO) + checkpoint_tree_stats("\t`type var -> type' map", TypeBindings, !IO) ; true ), @@ -1827,11 +1815,11 @@ checkpoint_2(Msg, T0, !IO) :- is det. checkpoint_tree_stats(Description, Tree, !IO) :- - map__count(Tree, Count), - io__write_string(Description, !IO), - io__write_string(": count = ", !IO), - io__write_int(Count, !IO), - io__write_string("\n", !IO). + map.count(Tree, Count), + io.write_string(Description, !IO), + io.write_string(": count = ", !IO), + io.write_int(Count, !IO), + io.write_string("\n", !IO). %-----------------------------------------------------------------------------% diff --git a/compiler/typecheck_info.m b/compiler/typecheck_info.m index b75a9bee7..88591d834 100644 --- a/compiler/typecheck_info.m +++ b/compiler/typecheck_info.m @@ -1,5 +1,7 @@ %-----------------------------------------------------------------------------% -% Copyright (C) 2005 The University of Melbourne. +% vim: ft=mercury ts=4 sw=4 et +%-----------------------------------------------------------------------------% +% Copyright (C) 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -32,61 +34,55 @@ % The typecheck_info data structure. % -:- type typecheck_info ---> - typecheck_info( - module_info :: module_info, +:- type typecheck_info + ---> typecheck_info( + module_info :: module_info, - call_id :: call_id, - % The call_id of the pred - % being called (if any) + call_id :: call_id, + % The call_id of the pred being called (if + % any). - arg_num :: int, - % The argument number within - % a pred call + arg_num :: int, + % The argument number within a pred call. - pred_id :: pred_id, - % The pred we're checking + pred_id :: pred_id, + % The pred we're checking. - import_status :: import_status, - % Import status of the pred - % being checked + import_status :: import_status, + % Import status of the pred being checked. - pred_markers :: pred_markers, - % Markers of the pred being checked + pred_markers :: pred_markers, + % Markers of the pred being checked - is_field_access_function :: bool, - % Is the pred we're checking - % a field access function? - % If so, there should only - % be a field access function - % application in the body, not - % predicate or function calls - % or constructor applications. + is_field_access_function :: bool, + % Is the pred we're checking a field access + % function? If so, there should only be + % a field access function application + % in the body, not predicate or function calls + % or constructor applications. - context :: prog_context, - % The context of the goal - % we're checking + context :: prog_context, + % The context of the goal we're checking. - unify_context :: unify_context, - % The original source of the - % unification we're checking + unify_context :: unify_context, + % The original source of the unification + % we're checking. - varset :: prog_varset, - % Variable names + varset :: prog_varset, + % Variable names - type_assign_set :: type_assign_set, - % This is the main piece of - % information that we are - % computing and which gets - % updated as we go along + type_assign_set :: type_assign_set, + % This is the main piece of information + % that we are computing and which gets updated + % as we go along. - found_error :: bool, - % did we find any type errors? + found_error :: bool, + % Did we find any type errors? - warned_about_overloading :: bool - % Have we already warned about - % highly ambiguous overloading? - ). + warned_about_overloading :: bool + % Have we already warned about highly + % ambiguous overloading? + ). %-----------------------------------------------------------------------------% % @@ -94,34 +90,34 @@ % :- pred typecheck_info_init(module_info::in, pred_id::in, - bool::in, tvarset::in, prog_varset::in, vartypes::in, - head_type_params::in, hlds_constraints::in, import_status::in, - pred_markers::in, typecheck_info::out) is det. + bool::in, tvarset::in, prog_varset::in, vartypes::in, + head_type_params::in, hlds_constraints::in, import_status::in, + pred_markers::in, typecheck_info::out) is det. - % typecheck_info_get_final_info(Info, OldHeadTypeParams, OldExistQVars, - % OldExplicitVarTypes, NewTypeVarSet, New* ..., TypeRenaming, - % ExistTypeRenaming): - % - % Extracts the final inferred types from Info. - % - % OldHeadTypeParams should be the type variables from the head of the - % predicate. - % OldExistQVars should be the declared existentially quantified - % type variables (if any). - % OldExplicitVarTypes is the vartypes map containing the explicit - % type qualifications. - % New* is the newly inferred types, in NewTypeVarSet. - % TypeRenaming is a map to rename things from the old TypeVarSet - % to the NewTypeVarSet. - % ExistTypeRenaming is a map (which should be applied *before* - % applying TypeRenaming) to rename existential type variables - % in OldExistQVars. - % + % typecheck_info_get_final_info(Info, OldHeadTypeParams, OldExistQVars, + % OldExplicitVarTypes, NewTypeVarSet, New* ..., TypeRenaming, + % ExistTypeRenaming): + % + % Extracts the final inferred types from Info. + % + % OldHeadTypeParams should be the type variables from the head of the + % predicate. + % OldExistQVars should be the declared existentially quantified + % type variables (if any). + % OldExplicitVarTypes is the vartypes map containing the explicit + % type qualifications. + % New* is the newly inferred types, in NewTypeVarSet. + % TypeRenaming is a map to rename things from the old TypeVarSet + % to the NewTypeVarSet. + % ExistTypeRenaming is a map (which should be applied *before* + % applying TypeRenaming) to rename existential type variables + % in OldExistQVars. + % :- pred typecheck_info_get_final_info(typecheck_info::in, list(tvar)::in, - existq_tvars::in, vartypes::in, tvarset::out, existq_tvars::out, - vartypes::out, prog_constraints::out, - constraint_proof_map::out, constraint_map::out, - tvar_renaming::out, tvar_renaming::out) is det. + existq_tvars::in, vartypes::in, tvarset::out, existq_tvars::out, + vartypes::out, prog_constraints::out, + constraint_proof_map::out, constraint_map::out, + tvar_renaming::out, tvar_renaming::out) is det. %-----------------------------------------------------------------------------% % @@ -129,40 +125,40 @@ % :- pred typecheck_info_get_module_info(typecheck_info::in, module_info::out) - is det. + is det. :- pred typecheck_info_get_called_predid(typecheck_info::in, call_id::out) - is det. + is det. :- pred typecheck_info_get_arg_num(typecheck_info::in, int::out) is det. :- pred typecheck_info_get_predid(typecheck_info::in, pred_id::out) is det. :- pred typecheck_info_get_context(typecheck_info::in, - prog_context::out) is det. + prog_context::out) is det. :- pred typecheck_info_get_unify_context(typecheck_info::in, - unify_context::out) is det. + unify_context::out) is det. :- pred typecheck_info_get_varset(typecheck_info::in, prog_varset::out) is det. :- pred typecheck_info_get_type_assign_set(typecheck_info::in, - type_assign_set::out) is det. + type_assign_set::out) is det. :- pred typecheck_info_get_found_error(typecheck_info::in, bool::out) is det. :- pred typecheck_info_get_warned_about_overloading(typecheck_info::in, - bool::out) is det. + bool::out) is det. :- pred typecheck_info_get_pred_import_status(typecheck_info::in, - import_status::out) is det. + import_status::out) is det. :- pred typecheck_info_set_called_predid(call_id::in, - typecheck_info::in, typecheck_info::out) is det. + typecheck_info::in, typecheck_info::out) is det. :- pred typecheck_info_set_arg_num(int::in, - typecheck_info::in, typecheck_info::out) is det. + typecheck_info::in, typecheck_info::out) is det. :- pred typecheck_info_set_context(prog_context::in, - typecheck_info::in, typecheck_info::out) is det. + typecheck_info::in, typecheck_info::out) is det. :- pred typecheck_info_set_unify_context(unify_context::in, - typecheck_info::in, typecheck_info::out) is det. + typecheck_info::in, typecheck_info::out) is det. :- pred typecheck_info_set_type_assign_set(type_assign_set::in, - typecheck_info::in, typecheck_info::out) is det. + typecheck_info::in, typecheck_info::out) is det. :- pred typecheck_info_set_found_error(bool::in, - typecheck_info::in, typecheck_info::out) is det. + typecheck_info::in, typecheck_info::out) is det. :- pred typecheck_info_set_warned_about_overloading(bool::in, - typecheck_info::in, typecheck_info::out) is det. + typecheck_info::in, typecheck_info::out) is det. :- pred typecheck_info_set_pred_import_status(import_status::in, - typecheck_info::in, typecheck_info::out) is det. + typecheck_info::in, typecheck_info::out) is det. %-----------------------------------------------------------------------------% % @@ -170,13 +166,13 @@ % :- pred typecheck_info_get_module_name(typecheck_info::in, module_name::out) - is det. + is det. :- pred typecheck_info_get_preds(typecheck_info::in, predicate_table::out) - is det. + is det. :- pred typecheck_info_get_types(typecheck_info::in, type_table::out) is det. :- pred typecheck_info_get_ctors(typecheck_info::in, cons_table::out) is det. :- pred typecheck_info_get_pred_markers(typecheck_info::in, pred_markers::out) - is det. + is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -184,31 +180,29 @@ % The type_assign and type_assign_set data structures. % -:- type type_assign_set == list(type_assign). +:- type type_assign_set == list(type_assign). -:- type type_assign ---> - type_assign( - var_types :: vartypes, - type_varset :: tvarset, - % type names - head_type_params :: head_type_params, - % universally quantified type variables - type_bindings :: tsubst, - % type bindings - class_constraints :: hlds_constraints, - % the set of class constraints - % collected so far - constraint_proofs :: constraint_proof_map, - % for each constraint - % found to be redundant, - % why is it so? - constraint_map :: constraint_map - % Maps constraint identifiers to the - % actual constraints. - ). +:- type type_assign + ---> type_assign( + var_types :: vartypes, + type_varset :: tvarset, + head_type_params :: head_type_params, + % Universally quantified type variables. + type_bindings :: tsubst, + % Type bindings. + class_constraints :: hlds_constraints, + % The set of class constraints + % collected so far. + constraint_proofs :: constraint_proof_map, + % For each constraint found to be + % redundant, why is it so? + constraint_map :: constraint_map + % Maps constraint identifiers to the + % actual constraints. + ). :- pred write_type_assign_set(type_assign_set::in, prog_varset::in, - io::di, io::uo) is det. + io::di, io::uo) is det. %-----------------------------------------------------------------------------% % @@ -216,34 +210,34 @@ % :- pred type_assign_get_var_types(type_assign::in, - vartypes::out) is det. + vartypes::out) is det. :- pred type_assign_get_typevarset(type_assign::in, - tvarset::out) is det. + tvarset::out) is det. :- pred type_assign_get_head_type_params(type_assign::in, - head_type_params::out) is det. + head_type_params::out) is det. :- pred type_assign_get_type_bindings(type_assign::in, - tsubst::out) is det. + tsubst::out) is det. :- pred type_assign_get_typeclass_constraints(type_assign::in, - hlds_constraints::out) is det. + hlds_constraints::out) is det. :- pred type_assign_get_constraint_proofs(type_assign::in, - constraint_proof_map::out) is det. + constraint_proof_map::out) is det. :- pred type_assign_get_constraint_map(type_assign::in, - constraint_map::out) is det. + constraint_map::out) is det. :- pred type_assign_set_var_types(vartypes::in, - type_assign::in, type_assign::out) is det. + type_assign::in, type_assign::out) is det. :- pred type_assign_set_typevarset(tvarset::in, - type_assign::in, type_assign::out) is det. + type_assign::in, type_assign::out) is det. :- pred type_assign_set_head_type_params(head_type_params::in, - type_assign::in, type_assign::out) is det. + type_assign::in, type_assign::out) is det. :- pred type_assign_set_type_bindings(tsubst::in, - type_assign::in, type_assign::out) is det. + type_assign::in, type_assign::out) is det. :- pred type_assign_set_typeclass_constraints(hlds_constraints::in, - type_assign::in, type_assign::out) is det. + type_assign::in, type_assign::out) is det. :- pred type_assign_set_constraint_proofs(constraint_proof_map::in, - type_assign::in, type_assign::out) is det. + type_assign::in, type_assign::out) is det. :- pred type_assign_set_constraint_map(constraint_map::in, - type_assign::in, type_assign::out) is det. + type_assign::in, type_assign::out) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -251,48 +245,44 @@ :- type args_type_assign_set == list(args_type_assign). :- type args_type_assign - ---> args( - caller_arg_assign :: type_assign, - % Type assignment. - callee_arg_types :: list(mer_type), - % Types of callee args, - % renamed apart. - callee_constraints :: hlds_constraints - % Constraints from callee, - % renamed apart. - ). + ---> args( + caller_arg_assign :: type_assign, + % Type assignment. + callee_arg_types :: list(mer_type), + % Types of callee args, renamed apart. + callee_constraints :: hlds_constraints + % Constraints from callee, renamed apart. + ). :- func get_caller_arg_assign(args_type_assign) = type_assign. :- func get_callee_arg_types(args_type_assign) = list(mer_type). :- func get_callee_constraints(args_type_assign) = hlds_constraints. :- pred write_args_type_assign_set(args_type_assign_set::in, prog_varset::in, - io::di, io::uo) is det. + io::di, io::uo) is det. :- pred convert_nonempty_args_type_assign_set(args_type_assign_set::in, - type_assign_set::out) is det. + type_assign_set::out) is det. - % Same as convert_nonempty_args_type_assign_set, but does not abort - % when the args are empty. - % + % Same as convert_nonempty_args_type_assign_set, but does not abort + % when the args are empty. + % :- pred convert_args_type_assign_set(args_type_assign_set::in, - type_assign_set::out) is det. + type_assign_set::out) is det. %-----------------------------------------------------------------------------% :- type cons_type_info - ---> cons_type_info( - tvarset, % Type variables - existq_tvars, % Existentially quantified - % type vars - mer_type, % Constructor type - list(mer_type), % Types of the arguments - hlds_constraints % Constraints introduced by - % this constructor (e.g. if - % it is actually a function, - % or if it is an existentially - % quantified data constructor) - ). + ---> cons_type_info( + tvarset, % Type variables. + existq_tvars, % Existentially quantified type vars. + mer_type, % Constructor type. + list(mer_type), % Types of the arguments. + hlds_constraints % Constraints introduced by this + % constructor (e.g. if it is actually + % a function, or if it is an existentially + % quantified data constructor). + ). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -315,185 +305,179 @@ %-----------------------------------------------------------------------------% typecheck_info_init(ModuleInfo, PredId, IsFieldAccessFunction, - TypeVarSet, VarSet, VarTypes, HeadTypeParams, - Constraints, Status, Markers, Info) :- - CallPredId = call(predicate - unqualified("") / 0), - term__context_init(Context), - map__init(TypeBindings), - map__init(Proofs), - map__init(ConstraintMap), - FoundTypeError = no, - WarnedAboutOverloading = no, - Info = typecheck_info( - ModuleInfo, CallPredId, 0, PredId, Status, Markers, - IsFieldAccessFunction, Context, - unify_context(explicit, []), VarSet, - [type_assign(VarTypes, TypeVarSet, HeadTypeParams, - TypeBindings, Constraints, Proofs, ConstraintMap)], - FoundTypeError, WarnedAboutOverloading - ). + TypeVarSet, VarSet, VarTypes, HeadTypeParams, + Constraints, Status, Markers, Info) :- + CallPredId = call(predicate - unqualified("") / 0), + term.context_init(Context), + map.init(TypeBindings), + map.init(Proofs), + map.init(ConstraintMap), + FoundTypeError = no, + WarnedAboutOverloading = no, + Info = typecheck_info( + ModuleInfo, CallPredId, 0, PredId, Status, Markers, + IsFieldAccessFunction, Context, + unify_context(explicit, []), VarSet, + [type_assign(VarTypes, TypeVarSet, HeadTypeParams, + TypeBindings, Constraints, Proofs, ConstraintMap)], + FoundTypeError, WarnedAboutOverloading + ). typecheck_info_get_final_info(Info, OldHeadTypeParams, OldExistQVars, - OldExplicitVarTypes, NewTypeVarSet, NewHeadTypeParams, - NewVarTypes, NewTypeConstraints, NewConstraintProofs, - NewConstraintMap, TSubst, ExistTypeRenaming) :- - typecheck_info_get_type_assign_set(Info, TypeAssignSet), - ( - TypeAssignSet = [TypeAssign | _], - type_assign_get_head_type_params(TypeAssign, HeadTypeParams), - type_assign_get_typevarset(TypeAssign, OldTypeVarSet), - type_assign_get_var_types(TypeAssign, VarTypes0), - type_assign_get_type_bindings(TypeAssign, TypeBindings), - type_assign_get_typeclass_constraints(TypeAssign, - HLDSTypeConstraints), - type_assign_get_constraint_proofs(TypeAssign, - ConstraintProofs0), - type_assign_get_constraint_map(TypeAssign, ConstraintMap0), + OldExplicitVarTypes, NewTypeVarSet, NewHeadTypeParams, + NewVarTypes, NewTypeConstraints, NewConstraintProofs, + NewConstraintMap, TSubst, ExistTypeRenaming) :- + typecheck_info_get_type_assign_set(Info, TypeAssignSet), + ( + TypeAssignSet = [TypeAssign | _], + type_assign_get_head_type_params(TypeAssign, HeadTypeParams), + type_assign_get_typevarset(TypeAssign, OldTypeVarSet), + type_assign_get_var_types(TypeAssign, VarTypes0), + type_assign_get_type_bindings(TypeAssign, TypeBindings), + type_assign_get_typeclass_constraints(TypeAssign, HLDSTypeConstraints), + type_assign_get_constraint_proofs(TypeAssign, ConstraintProofs0), + type_assign_get_constraint_map(TypeAssign, ConstraintMap0), - map__keys(VarTypes0, Vars), - expand_types(Vars, TypeBindings, VarTypes0, VarTypes), - apply_rec_subst_to_constraint_proofs(TypeBindings, - ConstraintProofs0, ConstraintProofs), - apply_rec_subst_to_constraint_map(TypeBindings, - ConstraintMap0, ConstraintMap1), + map.keys(VarTypes0, Vars), + expand_types(Vars, TypeBindings, VarTypes0, VarTypes), + apply_rec_subst_to_constraint_proofs(TypeBindings, + ConstraintProofs0, ConstraintProofs), + apply_rec_subst_to_constraint_map(TypeBindings, + ConstraintMap0, ConstraintMap1), - % - % When inferring the typeclass constraints, the universal - % constraints here may be assumed (if this is the last pass) - % but will not have been eliminated during context reduction, - % hence they will not yet be in the constraint map. Since - % they may be required, put them in now. - % - % Additionally, existential constraints are assumed so don't - % need to be eliminated during context reduction, so they - % need to be put in the constraint map now. - % - HLDSTypeConstraints = constraints(HLDSUnivConstraints, - HLDSExistConstraints, _), - list__foldl(update_constraint_map, HLDSUnivConstraints, - ConstraintMap1, ConstraintMap2), - list__foldl(update_constraint_map, HLDSExistConstraints, - ConstraintMap2, ConstraintMap), + % + % When inferring the typeclass constraints, the universal + % constraints here may be assumed (if this is the last pass) + % but will not have been eliminated during context reduction, + % hence they will not yet be in the constraint map. Since + % they may be required, put them in now. + % + % Additionally, existential constraints are assumed so don't + % need to be eliminated during context reduction, so they + % need to be put in the constraint map now. + % + HLDSTypeConstraints = constraints(HLDSUnivConstraints, + HLDSExistConstraints, _), + list.foldl(update_constraint_map, HLDSUnivConstraints, + ConstraintMap1, ConstraintMap2), + list.foldl(update_constraint_map, HLDSExistConstraints, + ConstraintMap2, ConstraintMap), - % - % Figure out how we should rename the existential types - % in the type declaration (if any). - % - get_existq_tvar_renaming(OldHeadTypeParams, OldExistQVars, - TypeBindings, ExistTypeRenaming), + % + % Figure out how we should rename the existential types + % in the type declaration (if any). + % + get_existq_tvar_renaming(OldHeadTypeParams, OldExistQVars, + TypeBindings, ExistTypeRenaming), - % - % We used to just use the OldTypeVarSet that we got - % from the type assignment. - % - % However, that caused serious efficiency problems, - % because the typevarsets get bigger and bigger with each - % inference step. Instead, we now construct a new - % typevarset NewTypeVarSet which contains only the - % variables we want, and we rename the type variables - % so that they fit into this new typevarset. - % + % + % We used to just use the OldTypeVarSet that we got + % from the type assignment. + % + % However, that caused serious efficiency problems, + % because the typevarsets get bigger and bigger with each + % inference step. Instead, we now construct a new + % typevarset NewTypeVarSet which contains only the + % variables we want, and we rename the type variables + % so that they fit into this new typevarset. + % - % - % First, find the set (sorted list) of type variables - % that we need. This must include any type variables - % in the inferred types, the explicit type qualifications, - % and any existentially typed variables that will remain - % in the declaration. - % - % There may also be some type variables in the HeadTypeParams - % which do not occur in the type of any variable (e.g. this - % can happen in the case of code containing type errors). - % We'd better keep those, too, to avoid errors - % when we apply the TSubst to the HeadTypeParams. - % (XXX should we do the same for TypeConstraints and - % ConstraintProofs too?) - % - map__values(VarTypes, Types), - prog_type__vars_list(Types, TypeVars0), - map__values(OldExplicitVarTypes, ExplicitTypes), - prog_type__vars_list(ExplicitTypes, ExplicitTypeVars0), - map__keys(ExistTypeRenaming, ExistQVarsToBeRenamed), - list__delete_elems(OldExistQVars, ExistQVarsToBeRenamed, - ExistQVarsToRemain), - list__condense([ExistQVarsToRemain, HeadTypeParams, - TypeVars0, ExplicitTypeVars0], TypeVars1), - list__sort_and_remove_dups(TypeVars1, TypeVars), - % - % Next, create a new typevarset with the same number of - % variables. - % - varset__squash(OldTypeVarSet, TypeVars, NewTypeVarSet, TSubst), - % - % Finally, rename the types and type class constraints - % to use the new typevarset type variables. - % - apply_variable_renaming_to_type_list(TSubst, Types, NewTypes), - map__from_corresponding_lists(Vars, NewTypes, NewVarTypes), - map__apply_to_list(HeadTypeParams, TSubst, NewHeadTypeParams), - retrieve_prog_constraints(HLDSTypeConstraints, - TypeConstraints), - apply_variable_renaming_to_prog_constraints(TSubst, - TypeConstraints, NewTypeConstraints), - apply_variable_renaming_to_constraint_proofs(TSubst, - ConstraintProofs, NewConstraintProofs), - apply_variable_renaming_to_constraint_map(TSubst, - ConstraintMap, NewConstraintMap) - ; - TypeAssignSet = [], - unexpected(this_file, - "internal error in typecheck_info_get_vartypes") - ). + % + % First, find the set (sorted list) of type variables + % that we need. This must include any type variables + % in the inferred types, the explicit type qualifications, + % and any existentially typed variables that will remain + % in the declaration. + % + % There may also be some type variables in the HeadTypeParams + % which do not occur in the type of any variable (e.g. this + % can happen in the case of code containing type errors). + % We'd better keep those, too, to avoid errors + % when we apply the TSubst to the HeadTypeParams. + % (XXX should we do the same for TypeConstraints and + % ConstraintProofs too?) + % + map.values(VarTypes, Types), + prog_type.vars_list(Types, TypeVars0), + map.values(OldExplicitVarTypes, ExplicitTypes), + prog_type.vars_list(ExplicitTypes, ExplicitTypeVars0), + map.keys(ExistTypeRenaming, ExistQVarsToBeRenamed), + list.delete_elems(OldExistQVars, ExistQVarsToBeRenamed, + ExistQVarsToRemain), + list.condense([ExistQVarsToRemain, HeadTypeParams, + TypeVars0, ExplicitTypeVars0], TypeVars1), + list.sort_and_remove_dups(TypeVars1, TypeVars), + % + % Next, create a new typevarset with the same number of + % variables. + % + varset.squash(OldTypeVarSet, TypeVars, NewTypeVarSet, TSubst), + % + % Finally, rename the types and type class constraints + % to use the new typevarset type variables. + % + apply_variable_renaming_to_type_list(TSubst, Types, NewTypes), + map.from_corresponding_lists(Vars, NewTypes, NewVarTypes), + map.apply_to_list(HeadTypeParams, TSubst, NewHeadTypeParams), + retrieve_prog_constraints(HLDSTypeConstraints, TypeConstraints), + apply_variable_renaming_to_prog_constraints(TSubst, + TypeConstraints, NewTypeConstraints), + apply_variable_renaming_to_constraint_proofs(TSubst, + ConstraintProofs, NewConstraintProofs), + apply_variable_renaming_to_constraint_map(TSubst, + ConstraintMap, NewConstraintMap) + ; + TypeAssignSet = [], + unexpected(this_file, "internal error in typecheck_info_get_vartypes") + ). - % Fully expand the types of the variables by applying the type - % bindings. - % -:- pred expand_types(list(prog_var)::in, tsubst::in, vartypes::in, - vartypes::out) is det. + % Fully expand the types of the variables by applying the type bindings. + % +:- pred expand_types(list(prog_var)::in, tsubst::in, + vartypes::in, vartypes::out) is det. expand_types([], _, !VarTypes). expand_types([Var | Vars], TypeSubst, !VarTypes) :- - map__lookup(!.VarTypes, Var, Type0), - apply_rec_subst_to_type(TypeSubst, Type0, Type), - map__det_update(!.VarTypes, Var, Type, !:VarTypes), - expand_types(Vars, TypeSubst, !VarTypes). + map.lookup(!.VarTypes, Var, Type0), + apply_rec_subst_to_type(TypeSubst, Type0, Type), + map.det_update(!.VarTypes, Var, Type, !:VarTypes), + expand_types(Vars, TypeSubst, !VarTypes). - % We rename any existentially quantified type variables which - % get mapped to other type variables, unless they are mapped to - % universally quantified type variables from the head of the predicate. - % + % We rename any existentially quantified type variables which + % get mapped to other type variables, unless they are mapped to + % universally quantified type variables from the head of the predicate. + % :- pred get_existq_tvar_renaming(list(tvar)::in, existq_tvars::in, tsubst::in, - tvar_renaming::out) is det. + tvar_renaming::out) is det. get_existq_tvar_renaming(OldHeadTypeParams, ExistQVars, TypeBindings, - ExistTypeRenaming) :- - list__foldl( - get_existq_tvar_renaming_2(OldHeadTypeParams, TypeBindings), - ExistQVars, map__init, ExistTypeRenaming). + ExistTypeRenaming) :- + list.foldl(get_existq_tvar_renaming_2(OldHeadTypeParams, TypeBindings), + ExistQVars, map.init, ExistTypeRenaming). :- pred get_existq_tvar_renaming_2(existq_tvars::in, tsubst::in, - tvar::in, tvar_renaming::in, tvar_renaming::out) is det. + tvar::in, tvar_renaming::in, tvar_renaming::out) is det. get_existq_tvar_renaming_2(OldHeadTypeParams, TypeBindings, TVar, !Renaming) :- - ( - tvar_maps_to_tvar(TypeBindings, TVar, NewTVar), - NewTVar \= TVar, - \+ list__member(NewTVar, OldHeadTypeParams) - -> - svmap__det_insert(TVar, NewTVar, !Renaming) - ; - true - ). + ( + tvar_maps_to_tvar(TypeBindings, TVar, NewTVar), + NewTVar \= TVar, + \+ list.member(NewTVar, OldHeadTypeParams) + -> + svmap.det_insert(TVar, NewTVar, !Renaming) + ; + true + ). :- pred tvar_maps_to_tvar(tsubst::in, tvar::in, tvar::out) is semidet. tvar_maps_to_tvar(TypeBindings, TVar0, TVar) :- - ( map__search(TypeBindings, TVar0, Type) -> - Type = variable(TVar1, _), - tvar_maps_to_tvar(TypeBindings, TVar1, TVar) - ; - TVar = TVar0 - ). + ( map.search(TypeBindings, TVar0, Type) -> + Type = variable(TVar1, _), + tvar_maps_to_tvar(TypeBindings, TVar1, TVar) + ; + TVar = TVar0 + ). %-----------------------------------------------------------------------------% @@ -507,40 +491,40 @@ typecheck_info_get_varset(Info, Info ^ varset). typecheck_info_get_type_assign_set(Info, Info ^ type_assign_set). typecheck_info_get_found_error(Info, Info ^ found_error). typecheck_info_get_warned_about_overloading(Info, - Info ^ warned_about_overloading). + Info ^ warned_about_overloading). typecheck_info_get_pred_import_status(Info, Info ^ import_status). typecheck_info_set_called_predid(PredCallId, Info, - Info ^ call_id := PredCallId). + Info ^ call_id := PredCallId). typecheck_info_set_arg_num(ArgNum, Info, Info ^ arg_num := ArgNum). typecheck_info_set_context(Context, Info, Info ^ context := Context). typecheck_info_set_unify_context(UnifyContext, Info, - Info ^ unify_context := UnifyContext). + Info ^ unify_context := UnifyContext). typecheck_info_set_type_assign_set(TypeAssignSet, Info, - Info ^ type_assign_set := TypeAssignSet). + Info ^ type_assign_set := TypeAssignSet). typecheck_info_set_found_error(FoundError, Info, - Info ^ found_error := FoundError). + Info ^ found_error := FoundError). typecheck_info_set_warned_about_overloading(Warned, Info, - Info ^ warned_about_overloading := Warned). + Info ^ warned_about_overloading := Warned). typecheck_info_set_pred_import_status(Status, Info, - Info ^ import_status := Status). + Info ^ import_status := Status). %-----------------------------------------------------------------------------% typecheck_info_get_module_name(Info, Name) :- - module_info_get_name(Info ^ module_info, Name). + module_info_get_name(Info ^ module_info, Name). typecheck_info_get_preds(Info, Preds) :- - module_info_get_predicate_table(Info ^ module_info, Preds). + module_info_get_predicate_table(Info ^ module_info, Preds). typecheck_info_get_types(Info, Types) :- - module_info_get_type_table(Info ^ module_info, Types). + module_info_get_type_table(Info ^ module_info, Types). typecheck_info_get_ctors(Info, Ctors) :- - module_info_get_cons_table(Info ^ module_info, Ctors). + module_info_get_cons_table(Info ^ module_info, Ctors). typecheck_info_get_pred_markers(Info, PredMarkers) :- - typecheck_info_get_module_info(Info, ModuleInfo), - typecheck_info_get_predid(Info, PredId), - module_info_pred_info(ModuleInfo, PredId, PredInfo), - pred_info_get_markers(PredInfo, PredMarkers). + typecheck_info_get_module_info(Info, ModuleInfo), + typecheck_info_get_predid(Info, PredId), + module_info_pred_info(ModuleInfo, PredId, PredInfo), + pred_info_get_markers(PredInfo, PredMarkers). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -564,153 +548,152 @@ type_assign_set_constraint_map(X, TA, TA ^ constraint_map := X). %-----------------------------------------------------------------------------% :- func varnums = bool. + varnums = yes. write_type_assign_set([], _) --> []. write_type_assign_set([TypeAssign | TypeAssigns], VarSet) --> - io__write_string("\t"), - write_type_assign(TypeAssign, VarSet), - io__write_string("\n"), - write_type_assign_set(TypeAssigns, VarSet). + io.write_string("\t"), + write_type_assign(TypeAssign, VarSet), + io.write_string("\n"), + write_type_assign_set(TypeAssigns, VarSet). :- pred write_type_assign(type_assign::in, prog_varset::in, io::di, io::uo) - is det. + is det. write_type_assign(TypeAssign, VarSet, !IO) :- - type_assign_get_head_type_params(TypeAssign, HeadTypeParams), - type_assign_get_var_types(TypeAssign, VarTypes), - type_assign_get_typeclass_constraints(TypeAssign, Constraints), - type_assign_get_type_bindings(TypeAssign, TypeBindings), - type_assign_get_typevarset(TypeAssign, TypeVarSet), - map__keys(VarTypes, Vars), - ( - HeadTypeParams = [] - ; - HeadTypeParams = [_ | _], - io__write_string("some [", !IO), - mercury_output_vars(HeadTypeParams, TypeVarSet, varnums, !IO), - io__write_string("]\n\t", !IO) - ), - write_type_assign_types(Vars, VarSet, VarTypes, TypeBindings, - TypeVarSet, no, !IO), - write_type_assign_constraints(Constraints, TypeBindings, TypeVarSet, - !IO), - io__write_string("\n", !IO). + type_assign_get_head_type_params(TypeAssign, HeadTypeParams), + type_assign_get_var_types(TypeAssign, VarTypes), + type_assign_get_typeclass_constraints(TypeAssign, Constraints), + type_assign_get_type_bindings(TypeAssign, TypeBindings), + type_assign_get_typevarset(TypeAssign, TypeVarSet), + map.keys(VarTypes, Vars), + ( + HeadTypeParams = [] + ; + HeadTypeParams = [_ | _], + io.write_string("some [", !IO), + mercury_output_vars(HeadTypeParams, TypeVarSet, varnums, !IO), + io.write_string("]\n\t", !IO) + ), + write_type_assign_types(Vars, VarSet, VarTypes, TypeBindings, TypeVarSet, + no, !IO), + write_type_assign_constraints(Constraints, TypeBindings, TypeVarSet, !IO), + io.write_string("\n", !IO). :- pred write_type_assign_types(list(prog_var)::in, prog_varset::in, - vartypes::in, tsubst::in, tvarset::in, bool::in, - io::di, io::uo) is det. + vartypes::in, tsubst::in, tvarset::in, bool::in, + io::di, io::uo) is det. write_type_assign_types([], _, _, _, _, FoundOne, !IO) :- - ( FoundOne = no -> - io__write_string("(No variables were assigned a type)", !IO) - ; - true - ). + ( + FoundOne = no, + io.write_string("(No variables were assigned a type)", !IO) + ; + FoundOne = yes + ). write_type_assign_types([Var | Vars], VarSet, VarTypes, TypeBindings, - TypeVarSet, FoundOne, !IO) :- - ( - map__search(VarTypes, Var, Type) - -> - ( - FoundOne = yes, - io__write_string("\n\t", !IO) - ; - FoundOne = no - ), - mercury_output_var(Var, VarSet, varnums, !IO), - io__write_string(": ", !IO), - write_type_with_bindings(Type, TypeVarSet, TypeBindings, !IO), - write_type_assign_types(Vars, VarSet, VarTypes, TypeBindings, - TypeVarSet, yes, !IO) - ; - write_type_assign_types(Vars, VarSet, VarTypes, TypeBindings, - TypeVarSet, FoundOne, !IO) - ). + TypeVarSet, FoundOne, !IO) :- + ( map.search(VarTypes, Var, Type) -> + ( + FoundOne = yes, + io.write_string("\n\t", !IO) + ; + FoundOne = no + ), + mercury_output_var(Var, VarSet, varnums, !IO), + io.write_string(": ", !IO), + write_type_with_bindings(Type, TypeVarSet, TypeBindings, !IO), + write_type_assign_types(Vars, VarSet, VarTypes, TypeBindings, + TypeVarSet, yes, !IO) + ; + write_type_assign_types(Vars, VarSet, VarTypes, TypeBindings, + TypeVarSet, FoundOne, !IO) + ). :- pred write_type_assign_constraints(hlds_constraints::in, - tsubst::in, tvarset::in, io::di, io::uo) is det. + tsubst::in, tvarset::in, io::di, io::uo) is det. write_type_assign_constraints(Constraints, TypeBindings, TypeVarSet, !IO) :- - Constraints = constraints(ConstraintsToProve, AssumedConstraints, _), - write_type_assign_constraints("&", AssumedConstraints, - TypeBindings, TypeVarSet, no, !IO), - write_type_assign_constraints("<=", ConstraintsToProve, - TypeBindings, TypeVarSet, no, !IO). + Constraints = constraints(ConstraintsToProve, AssumedConstraints, _), + write_type_assign_constraints("&", AssumedConstraints, + TypeBindings, TypeVarSet, no, !IO), + write_type_assign_constraints("<=", ConstraintsToProve, + TypeBindings, TypeVarSet, no, !IO). :- pred write_type_assign_constraints(string::in, list(hlds_constraint)::in, - tsubst::in, tvarset::in, bool::in, io::di, io::uo) is det. + tsubst::in, tvarset::in, bool::in, io::di, io::uo) is det. write_type_assign_constraints(_, [], _, _, _, !IO). write_type_assign_constraints(Operator, [Constraint | Constraints], - TypeBindings, TypeVarSet, FoundOne, !IO) :- - ( - FoundOne = no, - io__write_strings(["\n\t", Operator, " "], !IO) - ; - FoundOne = yes, - io__write_string(",\n\t ", !IO) - ), - apply_rec_subst_to_constraint(TypeBindings, Constraint, - BoundConstraint), - retrieve_prog_constraint(BoundConstraint, ProgConstraint), - mercury_output_constraint(TypeVarSet, varnums, ProgConstraint, - !IO), - write_type_assign_constraints(Operator, Constraints, TypeBindings, - TypeVarSet, yes, !IO). + TypeBindings, TypeVarSet, FoundOne, !IO) :- + ( + FoundOne = no, + io.write_strings(["\n\t", Operator, " "], !IO) + ; + FoundOne = yes, + io.write_string(",\n\t ", !IO) + ), + apply_rec_subst_to_constraint(TypeBindings, Constraint, + BoundConstraint), + retrieve_prog_constraint(BoundConstraint, ProgConstraint), + mercury_output_constraint(TypeVarSet, varnums, ProgConstraint, + !IO), + write_type_assign_constraints(Operator, Constraints, TypeBindings, + TypeVarSet, yes, !IO). - % write_type_with_bindings writes out a type after applying the - % type bindings. - % + % write_type_with_bindings writes out a type after applying the + % type bindings. + % :- pred write_type_with_bindings(mer_type::in, tvarset::in, tsubst::in, - io::di, io::uo) is det. + io::di, io::uo) is det. write_type_with_bindings(Type0, TypeVarSet, TypeBindings, !IO) :- - apply_rec_subst_to_type(TypeBindings, Type0, Type1), - strip_builtin_qualifiers_from_type(Type1, Type), - mercury_output_type(TypeVarSet, no, Type, !IO). + apply_rec_subst_to_type(TypeBindings, Type0, Type1), + strip_builtin_qualifiers_from_type(Type1, Type), + mercury_output_type(TypeVarSet, no, Type, !IO). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% write_args_type_assign_set([], _, !IO). write_args_type_assign_set([ArgTypeAssign | ArgTypeAssigns], VarSet, !IO) :- - ArgTypeAssign = args(TypeAssign, _ArgTypes, _Cnstrs), - io__write_string("\t", !IO), - write_type_assign(TypeAssign, VarSet, !IO), - io__write_string("\n", !IO), - write_args_type_assign_set(ArgTypeAssigns, VarSet, !IO). + ArgTypeAssign = args(TypeAssign, _ArgTypes, _Cnstrs), + io.write_string("\t", !IO), + write_type_assign(TypeAssign, VarSet, !IO), + io.write_string("\n", !IO), + write_args_type_assign_set(ArgTypeAssigns, VarSet, !IO). convert_nonempty_args_type_assign_set([], []). convert_nonempty_args_type_assign_set([ArgTypeAssign | ArgTypeAssigns], - [TypeAssign | TypeAssigns]) :- - ArgTypeAssign = args(_, Args, _), - ( - Args = [], - convert_args_type_assign(ArgTypeAssign, TypeAssign) - ; - Args = [_ | _], - % this should never happen, since the arguments should - % all have been processed at this point - unexpected(this_file, "convert_nonempty_args_type_assign_set") - ), - convert_nonempty_args_type_assign_set(ArgTypeAssigns, TypeAssigns). + [TypeAssign | TypeAssigns]) :- + ArgTypeAssign = args(_, Args, _), + ( + Args = [], + convert_args_type_assign(ArgTypeAssign, TypeAssign) + ; + Args = [_ | _], + % this should never happen, since the arguments should + % all have been processed at this point + unexpected(this_file, "convert_nonempty_args_type_assign_set") + ), + convert_nonempty_args_type_assign_set(ArgTypeAssigns, TypeAssigns). convert_args_type_assign_set([], []). convert_args_type_assign_set([X | Xs], [Y | Ys]) :- - convert_args_type_assign(X, Y), - convert_args_type_assign_set(Xs, Ys). + convert_args_type_assign(X, Y), + convert_args_type_assign_set(Xs, Ys). :- pred convert_args_type_assign(args_type_assign::in, type_assign::out) - is det. + is det. convert_args_type_assign(args(TypeAssign0, _, Constraints0), TypeAssign) :- - type_assign_get_typeclass_constraints(TypeAssign0, OldConstraints), - type_assign_get_type_bindings(TypeAssign0, Bindings), - apply_rec_subst_to_constraints(Bindings, Constraints0, Constraints), - merge_hlds_constraints(Constraints, OldConstraints, NewConstraints), - type_assign_set_typeclass_constraints(NewConstraints, - TypeAssign0, TypeAssign). + type_assign_get_typeclass_constraints(TypeAssign0, OldConstraints), + type_assign_get_type_bindings(TypeAssign0, Bindings), + apply_rec_subst_to_constraints(Bindings, Constraints0, Constraints), + merge_hlds_constraints(Constraints, OldConstraints, NewConstraints), + type_assign_set_typeclass_constraints(NewConstraints, + TypeAssign0, TypeAssign). get_caller_arg_assign(ArgsTypeAssign) = ArgsTypeAssign ^ caller_arg_assign. get_callee_arg_types(ArgsTypeAssign) = ArgsTypeAssign ^ callee_arg_types. diff --git a/compiler/typeclasses.m b/compiler/typeclasses.m index 0204d124a..d455abb0c 100644 --- a/compiler/typeclasses.m +++ b/compiler/typeclasses.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2005 The University of Melbourne. +% Copyright (C) 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -114,7 +114,7 @@ perform_context_reduction(OrigTypeAssignSet, !Info, !IO) :- module_info_get_superclass_table(ModuleInfo, SuperClassTable), module_info_get_instance_table(ModuleInfo, InstanceTable), typecheck_info_get_type_assign_set(!.Info, TypeAssignSet0), - list__filter_map( + list.filter_map( reduce_type_assign_context(ClassTable, SuperClassTable, InstanceTable), TypeAssignSet0, TypeAssignSet), ( @@ -131,7 +131,7 @@ perform_context_reduction(OrigTypeAssignSet, !Info, !IO) :- ^ redundant := multi_map.init, type_assign_set_typeclass_constraints(Constraints, TA0, TA) ), - list__map(DeleteConstraints, OrigTypeAssignSet, NewTypeAssignSet), + list.map(DeleteConstraints, OrigTypeAssignSet, NewTypeAssignSet), typecheck_info_set_type_assign_set(NewTypeAssignSet, !Info) ; typecheck_info_set_type_assign_set(TypeAssignSet, !Info) @@ -149,7 +149,7 @@ reduce_type_assign_context(ClassTable, SuperClassTable, InstanceTable, type_assign_get_constraint_proofs(!.TypeAssign, Proofs0), type_assign_get_constraint_map(!.TypeAssign, ConstraintMap0), - typeclasses__reduce_context_by_rule_application(ClassTable, + typeclasses.reduce_context_by_rule_application(ClassTable, InstanceTable, SuperClassTable, HeadTypeParams, Bindings0, Bindings, TVarSet0, TVarSet, Proofs0, Proofs, ConstraintMap0, ConstraintMap, Constraints0, Constraints), @@ -161,15 +161,15 @@ reduce_type_assign_context(ClassTable, SuperClassTable, InstanceTable, type_assign_set_constraint_proofs(Proofs, !TypeAssign), type_assign_set_constraint_map(ConstraintMap, !TypeAssign). -typeclasses__reduce_context_by_rule_application(ClassTable, InstanceTable, +reduce_context_by_rule_application(ClassTable, InstanceTable, SuperClassTable, HeadTypeParams, !Bindings, !TVarSet, !Proofs, !ConstraintMap, !Constraints) :- - typeclasses__reduce_context_by_rule_application_2(ClassTable, + reduce_context_by_rule_application_2(ClassTable, InstanceTable, SuperClassTable, HeadTypeParams, !Bindings, !TVarSet, !Proofs, !ConstraintMap, !Constraints, !.Constraints ^ unproven, _). -:- pred typeclasses__reduce_context_by_rule_application_2(class_table::in, +:- pred reduce_context_by_rule_application_2(class_table::in, instance_table::in, superclass_table::in, head_type_params::in, tsubst::in, tsubst::out, tvarset::in, tvarset::out, constraint_proof_map::in, constraint_proof_map::out, @@ -177,7 +177,7 @@ typeclasses__reduce_context_by_rule_application(ClassTable, InstanceTable, hlds_constraints::in, hlds_constraints::out, list(hlds_constraint)::in, list(hlds_constraint)::out) is det. -typeclasses__reduce_context_by_rule_application_2(ClassTable, InstanceTable, +reduce_context_by_rule_application_2(ClassTable, InstanceTable, SuperClassTable, HeadTypeParams, !Bindings, !TVarSet, !Proofs, !ConstraintMap, !Constraints, !Seen) :- apply_rec_subst_to_constraints(!.Bindings, !Constraints), @@ -201,7 +201,7 @@ typeclasses__reduce_context_by_rule_application_2(ClassTable, InstanceTable, apply_instance_rules(ClassTable, InstanceTable, !TVarSet, !Proofs, !ConstraintMap, !Seen, !Constraints, AppliedInstanceRule), % XXX Kind inference: we assume that all tvars have kind `star'. - map__init(KindMap), + map.init(KindMap), apply_class_rules(SuperClassTable, !.TVarSet, KindMap, !Proofs, !ConstraintMap, !Constraints, AppliedClassRule), ( @@ -213,7 +213,7 @@ typeclasses__reduce_context_by_rule_application_2(ClassTable, InstanceTable, % We have reached fixpoint. sort_and_merge_dups(!Constraints) ; - typeclasses__reduce_context_by_rule_application_2(ClassTable, + reduce_context_by_rule_application_2(ClassTable, InstanceTable, SuperClassTable, HeadTypeParams, !Bindings, !TVarSet, !Proofs, !ConstraintMap, !Constraints, !Seen) ). @@ -224,7 +224,7 @@ typeclasses__reduce_context_by_rule_application_2(ClassTable, InstanceTable, sort_and_merge_dups(!Constraints) :- % Should we also sort and merge the other fields? Unproven0 = !.Constraints ^ unproven, - list__sort(compare_hlds_constraints, Unproven0, Unproven1), + list.sort(compare_hlds_constraints, Unproven0, Unproven1), merge_adjacent_constraints(Unproven1, Unproven), !:Constraints = !.Constraints ^ unproven := Unproven. @@ -256,8 +256,8 @@ merge_adjacent_constraints_2(C0, [C1 | Cs], Constraints) :- merge_constraints(constraint(IdsA, Name, Types), constraint(IdsB, Name, Types), constraint(Ids, Name, Types)) :- - list__append(IdsA, IdsB, Ids0), - list__sort_and_remove_dups(Ids0, Ids). + list.append(IdsA, IdsB, Ids0), + list.sort_and_remove_dups(Ids0, Ids). :- pred apply_improvement_rules(class_table::in, instance_table::in, head_type_params::in, hlds_constraints::in, tvarset::in, tvarset::out, @@ -272,7 +272,7 @@ apply_improvement_rules(ClassTable, InstanceTable, HeadTypeParams, Constraints, % find_matching_instance_rule. do_instance_improvement(ClassTable, InstanceTable, HeadTypeParams, Constraints, !TVarSet, !Bindings, Changed2), - Changed = bool__or(Changed1, Changed2). + Changed = bool.or(Changed1, Changed2). :- pred do_class_improvement(class_table::in, head_type_params::in, hlds_constraints::in, tsubst::in, tsubst::out, bool::out) is det. @@ -281,8 +281,8 @@ do_class_improvement(ClassTable, HeadTypeParams, Constraints, !Bindings, Changed) :- Redundant = Constraints ^ redundant, Assumed = Constraints ^ assumed, - multi_map__keys(Redundant, ClassIds), - list__foldl2( + multi_map.keys(Redundant, ClassIds), + list.foldl2( do_class_improvement_2(ClassTable, HeadTypeParams, Redundant, Assumed), ClassIds, !Bindings, no, Changed). @@ -292,19 +292,19 @@ do_class_improvement(ClassTable, HeadTypeParams, Constraints, !Bindings, do_class_improvement_2(ClassTable, HeadTypeParams, RedundantConstraints, Assumed, ClassId, !Bindings, !Changed) :- - map__lookup(ClassTable, ClassId, ClassDefn), + map.lookup(ClassTable, ClassId, ClassDefn), FunDeps = ClassDefn ^ class_fundeps, - map__lookup(RedundantConstraints, ClassId, Constraints), + map.lookup(RedundantConstraints, ClassId, Constraints), do_class_improvement_by_pairs(Constraints, FunDeps, HeadTypeParams, !Bindings, !Changed), - list__filter(has_class_id(ClassId), Assumed, ThisClassAssumed), + list.filter(has_class_id(ClassId), Assumed, ThisClassAssumed), do_class_improvement_by_assumed(ThisClassAssumed, Constraints, FunDeps, HeadTypeParams, !Bindings, !Changed). :- pred has_class_id(class_id::in, hlds_constraint::in) is semidet. has_class_id(class_id(Name, Arity), constraint(_, Name, Args)) :- - list__length(Args, Arity). + list.length(Args, Arity). % Try to find an opportunity for improvement for each (unordered) % pair of constraints from the list. @@ -343,7 +343,7 @@ do_class_improvement_by_pairs_2(Constraint, [HeadConstraint | TailConstraints], do_class_improvement_by_assumed(Assumed, Constraints, FunDeps, HeadTypeParams, !Bindings, !Changed) :- - list__foldl2( + list.foldl2( do_class_improvement_by_assumed_2(Constraints, FunDeps, HeadTypeParams), Assumed, !Bindings, !Changed). @@ -408,8 +408,8 @@ do_class_improvement_fundep(ConstraintA, ConstraintB, FunDep, HeadTypeParams, do_instance_improvement(ClassTable, InstanceTable, HeadTypeParams, Constraints, !TVarSet, !Bindings, Changed) :- RedundantConstraints = Constraints ^ redundant, - map__keys(RedundantConstraints, ClassIds), - list__foldl3( + map.keys(RedundantConstraints, ClassIds), + list.foldl3( do_instance_improvement_2(ClassTable, InstanceTable, HeadTypeParams, RedundantConstraints), ClassIds, !TVarSet, !Bindings, no, Changed). @@ -421,11 +421,11 @@ do_instance_improvement(ClassTable, InstanceTable, HeadTypeParams, Constraints, do_instance_improvement_2(ClassTable, InstanceTable, HeadTypeParams, RedundantConstraints, ClassId, !TVarSet, !Bindings, !Changed) :- - map__lookup(ClassTable, ClassId, ClassDefn), + map.lookup(ClassTable, ClassId, ClassDefn), FunDeps = ClassDefn ^ class_fundeps, - map__lookup(InstanceTable, ClassId, InstanceDefns), - map__lookup(RedundantConstraints, ClassId, Constraints), - list__foldl3( + map.lookup(InstanceTable, ClassId, InstanceDefns), + map.lookup(RedundantConstraints, ClassId, Constraints), + list.foldl3( do_instance_improvement_3(Constraints, FunDeps, HeadTypeParams), InstanceDefns, !TVarSet, !Bindings, !Changed). @@ -441,7 +441,7 @@ do_instance_improvement_3(Constraints, FunDeps, HeadTypeParams, InstanceDefn, tvarset_merge_renaming(!.TVarSet, InstanceTVarSet, NewTVarSet, Renaming), apply_variable_renaming_to_type_list(Renaming, InstanceTypes0, InstanceTypes), - list__foldl2( + list.foldl2( do_instance_improvement_4(FunDeps, InstanceTypes, HeadTypeParams), Constraints, !Bindings, no, Changed0), ( @@ -458,7 +458,7 @@ do_instance_improvement_3(Constraints, FunDeps, HeadTypeParams, InstanceDefn, do_instance_improvement_4(FunDeps, InstanceTypes, HeadTypeParams, Constraint, !Bindings, !Changed) :- - list__foldl2( + list.foldl2( do_instance_improvement_fundep(Constraint, InstanceTypes, HeadTypeParams), FunDeps, !Bindings, !Changed). @@ -522,8 +522,8 @@ unify_on_elements(Elements, TypesA, TypesB, HeadTypeParams, !Bindings) :- subsumes_on_elements(Elements, TypesA, TypesB, Subst) :- RTypesA = restrict_list_elements(Elements, TypesA), RTypesB = restrict_list_elements(Elements, TypesB), - prog_type__vars_list(RTypesB, RTypesBVars), - map__init(Subst0), + prog_type.vars_list(RTypesB, RTypesBVars), + map.init(Subst0), type_unify_list(RTypesA, RTypesB, RTypesBVars, Subst0, Subst). :- pred eliminate_assumed_constraints(constraint_map::in, constraint_map::out, @@ -547,7 +547,7 @@ eliminate_assumed_constraints_2(AssumedCs, !ConstraintMap, [C | Cs], NewCs, Changed0), ( some [A] ( - list__member(A, AssumedCs), + list.member(A, AssumedCs), matching_constraints(A, C) ) -> @@ -587,8 +587,8 @@ apply_instance_rules_2(_, _, !TVarSet, !Proofs, !ConstraintMap, !Redundant, apply_instance_rules_2(ClassTable, InstanceTable, !TVarSet, !Proofs, !ConstraintMap, !Redundant, !Seen, [C | Cs], Constraints, Changed) :- C = constraint(_, ClassName, Types), - list__length(Types, Arity), - map__lookup(InstanceTable, class_id(ClassName, Arity), Instances), + list.length(Types, Arity), + map.lookup(InstanceTable, class_id(ClassName, Arity), Instances), InitialTVarSet = !.TVarSet, ( find_matching_instance_rule(Instances, C, !TVarSet, !Proofs, @@ -597,7 +597,7 @@ apply_instance_rules_2(ClassTable, InstanceTable, !TVarSet, !Proofs, update_constraint_map(C, !ConstraintMap), % Remove any constraints we've already seen. % This ensures we don't get into an infinite loop. - list__filter(matches_no_constraint(!.Seen), NewConstraints0, + list.filter(matches_no_constraint(!.Seen), NewConstraints0, NewConstraints), update_redundant_constraints(ClassTable, !.TVarSet, NewConstraints, !Redundant), @@ -612,15 +612,15 @@ apply_instance_rules_2(ClassTable, InstanceTable, !TVarSet, !Proofs, ), apply_instance_rules_2(ClassTable, InstanceTable, !TVarSet, !Proofs, !ConstraintMap, !Redundant, !Seen, Cs, TailConstraints, Changed2), - bool__or(Changed1, Changed2, Changed), - list__append(NewConstraints, TailConstraints, Constraints). + bool.or(Changed1, Changed2, Changed), + list.append(NewConstraints, TailConstraints, Constraints). :- pred matches_no_constraint(list(hlds_constraint)::in, hlds_constraint::in) is semidet. matches_no_constraint(Seen, Constraint) :- \+ ( some [S] ( - list__member(S, Seen), + list.member(S, Seen), matching_constraints(S, Constraint) )). @@ -671,7 +671,7 @@ find_matching_instance_rule_2([Instance | Instances], InstanceNum0, Constraint, NewProof = apply_instance(InstanceNum0), retrieve_prog_constraint(Constraint, ProgConstraint), - map__set(!.Proofs, ProgConstraint, NewProof, !:Proofs) + map.set(!.Proofs, ProgConstraint, NewProof, !:Proofs) ; InstanceNum = InstanceNum0 + 1, find_matching_instance_rule_2(Instances, InstanceNum, @@ -746,32 +746,32 @@ eliminate_constraint_by_class_rules(C, SubstC, SubClassSubst, KindMap, ParentConstraints, Proofs0, Proofs) :- % Make sure we aren't in a cycle in the superclass relation. - \+ list__member(C, ParentConstraints), + \+ list.member(C, ParentConstraints), C = constraint(SuperClassName, SuperClassTypes), - list__length(SuperClassTypes, SuperClassArity), + list.length(SuperClassTypes, SuperClassArity), SuperClassId = class_id(SuperClassName, SuperClassArity), - multi_map__search(SuperClassTable, SuperClassId, SubClasses), + multi_map.search(SuperClassTable, SuperClassId, SubClasses), % Convert all the subclass_details into prog_constraints by doing the % appropriate variable renaming and applying the type variable bindings. % If the unification of the type variables for a particular constraint % fails then that constraint is eliminated because it cannot contribute % to proving the constraint we are trying to prove. - list__filter_map( + list.filter_map( subclass_details_to_constraint(TVarSet, KindMap, SuperClassTypes), SubClasses, SubClassConstraints), ( % Do the first level of search. We search for an assumed constraint % which unifies with any of the subclass constraints. - varset__vars(TVarSet, XXXHeadTypeParams), + varset.vars(TVarSet, XXXHeadTypeParams), list.find_first_map( match_assumed_constraint(XXXHeadTypeParams, SubClassConstraints), AssumedConstraints, SubClass - SubClassSubst0) -> SubClassSubst = SubClassSubst0, apply_rec_subst_to_prog_constraint(SubClassSubst, C, SubstC), - map__set(Proofs0, SubstC, superclass(SubClass), Proofs) + map.set(Proofs0, SubstC, superclass(SubClass), Proofs) ; NewParentConstraints = [C | ParentConstraints], @@ -790,7 +790,7 @@ eliminate_constraint_by_class_rules(C, SubstC, SubClassSubst, find_first_map(SubClassSearch, SubClassConstraints, {NewSubClass, SubClassSubst, NewProofs}), apply_rec_subst_to_prog_constraint(SubClassSubst, C, SubstC), - map__set(NewProofs, SubstC, superclass(NewSubClass), Proofs) + map.set(NewProofs, SubstC, superclass(NewSubClass), Proofs) ). :- pred match_assumed_constraint(head_type_params::in, @@ -812,7 +812,7 @@ match_assumed_constraint_2(HeadTypeParams, AssumedConstraint, AssumedConstraintTypes), SubClassConstraint = constraint(AssumedConstraintClass, SubClassConstraintTypes), - map__init(EmptySub), + map.init(EmptySub), type_unify_list(SubClassConstraintTypes, AssumedConstraintTypes, HeadTypeParams, EmptySub, AssumedConstraintSub), retrieve_prog_constraint(AssumedConstraint, MatchingProgConstraint), @@ -838,7 +838,7 @@ subclass_details_to_constraint(TVarSet, KindMap0, SuperClassTypes, % Work out what the (renamed) vars from the typeclass declaration % are bound to here. - type_unify_list(SuperVars, SuperClassTypes, [], map__init, Bindings), + type_unify_list(SuperVars, SuperClassTypes, [], map.init, Bindings), SubID = class_id(SubName, _SubArity), apply_rec_subst_to_tvar_list(KindMap, Bindings, SubVars, SubClassTypes), @@ -877,12 +877,12 @@ subclass_details_to_constraint(TVarSet, KindMap0, SuperClassTypes, check_satisfiability(Constraints, HeadTypeParams) :- all [Constraint] ( - list__member(Constraint, Constraints) + list.member(Constraint, Constraints) => ( Constraint = constraint(_Ids, _ClassName, Types), type_list_contains_var(Types, TVar), - not list__member(TVar, HeadTypeParams) + not list.member(TVar, HeadTypeParams) ) ). diff --git a/compiler/unify_gen.m b/compiler/unify_gen.m index 5d34be85c..16afa8642 100644 --- a/compiler/unify_gen.m +++ b/compiler/unify_gen.m @@ -16,7 +16,7 @@ % %---------------------------------------------------------------------------% -:- module ll_backend__unify_gen. +:- module ll_backend.unify_gen. :- interface. :- import_module hlds.code_model. @@ -90,7 +90,7 @@ generate_unification(CodeModel, Uni, GoalInfo, Code, !CI) :- ), ( Uni = assign(Left, Right), - ( code_info__variable_is_forward_live(!.CI, Left) -> + ( code_info.variable_is_forward_live(!.CI, Left) -> generate_assignment(Left, Right, Code, !CI) ; Code = empty @@ -105,7 +105,7 @@ generate_unification(CodeModel, Uni, GoalInfo, Code, !CI) :- SubInfo = construct_sub_info(MaybeTakeAddr, MaybeSize) ), ( - ( code_info__variable_is_forward_live(!.CI, Var) + ( code_info.variable_is_forward_live(!.CI, Var) ; MaybeTakeAddr = yes(_) ) -> @@ -151,8 +151,8 @@ generate_unification(CodeModel, Uni, GoalInfo, Code, !CI) :- code_info::in, code_info::out) is det. generate_assignment(VarA, VarB, empty, !CI) :- - ( code_info__variable_is_forward_live(!.CI, VarA) -> - code_info__assign_var_to_var(VarA, VarB, !CI) + ( code_info.variable_is_forward_live(!.CI, VarA) -> + code_info.assign_var_to_var(VarA, VarB, !CI) ; % For free-free unifications, the mode analysis reports them as % assignment to the dead variable. For such unifications we of course @@ -171,10 +171,10 @@ generate_assignment(VarA, VarB, empty, !CI) :- code_info::in, code_info::out) is det. generate_test(VarA, VarB, Code, !CI) :- - code_info__produce_variable(VarA, CodeA, ValA, !CI), - code_info__produce_variable(VarB, CodeB, ValB, !CI), + code_info.produce_variable(VarA, CodeA, ValA, !CI), + code_info.produce_variable(VarB, CodeB, ValB, !CI), CodeAB = tree(CodeA, CodeB), - Type = code_info__variable_type(!.CI, VarA), + Type = code_info.variable_type(!.CI, VarA), ( Type = builtin(string) -> Op = str_eq ; Type = builtin(float) -> @@ -182,13 +182,13 @@ generate_test(VarA, VarB, Code, !CI) :- ; Op = eq ), - code_info__fail_if_rval_is_false(binop(Op, ValA, ValB), FailCode, !CI), + code_info.fail_if_rval_is_false(binop(Op, ValA, ValB), FailCode, !CI), Code = tree(CodeAB, FailCode). %---------------------------------------------------------------------------% generate_tag_test(Var, ConsId, Sense, ElseLab, Code, !CI) :- - code_info__produce_variable(Var, VarCode, Rval, !CI), + code_info.produce_variable(Var, VarCode, Rval, !CI), % As an optimization, for data types with exactly two alternatives, % one of which is a constant, we make sure that we test against the % constant (negating the result of the test, if needed), @@ -197,11 +197,11 @@ generate_tag_test(Var, ConsId, Sense, ElseLab, Code, !CI) :- ConsId = cons(_, Arity), Arity > 0 -> - Type = code_info__variable_type(!.CI, Var), - TypeDefn = code_info__lookup_type_defn(!.CI, Type), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + Type = code_info.variable_type(!.CI, Var), + TypeDefn = code_info.lookup_type_defn(!.CI, Type), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), ( ConsTable = TypeBody ^ du_type_cons_tag_values -> - map__to_assoc_list(ConsTable, ConsList), + map.to_assoc_list(ConsTable, ConsList), ( ConsList = [ConsId - _, OtherConsId - _], OtherConsId = cons(_, 0) @@ -221,31 +221,31 @@ generate_tag_test(Var, ConsId, Sense, ElseLab, Code, !CI) :- ; Reverse = no ), - VarName = code_info__variable_to_string(!.CI, Var), - ConsIdName = hlds_out__cons_id_to_string(ConsId), + VarName = code_info.variable_to_string(!.CI, Var), + ConsIdName = hlds_out.cons_id_to_string(ConsId), ( Reverse = no, - string__append_list(["checking that ", VarName, " has functor ", + string.append_list(["checking that ", VarName, " has functor ", ConsIdName], Comment), CommentCode = node([comment(Comment) - ""]), - Tag = code_info__cons_id_to_tag(!.CI, Var, ConsId), + Tag = code_info.cons_id_to_tag(!.CI, Var, ConsId), generate_tag_test_rval_2(Tag, Rval, TestRval) ; Reverse = yes(TestConsId), - string__append_list(["checking that ", VarName, " has functor ", + string.append_list(["checking that ", VarName, " has functor ", ConsIdName, " (inverted test)"], Comment), CommentCode = node([comment(Comment) - ""]), - Tag = code_info__cons_id_to_tag(!.CI, Var, TestConsId), + Tag = code_info.cons_id_to_tag(!.CI, Var, TestConsId), generate_tag_test_rval_2(Tag, Rval, NegTestRval), - code_util__neg_rval(NegTestRval, TestRval) + code_util.neg_rval(NegTestRval, TestRval) ), - code_info__get_next_label(ElseLab, !CI), + code_info.get_next_label(ElseLab, !CI), ( Sense = branch_on_success, TheRval = TestRval ; Sense = branch_on_failure, - code_util__neg_rval(TestRval, TheRval) + code_util.neg_rval(TestRval, TheRval) ), TestCode = node([if_val(TheRval, label(ElseLab)) - "tag test"]), Code = tree(VarCode, tree(CommentCode, TestCode)). @@ -256,8 +256,8 @@ generate_tag_test(Var, ConsId, Sense, ElseLab, Code, !CI) :- rval::out, code_tree::out, code_info::in, code_info::out) is det. generate_tag_test_rval(Var, ConsId, TestRval, Code, !CI) :- - code_info__produce_variable(Var, Code, Rval, !CI), - Tag = code_info__cons_id_to_tag(!.CI, Var, ConsId), + code_info.produce_variable(Var, Code, Rval, !CI), + Tag = code_info.cons_id_to_tag(!.CI, Var, ConsId), generate_tag_test_rval_2(Tag, Rval, TestRval). :- pred generate_tag_test_rval_2(cons_tag::in, rval::in, rval::out) @@ -331,7 +331,7 @@ generate_tag_test_rval_2(ConsTag, Rval, TestRval) :- unop(logical_not, EqualRA), InnerTestRval0) ), generate_tag_test_rval_2(ThisTag, Rval, MatchesThisTag), - TestRval = list__foldr(CheckReservedAddrs, ReservedAddrs, + TestRval = list.foldr(CheckReservedAddrs, ReservedAddrs, MatchesThisTag) ). @@ -361,7 +361,7 @@ generate_reserved_address(reserved_object(_, _, _)) = _ :- generate_construction(Var, ConsId, Args, Modes, TakeAddr, MaybeSize, GoalInfo, Code, !CI) :- - Tag = code_info__cons_id_to_tag(!.CI, Var, ConsId), + Tag = code_info.cons_id_to_tag(!.CI, Var, ConsId), generate_construction_2(Tag, Var, Args, Modes, TakeAddr, MaybeSize, GoalInfo, Code, !CI). @@ -374,15 +374,15 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, GoalInfo, Code, !CI) :- ( ConsTag = string_constant(String), - code_info__assign_const_to_var(Var, const(string_const(String)), !CI), + code_info.assign_const_to_var(Var, const(string_const(String)), !CI), Code = empty ; ConsTag = int_constant(Int), - code_info__assign_const_to_var(Var, const(int_const(Int)), !CI), + code_info.assign_const_to_var(Var, const(int_const(Int)), !CI), Code = empty ; ConsTag = float_constant(Float), - code_info__assign_const_to_var(Var, const(float_const(Float)), !CI), + code_info.assign_const_to_var(Var, const(float_const(Float)), !CI), Code = empty ; ConsTag = no_tag, @@ -392,7 +392,7 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, -> ( TakeAddr = [], - Type = code_info__variable_type(!.CI, Arg), + Type = code_info.variable_type(!.CI, Arg), generate_sub_unify(ref(Var), ref(Arg), Mode, Type, Code, !CI) ; TakeAddr = [_ | _], @@ -410,14 +410,14 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, Var, Args, Modes, TakeAddr, MaybeSize, GoalInfo, Code, !CI) ; ConsTag = unshared_tag(Ptag), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), var_types(!.CI, Args, ArgTypes), generate_cons_args(Args, ArgTypes, Modes, 0, 1, TakeAddr, ModuleInfo, Rvals, FieldAddrs), construct_cell(Var, Ptag, Rvals, MaybeSize, FieldAddrs, Code, !CI) ; ConsTag = shared_remote_tag(Ptag, Sectag), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), var_types(!.CI, Args, ArgTypes), generate_cons_args(Args, ArgTypes, Modes, 1, 1, TakeAddr, ModuleInfo, Rvals0, FieldAddrs), @@ -426,7 +426,7 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, construct_cell(Var, Ptag, Rvals, MaybeSize, FieldAddrs, Code, !CI) ; ConsTag = shared_local_tag(Bits1, Num1), - code_info__assign_const_to_var(Var, + code_info.assign_const_to_var(Var, mkword(Bits1, unop(mkbody, const(int_const(Num1)))), !CI), Code = empty ; @@ -435,7 +435,7 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, "generate_construction_2: type_ctor_info constant has args"), RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, TypeArity), DataAddr = rtti_addr(ctor_rtti_id(RttiTypeCtor, type_ctor_info)), - code_info__assign_const_to_var(Var, + code_info.assign_const_to_var(Var, const(data_addr_const(DataAddr, no)), !CI), Code = empty ; @@ -443,7 +443,7 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, expect(unify(Args, []), this_file, "generate_construction_2: base_typeclass_info constant has args"), TCName = generate_class_name(ClassId), - code_info__assign_const_to_var(Var, + code_info.assign_const_to_var(Var, const(data_addr_const(rtti_addr(tc_rtti_id(TCName, base_typeclass_info(ModuleName, Instance))), no)), !CI), Code = empty @@ -451,18 +451,18 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, ConsTag = tabling_pointer_constant(PredId, ProcId), expect(unify(Args, []), this_file, "generate_construction_2: tabling_pointer constant has args"), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), ProcLabel = make_proc_label(ModuleInfo, PredId, ProcId), module_info_get_name(ModuleInfo, ModuleName), DataAddr = data_addr(ModuleName, tabling_pointer(ProcLabel)), - code_info__assign_const_to_var(Var, + code_info.assign_const_to_var(Var, const(data_addr_const(DataAddr, no)), !CI), Code = empty ; ConsTag = deep_profiling_proc_layout_tag(PredId, ProcId), expect(unify(Args, []), this_file, "generate_construction_2: deep_profiling_proc_static has args"), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), RttiProcLabel = make_rtti_proc_label(ModuleInfo, PredId, ProcId), Origin = RttiProcLabel ^ pred_info_origin, ( Origin = special_pred(_) -> @@ -472,25 +472,24 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, ), ProcKind = proc_layout_proc_id(UserOrUCI), DataAddr = layout_addr(proc_layout(RttiProcLabel, ProcKind)), - code_info__assign_const_to_var(Var, + code_info.assign_const_to_var(Var, const(data_addr_const(DataAddr, no)), !CI), Code = empty ; ConsTag = table_io_decl_tag(PredId, ProcId), expect(unify(Args, []), this_file, "generate_construction_2: table_io_decl has args"), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), RttiProcLabel = make_rtti_proc_label(ModuleInfo, PredId, ProcId), DataAddr = layout_addr(table_io_decl(RttiProcLabel)), - code_info__assign_const_to_var(Var, + code_info.assign_const_to_var(Var, const(data_addr_const(DataAddr, no)), !CI), Code = empty ; ConsTag = reserved_address(RA), expect(unify(Args, []), this_file, "generate_construction_2: reserved_address constant has args"), - code_info__assign_const_to_var(Var, generate_reserved_address(RA), - !CI), + code_info.assign_const_to_var(Var, generate_reserved_address(RA), !CI), Code = empty ; ConsTag = shared_with_reserved_addresses(_RAs, ThisTag), @@ -517,11 +516,11 @@ generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize, code_info::in, code_info::out) is det. generate_closure(PredId, ProcId, EvalMethod, Var, Args, GoalInfo, Code, !CI) :- - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), module_info_preds(ModuleInfo, Preds), - map__lookup(Preds, PredId, PredInfo), + map.lookup(Preds, PredId, PredInfo), pred_info_procedures(PredInfo, Procs), - map__lookup(Procs, ProcId, ProcInfo), + map.lookup(Procs, ProcId, ProcInfo), % We handle currying of a higher-order pred variable as a special case. % We recognize @@ -570,30 +569,30 @@ generate_closure(PredId, ProcId, EvalMethod, Var, Args, GoalInfo, Code, !CI) :- % This optimization distorts deep profiles, so don't perform it % in deep profiling grades. module_info_get_globals(ModuleInfo, Globals), - globals__lookup_bool_option(Globals, profile_deep, Deep), + globals.lookup_bool_option(Globals, profile_deep, Deep), Deep = no -> ( CallArgs = [], % If there are no new arguments, we can just use the old closure. - code_info__assign_var_to_var(Var, CallPred, !CI), + code_info.assign_var_to_var(Var, CallPred, !CI), Code = empty ; CallArgs = [_ | _], - code_info__get_next_label(LoopStart, !CI), - code_info__get_next_label(LoopTest, !CI), - code_info__acquire_reg(r, LoopCounter, !CI), - code_info__acquire_reg(r, NumOldArgs, !CI), - code_info__acquire_reg(r, NewClosure, !CI), + code_info.get_next_label(LoopStart, !CI), + code_info.get_next_label(LoopTest, !CI), + code_info.acquire_reg(r, LoopCounter, !CI), + code_info.acquire_reg(r, NumOldArgs, !CI), + code_info.acquire_reg(r, NewClosure, !CI), Zero = const(int_const(0)), One = const(int_const(1)), Two = const(int_const(2)), Three = const(int_const(3)), - list__length(CallArgs, NumNewArgs), + list.length(CallArgs, NumNewArgs), NumNewArgs_Rval = const(int_const(NumNewArgs)), NumNewArgsPlusThree = NumNewArgs + 3, NumNewArgsPlusThree_Rval = const(int_const(NumNewArgsPlusThree)), - code_info__produce_variable(CallPred, OldClosureCode, + code_info.produce_variable(CallPred, OldClosureCode, OldClosure, !CI), NewClosureCode = node([ comment("build new closure from old closure") - "", @@ -635,42 +634,42 @@ generate_closure(PredId, ProcId, EvalMethod, Var, Args, GoalInfo, Code, !CI) :- ]), generate_extra_closure_args(CallArgs, LoopCounter, NewClosure, ExtraArgsCode, !CI), - code_info__release_reg(LoopCounter, !CI), - code_info__release_reg(NumOldArgs, !CI), - code_info__release_reg(NewClosure, !CI), - code_info__assign_lval_to_var(Var, NewClosure, AssignCode, !CI), + code_info.release_reg(LoopCounter, !CI), + code_info.release_reg(NumOldArgs, !CI), + code_info.release_reg(NewClosure, !CI), + code_info.assign_lval_to_var(Var, NewClosure, AssignCode, !CI), Code = tree_list([OldClosureCode, NewClosureCode, ExtraArgsCode, AssignCode]) ) ; - CodeAddr = code_info__make_entry_label(!.CI, ModuleInfo, + CodeAddr = code_info.make_entry_label(!.CI, ModuleInfo, PredId, ProcId, no), - code_util__extract_proc_label_from_code_addr(CodeAddr, ProcLabel), + code_util.extract_proc_label_from_code_addr(CodeAddr, ProcLabel), CallArgsRval = const(code_addr_const(CodeAddr)), - continuation_info__generate_closure_layout( ModuleInfo, PredId, ProcId, + continuation_info.generate_closure_layout( ModuleInfo, PredId, ProcId, ClosureInfo), module_info_get_name(ModuleInfo, ModuleName), goal_info_get_context(GoalInfo, Context), - term__context_file(Context, FileName), - term__context_line(Context, LineNumber), + term.context_file(Context, FileName), + term.context_line(Context, LineNumber), goal_info_get_goal_path(GoalInfo, GoalPath), goal_path_to_string(GoalPath, GoalPathStr), - code_info__get_cur_proc_label(!.CI, CallerProcLabel), - code_info__get_next_closure_seq_no(SeqNo, !CI), - code_info__get_static_cell_info(!.CI, StaticCellInfo0), + code_info.get_cur_proc_label(!.CI, CallerProcLabel), + code_info.get_next_closure_seq_no(SeqNo, !CI), + code_info.get_static_cell_info(!.CI, StaticCellInfo0), hlds.hlds_pred.pred_info_get_origin(PredInfo, PredOrigin), - stack_layout__construct_closure_layout(CallerProcLabel, + stack_layout.construct_closure_layout(CallerProcLabel, SeqNo, ClosureInfo, ProcLabel, ModuleName, FileName, LineNumber, PredOrigin, GoalPathStr, StaticCellInfo0, StaticCellInfo, ClosureLayoutRvalsTypes, Data), - code_info__set_static_cell_info(StaticCellInfo, !CI), - code_info__add_closure_layout(Data, !CI), + code_info.set_static_cell_info(StaticCellInfo, !CI), + code_info.add_closure_layout(Data, !CI), % For now, closures always have zero size, and the size slot % is never looked at. - code_info__add_static_cell(ClosureLayoutRvalsTypes, ClosureDataAddr, + code_info.add_static_cell(ClosureLayoutRvalsTypes, ClosureDataAddr, !CI), ClosureLayoutRval = const(data_addr_const(ClosureDataAddr, no)), - list__length(Args, NumArgs), + list.length(Args, NumArgs), proc_info_arg_info(ProcInfo, ArgInfo), generate_pred_args(Args, ArgInfo, PredArgs), Vector = [ @@ -679,7 +678,7 @@ generate_closure(PredId, ProcId, EvalMethod, Var, Args, GoalInfo, Code, !CI) :- yes(const(int_const(NumArgs))) | PredArgs ], - code_info__assign_cell_to_var(Var, no, 0, Vector, no, "closure", + code_info.assign_cell_to_var(Var, no, 0, Vector, no, "closure", Code, !CI) ). @@ -689,7 +688,7 @@ generate_closure(PredId, ProcId, EvalMethod, Var, Args, GoalInfo, Code, !CI) :- generate_extra_closure_args([], _, _, empty, !CI). generate_extra_closure_args([Var | Vars], LoopCounter, NewClosure, Code, !CI) :- - code_info__produce_variable(Var, Code0, Value, !CI), + code_info.produce_variable(Var, Code0, Value, !CI), One = const(int_const(1)), Code1 = node([ assign(field(yes(0), lval(NewClosure), lval(LoopCounter)), Value) @@ -735,8 +734,7 @@ generate_cons_args(Vars, Types, Modes, FirstOffset, FirstArgNum, TakeAddr, % Create a list of maybe(rval) for the arguments for a construction % unification. For each argument which is input to the construction % unification, we produce `yes(var(Var))', but if the argument is free, - % we just produce `no', meaning don't generate an assignment to that - % field. + % we just produce `no', meaning don't generate an assignment to that field. % :- pred generate_cons_args_2(list(prog_var)::in, list(mer_type)::in, list(uni_mode)::in, int::in, int::in, list(int)::in, module_info::in, @@ -772,7 +770,7 @@ generate_cons_args_2([Var | Vars], [Type | Types], [UniMode | UniModes], code_info::in, code_info::out) is det. construct_cell(Var, Ptag, MaybeRvals, MaybeSize, FieldAddrs, Code, !CI) :- - VarType = code_info__variable_type(!.CI, Var), + VarType = code_info.variable_type(!.CI, Var), var_type_msg(VarType, VarTypeMsg), % If we're doing accurate GC, then for types which hold RTTI that % will be traversed by the collector at GC-time, we need to allocate @@ -781,8 +779,8 @@ construct_cell(Var, Ptag, MaybeRvals, MaybeSize, FieldAddrs, Code, !CI) :- % in the "from" space, but this can't be done for objects which will be % referenced during the garbage collection process. ( - code_info__get_globals(!.CI, Globals), - globals__get_gc_method(Globals, GCMethod), + code_info.get_globals(!.CI, Globals), + globals.get_gc_method(Globals, GCMethod), GCMethod = accurate, is_introduced_type_info_type(VarType) -> @@ -790,7 +788,7 @@ construct_cell(Var, Ptag, MaybeRvals, MaybeSize, FieldAddrs, Code, !CI) :- ; ReserveWordAtStart = no ), - code_info__assign_cell_to_var(Var, ReserveWordAtStart, Ptag, MaybeRvals, + code_info.assign_cell_to_var(Var, ReserveWordAtStart, Ptag, MaybeRvals, MaybeSize, VarTypeMsg, CellCode, !CI), ( FieldAddrs = [], @@ -824,9 +822,9 @@ generate_field_take_address_assigns([FieldNum - Var | FieldAddrs], is det. var_types(CI, Vars, Types) :- - code_info__get_proc_info(CI, ProcInfo), + code_info.get_proc_info(CI, ProcInfo), proc_info_vartypes(ProcInfo, VarTypes), - map__apply_to_list(Vars, VarTypes, Types). + map.apply_to_list(Vars, VarTypes, Types). %---------------------------------------------------------------------------% @@ -859,15 +857,14 @@ make_fields_and_argvars([Var | Vars], Rval, Field0, TagNum, code_info::in, code_info::out) is det. generate_det_deconstruction(Var, Cons, Args, Modes, Code, !CI) :- - Tag = code_info__cons_id_to_tag(!.CI, Var, Cons), + Tag = code_info.cons_id_to_tag(!.CI, Var, Cons), generate_det_deconstruction_2(Var, Cons, Args, Modes, Tag, Code, !CI). :- pred generate_det_deconstruction_2(prog_var::in, cons_id::in, list(prog_var)::in, list(uni_mode)::in, cons_tag::in, code_tree::out, code_info::in, code_info::out) is det. -generate_det_deconstruction_2(Var, Cons, Args, Modes, Tag, Code, - !CI) :- +generate_det_deconstruction_2(Var, Cons, Args, Modes, Tag, Code, !CI) :- % For constants, if the deconstruction is det, then we already know % the value of the constant, so Code = empty. ( @@ -903,8 +900,8 @@ generate_det_deconstruction_2(Var, Cons, Args, Modes, Tag, Code, Args = [Arg], Modes = [Mode] -> - VarType = code_info__variable_type(!.CI, Var), - code_info__get_module_info(!.CI, ModuleInfo), + VarType = code_info.variable_type(!.CI, Var), + code_info.get_module_info(!.CI, ModuleInfo), ( is_dummy_argument_type(ModuleInfo, VarType) -> % We must handle this case specially. If we didn't, the % generated code would copy the reference to the Var's @@ -912,16 +909,16 @@ generate_det_deconstruction_2(Var, Cons, Args, Modes, Tag, Code, % for negative N, to be the location of Arg, and since Arg % may not be a dummy type, it would actually use that location. % This can happen in the unify/compare routines for e.g. - % io__state. + % io.state. ( variable_is_forward_live(!.CI, Arg) -> - code_info__assign_const_to_var(Arg, const(int_const(0)), + code_info.assign_const_to_var(Arg, const(int_const(0)), !CI) ; true ), Code = empty ; - ArgType = code_info__variable_type(!.CI, Arg), + ArgType = code_info.variable_type(!.CI, Arg), generate_sub_unify(ref(Var), ref(Arg), Mode, ArgType, Code, !CI) ) @@ -973,9 +970,9 @@ generate_det_deconstruction_2(Var, Cons, Args, Modes, Tag, Code, generate_semi_deconstruction(Var, Tag, Args, Modes, Code, !CI) :- generate_tag_test(Var, Tag, branch_on_success, SuccLab, TagTestCode, !CI), - code_info__remember_position(!.CI, AfterUnify), - code_info__generate_failure(FailCode, !CI), - code_info__reset_to_position(AfterUnify, !CI), + code_info.remember_position(!.CI, AfterUnify), + code_info.generate_failure(FailCode, !CI), + code_info.reset_to_position(AfterUnify, !CI), generate_det_deconstruction(Var, Tag, Args, Modes, DeconsCode, !CI), SuccessLabelCode = node([label(SuccLab) - ""]), Code = tree_list([TagTestCode, FailCode, SuccessLabelCode, DeconsCode]). @@ -1015,7 +1012,7 @@ generate_unify_args_2([L | Ls], [R | Rs], [M | Ms], [T | Ts], Code, !CI) :- generate_sub_unify(L, R, Mode, Type, Code, !CI) :- Mode = ((LI - RI) -> (LF - RF)), - code_info__get_module_info(!.CI, ModuleInfo), + code_info.get_module_info(!.CI, ModuleInfo), mode_to_arg_mode(ModuleInfo, (LI -> LF), Type, LeftMode), mode_to_arg_mode(ModuleInfo, (RI -> RF), Type, RightMode), ( @@ -1066,21 +1063,21 @@ generate_sub_assign(Left, Right, Code, !CI) :- Right = ref(Var), % Assignment from a variable to an lvalue - cannot cache % so generate immediately. - code_info__produce_variable(Var, SourceCode, Source, !CI), - code_info__materialize_vars_in_lval(Lval0, Lval, MaterializeCode, !CI), + code_info.produce_variable(Var, SourceCode, Source, !CI), + code_info.materialize_vars_in_lval(Lval0, Lval, MaterializeCode, !CI), CopyCode = node([assign(Lval, Source) - "Copy value"]), Code = tree_list([SourceCode, MaterializeCode, CopyCode]) ; Left = ref(Lvar), - ( code_info__variable_is_forward_live(!.CI, Lvar) -> + ( code_info.variable_is_forward_live(!.CI, Lvar) -> ( Right = lval(Lval), % Assignment of a value to a variable, generate now. - code_info__assign_lval_to_var(Lvar, Lval, Code, !CI) + code_info.assign_lval_to_var(Lvar, Lval, Code, !CI) ; Right = ref(Rvar), % Assignment of a variable to a variable, so cache it. - code_info__assign_var_to_var(Lvar, Rvar, !CI), + code_info.assign_var_to_var(Lvar, Rvar, !CI), Code = empty ) ; @@ -1095,9 +1092,9 @@ generate_sub_assign(Left, Right, Code, !CI) :- var_type_msg(Type, Msg) :- ( type_to_ctor_and_args(Type, TypeCtor, _) -> TypeCtor = TypeSym - TypeArity, - mdbcomp__prim_data__sym_name_to_string(TypeSym, TypeSymStr), - string__int_to_string(TypeArity, TypeArityStr), - string__append_list([TypeSymStr, "/", TypeArityStr], Msg) + mdbcomp.prim_data.sym_name_to_string(TypeSym, TypeSymStr), + string.int_to_string(TypeArity, TypeArityStr), + string.append_list([TypeSymStr, "/", TypeArityStr], Msg) ; unexpected(this_file, "type is still a type variable in var_type_msg") ). diff --git a/compiler/unify_proc.m b/compiler/unify_proc.m index 1cc12a3f1..94a7d2789 100644 --- a/compiler/unify_proc.m +++ b/compiler/unify_proc.m @@ -44,7 +44,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__unify_proc. +:- module check_hlds.unify_proc. :- interface. :- import_module check_hlds.mode_info. @@ -195,8 +195,8 @@ %-----------------------------------------------------------------------------% init_requests(Requests) :- - map__init(UnifyReqMap), - queue__init(ReqQueue), + map.init(UnifyReqMap), + queue.init(ReqQueue), Requests = proc_requests(UnifyReqMap, ReqQueue). %-----------------------------------------------------------------------------% @@ -242,19 +242,19 @@ search_mode_num(ModuleInfo, TypeCtor, UniMode, Determinism, ProcId) :- inst_is_ground_or_any(ModuleInfo, XInitial), inst_is_ground_or_any(ModuleInfo, YInitial) -> - hlds_pred__in_in_unification_proc_id(ProcId) + hlds_pred.in_in_unification_proc_id(ProcId) ; XInitial = not_reached -> - hlds_pred__in_in_unification_proc_id(ProcId) + hlds_pred.in_in_unification_proc_id(ProcId) ; YInitial = not_reached -> - hlds_pred__in_in_unification_proc_id(ProcId) + hlds_pred.in_in_unification_proc_id(ProcId) ; module_info_get_proc_requests(ModuleInfo, Requests), get_unify_req_map(Requests, UnifyReqMap), - map__search(UnifyReqMap, TypeCtor - UniMode, ProcId) + map.search(UnifyReqMap, TypeCtor - UniMode, ProcId) ). %-----------------------------------------------------------------------------% @@ -266,7 +266,7 @@ request_unify(UnifyId, InstVarSet, Determinism, Context, !ModuleInfo) :- module_info_get_maybe_recompilation_info(!.ModuleInfo, MaybeRecompInfo0), ( MaybeRecompInfo0 = yes(RecompInfo0), - recompilation__record_used_item(type_body_item, TypeCtor, TypeCtor, + recompilation.record_used_item(type_body_item, TypeCtor, TypeCtor, RecompInfo0, RecompInfo), module_info_set_maybe_recompilation_info(yes(RecompInfo), !ModuleInfo) ; @@ -280,8 +280,8 @@ request_unify(UnifyId, InstVarSet, Determinism, Context, !ModuleInfo) :- search_mode_num(!.ModuleInfo, TypeCtor, UnifyMode, Determinism, _) ; module_info_get_type_table(!.ModuleInfo, TypeTable), - map__search(TypeTable, TypeCtor, TypeDefn), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), + map.search(TypeTable, TypeCtor, TypeDefn), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), ( TypeCtor = TypeName - _TypeArity, TypeName = qualified(TypeModuleName, _), @@ -298,7 +298,7 @@ request_unify(UnifyId, InstVarSet, Determinism, Context, !ModuleInfo) :- % Lookup the pred_id for the unification procedure that we are % going to generate. module_info_get_special_pred_map(!.ModuleInfo, SpecialPredMap), - ( map__search(SpecialPredMap, spec_pred_unify - TypeCtor, PredId0) -> + ( map.search(SpecialPredMap, spec_pred_unify - TypeCtor, PredId0) -> PredId = PredId0 ; % We generate unification predicates for most imported types @@ -313,8 +313,8 @@ request_unify(UnifyId, InstVarSet, Determinism, Context, !ModuleInfo) :- % For polymorphic types, add extra modes for the type_infos. in_mode(InMode), TypeCtor = _ - TypeArity, - list__duplicate(TypeArity, InMode, TypeInfoModes), - list__append(TypeInfoModes, ArgModes0, ArgModes), + list.duplicate(TypeArity, InMode, TypeInfoModes), + list.append(TypeInfoModes, ArgModes0, ArgModes), ArgLives = no, % XXX ArgLives should be part of the UnifyId @@ -324,7 +324,7 @@ request_unify(UnifyId, InstVarSet, Determinism, Context, !ModuleInfo) :- % Save the proc_id for this unify_proc_id. module_info_get_proc_requests(!.ModuleInfo, Requests0), get_unify_req_map(Requests0, UnifyReqMap0), - map__set(UnifyReqMap0, UnifyId, ProcId, UnifyReqMap), + map.set(UnifyReqMap0, UnifyId, ProcId, UnifyReqMap), set_unify_req_map(UnifyReqMap, Requests0, Requests), module_info_set_proc_requests(Requests, !ModuleInfo) ). @@ -333,8 +333,8 @@ request_proc(PredId, ArgModes, InstVarSet, ArgLives, MaybeDet, Context, ProcId, !ModuleInfo) :- % Create a new proc_info for this procedure. module_info_preds(!.ModuleInfo, Preds0), - map__lookup(Preds0, PredId, PredInfo0), - list__length(ArgModes, Arity), + map.lookup(Preds0, PredId, PredInfo0), + list.length(ArgModes, Arity), DeclaredArgModes = no, add_new_proc(InstVarSet, Arity, ArgModes, DeclaredArgModes, ArgLives, MaybeDet, Context, address_is_not_taken, PredInfo0, PredInfo1, ProcId), @@ -343,7 +343,7 @@ request_proc(PredId, ArgModes, InstVarSet, ArgLives, MaybeDet, Context, ProcId, % and mark the procedure as one that cannot be processed yet. pred_info_procedures(PredInfo1, Procs1), pred_info_clauses_info(PredInfo1, ClausesInfo), - map__lookup(Procs1, ProcId, ProcInfo0), + map.lookup(Procs1, ProcId, ProcInfo0), proc_info_set_can_process(no, ProcInfo0, ProcInfo1), copy_clauses_to_proc(ProcId, ClausesInfo, ProcInfo1, ProcInfo2), @@ -351,15 +351,15 @@ request_proc(PredId, ArgModes, InstVarSet, ArgLives, MaybeDet, Context, ProcId, proc_info_goal(ProcInfo2, Goal0), set_goal_contexts(Context, Goal0, Goal), proc_info_set_goal(Goal, ProcInfo2, ProcInfo), - map__det_update(Procs1, ProcId, ProcInfo, Procs2), + map.det_update(Procs1, ProcId, ProcInfo, Procs2), pred_info_set_procedures(Procs2, PredInfo1, PredInfo2), - map__det_update(Preds0, PredId, PredInfo2, Preds2), + map.det_update(Preds0, PredId, PredInfo2, Preds2), module_info_set_preds(Preds2, !ModuleInfo), % Insert the pred_proc_id into the request queue. module_info_get_proc_requests(!.ModuleInfo, Requests0), get_req_queue(Requests0, ReqQueue0), - queue__put(ReqQueue0, proc(PredId, ProcId), ReqQueue), + queue.put(ReqQueue0, proc(PredId, ProcId), ReqQueue), set_req_queue(ReqQueue, Requests0, Requests), module_info_set_proc_requests(Requests, !ModuleInfo). @@ -372,7 +372,7 @@ modecheck_queued_procs(HowToCheckGoal, !OldPredTable, !ModuleInfo, Changed, module_info_get_proc_requests(!.ModuleInfo, Requests0), get_req_queue(Requests0, RequestQueue0), ( - queue__get(RequestQueue0, PredProcId, RequestQueue1) + queue.get(RequestQueue0, PredProcId, RequestQueue1) -> set_req_queue(RequestQueue1, Requests0, Requests1), module_info_set_proc_requests(Requests1, !ModuleInfo), @@ -385,7 +385,7 @@ modecheck_queued_procs(HowToCheckGoal, !OldPredTable, !ModuleInfo, Changed, % PredProcId = proc(PredId, _ProcId), module_info_predids(!.ModuleInfo, ValidPredIds), - ( list__member(PredId, ValidPredIds) -> + ( list.member(PredId, ValidPredIds) -> queued_proc_progress_message(PredProcId, HowToCheckGoal, !.ModuleInfo, !IO), modecheck_queued_proc(HowToCheckGoal, PredProcId, @@ -395,7 +395,7 @@ modecheck_queued_procs(HowToCheckGoal, !OldPredTable, !ModuleInfo, Changed, ), modecheck_queued_procs(HowToCheckGoal, !OldPredTable, !ModuleInfo, Changed2, !IO), - bool__or(Changed1, Changed2, Changed) + bool.or(Changed1, Changed2, Changed) ; Changed = no ). @@ -404,27 +404,28 @@ modecheck_queued_procs(HowToCheckGoal, !OldPredTable, !ModuleInfo, Changed, module_info::in, io::di, io::uo) is det. queued_proc_progress_message(PredProcId, HowToCheckGoal, ModuleInfo, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), - ( VeryVerbose = yes -> + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + ( + VeryVerbose = yes, ( HowToCheckGoal = check_unique_modes -> - io__write_string("% Analyzing modes, determinism, " ++ + io.write_string("% Analyzing modes, determinism, " ++ "and unique-modes for\n% ", !IO) ; - io__write_string("% Mode-analyzing ", !IO) + io.write_string("% Mode-analyzing ", !IO) ), PredProcId = proc(PredId, ProcId), - hlds_out__write_pred_proc_id(ModuleInfo, PredId, ProcId, !IO), - io__write_string("\n", !IO) + hlds_out.write_pred_proc_id(ModuleInfo, PredId, ProcId, !IO), + io.write_string("\n", !IO) % /***** % mode_list_get_initial_insts(Modes, ModuleInfo1, % InitialInsts), -% io__write_string("% Initial insts: `", !IO), -% varset__init(InstVarSet), +% io.write_string("% Initial insts: `", !IO), +% varset.init(InstVarSet), % mercury_output_inst_list(InitialInsts, InstVarSet, !IO), -% io__write_string("'\n", !IO) +% io.write_string("'\n", !IO) % *****/ ; - true + VeryVerbose = no ). :- pred modecheck_queued_proc(how_to_check_goal::in, pred_proc_id::in, @@ -436,19 +437,19 @@ modecheck_queued_proc(HowToCheckGoal, PredProcId, !OldPredTable, !ModuleInfo, % Mark the procedure as ready to be processed. PredProcId = proc(PredId, ProcId), module_info_preds(!.ModuleInfo, Preds0), - map__lookup(Preds0, PredId, PredInfo0), + map.lookup(Preds0, PredId, PredInfo0), pred_info_procedures(PredInfo0, Procs0), - map__lookup(Procs0, ProcId, ProcInfo0), + map.lookup(Procs0, ProcId, ProcInfo0), proc_info_set_can_process(yes, ProcInfo0, ProcInfo1), - map__det_update(Procs0, ProcId, ProcInfo1, Procs1), + map.det_update(Procs0, ProcId, ProcInfo1, Procs1), pred_info_set_procedures(Procs1, PredInfo0, PredInfo1), - map__det_update(Preds0, PredId, PredInfo1, Preds1), + map.det_update(Preds0, PredId, PredInfo1, Preds1), module_info_set_preds(Preds1, !ModuleInfo), % Modecheck the procedure. modecheck_proc(ProcId, PredId, !ModuleInfo, NumErrors, Changed1, !IO), ( NumErrors \= 0 -> - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), module_info_remove_predid(PredId, !ModuleInfo), Changed = Changed1 ; @@ -457,9 +458,9 @@ modecheck_queued_proc(HowToCheckGoal, PredProcId, !OldPredTable, !ModuleInfo, detect_cse_in_proc(ProcId, PredId, !ModuleInfo, !IO), determinism_check_proc(ProcId, PredId, !ModuleInfo, !IO), save_proc_info(ProcId, PredId, !.ModuleInfo, !OldPredTable), - unique_modes__check_proc(ProcId, PredId, !ModuleInfo, Changed2, + unique_modes.check_proc(ProcId, PredId, !ModuleInfo, Changed2, !IO), - bool__or(Changed1, Changed2, Changed) + bool.or(Changed1, Changed2, Changed) ; Changed = Changed1 ) @@ -474,11 +475,11 @@ modecheck_queued_proc(HowToCheckGoal, PredProcId, !OldPredTable, !ModuleInfo, save_proc_info(ProcId, PredId, ModuleInfo, !OldPredTable) :- module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _PredInfo, ProcInfo), - map__lookup(!.OldPredTable, PredId, OldPredInfo0), + map.lookup(!.OldPredTable, PredId, OldPredInfo0), pred_info_procedures(OldPredInfo0, OldProcTable0), - map__set(OldProcTable0, ProcId, ProcInfo, OldProcTable), + map.set(OldProcTable0, ProcId, ProcInfo, OldProcTable), pred_info_set_procedures(OldProcTable, OldPredInfo0, OldPredInfo), - map__det_update(!.OldPredTable, PredId, OldPredInfo, !:OldPredTable). + map.det_update(!.OldPredTable, PredId, OldPredInfo, !:OldPredTable). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -489,9 +490,9 @@ add_lazily_generated_unify_pred(TypeCtor, PredId, !ModuleInfo) :- % Build a hlds_type_body for the tuple constructor, which will % be used by generate_clause_info. - varset__init(TVarSet0), - varset__new_vars(TVarSet0, TupleArity, TupleArgTVars, TVarSet), - prog_type.var_list_to_type_list(map__init, TupleArgTVars, + varset.init(TVarSet0), + varset.new_vars(TVarSet0, TupleArity, TupleArgTVars, TVarSet), + prog_type.var_list_to_type_list(map.init, TupleArgTVars, TupleArgTypes), % Tuple constructors can't be existentially quantified. @@ -499,13 +500,13 @@ add_lazily_generated_unify_pred(TypeCtor, PredId, !ModuleInfo) :- ClassConstraints = [], MakeUnamedField = (func(ArgType) = no - ArgType), - CtorArgs = list__map(MakeUnamedField, TupleArgTypes), + CtorArgs = list.map(MakeUnamedField, TupleArgTypes), Ctor = ctor(ExistQVars, ClassConstraints, CtorSymName, CtorArgs), CtorSymName = unqualified("{}"), ConsId = cons(CtorSymName, TupleArity), - map__from_assoc_list([ConsId - single_functor], ConsTagValues), + map.from_assoc_list([ConsId - single_functor], ConsTagValues), UnifyPred = no, IsEnum = not_enum_or_dummy, IsForeign = no, @@ -515,7 +516,7 @@ add_lazily_generated_unify_pred(TypeCtor, PredId, !ModuleInfo) :- ReservedTag, IsForeign), construct_type(TypeCtor, TupleArgTypes, Type), - term__context_init(Context) + term.context_init(Context) ; collect_type_defn(!.ModuleInfo, TypeCtor, Type, TVarSet, TypeBody, Context) @@ -555,27 +556,27 @@ add_lazily_generated_special_pred(SpecialId, Item, TVarSet, Type, TypeCtor, % Add the declaration and maybe clauses. ( Item = clauses, - make_hlds__add_special_pred_for_real(SpecialId, TVarSet, - Type, TypeCtor, TypeBody, Context, PredStatus, !ModuleInfo) + add_special_pred_for_real(SpecialId, TVarSet, Type, TypeCtor, + TypeBody, Context, PredStatus, !ModuleInfo) ; Item = declaration, - make_hlds__add_special_pred_decl_for_real(SpecialId, TVarSet, - Type, TypeCtor, Context, PredStatus, !ModuleInfo) + add_special_pred_decl_for_real(SpecialId, TVarSet, Type, TypeCtor, + Context, PredStatus, !ModuleInfo) ), module_info_get_special_pred_map(!.ModuleInfo, SpecialPredMap), - map__lookup(SpecialPredMap, SpecialId - TypeCtor, PredId), + map.lookup(SpecialPredMap, SpecialId - TypeCtor, PredId), module_info_pred_info(!.ModuleInfo, PredId, PredInfo0), % The clauses are generated with all type information computed, % so just go on to post_typecheck. ( Item = clauses, - post_typecheck__finish_pred_no_io(!.ModuleInfo, + post_typecheck.finish_pred_no_io(!.ModuleInfo, ErrorProcs, PredInfo0, PredInfo) ; Item = declaration, - post_typecheck__finish_imported_pred_no_io(!.ModuleInfo, + post_typecheck.finish_imported_pred_no_io(!.ModuleInfo, ErrorProcs, PredInfo0, PredInfo) ), expect(unify(ErrorProcs, []), this_file, @@ -590,7 +591,7 @@ add_lazily_generated_special_pred(SpecialId, Item, TVarSet, Type, TypeCtor, % Such calls can be generated by generate_clause_info, % but unification predicates which contain such calls are never % generated lazily. - polymorphism__process_generated_pred(PredId, !ModuleInfo). + polymorphism.process_generated_pred(PredId, !ModuleInfo). :- type unify_pred_item ---> declaration @@ -601,13 +602,13 @@ add_lazily_generated_special_pred(SpecialId, Item, TVarSet, Type, TypeCtor, collect_type_defn(ModuleInfo, TypeCtor, Type, TVarSet, TypeBody, Context) :- module_info_get_type_table(ModuleInfo, Types), - map__lookup(Types, TypeCtor, TypeDefn), - hlds_data__get_type_defn_tvarset(TypeDefn, TVarSet), - hlds_data__get_type_defn_tparams(TypeDefn, TypeParams), - hlds_data__get_type_defn_kind_map(TypeDefn, KindMap), - hlds_data__get_type_defn_body(TypeDefn, TypeBody), - hlds_data__get_type_defn_status(TypeDefn, TypeStatus), - hlds_data__get_type_defn_context(TypeDefn, Context), + map.lookup(Types, TypeCtor, TypeDefn), + hlds_data.get_type_defn_tvarset(TypeDefn, TVarSet), + hlds_data.get_type_defn_tparams(TypeDefn, TypeParams), + hlds_data.get_type_defn_kind_map(TypeDefn, KindMap), + hlds_data.get_type_defn_body(TypeDefn, TypeBody), + hlds_data.get_type_defn_status(TypeDefn, TypeStatus), + hlds_data.get_type_defn_context(TypeDefn, Context), expect(special_pred_is_generated_lazily(ModuleInfo, TypeCtor, TypeBody, TypeStatus), this_file, "add_lazily_generated_unify_pred"), @@ -658,7 +659,7 @@ generate_clause_info(SpecialPredId, Type, TypeBody, Context, ModuleInfo, ), info_extract(!.Info, VarSet, Types) ), - map__init(TVarNameMap), + map.init(TVarNameMap), rtti_varmaps_init(RttiVarMaps), set_clause_list(Clauses, ClausesRep), HasForeignClauses = yes, @@ -672,7 +673,7 @@ generate_clause_info(SpecialPredId, Type, TypeBody, Context, ModuleInfo, generate_initialise_clauses(_Type, TypeBody, X, Context, Clauses, !Info) :- info_get_module_info(!.Info, ModuleInfo), ( - type_util__type_body_has_solver_type_details(ModuleInfo, + type_util.type_body_has_solver_type_details(ModuleInfo, TypeBody, SolverTypeDetails) -> % Just generate a call to the specified predicate, which is @@ -704,8 +705,8 @@ generate_initialise_clauses(_Type, TypeBody, X, Context, Clauses, !Info) :- unexpected(this_file, "generate_initialise_clauses: type_to_ctor_and_args failed") ), - PredName = special_pred__special_pred_name(spec_pred_init, TypeCtor), - hlds_module__module_info_get_name(ModuleInfo, ModuleName), + PredName = special_pred.special_pred_name(spec_pred_init, TypeCtor), + hlds_module.module_info_get_name(ModuleInfo, ModuleName), TypeCtor = TypeSymName - _TypeArity, sym_name_get_module_name(TypeSymName, ModuleName, TypeModuleName), InitPred = qualified(TypeModuleName, PredName), @@ -1259,7 +1260,7 @@ generate_du_unify_clauses([], _X, _Y, _Context, [], !Info). generate_du_unify_clauses([Ctor | Ctors], X, Y, Context, [Clause | Clauses], !Info) :- Ctor = ctor(ExistQTVars, _Constraints, FunctorName, ArgTypes), - list__length(ArgTypes, FunctorArity), + list.length(ArgTypes, FunctorArity), FunctorConsId = cons(FunctorName, FunctorArity), ( ArgTypes = [], @@ -1336,7 +1337,7 @@ generate_du_index_clauses([], _X, _Index, _Context, _N, [], !Info). generate_du_index_clauses([Ctor | Ctors], X, Index, Context, N, [Clause | Clauses], !Info) :- Ctor = ctor(ExistQTVars, _Constraints, FunctorName, ArgTypes), - list__length(ArgTypes, FunctorArity), + list.length(ArgTypes, FunctorArity), FunctorConsId = cons(FunctorName, FunctorArity), make_fresh_vars(ArgTypes, ExistQTVars, ArgVars, !Info), create_atomic_complicated_unification(X, @@ -1365,9 +1366,9 @@ generate_du_compare_clauses(Type, Ctors, Res, H1, H2, Context, Clauses, Ctors = [_ | _], info_get_module_info(!.Info, ModuleInfo), module_info_get_globals(ModuleInfo, Globals), - globals__lookup_int_option(Globals, compare_specialization, + globals.lookup_int_option(Globals, compare_specialization, CompareSpec), - list__length(Ctors, NumCtors), + list.length(Ctors, NumCtors), ( NumCtors =< CompareSpec -> generate_du_quad_compare_clauses( Ctors, Res, H1, H2, Context, Clauses, !Info) @@ -1638,7 +1639,7 @@ generate_compare_cases([Ctor | Ctors], R, X, Y, Context, [Case | Cases], generate_compare_case(Ctor, R, X, Y, Context, Kind, Case, !Info) :- Ctor = ctor(ExistQTVars, _Constraints, FunctorName, ArgTypes), - list__length(ArgTypes, FunctorArity), + list.length(ArgTypes, FunctorArity), FunctorConsId = cons(FunctorName, FunctorArity), ( ArgTypes = [], @@ -1685,8 +1686,8 @@ generate_asymmetric_compare_case(Ctor1, Ctor2, CompareOp, R, X, Y, Context, Case, !Info) :- Ctor1 = ctor(ExistQTVars1, _Constraints1, FunctorName1, ArgTypes1), Ctor2 = ctor(ExistQTVars2, _Constraints2, FunctorName2, ArgTypes2), - list__length(ArgTypes1, FunctorArity1), - list__length(ArgTypes2, FunctorArity2), + list.length(ArgTypes1, FunctorArity1), + list.length(ArgTypes2, FunctorArity2), FunctorConsId1 = cons(FunctorName1, FunctorArity1), FunctorConsId2 = cons(FunctorName2, FunctorArity2), make_fresh_vars(ArgTypes1, ExistQTVars1, Vars1, !Info), @@ -1758,7 +1759,7 @@ compare_args_2([_Name - Type | ArgTypes], ExistQTVars, [X | Xs], [Y | Ys], R, % which would be a type error, we call `typed_compare', which is a builtin % that first compares their types and then compares their values. ( - list__member(ExistQTVar, ExistQTVars), + list.member(ExistQTVar, ExistQTVars), type_contains_var(Type, ExistQTVar) -> ComparePred = "typed_compare" @@ -1806,7 +1807,7 @@ generate_return_equal(ResultVar, Context, Goal) :- build_call(Name, ArgVars, Context, Goal, !Info) :- info_get_module_info(!.Info, ModuleInfo), - list__length(ArgVars, Arity), + list.length(ArgVars, Arity), % % We assume that the special preds compare/3, index/2, and unify/2 % are the only public builtins called by code generated by this module. @@ -1816,7 +1817,7 @@ build_call(Name, ArgVars, Context, Goal, !Info) :- ; MercuryBuiltin = mercury_private_builtin_module ), - goal_util__generate_simple_call(MercuryBuiltin, Name, predicate, + goal_util.generate_simple_call(MercuryBuiltin, Name, predicate, mode_no(0), erroneous, ArgVars, [], [], ModuleInfo, Context, Goal). :- pred build_specific_call(mer_type::in, special_pred_id::in, @@ -1828,11 +1829,11 @@ build_specific_call(Type, SpecialPredId, ArgVars, InstmapDelta, Detism, Context, Goal, !Info) :- info_get_module_info(!.Info, ModuleInfo), ( - polymorphism__get_special_proc(Type, SpecialPredId, ModuleInfo, + polymorphism.get_special_proc(Type, SpecialPredId, ModuleInfo, PredName, PredId, ProcId) -> GoalExpr = call(PredId, ProcId, ArgVars, not_builtin, no, PredName), - set__list_to_set(ArgVars, NonLocals), + set.list_to_set(ArgVars, NonLocals), goal_info_init(NonLocals, InstmapDelta, Detism, purity_pure, GoalInfo0), goal_info_set_context(Context, GoalInfo0, GoalInfo), @@ -1851,8 +1852,8 @@ build_specific_call(Type, SpecialPredId, ArgVars, InstmapDelta, Detism, prog_var::out, unify_proc_info::in, unify_proc_info::out) is det. make_fresh_named_var_from_type(Type, BaseName, Num, Var, !Info) :- - string__int_to_string(Num, NumStr), - string__append(BaseName, NumStr, Name), + string.int_to_string(Num, NumStr), + string.append(BaseName, NumStr, Name), info_new_named_var(Type, Name, Var, !Info). :- pred make_fresh_named_vars_from_types(list(mer_type)::in, string::in, @@ -1879,7 +1880,7 @@ make_fresh_vars_from_types([Type | Types], [Var | Vars], !Info) :- make_fresh_vars(CtorArgs, ExistQTVars, Vars, !Info) :- ( ExistQTVars = [], - assoc_list__values(CtorArgs, ArgTypes), + assoc_list.values(CtorArgs, ArgTypes), make_fresh_vars_from_types(ArgTypes, Vars, !Info) ; ExistQTVars = [_ | _], @@ -1891,8 +1892,8 @@ make_fresh_vars(CtorArgs, ExistQTVars, Vars, !Info) :- % up to typecheck.m to infer their types. % info_get_varset(!.Info, VarSet0), - list__length(CtorArgs, NumVars), - varset__new_vars(VarSet0, NumVars, Vars, VarSet), + list.length(CtorArgs, NumVars), + varset.new_vars(VarSet0, NumVars, Vars, VarSet), info_set_varset(VarSet, !Info) ). @@ -1914,7 +1915,7 @@ unify_var_lists(ArgTypes, ExistQVars, Vars1, Vars2, Goal, !Info) :- unify_var_lists_2([], _, [], [], [], !Info). unify_var_lists_2([_Name - Type | ArgTypes], ExistQTVars, [X | Xs], [Y | Ys], [Goal | Goals], !Info) :- - term__context_init(Context), + term.context_init(Context), ( info_get_module_info(!.Info, ModuleInfo), @@ -1928,7 +1929,7 @@ unify_var_lists_2([_Name - Type | ArgTypes], ExistQTVars, [X | Xs], [Y | Ys], % a builtin that first checks that their types are equal and then % unifies the values. - list__member(ExistQTVar, ExistQTVars), + list.member(ExistQTVar, ExistQTVars), type_contains_var(Type, ExistQTVar) -> build_call("typed_unify", [X, Y], Context, Goal, !Info) @@ -1982,20 +1983,22 @@ equal_functor = functor(equal_cons_id, no, []). ). info_init(ModuleInfo, UPI) :- - varset__init(VarSet), - map__init(Types), + varset.init(VarSet), + map.init(Types), rtti_varmaps_init(RttiVarMaps), UPI = unify_proc_info(VarSet, Types, RttiVarMaps, ModuleInfo). -info_new_var(Type, Var, UPI, - (UPI ^ varset := VarSet) ^ vartypes := Types) :- - varset__new_var(UPI ^ varset, Var, VarSet), - map__det_insert(UPI ^ vartypes, Var, Type, Types). +info_new_var(Type, Var, !UPI) :- + varset.new_var(!.UPI ^ varset, Var, VarSet), + map.det_insert(!.UPI ^ vartypes, Var, Type, VarTypes), + !:UPI = !.UPI ^ varset := VarSet, + !:UPI = !.UPI ^ vartypes := VarTypes. -info_new_named_var(Type, Name, Var, UPI, - (UPI ^ varset := VarSet) ^ vartypes := Types) :- - varset__new_named_var(UPI ^ varset, Name, Var, VarSet), - map__det_insert(UPI ^ vartypes, Var, Type, Types). +info_new_named_var(Type, Name, Var, !UPI) :- + varset.new_named_var(!.UPI ^ varset, Name, Var, VarSet), + map.det_insert(!.UPI ^ vartypes, Var, Type, VarTypes), + !:UPI = !.UPI ^ varset := VarSet, + !:UPI = !.UPI ^ vartypes := VarTypes. info_extract(UPI, UPI ^ varset, UPI ^ vartypes). diff --git a/compiler/unique_modes.m b/compiler/unique_modes.m index cff3bafdb..e41627746 100644 --- a/compiler/unique_modes.m +++ b/compiler/unique_modes.m @@ -31,7 +31,7 @@ %-----------------------------------------------------------------------------% -:- module check_hlds__unique_modes. +:- module check_hlds.unique_modes. :- interface. :- import_module check_hlds.mode_info. @@ -115,7 +115,7 @@ check_proc(ProcId, PredId, !ModuleInfo, Changed, !IO) :- modecheck_proc_general(ProcId, PredId, check_unique_modes, may_change_called_proc, !ModuleInfo, NumErrors, Changed, !IO), ( NumErrors \= 0 -> - io__set_exit_status(1, !IO) + io.set_exit_status(1, !IO) ; true ). @@ -123,7 +123,7 @@ check_proc(ProcId, PredId, !ModuleInfo, Changed, !IO) :- check_goal(Goal0, Goal, !ModeInfo, !IO) :- Goal0 = GoalExpr0 - GoalInfo0, goal_info_get_context(GoalInfo0, Context), - term__context_init(EmptyContext), + term.context_init(EmptyContext), ( Context = EmptyContext -> true ; @@ -140,7 +140,7 @@ check_goal(Goal0, Goal, !ModeInfo, !IO) :- ( determinism_components(Detism, _, at_most_many) -> true ; - mode_info_set_nondet_live_vars(bag__init, !ModeInfo) + mode_info_set_nondet_live_vars(bag.init, !ModeInfo) ), check_goal_2(GoalExpr0, GoalInfo0, GoalExpr, !ModeInfo, !IO), @@ -155,8 +155,8 @@ check_goal(Goal0, Goal, !ModeInfo, !IO) :- make_all_nondet_live_vars_mostly_uniq(ModeInfo0, ModeInfo) :- mode_info_get_instmap(ModeInfo0, FullInstMap0), - ( instmap__is_reachable(FullInstMap0) -> - instmap__vars_list(FullInstMap0, AllVars), + ( instmap.is_reachable(FullInstMap0) -> + instmap.vars_list(FullInstMap0, AllVars), select_nondet_live_vars(AllVars, ModeInfo0, NondetLiveVars), make_var_list_mostly_uniq(NondetLiveVars, ModeInfo0, ModeInfo) ; @@ -198,9 +198,9 @@ select_changed_inst_vars([], _DeltaInstMap, _ModeInfo, []). select_changed_inst_vars([Var | Vars], DeltaInstMap, ModeInfo, ChangedVars) :- mode_info_get_module_info(ModeInfo, ModuleInfo), mode_info_get_instmap(ModeInfo, InstMap0), - instmap__lookup_var(InstMap0, Var, Inst0), + instmap.lookup_var(InstMap0, Var, Inst0), mode_info_get_var_types(ModeInfo, VarTypes), - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ( instmap_delta_is_reachable(DeltaInstMap), instmap_delta_search_var(DeltaInstMap, Var, Inst), @@ -228,10 +228,10 @@ make_var_mostly_uniq(Var, !ModeInfo) :- mode_info_get_module_info(!.ModeInfo, ModuleInfo0), ( % Only variables which are `unique' need to be changed. - instmap__is_reachable(InstMap0), - instmap__vars_list(InstMap0, Vars), - list__member(Var, Vars), - instmap__lookup_var(InstMap0, Var, Inst0), + instmap.is_reachable(InstMap0), + instmap.vars_list(InstMap0, Vars), + list.member(Var, Vars), + instmap.lookup_var(InstMap0, Var, Inst0), inst_expand(ModuleInfo0, Inst0, Inst1), ( Inst1 = ground(unique, _) ; Inst1 = bound(unique, _) @@ -240,7 +240,7 @@ make_var_mostly_uniq(Var, !ModeInfo) :- -> make_mostly_uniq_inst(Inst0, Inst, ModuleInfo0, ModuleInfo), mode_info_set_module_info(ModuleInfo, !ModeInfo), - instmap__set(Var, Inst, InstMap0, InstMap), + instmap.set(Var, Inst, InstMap0, InstMap), mode_info_set_instmap(InstMap, !ModeInfo) ; true @@ -275,7 +275,7 @@ check_goal_2(conj(ConjType, List0), GoalInfo0, conj(ConjType, List), % parallel conjunction. make_par_conj_nonlocal_multiset(List0, NonLocalsBag), check_par_conj(List0, NonLocalsBag, List, InstMapList, !ModeInfo, !IO), - instmap__unify(NonLocals, InstMapList, !ModeInfo), + instmap.unify(NonLocals, InstMapList, !ModeInfo), mode_info_remove_live_vars(NonLocals, !ModeInfo), mode_checkpoint(exit, "par_conj", !ModeInfo, !IO) ). @@ -285,7 +285,7 @@ check_goal_2(disj(List0), GoalInfo0, disj(List), !ModeInfo, !IO) :- ( List0 = [], List = [], - instmap__init_unreachable(InstMap), + instmap.init_unreachable(InstMap), mode_info_set_instmap(InstMap, !ModeInfo) ; List0 = [_ | _], @@ -314,7 +314,7 @@ check_goal_2(disj(List0), GoalInfo0, disj(List), !ModeInfo, !IO) :- % merge the resulting instmaps. check_disj(List0, Determinism, NonLocals, List, InstMapList, !ModeInfo, !IO), - instmap__merge(NonLocals, InstMapList, disj, !ModeInfo) + instmap.merge(NonLocals, InstMapList, disj, !ModeInfo) ), mode_checkpoint(exit, "disj", !ModeInfo, !IO). @@ -353,7 +353,7 @@ check_goal_2(if_then_else(Vars, Cond0, Then0, Else0), GoalInfo0, Goal, % ). mode_info_add_live_vars(Else_Vars, !ModeInfo), - set__to_sorted_list(Cond_Vars, Cond_Vars_List), + set.to_sorted_list(Cond_Vars, Cond_Vars_List), select_live_vars(Cond_Vars_List, !.ModeInfo, Cond_Live_Vars), Cond0 = _ - Cond0_GoalInfo, goal_info_get_instmap_delta(Cond0_GoalInfo, Cond0_DeltaInstMap), @@ -367,7 +367,7 @@ check_goal_2(if_then_else(Vars, Cond0, Then0, Else0), GoalInfo0, Goal, mode_info_remove_live_vars(Then_Vars, !ModeInfo), mode_info_unlock_vars(if_then_else, NonLocals, !ModeInfo), mode_info_get_instmap(!.ModeInfo, InstMapCond), - ( instmap__is_reachable(InstMapCond) -> + ( instmap.is_reachable(InstMapCond) -> check_goal(Then0, Then, !ModeInfo, !IO), mode_info_get_instmap(!.ModeInfo, InstMapThen) ; @@ -381,7 +381,7 @@ check_goal_2(if_then_else(Vars, Cond0, Then0, Else0), GoalInfo0, Goal, check_goal(Else0, Else, !ModeInfo, !IO), mode_info_get_instmap(!.ModeInfo, InstMapElse), mode_info_set_instmap(InstMap0, !ModeInfo), - instmap__merge(NonLocals, [InstMapThen, InstMapElse], if_then_else, + instmap.merge(NonLocals, [InstMapThen, InstMapElse], if_then_else, !ModeInfo), Goal = if_then_else(Vars, Cond, Then, Else), mode_checkpoint(exit, "if-then-else", !ModeInfo, !IO). @@ -395,7 +395,7 @@ check_goal_2(not(SubGoal0), GoalInfo0, not(SubGoal), !ModeInfo, !IO) :- % then the negation will succeed, and so these variables can be accessed % again after backtracking. goal_info_get_nonlocals(GoalInfo0, NonLocals), - set__to_sorted_list(NonLocals, NonLocalsList), + set.to_sorted_list(NonLocals, NonLocalsList), select_live_vars(NonLocalsList, !.ModeInfo, LiveNonLocals), make_var_list_mostly_uniq(LiveNonLocals, !ModeInfo), @@ -403,7 +403,7 @@ check_goal_2(not(SubGoal0), GoalInfo0, not(SubGoal), !ModeInfo, !IO) :- % succeeds then execution will immediately backtrack. So we need to set % the live variables set to empty here. mode_info_get_live_vars(!.ModeInfo, LiveVars0), - mode_info_set_live_vars(bag__init, !ModeInfo), + mode_info_set_live_vars(bag.init, !ModeInfo), % We need to lock the non-local variables, to ensure that the negation % does not bind them. @@ -423,7 +423,7 @@ check_goal_2(scope(Reason, SubGoal0), _, scope(Reason, SubGoal), check_goal_2(generic_call(GenericCall, Args, Modes, Det), _GoalInfo0, Goal, !ModeInfo, !IO) :- mode_checkpoint(enter, "generic_call", !ModeInfo, !IO), - hlds_goal__generic_call_id(GenericCall, CallId), + hlds_goal.generic_call_id(GenericCall, CallId), mode_info_set_call_context(call(CallId), !ModeInfo), ( determinism_components(Det, _, at_most_zero) -> NeverSucceeds = yes @@ -451,7 +451,7 @@ check_goal_2(generic_call(GenericCall, Args, Modes, Det), _GoalInfo0, Goal, check_goal_2(call(PredId, ProcId0, Args, Builtin, CallContext, PredName), GoalInfo0, Goal, !ModeInfo, !IO) :- sym_name_to_string(PredName, PredNameString), - string__append("call ", PredNameString, CallString), + string.append("call ", PredNameString, CallString), mode_checkpoint(enter, CallString, !ModeInfo, !IO), mode_info_get_call_id(!.ModeInfo, PredId, CallId), mode_info_set_call_context(call(call(CallId)), !ModeInfo), @@ -475,13 +475,13 @@ check_goal_2(switch(Var, CanFail, Cases0), GoalInfo0, ( Cases0 = [], Cases = [], - instmap__init_unreachable(InstMap), + instmap.init_unreachable(InstMap), mode_info_set_instmap(InstMap, !ModeInfo) ; Cases0 = [_ | _], goal_info_get_nonlocals(GoalInfo0, NonLocals), check_case_list(Cases0, Var, Cases, InstMapList, !ModeInfo, !IO), - instmap__merge(NonLocals, InstMapList, disj, !ModeInfo) + instmap.merge(NonLocals, InstMapList, disj, !ModeInfo) ), mode_checkpoint(exit, "switch", !ModeInfo, !IO). @@ -492,7 +492,7 @@ check_goal_2(foreign_proc(Attributes, PredId, ProcId0, Args, ExtraArgs, mode_checkpoint(enter, "foreign_proc", !ModeInfo, !IO), mode_info_get_call_id(!.ModeInfo, PredId, CallId), mode_info_set_call_context(call(call(CallId)), !ModeInfo), - ArgVars = list__map(foreign_arg_var, Args), + ArgVars = list.map(foreign_arg_var, Args), check_call(PredId, ProcId0, ArgVars, GoalInfo0, ProcId, !ModeInfo), Goal = foreign_proc(Attributes, PredId, ProcId, Args, ExtraArgs, PragmaCode), @@ -527,9 +527,9 @@ check_call(PredId, ProcId0, ArgVars, GoalInfo, ProcId, !ModeInfo) :- ( ModeErrors = [_ | _], % mode error in callee for this mode - WaitingVars = set__list_to_set(ArgVars), + WaitingVars = set.list_to_set(ArgVars), mode_info_get_instmap(!.ModeInfo, InstMap), - instmap__lookup_vars(ArgVars, InstMap, ArgInsts), + instmap.lookup_vars(ArgVars, InstMap, ArgInsts), mode_info_error(WaitingVars, mode_error_in_callee(ArgVars, ArgInsts, PredId, ProcId0, ProcInfo ^ mode_errors), @@ -548,7 +548,7 @@ check_call(PredId, ProcId0, ArgVars, GoalInfo, ProcId, !ModeInfo) :- % We're not allowed to try a different procedure here, so just return % all the errors. ProcId = ProcId0, - list__append(OldErrors, Errors, AllErrors), + list.append(OldErrors, Errors, AllErrors), mode_info_set_errors(AllErrors, !ModeInfo) ; % If it didn't work, restore the original instmap, and then call @@ -611,7 +611,7 @@ check_call_modes(ArgVars, ProcArgModes, ArgOffset, Determinism, NeverSucceeds, ), ( NeverSucceeds = yes, - instmap__init_unreachable(InstMap), + instmap.init_unreachable(InstMap), mode_info_set_instmap(InstMap, !ModeInfo) ; NeverSucceeds = no, @@ -638,7 +638,7 @@ check_conj([Goal0 | Goals0], Goals, !ModeInfo, !IO) :- ( Goal0 = conj(plain_conj, ConjGoals) - _ -> - list__append(ConjGoals, Goals0, Goals1), + list.append(ConjGoals, Goals0, Goals1), check_conj(Goals1, Goals, !ModeInfo, !IO) ; check_conj_2(Goal0, Goals0, Goals, !ModeInfo, !IO) @@ -652,7 +652,7 @@ check_conj_2(Goal0, Goals0, [Goal | Goals], !ModeInfo, !IO) :- mode_info_remove_live_vars(NonLocals, !ModeInfo), check_goal(Goal0, Goal, !ModeInfo, !IO), mode_info_get_instmap(!.ModeInfo, InstMap), - ( instmap__is_unreachable(InstMap) -> + ( instmap.is_unreachable(InstMap) -> % We should not mode-analyse the remaining goals, since they are % unreachable. Instead we optimize them away, so that later passes % won't complain about them not having unique mode information. @@ -671,13 +671,13 @@ check_conj_2(Goal0, Goals0, [Goal | Goals], !ModeInfo, !IO) :- bag(prog_var)::out) is det. make_par_conj_nonlocal_multiset([], Empty) :- - bag__init(Empty). + bag.init(Empty). make_par_conj_nonlocal_multiset([Goal | Goals], NonLocalsMultiSet) :- make_par_conj_nonlocal_multiset(Goals, NonLocalsMultiSet0), goal_get_nonlocals(Goal, NonLocals), - set__to_sorted_list(NonLocals, NonLocalsList), - bag__from_list(NonLocalsList, NonLocalsMultiSet1), - bag__union(NonLocalsMultiSet0, NonLocalsMultiSet1, NonLocalsMultiSet). + set.to_sorted_list(NonLocals, NonLocalsList), + bag.from_list(NonLocalsList, NonLocalsMultiSet1), + bag.union(NonLocalsMultiSet0, NonLocalsMultiSet1, NonLocalsMultiSet). % To unique-modecheck a parallel conjunction, we find the variables % that are nonlocal to more than one conjunct and make them shared, @@ -703,18 +703,18 @@ check_par_conj(Goals0, NonLocalVarsBag, Goals, Instmaps, !ModeInfo, !IO) :- is det. check_par_conj_0(NonLocalVarsBag, !ModeInfo) :- - bag__to_assoc_list(NonLocalVarsBag, NonLocalVarsList), - list__filter_map((pred(Pair::in, Var::out) is semidet :- + bag.to_assoc_list(NonLocalVarsBag, NonLocalVarsList), + list.filter_map((pred(Pair::in, Var::out) is semidet :- Pair = Var - Multiplicity, Multiplicity > 1 ), NonLocalVarsList, SharedList), mode_info_get_instmap(!.ModeInfo, InstMap0), - instmap__lookup_vars(SharedList, InstMap0, VarInsts), + instmap.lookup_vars(SharedList, InstMap0, VarInsts), mode_info_get_module_info(!.ModeInfo, ModuleInfo0), make_shared_inst_list(VarInsts, SharedVarInsts, ModuleInfo0, ModuleInfo1), mode_info_set_module_info(ModuleInfo1, !ModeInfo), - instmap__set_vars(SharedList, SharedVarInsts, InstMap0, InstMap1), + instmap.set_vars(SharedList, SharedVarInsts, InstMap0, InstMap1), mode_info_set_instmap(InstMap1, !ModeInfo). % Just process each conjunct in turn. Because we have already done @@ -802,7 +802,7 @@ check_case_list([Case0 | Cases0], Var, [Case | Cases], [InstMap | InstMaps], modecheck_functor_test(Var, ConsId, !ModeInfo), mode_info_get_instmap(!.ModeInfo, InstMap1), - ( instmap__is_reachable(InstMap1) -> + ( instmap.is_reachable(InstMap1) -> check_goal(Goal0, Goal1, !ModeInfo, !IO) ; % We should not mode-analyse the goal, since it is unreachable. diff --git a/compiler/unneeded_code.m b/compiler/unneeded_code.m index 80260dc3f..9e672f25f 100644 --- a/compiler/unneeded_code.m +++ b/compiler/unneeded_code.m @@ -56,7 +56,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__unneeded_code. +:- module transform_hlds.unneeded_code. :- interface. :- import_module hlds.hlds_module. @@ -215,20 +215,20 @@ process_proc_msg(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :- % Therefore we preprocess the procedure body to ensure that the nonlocals % sets are accurate reflections of the true needs of goals. - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), ( VeryVerbose = yes, - io__write_string("% Removing dead code in ", !IO), - hlds_out__write_pred_proc_id(!.ModuleInfo, PredId, ProcId, !IO), - io__write_string(": ", !IO), + io.write_string("% Removing dead code in ", !IO), + hlds_out.write_pred_proc_id(!.ModuleInfo, PredId, ProcId, !IO), + io.write_string(": ", !IO), pre_process_proc(!ProcInfo), process_proc(!ProcInfo, !ModuleInfo, Successful), ( Successful = yes, - io__write_string("done.\n", !IO) + io.write_string("done.\n", !IO) ; Successful = no, - io__write_string("none found.\n", !IO) + io.write_string("none found.\n", !IO) ) ; VeryVerbose = no, @@ -286,32 +286,32 @@ pre_process_proc(!ProcInfo) :- module_info::in, module_info::out, bool::out) is det. process_proc(!ProcInfo, !ModuleInfo, Successful) :- - goal_path__fill_slots(!.ModuleInfo, !ProcInfo), + fill_goal_path_slots(!.ModuleInfo, !ProcInfo), proc_info_goal(!.ProcInfo, Goal0), proc_info_varset(!.ProcInfo, Varset0), proc_info_vartypes(!.ProcInfo, VarTypes0), proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, InitInstMap), Goal0 = _ - GoalInfo0, goal_info_get_instmap_delta(GoalInfo0, InstMapDelta), - instmap__apply_instmap_delta(InitInstMap, InstMapDelta, FinalInstMap), + instmap.apply_instmap_delta(InitInstMap, InstMapDelta, FinalInstMap), proc_info_instantiated_head_vars(!.ModuleInfo, !.ProcInfo, NeededVarsList), - map__init(WhereNeededMap0), + map.init(WhereNeededMap0), NeededEverywhere = (pred(Var::in, NeededMap0::in, NeededMap::out) is det :- - map__det_insert(NeededMap0, Var, everywhere, NeededMap) + map.det_insert(NeededMap0, Var, everywhere, NeededMap) ), - list__foldl(NeededEverywhere, NeededVarsList, + list.foldl(NeededEverywhere, NeededVarsList, WhereNeededMap0, WhereNeededMap1), module_info_get_globals(!.ModuleInfo, Globals), - globals__lookup_bool_option(Globals, reorder_conj, ReorderConj), - globals__lookup_bool_option(Globals, fully_strict, FullyStrict), - globals__lookup_int_option(Globals, unneeded_code_copy_limit, Limit), + globals.lookup_bool_option(Globals, reorder_conj, ReorderConj), + globals.lookup_bool_option(Globals, fully_strict, FullyStrict), + globals.lookup_int_option(Globals, unneeded_code_copy_limit, Limit), Options = option_values(FullyStrict, ReorderConj, Limit), process_goal(Goal0, Goal1, InitInstMap, FinalInstMap, VarTypes0, - !.ModuleInfo, Options, WhereNeededMap1, _, map__init, RefinedGoals1, + !.ModuleInfo, Options, WhereNeededMap1, _, map.init, RefinedGoals1, no, Changed), refine_goal(Goal1, Goal2, RefinedGoals1, RefinedGoals), - expect(map__is_empty(RefinedGoals), + expect(map.is_empty(RefinedGoals), this_file, "process_proc: goal reattachment unsuccessful"), ( Changed = yes, @@ -350,8 +350,8 @@ process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, WhereInfo = branches(Branches), demand_inputs(Goal0, ModuleInfo, InitInstMap, WhereInfo, !WhereNeededMap), - map__to_assoc_list(Branches, BranchList), - list__foldl(insert_branch_into_refined_goals(Goal0), BranchList, + map.to_assoc_list(Branches, BranchList), + list.foldl(insert_branch_into_refined_goals(Goal0), BranchList, !RefinedGoals), Goal = true_goal, !:Changed = yes @@ -361,7 +361,7 @@ process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, ( Goal = _ - GoalInfo, goal_info_get_features(GoalInfo, Features), - set__member(impure_goal, Features) + set.member(impure_goal, Features) -> % By saying that all vars that are live before the impure goal are % needed everywhere, we prevent the movement of the goals producing @@ -369,7 +369,7 @@ process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, % % This code requires compound goals containing impure code % to also be marked impure. - map__map_values(demand_var_everywhere, !WhereNeededMap) + map.map_values(demand_var_everywhere, !WhereNeededMap) ; true ). @@ -381,8 +381,8 @@ process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, insert_branch_into_refined_goals(Goal, BranchPoint - BranchNumSet, !RefinedGoals) :- BranchPoint = branch_point(GoalPath, _), - set__to_sorted_list(BranchNumSet, BranchNums), - list__foldl(insert_branch_arm_into_refined_goals(Goal, GoalPath), + set.to_sorted_list(BranchNumSet, BranchNums), + list.foldl(insert_branch_arm_into_refined_goals(Goal, GoalPath), BranchNums, !RefinedGoals). :- pred insert_branch_arm_into_refined_goals(hlds_goal::in, goal_path::in, @@ -391,11 +391,11 @@ insert_branch_into_refined_goals(Goal, BranchPoint - BranchNumSet, insert_branch_arm_into_refined_goals(Goal, GoalPath, BranchNum, !RefinedGoals) :- Key = GoalPath - BranchNum, - ( map__search(!.RefinedGoals, Key, Goals0) -> + ( map.search(!.RefinedGoals, Key, Goals0) -> Goals = [Goal | Goals0], - map__det_update(!.RefinedGoals, Key, Goals, !:RefinedGoals) + map.det_update(!.RefinedGoals, Key, Goals, !:RefinedGoals) ; - map__det_insert(!.RefinedGoals, Key, [Goal], !:RefinedGoals) + map.det_insert(!.RefinedGoals, Key, [Goal], !:RefinedGoals) ). %-----------------------------------------------------------------------------% @@ -408,12 +408,12 @@ can_eliminate_or_move(Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options, WhereNeededMap, !:WhereInfo) :- instmap_changed_vars(InitInstMap, FinalInstMap, VarTypes, ModuleInfo, ChangedVarSet), - set__to_sorted_list(ChangedVarSet, ChangedVars), - map__init(Empty), + set.to_sorted_list(ChangedVarSet, ChangedVars), + map.init(Empty), !:WhereInfo = branches(Empty), Goal = _ - GoalInfo, goal_info_get_goal_path(GoalInfo, CurrentPath), - list__foldl(collect_where_needed(CurrentPath, WhereNeededMap), ChangedVars, + list.foldl(collect_where_needed(CurrentPath, WhereNeededMap), ChangedVars, !WhereInfo), adjust_where_needed(Goal, Options, !WhereInfo). @@ -421,7 +421,7 @@ can_eliminate_or_move(Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, where_needed::in, where_needed::out) is det. collect_where_needed(CurrentPath, WhereNeededMap, ChangedVar, !WhereInfo) :- - ( map__search(WhereNeededMap, ChangedVar, Where) -> + ( map.search(WhereNeededMap, ChangedVar, Where) -> where_needed_upper_bound(CurrentPath, Where, !WhereInfo) ; true @@ -448,7 +448,7 @@ adjust_where_needed(Goal, Options, !WhereInfo) :- % Do not move impure or semipure goals, since their ordering % wrt other such goals must be preserved. goal_info_get_features(GoalInfo, Features), - set__member(impure_goal, Features) + set.member(impure_goal, Features) ; % With --fully-strict, we cannot optimize away infinite loops % or exceptions. @@ -460,7 +460,7 @@ adjust_where_needed(Goal, Options, !WhereInfo) :- Options ^ reorder_conj = no, goal_can_loop_or_throw(Goal), !.WhereInfo = branches(BranchMap), - \+ map__is_empty(BranchMap) + \+ map.is_empty(BranchMap) ; % Do not delete the `true' goal, since deleting it is a no-op, % and thus does *not* strictly reduce the number of computation @@ -468,9 +468,9 @@ adjust_where_needed(Goal, Options, !WhereInfo) :- GoalExpr = true_goal_expr ; !.WhereInfo = branches(BranchMap), - map__values(BranchMap, BranchArms), - list__map(set__count, BranchArms, BranchArmCounts), - BranchArmCount = list.foldl(int__plus, BranchArmCounts, 0), + map.values(BranchMap, BranchArms), + list.map(set.count, BranchArms, BranchArmCounts), + BranchArmCount = list.foldl(int.plus, BranchArmCounts, 0), BranchArmCount > Options ^ copy_limit % We may also want to add other space time tradeoffs. E.g. if @@ -509,16 +509,16 @@ demand_inputs(Goal, ModuleInfo, InitInstMap, WhereNeeded, !WhereNeededMap) :- Goal = _ - GoalInfo, goal_info_get_nonlocals(GoalInfo, NonLocalSet), goal_info_get_goal_path(GoalInfo, GoalPath), - set__to_sorted_list(NonLocalSet, NonLocals), - list__filter(nonlocal_may_be_input(ModuleInfo, InitInstMap), NonLocals, + set.to_sorted_list(NonLocalSet, NonLocals), + list.filter(nonlocal_may_be_input(ModuleInfo, InitInstMap), NonLocals, Inputs), - list__foldl(demand_var(GoalPath, WhereNeeded), Inputs, !WhereNeededMap). + list.foldl(demand_var(GoalPath, WhereNeeded), Inputs, !WhereNeededMap). :- pred nonlocal_may_be_input(module_info::in, instmap::in, prog_var::in) is semidet. nonlocal_may_be_input(ModuleInfo, InstMap, Var) :- - instmap__lookup_var(InstMap, Var, Inst), + instmap.lookup_var(InstMap, Var, Inst), inst_is_bound(ModuleInfo, Inst). %---------------------------------------------------------------------------% @@ -529,16 +529,16 @@ nonlocal_may_be_input(ModuleInfo, InstMap, Var) :- undemand_virgin_outputs(Goal, ModuleInfo, InstMap, !WhereNeededMap) :- Goal = _ - GoalInfo, goal_info_get_nonlocals(GoalInfo, NonLocalSet), - set__to_sorted_list(NonLocalSet, NonLocals), - list__filter(nonlocal_is_virgin_output(ModuleInfo, InstMap), NonLocals, + set.to_sorted_list(NonLocalSet, NonLocals), + list.filter(nonlocal_is_virgin_output(ModuleInfo, InstMap), NonLocals, VirginOutputs), - list__foldl(undemand_var, VirginOutputs, !WhereNeededMap). + list.foldl(undemand_var, VirginOutputs, !WhereNeededMap). :- pred nonlocal_is_virgin_output(module_info::in, instmap::in, prog_var::in) is semidet. nonlocal_is_virgin_output(ModuleInfo, InstMap, Var) :- - instmap__lookup_var(InstMap, Var, Inst), + instmap.lookup_var(InstMap, Var, Inst), \+ inst_is_bound(ModuleInfo, Inst). %---------------------------------------------------------------------------% @@ -547,18 +547,18 @@ nonlocal_is_virgin_output(ModuleInfo, InstMap, Var) :- prog_var::in, where_needed_map::in, where_needed_map::out) is det. demand_var(CurrentPath, WhereNeeded, Var, !WhereNeededMap) :- - ( map__search(!.WhereNeededMap, Var, Where0) -> + ( map.search(!.WhereNeededMap, Var, Where0) -> where_needed_upper_bound(CurrentPath, WhereNeeded, Where0, Where), - svmap__det_update(Var, Where, !WhereNeededMap) + svmap.det_update(Var, Where, !WhereNeededMap) ; - svmap__det_insert(Var, WhereNeeded, !WhereNeededMap) + svmap.det_insert(Var, WhereNeeded, !WhereNeededMap) ). :- pred undemand_var(prog_var::in, where_needed_map::in, where_needed_map::out) is det. undemand_var(Var, WhereNeededMap0, WhereNeededMap) :- - map__delete(WhereNeededMap0, Var, WhereNeededMap). + map.delete(WhereNeededMap0, Var, WhereNeededMap). %---------------------------------------------------------------------------% @@ -626,8 +626,8 @@ process_goal_internal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, ), goal_info_get_goal_path(GoalInfo0, GoalPath), BranchPoint = branch_point(GoalPath, switch(NumAlt)), - map__map_values(demand_var_everywhere, !WhereNeededMap), - map__init(BranchNeededMap0), + map.map_values(demand_var_everywhere, !WhereNeededMap), + map.init(BranchNeededMap0), process_cases(Cases0, Cases, BranchPoint, 1, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options, GoalPath, !.WhereNeededMap, BranchNeededMap0, BranchNeededMap, !RefinedGoals, !Changed), @@ -639,7 +639,7 @@ process_goal_internal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, ; GoalExpr0 = disj(Disjuncts0), goal_info_get_goal_path(GoalInfo0, GoalPath), - map__map_values(demand_var_everywhere, !WhereNeededMap), + map.map_values(demand_var_everywhere, !WhereNeededMap), process_disj(Disjuncts0, Disjuncts, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options, GoalPath, !.WhereNeededMap, !.WhereNeededMap, !:WhereNeededMap, @@ -650,7 +650,7 @@ process_goal_internal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, GoalExpr0 = if_then_else(Quant, Cond0, Then0, Else0), goal_info_get_goal_path(GoalInfo0, GoalPath), BranchPoint = branch_point(GoalPath, ite), - map__map_values(demand_var_everywhere, !WhereNeededMap), + map.map_values(demand_var_everywhere, !WhereNeededMap), process_ite(Cond0, Cond, Then0, Then, Else0, Else, BranchPoint, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options, GoalPath, !WhereNeededMap, !RefinedGoals, !Changed), @@ -687,22 +687,22 @@ process_goal_internal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, process_conj(Goals0, Goals, InitInstMap, _FinalInstMap, VarTypes, ModuleInfo, Options, !WhereNeededMap, !RefinedGoals, !Changed) :- build_bracketed_conj(Goals0, InitInstMap, BracketedGoals), - list__reverse(BracketedGoals, RevBracketedGoals), + list.reverse(BracketedGoals, RevBracketedGoals), process_rev_bracketed_conj(RevBracketedGoals, RevGoals, VarTypes, ModuleInfo, Options, !WhereNeededMap, !RefinedGoals, !Changed), - list__reverse(RevGoals, Goals). + list.reverse(RevGoals, Goals). :- pred build_bracketed_conj(list(hlds_goal)::in, instmap::in, list(bracketed_goal)::out) is det. build_bracketed_conj([], _, []). build_bracketed_conj([Goal | Goals], InitInstMap, BracketedGoals) :- - ( instmap__is_unreachable(InitInstMap) -> + ( instmap.is_unreachable(InitInstMap) -> BracketedGoals = [] ; Goal = _ - GoalInfo, goal_info_get_instmap_delta(GoalInfo, InstMapDelta), - instmap__apply_instmap_delta(InitInstMap, InstMapDelta, FinalInstMap), + instmap.apply_instmap_delta(InitInstMap, InstMapDelta, FinalInstMap), build_bracketed_conj(Goals, FinalInstMap, BracketedTail), BracketedGoal = bracketed_goal(Goal, InitInstMap, FinalInstMap), BracketedGoals = [BracketedGoal | BracketedTail] @@ -744,7 +744,7 @@ process_disj([Goal0 | Goals0], [Goal | Goals], InitInstMap, FinalInstMap, process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options, StartWhereNeededMap, WhereNeededMapFirst, !RefinedGoals, !Changed), - map__to_assoc_list(WhereNeededMapFirst, WhereNeededList), + map.to_assoc_list(WhereNeededMapFirst, WhereNeededList), add_where_needed_list(WhereNeededList, CurrentPath, !WhereNeededMap), process_disj(Goals0, Goals, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options, CurrentPath, StartWhereNeededMap, @@ -768,7 +768,7 @@ process_cases([case(Var, Goal0) | Cases0], [case(Var, Goal) | Cases], process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options, StartWhereNeededMap, WhereNeededMapFirst, !RefinedGoals, !Changed), - map__to_assoc_list(WhereNeededMapFirst, WhereNeededList), + map.to_assoc_list(WhereNeededMapFirst, WhereNeededList), add_alt_start(WhereNeededList, BranchPoint, BranchNum, CurrentPath, !WhereNeededMap), process_cases(Cases0, Cases, BranchPoint, BranchNum + 1, @@ -789,7 +789,7 @@ process_ite(Cond0, Cond, Then0, Then, Else0, Else, BranchPoint, CurrentPath, !WhereNeededMap, !RefinedGoals, !Changed) :- Cond0 = _ - CondInfo0, goal_info_get_instmap_delta(CondInfo0, InstMapDelta), - instmap__apply_instmap_delta(InitInstMap, InstMapDelta, InstMapCond), + instmap.apply_instmap_delta(InitInstMap, InstMapDelta, InstMapCond), process_goal(Else0, Else, InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options, !.WhereNeededMap, WhereNeededMapElse, !RefinedGoals, @@ -798,11 +798,11 @@ process_ite(Cond0, Cond, Then0, Then, Else0, Else, BranchPoint, Options, !.WhereNeededMap, WhereNeededMapThen, !RefinedGoals, !Changed), - map__init(BranchNeededMap0), - map__to_assoc_list(WhereNeededMapElse, WhereNeededListElse), + map.init(BranchNeededMap0), + map.to_assoc_list(WhereNeededMapElse, WhereNeededListElse), add_alt_start(WhereNeededListElse, BranchPoint, 2, CurrentPath, BranchNeededMap0, BranchNeededMap1), - map__to_assoc_list(WhereNeededMapThen, WhereNeededListThen), + map.to_assoc_list(WhereNeededMapThen, WhereNeededListThen), add_alt_start(WhereNeededListThen, BranchPoint, 1, CurrentPath, BranchNeededMap1, BranchNeededMap), merge_where_needed_maps(CurrentPath, @@ -824,7 +824,7 @@ process_ite(Cond0, Cond, Then0, Then, Else0, Else, BranchPoint, merge_where_needed_maps(CurrentPath, WhereNeededMap1, WhereNeededMap2, WhereNeededMap) :- - map__to_assoc_list(WhereNeededMap1, WhereNeededList1), + map.to_assoc_list(WhereNeededMap1, WhereNeededList1), add_where_needed_list(WhereNeededList1, CurrentPath, WhereNeededMap2, WhereNeededMap). @@ -834,12 +834,12 @@ merge_where_needed_maps(CurrentPath, add_where_needed_list([], _, !WhereNeededMap). add_where_needed_list([Var - BranchWhere | WhereNeededList], CurrentPath, !WhereNeededMap) :- - ( map__search(!.WhereNeededMap, Var, OldWhere) -> + ( map.search(!.WhereNeededMap, Var, OldWhere) -> where_needed_upper_bound(CurrentPath, BranchWhere, OldWhere, CombinedWhere), - svmap__det_update(Var, CombinedWhere, !WhereNeededMap) + svmap.det_update(Var, CombinedWhere, !WhereNeededMap) ; - svmap__det_insert(Var, BranchWhere, !WhereNeededMap) + svmap.det_insert(Var, BranchWhere, !WhereNeededMap) ), add_where_needed_list(WhereNeededList, CurrentPath, !WhereNeededMap). @@ -859,20 +859,20 @@ add_alt_start([Var - BranchWhere0 | WhereNeededList], BranchPoint, BranchNum, CurrentPath, !WhereNeededMap) :- ( BranchWhere0 = everywhere, - map__init(Empty), - set__singleton_set(BranchNumSet, BranchNum), - map__det_insert(Empty, BranchPoint, BranchNumSet, BranchMap), + map.init(Empty), + set.singleton_set(BranchNumSet, BranchNum), + map.det_insert(Empty, BranchPoint, BranchNumSet, BranchMap), BranchWhere = branches(BranchMap) ; BranchWhere0 = branches(_), BranchWhere = BranchWhere0 ), - ( map__search(!.WhereNeededMap, Var, OldWhere) -> + ( map.search(!.WhereNeededMap, Var, OldWhere) -> where_needed_upper_bound(CurrentPath, BranchWhere, OldWhere, CombinedWhere), - svmap__det_update(Var, CombinedWhere, !WhereNeededMap) + svmap.det_update(Var, CombinedWhere, !WhereNeededMap) ; - svmap__det_insert(Var, BranchWhere, !WhereNeededMap) + svmap.det_insert(Var, BranchWhere, !WhereNeededMap) ), add_alt_start(WhereNeededList, BranchPoint, BranchNum, CurrentPath, !WhereNeededMap). @@ -962,9 +962,9 @@ refine_cases([], [], !RefinedGoals, _, _). refine_cases([case(Var, Goal0) | Cases0], [case(Var, Goal) | Cases], !RefinedGoals, GoalPath, BranchNum) :- refine_goal(Goal0, Goal1, !RefinedGoals), - ( map__search(!.RefinedGoals, GoalPath - BranchNum, ToInsertGoals) -> + ( map.search(!.RefinedGoals, GoalPath - BranchNum, ToInsertGoals) -> insert_refine_goals(ToInsertGoals, Goal1, Goal), - svmap__delete(GoalPath - BranchNum, !RefinedGoals) + svmap.delete(GoalPath - BranchNum, !RefinedGoals) ; Goal = Goal1 ), @@ -978,9 +978,9 @@ refine_disj([], [], !RefinedGoals, _, _). refine_disj([Goal0 | Goals0], [Goal | Goals], !RefinedGoals, GoalPath, BranchNum) :- refine_goal(Goal0, Goal1, !RefinedGoals), - ( map__search(!.RefinedGoals, GoalPath - BranchNum, ToInsertGoals) -> + ( map.search(!.RefinedGoals, GoalPath - BranchNum, ToInsertGoals) -> insert_refine_goals(ToInsertGoals, Goal1, Goal), - svmap__delete(GoalPath - BranchNum, !RefinedGoals) + svmap.delete(GoalPath - BranchNum, !RefinedGoals) ; Goal = Goal1 ), @@ -996,15 +996,15 @@ refine_ite(Cond0, Cond, Then0, Then, Else0, Else, refine_goal(Then0, Then1, !RefinedGoals), refine_goal(Else0, Else1, !RefinedGoals), - ( map__search(!.RefinedGoals, GoalPath - 1, ToInsertGoalsThen) -> + ( map.search(!.RefinedGoals, GoalPath - 1, ToInsertGoalsThen) -> insert_refine_goals(ToInsertGoalsThen, Then1, Then), - svmap__delete(GoalPath - 1, !RefinedGoals) + svmap.delete(GoalPath - 1, !RefinedGoals) ; Then = Then1 ), - ( map__search(!.RefinedGoals, GoalPath - 2, ToInsertGoalsElse) -> + ( map.search(!.RefinedGoals, GoalPath - 2, ToInsertGoalsElse) -> insert_refine_goals(ToInsertGoalsElse, Else1, Else), - svmap__delete(GoalPath - 2, !RefinedGoals) + svmap.delete(GoalPath - 2, !RefinedGoals) ; Else = Else1 ). @@ -1013,7 +1013,7 @@ refine_ite(Cond0, Cond, Then0, Then, Else0, Else, hlds_goal::out) is det. insert_refine_goals(ToInsertGoals, Goal0, Goal) :- - list__append(ToInsertGoals, [Goal0], Conj), + list.append(ToInsertGoals, [Goal0], Conj), % XXX GoalInfo0 Goal0 = _ - GoalInfo0, conj_list_to_goal(Conj, GoalInfo0, Goal). @@ -1053,7 +1053,7 @@ where_needed_upper_bound(CurrentPath, where_needed_branches_upper_bound(CurrentPath, BranchesA, BranchesB, WhereNeeded) :- % should select smaller map to convert to list - map__to_assoc_list(BranchesA, BranchesList), + map.to_assoc_list(BranchesA, BranchesList), where_needed_branches_upper_bound_2(CurrentPath, BranchesList, BranchesB, WhereNeeded). @@ -1066,21 +1066,21 @@ where_needed_branches_upper_bound_2(_, [], where_needed_branches_upper_bound_2(CurrentPath, [First | Rest], Branches0, WhereNeeded) :- First = BranchPoint - NewAlts, - ( map__search(Branches0, BranchPoint, OldAlts) -> - set__union(OldAlts, NewAlts, Alts), + ( map.search(Branches0, BranchPoint, OldAlts) -> + set.union(OldAlts, NewAlts, Alts), BranchPoint = branch_point(GoalPath, BranchAlts), ( branch_point_is_complete(BranchAlts, Alts) -> ( get_parent_branch_point(GoalPath, ParentGoalPath, ParentGoalPathStep, ParentBranchAlt, ParentBranchNum), - \+ list__remove_suffix(CurrentPath, + \+ list.remove_suffix(CurrentPath, [ParentGoalPathStep | ParentGoalPath], _) -> - map__delete(Branches0, BranchPoint, Branches1), + map.delete(Branches0, BranchPoint, Branches1), ParentBranchPoint = branch_point(ParentGoalPath, ParentBranchAlt), - set__singleton_set(ParentAlts, ParentBranchNum), + set.singleton_set(ParentAlts, ParentBranchNum), where_needed_branches_upper_bound_2(CurrentPath, [ParentBranchPoint - ParentAlts | Rest], Branches1, WhereNeeded) @@ -1088,12 +1088,12 @@ where_needed_branches_upper_bound_2(CurrentPath, [First | Rest], WhereNeeded = everywhere ) ; - map__det_update(Branches0, BranchPoint, Alts, Branches1), + map.det_update(Branches0, BranchPoint, Alts, Branches1), where_needed_branches_upper_bound_2(CurrentPath, Rest, Branches1, WhereNeeded) ) ; - map__det_insert(Branches0, BranchPoint, NewAlts, Branches1), + map.det_insert(Branches0, BranchPoint, NewAlts, Branches1), where_needed_branches_upper_bound_2(CurrentPath, Rest, Branches1, WhereNeeded) ). @@ -1126,10 +1126,10 @@ get_parent_branch_point([First | Rest], Parent, ParentStep, is semidet. branch_point_is_complete(ite, Alts) :- - set__count(Alts, NumAlts), + set.count(Alts, NumAlts), NumAlts = 2. branch_point_is_complete(switch(NumFunctors), Alts) :- - set__count(Alts, NumAlts), + set.count(Alts, NumAlts), NumAlts = NumFunctors. %---------------------------------------------------------------------------% diff --git a/compiler/untupling.m b/compiler/untupling.m index a35458ec7..23eb8a171 100644 --- a/compiler/untupling.m +++ b/compiler/untupling.m @@ -87,7 +87,7 @@ % %-----------------------------------------------------------------------------% -:- module transform_hlds__untupling. +:- module transform_hlds.untupling. :- interface. :- import_module hlds.hlds_module. @@ -164,8 +164,8 @@ untuple_arguments(!ModuleInfo, !IO) :- expand_args_in_module(!ModuleInfo, TransformMap) :- module_info_predids(!.ModuleInfo, PredIds), - list__foldl3(expand_args_in_pred, PredIds, - !ModuleInfo, map__init, TransformMap, counter__init(0), _). + list.foldl3(expand_args_in_pred, PredIds, + !ModuleInfo, map.init, TransformMap, counter.init(0), _). :- pred expand_args_in_pred(pred_id::in, module_info::in, module_info::out, transform_map::in, transform_map::out, counter::in, counter::out) is det. @@ -186,12 +186,12 @@ expand_args_in_pred(PredId, !ModuleInfo, !TransformMap, !Counter) :- pred_info_get_class_context(PredInfo, constraints([], [])), pred_info_get_origin(PredInfo, user(_)), pred_info_arg_types(PredInfo, TypeVarSet, ExistQVars, ArgTypes), - varset__is_empty(TypeVarSet), + varset.is_empty(TypeVarSet), ExistQVars = [], at_least_one_expandable_type(ArgTypes, TypeTable) -> ProcIds = pred_info_non_imported_procids(PredInfo), - list__foldl3(expand_args_in_proc(PredId), ProcIds, + list.foldl3(expand_args_in_proc(PredId), ProcIds, !ModuleInfo, !TransformMap, !Counter) ; true @@ -243,7 +243,7 @@ expand_args_in_proc(PredId, ProcId, !ModuleInfo, !TransformMap, !Counter) :- requantify_proc(!ProcInfo), recompute_instmap_delta_proc(yes, !ProcInfo, !ModuleInfo), - counter__allocate(Num, !Counter), + counter.allocate(Num, !Counter), create_aux_pred(PredId, ProcId, PredInfo0, !.ProcInfo, Num, AuxPredId, AuxProcId, CallAux, AuxPredInfo, AuxProcInfo0, !ModuleInfo), @@ -252,7 +252,7 @@ expand_args_in_proc(PredId, ProcId, !ModuleInfo, !TransformMap, !Counter) :- AuxProcInfo0, AuxProcInfo), module_info_set_pred_proc_info(AuxPredId, AuxProcId, AuxPredInfo, AuxProcInfo, !ModuleInfo), - svmap__det_insert(proc(PredId, ProcId), + svmap.det_insert(proc(PredId, ProcId), transformed_proc(proc(AuxPredId, AuxProcId), CallAux), !TransformMap) ). @@ -269,9 +269,9 @@ expand_args_in_proc_2(HeadVars0, ArgModes0, HeadVars, ArgModes, !VarTypes, [], TypeTable), goal_info_get_context(snd(Goal0), Context), goal_info_set_context(Context, GoalInfo1, GoalInfo), - list__condense(ListOfHeadVars, HeadVars), - list__condense(ListOfArgModes, ArgModes), - build_untuple_map(HeadVars0, ListOfHeadVars, map__init, UntupleMap). + list.condense(ListOfHeadVars, HeadVars), + list.condense(ListOfArgModes, ArgModes), + build_untuple_map(HeadVars0, ListOfHeadVars, map.init, UntupleMap). :- pred expand_args_in_proc_3(list(prog_var)::in, list(mer_mode)::in, list(list(prog_var))::out, list(list(mer_mode))::out, @@ -305,8 +305,8 @@ expand_one_arg_in_proc(HeadVar0, ArgMode0, HeadVars, ArgModes, expand_args_in_proc_3(HeadVars1, ArgModes1, ListOfHeadVars, ListOfArgModes, !Goal, !VarSet, !VarTypes, ContainerTypes, TypeTable), - HeadVars = list__condense(ListOfHeadVars), - ArgModes = list__condense(ListOfArgModes) + HeadVars = list.condense(ListOfHeadVars), + ArgModes = list.condense(ListOfArgModes) ; MaybeHeadVarsAndArgModes = no, HeadVars = [HeadVar0], @@ -322,15 +322,14 @@ expand_one_arg_in_proc(HeadVar0, ArgMode0, HeadVars, ArgModes, expand_one_arg_in_proc_2(HeadVar0, ArgMode0, MaybeHeadVarsAndArgModes, !Goal, !VarSet, !VarTypes, ContainerTypes0, ContainerTypes, TypeTable) :- - map__lookup(!.VarTypes, HeadVar0, Type), - expand_argument(ArgMode0, Type, ContainerTypes0, TypeTable, - Expansion), + map.lookup(!.VarTypes, HeadVar0, Type), + expand_argument(ArgMode0, Type, ContainerTypes0, TypeTable, Expansion), ( Expansion = expansion(ConsId, NewTypes), - varset__lookup_name(!.VarSet, HeadVar0, ParentName), + varset.lookup_name(!.VarSet, HeadVar0, ParentName), create_untuple_vars(ParentName, 0, NewTypes, NewHeadVars, !VarSet, !VarTypes), - list__duplicate(list__length(NewHeadVars), ArgMode0, NewArgModes), + list.duplicate(list.length(NewHeadVars), ArgMode0, NewArgModes), MaybeHeadVarsAndArgModes = yes(NewHeadVars - NewArgModes), ( ArgMode0 = in_mode -> construct_functor(HeadVar0, ConsId, NewHeadVars, UnifGoal), @@ -356,9 +355,9 @@ expand_one_arg_in_proc_2(HeadVar0, ArgMode0, MaybeHeadVarsAndArgModes, create_untuple_vars(_, _, [], [], !VarSet, !VarTypes). create_untuple_vars(ParentName, Num, [Type | Types], [NewVar | NewVars], !VarSet, !VarTypes) :- - string__format("Untupled_%s_%d", [s(ParentName), i(Num)], Name), - svvarset__new_named_var(Name, NewVar, !VarSet), - svmap__det_insert(NewVar, Type, !VarTypes), + string.format("Untupled_%s_%d", [s(ParentName), i(Num)], Name), + svvarset.new_named_var(Name, NewVar, !VarSet), + svmap.det_insert(NewVar, Type, !VarTypes), create_untuple_vars(ParentName, Num+1, Types, NewVars, !VarSet, !VarTypes). :- pred conjoin_goals_keep_detism(hlds_goal::in, hlds_goal::in, @@ -367,7 +366,7 @@ create_untuple_vars(ParentName, Num, [Type | Types], [NewVar | NewVars], conjoin_goals_keep_detism(GoalA, GoalB, Goal) :- goal_to_conj_list(GoalA, GoalListA), goal_to_conj_list(GoalB, GoalListB), - list__append(GoalListA, GoalListB, GoalList), + list.append(GoalListA, GoalListB, GoalList), goal_list_determinism(GoalList, Determinism), goal_info_init(GoalInfo0), goal_info_set_determinism(Determinism, GoalInfo0, GoalInfo), @@ -381,7 +380,7 @@ build_untuple_map([OldVar | OldVars], [NewVars | NewVarss], !UntupleMap) :- ( NewVars = [OldVar] -> build_untuple_map(OldVars, NewVarss, !UntupleMap) ; - svmap__det_insert(OldVar, NewVars, !UntupleMap), + svmap.det_insert(OldVar, NewVars, !UntupleMap), build_untuple_map(OldVars, NewVarss, !UntupleMap) ). build_untuple_map([], [_| _], !_) :- @@ -426,9 +425,9 @@ create_aux_pred(PredId, ProcId, PredInfo, ProcInfo, Counter, PredName = pred_info_name(PredInfo), PredOrFunc = pred_info_is_pred_or_func(PredInfo), goal_info_get_context(GoalInfo, Context), - term__context_line(Context, Line), + term.context_line(Context, Line), proc_id_to_int(ProcId, ProcNo), - AuxNamePrefix = string__format("untupling_%d", [i(ProcNo)]), + AuxNamePrefix = string.format("untupling_%d", [i(ProcNo)]), make_pred_name_with_context(ModuleName, AuxNamePrefix, PredOrFunc, PredName, Line, Counter, AuxPredSymName), ( @@ -438,7 +437,7 @@ create_aux_pred(PredId, ProcId, PredInfo, ProcInfo, Counter, ), Origin = transformed(untuple(ProcNo), OrigOrigin, PredId), - hlds_pred__define_new_pred(Origin, Goal, CallAux, AuxHeadVars, _ExtraArgs, + hlds_pred.define_new_pred(Origin, Goal, CallAux, AuxHeadVars, _ExtraArgs, InitialAuxInstMap, AuxPredName, TVarSet, VarTypes, ClassContext, RttiVarMaps, VarSet, InstVarSet, Markers, address_is_not_taken, !ModuleInfo, proc(AuxPredId, AuxProcId)), @@ -461,7 +460,7 @@ create_aux_pred(PredId, ProcId, PredInfo, ProcInfo, Counter, fix_calls_to_expanded_procs(TransformMap, !ModuleInfo) :- module_info_predids(!.ModuleInfo, PredIds), - list__foldl(fix_calls_in_pred(TransformMap), PredIds, !ModuleInfo). + list.foldl(fix_calls_in_pred(TransformMap), PredIds, !ModuleInfo). :- pred fix_calls_in_pred(transform_map::in, pred_id::in, module_info::in, module_info::out) is det. @@ -469,7 +468,7 @@ fix_calls_to_expanded_procs(TransformMap, !ModuleInfo) :- fix_calls_in_pred(TransformMap, PredId, !ModuleInfo) :- module_info_pred_info(!.ModuleInfo, PredId, PredInfo), ProcIds = pred_info_non_imported_procids(PredInfo), - list__foldl(fix_calls_in_proc(TransformMap, PredId), ProcIds, !ModuleInfo). + list.foldl(fix_calls_in_proc(TransformMap, PredId), ProcIds, !ModuleInfo). :- pred fix_calls_in_proc(transform_map::in, pred_id::in, proc_id::in, module_info::in, module_info::out) is det. @@ -512,7 +511,7 @@ fix_calls_in_goal(Goal0 - GoalInfo0, Goal, !VarSet, !VarTypes, TransformMap, ModuleInfo) :- Goal0 = call(CalleePredId, CalleeProcId, OrigArgs, _, _, _), ( - map__search(TransformMap, proc(CalleePredId, CalleeProcId), + map.search(TransformMap, proc(CalleePredId, CalleeProcId), transformed_proc(_, CallAux0 - CallAuxInfo)) -> module_info_get_type_table(ModuleInfo, TypeTable), @@ -650,15 +649,15 @@ expand_call_args_2([], [], [], [], [], !VarSet, !VarTypes, _, _). expand_call_args_2([Arg0 | Args0], [ArgMode | ArgModes], Args, EnterUnifs, ExitUnifs, !VarSet, !VarTypes, ContainerTypes0, TypeTable) :- - map__lookup(!.VarTypes, Arg0, Arg0Type), + map.lookup(!.VarTypes, Arg0, Arg0Type), expand_argument(ArgMode, Arg0Type, ContainerTypes0, TypeTable, Expansion), ( Expansion = expansion(ConsId, Types), - NumVars = list__length(Types), - svvarset__new_vars(NumVars, ReplacementArgs, !VarSet), - svmap__det_insert_from_corresponding_lists( + NumVars = list.length(Types), + svvarset.new_vars(NumVars, ReplacementArgs, !VarSet), + svmap.det_insert_from_corresponding_lists( ReplacementArgs, Types, !VarTypes), - list__duplicate(NumVars, ArgMode, ReplacementModes), + list.duplicate(NumVars, ArgMode, ReplacementModes), ContainerTypes = [Arg0Type | ContainerTypes0], ( ArgMode = in_mode -> deconstruct_functor(Arg0, ConsId, ReplacementArgs, Unif), @@ -734,14 +733,14 @@ expand_type(Type, ContainerTypes, TypeTable, Expansion) :- type_to_ctor_and_args(Type, TypeCtor, TypeArgs), type_ctor_is_tuple(TypeCtor) -> - Arity = list__length(TypeArgs), + Arity = list.length(TypeArgs), ConsId = cons(unqualified("{}"), Arity), Expansion = expansion(ConsId, TypeArgs) ; % Expand a discriminated union type if it has only a % single functor and the type has no parameters. type_to_ctor_and_args(Type, TypeCtor, []), - map__search(TypeTable, TypeCtor, TypeDefn), + map.search(TypeTable, TypeCtor, TypeDefn), get_type_defn_tparams(TypeDefn, []), get_type_defn_body(TypeDefn, TypeBody), TypeBody ^ du_type_ctors = [SingleCtor], @@ -750,11 +749,11 @@ expand_type(Type, ContainerTypes, TypeTable, Expansion) :- SingleCtorArgs = SingleCtor ^ cons_args, SingleCtorArgs \= [], % Prevent infinite loop with recursive types. - \+ list__member(Type, ContainerTypes) + \+ list.member(Type, ContainerTypes) -> - Arity = list__length(SingleCtorArgs), + Arity = list.length(SingleCtorArgs), ConsId = cons(SingleCtorName, Arity), - ExpandedTypes = list__map(snd, SingleCtorArgs), + ExpandedTypes = list.map(snd, SingleCtorArgs), Expansion = expansion(ConsId, ExpandedTypes) ; Expansion = no_expansion diff --git a/compiler/unused_args.m b/compiler/unused_args.m index fa1f79eed..b4f7c264d 100644 --- a/compiler/unused_args.m +++ b/compiler/unused_args.m @@ -44,7 +44,7 @@ %-----------------------------------------------------------------------------% -:- module transform_hlds__unused_args. +:- module transform_hlds.unused_args. :- interface. :- import_module analysis. @@ -54,7 +54,7 @@ %-----------------------------------------------------------------------------% -:- pred unused_args__process_module(module_info::in, module_info::out, +:- pred unused_args.process_module(module_info::in, module_info::out, io::di, io::uo) is det. %-----------------------------------------------------------------------------% @@ -195,7 +195,7 @@ unused_args_call_from_string(String) = unused_args_call(Arity) :- :- instance answer_pattern(unused_args_answer) where []. :- instance partial_order(unused_args_answer) where [ (more_precise_than(unused_args(Args1), unused_args(Args2)) :- - set__subset(sorted_list_to_set(Args2), sorted_list_to_set(Args1)) + set.subset(sorted_list_to_set(Args2), sorted_list_to_set(Args1)) ), equivalent(Args, Args) ]. @@ -208,7 +208,7 @@ unused_args_call_from_string(String) = unused_args_call(Arity) :- :- func unused_args_answer_to_string(unused_args_answer) = string. unused_args_answer_to_string(unused_args(Args)) = - string__join_list(" ", list__map(int_to_string, Args)). + string.join_list(" ", list.map(int_to_string, Args)). :- func unused_args_answer_from_string(string) = unused_args_answer is semidet. @@ -218,47 +218,47 @@ unused_args_answer_from_string(String) = unused_args(Args) :- %-----------------------------------------------------------------------------% -unused_args__process_module(!ModuleInfo, !IO) :- - globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO), +process_module(!ModuleInfo, !IO) :- + globals.io_lookup_bool_option(very_verbose, VeryVerbose, !IO), init_var_usage(VarUsage0, PredProcs, ProcCallInfo0, !ModuleInfo, !IO), % maybe_write_string(VeryVerbose, "% Finished initialisation.\n", !IO), unused_args_pass(PredProcs, VarUsage0, VarUsage), % maybe_write_string(VeryVerbose, "% Finished analysis.\n", !IO), - map__init(UnusedArgInfo0), + map.init(UnusedArgInfo0), get_unused_arg_info(!.ModuleInfo, PredProcs, VarUsage, UnusedArgInfo0, UnusedArgInfo), - map__keys(UnusedArgInfo, PredProcsToFix), - globals__io_lookup_bool_option(make_optimization_interface, MakeOpt, !IO), + map.keys(UnusedArgInfo, PredProcsToFix), + globals.io_lookup_bool_option(make_optimization_interface, MakeOpt, !IO), ( MakeOpt = yes, module_info_get_name(!.ModuleInfo, ModuleName), module_name_to_file_name(ModuleName, ".opt.tmp", no, OptFileName, !IO), - io__open_append(OptFileName, OptFileRes, !IO), + io.open_append(OptFileName, OptFileRes, !IO), ( OptFileRes = ok(OptFile), MaybeOptFile = yes(OptFile) ; OptFileRes = error(IOError), - io__error_message(IOError, IOErrorMessage), - io__write_strings(["Cannot open `", OptFileName, "' for output: ", + io.error_message(IOError, IOErrorMessage), + io.write_strings(["Cannot open `", OptFileName, "' for output: ", IOErrorMessage], !IO), - io__set_exit_status(1, !IO), + io.set_exit_status(1, !IO), MaybeOptFile = no ) ; MakeOpt = no, MaybeOptFile = no ), - globals__io_lookup_bool_option(warn_unused_args, DoWarn, !IO), + globals.io_lookup_bool_option(warn_unused_args, DoWarn, !IO), ( ( DoWarn = yes ; MakeOpt = yes ) -> - set__init(WarnedPredIds0), + set.init(WarnedPredIds0), output_warnings_and_pragmas(!.ModuleInfo, UnusedArgInfo, MaybeOptFile, DoWarn, PredProcsToFix, WarnedPredIds0, !IO) ; @@ -266,32 +266,32 @@ unused_args__process_module(!ModuleInfo, !IO) :- ), ( MaybeOptFile = yes(OptFile2), - io__close_output(OptFile2, !IO) + io.close_output(OptFile2, !IO) ; MaybeOptFile = no ), - globals__io_lookup_bool_option(make_analysis_registry, + globals.io_lookup_bool_option(make_analysis_registry, MakeAnalysisRegistry, !IO), ( MakeAnalysisRegistry = yes, module_info_get_analysis_info(!.ModuleInfo, AnalysisInfo0), - list__foldl2(record_intermod_dependencies(!.ModuleInfo), + list.foldl2(record_intermod_dependencies(!.ModuleInfo), PredProcs, AnalysisInfo0, AnalysisInfo, !IO), module_info_set_analysis_info(AnalysisInfo, !ModuleInfo) ; MakeAnalysisRegistry = no ), - globals__io_lookup_bool_option(optimize_unused_args, DoFixup, !IO), + globals.io_lookup_bool_option(optimize_unused_args, DoFixup, !IO), ( DoFixup = yes, - list__foldl3(create_new_pred(UnusedArgInfo), PredProcsToFix, + list.foldl3(create_new_pred(UnusedArgInfo), PredProcsToFix, ProcCallInfo0, ProcCallInfo, !ModuleInfo, !IO), % maybe_write_string(VeryVerbose, "% Finished new preds.\n", % !IO), fixup_unused_args(VarUsage, PredProcs, ProcCallInfo, !ModuleInfo, VeryVerbose, !IO), % maybe_write_string(VeryVerbose, "% Fixed up goals.\n", !IO), - ( map__is_empty(ProcCallInfo) -> + ( map.is_empty(ProcCallInfo) -> true ; % The dependencies have changed, so the dependency graph is now @@ -316,8 +316,8 @@ unused_args__process_module(!ModuleInfo, !IO) :- io::di, io::uo) is det. init_var_usage(VarUsage, PredProcList, ProcCallInfo, !ModuleInfo, !IO) :- - map__init(ProcCallInfo0), - map__init(VarUsage0), + map.init(ProcCallInfo0), + map.init(VarUsage0), module_info_predids(!.ModuleInfo, PredIds), setup_local_var_usage(PredIds, VarUsage0, VarUsage, [], PredProcList, ProcCallInfo0, ProcCallInfo, !ModuleInfo, !IO). @@ -392,8 +392,8 @@ setup_proc_args(PredId, ProcId, !VarUsage, !PredProcs, !OptProcs, !ModuleInfo, module_info_pred_proc_info(!.ModuleInfo, PredId, ProcId, PredInfo, ProcInfo), some [!VarDep] ( - map__init(!:VarDep), - globals__io_lookup_bool_option(intermodule_analysis, Intermod, !IO), + map.init(!:VarDep), + globals.io_lookup_bool_option(intermodule_analysis, Intermod, !IO), ( % Don't use the intermodule analysis info when we have the clauses % (opt_imported preds) since we may be able to do better with the @@ -417,11 +417,11 @@ setup_proc_args(PredId, ProcId, !VarUsage, !PredProcs, !OptProcs, !ModuleInfo, ( UnusedArgs = [_|_], proc_info_headvars(ProcInfo, HeadVars), - list__map(list__index1_det(HeadVars), UnusedArgs, + list.map(list.index1_det(HeadVars), UnusedArgs, UnusedVars), initialise_vardep(UnusedVars, !.VarDep, VarDep), - svmap__set(proc(PredId, ProcId), VarDep, !VarUsage), - globals__io_lookup_bool_option(optimize_unused_args, + svmap.set(proc(PredId, ProcId), VarDep, !VarUsage), + globals.io_lookup_bool_option(optimize_unused_args, Optimize, !IO), ( Optimize = yes, @@ -441,7 +441,7 @@ setup_proc_args(PredId, ProcId, !VarUsage, !PredProcs, !OptProcs, !ModuleInfo, ( IsLocal = yes, % XXX makes too many requests - globals__io_lookup_bool_option(make_analysis_registry, + globals.io_lookup_bool_option(make_analysis_registry, MakeAnalysisRegistry, !IO), ( MakeAnalysisRegistry = yes, @@ -465,7 +465,7 @@ setup_proc_args(PredId, ProcId, !VarUsage, !PredProcs, !OptProcs, !ModuleInfo, pred_info_is_imported(PredInfo) ; pred_info_is_pseudo_imported(PredInfo), - hlds_pred__in_in_unification_proc_id(ProcId) + hlds_pred.in_in_unification_proc_id(ProcId) ; % Unused argument optimization and tabling are % not compatible with each other. @@ -476,7 +476,7 @@ setup_proc_args(PredId, ProcId, !VarUsage, !PredProcs, !OptProcs, !ModuleInfo, true ; proc_info_vartypes(ProcInfo, VarTypes), - map__keys(VarTypes, Vars), + map.keys(VarTypes, Vars), initialise_vardep(Vars, !VarDep), setup_output_args(!.ModuleInfo, ProcInfo, !VarDep), @@ -495,7 +495,7 @@ setup_proc_args(PredId, ProcId, !VarUsage, !PredProcs, !OptProcs, !ModuleInfo, proc_info_goal(ProcInfo, Goal), Info = traverse_info(!.ModuleInfo, VarTypes), traverse_goal(Info, Goal, !VarDep), - svmap__set(proc(PredId, ProcId), !.VarDep, !VarUsage), + svmap.set(proc(PredId, ProcId), !.VarDep, !VarUsage), !:PredProcs = [proc(PredId, ProcId) | !.PredProcs] ) @@ -506,9 +506,9 @@ setup_proc_args(PredId, ProcId, !VarUsage, !PredProcs, !OptProcs, !ModuleInfo, initialise_vardep([], !VarDep). initialise_vardep([Var | Vars], !VarDep) :- - set__init(VDep), - set__init(Args), - svmap__set(Var, unused(VDep, Args), !VarDep), + set.init(VDep), + set.init(Args), + svmap.set(Var, unused(VDep, Args), !VarDep), initialise_vardep(Vars, !VarDep). %-----------------------------------------------------------------------------% @@ -534,9 +534,9 @@ setup_typeinfo_deps([Var | Vars], VarTypeMap, PredProcId, RttiVarMaps, pred_proc_id::in, rtti_varmaps::in, var_dep::in, var_dep::out) is det. setup_typeinfo_dep(Var, VarTypeMap, PredProcId, RttiVarMaps, !VarDep) :- - map__lookup(VarTypeMap, Var, Type), - prog_type__vars(Type, TVars), - list__map((pred(TVar::in, TypeInfoVar::out) is det :- + map.lookup(VarTypeMap, Var, Type), + prog_type.vars(Type, TVars), + list.map((pred(TVar::in, TypeInfoVar::out) is det :- rtti_lookup_type_info_locn(RttiVarMaps, TVar, Locn), type_info_locn_var(Locn, TypeInfoVar) ), TVars, TypeInfoVars), @@ -544,7 +544,7 @@ setup_typeinfo_dep(Var, VarTypeMap, PredProcId, RttiVarMaps, !VarDep) :- (pred(TVar::in, VarDepA::in, VarDepB::out) is det :- add_arg_dep(TVar, PredProcId, Var, VarDepA, VarDepB) ), - list__foldl(AddArgDependency, TypeInfoVars, !VarDep). + list.foldl(AddArgDependency, TypeInfoVars, !VarDep). % Get output arguments for a procedure given the headvars and the % argument modes, and set them as used. @@ -555,7 +555,7 @@ setup_typeinfo_dep(Var, VarTypeMap, PredProcId, RttiVarMaps, !VarDep) :- setup_output_args(ModuleInfo, ProcInfo, !VarDep) :- proc_info_instantiated_head_vars(ModuleInfo, ProcInfo, ChangedInstHeadVars), - list__foldl(set_var_used, ChangedInstHeadVars, !VarDep). + list.foldl(set_var_used, ChangedInstHeadVars, !VarDep). % Searches for the dependencies of a variable, succeeds if the variable % is definitely used. @@ -564,14 +564,14 @@ setup_output_args(ModuleInfo, ProcInfo, !VarDep) :- var_is_used(PredProc, Var, VarUsage) :- \+ ( - map__search(VarUsage, PredProc, UsageInfos), - map__contains(UsageInfos, Var) + map.search(VarUsage, PredProc, UsageInfos), + map.contains(UsageInfos, Var) ). :- pred local_var_is_used(var_dep::in, prog_var::in) is semidet. local_var_is_used(VarDep, Var) :- - \+ map__contains(VarDep, Var). + \+ map.contains(VarDep, Var). % Add a list of aliases for a variable. % @@ -579,11 +579,11 @@ local_var_is_used(VarDep, Var) :- var_dep::in, var_dep::out) is det. add_aliases(Var, Aliases, !VarDep) :- - ( map__search(!.VarDep, Var, VarInf0) -> + ( map.search(!.VarDep, Var, VarInf0) -> VarInf0 = unused(VarDep0, ArgDep), - set__insert_list(VarDep0, Aliases, VarDep), + set.insert_list(VarDep0, Aliases, VarDep), VarInf = unused(VarDep, ArgDep), - map__det_update(!.VarDep, Var, VarInf, !:VarDep) + map.det_update(!.VarDep, Var, VarInf, !:VarDep) ; true ). @@ -592,18 +592,18 @@ add_aliases(Var, Aliases, !VarDep) :- is det. set_list_vars_used(Vars, !VarDep) :- - map__delete_list(!.VarDep, Vars, !:VarDep). + map.delete_list(!.VarDep, Vars, !:VarDep). :- pred set_var_used(prog_var::in, var_dep::in, var_dep::out) is det. set_var_used(Var, !VarDep) :- - map__delete(!.VarDep, Var, !:VarDep). + map.delete(!.VarDep, Var, !:VarDep). :- pred lookup_local_var(var_dep::in, prog_var::in, usage_info::out) is semidet. lookup_local_var(VarDep, Var, UsageInfo) :- - map__search(VarDep, Var, UsageInfo). + map.search(VarDep, Var, UsageInfo). %-----------------------------------------------------------------------------% % @@ -651,7 +651,7 @@ traverse_goal(Info, Goal, !VarDep) :- traverse_goal(Info, SubGoal, !VarDep) ; GoalExpr = generic_call(GenericCall, Args, _, _), - goal_util__generic_call_vars(GenericCall, CallArgs), + goal_util.generic_call_vars(GenericCall, CallArgs), set_list_vars_used(CallArgs, !VarDep), set_list_vars_used(Args, !VarDep) ; @@ -664,7 +664,7 @@ traverse_goal(Info, Goal, !VarDep) :- Arg = foreign_arg(Var, MaybeNameAndMode, _, _), MaybeNameAndMode = yes(_) ), - list__filter_map(ArgIsUsed, Args ++ ExtraArgs, UsedVars), + list.filter_map(ArgIsUsed, Args ++ ExtraArgs, UsedVars), set_list_vars_used(UsedVars, !VarDep) ; GoalExpr = unify(LHS, RHS, _, Unify, _), @@ -755,9 +755,9 @@ add_pred_call_arg_dep(PredProc, LocalArguments, HeadVarIds, !VarDep) :- add_arg_dep(Var, PredProc, Arg, !VarDep) :- ( lookup_local_var(!.VarDep, Var, VarUsage0) -> VarUsage0 = unused(VarDep, ArgDep0), - set__insert(ArgDep0, PredProc - Arg, ArgDep), + set.insert(ArgDep0, PredProc - Arg, ArgDep), VarUsage = unused(VarDep, ArgDep), - svmap__det_update(Var, VarUsage, !VarDep) + svmap.det_update(Var, VarUsage, !VarDep) ; true ). @@ -776,7 +776,7 @@ partition_deconstruct_args(Info, ArgVars, ArgModes, InputVars, OutputVars) :- partition_deconstruct_args(Info, Vars, Modes, InputVars1, OutputVars1), Mode = ((InitialInst1 - InitialInst2) -> (FinalInst1 - FinalInst2)), - map__lookup(Info ^ vartypes, Var, Type), + map.lookup(Info ^ vartypes, Var, Type), % If the inst of the argument of the LHS is changed, % the argument is input. @@ -818,9 +818,9 @@ add_construction_aliases(_, [], !VarDep). add_construction_aliases(Alias, [Var | Vars], !VarDep) :- ( lookup_local_var(!.VarDep, Var, VarInfo0) -> VarInfo0 = unused(VarDep0, ArgDep), - set__insert(VarDep0, Alias, VarDep), + set.insert(VarDep0, Alias, VarDep), VarInfo = unused(VarDep, ArgDep), - svmap__set(Var, VarInfo, !VarDep) + svmap.set(Var, VarInfo, !VarDep) ; true ), @@ -875,13 +875,13 @@ unused_args_single_pass([PredProc | PredProcs], !Changed, !VarUsage) :- var_usage::in, var_usage::out) is det. unused_args_check_proc(PredProcId, !Changed, !VarUsage) :- - map__lookup(!.VarUsage, PredProcId, LocalUsages0), - map__keys(LocalUsages0, Vars), + map.lookup(!.VarUsage, PredProcId, LocalUsages0), + map.keys(LocalUsages0, Vars), unused_args_check_all_vars(!.VarUsage, Vars, no, LocalChanged, LocalUsages0, LocalUsages), ( LocalChanged = yes, - svmap__det_update(PredProcId, LocalUsages, !VarUsage), + svmap.det_update(PredProcId, LocalUsages, !VarUsage), !:Changed = yes ; LocalChanged = no @@ -901,7 +901,7 @@ unused_args_check_all_vars(VarUsage, [Var | Vars], !Changed, !LocalVars) :- % Check whether any arguments that the current variable % depends on are used. some [Argument] ( - set__member(Argument, ArgDep0), + set.member(Argument, ArgDep0), Argument = PredProc - ArgVar, var_is_used(PredProc, ArgVar, VarUsage) ) @@ -909,7 +909,7 @@ unused_args_check_all_vars(VarUsage, [Var | Vars], !Changed, !LocalVars) :- % Check whether any variables that the current variable % depends on are used. some [X] ( - set__member(X, VarDep0), + set.member(X, VarDep0), local_var_is_used(!.LocalVars, X) ) ) @@ -936,11 +936,11 @@ get_unused_arg_info(_, [], _, !UnusedArgInfo). get_unused_arg_info(ModuleInfo, [PredProc | PredProcs], VarUsage, !UnusedArgInfo) :- PredProc = proc(PredId, ProcId), - map__lookup(VarUsage, PredProc, LocalVarUsage), + map.lookup(VarUsage, PredProc, LocalVarUsage), module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo), proc_info_headvars(ProcInfo, HeadVars), get_unused_arg_nos(LocalVarUsage, HeadVars, 1, UnusedArgs), - svmap__det_insert(PredProc, UnusedArgs, !UnusedArgInfo), + svmap.det_insert(PredProc, UnusedArgs, !UnusedArgInfo), get_unused_arg_info(ModuleInfo, PredProcs, VarUsage, !UnusedArgInfo). %-----------------------------------------------------------------------------% @@ -971,13 +971,13 @@ get_unused_arg_info(ModuleInfo, [PredProc | PredProcs], VarUsage, create_new_pred(UnusedArgInfo, proc(PredId, ProcId), !ProcCallInfo, !ModuleInfo, !IO) :- - map__lookup(UnusedArgInfo, proc(PredId, ProcId), UnusedArgs), + map.lookup(UnusedArgInfo, proc(PredId, ProcId), UnusedArgs), module_info_pred_proc_info(!.ModuleInfo, PredId, ProcId, OrigPredInfo, OrigProcInfo), PredModule = pred_info_module(OrigPredInfo), PredName = pred_info_name(OrigPredInfo), - globals__io_lookup_bool_option(intermodule_analysis, Intermod, !IO), + globals.io_lookup_bool_option(intermodule_analysis, Intermod, !IO), ( Intermod = yes, module_info_get_analysis_info(!.ModuleInfo, AnalysisInfo0), @@ -993,20 +993,20 @@ create_new_pred(UnusedArgInfo, proc(PredId, ProcId), !ProcCallInfo, IntermodResultsTriples : list({unused_args_call, unused_args_answer, analysis_status}), AnalysisInfo0, AnalysisInfo1, !IO), - IntermodOldAnswers = list__map((func({_, Ans, _}) = Ans), + IntermodOldAnswers = list.map((func({_, Ans, _}) = Ans), IntermodResultsTriples), FilterUnused = (pred(VersionAnswer::in) is semidet :- VersionAnswer \= Answer, VersionAnswer \= unused_args([]), Answer `more_precise_than` VersionAnswer ), - IntermodOldArgLists = list__map(get_unused_args, - list__filter(FilterUnused, IntermodOldAnswers)), + IntermodOldArgLists = list.map(get_unused_args, + list.filter(FilterUnused, IntermodOldAnswers)), % XXX: optimal? If we know some output arguments are not going to be % used by the caller then more input arguments could be deduced to be % unused. This analysis doesn't handle that yet. - globals__io_lookup_bool_option(make_analysis_registry, + globals.io_lookup_bool_option(make_analysis_registry, MakeAnalysisRegistry, !IO), ( MakeAnalysisRegistry = yes, @@ -1017,7 +1017,7 @@ create_new_pred(UnusedArgInfo, proc(PredId, ProcId), !ProcCallInfo, % intermodule-optimization; they may not be here.) % (See exception_analysis.should_write_exception_info/4). -> - analysis__record_result(ModuleId, FuncId, Call, Answer, optimal, + analysis.record_result(ModuleId, FuncId, Call, Answer, optimal, AnalysisInfo1, AnalysisInfo) ; AnalysisInfo = AnalysisInfo1 @@ -1060,7 +1060,7 @@ create_new_pred(UnusedArgInfo, proc(PredId, ProcId), !ProcCallInfo, % Assign the old procedure to a new predicate, which will be fixed up % in fixup_unused_args. - map__set(NewProcs0, ProcId, OrigProcInfo, NewProcs), + map.set(NewProcs0, ProcId, OrigProcInfo, NewProcs), pred_info_set_procedures(NewProcs, NewPredInfo0, NewPredInfo), % Add the new proc to the pred table. @@ -1070,7 +1070,7 @@ create_new_pred(UnusedArgInfo, proc(PredId, ProcId), !ProcCallInfo, % Add the new proc to the proc_call_info map. PredSymName = qualified(PredModule, NewPredName), - map__det_insert(!.ProcCallInfo, proc(PredId, ProcId), + map.det_insert(!.ProcCallInfo, proc(PredId, ProcId), call_info(NewPredId, ProcId, PredSymName, UnusedArgs), !:ProcCallInfo), @@ -1087,7 +1087,7 @@ create_new_pred(UnusedArgInfo, proc(PredId, ProcId), !ProcCallInfo, % again without changing anything else, we won't remember to % produce the same forwarding predicates. If some callers refer % to those forwarding predicates then linking will fail. - list__foldl( + list.foldl( make_intermod_proc(PredId, NewPredId, ProcId, NewPredName, OrigPredInfo, OrigProcInfo, UnusedArgs), IntermodOldArgLists, !ModuleInfo) @@ -1113,7 +1113,7 @@ make_intermod_proc(PredId, NewPredId, ProcId, NewPredName, remove_listof_elements(1, UnusedArgs2, ArgModes0, IntermodArgModes), proc_info_set_argmodes(IntermodArgModes, ExtraProc1, ExtraProc), pred_info_procedures(ExtraPredInfo0, ExtraProcs0), - map__set(ExtraProcs0, ProcId, ExtraProc, ExtraProcs), + map.set(ExtraProcs0, ProcId, ExtraProc, ExtraProcs), pred_info_set_procedures(ExtraProcs, ExtraPredInfo0, ExtraPredInfo), module_info_get_predicate_table(!.ModuleInfo, PredTable0), predicate_table_insert(ExtraPredInfo, _, PredTable0, PredTable), @@ -1131,22 +1131,21 @@ make_new_pred_info(ModuleInfo, UnusedArgs, Status, proc(PredId, ProcId), pred_info_get_origin(!.PredInfo, OrigOrigin), % Create a unique new pred name using the old proc_id. ( - string__prefix(Name0, "__"), - \+ string__prefix(Name0, "__LambdaGoal__") + string.prefix(Name0, "__"), + \+ string.prefix(Name0, "__LambdaGoal__") -> ( % Fix up special pred names. OrigOrigin = special_pred(_SpecialId - TypeCtor) -> - type_util__type_ctor_module(ModuleInfo, TypeCtor, TypeModule), - type_util__type_ctor_name(ModuleInfo, TypeCtor, TypeName), - type_util__type_ctor_arity(ModuleInfo, TypeCtor, TypeArity), - string__int_to_string(TypeArity, TypeAr), + type_ctor_module(ModuleInfo, TypeCtor, TypeModule), + type_ctor_name(ModuleInfo, TypeCtor, TypeName), + type_ctor_arity(ModuleInfo, TypeCtor, TypeArity), + string.int_to_string(TypeArity, TypeArityStr), sym_name_to_string(TypeModule, TypeModuleString0), - string__replace_all(TypeModuleString0, ".", "__", - TypeModuleString), - string__append_list([Name0, "_", TypeModuleString, - "__", TypeName, "_", TypeAr], Name1) + string.replace_all(TypeModuleString0, ".", "__", TypeModuleString), + string.append_list([Name0, "_", TypeModuleString, "__", TypeName, + "_", TypeArityStr], Name1) ; % The special predicate has already been specialised. Name1 = Name0 @@ -1176,8 +1175,8 @@ make_new_pred_info(ModuleInfo, UnusedArgs, Status, proc(PredId, ProcId), % Since this pred_info isn't built until after the polymorphism % transformation is complete, we just use dummy maps for the class % constraints. - map__init(EmptyProofs), - map__init(EmptyConstraintMap), + map.init(EmptyProofs), + map.init(EmptyConstraintMap), Origin = transformed(unused_argument_elimination(UnusedArgs), OrigOrigin, PredId), pred_info_init(PredModule, Name, Arity, PredOrFunc, Context, Origin, @@ -1206,9 +1205,9 @@ create_call_goal(UnusedArgs, NewPredId, NewProcId, PredModule, PredName, goal_info_set_determinism(Determinism, GoalInfo0, GoalInfo1), proc_info_vartypes(!.OldProc, VarTypes0), - set__list_to_set(HeadVars, NonLocals), - map__apply_to_list(HeadVars, VarTypes0, VarTypeList), - map__from_corresponding_lists(HeadVars, VarTypeList, VarTypes1), + set.list_to_set(HeadVars, NonLocals), + map.apply_to_list(HeadVars, VarTypes0, VarTypeList), + map.from_corresponding_lists(HeadVars, VarTypeList, VarTypes1), % The varset should probably be fixed up, but it shouldn't make % too much difference. proc_info_varset(!.OldProc, VarSet0), @@ -1245,7 +1244,7 @@ make_imported_unused_args_pred_info(OptProc, UnusedArgs, !ProcCallInfo, proc_info_argmodes(ProcInfo1, ArgModes0), remove_listof_elements(1, UnusedArgs, ArgModes0, ArgModes), proc_info_set_argmodes(ArgModes, ProcInfo1, ProcInfo), - map__set(NewProcs0, ProcId, ProcInfo, NewProcs), + map.set(NewProcs0, ProcId, ProcInfo, NewProcs), pred_info_set_procedures(NewProcs, NewPredInfo0, NewPredInfo), % Add the new proc to the pred table. @@ -1256,7 +1255,7 @@ make_imported_unused_args_pred_info(OptProc, UnusedArgs, !ProcCallInfo, PredName = pred_info_name(NewPredInfo), PredSymName = qualified(PredModule, PredName), % Add the new proc to the proc_call_info map. - svmap__det_insert(proc(PredId, ProcId), + svmap.det_insert(proc(PredId, ProcId), call_info(NewPredId, ProcId, PredSymName, UnusedArgs), !ProcCallInfo). :- pred remove_listof_elements(int::in, list(int)::in, @@ -1271,7 +1270,7 @@ remove_listof_elements(ArgNo, ElemsToRemove, !List) :- !.List = [Head | Tail], NextArg = ArgNo + 1, remove_listof_elements(NextArg, ElemsToRemove, Tail, NewTail), - ( list__member(ArgNo, ElemsToRemove) -> + ( list.member(ArgNo, ElemsToRemove) -> !:List = NewTail ; !:List = [Head | NewTail] @@ -1288,7 +1287,7 @@ get_unused_arg_nos(_, [], _, []). get_unused_arg_nos(LocalVars, [HeadVar | HeadVars], ArgNo, UnusedArgs) :- get_unused_arg_nos(LocalVars, HeadVars, NextArg, UnusedArgsTail), NextArg = ArgNo + 1, - ( map__contains(LocalVars, HeadVar) -> + ( map.contains(LocalVars, HeadVar) -> UnusedArgs = [ArgNo | UnusedArgsTail] ; UnusedArgs = UnusedArgsTail @@ -1302,7 +1301,7 @@ get_unused_arg_nos(LocalVars, [HeadVar | HeadVars], ArgNo, UnusedArgs) :- fixup_unused_args(VarUsage, PredProcs, ProcCallInfo, !ModuleInfo, VeryVerbose, !IO) :- - list__foldl2(fixup_unused_args_proc(VeryVerbose, VarUsage, ProcCallInfo), + list.foldl2(fixup_unused_args_proc(VeryVerbose, VarUsage, ProcCallInfo), PredProcs, !ModuleInfo, !IO). % Note - we should probably remove unused variables from the type map. @@ -1316,16 +1315,16 @@ fixup_unused_args_proc(VeryVerbose, VarUsage, ProcCallInfo, PredProc, ( VeryVerbose = yes, PredProc = proc(PredId, ProcId), - io__write_string("% Fixing up `", !IO), + io.write_string("% Fixing up `", !IO), predicate_name(!.ModuleInfo, PredId, Name), predicate_arity(!.ModuleInfo, PredId, Arity), proc_id_to_int(ProcId, ProcInt), - io__write_string(Name, !IO), - io__write_string("/", !IO), - io__write_int(Arity, !IO), - io__write_string("' in mode ", !IO), - io__write_int(ProcInt, !IO), - io__write_char('\n', !IO) + io.write_string(Name, !IO), + io.write_string("/", !IO), + io.write_int(Arity, !IO), + io.write_string("' in mode ", !IO), + io.write_int(ProcInt, !IO), + io.write_char('\n', !IO) ; VeryVerbose = no ), @@ -1338,7 +1337,7 @@ do_fixup_unused_args(VarUsage, proc(OldPredId, OldProcId), ProcCallInfo, ModuleInfo0, ModuleInfo) :- ( % Work out which proc we should be fixing up. - map__search(ProcCallInfo, proc(OldPredId, OldProcId), + map.search(ProcCallInfo, proc(OldPredId, OldProcId), call_info(NewPredId, NewProcId, _, UnusedArgs0)) -> UnusedArgs = UnusedArgs0, @@ -1349,8 +1348,8 @@ do_fixup_unused_args(VarUsage, proc(OldPredId, OldProcId), ProcCallInfo, PredId = OldPredId, ProcId = OldProcId ), - map__lookup(VarUsage, proc(OldPredId, OldProcId), UsageInfos), - map__keys(UsageInfos, UnusedVars), + map.lookup(VarUsage, proc(OldPredId, OldProcId), UsageInfos), + map.keys(UsageInfos, UnusedVars), module_info_pred_proc_info(ModuleInfo0, PredId, ProcId, PredInfo0, ProcInfo0), proc_info_vartypes(ProcInfo0, VarTypes0), @@ -1379,7 +1378,7 @@ do_fixup_unused_args(VarUsage, proc(OldPredId, OldProcId), ProcCallInfo, ( Changed = yes, % If anything has changed, rerun quantification. - set__list_to_set(HeadVars, NonLocals), + set.list_to_set(HeadVars, NonLocals), implicitly_quantify_goal(NonLocals, _, !Goal, VarSet1, VarSet, VarTypes1, VarTypes), proc_info_set_goal(!.Goal, !ProcInfo), @@ -1391,9 +1390,9 @@ do_fixup_unused_args(VarUsage, proc(OldPredId, OldProcId), ProcCallInfo, ProcInfo = !.ProcInfo ), - map__set(Procs0, ProcId, ProcInfo, Procs), + map.set(Procs0, ProcId, ProcInfo, Procs), pred_info_set_procedures(Procs, PredInfo0, PredInfo), - map__set(Preds0, PredId, PredInfo, Preds), + map.set(Preds0, PredId, PredInfo, Preds), module_info_set_preds(Preds, ModuleInfo0, ModuleInfo). :- type fixup_info @@ -1452,7 +1451,7 @@ fixup_goal_expr(GoalExpr0 - GoalInfo0, Goal, !Info, Changed) :- fixup_goal(Cond0, Cond, !Info, Changed1), fixup_goal(Then0, Then, !Info, Changed2), fixup_goal(Else0, Else, !Info, Changed3), - bool__or_list([Changed1, Changed2, Changed3], Changed), + bool.or_list([Changed1, Changed2, Changed3], Changed), GoalExpr = if_then_else(Vars, Cond, Then, Else), Goal = GoalExpr - GoalInfo0 ; @@ -1463,7 +1462,7 @@ fixup_goal_expr(GoalExpr0 - GoalInfo0, Goal, !Info, Changed) :- ; GoalExpr0 = call(PredId, ProcId, ArgVars0, Builtin, UnifyC, _Name), ProcCallInfo = !.Info ^ fixup_proc_call_info, - ( map__search(ProcCallInfo, proc(PredId, ProcId), CallInfo) -> + ( map.search(ProcCallInfo, proc(PredId, ProcId), CallInfo) -> CallInfo = call_info(NewPredId, NewProcId, NewName, UnusedArgs), Changed = yes, remove_listof_elements(1, UnusedArgs, ArgVars0, ArgVars), @@ -1496,10 +1495,10 @@ fixup_goal_expr(GoalExpr0 - GoalInfo0, Goal, !Info, Changed) :- % The code in here should be kept in sync with the treatment of % foreign_procs in traverse_goal. Changed0 = no, - map__init(Subst0), - list__map_foldl3(rename_apart_unused_foreign_arg, + map.init(Subst0), + list.map_foldl3(rename_apart_unused_foreign_arg, Args0, Args, Subst0, Subst1, !Info, Changed0, ArgsChanged), - list__map_foldl3(rename_apart_unused_foreign_arg, + list.map_foldl3(rename_apart_unused_foreign_arg, ExtraArgs0, ExtraArgs, Subst1, Subst, !Info, ArgsChanged, Changed), GoalExpr = foreign_proc(Attributes, PredId, ProcId, Args, ExtraArgs, Impl), @@ -1524,19 +1523,19 @@ rename_apart_unused_foreign_arg(Arg0, Arg, !Subst, !Info, !Changed) :- MaybeName = no, VarSet0 = !.Info ^ fixup_varset, VarTypes0 = !.Info ^ fixup_vartypes, - ( varset__search_name(VarSet0, OldVar, Name) -> - varset__new_named_var(VarSet0, Name, NewVar, VarSet) + ( varset.search_name(VarSet0, OldVar, Name) -> + varset.new_named_var(VarSet0, Name, NewVar, VarSet) ; - varset__new_var(VarSet0, NewVar, VarSet) + varset.new_var(VarSet0, NewVar, VarSet) ), - map__lookup(VarTypes0, OldVar, Type), - map__det_insert(VarTypes0, NewVar, Type, VarTypes), + map.lookup(VarTypes0, OldVar, Type), + map.det_insert(VarTypes0, NewVar, Type, VarTypes), !:Info = !.Info ^ fixup_varset := VarSet, !:Info = !.Info ^ fixup_vartypes := VarTypes, % It is possible for an unnamed input argument to occur more than once % in the list of foreign_args. - svmap__set(OldVar, NewVar, !Subst), + svmap.set(OldVar, NewVar, !Subst), Arg = foreign_arg(NewVar, MaybeName, OrigType, BoxPolicy), !:Changed = yes ). @@ -1609,16 +1608,16 @@ need_unify(ModuleInfo, UnusedVars, Unify, Changed) :- % Target unused => we don't need the assignment % Source unused => Target unused Unify = assign(Target, _Source), - \+ list__member(Target, UnusedVars), + \+ list.member(Target, UnusedVars), Changed = no ; % LVar unused => we don't need the unification Unify = construct(LVar, _, _, _, _, _, _), - \+ list__member(LVar, UnusedVars), + \+ list.member(LVar, UnusedVars), Changed = no ; Unify = deconstruct(LVar, _, ArgVars, ArgModes, CanFail, _CanCGC), - \+ list__member(LVar, UnusedVars), + \+ list.member(LVar, UnusedVars), ( % Are any of the args unused? If so, we need to to fix up the % goal_info. @@ -1652,7 +1651,7 @@ check_deconstruct_args(ModuleInfo, UnusedVars, Args, Modes, !.SomeUsed, ( ArgMode = ((Inst1 - Inst2) -> _), mode_is_output(ModuleInfo, (Inst1 -> Inst2)), - list__member(ArgVar, UnusedVars) + list.member(ArgVar, UnusedVars) -> check_deconstruct_args(ModuleInfo, UnusedVars, ArgVars, ArgModes, !.SomeUsed, _), @@ -1689,13 +1688,13 @@ fixup_goal_info(UnusedVars, !GoalInfo) :- % predicate should be unused in all of the modes of a predicate, so we only % need to put out one warning for each predicate. :- pred output_warnings_and_pragmas(module_info::in, unused_arg_info::in, - maybe(io__output_stream)::in, bool::in, pred_proc_list::in, + maybe(io.output_stream)::in, bool::in, pred_proc_list::in, set(pred_id)::in, io::di, io::uo) is det. output_warnings_and_pragmas(_, _, _, _, [], _, !IO). output_warnings_and_pragmas(ModuleInfo, UnusedArgInfo, WriteOptPragmas, DoWarn, [proc(PredId, ProcId) | PredProcIds], !.WarnedPredIds, !IO) :- - ( map__search(UnusedArgInfo, proc(PredId, ProcId), UnusedArgs) -> + ( map.search(UnusedArgInfo, proc(PredId, ProcId), UnusedArgs) -> module_info_pred_info(ModuleInfo, PredId, PredInfo), ( Name = pred_info_name(PredInfo), @@ -1715,15 +1714,15 @@ output_warnings_and_pragmas(ModuleInfo, UnusedArgInfo, WriteOptPragmas, % Don't warn about lambda expressions not using arguments. % (The warning message for these doesn't contain context, % so it's useless). - \+ string__sub_string_search(Name, "__LambdaGoal__", _), + \+ string.sub_string_search(Name, "__LambdaGoal__", _), % Don't warn for a specialized version. \+ ( - string__sub_string_search(Name, "__ho", Position), - string__length(Name, Length), + string.sub_string_search(Name, "__ho", Position), + string.length(Name, Length), IdLen = Length - Position - 4, - string__right(Name, IdLen, Id), - string__to_int(Id, _) + string.right(Name, IdLen, Id), + string.to_int(Id, _) ), % XXX We don't currently generate pragmas for the automatically % generated class instance methods because the compiler aborts @@ -1744,7 +1743,7 @@ output_warnings_and_pragmas(ModuleInfo, UnusedArgInfo, WriteOptPragmas, output_warnings_and_pragmas(ModuleInfo, UnusedArgInfo, WriteOptPragmas, DoWarn, PredProcIds, !.WarnedPredIds, !IO). -:- pred write_unused_args_to_opt_file(maybe(io__output_stream)::in, +:- pred write_unused_args_to_opt_file(maybe(io.output_stream)::in, pred_info::in, proc_id::in, list(int)::in, io::di, io::uo) is det. write_unused_args_to_opt_file(no, _, _, _, !IO). @@ -1761,11 +1760,11 @@ write_unused_args_to_opt_file(yes(OptStream), PredInfo, ProcId, UnusedArgs, Name = pred_info_name(PredInfo), Arity = pred_info_orig_arity(PredInfo), PredOrFunc = pred_info_is_pred_or_func(PredInfo), - io__set_output_stream(OptStream, OldOutput, !IO), + io.set_output_stream(OptStream, OldOutput, !IO), proc_id_to_int(ProcId, ModeNum), mercury_output_pragma_unused_args(PredOrFunc, qualified(Module, Name), Arity, ModeNum, UnusedArgs, !IO), - io__set_output_stream(OldOutput, _, !IO) + io.set_output_stream(OldOutput, _, !IO) ; true ). @@ -1777,14 +1776,14 @@ write_unused_args_to_opt_file(yes(OptStream), PredInfo, ProcId, UnusedArgs, maybe_warn_unused_args(no, _, _, _, _, _, !WarnedPredIds, !IO). maybe_warn_unused_args(yes, _ModuleInfo, PredInfo, PredId, ProcId, UnusedArgs0, !WarnedPredIds, !IO) :- - ( set__member(PredId, !.WarnedPredIds) -> + ( set.member(PredId, !.WarnedPredIds) -> true ; - set__insert(!.WarnedPredIds, PredId, !:WarnedPredIds), + set.insert(!.WarnedPredIds, PredId, !:WarnedPredIds), pred_info_procedures(PredInfo, Procs), - map__lookup(Procs, ProcId, Proc), + map.lookup(Procs, ProcId, Proc), proc_info_headvars(Proc, HeadVars), - list__length(HeadVars, NumHeadVars), + list.length(HeadVars, NumHeadVars), % Strip off the extra type_info arguments % inserted at the front by polymorphism.m @@ -1820,7 +1819,7 @@ adjust_unused_args(NumToDrop, [UnusedArgNo | UnusedArgNos0], AdjUnusedArgs) :- io::di, io::uo) is det. report_unused_args(PredInfo, UnusedArgs, !IO) :- - list__length(UnusedArgs, NumArgs), + list.length(UnusedArgs, NumArgs), pred_info_context(PredInfo, Context), PredOrFunc = pred_info_is_pred_or_func(PredInfo), Module = pred_info_module(PredInfo), diff --git a/compiler/var_locn.m b/compiler/var_locn.m index 69d503514..708b03e6c 100644 --- a/compiler/var_locn.m +++ b/compiler/var_locn.m @@ -1,7 +1,7 @@ %---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %---------------------------------------------------------------------------% -% Copyright (C) 2000-2005 The University of Melbourne. +% Copyright (C) 2000-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %---------------------------------------------------------------------------% @@ -17,7 +17,7 @@ %----------------------------------------------------------------------------% -:- module ll_backend__var_locn. +:- module ll_backend.var_locn. :- interface. :- import_module parse_tree.prog_data. @@ -485,23 +485,23 @@ init_state(VarLocs, Liveness, VarSet, VarTypes, StackSlots, FollowVars, Options, VarLocnInfo) :- - map__init(VarStateMap0), - map__init(LocVarMap0), + map.init(VarStateMap0), + map.init(LocVarMap0), init_state_2(VarLocs, yes(Liveness), VarStateMap0, VarStateMap, LocVarMap0, LocVarMap), - exprn_aux__init_exprn_opts(Options, ExprnOpts), + exprn_aux.init_exprn_opts(Options, ExprnOpts), FollowVars = abs_follow_vars(FollowVarMap, NextNonReserved), - set__init(AcquiredRegs), + set.init(AcquiredRegs), VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots, ExprnOpts, FollowVarMap, NextNonReserved, VarStateMap, LocVarMap, AcquiredRegs, 0, []). reinit_state(VarLocs, !VarLocnInfo) :- - map__init(VarStateMap0), - map__init(LocVarMap0), + map.init(VarStateMap0), + map.init(LocVarMap0), init_state_2(VarLocs, no, VarStateMap0, VarStateMap, LocVarMap0, LocVarMap), - set__init(AcquiredRegs), + set.init(AcquiredRegs), !.VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots, ExprnOpts, FollowVarMap, NextNonReserved, _, _, _, _, _), !:VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots, ExprnOpts, @@ -517,7 +517,7 @@ init_state_2([Var - Lval | Rest], MaybeLiveness, !VarStateMap, !LocVarMap) :- expect(is_root_lval(Lval), this_file, "init_state_2: unexpected lval"), ( MaybeLiveness = yes(Liveness), - \+ set__member(Var, Liveness) + \+ set.member(Var, Liveness) -> % If a variable is not live, then we do not record its % state. If we did, then the variable will never die @@ -527,13 +527,13 @@ init_state_2([Var - Lval | Rest], MaybeLiveness, !VarStateMap, !LocVarMap) :- % storing the value of a "live" variable. true ; - ( map__search(!.VarStateMap, Var, _) -> + ( map.search(!.VarStateMap, Var, _) -> unexpected(this_file, "init_state_2: repeated variable") ; - set__singleton_set(NewLocs, Lval), - set__init(Using), + set.singleton_set(NewLocs, Lval), + set.init(Using), State = state(NewLocs, no, no, Using, alive), - map__det_insert(!.VarStateMap, Var, State, !:VarStateMap) + map.det_insert(!.VarStateMap, Var, State, !:VarStateMap) ), make_var_depend_on_lval_roots(Var, Lval, !LocVarMap) ), @@ -543,9 +543,9 @@ init_state_2([Var - Lval | Rest], MaybeLiveness, !VarStateMap, !LocVarMap) :- get_var_locations(VLI, VarLocations) :- get_var_state_map(VLI, VarStateMap), - map__to_assoc_list(VarStateMap, VarLocList), - list__filter_map(convert_live_to_lval_set, VarLocList, LiveVarLocList), - map__from_assoc_list(LiveVarLocList, VarLocations). + map.to_assoc_list(VarStateMap, VarLocList), + list.filter_map(convert_live_to_lval_set, VarLocList, LiveVarLocList), + map.from_assoc_list(LiveVarLocList, VarLocations). :- pred convert_live_to_lval_set(pair(prog_var, var_state)::in, pair(prog_var, set(lval))::out) is semidet. @@ -556,12 +556,12 @@ convert_live_to_lval_set(Var - State, Var - Lvals) :- %----------------------------------------------------------------------------% clobber_all_regs(OkToDeleteAny, !VLI) :- - set_acquired(set__init, !VLI), + set_acquired(set.init, !VLI), set_locked(0, !VLI), set_exceptions([], !VLI), get_loc_var_map(!.VLI, LocVarMap0), get_var_state_map(!.VLI, VarStateMap0), - map__keys(LocVarMap0, Locs), + map.keys(LocVarMap0, Locs), clobber_regs_in_maps(Locs, OkToDeleteAny, LocVarMap0, LocVarMap, VarStateMap0, VarStateMap), set_loc_var_map(LocVarMap, !VLI), @@ -569,7 +569,7 @@ clobber_all_regs(OkToDeleteAny, !VLI) :- clobber_regs(Regs, !VLI) :- get_acquired(!.VLI, Acquired0), - Acquired = set__delete_list(Acquired0, Regs), + Acquired = set.delete_list(Acquired0, Regs), set_acquired(Acquired, !VLI), get_loc_var_map(!.VLI, LocVarMap0), get_var_state_map(!.VLI, VarStateMap0), @@ -587,11 +587,11 @@ clobber_regs_in_maps([Lval | Lvals], OkToDeleteAny, !LocVarMap, !VarStateMap) :- ( Lval = reg(_, _), - map__search(!.LocVarMap, Lval, DependentVarsSet) + map.search(!.LocVarMap, Lval, DependentVarsSet) -> - map__delete(!.LocVarMap, Lval, !:LocVarMap), - set__to_sorted_list(DependentVarsSet, DependentVars), - list__foldl(clobber_lval_in_var_state_map(Lval, [], OkToDeleteAny), + map.delete(!.LocVarMap, Lval, !:LocVarMap), + set.to_sorted_list(DependentVarsSet, DependentVars), + list.foldl(clobber_lval_in_var_state_map(Lval, [], OkToDeleteAny), DependentVars, !VarStateMap) ; true @@ -622,25 +622,25 @@ clobber_lval_in_var_state_map(Lval, OkToDeleteVars, OkToDeleteAny, Var, try_clobber_lval_in_var_state_map(Lval, OkToDeleteVars, OkToDeleteAny, Var, !VarStateMap) :- - map__lookup(!.VarStateMap, Var, State0), + map.lookup(!.VarStateMap, Var, State0), State0 = state(LvalSet0, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), - LvalSet = set__filter(lval_does_not_support_lval(Lval), LvalSet0), + LvalSet = set.filter(lval_does_not_support_lval(Lval), LvalSet0), State = state(LvalSet, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), ( nonempty_state(State) ; - list__member(Var, OkToDeleteVars) + list.member(Var, OkToDeleteVars) ; OkToDeleteAny = yes ; DeadOrAlive = dead, - set__to_sorted_list(Using, UsingVars), + set.to_sorted_list(Using, UsingVars), recursive_using_vars_dead_and_ok_to_delete(UsingVars, !.VarStateMap, OkToDeleteVars) ), - map__det_update(!.VarStateMap, Var, State, !:VarStateMap). + map.det_update(!.VarStateMap, Var, State, !:VarStateMap). :- pred recursive_using_vars_dead_and_ok_to_delete( list(prog_var)::in, var_state_map::in, list(prog_var)::in) is semidet. @@ -649,12 +649,12 @@ recursive_using_vars_dead_and_ok_to_delete([], _, _). recursive_using_vars_dead_and_ok_to_delete([Var | Vars], VarStateMap, OkToDeleteVars) :- ( - list__member(Var, OkToDeleteVars) + list.member(Var, OkToDeleteVars) ; - map__lookup(VarStateMap, Var, State), + map.lookup(VarStateMap, Var, State), State = state(_, _, _, Using, DeadOrAlive), DeadOrAlive = dead, - set__to_sorted_list(Using, UsingVars), + set.to_sorted_list(Using, UsingVars), recursive_using_vars_dead_and_ok_to_delete(UsingVars, VarStateMap, OkToDeleteVars) ), @@ -666,24 +666,24 @@ recursive_using_vars_dead_and_ok_to_delete([Var | Vars], VarStateMap, assign_var_to_var(Var, OldVar, !VLI) :- check_var_is_unknown(!.VLI, Var), get_var_state_map(!.VLI, VarStateMap0), - map__lookup(VarStateMap0, OldVar, OldState0), + map.lookup(VarStateMap0, OldVar, OldState0), OldState0 = state(Lvals, MaybeConstRval, MaybeExprRval, Using0, DeadOrAlive), ( MaybeExprRval = yes(_), - State = state(Lvals, MaybeConstRval, yes(var(OldVar)), set__init, + State = state(Lvals, MaybeConstRval, yes(var(OldVar)), set.init, alive), - set__insert(Using0, Var, Using), + set.insert(Using0, Var, Using), OldState = state(Lvals, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), - map__det_update(VarStateMap0, OldVar, OldState, VarStateMap1) + map.det_update(VarStateMap0, OldVar, OldState, VarStateMap1) ; MaybeExprRval = no, - set__init(Empty), + set.init(Empty), State = state(Lvals, MaybeConstRval, no, Empty, alive), VarStateMap1 = VarStateMap0 ), - map__det_insert(VarStateMap1, Var, State, VarStateMap), + map.det_insert(VarStateMap1, Var, State, VarStateMap), set_var_state_map(VarStateMap, !VLI), get_loc_var_map(!.VLI, LocVarMap0), @@ -696,7 +696,7 @@ assign_lval_to_var(ModuleInfo, Var, Lval0, StaticCellInfo, Code, !VLI) :- check_var_is_unknown(!.VLI, Var), ( Lval0 = field(yes(Ptag), var(BaseVar), const(int_const(Offset))) -> get_var_state_map(!.VLI, VarStateMap0), - map__lookup(VarStateMap0, BaseVar, BaseState), + map.lookup(VarStateMap0, BaseVar, BaseState), BaseState = state(BaseVarLvals, MaybeConstBaseVarRval, _MaybeExprRval, _UsingVars, _DeadOrAlive), ( @@ -710,22 +710,22 @@ assign_lval_to_var(ModuleInfo, Var, Lval0, StaticCellInfo, Code, !VLI) :- SelectedArgRval) -> MaybeConstRval = yes(SelectedArgRval), - Lvals = set__map(add_field_offset(yes(Ptag), + Lvals = set.map(add_field_offset(yes(Ptag), const(int_const(Offset))), BaseVarLvals), - set__init(Using), + set.init(Using), State = state(Lvals, MaybeConstRval, no, Using, alive), - map__det_insert(VarStateMap0, Var, State, VarStateMap), + map.det_insert(VarStateMap0, Var, State, VarStateMap), set_var_state_map(VarStateMap, !VLI), get_loc_var_map(!.VLI, LocVarMap0), make_var_depend_on_lvals_roots(Var, Lvals, LocVarMap0, LocVarMap), set_loc_var_map(LocVarMap, !VLI) ; - set__init(Lvals), + set.init(Lvals), Expr = lval(Lval0), - set__init(Using), + set.init(Using), State = state(Lvals, no, yes(Expr), Using, alive), - map__det_insert(VarStateMap0, Var, State, VarStateMap1), + map.det_insert(VarStateMap0, Var, State, VarStateMap1), add_use_ref(BaseVar, Var, VarStateMap1, VarStateMap), set_var_state_map(VarStateMap, !VLI) ), @@ -734,9 +734,9 @@ assign_lval_to_var(ModuleInfo, Var, Lval0, StaticCellInfo, Code, !VLI) :- materialize_vars_in_lval(ModuleInfo, Lval0, Lval, Code, !VLI), get_var_state_map(!.VLI, VarStateMap0), - set__singleton_set(LvalSet, Lval), - State = state(LvalSet, no, no, set__init, alive), - map__det_insert(VarStateMap0, Var, State, VarStateMap), + set.singleton_set(LvalSet, Lval), + State = state(LvalSet, no, no, set.init, alive), + map.det_insert(VarStateMap0, Var, State, VarStateMap), set_var_state_map(VarStateMap, !VLI), get_loc_var_map(!.VLI, LocVarMap0), @@ -757,8 +757,8 @@ assign_const_to_var(Var, ConstRval0, !VLI) :- get_var_state_map(!.VLI, VarStateMap0), get_exprn_opts(!.VLI, ExprnOpts), ( expr_is_constant(VarStateMap0, ExprnOpts, ConstRval0, ConstRval) -> - State = state(set__init, yes(ConstRval), no, set__init, alive), - map__det_insert(VarStateMap0, Var, State, VarStateMap), + State = state(set.init, yes(ConstRval), no, set.init, alive), + map.det_insert(VarStateMap0, Var, State, VarStateMap), set_var_state_map(VarStateMap, !VLI) ; unexpected(this_file, "set_var_state_map: supposed constant isn't") @@ -770,11 +770,11 @@ assign_expr_to_var(Var, Rval, empty, !VLI) :- check_var_is_unknown(!.VLI, Var), get_var_state_map(!.VLI, VarStateMap0), - State = state(set__init, no, yes(Rval), set__init, alive), - map__det_insert(VarStateMap0, Var, State, VarStateMap1), + State = state(set.init, no, yes(Rval), set.init, alive), + map.det_insert(VarStateMap0, Var, State, VarStateMap1), - exprn_aux__vars_in_rval(Rval, ContainedVars0), - list__remove_dups(ContainedVars0, ContainedVars), + exprn_aux.vars_in_rval(Rval, ContainedVars0), + list.remove_dups(ContainedVars0, ContainedVars), add_use_refs(ContainedVars, Var, VarStateMap1, VarStateMap), set_var_state_map(VarStateMap, !VLI). @@ -790,11 +790,11 @@ add_use_refs([ContainedVar | ContainedVars], UsingVar, !VarStateMap) :- var_state_map::in, var_state_map::out) is det. add_use_ref(ContainedVar, UsingVar, !VarStateMap) :- - map__lookup(!.VarStateMap, ContainedVar, State0), + map.lookup(!.VarStateMap, ContainedVar, State0), State0 = state(Lvals, MaybeConstRval, MaybeExprRval, Using0, DeadOrAlive), - set__insert(Using0, UsingVar, Using), + set.insert(Using0, UsingVar, Using), State = state(Lvals, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), - map__det_update(!.VarStateMap, ContainedVar, State, !:VarStateMap). + map.det_update(!.VarStateMap, ContainedVar, State, !:VarStateMap). %----------------------------------------------------------------------------% @@ -839,7 +839,7 @@ assign_dynamic_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag, Vector, select_preferred_reg_or_stack_check(!.VLI, Var, Lval), get_var_name(!.VLI, Var, VarName), - list__length(Vector, Size), + list.length(Vector, Size), ( ReserveWordAtStart = yes, ( @@ -860,7 +860,7 @@ assign_dynamic_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag, Vector, CellCode = node([ incr_hp(Lval, yes(Ptag), TotalOffset, const(int_const(TotalSize)), TypeMsg) - - string__append("Allocating heap for ", VarName) + - string.append("Allocating heap for ", VarName) ]), set_magic_var_location(Var, Lval, !VLI), ( @@ -895,7 +895,7 @@ assign_cell_args(ModuleInfo, [MaybeRval0 | MaybeRvals0], Ptag, Base, Offset, !VLI) ), get_vartypes(!.VLI, VarTypes), - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ( is_dummy_argument_type(ModuleInfo, Type) -> AssignCode = empty ; @@ -934,12 +934,12 @@ add_additional_lval_for_var(Var, Lval, !VLI) :- set_loc_var_map(LocVarMap, !VLI), get_var_state_map(!.VLI, VarStateMap0), - map__lookup(VarStateMap0, Var, State0), + map.lookup(VarStateMap0, Var, State0), State0 = state(LvalSet0, MaybeConstRval, MaybeExprRval0, Using, DeadOrAlive), - set__insert(LvalSet0, Lval, LvalSet), + set.insert(LvalSet0, Lval, LvalSet), State = state(LvalSet, MaybeConstRval, no, Using, DeadOrAlive), - map__det_update(VarStateMap0, Var, State, VarStateMap), + map.det_update(VarStateMap0, Var, State, VarStateMap), set_var_state_map(VarStateMap, !VLI), remove_use_refs(MaybeExprRval0, Var, !VLI). @@ -950,8 +950,8 @@ add_additional_lval_for_var(Var, Lval, !VLI) :- remove_use_refs(MaybeExprRval, UsingVar, !VLI) :- ( MaybeExprRval = yes(ExprRval), - exprn_aux__vars_in_rval(ExprRval, ContainedVars0), - list__remove_dups(ContainedVars0, ContainedVars), + exprn_aux.vars_in_rval(ExprRval, ContainedVars0), + list.remove_dups(ContainedVars0, ContainedVars), remove_use_refs_2(ContainedVars, UsingVar, !VLI) ; MaybeExprRval = no @@ -963,18 +963,18 @@ remove_use_refs(MaybeExprRval, UsingVar, !VLI) :- remove_use_refs_2([], _, !VLI). remove_use_refs_2([ContainedVar | ContainedVars], UsingVar, !VLI) :- get_var_state_map(!.VLI, VarStateMap0), - map__lookup(VarStateMap0, ContainedVar, State0), + map.lookup(VarStateMap0, ContainedVar, State0), State0 = state(Lvals, MaybeConstRval, MaybeExprRval, Using0, DeadOrAlive), - ( set__remove(Using0, UsingVar, Using1) -> + ( set.remove(Using0, UsingVar, Using1) -> Using = Using1 ; unexpected(this_file, "remove_use_refs_2: using ref not present") ), State = state(Lvals, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), - map__det_update(VarStateMap0, ContainedVar, State, VarStateMap), + map.det_update(VarStateMap0, ContainedVar, State, VarStateMap), set_var_state_map(VarStateMap, !VLI), ( - set__empty(Using), + set.empty(Using), DeadOrAlive = dead -> var_becomes_dead(ContainedVar, no, !VLI) @@ -998,9 +998,9 @@ set_magic_var_location(Var, Lval, !VLI) :- set_loc_var_map(LocVarMap, !VLI), get_var_state_map(!.VLI, VarStateMap0), - set__singleton_set(LvalSet, Lval), - State = state(LvalSet, no, no, set__init, alive), - map__det_insert(VarStateMap0, Var, State, VarStateMap), + set.singleton_set(LvalSet, Lval), + State = state(LvalSet, no, no, set.init, alive), + map.det_insert(VarStateMap0, Var, State, VarStateMap), set_var_state_map(VarStateMap, !VLI). %----------------------------------------------------------------------------% @@ -1009,7 +1009,7 @@ set_magic_var_location(Var, Lval, !VLI) :- check_var_is_unknown(VLI, Var) :- get_var_state_map(VLI, VarStateMap0), - ( map__search(VarStateMap0, Var, _) -> + ( map.search(VarStateMap0, Var, _) -> get_var_name(VLI, Var, Name), Msg = "assign_to_var: existing definition of variable " ++ Name, unexpected(this_file, Msg) @@ -1021,9 +1021,9 @@ check_var_is_unknown(VLI, Var) :- produce_var(ModuleInfo, Var, Rval, Code, !VLI) :- get_var_state_map(!.VLI, VarStateMap), - map__lookup(VarStateMap, Var, State), + map.lookup(VarStateMap, Var, State), State = state(Lvals, MaybeConstRval, MaybeExprRval, _, _), - set__to_sorted_list(Lvals, LvalsList), + set.to_sorted_list(Lvals, LvalsList), ( maybe_select_lval_or_rval(LvalsList, MaybeConstRval, Rval1) -> @@ -1031,9 +1031,9 @@ produce_var(ModuleInfo, Var, Rval, Code, !VLI) :- Code = empty ; MaybeExprRval = yes(var(ExprVar)), - map__lookup(VarStateMap, ExprVar, ExprState), + map.lookup(VarStateMap, ExprVar, ExprState), ExprState = state(ExprLvals, ExprMaybeConstRval, _, _, _), - set__to_sorted_list(ExprLvals, ExprLvalsList), + set.to_sorted_list(ExprLvals, ExprLvalsList), maybe_select_lval_or_rval(ExprLvalsList, ExprMaybeConstRval, Rval2) -> % This path is designed to generate efficient code @@ -1048,9 +1048,9 @@ produce_var(ModuleInfo, Var, Rval, Code, !VLI) :- produce_var_in_reg(ModuleInfo, Var, Lval, Code, !VLI) :- get_var_state_map(!.VLI, VarStateMap), - map__lookup(VarStateMap, Var, State), + map.lookup(VarStateMap, Var, State), State = state(Lvals, _, _, _, _), - set__to_sorted_list(Lvals, LvalList), + set.to_sorted_list(Lvals, LvalList), ( select_reg_lval(LvalList, SelectLval) -> Lval = SelectLval, Code = empty @@ -1061,9 +1061,9 @@ produce_var_in_reg(ModuleInfo, Var, Lval, Code, !VLI) :- produce_var_in_reg_or_stack(ModuleInfo, Var, Lval, Code, !VLI) :- get_var_state_map(!.VLI, VarStateMap), - map__lookup(VarStateMap, Var, State), + map.lookup(VarStateMap, Var, State), State = state(Lvals, _, _, _, _), - set__to_sorted_list(Lvals, LvalList), + set.to_sorted_list(Lvals, LvalList), ( select_reg_or_stack_lval(LvalList, SelectLval) -> Lval = SelectLval, Code = empty @@ -1094,8 +1094,8 @@ place_vars(ModuleInfo, VarLocns, Code, !VLI) :- % stack slots.) However, we do make one exception: if the variable being % moved by a freeing up operation is in VarLocns, then it is OK to move it % to the location assigned to it by VarLocns. - assoc_list__values(VarLocns, Lvals), - code_util__max_mentioned_reg(Lvals, MaxReg), + assoc_list.values(VarLocns, Lvals), + code_util.max_mentioned_reg(Lvals, MaxReg), lock_regs(MaxReg, VarLocns, !VLI), actually_place_vars(ModuleInfo, VarLocns, Code, !VLI), unlock_regs(!VLI). @@ -1118,15 +1118,15 @@ place_var(ModuleInfo, Var, Target, Code, !VLI) :- actually_place_var(ModuleInfo, Var, Target, ForbiddenLvals, Code, !VLI) :- get_acquired(!.VLI, Acquired), - ( set__member(Target, Acquired) -> + ( set.member(Target, Acquired) -> unexpected(this_file, "actually_place_var: target is acquired reg") ; true ), get_var_state_map(!.VLI, VarStateMap0), - map__lookup(VarStateMap0, Var, State0), + map.lookup(VarStateMap0, Var, State0), State0 = state(Lvals0, _, _, _, _), - ( set__member(Target, Lvals0) -> + ( set.member(Target, Lvals0) -> Code = empty ; free_up_lval(ModuleInfo, Target, [Var], ForbiddenLvals, FreeCode, @@ -1161,16 +1161,16 @@ actually_place_var(ModuleInfo, Var, Target, ForbiddenLvals, Code, !VLI) :- get_var_name(!.VLI, Var, VarName), ( ForbiddenLvals = [], - string__append("Placing ", VarName, Msg) + string.append("Placing ", VarName, Msg) ; ForbiddenLvals = [_ | _], - string__int_to_string(list__length(ForbiddenLvals), + string.int_to_string(list.length(ForbiddenLvals), LengthStr), - string__append_list(["Placing ", VarName, + string.append_list(["Placing ", VarName, " (depth ", LengthStr, ")"], Msg) ), get_vartypes(!.VLI, VarTypes), - map__lookup(VarTypes, Var, Type), + map.lookup(VarTypes, Var, Type), ( is_dummy_argument_type(ModuleInfo, Type) -> AssignCode = empty ; @@ -1185,13 +1185,13 @@ actually_place_var(ModuleInfo, Var, Target, ForbiddenLvals, Code, !VLI) :- record_clobbering(Target, Assigns, !VLI) :- get_loc_var_map(!.VLI, LocVarMap1), - ( map__search(LocVarMap1, Target, DependentVarsSet) -> - set__to_sorted_list(DependentVarsSet, DependentVars), - map__delete(LocVarMap1, Target, LocVarMap), + ( map.search(LocVarMap1, Target, DependentVarsSet) -> + set.to_sorted_list(DependentVarsSet, DependentVars), + map.delete(LocVarMap1, Target, LocVarMap), set_loc_var_map(LocVarMap, !VLI), get_var_state_map(!.VLI, VarStateMap2), - list__foldl(clobber_lval_in_var_state_map(Target, Assigns, no), + list.foldl(clobber_lval_in_var_state_map(Target, Assigns, no), DependentVars, VarStateMap2, VarStateMap), set_var_state_map(VarStateMap, !VLI) ; @@ -1222,10 +1222,10 @@ record_clobbering(Target, Assigns, !VLI) :- free_up_lval(ModuleInfo, Lval, ToBeAssignedVars, ForbiddenLvals, Code, !VLI) :- ( get_loc_var_map(!.VLI, LocVarMap0), - map__search(LocVarMap0, Lval, AffectedVarSet), - set__to_sorted_list(AffectedVarSet, AffectedVars), + map.search(LocVarMap0, Lval, AffectedVarSet), + set.to_sorted_list(AffectedVarSet, AffectedVars), get_var_state_map(!.VLI, VarStateMap0), - \+ list__foldl( + \+ list.foldl( try_clobber_lval_in_var_state_map(Lval, ToBeAssignedVars, no), AffectedVars, VarStateMap0, _) -> @@ -1260,9 +1260,9 @@ free_up_lval_with_copy(ModuleInfo, Lval, ToBeAssignedVars, ForbiddenLvals, Code, !VLI) :- ( get_loc_var_map(!.VLI, LocVarMap0), - map__search(LocVarMap0, Lval, AffectedVarSet), - set__delete_list(AffectedVarSet, ToBeAssignedVars, EffAffectedVarSet), - set__to_sorted_list(EffAffectedVarSet, EffAffectedVars), + map.search(LocVarMap0, Lval, AffectedVarSet), + set.delete_list(AffectedVarSet, ToBeAssignedVars, EffAffectedVarSet), + set.to_sorted_list(EffAffectedVarSet, EffAffectedVars), get_var_state_map(!.VLI, VarStateMap0), ( @@ -1270,8 +1270,8 @@ free_up_lval_with_copy(ModuleInfo, Lval, ToBeAssignedVars, ForbiddenLvals, OccupyingVar, OtherSources) -> MovedVar = OccupyingVar, - list__delete_all(EffAffectedVars, MovedVar, OtherVars), - list__foldl(ensure_copies_are_present(Lval, OtherSources), + list.delete_all(EffAffectedVars, MovedVar, OtherVars), + list.foldl(ensure_copies_are_present(Lval, OtherSources), OtherVars, !VLI) ; EffAffectedVars = [MovedVar] @@ -1280,7 +1280,7 @@ free_up_lval_with_copy(ModuleInfo, Lval, ToBeAssignedVars, ForbiddenLvals, CheckInUse = no, select_preferred_reg_or_stack(!.VLI, MovedVar, Pref, CheckInUse), \+ Pref = Lval, - \+ list__member(Pref, ForbiddenLvals), + \+ list.member(Pref, ForbiddenLvals), ( \+ lval_in_use(!.VLI, Pref) -> true ; @@ -1321,12 +1321,12 @@ free_up_lval_with_copy(ModuleInfo, Lval, ToBeAssignedVars, ForbiddenLvals, find_one_occupying_var([Var | Vars], Lval, VarStateMap, OccupyingVar, OtherSources) :- - map__lookup(VarStateMap, Var, State), + map.lookup(VarStateMap, Var, State), State = state(LvalSet, _, _, _, _), - ( set__member(Lval, LvalSet) -> + ( set.member(Lval, LvalSet) -> OccupyingVar = Var, - set__delete(LvalSet, Lval, OtherSourceSet), - set__to_sorted_list(OtherSourceSet, OtherSources) + set.delete(LvalSet, Lval, OtherSourceSet), + set.to_sorted_list(OtherSourceSet, OtherSources) ; find_one_occupying_var(Vars, Lval, VarStateMap, OccupyingVar, OtherSources) @@ -1337,14 +1337,14 @@ find_one_occupying_var([Var | Vars], Lval, VarStateMap, OccupyingVar, ensure_copies_are_present(OneSource, OtherSources, Var, !VLI) :- get_var_state_map(!.VLI, VarStateMap0), - map__lookup(VarStateMap0, Var, State0), + map.lookup(VarStateMap0, Var, State0), State0 = state(LvalSet0, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), - set__to_sorted_list(LvalSet0, Lvals0), - list__foldl(ensure_copies_are_present_lval(OtherSources, OneSource), + set.to_sorted_list(LvalSet0, Lvals0), + list.foldl(ensure_copies_are_present_lval(OtherSources, OneSource), Lvals0, LvalSet0, LvalSet), State = state(LvalSet, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), - map__det_update(VarStateMap0, Var, State, VarStateMap), + map.det_update(VarStateMap0, Var, State, VarStateMap), set_var_state_map(VarStateMap, !VLI), get_loc_var_map(!.VLI, LocVarMap0), @@ -1359,7 +1359,7 @@ ensure_copies_are_present_lval([], _, _, !LvalSet). ensure_copies_are_present_lval([OtherSource | OtherSources], OneSource, Lval, !LvalSet) :- SubstLval = substitute_lval_in_lval(OneSource, OtherSource, Lval), - set__insert(!.LvalSet, SubstLval, !:LvalSet), + set.insert(!.LvalSet, SubstLval, !:LvalSet), ensure_copies_are_present_lval(OtherSources, OneSource, Lval, !LvalSet). %----------------------------------------------------------------------------% @@ -1382,19 +1382,19 @@ record_copy(Old, New, !VLI) :- expect(is_root_lval(New), this_file, "record_copy: non-root New lval"), get_var_state_map(!.VLI, VarStateMap0), get_loc_var_map(!.VLI, LocVarMap0), - set__list_to_set([Old, New], AssignSet), + set.list_to_set([Old, New], AssignSet), get_var_set_roots(AssignSet, NoDupRootLvals), % Convert the list of root lvals to the list of sets of % affected vars; if a root lval is not in LocVarMap0, % then it does not affect any variables. - list__filter_map(map__search(LocVarMap0), NoDupRootLvals, + list.filter_map(map.search(LocVarMap0), NoDupRootLvals, AffectedVarSets), % Take the union of the list of sets of affected vars. - list__foldl(set__union, AffectedVarSets, - set__init, AffectedVarSet), + list.foldl(set.union, AffectedVarSets, + set.init, AffectedVarSet), % Convert the union set to a list of affected vars. - set__to_sorted_list(AffectedVarSet, AffectedVars), - list__foldl2(record_copy_for_var(Old, New), AffectedVars, + set.to_sorted_list(AffectedVarSet, AffectedVars), + list.foldl2(record_copy_for_var(Old, New), AffectedVars, VarStateMap0, VarStateMap, LocVarMap0, LocVarMap), set_loc_var_map(LocVarMap, !VLI), set_var_state_map(VarStateMap, !VLI). @@ -1438,19 +1438,19 @@ record_copy(Old, New, !VLI) :- loc_var_map::in, loc_var_map::out) is det. record_copy_for_var(Old, New, Var, !VarStateMap, !LocVarMap) :- - map__lookup(!.VarStateMap, Var, State0), + map.lookup(!.VarStateMap, Var, State0), State0 = state(LvalSet0, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), Token = reg(r, -42), - LvalSet1 = set__map(substitute_lval_in_lval(Old, Token), LvalSet0), - set__union(LvalSet0, LvalSet1, LvalSet2), - LvalSet3 = set__filter(lval_does_not_support_lval(New), LvalSet2), - LvalSet = set__map(substitute_lval_in_lval(Token, New), LvalSet3), + LvalSet1 = set.map(substitute_lval_in_lval(Old, Token), LvalSet0), + set.union(LvalSet0, LvalSet1, LvalSet2), + LvalSet3 = set.filter(lval_does_not_support_lval(New), LvalSet2), + LvalSet = set.map(substitute_lval_in_lval(Token, New), LvalSet3), State = state(LvalSet, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive), expect(nonempty_state(State), this_file, "record_copy_for_var: empty state"), - map__det_update(!.VarStateMap, Var, State, !:VarStateMap), + map.det_update(!.VarStateMap, Var, State, !:VarStateMap), record_change_in_root_dependencies(LvalSet0, LvalSet, Var, !LocVarMap). :- pred record_change_in_root_dependencies(set(lval)::in, @@ -1459,19 +1459,19 @@ record_copy_for_var(Old, New, Var, !VarStateMap, !LocVarMap) :- record_change_in_root_dependencies(OldLvalSet, NewLvalSet, Var, !LocVarMap) :- get_var_set_roots(OldLvalSet, OldRootLvals), get_var_set_roots(NewLvalSet, NewRootLvals), - set__list_to_set(OldRootLvals, OldRootLvalSet), - set__list_to_set(NewRootLvals, NewRootLvalSet), - set__difference(NewRootLvalSet, OldRootLvalSet, InsertSet), - set__difference(OldRootLvalSet, NewRootLvalSet, DeleteSet), - set__to_sorted_list(InsertSet, Inserts), - set__to_sorted_list(DeleteSet, Deletes), - list__foldl(make_var_depend_on_root_lval(Var), Inserts, !LocVarMap), - list__foldl(make_var_not_depend_on_root_lval(Var), Deletes, !LocVarMap). + set.list_to_set(OldRootLvals, OldRootLvalSet), + set.list_to_set(NewRootLvals, NewRootLvalSet), + set.difference(NewRootLvalSet, OldRootLvalSet, InsertSet), + set.difference(OldRootLvalSet, NewRootLvalSet, DeleteSet), + set.to_sorted_list(InsertSet, Inserts), + set.to_sorted_list(DeleteSet, Deletes), + list.foldl(make_var_depend_on_root_lval(Var), Inserts, !LocVarMap), + list.foldl(make_var_not_depend_on_root_lval(Var), Deletes, !LocVarMap). :- func substitute_lval_in_lval(lval, lval, lval) = lval. substitute_lval_in_lval(Old, New, Lval0) = Lval :- - exprn_aux__substitute_lval_in_lval(Old, New, Lval0, Lval). + exprn_aux.substitute_lval_in_lval(Old, New, Lval0, Lval). %----------------------------------------------------------------------------% @@ -1490,7 +1490,7 @@ substitute_lval_in_lval(Old, New, Lval0) = Lval :- % var_becomes_dead(Var, FirstTime, !VLI) :- get_var_state_map(!.VLI, VarStateMap0), - ( map__search(VarStateMap0, Var, State0) -> + ( map.search(VarStateMap0, Var, State0) -> State0 = state(Lvals, MaybeConstRval, MaybeExprRval, Using, DeadOrAlive0), ( @@ -1500,20 +1500,20 @@ var_becomes_dead(Var, FirstTime, !VLI) :- ; DeadOrAlive0 = alive ), - ( set__empty(Using) -> - map__det_remove(VarStateMap0, Var, _, VarStateMap), + ( set.empty(Using) -> + map.det_remove(VarStateMap0, Var, _, VarStateMap), set_var_state_map(VarStateMap, !VLI), get_loc_var_map(!.VLI, LocVarMap0), get_var_set_roots(Lvals, NoDupRootLvals), - list__foldl(make_var_not_depend_on_root_lval(Var), + list.foldl(make_var_not_depend_on_root_lval(Var), NoDupRootLvals, LocVarMap0, LocVarMap), set_loc_var_map(LocVarMap, !VLI), remove_use_refs(MaybeExprRval, Var, !VLI) ; State = state(Lvals, MaybeConstRval, MaybeExprRval, Using, dead), - map__det_update(VarStateMap0, Var, State, VarStateMap), + map.det_update(VarStateMap0, Var, State, VarStateMap), set_var_state_map(VarStateMap, !VLI) ) ; @@ -1527,11 +1527,11 @@ var_becomes_dead(Var, FirstTime, !VLI) :- :- pred get_var_set_roots(set(lval)::in, list(lval)::out) is det. get_var_set_roots(Lvals, NoDupRootLvals) :- - set__to_sorted_list(Lvals, LvalList), - code_util__lvals_in_lvals(LvalList, ContainedLvals), - list__append(LvalList, ContainedLvals, AllLvals), - list__filter(is_root_lval, AllLvals, RootLvals), - list__sort_and_remove_dups(RootLvals, NoDupRootLvals). + set.to_sorted_list(Lvals, LvalList), + code_util.lvals_in_lvals(LvalList, ContainedLvals), + list.append(LvalList, ContainedLvals, AllLvals), + list.filter(is_root_lval, AllLvals, RootLvals), + list.sort_and_remove_dups(RootLvals, NoDupRootLvals). %----------------------------------------------------------------------------% @@ -1644,7 +1644,7 @@ select_preferred_reg(VLI, Var, Lval) :- select_preferred_reg(VLI, Var, CheckInUse, Avoid, Lval) :- get_follow_var_map(VLI, FollowVarMap), ( - map__search(FollowVarMap, Var, PrefLocn), + map.search(FollowVarMap, Var, PrefLocn), ( PrefLocn = abs_reg(_) ; PrefLocn = any_reg ) @@ -1658,7 +1658,7 @@ select_preferred_reg(VLI, Var, CheckInUse, Avoid, Lval) :- ; CheckInUse = no ), - \+ list__member(PrefLval, Avoid) + \+ list.member(PrefLval, Avoid) -> Lval = PrefLval ; @@ -1690,7 +1690,7 @@ select_preferred_reg_or_stack_check(VLI, Var, Lval) :- select_preferred_reg_or_stack(VLI, Var, Lval, CheckInUse) :- get_follow_var_map(VLI, FollowVarMap), ( - map__search(FollowVarMap, Var, PrefLocn), + map.search(FollowVarMap, Var, PrefLocn), ( PrefLocn = abs_reg(_) ; PrefLocn = any_reg ) @@ -1712,7 +1712,7 @@ select_preferred_reg_or_stack(VLI, Var, Lval, CheckInUse) :- ; ( get_stack_slots(VLI, StackSlots), - map__search(StackSlots, Var, StackSlotLocn), + map.search(StackSlots, Var, StackSlotLocn), StackSlot = stack_slot_to_lval(StackSlotLocn), ( CheckInUse = yes, @@ -1760,7 +1760,7 @@ get_spare_reg_2(VLI, Avoid, N0, Lval) :- TryLval = reg(r, N0), ( lval_in_use(VLI, TryLval) -> get_spare_reg_2(VLI, Avoid, N0 + 1, Lval) - ; list__member(TryLval, Avoid) -> + ; list.member(TryLval, Avoid) -> get_spare_reg_2(VLI, Avoid, N0 + 1, Lval) ; Lval = TryLval @@ -1771,10 +1771,10 @@ lval_in_use(VLI, Lval) :- get_acquired(VLI, Acquired), get_locked(VLI, Locked), ( - map__search(LocVarMap, Lval, UsingVars), - \+ set__empty(UsingVars) + map.search(LocVarMap, Lval, UsingVars), + \+ set.empty(UsingVars) ; - set__member(Lval, Acquired) + set.member(Lval, Acquired) ; Lval = reg(r, N), N =< Locked @@ -1792,15 +1792,15 @@ reg_is_not_locked_for_var(VLI, RegNum, Var) :- get_locked(VLI, Locked), get_exceptions(VLI, Exceptions), Reg = reg(r, RegNum), - \+ set__member(Reg, Acquired), - RegNum =< Locked => list__member(Var - Reg, Exceptions). + \+ set.member(Reg, Acquired), + RegNum =< Locked => list.member(Var - Reg, Exceptions). %----------------------------------------------------------------------------% acquire_reg(Lval, !VLI) :- get_spare_reg(!.VLI, Lval), get_acquired(!.VLI, Acquired0), - set__insert(Acquired0, Lval, Acquired), + set.insert(Acquired0, Lval, Acquired), set_acquired(Acquired, !VLI). acquire_reg_require_given(Lval, !VLI) :- @@ -1810,7 +1810,7 @@ acquire_reg_require_given(Lval, !VLI) :- true ), get_acquired(!.VLI, Acquired0), - set__insert(Acquired0, Lval, Acquired), + set.insert(Acquired0, Lval, Acquired), set_acquired(Acquired, !VLI). acquire_reg_prefer_given(Pref, Lval, !VLI) :- @@ -1821,7 +1821,7 @@ acquire_reg_prefer_given(Pref, Lval, !VLI) :- Lval = PrefLval ), get_acquired(!.VLI, Acquired0), - set__insert(Acquired0, Lval, Acquired), + set.insert(Acquired0, Lval, Acquired), set_acquired(Acquired, !VLI). acquire_reg_start_at_given(Start, Lval, !VLI) :- @@ -1831,14 +1831,14 @@ acquire_reg_start_at_given(Start, Lval, !VLI) :- ; Lval = StartLval, get_acquired(!.VLI, Acquired0), - set__insert(Acquired0, Lval, Acquired), + set.insert(Acquired0, Lval, Acquired), set_acquired(Acquired, !VLI) ). release_reg(Lval, !VLI) :- get_acquired(!.VLI, Acquired0), - ( set__member(Lval, Acquired0) -> - set__delete(Acquired0, Lval, Acquired), + ( set.member(Lval, Acquired0) -> + set.delete(Acquired0, Lval, Acquired), set_acquired(Acquired, !VLI) ; unexpected(this_file, "release_reg: unacquired reg") @@ -1858,12 +1858,12 @@ unlock_regs(!VLI) :- max_reg_in_use(VLI, Max) :- get_loc_var_map(VLI, LocVarMap), - map__keys(LocVarMap, VarLocs), - code_util__max_mentioned_reg(VarLocs, Max1), + map.keys(LocVarMap, VarLocs), + code_util.max_mentioned_reg(VarLocs, Max1), get_acquired(VLI, Acquired), - set__to_sorted_list(Acquired, AcquiredList), - code_util__max_mentioned_reg(AcquiredList, Max2), - int__max(Max1, Max2, Max). + set.to_sorted_list(Acquired, AcquiredList), + code_util.max_mentioned_reg(AcquiredList, Max2), + int.max(Max1, Max2, Max). %----------------------------------------------------------------------------% @@ -1880,14 +1880,14 @@ cell_is_constant(VarStateMap, ExprnOpts, [yes(Rval0) | MaybeRvals], % expr_is_constant(VarStateMap, ExprnOpts, Rval0, Rval): % Check if Rval0 is a constant rval, after substituting the values of the % variables inside it. Returns the substituted, ground rval in Rval. - % Note that this predicate is similar to code_exprn__expr_is_constant, + % Note that this predicate is similar to code_exprn.expr_is_constant, % but it uses its own version of the variable state data structure. % :- pred expr_is_constant(var_state_map::in, exprn_opts::in, rval::in, rval::out) is semidet. expr_is_constant(_, ExprnOpts, const(Const), const(Const)) :- - exprn_aux__const_is_constant(Const, ExprnOpts, yes). + exprn_aux.const_is_constant(Const, ExprnOpts, yes). expr_is_constant(VarStateMap, ExprnOpts, unop(Op, Expr0), unop(Op, Expr)) :- expr_is_constant(VarStateMap, ExprnOpts, Expr0, Expr). @@ -1899,7 +1899,7 @@ expr_is_constant(VarStateMap, ExprnOpts, mkword(Tag, Expr0), mkword(Tag, Expr)) :- expr_is_constant(VarStateMap, ExprnOpts, Expr0, Expr). expr_is_constant(VarStateMap, ExprnOpts, var(Var), Rval) :- - map__search(VarStateMap, Var, State), + map.search(VarStateMap, Var, State), State = state(_, yes(Rval), _, _, _), expect(expr_is_constant(VarStateMap, ExprnOpts, Rval, _), this_file, "non-constant rval in variable state"). @@ -2075,12 +2075,12 @@ materialize_vars_in_mem_ref(ModuleInfo, MemRef0, MemRef, Avoid, Code, !VLI) :- find_var_availability(VLI, Var, MaybePrefer, Avail) :- get_var_state_map(VLI, VarStateMap), - map__lookup(VarStateMap, Var, State), + map.lookup(VarStateMap, Var, State), State = state(Lvals, MaybeConstRval, _, _, _), - set__to_sorted_list(Lvals, LvalsList), + set.to_sorted_list(Lvals, LvalsList), ( MaybePrefer = yes(Prefer), - list__member(Prefer, LvalsList) + list.member(Prefer, LvalsList) -> Rval = lval(Prefer), Avail = available(Rval) @@ -2099,7 +2099,7 @@ find_var_availability(VLI, Var, MaybePrefer, Avail) :- materialize_var(ModuleInfo, Var, MaybePrefer, StoreIfReq, Avoid, Rval, Code, !VLI) :- get_var_state_map(!.VLI, VarStateMap), - map__lookup(VarStateMap, Var, State), + map.lookup(VarStateMap, Var, State), State = state(_Lvals, _MaybeConstRval, MaybeExprRval, UsingVars, _DeadOrAlive), ( @@ -2112,7 +2112,7 @@ materialize_var(ModuleInfo, Var, MaybePrefer, StoreIfReq, Avoid, Rval, Code, ExprCode, !VLI), ( StoreIfReq = yes, - set__count(UsingVars, NumUsingVars), + set.count(UsingVars, NumUsingVars), NumUsingVars > 1 -> select_preferred_reg_avoid(!.VLI, Var, Avoid, Lval), @@ -2134,14 +2134,14 @@ materialize_var(ModuleInfo, Var, MaybePrefer, StoreIfReq, Avoid, Rval, Code, make_var_depend_on_lvals_roots(Var, Lvals, !LocVarMap) :- get_var_set_roots(Lvals, NoDupRootLvals), - list__foldl(make_var_depend_on_root_lval(Var), + list.foldl(make_var_depend_on_root_lval(Var), NoDupRootLvals, !LocVarMap). :- pred make_var_depend_on_lval_roots(prog_var::in, lval::in, loc_var_map::in, loc_var_map::out) is det. make_var_depend_on_lval_roots(Var, Lval, !LocVarMap) :- - set__singleton_set(Lvals, Lval), + set.singleton_set(Lvals, Lval), make_var_depend_on_lvals_roots(Var, Lvals, !LocVarMap). :- pred make_var_depend_on_root_lval(prog_var::in, lval::in, @@ -2150,12 +2150,12 @@ make_var_depend_on_lval_roots(Var, Lval, !LocVarMap) :- make_var_depend_on_root_lval(Var, Lval, !LocVarMap) :- expect(is_root_lval(Lval), this_file, "make_var_depend_on_root_lval: non-root lval"), - ( map__search(!.LocVarMap, Lval, Vars0) -> - set__insert(Vars0, Var, Vars), - map__det_update(!.LocVarMap, Lval, Vars, !:LocVarMap) + ( map.search(!.LocVarMap, Lval, Vars0) -> + set.insert(Vars0, Var, Vars), + map.det_update(!.LocVarMap, Lval, Vars, !:LocVarMap) ; - set__singleton_set(Vars, Var), - map__det_insert(!.LocVarMap, Lval, Vars, !:LocVarMap) + set.singleton_set(Vars, Var), + map.det_insert(!.LocVarMap, Lval, Vars, !:LocVarMap) ). % Update LocVarMap0 to reflect that Var is no longer dependent @@ -2167,12 +2167,12 @@ make_var_depend_on_root_lval(Var, Lval, !LocVarMap) :- make_var_not_depend_on_root_lval(Var, Lval, !LocVarMap) :- expect(is_root_lval(Lval), this_file, "make_var_depend_on_root_lval: non-root lval"), - ( map__search(!.LocVarMap, Lval, Vars0) -> - set__delete(Vars0, Var, Vars), - ( set__empty(Vars) -> - map__det_remove(!.LocVarMap, Lval, _, !:LocVarMap) + ( map.search(!.LocVarMap, Lval, Vars0) -> + set.delete(Vars0, Var, Vars), + ( set.empty(Vars) -> + map.det_remove(!.LocVarMap, Lval, _, !:LocVarMap) ; - map__det_update(!.LocVarMap, Lval, Vars, !:LocVarMap) + map.det_update(!.LocVarMap, Lval, Vars, !:LocVarMap) ) ; unexpected(this_file, "make_var_not_depend_on_root_lval: no record") @@ -2263,7 +2263,7 @@ set_follow_vars(abs_follow_vars(FollowVarMap, NextNonReserved), !VLI) :- get_var_name(VLI, Var, Name) :- get_varset(VLI, VarSet), - varset__lookup_name(VarSet, Var, Name). + varset.lookup_name(VarSet, Var, Name). %----------------------------------------------------------------------------% @@ -2271,7 +2271,7 @@ get_var_name(VLI, Var, Name) :- nonempty_state(State) :- State = state(LvalSet, MaybeConstRval, MaybeExprRval, _, _), - ( set__non_empty(LvalSet) + ( set.non_empty(LvalSet) ; MaybeConstRval = yes(_) ; MaybeExprRval = yes(_) ). diff --git a/compiler/wrap_blocks.m b/compiler/wrap_blocks.m index 0fab1e5f9..5f664464a 100644 --- a/compiler/wrap_blocks.m +++ b/compiler/wrap_blocks.m @@ -1,7 +1,7 @@ %-----------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% -% Copyright (C) 2001, 2003, 2005 The University of Melbourne. +% Copyright (C) 2001, 2003, 2005-2006 The University of Melbourne. % This file may only be copied under the terms of the GNU General % Public License - see the file COPYING in the Mercury distribution. %-----------------------------------------------------------------------------% @@ -18,7 +18,7 @@ %-----------------------------------------------------------------------------% -:- module ll_backend__wrap_blocks. +:- module ll_backend.wrap_blocks. :- interface. :- import_module ll_backend.llds. @@ -66,7 +66,7 @@ wrap_instrs([], R, F, RevSofar, []) :- ). wrap_instrs([Instr0 | Instrs0], R0, F0, RevSofar, Instrs) :- Instr0 = Uinstr0 - _Comment0, - opt_util__count_temps_instr(Uinstr0, R0, R1, F0, F1), + opt_util.count_temps_instr(Uinstr0, R0, R1, F0, F1), ( ( R1 > 0 ; F1 > 0) -> % We must close the block before a label, since you can jump % to a label from other blocks. @@ -79,11 +79,11 @@ wrap_instrs([Instr0 | Instrs0], R0, F0, RevSofar, Instrs) :- % debugger/all_solutions to fail. ( ( Uinstr0 = label(_) ; Uinstr0 = call(_, _, _, _, _, _) ) -> - list__reverse(RevSofar, BlockInstrs), + list.reverse(RevSofar, BlockInstrs), wrap_instrs(Instrs0, 0, 0, [], Instrs1), Instrs = [block(R1, F1, BlockInstrs) - "", Instr0 | Instrs1] - ; opt_util__can_instr_fall_through(Uinstr0, no) -> - list__reverse([Instr0 | RevSofar], BlockInstrs), + ; opt_util.can_instr_fall_through(Uinstr0, no) -> + list.reverse([Instr0 | RevSofar], BlockInstrs), wrap_instrs(Instrs0, 0, 0, [], Instrs1), Instrs = [block(R1, F1, BlockInstrs) - "" | Instrs1] ;