[m-rev.] trivial diff: switch on mlds_entity_name type

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Jun 15 22:12:06 AEST 2007


Estimated hours taken: 0.1
Branches: main

compiler/ml_elim_nested.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_io.m:
compiler/mlds_to_java.m:
 	Turn if-thene-elses into switches.

Julien.

Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.90
diff -u -r1.90 ml_elim_nested.m
--- compiler/ml_elim_nested.m	4 Mar 2007 23:38:02 -0000	1.90
+++ compiler/ml_elim_nested.m	15 Jun 2007 12:06:19 -0000
@@ -985,7 +985,8 @@
      % XXX This is a bit of a hack; maybe we should add
      % another field to the `function' ctor for mlds_entity_name.
      %
-    ( FuncName = entity_function(PredLabel, ProcId, MaybeSeqNum, PredId) ->
+    (
+        FuncName = entity_function(PredLabel, ProcId, MaybeSeqNum, PredId),
          (
              MaybeSeqNum = yes(SeqNum)
          ;
@@ -1000,6 +1001,10 @@
          GCTraceFuncAddr =
              code_addr_internal(QualProcLabel, NewSeqNum, Signature)
      ;
+        ( FuncName = entity_type(_, _)
+        ; FuncName = entity_data(_)
+        ; FuncName = entity_export(_)
+        ),
          unexpected(this_file, "gen_gc_trace_func: not a function")
      ),

Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.149
diff -u -r1.149 mlds.m
--- compiler/mlds.m	7 May 2007 05:21:33 -0000	1.149
+++ compiler/mlds.m	15 Jun 2007 12:06:19 -0000
@@ -651,21 +651,21 @@

  :- type mlds_class_kind
      --->    mlds_class     % A generic class: can inherit other classes and
-                            % interfaces (but most targets will only support
-                            % single inheritence, so usually there will be
-                            % at most one class).
+                           % interfaces (but most targets will only support
+                           % single inheritence, so usually there will be
+                           % at most one class).

      ;       mlds_package   % A class with only static members (can only
-                            % inherit other packages). Unlike other kinds
-                            % of classes, packages should not be used as types.
+                           % inherit other packages). Unlike other kinds
+                           % of classes, packages should not be used as types.

      ;       mlds_interface % A class with no variable data members (can only
-                            % inherit other interfaces).
+                           % inherit other interfaces).

      ;       mlds_struct    % A value class (can only inherit other structs).

      ;       mlds_enum.     % A class with one integer member and a bunch
-                            % of static consts (cannot inherit anything).
+                           % of static consts (cannot inherit anything).

  :- type mlds_class_name == string.
  :- type mlds_class == mlds_fully_qualified_name(mlds_class_name).
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.215
diff -u -r1.215 mlds_to_c.m
--- compiler/mlds_to_c.m	22 May 2007 05:14:10 -0000	1.215
+++ compiler/mlds_to_c.m	15 Jun 2007 12:06:19 -0000
@@ -1464,13 +1464,17 @@
      % enumeration constants and for the nested classes that we generate for
      % constructors of discriminated union types.) Here we compute the
      % appropriate qualifier.
-
      Name = qual(ModuleName, QualKind, UnqualName),
-    ( UnqualName = entity_type(ClassName, ClassArity) ->
+    (
+        UnqualName = entity_type(ClassName, ClassArity),
          globals.io_get_globals(Globals, !IO),
          ClassModuleName = mlds_append_class_qualifier(ModuleName,
              QualKind, Globals, ClassName, ClassArity)
      ;
+        ( UnqualName = entity_data(_)
+        ; UnqualName = entity_function(_, _, _, _)
+        ; UnqualName = entity_export(_)
+        ),
          unexpected(this_file, "mlds_output_enum_constants")
      ),

Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.182
diff -u -r1.182 mlds_to_il.m
--- compiler/mlds_to_il.m	12 Jun 2007 03:29:59 -0000	1.182
+++ compiler/mlds_to_il.m	15 Jun 2007 12:06:19 -0000
@@ -1424,11 +1424,16 @@
      ReturnRvals = list.map((func(X) = lval(X)), ReturnLvals),

      Signature = mlds_func_signature(ArgTypes, RetTypes),
-    ( UnqualName = entity_function(PredLabel, ProcId, _MaybeSeq, _PredId) ->
+    (
+        UnqualName = entity_function(PredLabel, ProcId, _MaybeSeq, _PredId),
          CodeRval = const(mlconst_code_addr(code_addr_proc(
              qual(ModuleName, module_qual, mlds_proc_label(PredLabel, ProcId)),
              Signature)))
      ;
+        ( UnqualName = entity_type(_, _)
+        ; UnqualName = entity_data(_)
+        ; UnqualName = entity_export(_)
+        ),
          unexpected(this_file, "exported entity is not a function")
      ),

Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.92
diff -u -r1.92 mlds_to_java.m
--- compiler/mlds_to_java.m	7 May 2007 05:21:34 -0000	1.92
+++ compiler/mlds_to_java.m	15 Jun 2007 12:06:19 -0000
@@ -1228,11 +1228,16 @@

  output_class(Indent, ModuleInfo, Name, _Context, ClassDefn, !IO) :-
      Name = qual(ModuleName, _QualKind, UnqualName),
-    ( UnqualName = entity_type(ClassNamePrime, ArityPrime) ->
+    (
+        UnqualName = entity_type(ClassNamePrime, ArityPrime),
          ClassName = ClassNamePrime,
          Arity = ArityPrime
      ;
-        unexpected(this_file, "output_class")
+        ( UnqualName = entity_data(_)
+        ; UnqualName = entity_function(_, _, _, _)
+        ; UnqualName = entity_export(_)
+        ),
+        unexpected(this_file, "output_class: name is not entity_type.")
      ),
      ClassDefn = mlds_class_defn(Kind, _Imports, BaseClasses, Implements,
          Ctors, AllMembers),

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