src/Pure/Tools/codegen_thingol.ML
changeset 20216 f30b73385060
parent 20192 956cd30ef3be
child 20353 d73e49780ef2
equal deleted inserted replaced
20215:96a4b3b7a6aa 20216:f30b73385060
    86   val get_def: module -> string -> def;
    86   val get_def: module -> string -> def;
    87   val merge_module: module * module -> module;
    87   val merge_module: module * module -> module;
    88   val diff_module: module * module -> (string * def) list;
    88   val diff_module: module * module -> (string * def) list;
    89   val project_module: string list -> module -> module;
    89   val project_module: string list -> module -> module;
    90   val purge_module: string list -> module -> module;
    90   val purge_module: string list -> module -> module;
    91   val add_eval_def: iterm -> module -> string * module;
    91   val add_eval_def: string (*shallow name space*) * iterm -> module -> string * module;
    92   val delete_garbage: string list (*hidden definitions*) -> module -> module;
    92   val delete_garbage: string list (*hidden definitions*) -> module -> module;
    93   val has_nsp: string -> string -> bool;
    93   val has_nsp: string -> string -> bool;
    94   val ensure_def: (string -> transact -> def transact_fin) -> bool -> string
    94   val ensure_def: (string -> transact -> def transact_fin) -> bool -> string
    95     -> string -> transact -> transact;
    95     -> string -> transact -> transact;
    96   val succeed: 'a -> transact -> 'a transact_fin;
    96   val succeed: 'a -> transact -> 'a transact_fin;
   831     val _ = (writeln o cat_lines o map (fn (x, y) => x ^ " -> " ^ y)) adddeps;*)
   831     val _ = (writeln o cat_lines o map (fn (x, y) => x ^ " -> " ^ y)) adddeps;*)
   832   in
   832   in
   833     empty_module
   833     empty_module
   834     |> fold (fn name => add_def (name, get_def modl name)) selected
   834     |> fold (fn name => add_def (name, get_def modl name)) selected
   835 (*     |> fold ensure_bot (hidden @ bots')  *)
   835 (*     |> fold ensure_bot (hidden @ bots')  *)
   836     |> fold (fn (x, y) => (writeln ("adding " ^ x ^ " -> " ^ y); add_dep (x, y))) adddeps
   836     |> fold (fn (x, y) => ((*writeln ("adding " ^ x ^ " -> " ^ y);*) add_dep (x, y))) adddeps
   837   end;
   837   end;
   838 
   838 
   839 fun allimports_of modl =
   839 fun allimports_of modl =
   840   let
   840   let
   841     fun imps_of prfx (Module modl) imps tab =
   841     fun imps_of prfx (Module modl) imps tab =
  1026     |> pair init
  1026     |> pair init
  1027     |> handle_fail f
  1027     |> handle_fail f
  1028     |-> (fn x => fn (_, modl) => (x, modl))
  1028     |-> (fn x => fn (_, modl) => (x, modl))
  1029   end;
  1029   end;
  1030 
  1030 
  1031 fun add_eval_def e modl =
  1031 fun add_eval_def (shallow, e) modl =
  1032   let
  1032   let
  1033     val name = hd (Name.invent_list (Graph.keys modl) "VALUE" 1);
  1033     val name = "VALUE";
       
  1034     val sname = NameSpace.pack [shallow, name];
  1034   in
  1035   in
  1035     modl
  1036     modl
  1036     |> add_def (name, Fun ([([], e)], ([], "" `%% [])))
  1037     |> add_def (sname, Fun ([([], e)], ([("a", [])], ITyVar "a")))
  1037     |> fold (curry add_dep name) (add_deps_of_term e [])
  1038     |> fold (curry add_dep sname) (add_deps_of_term e [])
  1038     |> pair name
  1039     |> pair name
  1039   end;
  1040   end;
  1040 
  1041 
  1041 
  1042 
  1042 (** generic serialization **)
  1043 (** generic serialization **)