[m-rev.] diff: minor prim_data.m changes

Zoltan Somogyi zs at csse.unimelb.edu.au
Mon Aug 4 18:24:20 AEST 2008


mdbcomp/prim_data.m:
	Convert the predicates that transform sym_names from clauses to
	explicit disjunctions, since this makes it easier to see what they do
	(in particular, what they do that is the same and what they do that
	is different between predicates).

Zoltan.

cvs diff: Diffing mdbcomp
Index: mdbcomp/prim_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/mdbcomp/prim_data.m,v
retrieving revision 1.30
diff -u -b -r1.30 prim_data.m
--- mdbcomp/prim_data.m	4 Aug 2008 03:17:54 -0000	1.30
+++ mdbcomp/prim_data.m	4 Aug 2008 08:11:05 -0000
@@ -80,7 +80,7 @@
     % as a qualifier to the label.
     %
     % The type string_proc_label in program_representation.m parallels this
-    % type, but differs from it in being used not inside the compiler by
+    % type, but differs from it in being used not inside the compiler but
     % outside, which means it needs to use different types for many fields.
     %
 :- type proc_label
@@ -431,48 +431,87 @@
 match_sym_name(unqualified(Name), unqualified(Name)).
 match_sym_name(unqualified(Name), qualified(_, Name)).
 
-remove_sym_name_prefix(qualified(Module, Name0), Prefix,
-        qualified(Module, Name)) :-
-    string.append(Prefix, Name, Name0).
-remove_sym_name_prefix(unqualified(Name0), Prefix, unqualified(Name)) :-
-    string.append(Prefix, Name, Name0).
-
-remove_sym_name_suffix(qualified(Module, Name0), Suffix,
-        qualified(Module, Name)) :-
-    string.remove_suffix(Name0, Suffix, Name).
-remove_sym_name_suffix(unqualified(Name0), Suffix, unqualified(Name)) :-
-    string.remove_suffix(Name0, Suffix, Name).
-
-add_sym_name_suffix(qualified(Module, Name0), Suffix,
-        qualified(Module, Name)) :-
-    string.append(Name0, Suffix, Name).
-add_sym_name_suffix(unqualified(Name0), Suffix, unqualified(Name)) :-
-    string.append(Name0, Suffix, Name).
-
-transform_sym_base_name(TransformFunc, qualified(Module, Name0)) =
-        qualified(Module, TransformFunc(Name0)).
-transform_sym_base_name(TransformFunc, unqualified(Name0)) =
-        unqualified(TransformFunc(Name0)).
-
-insert_module_qualifier(ModuleName, unqualified(PlainName)) =
-        qualified(unqualified(ModuleName), PlainName).
-insert_module_qualifier(ModuleName, qualified(ModuleQual0, PlainName)) =
-        qualified(ModuleQual, PlainName) :-
-    insert_module_qualifier(ModuleName, ModuleQual0) = ModuleQual.
-
-outermost_qualifier(unqualified(Name)) = Name.
-outermost_qualifier(qualified(Module, _Name)) = outermost_qualifier(Module).
-
-add_outermost_qualifier(Qual, unqualified(Name)) =
-        qualified(unqualified(Qual), Name).
-add_outermost_qualifier(Qual, qualified(Module, Name)) =
-        qualified(add_outermost_qualifier(Qual, Module), Name).
-
-strip_outermost_qualifier(qualified(unqualified(OuterQual), Name),
-        OuterQual, unqualified(Name)).
-strip_outermost_qualifier(qualified(Module @ qualified(_, _), Name),
-        OuterQual, qualified(RemainingQual, Name)) :-
-    strip_outermost_qualifier(Module, OuterQual, RemainingQual).
+remove_sym_name_prefix(SymName0, Prefix, SymName) :-
+    (
+        SymName0 = unqualified(Name0),
+        string.append(Prefix, Name, Name0),
+        SymName = unqualified(Name)
+    ;
+        SymName0 = qualified(Module, Name0),
+        string.append(Prefix, Name, Name0),
+        SymName = qualified(Module, Name)
+    ).
+
+remove_sym_name_suffix(SymName0, Suffix, SymName) :-
+    (
+        SymName0 = unqualified(Name0),
+        string.remove_suffix(Name0, Suffix, Name),
+        SymName = unqualified(Name)
+    ;
+        SymName0 = qualified(Module, Name0),
+        string.remove_suffix(Name0, Suffix, Name),
+        SymName = qualified(Module, Name)
+    ).
+
+add_sym_name_suffix(SymName0, Suffix, SymName) :-
+    (
+        SymName0 = unqualified(Name0),
+        string.append(Name0, Suffix, Name),
+        SymName = unqualified(Name)
+    ;
+        SymName0 = qualified(Module, Name0),
+        string.append(Name0, Suffix, Name),
+        SymName = qualified(Module, Name)
+    ).
+
+transform_sym_base_name(TransformFunc, SymName0) = SymName :-
+    (
+        SymName0 = unqualified(Name0),
+        SymName = unqualified(TransformFunc(Name0))
+    ;
+        SymName0 = qualified(Module, Name0),
+        SymName = qualified(Module, TransformFunc(Name0))
+    ).
+
+insert_module_qualifier(ModuleName, SymName0) = SymName :-
+    (
+        SymName0 = unqualified(Name),
+        SymName = qualified(unqualified(ModuleName), Name)
+    ;
+        SymName0 = qualified(ModuleSymName0, Name),
+        ModuleSymName = insert_module_qualifier(ModuleName, ModuleSymName0),
+        SymName = qualified(ModuleSymName, Name)
+    ).
+
+outermost_qualifier(SymName) = Name :-
+    (
+        SymName = unqualified(Name)
+    ;
+        SymName = qualified(ModuleSymName, _),
+        Name = outermost_qualifier(ModuleSymName)
+    ).
+
+add_outermost_qualifier(ModuleName, SymName0) = SymName :-
+    (
+        SymName0 = unqualified(Name),
+        SymName = qualified(unqualified(ModuleName), Name)
+    ;
+        SymName0 = qualified(ModuleSymName0, Name),
+        ModuleSymName = add_outermost_qualifier(ModuleName, ModuleSymName0),
+        SymName = qualified(ModuleSymName, Name)
+    ).
+
+strip_outermost_qualifier(SymName0, OuterModuleName, SymName) :-
+    SymName0 = qualified(ModuleSymName0, Name),
+    (
+        ModuleSymName0 = unqualified(OuterModuleName),
+        SymName = unqualified(Name)
+    ;
+        ModuleSymName0 = qualified(_, _),
+        strip_outermost_qualifier(ModuleSymName0, OuterModuleName,
+            ModuleSymName),
+        SymName = qualified(ModuleSymName, Name)
+    ).
 
 %-----------------------------------------------------------------------------%
 
@@ -504,7 +543,8 @@
         mercury_profiling_builtin_module,
         mercury_term_size_prof_builtin_module,
         mercury_par_builtin_module,
-        mercury_ssdb_builtin_module].
+    mercury_ssdb_builtin_module
+].
 
 % We may eventually want to put the standard library into a package "std":
 % mercury_public_builtin_module = qualified(unqualified("std"), "builtin").
--------------------------------------------------------------------------
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