PreviousUpNext

15.3.257  src/lib/compiler/front/typer-stuff/modules/module-junk.api

## module-junk.api 

# Compiled by:
#     src/lib/compiler/front/typer-stuff/typecheckdata.sublib



# The center of the typechecker is
#
#     src/lib/compiler/front/typer/main/type-package-language-g.pkg
#
# -- see it for a higher-level overview.
#
# This file contains support functions used mainly
# during typechecking of module-language stuff.
#
# In particular, we implement looking up things
# in nested packages:
#     Source code like "a::b.c" accessing stuff
# in such nested packages parses into a list
# of symbols [a, b, c] called a "symbol_path".
#     To actually turn a symbol_path into something
# useful, we must look up 'a' in the symbol table,
# look up 'b' in the value of 'a', look up 'c' in
# the value of 'b', etc to the end of the path.
#    In this file, we implement the busywork of
# actually doing so.
#    To keep things nicely typed, we need one
# get_xxx_via_path function for each type of
# thing XXX that we want to fetch.  To keep
# the redundancy level down, we implement one
# generic routine and then one wrapper per
# result type.


stipulate
    package id  =  inlining_data;                                                               # inlining_data                         is from   src/lib/compiler/front/typer-stuff/basics/inlining-data.pkg
    package ip  =  inverse_path;                                                                # inverse_path                          is from   src/lib/compiler/front/typer-stuff/basics/symbol-path.pkg
    package mld =  module_level_declarations;                                                   # module_level_declarations             is from   src/lib/compiler/front/typer-stuff/modules/module-level-declarations.pkg
    package mp  =  stamppath;                                                                   # stamppath                             is from   src/lib/compiler/front/typer-stuff/modules/stamppath.pkg
    package spc =  stamppath_context;                                                           # stamppath_context                     is from   src/lib/compiler/front/typer-stuff/modules/stamppath-context.pkg
    package sta =  stamp;                                                                       # stamp                                 is from   src/lib/compiler/front/typer-stuff/basics/stamp.pkg
    package sxe =  symbolmapstack_entry;                                                        # symbolmapstack_entry                  is from   src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack-entry.pkg
    package stx =  stampmapstack;                                                               # stampmapstack                         is from   src/lib/compiler/front/typer-stuff/modules/stampmapstack.pkg
    package sy  =  symbol;                                                                      # symbol                                is from   src/lib/compiler/front/basics/map/symbol.pkg
    package syp =  symbol_path;                                                                 # symbol_path                           is from   src/lib/compiler/front/typer-stuff/basics/symbol-path.pkg
    package syx =  symbolmapstack;                                                              # symbolmapstack                        is from   src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack.pkg
    package tdt =  type_declaration_types;                                                      # type_declaration_types                is from   src/lib/compiler/front/typer-stuff/types/type-declaration-types.pkg
    package vac =  variables_and_constructors;                                                  # variables_and_constructors            is from   src/lib/compiler/front/typer-stuff/deep-syntax/variables-and-constructors.pkg
herein

    api Module_Junk {
        #
        #

        exception UNBOUND  sy::Symbol;

        get_api_element:   (mld::Api_Elements, sy::Symbol)  ->  mld::Api_Element;

        get_api_element_variable:  mld::Api_Element -> Null_Or( sta::Stamp );

        package_definition_to_package:  (mld::Package_Definition, mld::Typerstore)   ->   mld::Package;

        # ** getTypeConstructor, get_package and get_generic are used in modules/sigmatch.sml only **

        get_type
            :
            ( mld::Api_Elements,
              mld::Typerstore,
              sy::Symbol
            ) 
            ->
            ( tdt::Type,
              sta::Stamp
            );

        get_package
            :
            ( mld::Api_Elements,
              mld::Typerstore,
              sy::Symbol,
              varhome::Varhome,
              id::Inlining_Data
            )
            ->
            ( mld::Package,
              sta::Stamp
            );

        get_generic
            :
            ( mld::Api_Elements,
              mld::Typerstore,
              sy::Symbol,
              varhome::Varhome,
              id::Inlining_Data
            )
            ->
            ( mld::Generic,
              sta::Stamp
            );

        # These functions are used in eq-types.pkg:
        #
        get_package_stamp:      mld::Package ->  sta::Stamp;
        get_package_name:       mld::Package ->  ip::Inverse_Path;
        get_packages:           mld::Package ->  List( mld::Package );
        get_types:              mld::Package ->  List( tdt::Type );
        get_package_symbols:    mld::Package ->  List( sy::Symbol );



        # These functions should be called in
        # dictionary/find-in-symbolmapstack.pkg only:

        get_package_via_path:  ( mld::Package,
                                 syp::Symbol_Path,
                                 syp::Symbol_Path
                               ) 
                               ->
                               mld::Package;

        get_package_definition_via_path:
                               ( mld::Package,
                                 syp::Symbol_Path,
                                 syp::Symbol_Path
                               ) 
                               ->
                               mld::Package_Definition;

        get_generic_via_path:( mld::Package,
                               syp::Symbol_Path,
                               syp::Symbol_Path
                             )
                             ->
                             mld::Generic;

        get_type_via_path: ( mld::Package,
                               syp::Symbol_Path,
                               syp::Symbol_Path
                             )
                             ->
                             tdt::Type;

        get_value_via_path:  ( mld::Package,
                               syp::Symbol_Path,
                               syp::Symbol_Path
                             )
                             ->
                             vac::Variable_Or_Constructor;

        check_path_sig:      ( mld::Api,
                               syp::Symbol_Path
                             )
                             ->
                             Null_Or( sy::Symbol );

        apis_equal:        (mld::Api,     mld::Api    )  ->  Bool;
        eq_origin:         (mld::Package, mld::Package)  ->  Bool;

        typestamp_of:       tdt::Type   ->  stx::Typestamp;
        packagestamp_of:    mld::Package ->  stx::Packagestamp;
        genericstamp_of:    mld::Generic ->  stx::Genericstamp;

        make_packagestamp: (mld::Api,         mld::Typechecked_Package)  ->  stx::Packagestamp;
        make_genericstamp: (mld::Generic_Api, mld::Typechecked_Generic)  ->  stx::Genericstamp;

        # Translate typ or type
        # in a Typerstore:
        #
        translate_type:      mld::Typerstore -> tdt::Type -> tdt::Type;
        translate_typoid:     mld::Typerstore -> tdt::Typoid   -> tdt::Typoid;

        # Relativize type or typ
        # in an stamppath_context:
        #
        relativize_type:  spc::Context -> tdt::Type -> (tdt::Type, Bool);
        relativize_typoid:    spc::Context -> tdt::Typoid   -> (tdt::Typoid,   Bool);

        include_package:  ( syx::Symbolmapstack,
                            mld::Package
                          )
                          ->
                          syx::Symbolmapstack;

        # Extract inlining_data
        # from a list of namings: 
        #
        extract_inlining_data:  sxe::Symbolmapstack_Entry
                                ->
                                id::Inlining_Data;

        get_api_symbols: mld::Api -> List( sy::Symbol );
        get_api_names:   mld::Package -> List( sy::Symbol );

        debugging:  Ref(  Bool );
    };
end;




## COPYRIGHT (c) 1996 Bell Laboratories. 
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext