From f09c8b6c48ceb1f2449284984d445c1853ebf9ec Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Mon, 16 May 2022 11:43:45 +0300 Subject: [PATCH 1/3] Fix empty_increment_data after Goblint dce --- src/state/gvGoblint.ml | 2 +- src/state/search.ml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/state/gvGoblint.ml b/src/state/gvGoblint.ml index 2c40857..f90ee99 100644 --- a/src/state/gvGoblint.ml +++ b/src/state/gvGoblint.ml @@ -171,7 +171,7 @@ let unmarshal spec cil = let (module G : Sig) = (module Make (Cfg) (Spec) (struct - let increment = Analyses.empty_increment_data cil + let increment = Analyses.empty_increment_data () end)) in G.wrap_solver_state () diff --git a/src/state/search.ml b/src/state/search.ml index d00c07a..f251c5c 100644 --- a/src/state/search.ml +++ b/src/state/search.ml @@ -30,7 +30,7 @@ module Query = struct let execute (q : t) cil = if is_semantic q then ( ExpressionEvaluation.gv_query := Some q; - Maingoblint.do_analyze (Analyses.empty_increment_data cil) cil; + Maingoblint.do_analyze (Analyses.empty_increment_data ()) cil; let results = !ExpressionEvaluation.gv_results in let pred = if q.mode = `Must then snd %> Option.default false else snd %> Option.default true From 6752eb4871e7f4c9de8565a412ab71e9884ef1c7 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Mon, 16 May 2022 12:02:25 +0300 Subject: [PATCH 2/3] Run dead code analysis with reanalyze --- src/DTreeView.re | 50 -------------------------------- src/Menu.re | 29 ------------------- src/bindings/dOMParser.ml | 20 ------------- src/bindings/dOMParser.mli | 7 ----- src/state/gvDisplay.ml | 1 + src/state/gvInspect.ml | 8 ------ src/ui/base/form.re | 8 ------ src/ui/base/mappedInput.re | 37 ------------------------ src/utils/httpClient.ml | 1 + src/utils/xml.ml | 59 -------------------------------------- src/utils/xmlParser.ml | 15 ---------- 11 files changed, 2 insertions(+), 233 deletions(-) delete mode 100644 src/DTreeView.re delete mode 100644 src/Menu.re delete mode 100644 src/bindings/dOMParser.ml delete mode 100644 src/bindings/dOMParser.mli delete mode 100644 src/ui/base/form.re delete mode 100644 src/ui/base/mappedInput.re delete mode 100644 src/utils/xml.ml delete mode 100644 src/utils/xmlParser.ml diff --git a/src/DTreeView.re b/src/DTreeView.re deleted file mode 100644 index d3dcbf9..0000000 --- a/src/DTreeView.re +++ /dev/null @@ -1,50 +0,0 @@ -open Tree; - -let makeProps: (~tree: dtree, ~key: string=?, unit) => Js_of_ocaml.Js.t({. tree: Js_of_ocaml.Js.readonly_prop(dtree)}) = - (~tree, ~key=?, _) => - Js_of_ocaml.Js.Unsafe.( - obj( - [| - Option.map( - _ => ( - "key", - inject( - Option.map(Js_of_ocaml.Js.string, key) - |> Js_of_ocaml.Js.Opt.option, - ), - ), - key, - ), - Some(("tree", inject(tree))), - |] - |> Array.to_list - |> List.filter_map(x => x) - |> Array.of_list, - ) - ); - -let rec make = ( props: Js_of_ocaml.Js.t({ . tree: Js_of_ocaml.Js.readonly_prop(dtree), }) ) => { - let (Dnode (different, s, c)) = props##.tree; - let (collapse, setCollapse) = React.useState(() => s == "context" ); -
  • - {setCollapse(x => !x)} } - className={(List.length(c) > 0 ? "caret " : "") ++ (collapse ? "" : "caret-down ") ++ (!different ? "differentState" : "")} > - {s |> React.string} - - { - if (List.length(c) > 0 && !collapse) { -
      - {List.mapi( (i, n) => {React.createElement( - make, - makeProps( - ~tree=n, ~key=string_of_int(i), - (), - ), - )}, c) |> React.list} -
    - } else{ - React.null - } - } -
  • ; -}; \ No newline at end of file diff --git a/src/Menu.re b/src/Menu.re deleted file mode 100644 index 0a3fb97..0000000 --- a/src/Menu.re +++ /dev/null @@ -1,29 +0,0 @@ -open SelectedView; -open State; - -let views = [ - (Content, "Content View"), - (Warning, "Warnings"), - (DeadCode, "Dead Code"), - (Parameters, "Parameters"), - (Statistics, "Statistics"), -]; - -[@react.component] -let make = (~state, ~dispatch) => { - ; -}; diff --git a/src/bindings/dOMParser.ml b/src/bindings/dOMParser.ml deleted file mode 100644 index 310681a..0000000 --- a/src/bindings/dOMParser.ml +++ /dev/null @@ -1,20 +0,0 @@ -open Js_of_ocaml - -class type dom_parser = - object - method parseFromString : - Js.js_string Js.t -> - Js.js_string Js.t -> - Dom.element Dom.document Js.t Js.meth - end - -let constr = Js.Unsafe.global##._DOMParser - -type t = dom_parser Js.t - -let create () = new%js constr - -let parse_from_string p s m = - let s = Js.string s in - let m = Js.string m in - p##parseFromString s m diff --git a/src/bindings/dOMParser.mli b/src/bindings/dOMParser.mli deleted file mode 100644 index 671ceb2..0000000 --- a/src/bindings/dOMParser.mli +++ /dev/null @@ -1,7 +0,0 @@ -open Js_of_ocaml - -type t - -val create : unit -> t - -val parse_from_string : t -> string -> string -> Dom.element Dom.document Js.t diff --git a/src/state/gvDisplay.ml b/src/state/gvDisplay.ml index f0e7e22..9356132 100644 --- a/src/state/gvDisplay.ml +++ b/src/state/gvDisplay.ml @@ -28,4 +28,5 @@ type t = File of file | Func of func let file ~path ?contents () = File (File.make ~path ?contents ()) +(* TODO: unused *) let func ~name ~file ?dot () = Func (Func.make ~name ~file ?dot ()) diff --git a/src/state/gvInspect.ml b/src/state/gvInspect.ml index f3fac31..0256d4f 100644 --- a/src/state/gvInspect.ml +++ b/src/state/gvInspect.ml @@ -1,12 +1,6 @@ module Line = struct type t = string * int - let empty = ("", -1) - - let make file num = (file, num) - - let valid (_, n) = n != -1 - let of_location (loc : Cil.location) = (loc.file, loc.line) end @@ -22,6 +16,4 @@ type t = Line of line | Node of node let line file num = Line (file, num) -let line_num = function Line ((_, n) as line) when Line.valid line -> Some n | _ -> None - let node id = Node id diff --git a/src/ui/base/form.re b/src/ui/base/form.re deleted file mode 100644 index 7592d7d..0000000 --- a/src/ui/base/form.re +++ /dev/null @@ -1,8 +0,0 @@ -[@react.component] -let make = (~on_submit, ~children) => { - let onSubmit = ev => { - React.Event.Form.preventDefault(ev); - on_submit(); - }; -
    children
    ; -}; diff --git a/src/ui/base/mappedInput.re b/src/ui/base/mappedInput.re deleted file mode 100644 index 35bb1f8..0000000 --- a/src/ui/base/mappedInput.re +++ /dev/null @@ -1,37 +0,0 @@ -// jsoo-react seems to have some trouble with -// non-mandatory component properties. This is a -// workaround until the issue is resolved. -let make_extras = (~label=?, ()) => { - label; -}; - -[@react.component] -let make = (~value, ~from_string, ~to_string, ~on_change, ~extras, ~children) => { - let label = extras; - - let onChange = ev => { - React.Event.Synthetic.preventDefault(ev); - React.Event.Synthetic.target(ev) - |> Ojs.get(_, "value") - |> Ojs.string_of_js - |> from_string - |> on_change; - }; - - let className = - switch (value) { - | Ok(_) => "form-control" - | _ => "form-control is-invalid" - }; - - let value = to_string(value); - -
    - {switch (label) { - | Some(s) => - | _ => React.null - }} - - children -
    ; -}; diff --git a/src/utils/httpClient.ml b/src/utils/httpClient.ml index 4f0c5a2..b393887 100644 --- a/src/utils/httpClient.ml +++ b/src/utils/httpClient.ml @@ -14,6 +14,7 @@ let get url = (fun () -> Lwt.return (Error NoContentAvailable)) (fun c -> Lwt.return (Ok (Typed_array.String.of_arrayBuffer c))) +(* TODO: unused *) let get_opt url = get url >>= fun resp -> Lwt.return (Result.to_option resp) let on_get f url = diff --git a/src/utils/xml.ml b/src/utils/xml.ml deleted file mode 100644 index 7dc772d..0000000 --- a/src/utils/xml.ml +++ /dev/null @@ -1,59 +0,0 @@ -open Js_of_ocaml - -type xml = Dom.node Js.t - -exception Not_element of xml - -exception Not_pcdata of xml - -exception No_attribute of string - -let to_element (x : xml) = - match x |> Dom.CoerceTo.element |> Js.Opt.to_option with - | Some e -> e - | _ -> raise (Not_element x) - -let to_text (x : xml) = - match x |> Dom.CoerceTo.text |> Js.Opt.to_option with - | Some e -> e - | _ -> raise (Not_pcdata x) - -let tag (x : xml) = - let e = to_element x in - e##.tagName |> Js.to_string - -let children (x : xml) = - let filter_empty_lines n = - Js.Opt.case (Dom.CoerceTo.text n) - (fun () -> true) - (fun t -> - let data = t##.data |> Js.to_string in - String.trim data |> String.length |> ( <> ) 0) - in - let e = to_element x in - e##.childNodes |> Dom.list_of_nodeList |> List.filter filter_empty_lines - -let pcdata (x : xml) = - let t = to_text x in - t##.data |> Js.to_string - -let attrib (x : xml) a = - let e = to_element x in - let a' = Js.string a in - match e##getAttribute a' |> Js.Opt.to_option with - | Some s -> s |> Js.to_string - | _ -> raise (No_attribute a) - -let attribs (x : xml) = - let e = to_element x in - let attrs = e##.attributes in - let rec collect l i = - if i >= 0 then - let attr = attrs##item i |> Js.Opt.to_option |> Option.get in - let n = attr##.name |> Js.to_string in - let v = attr##.value |> Js.to_string in - let l' = (n, v) :: l in - collect l' (i - 1) - else l - in - collect [] (attrs##.length - 1) diff --git a/src/utils/xmlParser.ml b/src/utils/xmlParser.ml deleted file mode 100644 index 683a086..0000000 --- a/src/utils/xmlParser.ml +++ /dev/null @@ -1,15 +0,0 @@ -open Js_of_ocaml - -type t = DOMParser.t - -type source = SString of string - -let make () = DOMParser.create () - -let prove _ _ = () - -let parse p s = - match s with - | SString s -> - let doc = DOMParser.parse_from_string p s "application/xml" in - doc##.documentElement |> Js.Unsafe.coerce From 693a7c934f5d231576506637f7d0cf5b3a9216b3 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 17 May 2022 11:40:23 +0300 Subject: [PATCH 3/3] Add more TODOs about unused code --- src/state/gvDisplay.ml | 2 +- src/state/gvMessages.ml | 1 + src/state/search.ml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/state/gvDisplay.ml b/src/state/gvDisplay.ml index 9356132..98a7d20 100644 --- a/src/state/gvDisplay.ml +++ b/src/state/gvDisplay.ml @@ -26,7 +26,7 @@ type func = Func.t type t = File of file | Func of func -let file ~path ?contents () = File (File.make ~path ?contents ()) +let file ~path ?contents () = File (File.make ~path ?contents ()) (* TODO: contents argument never used *) (* TODO: unused *) let func ~name ~file ?dot () = Func (Func.make ~name ~file ?dot ()) diff --git a/src/state/gvMessages.ml b/src/state/gvMessages.ml index 0715d23..0668a21 100644 --- a/src/state/gvMessages.ml +++ b/src/state/gvMessages.ml @@ -19,6 +19,7 @@ end type t = Message.t list +(* TODO: unused *) let filter_by_line (file, line) = let pred msg = match Message.location msg with diff --git a/src/state/search.ml b/src/state/search.ml index f251c5c..f8da543 100644 --- a/src/state/search.ml +++ b/src/state/search.ml @@ -6,7 +6,7 @@ module Query = struct type error = ParseError of string let create ?(kind = CodeQuery.Var_k) ?(target = CodeQuery.Name_t "") ?(find = CodeQuery.Uses_f) - ?(structure = CodeQuery.None_s) ?(limitation = CodeQuery.None_c) ?(expression = "") + ?(structure = CodeQuery.None_s) ?(limitation = CodeQuery.None_c) ?(expression = "") (* TODO: limitation argument never used *) ?(mode = `Must) () : t = { kind; target; find; structure; limitation; expression; mode }