From a0cfa4f118023d35b767a999d5a2ac4b082857b4 Mon Sep 17 00:00:00 2001 From: Samuel Mimram Date: Fri, 25 Jul 2008 15:12:53 +0200 Subject: Imported Upstream version 8.2~beta3+dfsg --- kernel/retroknowledge.ml | 279 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 kernel/retroknowledge.ml (limited to 'kernel/retroknowledge.ml') diff --git a/kernel/retroknowledge.ml b/kernel/retroknowledge.ml new file mode 100644 index 00000000..7a1880be --- /dev/null +++ b/kernel/retroknowledge.ml @@ -0,0 +1,279 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* continuation -> result *) + (bool->Cbytecodes.comp_env->constr array -> + int->Cbytecodes.bytecodes->Cbytecodes.bytecodes) + option; + vm_constant_static : + (*fastcomputation flag -> constructor -> args -> result*) + (bool->constr array->Cbytecodes.structured_constant) + option; + vm_constant_dynamic : + (*fastcomputation flag -> constructor -> reloc -> args -> sz -> cont -> result *) + (bool->Cbytecodes.comp_env->Cbytecodes.block array->int-> + Cbytecodes.bytecodes->Cbytecodes.bytecodes) + option; + (* fastcomputation flag -> cont -> result *) + vm_before_match : (bool -> Cbytecodes.bytecodes -> Cbytecodes.bytecodes) option; + (* tag (= compiled int for instance) -> result *) + vm_decompile_const : (int -> Term.constr) option} + + + +and reactive = reactive_end Reactive.t + +and retroknowledge = {flags : flags; proactive : proactive; reactive : reactive} + +(* This type represent an atomic action of the retroknowledge. It + is stored in the compiled libraries *) +(* As per now, there is only the possibility of registering things + the possibility of unregistering or changing the flag is under study *) +type action = + | RKRegister of field*entry + + +(*initialisation*) +let initial_flags = + {fastcomputation = true;} + +let initial_proactive = + (Proactive.empty:proactive) + +let initial_reactive = + (Reactive.empty:reactive) + +let initial_retroknowledge = + {flags = initial_flags; + proactive = initial_proactive; + reactive = initial_reactive } + +let empty_reactive_end = + { vm_compiling = None ; + vm_constant_static = None; + vm_constant_dynamic = None; + vm_before_match = None; + vm_decompile_const = None } + + + + +(* acces functions for proactive retroknowledge *) +let add_field knowledge field value = + {knowledge with proactive = Proactive.add field value knowledge.proactive} + +let mem knowledge field = + Proactive.mem field knowledge.proactive + +let remove knowledge field = + {knowledge with proactive = Proactive.remove field knowledge.proactive} + +let find knowledge field = + Proactive.find field knowledge.proactive + + + + + +(*access functions for reactive retroknowledge*) + +(* used for compiling of functions (add, mult, etc..) *) +let get_vm_compiling_info knowledge key = + match (Reactive.find key knowledge.reactive).vm_compiling + with + | None -> raise Not_found + | Some f -> f knowledge.flags.fastcomputation + +(* used for compilation of fully applied constructors *) +let get_vm_constant_static_info knowledge key = + match (Reactive.find key knowledge.reactive).vm_constant_static + with + | None -> raise Not_found + | Some f -> f knowledge.flags.fastcomputation + +(* used for compilation of partially applied constructors *) +let get_vm_constant_dynamic_info knowledge key = + match (Reactive.find key knowledge.reactive).vm_constant_dynamic + with + | None -> raise Not_found + | Some f -> f knowledge.flags.fastcomputation + +let get_vm_before_match_info knowledge key = + match (Reactive.find key knowledge.reactive).vm_before_match + with + | None -> raise Not_found + | Some f -> f knowledge.flags.fastcomputation + +let get_vm_decompile_constant_info knowledge key = + match (Reactive.find key knowledge.reactive).vm_decompile_const + with + | None -> raise Not_found + | Some f -> f + + + +(* functions manipulating reactive knowledge *) +let add_vm_compiling_info knowledge value nfo = + {knowledge with reactive = + try + Reactive.add value + {(Reactive.find value (knowledge.reactive)) with vm_compiling = Some nfo} + knowledge.reactive + with Not_found -> + Reactive.add value {empty_reactive_end with vm_compiling = Some nfo} + knowledge.reactive + } + +let add_vm_constant_static_info knowledge value nfo = + {knowledge with reactive = + try + Reactive.add value + {(Reactive.find value (knowledge.reactive)) with vm_constant_static = Some nfo} + knowledge.reactive + with Not_found -> + Reactive.add value {empty_reactive_end with vm_constant_static = Some nfo} + knowledge.reactive + } + +let add_vm_constant_dynamic_info knowledge value nfo = + {knowledge with reactive = + try + Reactive.add value + {(Reactive.find value (knowledge.reactive)) with vm_constant_dynamic = Some nfo} + knowledge.reactive + with Not_found -> + Reactive.add value {empty_reactive_end with vm_constant_dynamic = Some nfo} + knowledge.reactive + } + +let add_vm_before_match_info knowledge value nfo = + {knowledge with reactive = + try + Reactive.add value + {(Reactive.find value (knowledge.reactive)) with vm_before_match = Some nfo} + knowledge.reactive + with Not_found -> + Reactive.add value {empty_reactive_end with vm_before_match = Some nfo} + knowledge.reactive + } + +let add_vm_decompile_constant_info knowledge value nfo = + {knowledge with reactive = + try + Reactive.add value + {(Reactive.find value (knowledge.reactive)) with vm_decompile_const = Some nfo} + knowledge.reactive + with Not_found -> + Reactive.add value {empty_reactive_end with vm_decompile_const = Some nfo} + knowledge.reactive + } + +let clear_info knowledge value = + {knowledge with reactive = Reactive.remove value knowledge.reactive} -- cgit v1.2.3