PreviousUpNext

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

## variables-and-constructors.pkg
## (C) 2001 Lucent Technologies, Bell Labs

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



# Datastructures describing variable and
# constructor declarations.
#
# In particular, the datatypes
#
#     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 ty  =  types;                               # types                         is from   src/lib/compiler/front/typer-stuff/types/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
            = ORDINARY_VARIABLE
                  {
                    path:          syp::Symbol_Path,
                    var_type:      Ref( ty::Type ),
                    varhome:      vh::Varhome,
                    inlining_data: inlining_data::Inlining_Data
                  }

            | OVERLOADED_IDENTIFIER
                  {
                    name:         sy::Symbol,
                    type_scheme:  ty::Type_Scheme,
                    alternatives: Ref( List { indicator: ty::Type,
                                              variant: Variable
                                            }
                                     )
                  }

            | ERRORVAR;

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

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

        fun make_ordinary_variable (id, varhome)
            =
            ORDINARY_VARIABLE
                {
                  path          =>  syp::SYMBOL_PATH [id], 
                  var_type      =>  REF ty::UNDEFINED_TYPE,
                  varhome,
                  inlining_data =>  inlining_data::NULL
                };

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

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


    };                                                  # package variables_and_constructors 
end;                                                    # stipulate


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext