Files
mercury/tests/valid/agc_graph.m
Zoltan Somogyi fdd141bf77 Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the tests
    that check compiler error messages, expect the new line numbers.

browser/cterm.m:
browser/tree234_cc.m:
    Import only one module per line.

tests/hard_coded/boyer.m:
    Fix something I missed.
2015-02-16 12:32:18 +11:00

93 lines
2.6 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% Regression test.
% This code was taken from library/graph.m and simplified.
%
% Description of bug:
% The liveness of polymorphic type variables for accurate gc
% wasn't being computed correctly.
% It was being removed from the initial_liveness for not being
% part of the non-locals (like an unused variable).
%
% Symptom(s) of bug:
% % Allocating storage locations for live vars in predicate
% `agc_graph:insert_node/4' mode 0
% Software error: variable TypeInfo_for_A (18) not found
%
% Date bug existed: 1-July-1997
% Author: trd
:- module agc_graph.
:- interface.
:- import_module unit.
:- type graph(N, A).
:- type node(N).
:- type arc(A).
:- type graph(N) == graph(N, unit).
:- type arc == arc(unit).
:- pred agc_graph__insert_node(graph(N, A), N, node(N), graph(N, A)).
:- mode agc_graph__insert_node(in, in, out, out) is semidet.
%---------------------------------------------------------------------------%
:- type node(N) == int.
:- type arc(A) == int.
%---------------------------------------------------------------------------%
:- implementation.
:- import_module int.
:- import_module list.
:- import_module map.
:- import_module require.
:- import_module std_util.
:- type graph(N, A)
---> graph(
agc_graph__node_supply,
agc_graph__arc_supply,
map(node(N), N),
map(arc(A), arc_info(N, A)),
map(node(N), map(arc(A), node(N)))
).
:- type agc_graph__node_supply == int.
:- type agc_graph__arc_supply == int.
:- type arc_info(N, A)
---> arc_info(node(N), node(N), A).
%---------------------------------------------------------------------------%
agc_graph__insert_node(G, NInfo, N, G) :-
G = graph(_, _, Nodes0, _, _),
agc_graph__get_node_supply(G, N),
agc_graph__get_edges(G, Edges0),
\+ map__member(Nodes0, _, NInfo),
map__init(Edges0).
%---------------------------------------------------------------------------%
:- pred agc_graph__get_node_supply(graph(N, A), agc_graph__node_supply).
:- mode agc_graph__get_node_supply(in, out) is det.
agc_graph__get_node_supply(G, NS) :-
G = graph(NS, _AS, _N, _A, _E).
:- pred agc_graph__get_edges(graph(N, A), map(node(N), map(arc(A), node(N)))).
:- mode agc_graph__get_edges(in, out) is det.
agc_graph__get_edges(G, E) :-
G = graph(_NS, _AS, _N, _A, E).
%---------------------------------------------------------------------------%