src/Tools/code/code_thingol.ML
changeset 24283 8ca96f4e49cd
parent 24252 4eb5bc6af008
child 24381 560e8ecdf633
equal deleted inserted replaced
24282:9b64aa297524 24283:8ca96f4e49cd
    74   val project_code: bool (*delete empty funs*)
    74   val project_code: bool (*delete empty funs*)
    75     -> string list (*hidden*) -> string list option (*selected*)
    75     -> string list (*hidden*) -> string list option (*selected*)
    76     -> code -> code;
    76     -> code -> code;
    77   val empty_funs: code -> string list;
    77   val empty_funs: code -> string list;
    78   val is_cons: code -> string -> bool;
    78   val is_cons: code -> string -> bool;
    79   val add_eval_def: string (*bind name*) * iterm -> code -> code;
    79   val add_eval_def: string (*bind name*) * (iterm * itype) -> code -> code;
    80 
    80 
    81   val ensure_def: (string -> string) -> (transact -> def * transact) -> string
    81   val ensure_def: (string -> string) -> (transact -> def * transact) -> string
    82     -> string -> transact -> transact;
    82     -> string -> transact -> transact;
    83   val start_transact: (transact -> 'a * transact) -> code -> 'a * code;
    83   val start_transact: (transact -> 'a * transact) -> code -> 'a * code;
    84 end;
    84 end;
   245   | Classinst of (class * (string * (vname * sort) list))
   245   | Classinst of (class * (string * (vname * sort) list))
   246         * ((class * (string * (string * dict list list))) list
   246         * ((class * (string * (string * dict list list))) list
   247       * (string * iterm) list);
   247       * (string * iterm) list);
   248 
   248 
   249 type code = def Graph.T;
   249 type code = def Graph.T;
   250 type transact = Graph.key option * code;
       
   251 
   250 
   252 
   251 
   253 (* abstract code *)
   252 (* abstract code *)
   254 
   253 
   255 val empty_code = Graph.empty : code; (*read: "depends on"*)
   254 val empty_code = Graph.empty : code; (*read: "depends on"*)
   370       I;
   369       I;
   371 
   370 
   372 
   371 
   373 (* transaction protocol *)
   372 (* transaction protocol *)
   374 
   373 
       
   374 type transact = Graph.key option * code;
       
   375 
   375 fun ensure_def labelled_name defgen msg name (dep, code) =
   376 fun ensure_def labelled_name defgen msg name (dep, code) =
   376   let
   377   let
   377     val msg' = (case dep
   378     val msg' = (case dep
   378      of NONE => msg
   379      of NONE => msg
   379       | SOME dep => msg ^ ", required for " ^ labelled_name dep);
   380       | SOME dep => msg ^ ", required for " ^ labelled_name dep);
   400 fun start_transact f code =
   401 fun start_transact f code =
   401   (NONE, code)
   402   (NONE, code)
   402   |> f
   403   |> f
   403   |-> (fn x => fn (_, code) => (x, code));
   404   |-> (fn x => fn (_, code) => (x, code));
   404 
   405 
   405 fun add_eval_def (name, t) code =
   406 fun add_eval_def (name, (t, ty)) code =
   406   code
   407   code
   407   |> Graph.new_node (name, Fun ([([], t)], ([("_", [])], ITyVar "_")))
   408   |> Graph.new_node (name, Fun ([([], t)], ([], ty)))
   408   |> fold (curry Graph.add_edge name) (Graph.keys code);
   409   |> fold (curry Graph.add_edge name) (Graph.keys code);
   409 
   410 
   410 end; (*struct*)
   411 end; (*struct*)
   411 
   412 
   412 
   413