[m-rev.] diff: fix problem with initialise declarations and sub-modules
Julien Fischer
juliensf at cs.mu.OZ.AU
Tue Aug 30 17:21:43 AEST 2005
Estimated hours taken: 1.5
Branches: main
Fix a problem with the new initialise declarations and sub-modules.
compiler/modules.m:
Don't write `:- initialise' declarations to private interfaces.
The compiler cannot read them back in and in any case child
modules don't need to know about them.
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/initialise_parent.m:
tests/hard_coded/sub-modules/initialise_child.m:
tests/hard_coded/sub-modules/initialise_parent.exp:
tests/hard_coded/sub-modules/initialise_parent.exp2:
Test case for the above. (There are two expected orders
because the ordering of calls to module initialisers between
a parent and its children is arbitrary.)
vim/syntax/mercury.vim:
Highlight initialise declarations appropriately.
Julien.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.336
diff -u -r1.336 modules.m
--- compiler/modules.m 29 Aug 2005 03:22:23 -0000 1.336
+++ compiler/modules.m 30 Aug 2005 07:12:11 -0000
@@ -1964,12 +1964,16 @@
).
% strip_clauses_from_interface is the same as
- % check_for_clauses_in_interface except that it doesn't issue any warnings,
- % and that it also strips out the `:- interface' and `:- implementation'
- % declarations.
- %
- % This is used when creating the private interface (`.int0') files
- % for packages with sub-modules.
+ % check_for_clauses_in_interface except that it doesn't issue any
+ % warnings, and that it also strips out the `:- interface' and `:-
+ % implementation' declarations.
+ %
+ % This is used when creating the private interface (`.int0') files for
+ % packages with sub-modules.
+ %
+ % We treat initialise declarations as a special kind of clause, since they
+ % should always be grouped together with the clauses and should not appear
+ % in private interfaces.
%
:- pred strip_clauses_from_interface(item_list::in, item_list::out) is det.
@@ -1995,6 +1999,8 @@
;
Item0 = pragma(Pragma),
pragma_allowed_in_interface(Pragma, no)
+ ;
+ Item0 = initialise(_)
)
->
split_clauses_and_decls(Items0, ClauseItems1, InterfaceItems),
Index: tests/hard_coded/sub-modules/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/sub-modules/Mmakefile,v
retrieving revision 1.9
diff -u -r1.9 Mmakefile
--- tests/hard_coded/sub-modules/Mmakefile 23 Apr 2003 10:58:55 -0000 1.9
+++ tests/hard_coded/sub-modules/Mmakefile 30 Aug 2005 06:53:32 -0000
@@ -1,7 +1,7 @@
#-----------------------------------------------------------------------------#
#
# This directory contains test cases for sub-modules,
-# including both nested modules and seperate sub-modules.
+# including both nested modules and separate sub-modules.
#
#-----------------------------------------------------------------------------#
@@ -25,7 +25,8 @@
nested2 \
nested3 \
class \
- nested_intermod_main
+ nested_intermod_main \
+ initialise_parent
# We currently don't do any testing in grade java on this directory.
ifneq "$(findstring java,$(GRADE))" ""
Index: tests/hard_coded/sub-modules/initialise_child.m
===================================================================
RCS file: tests/hard_coded/sub-modules/initialise_child.m
diff -N tests/hard_coded/sub-modules/initialise_child.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/sub-modules/initialise_child.m 30 Aug 2005 06:10:38 -0000
@@ -0,0 +1,13 @@
+:- module initialise_parent.initialise_child.
+
+:- interface.
+
+:- type foo ---> foo.
+
+:- implementation.
+
+:- initialise child_init.
+
+:- pred child_init(io::di, io::uo) is det.
+
+child_init(!IO) :- io.write_string("This is child_init/2...\n", !IO).
Index: tests/hard_coded/sub-modules/initialise_parent.exp
===================================================================
RCS file: tests/hard_coded/sub-modules/initialise_parent.exp
diff -N tests/hard_coded/sub-modules/initialise_parent.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/sub-modules/initialise_parent.exp 30 Aug 2005 06:59:35 -0000
@@ -0,0 +1,3 @@
+This is parent_init/2...
+This is child_init/2...
+This is main/2...
Index: tests/hard_coded/sub-modules/initialise_parent.exp2
===================================================================
RCS file: tests/hard_coded/sub-modules/initialise_parent.exp2
diff -N tests/hard_coded/sub-modules/initialise_parent.exp2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/sub-modules/initialise_parent.exp2 30 Aug 2005 06:59:52 -0000
@@ -0,0 +1,3 @@
+This is child_init/2...
+This is parent_init/2...
+This is main/2...
Index: tests/hard_coded/sub-modules/initialise_parent.m
===================================================================
RCS file: tests/hard_coded/sub-modules/initialise_parent.m
diff -N tests/hard_coded/sub-modules/initialise_parent.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/sub-modules/initialise_parent.m 30 Aug 2005 06:11:55 -0000
@@ -0,0 +1,25 @@
+%
+% This is to test that `:- intialise' declarations are not
+% written out to private interfaces.
+%
+:- module initialise_parent.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- include_module initialise_child.
+
+:- implementation.
+
+:- initialise parent_init.
+
+:- pred parent_init(io::di, io::uo) is det.
+
+main(!IO) :-
+ io.write_string("This is main/2...\n", !IO).
+
+parent_init(!IO) :-
+ io.write_string("This is parent_init/2...\n", !IO).
Index: vim/syntax/mercury.vim
===================================================================
RCS file: /home/mercury1/repository/mercury/vim/syntax/mercury.vim,v
retrieving revision 1.13
diff -u -r1.13 mercury.vim
--- vim/syntax/mercury.vim 24 Feb 2005 06:07:12 -0000 1.13
+++ vim/syntax/mercury.vim 30 Aug 2005 03:58:22 -0000
@@ -34,6 +34,7 @@
endif
syn keyword mercuryKeyword module use_module import_module
syn keyword mercuryKeyword include_module end_module
+syn keyword mercuryKeyword initialise
syn keyword mercuryKeyword interface implementation
syn keyword mercuryKeyword pred mode func type inst solver
syn keyword mercuryKeyword is semidet det nondet multi erroneous failure
--------------------------------------------------------------------------
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