PreviousUpNext

15.4.585  src/lib/compiler/front/semantic/pickle/rehash-module.pkg

# rehash-module.pkg
#
#  (C) 2001 Lucent Technologies, Bell Labs
#
# Compute hash for a library that is the product of filtering
# a larger dictionary.  Since every dictionary (after unpickling)
# contains references to its own hash id, re-hashing requires
# the original hash id (to be able to recognize it).  The result
# of re-hashing will then be the same value that would have been
# produced had the smaller dictionary been pickled (and hashed) in
# the first place.

# Compiled by:
#     src/lib/compiler/core.sublib

stipulate
    package ph  =  picklehash;                                                  # picklehash    is from   src/lib/compiler/front/basics/map/picklehash.pkg
    package pkj =  pickler_junk;                                                # pickler_junk  is from   src/lib/compiler/front/semantic/pickle/pickler-junk.pkg
    package syx =  symbolmapstack;                                                      # symbolmapstack        is from   src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack.pkg
herein

    package rehash_module: (weak)
    api {

        add_compiledfile_version
            :
            { picklehash: ph::Picklehash,
              compiledfile_version: String                                      # Something like:   "version-$ROOT/src/app/makelib/(makelib-lib.lib):compilable/thawedlib-tome.pkg-1187780741.285"
            }
            ->
            ph::Picklehash;

        rehash_module
            :
            { symbolmapstack:         syx::Symbolmapstack,
              original_picklehash:  ph::Picklehash,
              compiledfile_version: String                                      # Something like:   "version-$ROOT/src/app/makelib/(makelib-lib.lib):compilable/thawedlib-tome.pkg-1187780741.285"
            }
            ->
            ph::Picklehash;
    }

    {
        fun add_compiledfile_version { picklehash, compiledfile_version }
            =
            {   crc =
                    crc::from_string
                        (byte::bytes_to_string
                            (ph::to_bytes picklehash));

                                                                                # crc           is from   src/lib/compiler/src/library/crc.pkg
                                                                                # byte          is from   src/lib/std/src/byte.pkg
                                                                                # vector_of_chars       is from   src/lib/std/vector-of-chars.pkg

                fun append (c, x)
                    =
                    crc::append (x, c);


                crc' =
                    vector_of_chars::fold_forward
                        append
                            crc
                            compiledfile_version;

                ph::from_bytes
                    (byte::string_to_bytes
                        (crc::to_string crc'));
            };


        fun rehash_module { symbolmapstack, original_picklehash, compiledfile_version }
            =
            add_compiledfile_version
                {
                  picklehash =>   (pkj::pickle_symbolmapstack (pkj::REPICKLING original_picklehash) symbolmapstack).picklehash,
                  compiledfile_version
                };
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext