Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing parsing_data in the unsafe_raw_read_checked_file #3018

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
With @bollu, exposing parsing_data in the unsafe_raw_read_checked_fil…
…e, so that we can reconstruct friend dependences in a standalone tool
  • Loading branch information
nikswamy committed Aug 10, 2023
commit 8290b5e85ba0815a1f161b9c0ae1208a802f8453
5 changes: 3 additions & 2 deletions ocaml/fstar-lib/generated/FStar_CheckedFiles.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 34 additions & 22 deletions ocaml/fstar-lib/generated/FStar_Parser_Dep.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/fstar/FStar.CheckedFiles.fst
Original file line number Diff line number Diff line change
@@ -472,8 +472,7 @@ let store_module_to_cache env fn parsing_data tc_result =
end

let unsafe_raw_load_checked_file (checked_fn:string)
: option (list string & tc_result)
= let entry : option (checked_file_entry_stage1 * checked_file_entry_stage2) = BU.load_2values_from_file checked_fn in
match entry with
| Some ((s1,s2)) -> Some (List.map fst s2.deps_dig, s2.tc_res)
| Some ((s1,s2)) -> Some (s1.parsing_data, List.map fst s2.deps_dig, s2.tc_res)
| _ -> None
2 changes: 1 addition & 1 deletion src/fstar/FStar.CheckedFiles.fsti
Original file line number Diff line number Diff line change
@@ -58,4 +58,4 @@ val load_module_from_cache: (uenv -> string -> option tc_result)
val store_module_to_cache: uenv -> file_name:string -> Dep.parsing_data -> tc_result -> unit

val unsafe_raw_load_checked_file (checked_file_name:string)
: option (list string & tc_result)
: option (FStar.Parser.Dep.parsing_data & list string & tc_result)
13 changes: 11 additions & 2 deletions src/parser/FStar.Parser.Dep.fst
Original file line number Diff line number Diff line change
@@ -190,6 +190,15 @@ let str_of_parsing_data = function
| Mk_pd l ->
l |> List.fold_left (fun s elt -> s ^ "; " ^ (elt |> str_of_parsing_data_elt)) ""

let friends (p:parsing_data) : list lident =
let Mk_pd p = p in
List.collect
(function
| P_dep (true, l) -> [l]
| _ -> [])
p


let parsing_data_elt_eq (e1:parsing_data_elt) (e2:parsing_data_elt) =
match e1, e2 with
| P_begin_module l1, P_begin_module l2 -> lid_equals l1 l2
@@ -751,9 +760,9 @@ let collect_one
let data_from_cache = filename |> get_parsing_data_from_cache in

if data_from_cache |> is_some then begin //we found the parsing data in the checked file
if Options.debug_at_level_no_module (Options.Other "Dep") then
BU.print1 "Reading the parsing data for %s from its checked file\n" filename;
let deps, has_inline_for_extraction, mo_roots = from_parsing_data (data_from_cache |> must) original_map filename in
if Options.debug_at_level_no_module (Options.Other "Dep") then
BU.print2 "Reading the parsing data for %s from its checked file .. found [%s]\n" filename (List.map dep_to_string deps |> String.concat ", ");
data_from_cache |> must,
deps, has_inline_for_extraction, mo_roots
end
4 changes: 2 additions & 2 deletions src/parser/FStar.Parser.Dep.fsti
Original file line number Diff line number Diff line change
@@ -44,9 +44,9 @@ val is_interface: string -> bool
val is_implementation: string -> bool

val parsing_data : Type0 //cached in the checked files

val str_of_parsing_data (p:parsing_data) : string
val empty_parsing_data: parsing_data //for legacy ide

val friends (p:parsing_data) : list lident
val deps : Type0

val empty_deps : deps