for review: fix for name mangling bug

Fergus Henderson fjh at cs.mu.oz.au
Sat Apr 5 17:15:53 AEST 1997


Hi,

Tyson, can you please review this one?
(It is a pretty trivial change.)

Estimated hours taken: 0.75

Fix a bug where having a type named `,'/2 caused an error in
the generated C code, because the type name was not being mangled.

compiler/llds_out.m:
	Mangle type names for base_type_infos.

tests/valid/name_mangling.m:
tests/valid/Mmake:
tests/hard_coded/name_mangling.m:
tests/hard_coded/Mmake:
	Add some more tests of name mangling to `name_mangling.m',
	and move it from the `valid' to the `hard_coded' directory,
	since it is now a complete program that produces output.

Index: llds_out.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/llds_out.m,v
retrieving revision 1.41
diff -u -r1.41 llds_out.m
--- llds_out.m	1997/03/06 05:09:19	1.41
+++ llds_out.m	1997/04/05 06:15:01
@@ -348,7 +348,8 @@
 		;
 			io__write_string(UnderscoresModule)
 		),
-		io__write_string(TypeName),
+		{ llds_out__name_mangle(TypeName, MangledTypeName) },
+		io__write_string(MangledTypeName),
 		io__write_string("_"),
 		io__write_int(Arity),
 		io__write_string("_0);\n")


Index: Mmake
===================================================================
RCS file: /home/staff/zs/imp/tests/hard_coded/Mmake,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- Mmake	1997/03/21 10:57:43	1.36
+++ Mmake	1997/04/05 07:11:32	1.37
@@ -13,7 +13,8 @@
 	cc_nondet_disj bidirectional address_of_builtins \
 	reverse_arith curry curry2 higher_order_syntax \
 	ho_func_reg float_reg write expand ho_solns write_reg1 \
-	ho_univ_to_type elim_special_pred division_test
+	ho_univ_to_type elim_special_pred division_test \
+	name_mangling
 
 #-----------------------------------------------------------------------------#
 

Index: Mmake
===================================================================
RCS file: /home/staff/zs/imp/tests/valid/Mmake,v
retrieving revision 1.27
diff -u -r1.27 Mmake
--- Mmake	1997/02/17 01:31:08	1.27
+++ Mmake	1997/04/05 06:52:51
@@ -36,7 +36,6 @@
 	multidet_prune1.m \
 	multidet_test.m \
 	nasty_func_test.m \
-	name_mangling.m \
 	nondet_live.m \
 	qualified_cons_id.m \
 	semidet_disj.m \


:- module name_mangling.
:- interface.
:- import_module io.

:- pred main(io__state::di, io__state::uo) is det.

:- type 'a strange type name'
	--->	'a strange functor'
	;	'another strange functor'.

:- type 'another wierd type' == int.

:- type (A,B) ---> (A,B).
:- inst (A,B) ---> (A,B).
:- func mk_pair(A,B) = (A,B).

:- pred 'this is a test' is det.

:- pred 'this is another test'('a strange type name'::out) is multi.

:- pred 'yet another test'('another wierd type'::out) is det.

:- implementation.
:- import_module std_util.

mk_pair(A,B) = (A,B).

'this is a test'.

'this is another test'('a strange functor').
'this is another test'('another strange functor').

'yet another test'(42).

main -->
	{ 'this is a test' },
	write('a strange functor'), nl,
	write('another strange functor'), nl,
	{ solutions('this is another test', List) },
	write(List), nl.


-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list