Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
infosec-ecomp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
cidre-public
Compilation
infosec-ecomp
Commits
350cb09b
Commit
350cb09b
authored
5 years ago
by
Wilke Pierre
Browse files
Options
Downloads
Patches
Plain Diff
Nous vous fournissons le code qui génère le CFG. Promis !
parent
7ef18d1f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cfg_gen.ml
+33
-2
33 additions, 2 deletions
src/cfg_gen.ml
with
33 additions
and
2 deletions
src/cfg_gen.ml
+
33
−
2
View file @
350cb09b
...
...
@@ -11,7 +11,17 @@ open Prog
but not to [Cfg.expr], hence the distinction.
*)
let
rec
cfg_expr_of_eexpr
(
e
:
Elang
.
expr
)
:
expr
res
=
Error
"cfg_expr_of_eexpr not implemented yet."
match
e
with
|
Elang
.
Ebinop
(
b
,
e1
,
e2
)
->
cfg_expr_of_eexpr
e1
>>=
fun
ee1
->
cfg_expr_of_eexpr
e2
>>=
fun
ee2
->
OK
(
Ebinop
(
b
,
ee1
,
ee2
))
|
Elang
.
Eunop
(
u
,
e
)
->
cfg_expr_of_eexpr
e
>>=
fun
ee
->
OK
(
Eunop
(
u
,
ee
))
|
Elang
.
Eint
i
->
OK
(
Eint
i
)
|
Elang
.
Evar
v
->
OK
(
Evar
v
)
(* [cfg_node_of_einstr next cfg succ i] builds the CFG node(s) that correspond
to the E instruction [i].
...
...
@@ -35,7 +45,28 @@ let rec cfg_node_of_einstr (next: int) (cfg : (int, cfg_node) Hashtbl.t)
cfg_expr_of_eexpr
e
>>=
fun
e
->
Hashtbl
.
replace
cfg
next
(
Cassign
(
v
,
e
,
succ
));
OK
(
next
,
next
+
1
)
|
_
->
Error
"cfg_node_of_einstr not implemented yet."
|
Elang
.
Iif
(
c
,
ithen
,
ielse
)
->
cfg_expr_of_eexpr
c
>>=
fun
c
->
cfg_node_of_einstr
next
cfg
succ
ithen
>>=
fun
(
nthen
,
next
)
->
cfg_node_of_einstr
next
cfg
succ
ielse
>>=
fun
(
nelse
,
next
)
->
Hashtbl
.
replace
cfg
next
(
Ccmp
(
c
,
nthen
,
nelse
));
OK
(
next
,
next
+
1
)
|
Elang
.
Iwhile
(
c
,
i
)
->
cfg_expr_of_eexpr
c
>>=
fun
c
->
let
(
cmp
,
next
)
=
(
next
,
next
+
1
)
in
cfg_node_of_einstr
next
cfg
cmp
i
>>=
fun
(
nthen
,
next
)
->
Hashtbl
.
replace
cfg
cmp
(
Ccmp
(
c
,
nthen
,
succ
));
OK
(
cmp
,
next
+
1
)
|
Elang
.
Iblock
il
->
List
.
fold_right
(
fun
i
acc
->
acc
>>=
fun
(
succ
,
next
)
->
cfg_node_of_einstr
next
cfg
succ
i
)
il
(
OK
(
succ
,
next
))
|
Elang
.
Ireturn
e
->
cfg_expr_of_eexpr
e
>>=
fun
e
->
Hashtbl
.
replace
cfg
next
(
Creturn
e
);
OK
(
next
,
next
+
1
)
|
Elang
.
Iprint
e
->
cfg_expr_of_eexpr
e
>>=
fun
e
->
Hashtbl
.
replace
cfg
next
(
Cprint
(
e
,
succ
));
OK
(
next
,
next
+
1
)
(* Some nodes may be unreachable after the CFG is entirely generated. The
[reachable_nodes n cfg] constructs the set of node identifiers that are
...
...
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