[m-rev.] diff: fix bug #258 - compilation of library in csharp or java grades

Julien Fischer juliensf at csse.unimelb.edu.au
Sat Jun 23 04:04:12 AEST 2012


Branches: main

Fix bug #258: the recent change to use a dummy integer tag for arity-zero
tuples results in invalid C# or Java code with the respective backed.
Revert to the old approach for those backends.

compiler/hlds_code_util.m:
 	Do not use a dummy integer tag for arity-zero tuples with the
 	C# or Java backends.

Julien.

Index: compiler/hlds_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_code_util.m,v
retrieving revision 1.49
diff -u -r1.49 hlds_code_util.m
--- compiler/hlds_code_util.m	11 Jun 2012 03:13:21 -0000	1.49
+++ compiler/hlds_code_util.m	22 Jun 2012 17:54:42 -0000
@@ -57,6 +57,7 @@
  :- import_module check_hlds.mode_util.
  :- import_module check_hlds.type_util.
  :- import_module hlds.hlds_pred.
+:- import_module libs.globals.
  :- import_module mdbcomp.prim_data.
  :- import_module parse_tree.prog_type.

@@ -128,9 +129,26 @@
          % Tuples do not need a tag. Note that unary tuples are not treated
          % as no_tag types. There is no reason why they couldn't be, it is
          % just not worth the effort.
-        ( Arity = 0 ->
-            Tag = int_tag(0)
+        module_info_get_globals(ModuleInfo, Globals),
+        globals.get_target(Globals, TargetLang),
+        (
+            ( TargetLang = target_c
+            ; TargetLang = target_asm
+            ; TargetLang = target_x86_64
+            ; TargetLang = target_erlang
+            ), 
+            ( Arity = 0 ->
+                Tag = int_tag(0)
+            ;
+                Tag = single_functor_tag
+            )
          ;
+            % For these target languages, converting arity-zero tuples into
+            % dummy integer tags results in invalid code being generated.
+            ( TargetLang = target_il
+            ; TargetLang = target_csharp
+            ; TargetLang = target_java
+            ),
              Tag = single_functor_tag
          )
      ;

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