aboutsummaryrefslogtreecommitdiff
path: root/stm
diff options
context:
space:
mode:
authorGaëtan Gilbert2018-11-13 22:51:29 +0100
committerGaëtan Gilbert2018-11-15 15:46:29 +0100
commite47ef6323e7ce4c00ae38a23ed5542059abbda6e (patch)
tree906b00a6e8933cdeec897a8ff03c675e87a3d6bc /stm
parentb6f65c72cce697d7acc11f731983a8c18f497d10 (diff)
coqide: use correct toplevel name in files
Fix #8989. This adds an option -topfile taking a path so that inferring the right dirpath is done by the toplevel after processing -Q/-R instead of the client having to do it.
Diffstat (limited to 'stm')
-rw-r--r--stm/stm.ml20
-rw-r--r--stm/stm.mli4
2 files changed, 18 insertions, 6 deletions
diff --git a/stm/stm.ml b/stm/stm.ml
index 514b364af3..9a2beca0ce 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -308,11 +308,13 @@ end (* }}} *)
(*************************** THE DOCUMENT *************************************)
(******************************************************************************)
+type interactive_top = TopLogical of DirPath.t | TopPhysical of string
+
(* The main document type associated to a VCS *)
type stm_doc_type =
| VoDoc of string
| VioDoc of string
- | Interactive of Names.DirPath.t
+ | Interactive of interactive_top
(* Dummy until we land the functional interp patch + fixed start_library *)
type doc = int
@@ -522,7 +524,7 @@ end = struct (* {{{ *)
type vcs = (branch_type, transaction, vcs state_info, box) t
let vcs : vcs ref = ref (empty Stateid.dummy)
- let doc_type = ref (Interactive (Names.DirPath.make []))
+ let doc_type = ref (Interactive (TopLogical (Names.DirPath.make [])))
let ldir = ref Names.DirPath.empty
let init dt id =
@@ -2609,9 +2611,17 @@ let new_doc { doc_type ; iload_path; require_libs; stm_options } =
List.iter Mltop.add_coq_path iload_path;
begin match doc_type with
- | Interactive ln ->
- Safe_typing.allow_delayed_constants := true;
- Declaremods.start_library ln
+ | Interactive ln ->
+ let dp = match ln with
+ | TopLogical dp -> dp
+ | TopPhysical f ->
+ let base = try Loadpath.logical (Loadpath.find_load_path (Filename.dirname f))
+ with Not_found -> Libnames.default_root_prefix
+ in
+ Libnames.add_dirpath_suffix base (Id.of_string Filename.(chop_extension (basename f)))
+ in
+ Safe_typing.allow_delayed_constants := true;
+ Declaremods.start_library dp
| VoDoc ln ->
let ldir = Flags.verbosely Library.start_library ln in
diff --git a/stm/stm.mli b/stm/stm.mli
index 1e5ceb7e23..95117f04f4 100644
--- a/stm/stm.mli
+++ b/stm/stm.mli
@@ -39,13 +39,15 @@ module AsyncOpts : sig
end
+type interactive_top = TopLogical of DirPath.t | TopPhysical of string
+
(** The STM document type [stm_doc_type] determines some properties
such as what uncompleted proofs are allowed and what gets recorded
to aux files. *)
type stm_doc_type =
| VoDoc of string (* file path *)
| VioDoc of string (* file path *)
- | Interactive of DirPath.t (* module path *)
+ | Interactive of interactive_top (* module path *)
(** Coq initalization options: