[m-rev.] diff: fix bug compiling updated _init.erl files

Peter Wang wangp at students.csse.unimelb.edu.au
Mon Aug 20 15:59:33 AEST 2007


On 2007-08-17, Peter Wang <wangp at students.csse.unimelb.edu.au> wrote:
> Estimated hours taken: 0.2
> Branches: main
> 
> compiler/compile_target_code.m:
> 	Fix an inverted comparison which caused updated _init.erl files not
> 	to be compiled to the respective .beam file.

As suggested by zs.

Estimated hours taken: 0.2
Branches: main

compiler/compile_target_code.m:
	Change the interface of file_as_new_as to reduce the chance of
	confusion.

Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.117
diff -u -r1.117 compile_target_code.m
--- compiler/compile_target_code.m	17 Aug 2007 05:38:09 -0000	1.117
+++ compiler/compile_target_code.m	20 Aug 2007 05:37:34 -0000
@@ -1337,10 +1337,11 @@
     globals.io_lookup_bool_option(statistics, Stats, !IO),
     (
         MaybeInitTargetFile = yes(InitTargetFileName),
-        file_as_new_as(InitObjFileName, InitTargetFileName, UpToDate, !IO),
+        file_as_new_as(InitObjFileName, Rel, InitTargetFileName, !IO),
         (
             ( MustCompile = yes
-            ; UpToDate = no
+            ; Rel = is_not_as_new_as
+            ; Rel = missing_timestamp
             )
         ->
             maybe_write_string(Verbose,
@@ -1362,26 +1363,33 @@
         Result = no
     ).
 
-    % file_as_new_as(FileNameA, FileNameB, IsAsNew, !IO)
+    % file_as_new_as(FileNameA, Rel, FileNameB, !IO)
     %
-    % IsAsNew is `yes' iff file A has a timestamp at least as new as the
-    % timestamp of file B.
+    % Check if file A has a timestamp at least as new as the timestamp of
+    % file B.  Rel is `missing_timestamp' iff either timestamp could not
+    % be retrieved.
     %
-:- pred file_as_new_as(file_name::in, file_name::in, bool::out,
+:- pred file_as_new_as(file_name::in, is_as_new_as::out, file_name::in,
     io::di, io::uo) is det.
 
-file_as_new_as(FileNameA, FileNameB, IsAsNew, !IO) :-
+:- type is_as_new_as
+    --->    is_as_new_as
+    ;       is_not_as_new_as
+    ;       missing_timestamp.
+
+file_as_new_as(FileNameA, Rel, FileNameB, !IO) :-
     compare_file_timestamps(FileNameA, FileNameB, MaybeCompare, !IO),
     (
         ( MaybeCompare = yes(=)
         ; MaybeCompare = yes(>)
         ),
-        IsAsNew = yes
+        Rel = is_as_new_as 
     ;
-        ( MaybeCompare = yes(<)
-        ; MaybeCompare = no
-        ),
-        IsAsNew = no
+        MaybeCompare = yes(<),
+        Rel = is_not_as_new_as
+    ;
+        MaybeCompare = no,
+        Rel = missing_timestamp
     ).
 
 :- pred compare_file_timestamps(file_name::in, file_name::in,
--------------------------------------------------------------------------
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