Skip to content
Snippets Groups Projects
Commit a94ea160 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[dive] fix server interface

parent 75060621
No related branches found
No related tags found
No related merge requests found
...@@ -33,30 +33,27 @@ let get_graph = ...@@ -33,30 +33,27 @@ let get_graph =
graph := Some g; graph := Some g;
g g
let package = Package.package ~plugin:"dive" ~title:"Dive Services" ()
let page = Doc.page (`Plugin "dive")
~title:"Dive Services"
~filename:"dive.md"
module Graph = module Graph =
struct struct
type t = Imprecision_graph.t type t = Imprecision_graph.t
let syntax = Syntax.any let jtype = Data.Jany.jtype
let to_json = Imprecision_graph.to_json let to_json = Imprecision_graph.to_json
end end
module GraphDiff = module GraphDiff =
struct struct
type t = Imprecision_graph.t * Graph_types.graph_diff type t = Imprecision_graph.t * Graph_types.graph_diff
let syntax = Syntax.any let jtype = Data.Jany.jtype
let to_json = fun (g,d) -> Imprecision_graph.diff_to_json g d let to_json = fun (g,d) -> Imprecision_graph.diff_to_json g d
end end
module Variable = Data.Collection (struct module Variable = Data.Collection (struct
let name = "dive-variable-name" let name = "variableName"
let descr = Markdown.plain "The name of variable of the program" let descr = Markdown.plain "The name of variable of the program"
let signature = Data.Record.signature ~page ~name ~descr () let signature = Data.Record.signature ()
let _fun_field = Data.Record.option signature let _fun_field = Data.Record.option signature
~descr:(Markdown.plain "owner function for a local variable") ~descr:(Markdown.plain "owner function for a local variable")
...@@ -68,9 +65,9 @@ module Variable = Data.Collection (struct ...@@ -68,9 +65,9 @@ module Variable = Data.Collection (struct
type t = Cil_types.varinfo type t = Cil_types.varinfo
module R = module R =
(val (Data.Record.publish signature): Data.Record.S with type r = t) (val (Data.Record.publish ~package ~name ~descr signature): Data.Record.S with type r = t)
let syntax = R.syntax let jtype = R.jtype
let to_json v = let to_json v =
let varname = v.Cil_types.vname in let varname = v.Cil_types.vname in
...@@ -116,9 +113,7 @@ module Variable = Data.Collection (struct ...@@ -116,9 +113,7 @@ module Variable = Data.Collection (struct
module Function = Data.Collection (struct module Function = Data.Collection (struct
type t = Cil_types.kernel_function type t = Cil_types.kernel_function
let syntax = Syntax.publish ~page ~name:"dive-function-name" let jtype = Package.Jkey "fct-name"
~synopsis:Syntax.string
~descr:(Markdown.plain "The name of a function of the program") ()
let to_json kf = let to_json kf =
`String (Kernel_function.get_name kf) `String (Kernel_function.get_name kf)
...@@ -135,9 +130,7 @@ module Function = Data.Collection (struct ...@@ -135,9 +130,7 @@ module Function = Data.Collection (struct
module Node = Data.Collection (struct module Node = Data.Collection (struct
type t = Graph_types.node type t = Graph_types.node
let syntax = Syntax.publish ~page ~name:"dive-node" let jtype = Package.Jindex "dive-node"
~synopsis:Syntax.int
~descr:(Markdown.plain "A node identifier in the graph") ()
let to_json node = let to_json node =
`Int node.Graph_types.node_key `Int node.Graph_types.node_key
...@@ -152,20 +145,20 @@ module Node = Data.Collection (struct ...@@ -152,20 +145,20 @@ module Node = Data.Collection (struct
end) end)
let () = Request.register ~page let () = Request.register ~package
~kind:`GET ~name:"dive.graph" ~kind:`GET ~name:"graph"
~descr:(Markdown.plain "Retrieve the whole graph") ~descr:(Markdown.plain "Retrieve the whole graph")
~input:(module Data.Junit) ~output:(module Graph) ~input:(module Data.Junit) ~output:(module Graph)
(fun () -> Build.get_graph (get_graph ())) (fun () -> Build.get_graph (get_graph ()))
let () = Request.register ~page let () = Request.register ~package
~kind:`EXEC ~name:"dive.clear" ~kind:`EXEC ~name:"clear"
~descr:(Markdown.plain "Erase the graph and start over with an empty one") ~descr:(Markdown.plain "Erase the graph and start over with an empty one")
~input:(module Data.Junit) ~output:(module Data.Junit) ~input:(module Data.Junit) ~output:(module Data.Junit)
(fun () -> Build.clear (get_graph ())) (fun () -> Build.clear (get_graph ()))
let () = Request.register ~page let () = Request.register ~package
~kind:`EXEC ~name:"dive.add_var" ~kind:`EXEC ~name:"addVar"
~descr:(Markdown.plain "Add a variable to the graph") ~descr:(Markdown.plain "Add a variable to the graph")
~input:(module Variable) ~output:(module GraphDiff) ~input:(module Variable) ~output:(module GraphDiff)
begin fun var -> begin fun var ->
...@@ -175,8 +168,8 @@ let () = Request.register ~page ...@@ -175,8 +168,8 @@ let () = Request.register ~page
Build.get_graph g, Build.take_last_differences g Build.get_graph g, Build.take_last_differences g
end end
let () = Request.register ~page let () = Request.register ~package
~kind:`EXEC ~name:"dive.add_function_alarms" ~kind:`EXEC ~name:"addFunctionAlarms"
~descr:(Markdown.plain "Add all alarms of the given function") ~descr:(Markdown.plain "Add all alarms of the given function")
~input:(module Function) ~output:(module GraphDiff) ~input:(module Function) ~output:(module GraphDiff)
begin fun kf -> begin fun kf ->
...@@ -186,8 +179,8 @@ let () = Request.register ~page ...@@ -186,8 +179,8 @@ let () = Request.register ~page
Build.get_graph g, Build.take_last_differences g Build.get_graph g, Build.take_last_differences g
end end
let () = Request.register ~page let () = Request.register ~package
~kind:`EXEC ~name:"dive.explore" ~kind:`EXEC ~name:"explore"
~descr:(Markdown.plain "Explore the graph starting from an existing vertex") ~descr:(Markdown.plain "Explore the graph starting from an existing vertex")
~input:(module Node) ~output:(module GraphDiff) ~input:(module Node) ~output:(module GraphDiff)
begin fun node -> begin fun node ->
...@@ -197,8 +190,8 @@ let () = Request.register ~page ...@@ -197,8 +190,8 @@ let () = Request.register ~page
Build.get_graph g, Build.take_last_differences g Build.get_graph g, Build.take_last_differences g
end end
let () = Request.register ~page let () = Request.register ~package
~kind:`EXEC ~name:"dive.show" ~kind:`EXEC ~name:"show"
~descr:(Markdown.plain "Show the dependencies of an existing vertex") ~descr:(Markdown.plain "Show the dependencies of an existing vertex")
~input:(module Node) ~output:(module GraphDiff) ~input:(module Node) ~output:(module GraphDiff)
begin fun node -> begin fun node ->
...@@ -208,8 +201,8 @@ let () = Request.register ~page ...@@ -208,8 +201,8 @@ let () = Request.register ~page
Build.get_graph g, Build.take_last_differences g Build.get_graph g, Build.take_last_differences g
end end
let () = Request.register ~page let () = Request.register ~package
~kind:`EXEC ~name:"dive.hide" ~kind:`EXEC ~name:"hide"
~descr:(Markdown.plain "Hide the dependencies of an existing vertex") ~descr:(Markdown.plain "Hide the dependencies of an existing vertex")
~input:(module Node) ~output:(module GraphDiff) ~input:(module Node) ~output:(module GraphDiff)
begin fun node -> begin fun node ->
......
...@@ -302,17 +302,17 @@ let collection = ref None (* computed *) ...@@ -302,17 +302,17 @@ let collection = ref None (* computed *)
let name_re = Str.regexp "^[a-zA-Z0-9]+$" let name_re = Str.regexp "^[a-zA-Z0-9]+$"
let package_re = Str.regexp "^[a-z0-9]+\\(\\.[a-z0-9]+\\)*$" let package_re = Str.regexp "^[a-z0-9]+\\(\\.[a-z0-9]+\\)*$"
let check_name name =
if not (Str.string_match name_re name 0) then
Senv.fatal
"Invalid identifier %S (use « camlCased » names)" name
let check_package pkg = let check_package pkg =
if not (Str.string_match package_re pkg 0) then if not (Str.string_match package_re pkg 0) then
Senv.fatal Senv.fatal
"Invalid package identifier %S (use dot separated lowercase names)" "Invalid package identifier %S (use dot separated lowercase names)"
pkg pkg
let check_name name =
if not (Str.string_match name_re name 0) then
Senv.fatal
"Invalid identifier %S (use « camlCased » names)" name
let register_ident id = let register_ident id =
if IdSet.mem id !registry then if IdSet.mem id !registry then
Senv.fatal "Duplicate identifier '%a'" pp_ident id ; Senv.fatal "Duplicate identifier '%a'" pp_ident id ;
...@@ -333,10 +333,11 @@ let resolve_readme ~plugin = function ...@@ -333,10 +333,11 @@ let resolve_readme ~plugin = function
(* --- Declarations --- *) (* --- Declarations --- *)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
let package ?plugin ~title ?(descr=[]) ?readme ~name () = let package ?plugin ?name ~title ?(descr=[]) ?readme () =
check_package name ;
let plugin = match plugin with None -> Kernel | Some p -> Plugin p in let plugin = match plugin with None -> Kernel | Some p -> Plugin p in
let pkgname = String.split_on_char '.' name in let pkgname = match name with
| None -> []
| Some pkg -> check_package pkg ; String.split_on_char '.' pkg in
let pkgid = { plugin ; package = pkgname ; name = "*"} in let pkgid = { plugin ; package = pkgname ; name = "*"} in
let pkgInfo = { let pkgInfo = {
p_plugin = plugin ; p_plugin = plugin ;
......
...@@ -133,10 +133,10 @@ type package ...@@ -133,10 +133,10 @@ type package
val package : val package :
?plugin:string -> ?plugin:string ->
?name:string ->
title:string -> title:string ->
?descr:Markdown.text -> ?descr:Markdown.text ->
?readme:string -> ?readme:string ->
name:string ->
unit -> package unit -> package
(** (**
......
...@@ -89,7 +89,7 @@ val on_signal : signal -> (bool -> unit) -> unit ...@@ -89,7 +89,7 @@ val on_signal : signal -> (bool -> unit) -> unit
*) *)
val register : val register :
package:package -> package:package ->
kind:Main.kind -> kind:kind ->
name:string -> name:string ->
descr:Markdown.text -> descr:Markdown.text ->
input:'a input -> input:'a input ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment