[m-rev.] diff: delete aditi stuff from library

Julien Fischer juliensf at cs.mu.OZ.AU
Thu Jun 22 12:49:08 AEST 2006


Estimated hours taken: 0.5
Branches: main, release

Delete Aditi specific stuff from the standard library.

library/term.m:
library/io.m:
	Delete the predicates term.term_to_type_with_int_instead_of_char/2 and
	io.read_from_string_with_int_instead_of_char/6.  These were intended
	for use with the Aditi backend.  (Note: they were never publicly
	documented in the library reference manual).

	Simplify the remaining code accordingly.

Julien.

Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.347
diff -u -r1.347 io.m
--- library/io.m	19 Apr 2006 05:17:52 -0000	1.347
+++ library/io.m	22 Jun 2006 02:13:26 -0000
@@ -1480,18 +1480,6 @@
 :- mode io.write_univ(in, in, in, di, uo) is cc_multi.

 %
-% For use by extras/aditi/aditi.m.
-%
-
-    % This is the same as io.read_from_string, except that an integer
-    % is allowed where a character is expected. This is needed because
-    % Aditi does not have a builtin character type. This also allows an
-    % integer where a float is expected.
-    %
-:- pred io.read_from_string_with_int_instead_of_char(string::in, string::in,
-    int::in, io.read_result(T)::out, posn::in, posn::out) is det.
-
-%
 % For use by compiler/process_util.m:
 %

@@ -3603,41 +3591,21 @@
 io.read(Result, !IO) :-
     term_io.read_term(ReadResult, !IO),
     io.get_line_number(LineNumber, !IO),
-    IsAditiTuple = no,
-    io.process_read_term(IsAditiTuple, ReadResult, LineNumber, Result).
-
-io.read_from_string_with_int_instead_of_char(FileName, String, Len, Result,
-        !Posn) :-
-    IsAditiTuple = yes,
-    io.read_from_string(IsAditiTuple, FileName, String, Len, Result, !Posn).
+    io.process_read_term(ReadResult, LineNumber, Result).

 io.read_from_string(FileName, String, Len, Result, !Posn) :-
-    IsAditiTuple = no,
-    io.read_from_string(IsAditiTuple, FileName, String, Len, Result, !Posn).
-
-:- pred io.read_from_string(bool::in, string::in, string::in, int::in,
-    io.read_result(T)::out, posn::in, posn::out) is det.
-
-io.read_from_string(IsAditiTuple, FileName, String, Len, Result, !Posn) :-
-    parser.read_term_from_string(FileName, String, Len, !Posn,
-        ReadResult),
+    parser.read_term_from_string(FileName, String, Len, !Posn, ReadResult),
     !.Posn = posn(LineNumber, _, _),
-    io.process_read_term(IsAditiTuple, ReadResult, LineNumber, Result).
+    io.process_read_term(ReadResult, LineNumber, Result).

-:- pred io.process_read_term(bool::in, read_term::in, int::in,
-    io.read_result(T)::out) is det.
+:- pred io.process_read_term(read_term::in, int::in, io.read_result(T)::out)
+    is det.

-io.process_read_term(IsAditiTuple, ReadResult, LineNumber, Result) :-
+io.process_read_term(ReadResult, LineNumber, Result) :-
     (
         ReadResult = term(_VarSet, Term),
         (
-            (
-                IsAditiTuple = yes,
-                term_to_type_with_int_instead_of_char(Term, Type)
-            ;
-                IsAditiTuple = no,
-                term_to_type(Term, Type)
-            )
+            term_to_type(Term, Type)
         ->
             Result = ok(Type)
         ;
Index: library/term.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/term.m,v
retrieving revision 1.119
diff -u -r1.119 term.m
--- library/term.m	19 Apr 2006 05:17:58 -0000	1.119
+++ library/term.m	22 Jun 2006 02:10:11 -0000
@@ -445,14 +445,6 @@

 :- interface.

-% This is the same as term_to_type, except that an integer is allowed
-% where a character is expected. This is needed by extras/aditi/aditi.m
-% because Aditi does not have a builtin character type. This also allows
-% an integer where a float is expected.
-
-:- pred term_to_type_with_int_instead_of_char(term(U)::in, T::out)
-    is semidet.
-
     % Returns the highest numbered variable returned from this var_supply.
     %
 :- func var_supply_max_var(var_supply(T)) = var(T).
@@ -486,20 +478,8 @@
 term_to_type(Term, Val) :-
     try_term_to_type(Term, ok(Val)).

-term_to_type_with_int_instead_of_char(Term, Val) :-
-    IsAditiTuple = yes,
-    try_term_to_type(IsAditiTuple, Term, ok(Val)).
-
 try_term_to_type(Term, Result) :-
-    IsAditiTuple = no,
-    try_term_to_type(IsAditiTuple, Term, Result).
-
-:- pred try_term_to_type(bool::in, term(U)::in,
-    term_to_type_result(T, U)::out) is det.
-
-try_term_to_type(IsAditiTuple, Term, Result) :-
-    try_term_to_univ(IsAditiTuple, Term, type_desc.type_of(ValTypedVar),
-        UnivResult),
+    try_term_to_univ(Term, type_desc.type_of(ValTypedVar), UnivResult),
     (
         UnivResult = ok(Univ),
         det_univ_to_type(Univ, Val),
@@ -510,23 +490,23 @@
         Result = error(Error)
     ).

-:- pred try_term_to_univ(bool::in, term(T)::in, type_desc.type_desc::in,
+:- pred try_term_to_univ(term(T)::in, type_desc.type_desc::in,
     term_to_type_result(univ, T)::out) is det.

-try_term_to_univ(IsAditiTuple, Term, Type, Result) :-
-    try_term_to_univ_2(IsAditiTuple, Term, Type, [], Result).
+try_term_to_univ(Term, Type, Result) :-
+    try_term_to_univ_2(Term, Type, [], Result).

-:- pred try_term_to_univ_2(bool::in, term(T)::in,
+:- pred try_term_to_univ_2(term(T)::in,
     type_desc.type_desc::in, term_to_type_context::in,
     term_to_type_result(univ, T)::out) is det.

-try_term_to_univ_2(_, variable(Var), _Type, Context,
+try_term_to_univ_2(variable(Var), _Type, Context,
         error(mode_error(Var, Context))).
-try_term_to_univ_2(IsAditiTuple, Term, Type, Context, Result) :-
+try_term_to_univ_2(Term, Type, Context, Result) :-
     Term = functor(Functor, ArgTerms, TermContext),
     (
         type_desc.type_ctor_and_args(Type, TypeCtor, TypeArgs),
-        term_to_univ_special_case(IsAditiTuple,
+        term_to_univ_special_case(
             type_desc.type_ctor_module_name(TypeCtor),
             type_desc.type_ctor_name(TypeCtor),
             TypeArgs, Term, Type, Context, SpecialCaseResult)
@@ -536,8 +516,8 @@
         Functor = atom(FunctorName),
         list.length(ArgTerms, Arity),
         find_functor(Type, FunctorName, Arity, FunctorNumber, ArgTypes),
-        term_list_to_univ_list(IsAditiTuple, ArgTerms,
-            ArgTypes, Functor, 1, Context, TermContext, ArgsResult)
+        term_list_to_univ_list(ArgTerms, ArgTypes, Functor, 1, Context,
+            TermContext, ArgsResult)
     ->
         (
             ArgsResult = ok(ArgValues),
@@ -557,43 +537,28 @@
         Result = error(type_error(Term, Type, TermContext, RevContext))
     ).

-:- pred term_to_univ_special_case(bool::in, string::in, string::in,
+:- pred term_to_univ_special_case(string::in, string::in,
     list(type_desc.type_desc)::in,
     term(T)::in(bound(functor(ground, ground, ground))),
     type_desc.type_desc::in, term_to_type_context::in,
     term_to_type_result(univ, T)::out) is semidet.

-term_to_univ_special_case(IsAditiTuple, "builtin", "character", [],
-        Term, _, _, ok(Univ)) :-
-    (
-        IsAditiTuple = no,
-        Term = functor(atom(FunctorName), [], _),
-        string.first_char(FunctorName, Char, "")
-    ;
-        IsAditiTuple = yes,
-        Term = functor(integer(Int), [], _),
-        char.to_int(Char, Int)
-    ),
+term_to_univ_special_case("builtin", "character", [], Term, _, _, ok(Univ)) :-
+    Term = functor(atom(FunctorName), [], _),
+    string.first_char(FunctorName, Char, ""),
     type_to_univ(Char, Univ).
-term_to_univ_special_case(_, "builtin", "int", [],
+term_to_univ_special_case("builtin", "int", [],
         Term, _, _, ok(Univ)) :-
     Term = functor(integer(Int), [], _),
     type_to_univ(Int, Univ).
-term_to_univ_special_case(_, "builtin", "string", [],
+term_to_univ_special_case("builtin", "string", [],
         Term, _, _, ok(Univ)) :-
     Term = functor(string(String), [], _),
     type_to_univ(String, Univ).
-term_to_univ_special_case(IsAditiTuple, "builtin", "float", [],
-        Term, _, _, ok(Univ)) :-
-    ( Term = functor(float(Float), [], _) ->
-        type_to_univ(Float, Univ)
-    ;
-        IsAditiTuple = yes,
-        Term = functor(integer(Int), [], _),
-        Float = float.float(Int),
-        type_to_univ(Float, Univ)
-    ).
-term_to_univ_special_case(IsAditiTuple, "array", "array", [ElemType],
+term_to_univ_special_case("builtin", "float", [], Term, _, _, ok(Univ)) :-
+    Term = functor(float(Float), [], _),
+    type_to_univ(Float, Univ).
+term_to_univ_special_case("array", "array", [ElemType],
         Term, _Type, PrevContext, Result) :-
     %
     % arrays are represented as terms of the form
@@ -609,7 +574,7 @@
     ListType = type_desc.type_of([Elem]),
     ArgContext = arg_context(atom("array"), 1, TermContext),
     NewContext = [ArgContext | PrevContext],
-    try_term_to_univ_2(IsAditiTuple, ArgList, ListType, NewContext, ArgResult),
+    try_term_to_univ_2(ArgList, ListType, NewContext, ArgResult),
     (
         ArgResult = ok(ListUniv),
         type_desc.has_type(Elem2, ElemType),
@@ -621,9 +586,9 @@
         ArgResult = error(Error),
         Result = error(Error)
     ).
-term_to_univ_special_case(_, "builtin", "c_pointer", _, _, _, _, _) :-
+term_to_univ_special_case("builtin", "c_pointer", _, _, _, _, _) :-
     fail.
-term_to_univ_special_case(_, "univ", "univ", [], Term, _, _, Result) :-
+term_to_univ_special_case("univ", "univ", [], Term, _, _, Result) :-
     % Implementing this properly would require keeping a global table mapping
     % from type names to type_infos for all of the types in the program...
     % so for the moment, we only allow it for basic types.
@@ -646,25 +611,24 @@
     % like all the other results returned from this procedure.
     Result = ok(univ(Univ)).

-term_to_univ_special_case(_, "type_desc", "type_desc", _, _, _, _, _) :-
+term_to_univ_special_case("type_desc", "type_desc", _, _, _, _, _) :-
     % Ditto.
     fail.

-:- pred term_list_to_univ_list(bool::in, list(term(T))::in,
+:- pred term_list_to_univ_list(list(term(T))::in,
     list(type_desc.type_desc)::in, const::in, int::in,
     term_to_type_context::in, context::in,
     term_to_type_result(list(univ), T)::out) is semidet.

-term_list_to_univ_list(_, [], [], _, _, _, _, ok([])).
-term_list_to_univ_list(IsAditiTuple, [ArgTerm | ArgTerms],
+term_list_to_univ_list([], [], _, _, _, _, ok([])).
+term_list_to_univ_list([ArgTerm | ArgTerms],
         [Type | Types], Functor, ArgNum, PrevContext, TermContext, Result) :-
     ArgContext = arg_context(Functor, ArgNum, TermContext),
     NewContext = [ArgContext | PrevContext],
-    try_term_to_univ_2(IsAditiTuple, ArgTerm, Type, NewContext,
-        ArgResult),
+    try_term_to_univ_2(ArgTerm, Type, NewContext, ArgResult),
     (
         ArgResult = ok(Arg),
-        term_list_to_univ_list(IsAditiTuple, ArgTerms, Types, Functor,
+        term_list_to_univ_list(ArgTerms, Types, Functor,
             ArgNum + 1, PrevContext, TermContext, RestResult),
         (
             RestResult = ok(Rest),

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list