[m-rev.] diff: fix sub-module build problem

Peter Ross peter.ross at miscrit.be
Fri Nov 16 01:51:08 AEDT 2001


On Thu, Nov 15, 2001 at 03:22:45AM +1100, Simon Taylor wrote:
> On 15-Nov-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > Estimated hours taken: 1
> > Branches: main
> > 
> > When compiling a module which contains a nested sub-module you must
> > build the .int0 file before attempting to build the .int file.  This is
> > because while building the .int file you will need the .int0 file to
> > build the .int file of the nested sub-module.
> > 
> > compiler/modules.m:
> >     Add the dependency <module>.date : <module>.date0
> > 
> > 
> > Index: compiler/modules.m
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
> > retrieving revision 1.200
> > diff -u -r1.200 modules.m
> > --- compiler/modules.m	6 Nov 2001 15:21:06 -0000	1.200
> > +++ compiler/modules.m	14 Nov 2001 15:23:37 -0000
> > @@ -2046,7 +2046,10 @@
> >  		module_name_to_file_name(ModuleName, ".date0", no,
> >  						Date0FileName),
> >  		io__write_strings(DepStream, [
> > -				"\n\n", DateFileName, " ",
> > +				"\n\n", DateFileName, " : ", Date0FileName
> > +		]),
> > +		io__write_strings(DepStream, [
> > +				"\n", DateFileName, " ",
> >  				Date0FileName, " : ",
> >  				SourceFileName
> >  		]),
> 


===================================================================


Estimated hours taken: 1
Branches: main

When compiling a module which contains a nested sub-module you must
build the .int0 file before attempting to build the .int file.  This is
because while building the .int file you will need the .int0 file to
build the .int file of the nested sub-module.

compiler/modules.m:
    When generating the .d file for a nested submodule.  Add the rule
        <sourcefilename>.date : <sourcefilename>.int0
    where <sourcefilename> is the name of the sourcefile which contains
    the nested sub-module.
    
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/include_parent.m:
tests/hard_coded/sub-modules/include_parent.separate.m:
tests/hard_coded/sub-modules/use_submodule.exp:
tests/hard_coded/sub-modules/use_submodule.m:
    Include a test which tests that we can build both nested and
    separate sub-modules when they are not the module which contains
    main.

Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.203
diff -u -r1.203 modules.m
--- compiler/modules.m	15 Nov 2001 13:32:44 -0000	1.203
+++ compiler/modules.m	15 Nov 2001 14:41:43 -0000
@@ -1885,7 +1885,9 @@
 			string__remove_suffix(SourceFileName, ".m",
 				SourceFileBase)
 		->
-			string__append(SourceFileBase, ".err", ErrFileName)
+			ErrFileName = SourceFileBase ++ ".err",
+			SourceDate = SourceFileBase ++ ".date",
+			SourceInt0 = SourceFileBase ++ ".int0"
 		;
 			error("modules.m: source file doesn't end in `.m'")
 		},
@@ -2224,6 +2226,7 @@
 			%
 			io__write_strings(DepStream, [
 				"\n",
+				SourceDate, " : ", SourceInt0, "\n",
 				Date0FileName, " : ", SourceFileName, "\n",
 				"\t$(MCPI) $(ALL_MCPIFLAGS) $<\n",
 				DateFileName, " : ", SourceFileName, "\n",
Index: tests/hard_coded/sub-modules/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/sub-modules/Mmakefile,v
retrieving revision 1.3
diff -u -r1.3 Mmakefile
--- tests/hard_coded/sub-modules/Mmakefile	7 Feb 2001 13:50:52 -0000	1.3
+++ tests/hard_coded/sub-modules/Mmakefile	15 Nov 2001 14:41:48 -0000
@@ -18,6 +18,7 @@
 #
 
 PROGS=	\
+	use_submodule \
 	parent \
 	parent2 \
 	nested \
Index: tests/hard_coded/sub-modules/include_parent.m
===================================================================
RCS file: tests/hard_coded/sub-modules/include_parent.m
diff -N tests/hard_coded/sub-modules/include_parent.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/sub-modules/include_parent.m	15 Nov 2001 14:41:48 -0000
@@ -0,0 +1,32 @@
+% Used by use_submodule.m
+
+:- module include_parent.
+
+:- interface.
+
+:- import_module io.
+:- include_module separate.
+
+:- pred hello(io__state::di, io__state::uo) is det.
+
+  :- module include_parent__nested.
+  :- interface.
+  :- pred hello(io__state::di, io__state::uo) is det.
+  :- end_module include_parent__nested.
+
+:- implementation.
+
+hello -->
+	io__write_string("include_parent: hello\n").
+
+%-----------------------------------------------------------------------------%
+
+:- module include_parent__nested.
+:- implementation.
+
+hello -->
+	io__write_string("include_parent__nested: hello\n").
+
+:- end_module include_parent__nested.
+
+%-----------------------------------------------------------------------------%
Index: tests/hard_coded/sub-modules/include_parent.separate.m
===================================================================
RCS file: tests/hard_coded/sub-modules/include_parent.separate.m
diff -N tests/hard_coded/sub-modules/include_parent.separate.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/sub-modules/include_parent.separate.m	15 Nov 2001 14:41:48 -0000
@@ -0,0 +1,19 @@
+% Used by use_submodule.m
+
+:- module include_parent__separate.
+
+:- interface.
+
+% The parent module includes io.
+
+:- pred hello(io__state::di, io__state::uo) is det.
+
+:- pred hello2(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+hello -->
+	io__write_string("include_parent__separate: hello\n").
+
+hello2 -->
+	io__write_string("include_parent__separate: hello2\n").
Index: tests/hard_coded/sub-modules/use_submodule.exp
===================================================================
RCS file: tests/hard_coded/sub-modules/use_submodule.exp
diff -N tests/hard_coded/sub-modules/use_submodule.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/sub-modules/use_submodule.exp	15 Nov 2001 14:41:48 -0000
@@ -0,0 +1,8 @@
+include_parent: hello
+include_parent__nested: hello
+include_parent__nested: hello
+include_parent__separate: hello
+include_parent__separate: hello
+include_parent__separate: hello2
+include_parent__separate: hello2
+include_parent__separate: hello2
Index: tests/hard_coded/sub-modules/use_submodule.m
===================================================================
RCS file: tests/hard_coded/sub-modules/use_submodule.m
diff -N tests/hard_coded/sub-modules/use_submodule.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/sub-modules/use_submodule.m	15 Nov 2001 14:41:48 -0000
@@ -0,0 +1,25 @@
+% Test that we can use both nested and separate sub-modules.
+
+:- module use_submodule.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module include_parent.
+:- import_module include_parent__nested.
+:- import_module include_parent__separate.
+
+main -->
+	include_parent__hello,
+	include_parent__nested__hello,
+	nested__hello,
+	include_parent__separate__hello,
+	separate__hello,
+	include_parent__separate__hello2,
+	separate__hello2,
+	hello2.

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