Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
LARA
inox
Commits
0693b307
Commit
0693b307
authored
13 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
start to print graph to .dot format
parent
4cd540f9
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/main/scala/leon/CallGraph.scala
+30
-11
30 additions, 11 deletions
src/main/scala/leon/CallGraph.scala
with
30 additions
and
11 deletions
src/main/scala/leon/CallGraph.scala
+
30
−
11
View file @
0693b307
...
@@ -22,23 +22,21 @@ class CallGraph(val program: Program) {
...
@@ -22,23 +22,21 @@ class CallGraph(val program: Program) {
private
lazy
val
graph
:
Map
[
ProgramPoint
,
Set
[(
ProgramPoint
,
TransitionLabel
)]]
=
buildGraph
private
lazy
val
graph
:
Map
[
ProgramPoint
,
Set
[(
ProgramPoint
,
TransitionLabel
)]]
=
buildGraph
private
def
buildGraph
:
Map
[
ProgramPoint
,
Set
[(
ProgramPoint
,
TransitionLabel
)]]
=
{
private
def
buildGraph
:
Map
[
ProgramPoint
,
Set
[(
ProgramPoint
,
TransitionLabel
)]]
=
{
//
var
fd2point: Map[FunDef, ProgramPoint
] = Map()
var
callGraph
:
Map
[
ProgramPoint
,
Set
[(
ProgramPoint
,
TransitionLabel
)]
]
=
Map
()
program
.
definedFunctions
.
foreach
(
fd
=>
{
program
.
definedFunctions
.
foreach
(
fd
=>
{
val
body
=
fd
.
body
.
get
val
body
=
fd
.
body
.
get
//val cleanBody = hoistIte(expandLets(matchToIfThenElse(body)))
//val cleanBody = hoistIte(expandLets(matchToIfThenElse(body)))
val
cleanBody
=
expandLets
(
matchToIfThenElse
(
body
))
val
cleanBody
=
expandLets
(
matchToIfThenElse
(
body
))
// collectWithPathCondition(cleanBody).foreach{
val
subgraph
=
collectWithPathCondition
(
cleanBody
,
FunctionStart
(
fd
))
// case (path, WayPoint) =>
callGraph
++=
subgraph
})
})
null
callGraph
}
}
private
def
collectWithPathCondition
(
expression
:
Expr
,
startingPoint
:
ProgramPoint
)
:
Map
[
ProgramPoint
,
(
ProgramPoint
,
Set
[
TransitionLabel
]
)]
=
{
private
def
collectWithPathCondition
(
expression
:
Expr
,
startingPoint
:
ProgramPoint
)
:
Map
[
ProgramPoint
,
Set
[
(
ProgramPoint
,
TransitionLabel
)
]
]
=
{
var
callGraph
:
Map
[
ProgramPoint
,
Set
[(
ProgramPoint
,
TransitionLabel
)]]
=
Map
()
var
callGraph
:
Map
[
ProgramPoint
,
Set
[(
ProgramPoint
,
TransitionLabel
)]]
=
Map
()
def
rec
(
expr
:
Expr
,
path
:
List
[
Expr
],
startingPoint
:
ProgramPoint
)
:
Unit
=
expr
match
{
def
rec
(
expr
:
Expr
,
path
:
List
[
Expr
],
startingPoint
:
ProgramPoint
)
:
Unit
=
expr
match
{
...
@@ -49,8 +47,8 @@ class CallGraph(val program: Program) {
...
@@ -49,8 +47,8 @@ class CallGraph(val program: Program) {
}
}
val
newPoint
=
FunctionStart
(
fd
)
val
newPoint
=
FunctionStart
(
fd
)
val
newTransition
=
TransitionLabel
(
And
(
path
.
toSeq
),
fd
.
args
.
zip
(
args
).
map
{
case
(
VarDecl
(
id
,
_
),
arg
)
=>
(
id
.
toVariable
,
arg
)
}.
toMap
)
val
newTransition
=
TransitionLabel
(
And
(
path
.
toSeq
),
fd
.
args
.
zip
(
args
).
map
{
case
(
VarDecl
(
id
,
_
),
arg
)
=>
(
id
.
toVariable
,
arg
)
}.
toMap
)
callGraph
+=
(
startingPoint
->
(
transitions
+
(
newPoint
,
newTransition
)))
callGraph
+=
(
startingPoint
->
(
transitions
+
(
(
newPoint
,
newTransition
)))
)
args
.
foreach
(
arg
=>
rec
(
arg
,
startingPoint
,
startingPoint
))
args
.
foreach
(
arg
=>
rec
(
arg
,
path
,
startingPoint
))
}
}
case
WayPoint
(
e
)
=>
{
case
WayPoint
(
e
)
=>
{
val
transitions
:
Set
[(
ProgramPoint
,
TransitionLabel
)]
=
callGraph
.
get
(
startingPoint
)
match
{
val
transitions
:
Set
[(
ProgramPoint
,
TransitionLabel
)]
=
callGraph
.
get
(
startingPoint
)
match
{
...
@@ -58,8 +56,8 @@ class CallGraph(val program: Program) {
...
@@ -58,8 +56,8 @@ class CallGraph(val program: Program) {
case
Some
(
s
)
=>
s
case
Some
(
s
)
=>
s
}
}
val
newPoint
=
ExpressionPoint
(
expr
)
val
newPoint
=
ExpressionPoint
(
expr
)
val
newTransition
=
TransitionLabel
(
And
(
path
.
toSeq
),
fd
.
args
.
zip
(
args
).
map
{
case
(
VarDecl
(
id
,
_
),
arg
)
=>
(
id
.
toVariable
,
arg
)
}.
to
Map
)
val
newTransition
=
TransitionLabel
(
And
(
path
.
toSeq
),
Map
()
)
callGraph
+=
(
startingPoint
->
(
transitions
+
(
newPoint
,
newTransition
)))
callGraph
+=
(
startingPoint
->
(
transitions
+
(
(
newPoint
,
newTransition
)))
)
rec
(
e
,
List
(),
newPoint
)
rec
(
e
,
List
(),
newPoint
)
}
}
case
IfExpr
(
cond
,
then
,
elze
)
=>
{
case
IfExpr
(
cond
,
then
,
elze
)
=>
{
...
@@ -107,6 +105,27 @@ class CallGraph(val program: Program) {
...
@@ -107,6 +105,27 @@ class CallGraph(val program: Program) {
fix
(
searchAndReplaceDFS
(
transform
),
expr
)
fix
(
searchAndReplaceDFS
(
transform
),
expr
)
}
}
lazy
val
toDotString
:
String
=
{
var
vertexId
=
-
1
var
point2vertex
:
Map
[
ProgramPoint
,
Int
]
=
Map
()
//return id and label
def
getVertex
(
p
:
ProgramPoint
)
:
(
String
,
String
)
=
point2vertex
.
get
(
p
)
match
{
case
Some
(
id
)
=>
(
"v_"
+
id
,
pp
(
p
))
case
None
=>
{
vertexId
+=
1
point2vertex
+=
(
p
->
vertexId
)
(
"v_"
+
vertexId
,
pp
(
p
))
}
}
def
pp
(
p
:
ProgramPoint
)
:
String
=
p
match
{
case
FunctionStart
(
fd
)
=>
fd
.
id
.
name
case
ExpressionPoint
(
WayPoint
(
e
))
=>
"WayPoint"
}
}
//def analyse(program: Program) {
//def analyse(program: Program) {
// z3Solver.setProgram(program)
// z3Solver.setProgram(program)
// reporter.info("Running test generation")
// reporter.info("Running test generation")
...
...
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