Files
mercury/tests/hard_coded/nested2.m
Fergus Henderson 935fbfe36e Add Mmake support for nested sub-modules.
Estimated hours taken: 6

Add Mmake support for nested sub-modules.

compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
	Pass down the source file name to various places.
	Store the source file name in the module_imports data structure.
	In various places, use this source file name instead of assuming
	that the source file name can be obtained from the module name.

compiler/modules.m:
	Change the generated .d and .dep files to use the source file names.
	Add hard-coded rules in the .d files if the source file name does not
	match the form expected by the pattern rules in scripts/Mmake.rules.
	XXX unfortunately the rules don't work right for parallel makes of
	    nested modules

scripts/Mmake.rules:
	Add a comment saying that any changes here might need to
	be duplicated in compiler/modules.m.

tests/hard_coded/Mmakefile:
tests/hard_coded/nested.m:
tests/hard_coded/nested2.m:
tests/hard_coded/nested.exp:
tests/hard_coded/nested2.exp:
	Add a couple of test cases for nested modules (XXX not enabled,
	due to the above-mentioned problem with parallel makes).

doc/reference_manual.texi:
	Update the "implementation bugs and limitations" section.

NEWS:
	Update the news about nested modules.
1998-05-27 04:00:54 +00:00

62 lines
1.3 KiB
Mathematica

% Another test case to test nested modules.
:- module nested2.
:- interface.
:- import_module io.
%-----------------------------------------------------------------------------%
:- module nested2:child.
:- interface.
% module `io' is imported in nested2
:- type t1 == foo.
:- type t2 == nested2:foo.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module std_util.
:- type t3 == foo.
:- type t4 == nested2:foo.
:- func has_type_t1 = t1.
:- func has_type_t2 = t2.
:- func has_type_t3 = t3.
:- func has_type_t4 = t4.
has_type_t1 = bar.
has_type_t2 = nested2:bar.
has_type_t3 = baz(42).
has_type_t4 = nested2:baz(42).
main -->
nested2:hello,
hello,
print("t1 = "), print(type_of(has_type_t1)), nl,
print("t2 = "), print(type_of(has_type_t2)), nl,
print("t3 = "), print(type_of(has_type_t3)), nl,
print("t4 = "), print(type_of(has_type_t4)), nl,
print("has_type_t1 = "), print(has_type_t1), nl,
print("has_type_t2 = "), print(has_type_t2), nl,
print("has_type_t3 = "), print(has_type_t3), nl,
print("has_type_t4 = "), print(has_type_t4), nl.
:- end_module nested2:child.
%-----------------------------------------------------------------------------%
:- implementation.
:- type foo ---> bar ; baz(int).
:- pred hello(io__state::di, io__state::uo) is det.
hello --> print("nested2:hello\n").
:- end_module nested2.