## verify-freezefile-g.pkg
# Compiled by:
#
src/app/makelib/makelib.sublib# Verifying the validity of an existing freezefile.
#
# - This is used for "paranoia" mode during bootstrap compilation.
# Normally, makelib accepts freezefiles and doesn't ask questions,
# but during bootstrap compilation it takes the freezefile only
# if it is verified to be valid.
stipulate
package ad = anchor_dictionary; # anchor_dictionary is from
src/app/makelib/paths/anchor-dictionary.pkg package fcm = frozenlib_tome_map; # frozenlib_tome_map is from
src/app/makelib/freezefile/frozenlib-tome-map.pkg package frn = find_reachable_sml_nodes; # find_reachable_sml_nodes is from
src/app/makelib/depend/find-reachable-sml-nodes.pkg package lg = inter_library_dependency_graph; # inter_library_dependency_graph is from
src/app/makelib/depend/inter-library-dependency-graph.pkg package ms = makelib_state; # makelib_state is from
src/app/makelib/main/makelib-state.pkg package sg = intra_library_dependency_graph; # intra_library_dependency_graph is from
src/app/makelib/depend/intra-library-dependency-graph.pkg package sps = source_path_set; # source_path_set is from
src/app/makelib/paths/source-path-set.pkg package sym = symbol_map; # symbol_map is from
src/app/makelib/stuff/symbol-map.pkg package tlt = thawedlib_tome; # thawedlib_tome is from
src/app/makelib/compilable/thawedlib-tome.pkg package tcs = thawedlib_tome_set; # thawedlib_tome_set is from
src/app/makelib/compilable/thawedlib-tome-set.pkg package ts = timestamp; # timestamp is from
src/app/makelib/paths/timestamp.pkgherein
generic package verify_freezefile_g (
#
package freezefile: Freezefile; # Freezefile is from
src/app/makelib/freezefile/freezefile.api )
: Verify_Freezefile # Verify_Freezefile is from
src/app/makelib/freezefile/verify-freezefile.api {
Exportmap = fcm::Map( tlt::Thawedlib_Tome );
fun verify' (makelib_state: ms::Makelib_State) em args
=
{ args -> (libfile, export_nodes, sublibraries, groups, version);
groups = sps::add (groups, libfile);
policy = makelib_state.makelib_session.filename_policy;
freezefile_name
=
filename_policy::make_freezefile_name
policy
libfile;
fun invalid_member stable_timestamp tome
=
{ p = tlt::sourcepath_of tome;
bn = tlt::make_compiledfile_name tome;
case (ad::timestamp p, ts::last_file_modification_time bn)
#
(ts::TIMESTAMP source_timestamp, ts::TIMESTAMP binary_timestamp)
=>
time::compare (source_timestamp, binary_timestamp) != EQUAL or
time::compare (source_timestamp, stable_timestamp) == GREATER;
#
_ => TRUE;
esac;
};
fun thawed_sublibrary (lt: lg::Library_Thunk)
=
case (lt.library_thunk ())
#
lg::LIBRARY { more => lg::MAIN_LIBRARY { frozen_vs_thawed_stuff => lg::FROZENLIB_STUFF _, ... }, ... }
=>
FALSE;
#
_ => TRUE;
esac;
fun invalid_group freezefile_timestamp p
=
case (ad::timestamp p)
#
ts::TIMESTAMP g_t
=>
time::compare (g_t, freezefile_timestamp) == GREATER;
#
_ => TRUE;
esac;
on_disk_library_picklehash_matches_in_memory_library_image
=
freezefile::on_disk_library_picklehash_matches_in_memory_library_image makelib_state;
is_valid
=
case (ts::last_file_modification_time freezefile_name)
#
ts::TIMESTAMP st
=>
{ my (m, i) = frn::reachable' export_nodes;
# The library itself is included in "groups"...
not (sps::exists (invalid_group st) groups)
and
not (list::exists thawed_sublibrary sublibraries)
and
on_disk_library_picklehash_matches_in_memory_library_image (libfile, export_nodes, sublibraries)
and
not (tcs::exists (invalid_member st) m);
};
#
_ => FALSE;
esac;
if (not is_valid)
#
winix__premicrothread::file::remove_file freezefile_name
except
_ = ();
fi;
is_valid;
};
fun verify _ _ lg::BAD_LIBRARY
=>
FALSE;
verify makelib_state em (group as lg::LIBRARY g)
=>
{ g -> { catalog, libfile, sublibraries, more, ... };
groups = frn::groups_of group;
makelib_version_intlist
=
case more
#
lg::MAIN_LIBRARY { makelib_version_intlist, ... } => makelib_version_intlist;
lg::SUBLIBRARY _ => NULL;
esac;
fun force f
=
f ();
verify'
makelib_state
em
( libfile,
map (.tome_tin o force o .masked_tome_thunk) (sym::vals_list catalog),
sublibraries,
groups,
makelib_version_intlist
);
};
end; # fun verify
};
end;
## (C) 2000 Lucent Technologies, Bell Laboratories
## Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.