[m-rev.] for review: don't abort on :- pragma memo on non-C backends

Peter Wang wangp at students.csse.unimelb.edu.au
Fri Jul 27 12:26:45 AEST 2007


Estimated hours taken: 1
Branches: main

compiler/add_pragma.m:
	Don't add declarations or clauses for tabling statistics and tabling
	reset predicates unless the backend supports C as a foreign language.
	This prevents warnings about those predicates missing clauses on other
	backends during type checking.

	Rename table_info_global_var_name to table_info_c_global_var_name.

Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.67
diff -u -r1.67 add_pragma.m
--- compiler/add_pragma.m	25 Jul 2007 06:12:18 -0000	1.67
+++ compiler/add_pragma.m	27 Jul 2007 02:25:27 -0000
@@ -2361,21 +2361,29 @@
             % even in the presence of errors above, because if didn't do so,
             % later compiler passes would report errors at the sites where
             % these predicates are called.
-            (
-                Statistics = table_gather_statistics,
-                create_tabling_statistics_pred(ProcId, Context,
-                    SimpleCallId, SingleProc, !ProcTable,
-                    !Status, !ModuleInfo, !QualInfo, !Specs)
-            ;
-                Statistics = table_dont_gather_statistics
-            ),
-            (
-                AllowReset = table_allow_reset,
-                create_tabling_reset_pred(ProcId, Context,
-                    SimpleCallId, SingleProc, !ProcTable,
-                    !Status, !ModuleInfo, !QualInfo, !Specs)
+            % We only do it if C is supported as a foreign language, otherwise
+            % we get warnings that these predicates are missing clauses.
+            module_info_get_globals(!.ModuleInfo, Globals),
+            get_backend_foreign_languages(Globals, ForeignLanguages),
+            ( list.member(lang_c, ForeignLanguages) ->
+                (
+                    Statistics = table_gather_statistics,
+                    create_tabling_statistics_pred(ProcId, Context,
+                        SimpleCallId, SingleProc, !ProcTable,
+                        !Status, !ModuleInfo, !QualInfo, !Specs)
+                ;
+                    Statistics = table_dont_gather_statistics
+                ),
+                (
+                    AllowReset = table_allow_reset,
+                    create_tabling_reset_pred(ProcId, Context,
+                        SimpleCallId, SingleProc, !ProcTable,
+                        !Status, !ModuleInfo, !QualInfo, !Specs)
+                ;
+                    AllowReset = table_dont_allow_reset
+                )
             ;
-                AllowReset = table_dont_allow_reset
+                true
             )
         )
     ).
@@ -2429,7 +2437,7 @@
         Arg2 = pragma_var(IO0, "_IO0", di_mode, always_boxed),
         Arg3 = pragma_var(IO, "_IO", uo_mode, always_boxed),
 
-        Global = table_info_global_var_name(!.ModuleInfo, SimpleCallId,
+        Global = table_info_c_global_var_name(!.ModuleInfo, SimpleCallId,
             ProcId),
         StatsPredClause = item_pragma(compiler(pragma_memo_attribute),
             pragma_foreign_proc(!.Attrs, StatsPredSymName, pf_predicate,
@@ -2481,7 +2489,7 @@
         Arg1 = pragma_var(IO0, "_IO0", di_mode, always_boxed),
         Arg2 = pragma_var(IO, "_IO", uo_mode, always_boxed),
 
-        Global = table_info_global_var_name(!.ModuleInfo, SimpleCallId,
+        Global = table_info_c_global_var_name(!.ModuleInfo, SimpleCallId,
             ProcId),
         ResetPredClause = item_pragma(compiler(pragma_memo_attribute),
             pragma_foreign_proc(!.Attrs, ResetPredSymName, pf_predicate,
@@ -2538,10 +2546,10 @@
         NewSymName = unqualified(NewName)
     ).
 
-:- func table_info_global_var_name(module_info, simple_call_id, proc_id)
+:- func table_info_c_global_var_name(module_info, simple_call_id, proc_id)
     = string.
 
-table_info_global_var_name(ModuleInfo, SimpleCallId, ProcId) = VarName :-
+table_info_c_global_var_name(ModuleInfo, SimpleCallId, ProcId) = VarName :-
     module_info_get_globals(ModuleInfo, Globals),
     globals.get_target(Globals, Target),
     expect(unify(Target, target_c), this_file,
--------------------------------------------------------------------------
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