[m-rev.] diff: shorten too long function names in generated erlang code

Peter Wang novalazy at gmail.com
Thu Oct 4 10:35:16 AEST 2007


Estimated hours taken: 0.2
Branches: main

compiler/elds_to_erlang.m:
	Shorten function names which are too long for Erlang.  Previously we
	did this only for RTTI functions.

tests/valid/Mmakefile:
tests/valid/long_name.m:
	Add test case.

Index: compiler/elds_to_erlang.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/elds_to_erlang.m,v
retrieving revision 1.30
diff -u -r1.30 elds_to_erlang.m
--- compiler/elds_to_erlang.m	28 Aug 2007 05:32:32 -0000	1.30
+++ compiler/elds_to_erlang.m	4 Oct 2007 00:31:44 -0000
@@ -850,7 +850,8 @@
     ;
         MaybeExtModule = no
     ),
-    output_atom(Name, !IO).
+    ShortName = shorten_long_atom_name(Name),
+    output_atom(ShortName, !IO).
 
 :- pred output_rtti_id(module_info::in, elds_rtti_id::in, io::di, io::uo)
     is det.
@@ -911,7 +912,7 @@
     ),
     output_atom(Atom, !IO).
 
-    % Some RTTI function names can be longer than the character limit on
+    % Some function names can be longer than the character limit on
     % atom names.  To shorten long names, we take the left and right parts
     % of the string and stick the hash of the string in the middle.
     %
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.196
diff -u -r1.196 Mmakefile
--- tests/valid/Mmakefile	3 Oct 2007 03:33:23 -0000	1.196
+++ tests/valid/Mmakefile	4 Oct 2007 00:31:44 -0000
@@ -144,6 +144,7 @@
 	lazy_list \
 	liveness_nonlocals \
 	livevals_seq \
+	long_name \
 	loop \
 	loop_in_disj \
 	loop_inv_bug \
Index: tests/valid/long_name.m
===================================================================
RCS file: tests/valid/long_name.m
diff -N tests/valid/long_name.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/long_name.m	4 Oct 2007 00:31:44 -0000
@@ -0,0 +1,8 @@
+:- module long_name.
+:- interface.
+
+:- pred this_name_is_too_long_for_erlang_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz is det.
+  
+:- implementation.
+
+this_name_is_too_long_for_erlang_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz.

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list