mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-20 00:15:27 +00:00
mercury_builtin.nl: Use det_pred(...), semidet_pred(...), nondet_pred(...) rather than call_pred(...) for the higher-order predicate modes. prog_io.nl, io.nl, varset.nl, etc. Add determinism annotations. hlds.nl, make_hlds.nl, LOTS of other files: Reorganize the way the predicate table works. Make hlds.nl a bit more modular. Change call/4 to call/5. Remove all/2 from the hlds. Changed pred_id to an integer. Added pred_call_id which is similar to the old pred_id. Makefile: Add a rule for creating *.hlds_dump. array.nl: Fix determinism error. det_analysis.nl: Fix a bug in printing determinism warnings. fix_errors.sed: Modify this so it allows all the `inferred nondet' determinism errors but none of the `inferred semidet' ones. llds.nl: Rename llds__pred_mode_id as llds__proc_id. mode_errors.nl: Finally got around to implementing Zoltan's suggestions about the error messages from the mode analysis. If an error occurs in a conjunction, only one error message is printed out - the first error which doesn't relate to a head unification. modes.nl: Handle X = f(X) properly. NB: determinism analysis and code generation still get it wrong! undef_modes, undef_insts: I've broken the error message code, since it's not easy to print pred_ids. I just changed it so that it didn't print the pred_ids out. Should fix this properly at some stage...
72 lines
2.7 KiB
Mathematica
72 lines
2.7 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module code_util.
|
|
|
|
:- interface.
|
|
|
|
:- import_module hlds, llds, code_info.
|
|
|
|
:- pred code_util__make_entry_label(module_info, pred_id, proc_id, code_addr).
|
|
:- mode code_util__make_entry_label(in, in, in, out) is det.
|
|
|
|
:- pred code_util__make_local_entry_label(module_info, pred_id, proc_id, label).
|
|
:- mode code_util__make_local_entry_label(in, in, in, out) is det.
|
|
|
|
:- pred code_util__make_local_label(module_info, pred_id, proc_id, int, label).
|
|
:- mode code_util__make_local_label(in, in, in, in, out) is det.
|
|
|
|
:- pred code_util__uni_mode_to_unilabel(uni_mode, unilabel).
|
|
:- mode code_util__uni_mode_to_unilabel(in, out) is det.
|
|
|
|
:- pred code_util__arg_loc_to_register(arg_loc, reg).
|
|
:- mode code_util__arg_loc_to_register(in, out) is det.
|
|
|
|
:- pred atom_to_operator(string, operator).
|
|
:- mode atom_to_operator(in, out) is semidet.
|
|
:- mode atom_to_operator(out, in) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
:- implementation.
|
|
|
|
code_util__make_local_entry_label(ModuleInfo, PredId, ProcId, Label) :-
|
|
predicate_module(ModuleInfo, PredId, ModuleName),
|
|
predicate_name(ModuleInfo, PredId, PredName),
|
|
predicate_arity(ModuleInfo, PredId, Arity),
|
|
Label = entrylabel(ModuleName, PredName, Arity, ProcId).
|
|
|
|
code_util__make_local_label(ModuleInfo, PredId, ProcId, LabelNum, Label) :-
|
|
predicate_module(ModuleInfo, PredId, ModuleName),
|
|
predicate_name(ModuleInfo, PredId, PredName),
|
|
predicate_arity(ModuleInfo, PredId, Arity),
|
|
Label = label(ModuleName, PredName, Arity, ProcId, LabelNum).
|
|
|
|
code_util__make_entry_label(ModuleInfo, PredId, ProcId, PredAddress) :-
|
|
code_util__make_local_entry_label(ModuleInfo, PredId, ProcId, Label),
|
|
PredAddress = local(Label).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
code_util__uni_mode_to_unilabel(_UniMode,
|
|
unilabel("xxx","outofline","unification")).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
code_util__arg_loc_to_register(ArgLoc, r(ArgLoc)).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
atom_to_operator("builtin_plus", (+)).
|
|
atom_to_operator("builtin_minus", (-)).
|
|
atom_to_operator("builtin_times", (*)).
|
|
atom_to_operator("builtin_div", (/)).
|
|
atom_to_operator(">", (>)).
|
|
atom_to_operator("<", (<)).
|
|
atom_to_operator(">=", (>=)).
|
|
atom_to_operator("=<", (<=)).
|
|
|
|
%-----------------------------------------------------------------------------%
|