[m-rev.] For review: Ignore dummy types in the IL backend

Jonathan Morgan jonmmorgan at gmail.com
Mon Sep 18 21:42:24 AEST 2006


The below patch fixes most of the problems with the IL backend and
dummy types, by simply not recognising them.  I suspect that a better
fix would be to modify type_needs_lowlevel_rep to force dummy
variables to use a low-level representation, but that would require
more information than is currently passed into type_needs_lowlevel_rep
(eg. a module_info), and I'm not convinced that adding that
information is the right step (or even possible in all the places it
is called from).  Alternatively, it would be better to only disable
dummy var recognition in places where it causes type conflicts, rather
than everywhere.

Note that this patch does not seem to have completely disabled the
recognition of dummy types - io.write() fails because it tries to call
an op_table method with an op_table, when the method has optimised the
op_table away.

Jon

---------------------------------------------------------------------------------------------------------------------------------
Branches: release, main

Fix the problems caused with type issues in the IL backend by the
introduction of dummy type recognition to the compiler, by not
recognising these types as dummy types when the target is IL.

compiler/type_util.m:
    Do not recognise types with a single, zero-arity constructor as
dummy types when the
    target is IL.

Index: compiler/type_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.169
diff -u -u -r1.169 type_util.m
--- compiler/type_util.m	7 Sep 2006 05:51:06 -0000	1.169
+++ compiler/type_util.m	16 Sep 2006 13:25:41 -0000
@@ -462,7 +462,18 @@
             get_type_defn_body(TypeDefn, TypeBody),
             Ctors = TypeBody ^ du_type_ctors,
             UserEqCmp = TypeBody ^ du_type_usereq,
-            constructor_list_represents_dummy_argument_type(Ctors, UserEqCmp)
+            constructor_list_represents_dummy_argument_type(Ctors, UserEqCmp),
+            % XXX: Dummy types cannot be assigned to dummy_var, as they do not
+            % use a low-level type (System.Object[]).
+            % This fixes the problem by ignoring dummy types in the IL backend.
+            % A better fix would be to only ignore the dummy types when
+            % generating assignments to private_builtin.dummy_var.
+            % Alternatively, these dummy types could be made to require a
+            % low-level representation, ensuring that they could be assigned
+            % to private_builtin.dummy_var.
+            module_info_get_globals(ModuleInfo, Globals),
+            globals.get_target(Globals, Target),
+            Target \= il
         )
     ;
         fail
--------------------------------------------------------------------------
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