PreviousUpNext

15.4.605  src/lib/compiler/front/typer-stuff/deep-syntax/variables-and-constructors.pkg

## variables-and-constructors.pkg

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



# Datastructures describing variable and
# constructor declarations.
#
# In particular, the sumtypes
#
#     Variable
#     ty::Valcon
#
# provide the value types bound by the symbol table
# for those two namespaces -- see OVERVIEW section in
#
#     compiler/typer-stuff/symbolmapstack/symbolmapstack.sml



stipulate
    package id  =  inlining_data;                                                       # inlining_data                 is from   src/lib/compiler/front/typer-stuff/basics/inlining-data.pkg
    package tdt =  type_declaration_types;                                              # type_declaration_types        is from   src/lib/compiler/front/typer-stuff/types/type-declaration-types.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 vh  =  varhome;                                                             # varhome                       is from   src/lib/compiler/front/typer-stuff/basics/varhome.pkg
herein


    package   variables_and_constructors
    : (weak)  Variables_And_Constructors                                                # Variables_And_Constructors    is from   src/lib/compiler/front/typer-stuff/deep-syntax/variables-and-constructors.api
    {

        Variable                                                                        # 'Variable' is the referent for   symbolmapstack_entry::Symbolmapstack_Entry.NAMED_VARIABLE
            = PLAIN_VARIABLE
                  {
                    path:           syp::Symbol_Path,
                    vartypoid_ref:  Ref( tdt::Typoid ),                                 # Gets set in   generalize_type()       in   src/lib/compiler/front/typer/types/type-core-language-declaration-g.pkg
                    varhome:        vh::Varhome,
                    inlining_data:  id::Inlining_Data
                  }

            | OVERLOADED_VARIABLE
                  {
                    name:           sy::Symbol,
                    typescheme:     tdt::Typescheme,
                    #
                    alternatives:   Ref( List { indicator:  tdt::Typoid,
                                                variant:    Variable
                                              }
                                       )
                  }

            | ERROR_VARIABLE;

#       Constructor                                     # 'Constructor' is the referent for   symbolmapstack_entry::Symbolmapstack_Entry.NAMED_CONSTRUCTOR
#            =
#            tdt::Valcon;                     

        Variable_Or_Constructor
          #
          = VARIABLE  Variable
          | CONSTRUCTOR    tdt::Valcon                  # "VALCON" == "VALUE_CONSTRUCTOR" -- e.g. FOO in   Foo = FOO;
          ;

        fun make_ordinary_variable (id, varhome)
            =
            PLAIN_VARIABLE
                {
                  path          =>  syp::SYMBOL_PATH [id], 
                  vartypoid_ref =>  REF tdt::UNDEFINED_TYPOID,
                  varhome,
                  inlining_data =>  id::NIL
                };

        bogus_valcon
            =
            tdt::VALCON
                {
                  name             =>  sy::make_value_symbol "bogus",
                  typoid           =>  tdt::WILDCARD_TYPOID,
                  form             =>  vh::CONSTANT 0,
                  is_constant      =>  TRUE,
                  is_lazy          =>  FALSE,
                  signature        =>  vh::CONSTRUCTOR_SIGNATURE (0, 1)
                };

        bogus_exception
            =
            tdt::VALCON
                {
                  name             =>  sy::make_value_symbol "bogus",
                  typoid           =>  core_type_types::exception_typoid,
                  form             =>  vh::CONSTANT 0,
                  is_constant      =>  TRUE,
                  is_lazy          =>  FALSE,
                  signature        =>  vh::NULLARY_CONSTRUCTOR
                };


    };                                                  # package variables_and_constructors 
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