Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
5293ce76
Commit
5293ce76
authored
2 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[server] removed input-tag cache
parent
03231507
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ivette/src/frama-c/kernel/api/ast/index.ts
+3
-5
3 additions, 5 deletions
ivette/src/frama-c/kernel/api/ast/index.ts
src/plugins/server/kernel_ast.ml
+15
-73
15 additions, 73 deletions
src/plugins/server/kernel_ast.ml
with
18 additions
and
78 deletions
ivette/src/frama-c/kernel/api/ast/index.ts
+
3
−
5
View file @
5293ce76
...
...
@@ -445,20 +445,18 @@ export const setFiles: Server.SetRequest<string[],null>= setFiles_internal;
const
parseExpr_internal
:
Server
.
GetRequest
<
{
term
:
string
,
stmt
:
marker
},
marker
|
undefined
marker
>
=
{
kind
:
Server
.
RqKind
.
GET
,
name
:
'
kernel.ast.parseExpr
'
,
input
:
Json
.
jObject
({
term
:
Json
.
jString
,
stmt
:
jMarker
,}),
output
:
Json
.
jOption
(
jMarker
)
,
output
:
jMarker
,
signals
:
[],
};
/** Parse a C expression and returns the associated marker */
export
const
parseExpr
:
Server
.
GetRequest
<
{
term
:
string
,
stmt
:
marker
},
marker
|
undefined
marker
>=
parseExpr_internal
;
/* ------------------------------------- */
This diff is collapsed.
Click to expand it.
src/plugins/server/kernel_ast.ml
+
15
−
73
View file @
5293ce76
...
...
@@ -795,68 +795,24 @@ let () =
(* --- Build a marker from an ACSL term --- *)
(* -------------------------------------------------------------------------- *)
module
TermAt
=
Datatype
.
Pair
(
Cil_datatype
.
Stmt
)(
Cil_datatype
.
Term
)
module
TermHash
=
Hashtbl
.
Make
(
TermAt
)
module
TERMHASH
:
Datatype
.
S
with
type
t
=
Marker
.
t
TermHash
.
t
=
Datatype
.
Make
(
struct
type
t
=
Marker
.
t
TermHash
.
t
include
Datatype
.
Undefined
let
reprs
=
[
TermHash
.
create
0
]
let
name
=
"Server.Kernel_ast.TermHash"
let
mem_project
=
Datatype
.
never_any_project
end
)
module
TERMCACHE
=
State_builder
.
Ref
(
TERMHASH
)
(
struct
let
name
=
"Server.Kernel_ast.TermCache"
let
default
()
=
TermHash
.
create
0
let
dependencies
=
[]
end
)
let
parse_term
kf
text
=
let
build_marker
~
stmt
~
term
=
let
env
=
let
open
Logic_typing
in
Lenv
.
empty
()
|>
append_pre_label
|>
append_init_label
|>
append_here_label
in
try
Ok
(
Logic_parse_string
.
term
~
env
kf
text
)
with
|
Logic_parse_string
.
Error
(
_
,
msg
)
->
Error
msg
|
Parsing
.
Parse_error
->
Error
"Parse error"
let
reparse_term
kf
stmt
text
=
match
parse_term
kf
text
with
|
Ok
t
->
Some
(
stmt
,
t
)
|
Error
_
->
None
let
parseable_marker
=
let
open
Printer_tag
in
function
|
PStmt
_
|
PStmtStart
_
|
PTermLval
_
|
PVDecl
_
|
PGlobal
_
|
PIP
_
|
PLval
(
None
,
_
,
_
)
|
PExp
(
None
,
_
,
_
)
|
PLval
(
_
,
Kglobal
,
_
)
|
PExp
(
_
,
Kglobal
,
_
)
|
PType
_
->
None
|
PLval
(
Some
kf
,
Kstmt
stmt
,
lval
)
->
reparse_term
kf
stmt
@@
Format
.
asprintf
"%a"
Cil_datatype
.
Lval
.
pretty
lval
|
PExp
(
Some
kf
,
Kstmt
stmt
,
exp
)
->
reparse_term
kf
stmt
@@
Format
.
asprintf
"%a"
Cil_datatype
.
Exp
.
pretty
exp
(* pre-fill the cache with known markers *)
let
()
=
Marker
.
hook
begin
fun
(
m
,_
)
->
match
parseable_marker
m
with
|
None
->
()
|
Some
entry
->
let
cache
=
TERMCACHE
.
get
()
in
if
not
(
TermHash
.
mem
cache
entry
)
then
TermHash
.
add
cache
entry
m
end
try
let
kf
=
Kernel_function
.
find_englobing_kf
stmt
in
let
term
=
Logic_parse_string
.
term
~
env
kf
term
in
let
exp
=
Logic_to_c
.
term_to_exp
term
in
Some
(
Printer_tag
.
PExp
(
Some
kf
,
Kstmt
stmt
,
exp
))
with
Not_found
|
Logic_parse_string
.
Error
_
|
Logic_parse_string
.
Unbound
_
|
Logic_to_c
.
No_conversion
->
None
(* TODO: return an error message. *)
(* request to parse a new marker from C expression or l-value *)
let
()
=
let
module
Md
=
Markdown
in
let
s
=
Request
.
signature
~
output
:
(
module
Data
.
Joption
(
Marker
)
)
()
in
let
s
=
Request
.
signature
~
output
:
(
module
Marker
)
()
in
let
get_marker
=
Request
.
param
s
~
name
:
"stmt"
~
descr
:
(
Md
.
plain
"Marker position from where to localize the term"
)
(
module
Marker
)
in
...
...
@@ -868,25 +824,11 @@ let () =
~
descr
:
(
Md
.
plain
"Parse a C expression and returns the associated marker"
)
begin
fun
rq
()
->
match
Printer_tag
.
ki_of_localizable
@@
get_marker
rq
with
|
Kglobal
->
failwith
"No statement at selection point"
|
Kglobal
->
Data
.
failure
"No statement at selection point"
|
Kstmt
stmt
->
let
kf
=
Kernel_function
.
find_englobing_kf
stmt
in
match
parse_term
kf
@@
get_term
rq
with
|
Error
msg
->
failwith
msg
|
Ok
term
->
let
entry
=
(
stmt
,
term
)
in
let
cache
=
TERMCACHE
.
get
()
in
try
Some
(
TermHash
.
find
cache
entry
)
with
Not_found
->
try
let
marker
=
match
Logic_to_c
.
term_to_exp
term
with
|
{
enode
=
Lval
lv
}
->
Printer_tag
.
PLval
(
Some
kf
,
Kstmt
stmt
,
lv
)
|
exp
->
Printer_tag
.
PExp
(
Some
kf
,
Kstmt
stmt
,
exp
)
in
TermHash
.
add
cache
entry
marker
;
Some
marker
with
Logic_to_c
.
No_conversion
->
failwith
"Not a C-expression"
match
build_marker
~
stmt
~
term
:
(
get_term
rq
)
with
|
None
->
Data
.
failure
"Invalid expression"
|
Some
tag
->
tag
end
(* -------------------------------------------------------------------------- *)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment