src/Pure/Thy/thy_info.ML
changeset 8805 e1c36f2c02c0
parent 7952 43d3e087688c
child 8999 ad8260dc6e4a
equal deleted inserted replaced
8804:de0e9f689c6e 8805:e1c36f2c02c0
     1 (*  Title:      Pure/Thy/thy_info.ML
     1 (*  Title:      Pure/Thy/thy_info.ML
     2     ID:         $Id$
     2     ID:         $Id$
     3     Author:     Markus Wenzel, TU Muenchen
     3     Author:     Markus Wenzel, TU Muenchen
       
     4     License:    GPL (GNU GENERAL PUBLIC LICENSE)
     4 
     5 
     5 Theory loader database, including theory and file dependencies.
     6 Theory loader database, including theory and file dependencies.
     6 *)
     7 *)
     7 
     8 
     8 signature BASIC_THY_INFO =
     9 signature BASIC_THY_INFO =
    38   val touch_child_thys: string -> unit
    39   val touch_child_thys: string -> unit
    39   val touch_all_thys: unit -> unit
    40   val touch_all_thys: unit -> unit
    40   val load_file: bool -> Path.T -> unit
    41   val load_file: bool -> Path.T -> unit
    41   val use: string -> unit
    42   val use: string -> unit
    42   val quiet_update_thy: bool -> string -> unit
    43   val quiet_update_thy: bool -> string -> unit
    43   val begin_theory: string -> string list -> (Path.T * bool) list -> theory
    44   val begin_theory: (string -> string list -> (Path.T * bool) list -> theory -> theory) ->
    44   val begin_update_theory: string -> string list -> (Path.T * bool) list -> theory
    45     bool -> string -> string list -> (Path.T * bool) list -> theory
    45   val end_theory: theory -> theory
    46   val end_theory: theory -> theory
    46   val finish: unit -> unit
    47   val finish: unit -> unit
    47   val register_theory: theory -> unit
    48   val register_theory: theory -> unit
    48 end;
    49 end;
    49 
    50 
   368     end;
   369     end;
   369 
   370 
   370 
   371 
   371 (* begin / end theory *)
   372 (* begin / end theory *)
   372 
   373 
   373 fun gen_begin_theory assert_thy name parents paths =
   374 fun begin_theory present upd name parents paths =
   374   let
   375   let
       
   376     val assert_thy = if upd then quiet_update_thy true else weak_use_thy;
   375     val _ = check_unfinished error name;
   377     val _ = check_unfinished error name;
   376     val _ = (map Path.basic parents; seq assert_thy parents);
   378     val _ = (map Path.basic parents; seq assert_thy parents);
   377     val theory = PureThy.begin_theory name (map get_theory parents);
   379     val theory = PureThy.begin_theory name (map get_theory parents);
   378     val deps =
   380     val deps =
   379       if known_thy name then get_deps name
   381       if known_thy name then get_deps name
   380       else (init_deps None (map #1 paths));   (*records additional ML files only!*)
   382       else (init_deps None (map #1 paths));   (*records additional ML files only!*)
   381     val _ = change_thys (update_node name parents (deps, Some theory));
   383     val _ = change_thys (update_node name parents (deps, Some theory));
   382     val use_paths = mapfilter (fn (x, true) => Some x | _ => None) paths;
   384     val use_paths = mapfilter (fn (x, true) => Some x | _ => None) paths;
   383   in Context.setmp (Some theory) (seq (load_file false)) use_paths; theory end;
   385     val theory' = theory |> present name parents paths;
   384 
   386     val ((), theory'') = Context.pass_theory theory' (seq (load_file false)) use_paths;
   385 val begin_theory = gen_begin_theory weak_use_thy;
   387   in theory'' end;
   386 val begin_update_theory = gen_begin_theory (quiet_update_thy true);
       
   387 
   388 
   388 fun end_theory theory =
   389 fun end_theory theory =
   389   let
   390   let
   390     val theory' = PureThy.end_theory theory;
   391     val theory' = PureThy.end_theory theory;
   391     val name = PureThy.get_name theory;
   392     val name = PureThy.get_name theory;