PreviousUpNext

15.4.606  src/lib/compiler/front/typer-stuff/main/per-compile-info.pkg

## per-compile-info.pkg
#
# Here we track information relating to
# one compile of one source file, such as
# the name of the sourcefile and whether
# the compile was successful.

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


stipulate
    package cpu =  cpu_timer;                                   # cpu_timer             is from   src/lib/std/src/cpu-timer.pkg
    package err =  error_message;                               # error_message         is from   src/lib/compiler/front/basics/errormsg/error-message.pkg
    package tmp =  highcode_codetemp;                           # highcode_codetemp     is from   src/lib/compiler/back/top/highcode/highcode-codetemp.pkg
    package lnd =  line_number_db;                              # line_number_db        is from   src/lib/compiler/front/basics/source/line-number-db.pkg
    package pp  =  prettyprinter;                               # prettyprinter         is from   src/lib/prettyprint/big/src/prettyprinter.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 vh  =  varhome;                                     # varhome               is from   src/lib/compiler/front/typer-stuff/basics/varhome.pkg
herein

    package per_compile_info {
        #
        #
                                
        Per_Compile_Info( A_deep_syntax_tree )
            =
            { make_fresh_stamp:        Void -> sta::Stamp,
              issue_highcode_codetemp: Null_Or( sy::Symbol ) -> tmp::Codetemp,
              saw_errors:              Ref( Bool ),
              error_fn:                err::Error_Function,
              error_match:             lnd::Source_Code_Region -> String,
              transform:               A_deep_syntax_tree -> A_deep_syntax_tree,
              source_name:             String,
              prettyprinter_or_null:   Null_Or pp::Prettyprinter,
              cpu_timer:               cpu::Cpu_Timer
            };
            #
            # 2010-09-07 CrT:   XXX BUGGO FIXME
            #
            # I think
            #
            #     prettyprinter_or_null:   Null_Or pp::Prettyprinter
            #
            # above should be changed go
            #
            #     compile_log: Null_Or( file::Output_Stream ),
            #
            # per "simple things should be simple; complex things should be possible":
            # Most of the time we'll just want to write a line of text, so that should
            # be the favored case.
            #
            # (I'd like to treat the prettyprint stuff not as an opaque output stream,
            # but rather as a buffer/datastructure that a client uses to produce a string
            # which is then written to an output stream.)
            #
            # Over time, I'd like to evolve the .compile.log
            # support stuff in the direction of
            #
            #     src/lib/src/lib/thread-kit/src/lib/logger.pkg
            #
            # This cannot be done immediately because logger.pkg depends on having
            # threadkit running, and the compiler doesn't currently run threadkit.
            #
            # Also, we probably don't want trace.logs to interfere with compile.log
            # generation or vice versa, even if user apps invoke the compiler internally,
            # so we probably don't want to do a simple-minded merge of the two facilities.
            # (Maybe they can wind up being two calls to a single generic package?)

        fun make_per_compile_info {
                sourcecode_info,
                transform:  X -> X,
                make_fresh_stamp_maker,
                prettyprinter_or_null
            }
            =
            (   { make_fresh_stamp,
                  issue_highcode_codetemp,
                  source_name            =>  sourcecode_info.file_opened,
                  saw_errors,
                  error_fn,
                  error_match,
                  transform,
                  prettyprinter_or_null,
                  cpu_timer
                }
                : Per_Compile_Info(X)
            )
            where
                # We get called from the tops of
                # 
                #     compile_one_sourcefile ()     in    src/app/makelib/compile/compile-in-dependency-order-g.pkg
                #     read_eval_print_loop   ()     in    src/lib/compiler/toplevel/interact/read-eval-print-loop-g.pkg

                (err::errors  sourcecode_info)
                    ->
                    { error_fn, error_match, saw_errors };

                tmp::clear ();

                make_fresh_stamp =  make_fresh_stamp_maker   ();

                cpu_timer =  cpu::make_cpu_timer ();


                fun issue_highcode_codetemp  NULL
                        =>
                        tmp::issue_highcode_codetemp ();

                    issue_highcode_codetemp (THE symbol)
                        =>
                        tmp::issue_named_highcode_codetemp symbol;
                end;
            end;

        fun saw_errors (per_compile_info: Per_Compile_Info(X))
            =
            *per_compile_info.saw_errors;

    };                                                                          # package per_compile_info 
end;                                                                            # stipulate


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


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext