Skip to content

Commit bd9e500

Browse files
committed
fix file loading
1 parent a717e9e commit bd9e500

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

src/App.re

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ let init_goblint = (solver, spec, registered_name, config, cil) => {
8989
(goblint, cil);
9090
};
9191

92-
let init = (solver, spec, config, meta, cil, analyses, warnings, stats) => {
92+
let init = (solver, spec, config, meta, cil, analyses, warnings, stats, file_loc) => {
9393
let cil =
9494
switch (cil) {
9595
| Ok(s) =>
@@ -128,9 +128,15 @@ let init = (solver, spec, config, meta, cil, analyses, warnings, stats) => {
128128
| _ => raise(InitFailed("Failed to load runtime stats"))
129129
};
130130

131+
let file_loc =
132+
switch (file_loc) {
133+
| Ok(s) => Marshal.from_string(s, 0)
134+
| _ => raise(InitFailed("Failed to load file path table"))
135+
};
136+
131137
print_endline("Rendering app...");
132138
React.Dom.renderToElementWithId(
133-
<Main cil goblint warnings meta stats />,
139+
<Main cil goblint warnings meta stats file_loc/>,
134140
"app",
135141
);
136142
};
@@ -153,15 +159,16 @@ let handle_error = exc => {
153159
"./analyses.marshalled",
154160
"./warnings.marshalled",
155161
"./stats.marshalled",
162+
"./file_loc.marshalled",
156163
]
157164
|> List.map(HttpClient.get)
158165
|> Lwt.all
159166
>>= (
160167
l =>
161168
Lwt.return(
162169
switch (l) {
163-
| [solver, spec, config, meta, cil, analyses, warnings, stats] =>
164-
try(init(solver, spec, config, meta, cil, analyses, warnings, stats)) {
170+
| [solver, spec, config, meta, cil, analyses, warnings, stats, file_loc] =>
171+
try(init(solver, spec, config, meta, cil, analyses, warnings, stats, file_loc)) {
165172
| exc => handle_error(exc)
166173
}
167174
| _ => ()

src/Main.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
open Batteries;
22

33
[@react.component]
4-
let make = (~cil, ~goblint, ~warnings, ~meta, ~stats) => {
4+
let make = (~cil, ~goblint, ~warnings, ~meta, ~stats, ~file_loc) => {
55
let (state, dispatch) =
66
React.useReducer(
77
Reducer.reducer,
8-
State.make(~cil, ~goblint, ~warnings, ~meta, ~stats, ()),
8+
State.make(~cil, ~goblint, ~warnings, ~meta, ~stats, ~file_loc, ()),
99
);
1010

1111
let fetch_file =
@@ -38,7 +38,7 @@ let make = (~cil, ~goblint, ~warnings, ~meta, ~stats) => {
3838
React.useEffect1(
3939
() => {
4040
switch (state.display) {
41-
| Some(File(f)) when Option.is_none(f.contents) => fetch_file(f.path)
41+
| Some(File(f)) when Option.is_none(f.contents) => fetch_file(Hashtbl.find(file_loc, f.path))
4242
| Some(Func(f)) when Option.is_none(f.dot) =>
4343
fetch_dot(f.name, f.file)
4444
| _ => ()

src/Panel.re

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ let make = (~state, ~dispatch) => {
5252
<div className="tab-content">
5353
<div className="tab-pane active">
5454
{switch (current) {
55-
| Some(Warnings) =>
56-
<WarningView warnings={state.warnings} dispatch />
55+
| Some(Warnings) => <WarningView warnings={state.warnings} dispatch />
5756
| Some(DeadCode) => <DeadCodeView locations dispatch />
5857
| Some(Parameters) => <ParameterView parameters />
5958
| Some(Statistics) => <GvStatisticsView stats={state.stats} />

src/state/state.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type t = {
2323
warnings : GvMessages.t;
2424
meta : Yojson.Safe.t;
2525
stats : Stats.t * Gc.stat;
26+
file_loc : (string, string) Hashtbl.t;
2627
display : display option;
2728
inspect : inspect option;
2829
selected_sidebar : selected_sidebar;
@@ -37,12 +38,13 @@ let default =
3738
warnings = [];
3839
meta = `Null;
3940
stats = (Stats.top, Gc.quick_stat ());
41+
file_loc = Hashtbl.create 113;
4042
display = None;
4143
inspect = None;
4244
selected_sidebar = SelectedSidebar.Nodes;
4345
selected_panel = None;
4446
search = Search.default;
4547
}
4648

47-
let make ~cil ~goblint ~warnings ~meta ~stats () =
48-
{ default with cil; goblint; warnings; meta; stats }
49+
let make ~cil ~goblint ~warnings ~meta ~stats ~file_loc () =
50+
{ default with cil; goblint; warnings; meta; stats; file_loc }

0 commit comments

Comments
 (0)