[m-rev.] diff: fix bootstrapping problem

Peter Wang wangp at students.csse.unimelb.edu.au
Thu May 31 11:08:25 AEST 2007


On 2007-05-31, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> 
> Estimated hours taken: 1
> Branches: main
> 
> Fix a problem that prevented the compiler bootstrapping.
> 
> compiler/term_constr_initial.m:
> compiler/termination.m:
> 	Conform to the new behaviour of status_defined_in_this_module/1
> 	w.r.t procedures defined by `:- external'.
> 
> 	Change the progress message emitted during termination analysis
> 	to say that we are `Checking the termination of' a procedure
> 	rather than just `Checking' it.
> 
> Julien.

Sorry about that.  I think I see why the status_* functions are defined
the way that they are now.  Do you want me to apply the following patch?

Peter


Index: compiler/elds_to_erlang.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/elds_to_erlang.m,v
retrieving revision 1.6
diff -u -r1.6 elds_to_erlang.m
--- compiler/elds_to_erlang.m	30 May 2007 08:16:01 -0000	1.6
+++ compiler/elds_to_erlang.m	31 May 2007 00:49:09 -0000
@@ -127,7 +127,12 @@
     PredProcId = proc(PredId, _ProcId),
     module_info_pred_info(ModuleInfo, PredId, PredInfo),
     pred_info_get_import_status(PredInfo, ImportStatus),
-    IsExported = status_is_exported(ImportStatus),
+    ( ImportStatus = status_external(ExternalImportStatus) ->
+        % status_is_exported returns `no' for :- external procedures.
+        IsExported = status_is_exported(ExternalImportStatus),
+    ;
+        IsExported = status_is_exported(ImportStatus),
+    ),
     (
         IsExported = yes,
         maybe_write_comma(!.NeedComma, !IO),
@@ -554,11 +559,10 @@
         PredIsImported0, _PredIsPseudoImported,
         Origin, _ProcIsExported, _ProcIsImported),
 
-    % XXX I think pred_info_is_imported is wrong for status_external
-    % procedures
     module_info_pred_info(ModuleInfo, PredId, PredInfo),
     pred_info_get_import_status(PredInfo, ImportStatus),
     ( ImportStatus = status_external(_) ->
+        % pred_info_is_imported returns `yes' for :- external predicates.
         PredIsImported = no
     ;
         PredIsImported = PredIsImported0
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.227
diff -u -r1.227 hlds_pred.m
--- compiler/hlds_pred.m	30 May 2007 05:15:04 -0000	1.227
+++ compiler/hlds_pred.m	31 May 2007 00:58:49 -0000
@@ -215,6 +215,14 @@
                 % foreign_code' clauses). It can be through the use of another
                 % language, or it could be through some other method we haven't
                 % thought of yet.
+                %
+                % From the point of view of code generation, an external
+                % procedure usually acts like an imported procedure, as its
+                % definition is not visible. But in some cases, e.g. writing
+                % out declarations for procedures defined in a module, it may
+                % need to be treated like an exported procedure (depending on
+                % its inner import_status).
+                %
     ;       status_imported(import_locn)
                 % Defined in the interface of some other module.
     ;       status_opt_imported
@@ -250,22 +258,30 @@
     % -- that is, if it could be used by any other module, or by sub-modules
     % of this module.
     %
+    % NOTE: this returns `no' for :- external procedures.
+    %
 :- func status_is_exported(import_status) = bool.
 
     % Returns yes if the status indicates that the item was exported
     % to importing modules (not just to sub-modules).
     %
+    % NOTE: this returns `no' for :- external procedures.
+    %
 :- func status_is_exported_to_non_submodules(import_status) = bool.
 
     % Returns yes if the status indicates that the item was in any way imported
     % -- that is, if it was defined in some other module, or in a sub-module
     % of this module. This is the opposite of status_defined_in_this_module.
     %
+    % NOTE: this returns `yes' for :- external procedures.
+    %
 :- func status_is_imported(import_status) = bool.
 
     % Returns yes if the status indicates that the item was defined in this
     % module. This is the opposite of status_is_imported.
     %
+    % NOTE: this returns `no' for :- external procedures.
+    %
 :- func status_defined_in_this_module(import_status) = bool.
 
     % Returns yes if the import_status indicates the item came from
@@ -854,8 +870,7 @@
     proc_id_to_int(ModeId, ModeInt).
 
 status_is_exported(status_imported(_)) =             no.
-status_is_exported(status_external(Status)) =
-    status_is_exported(Status).
+status_is_exported(status_external(_)) =             no.
 status_is_exported(status_abstract_imported) =       no.
 status_is_exported(status_pseudo_imported) =         no.
 status_is_exported(status_opt_imported) =            no.
@@ -879,8 +894,7 @@
 status_is_imported(Status) = bool.not(status_defined_in_this_module(Status)).
 
 status_defined_in_this_module(status_imported(_)) =             no.
-status_defined_in_this_module(status_external(Status)) =
-    status_defined_in_this_module(Status).
+status_defined_in_this_module(status_external(_)) =             no.
 status_defined_in_this_module(status_abstract_imported) =       no.
 status_defined_in_this_module(status_pseudo_imported) =         no.
 status_defined_in_this_module(status_opt_imported) =            no.
Index: compiler/term_constr_initial.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_constr_initial.m,v
retrieving revision 1.19
diff -u -r1.19 term_constr_initial.m
--- compiler/term_constr_initial.m	30 May 2007 14:17:27 -0000	1.19
+++ compiler/term_constr_initial.m	31 May 2007 00:44:32 -0000
@@ -290,10 +290,7 @@
         ->
             true
         ;
-            % Since we cannot see the definition we consider procedures
-            % defined using `:- external' to be imported.
-            status_defined_in_this_module(ImportStatus) = yes,
-            ImportStatus \= status_external(_)
+            status_defined_in_this_module(ImportStatus) = yes
         ->
             % XXX At the moment if a procedure has a pragma terminates
             % declaration its argument size information is set to true.
Index: compiler/termination.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/termination.m,v
retrieving revision 1.75
diff -u -r1.75 termination.m
--- compiler/termination.m	30 May 2007 14:17:27 -0000	1.75
+++ compiler/termination.m	31 May 2007 00:45:05 -0000
@@ -604,11 +604,8 @@
     ->
         ProcTable2 = ProcTable1
     ;
-        status_defined_in_this_module(ImportStatus) = yes,
-        ImportStatus \= status_external(_)
+        status_defined_in_this_module(ImportStatus) = yes
     ->
-        % Since we cannot see the definition we consider procedures
-        % defined using `:- external' to be imported.
         ( check_marker(Markers, marker_terminates) ->
             change_procs_termination_info(ProcIds, yes, cannot_loop(unit),
                 ProcTable0, ProcTable2)
--------------------------------------------------------------------------
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