src/Pure/Thy/thy_info.ML
changeset 22086 cf6019fece63
parent 21858 05f57309170c
child 22095 07875394618e
equal deleted inserted replaced
22085:c138cfd500f7 22086:cf6019fece63
   259         " on file: " ^ quote (Path.implode path));
   259         " on file: " ^ quote (Path.implode path));
   260       SOME (make_deps present outdated master (AList.update (op =) (path, SOME info) files)))
   260       SOME (make_deps present outdated master (AList.update (op =) (path, SOME info) files)))
   261   | provide _ _ _ NONE = NONE;
   261   | provide _ _ _ NONE = NONE;
   262 
   262 
   263 fun run_file path =
   263 fun run_file path =
   264   (case Option.map Context.theory_name (Context.get_context ()) of
   264   (case Option.map (Context.theory_name o Context.the_theory) (Context.get_context ()) of
   265     NONE => (ThyLoad.load_file NONE path; ())
   265     NONE => (ThyLoad.load_file NONE path; ())
   266   | SOME name => (case lookup_deps name of
   266   | SOME name => (case lookup_deps name of
   267       SOME deps => change_deps name (provide path name
   267       SOME deps => change_deps name (provide path name
   268         (ThyLoad.load_file (opt_path' deps) path))
   268         (ThyLoad.load_file (opt_path' deps) path))
   269     | NONE => (ThyLoad.load_file NONE path; ())));
   269     | NONE => (ThyLoad.load_file NONE path; ())));
   380       in (visited', (result, name)) end
   380       in (visited', (result, name)) end
   381   end;
   381   end;
   382 
   382 
   383 fun gen_use_thy' req prfx s = Output.toplevel_errors (fn () =>
   383 fun gen_use_thy' req prfx s = Output.toplevel_errors (fn () =>
   384   let val (_, (_, name)) = req [] prfx ([], s)
   384   let val (_, (_, name)) = req [] prfx ([], s)
   385   in Context.context (get_theory name) end) ();
   385   in Context.set_context (SOME (Context.Theory (get_theory name))) end) ();
   386 
   386 
   387 fun gen_use_thy req = gen_use_thy' req Path.current;
   387 fun gen_use_thy req = gen_use_thy' req Path.current;
   388 
   388 
   389 fun warn_finished f name = (check_unfinished warning name; f name);
   389 fun warn_finished f name = (check_unfinished warning name; f name);
   390 
   390 
   442     val uses_now = map_filter (fn (x, true) => SOME x | _ => NONE) uses;
   442     val uses_now = map_filter (fn (x, true) => SOME x | _ => NONE) uses;
   443 
   443 
   444     val _ = change_thys (update_node name bparents (deps, SOME (Theory.copy theory)));
   444     val _ = change_thys (update_node name bparents (deps, SOME (Theory.copy theory)));
   445     val theory' = theory |> present dir' name bparents uses;
   445     val theory' = theory |> present dir' name bparents uses;
   446     val _ = put_theory name (Theory.copy theory');
   446     val _ = put_theory name (Theory.copy theory');
   447     val ((), theory'') = Context.pass_theory theory' (List.app (load_file false)) uses_now;
   447     val ((), theory'') =
       
   448       Context.pass_context (Context.Theory theory') (List.app (load_file false)) uses_now
       
   449       ||> Context.the_theory;
   448     val _ = put_theory name (Theory.copy theory'');
   450     val _ = put_theory name (Theory.copy theory'');
   449   in theory'' end;
   451   in theory'' end;
   450 
   452 
   451 fun end_theory theory =
   453 fun end_theory theory =
   452   let
   454   let