PreviousUpNext

15.4.107  src/app/makelib/stuff/library-source-index.pkg

## library-source-index.pkg
## (C) 1999 Lucent Technologies, Bell Laboratories
## Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)

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



# The "library registry".
# makelib uses this to remember which libraries
# it is currently working on and what the
# corresponding input sources are.


stipulate
    package ad  =  anchor_dictionary;                                           # anchor_dictionary     is from   src/app/makelib/paths/anchor-dictionary.pkg
    package err =  error_message;                                               # error_message         is from   src/lib/compiler/front/basics/errormsg/error-message.pkg
    package lnd =  line_number_db;                                              # line_number_db        is from   src/lib/compiler/front/basics/source/line-number-db.pkg
    package sci =  sourcecode_info;                                             # sourcecode_info       is from   src/lib/compiler/front/basics/source/sourcecode-info.pkg
herein

    api Library_Source_Index {
        #
        Library_Source_Index;

        make_library_source_index:  Void -> Library_Source_Index;

        register
            :  Library_Source_Index
            -> ( ad::File,
                 sci::Sourcecode_Info
               )
            -> Void;

        look_up
           :  Library_Source_Index
           -> ad::File
           -> sci::Sourcecode_Info;

        registered
            :  Library_Source_Index
            -> ad::File
            -> Bool;

        error
            :  Library_Source_Index
            -> ( ad::File,
                 lnd::Source_Code_Region
               )
            -> err::Plaint_Sink;

        saw_errors
            :  Library_Source_Index
            -> ad::File
            -> Bool;
    };
end;



stipulate
    package ad  =  anchor_dictionary;                                           # anchor_dictionary     is from   src/app/makelib/paths/anchor-dictionary.pkg
    package err =  error_message;                                               # error_message         is from   src/lib/compiler/front/basics/errormsg/error-message.pkg
    package sci =  sourcecode_info;                                             # sourcecode_info       is from   src/lib/compiler/front/basics/source/sourcecode-info.pkg
    package spm =  source_path_map;                                             # source_path_map       is from   src/app/makelib/paths/source-path-map.pkg
herein

    package   library_source_index
    :         Library_Source_Index                                              # Library_Source_Index  is from   src/app/makelib/stuff/library-source-index.pkg
    {
        Library_Source_Index
             =
             Ref( spm::Map( sci::Sourcecode_Info ) );

        #
        fun make_library_source_index ()
            =
            REF spm::empty:  Library_Source_Index;

        #
        fun register gr (p, s)
            =
            gr := spm::set (*gr, p, s);

        #
        fun look_up gr path
            =
            case (spm::get (*gr, path))
                #
                THE s =>  s;
                NULL  =>  raise exception FAIL ("library_source_index::look_up " + ad::describe path);
            esac;

        #
        fun registered gr g
            =
            not_null (spm::get (*gr, g));

        #
        fun error gr (g, r)
            =
            err::error (look_up gr g) r;

        #
        fun saw_errors gr g
            =
            {   my  input_source:   sci::Sourcecode_Info
                    =
                    look_up gr g;

                *input_source.saw_errors;
            };
    };
end;



Comments and suggestions to: bugs@mythryl.org

PreviousUpNext