[m-rev.] for review (needs committing): Document and fix pragma foreign_export("IL")

Jonathan Morgan jonmmorgan at gmail.com
Fri Dec 29 22:32:19 AEDT 2006


Estimated hours taken: 6
Branches: main

Document `:- pragma foreign_export' for the IL foreign language (this
had previously been implemented for `:- pragma export').  Make the
MLDS filter foreign exports by foreign language (this is not a problem
for the other backends, as they only have one foreign language).
Remove warnings and todos associated with this.

Add IL foreign exports for all the existing C foreign exports, to
restore the backend to the same state as it was in before pragma
foreign_export was implemented.  (Note that the IL standard library
usage should be reviewed after `pragma foreign_export' is implemented
for C#).

compiler/foreign.m:
compiler/ml_code_gen.m:
    For any given foreign language, only include those `pragma
foreign_exports' that have the given target language.

compiler/add_pragma.m:
compiler/mlds_to_il.m:
    Remove warnings.

library/*.m:
    Add a foreign_export("IL") for every existing foreign_export("C").

    Convert a couple of `pragma export' statements to `pragma foreign_export'.

doc/reference_manual.texi:
    Document `pragma foreign_export` for the IL foreign language.

Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.57
diff -u -r1.57 add_pragma.m
--- compiler/add_pragma.m	27 Dec 2006 04:16:25 -0000	1.57
+++ compiler/add_pragma.m	29 Dec 2006 10:57:39 -0000
@@ -401,11 +401,10 @@
             ;
                 % Emit a warning about using pragma foreign_export with
                 % a foreign language that is not supported.
-                % XXX That's currently all of them except C.
+                % XXX That's currently all of them except C and IL.
                 (
                     ( Lang = lang_java
                     ; Lang = lang_csharp
-                    ; Lang = lang_il
                     ; Lang = lang_managed_cplusplus
                     ),
                     Pieces = [words("Warning:"),
@@ -417,7 +416,9 @@
                         phase_parse_tree_to_hlds, [Msg]),
                     !:Specs = [Spec | !.Specs]
                 ;
-                    Lang = lang_c
+                    ( Lang = lang_c
+                    ; Lang = lang_il
+                    )
                 ),

                 % Only add the foreign export if the specified language matches
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.67
diff -u -r1.67 foreign.m
--- compiler/foreign.m	2 Oct 2006 05:21:10 -0000	1.67
+++ compiler/foreign.m	29 Dec 2006 10:57:42 -0000
@@ -112,6 +112,15 @@
 :- pred filter_bodys(foreign_language::in, foreign_body_info::in,
     foreign_body_info::out, foreign_body_info::out) is det.

+    % Filter the foreign exports for the given foreign language.
+    % The first return value is the list of matches, the second is
+    % the list of mis-matches.
+    %
+:- pred filter_exports(foreign_language::in,
+    list(pragma_exported_proc)::in,
+    list(pragma_exported_proc)::out, list(pragma_exported_proc)::out)
+    is det.
+
     % Given some foreign code, generate some suitable proxy code for
     % calling the code via one of the given languages.
     % This might mean, for example, generating a call to a
@@ -193,6 +202,11 @@
     IsWanted = (pred(foreign_body_code(Lang, _, _)::in) is semidet :-
         WantedLang = Lang),
     list.filter(IsWanted, Bodys0, LangBodys, NotLangBodys).
+
+filter_exports(WantedLang, Exports0, LangExports, NotLangExports) :-
+    IsWanted = (pred(pragma_exported_proc(Lang, _, _, _, _)::in) is semidet :-
+        WantedLang = Lang),
+    list.filter(IsWanted, Exports0, LangExports, NotLangExports).

 extrude_pragma_implementation([], _PragmaVars, _PredName, _PredOrFunc,
         _Context, !ModuleInfo, !NewAttributes, !Impl) :-
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.193
diff -u -r1.193 ml_code_gen.m
--- compiler/ml_code_gen.m	27 Dec 2006 04:16:29 -0000	1.193
+++ compiler/ml_code_gen.m	29 Dec 2006 10:57:52 -0000
@@ -818,6 +818,7 @@
     module_info_get_foreign_decl(ModuleInfo, ForeignDecls),
     module_info_get_foreign_import_module(ModuleInfo, ForeignImports),
     module_info_get_foreign_body_code(ModuleInfo, ForeignBodys),
+    module_info_get_pragma_exported_procs(ModuleInfo, ForeignExports),
     globals.io_get_backend_foreign_languages(BackendForeignLanguages, !IO),

     WantedForeignImports = list.condense(
@@ -826,27 +827,31 @@
         ), BackendForeignLanguages)),

     list.foldl(ml_gen_foreign_code_lang(ModuleInfo, ForeignDecls,
-        ForeignBodys, WantedForeignImports),
+        ForeignBodys, WantedForeignImports, ForeignExports),
         BackendForeignLanguages, map.init, AllForeignCode).

 :- pred ml_gen_foreign_code_lang(module_info::in, foreign_decl_info::in,
     foreign_body_info::in, foreign_import_module_info_list::in,
-    foreign_language::in,
+    list(pragma_exported_proc)::in, foreign_language::in,
     map(foreign_language, mlds_foreign_code)::in,
     map(foreign_language, mlds_foreign_code)::out) is det.

 ml_gen_foreign_code_lang(ModuleInfo, ForeignDecls, ForeignBodys,
-        WantedForeignImports, Lang, Map0, Map) :-
+        WantedForeignImports, ForeignExports, Lang, Map0, Map) :-
     foreign.filter_decls(Lang, ForeignDecls, WantedForeignDecls,
         _OtherForeignDecls),
     foreign.filter_bodys(Lang, ForeignBodys, WantedForeignBodys,
         _OtherForeignBodys),
+    foreign.filter_exports(Lang, ForeignExports, WantedForeignExports,
+        _OtherForeignExports),
     ConvBody = (func(foreign_body_code(L, S, C)) =
         user_foreign_code(L, S, C)),
     MLDSWantedForeignBodys = list.map(ConvBody, WantedForeignBodys),
-    ml_gen_pragma_export(ModuleInfo, MLDS_PragmaExports),
+    list.map(ml_gen_pragma_export_proc(ModuleInfo),
+        WantedForeignExports, MLDSWantedForeignExports),
     MLDS_ForeignCode = mlds_foreign_code(WantedForeignDecls,
-        WantedForeignImports, MLDSWantedForeignBodys, MLDS_PragmaExports),
+        WantedForeignImports, MLDSWantedForeignBodys,
+        MLDSWantedForeignExports),
     map.det_insert(Map0, Lang, MLDS_ForeignCode, Map).

 :- pred ml_gen_imports(module_info::in, mlds_imports::out) is det.
@@ -909,14 +914,6 @@
 %
 % For each pragma export declaration we associate with it the information
 % used to generate the function prototype for the MLDS entity.
-
-:- pred ml_gen_pragma_export(module_info::in, list(mlds_pragma_export)::out)
-    is det.
-
-ml_gen_pragma_export(ModuleInfo, MLDS_PragmaExports) :-
-    module_info_get_pragma_exported_procs(ModuleInfo, PragmaExports),
-    list.map(ml_gen_pragma_export_proc(ModuleInfo),
-        PragmaExports, MLDS_PragmaExports).

 :- pred ml_gen_pragma_export_proc(module_info::in, pragma_exported_proc::in,
     mlds_pragma_export::out) is det.
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.175
diff -u -r1.175 mlds_to_il.m
--- compiler/mlds_to_il.m	23 Dec 2006 12:49:24 -0000	1.175
+++ compiler/mlds_to_il.m	29 Dec 2006 10:58:06 -0000
@@ -53,7 +53,6 @@
 % [ ] Add an option to do overflow checking.
 % [ ] Should replace hard-coded of int32 with a more abstract name such
 %     as `mercury_int_il_type'.
-% [ ] Document `pragma foreign_export' for IL.
 % [ ] Implement `pragma foreign_export' for C# and MC++.
 %
 % XXX We should rename this module to mlds_to_ilds, since that is what
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.373
diff -u -r1.373 reference_manual.texi
--- doc/reference_manual.texi	4 Dec 2006 04:30:50 -0000	1.373
+++ doc/reference_manual.texi	29 Dec 2006 10:58:35 -0000
@@ -7399,7 +7399,54 @@
 @node Using pragma foreign_export for IL
 @subsubsection Using pragma foreign_export for IL

- at samp{pragma foreign_export} is currently not supported for IL.
+A @samp{pragma foreign_export} declaration for IL has the form:
+
+ at example
+:- pragma foreign_export("IL", @var{MercuryMode}, "@var{IL_Name}").
+ at end example
+
+For example,
+
+ at example
+:- pragma foreign_export("IL", foo(in, in, out), "foo").
+ at end example
+
+For each Mercury module containing @samp{pragma foreign_export} declarations
+for IL, the Mercury implementation will automatically create a static method
+ at var{IL_Name}() in the <module_name>.mercury_code class for each of the
+ at samp{pragma foreign_export} declarations.  Each such IL method is the
+.NET interface to the specified Mercury procedure, and should be usable from
+any .NET language.
+
+The type signature of the IL interface to a Mercury procedure is determined as
+follows.  Mercury types are converted to IL types according to the rules in
+ at ref{IL and C# data passing conventions}.  Input arguments are passed by value.
+For output arguments, the caller must pass the address in which to store the
+result.  If the Mercury procedure can fail, then its IL interface method
+returns a truth value indicating success or failure.  If the Mercury procedure
+is a Mercury function that cannot fail, and the function result has an output
+mode, then the IL interface method will return the Mercury function result
+value.  Otherwise the function result is appended as an extra argument.
+ at c XXX We need to update this for dummy unit types.
+Arguments of type @samp{io.state} or @samp{store.store(_)} are not passed
+at all.  (The reason for this is that these types represent mutable state,
+and in .NET modifications to mutable state are done via side effects, rather
+than argument passing.)
+
+Calling polymorphically typed Mercury procedures from .NET is a little bit more
+difficult than calling ordinary (monomorphically typed) Mercury procedures.
+The simplest method is to just create monomorphic forwarding procedures that
+call the polymorphic procedures, and export them, rather than exporting the
+polymorphic procedures.
+
+If you do export a polymorphically typed Mercury procedure, the compiler
+will prepend one @samp{type_info} argument to the parameter list of
+the IL interface method for each polymorphic type variable in the
+Mercury procedure's type signature.  The caller must arrange to pass
+in appropriate @samp{type_info} values corresponding to the types
+of the other arguments passed.  These @samp{type_info} arguments can
+be obtained using the Mercury @samp{type_of} function in the Mercury
+standard library module @samp{type_desc}.

 @node Using pragma foreign_decl for IL
 @subsubsection Using pragma foreign_decl for IL
Index: library/array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.149
diff -u -r1.149 array.m
--- library/array.m	23 Oct 2006 00:32:55 -0000	1.149
+++ library/array.m	29 Dec 2006 10:58:47 -0000
@@ -423,6 +423,7 @@
     %
 :- pred array_equal(array(T)::in, array(T)::in) is semidet.
 :- pragma foreign_export("C", array_equal(in, in), "ML_array_equal").
+:- pragma foreign_export("IL", array_equal(in, in), "ML_array_equal").
 :- pragma terminates(array_equal/2).

 array_equal(Array1, Array2) :-
@@ -453,6 +454,7 @@
 :- pred array_compare(comparison_result::uo, array(T)::in, array(T)::in)
     is det.
 :- pragma foreign_export("C", array_compare(uo, in, in), "ML_array_compare").
+:- pragma foreign_export("IL", array_compare(uo, in, in), "ML_array_compare").
 :- pragma terminates(array_compare/3).

 array_compare(Result, Array1, Array2) :-
Index: library/bool.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/bool.m,v
retrieving revision 1.17
diff -u -r1.17 bool.m
--- library/bool.m	31 Aug 2006 11:09:51 -0000	1.17
+++ library/bool.m	29 Dec 2006 10:58:47 -0000
@@ -118,7 +118,9 @@
 :- func bool.return_no = bool.
 :- func bool.return_yes = bool.
 :- pragma foreign_export("C", bool.return_no = out, "ML_bool_return_no").
+:- pragma foreign_export("IL", bool.return_no = out, "ML_bool_return_no").
 :- pragma foreign_export("C", bool.return_yes = out, "ML_bool_return_yes").
+:- pragma foreign_export("IL", bool.return_yes = out, "ML_bool_return_yes").

 bool.return_no = no.
 bool.return_yes = yes.
Index: library/dir.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/dir.m,v
retrieving revision 1.37
diff -u -r1.37 dir.m
--- library/dir.m	1 Oct 2006 04:57:39 -0000	1.37
+++ library/dir.m	29 Dec 2006 10:58:48 -0000
@@ -307,6 +307,8 @@

 :- pragma foreign_export("C", (dir.this_directory = out),
     "ML_dir_this_directory").
+:- pragma foreign_export("IL", (dir.this_directory = out),
+    "ML_dir_this_directory").

 dir.this_directory = ".".

@@ -752,6 +754,8 @@

 :- pragma foreign_export("C", dir.make_path_name(in, in) = out,
     "ML_make_path_name").
+:- pragma foreign_export("IL", dir.make_path_name(in, in) = out,
+    "ML_make_path_name").

 DirName0/FileName0 = PathName :-
     DirName = string.from_char_list(canonicalize_path_chars(
@@ -1046,6 +1050,8 @@
 :- func dir.make_mkdir_res_ok = io.res.
 :- pragma foreign_export("C", (dir.make_mkdir_res_ok = out),
     "ML_make_mkdir_res_ok").
+:- pragma foreign_export("IL", (dir.make_mkdir_res_ok = out),
+    "ML_make_mkdir_res_ok").

 dir.make_mkdir_res_ok = ok.

@@ -1053,6 +1059,8 @@
     io::di, io::uo) is det.
 :- pragma foreign_export("C", dir.make_mkdir_res_error(in, out, di, uo),
     "ML_make_mkdir_res_error").
+:- pragma foreign_export("IL", dir.make_mkdir_res_error(in, out, di, uo),
+    "ML_make_mkdir_res_error").

 dir.make_mkdir_res_error(Error, error(make_io_error(Msg)), !IO) :-
     io.make_maybe_win32_err_msg(Error, "dir.make_directory failed: ",
@@ -1062,6 +1070,8 @@
     string::in, io.res::out, io::di, io::uo) is det.
 :- pragma foreign_export("C", dir.make_mkdir_res_exists(in, in, out, di, uo),
     "ML_make_mkdir_res_exists").
+:- pragma foreign_export("IL", dir.make_mkdir_res_exists(in, in, out, di, uo),
+    "ML_make_mkdir_res_exists").

 dir.make_mkdir_res_exists(Error, DirName, Res, !IO) :-
     io.file_type(yes, DirName, TypeResult, !IO),
@@ -1075,6 +1085,8 @@
     is det.
 :- pragma foreign_export("C", dir.check_dir_accessibility(in, out, di, uo),
     "ML_check_dir_accessibility").
+:- pragma foreign_export("IL", dir.check_dir_accessibility(in, out, di, uo),
+    "ML_check_dir_accessibility").

 dir.check_dir_accessibility(DirName, Res, !IO) :-
     % Check whether we can read and write the directory.
@@ -1426,6 +1438,8 @@
     io.result({dir.stream, string})::out, io::di, io::uo) is det.
 :- pragma foreign_export("C", dir.check_dir_readable(in, out, out, di, uo),
     "ML_check_dir_readable").
+:- pragma foreign_export("IL", dir.check_dir_readable(in, out, out, di, uo),
+    "ML_check_dir_readable").

 dir.check_dir_readable(DirName, IsReadable, Result, !IO) :-
     io.file_type(yes, DirName, FileTypeRes, !IO),
@@ -1460,6 +1474,8 @@
     io.result({dir.stream, string})::out, io::di, io::uo) is det.
 :- pragma foreign_export("C", dir.read_first_entry(in, out, di, uo),
     "ML_dir_read_first_entry").
+:- pragma foreign_export("IL", dir.read_first_entry(in, out, di, uo),
+    "ML_dir_read_first_entry").

 dir.read_first_entry(Dir, Result, !IO) :-
     dir.read_entry(Dir, EntryResult, !IO),
@@ -1478,6 +1494,8 @@
     io.result({dir.stream, string})::out, io::di, io::uo) is det.
 :- pragma foreign_export("C", make_win32_dir_open_result_ok(in, in,
out, di, uo),
     "ML_make_win32_dir_open_result_ok").
+:- pragma foreign_export("IL", make_win32_dir_open_result_ok(in, in,
out, di, uo),
+    "ML_make_win32_dir_open_result_ok").

 make_win32_dir_open_result_ok(Dir, FirstFilePtr, Result, !IO) :-
     FirstFile0 = copy_c_string(FirstFilePtr),
@@ -1529,12 +1547,16 @@
 :- func make_dir_open_result_eof = io.result({dir.stream, string}).
 :- pragma foreign_export("C", (make_dir_open_result_eof = out),
     "ML_make_dir_open_result_eof").
+:- pragma foreign_export("IL", (make_dir_open_result_eof = out),
+    "ML_make_dir_open_result_eof").

 make_dir_open_result_eof = eof.

 :- pred make_dir_open_result_error(io.system_error::in,
     io.result({dir.stream, string})::out, io::di, io::uo) is det.
 :- pragma foreign_export("C", make_dir_open_result_error(in, out, di, uo),
+    "ML_make_dir_open_result_error").
+:- pragma foreign_export("IL", make_dir_open_result_error(in, out, di, uo),
     "ML_make_dir_open_result_error").

 make_dir_open_result_error(Error, error(io.make_io_error(Msg)), !IO) :-
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.120
diff -u -r1.120 exception.m
--- library/exception.m	26 Dec 2006 06:41:36 -0000	1.120
+++ library/exception.m	29 Dec 2006 10:58:56 -0000
@@ -1392,8 +1392,12 @@

 :- pragma foreign_export("C", call_goal(pred(out) is det, out),
     "ML_call_goal_det").
+:- pragma foreign_export("IL", call_goal(pred(out) is det, out),
+    "ML_call_goal_det").
 :- pragma foreign_export("C", call_goal(pred(out) is semidet, out),
     "ML_call_goal_semidet").
+:- pragma foreign_export("IL", call_goal(pred(out) is semidet, out),
+    "ML_call_goal_semidet").

 % This causes problems because the LLDS back-end
 % does not let you export code with determinism `nondet'.
@@ -1408,6 +1412,8 @@

 :- pragma foreign_export("C", call_handler(pred(in, out) is det, in, out),
     "ML_call_handler_det").
+:- pragma foreign_export("IL", call_handler(pred(in, out) is det, in, out),
+    "ML_call_handler_det").

 :- pragma foreign_proc("Java",
     throw_impl(_T::in),
@@ -2484,6 +2490,8 @@
 %-----------------------------------------------------------------------------%

 :- pragma foreign_export("C", report_uncaught_exception(in, di, uo),
+    "ML_report_uncaught_exception").
+:- pragma foreign_export("IL", report_uncaught_exception(in, di, uo),
     "ML_report_uncaught_exception").

 :- pred report_uncaught_exception(univ::in, io::di, io::uo) is cc_multi.
Index: library/gc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/gc.m,v
retrieving revision 1.23
diff -u -r1.23 gc.m
--- library/gc.m	31 Aug 2006 11:09:52 -0000	1.23
+++ library/gc.m	29 Dec 2006 10:58:56 -0000
@@ -44,6 +44,7 @@
 :- pragma no_inline(garbage_collect/0).

 :- pragma foreign_export("C", garbage_collect, "ML_garbage_collect").
+:- pragma foreign_export("IL", garbage_collect, "ML_garbage_collect").

 :- pragma foreign_proc("C",
 	garbage_collect,
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.365
diff -u -r1.365 io.m
--- library/io.m	21 Dec 2006 11:11:31 -0000	1.365
+++ library/io.m	29 Dec 2006 10:59:15 -0000
@@ -2253,6 +2253,8 @@

 :- pragma foreign_export("C", make_err_msg(in, in, out, di, uo),
     "ML_make_err_msg").
+:- pragma foreign_export("IL", make_err_msg(in, in, out, di, uo),
+    "ML_make_err_msg").

 :- pragma foreign_proc("C",
     make_err_msg(Error::in, Msg0::in, Msg::out, IO0::di, IO::uo),
@@ -2318,6 +2320,8 @@

 :- pragma foreign_export("C", make_win32_err_msg(in, in, out, di, uo),
     "ML_make_win32_err_msg").
+:- pragma foreign_export("IL", make_win32_err_msg(in, in, out, di, uo),
+    "ML_make_win32_err_msg").

 make_win32_err_msg(_, _, "", !IO) :-
     ( semidet_succeed ->
@@ -2737,26 +2741,48 @@

 :- pragma foreign_export("C", file_type_character_device = out,
     "ML_file_type_character_device").
+:- pragma foreign_export("IL", file_type_character_device = out,
+    "ML_file_type_character_device").
 :- pragma foreign_export("C", file_type_block_device = out,
     "ML_file_type_block_device").
+:- pragma foreign_export("IL", file_type_block_device = out,
+    "ML_file_type_block_device").
 :- pragma foreign_export("C", file_type_fifo = out,
     "ML_file_type_fifo").
+:- pragma foreign_export("IL", file_type_fifo = out,
+    "ML_file_type_fifo").
 :- pragma foreign_export("C", file_type_directory = out,
     "ML_file_type_directory").
+:- pragma foreign_export("IL", file_type_directory = out,
+    "ML_file_type_directory").
 :- pragma foreign_export("C", file_type_socket = out,
     "ML_file_type_socket").
+:- pragma foreign_export("IL", file_type_socket = out,
+    "ML_file_type_socket").
 :- pragma foreign_export("C", file_type_symbolic_link = out,
     "ML_file_type_symbolic_link").
+:- pragma foreign_export("IL", file_type_symbolic_link = out,
+    "ML_file_type_symbolic_link").
 :- pragma foreign_export("C", file_type_regular = out,
     "ML_file_type_regular").
+:- pragma foreign_export("IL", file_type_regular = out,
+    "ML_file_type_regular").
 :- pragma foreign_export("C", file_type_message_queue = out,
     "ML_file_type_message_queue").
+:- pragma foreign_export("IL", file_type_message_queue = out,
+    "ML_file_type_message_queue").
 :- pragma foreign_export("C", file_type_semaphore = out,
     "ML_file_type_semaphore").
+:- pragma foreign_export("IL", file_type_semaphore = out,
+    "ML_file_type_semaphore").
 :- pragma foreign_export("C", file_type_shared_memory = out,
     "ML_file_type_shared_memory").
+:- pragma foreign_export("IL", file_type_shared_memory = out,
+    "ML_file_type_shared_memory").
 :- pragma foreign_export("C", file_type_unknown = out,
     "ML_file_type_unknown").
+:- pragma foreign_export("IL", file_type_unknown = out,
+    "ML_file_type_unknown").

 %-----------------------------------------------------------------------------%

@@ -3013,6 +3039,8 @@
 :- pred access_types_includes_read(list(access_type)::in) is semidet.
 :- pragma foreign_export("C", access_types_includes_read(in),
     "ML_access_types_includes_read").
+:- pragma foreign_export("IL", access_types_includes_read(in),
+    "ML_access_types_includes_read").

 access_types_includes_read(Access) :-
     list.member(read, Access).
@@ -3020,6 +3048,8 @@
 :- pred access_types_includes_write(list(access_type)::in) is semidet.
 :- pragma foreign_export("C", access_types_includes_write(in),
     "ML_access_types_includes_write").
+:- pragma foreign_export("IL", access_types_includes_write(in),
+    "ML_access_types_includes_write").

 access_types_includes_write(Access) :-
     list.member(write, Access).
@@ -3027,6 +3057,8 @@
 :- pred access_types_includes_execute(list(access_type)::in) is semidet.
 :- pragma foreign_export("C", access_types_includes_execute(in),
     "ML_access_types_includes_execute").
+:- pragma foreign_export("IL", access_types_includes_execute(in),
+    "ML_access_types_includes_execute").

 access_types_includes_execute(Access) :-
     list.member(execute, Access).
@@ -3034,6 +3066,8 @@
 :- func make_io_res_0_ok = io.res.
 :- pragma foreign_export("C", (make_io_res_0_ok = out),
     "ML_make_io_res_0_ok").
+:- pragma foreign_export("IL", (make_io_res_0_ok = out),
+    "ML_make_io_res_0_ok").

 make_io_res_0_ok = ok.

@@ -3041,6 +3075,8 @@
     io::di, io::uo) is det.
 :- pragma foreign_export("C", make_io_res_0_error(in, in, out, di, uo),
     "ML_make_io_res_0_error").
+:- pragma foreign_export("IL", make_io_res_0_error(in, in, out, di, uo),
+    "ML_make_io_res_0_error").

 make_io_res_0_error(Error, Msg0, error(make_io_error(Msg)), !IO) :-
     io.make_err_msg(Error, Msg0, Msg, !IO).
@@ -3048,12 +3084,16 @@
 :- func make_io_res_0_error_msg(string) = io.res.
 :- pragma foreign_export("C", (make_io_res_0_error_msg(in) = out),
     "ML_make_io_res_0_error_msg").
+:- pragma foreign_export("IL", (make_io_res_0_error_msg(in) = out),
+    "ML_make_io_res_0_error_msg").

 make_io_res_0_error_msg(Msg) = error(make_io_error(Msg)).

 :- func make_io_res_1_ok_file_type(file_type) = io.res(file_type).
 :- pragma foreign_export("C", (make_io_res_1_ok_file_type(in) = out),
     "ML_make_io_res_1_ok_file_type").
+:- pragma foreign_export("IL", (make_io_res_1_ok_file_type(in) = out),
+    "ML_make_io_res_1_ok_file_type").

 make_io_res_1_ok_file_type(FileType) = ok(FileType).

@@ -3062,6 +3102,9 @@
 :- pragma foreign_export("C",
     make_io_res_1_error_file_type(in, in, out, di, uo),
     "ML_make_io_res_1_error_file_type").
+:- pragma foreign_export("IL",
+    make_io_res_1_error_file_type(in, in, out, di, uo),
+    "ML_make_io_res_1_error_file_type").

 make_io_res_1_error_file_type(Error, Msg0, error(make_io_error(Msg)), !IO) :-
     io.make_err_msg(Error, Msg0, Msg, !IO).
@@ -3836,6 +3879,8 @@

 :- pragma foreign_export("C", io.print(in, di, uo),
     "ML_io_print_to_cur_stream").
+:- pragma foreign_export("IL", io.print(in, di, uo),
+    "ML_io_print_to_cur_stream").

 io.print(Term, !IO) :-
     io.output_stream(Stream, !IO),
@@ -3855,6 +3900,8 @@

 :- pragma foreign_export("C", io.print_to_stream(in, in, di, uo),
     "ML_io_print_to_stream").
+:- pragma foreign_export("IL", io.print_to_stream(in, in, di, uo),
+    "ML_io_print_to_stream").

 io.print_to_stream(Stream, Term, !IO) :-
     io.print(output_stream(Stream), canonicalize, Term, !IO).
@@ -4523,6 +4570,7 @@
     % For use by the Mercury runtime.
     %
 :- pragma foreign_export("C", io.init_state(di, uo), "ML_io_init_state").
+:- pragma foreign_export("IL", io.init_state(di, uo), "ML_io_init_state").

 io.init_state(!IO) :-
     io.gc_init(type_of(StreamDb), type_of(Globals), !IO),
@@ -4538,6 +4586,7 @@
     % For use by the Mercury runtime.
     %
 :- pragma foreign_export("C", io.finalize_state(di, uo),
"ML_io_finalize_state").
+:- pragma foreign_export("IL", io.finalize_state(di, uo),
"ML_io_finalize_state").

     % Currently no finalization needed...
     % (Perhaps we should close all open Mercury files?
@@ -4624,6 +4673,8 @@

 :- pragma foreign_export("C", io.get_io_input_stream_type(out, di, uo),
     "ML_io_input_stream_type").
+:- pragma foreign_export("IL", io.get_io_input_stream_type(out, di, uo),
+    "ML_io_input_stream_type").

 io.get_io_input_stream_type(Type, !IO) :-
     io.stdin_stream(Stream, !IO),
@@ -4633,6 +4684,8 @@

 :- pragma foreign_export("C", io.get_io_output_stream_type(out, di, uo),
     "ML_io_output_stream_type").
+:- pragma foreign_export("IL", io.get_io_output_stream_type(out, di, uo),
+    "ML_io_output_stream_type").

 io.get_io_output_stream_type(Type, !IO) :-
     io.stdout_stream(Stream, !IO),
@@ -5517,6 +5570,7 @@

 :- pred throw_io_error(string::in) is erroneous.
 :- pragma foreign_export("C", throw_io_error(in), "ML_throw_io_error").
+:- pragma foreign_export("IL", throw_io_error(in), "ML_throw_io_error").

 throw_io_error(Message) :-
     throw(io_error(Message)).
@@ -6713,9 +6767,15 @@

 :- pragma foreign_export("C", io.stdin_stream_2(out, di, uo),
     "ML_io_stdin_stream").
+:- pragma foreign_export("IL", io.stdin_stream_2(out, di, uo),
+    "ML_io_stdin_stream").
 :- pragma foreign_export("C", io.stdout_stream_2(out, di, uo),
     "ML_io_stdout_stream").
+:- pragma foreign_export("IL", io.stdout_stream_2(out, di, uo),
+    "ML_io_stdout_stream").
 :- pragma foreign_export("C", io.stderr_stream_2(out, di, uo),
+    "ML_io_stderr_stream").
+:- pragma foreign_export("IL", io.stderr_stream_2(out, di, uo),
     "ML_io_stderr_stream").

 io.stdin_stream = input_stream(io.stdin_stream_2).
Index: library/list.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.157
diff -u -r1.157 list.m
--- library/list.m	29 Nov 2006 06:42:39 -0000	1.157
+++ library/list.m	29 Dec 2006 10:59:23 -0000
@@ -2166,11 +2166,13 @@
 % managed languages on the il backend.

 :- func empty_list = list(T).
-:- pragma export(empty_list = out, "ML_empty_list").
+:- pragma foreign_export("C", empty_list = out, "ML_empty_list").
+:- pragma foreign_export("IL", empty_list = out, "ML_empty_list").

 empty_list = [].

-:- pragma export((list.cons(in, in) = (out)), "ML_cons").
+:- pragma foreign_export("C", (list.cons(in, in) = (out)), "ML_cons").
+:- pragma foreign_export("IL", (list.cons(in, in) = (out)), "ML_cons").

 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.252
diff -u -r1.252 string.m
--- library/string.m	7 Dec 2006 05:10:30 -0000	1.252
+++ library/string.m	29 Dec 2006 10:59:35 -0000
@@ -3096,6 +3096,7 @@
     ).

 :- pragma foreign_export("C", string.to_float(in, out), "ML_string_to_float").
+:- pragma foreign_export("IL", string.to_float(in, out), "ML_string_to_float").

 :- pragma foreign_proc("C",
     string.to_float(FloatString::in, FloatVal::out),
Index: library/table_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/table_builtin.m,v
retrieving revision 1.55
diff -u -r1.55 table_builtin.m
--- library/table_builtin.m	31 Aug 2006 11:09:53 -0000	1.55
+++ library/table_builtin.m	29 Dec 2006 10:59:39 -0000
@@ -199,6 +199,8 @@
     io::di, io::uo) is det.
 :- pragma foreign_export("C", get_tabling_stats(in, out, di, uo),
     "MR_get_tabling_stats").
+:- pragma foreign_export("IL", get_tabling_stats(in, out, di, uo),
+    "MR_get_tabling_stats").

 get_tabling_stats(Info, Statistics, !IO) :-
     get_direct_fields(Info, AnswerTable, NumInputs, NumOutputs,
Index: library/time.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/time.m,v
retrieving revision 1.54
diff -u -r1.54 time.m
--- library/time.m	31 Aug 2006 11:09:53 -0000	1.54
+++ library/time.m	29 Dec 2006 10:59:43 -0000
@@ -929,6 +929,8 @@

 :- pragma foreign_export("C", construct_time_t(in) = out,
     "ML_construct_time_t").
+:- pragma foreign_export("IL", construct_time_t(in) = out,
+    "ML_construct_time_t").

 construct_time_t(T) = time_t(T).

Index: library/type_desc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/type_desc.m,v
retrieving revision 1.44
diff -u -r1.44 type_desc.m
--- library/type_desc.m	23 Oct 2006 00:33:02 -0000	1.44
+++ library/type_desc.m	29 Dec 2006 10:59:44 -0000
@@ -223,6 +223,8 @@

 :- pragma foreign_export("C", call_rtti_compare_type_infos(out, in, in),
     "ML_call_rtti_compare_type_infos").
+:- pragma foreign_export("IL", call_rtti_compare_type_infos(out, in, in),
+    "ML_call_rtti_compare_type_infos").

 :- pred call_rtti_compare_type_infos(comparison_result::out,
     rtti_implementation.type_info::in, rtti_implementation.type_info::in)
@@ -447,6 +449,7 @@

 % Export this function in order to use it in runtime/mercury_trace_external.c
 :- pragma foreign_export("C", type_name(in) = out, "ML_type_name").
+:- pragma foreign_export("IL", type_name(in) = out, "ML_type_name").

 type_name(Type) = TypeName :-
     type_ctor_and_args(Type, TypeCtor, ArgTypes),
@@ -782,6 +785,8 @@
 :- func get_type_info_for_type_info = type_desc.

 :- pragma foreign_export("C", get_type_info_for_type_info = out,
+    "ML_get_type_info_for_type_info").
+:- pragma foreign_export("IL", get_type_info_for_type_info = out,
     "ML_get_type_info_for_type_info").

 get_type_info_for_type_info = TypeDesc :-
Index: library/univ.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/univ.m,v
retrieving revision 1.4
diff -u -r1.4 univ.m
--- library/univ.m	23 Oct 2006 00:33:02 -0000	1.4
+++ library/univ.m	29 Dec 2006 10:59:44 -0000
@@ -127,12 +127,14 @@

 :- pred construct_univ(T::in, univ::out) is det.
 :- pragma foreign_export("C", construct_univ(in, out), "ML_construct_univ").
+:- pragma foreign_export("IL", construct_univ(in, out), "ML_construct_univ").

 construct_univ(X, Univ) :-
     Univ = univ(X).

 :- some [T] pred unravel_univ(univ::in, T::out) is det.
 :- pragma foreign_export("C", unravel_univ(in, out), "ML_unravel_univ").
+:- pragma foreign_export("IL", unravel_univ(in, out), "ML_unravel_univ").

 unravel_univ(Univ, X) :-
     univ_value(Univ) = X.
Index: library/unsafe.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/unsafe.m,v
retrieving revision 1.6
diff -u -r1.6 unsafe.m
--- library/unsafe.m	31 Aug 2006 11:09:53 -0000	1.6
+++ library/unsafe.m	29 Dec 2006 10:59:44 -0000
@@ -80,7 +80,11 @@

 :- pragma foreign_export("C", call_io_pred(pred(di, uo) is det, di, uo),
     "call_io_pred_det").
+:- pragma foreign_export("IL", call_io_pred(pred(di, uo) is det, di, uo),
+    "call_io_pred_det").
 :- pragma foreign_export("C", call_io_pred(pred(di, uo) is cc_multi, di, uo),
+    "call_io_pred_cc_multi").
+:- pragma foreign_export("IL", call_io_pred(pred(di, uo) is cc_multi, di, uo),
     "call_io_pred_cc_multi").

 call_io_pred(P, !IO) :-
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list