[m-rev.] diff: fix mutable_parent test case failure on saturn

Julien Fischer juliensf at cs.mu.OZ.AU
Fri Sep 30 17:27:49 AEST 2005


Estimated hours taken: 1
Branches: main

Fix a problem with mutables and intermodule-optimization.
This was causing tests/hard_coded/sub-modules/mutable_parent to fail on
saturn.

compiler/modules.m:
	Fix the handling of mutable, initialise and finalise declarations with
	respect to foreign code.  The problem is that these three declarations
	all expand to various types of foreign pragma but at the time
	modules.m processes the item list this expansion hasn't yet been done
	(it's done when the items are added to the HLDS).  Consequently
	various foreign language dependencies are not being correctly set,
	which in turn is causing problems when compiling programs that use
	mutables with intermodule-optimization enabled.

	Fix a bit of formatting.

compiler/intermod.m:
	Position a section heading according to our current coding standards.

Julien.

Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.177
diff -u -r1.177 intermod.m
--- compiler/intermod.m	12 Sep 2005 08:41:56 -0000	1.177
+++ compiler/intermod.m	30 Sep 2005 07:00:25 -0000
@@ -37,8 +37,6 @@

 :- module transform_hlds__intermod.

-%-----------------------------------------------------------------------------%
-
 :- interface.

 :- import_module hlds__hlds_module.
@@ -49,6 +47,8 @@
 :- import_module bool.
 :- import_module io.

+%-----------------------------------------------------------------------------%
+
     % Open the file "<module-name>.opt.tmp", and write out the declarations
     % and clauses for intermodule optimization. Note that update_interface
     % and touch_interface_datestamp are called from mercury_compile.m since
@@ -187,7 +187,8 @@

 %-----------------------------------------------------------------------------%
 %
-% Predicates to gather stuff to output to .opt file.
+% Predicates to gather stuff to output to .opt file
+%

 :- pred intermod__gather_preds(list(pred_id)::in, bool::in, int::in,
     int::in, bool::in, intermod_info::in, intermod_info::out) is det.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.346
diff -u -r1.346 modules.m
--- compiler/modules.m	29 Sep 2005 06:33:11 -0000	1.346
+++ compiler/modules.m	30 Sep 2005 07:15:59 -0000
@@ -669,8 +669,8 @@
     % get_ancestors(ModuleName) =  ParentDeps:
     %
     % ParentDeps is the list of ancestor modules for this module, oldest first;
-    % e.g. if the ModuleName is `foo:bar:baz', then ParentDeps would be
-    % [`foo', `foo:bar'].
+    % e.g. if the ModuleName is `foo.bar.baz', then ParentDeps would be
+    % [`foo', `foo.bar'].
     %
 :- func get_ancestors(module_name) = list(module_name).

@@ -748,8 +748,9 @@
     io::di, io::uo) is det.

 %-----------------------------------------------------------------------------%
-
-    % Java command-line tools utilities.
+%
+% Java command-line tools utilities
+%

     % Create a shell script with the same name as the given module to invoke
     % Java with the appropriate options on the class of the same name.
@@ -5745,10 +5746,28 @@
 :- pred get_item_foreign_code(globals::in, item_and_context::in,
     module_foreign_info::in, module_foreign_info::out) is det.

-get_item_foreign_code(Globals, Item, !Info) :-
-    ( Item = pragma(_, Pragma) - Context ->
+get_item_foreign_code(Globals, Item - Context, !Info) :-
+    ( Item = pragma(_, Pragma) ->
         do_get_item_foreign_code(Globals, Pragma, Context, !Info)
-    ;
+    ; Item = mutable(_, _, _, _, _) ->
+        % Mutables introduce foreign_procs, but mutable declarations
+        % won't have been expanded by the time we get here so we need
+        % to handle them separately.
+        % XXX mutables are currently only implemented for the C backends
+        % but we should handle the Java/IL backends here as well.
+        % (See do_get_item_foreign_code for details/5).
+        !:Info = !.Info ^ used_foreign_languages :=
+            set__insert(!.Info ^ used_foreign_languages, c)
+    ; ( Item = initialise(_, _) ; Item = finalise(_, _) ) ->
+        % Intialise/finalise declarations introduce export pragmas, but
+        % again they won't have been expanded by the time we get here.
+        % XXX we don't currently support these on non-C backends.
+        Lang = c,
+        !:Info = !.Info ^ used_foreign_languages :=
+            set__insert(!.Info ^ used_foreign_languages, Lang),
+        !:Info = !.Info ^ module_contains_foreign_export :=
+            contains_foreign_export
+    ;
         true
     ).

@@ -7366,6 +7385,8 @@
 item_needs_foreign_imports(pragma(_, foreign_code(Lang, _)), Lang).
 item_needs_foreign_imports(pragma(_, foreign_proc(Attrs, _, _, _, _, _)),
         foreign_language(Attrs)).
+item_needs_foreign_imports(mutable(_, _, _, _, _), Lang) :-
+    foreign_language(Lang).

 :- pred include_in_int_file_implementation(item::in) is semidet.


--------------------------------------------------------------------------
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