[m-dev.] for review: Infrastructure for Java Backend

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jan 25 14:55:10 AEDT 2001


On 25-Jan-2001, Julien Fischer <juliensf at students.cs.mu.oz.au> wrote:
> 
> On Tue, 23 Jan 2001, Fergus Henderson wrote:
> 
> > On 23-Jan-2001, Julien Fischer <juliensf at students.cs.mu.oz.au> wrote:
> > > 
> > > +	% Succeeds iff this definition is a function definition which
> > > +	% defines a special_pred
> > > +:- pred defn_is_special_pred(mlds__defn).
> > > +:- mode defn_is_special_pred(in) is semidet.
> > 
> > What should this do for continuation functions which form part of the
> > definition of special_pred?  This can occur e.g. for types with 
> > user-defined equality functions, if the user-defined equality function
> > calls nondeterministic procedures.
> > Should defn_is_special_pred succeed for those?
> 
> It should succeed for anything that is a special pred. (See below)  
> 
> > > +defn_is_special_pred(Defn) :-
> > > +	Defn  = mlds__defn(Name, _Context, _Flags, _Body),
> > > +	Name  = function(Label, _ProcID, _MaybeSeqNum, _PredID),
> > > +	Label = special_pred(_, _, _, _).
> > 
> > This ignores _MaybeSeqNum -- is that the right thing to do?
> Probably, it seems to be working thus far. 

Please try a test case that tests the scenario that I outlined above.
E.g. see the nondet_user_eq.m test case that I have attached.

> > > +	% Succeeds iff this definition is a data definition which
> > > +	% defines RTTI 
> > > +:- pred defn_is_rtti(mlds__defn).
> > > +:- mode defn_is_rtti(in) is semidet.
> > ...
> > > +defn_is_rtti(Defn) :-
> > > +	Defn = mlds__defn(_Name, _Context, _Flags, Body),
> > > +	Body = mlds__data(Type, _),
> > > +	Type = mlds__rtti_type(_).
> > 
> > What is that needed for?
> 
> Both these predicates are used by the Java backend for MLDS->MLDS 
> transformations.  They are in ml_util.m rather mlds_to_java.m, because
> the code that does the transformations is probably going to be moved
> from there (Tyson said something about using it in the IL backend).

I suggest committing those predicates at the same time as the code
that uses them, rather than in this change.

Otherwise it's pretty much impossible for me to review them properly,
since I can't tell what the code that calls them is trying to do.

> defn_is_special_pred should succeed for all special predicates,

Yes, but should it succeed for all MLDS functions that define parts of
special predicates, or just for MLDS functions that define the entry
point to special predicates?  See the attached test case for
an example where it makes a difference.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
-------------- next part --------------
% This module tests the case where a user-defined
% equality pred calls nondet code.

:- module nondet_user_eq.
:- interface.
:- import_module list, int.
:- pred foo_equal(foo::in, foo::in) is semidet.

:- type foo ---> mkfoo(list(int)) where equality is foo_equal.

:- implementation.

:- pragma inline(foo_equal/2).
foo_equal(_, _) :-
	list__member(X, [1,2,3]),
	X * X = 4.


More information about the developers mailing list