diff options
| author | notin | 2008-07-24 11:16:48 +0000 |
|---|---|---|
| committer | notin | 2008-07-24 11:16:48 +0000 |
| commit | 417653e0119f8b7479d9a52725c4cb32b3d4af14 (patch) | |
| tree | 1d33265784b3cb1365ef706143d9207ed114e7a5 /interp | |
| parent | 80921b2f279b70f60cb66684f88c7e6f180f8117 (diff) | |
Suite commit 11236
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@11252 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'interp')
| -rw-r--r-- | interp/constrintern.ml | 16 | ||||
| -rw-r--r-- | interp/dumpglob.ml | 92 | ||||
| -rw-r--r-- | interp/dumpglob.mli | 43 |
3 files changed, 91 insertions, 60 deletions
diff --git a/interp/constrintern.ml b/interp/constrintern.ml index fccfb1bf35..26ed023798 100644 --- a/interp/constrintern.ml +++ b/interp/constrintern.ml @@ -252,7 +252,7 @@ let rec subst_aconstr_in_rawconstr loc interp subst (renaming,(ids,_,scopes)) = let intern_notation intern (_,tmp_scope,scopes as env) loc ntn args = let ntn,args = contract_notation ntn args in let ((ids,c),df) = Notation.interp_notation loc ntn (tmp_scope,scopes) in - if Dumpglob.dump () then Dumpglob.dump_notation_location (Topconstr.ntn_loc loc args ntn) df; + Dumpglob.dump_notation_location (Topconstr.ntn_loc loc args ntn) df; let subst = List.map2 (fun (id,scl) a -> (id,(a,scl))) ids args in subst_aconstr_in_rawconstr loc intern subst ([],env) c @@ -334,10 +334,10 @@ let check_no_explicitation l = let intern_qualid loc qid intern env args = try match Nametab.extended_locate qid with | TrueGlobal ref -> - if Dumpglob.dump() then Dumpglob.add_glob loc ref; + Dumpglob.add_glob loc ref; RRef (loc, ref), args | SyntacticDef sp -> - if Dumpglob.dump() then Dumpglob.add_glob_kn loc sp; + Dumpglob.add_glob_kn loc sp; let (ids,c) = Syntax_def.search_syntactic_definition loc sp in let nids = List.length ids in if List.length args < nids then error_not_enough_arguments loc; @@ -567,7 +567,7 @@ let find_constructor ref f aliases pats scopes = let v = Environ.constant_value (Global.env()) cst in unf (global_of_constr v) | ConstructRef cstr -> - if Dumpglob.dump() then Dumpglob.add_glob loc r; + Dumpglob.add_glob loc r; cstr, [], pats | _ -> raise Not_found in unf r @@ -618,7 +618,7 @@ let rec intern_cases_pattern genv scopes (ids,subst as aliases) tmp_scope pat = | CPatNotation (loc, ntn, args) -> let ntn,args = contract_pat_notation ntn args in let ((ids',c),df) = Notation.interp_notation loc ntn (tmp_scope,scopes) in - if Dumpglob.dump () then Dumpglob.dump_notation_location (Topconstr.patntn_loc loc args ntn) df; + Dumpglob.dump_notation_location (Topconstr.patntn_loc loc args ntn) df; let subst = List.map2 (fun (id,scl) a -> (id,(a,scl))) ids' args in let ids'',pl = subst_cases_pattern loc (alias_of aliases) intern_pat subst scopes c @@ -627,7 +627,7 @@ let rec intern_cases_pattern genv scopes (ids,subst as aliases) tmp_scope pat = let a = alias_of aliases in let (c,df) = Notation.interp_prim_token_cases_pattern loc p a (tmp_scope,scopes) in - if Dumpglob.dump () then Dumpglob.dump_notation_location (fst (unloc loc)) df; + Dumpglob.dump_notation_location (fst (unloc loc)) df; (ids,[subst,c]) | CPatDelimiters (loc, key, e) -> intern_pat (find_delimiters_scope loc key::scopes) aliases None e @@ -687,7 +687,7 @@ let push_loc_name_env lvar (ids,tmpsc,scopes as env) loc = function | Anonymous -> env | Name id -> check_hidden_implicit_parameters id lvar; - if Dumpglob.dump() then Dumpglob.dump_binding loc id; + Dumpglob.dump_binding loc id; (Idset.add id ids,tmpsc,scopes) let intern_typeclass_binders intern_type lvar env bl = @@ -887,7 +887,7 @@ let internalise sigma globalenv env allow_patvar lvar c = intern_notation intern env loc ntn args | CPrim (loc, p) -> let c,df = Notation.interp_prim_token loc p (tmp_scope,scopes) in - if Dumpglob.dump () then Dumpglob.dump_notation_location (fst (unloc loc)) df; + Dumpglob.dump_notation_location (fst (unloc loc)) df; c | CDelimiters (loc, key, e) -> intern (ids,None,find_delimiters_scope loc key::scopes) e diff --git a/interp/dumpglob.ml b/interp/dumpglob.ml index a8f4b31d2d..0035b3f071 100644 --- a/interp/dumpglob.ml +++ b/interp/dumpglob.ml @@ -9,8 +9,6 @@ (* $Id$ *) -let rec drop_last = function [] -> assert false | hd :: [] -> [] | hd :: tl -> hd :: drop_last tl - (* Dump of globalization (to be used by coqdoc) *) let glob_file = ref Pervasives.stdout @@ -130,16 +128,17 @@ let dump_ref loc filepath modpath ident ty = (fst (Util.unloc loc)) filepath modpath ident ty) let add_glob_gen loc sp lib_dp ty = - let mod_dp,id = Libnames.repr_path sp in - let mod_dp = remove_sections mod_dp in - let mod_dp_trunc = Libnames.drop_dirpath_prefix lib_dp mod_dp in - let filepath = Names.string_of_dirpath lib_dp in - let modpath = Names.string_of_dirpath mod_dp_trunc in - let ident = Names.string_of_id id in - dump_ref loc filepath modpath ident ty + if dump () then + let mod_dp,id = Libnames.repr_path sp in + let mod_dp = remove_sections mod_dp in + let mod_dp_trunc = Libnames.drop_dirpath_prefix lib_dp mod_dp in + let filepath = Names.string_of_dirpath lib_dp in + let modpath = Names.string_of_dirpath mod_dp_trunc in + let ident = Names.string_of_id id in + dump_ref loc filepath modpath ident ty let add_glob loc ref = - if loc <> Util.dummy_loc then + if dump () && loc <> Util.dummy_loc then let sp = Nametab.sp_of_global ref in let lib_dp = Lib.library_part ref in let ty = type_of_global_ref ref in @@ -150,7 +149,7 @@ let mp_of_kn kn = Names.MPdot (mp,l) let add_glob_kn loc kn = - if loc <> Util.dummy_loc then + if dump () && loc <> Util.dummy_loc then let sp = Nametab.sp_of_syntactic_definition kn in let lib_dp = Lib.dp_of_mp (mp_of_kn kn) in add_glob_gen loc sp lib_dp "syndef" @@ -167,21 +166,6 @@ let add_local loc id = () let dump_binding loc id = () -(* BEGIN obsolete *) - -let dump_modref qid = Pp.warning ("Dumpglob.modref: not yet implemented") - -let dump_def loc ref = - let curr_mp, _ = Lib.current_prefix() in - let lib_dp, curr_dp = Lib.split_mp curr_mp in - let mod_dp_trunc = Libnames.drop_dirpath_prefix lib_dp curr_dp in - - let fullname = Libnames.string_of_qualid (Libnames.make_qualid mod_dp_trunc ref) in - let filepath = Names.string_of_dirpath lib_dp in - dump_string (Printf.sprintf "D%d %s %s\n" (fst (Util.unloc loc)) filepath fullname) - -(* END obsolete *) - let dump_definition (loc, id) sec s = dump_string (Printf.sprintf "%s %d %s %s\n" s (fst (Util.unloc loc)) (Names.string_of_dirpath (Lib.current_dirpath sec)) (Names.string_of_id id)) @@ -197,43 +181,47 @@ let dump_constraint ((loc, n), _, _) sec ty = let dump_name (loc, n) sec ty = match n with - | Names.Name id -> dump_definition (loc, id) sec ty - | Names.Anonymous -> () + | Names.Name id -> dump_definition (loc, id) sec ty + | Names.Anonymous -> () let dump_local_binder b sec ty = - match b with - | Topconstr.LocalRawAssum (nl, _, _) -> - List.iter (fun x -> dump_name x sec ty) nl - | Topconstr.LocalRawDef _ -> () + if dump () then + match b with + | Topconstr.LocalRawAssum (nl, _, _) -> + List.iter (fun x -> dump_name x sec ty) nl + | Topconstr.LocalRawDef _ -> () let dump_modref loc mp ty = - let (dp, l) = Lib.split_modpath mp in - let fp = Names.string_of_dirpath dp in - let mp = Names.string_of_dirpath (Names.make_dirpath (drop_last l)) in - dump_string (Printf.sprintf "R%d %s %s %s %s\n" - (fst (Util.unloc loc)) fp mp "<>" ty) + if dump () then + let (dp, l) = Lib.split_modpath mp in + let fp = Names.string_of_dirpath dp in + let mp = Names.string_of_dirpath (Names.make_dirpath (Util.list_drop_last l)) in + dump_string (Printf.sprintf "R%d %s %s %s %s\n" + (fst (Util.unloc loc)) fp mp "<>" ty) let dump_moddef loc mp ty = - let (dp, l) = Lib.split_modpath mp in - let mp = Names.string_of_dirpath (Names.make_dirpath l) in - dump_string (Printf.sprintf "%s %d %s %s\n" ty (fst (Util.unloc loc)) "<>" mp) + if dump () then + let (dp, l) = Lib.split_modpath mp in + let mp = Names.string_of_dirpath (Names.make_dirpath l) in + dump_string (Printf.sprintf "%s %d %s %s\n" ty (fst (Util.unloc loc)) "<>" mp) let dump_libref loc dp ty = dump_string (Printf.sprintf "R%d %s <> <> %s\n" (fst (Util.unloc loc)) (Names.string_of_dirpath dp) ty) let dump_notation_location pos ((path,df),sc) = - let rec next growing = - let loc = Lexer.location_function !token_number in - let (bp,_) = Util.unloc loc in - if growing then if bp >= pos then loc else (incr token_number; next true) - else if bp = pos then loc - else if bp > pos then (decr token_number;next false) - else (incr token_number;next true) in - let loc = next (pos >= !last_pos) in - last_pos := pos; - let path = Names.string_of_dirpath path in - let _sc = match sc with Some sc -> " "^sc | _ -> "" in - dump_string (Printf.sprintf "R%d %s \"%s\" not\n" (fst (Util.unloc loc)) path df) + if dump () then + let rec next growing = + let loc = Lexer.location_function !token_number in + let (bp,_) = Util.unloc loc in + if growing then if bp >= pos then loc else (incr token_number; next true) + else if bp = pos then loc + else if bp > pos then (decr token_number;next false) + else (incr token_number;next true) in + let loc = next (pos >= !last_pos) in + last_pos := pos; + let path = Names.string_of_dirpath path in + let _sc = match sc with Some sc -> " "^sc | _ -> "" in + dump_string (Printf.sprintf "R%d %s \"%s\" not\n" (fst (Util.unloc loc)) path df) diff --git a/interp/dumpglob.mli b/interp/dumpglob.mli new file mode 100644 index 0000000000..2f36c25c59 --- /dev/null +++ b/interp/dumpglob.mli @@ -0,0 +1,43 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +(* $Id$ *) + + +val open_glob_file : string -> unit +val close_glob_file : unit -> unit + +val dump : unit -> bool +val multi_dump : unit -> bool + +val noglob : unit -> unit +val dump_to_stdout : unit -> unit +val dump_into_file : string -> unit +val dump_to_dotglob : unit -> unit + +val pause : unit -> unit +val continue : unit -> unit + +val coqdoc_freeze : unit -> Lexer.location_table * int * int +val coqdoc_unfreeze : Lexer.location_table * int * int -> unit + +val add_glob : Util.loc -> Libnames.global_reference -> unit +val add_glob_kn : Util.loc -> Names.kernel_name -> unit + +val dump_definition : Util.loc * Names.identifier -> bool -> string -> unit +val dump_moddef : Util.loc -> Names.module_path -> string -> unit +val dump_modref : Util.loc -> Names.module_path -> string -> unit +val dump_reference : Util.loc -> string -> string -> string -> unit +val dump_libref : Util.loc -> Names.dir_path -> string -> unit +val dump_notation_location : int -> (Notation.notation_location * Topconstr.scope_name option) -> unit +val dump_binding : Util.loc -> Names.Idset.elt -> unit +val dump_constraint : Topconstr.typeclass_constraint -> bool -> string -> unit +val dump_local_binder : Topconstr.local_binder -> bool -> string -> unit + +val dump_string : string -> unit + |
