src/Tools/Code/code_target.ML
changeset 55684 ee49b4f7edc8
parent 55683 5732a55b9232
child 55757 9fc71814b8c1
equal deleted inserted replaced
55683:5732a55b9232 55684:ee49b4f7edc8
    27   val check_code: theory -> bool -> string list
    27   val check_code: theory -> bool -> string list
    28     -> ((string * bool) * Token.T list) list -> unit
    28     -> ((string * bool) * Token.T list) list -> unit
    29 
    29 
    30   val generatedN: string
    30   val generatedN: string
    31   val evaluator: theory -> string -> Code_Thingol.program
    31   val evaluator: theory -> string -> Code_Thingol.program
    32     -> Code_Symbol.T list -> ((string * class list) list * Code_Thingol.itype) * Code_Thingol.iterm
    32     -> Code_Symbol.T list -> bool -> ((string * class list) list * Code_Thingol.itype) * Code_Thingol.iterm
    33     -> (string * string) list * string
    33     -> (string * string) list * string
    34 
    34 
    35   type serializer
    35   type serializer
    36   type literals = Code_Printer.literals
    36   type literals = Code_Printer.literals
    37   val add_target: string * { serializer: serializer, literals: literals,
    37   val add_target: string * { serializer: serializer, literals: literals,
   424       then error (env_var ^ " not set; cannot check code for " ^ target)
   424       then error (env_var ^ " not set; cannot check code for " ^ target)
   425       else warning (env_var ^ " not set; skipped checking code for " ^ target)
   425       else warning (env_var ^ " not set; skipped checking code for " ^ target)
   426     else Isabelle_System.with_tmp_dir "Code_Test" ext_check
   426     else Isabelle_System.with_tmp_dir "Code_Test" ext_check
   427   end;
   427   end;
   428 
   428 
   429 fun evaluation mounted_serializer prepared_program syms ((vs, ty), t) =
   429 fun evaluation mounted_serializer prepared_program syms all_public ((vs, ty), t) =
   430   let
   430   let
   431     val _ = if Code_Thingol.contains_dict_var t then
   431     val _ = if Code_Thingol.contains_dict_var t then
   432       error "Term to be evaluated contains free dictionaries" else ();
   432       error "Term to be evaluated contains free dictionaries" else ();
   433     val v' = singleton (Name.variant_list (map fst vs)) "a";
   433     val v' = singleton (Name.variant_list (map fst vs)) "a";
   434     val vs' = (v', []) :: vs;
   434     val vs' = (v', []) :: vs;
   437       |> Code_Symbol.Graph.new_node (Code_Symbol.value,
   437       |> Code_Symbol.Graph.new_node (Code_Symbol.value,
   438           Code_Thingol.Fun (((vs', ty'), [(([IVar NONE], t), (NONE, true))]), NONE))
   438           Code_Thingol.Fun (((vs', ty'), [(([IVar NONE], t), (NONE, true))]), NONE))
   439       |> fold (curry (perhaps o try o
   439       |> fold (curry (perhaps o try o
   440           Code_Symbol.Graph.add_edge) Code_Symbol.value) syms;
   440           Code_Symbol.Graph.add_edge) Code_Symbol.value) syms;
   441     val (program_code, deresolve) =
   441     val (program_code, deresolve) =
   442       produce (mounted_serializer program [Code_Symbol.value]);
   442       produce (mounted_serializer program (if all_public then [] else [Code_Symbol.value]));
   443     val value_name = the (deresolve Code_Symbol.value);
   443     val value_name = the (deresolve Code_Symbol.value);
   444   in (program_code, value_name) end;
   444   in (program_code, value_name) end;
   445 
   445 
   446 fun evaluator thy target program syms =
   446 fun evaluator thy target program syms =
   447   let
   447   let