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
715fe63a
Commit
715fe63a
authored
9 years ago
by
Lars Hupel
Committed by
Etienne Kneuss
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
track dependencies on unapply patterns in CallGraph
Fixes #143.
parent
bbd4170b
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
src/main/scala/leon/purescala/CallGraph.scala
+8
-1
8 additions, 1 deletion
src/main/scala/leon/purescala/CallGraph.scala
src/test/scala/leon/integration/purescala/CallGraphSuite.scala
+29
-0
29 additions, 0 deletions
...est/scala/leon/integration/purescala/CallGraphSuite.scala
with
37 additions
and
1 deletion
src/main/scala/leon/purescala/CallGraph.scala
+
8
−
1
View file @
715fe63a
...
@@ -69,13 +69,20 @@ class CallGraph(p: Program) {
...
@@ -69,13 +69,20 @@ class CallGraph(p: Program) {
transitiveClosure
()
transitiveClosure
()
}
}
private
def
collectCallsInPats
(
fd
:
FunDef
)(
p
:
Pattern
)
:
Set
[(
FunDef
,
FunDef
)]
=
(
p
match
{
case
u
:
UnapplyPattern
=>
Set
((
fd
,
u
.
unapplyFun
.
fd
))
case
_
=>
Set
()
})
++
p
.
subPatterns
.
flatMap
(
collectCallsInPats
(
fd
))
private
def
collectCalls
(
fd
:
FunDef
)(
e
:
Expr
)
:
Set
[(
FunDef
,
FunDef
)]
=
e
match
{
private
def
collectCalls
(
fd
:
FunDef
)(
e
:
Expr
)
:
Set
[(
FunDef
,
FunDef
)]
=
e
match
{
case
f
@
FunctionInvocation
(
f2
,
_
)
=>
Set
((
fd
,
f2
.
fd
))
case
f
@
FunctionInvocation
(
f2
,
_
)
=>
Set
((
fd
,
f2
.
fd
))
case
MatchExpr
(
_
,
cases
)
=>
cases
.
toSet
.
flatMap
((
mc
:
MatchCase
)
=>
collectCallsInPats
(
fd
)(
mc
.
pattern
))
case
_
=>
Set
()
case
_
=>
Set
()
}
}
private
def
scanForCalls
(
fd
:
FunDef
)
{
private
def
scanForCalls
(
fd
:
FunDef
)
{
for
(
(
from
,
to
)
<-
collect
(
collectCalls
(
fd
)
(
_
)
)(
fd
.
fullBody
)
)
{
for
(
(
from
,
to
)
<-
collect
(
collectCalls
(
fd
))(
fd
.
fullBody
)
)
{
_calls
+=
(
from
->
to
)
_calls
+=
(
from
->
to
)
_callees
+=
(
from
->
(
_callees
.
getOrElse
(
from
,
Set
())
+
to
))
_callees
+=
(
from
->
(
_callees
.
getOrElse
(
from
,
Set
())
+
to
))
_callers
+=
(
to
->
(
_callers
.
getOrElse
(
to
,
Set
())
+
from
))
_callers
+=
(
to
->
(
_callers
.
getOrElse
(
to
,
Set
())
+
from
))
...
...
This diff is collapsed.
Click to expand it.
src/test/scala/leon/integration/purescala/CallGraphSuite.scala
0 → 100644
+
29
−
0
View file @
715fe63a
/* Copyright 2009-2015 EPFL, Lausanne */
package
leon.integration.purescala
import
leon.test._
import
leon._
import
leon.purescala.Definitions._
import
leon.utils._
class
CallGraphSuite
extends
LeonTestSuiteWithProgram
with
helpers
.
ExpressionsDSL
{
val
sources
=
List
(
"""object Matches {
| import leon.collection._
| def aMatch(a: List[Int]) = a match {
| case _ :: _ => 0
| }
|}"""
.
stripMargin
)
test
(
"CallGraph tracks dependency to unapply pattern"
)
{
implicit
fix
=>
val
fd1
=
funDef
(
"Matches.aMatch"
)
val
fd2
=
funDef
(
"leon.collection.::.unapply"
)
assert
(
implicitly
[
Program
].
callGraph
.
calls
(
fd1
,
fd2
))
}
}
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