PreviousUpNext

15.3.289  src/lib/compiler/toplevel/interact/compiler-state.api

## compiler-state.api

# Compiled by:
#     src/lib/compiler/core.sublib



# This defines the core toplevel datastructures
# used to track known symbols, loaded modules etc
# during a compile.
#
# (But see   src/app/makelib/main/makelib-state.pkg
# for a still higher level in the state hierarchy.)
#
# As a rough guide to the lay of the land,
# here we implement references to compiler_mapstack_set
# records, which is to say, compiler_mapstack_set records
# which we can update via side-effect.
#
# compiler_mapstack_set records are defined in
#
#     src/lib/compiler/toplevel/compiler-state/compiler-mapstack-set.pkg
#
# and are composed of three principal parts:
#
#    A symbol table holding per-symbol type information etc
#    A linking table tracking loaded libraries.
#    An inlining table tracking cross-module function inlining info.


stipulate
    package cms =  compiler_mapstack_set;                                                       # compiler_mapstack_set                 is from   src/lib/compiler/toplevel/compiler-state/compiler-mapstack-set.pkg
    package pl  =  property_list;                                                               # property_list                         is from   src/lib/src/property-list.pkg
    package sy  =  symbol;                                                                      # symbol                                is from   src/lib/compiler/front/basics/map/symbol.pkg
    package pcs =  per_compile_stuff;                                                           # per_compile_stuff                     is from   src/lib/compiler/front/typer-stuff/main/per-compile-stuff.pkg
    package ds  =  deep_syntax;                                                                 # deep_syntax                           is from   src/lib/compiler/front/typer-stuff/deep-syntax/deep-syntax.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/compiler/toplevel/interact/compiler-state.pkg
    #
    api Compiler_State {
        #
        Compiler_Mapstack_Set
            =
            cms::Compiler_Mapstack_Set;

        Compiler_Mapstack_Set_Jar
          =
          { get_mapstack_set:   Void -> Compiler_Mapstack_Set,
            set_mapstack_set:   Compiler_Mapstack_Set -> Void
          };

        Compiler_State
          =
          { top_level_pkg_etc_defs_jar: Compiler_Mapstack_Set_Jar,
            baselevel_pkg_etc_defs_jar: Compiler_Mapstack_Set_Jar,
            property_list:                      pl::Property_List
          };

        make__compiler_state_stack:     Void -> (Compiler_State, List(Compiler_State));         # Generate a fresh toplevel compiler state, for packages which maintain their own compiler state like   src/lib/x-kit/widget/edit/eval-mill.pkg
                                                                                                # Added 2015-09-03 CrT.
        compiler_state:                 Void -> Compiler_State;

        get_top_level_pkg_etc_defs_jar: Void -> Compiler_Mapstack_Set_Jar;                      # Interactive top level dictionary 
        get_baselevel_pkg_etc_defs_jar: Void -> Compiler_Mapstack_Set_Jar;
        pervasive_fun_etc_defs_jar:             Compiler_Mapstack_Set_Jar;

        property_list:  Void -> pl::Property_List;


        combined:  Void -> Compiler_Mapstack_Set;

        # Push a given Compiler_State onto the stack,
        # run the thunk, then pop the state:

        run_thunk_in_compiler_state:  ((Void -> X), Compiler_State)   -> X;

        list_bound_symbols:  Void -> List( sy::Symbol );

        Compile_And_Eval_String_Option                                                          # Does not particularly belong here, but a better place isn't obvious and I don't feel like creating a separate package just for it.
          #                                                                                     # This gets used in  compile_raw_declaration_to_package_closure()  in   src/lib/compiler/toplevel/interact/read-eval-print-loop-g.pkg
          #                                                                                     # which is not a convenient place from which to export a datatype widely -- needed in (e.g.)    src/lib/x-kit/widget/edit/eval-mode.pkg
          = COMPILER_VERBOSITY          pcs::Compiler_Verbosity                                 # Controls printing of intermediate code forms etc.
          | DEEP_SYNTAX_TRANSFORM       ds::Declaration -> ds::Declaration                      # Allows arbitrary rewriting of the deep syntax tree.  Rarely used; potentially useful for profiling or instrumenting code or adding debug support.
          ;     
    };
end;




Comments and suggestions to: bugs@mythryl.org

PreviousUpNext