PreviousUpNext

15.4.61  src/app/makelib/depend/intra-library-dependency-graph.pkg

## intra-library-dependency-graph.pkg

# Compiled by:
#     src/app/makelib/makelib.sublib

# See overview comments in src/A.DEPENDENCY-GRAPH.OVERVIEW

# Our usual nickname for this package is "sg":  Small-scale dependency Graph.



stipulate
    package flt =  frozenlib_tome;                                                      # frozenlib_tome        is from   src/app/makelib/freezefile/frozenlib-tome.pkg
    package tlt =  thawedlib_tome;                                                      # thawedlib_tome        is from   src/app/makelib/compilable/thawedlib-tome.pkg
    package sys =  symbol_set;                                                          # symbol_set            is from   src/app/makelib/stuff/symbol-set.pkg
    package syx =  symbolmapstack;                                                      # symbolmapstack        is from   src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack.pkg
    package im  =  inlining_mapstack;                                                   # inlining_mapstack     is from   src/lib/compiler/toplevel/compiler-state/inlining-mapstack.pkg
    package ph  =  picklehash;                                                          # picklehash            is from   src/lib/compiler/front/basics/map/picklehash.pkg
herein

    package intra_library_dependency_graph {
        #
        #
        Tome_Tin                                                                        # Contents of either an .api or .pkg file, belonging to either a thawed or frozen library.
          #
          = TOME_IN_THAWEDLIB                   Thawedlib_Tome_Tin
          #
          | TOME_IN_FROZENLIB                                                           # 'Tome_Tin' is used only in thawed libraries (Thawedlib_Tome), so we are at the thawed/frozen boundary.
              {
                frozenlib_tome_tin:             Frozenlib_Tome_Tin,
                symbol_and_inlining_mapstacks:  Tome_Compile_Result,                    # To save space, frozen libraries contain no symbol or inlining tables, so we store them here at the thawed/frozen boundary.
                sublibs_index:                  Null_Or( Int )                          # References i'th entry of lg::LIBRARY::sublibraries list.
              }

        also
        Frozenlib_Tome_Tin                                                              # A foo.api.compiled or foo.pkg.compiled file packed inside a foo.lib.frozen freezefile, like a unix foo.o in a libfoo.a or libfoo.so.
            =
            FROZENLIB_TOME_TIN
              {
                frozenlib_tome:         flt::Frozenlib_Tome,
                near_imports:           List(             Frozenlib_Tome_Tin ),         # Referenced .api and .pkg files in the same library -- ie, built by same .lib makefile.        
                far_import_thunks:      List( Void -> Far_Frozenlib_Tome )              # Referenced .api and .pkg files in other libraries, as thunks because we build them on demand.  NB: A Frozenlib may refer only to other frozenlibs.
              }

        also
        Thawedlib_Tome_Tin                                                              # An individual sourcefile on disk.
            =
            THAWEDLIB_TOME_TIN
              {
                thawedlib_tome:         tlt::Thawedlib_Tome,
                near_imports:           List( Thawedlib_Tome_Tin ),                     # Referenced .api and .pkg files in the same library -- ie, built by same .lib file.
                far_imports:            List( Masked_Tome  )                            # Referenced .api and .pkg files in other libraries. A thawedlib may refer to both thawed and frozen libs.
              }

        withtype
        Exports_Mask =   Null_Or( sys::Set )                                            # Only symbols in a tome's exports_mask are to be regareded as externally visible. (This implements package filtering per a given api.)

        also
        Masked_Tome                                             # <=====================  Masked_Tome is the only type here which is referenced in   src/app/makelib/depend/inter-library-dependency-graph.pkg
          =
          {  exports_mask:              Exports_Mask,
             tome_tin:                  Tome_Tin
          }

        also
        Far_Frozenlib_Tome
          =
          { frozenlib_tome_tin:         Frozenlib_Tome_Tin,
            exports_mask:               Exports_Mask,
            sublibs_index:              Null_Or(Int)                                    # Position withint lg::LIBRARY::sublibraries list.
          }

        also
        Tome_Compile_Result
          =
          # To save space in foo.lib.frozen files we strip
          # the symbolmapstack and inlining-mapstack from any tome
          # in a foo.lib.frozen file.  This is implemented
          # via the   drop_symbol_and_inlining_mapstacks   arg
          # to        write_compiledfile   in   src/lib/compiler/execution/compiledfile/compiledfile.pkg
          #
          # These tables will however still be needed by thawed
          # code referencing tomes in frozen libraries, so we store
          # it in Tome_Compile_Result records at the thawed/frozen boundary.
          # layer. (Recall that we require all libraries referenced by
          # a frozen library must also be frozen, hence freezing takes
          # place in a wave from the leaf libraries upward.)
          #
          # Independently, we also use Tome_Compile_Result records as intermediate
          # results in compile-in-dependency-order-g.pkg:
          #
          { symbolmapstack_thunk:               Void -> syx::Symbolmapstack,
            inlining_mapstack_thunk:            Void -> im::Picklehash_To_Anormcode_Mapstack,
            #
            symbolmapstack_picklehash:          ph::Picklehash,                                 # If these two are unchanged after a compile, the module is effectively
            inlining_mapstack_picklehash:       ph::Picklehash,                                 # unchanged -- the user probably just edited some comments or such.
            #
            compiledfile_version:               String                                          # Something like "version-$ROOT/src/lib/compiler/(core.sublib):semantic/basics/inlining-junk.api-1187727181.821"
          };



        fun describe_tome (TOME_IN_FROZENLIB { frozenlib_tome_tin => FROZENLIB_TOME_TIN r, ... }) =>  flt::describe_frozenlib_tome  r.frozenlib_tome;
            describe_tome (TOME_IN_THAWEDLIB (                       THAWEDLIB_TOME_TIN r      )) =>  tlt::describe_thawedlib_tome  r.thawedlib_tome;
        end;

        fun describe_far_tome (_, tome)                                                 #  This fun is actually never used at present.                          
            =
            describe_tome tome;



        #############################################
        # Comparing compiledfile nodes for equality 


        fun same_frozenlib_tome_tin ( FROZENLIB_TOME_TIN { frozenlib_tome => i,  ... },
                                      FROZENLIB_TOME_TIN { frozenlib_tome => i', ... }
                                    )
            =
            flt::compare (i, i') == EQUAL;


        fun same_thawedlib_tome_tin ( THAWEDLIB_TOME_TIN  { thawedlib_tome => i,  ... },
                                      THAWEDLIB_TOME_TIN  { thawedlib_tome => i', ... }
                                    )
            =
            tlt::same_thawedlib_tome (i, i');


        fun same_tome_tin ( TOME_IN_THAWEDLIB  n,
                            TOME_IN_THAWEDLIB  n'
                          )
                =>
                same_thawedlib_tome_tin (n, n');

            same_tome_tin ( TOME_IN_FROZENLIB r1,
                            TOME_IN_FROZENLIB r2
                          )
                    =>
                    same_frozenlib_tome_tin ( r1.frozenlib_tome_tin,
                                              r2.frozenlib_tome_tin
                                            );

            same_tome_tin _ =>   FALSE;
        end;
    };
end;





Comments and suggestions to: bugs@mythryl.org

PreviousUpNext