src/Tools/Code/code_runtime.ML
changeset 62494 b90109b2487c
parent 62493 dd154240a53c
child 62495 83db706d7771
equal deleted inserted replaced
62493:dd154240a53c 62494:b90109b2487c
    80 val trace = Attrib.setup_config_bool @{binding "code_runtime_trace"} (K false);
    80 val trace = Attrib.setup_config_bool @{binding "code_runtime_trace"} (K false);
    81 
    81 
    82 fun exec ctxt verbose code =
    82 fun exec ctxt verbose code =
    83  (if Config.get ctxt trace then tracing code else ();
    83  (if Config.get ctxt trace then tracing code else ();
    84   ML_Context.exec (fn () =>
    84   ML_Context.exec (fn () =>
    85     use_text ML_Env.local_context
    85     ML_Compiler0.use_text ML_Env.local_context
    86       {line = 0, file = "generated code", verbose = verbose, debug = false} code));
    86       {line = 0, file = "generated code", verbose = verbose, debug = false} code));
    87 
    87 
    88 fun value ctxt (get, put, put_ml) (prelude, value) =
    88 fun value ctxt (get, put, put_ml) (prelude, value) =
    89   let
    89   let
    90     val code = (prelude
    90     val code = (prelude
   507     val _ = Theory.setup (Loaded_Values.map (insert (op =) string));
   507     val _ = Theory.setup (Loaded_Values.map (insert (op =) string));
   508   in () end;
   508   in () end;
   509 
   509 
   510 fun abort _ = error "Only value bindings allowed.";
   510 fun abort _ = error "Only value bindings allowed.";
   511 
   511 
   512 val notifying_context : use_context =
   512 val notifying_context : ML_Compiler0.context =
   513  {name_space =
   513  {name_space =
   514    {lookupVal    = #lookupVal ML_Env.local_name_space,
   514    {lookupVal    = #lookupVal ML_Env.local_name_space,
   515     lookupType   = #lookupType ML_Env.local_name_space,
   515     lookupType   = #lookupType ML_Env.local_name_space,
   516     lookupFix    = #lookupFix ML_Env.local_name_space,
   516     lookupFix    = #lookupFix ML_Env.local_name_space,
   517     lookupStruct = #lookupStruct ML_Env.local_name_space,
   517     lookupStruct = #lookupStruct ML_Env.local_name_space,
   538 fun use_file filepath thy =
   538 fun use_file filepath thy =
   539   let
   539   let
   540     val thy' = Loaded_Values.put [] thy;
   540     val thy' = Loaded_Values.put [] thy;
   541     val _ = Context.set_thread_data ((SOME o Context.Theory) thy');
   541     val _ = Context.set_thread_data ((SOME o Context.Theory) thy');
   542     val _ =
   542     val _ =
   543       use_text notifying_context
   543       ML_Compiler0.use_text notifying_context
   544         {line = 0, file = Path.implode filepath, verbose = false, debug = false}
   544         {line = 0, file = Path.implode filepath, verbose = false, debug = false}
   545         (File.read filepath);
   545         (File.read filepath);
   546     val thy'' = Context.the_theory (Context.the_thread_data ());
   546     val thy'' = Context.the_theory (Context.the_thread_data ());
   547     val names = Loaded_Values.get thy'';
   547     val names = Loaded_Values.get thy'';
   548   in (names, thy'') end;
   548   in (names, thy'') end;