From dbd6cf011f34e80948138a411f75e98b3e6c65f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=BChler?= <david.buhler@cea.fr> Date: Thu, 16 Sep 2021 14:27:58 +0200 Subject: [PATCH] [server] New GET request getMainFunction returning the current entry point. In ivette, selects the entry point after opening new source files. --- ivette/src/frama-c/api/generated/kernel/ast/index.ts | 9 +++++++++ ivette/src/frama-c/menu.ts | 3 ++- src/plugins/server/kernel_ast.ml | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ivette/src/frama-c/api/generated/kernel/ast/index.ts b/ivette/src/frama-c/api/generated/kernel/ast/index.ts index 03afaed2e4d..f72426c5a32 100644 --- a/ivette/src/frama-c/api/generated/kernel/ast/index.ts +++ b/ivette/src/frama-c/api/generated/kernel/ast/index.ts @@ -284,6 +284,15 @@ export const byLocation: Compare.Order<location> = marker: byMarker, }); +const getMainFunction_internal: Server.GetRequest<null,Json.key<'#fct'>> = { + kind: Server.RqKind.GET, + name: 'kernel.ast.getMainFunction', + input: Json.jNull, + output: Json.jKey<'#fct'>('#fct'), +}; +/** Get the current 'main' function. */ +export const getMainFunction: Server.GetRequest<null,Json.key<'#fct'>>= getMainFunction_internal; + const getFunctions_internal: Server.GetRequest<null,Json.key<'#fct'>[]> = { kind: Server.RqKind.GET, name: 'kernel.ast.getFunctions', diff --git a/ivette/src/frama-c/menu.ts b/ivette/src/frama-c/menu.ts index ea9e37c0a01..0fa35529440 100644 --- a/ivette/src/frama-c/menu.ts +++ b/ivette/src/frama-c/menu.ts @@ -46,7 +46,8 @@ async function setFiles(): Promise<void> { }); await Server.send(Ast.setFiles, files); await Server.send(Ast.compute, { }); - States.setSelection({fct: undefined}); + const main = await Server.send(Ast.getMainFunction, { }); + States.setSelection({ fct: main }); return; } diff --git a/src/plugins/server/kernel_ast.ml b/src/plugins/server/kernel_ast.ml index 5f98ce74146..10c62c2128a 100644 --- a/src/plugins/server/kernel_ast.ml +++ b/src/plugins/server/kernel_ast.ml @@ -353,6 +353,12 @@ end (* --- Functions --- *) (* -------------------------------------------------------------------------- *) +let () = Request.register ~package + ~kind:`GET ~name:"getMainFunction" + ~descr:(Md.plain "Get the current 'main' function.") + ~input:(module Junit) ~output:(module Kf) + (fun () -> fst (Globals.entry_point ())) + let () = Request.register ~package ~kind:`GET ~name:"getFunctions" ~descr:(Md.plain "Collect all functions in the AST") -- GitLab