[m-rev.] for review: fix bug #118

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Dec 11 12:16:45 AEDT 2009


For review by anyone.

Generate dummy table reset predicates for the Erlang, Java and .NET backends.
If we don't this then code that contains references to table reset predicates
cannot be compiled with those backends.  (This currently prevents us building
the Mercury compiler itself with the above backends.)

We don't generate dummy predicates for the table statistics predicates,
although we can also do that if necessary.

This is bug #118 in Mantis.

compiler/add_pragma.m:
 	Add dummy definitions for table reset predicates in non-C grades.

Julien.

Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.101
diff -u -r1.101 add_pragma.m
--- compiler/add_pragma.m	4 Nov 2009 03:44:46 -0000	1.101
+++ compiler/add_pragma.m	11 Dec 2009 00:58:57 -0000
@@ -2758,8 +2758,8 @@
              % 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.
-            % We only do it if C is supported as a foreign language, otherwise
-            % we get warnings that these predicates are missing clauses.
+            % XXX Currently, we only create the statistics predicates in C
+            % grades; references to them in non-C grades will cause errors.
              module_info_get_globals(!.ModuleInfo, Globals),
              get_backend_foreign_languages(Globals, ForeignLanguages),
              ( list.member(lang_c, ForeignLanguages) ->
@@ -2770,17 +2770,17 @@
                          !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
                  )
              ;
                  true
+            ),
+            (
+                AllowReset = table_allow_reset,
+                create_tabling_reset_pred(ProcId, Context,
+                    SimpleCallId, SingleProc, !ProcTable,
+                    !Status, !ModuleInfo, !QualInfo, !Specs)
+            ;
+                AllowReset = table_dont_allow_reset
              )
          )
      ).
@@ -2882,7 +2882,25 @@
          !ModuleInfo, !Specs),

      some [!Attrs, !VarSet] (
-        !:Attrs = default_attributes(lang_c),
+        module_info_get_globals(!.ModuleInfo, Globals),
+        get_target(Globals, TargetLang),
+        (
+            ( TargetLang = target_c
+            ; TargetLang = target_asm
+            ; TargetLang = target_x86_64
+            ),
+            ForeignLang = lang_c
+        ;
+            TargetLang = target_il,
+            ForeignLang = lang_csharp
+        ;
+            TargetLang = target_java,
+            ForeignLang = lang_java
+        ;
+            TargetLang = target_erlang,
+            ForeignLang = lang_erlang
+        ), 
+        !:Attrs = default_attributes(ForeignLang),
          set_may_call_mercury(proc_will_not_call_mercury, !Attrs),
          set_thread_safe(proc_thread_safe, !Attrs),
          set_purity(purity_pure, !Attrs),
@@ -2893,7 +2911,6 @@
          Arg1 = pragma_var(IO0, "_IO0", di_mode, always_boxed),
          Arg2 = pragma_var(IO, "_IO", uo_mode, always_boxed),

-        module_info_get_globals(!.ModuleInfo, Globals),
          current_grade_supports_tabling(Globals, IsTablingSupported),
          (
              IsTablingSupported = yes,

--------------------------------------------------------------------------
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