diff options
author | 2013-06-21 21:04:00 +0000 | |
---|---|---|
committer | 2013-06-21 21:04:00 +0000 | |
commit | bd7da353ea503423206e329af7a56174cb39f435 (patch) | |
tree | 275cce39ed6fb899660155a43ab0987c4f83025b /tactics/geninterp.ml | |
parent | 9024a91b59b9ecfb94e68b3748f2a9a66adcf515 (diff) |
Splitted up Genarg in four different levels:
1. Genarg itself which only defines the abstract datatypes needed.
2. Genintern, first file of interp/, defining the intern and subst
functions.
3. Geninterp, first file of tactics/, defining the interp function.
4. Genprint, first file of printing/, dealing with the printers.
The Genarg file has no dependency and is in lib/, so that we can put
generic arguments everywhere, and in particular in ASTs.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16601 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'tactics/geninterp.ml')
-rw-r--r-- | tactics/geninterp.ml | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tactics/geninterp.ml b/tactics/geninterp.ml new file mode 100644 index 000000000..deba01536 --- /dev/null +++ b/tactics/geninterp.ml @@ -0,0 +1,53 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2012 *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +open Pp +open Util +open Names +open Genarg + +module TacStore = Store.Make(struct end) + +type interp_sign = { + lfun : (Id.t * tlevel generic_argument) list; + extra : TacStore.t } + +type ('glb, 'top) interp_fun = interp_sign -> + Goal.goal Evd.sigma -> 'glb -> Evd.evar_map * 'top + +let arg0_interp_map = + ref (String.Map.empty : (Obj.t, Obj.t) interp_fun String.Map.t) + +let get_interp0 name = + try String.Map.find name !arg0_interp_map + with Not_found -> + Errors.anomaly (str "interp0 function not found: " ++ str name) + +(** For now, the following functions are quite dummy and should only be applied + to an extra argument type, otherwise, they will badly fail. *) + +let rec obj_interp t = match t with +| ExtraArgType s -> get_interp0 s +| _ -> assert false + +let interp t = Obj.magic (obj_interp (unquote (rawwit t))) + +let generic_interp ist gl v = + let t = genarg_tag v in + let (sigma, ans) = obj_interp t ist gl (Unsafe.prj v) in + (sigma, Unsafe.inj t ans) + +(** Registering functions *) + +let register_interp0 arg f = match unquote (rawwit arg) with +| ExtraArgType s -> + if String.Map.mem s !arg0_interp_map then + Errors.anomaly (str "interp0 function already registered: " ++ str s) + else + arg0_interp_map := String.Map.add s (Obj.magic f) !arg0_interp_map +| _ -> assert false |