Files
mercury/tests/invalid/overloading.m
Zoltan Somogyi 59cf3a51e1 Don't accept `:- external' items.
compiler/parse_item.m:
    Don't accept `:- external' items.

compiler/prog_item.m:
    Require the presence of a pred_or_func flag on external pragmas.
    They are specified by `:- pragma external_{pred/func}' pragmas,
    which are still supported.

compiler/parse_pragma.m:
    When parsing external_{pred/func} pragmas, allow the predicate name
    to contain a module qualifier; they were allowed on `:- external' items.
    We do require the module qualifier to specify the expected (i.e. the
    current)  module.

compiler/add_pragma.m:
compiler/parse_tree_out_pragma.m:
compiler/recompilation.version.m:
    Conform to the changes above.

tests/hard_coded/backend_external.m:
tests/hard_coded/constant_prop_2.m:
tests/invalid/external.err_exp:
tests/invalid/external.m:
tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/io_in_ite_cond.m:
tests/invalid/overloading.m:
tests/invalid/tricky_assert1.m:
tests/invalid/type_spec.err_exp:
tests/invalid/type_spec.m:
tests/invalid/uniq_neg.err_exp:
tests/invalid/uniq_neg.m:
tests/valid/dcg_test.m:
tests/valid/inst_perf_bug_1.m:
tests/valid/lambda_recompute.m:
tests/valid/semidet_disj.m:
tests/valid/solv.m:
tests/valid/solver_type_bug.m:
tests/valid/stack_alloc.m:
tests/valid/tricky_assert2.m:
    Replace `:- external' items with external_{pred/func} pragmas.
    Modernize the code where needed, replacing DCGs with state variables.
2016-03-13 01:11:05 +11:00

63 lines
2.0 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
:- module overloading.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module counter.
:- import_module int.
:- import_module list.
:- import_module map.
:- import_module set.
:- import_module term.
main -->
{ q(A, B, C) },
{ p(A, B, C, T) },
io__write(T),
io__nl.
:- type var_save_map == map(var, save_map).
:- type save_map == map(goal_path, string).
:- type goal_path ---> goal_path(string).
:- type anchor ---> anchor(string).
:- type interval_id ---> interval_id(int).
:- type opt_info
---> opt_info(
must_have_own_slot :: set(var),
ever_on_stack :: set(var),
var_save_map :: var_save_map,
cur_interval :: interval_id,
interval_counter :: counter,
interval_start :: map(interval_id, anchor),
interval_end :: map(interval_id, anchor),
interval_vars :: map(interval_id, set(var)),
interval_succ :: map(interval_id, list(interval_id))
).
:- pred p(set(var)::in, set(var)::in, set(var)::in, opt_info::out) is det.
p(MustHaveOwnSlot, EverOnStack, OutputVars, OptInfo) :-
Counter0 = counter__init(1),
counter__allocate(CurInterval, Counter0, Counter1),
CurIntervalId = interval_id(CurInterval),
EndMap0 = map__det_insert(map__init, CurIntervalId, anchor("end")),
StartMap0 = map__init,
VarsMap0 = map__det_insert(map__init, CurIntervalId, OutputVars),
SuccMap0 = map__init,
OptInfo = opt_info(MustHaveOwnSlot, EverOnStack,
CurIntervalId, map__init, Counter1, StartMap0, EndMap0,
VarsMap0, SuccMap0).
:- pred q(set(var)::out, set(var)::out, set(var)::out) is det.
:- pragma external_pred(q/3).