PreviousUpNext

15.3.258  src/lib/compiler/front/typer-stuff/modules/module-level-declarations.api

## module-level-declarations.api

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



# Datastructures describing module-level declarations.
#
# In particular, the sumtypes
#
#     Api,
#     Package,
#     Generic,
#     Generic_Api,
#
# provide the value types bound by the symbol table
# for those four namespaces -- see OVERVIEW section in
#
#     src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack.pkg
#
#
#
# NB:, the 'Stampmapstack' type defined in
#
#     src/lib/compiler/front/typer-stuff/modules/stampmapstack.pkg
#
# is a low-maintenance alternative to the the 'Modtree'
# type we define here.  See comments in above file for more info.



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 mp  =  stamppath;                   # stamppath                     is from   src/lib/compiler/front/typer-stuff/modules/stamppath.pkg
    package pl  =  property_list;               # property_list                 is from   src/lib/src/property-list.pkg
    package sp  =  symbol_path;                 # symbol_path                   is from   src/lib/compiler/front/typer-stuff/basics/symbol-path.pkg
    package sta =  stamp;                       # stamp                         is from   src/lib/compiler/front/typer-stuff/basics/stamp.pkg
    package sy  =  symbol;                      # symbol                        is from   src/lib/compiler/front/basics/map/symbol.pkg
    package tdt =  type_declaration_types;      # type_declaration_types        is from   src/lib/compiler/front/typer-stuff/types/type-declaration-types.pkg
    package vh  =  varhome;                     # varhome                       is from   src/lib/compiler/front/typer-stuff/basics/varhome.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/compiler/front/typer-stuff/modules/module-level-declarations.pkg
    #
    api Module_Level_Declarations {
        #
        Share_Spec
            =
            List( sp::Symbol_Path );


        Api = API  Api_Record
            | ERRONEOUS_API


        also
        Api_Element
          #
          = TYPE_IN_API
              {
                module_stamp:   sta::Stamp,
                type:           tdt::Type,
                is_a_replica:   Bool,
                scope:          Int
              }
          #
          | PACKAGE_IN_API
              {
                module_stamp:   sta::Stamp,
                an_api:         Api,
                definition:     Null_Or( (Package_Definition, Int) ),
                slot:           Int
              }
          #
          | GENERIC_IN_API
              {
                module_stamp:   sta::Stamp,
                a_generic_api:  Generic_Api,
                slot:           Int
              }
          #
          | VALUE_IN_API
              {
                typoid:         tdt::Typoid,
                slot:           Int
              }
          #
          | VALCON_IN_API
              {
                sumtype:        tdt::Valcon,
                slot:           Null_Or( Int )
              }



        also
        Generic_Api 
          #
          = GENERIC_API
              {
                kind:                 Null_Or( sy::Symbol ),
                parameter_api:        Api,
                parameter_variable:   sta::Stamp,
                parameter_symbol:     Null_Or( sy::Symbol ),
                body_api:             Api
              }
          #
          | ERRONEOUS_GENERIC_API



        also
        External_Definition
          #
          = EXTERNAL_DEFINITION_OF_PACKAGE  (sp::Symbol_Path, Package_Definition)
          #
          | EXTERNAL_DEFINITION_OF_TYPE
              {
                extdef_path:            sp::Symbol_Path,        #  The (inward) path to the spec being defined 
                extdef_type:            tdt::Type,              #  The definition, typically relativized.      
                extdef_is_relative:     Bool                    #  Does typ contain typechecked_package paths?  
              } 




        also
        Package_Definition
          #
          = CONSTANT_PACKAGE_DEFINITION  Package                        # Constant 
          | VARIABLE_PACKAGE_DEFINITION  (Api, mp::Stamppath)           # relative 




        #  ------------------------- packages and generics ---------------------- 

        also
        Package
          #
          = A_PACKAGE  Package_Record
          #
          | ERRONEOUS_PACKAGE
          #
          | PACKAGE_API
              {
                an_api:       Api,
                stamppath:  mp::Stamppath
              }



      also
      Generic
        #
        = GENERIC  Generic_Record
        | ERRONEOUS_GENERIC



        #  ----------------------- macroExpansion-related definitions -------------------- 

        also
        Typerstore_Entry                #  Elements of a Typerstore: 
          #
          = TYPE_ENTRY          Typechecked_Type
          | PACKAGE_ENTRY       Typechecked_Package
          | GENERIC_ENTRY       Typechecked_Generic
          | ERRONEOUS_ENTRY

                   # We have no typechecked versions yet for
                   # values, constructors or exceptions,
                   # but this may change.



        also
        Generic_Closure                                         # Application of a generic
          #
          = GENERIC_CLOSURE {
              parameter_module_stamp:   sta::Stamp,
              body_package_expression:  Package_Expression,
              typerstore:               Typerstore
            }



        also
        Stamp_Expression                                        # Stamps are arbitrary unique labels. They are kludges used in the Definition of Standard ML semantics; the more recent Harper-Stone semantics dispenses with them.
          #
          = MAKE_STAMP                                          # Generate a new stamp.
          | GET_STAMP   Package_Expression
  #       | CONST       sta::Stamp                              # An existing stamp 




        also
        Typechecked_Type_Expression                             # Expression evaluating to a type constructor typechecked_package: 
          #
          = TYPEVAR_TYPE        mp::Stamppath                   # Selection from current Typerstore 
          | CONSTANT_TYPE       tdt::Type                       # Actual typ 
          | FORMAL_TYPE         tdt::Type                       # Formal typ 



        also
        Package_Expression
          #
          = VARIABLE_PACKAGE  mp::Stamppath 
          | CONSTANT_PACKAGE  Typechecked_Package
          | PACKAGE           { stamp: Stamp_Expression,  module_declaration: Module_Declaration }
          | APPLY             (Generic_Expression, Package_Expression)  
          | ABSTRACT_PACKAGE  (Api, Package_Expression)
          | FORMAL_PACKAGE    Generic_Api
          #
          | PACKAGE_LET       { declaration: Module_Declaration,
                                expression:  Package_Expression
                              }
          #
          | COERCED_PACKAGE   { boundvar:    sta::Stamp,
                                raw:         Package_Expression,
                                coercion:    Package_Expression
                              }

                # COERCED_PACKAGE is similar to
                #    PACKAGE_LET (m::PACKAGE_DECLARATION (boundvar, raw), coercion),
                # but with special treatment of inverse_path propagation to support
                # accurate type names in generic results where the generic has
                # a result api constraint.



        also
        Generic_Expression
          #
          = VARIABLE_GENERIC  mp::Stamppath 
          | CONSTANT_GENERIC  Typechecked_Generic
          | LAMBDA            { parameter: sta::Stamp, body: Package_Expression }
          | LAMBDA_TP         { parameter: sta::Stamp, body: Package_Expression, an_api: Generic_Api }
          | LET_GENERIC       (Module_Declaration, Generic_Expression)



        also
        Module_Expression
          #
          = TYPE_EXPRESSION             Typechecked_Type_Expression
          | PACKAGE_EXPRESSION          Package_Expression
          | GENERIC_EXPRESSION          Generic_Expression
          | DUMMY_GENERIC_EVALUATION_EXPRESSION
          | ERRONEOUS_ENTRY_EXPRESSION



        also
        Module_Declaration
          #
          = TYPE_DECLARATION              (sta::Stamp, Typechecked_Type_Expression)
          | PACKAGE_DECLARATION           (sta::Stamp, Package_Expression, sy::Symbol)
          | GENERIC_DECLARATION           (sta::Stamp, Generic_Expression)
          | SEQUENTIAL_DECLARATIONS       List( Module_Declaration )
          | LOCAL_DECLARATION             (Module_Declaration, Module_Declaration)
          | ERRONEOUS_ENTRY_DECLARATION
          | EMPTY_GENERIC_EVALUATION_DECLARATION



        also
        Typerstore
          #
          = MARKED_TYPERSTORE  Typerstore_Record
          | NAMED_TYPERSTORE   (mp::module_stamp_map::Map( Typerstore_Entry ), Typerstore)
          | NULL_TYPERSTORE
          | ERRONEOUS_ENTRY_DICTIONARY



        also
        Modtree                         # "modtree" == "module tree"            # Used (only) in Stub_Info (next) to describe resources in libraries and compilation units external to the current compile.
          #
          = SUMTYPE_MODTREE_NODE        tdt::Sumtype_Record
          | API_MODTREE_NODE            Api_Record
          | PACKAGE_MODTREE_NODE        Package_Record
          | GENERIC_MODTREE_NODE        Generic_Record
          | TYPERSTORE_MODTREE_NODE     Typerstore_Record
          | MODTREE_BRANCH              List( Modtree )



        withtype
        Stub_Info                                                               # Used to describe resources in other libraries (or more generally, other compilation units).
          =
          { owner:                  picklehash::Picklehash,                     # Hash of complete contents of external library, used as its name for lookup.
            is_lib:                 Bool,
            modtree:                Modtree                                     # Summary of what we need to know about the external library/compilation-unit.
          }

        also
        Api_Record
          =
          { stamp:                  sta::Stamp,
            name:                   Null_Or( sy::Symbol ),
            closed:                 Bool,
            #   
            symbols:                List( sy::Symbol ), 
            api_elements:           List( (sy::Symbol, Api_Element)),
            property_list:          pl::Property_List,
            #
            contains_generic:       Bool,
            type_sharing:           List( Share_Spec ),
            package_sharing:        List( Share_Spec ),
            stub:                   Null_Or( Stub_Info )
          }

        also
        Typerstore_Record
          =
          { stamp:                  sta::Stamp,
            typerstore:             Typerstore,
            stub:                   Null_Or( Stub_Info )
          }

        also
        Typechecked_Package
          =
          { stamp:                  sta::Stamp,
            typerstore:             Typerstore,
            property_list:          pl::Property_List,
            inverse_path:           ip::Inverse_Path,
            stub:                   Null_Or( Stub_Info )
          }

        also
        Package_Record
          =
          { an_api:                 Api,
            typechecked_package:    Typechecked_Package,
            varhome:                vh::Varhome,
            inlining_data:          id::Inlining_Data
          }

        also
        Typechecked_Generic
          =
          { stamp:                  sta::Stamp,
            generic_closure:        Generic_Closure,
            property_list:          pl::Property_List,
            typepath:               Null_Or( tdt::Typepath ),
            inverse_path:           ip::Inverse_Path,
            stub:                   Null_Or( Stub_Info )
          }

        also
        Generic_Record
          =
          { a_generic_api:          Generic_Api,
            typechecked_generic:    Typechecked_Generic,
            varhome:                vh::Varhome, 
            inlining_data:          id::Inlining_Data
          }


        also
        Typechecked_Type                # The stamp and arith inside tdt::Type are critical:
          =
          tdt::Type;

        Api_Elements
          =
          List( (sy::Symbol, Api_Element) );


    #    also constraint  
    #      = { my_path:  sp::Symbol_Path, its_ancestor:  instrep, its_path:  sp::Symbol_Path }


        bogus_typechecked_package:      Typechecked_Package;
        bogus_typechecked_generic:      Typechecked_Generic;
    };                                                                          # Api Module 
end;                                                                            # stipulate


## (C) 2001 Lucent Technologies, Bell Labs
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext