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
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
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
Charles Southerland
frama-c
Commits
a3084f08
Commit
a3084f08
authored
5 years ago
by
Julien Signoles
Browse files
Options
Downloads
Patches
Plain Diff
[translate] add a few assertions
parent
2a3171cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/e-acsl/translate.ml
+21
-25
21 additions, 25 deletions
src/plugins/e-acsl/translate.ml
with
21 additions
and
25 deletions
src/plugins/e-acsl/translate.ml
+
21
−
25
View file @
a3084f08
...
@@ -210,8 +210,8 @@ let conditional_to_exp ?(name="if") loc t_opt e1 (e2, env2) (e3, env3) =
...
@@ -210,8 +210,8 @@ let conditional_to_exp ?(name="if") loc t_opt e1 (e2, env2) (e3, env3) =
let
lv
=
Cil
.
var
v
in
let
lv
=
Cil
.
var
v
in
let
ty
=
Cil
.
typeOf
ev
in
let
ty
=
Cil
.
typeOf
ev
in
let
init_set
=
let
init_set
=
(* TODO RATIONAL: how is it possible to get a real here? *)
assert
(
not
(
Real
.
is_t
ty
));
if
Real
.
is_t
ty
then
Real
.
init_set
else
Gmp
.
init_set
Gmp
.
init_set
in
in
let
affect
e
=
init_set
~
loc
lv
ev
e
in
let
affect
e
=
init_set
~
loc
lv
ev
e
in
let
then_block
,
_
=
let
then_block
,
_
=
...
@@ -340,12 +340,10 @@ and context_insensitive_term_to_exp kf env t =
...
@@ -340,12 +340,10 @@ and context_insensitive_term_to_exp kf env t =
else
if
Real
.
is_t
ty
then
else
if
Real
.
is_t
ty
then
let
e
,
env
=
Real
.
binop
~
loc
bop
e1
e2
env
(
Some
t
)
in
let
e
,
env
=
Real
.
binop
~
loc
bop
e1
e2
env
(
Some
t
)
in
e
,
env
,
C_number
,
""
e
,
env
,
C_number
,
""
else
else
begin
if
Logic_typing
.
is_integral_type
t
.
term_type
then
assert
(
Logic_typing
.
is_integral_type
t
.
term_type
);
Cil
.
new_exp
~
loc
(
BinOp
(
bop
,
e1
,
e2
,
ty
))
,
env
,
C_number
,
""
Cil
.
new_exp
~
loc
(
BinOp
(
bop
,
e1
,
e2
,
ty
))
,
env
,
C_number
,
""
else
end
(* TODO RATIONAL: why question mark? *)
not_yet
env
"floating-point context (?)"
|
TBinOp
(
Div
|
Mod
as
bop
,
t1
,
t2
)
->
|
TBinOp
(
Div
|
Mod
as
bop
,
t1
,
t2
)
->
let
ty
=
Typing
.
get_typ
t
in
let
ty
=
Typing
.
get_typ
t
in
let
e1
,
env
=
term_to_exp
kf
env
t1
in
let
e1
,
env
=
term_to_exp
kf
env
t1
in
...
@@ -368,19 +366,19 @@ and context_insensitive_term_to_exp kf env t =
...
@@ -368,19 +366,19 @@ and context_insensitive_term_to_exp kf env t =
~
loc
kf
env
Typing
.
gmpz
~
e1
:
e2
~
name
Eq
t2
zero
t
~
loc
kf
env
Typing
.
gmpz
~
e1
:
e2
~
name
Eq
t2
zero
t
in
in
let
mk_stmts
_v
e
=
let
mk_stmts
_v
e
=
assert
(
Gmp
.
Z
.
is_t
ty
);
assert
(
Gmp
.
Z
.
is_t
ty
);
let
vis
=
Env
.
get_visitor
env
in
let
vis
=
Env
.
get_visitor
env
in
let
kf
=
Extlib
.
the
vis
#
current_kf
in
let
kf
=
Extlib
.
the
vis
#
current_kf
in
let
cond
=
let
cond
=
Misc
.
mk_e_acsl_guard
Misc
.
mk_e_acsl_guard
(
Env
.
annotation_kind
env
)
(
Env
.
annotation_kind
env
)
kf
kf
guard
guard
(
Logic_const
.
prel
~
loc
(
Req
,
t2
,
zero
))
(
Logic_const
.
prel
~
loc
(
Req
,
t2
,
zero
))
in
in
Env
.
add_assert
env
cond
(
Logic_const
.
prel
(
Rneq
,
t2
,
zero
));
Env
.
add_assert
env
cond
(
Logic_const
.
prel
(
Rneq
,
t2
,
zero
));
let
instr
=
Misc
.
mk_call
~
loc
name
[
e
;
e1
;
e2
]
in
let
instr
=
Misc
.
mk_call
~
loc
name
[
e
;
e1
;
e2
]
in
[
cond
;
instr
]
[
cond
;
instr
]
in
in
let
name
=
Misc
.
name_of_binop
bop
in
let
name
=
Misc
.
name_of_binop
bop
in
let
_
,
e
,
env
=
Env
.
new_var_and_mpz_init
~
loc
~
name
env
t
mk_stmts
in
let
_
,
e
,
env
=
Env
.
new_var_and_mpz_init
~
loc
~
name
env
t
mk_stmts
in
...
@@ -388,13 +386,11 @@ and context_insensitive_term_to_exp kf env t =
...
@@ -388,13 +386,11 @@ and context_insensitive_term_to_exp kf env t =
else
if
Real
.
is_t
ty
then
else
if
Real
.
is_t
ty
then
let
e
,
env
=
Real
.
binop
~
loc
bop
e1
e2
env
(
Some
t
)
in
let
e
,
env
=
Real
.
binop
~
loc
bop
e1
e2
env
(
Some
t
)
in
e
,
env
,
C_number
,
""
e
,
env
,
C_number
,
""
else
else
begin
assert
(
Logic_typing
.
is_integral_type
t
.
term_type
);
(* no guard required since RTEs are generated separately *)
(* no guard required since RTEs are generated separately *)
if
Logic_typing
.
is_integral_type
t
.
term_type
then
Cil
.
new_exp
~
loc
(
BinOp
(
bop
,
e1
,
e2
,
ty
))
,
env
,
C_number
,
""
Cil
.
new_exp
~
loc
(
BinOp
(
bop
,
e1
,
e2
,
ty
))
,
env
,
C_number
,
""
else
end
(* TODO RATIONAL: why question mark? *)
not_yet
env
"floating-point context (?)"
|
TBinOp
(
Lt
|
Gt
|
Le
|
Ge
|
Eq
|
Ne
as
bop
,
t1
,
t2
)
->
|
TBinOp
(
Lt
|
Gt
|
Le
|
Ge
|
Eq
|
Ne
as
bop
,
t1
,
t2
)
->
(* comparison operators *)
(* comparison operators *)
let
ity
=
Typing
.
get_integer_op
t
in
let
ity
=
Typing
.
get_integer_op
t
in
...
...
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