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
ae3828da
Commit
ae3828da
authored
11 months ago
by
Virgile Prevosto
Browse files
Options
Downloads
Patches
Plain Diff
[devman] minor changes in documentation of the new Current_loc
parent
6d81ddc4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/developer/advance.tex
+16
-21
16 additions, 21 deletions
doc/developer/advance.tex
doc/developer/changes.tex
+1
-0
1 addition, 0 deletions
doc/developer/changes.tex
with
17 additions
and
21 deletions
doc/developer/advance.tex
+
16
−
21
View file @
ae3828da
...
...
@@ -1383,18 +1383,19 @@ specify a source location, either specifically or by using the current
location of an
\texttt
{
AST
}
visitor.
\lstset
{
style=frama-c-style
}
\begin{itemize}
\item
[]
\lstinline
{
~source:
$
s
$}
use the source
loca
tion
$
s
$
(see
\texttt
{
Log.mli
}
)
\item
[]
\lstinline
{
~current:true
}
use the
current
source location
managed by
\texttt
{
Current
\_
loc
}
(see
\texttt
{
Current
\_
loc.mli
}
).
\item
[]
\lstinline
{
~source:
$
s
$}
use the source
posi
tion
$
s
$
(see
\texttt
{
Log.mli
}
)
\item
[]
\lstinline
{
~current:true
}
use the source location
managed by
\texttt
{
Current
\_
loc
}
(see
below
).
\end{itemize}
\codeidxdef
{
Current
\_
loc
}
The current location is set manually, either by frama-c's kernel or by
developpers in their plug-in. For instance
\texttt
{
Cil
}
visitors update this
location when visiting expressions, statements, globals, etc.
\codeidxdef
{
Current
\_
loc
}
The
\texttt
{
Current
\_
loc
}
module is used to
manage the code location that is currently under focus.
The current location must be set, either by
\framac
's kernel or by
the plug-in themselves. In particular,
\texttt
{
Cil
}
visitors update this
location when visiting each node.
\begin{example}
Different ways
to se
t
and
u
se
\texttt
{
C
urrent
\_
loc
}
:
The code samples below show how
to
u
se and se
t the c
urrent
loc
ation.
\scodeidx
{
Current
\_
loc
}{
let-bindings
}
\scodeidx
{
Current
\_
loc
}{
with
\_
loc
\_
opt
}
\scodeidx
{
Current
\_
loc
}{
with
\_
loc
}
...
...
@@ -1409,33 +1410,27 @@ location when visiting expressions, statements, globals, etc.
exceptions inside [f] will be caught and re-raised after resetting the
location to its previous value. *)
let apply
_
stmt f stmt =
Current
_
loc.with
_
loc (Cil
_
datatype.Stmt.loc s) f
S
tmt
Current
_
loc.with
_
loc (Cil
_
datatype.Stmt.loc s) f
s
tmt
(* [with
_
loc
_
opt opt
_
loc f x] behaves like [with
_
loc] if [loc
_
opt] is
[Some loc], and does not update the current location if it is [None].*)
let apply
_
code
_
annot f ca =
Current
_
loc.with
_
loc
_
opt (Cil
_
datatype.Code
_
annotation.loc
s
) f
stmt
Current
_
loc.with
_
loc
_
opt (Cil
_
datatype.Code
_
annotation.loc
ca
) f
ca
(* Current
_
loc defines 2 let-binding operators which call [with
_
loc] and
[with
_
loc
_
opt]. Here is a function that set the current location to the
expr location, and reset it after the match. *)
let do
_
expr e =
let open Current
_
loc.Operators in
let
$
<>
$
UpdatedC
U
rrentLoc = e.eloc in
let
$
<>
$
UpdatedC
u
rrentLoc = e.eloc in
match e.enode with
| ...
(* The same function after removing the let-binding syntax. Here [let
$
<>
$
] can
be replaced with [with
_
loc]. [UpdatedCUrrentLoc] is used as documentation
to know which operation is done by the operator, and to be sure we are
using the right one. It can be replaced by [
_
]. *)
let do
_
expr2 e =
(* When we only have a [loc option], we can use the
$
<?>
$
operator *)
let do
_
code
_
annot f ca =
let open Current
_
loc.Operators in
( let
$
<>
$
) e.eloc (fun UpdatedCUrrentLoc ->
match e.enode with
| ...
) UpdatedCUrrentLoc
let <?> UpdatedCurrentLoc = Cil
_
datatype.Code
_
annotation.loc ca in
f ca
\end{ocamlcode}
\end{example}
...
...
This diff is collapsed.
Click to expand it.
doc/developer/changes.tex
+
1
−
0
View file @
ae3828da
...
...
@@ -7,6 +7,7 @@ This chapter summarizes the major changes in this documentation between each
\section*
{
Frama-C+dev
}
\begin{itemize}
\item
\textbf
{
Logging Services
}
: Document new
\texttt
{
Current
\_
loc
}
module
\item
There is no more
\texttt
{
Db
}
module:
\begin{itemize}
\item
Whole document:
\texttt
{
Db.Main.extend
}
is now
\texttt
{
Boot.Main.extend
}
...
...
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