src/Tools/Code/code_eval.ML
changeset 38921 15f8cffdbf5d
parent 38669 9ff76d0f0610
child 38922 ec2a8efd8990
equal deleted inserted replaced
38919:fd6b9bdb428e 38921:15f8cffdbf5d
    27   let
    27   let
    28     val (consts', (naming, program)) = Code_Thingol.consts_program thy false consts;
    28     val (consts', (naming, program)) = Code_Thingol.consts_program thy false consts;
    29     val tycos' = map (the o Code_Thingol.lookup_tyco naming) tycos;
    29     val tycos' = map (the o Code_Thingol.lookup_tyco naming) tycos;
    30     val struct_name = if struct_name_hint = "" then eval_struct_name
    30     val struct_name = if struct_name_hint = "" then eval_struct_name
    31       else struct_name_hint;
    31       else struct_name_hint;
    32     val (ml_code, target_names) = Code_ML.evaluation_code_of thy target
    32     val (ml_code, target_names) = Code_Target.produce_code_for thy
    33       struct_name naming program (consts' @ tycos');
    33       target NONE (SOME struct_name) [] naming program (consts' @ tycos', []);
    34     val (consts'', tycos'') = chop (length consts') target_names;
    34     val (consts'', tycos'') = chop (length consts') target_names;
    35     val consts_map = map2 (fn const => fn NONE =>
    35     val consts_map = map2 (fn const => fn NONE =>
    36         error ("Constant " ^ (quote o Code.string_of_const thy) const
    36         error ("Constant " ^ (quote o Code.string_of_const thy) const
    37           ^ "\nhas a user-defined serialization")
    37           ^ "\nhas a user-defined serialization")
    38       | SOME const'' => (const, const'')) consts consts''
    38       | SOME const'' => (const, const'')) consts consts''
    55         val value_name = "Value.VALUE.value"
    55         val value_name = "Value.VALUE.value"
    56         val program' = program
    56         val program' = program
    57           |> Graph.new_node (value_name,
    57           |> Graph.new_node (value_name,
    58               Code_Thingol.Fun (Term.dummy_patternN, ((([], ty), [(([], t), (NONE, true))]), NONE)))
    58               Code_Thingol.Fun (Term.dummy_patternN, ((([], ty), [(([], t), (NONE, true))]), NONE)))
    59           |> fold (curry Graph.add_edge value_name) deps;
    59           |> fold (curry Graph.add_edge value_name) deps;
    60         val (value_code, [SOME value_name']) = Code_ML.evaluation_code_of thy
    60         val (value_code, [SOME value_name']) = Code_Target.produce_code_for thy
    61           (the_default target some_target) "" naming program' [value_name];
    61           (the_default target some_target) NONE (SOME "") [] naming program ([value_name], []);
    62         val sml_code = "let\n" ^ value_code ^ "\nin " ^ value_name'
    62         val sml_code = "let\n" ^ value_code ^ "\nin " ^ value_name'
    63           ^ space_implode " " (map (enclose "(" ")") args) ^ " end";
    63           ^ space_implode " " (map (enclose "(" ")") args) ^ " end";
    64       in ML_Context.evaluate ctxt false reff sml_code end;
    64       in ML_Context.evaluate ctxt false reff sml_code end;
    65   in Code_Thingol.dynamic_eval_value thy postproc evaluator t end;
    65   in Code_Thingol.dynamic_eval_value thy postproc evaluator t end;
    66 
    66