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
a7c176f5
Commit
a7c176f5
authored
12 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
find one path among multiple waypoints
parent
48378638
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
src/main/scala/leon/CallGraph.scala
+13
-1
13 additions, 1 deletion
src/main/scala/leon/CallGraph.scala
src/main/scala/leon/TestGeneration.scala
+4
-1
4 additions, 1 deletion
src/main/scala/leon/TestGeneration.scala
with
17 additions
and
2 deletions
src/main/scala/leon/CallGraph.scala
+
13
−
1
View file @
a7c176f5
...
@@ -84,13 +84,25 @@ class CallGraph(val program: Program) {
...
@@ -84,13 +84,25 @@ class CallGraph(val program: Program) {
callGraph
callGraph
}
}
//given a path, follow the path to build the logical constraint that need to be satisfiable
def
pathConstraint
(
path
:
Seq
[(
ProgramPoint
,
ProgramPoint
,
TransitionLabel
)],
assigns
:
List
[
Map
[
Expr
,
Expr
]]
=
List
())
:
Expr
=
{
if
(
path
.
isEmpty
)
BooleanLiteral
(
true
)
else
{
val
(
_
,
_
,
TransitionLabel
(
cond
,
assign
))
=
path
.
head
val
finalCond
=
assigns
.
foldRight
(
cond
)((
map
,
acc
)
=>
replace
(
map
,
acc
))
And
(
finalCond
,
pathConstraint
(
path
.
tail
,
assign
.
asInstanceOf
[
Map
[
Expr
,
Expr
]]
::
assigns
))
}
}
def
findAllPathes
:
Set
[
Seq
[(
ProgramPoint
,
ProgramPoint
,
TransitionLabel
)]]
=
{
def
findAllPathes
:
Set
[
Seq
[(
ProgramPoint
,
ProgramPoint
,
TransitionLabel
)]]
=
{
val
waypoints
:
Set
[
ProgramPoint
]
=
programPoints
.
filter
{
case
ExpressionPoint
(
_
)
=>
true
case
_
=>
false
}
val
waypoints
:
Set
[
ProgramPoint
]
=
programPoints
.
filter
{
case
ExpressionPoint
(
_
)
=>
true
case
_
=>
false
}
val
sortedWaypoints
:
Seq
[
ProgramPoint
]
=
waypoints
.
toSeq
.
sortWith
((
p1
,
p2
)
=>
{
val
sortedWaypoints
:
Seq
[
ProgramPoint
]
=
waypoints
.
toSeq
.
sortWith
((
p1
,
p2
)
=>
{
val
(
ExpressionPoint
(
Waypoint
(
i1
,
_
)),
ExpressionPoint
(
Waypoint
(
i2
,
_
)))
=
(
p1
,
p2
)
val
(
ExpressionPoint
(
Waypoint
(
i1
,
_
)),
ExpressionPoint
(
Waypoint
(
i2
,
_
)))
=
(
p1
,
p2
)
i1
<=
i2
i1
<=
i2
})
})
Set
(
findPath
(
sortedWaypoints
(
0
),
sortedWaypoints
(
1
)))
Set
(
sortedWaypoints
.
zip
(
sortedWaypoints
.
tail
).
foldLeft
(
Seq
[(
ProgramPoint
,
ProgramPoint
,
TransitionLabel
)]())((
path
,
waypoint
)
=>
path
++
findPath
(
waypoint
.
_1
,
waypoint
.
_2
))
)
}
}
//find a path that goes through all waypoint in order
//find a path that goes through all waypoint in order
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/TestGeneration.scala
+
4
−
1
View file @
a7c176f5
...
@@ -18,7 +18,10 @@ class TestGeneration(reporter: Reporter) extends Analyser(reporter) {
...
@@ -18,7 +18,10 @@ class TestGeneration(reporter: Reporter) extends Analyser(reporter) {
def
analyse
(
program
:
Program
)
{
def
analyse
(
program
:
Program
)
{
val
callGraph
=
new
CallGraph
(
program
)
val
callGraph
=
new
CallGraph
(
program
)
println
(
callGraph
.
toDotString
)
println
(
callGraph
.
toDotString
)
println
(
callGraph
.
findAllPathes
)
callGraph
.
findAllPathes
.
foreach
(
path
=>
{
println
(
"Path is: "
+
path
)
println
(
"constraint is: "
+
callGraph
.
pathConstraint
(
path
))
})
//z3Solver.setProgram(program)
//z3Solver.setProgram(program)
//reporter.info("Running test generation")
//reporter.info("Running test generation")
//val allFuns = program.definedFunctions
//val allFuns = program.definedFunctions
...
...
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