Files
mercury/browser/set_cc.m
Mark Brown fb27d22a8f Implement a committed choice version of the 'set' module, and use this in
Estimated hours taken: 1.5
Branches: main

Implement a committed choice version of the 'set' module, and use this in
the declarative debugging oracle.  This implementation of sets avoids the
use of builtin comparison, which would otherwise cause problems for the
oracle.

This fixes a bug that was causing test case 'ho5' to fail.

browser/set_cc.m:
	The new module.  This is mostly a wrapper around tree234_cc.

browser/mdb.m:
	Make the new module a sub-module of mdb.

browser/declarative_oracle.m:
	Use the new module instead of sets from the standard library.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/ho5.exp:
tests/debugger/declarative/ho5.exp2:
tests/debugger/declarative/ho5.inp:
	Enable this test case, and provide input and expected output.
2002-10-15 07:40:48 +00:00

70 lines
1.8 KiB
Mathematica

%---------------------------------------------------------------------------%
% Copyright (C) 2002 The University of Melbourne.
% This file may only be copied under the terms of the GNU Library General
% Public License - see the file COPYING.LIB in the Mercury distribution.
%---------------------------------------------------------------------------%
% Set_cc is an implementation of sets which uses compare_representation
% instead of builtin comparison, hence it is suitable for use with terms
% that don't have a canonical representation. It is implemented using
% tree234_cc; see that module for further discussion about the implications
% of using compare_representation.
%
% Author: Mark Brown (dougl)
%---------------------------------------------------------------------------%
:- module mdb__set_cc.
:- interface.
:- import_module bool.
:- type set_cc(T).
:- pred set_cc__init(set_cc(T)).
:- mode set_cc__init(uo) is det.
:- pred set_cc__is_empty(set_cc(T)).
:- mode set_cc__is_empty(in) is semidet.
:- pred set_cc__member(T, set_cc(T), bool).
:- mode set_cc__member(in, in, out) is cc_multi.
:- pred set_cc__insert(set_cc(T), T, set_cc(T)).
:- mode set_cc__insert(in, in, out) is cc_multi.
:- pred set_cc__delete(set_cc(T), T, set_cc(T)).
:- mode set_cc__delete(in, in, out) is cc_multi.
%---------------------------------------------------------------------------%
:- implementation.
:- import_module std_util.
:- import_module mdb__tree234_cc.
:- type set_cc(T) == tree234_cc(T, unit).
set_cc__init(S) :-
tree234_cc__init(S).
set_cc__is_empty(S) :-
tree234_cc__is_empty(S).
set_cc__member(T, S, Bool) :-
tree234_cc__search(S, T, Maybe),
(
Maybe = yes(_),
Bool = yes
;
Maybe = no,
Bool = no
).
set_cc__insert(S0, T, S) :-
tree234_cc__set(S0, T, unit, S).
set_cc__delete(S0, T, S) :-
tree234_cc__delete(S0, T, S).