PreviousUpNext

15.4.732  src/lib/core/internal/make-mythryl-compiler-etc.pkg

## make-mythryl-compiler-etc.pkg

# Compiled by:
#     src/lib/core/internal/interactive-system.lib


# Run the make_mythryl_compiler_etc_g generic which builds the compiler and related stuff.
#
# It is important that this generic is done executing by the time
# the mythryld main package code (src/lib/core/internal/make-mythryld-executable.pkg)
# runs:  Otherwise, we would never be able to get rid of makelib/make_compiler
# from an interactive heap image.
#                                  -Matthias Blume (6/1998)
#
# generic arguments:
#
#     mythryl_compiler:  For the definition of this, see the comments in
#
#         src/lib/compiler/toplevel/compiler/mythryl-compiler-g.pkg
#
#     makelib_internal:
#
#         This is defined in
#
#             src/lib/core/internal/makelib-internal.pkg
#
#         which is a trivial invocation of makelib_g in
#
#             src/app/makelib/main/makelib-g.pkg
#
# References:
#
#     make_compiler_etc is (only) referenced in
#
#         src/lib/core/internal/make-mythryld-executable.pkg
#
#              make_mythryl_compiler_etc::make_compiler_etc  root_directory



###                   "Our paper became a monograph.
###                    When we had completed the details,
###                    we rewrote everything so that no
###                    one could tell how we came upon
###                    our ideas or why. This is the
###                    standard in mathematics."
###            
###                          -- David Berlinski, "Black Mischief" (1988).


                                                                                                
                                        
stipulate
    package mli =  makelib_internal;                                    # makelib_internal              is from   src/lib/core/internal/makelib-internal.pkg
    package ph  =  picklehash;                                          # picklehash                    is from   src/lib/compiler/front/basics/map/picklehash.pkg
    package lt  =  linking_mapstack;                                    # linking_mapstack              is from   src/lib/compiler/execution/linking-mapstack/linking-mapstack.pkg
    package mc  =  mythryl_compiler;                                    # mythryl_compiler              is from   src/lib/core/compiler/set-mythryl_compiler-to-mythryl_compiler_for_intel32_posix.pkg
    package un  =  unsafe;                                              # unsafe                        is from   src/lib/std/src/unsafe/unsafe.pkg
herein

    package   make_mythryl_compiler_etc
    :         Make_Mythryl_Compiler_Etc                                 # Make_Mythryl_Compiler_Etc     is from   src/lib/core/internal/make-mythryl-compiler-etc.api
    {
        # "To be able to use mythryl-yacc and mythryl-lex
        #  at -rebuild time it is necessary to
        #  force their plugins to be _always_ plugged in.
        #
        # "We achieve this by simply mentioning
        #  the package names here."
        #                             -- Matthias Blume
        #
        package yacc_tool =  yacc_tool;
        package lex_tool  =  lex_tool;
            #
            # 2010-11-05 CrT: Commenting out the above two results during "make rest" in:
            #
            #          src/app/makelib/main/makelib-g.pkg:  Attempting to load plugin $/mllex-tool.cm
            #          src/app/makelib/main/makelib-g.pkg:  Unable to load plugin $/mllex-tool.cm



        # Our sole invocation is from
        #     src/lib/core/internal/make-mythryld-executable.pkg
        #
        fun make_mythryl_compiler_etc  { root_dir_of_mythryl_source_distro:   String }          # Containing sh/ bin/ src/ ... 
            =
            {   fun make_linking_mapstack (un::p::NIL, linking_mapstack)
                        =>
                        linking_mapstack;

                    make_linking_mapstack (un::p::CONS (raw_dynamic_picklehash, chunk, rest), linking_mapstack)
                        =>
                        {   dynamic_picklehash
                                =
                                ph::from_bytes raw_dynamic_picklehash;

                            make_linking_mapstack (rest, lt::bind (dynamic_picklehash, chunk, linking_mapstack));
                        };
                end;

                linking_mapstack
                    =
                    make_linking_mapstack (*un::pervasive_package_pickle_list__global, lt::empty);

                fun errorwrap treat_as_user f x
                    =
                    mc::rpl::with_exception_trapping
                        #
                        { treat_as_user,
                          pp => NULL
                        }
                        #
                        { thunk =>  \\ () =  f x,
                          flush =>  \\ () =  (),
                          fate  =>  \\ e  =  raise exception e
                        };

                # Set pickle-list to empty.
                # This is a global C variable used to
                # communicate with the C runtime -- see (e.g.)
                #
                #     src/c/main/construct-runtime-package.c
                #
                un::pervasive_package_pickle_list__global
                    :=
                    un::p::NIL;


                # read_''library_contents''_and_compile_''init_cmi''_and_preload_libraries
                # 
                # is ultimately from
                # 
                #     src/app/makelib/main/makelib-g.pkg
                # 
                the_do_all_requested_compiles
                    =
                    mli::read_''library_contents''_and_compile_''init_cmi''_and_preload_libraries
                      (
                        root_dir_of_mythryl_source_distro,
                        linking_mapstack,

                        mc::rpl::parse_string_to_raw_declarations,
                        mc::rpl::compile_raw_declaration_to_package_closure,
                        mc::rpl::link_and_run_package_closure,

                        mc::rpl::read_eval_print_from_user,
                        mc::rpl::read_eval_print_from_stream,

                        errorwrap FALSE mc::rpl::read_eval_print_from_file,

                        errorwrap TRUE
                      );

                { the_do_all_requested_compiles };
            };                                                                                  # fun make_compiler_etc
    };                                                                                          # package make_mythryl_compiler_etc
end;

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


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext